On Thu, Mar 09, 2017 at 05:13:33PM +0100, Paolo Bonzini wrote: > This is not how you check if running under a hypervisor; you should > check the HYPERVISOR bit, i.e. bit 31 of cpuid(1).ecx. This in turn > tells you if leaf 0x40000000 is valid. Ah, good point, I already do that in the microcode loader :) /* * CPUID(1).ECX[31]: reserved for hypervisor use. This is still not * completely accurate as xen pv guests don't see that CPUID bit set but * that's good enough as they don't land on the BSP path anyway. */ if (native_cpuid_ecx(1) & BIT(31)) return *res; > That said, the main issue with this function is that it hardcodes the > behavior for KVM. It is possible that another hypervisor defines its > 0x40000001 leaf in such a way that KVM_FEATURE_SEV has a different meaning. > > Instead, AMD should define a "well-known" bit in its own space (i.e. > 0x800000xx) that is only used by hypervisors that support SEV. This is > similar to how Intel defined one bit in leaf 1 to say "is leaf > 0x40000000 valid". > > > + if (eax > 0x40000000) { > > + eax = 0x40000001; > > + ecx = 0; > > + native_cpuid(&eax, &ebx, &ecx, &edx); > > + if (!(eax & BIT(KVM_FEATURE_SEV))) > > + goto out; > > + > > + eax = 0x8000001f; > > + ecx = 0; > > + native_cpuid(&eax, &ebx, &ecx, &edx); > > + if (!(eax & 1)) Right, so this is testing CPUID_0x8000001f_ECX(0)[0], SME. Why not simply set that bit for the guest too, in kvm? -- Regards/Gruss, Boris. SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg) -- -- To unsubscribe from this list: send the line "unsubscribe linux-efi" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html