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.web11.72593.1679579196047366135 for ; Thu, 23 Mar 2023 06:46:36 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=byPro+MX; 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=1679579196; x=1711115196; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=nHPgh9ywZjaJzvpNLjRvGG05+AIdzeq4p04YpPG7a+8=; b=byPro+MXVDxlVcd1e/L2QSK9I4YczMhk1LWlLz59xlBUCZyqQzDX0dlk jdNxZkTp+VMciNbXBgZ0emlt0R0QdE8xa1+braXXuKocWzQItfyhKoTn1 Abjo8uVUs9RqSJ/+E4og+IEPGWNt712n2qjWglSqVCml+9sKkjbgtaTup HY5K2pk1Z6WT5y77AmscbSfEa0QRy5E2nHrOd660mnP+/CB9kFkq6oYhL syOP+g4K26nnenixpQmCMJqqJe3XqDNhNPeowqGgT50SAtdyYKjunf1E5 dZFtjEqmyscyF570owFrIGiTFetkeEwGtn/PuQgzZPcPnXkShRktKGF/M g==; X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="323348261" X-IronPort-AV: E=Sophos;i="5.98,285,1673942400"; d="scan'208";a="323348261" 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:33:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="659610129" X-IronPort-AV: E=Sophos;i="5.98,285,1673942400"; d="scan'208";a="659610129" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by orsmga006.jf.intel.com with ESMTP; 23 Mar 2023 06:32:54 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx602.amr.corp.intel.com (10.18.126.82) 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:32:52 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx611.amr.corp.intel.com (10.18.126.91) 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:32:52 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx610.amr.corp.intel.com (10.18.126.90) 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:32:52 -0700 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (104.47.51.43) by edgegateway.intel.com (192.55.55.68) 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:32:51 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I8MExrceBGB8Fbu0ocNIu23DnRtHYDpJ0ktJSekT//1M8D3B2GQ2g306WmxlIMGyvdPkgV6o5EhRQjyXyt0SoEARgblCIppVxRgnROOeFa9HYEHiavVW7A6kdJMYvvV4F9Mbd8F48Jqk2y9zjd3j2Z16KhsliKECMqL3oiWeq+RFDZrm0iuZ/fIGjooGAvIekvgn5WinqeXSkYHF0gYo9P3URJ1MUW02nK1TRmP/D5AQ44so7OvCN58iKvb6RfVe4mL94TiJSbB96KlUexE4NjrIxoPYn0XN1MyaxlEx62rIcKlcggv6uC+RJaL3kRcM4wjzJQsn+fh+htUxnHZvmA== 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=rLLZIWzAQRCnW4EAYvWjWzJdWC/x1deQ0EdVjFcaI5w=; b=bpbwcuKzIFtyxg6mJuDSViNPfQxD61ZW9jSpC+LMpG2gvFxop862g/touTkQXLGlALLu8IV923duqu3hPvEqixUC9mWyAduRKw7imazB4yMVFTDSGOEXjsB2mQnalri23wrlt/xLeb6WpTJj3h3VFwbIxEwlTUsdquOtPWXm01tR1BVDuRgWclsGb7HKxEhdVtemM4HcWK0ofsTKKM7rpoY4z4LEWSF0OBcHL4zIheuKCui5i8q1vbi+DzcjEILuibilDMgyrXmM3xcfxkrjo7MW4Iq9mdTvjwWHM1tSTi9D0jNckkUcI458w3WT4/7UtVErL8OTcE2OwzcTekg0Fw== 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:32:49 +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:32:49 +0000 From: "Ni, Ray" To: "Tan, Dun" , "devel@edk2.groups.io" CC: "Dong, Eric" , "Kumar, Rahul R" , Gerd Hoffmann Subject: Re: [Patch V4 18/21] UefiCpuPkg: Combine branch for non-present and leaf ParentEntry Thread-Topic: [Patch V4 18/21] UefiCpuPkg: Combine branch for non-present and leaf ParentEntry Thread-Index: AQHZXVr2mdy2R6nCJUqdQ+Xg3h+Uc68IXJ7g Date: Thu, 23 Mar 2023 13:32:49 +0000 Message-ID: References: <20230323074057.549-1-dun.tan@intel.com> <20230323074057.549-19-dun.tan@intel.com> In-Reply-To: <20230323074057.549-19-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: cf704b35-8543-4748-90ee-08db2ba31871 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: nPqOKv/C1mOoqZOWKzZj3vImSoBK2tNTx6zSUj3+KGBgZD6qXNta42i0FVtfwNQ1GOR6WXIsHCFw1Rpjv78Msyo3eFlfxaptDpwGWdY2RYwRDFbF4G9FRMHYyGsTuysX7i/OgUXLLNKrIZQvNF1wMpHIoHfIPZBlY5cNQsjpkdj5gEIplmPggLpApofuXQ08c/C/vDOUx75Mj8nU9iYWBsO7w9Mg6ty0f3FToRK1jxQQ0PACiy0ZIKHzAoPE+XHk0+OiIN9GW832LowdyuJZ1QEYzmsLla7G8CquzOFlf4f9Ngxfs5+x4h77lDeKlyUjvncqAMMMZ6rLQKzd+acjJhsfp6ac46ZuPpgyFBwYap7rXIogzEJ3GiC64VxfmO0aduIqsRhD9YXoSSLbRoWGyFMLS1nSmQsG9906/nHRsrbXFn27Jv3fzMs8ANzMyidPKNFVHluUiLRHKBW2Y6V1t+biFuO/haOrP/WRP1up7OukPpTzhvK48/uygQKfr+jL5cyA8q0uDN+7scWzhVJTKFU5Eq2nm2HqTkwag8gN0Tn659wcstF2V5/npXB/VJuFjbwq7wkuKcRKRGIHBL8YY7UKoGZ5aSzyi1KDj0UYxUba64Y1RTqVa4HK5tN7aQA8YR7x99IYyQDWzvtYl/MirstCIy3stzag0mrN/afxjo0UGsbDP3RePIQfA43N4hqubod2Lk5AL73Yq1pnAqXsxw== 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)(26005)(6506007)(186003)(9686003)(71200400001)(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?dzlIGsGJUK3jUkv+3yb1M9qlf9KcSjx1ZBw6F/z5jQB346QLY7UERjJuamZi?= =?us-ascii?Q?QOUaol4O3O1qDN59U2eKgaXRIVdU/iWyqCtb557y5Am5Tg3SCdLrY3YkP6Az?= =?us-ascii?Q?KDXPfqjFJhGJPFxF6MLCKBDXjnBt9rNayyDLqX7mARX6nzIQ8WDxw6fKQm3r?= =?us-ascii?Q?o2IwWauA5OVU3B9pkhyQhi0aek/XQPqosE/8ugcXT/P7v6tMx8Df7u//+J4A?= =?us-ascii?Q?IBxFRUzqs8+JOQ/9XHKvujwj30eG1bomW+WcFkMg05Jo+XVod5e/jeKfNLTJ?= =?us-ascii?Q?1NjotcVYivIzuLEEQ3Or9DPBN+noEBCGpPlpL7dDuZgilyNcJ7ni8AQekGZW?= =?us-ascii?Q?KwrjSchzHOR39nPt0ZVDMRXwsoA+/XMvctbl6xZ4sXzIOosEyfhsWY/noP5v?= =?us-ascii?Q?ZHNfFtqoOGIcbWlxI6WLxyranpcIrZh3EEiQwPJ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V2xhFpG7hl36L0kinKJssfSJfUwbEgsIz+94CDqS7Cityh?= =?us-ascii?Q?TwsLorSI7bvrDAExE7hpc8DLFyMyYtM/vGsckGT31aILSthgK61spH0MIxDJ?= =?us-ascii?Q?+D6FmW2z6zFjR+V/vB5NNCzZpUKBjnwc4awqIr3jKA7O1MJMwgdtLmp3K9Jq?= =?us-ascii?Q?1V5hHaPp72r96AoVLPRdB3kOtwkiQBc3+cfRqADpBa5bAbOnsk6z5+1sUxID?= =?us-ascii?Q?GaqY6ACirqHNpYPADlZmjQADVTcgBZoCcpQe9Xr7?= 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: cf704b35-8543-4748-90ee-08db2ba31871 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Mar 2023 13:32:49.2660 (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: QuomjFCHU+kcd5tEvitPwI/g/WNamZKsT8LN5VWZNw5lkiCUy8zJJxxmxlsTQuaIfkamKJhC+2Rctug1lb5VDA== 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 > - // > - // The parent entry is CR3 or PML5E/PML4E/PDPTE/PDE. > + // When ParentPagingEntry is non-present, parent entry is CR3 or > PML5E/PML4E/PDPTE/PDE. > // It does NOT point to an existing page directory. > + // When ParentPagingEntry is present, parent entry is leaf PDPTE_1G = or > PDE_2M. Split to 2M or 4K pages. > + // Note: it's impossible the parent entry is a PTE_4K. > // > - ASSERT (Buffer =3D=3D NULL || *BufferSize >=3D SIZE_4KB); > - CreateNew =3D TRUE; > - *BufferSize -=3D SIZE_4KB; > + OneOfPagingEntry.Pnle.Uint64 =3D 0; > + PleBAttribute.Uint64 =3D PageTableLibGetPleBMapAttribute > (&ParentPagingEntry->PleB, ParentAttribute); >=20 > - if (Modify) { > - ParentPagingEntry->Uintn =3D (UINTN)Buffer + *BufferSize; > - ZeroMem ((VOID *)ParentPagingEntry->Uintn, SIZE_4KB); > + if (ParentPagingEntry->Pce.Present =3D=3D 0) { > // > - // Set default attribute bits for PML5E/PML4E/PDPTE/PDE. > + // [LinearAddress, LinearAddress + Length] contains non-present ra= nge. > // > - PageTableLibSetPnle (&ParentPagingEntry->Pnle, &NopAttribute, > &AllOneMask); > + Status =3D IsAttributesAndMaskValidForNonPresentEntry (Attribute, > Mask); > + if (RETURN_ERROR (Status)) { > + return Status; > + } 1. do you think put " OneOfPagingEntry.Pnle.Uint64 =3D 0;" in the if-body i= s better? So both if and else initializes OneOfPagingEntry. Other logic looks good to me.