From: Ravi Bangoria <ravi.bangoria@amd.com>
To: Sean Christopherson <seanjc@google.com>
Cc: pbonzini@redhat.com, thomas.lendacky@amd.com, tglx@linutronix.de,
mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com,
x86@kernel.org, hpa@zytor.com, michael.roth@amd.com,
nikunj.dadhania@amd.com, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org, santosh.shukla@amd.com,
Ravi Bangoria <ravi.bangoria@amd.com>
Subject: Re: [PATCH v2] KVM: SEV-ES: Don't intercept MSR_IA32_DEBUGCTLMSR for SEV-ES guests
Date: Mon, 6 May 2024 10:19:05 +0530 [thread overview]
Message-ID: <9252b68e-2b6a-6173-2e13-20154903097d@amd.com> (raw)
In-Reply-To: <ZjQnFO9Pf4OLZdLU@google.com>
On 03-May-24 5:21 AM, Sean Christopherson wrote:
> On Tue, Apr 16, 2024, Ravi Bangoria wrote:
>> Currently, LBR Virtualization is dynamically enabled and disabled for
>> a vcpu by intercepting writes to MSR_IA32_DEBUGCTLMSR. This helps by
>> avoiding unnecessary save/restore of LBR MSRs when nobody is using it
>> in the guest. However, SEV-ES guest mandates LBR Virtualization to be
>> _always_ ON[1] and thus this dynamic toggling doesn't work for SEV-ES
>> guest, in fact it results into fatal error:
>>
>> SEV-ES guest on Zen3, kvm-amd.ko loaded with lbrv=1
>>
>> [guest ~]# wrmsr 0x1d9 0x4
>> KVM: entry failed, hardware error 0xffffffff
>> EAX=00000004 EBX=00000000 ECX=000001d9 EDX=00000000
>> ...
>>
>> Fix this by never intercepting MSR_IA32_DEBUGCTLMSR for SEV-ES guests.
>
> Uh, what? I mean, sure, it works, maybe, I dunno. But there's a _massive_
> disconnect between the first paragraph and this statement.
>
> Oh, good gravy, it "works" because SEV already forces LBR virtualization.
>
> svm->vmcb->control.virt_ext |= LBR_CTL_ENABLE_MASK;
>
> (a) the changelog needs to call that out.
Sorry, I should have called that out explicitly.
> (b) KVM needs to disallow SEV-ES if
> LBR virtualization is disabled by the admin, i.e. if lbrv=false.
That's what I initially thought. But since KVM currently allows booting SEV-ES
guests even when lbrv=0 (by silently ignoring lbrv value), erroring out would
be a behavior change.
> Alternatively, I would be a-ok simply deleting lbrv, e.g. to avoid yet more
> printks about why SEV-ES couldn't be enabled.
>
> Hmm, I'd probably be more than ok. Because AMD (thankfully, blessedly) uses CPUID
> bits for SVM features, the admin can disable LBRV via clear_cpuid (or whatever it's
> called now). And there are hardly any checks on the feature, so it's not like
> having a boolean saves anything. AMD is clearly committed to making sure LBRV
> works, so the odds of KVM really getting much value out of a module param is low.
Currently, lbrv is not enabled by default with model specific -cpu profiles in
qemu. So I guess this is not backward compatible?
> And then when you delete lbrv, please add a WARN_ON_ONCE() sanity check in
> sev_hardware_setup() (if SEV-ES is supported), because like the DECODEASSISTS
> and FLUSHBYASID requirements, it's not super obvious that LBRV is a hard
> requirement for SEV-ES (that's an understatment; I'm curious how some decided
> that LBR virtualization is where the line go drawn for "yeah, _this_ is mandatory").
I'm not sure. Some ES internal dependency.
In any case, the patch simply fixes 'missed clearing MSR Interception' for
SEV-ES guests. So, would it be okay to apply this patch as is and do lbrv
cleanup as a followup series?
PS: AMD Bus Lock Detect virtualization also dependents on LBR Virtualization:
https://lore.kernel.org/r/20240429060643.211-4-ravi.bangoria@amd.com
Thanks for the review,
Ravi
next prev parent reply other threads:[~2024-05-06 4:49 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-16 5:03 [PATCH v2] KVM: SEV-ES: Don't intercept MSR_IA32_DEBUGCTLMSR for SEV-ES guests Ravi Bangoria
2024-04-16 8:48 ` Gupta, Pankaj
2024-05-02 23:51 ` Sean Christopherson
2024-05-06 4:49 ` Ravi Bangoria [this message]
2024-05-07 19:07 ` Sean Christopherson
2024-05-17 6:18 ` Ravi Bangoria
2024-05-17 14:31 ` Sean Christopherson
2024-05-20 5:04 ` Ravi Bangoria
2024-05-20 5:06 ` Ravi Bangoria
2024-05-21 20:31 ` Sean Christopherson
2024-05-21 20:47 ` Paolo Bonzini
2024-05-21 22:22 ` Sean Christopherson
2024-05-22 6:12 ` Ravi Bangoria
2024-05-22 6:11 ` Ravi Bangoria
2024-05-22 8:09 ` Paolo Bonzini
2024-05-22 6:11 ` Ravi Bangoria
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=9252b68e-2b6a-6173-2e13-20154903097d@amd.com \
--to=ravi.bangoria@amd.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.roth@amd.com \
--cc=mingo@redhat.com \
--cc=nikunj.dadhania@amd.com \
--cc=pbonzini@redhat.com \
--cc=santosh.shukla@amd.com \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--cc=thomas.lendacky@amd.com \
--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