]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
KVM: x86: Move MSR_TYPE_{R,W,RW} values from VMX to x86, as enums
authorSean Christopherson <seanjc@google.com>
Fri, 2 Aug 2024 18:19:27 +0000 (11:19 -0700)
committerSean Christopherson <seanjc@google.com>
Thu, 22 Aug 2024 19:06:29 +0000 (12:06 -0700)
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>
arch/x86/kvm/vmx/vmx.h
arch/x86/kvm/x86.h

index 42498fa63abbe567009f7be70b3254ad2c754dc4..3839afb921e220a88dc8a8608f06bb46ba58d86a 100644 (file)
 #include "run_flags.h"
 #include "../mmu.h"
 
-#define MSR_TYPE_R     1
-#define MSR_TYPE_W     2
-#define MSR_TYPE_RW    3
-
 #define X2APIC_MSR(r) (APIC_BASE_MSR + ((r) >> 4))
 
 #ifdef CONFIG_X86_64
index 50596f6f83208586c6f9c6b58437f437b9dfcb18..499adef960385d0b82f1bbb8732e73a5fb6dd6a9 100644 (file)
@@ -504,6 +504,12 @@ int kvm_handle_memory_failure(struct kvm_vcpu *vcpu, int r,
 int kvm_handle_invpcid(struct kvm_vcpu *vcpu, unsigned long type, gva_t gva);
 bool kvm_msr_allowed(struct kvm_vcpu *vcpu, u32 index, u32 type);
 
+enum kvm_msr_access {
+       MSR_TYPE_R      = BIT(0),
+       MSR_TYPE_W      = BIT(1),
+       MSR_TYPE_RW     = MSR_TYPE_R | MSR_TYPE_W,
+};
+
 /*
  * Internal error codes that are used to indicate that MSR emulation encountered
  * an error that should result in #GP in the guest, unless userspace