Skip to content

Commit b58b808

Browse files
committed
KVM: x86: Move MSR_TYPE_{R,W,RW} values from VMX to x86, as enums
Move VMX's MSR_TYPE_{R,W,RW} #defines to x86.h, as enums, so that they can be used by common x86 code, e.g. instead of doing "bool write". Opportunistically tweak the definitions to make it more obvious that the values are bitmasks, not arbitrary ascending values. No functional change intended. Link: https://lore.kernel.org/r/20240802181935.292540-3-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 74a0e79 commit b58b808

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

arch/x86/kvm/vmx/vmx.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@
1717
#include "run_flags.h"
1818
#include "../mmu.h"
1919

20-
#define MSR_TYPE_R 1
21-
#define MSR_TYPE_W 2
22-
#define MSR_TYPE_RW 3
23-
2420
#define X2APIC_MSR(r) (APIC_BASE_MSR + ((r) >> 4))
2521

2622
#ifdef CONFIG_X86_64

arch/x86/kvm/x86.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,12 @@ int kvm_handle_memory_failure(struct kvm_vcpu *vcpu, int r,
504504
int kvm_handle_invpcid(struct kvm_vcpu *vcpu, unsigned long type, gva_t gva);
505505
bool kvm_msr_allowed(struct kvm_vcpu *vcpu, u32 index, u32 type);
506506

507+
enum kvm_msr_access {
508+
MSR_TYPE_R = BIT(0),
509+
MSR_TYPE_W = BIT(1),
510+
MSR_TYPE_RW = MSR_TYPE_R | MSR_TYPE_W,
511+
};
512+
507513
/*
508514
* Internal error codes that are used to indicate that MSR emulation encountered
509515
* an error that should result in #GP in the guest, unless userspace

0 commit comments

Comments
 (0)