On Thu, Jan 04, 2024, Ashish Kalra wrote: > From: Ashish Kalra <ashish.kalra@xxxxxxx> > > Some BIOSes allow the end user to set the minimum SEV ASID value > (CPUID 0x8000001F_EDX) to be greater than the maximum number of > encrypted guests, or maximum SEV ASID value (CPUID 0x8000001F_ECX) > in order to dedicate all the SEV ASIDs to SEV-ES or SEV-SNP. > > The SEV support, as coded, does not handle the case where the minimum > SEV ASID value can be greater than the maximum SEV ASID value. > As a result, the following confusing message is issued: > > [ 30.715724] kvm_amd: SEV enabled (ASIDs 1007 - 1006) > > Fix the support to properly handle this case. > > Fixes: 916391a2d1dc ("KVM: SVM: Add support for SEV-ES capability in KVM") > Suggested-by: Sean Christopherson <seanjc@xxxxxxxxxx> > Signed-off-by: Ashish Kalra <ashish.kalra@xxxxxxx> > Cc: stable@xxxxxxxxxxxxxxx > --- > arch/x86/kvm/svm/sev.c | 40 ++++++++++++++++++++++++---------------- This should be ~3 patches: 1. Convert ASID variables/params to unsigned integers. 2. Return -EINVAL instead of -EBUSY 3. The actual fix here E.g if #2 breaks userspace (extremely unlikely) then bisection should point at exactly that, not at a commit with a whole pile of unrelated things going on. I'll send a v4, #1 should also be accompanied by a cleanup of sev_asid_new() to not multiplex the ASID with the return code. It can simply set sev->asid directly, which as a bonus makes sev_asid_new() and sev_asid_free() more symmetric.