Skip to content

Commit

Permalink
kmsan: suppress false positives in KVM
Browse files Browse the repository at this point in the history
KMSAN doesn't see writes from inline asm directives and considers some
locals uninitialized.
  • Loading branch information
ramosian-glider committed Oct 18, 2018
1 parent d2e40b9 commit 3dc5480
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
3 changes: 2 additions & 1 deletion arch/x86/include/asm/msr.h
Expand Up @@ -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);

Expand Down
15 changes: 10 additions & 5 deletions arch/x86/kvm/vmx.c
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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);
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 3dc5480

Please sign in to comment.