From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (NAM12-BN8-obe.outbound.protection.outlook.com [40.107.237.64]) by mx.groups.io with SMTP id smtpd.web09.302.1654622893398061082 for ; Tue, 07 Jun 2022 10:28:13 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=5ujTTkTQ; 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.237.64, mailfrom: ashish.kalra@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l/HT0DbV3Zx6k5R5eoAUFftHVhoEfOpv4yH5S4Bzb1JRDZ6twB931dQSk6iR8UcvYAHnYbnouBogqMH9hvjmmRPupXpMG+210YzSHManLXZkEK1aHzB8lG6VsRRRHHwhXsYNNvGknk3cDfD+IeiS2pOWrlGPhiT8gv3TKLFAktNhmwjreAFii5p2f9oI+MPYN/7fiyKkt/4WvJE3w+680C+1E4ViUAnWS/OM6zdjxgQrzmJsl6tL1SzuQwQKvUmLyB+zbPBSGCkyxgvmjwYZV9YtuZWgEjF6f+/SLlTLd4DRovCsS2I0A/aHfcRJNNWCttVcpP34CUk6YsTHTbIMZw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QZN6lUov0J2gFuI0oZalP4fVRLmddLUJDAaFi7Tgh3s=; b=RWWFvaSuyCiX+mjwBiTTNFPr9RI6t8v6a2/gMKyhF3iZnlcP/EC2p1e2rJ6QarflknGnkuPO3zNPekCeNtwa+QIUODxk0nXu6GoJCMKyFIppsZnOIlHw35A+matF7EHSuG+LF8nN8f9y8pxNJ50t/Zeh0r+c6MIvN9d8dNBs1I764c1lbBeEkaHhQy6gsmpk0R6D1TOIYkqLH/r1sjpuyvNmE2ypOr3bcSvwAKAa2v4mUqNN2Gjlio9/o0K9tRN0cuv1IolWWdrCljWdz4lgMuV03HHZ8B+RvclLQKzcVCRO0RfYl6KfANNF0dbUuN+HYvV+wH1C/hJ7bq0DyA4Ong== 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=QZN6lUov0J2gFuI0oZalP4fVRLmddLUJDAaFi7Tgh3s=; b=5ujTTkTQPnyfFn+aYP+fDlqCbJVq4cBOh5f4+4Z/FChjIFyzUGBqVilBZULRi9SR+8jjaZgRmpZDoXmvLNzgWpFYc/e4zaw9Ui8zHNemAFwSFyk2H+veVepWe3J9fQuFw8NCa0w4sGcfwAK0y5gALcJDmfrrtN/qks4MYMsFu4Q= Received: from SN6PR12MB2767.namprd12.prod.outlook.com (2603:10b6:805:75::23) by BN8PR12MB3489.namprd12.prod.outlook.com (2603:10b6:408:44::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.12; Tue, 7 Jun 2022 17:28:10 +0000 Received: from SN6PR12MB2767.namprd12.prod.outlook.com ([fe80::25d7:1ecc:64f2:f9c0]) by SN6PR12MB2767.namprd12.prod.outlook.com ([fe80::25d7:1ecc:64f2:f9c0%6]) with mapi id 15.20.5314.019; Tue, 7 Jun 2022 17:28:10 +0000 From: "Ashish Kalra" To: "Dadhania, Nikunj" , "devel@edk2.groups.io" Subject: Re: [edk2-devel] [PATCH v8 3/6] OvmfPkg/BaseMemEncryptLib: Invoke page encryption state change hypercall Thread-Topic: [edk2-devel] [PATCH v8 3/6] OvmfPkg/BaseMemEncryptLib: Invoke page encryption state change hypercall Thread-Index: AQHYekoDQr1amdCBT0y2DHbdzmaNOq1EMkRA Date: Tue, 7 Jun 2022 17:28:09 +0000 Message-ID: References: <12370.1654591126491114870@groups.io> In-Reply-To: <12370.1654591126491114870@groups.io> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Enabled=true; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SetDate=2022-06-07T17:24:20Z; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Method=Standard; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Name=General; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ActionId=7a86e229-aaba-4e59-adee-488b246ba4cb; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ContentBits=1 msip_label_4342314e-0df4-4b58-84bf-38bed6170a0f_enabled: true msip_label_4342314e-0df4-4b58-84bf-38bed6170a0f_setdate: 2022-06-07T17:28:08Z msip_label_4342314e-0df4-4b58-84bf-38bed6170a0f_method: Standard msip_label_4342314e-0df4-4b58-84bf-38bed6170a0f_name: General msip_label_4342314e-0df4-4b58-84bf-38bed6170a0f_siteid: 3dd8961f-e488-4e60-8e11-a82d994e183d msip_label_4342314e-0df4-4b58-84bf-38bed6170a0f_actionid: 3f6f9b2a-af48-47ff-ba46-961260cb31f8 msip_label_4342314e-0df4-4b58-84bf-38bed6170a0f_contentbits: 0 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 7bf79e3f-7686-4e2c-5233-08da48ab17aa x-ms-traffictypediagnostic: BN8PR12MB3489:EE_ x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: kQm9pGhfilbo/0OIwsdRfXLyyk1YIywwYQ4PirfcZJCiQgLsOUPBwFN25i7OWjIP3rfMi5lDJftemCS79liqqLLaCMH4zP2G29Zq+A8/DphzUNAn6g66ggjgqvjrP+CwDtCq2B5/wA+bnFB3WaQWF3lnQKDj3NzQSw98zL/KebSJXG9xqCK/v8iGDVGwDxt3k/X3TpSCldrRaAhsv4GJagB/4Po/dut5TxScnPlJLymB4eTeMv/EioUaKmRStF5UVnREJTPGGkcUIHn4qk9Gz98D8xWZaF9QRkyAbaoPm15jH00nbNkHL00s+kIPwF8Hqe6b+6ird9kGu+agr/0i2AG8W17NCCq2PFD+xOHJdIYgfRZnIujcC2E6jlW6CB2wiU0ka/HKRE9G43S0cJWvYxZQm8G6LTU4Pqt6nglUWoTANp0s/Df1xVy0pqSIAqHqn5Hp7693P90fuKa8Xnhb/9XAIddKz0Cnb1e7zKJI9xvBaUkwDiQu+b4251Q8Wa9tPhCAksbwpG5shDkifBljPTobIaazX6XB6CEgnii0LgmBzDJDa2GbCnl3w9f9NRM+G/1SCLYIVvkJK8KqcMCTeKm77VnMyfWKQT0+Reow2M/yWEF5b6HqHRTPhYfbeJ70e1i5M59yaZ27M6MF9CFPAFwFMB15cah9Enr27cMFk7d/GTkwOE+TzzeXHxYUKYBeEBFCWCPFNcqPoCvf+1JneQ== 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:(13230001)(4636009)(366004)(66946007)(66446008)(6506007)(19627235002)(76116006)(9686003)(53546011)(55016003)(38100700002)(122000001)(508600001)(186003)(26005)(5660300002)(38070700005)(52536014)(8936002)(8676002)(110136005)(316002)(66556008)(66476007)(2906002)(86362001)(71200400001)(33656002)(64756008)(7696005);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?L9Y13bm74lTuLQ2o9F3x1nLPrZvPrYrg01cQ/WLauOVBcuxvI7VKlPr5bZ08?= =?us-ascii?Q?8WlqYNptjmmfmS5YnoaiTck8Jgr4BTCwc5tLGmxgQtKZCedsvPGBJsEuJY16?= =?us-ascii?Q?SPz3qNxs0zEwi/ENt5hJKx4gI9PVdxOpPdiZsROXVFHppIv/ffpAV77AXzZ7?= =?us-ascii?Q?tIdbM5dfn3NDaXqQ/N/0GGwQQTeHVk7ApoLrV2hbmNhzaQePbiqLfqIb/C6R?= =?us-ascii?Q?TzLh8vJXJaXg//uwtI3f7Prg/MFoc70+Xa9oSssNJdJBr5hI+5qsiYCAJEuv?= =?us-ascii?Q?MB5M77BJl2WNz0hzrTPTOtjrBNM1YBFTYHtYsF0yGdLsX/6GaWR7thEVnD/h?= =?us-ascii?Q?8VGkW4CfLygHTq0q7uD+iHUhslQqwLfOhX6t2WwOwr+toX9M/ObrOzPfy5aU?= =?us-ascii?Q?gTnL//XhwtpUhTgeC95BTWCD5m21aQjIbyDd/16mbZ30SGnpOpQkcaDG1X+x?= =?us-ascii?Q?Wz25U/aK2Tube6pDJMtnsmEUg6v4UO0YK8U9b0QhEIXRRQZ51uhVIrd5Xq+B?= =?us-ascii?Q?/+262HengBPoCu7rvOCIavlmOUoNHC5n6D2ZK/u3pskQOXlnXYkW/n3Hq+ez?= =?us-ascii?Q?6jjt2S/SF45KkSRuYWhf9aJmEGEQN92sGnn1t+oRoQZ/2yFpHRMNuoAbmLOT?= =?us-ascii?Q?CkLC6b2BwsqZDu+5Y98QpMqxdRGvNoLwgFB+2Ijrn/VEYxiQbMUxTOa0z2wR?= =?us-ascii?Q?omtpTa6xBBzXhzfNC+jyuYt/h/zStfCWQ3hY5SsZLTt3xrhwCExoDLWlkKdL?= =?us-ascii?Q?gVe4918r8UOvSRSaf13Kd40i+EMzjSqZSeqwGKDg4lj5o7P7IoKZ+WA3lMTH?= =?us-ascii?Q?kE/fvX6RUbHX0BIj9BdMDqC3JIh+HeFRp0SqMm9l/kAaDXIMVoahVps3WQU4?= =?us-ascii?Q?nU3uXRwK9Th642eJErEyYJg1rhYy5IO8JIVMQLmqnmCq8+MNhmAeDbMtxbJH?= =?us-ascii?Q?ieoQhN++jt3TAwpbPXjRgthe/jG66FP+khWAjWGsUJcGRLqN2YjKDIgcv4Ej?= =?us-ascii?Q?q7KBr/wLSuk/pe8q+SImN8ZlRA2seUhtMHjldJJHgIuDPSVe1UkOyJhzWbAI?= =?us-ascii?Q?PzewByfBwnPjQLJkX4mcSMhp12jaqbWo64Q17bGVra7olA/Eq8kYdWWGFLnt?= =?us-ascii?Q?JMKXXdws08wrSiwenMJ3p4qKU89ycetWoIcX+V6n1euQ3LHmTuf+nMoydS7G?= =?us-ascii?Q?sa17r/+bc+8GY7TKQnUsYPswqFwavTnSYIL54AuahvahU/7WhOYmpTlnuDSc?= =?us-ascii?Q?p/+WfV87MJvb2dVkBgoP5dQ3J+zbbyFVSdsv67VV0xkyJHO39L09jO8Cn+Te?= =?us-ascii?Q?YWAIse695W/50KYg/iLDUeWY6BeuK4qK0u3cFWYtBfgSZksKBLl6gO8VjiEV?= =?us-ascii?Q?gZicAhlFl91EdZyvM4Yh5wBEEqDrHBhRKloM1A4+dUH/WO1ohEu8zJuhQTWG?= =?us-ascii?Q?L1imgdPTzSfL424DkPrAK224UMomefb3liVI4H8jBo7NghDg3ArsF4SMA/YP?= =?us-ascii?Q?bAUiK7l0CSAtIo4NVMSqhTxu+kin3f1oldf3SbLrL5Yded86yFY52dsQBZ57?= =?us-ascii?Q?Zuodiy/sewLufUnWYRuN9I476xiWiOyhPW0ORT2N2d6USVu2i/fgWrdZvJW+?= =?us-ascii?Q?vGJAKMFDeTGH5GcswzotD9q/VHCuZXhXLq7fuRWvrRUvhfLUosW8iyioqpVf?= =?us-ascii?Q?Z+t6blBD2sS2V4I0VuDcuie28Roja4fW9LQCd9BYsNRiVSak?= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB2767.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7bf79e3f-7686-4e2c-5233-08da48ab17aa X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Jun 2022 17:28:09.9367 (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: KHguUGCGKTYcOekrn5/RFijxpjlPsUmlDmZwfQ54rfHG0T+SslMkOXVhCWdqlkuoT9wV9DDq+25bH3oxCUqJrg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR12MB3489 Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_SN6PR12MB27677B2A778476E5075C40768EA59SN6PR12MB2767namp_" --_000_SN6PR12MB27677B2A778476E5075C40768EA59SN6PR12MB2767namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable [AMD Official Use Only - General] Hello Nikunj, Yes we can move MemEncryptSevLiveMigrationIsEnabled() check here before cal= ling SetMemoryEncDecHypercall3() but then we also need to remove the same check from inside SetMemoryEncDecH= ypercall3() function. Thanks, Ashish From: nikunj via groups.io Sent: Tuesday, June 7, 2022 3:39 AM To: Kalra, Ashish ; devel@edk2.groups.io Subject: Re: [edk2-devel] [PATCH v8 3/6] OvmfPkg/BaseMemEncryptLib: Invoke = page encryption state change hypercall Hi Ashish, For case with latest OVMF and older qemu that does not enable live migratio= ns, SetMemoryEncDecHypercall3() returns RETURN_UNSUPPORTED, which is correct. But then its actually treated as an error and OVMF sees an assert. This is = a valid usecase and OVMF should move ahead without live migration and HC_MAP_GPA_RANGE. .... > + // > + // Notify Hypervisor on C-bit status > + // > + if (CBitChanged) { Should we call the SetMemoryEncDecHypercall() only if migration is enabled = like below? if (CBitChanged && MemEncryptSevLiveMigrationIsEnabled () { > + Status =3D SetMemoryEncDecHypercall3 ( > + OrigPhysicalAddress, > + EFI_SIZE_TO_PAGES (OrigLength), > + (Mode =3D=3D SetCBit) ? TRUE : FALSE > + ); > + } > + > ... > > return Status; Regards Nikunj --_000_SN6PR12MB27677B2A778476E5075C40768EA59SN6PR12MB2767namp_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

[AMD Officia= l Use Only - General]

 

Hello Nikunj,

 

Yes we can move MemEncryptSevLiveMigrationIsEnabled(= ) check here before calling SetMemoryEncDecHypercall3()

but then we also need to remove the same check from = inside SetMemoryEncDecHypercall3() function.

 

Thanks,

Ashish

 

From: nikunj via groups.io <nikunj=3Damd.c= om@groups.io>
Sent: Tuesday, June 7, 2022 3:39 AM
To: Kalra, Ashish <Ashish.Kalra@amd.com>; devel@edk2.groups.io=
Subject: Re: [edk2-devel] [PATCH v8 3/6] OvmfPkg/BaseMemEncryptLib: = Invoke page encryption state change hypercall

 

Hi Ashish,

For case with latest OVMF and older qemu that does not enable live migratio= ns,
SetMemoryEncDecHypercall3() returns RETURN_UNSUPPORTED, which is correct. <= br> But then its actually treated as an error and OVMF sees an assert. This is = a valid usecase
and OVMF should move ahead without live migration and HC_MAP_GPA_RANGE.
....

> + //
> + // Notify Hypervisor on C-bit status
> + //
> + if (CBitChanged) {

Should we call the SetMemoryEncDecHypercall() only if migration is enabled = like below?

if (CBitChanged && MemEncryptSevLiveMigrationIsEnabled () {

> + Status =3D SetMemoryEncDecHypercall3 (
> + OrigPhysicalAddress,
> + EFI_SIZE_TO_PAGES (OrigLength),
> + (Mode =3D=3D SetCBit) ? TRUE : FALSE
> + );
> + }
> +
> ...
>
> return Status;

Regards
Nikunj

--_000_SN6PR12MB27677B2A778476E5075C40768EA59SN6PR12MB2767namp_--