mirror of
https://github.com/torvalds/linux.git
synced 2026-09-24 06:24:02 +02:00
KVM: x86: Move supported EFER bits to kvm_caps
Supported EFER bits naturally fits into kvm_caps because it gets recomputed during vendor initialization (e.g. to account for EFER.SVME being allowed/disallowed based on nested being enabled/disabled). Move efer_supported_bits into kvm_caps as supported_efer_bits (for naming consistency). As the bitmask is now globally visible as part of kvm_caps, there's little use for helpers to enable/disable specific bits, so drop them and open-code updates to kvm_caps.supported_efer_bits. No functional change intended. Suggested-by: Sean Christopherson <seanjc@google.com> Reviewed-by: Nikolay Borisov <nik.borisov@suse.com> Signed-off-by: Yosry Ahmed <yosry@kernel.org> Link: https://patch.msgid.link/20260713181020.2735367-6-yosry@kernel.org Signed-off-by: Sean Christopherson <seanjc@google.com>
This commit is contained in:
parent
37352c4fbd
commit
92b2af2b6d
|
|
@ -272,6 +272,8 @@ struct kvm_caps {
|
|||
u64 supported_xss;
|
||||
u64 supported_perf_cap;
|
||||
|
||||
u64 supported_efer_bits;
|
||||
|
||||
u64 supported_quirks;
|
||||
u64 inapplicable_quirks;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -19,8 +19,6 @@ bool __read_mostly report_ignored_msrs = true;
|
|||
module_param(report_ignored_msrs, bool, 0644);
|
||||
EXPORT_SYMBOL_FOR_KVM_INTERNAL(report_ignored_msrs);
|
||||
|
||||
static u64 __read_mostly efer_supported_bits;
|
||||
|
||||
#define MAX_IO_MSRS 256
|
||||
|
||||
struct msr_bitmap_range {
|
||||
|
|
@ -605,7 +603,7 @@ static bool __kvm_valid_efer(struct kvm_vcpu *vcpu, u64 efer)
|
|||
}
|
||||
bool kvm_valid_efer(struct kvm_vcpu *vcpu, u64 efer)
|
||||
{
|
||||
if (efer & ~efer_supported_bits)
|
||||
if (efer & ~kvm_caps.supported_efer_bits)
|
||||
return false;
|
||||
|
||||
return __kvm_valid_efer(vcpu, efer);
|
||||
|
|
@ -618,7 +616,7 @@ static int set_efer(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
|
|||
u64 efer = msr_info->data;
|
||||
int r;
|
||||
|
||||
if (efer & ~efer_supported_bits)
|
||||
if (efer & ~kvm_caps.supported_efer_bits)
|
||||
return 1;
|
||||
|
||||
if (!msr_info->host_initiated) {
|
||||
|
|
@ -649,19 +647,6 @@ static int set_efer(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void kvm_init_efer_bits(void)
|
||||
{
|
||||
/* Enable syscall by default because its emulated by KVM */
|
||||
efer_supported_bits = (u64)EFER_SCE;
|
||||
}
|
||||
EXPORT_SYMBOL_FOR_KVM_INTERNAL(kvm_init_efer_bits);
|
||||
|
||||
void kvm_enable_efer_bits(u64 mask)
|
||||
{
|
||||
efer_supported_bits |= mask;
|
||||
}
|
||||
EXPORT_SYMBOL_FOR_KVM_INTERNAL(kvm_enable_efer_bits);
|
||||
|
||||
bool kvm_msr_allowed(struct kvm_vcpu *vcpu, u32 index, u32 type)
|
||||
{
|
||||
struct kvm_x86_msr_filter *msr_filter;
|
||||
|
|
|
|||
|
|
@ -58,8 +58,6 @@ int kvm_get_set_one_reg(struct kvm_vcpu *vcpu, unsigned int ioctl,
|
|||
int kvm_get_reg_list(struct kvm_vcpu *vcpu,
|
||||
struct kvm_reg_list __user *user_list);
|
||||
|
||||
void kvm_init_efer_bits(void);
|
||||
void kvm_enable_efer_bits(u64);
|
||||
bool kvm_valid_efer(struct kvm_vcpu *vcpu, u64 efer);
|
||||
int kvm_emulate_msr_read(struct kvm_vcpu *vcpu, u32 index, u64 *data);
|
||||
int kvm_emulate_msr_write(struct kvm_vcpu *vcpu, u32 index, u64 data);
|
||||
|
|
|
|||
|
|
@ -6910,24 +6910,25 @@ EXPORT_SYMBOL_FOR_KVM_INTERNAL(kvm_setup_xss_caps);
|
|||
|
||||
static void kvm_setup_efer_caps(void)
|
||||
{
|
||||
kvm_init_efer_bits();
|
||||
/* Enable syscall by default because its emulated by KVM */
|
||||
kvm_caps.supported_efer_bits = (u64)EFER_SCE;
|
||||
|
||||
if (kvm_cpu_cap_has(X86_FEATURE_LM))
|
||||
kvm_enable_efer_bits(EFER_LME | EFER_LMA);
|
||||
kvm_caps.supported_efer_bits |= (EFER_LME | EFER_LMA);
|
||||
|
||||
if (kvm_cpu_cap_has(X86_FEATURE_NX))
|
||||
kvm_enable_efer_bits(EFER_NX);
|
||||
kvm_caps.supported_efer_bits |= EFER_NX;
|
||||
|
||||
if (kvm_cpu_cap_has(X86_FEATURE_FXSR_OPT))
|
||||
kvm_enable_efer_bits(EFER_FFXSR);
|
||||
kvm_caps.supported_efer_bits |= EFER_FFXSR;
|
||||
|
||||
if (kvm_cpu_cap_has(X86_FEATURE_AUTOIBRS))
|
||||
kvm_enable_efer_bits(EFER_AUTOIBRS);
|
||||
kvm_caps.supported_efer_bits |= EFER_AUTOIBRS;
|
||||
|
||||
if (kvm_cpu_cap_has(X86_FEATURE_SVM)) {
|
||||
kvm_enable_efer_bits(EFER_SVME);
|
||||
kvm_caps.supported_efer_bits |= EFER_SVME;
|
||||
if (!boot_cpu_has(X86_FEATURE_EFER_LMSLE_MBZ))
|
||||
kvm_enable_efer_bits(EFER_LMSLE);
|
||||
kvm_caps.supported_efer_bits |= EFER_LMSLE;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user