From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (NAM11-BN8-obe.outbound.protection.outlook.com [40.107.236.73]) by mx.groups.io with SMTP id smtpd.web08.1256.1624552154883762259 for ; Thu, 24 Jun 2021 09:29:15 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=nM2bcotP; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: 40.107.236.73, mailfrom: ashish.kalra@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YD5heGUQmds23YVnnlevpTVuUQE+sOQdVbD6BQRab1HE5Dqe3M8VPrvSlcyaX/R4bRQI414rdShhBtmlXxedDLYoyDQ87nVGhg0bXsJnKbwVPn0mQ9NBzmxyLTye8plfijA/WSj+T84FNi2IN8F40Bt9WOmNXDXrQt25aDrHFszzoa3GDWMz46VDEewii/+9Ew/KH5VCzwwNSTxu+gVeXPsXVMzOLLeZUs/rBRwPld7cvf32kvFx51NFtuIe5Mf0fghFE53ppnb4fBlBRHZDkA9HTbV37Ui46yUBk/KjY40n/6W9JZw7r1LydOz4xOyjoBIoEw7G9uj+3Ncwhvi85g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wJPAvAhiEW2XH7hblnVYmsHWq38e5GtWrCWRNgTABWA=; b=b46jbTJWdy2Od12uZEJKebQLlh37+0tWrCF6m+mS2QlIT+EWAPw8VES0C5daJtnXHT9+KReYM6JPo6lr5/1g2oEmkH8jM/PYCVbKU68961E5rew04t8QTRkeEPNCZx00en9DV3a58dWwQSbbSZPm2NbtwW9HQcyQY299uH/f3NBudiExR7myxyEWKXeqsPgVpmQ3rjxKpFArLtOmEVn7eR1X2raR4j8j+UhJCcenE+fbxfT1pWGXkQw9SQp8ejoZ+soLW+IPKMiMXhE7cNBh/garHddHZKrxM6xPLGEm87+HnaU+tMzoWIEjquysFz7bUfhKY0260O4MurIqnUgu4A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wJPAvAhiEW2XH7hblnVYmsHWq38e5GtWrCWRNgTABWA=; b=nM2bcotPbhrJNxfuo/JjYGaEgytjYJua3D60POeibQpdp2LOIp9mEad5c0ka+XBu6PDRsWj2Ou8bGUHa8Ke/5+TasFxuDKY17hvs0gra3FU9Nx277FhKA1ZYSriaGl2cWUR4rNkS0h2i07XTC1tjvK528tspWwmzOLki+SXXE6I= Authentication-Results: amd.com; dkim=none (message not signed) header.d=none;amd.com; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB2767.namprd12.prod.outlook.com (2603:10b6:805:75::23) by SN1PR12MB2445.namprd12.prod.outlook.com (2603:10b6:802:31::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.18; Thu, 24 Jun 2021 16:29:11 +0000 Received: from SN6PR12MB2767.namprd12.prod.outlook.com ([fe80::958d:2e44:518c:744c]) by SN6PR12MB2767.namprd12.prod.outlook.com ([fe80::958d:2e44:518c:744c%7]) with mapi id 15.20.4242.025; Thu, 24 Jun 2021 16:29:11 +0000 Date: Thu, 24 Jun 2021 16:29:05 +0000 From: "Ashish Kalra" To: Tom Lendacky Cc: devel@edk2.groups.io, brijesh.singh@amd.com, jejb@linux.ibm.com, erdemaktas@google.com, jiewen.yao@intel.com, min.m.xu@intel.com, lersek@redhat.com, jordan.l.justen@intel.com, ard.biesheuvel@arm.com, pbonzini@redhat.com, dgilbert@redhat.com, dovmurik@linux.ibm.com, tobin@ibm.com Subject: Re: [PATCH v4 4/4] OvmfPkg/PlatformDxe: Add support for SEV live migration. Message-ID: <20210624162905.GA20084@ashkalra_ubuntu_server> References: In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: SN1PR12CA0070.namprd12.prod.outlook.com (2603:10b6:802:20::41) To SN6PR12MB2767.namprd12.prod.outlook.com (2603:10b6:805:75::23) Return-Path: ashish.kalra@amd.com MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ashkalra_ubuntu_server (165.204.77.1) by SN1PR12CA0070.namprd12.prod.outlook.com (2603:10b6:802:20::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.19 via Frontend Transport; Thu, 24 Jun 2021 16:29:10 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b0fc303d-ce7b-4cf2-41d5-08d9372d32ab X-MS-TrafficTypeDiagnostic: SN1PR12MB2445: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: M3G+zAthDZhiVcS3PplUyJLADdvVujAxlCzRl4F5yFufa6oMm7mEhHezJPQ4NeXlFJpZ75FJeyOZsYuu5cqUxPgT69IyMpP6v3t6/fQN0XFKAMf/h/NTW9fFqLr2mwgslRQ7xXXVE27ACo6hluTH195V139YYolmsWWF0XwQ5+xPh/ybEqsDV21sTJxaxJl6ff7pBOH70yUIPbgsYYImJblnDTFfuKCErOudTfwaCza6SkPt//cGPQDAyHvrJWb31ITBGydY7q31nk8um3WYM9PdizYLCE6kGBJiKu0aelz/CGXEdbGSNr1uPdNnIXC4uf9ll5pikTmcEoL3yKcH49bY7UE1966JCNKS4pTny6rBUva+V0EXOZCoSVGxLFdKGGws1gbPtml+YmUzo4XTbYU4xqYP9BrgcbFnF2Gf4bfJP8svU1EYb1Lm9CY97IQynxOQm3MufFBpopnOLABDzAc310ne7WbrRN8Fwe0YcUHVz9dn7bMnvAYiynCt3JqfDcYZGIL6xaFiKPYhrMINufWoMT2R6gTUcjAwBAf/gNvI35BG8/2YSR6xgeNiKcmCEKozveDzSWP7IgRv9lCEWVPK6yNy8CWnhFKOtXX87YV93GZmFPfOWtr5mmr9kyqdOEBirhKmV522CQ7AUr/QXA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR12MB2767.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(39860400002)(396003)(366004)(136003)(346002)(376002)(7416002)(6496006)(956004)(44832011)(8676002)(86362001)(1076003)(8936002)(316002)(2906002)(66556008)(66946007)(66476007)(52116002)(186003)(6862004)(38350700002)(33656002)(38100700002)(9686003)(33716001)(16526019)(83380400001)(478600001)(26005)(5660300002)(4326008)(6636002)(6666004)(55016002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?ZYOjyVj2kBvQIpkS7CBV2RPJNoyW/m35NJXyyWkMP8uhnvCv26UdNQPx6Sq3?= =?us-ascii?Q?t99AhRwC+vxeBefYxBGjFKUpHQE0GYJ2WQv4RfWClFkGyn0wdlkGsVA3iSGf?= =?us-ascii?Q?e2hDVLBudwYoMfqR2h7RndD8fJtNasb/hYeBl3x7JBZGKi1CCofGsCYiNkFv?= =?us-ascii?Q?S80etL6q8qoRfkYwsSbTbFy7epkVmFmixX/PwH6XuZZeBRUiEI7is7t+9fPb?= =?us-ascii?Q?W3tyxdvhkiYdA/vvCsCEDXqDxZUmZLaFF9Df2uUJ4WjAcZfJeqrP6w4VaPJ9?= =?us-ascii?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/C6isBW?= =?us-ascii?Q?jIKQv6fXf6jQ99xX45F14uAemSPPs6n6hkJ6oW7irUTx8temDKlcOhftgRJr?= =?us-ascii?Q?5oIJizumesPfqypszXlPjQly1tAhrJ6gdxZeb7mzEDQG79JTTRAU3xPodgi4?= =?us-ascii?Q?h0MGMO1HQ8y3frCIOwd3lyyc?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: b0fc303d-ce7b-4cf2-41d5-08d9372d32ab X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB2767.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jun 2021 16:29:11.5604 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: G4HuSBvKgpMFn+twhOD49tUrlXgwpXfIS5cNvhqO//oSqx9moZB4Wplg1MZB73QANQD46zO89r3bA1kPYy0BkA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2445 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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