From 3dc548051be33059fd29e90662944a606235acbf Mon Sep 17 00:00:00 2001 From: Alexander Potapenko Date: Mon, 8 Oct 2018 10:53:24 +0200 Subject: [PATCH] kmsan: suppress false positives in KVM KMSAN doesn't see writes from inline asm directives and considers some locals uninitialized. --- arch/x86/include/asm/msr.h | 3 ++- arch/x86/kvm/vmx.c | 15 ++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/arch/x86/include/asm/msr.h b/arch/x86/include/asm/msr.h index 04addd6e0a4a2..c09a277d28423 100644 --- a/arch/x86/include/asm/msr.h +++ b/arch/x86/include/asm/msr.h @@ -124,7 +124,8 @@ do { \ static inline unsigned long long native_read_msr(unsigned int msr) { - unsigned long long val; + // TODO(glider): suppressing a false positive. + unsigned long long val = 0; val = __rdmsr(msr); diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index e665aa7167cf9..362da1ccb94bf 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -2084,7 +2084,8 @@ static inline void __invvpid(int ext, u16 vpid, gva_t gva) u64 rsvd : 48; u64 gva; } operand = { vpid, 0, gva }; - bool error; + // TODO(glider): suppressing a false positive. + bool error = false; asm volatile (__ex(ASM_VMX_INVVPID) CC_SET(na) : CC_OUT(na) (error) : "a"(&operand), "c"(ext) @@ -2097,7 +2098,8 @@ static inline void __invept(int ext, u64 eptp, gpa_t gpa) struct { u64 eptp, gpa; } operand = {eptp, gpa}; - bool error; + // TODO(glider): suppressing a false positive. + bool error = false; asm volatile (__ex(ASM_VMX_INVEPT) CC_SET(na) : CC_OUT(na) (error) : "a" (&operand), "c" (ext) @@ -2118,7 +2120,8 @@ static struct shared_msr_entry *find_msr_entry(struct vcpu_vmx *vmx, u32 msr) static void vmcs_clear(struct vmcs *vmcs) { u64 phys_addr = __pa(vmcs); - bool error; + // TODO(glider): suppressing a false positive. + bool error = false; asm volatile (__ex(ASM_VMX_VMCLEAR_RAX) CC_SET(na) : CC_OUT(na) (error) : "a"(&phys_addr), "m"(phys_addr) @@ -2140,7 +2143,8 @@ static inline void loaded_vmcs_init(struct loaded_vmcs *loaded_vmcs) static void vmcs_load(struct vmcs *vmcs) { u64 phys_addr = __pa(vmcs); - bool error; + // TODO(glider): suppressing a false positive. + bool error = false; if (static_branch_unlikely(&enable_evmcs)) return evmcs_load(phys_addr); @@ -2373,7 +2377,8 @@ static noinline void vmwrite_error(unsigned long field, unsigned long value) static __always_inline void __vmcs_writel(unsigned long field, unsigned long value) { - bool error; + // TODO(glider): suppressing a false positive. + bool error = false; asm volatile (__ex(ASM_VMX_VMWRITE_RAX_RDX) CC_SET(na) : CC_OUT(na) (error) : "a"(value), "d"(field));