From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web10.73006.1679579094671417321 for ; Thu, 23 Mar 2023 06:44:55 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=htCY61Au; spf=pass (domain: intel.com, ip: 134.134.136.126, mailfrom: ray.ni@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679579094; x=1711115094; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=tEb5HdUqmlfvODRiRpf2bhJowOZWUzCKK1nAq0/vT9w=; b=htCY61Au3fBTDKJXBGBLQ+rqRgmUan6arw9stD0LBN5yNGVkca0AHpSG hgUGwzrrA3H/B3mnKGxVsFeoxvOWaJJZRsXQOJNdN4akc6R2G9x6ZTavL foRMLk10/pctQyyz7FbhWzl3Vi21j2OXNgYLPZWOa8nAwb+zu6NYjx/kA ERIyb5qKiLOpSLkbmSzZWjQKr6etS8o8CYfb9tLQpppfOl7nPPS8hmC0L YpKGheIV6u6AL/iNFxeJWofzq2lp2Kp92QoCDR+W85g6ByL0JS1UHmSKj X1HqxBKPnKjbsIKG0x3jannvZVSkKHHwW74FM0vc0qXtSw8pf6g+uEhj+ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="323347300" X-IronPort-AV: E=Sophos;i="5.98,285,1673942400"; d="scan'208";a="323347300" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2023 06:29:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="659606956" X-IronPort-AV: E=Sophos;i="5.98,283,1673942400"; d="scan'208";a="659606956" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by orsmga006.jf.intel.com with ESMTP; 23 Mar 2023 06:29:14 -0700 Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Thu, 23 Mar 2023 06:29:14 -0700 Received: from orsmsx603.amr.corp.intel.com (10.22.229.16) by ORSMSX612.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Thu, 23 Mar 2023 06:29:13 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21 via Frontend Transport; Thu, 23 Mar 2023 06:29:13 -0700 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.172) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.21; Thu, 23 Mar 2023 06:29:13 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gjuf+Xs/9mdTCEQZKxUsgam+Ed0rD0/jdL+Uaz8tbZ9qaVI2fbjyqeucgtcNKveKMUT6wHWLY/nMho7j39dcL8EthNTkqwjTd/PY+BULxk82Ta495VNLVC4+yG4KS/CzRRUp9WESIbZ0DvxggvqXYBPJv+uK9w/MGUEaXhg0IIrY7X77wcr63o4Wei71rsiY18QHiBTRl0TFrsRKg9lhgXGRxEmi6upt2F+gR7MPBc2gLsLfL2IyVDQsAYtuD0GG9vktPlLWxHYQIkOvz92ciufbeQGP9Kjw2KClnfM+H6Qc3IfgNvLhien5slKL6/ya6bvYBLAk+E/XdPGMD8Lm2w== 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=SuE4F1Q5OCnisYVelL2zZEp0Cd8d6yHbAHGF3bj8F6o=; b=NQu47jNhKUVHw6D09317rKSBG8t1fBjCF6bI0KxBhdGq4ZeqBdTSEJAOTW6gBnbYYrd1zwnu7vzBG4GzkKny/jtxdYCkLUdMP7WXbF+zt1B7JusIF1kJgZTSrumM8FMDXNP6juvYKXyKxKgoz5ZtFLalKIP5xOnOM+YZeVJ7iOmRYkVM6FtfX100bGIMsPVgVywCFOhwa9jOmQ9sfaOu86VOVvOVbnrUG1RvoB7OTcIjxr3mhJCJPygs+/0G5MQfMJsS+h0r0DPSWrqP2Fp1WCZFPA4SSifusRI7+jjdqIGl360SoIRKuxVdRCLjk8+DbFNCM9XgQbcBn6AAei9Rnw== 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 MN6PR11MB8244.namprd11.prod.outlook.com (2603:10b6:208:470::14) by MW4PR11MB6984.namprd11.prod.outlook.com (2603:10b6:303:22e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.37; Thu, 23 Mar 2023 13:29:12 +0000 Received: from MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::ae07:e96a:4a24:8a69]) by MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::ae07:e96a:4a24:8a69%7]) with mapi id 15.20.6178.037; Thu, 23 Mar 2023 13:29:11 +0000 From: "Ni, Ray" To: "Tan, Dun" , "devel@edk2.groups.io" CC: "Dong, Eric" , "Kumar, Rahul R" , Gerd Hoffmann Subject: Re: [Patch V4 17/21] UefiCpuPkg/CpuPageTableLib: Add check for page table creation Thread-Topic: [Patch V4 17/21] UefiCpuPkg/CpuPageTableLib: Add check for page table creation Thread-Index: AQHZXVrzfBWEWhYvKE2rQWRlR4sdda8IXCKQ Date: Thu, 23 Mar 2023 13:29:10 +0000 Message-ID: References: <20230323074057.549-1-dun.tan@intel.com> <20230323074057.549-18-dun.tan@intel.com> In-Reply-To: <20230323074057.549-18-dun.tan@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MN6PR11MB8244:EE_|MW4PR11MB6984:EE_ x-ms-office365-filtering-correlation-id: 78c32ef7-40f6-4b7c-4df0-08db2ba2964d x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: zxry5QJVQuqBXwth1A2+VmUEXvXzoOYUlFs1c2o9NVfA7ngskKhCNijVDmpDnnJqhM7mCkyLgzI7Av2hqROPqx5b0O/FYyFJEOXnxnnD98UMeOikAW4xmQ62Mm7rvrGBZvUvWW5nSwRiSVP9+e6mCMtc2m8lVMKJq3tgR53kKMNyw/7MX4uWjx63jruu61H9zszJqDk79ZbOAHUJbNfb6adS/aesrCWd6fLWt+j7RHICqYqM6TenWBsqYJo1G+z7o1B6TQWypsxkqk2JFSwC663bkFGTcBg/q8hHg0W36nGR+H8WrNvxSaGLCB+33VRwRMm/S3z5eWh6q+MQIlXZUgKkKhi9iUNXyGA1DW8I2XQn3T9ksLBqMwsYyUMgaXGrS+KZxNFYibdDaKJlhGdtp02T3uVlBO4cmIPy5Xe6DgPABLr42+npgtfeCHPZVGhXONt/WYbUee15GZAvMvtRd2EfFTnN3dBRtpEd1OaFl9OHQaylUcohLa0sgr27nihRVi1AvhKNykO4YPevZ5s3RYT+D/7gjGsYycxzErEALZ40eXy7TCEpk7rQcjKB7js2HHyROrb01ZtvcvnE0t0cKl3vpBfxDDkQhqliNb3oqZCMgAQWqmQ1wsnaCRmTjob5r8tWlHbA+dZUkNUzOx9bYnTkU0haFoK79aN7ECKFxC2+zc4Wye+dRuD+Rhj36Cq4gTLQsrYhepCepoBuSG+9Wg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN6PR11MB8244.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(396003)(39860400002)(366004)(376002)(346002)(136003)(451199018)(64756008)(76116006)(4326008)(8676002)(66556008)(66946007)(66446008)(66476007)(316002)(19627235002)(110136005)(54906003)(5660300002)(122000001)(41300700001)(82960400001)(8936002)(52536014)(53546011)(26005)(6506007)(186003)(9686003)(71200400001)(83380400001)(478600001)(7696005)(86362001)(33656002)(55016003)(38070700005)(38100700002)(2906002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?VgkeeYpIYsK8G+9AUKRRTzh5ASNZZz1pYQ5p1I/Pj8+K3vb8JUI4MIebjJA0?= =?us-ascii?Q?yV42ByKBerEfuTM4qB0sVTQdoxjrbRvmmC2ucVLYpJt8A6wDiPPWwaakKYOy?= =?us-ascii?Q?lZL1yUkSoY2ep86RHzAb11aTg/+nbq7vTZqgho69VHNxtnVtoosnzWU7W038?= =?us-ascii?Q?dao6uzFHpiW2mhgqX7X/qspSH7hIw2jHlh/TqjPDsoOzm2WOpu9sNVfWBuDx?= =?us-ascii?Q?aKnhUWTX2U9deatB9FpRWG4X8Uksjvf9EdsxGYrQVzxSjl7bA/T7C5qqNDps?= =?us-ascii?Q?v16YXJ/mib8ZL20xgXc34bbXCM4lOE8M23VhwQPxBSW2PvmYkA+wGGA3xCpw?= =?us-ascii?Q?/MeX8gI/+3dX4Etwbm1vf/OhU11Awy4hDaqgbCRdRXKH1VQl9nzuWtZ5VBHw?= =?us-ascii?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Deh6z5S9rthbt4dImv?= =?us-ascii?Q?H6d/TLOP+u8jZwmNpZ/E4co0pYAONXX/oPWwWzsFHkairVnylNJM0n5aeuHT?= =?us-ascii?Q?zE3TMBzNoieFg/hLGrkXbSclMEVtKQtMayz8m8Uym40FIm2/e8MB/lWTBj6H?= =?us-ascii?Q?2WYEb1AuszqOYguc4aqT6cksl1iocqbDQQ9IjxWFfKFq9Sl3r0MN/b7v3cQ1?= =?us-ascii?Q?UeZFfzV1p3fWk6q+t7dI8tpeqJBKHJhRMdHSE1yXOmqZcyPOdIeZSmQKxcdZ?= =?us-ascii?Q?Uq6QuiiDpKxq2sv0HzvEiacnDtak593UYH/FG7lo?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN6PR11MB8244.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 78c32ef7-40f6-4b7c-4df0-08db2ba2964d X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Mar 2023 13:29:10.8777 (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: 8OdYvEFzA7+MmATj7xnqOolXQ+m23vPMrcUaYmnRUwUIQrw7U5rpxCNHaP5OoLHCno4bBOttHdptGC5PUgpHrw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR11MB6984 Return-Path: ray.ni@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Ray Ni > -----Original Message----- > From: Tan, Dun > Sent: Thursday, March 23, 2023 3:41 PM > To: devel@edk2.groups.io > Cc: Dong, Eric ; Ni, Ray ; Kumar, > Rahul R ; Gerd Hoffmann > Subject: [Patch V4 17/21] UefiCpuPkg/CpuPageTableLib: Add check for page > table creation >=20 > Add code to compare ParentPagingEntry Attribute&Mask and input > Attribute&Mask to decide if new next level page table is needed > in non-present ParentPagingEntry condition. This can help avoid > unneccessary page table creation. >=20 > For example, there is a page table in which [0, 1G] is mapped(Lv4[0] > ,Lv3[0,0], a non-leaf level4 entry and a leaf level3 entry).And we > only want to map [1G, 1G+2M] linear address still as non-present. > The expected behaviour should be nothing happens in the process. > However, previous code logic doesn't check if ParentPagingEntry > Attribute&Mask and input Attribute&Mask are the same in non-present > ParentPagingEntry condition. Then a new 4K memory is allocated for > Lv2 since 1G+2M is not 1G-aligned. > So when ParentPagingEntry is non-present, before allocate 4K memory > for next level paging, we also check if ParentPagingEntry Attribute& > Mask and input Attribute&Mask are the same. >=20 > Signed-off-by: Dun Tan > Cc: Eric Dong > Cc: Ray Ni > Cc: Rahul Kumar > Cc: Gerd Hoffmann > --- > UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c | 10 > ++++++++++ > 1 file changed, 10 insertions(+) >=20 > diff --git a/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c > b/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c > index 982652b58b..55a756ad90 100644 > --- a/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c > +++ b/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c > @@ -358,6 +358,16 @@ PageTableLibMapInLevel ( > return Status; > } >=20 > + // > + // Check the attribute in ParentPagingEntry is equal to attribute ca= lculated > by input Attribue and Mask. > + // > + PleBAttribute.Uint64 =3D PageTableLibGetPleBMapAttribute > (&ParentPagingEntry->PleB, ParentAttribute); > + if ((IA32_MAP_ATTRIBUTE_ATTRIBUTES (&PleBAttribute) & > IA32_MAP_ATTRIBUTE_ATTRIBUTES (Mask)) > + =3D=3D (IA32_MAP_ATTRIBUTE_ATTRIBUTES (Attribute) & > IA32_MAP_ATTRIBUTE_ATTRIBUTES (Mask))) > + { > + return RETURN_SUCCESS; > + } > + > // > // The parent entry is CR3 or PML5E/PML4E/PDPTE/PDE. > // It does NOT point to an existing page directory. > -- > 2.31.1.windows.1