The patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable(a)vger.kernel.org>.
Possible dependencies:
b333b8ebb85d ("KVM: VMX: Ignore guest CPUID for host userspace writes to DEBUGCTL")
18e897d213cb ("KVM: VMX: Fold vmx_supported_debugctl() into vcpu_supported_debugctl()")
2f4073e08f4c ("KVM: VMX: Enable Notify VM exit")
938c8745bcf2 ("KVM: x86: Introduce "struct kvm_caps" to track misc caps/settings")
ed2351174e38 ("KVM: x86: Extend KVM_{G,S}ET_VCPU_EVENTS to support pending triple fault")
35875316384b ("KVM: x86: Allow userspace to set maximum VCPU id for VM")
e9bf3acb23f0 ("KVM: s390: Add KVM_CAP_S390_PROTECTED_DUMP")
8aba09588d2a ("KVM: s390: Add CPU dump functionality")
0460eb35b443 ("KVM: s390: Add configuration dump functionality")
35d02493dba1 ("KVM: s390: pv: Add query interface")
47e8eec83262 ("Merge tag 'kvmarm-5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm into HEAD")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From b333b8ebb85d62469f32b52fa03fd7d1522afc03 Mon Sep 17 00:00:00 2001
From: Sean Christopherson <seanjc(a)google.com>
Date: Thu, 6 Oct 2022 00:03:10 +0000
Subject: [PATCH] KVM: VMX: Ignore guest CPUID for host userspace writes to
DEBUGCTL
Ignore guest CPUID for host userspace writes to the DEBUGCTL MSR, KVM's
ABI is that setting CPUID vs. state can be done in any order, i.e. KVM
allows userspace to stuff MSRs prior to setting the guest's CPUID that
makes the new MSR "legal".
Keep the vmx_get_perf_capabilities() check for guest writes, even though
it's technically unnecessary since the vCPU's PERF_CAPABILITIES is
consulted when refreshing LBR support. A future patch will clean up
vmx_get_perf_capabilities() to avoid the RDMSR on every call, at which
point the paranoia will incur no meaningful overhead.
Note, prior to vmx_get_perf_capabilities() checking that the host fully
supports LBRs via x86_perf_get_lbr(), KVM effectively relied on
intel_pmu_lbr_is_enabled() to guard against host userspace enabling LBRs
on platforms without full support.
Fixes: c646236344e9 ("KVM: vmx/pmu: Add PMU_CAP_LBR_FMT check when guest LBR is enabled")
Signed-off-by: Sean Christopherson <seanjc(a)google.com>
Message-Id: <20221006000314.73240-5-seanjc(a)google.com>
Cc: stable(a)vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini(a)redhat.com>
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index 981b38355066..63247c57c72c 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -2021,16 +2021,16 @@ static u64 nested_vmx_truncate_sysenter_addr(struct kvm_vcpu *vcpu,
return (unsigned long)data;
}
-static u64 vcpu_supported_debugctl(struct kvm_vcpu *vcpu)
+static u64 vmx_get_supported_debugctl(struct kvm_vcpu *vcpu, bool host_initiated)
{
u64 debugctl = 0;
if (boot_cpu_has(X86_FEATURE_BUS_LOCK_DETECT) &&
- guest_cpuid_has(vcpu, X86_FEATURE_BUS_LOCK_DETECT))
+ (host_initiated || guest_cpuid_has(vcpu, X86_FEATURE_BUS_LOCK_DETECT)))
debugctl |= DEBUGCTLMSR_BUS_LOCK_DETECT;
if ((vmx_get_perf_capabilities() & PMU_CAP_LBR_FMT) &&
- intel_pmu_lbr_is_enabled(vcpu))
+ (host_initiated || intel_pmu_lbr_is_enabled(vcpu)))
debugctl |= DEBUGCTLMSR_LBR | DEBUGCTLMSR_FREEZE_LBRS_ON_PMI;
return debugctl;
@@ -2105,7 +2105,9 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
vmcs_writel(GUEST_SYSENTER_ESP, data);
break;
case MSR_IA32_DEBUGCTLMSR: {
- u64 invalid = data & ~vcpu_supported_debugctl(vcpu);
+ u64 invalid;
+
+ invalid = data & ~vmx_get_supported_debugctl(vcpu, msr_info->host_initiated);
if (invalid & (DEBUGCTLMSR_BTF|DEBUGCTLMSR_LBR)) {
if (report_ignored_msrs)
vcpu_unimpl(vcpu, "%s: BTF|LBR in IA32_DEBUGCTLMSR 0x%llx, nop\n",
The patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable(a)vger.kernel.org>.
Possible dependencies:
18e897d213cb ("KVM: VMX: Fold vmx_supported_debugctl() into vcpu_supported_debugctl()")
2f4073e08f4c ("KVM: VMX: Enable Notify VM exit")
938c8745bcf2 ("KVM: x86: Introduce "struct kvm_caps" to track misc caps/settings")
ed2351174e38 ("KVM: x86: Extend KVM_{G,S}ET_VCPU_EVENTS to support pending triple fault")
35875316384b ("KVM: x86: Allow userspace to set maximum VCPU id for VM")
e9bf3acb23f0 ("KVM: s390: Add KVM_CAP_S390_PROTECTED_DUMP")
8aba09588d2a ("KVM: s390: Add CPU dump functionality")
0460eb35b443 ("KVM: s390: Add configuration dump functionality")
35d02493dba1 ("KVM: s390: pv: Add query interface")
47e8eec83262 ("Merge tag 'kvmarm-5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm into HEAD")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 18e897d213cb152c786abab14919196bd9dc3a9f Mon Sep 17 00:00:00 2001
From: Sean Christopherson <seanjc(a)google.com>
Date: Thu, 6 Oct 2022 00:03:09 +0000
Subject: [PATCH] KVM: VMX: Fold vmx_supported_debugctl() into
vcpu_supported_debugctl()
Fold vmx_supported_debugctl() into vcpu_supported_debugctl(), its only
caller. Setting bits only to clear them a few instructions later is
rather silly, and splitting the logic makes things seem more complicated
than they actually are.
Opportunistically drop DEBUGCTLMSR_LBR_MASK now that there's a single
reference to the pair of bits. The extra layer of indirection provides
no meaningful value and makes it unnecessarily tedious to understand
what KVM is doing.
No functional change.
Signed-off-by: Sean Christopherson <seanjc(a)google.com>
Message-Id: <20221006000314.73240-4-seanjc(a)google.com>
Cc: stable(a)vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini(a)redhat.com>
diff --git a/arch/x86/kvm/vmx/capabilities.h b/arch/x86/kvm/vmx/capabilities.h
index 3bd7a8970618..07254314f3dd 100644
--- a/arch/x86/kvm/vmx/capabilities.h
+++ b/arch/x86/kvm/vmx/capabilities.h
@@ -24,8 +24,6 @@ extern int __read_mostly pt_mode;
#define PMU_CAP_FW_WRITES (1ULL << 13)
#define PMU_CAP_LBR_FMT 0x3f
-#define DEBUGCTLMSR_LBR_MASK (DEBUGCTLMSR_LBR | DEBUGCTLMSR_FREEZE_LBRS_ON_PMI)
-
struct nested_vmx_msrs {
/*
* We only store the "true" versions of the VMX capability MSRs. We
@@ -421,19 +419,6 @@ static inline u64 vmx_get_perf_capabilities(void)
return perf_cap;
}
-static inline u64 vmx_supported_debugctl(void)
-{
- u64 debugctl = 0;
-
- if (boot_cpu_has(X86_FEATURE_BUS_LOCK_DETECT))
- debugctl |= DEBUGCTLMSR_BUS_LOCK_DETECT;
-
- if (vmx_get_perf_capabilities() & PMU_CAP_LBR_FMT)
- debugctl |= DEBUGCTLMSR_LBR_MASK;
-
- return debugctl;
-}
-
static inline bool cpu_has_notify_vmexit(void)
{
return vmcs_config.cpu_based_2nd_exec_ctrl &
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index 65f092e4a81b..981b38355066 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -2023,13 +2023,15 @@ static u64 nested_vmx_truncate_sysenter_addr(struct kvm_vcpu *vcpu,
static u64 vcpu_supported_debugctl(struct kvm_vcpu *vcpu)
{
- u64 debugctl = vmx_supported_debugctl();
+ u64 debugctl = 0;
- if (!intel_pmu_lbr_is_enabled(vcpu))
- debugctl &= ~DEBUGCTLMSR_LBR_MASK;
+ if (boot_cpu_has(X86_FEATURE_BUS_LOCK_DETECT) &&
+ guest_cpuid_has(vcpu, X86_FEATURE_BUS_LOCK_DETECT))
+ debugctl |= DEBUGCTLMSR_BUS_LOCK_DETECT;
- if (!guest_cpuid_has(vcpu, X86_FEATURE_BUS_LOCK_DETECT))
- debugctl &= ~DEBUGCTLMSR_BUS_LOCK_DETECT;
+ if ((vmx_get_perf_capabilities() & PMU_CAP_LBR_FMT) &&
+ intel_pmu_lbr_is_enabled(vcpu))
+ debugctl |= DEBUGCTLMSR_LBR | DEBUGCTLMSR_FREEZE_LBRS_ON_PMI;
return debugctl;
}
The patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable(a)vger.kernel.org>.
Possible dependencies:
18e897d213cb ("KVM: VMX: Fold vmx_supported_debugctl() into vcpu_supported_debugctl()")
2f4073e08f4c ("KVM: VMX: Enable Notify VM exit")
938c8745bcf2 ("KVM: x86: Introduce "struct kvm_caps" to track misc caps/settings")
ed2351174e38 ("KVM: x86: Extend KVM_{G,S}ET_VCPU_EVENTS to support pending triple fault")
35875316384b ("KVM: x86: Allow userspace to set maximum VCPU id for VM")
e9bf3acb23f0 ("KVM: s390: Add KVM_CAP_S390_PROTECTED_DUMP")
8aba09588d2a ("KVM: s390: Add CPU dump functionality")
0460eb35b443 ("KVM: s390: Add configuration dump functionality")
35d02493dba1 ("KVM: s390: pv: Add query interface")
47e8eec83262 ("Merge tag 'kvmarm-5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm into HEAD")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 18e897d213cb152c786abab14919196bd9dc3a9f Mon Sep 17 00:00:00 2001
From: Sean Christopherson <seanjc(a)google.com>
Date: Thu, 6 Oct 2022 00:03:09 +0000
Subject: [PATCH] KVM: VMX: Fold vmx_supported_debugctl() into
vcpu_supported_debugctl()
Fold vmx_supported_debugctl() into vcpu_supported_debugctl(), its only
caller. Setting bits only to clear them a few instructions later is
rather silly, and splitting the logic makes things seem more complicated
than they actually are.
Opportunistically drop DEBUGCTLMSR_LBR_MASK now that there's a single
reference to the pair of bits. The extra layer of indirection provides
no meaningful value and makes it unnecessarily tedious to understand
what KVM is doing.
No functional change.
Signed-off-by: Sean Christopherson <seanjc(a)google.com>
Message-Id: <20221006000314.73240-4-seanjc(a)google.com>
Cc: stable(a)vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini(a)redhat.com>
diff --git a/arch/x86/kvm/vmx/capabilities.h b/arch/x86/kvm/vmx/capabilities.h
index 3bd7a8970618..07254314f3dd 100644
--- a/arch/x86/kvm/vmx/capabilities.h
+++ b/arch/x86/kvm/vmx/capabilities.h
@@ -24,8 +24,6 @@ extern int __read_mostly pt_mode;
#define PMU_CAP_FW_WRITES (1ULL << 13)
#define PMU_CAP_LBR_FMT 0x3f
-#define DEBUGCTLMSR_LBR_MASK (DEBUGCTLMSR_LBR | DEBUGCTLMSR_FREEZE_LBRS_ON_PMI)
-
struct nested_vmx_msrs {
/*
* We only store the "true" versions of the VMX capability MSRs. We
@@ -421,19 +419,6 @@ static inline u64 vmx_get_perf_capabilities(void)
return perf_cap;
}
-static inline u64 vmx_supported_debugctl(void)
-{
- u64 debugctl = 0;
-
- if (boot_cpu_has(X86_FEATURE_BUS_LOCK_DETECT))
- debugctl |= DEBUGCTLMSR_BUS_LOCK_DETECT;
-
- if (vmx_get_perf_capabilities() & PMU_CAP_LBR_FMT)
- debugctl |= DEBUGCTLMSR_LBR_MASK;
-
- return debugctl;
-}
-
static inline bool cpu_has_notify_vmexit(void)
{
return vmcs_config.cpu_based_2nd_exec_ctrl &
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index 65f092e4a81b..981b38355066 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -2023,13 +2023,15 @@ static u64 nested_vmx_truncate_sysenter_addr(struct kvm_vcpu *vcpu,
static u64 vcpu_supported_debugctl(struct kvm_vcpu *vcpu)
{
- u64 debugctl = vmx_supported_debugctl();
+ u64 debugctl = 0;
- if (!intel_pmu_lbr_is_enabled(vcpu))
- debugctl &= ~DEBUGCTLMSR_LBR_MASK;
+ if (boot_cpu_has(X86_FEATURE_BUS_LOCK_DETECT) &&
+ guest_cpuid_has(vcpu, X86_FEATURE_BUS_LOCK_DETECT))
+ debugctl |= DEBUGCTLMSR_BUS_LOCK_DETECT;
- if (!guest_cpuid_has(vcpu, X86_FEATURE_BUS_LOCK_DETECT))
- debugctl &= ~DEBUGCTLMSR_BUS_LOCK_DETECT;
+ if ((vmx_get_perf_capabilities() & PMU_CAP_LBR_FMT) &&
+ intel_pmu_lbr_is_enabled(vcpu))
+ debugctl |= DEBUGCTLMSR_LBR | DEBUGCTLMSR_FREEZE_LBRS_ON_PMI;
return debugctl;
}
The patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable(a)vger.kernel.org>.
Possible dependencies:
145dfad998ea ("KVM: VMX: Advertise PMU LBRs if and only if perf supports LBRs")
cf8e55fe50df ("KVM: x86/pmu: Expose CPUIDs feature bits PDCM, DS, DTES64")
4732f2444acd ("KVM: x86: Making the module parameter of vPMU more common")
b1d66dad65dc ("KVM: x86/svm: Add module param to control PMU virtualization")
f800650a4ed2 ("KVM: x86: SVM: add module param to control TSC scaling")
4c84926e229e ("KVM: x86: SVM: add module param to control LBR virtualization")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 145dfad998eac74abc59219d936e905766ba2d98 Mon Sep 17 00:00:00 2001
From: Sean Christopherson <seanjc(a)google.com>
Date: Thu, 6 Oct 2022 00:03:08 +0000
Subject: [PATCH] KVM: VMX: Advertise PMU LBRs if and only if perf supports
LBRs
Advertise LBR support to userspace via MSR_IA32_PERF_CAPABILITIES if and
only if perf fully supports LBRs. Perf may disable LBRs (by zeroing the
number of LBRs) even on platforms the allegedly support LBRs, e.g. if
probing any LBR MSRs during setup fails.
Fixes: be635e34c284 ("KVM: vmx/pmu: Expose LBR_FMT in the MSR_IA32_PERF_CAPABILITIES")
Reported-by: Like Xu <like.xu.linux(a)gmail.com>
Signed-off-by: Sean Christopherson <seanjc(a)google.com>
Message-Id: <20221006000314.73240-3-seanjc(a)google.com>
Cc: stable(a)vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini(a)redhat.com>
diff --git a/arch/x86/kvm/vmx/capabilities.h b/arch/x86/kvm/vmx/capabilities.h
index 87c4e46daf37..3bd7a8970618 100644
--- a/arch/x86/kvm/vmx/capabilities.h
+++ b/arch/x86/kvm/vmx/capabilities.h
@@ -400,6 +400,7 @@ static inline bool vmx_pebs_supported(void)
static inline u64 vmx_get_perf_capabilities(void)
{
u64 perf_cap = PMU_CAP_FW_WRITES;
+ struct x86_pmu_lbr lbr;
u64 host_perf_cap = 0;
if (!enable_pmu)
@@ -408,7 +409,8 @@ static inline u64 vmx_get_perf_capabilities(void)
if (boot_cpu_has(X86_FEATURE_PDCM))
rdmsrl(MSR_IA32_PERF_CAPABILITIES, host_perf_cap);
- perf_cap |= host_perf_cap & PMU_CAP_LBR_FMT;
+ if (x86_perf_get_lbr(&lbr) >= 0 && lbr.nr)
+ perf_cap |= host_perf_cap & PMU_CAP_LBR_FMT;
if (vmx_pebs_supported()) {
perf_cap |= host_perf_cap & PERF_CAP_PEBS_MASK;
The patch below does not apply to the 4.19-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable(a)vger.kernel.org>.
Possible dependencies:
86c4f0d547f6 ("KVM: x86: Mask off reserved bits in CPUID.8000001FH")
e39f00f60ebd ("KVM: x86: Use kernel's x86_phys_bits to handle reduced MAXPHYADDR")
4bf48e3c0aaf ("KVM: x86: Use guest MAXPHYADDR from CPUID.0x8000_0008 iff TDP is enabled")
d9db0fd6c5c9 ("KVM: SEV: Mask CPUID[0x8000001F].eax according to supported features")
013380782d4d ("KVM: x86: Move reverse CPUID helpers to separate header file")
01de8682b32d ("KVM: x86: Add reverse-CPUID lookup support for scattered SGX features")
4e66c0cb79b7 ("KVM: x86: Add support for reverse CPUID lookup of scattered features")
e42033342293 ("KVM: x86: Advertise INVPCID by default")
916391a2d1dc ("KVM: SVM: Add support for SEV-ES capability in KVM")
9d4747d02376 ("KVM: SVM: Remove the call to sev_platform_status() during setup")
dc46515cf838 ("KVM: x86: Move illegal GPA helper out of the MMU code")
1dbf5d68af6f ("KVM: VMX: Add guest physical address check in EPT violation and misconfig")
a0c134347baf ("KVM: VMX: introduce vmx_need_pf_intercept")
ec7771ab471b ("KVM: x86: mmu: Add guest physical address check in translate_gpa()")
cd313569f581 ("KVM: x86: mmu: Move translate_gpa() to mmu.c")
985ab2780164 ("KVM: x86/mmu: Make kvm_mmu_page definition and accessor internal-only")
6ca9a6f3adef ("KVM: x86/mmu: Add MMU-internal header")
06e7852c0ffb ("KVM: SVM: Add vmcb_ prefix to mark_*() functions")
f25a9dec2da3 ("KVM: x86/mmu: Drop kvm_arch_write_log_dirty() wrapper")
2dbebf7ae1ed ("KVM: nVMX: Plumb L2 GPA through to PML emulation")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 86c4f0d547f6460d0426ebb3ba0614f1134b8cda Mon Sep 17 00:00:00 2001
From: Jim Mattson <jmattson(a)google.com>
Date: Thu, 29 Sep 2022 15:52:03 -0700
Subject: [PATCH] KVM: x86: Mask off reserved bits in CPUID.8000001FH
KVM_GET_SUPPORTED_CPUID should only enumerate features that KVM
actually supports. CPUID.8000001FH:EBX[31:16] are reserved bits and
should be masked off.
Fixes: 8765d75329a3 ("KVM: X86: Extend CPUID range to include new leaf")
Signed-off-by: Jim Mattson <jmattson(a)google.com>
Message-Id: <20220929225203.2234702-6-jmattson(a)google.com>
Cc: stable(a)vger.kernel.org
[Clear NumVMPL too. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini(a)redhat.com>
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index a0292ba650df..0810e93cbedc 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -1199,7 +1199,8 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
entry->eax = entry->ebx = entry->ecx = entry->edx = 0;
} else {
cpuid_entry_override(entry, CPUID_8000_001F_EAX);
-
+ /* Clear NumVMPL since KVM does not support VMPL. */
+ entry->ebx &= ~GENMASK(31, 12);
/*
* Enumerate '0' for "PA bits reduction", the adjusted
* MAXPHYADDR is enumerated directly (see 0x80000008).
The patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable(a)vger.kernel.org>.
Possible dependencies:
86c4f0d547f6 ("KVM: x86: Mask off reserved bits in CPUID.8000001FH")
e39f00f60ebd ("KVM: x86: Use kernel's x86_phys_bits to handle reduced MAXPHYADDR")
4bf48e3c0aaf ("KVM: x86: Use guest MAXPHYADDR from CPUID.0x8000_0008 iff TDP is enabled")
d9db0fd6c5c9 ("KVM: SEV: Mask CPUID[0x8000001F].eax according to supported features")
013380782d4d ("KVM: x86: Move reverse CPUID helpers to separate header file")
01de8682b32d ("KVM: x86: Add reverse-CPUID lookup support for scattered SGX features")
4e66c0cb79b7 ("KVM: x86: Add support for reverse CPUID lookup of scattered features")
e42033342293 ("KVM: x86: Advertise INVPCID by default")
916391a2d1dc ("KVM: SVM: Add support for SEV-ES capability in KVM")
9d4747d02376 ("KVM: SVM: Remove the call to sev_platform_status() during setup")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 86c4f0d547f6460d0426ebb3ba0614f1134b8cda Mon Sep 17 00:00:00 2001
From: Jim Mattson <jmattson(a)google.com>
Date: Thu, 29 Sep 2022 15:52:03 -0700
Subject: [PATCH] KVM: x86: Mask off reserved bits in CPUID.8000001FH
KVM_GET_SUPPORTED_CPUID should only enumerate features that KVM
actually supports. CPUID.8000001FH:EBX[31:16] are reserved bits and
should be masked off.
Fixes: 8765d75329a3 ("KVM: X86: Extend CPUID range to include new leaf")
Signed-off-by: Jim Mattson <jmattson(a)google.com>
Message-Id: <20220929225203.2234702-6-jmattson(a)google.com>
Cc: stable(a)vger.kernel.org
[Clear NumVMPL too. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini(a)redhat.com>
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index a0292ba650df..0810e93cbedc 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -1199,7 +1199,8 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
entry->eax = entry->ebx = entry->ecx = entry->edx = 0;
} else {
cpuid_entry_override(entry, CPUID_8000_001F_EAX);
-
+ /* Clear NumVMPL since KVM does not support VMPL. */
+ entry->ebx &= ~GENMASK(31, 12);
/*
* Enumerate '0' for "PA bits reduction", the adjusted
* MAXPHYADDR is enumerated directly (see 0x80000008).
The patch below does not apply to the 5.4-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable(a)vger.kernel.org>.
Possible dependencies:
86c4f0d547f6 ("KVM: x86: Mask off reserved bits in CPUID.8000001FH")
e39f00f60ebd ("KVM: x86: Use kernel's x86_phys_bits to handle reduced MAXPHYADDR")
4bf48e3c0aaf ("KVM: x86: Use guest MAXPHYADDR from CPUID.0x8000_0008 iff TDP is enabled")
d9db0fd6c5c9 ("KVM: SEV: Mask CPUID[0x8000001F].eax according to supported features")
013380782d4d ("KVM: x86: Move reverse CPUID helpers to separate header file")
01de8682b32d ("KVM: x86: Add reverse-CPUID lookup support for scattered SGX features")
4e66c0cb79b7 ("KVM: x86: Add support for reverse CPUID lookup of scattered features")
e42033342293 ("KVM: x86: Advertise INVPCID by default")
916391a2d1dc ("KVM: SVM: Add support for SEV-ES capability in KVM")
9d4747d02376 ("KVM: SVM: Remove the call to sev_platform_status() during setup")
dc46515cf838 ("KVM: x86: Move illegal GPA helper out of the MMU code")
1dbf5d68af6f ("KVM: VMX: Add guest physical address check in EPT violation and misconfig")
a0c134347baf ("KVM: VMX: introduce vmx_need_pf_intercept")
ec7771ab471b ("KVM: x86: mmu: Add guest physical address check in translate_gpa()")
cd313569f581 ("KVM: x86: mmu: Move translate_gpa() to mmu.c")
985ab2780164 ("KVM: x86/mmu: Make kvm_mmu_page definition and accessor internal-only")
6ca9a6f3adef ("KVM: x86/mmu: Add MMU-internal header")
06e7852c0ffb ("KVM: SVM: Add vmcb_ prefix to mark_*() functions")
f25a9dec2da3 ("KVM: x86/mmu: Drop kvm_arch_write_log_dirty() wrapper")
2dbebf7ae1ed ("KVM: nVMX: Plumb L2 GPA through to PML emulation")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 86c4f0d547f6460d0426ebb3ba0614f1134b8cda Mon Sep 17 00:00:00 2001
From: Jim Mattson <jmattson(a)google.com>
Date: Thu, 29 Sep 2022 15:52:03 -0700
Subject: [PATCH] KVM: x86: Mask off reserved bits in CPUID.8000001FH
KVM_GET_SUPPORTED_CPUID should only enumerate features that KVM
actually supports. CPUID.8000001FH:EBX[31:16] are reserved bits and
should be masked off.
Fixes: 8765d75329a3 ("KVM: X86: Extend CPUID range to include new leaf")
Signed-off-by: Jim Mattson <jmattson(a)google.com>
Message-Id: <20220929225203.2234702-6-jmattson(a)google.com>
Cc: stable(a)vger.kernel.org
[Clear NumVMPL too. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini(a)redhat.com>
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index a0292ba650df..0810e93cbedc 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -1199,7 +1199,8 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
entry->eax = entry->ebx = entry->ecx = entry->edx = 0;
} else {
cpuid_entry_override(entry, CPUID_8000_001F_EAX);
-
+ /* Clear NumVMPL since KVM does not support VMPL. */
+ entry->ebx &= ~GENMASK(31, 12);
/*
* Enumerate '0' for "PA bits reduction", the adjusted
* MAXPHYADDR is enumerated directly (see 0x80000008).
The patch below does not apply to the 4.9-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable(a)vger.kernel.org>.
Possible dependencies:
0469e56a14bf ("KVM: x86: Mask off reserved bits in CPUID.80000001H")
bd7919999047 ("KVM: x86: Override host CPUID results with kvm_cpu_caps")
09f628a0b49c ("KVM: x86: Fold CPUID 0x7 masking back into __do_cpuid_func()")
90d2f60f41f7 ("KVM: x86: Use KVM cpu caps to track UMIP emulation")
b3d895d5c415 ("KVM: x86: Move XSAVES CPUID adjust to VMX's KVM cpu cap update")
3ec6fd8cf0ba ("KVM: VMX: Convert feature updates from CPUID to KVM cpu caps")
9b58b9857f22 ("KVM: SVM: Convert feature updates from CPUID to KVM cpu caps")
66a6950f9995 ("KVM: x86: Introduce kvm_cpu_caps to replace runtime CPUID masking")
9e6d01c2d908 ("KVM: x86: Refactor handling of XSAVES CPUID adjustment")
fb7d4377d513 ("KVM: x86: handle GBPAGE CPUID adjustment for EPT with generic code")
dbd068040c64 ("KVM: x86: Handle Intel PT CPUID adjustment in VMX code")
733deafc00df ("KVM: x86: Handle RDTSCP CPUID adjustment in VMX code")
d64d83d1e026 ("KVM: x86: Handle PKU CPUID adjustment in VMX code")
e574768f841b ("KVM: x86: Handle UMIP emulation CPUID adjustment in VMX code")
5ffec6f910dc ("KVM: x86: Handle INVPCID CPUID adjustment in VMX code")
6c7ea4b56bfe ("KVM: x86: Handle MPX CPUID adjustment in VMX code")
e745e37d4977 ("KVM: x86: Refactor cpuid_mask() to auto-retrieve the register")
b32666b13a72 ("KVM: x86: Introduce cpuid_entry_{change,set,clear}() mutators")
4c61534aaae2 ("KVM: x86: Introduce cpuid_entry_{get,has}() accessors")
5e12b2bb34e9 ("KVM: x86: Replace bare "unsigned" with "unsigned int" in cpuid helpers")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 0469e56a14bf8cfb80507e51b7aeec0332cdbc13 Mon Sep 17 00:00:00 2001
From: Jim Mattson <jmattson(a)google.com>
Date: Fri, 30 Sep 2022 00:51:58 +0200
Subject: [PATCH] KVM: x86: Mask off reserved bits in CPUID.80000001H
KVM_GET_SUPPORTED_CPUID should only enumerate features that KVM
actually supports. CPUID.80000001:EBX[27:16] are reserved bits and
should be masked off.
Fixes: 0771671749b5 ("KVM: Enhance guest cpuid management")
Signed-off-by: Jim Mattson <jmattson(a)google.com>
Cc: stable(a)vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini(a)redhat.com>
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index 7065462378e2..834feeb0a828 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -1133,6 +1133,7 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
entry->eax = max(entry->eax, 0x80000021);
break;
case 0x80000001:
+ entry->ebx &= ~GENMASK(27, 16);
cpuid_entry_override(entry, CPUID_8000_0001_EDX);
cpuid_entry_override(entry, CPUID_8000_0001_ECX);
break;
The patch below does not apply to the 4.14-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable(a)vger.kernel.org>.
Possible dependencies:
0469e56a14bf ("KVM: x86: Mask off reserved bits in CPUID.80000001H")
bd7919999047 ("KVM: x86: Override host CPUID results with kvm_cpu_caps")
09f628a0b49c ("KVM: x86: Fold CPUID 0x7 masking back into __do_cpuid_func()")
90d2f60f41f7 ("KVM: x86: Use KVM cpu caps to track UMIP emulation")
b3d895d5c415 ("KVM: x86: Move XSAVES CPUID adjust to VMX's KVM cpu cap update")
3ec6fd8cf0ba ("KVM: VMX: Convert feature updates from CPUID to KVM cpu caps")
9b58b9857f22 ("KVM: SVM: Convert feature updates from CPUID to KVM cpu caps")
66a6950f9995 ("KVM: x86: Introduce kvm_cpu_caps to replace runtime CPUID masking")
9e6d01c2d908 ("KVM: x86: Refactor handling of XSAVES CPUID adjustment")
fb7d4377d513 ("KVM: x86: handle GBPAGE CPUID adjustment for EPT with generic code")
dbd068040c64 ("KVM: x86: Handle Intel PT CPUID adjustment in VMX code")
733deafc00df ("KVM: x86: Handle RDTSCP CPUID adjustment in VMX code")
d64d83d1e026 ("KVM: x86: Handle PKU CPUID adjustment in VMX code")
e574768f841b ("KVM: x86: Handle UMIP emulation CPUID adjustment in VMX code")
5ffec6f910dc ("KVM: x86: Handle INVPCID CPUID adjustment in VMX code")
6c7ea4b56bfe ("KVM: x86: Handle MPX CPUID adjustment in VMX code")
e745e37d4977 ("KVM: x86: Refactor cpuid_mask() to auto-retrieve the register")
b32666b13a72 ("KVM: x86: Introduce cpuid_entry_{change,set,clear}() mutators")
4c61534aaae2 ("KVM: x86: Introduce cpuid_entry_{get,has}() accessors")
5e12b2bb34e9 ("KVM: x86: Replace bare "unsigned" with "unsigned int" in cpuid helpers")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 0469e56a14bf8cfb80507e51b7aeec0332cdbc13 Mon Sep 17 00:00:00 2001
From: Jim Mattson <jmattson(a)google.com>
Date: Fri, 30 Sep 2022 00:51:58 +0200
Subject: [PATCH] KVM: x86: Mask off reserved bits in CPUID.80000001H
KVM_GET_SUPPORTED_CPUID should only enumerate features that KVM
actually supports. CPUID.80000001:EBX[27:16] are reserved bits and
should be masked off.
Fixes: 0771671749b5 ("KVM: Enhance guest cpuid management")
Signed-off-by: Jim Mattson <jmattson(a)google.com>
Cc: stable(a)vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini(a)redhat.com>
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index 7065462378e2..834feeb0a828 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -1133,6 +1133,7 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
entry->eax = max(entry->eax, 0x80000021);
break;
case 0x80000001:
+ entry->ebx &= ~GENMASK(27, 16);
cpuid_entry_override(entry, CPUID_8000_0001_EDX);
cpuid_entry_override(entry, CPUID_8000_0001_ECX);
break;
The patch below does not apply to the 4.19-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable(a)vger.kernel.org>.
Possible dependencies:
0469e56a14bf ("KVM: x86: Mask off reserved bits in CPUID.80000001H")
bd7919999047 ("KVM: x86: Override host CPUID results with kvm_cpu_caps")
09f628a0b49c ("KVM: x86: Fold CPUID 0x7 masking back into __do_cpuid_func()")
90d2f60f41f7 ("KVM: x86: Use KVM cpu caps to track UMIP emulation")
b3d895d5c415 ("KVM: x86: Move XSAVES CPUID adjust to VMX's KVM cpu cap update")
3ec6fd8cf0ba ("KVM: VMX: Convert feature updates from CPUID to KVM cpu caps")
9b58b9857f22 ("KVM: SVM: Convert feature updates from CPUID to KVM cpu caps")
66a6950f9995 ("KVM: x86: Introduce kvm_cpu_caps to replace runtime CPUID masking")
9e6d01c2d908 ("KVM: x86: Refactor handling of XSAVES CPUID adjustment")
fb7d4377d513 ("KVM: x86: handle GBPAGE CPUID adjustment for EPT with generic code")
dbd068040c64 ("KVM: x86: Handle Intel PT CPUID adjustment in VMX code")
733deafc00df ("KVM: x86: Handle RDTSCP CPUID adjustment in VMX code")
d64d83d1e026 ("KVM: x86: Handle PKU CPUID adjustment in VMX code")
e574768f841b ("KVM: x86: Handle UMIP emulation CPUID adjustment in VMX code")
5ffec6f910dc ("KVM: x86: Handle INVPCID CPUID adjustment in VMX code")
6c7ea4b56bfe ("KVM: x86: Handle MPX CPUID adjustment in VMX code")
e745e37d4977 ("KVM: x86: Refactor cpuid_mask() to auto-retrieve the register")
b32666b13a72 ("KVM: x86: Introduce cpuid_entry_{change,set,clear}() mutators")
4c61534aaae2 ("KVM: x86: Introduce cpuid_entry_{get,has}() accessors")
5e12b2bb34e9 ("KVM: x86: Replace bare "unsigned" with "unsigned int" in cpuid helpers")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 0469e56a14bf8cfb80507e51b7aeec0332cdbc13 Mon Sep 17 00:00:00 2001
From: Jim Mattson <jmattson(a)google.com>
Date: Fri, 30 Sep 2022 00:51:58 +0200
Subject: [PATCH] KVM: x86: Mask off reserved bits in CPUID.80000001H
KVM_GET_SUPPORTED_CPUID should only enumerate features that KVM
actually supports. CPUID.80000001:EBX[27:16] are reserved bits and
should be masked off.
Fixes: 0771671749b5 ("KVM: Enhance guest cpuid management")
Signed-off-by: Jim Mattson <jmattson(a)google.com>
Cc: stable(a)vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini(a)redhat.com>
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index 7065462378e2..834feeb0a828 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -1133,6 +1133,7 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
entry->eax = max(entry->eax, 0x80000021);
break;
case 0x80000001:
+ entry->ebx &= ~GENMASK(27, 16);
cpuid_entry_override(entry, CPUID_8000_0001_EDX);
cpuid_entry_override(entry, CPUID_8000_0001_ECX);
break;