Re: [PATCH v15 13/41] KVM: x86: Enable guest SSP read/write interface with new uAPIs

Sean Christopherson
2025-09-19T17:47:20Z

On Tue, Sep 16, 2025, Xiaoyao Li wrote:
> On 9/16/2025 6:12 AM, Sean Christopherson wrote:
> > For 6.18, I think the safe play is to go with the first path (exempt KVM-internal
> > MSRs), and then try to go for the second approach (exempt all host accesses) for
> > 6.19. KVM's ABI for ignore_msrs=true is already all kinds of messed up, so I'm
> > not terribly concerned about temporarily making it marginally worse.
>
> Looks OK to me.

Actually, better idea. Just use kvm_msr_{read,write}() for ONE_REG and bypass
the ignore_msrs crud. It's new uAPI, so we can define the semantics to be anything
we want. I see zero reason for ignore_msrs to apply to host accesses, and even
less reason for it to apply to ONE_REG.

Then there's no need to special case GUEST_SSP, and what to do about ignore_msrs
for host accesses remains an orthogonal discussion.

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 4ed25d33aaee..4adfece25630 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -5932,7 +5932,7 @@ static int kvm_get_one_msr(struct kvm_vcpu *vcpu, u32 msr, u64 __user *user_val)
{
u64 val;

- if (do_get_msr(vcpu, msr, &val))
+ if (kvm_msr_read(vcpu, msr, &val))
return -EINVAL;

if (put_user(val, user_val))
@@ -5948,7 +5948,7 @@ static int kvm_set_one_msr(struct kvm_vcpu *vcpu, u32 msr, u64 __user *user_val)
if (get_user(val, user_val))
return -EFAULT;

- if (do_set_msr(vcpu, msr, &val))
+ if (kvm_msr_write(vcpu, msr, &val))
return -EINVAL;

return 0;