[edk2-devel] [PATCH v4 4/4] OvmfPkg/PlatformDxe: Add support for SEV live migration.
Ashish Kalra via groups.io
ashish.kalra=amd.com at groups.io
Thu Jun 24 16:29:05 UTC 2021
Hello Tom,
On Tue, Jun 22, 2021 at 06:06:24PM -0500, Tom Lendacky wrote:
> > +
> > +/**
> > + Figures out if we are running inside KVM HVM and
> > + KVM HVM supports SEV Live Migration feature.
> > +
> > + @retval TRUE KVM was detected and Live Migration supported
> > + @retval FALSE KVM was not detected or Live Migration not supported
> > +
> > +**/
> > +BOOLEAN
> > +KvmDetectSevLiveMigrationFeature(
> > + VOID
> > + )
> > +{
> > + UINT8 Signature[13];
> > + UINT32 mKvmLeaf = 0;
> > + UINT32 RegEax, RegEbx, RegEcx, RegEdx;
> > +
> > + Signature[12] = '\0';
> > + for (mKvmLeaf = 0x40000000; mKvmLeaf < 0x40010000; mKvmLeaf += 0x100) {
>
> What's the reason for the loop? I would think that just checking
> 0x40000000 would be enough, so a comment seems to be warranted.
>
0x40000000 leaf is the hypervisor CPUID information leaf, so probably
just checking 0x40000000 should be enough.
But i see that other hypervisor detection functions like XenDetect()
do a loop test on the hypervisor existence function until the
signature match, is there a specific reason for that ?
Is this for some kind of support for another/multiple hypervisors ?
> > + AsmCpuid (mKvmLeaf,
> > + NULL,
> > + (UINT32 *) &Signature[0],
> > + (UINT32 *) &Signature[4],
> > + (UINT32 *) &Signature[8]);
> > +
> > + if (!AsciiStrCmp ((CHAR8 *) Signature, "KVMKVMKVM\0\0\0")) {
> > + DEBUG ((
> > + DEBUG_ERROR,
>
> DEBUG_INFO, it doesn't seem like an error.
>
Ok.
> > + "%a: KVM Detected, signature = %s\n",
> > + __FUNCTION__,
> > + Signature
> > + ));
> > +> + RegEax = 0x40000001;
>
> Should this be mKvmLeaf + 1? It is confusing that you may check 0x40000100
> and then not do 0x40000101.
>
Yes, it should be mKvmLeaf + 1, assuming the loop above is being used.
> > + RegEcx = 0;
> > + AsmCpuid (0x40000001, &RegEax, &RegEbx, &RegEcx, &RegEdx);
> > + if (RegEax & (1 << KVM_FEATURE_MIGRATION_CONTROL)) {
>
Thanks,
Ashish
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#77067): https://edk2.groups.io/g/devel/message/77067
Mute This Topic: https://groups.io/mt/83688901/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-
More information about the edk2-devel-archive
mailing list