From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web09.2740.1655863383022639608 for ; Tue, 21 Jun 2022 19:03:03 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=YkIGOSAm; spf=pass (domain: intel.com, ip: 134.134.136.31, mailfrom: min.m.xu@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1655863383; x=1687399383; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=0457FhA0QgRIZETiE51kc2YgF0QMpNKm2X0f9oj9JkY=; b=YkIGOSAm3wTUoxoIkkDNqU0/sQwQ8/AlmGuwPerQ+4nQamEHJMKi8hDP jvdrqzmv1RIdpQIuStEAcwyj/tH8aNeJ8FF44MNp7YRSxv47bw62KtzX8 SCt2XBBuCrodq6er1B3NBN4r4lEUb7R/j0otrCsmGbtaWE5Rx9ry0NSnr m22foxh5WlozI4viXAmv+Cru2aB9BGO0S8VgbbavSxX2rBi8UiAJ2N10M Os8N9uMZw4HSLQtPi2mW7bNhjnulFGYT4WHebTQrLczJroWsVMiuRPXqb Trtt0ZRMAgkQ9d1hUWEI1oFyFI785iWjPLQx2xwiZ7fjKVbC5h0aFeVPX w==; X-IronPort-AV: E=McAfee;i="6400,9594,10385"; a="341971762" X-IronPort-AV: E=Sophos;i="5.92,211,1650956400"; d="scan'208";a="341971762" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jun 2022 19:03:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,211,1650956400"; d="scan'208";a="655415933" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by fmsmga004.fm.intel.com with ESMTP; 21 Jun 2022 19:03:01 -0700 Received: from fmsmsx604.amr.corp.intel.com (10.18.126.84) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Tue, 21 Jun 2022 19:03:01 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx604.amr.corp.intel.com (10.18.126.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27 via Frontend Transport; Tue, 21 Jun 2022 19:03:01 -0700 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (104.47.73.170) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.27; Tue, 21 Jun 2022 19:02:28 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B8rD4A2Qfa6IWNAQTGLcOKvl7oqddFdQMoIoo6/ASYPmc/LU9hoCyM+sFx9XASCvsjvR3iEFIi9QIzLg8B8MiGx+cqZAiP0EUN1V78GolHPT9c8IzU9l9k+LviF4iPdze2FO6cYm/lnzF7ZeS8lqpXCUzEUJtynH1nvKiefapiHmtJ0r2RLCsTLegA/PvvCEN2IxnvGevNdY+BF7M1g6yzFHwit1x6GwuUgzwtoFGP5RFIuBnbDJdwCKogUzqciAJZAORYPvV9YfQ6MlSpydE3KkT1yy3g7h9J+eADx/x5XxMDLeqcXs9U0BLnek9V7Kj7KiY1aSQKkjCi/zNeM4vg== 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=qMeBploRokLuPrmnpZy1XV8bLRW1FpUVPWuujG+WMBc=; b=GM6rkQNYOb1R3fjYbrUZm/Uze5PRCMWR/8SCJutEZy6KWT257OF/AGjStM0LbbiyNb4nOyimjUZKgWw3soSGYjKl+L2tDe97LfHWObc6CEOhhLZPIKCsHOFhB06QJPxZHM8104HpKV04iWPlL5PpVgQFyHb0c8LqqHCObgpgAuTFM1FE+quuZwYOpOfap5M6nd3pOnETOoQ43uZzhXMs3fDp9y29ZxiucineZcHUfnSrETI0hGXkAZQZxh2i10JG63FFvFAccBOW6nhgGXrBI2kMTjcl3MQvCMyfof+X45C6x9w0OHQxKAWfM/jaRrKsjBzxGGQumNFmHJbF5CXEWw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from PH0PR11MB5064.namprd11.prod.outlook.com (2603:10b6:510:3b::15) by SN6PR11MB3341.namprd11.prod.outlook.com (2603:10b6:805:bc::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.15; Wed, 22 Jun 2022 02:02:00 +0000 Received: from PH0PR11MB5064.namprd11.prod.outlook.com ([fe80::a0ea:2e53:9c0e:9148]) by PH0PR11MB5064.namprd11.prod.outlook.com ([fe80::a0ea:2e53:9c0e:9148%5]) with mapi id 15.20.5353.022; Wed, 22 Jun 2022 02:02:00 +0000 From: "Min Xu" To: Gerd Hoffmann CC: "devel@edk2.groups.io" , "Aktas, Erdem" , James Bottomley , "Yao, Jiewen" , Tom Lendacky , "Xu, Min M" Subject: Re: [PATCH 3/3] OvmfPkg: Initialize NvVarStore with Configuration FV in Td guest Thread-Topic: [PATCH 3/3] OvmfPkg: Initialize NvVarStore with Configuration FV in Td guest Thread-Index: AQHYgrunQTagdJr+U0Cd3PQwnRDZh61YJLIAgADbbpA= Date: Wed, 22 Jun 2022 02:02:00 +0000 Message-ID: References: <20220620110124.s4sutzqnsvlmvdg5@sirius.home.kraxel.org> In-Reply-To: <20220620110124.s4sutzqnsvlmvdg5@sirius.home.kraxel.org> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.6.500.17 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 48571f1d-26e8-4bca-33b4-08da53f331bc x-ms-traffictypediagnostic: SN6PR11MB3341:EE_ x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr 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: LhodUwdXTeRtRegRiRHXcOxF1Bwx/nJmYamTweor+ltNMlt3MD8agjzeklY6Bohyx+XDUD1Jc6SbHeqCJYzaQgM0BrCFpqsYhWfT7dxFGWp6V8P0Bhz9HeFCBsJ5DLWHu9g9RJCPWnS0DFv4d8jaIcr1pVi274S8O82Vf1ItBGIPigPUi5bdueujbGQToFvWqmqLBqnOjWbR9lPJN+tRZnPeYahnSxuyjkXY9NypiZ5E5OSv6JQqmI1N+lBLzk7BybYFxrAKK+7aoEgxY+9jmmejH3Wk0jJ38cj+sRK67SjzULO0hPRdW21Qf6y27wytfP954/ao/cJfW5yCS32KwLLsVEpeZyMTF5OzIOesCf08ulV4wKMJIBmALoGeTE4VBJ5MrSjWRhvGSTv3zGz94VMJ9OOGI5fVRrlfI0UM9zTl03mpKaQL5XQk04nx9DmMx88n/z8AL+P/bTEQJa41ssZax5cyriZsdiGFd1y3jb5Ls8VvhB3iuzroPCcRR/ufxpfY1Lvs0tZ6pnUoTARXmFET4YJLms42GtTHXoTdelLca5yi30tJ8m9+0eyQsxtrlBqCWwPSSVHKNb/BPPZ/IVoWGy56G2ixA/BEdeKWdvnSjLYPG6BWvfYywJyFvIeUclFExzcnLNeC+0MO+6HqadWproVXqrVAOHmx6sdpRLOl4NcH05b425tyOTzWxjmFRV7uF9aqkZwnJMxNezO3bA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR11MB5064.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(6029001)(346002)(396003)(39860400002)(376002)(136003)(366004)(83380400001)(5660300002)(478600001)(71200400001)(66476007)(41300700001)(38070700005)(8936002)(26005)(33656002)(186003)(86362001)(7696005)(52536014)(9686003)(107886003)(55016003)(8676002)(6506007)(76116006)(66446008)(4326008)(38100700002)(82960400001)(2906002)(316002)(66946007)(6916009)(66556008)(64756008)(54906003)(122000001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?cFmcoaJgpQam6XYpb2nulryEt8jKHJcBe+ND/rGs4sb0BnQi4HGb9jgO0RDd?= =?us-ascii?Q?+F9kW+nmxRBGpJKrqGiduVT6yG0Rp1CkEsh7/dtkz/xWn3fDHZ0jOrJ4s4tk?= =?us-ascii?Q?jMUUatrM2/Kw5DEh3fIOKOD7laTg0Tvn7/fUK9EsvhMwF3NM6bvbIc9XtQmS?= =?us-ascii?Q?lnh/Nx8wVxsHKRb9Ck1KqGRm1rq2YSkFFzE3vUpBFqA9vuzc0aDd5+b+nqBu?= =?us-ascii?Q?1h6yDNEphE5QdIE+8MR8xwcdREDpy5QRtxI0kEKB+JaKRJty1U5oK8Ajt0lB?= =?us-ascii?Q?A7TqKeTBcDHOoHo2ppfMT3FtO9uYtVvo3VmKNeL6lqjVOXdkLomF9e63i6Og?= =?us-ascii?Q?um0edpHy8WUFyd9t0w6QxkI6IL6RZTQMSTckUAR4itpGMNMvt5C7PLyVdwro?= =?us-ascii?Q?Ggstpe+1ecXkrQG8/rItmgVkNeq7MzCpbmDKcrq1+X29R8wPxmeU3IAGl0VZ?= =?us-ascii?Q?CC/Gw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KUNQagDeAw3HI?= =?us-ascii?Q?e5vw4pqqPPc+8gsS/TypgG8CZTLOSCgR9TNNWY3hupxK7G0zWN/6DFGchA/T?= =?us-ascii?Q?VY06/3M0ZHUhimxN3MDgTY0kAevkH9yqtgZmg1PRtD5bVQxUK4QKWkFVSs6L?= =?us-ascii?Q?p2ps1L7GfI3gcv9u8zz2ooBV4qgFba1O1LKDyHG+LA2yATOBw1veS03xqsLl?= =?us-ascii?Q?x/U3m3uIU0tJNdNL3bjNsnOXGT5IMiPrIGaHBS4LqAd1hMLDqtlhgSG9DOAS?= =?us-ascii?Q?B8QRr58PQkOSs6EtVlod/BxZf5mrp6vLprgi0yjUCEJTFjVj9UcQjBtDtwvm?= =?us-ascii?Q?AuyvYufMcChrUvTQ0dO/+EQAM1BJKMDVUuXWY/ejDIB5a69t9Fmt9MOw7tBY?= =?us-ascii?Q?ty5LTcjvbA=3D=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PH0PR11MB5064.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 48571f1d-26e8-4bca-33b4-08da53f331bc X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Jun 2022 02:02:00.2297 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Zk32n3eziaKRwG3h7aQrcRzrSAYQWOnn8JIVSnEnjCF+5SLB388AIrcZShO8vPGJwxmnNheqx4GIj7WjFofjwA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR11MB3341 Return-Path: min.m.xu@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable On June 20, 2022 7:01 PM, Gerd Hoffman wrote: >=20 > > + UINT8 *CfvBase; > > + UINT32 CfvSize; > > > > DEBUG ((DEBUG_INFO, "EMU Variable FVB Started\n")); > > > > @@ -774,6 +776,23 @@ FvbInitialize ( > > > > mEmuVarsFvb.BufferPtr =3D Ptr; > > > > + // > > + // In Tdx guest the VarNvStore content should be initialized by the > Configuration FV (CFV). > > + // Integrity of the CFV has been validated by TdxValidateCfv > > + (@PlatformInitLib) // if (TdIsEnabled ()) { > > + CfvBase =3D (UINT8 *)(UINTN)PcdGet32 (PcdCfvBase); > > + CfvSize =3D (UINT32)PcdGet32 (PcdCfvRawDataSize); > > + > > + if (CfvSize > mEmuVarsFvb.Size) { > > + DEBUG ((DEBUG_ERROR, "Size of CFV is larger than the EMU Variabl= e > FVB.\n")); > > + ASSERT (FALSE); > > + } else { > > + CopyMem (Ptr, CfvBase, CfvSize); > > + Initialize =3D FALSE; > > + } > > + } >=20 > There is PcdEmuVariableNvStoreReserved for that. How about just copying > the store to ram, then set PcdEmuVariableNvStoreReserved to the location > and let the existing logic handle it? There is ReserveEmuVariableNvStore in PlatformPei/Platform.c. This function= is called to allocate storage for NV Variables. PcdEmuVariableNvStoreReser= ved is set in that function too. So we can copy the content to that reserve= d storage if it is tdx guest. Then we let the exiting logic to handle it. S= o I would like to extract ReserveEmuVariableNvStore to PlatformReserveEmuVa= riableNvStore (in PlatformInitLib) and call it in both PlatformPei/Platform= .c and PeilesssStartup.c. What's your thought? >=20 > Also why limit this to tdx? Because I am not sure if other platforms need such operation. So in current= stage it is limit to tdx. Thanks Min