[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <478030b2-7521-4080-c3de-46533c2cc3cf@redhat.com>
Date: Wed, 21 Apr 2021 14:03:37 +0200
From: Paolo Bonzini <pbonzini@...hat.com>
To: Sean Christopherson <seanjc@...gle.com>
Cc: linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
srutherford@...gle.com, joro@...tes.org, brijesh.singh@....com,
thomas.lendacky@....com, venu.busireddy@...cle.com,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
"H. Peter Anvin" <hpa@...or.com>, Borislav Petkov <bp@...e.de>,
x86@...nel.org, Ashish Kalra <ashish.kalra@....com>
Subject: Re: [PATCH 0/3] KVM: x86: guest interface for SEV live migration
On 21/04/21 01:20, Sean Christopherson wrote:
> If userspace blindly copies CPUID, but doesn't
> enable the capability, the guest will think the hypercall is supported. The
> guest hopefully won't freak out too much on the resulting -KVM_ENOSYS, but it
> does make the CPUID flag rather useless.
Yes that's why the CPUID bit must *not* be in KVM_GET_SUPPORTED_CPUID.
> The
> guest hopefully won't freak out too much on the resulting -KVM_ENOSYS, but it
> does make the CPUID flag rather useless.
>
> We can make it work with:
>
> u64 gpa = a0, npages = a1, enc = a2;
>
> if (!guest_pv_has(vcpu, KVM_FEATURE_HC_PAGE_ENC_STATUS))
> break;
>
> if (!PAGE_ALIGNED(gpa) || !npages ||
> gpa_to_gfn(gpa) + npages <= gpa_to_gfn(gpa)) {
> ret = -EINVAL;
> break;
> }
>
> if (!vcpu->kvm->arch.hypercall_exit_enabled) {
> ret = 0;
> break;
> }
>
> [...]
The interaction with KVM_CAP_ENFORCE_PV_FEATURE_CPUID scares me. But
I'll take it into account when posting v2.
>>>> (BTW, it's better to return a bitmask of hypercalls that will exit to
>>>> userspace from KVM_CHECK_EXTENSION. Userspace can still reject with -ENOSYS
>>>> those that it doesn't know, but it's important that it knows in general how
>>>> to handle KVM_EXIT_HYPERCALL).
>
> Speaking of bitmasks, what about also accepting a bitmask for enabling the
> capability? (not sure if the above implies that). E.g.
Yes, makes sense.
Paolo
Powered by blists - more mailing lists