From: Sean Christopherson <seanjc@google.com>
To: Jim Mattson <jmattson@google.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Jonathan Corbet <corbet@lwn.net>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
Maxim Levitsky <mlevitsk@redhat.com>,
kvm@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] KVM: VMX: Add quirk to allow L1 to set FREEZE_IN_SMM in vmcs12
Date: Wed, 4 Feb 2026 17:18:00 -0800 [thread overview]
Message-ID: <aYPvyMDipM9Z9Z7t@google.com> (raw)
In-Reply-To: <CALMp9eSc=0zS+6Rk-c_0P-Q1Y8_9Xv58G5BYxieKpv_XaSj0wg@mail.gmail.com>
On Wed, Feb 04, 2026, Jim Mattson wrote:
> On Tue, Feb 3, 2026 at 6:00 PM Sean Christopherson <seanjc@google.com> wrote:
> >
> > On Thu, Jan 22, 2026, Jim Mattson wrote:
> > > On Tue, Jan 13, 2026 at 7:47 PM Jim Mattson <jmattson@google.com> wrote:
> > > > On Tue, Jan 13, 2026 at 4:42 PM Sean Christopherson <seanjc@google.com> wrote:
> > > > >
> > > > > On Tue, Jan 13, 2026, Jim Mattson wrote:
> > > > > > Add KVM_X86_QUIRK_VMCS12_FREEZE_IN_SMM to allow L1 to set
> > > > > > IA32_DEBUGCTL.FREEZE_IN_SMM in vmcs12 when using nested VMX. Prior to
> > > > > > commit 6b1dd26544d0 ("KVM: VMX: Preserve host's
> > > > > > DEBUGCTLMSR_FREEZE_IN_SMM while running the guest"), L1 could set
> > > > > > FREEZE_IN_SMM in vmcs12 to freeze PMCs during physical SMM coincident
> > > > > > with L2's execution. The quirk is enabled by default for backwards
> > > > > > compatibility; userspace can disable it via KVM_CAP_DISABLE_QUIRKS2 if
> > > > > > consistency with WRMSR(IA32_DEBUGCTL) is desired.
> > > > >
> > > > > It's probably worth calling out that KVM will still drop FREEZE_IN_SMM in vmcs02
> > > > >
> > > > > if (vmx->nested.nested_run_pending &&
> > > > > (vmcs12->vm_entry_controls & VM_ENTRY_LOAD_DEBUG_CONTROLS)) {
> > > > > kvm_set_dr(vcpu, 7, vmcs12->guest_dr7);
> > > > > vmx_guest_debugctl_write(vcpu, vmcs12->guest_ia32_debugctl &
> > > > > vmx_get_supported_debugctl(vcpu, false)); <====
> > > > > } else {
> > > > > kvm_set_dr(vcpu, 7, vcpu->arch.dr7);
> > > > > vmx_guest_debugctl_write(vcpu, vmx->nested.pre_vmenter_debugctl);
> > > > > }
> > > > >
> > > > > both from a correctness standpoint and so that users aren't mislead into thinking
> > > > > the quirk lets L1 control of FREEZE_IN_SMM while running L2.
> > > >
> > > > Yes, it's probably worth pointing out that the VM is now subject to
> > > > the whims of the L0 administrators.
> > > >
> > > > While that makes some sense for the legacy vPMU, where KVM is just
> > > > another client of host perf, perhaps the decision should be revisited
> > > > in the case of the MPT vPMU, where KVM owns the PMU while the vCPU is
> > > > in VMX non-root operation.
> >
> > Eh, running guests with FREEZE_IN_SMM=0 seems absolutely crazy from a security
> > perspective. If an admin wants to disable FREEZE_IN_SMM, they get to keep the
> > pieces. And KVM definitely isn't going to override the admin, e.g. to allow the
> > guest to profile host SMM.
>
> I'm not sure what you mean by "they get to keep the pieces." What is
> the security problem with allowing L1 to freeze *guest-owned* PMCs
> during SMM?
To give L1 the option to freeze PMCs, KVM would also need to give L1 the option
to *not* freeze PMCs. At that point, the guest can use its PMCs to profile host
SMM code. Maybe even leverage a PMI to attack a poorly written SMM handler.
In other words, unless I'm missing something, the only reasonable option is to
run the guest with FREEZE_IN_SMM=1, which means ignoring the guest's wishes.
Or I guess another way to look at it: you can have any color car you want, as
long as it's black :-)
next prev parent reply other threads:[~2026-02-05 1:18 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-13 22:53 [PATCH] KVM: VMX: Add quirk to allow L1 to set FREEZE_IN_SMM in vmcs12 Jim Mattson
2026-01-14 0:42 ` Sean Christopherson
2026-01-14 3:47 ` Jim Mattson
2026-01-22 21:26 ` Jim Mattson
2026-02-04 2:00 ` Sean Christopherson
2026-02-05 0:42 ` Jim Mattson
2026-02-05 1:18 ` Sean Christopherson [this message]
2026-02-05 4:11 ` Jim Mattson
2026-02-05 14:47 ` Sean Christopherson
2026-02-05 17:43 ` Jim Mattson
2026-02-05 18:16 ` Sean Christopherson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aYPvyMDipM9Z9Z7t@google.com \
--to=seanjc@google.com \
--cc=bp@alien8.de \
--cc=corbet@lwn.net \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=mlevitsk@redhat.com \
--cc=pbonzini@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox