From: Ravi Bangoria <ravi.bangoria@amd.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
seanjc@google.com, nikunj.dadhania@amd.com
Cc: 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, pankaj.gupta@amd.com,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
santosh.shukla@amd.com, ravi.bangoria@amd.com
Subject: Re: [PATCH v3 1/3] KVM: SEV-ES: Prevent MSR access post VMSA encryption
Date: Wed, 29 May 2024 16:14:10 +0530 [thread overview]
Message-ID: <f0de86a8-81c9-4656-862f-e229845d47cd@amd.com> (raw)
In-Reply-To: <3eca1e7e-9ddc-47a2-b214-d8788a069222@redhat.com>
On 5/28/2024 10:01 PM, Paolo Bonzini wrote:
> On 5/23/24 14:18, Ravi Bangoria wrote:
>> From: Nikunj A Dadhania <nikunj@amd.com>
>>
>> KVM currently allows userspace to read/write MSRs even after the VMSA is
>> encrypted. This can cause unintentional issues if MSR access has side-
>> effects. For ex, while migrating a guest, userspace could attempt to
>> migrate MSR_IA32_DEBUGCTLMSR and end up unintentionally disabling LBRV on
>> the target. Fix this by preventing access to those MSRs which are context
>> switched via the VMSA, once the VMSA is encrypted.
>>
>> Suggested-by: Sean Christopherson <seanjc@google.com>
>> Signed-off-by: Nikunj A Dadhania <nikunj@amd.com>
>> Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com>
>> ---
>> arch/x86/kvm/svm/svm.c | 18 ++++++++++++++++++
>> 1 file changed, 18 insertions(+)
>>
>> diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
>> index 3d0549ca246f..489b0183f37d 100644
>> --- a/arch/x86/kvm/svm/svm.c
>> +++ b/arch/x86/kvm/svm/svm.c
>> @@ -2834,10 +2834,24 @@ static int svm_get_msr_feature(struct kvm_msr_entry *msr)
>> return 0;
>> }
>> +static bool
>> +sev_es_prevent_msr_access(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
>> +{
>> + return sev_es_guest(vcpu->kvm) &&
>> + vcpu->arch.guest_state_protected &&
>> + svm_msrpm_offset(msr_info->index) != MSR_INVALID &&
>> + !msr_write_intercepted(vcpu, msr_info->index);
>> +}
>> +
>> static int svm_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
>> {
>> struct vcpu_svm *svm = to_svm(vcpu);
>> + if (sev_es_prevent_msr_access(vcpu, msr_info)) {
>> + msr_info->data = 0;
>> + return 0;
>
> This should return -EINVAL, not 0. Likewise below in svm_set_msr().
Sure.
Thanks,
Ravi
next prev parent reply other threads:[~2024-05-29 10:44 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-23 12:18 [PATCH v3 0/3] KVM: SEV-ES: Fix KVM_{GET|SET}_MSRS and LBRV handling Ravi Bangoria
2024-05-23 12:18 ` [PATCH v3 1/3] KVM: SEV-ES: Prevent MSR access post VMSA encryption Ravi Bangoria
2024-05-28 16:31 ` Paolo Bonzini
2024-05-29 10:44 ` Ravi Bangoria [this message]
2024-06-04 23:10 ` Michael Roth
2024-05-23 12:18 ` [PATCH v3 2/3] KVM: SEV-ES: Disallow SEV-ES guests when X86_FEATURE_LBRV is absent Ravi Bangoria
2024-05-28 16:33 ` Paolo Bonzini
2024-05-29 10:43 ` Ravi Bangoria
2024-05-23 12:18 ` [PATCH v3 3/3] KVM: SEV-ES: Fix LBRV code Ravi Bangoria
2024-05-30 14:03 ` Tom Lendacky
2024-05-31 4:06 ` 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=f0de86a8-81c9-4656-862f-e229845d47cd@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=pankaj.gupta@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