On Wed, Apr 10, 2019 at 06:36:15PM +0200, Borislav Petkov wrote: > Well, this is going in the wrong direction. The proper thing to do would > be to have: > > rdpkru() > wrpkru() > > which only do the inline asm with the respective opcodes. Just like > rdtsc(), clflush(), etc. IOW, like this: --- diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index 2779ace16d23..e2948ce1376c 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -127,14 +127,14 @@ static inline int pte_dirty(pte_t pte) static inline u32 read_pkru(void) { if (boot_cpu_has(X86_FEATURE_OSPKE)) - return __read_pkru(); + return rdpkru(); return 0; } static inline void write_pkru(u32 pkru) { if (boot_cpu_has(X86_FEATURE_OSPKE)) - __write_pkru(pkru); + wrpkru(pkru); } static inline int pte_young(pte_t pte) diff --git a/arch/x86/include/asm/special_insns.h b/arch/x86/include/asm/special_insns.h index 43c029cdc3fe..396ff572d66a 100644 --- a/arch/x86/include/asm/special_insns.h +++ b/arch/x86/include/asm/special_insns.h @@ -92,7 +92,7 @@ static inline void native_write_cr8(unsigned long val) #endif #ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS -static inline u32 __read_pkru(void) +static inline u32 rdpkru(void) { u32 ecx = 0; u32 edx, pkru; @@ -107,7 +107,7 @@ static inline u32 __read_pkru(void) return pkru; } -static inline void __write_pkru(u32 pkru) +static inline void wrpkru(u32 pkru) { u32 ecx = 0, edx = 0; @@ -119,12 +119,12 @@ static inline void __write_pkru(u32 pkru) : : "a" (pkru), "c"(ecx), "d"(edx)); } #else -static inline u32 __read_pkru(void) +static inline u32 rdpkru(void) { return 0; } -static inline void __write_pkru(u32 pkru) +static inline void wrpkru(u32 pkru) { } #endif diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index ab432a930ae8..85260aa2a920 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -6413,7 +6413,7 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu) if (static_cpu_has(X86_FEATURE_PKU) && kvm_read_cr4_bits(vcpu, X86_CR4_PKE) && vcpu->arch.pkru != vmx->host_pkru) - __write_pkru(vcpu->arch.pkru); + wrpkru(vcpu->arch.pkru); pt_guest_enter(vmx); @@ -6501,9 +6501,9 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu) */ if (static_cpu_has(X86_FEATURE_PKU) && kvm_read_cr4_bits(vcpu, X86_CR4_PKE)) { - vcpu->arch.pkru = __read_pkru(); + vcpu->arch.pkru = rdpkru(); if (vcpu->arch.pkru != vmx->host_pkru) - __write_pkru(vmx->host_pkru); + wrpkru(vmx->host_pkru); } vmx->nested.nested_run_pending = 0; -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.