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.web11.1953.1660103531154500195 for ; Tue, 09 Aug 2022 20:52:11 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=Orq4Bu1e; spf=pass (domain: intel.com, ip: 134.134.136.31, 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=1660103531; x=1691639531; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=nlGcsJ7euielIkIkkHwNnuEWobP/a1j7PaOE7ON3NsM=; b=Orq4Bu1egfvnsU8SDHnT9ow9UkdmuPMA3KYA9q/4/4HFQM37XlmgegwP +hnlagW/Uvu1o/6DkaDouEWkqAavmipFovW0docOyCYV+az3XORiYrZq/ DGcPGDjrtLRfiomnn1VFLawN37awzL48AcoezmDyS1pW6dRkiqI/FVnm6 y6acrTlWiF54JFX/LlcNH8OUMR5ddhx90lidtjblz6foVoMu9zLXEji1X NBaN2O8gMdspjDs/h0xAio8hQ/eVKQl01jbTfJ02VBX19Ww2vnpu/unLu zZEolO9MysM9kGXf7CUsFsA7khhxgOaB5smfgOEBLRcEl2UFAEuCqruBf Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10434"; a="352720879" X-IronPort-AV: E=Sophos;i="5.93,226,1654585200"; d="scan'208";a="352720879" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Aug 2022 20:52:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,226,1654585200"; d="scan'208";a="581068235" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by orsmga006.jf.intel.com with ESMTP; 09 Aug 2022 20:52:10 -0700 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Tue, 9 Aug 2022 20:52:10 -0700 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Tue, 9 Aug 2022 20:52:09 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28 via Frontend Transport; Tue, 9 Aug 2022 20:52:09 -0700 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (104.47.57.42) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2375.28; Tue, 9 Aug 2022 20:52:06 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TFnFsNSSDj5/fNhA/+byWXwQT/aZFNdbR1rg2Fel3qzKEMOctOPsxQJsBZseZslQT20m5ZUzNAfS68qrI/q5L8oRU5Tc8EzZMHirX7H88Otj8ayWLoQeBd2TXUrP475/DBv2EsAUfr5SUOCoJB/LFdkJmFDSaeFTlbjBkL+2apUWgFmjamhK+kxTvMreA6Kwnq+Qru0mtD4XaCGHq7gGosm0v7bWN9Ppw7gpeAqGvRjwVXZnFfmoJYgrSvl8jVYGqKijP6K07I6d1w3ZmlujsVhIxR26kdGEqytpxekV/nKBn562bzG2wPFp0d+eni18rB+LlnjGI0TaySaVClkQDw== 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=0xEypQ0/va2tj+k1LHorvgNS2L4Y/swZST6AT6n2FKE=; b=XuX1QEyynpF5kH7woYTLPtvoIZp7x8GRyUUgApZJKGVXsicq1960oAdmw43CIemdxTGRUupaQnRkg77SQY5iQumaxX4Zwlxx/e5LQVAtxTp+P5WGdJaalv9h+5lMy0Aai8x8HqtsRiQk7IDspfRzTiM0XzdEp64MQf5m2lZnwoZtB2+ozrDZbAStJdQ7OK55La3XkVYYkcHR7z4Bh5Va2V/n+bgFSi/QPk8hWFDfN4c1IyxllAWwj/5sC30Rbx/B6OI2Uec9a+nL2b1GDGWdjxe5+VwJvrfC1mGD90CGtTpxCcZEoqCxe7u/umPnEUuspbDOG0gXd27uQVfjUX+MtQ== 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 MWHPR11MB1631.namprd11.prod.outlook.com (2603:10b6:301:10::10) by DM6PR11MB4756.namprd11.prod.outlook.com (2603:10b6:5:2a7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Wed, 10 Aug 2022 03:51:59 +0000 Received: from MWHPR11MB1631.namprd11.prod.outlook.com ([fe80::991b:97a0:7836:5174]) by MWHPR11MB1631.namprd11.prod.outlook.com ([fe80::991b:97a0:7836:5174%10]) with mapi id 15.20.5504.020; Wed, 10 Aug 2022 03:51:59 +0000 From: "Ni, Ray" To: "devel@edk2.groups.io" , "Tan, Dun" CC: "Dong, Eric" , "Kumar, Rahul R" Subject: Re: [edk2-devel] [PATCH 1/2] UefiCpuPkg/PiSmmCpuDxeSmm: Add a new IsShadowStack flag Thread-Topic: [edk2-devel] [PATCH 1/2] UefiCpuPkg/PiSmmCpuDxeSmm: Add a new IsShadowStack flag Thread-Index: AQHYrFr0A2kijN8iT0ybuAusuBZ4e62nf5OA Date: Wed, 10 Aug 2022 03:51:59 +0000 Message-ID: References: <20220810014532.117-1-dun.tan@intel.com> <20220810014532.117-2-dun.tan@intel.com> In-Reply-To: <20220810014532.117-2-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-office365-filtering-correlation-id: bd818266-f69a-41b4-7b17-08da7a83ad4e x-ms-traffictypediagnostic: DM6PR11MB4756:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: wYrrwW93wjDurpFf+Y2w0BEzhEf2zvQidLHADZf1taUf9USMI2srUYIqfwNOxJ87PzsMUiKsOogkhDwiZuLOrki8vmqrRQ7lUamotbgDRHYawFH+abEomftIjhSbXdMACDxr3ySIim9vSUrvVusVs/5Y+4pyvOrBQi9oTuvo4nb0WpHGguA7cHstAYbYHfWjJGQUdhHlEtygBv9O7qBpamT7F/180yNdU7pkbnotoKTjZZqdjjAOkj1GwPQAHVQ4cEJzX7b331TsOVm9F4OHcbGTKi9H/C2C4VkejT07CiMZXBfCXho33RsgtPilyv8IPZ+HTSqw0CghJeBzme8b7Y1d63Hc9CN5CHvpp9WPO/+/UmNLd+V8GEDn+JKw2VeAwxc36LL4kkFI4RX35nrqShdP/VrLASISUC3zTEp0/ODCmAvm305WLyrUUmIGrdmiHi4gUB77XDepWP2De/5eoDp41VSIYcgSgGKy55SJqQvGZB7HjMDi6mOh2MURH2p3AOO1W1Qp+HzAG4VHq6dWO1i79jScvfB+fuEW5LZJi2m3BbrgvHMRyaSHL4d1gqtCKv8k2OxNWJrLKGtgADJqQg/rmbOQxorwHpYkfiPnlLr8Tp1WfcXHt/RWJn9m52alQb6dvcD3jftJ8MrfvjscRb8jUvAZNuHjcK/5BVSkOEUkAXGNfjNeunOyl9wSeK45jNcwQ0ywmD5ayJs0bjyVB9zCh+28cFbhjEZzTCYYtmi3bZ1bLozEzO6d+lB5q2hkUrsXyZy/boDqL7XoDvklROEzNrjtIRU4T8IZocHfy+kzo8L3wNh+i8U6fJcgnPJXL3tHTqEaqTIuUf7ujf/9NSJ/ofFq5jKwQIQSKtH4Ydg15+h4h5jpNWy3qkr5Oqzh x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR11MB1631.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(6029001)(346002)(39860400002)(376002)(396003)(366004)(136003)(76116006)(66556008)(66476007)(66946007)(107886003)(478600001)(5660300002)(8936002)(55016003)(86362001)(52536014)(83380400001)(122000001)(66446008)(6636002)(33656002)(54906003)(71200400001)(186003)(110136005)(316002)(7696005)(6506007)(53546011)(26005)(82960400001)(41300700001)(64756008)(2906002)(38070700005)(966005)(4326008)(8676002)(38100700002)(9686003);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?7KChxIU0HPK3rNWsD6hxgWgJTqBkq+epPd9IR8vp3HZoWQO0IoYDA8DUxo0K?= =?us-ascii?Q?yoPVcauIa0Y11hOS12eltJ4iV3TNc59L2IuH1phOkl2kbKgt6sXP5wnUdkuR?= =?us-ascii?Q?FSNmdzatB1ebEzYSlLWTUBDZd7v7zw0l0xEVYOXTd5HBpMzkd6R3uVKvoPmx?= =?us-ascii?Q?VIGQnVjG9QQXEYS69vcGIDADHGVq9LOu5TduppwWHs3jhRBxUp7/XiqMNGQZ?= =?us-ascii?Q?EUDORW3ykiRZo2OrzAF9QuoEMNh9EJSVuFaeqskuzeJvOTnB40hAEX5lfJZF?= =?us-ascii?Q?J6vesXhxEIhtB554ex1sE29VKMVg5KK9VS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1j+aqUOAaSwlv7kjT4SwOBMl2RirXwToHCVgQ2TPqoYxXqCr7WoX/Q?= =?us-ascii?Q?RmtRBFwxp8NSqtu4ZJnPGpuTaprbKWa6XL233Qh55+o8gt8+he0qaDzDdITn?= =?us-ascii?Q?vp2NsWmUGULfc8kT+Ul0J6QlpbL1ky3BX5TJ93hBbY+2sVWoRRsUS9JpSW2S?= =?us-ascii?Q?09uMdURmZ0bpRR8oZkHfeXYz2oEXrfb7DqdZ3p7O6yC/j4LX63jS/EsalRXg?= =?us-ascii?Q?ZHQJ7Qep8ZbcKkKjzOVOZYkfDC8y/4mdGM7T/dR6EUcyi6QihY9bOJde/qzM?= =?us-ascii?Q?q0ZbV9gqfLJlzL5ruAanB566sQqpiXLHT+K96Z+oenkXmCyWxKGF8RLCVDON?= =?us-ascii?Q?6zpg6bTXWnGDKIr5ifk=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MWHPR11MB1631.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: bd818266-f69a-41b4-7b17-08da7a83ad4e X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Aug 2022 03:51:59.2627 (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: XlQz8euTO8clExs2yOGcVekZ0ljxvr2aHyxJ3co3np1h4bT60h8fR+HuJ81L9FXXNSOHq5pycXDCSxKY2tF/Vg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB4756 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 Dun, Can you please update the commit message to explain it's a code refactoring= and doesn't change any functionality? Also explain why such refactoring is need= ed. IsShadowStack: the name doesn't follow EDKII coding style. You need to use "mIsShadowStack". Thanks, Ray > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of duntan > Sent: Wednesday, August 10, 2022 9:46 AM > To: devel@edk2.groups.io > Cc: Dong, Eric ; Ni, Ray ; Kumar, > Rahul R > Subject: [edk2-devel] [PATCH 1/2] UefiCpuPkg/PiSmmCpuDxeSmm: Add a > new IsShadowStack flag >=20 > Add a new IsShadowStack flag to identify whether current memory is > shadow stack. The dirty bit in page table entry for this memory will > be set if IsShadowStack is TRUE, instead of depending on mInternalCr3. >=20 > Signed-off-by: Dun Tan > Cc: Eric Dong > Cc: Ray Ni > Cc: Rahul Kumar > --- > UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c | 8 > +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) >=20 > diff --git > a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c > b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c > index 1f7cc15727..b369c0c435 100644 > --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c > +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c > @@ -33,6 +33,7 @@ PAGE_ATTRIBUTE_TABLE mPageAttributeTable[] =3D { > }; >=20 > UINTN mInternalCr3; > +UINTN IsShadowStack =3D FALSE; >=20 > /** > Set the internal page table base address. > @@ -249,7 +250,7 @@ ConvertPageEntryAttribute ( > if ((Attributes & EFI_MEMORY_RO) !=3D 0) { > if (IsSet) { > NewPageEntry &=3D ~(UINT64)IA32_PG_RW; > - if (mInternalCr3 !=3D 0) { > + if (IsShadowStack) { > // Environment setup > // ReadOnly page need set Dirty bit for shadow stack > NewPageEntry |=3D IA32_PG_D; > @@ -734,10 +735,11 @@ SetShadowStack ( > EFI_STATUS Status; >=20 > SetPageTableBase (Cr3); > - > - Status =3D SmmSetMemoryAttributes (BaseAddress, Length, > EFI_MEMORY_RO); > + IsShadowStack =3D TRUE; > + Status =3D SmmSetMemoryAttributes (BaseAddress, Length, > EFI_MEMORY_RO); >=20 > SetPageTableBase (0); > + IsShadowStack =3D FALSE; >=20 > return Status; > } > -- > 2.31.1.windows.1 >=20 >=20 >=20 >=20 >=20