From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web11.12397.1654609387582817043 for ; Tue, 07 Jun 2022 06:43:09 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=dt002KOG; spf=pass (domain: intel.com, ip: 192.55.52.43, mailfrom: jiewen.yao@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654609387; x=1686145387; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=JfKYCMSaGVTxTsHR7UdMFTuBLDaeyJl5EH+DIeFTF58=; b=dt002KOG7JjXpiUsd3lG4Kj96Ejw+DaUZxHQkGT1x4lnW0Bvc1os9c6a qd6SBRsp8dIh7t8JqcykeUvk30qY4mXCXpenYwUJEWVk6e5yzwn0y0dhx 58v3R/YP4Jyjd/jA/w7OrYeWMdELWgHlPdMtSKy/QRf+rcbal8EH0AG23 tIFR8i7/H23rivVtO6a7jG//BBPiBYzdBpDzzU1y2bbqKsFe8FiafwVQD 4+q2GTSRcOkBPCnqGSf3rDgQ1jFNUPz//nobiWJC19tsjGiTkBuFFdBZ9 zTqjxdpaKA8Yjek+PAskr2DA33i3Q2I/kID+BITcvt7GV1vr8CjVSFw3d g==; X-IronPort-AV: E=McAfee;i="6400,9594,10370"; a="363064416" X-IronPort-AV: E=Sophos;i="5.91,284,1647327600"; d="scan'208";a="363064416" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jun 2022 06:43:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,284,1647327600"; d="scan'208";a="907055960" Received: from orsmsx605.amr.corp.intel.com ([10.22.229.18]) by fmsmga005.fm.intel.com with ESMTP; 07 Jun 2022 06:43:04 -0700 Received: from orsmsx606.amr.corp.intel.com (10.22.229.19) by ORSMSX605.amr.corp.intel.com (10.22.229.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Tue, 7 Jun 2022 06:43:04 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx606.amr.corp.intel.com (10.22.229.19) 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, 7 Jun 2022 06:43:04 -0700 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (104.47.74.47) 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.2308.27; Tue, 7 Jun 2022 06:43:04 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J79OGvkT5WnEc1qDd0n2oIlwQKhHzIdvXBetzyfFPe+vm6tzC6mtbZZ2YTyPjeaQBQUHxoc+Mo4Lb1bLpGiQ88O3yzsu47TtBryfsYoQJ9riU6FzMcJAFJl09AUg+T80OlLwlHgyLFEjay4zCc5DLadM/GztSsXdMjmeWoxxwcTiNdbEosue0bibLd1C2zPmHtMBPDaxKRtviH7vlczZL45SLslTWuRq124ywgSgtkpLWUUc0w6tCtEzv6+NBch+n+3q/fKPnfOSDaSb9BNLz3Ky9N53AVkuVsYsbp6Hs2FvlXURE0aTK8FxxDtI/1/WdpErpGqEaLDZl3qlMfSWpQ== 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=O4I7abneWGnCt5MPJaxUkDlHbrrpmXtATI8Jv1ukzL0=; b=TQM6mN2bkGqVjPZprb/Uch5i6/9Lrv4wPSRgY6HIqscC2lUdW19yz6TZulsYG4ez2yaiQyj+PXhmvOuZhmUMAWriSuJ4bCGFG4B4k+0cNFrJzwClfWqxWVqbvf7DJSmDLSs/BC5bakBgGongu2zAmwd+HWg/ah0GCND4QbC64u0s+Sgf9v7WbJlm5EBUdP1pURxS+i3DHZsW0Ef9iZ7LBB4VmGDCKtFoaghbrT5qX8xl1fV0XamGDpFEhpldB6uqxcHkxPf38GAUBBznnA7zEdI2ylnwMiXntSFC8R3ejkH/c+cX1uuAVUtITOr/JTcdNZiXSGNCJqyyUK2zlqzOEw== 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 MW4PR11MB5872.namprd11.prod.outlook.com (2603:10b6:303:169::14) by CY4PR1101MB2359.namprd11.prod.outlook.com (2603:10b6:903:bb::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.13; Tue, 7 Jun 2022 13:43:00 +0000 Received: from MW4PR11MB5872.namprd11.prod.outlook.com ([fe80::24ae:1cd3:3192:4c7e]) by MW4PR11MB5872.namprd11.prod.outlook.com ([fe80::24ae:1cd3:3192:4c7e%5]) with mapi id 15.20.5314.019; Tue, 7 Jun 2022 13:43:00 +0000 From: "Yao, Jiewen" To: "devel@edk2.groups.io" , "kraxel@redhat.com" CC: Pawel Polawski , Brijesh Singh , Oliver Steffen , "James Bottomley" , Ard Biesheuvel , "Aktas, Erdem" , "Feng, Bob C" , "Chen, Christine" , "Gao, Liming" , "Xu, Min M" , Tom Lendacky , "Justen, Jordan L" , Jiri Slaby Subject: Re: [edk2-devel] [PATCH v4 1/1] OvmfPkg/Sec: fix stack switch Thread-Topic: [edk2-devel] [PATCH v4 1/1] OvmfPkg/Sec: fix stack switch Thread-Index: AQHYemvPThjOwEXOQEq/lp/7Jkz+TK1D6g5Q Date: Tue, 7 Jun 2022 13:43:00 +0000 Message-ID: References: <20220607123905.2980161-1-kraxel@redhat.com> In-Reply-To: <20220607123905.2980161-1-kraxel@redhat.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.6.500.17 dlp-product: dlpe-windows dlp-reaction: no-action 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: df5d1bed-a12d-46f0-a16c-08da488ba358 x-ms-traffictypediagnostic: CY4PR1101MB2359: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: VWgZZpeUst+zMpJ9MMSgHxwXO/cR4z+2YRKouiv9vjkr5rOUF+ydA/F5UVChJ1402rl/RkIzLHRxTJDtNz7/ximAXEOOEbft6Ubduw+Jmf1ic3CBE+kojCKhjzCGv2koxfaUdSfZEkzMpa5bWP5VHvEcB5Ckxo5wRH/9dNNIM8SZmtcWd8XcTF9BEsibdguolaHnrLCAvPOpH3Yf0SguYxsenMyFINfna+kvK8vkKIc3WFvVD0K3Jzu6Rbi34dhH4Xpxh/9+bejinrAcF3p0mb9lxfqvnI7ChVRrkG6//dDysGW7glPDLdHuVuKS3qvs+vjdNHdGyrZhQshTTsj5KpaTz6O5i3mZfd89gDD5TlAatEb6uwyIXFvXDleHrJ0oULe9fsiUxLlfKu30eRG87zgDr5bsnM4TF7Ip279hgC6oU6P3AFRXKMmsWYUMpHqwy2cd5JlpQEOlp/Kw6MqSY8L5HKcqetzJ9KzNBFngP/iTSoAD12aPkdHCwyRfJQUlYZLf4uGMnoO+bJedbbDLW7hqYwm/Qmld+9cOM4hzEBnJKm6uAwPysm+FdgtWagJIIDRiqHFaf0GEYy4KibD/kE0gICgkfm1RC9dfQou5g346K3oIRJM9hlUd/djA9vty8FQRmdwtAkEQKjeeBjnKnFBrBSws6UuyxA57YPjxHTZj8ic5xOYtC4kOt1y2XPDQhkP7f33MedZ1sTBBWWDW92a/qv/e4JDmO5YHgk36bSmIc63mpN4gdZt/HvB3pUmpsRaRdl9VdABEFDLmoD8+/0mj7POL+0epo/T88DxNWNQaZ4AnQe18sJSmXRXgyDAMuqPL/VDc6Z9u+qU/+NyUwg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW4PR11MB5872.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(53546011)(55016003)(52536014)(186003)(86362001)(316002)(8936002)(7696005)(54906003)(110136005)(76116006)(508600001)(66946007)(66476007)(8676002)(66556008)(66446008)(64756008)(4326008)(33656002)(122000001)(82960400001)(6506007)(2906002)(7416002)(9686003)(71200400001)(38100700002)(5660300002)(966005)(26005)(83380400001)(38070700005);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?R5ey5yi4Yko0lT7aEVWjQ68WcOzM8FGhvsi6QREePvwloVTyd0acUIB2WV6/?= =?us-ascii?Q?7rUEF+coHhP1H0WLENZvBGc6kiH7jD9m9Q+FejufK7juiShaL1NO2LcyBGCD?= =?us-ascii?Q?Qq9IrDfK7Sr5VhQFHRV78YXQxJ88CbtGla5vJpJcNbWHDk2vBxl19srntDUa?= =?us-ascii?Q?dUmFyEfYvPtc7TqZEC0nF7Xpmce9IVfK5mUpWzb+L4RVek/UrJjM5vq5Sy1D?= =?us-ascii?Q?xmyAnHPxXDbS7lZyaT4RLK3yzZ6B6vvZ2V3asXC9lf8X18IOKWlq7wUkYtoc?= =?us-ascii?Q?NzIDQn/ACDZX1u7upB2KdyQtBpp61SYx0rchKAE+adese8gcKaLRxLTC9Ae8?= =?us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CIKjjwouFZXdOa7ebucfRY1VyLQGl?= =?us-ascii?Q?eHO5zRWGtf9U+biEaiDLZJpY9o/qiV/6y8FrBCEdPRfymkzraE/eX2VO8dsm?= =?us-ascii?Q?Y9oDMovmCGQqopBo3ZDh/UGopax+Ssyo8WWuMDfn7a4aP9k1Fnk+2DREifmF?= =?us-ascii?Q?6lk42jzocZGAmM3GWU37h6jGEXKybeNTKZp+N5RqJ4/eHL6vOG1wKx2w45Q5?= =?us-ascii?Q?+wj/6zUTqOGTwSLgpTzevEy2Of3+xGqXU0uVWuTnG2LjWVcTQ37BFd1hXUB0?= =?us-ascii?Q?g0KjYVsCTqF8uqA8ssRi4z9HflVeoXRBkQ9/BoHhgaHHeA/SXoTl7X45Eril?= =?us-ascii?Q?9qOAGhLyZWgQe/S3gQBltai0SdgfzIiEqGlZ3wpedClHr+f/XS4NSM+AA339?= =?us-ascii?Q?4VoaYunMKT+KPh3B8PDdWcORR5CIPuqrFRvMvz8ggd8WP3FPtAIWSEmB20tk?= =?us-ascii?Q?kaVH68sIbdYNYWpAyGWG5kUwrOH0siDR5n/1nPZ1kn8hrI/TblIuWWAi6dMJ?= =?us-ascii?Q?gBzSucF96A=3D=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW4PR11MB5872.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: df5d1bed-a12d-46f0-a16c-08da488ba358 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Jun 2022 13:43:00.4182 (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: 2s6eeq/8CAqe/3zD//fQKyHvFTtetzlq5SPdfM3WKfcVkEJ5Pqupr/j6DNFllO0aIm+ummGX4en934UrWUmmVw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1101MB2359 Return-Path: jiewen.yao@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hello As far as I know the TemporaryRamMigration() is an optional PPI according t= o PI spec, I forget why we add it in the beginning. To reduce the maintenance effort, can we try to remove it? As such the PEI = core can perform the migration in https://github.com/tianocore/edk2/blob/ma= ster/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c. Thank you Yao Jiewen > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Gerd > Hoffmann > Sent: Tuesday, June 7, 2022 8:39 PM > To: devel@edk2.groups.io > Cc: Yao, Jiewen ; Gerd Hoffmann > ; Pawel Polawski ; Brijesh Singh > ; Oliver Steffen ; James > Bottomley ; Ard Biesheuvel ; > Aktas, Erdem ; Feng, Bob C > ; Chen, Christine ; Gao, Limi= ng > ; Xu, Min M ; Tom > Lendacky ; Justen, Jordan L > ; Jiri Slaby > Subject: [edk2-devel] [PATCH v4 1/1] OvmfPkg/Sec: fix stack switch >=20 > The ebp/rbp register can either be used for the frame pointer or > as general purpose register. With gcc (and clang) this depends > on the -f(no-)omit-frame-pointer switch. >=20 > This patch updates tools_def.template to explicitly set the compiler > option and also add a define to allow conditionally compile code. >=20 > The new define is used to fix stack switching in TemporaryRamMigration. > The ebp/rbp must not be touched when the compiler can use it as general > purpose register. With version 12 gcc starts actually using the > register, so changing it leads to firmware crashes in some > configurations. >=20 > Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3934 > Reported-by: Jiri Slaby > Signed-off-by: Gerd Hoffmann > --- > OvmfPkg/Sec/SecMain.c | 4 ++++ > BaseTools/Conf/tools_def.template | 4 ++-- > 2 files changed, 6 insertions(+), 2 deletions(-) >=20 > diff --git a/OvmfPkg/Sec/SecMain.c b/OvmfPkg/Sec/SecMain.c > index 1167d22a68cc..3ca0dcdfd3dd 100644 > --- a/OvmfPkg/Sec/SecMain.c > +++ b/OvmfPkg/Sec/SecMain.c > @@ -1052,11 +1052,15 @@ TemporaryRamMigration ( > if (SetJump (&JumpBuffer) =3D=3D 0) { > #if defined (MDE_CPU_IA32) > JumpBuffer.Esp =3D JumpBuffer.Esp + DebugAgentContext.StackMigrateOf= fset; > + #ifndef OMIT_FRAME_POINTER > JumpBuffer.Ebp =3D JumpBuffer.Ebp + DebugAgentContext.StackMigrateOf= fset; > #endif > + #endif > #if defined (MDE_CPU_X64) > JumpBuffer.Rsp =3D JumpBuffer.Rsp + DebugAgentContext.StackMigrateOf= fset; > + #ifndef OMIT_FRAME_POINTER > JumpBuffer.Rbp =3D JumpBuffer.Rbp + DebugAgentContext.StackMigrateOf= fset; > + #endif > #endif > LongJump (&JumpBuffer, (UINTN)-1); > } > diff --git a/BaseTools/Conf/tools_def.template > b/BaseTools/Conf/tools_def.template > index 5ed19810b727..18e3d6c5e907 100755 > --- a/BaseTools/Conf/tools_def.template > +++ b/BaseTools/Conf/tools_def.template > @@ -1848,10 +1848,10 @@ NOOPT_*_*_OBJCOPY_ADDDEBUGFLAG =3D -- > add-gnu-debuglink=3D$(DEBUG_DIR)/$(MODULE_N > *_*_*_DTCPP_PATH =3D DEF(DTCPP_BIN) > *_*_*_DTC_PATH =3D DEF(DTC_BIN) >=20 > -DEFINE GCC_ALL_CC_FLAGS =3D -g -Os -fshort-wchar -fno-builtin= -fno- > strict-aliasing -Wall -Werror -Wno-array-bounds -include AutoGen.h -fno- > common > +DEFINE GCC_ALL_CC_FLAGS =3D -g -Os -fshort-wchar -fno-builtin= -fno- > strict-aliasing -Wall -Werror -Wno-array-bounds -include AutoGen.h -fno- > common -fomit-frame-pointer -DOMIT_FRAME_POINTER=3D1 > DEFINE GCC_IA32_CC_FLAGS =3D DEF(GCC_ALL_CC_FLAGS) -m32 -malig= n- > double -freorder-blocks -freorder-blocks-and-partition -O2 -mno-stack-arg= - > probe > DEFINE GCC_X64_CC_FLAGS =3D DEF(GCC_ALL_CC_FLAGS) -mno-red-zo= ne - > Wno-address -mno-stack-arg-probe > -DEFINE GCC_ARM_CC_FLAGS =3D DEF(GCC_ALL_CC_FLAGS) -mlittle-en= dian > -mabi=3Daapcs -fno-short-enums -funsigned-char -ffunction-sections -fdata= - > sections -fomit-frame-pointer -Wno-address -mthumb -mfloat-abi=3Dsoft -fn= o-pic > -fno-pie > +DEFINE GCC_ARM_CC_FLAGS =3D DEF(GCC_ALL_CC_FLAGS) -mlittle-en= dian > -mabi=3Daapcs -fno-short-enums -funsigned-char -ffunction-sections -fdata= - > sections -Wno-address -mthumb -mfloat-abi=3Dsoft -fno-pic -fno-pie > DEFINE GCC_ARM_CC_XIPFLAGS =3D -mno-unaligned-access > DEFINE GCC_AARCH64_CC_FLAGS =3D DEF(GCC_ALL_CC_FLAGS) -mlittle- > endian -fno-short-enums -fverbose-asm -funsigned-char -ffunction-section= s - > fdata-sections -Wno-address -fno-asynchronous-unwind-tables -fno-unwind- > tables -fno-pic -fno-pie -ffixed-x18 > DEFINE GCC_AARCH64_CC_XIPFLAGS =3D -mstrict-align -mgeneral-regs-onl= y > -- > 2.36.1 >=20 >=20 >=20 >=20 >=20