From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web10.92158.1679622938545601593 for ; Thu, 23 Mar 2023 18:55:38 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=n4E/i5sR; spf=pass (domain: intel.com, ip: 134.134.136.65, mailfrom: dun.tan@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679622938; x=1711158938; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=KXTIM1noJw0utwU5KRrfuxDpUl0tNA61pKOrCLzfRyY=; b=n4E/i5sRIyRhgXBHPihG+AAvjg0mlXT2qZ/hTutERJaDr8/zqFmv3WCm YP960+H49bJsDRiskqAnBHYy0BQ0OcORc+6nVN9w2BxH3033zo0IzpCLK /SyqpzNqSKy6JJ76TIt6azs16b30JkhyZOLq0dN2bXgKxb718STZWrE/B +ldECtos3fSGLPQEJDO+zpRFG8RaO8ktBwh7/2IhTEIe7MEdd+KS5zFCH qjJiESxxl/rcxoYPnC30Q2JTkkEMnXYTHWvZDQPLe87eyQxL2QTSpOP9l UzUCLhczpGSvy3CvRavBunsKpjM2GkNtjyewadipocHMfSctcEIn7WuIA Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="342059833" X-IronPort-AV: E=Sophos;i="5.98,286,1673942400"; d="scan'208";a="342059833" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2023 18:55:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="1012074110" X-IronPort-AV: E=Sophos;i="5.98,286,1673942400"; d="scan'208";a="1012074110" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by fmsmga005.fm.intel.com with ESMTP; 23 Mar 2023 18:55:33 -0700 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) 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 18:55:27 -0700 Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX611.amr.corp.intel.com (10.22.229.24) 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 18:55:27 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) 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 via Frontend Transport; Thu, 23 Mar 2023 18:55:27 -0700 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.40) by edgegateway.intel.com (134.134.137.100) 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 18:55:26 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TvkO686wKi/yhjZdc9MN0kzX+JrLnHPdMlV7KqtxAxuS6dyFPa9MhidgdWY3yhOswjM5Tza9xsFLTgmbgx43LjJRz5dmy+p2rLl43LOoN47zx3T+l+cMxd7Uejr8kFNkkBrPrkSpVDijvnDyC8KZhlH+TqSoZmEDheNaR63QSq+AMqc3v4wavPgSXAI1XQN5zkGRUJyaXEtzzRNZ5dNDO6pLqaqUTXDrM97NASSI3QIEKGQ5ulmnQOiAiJqo0ZlxNr3uTR1iiSItv/1CeLjNH1t2+gMLLQvtFgliYZIJSaDZubx6FOEbCzjl56aC2QwNwkqzYypCj1cuL3H7732g3A== 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=/NmfCl21rlWLofmcJBLZwltHQ964Zw7eE0r3wSl6qoE=; b=ZCHXjp4ocfkS0XVOR8ZJyhCokYs1LX8pkUy42OdxRjeXlD+cGe45R3h/2JXv7/osEBsf/8YyIxWOznyCEzHDObQWXgnWq0ATXuKqCeQx5TlcL4E1huzTz8wJTXCsYMgA9SgxCWwuQSORTROIXAOTGByJov73az/bx4GdCxBInUM1ZN4Nz/mR+kWoY/RPLSnBs6LpvYQa+mXzV4qnr+ke7AJ4bfs9OY1dgrexH07yX8DQy7igCnHwU9Cz3fYrb7H+tjLx+a9a2JZW3yOEDbindKs80OXzNxTYBqmROGmK+wzKtnEA6bMXXAH+00xKBZF8TrgYxgGrlxA1NshY6gjEyw== 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 BN9PR11MB5483.namprd11.prod.outlook.com (2603:10b6:408:104::10) by DS0PR11MB7621.namprd11.prod.outlook.com (2603:10b6:8:143::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.37; Fri, 24 Mar 2023 01:55:19 +0000 Received: from BN9PR11MB5483.namprd11.prod.outlook.com ([fe80::af70:de56:4a6f:b2cc]) by BN9PR11MB5483.namprd11.prod.outlook.com ([fe80::af70:de56:4a6f:b2cc%7]) with mapi id 15.20.6178.038; Fri, 24 Mar 2023 01:55:19 +0000 From: "duntan" To: "Ni, Ray" , "devel@edk2.groups.io" CC: "Dong, Eric" , "Kumar, Rahul R" , Gerd Hoffmann Subject: Re: [Patch V4 08/21] UefiCpuPkg/CpuPageTableLib:Add check for Mask and Attr Thread-Topic: [Patch V4 08/21] UefiCpuPkg/CpuPageTableLib:Add check for Mask and Attr Thread-Index: AQHZXVrp9suyNGIwO023H3PDJ3AIt68ITjxQgADdJrA= Date: Fri, 24 Mar 2023 01:55:18 +0000 Message-ID: References: <20230323074057.549-1-dun.tan@intel.com> <20230323074057.549-9-dun.tan@intel.com> In-Reply-To: Accept-Language: zh-CN, 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: BN9PR11MB5483:EE_|DS0PR11MB7621:EE_ x-ms-office365-filtering-correlation-id: 534c4be8-3e29-4a25-654d-08db2c0ad1ff x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: XzQknEma5kNsFPaqUUIzZgY50mkfnlhgGI9jwJc60h7qGZosgRNWtivPmaadzGug5UKNKF2pma4bfKOiCIhfBYB1DjQe0DVI3jugOgFx8BJGPMlak9O/i50OhSWN+6qkrFDnc00TbjfZkWpMjcmPK5OQjKAdPMZD6v6fVsx5KPuPZrkS/Ul/dNSd2T0RKeFHLLfPKvVDBoqGePsID78W+iheD1Zwne2ZAub770U5qh5HPyks0NwivTlZSHdA8rpRbzjFFN/Sw27HgqREPlu5MVD83YPfUKKwnjJCUQ+3rBSoe/RE1HeN5m116UvoV5Jz2Q0FHGs3Vrb2x2ElLvxtGQx4ufa0fizjTZ2NrujUOmZmgP8pYTA6nxFy5i1ahnoAeP02TktnZUXtc+7PeTA4I6CA6cAACLS5qWmW/MXSx+0pLu1lUGcdunNy3Pzd/GHFKjbaWxoIm3rUIJLe8CQVkc/q9/GUEkggnoomApvXgf7v47QBCWN4vjaJbN2tmKYeAqJdajhaCPhlWZcuAdwO5AY25Zb15xzdA9aKycbxzYzNHQ3BN4/3jz54XhDOSN9Io7UaDgxH/wyiBrzEHwR4rsDN8ax7JOf0bS/nQsg9Wxqw+h6v0OB8aDBcw+QxJGSfxIPCWqC9HIcByiw2RzoHCq6QT0BGehyPZBcKrmBY6ZRlfGf/7H9VFSzTFPDp9IIiAtE28Kn7zQb9jTXh7mD4bw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN9PR11MB5483.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(136003)(39860400002)(396003)(376002)(346002)(366004)(451199018)(66446008)(8676002)(4326008)(64756008)(66556008)(52536014)(5660300002)(53546011)(66946007)(66476007)(76116006)(54906003)(82960400001)(41300700001)(26005)(8936002)(122000001)(316002)(6506007)(9686003)(186003)(71200400001)(478600001)(83380400001)(110136005)(7696005)(33656002)(86362001)(55016003)(38070700005)(38100700002)(2906002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?gUL+eeoj24rBafz1e8lNnJcwjgOj/TVeaJbi87+Ch+bNlEKB+kY7nfSRFDo3?= =?us-ascii?Q?KCgs/cSISiqrQ4zx8CKEFxWCwvZ/UVkkDr39knY76o9ytmhTMpCubZx7OEwW?= =?us-ascii?Q?jA10ELQEzsa8OBu7KaUu7+pXsm5RD/moq2eHwwnN8+IQs1HUfJ61kUpG+NMg?= =?us-ascii?Q?agnjzkvn0Mau5ZnL5J5+7lFQzcfjlwbLVqQzsnRcg9XGowACh9rlWERlyLcq?= =?us-ascii?Q?KJdLHGrzSprcJOG6VL26u49XII8upMDq//7F+7NmC9I8RfMJ46EYVYfhEaJ+?= =?us-ascii?Q?Ziz1Di1sV7Vpc4pfLTtwwUOememAKHfaM4Yo4ADiugbU0SFzJqxRbdGhuYiX?= =?us-ascii?Q?tnYrEonseu4Ol1MyoLt4y9h1ogB1qGHFQdtmSWT2nS0iVJ9BET6xEWF7oQZr?= =?us-ascii?Q?UDJZqLjX1IB7Jl5HWZtc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/Qt5clPNPC?= =?us-ascii?Q?AG8T/7yIw7qkDPYGKd2vMN6mi5c07gcMb2i1WTK8b+xRhBOOkTA4m3JaWAEJ?= =?us-ascii?Q?jCUVJPu6kmZGhq79zacOhs0WRHoFDG6J7O6jJ8HZxTI8bzsUqi4Qzo2zzTh9?= =?us-ascii?Q?ZbhQXDMNqdmNi26I5TXDbXIqNbdnQowm34o5trlqP5fUbXNjnmELy0Jb9bPA?= =?us-ascii?Q?jy2JZoIB1h8Wi/Hi2YErn2lSxvW6kwijiVayfilw/Grgz3+VnNT6M7M+ZjnH?= =?us-ascii?Q?8goviEU04sbX2SF8jwZWFp7aIcegmYeAt7wUtHiH?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BN9PR11MB5483.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 534c4be8-3e29-4a25-654d-08db2c0ad1ff X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Mar 2023 01:55:18.7371 (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: PDWxpCC9FvkVyLdeodFL8GVoxSqBH+wU3g9ezQHQdd0ZnpRFFkzd+EjtcVsXfWrDFjD/H5bwicMLhP3NkrwZsw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR11MB7621 Return-Path: dun.tan@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Thanks for the comments Ray. I will update the patches in next version patc= h set. -----Why break out of the loop when meeting a non-present entry? Because I think the parameter check is only needed once. Thanks, Dun -----Original Message----- From: Ni, Ray =20 Sent: Thursday, March 23, 2023 8:53 PM To: Tan, Dun ; devel@edk2.groups.io Cc: Dong, Eric ; Kumar, Rahul R ; Gerd Hoffmann Subject: RE: [Patch V4 08/21] UefiCpuPkg/CpuPageTableLib:Add check for Mask= and Attr The commit message is very detailed. But the function header comments are not. Can you please update the function header comments to add 4 lines of @retva= l RETURN_INVALID_PARAMETER, each line describes one invalid case. It's ok to have multiple lines starting with @retval RETURN_INVALID_PARAMET= ER> > + // If (LinearAddress + Length - 1) is not in the same=20 > + ParentPagingEntry > with (LinearAddress + Offset), then the remaining child PagingEntry > + // starting from PagingEntryIndex of ParentPagingEntry is all=20 > + covered by > [LinearAddress + Offset, LinearAddress + Length - 1]. > + // > + PagingEntryIndexEnd =3D (BitFieldRead64 (LinearAddress + Length -=20 > + 1, > BitStart + 9, 63) !=3D BitFieldRead64 (LinearAddress + Offset, BitStart += 9, 63)) ? > 511 : > + (UINTN)BitFieldRead64 (LinearAddress +=20 > + Length - 1, BitStart, > BitStart + 9 - 1); > + PagingEntry =3D (IA32_PAGING_ENTRY > *)(UINTN)IA32_PNLE_PAGE_TABLE_BASE_ADDRESS (&ParentPagingEntry- > >Pnle); > + for (Index =3D PagingEntryIndex; Index <=3D PagingEntryIndexEnd; Ind= ex++) { > + if (PagingEntry[Index].Pce.Present =3D=3D 0) { > + // > + // [LinearAddress, LinearAddress + Length] contains non-present = range. > + // > + Status =3D IsAttributesAndMaskValidForNonPresentEntry=20 > + (Attribute, > Mask); > + if (RETURN_ERROR (Status)) { > + return Status; > + } > + > + break; Why break out of the loop when meeting a non-present entry?