From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web11.9394.1672994642796752144 for ; Fri, 06 Jan 2023 00:44:02 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=WiZEOIXe; spf=pass (domain: intel.com, ip: 134.134.136.24, mailfrom: yuanhao.xie@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672994642; x=1704530642; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=stpOtufrN89KbYRig5Lh5SjxiJ1W36nVoV+Pt9XYzTI=; b=WiZEOIXe//AKMOdL64l7AJNWA4yO7uTOz6je458xsQm47fWo4B7SX1Ch vrRokES/aFfDN3Py6THqhDR6Ns/UIMOj+TTkWLpsWH+RjLq0wptQTpTSA HkQ/9Y60TRJzzd/kBtsa1yeTPKl+bkbLV3uPRAHdHtKEfyjaiJ3aWCQ+Q vnlc4TRvqnMQpsDGtfRL7scLYmv/kVxT3sYcP2iGIkIPJlM2D3WSzqPBQ tcaxmcmZc/lSCFjcIAZEYkBgGxwqkV34btakov9CqU1AoGvWzlT1YW10U ao/8qqr4uyAs9FzvAnCAYI/VppGbW0a/Z0FD0TydyQtra3zuZlib5NBmj Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10581"; a="323687122" X-IronPort-AV: E=Sophos;i="5.96,304,1665471600"; d="scan'208";a="323687122" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jan 2023 00:44:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10581"; a="984615138" X-IronPort-AV: E=Sophos;i="5.96,304,1665471600"; d="scan'208";a="984615138" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by fmsmga005.fm.intel.com with ESMTP; 06 Jan 2023 00:44:01 -0800 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Fri, 6 Jan 2023 00:44:01 -0800 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) 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.16; Fri, 6 Jan 2023 00:44:00 -0800 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) 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.16 via Frontend Transport; Fri, 6 Jan 2023 00:44:00 -0800 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (104.47.74.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.2507.16; Fri, 6 Jan 2023 00:44:00 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MFaDz+cfpC7Vu7C+/rvRyTUeb60D0qQmPN9qEi/o2g7YinfJoKMq6eaQVqB9RJZnpmXogyxgF1uAODUnp9xGYavY5uLUw3c4P7/yGMahaQZUZTxi1PMp9atP3xvCw/l91/eH5iWwwdO0BkI+iECBAgAzQ6Ui9mMe0eh3nfbKacg2uxQxZbZATcG8jrEhrMPLxkgCxd8LAIo42HXn2tiF/jkr0ibWvIdnPXxrQjw1u9YwVeSsFFxnXUQ0UMtaa2EHoO8+ezcdT0nBIac5QRlEaD4BNXehEmLcmrYTrXmcYMDaOmihXzDyAB24vdOiKFru9+B+6DDdlw6QVZ7AGOTMoQ== 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=OmAAUVKQWFzUcj//U4Ift/mnMMrMdFU3cHPPMlwc37o=; b=WZCI7+gJw0uFko8H3XKjorkj/4EeJpHOlqnMZVOKI2ujnYyTFd9ldhnhDwy8By/Du0zkrKKWu0ibXFEBFxW2U/CXbO2UXwDj+tR5vZjfL/KIakEkjKUXWCNkfq4H9Sbw9de3WZX+mUDc41RcXHsWcHG0i0euZLN2/leW52fkXOX8BZLeaJsJTwWRYrWzgKSuel2ntpWe/kkYhtd19Hk6kZPPKHzJKr3vyD/ZtUAUPX7OMYq3SWu8e8D7JrNsNac6TQsOO8iHelILX0kDYLt6EzSLRRQruYlZrK0hR/4ZZZmBIm8cI1zWkvg92Qu8RQq9l02rWgQvfc/wGe5YMDEDgQ== 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 CO1PR11MB5026.namprd11.prod.outlook.com (2603:10b6:303:9c::13) by BN9PR11MB5449.namprd11.prod.outlook.com (2603:10b6:408:11e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Fri, 6 Jan 2023 08:43:58 +0000 Received: from CO1PR11MB5026.namprd11.prod.outlook.com ([fe80::9752:5dd6:f56d:fddd]) by CO1PR11MB5026.namprd11.prod.outlook.com ([fe80::9752:5dd6:f56d:fddd%7]) with mapi id 15.20.5944.019; Fri, 6 Jan 2023 08:43:58 +0000 From: "Yuanhao Xie" To: "devel@edk2.groups.io" , "kraxel@redhat.com" , Laszlo Ersek CC: "Ni, Ray" , "ardb@kernel.org" , "thomas.lendacky@amd.com" Subject: Re: [edk2-devel] [PATCH] UefiCpuPkg:Fixed AsmRelocateApLoopStart and ensure allocated memory <4GB Thread-Topic: [edk2-devel] [PATCH] UefiCpuPkg:Fixed AsmRelocateApLoopStart and ensure allocated memory <4GB Thread-Index: AQHZIOlm7zRguZhih0CPAG/4hrEpf66QyDsAgAAp/gCAABaKAIAACyVg Date: Fri, 6 Jan 2023 08:43:58 +0000 Message-ID: References: <20230105062108.1796-1-yuanhao.xie@intel.com> <20230106080300.tsohpx24ddxjo5x4@sirius.home.kraxel.org> In-Reply-To: <20230106080300.tsohpx24ddxjo5x4@sirius.home.kraxel.org> 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: CO1PR11MB5026:EE_|BN9PR11MB5449:EE_ x-ms-office365-filtering-correlation-id: 66c12a87-53f9-4d3c-0ac3-08daefc226e7 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: w3149krCaQVz+utudI0ti1UkOIDY9w4XYVuWIHq42QgrDjcJ2d0xWpTT4kmELgbm/5vZO1tprrB2bBIT16qoX4a+sExu71SwlcrHbcRx4C5Qk+0226/a36j+SJ/D1NdQkLgUYlM+8ImreYE7NFe0Thkzx+Riy6/LQrw4/StFyTelrB+AOleOz9WL92uAU2QEAB7V7RCcPXkz4VYrbD7YuLMG7TQS9RLUdfD+4RYompBkuPU5S5nm/VDEVdKu0TInRxrMVAobxVGnqoxrceXq3AgtmqHTNEp4u0F4BfJUoiOmHc+n5KSwnKHbTnEHy1hPFjQfbCPaawIIZQC4sp/oy4u9Jf40jVbbxLgHaTIqdAQFiwJxBL40fUBqycseseQ2QIfc9eM4isrx+MfGkr3NLbnJLRh5jWKMiH4qBtCb4+qFCCe6kpQISU9qQz550les16SNiBFZqWKchx+JETuTiXdahqUeQtouGh8bnLpD8srtAo5o9gJ1GHFKgKh6idQu/t9r7dOZ1dMQa4eeIizosdTIUsfVqf9pdBBVJS1bfIXijd0vbDMb5zM0uVO98TlXESq2ur+7bJZbrxoe/ZiqBJfEiraWPD7F5uCAPsBKdvPbIpMoWWTbnG8LrkQcn7UKgHgCEr1phtiLU3qqsOhcW+Ro6k1t6irffDt3KzBMDoba5siLDBy0ENqt9jEdDbTekOYeorBwDaWX9D62gbqmCgT93jobSHbfr5Pz56Vc24wME89oroux0r25wpbPBGjmkMButQRjsBqPIMuCREn3sg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR11MB5026.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(6029001)(39860400002)(376002)(346002)(136003)(396003)(366004)(451199015)(83380400001)(7696005)(26005)(9686003)(33656002)(55016003)(6506007)(38070700005)(86362001)(122000001)(186003)(82960400001)(53546011)(38100700002)(316002)(478600001)(4326008)(41300700001)(66899015)(8676002)(52536014)(2906002)(4001150100001)(5660300002)(8936002)(71200400001)(966005)(76116006)(66476007)(54906003)(66556008)(66446008)(64756008)(66946007)(110136005);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?DfQWw5sqSqw7b3RINwsblxQ9qg5GKXVTaLekHZHF+7yYQBnHMSBH4VURrfWm?= =?us-ascii?Q?57WXEldM8N4o5WSdull75kj4bVyDvUqOxupVnKJNIfXWjgEUGr98sRFAc93j?= =?us-ascii?Q?ercsSQEnEmnEc1MavXj1ngRhluMjS7qMJUvdgAX3soTBAMOJWaR0f4wXn45d?= =?us-ascii?Q?iyTXW+MqeAtXSo0lh50NAhrBMZ7Yv+eOvcuJwZhtIiVC42NQ7PvJxYY9Q5Se?= =?us-ascii?Q?r14O4EWxgs5rn8/hlnfEBYZdok0xhfpO9hzY0CTO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q?IzLoHSUg2bDtIs2yIaoJtOUlzg/O72cUxx0qR2YeaPCh25XaAJIdkmCI62pi?= =?us-ascii?Q?5sHlio6jNJUd9aGZMPBhmNKjKbbNL6AWjkHA8q3PlRzutSx/dUNj+V3QVx7e?= =?us-ascii?Q?1J47qa6RopJBNZ8ILgyzNf2pBCSYfWGofAllkRtcn7/98+saXkb8OOW76XTk?= =?us-ascii?Q?ccOhSCn7SJCtlmdHt1vpKtcFO7zBzrqHAG2WHy3GE4JYdgsvAYHSiF7DDxPr?= =?us-ascii?Q?hxnP7TPkrwdIt6gywbzIY+kA5AgOSmZOdMRIJ8yuV5529j4SFLTuUBdAjXyo?= =?us-ascii?Q?zQhDsqblUjwL+DHXPCOaOoyeG27jXsUWtx9qGEwId1F6j/npFv4YNieTCAyZ?= =?us-ascii?Q?1DV3Rjio2eK80Ky8fcRSld3RZGnWNunFwWrJNpk6E9c0OgtxRTOhlEty7YW9?= =?us-ascii?Q?MvwkXG29ajYU9uHFcPZ+SBDRDWiHp/5pr0/VRBLC?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CO1PR11MB5026.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 66c12a87-53f9-4d3c-0ac3-08daefc226e7 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Jan 2023 08:43:58.1559 (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: aVQQypZL68dNSEDPyQZ908VPDYQwuTbzcILUvXV8OwtP9mYdXgis+wjOFGqn5y68H17AMhaP+z71+41jVbeVSw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR11MB5449 Return-Path: yuanhao.xie@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi all, Thanks for feedbacks. I will revert the original ones, and send the new ver= sion. Yuanhao -----Original Message----- From: devel@edk2.groups.io On Behalf Of Gerd Hoffman= n Sent: Friday, January 6, 2023 4:03 PM To: Laszlo Ersek Cc: devel@edk2.groups.io; Ni, Ray ; ardb@kernel.org; Xie,= Yuanhao ; thomas.lendacky@amd.com Subject: Re: [edk2-devel] [PATCH] UefiCpuPkg:Fixed AsmRelocateApLoopStart a= nd ensure allocated memory <4GB On Fri, Jan 06, 2023 at 07:42:20AM +0100, Laszlo Ersek wrote: > On 1/6/23 05:12, Ni, Ray wrote: > > > > Ard, > > > > Only AMD X64 (including SEV and without SEV) runs the code that=20 > > switches to 32bit paging disabled mode. > > Intel X64 runs the code that stays at 64bit paging mode. So no need=20 > > for <4G memory. > > All IA32 CPUs (including intel and AMD) stays at 32bit paging=20 > > disabled mode. The AllocateReservedPages() call should not return a=20 > > memory above 4GB in 32bit env. >=20 > This argument about the allocations sounds valid, thanks. >=20 > The code still remains incredibly hard to read. It needs serious=20 > cleanup. >=20 > (1) Wherever we have "Amd" in an identifier, let's rename it to "Amd64", > to better reflect the revised check. Maybe even better: Use PcdConfidentialComputingGuestAttr to figure wheneve= r SEV is active, if so branch into Amd assembler code. Rename "Amd" to "Am= dSev". Otherwise just call normal X64 / Ia32 code. Amd assembler code can subsequently be simplified, the checks for SEV are n= ot needed any more (but should not harm either). [ Adding Tom to CC ] > Commit 73ccde8f6d04 ("UefiCpuPkg: Has APs in 64 bit long-mode before > booting to OS.", 2022-12-20) *removed* the executable marking. >=20 > (4a) Is that not a problem? I think so. Booting with strict NX checking (PcdDxeNxMemoryProtectionPolicy =3D 0xC000000000007FD5) and "qemu -smp 2" makes my qemu hang with 200% CPU, so = probably both vcpus are spinning in a dead loop. For the BSP this is expec= ted behavior (buggy grub.efi, see parallel thread). For the AP it is not, = so apparently it is not running idle in hlt like it is supposed to. > Honestly, at this point I'm *even more convinced* that the original=20 > series should be reverted, and redone from the ground up. Yes, "back to drawing board" looks like the best option at this point. take care, Gerd