[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7f045418-6ce4-4f2f-a3ee-4ddc3cf2fda5@intel.com>
Date: Thu, 29 Jan 2026 11:09:02 +0800
From: Xiaoyao Li <xiaoyao.li@...el.com>
To: Sean Christopherson <seanjc@...gle.com>,
Paolo Bonzini <pbonzini@...hat.com>
Cc: kvm@...r.kernel.org, linux-kernel@...r.kernel.org,
Mathias Krause <minipli@...ecurity.net>, John Allen <john.allen@....com>,
Rick Edgecombe <rick.p.edgecombe@...el.com>, Chao Gao <chao.gao@...el.com>,
Binbin Wu <binbin.wu@...ux.intel.com>, Jim Mattson <jmattson@...gle.com>
Subject: Re: [PATCH v2 2/3] KVM: x86: Harden against unexpected adjustments to
kvm_cpu_caps
On 1/28/2026 9:43 AM, Sean Christopherson wrote:
> Add a flag to track when KVM is actively configuring its CPU caps, and
> WARN if a cap is set or cleared if KVM isn't in its configuration stage.
> Modifying CPU caps after {svm,vmx}_set_cpu_caps() can be fatal to KVM, as
> vendor setup code expects the CPU caps to be frozen at that point, e.g.
> will do additional configuration based on the caps.
>
> Rename kvm_set_cpu_caps() to kvm_initialize_cpu_caps() to pair with the
> new "finalize", and to make it more obvious that KVM's CPU caps aren't
> fully configured within the function.
>
> Signed-off-by: Sean Christopherson <seanjc@...gle.com>
> ---
> arch/x86/kvm/cpuid.c | 10 ++++++++--
> arch/x86/kvm/cpuid.h | 12 +++++++++++-
> arch/x86/kvm/svm/svm.c | 4 +++-
> arch/x86/kvm/vmx/vmx.c | 4 +++-
> 4 files changed, 25 insertions(+), 5 deletions(-)
>
> diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
> index 575244af9c9f..7fe4e58a6ebf 100644
> --- a/arch/x86/kvm/cpuid.c
> +++ b/arch/x86/kvm/cpuid.c
> @@ -36,6 +36,9 @@
> u32 kvm_cpu_caps[NR_KVM_CPU_CAPS] __read_mostly;
> EXPORT_SYMBOL_FOR_KVM_INTERNAL(kvm_cpu_caps);
>
> +bool kvm_is_configuring_cpu_caps __read_mostly;
I prefer the name, kvm_cpu_caps_finalized. But not strongly, so
Reviewed-by: Xiaoyao Li <xiaoyao.li@...el.com>
Powered by blists - more mailing lists