From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web12.8815.1635322612879316072 for ; Wed, 27 Oct 2021 01:16:55 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=irXd1Caj; spf=pass (domain: intel.com, ip: 192.55.52.93, mailfrom: nathaniel.l.desimone@intel.com) X-IronPort-AV: E=McAfee;i="6200,9189,10149"; a="227561380" X-IronPort-AV: E=Sophos;i="5.87,186,1631602800"; d="scan'208";a="227561380" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2021 01:16:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,186,1631602800"; d="scan'208";a="555152372" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by fmsmga004.fm.intel.com with ESMTP; 27 Oct 2021 01:16:53 -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.2242.12; Wed, 27 Oct 2021 01:16:53 -0700 Received: from fmsmsx608.amr.corp.intel.com (10.18.126.88) 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.2242.12; Wed, 27 Oct 2021 01:16:52 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx608.amr.corp.intel.com (10.18.126.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12 via Frontend Transport; Wed, 27 Oct 2021 01:16:52 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.175) 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.2242.12; Wed, 27 Oct 2021 01:16:51 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FtZVl7Odzt6iDbtEcRYss6Ivye9g6y6av7tuDzbFDDixcmGUlg0nWn1uFpnEUmVHWVKLJ3t/zKn1IDtQ6DC0N8/5++UH2QHhogKfoF2BT5eN/AKIcXv4skjHdy2m4J1nYNZ9y/orgGfHDYMpIM1KPtIkCkNi4zl/a6qrCR1VTM8Pu+qd6m3ZHv4zmPTYLlFi26U2Zm4MIcbWMfrRA/ZR+U2PmC89HjktGnMPsz4Pi6TYenl9n+KqMDFqkClh+PYzIxzyGYkB2aBPrn9MtOSNVEjK5atOypp560nd3n+oAHSR/cVDwzniqyqaTr6NtRDzdrDlfBsFhfoe0oocHi6Nxw== 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=PVB5mDPtibG0y/aGhTQUl35fC9cEPU/jZrHztHJaD7U=; b=cGUfAfD+uOWr/36pU2J5kK0sFVeeDhH+4T3P7KPulDP+KWSGsX3/QV+TlPXXhWS8EPdjA/X8+R64+AdMSljT7eXg9HXLP3iQxoM3I7mvbHQm+jkenQRHAWddEa+1we3FQFKx1TkuAmbNC1KFc0QPvMSbXm5YAUwjaihUcUhShvv7DPvdbvvq0bYsMTWRNPEjZBNrVfaifplpgn/566BaP2Ujli83Wd4/A4qvQ3QVk5PUuJ7kvr33cD3uiGZbdkLTg6tB3ozdqi8OTENea/g0QKjv0M5nNvSD9GkyQMVeovbth9LtgygyMFkYvrGbsupXXEF81Jc95u+irrAT6EfSZw== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PVB5mDPtibG0y/aGhTQUl35fC9cEPU/jZrHztHJaD7U=; b=irXd1Cajz9SQd8kHgsh32HTUM3rNBICMSxBkytslu7Kpf+OLIFSjfoVGk7orZvOwoNvgzKGsRW6hmZ5WvQSGliynMZtsT4GwlMojowZAgDeM1P0xxbkax/RXarapPtcSQ7G+L0vmJMNb41+LD99XJJpoElQVpAKHePno3G6vog8= Received: from MW4PR11MB5821.namprd11.prod.outlook.com (2603:10b6:303:184::5) by MWHPR11MB1501.namprd11.prod.outlook.com (2603:10b6:301:d::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.18; Wed, 27 Oct 2021 08:16:45 +0000 Received: from MW4PR11MB5821.namprd11.prod.outlook.com ([fe80::6140:8298:9d5a:df46]) by MW4PR11MB5821.namprd11.prod.outlook.com ([fe80::6140:8298:9d5a:df46%9]) with mapi id 15.20.4649.014; Wed, 27 Oct 2021 08:16:45 +0000 From: "Nate DeSimone" To: "devel@edk2.groups.io" , "abdattar@amd.com" CC: "Chiu, Chasel" , Liming Gao , "Dong, Eric" Subject: Re: [edk2-devel] [edk2-platforms] [PATCH v1 1/2] MinPlatformPkg: Update APIC Table based on mode Thread-Topic: [edk2-devel] [edk2-platforms] [PATCH v1 1/2] MinPlatformPkg: Update APIC Table based on mode Thread-Index: AQHXx1PccLMfQXfqmkyzYSoXVNfR5avmgukg Date: Wed, 27 Oct 2021 08:16:45 +0000 Message-ID: References: <20211022144746.10671-1-abdattar@amd.com> <20211022144746.10671-2-abdattar@amd.com> In-Reply-To: <20211022144746.10671-2-abdattar@amd.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-reaction: no-action dlp-version: 11.6.200.16 dlp-product: dlpe-windows authentication-results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 8eb8185a-101a-484e-60df-08d999221d8c x-ms-traffictypediagnostic: MWHPR11MB1501: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:10000; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: U66ucrINDCAlfxfRIQpxCMKKBTgpL2QDuWIEeJiefLjIrQv3An7pn4MplILJhFEO6B/rUn1gSiZv0wONbioctEeKn0OA+VTXQZEPgjvpeweAjqZBRLF0VBuUZa1CyjPcJkS0h+52XiYbafZd8SNl0+WKGx0SvibWgzDd3h7w9/QwSPlN6WYKRPHh4riPImnO3uSLVN+5nG5G8qXXxS2KNncDfwoC5adFd/fcfG0gtl81R1XM+RgsXz+1i3C45RCgYedP79Verthg1NVKtp/fRmT3xS4+LvcXMXA5gniemjm59C4kB72A4tcXIUGhtKlPtsdiTrSMIQfoIQTJVJPAymDc9HHNtehqBsWyYoeKugL+U06Pyn6DK0OkoTzN9i2C/m6konyFBkMRitcQFI6LTDhjQNOVf52ia7LfseGgt9b5hzvpByrfL0HyM7ztvnAPodfO1rW4bNQWd5C3L39VpKbnusOugz2YCGsfswVljmmLNriBEVODdFI/5XmljWRrFgMf9Bm2L58GPg+DcLJZzyQvqc3bCXJDp9Y7AjOz4q6ZlcWqw1dankPadXSK/8MlWkZ9IwsGoJOj6ceJiZ8ZmfiY2uRXyiJbVJTN+Meixche0W1zN1sdKMGG0h7WGv44J4UFnfXBYphKgbq0x+rv6EO+b1Kt+Dgiz4LyqSfp99OblYwRBgIJT0WiiEU0NZaLe4tmVHTmD6fDFo9jHM34M85N9hW3YOAb4/2S8c/6FvKiQWGv9kpVtQU4rok29bK4geGUKjwSrINMxdtlvYAa749zcjV0nLExGT3eJQjfUVvzIUEdNOcysZsE1XtC+TzcFCzOO1yobbdSLUFD8W3yBA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW4PR11MB5821.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(66946007)(53546011)(66446008)(6506007)(966005)(4326008)(2906002)(45080400002)(8936002)(107886003)(82960400001)(38070700005)(83380400001)(71200400001)(66556008)(64756008)(86362001)(55016002)(76116006)(66476007)(52536014)(9686003)(38100700002)(508600001)(15650500001)(26005)(33656002)(316002)(186003)(7696005)(54906003)(8676002)(122000001)(5660300002)(110136005);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?GXO6ugdk+AG3lhEoY9LVEhe12crWT8AyFSlA9ePkkMxiOy2GiE6ZyTA3zn9j?= =?us-ascii?Q?frWpmFFrkSYptyOCP4Jf0cSqgmMuUuUhqC3f8BdMfL5LkGf33KN4HIvVDcfU?= =?us-ascii?Q?KpQ0yWs1E/O7258f3InufMQWX1ohX71Y77e88NIDy7rm7vvZ1rqb768e89jr?= =?us-ascii?Q?EmtGLQGnwG1fSWhjtPNzJxuAUp2SzrDpIyrzaz3kG8I1QAjLBI/xnKLf2a99?= =?us-ascii?Q?f0VkmwH4VRKB5wOFagdrcUianSW+TWEe/p8gkObAWYxuUE9PMZLnGR4CFBVk?= =?us-ascii?Q?tB8huy2NXrAB5gmTUKKinAiAqVWvnBQQHSOtnPS52vH5KiXfaJxkT4T+K+Br?= =?us-ascii?Q?mrcn79RkVT4SJh7OP6NKhZnEoIfck+jKa4bLn8az4JmZz8kDcmJwyaHoe92V?= =?us-ascii?Q?bcwLLpwVjcnnazABAill/DH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nAgi8o+S6MzmbZFT9p+5zOMkVCk1KWPkBtDClFrznmKxNZFMtflL3+Y6r?= =?us-ascii?Q?uF0neNOebiBnu95w2Kgb0MR9lZmTFQB5XzWYIUCBord/m5naOLaYd6/9Rj5N?= =?us-ascii?Q?ctAUGZt0LaNSup+IH+GOfcsF7C07HfP1wMSIqt3OvZEU/MqPgpgNJRWexNxi?= =?us-ascii?Q?dn/2KaBkUhlMOTYw1H3OL1eE4oCDUfqcZqTlah4yHQIkA33DGpr7qr9unImQ?= =?us-ascii?Q?vUjEPSHQyRUVvjl4CJE+VxTcNZesT8H15aaUgLAk/dzp9NnWiCGSd79dLK7L?= =?us-ascii?Q?2kSHnmQcpoIeleTcHZtq1ofuF48A4Fp7uuju3mPmFJrxatJEl/MvhfGXYKvW?= =?us-ascii?Q?tPuWtA=3D=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW4PR11MB5821.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8eb8185a-101a-484e-60df-08d999221d8c X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Oct 2021 08:16:45.2147 (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: WqvklcFu8bEAVcztPkekMCyalVag9bjY0YM7ygixQH9Jil/wr4/DWM7qzx1ZpNkklB7fftVEh5WoDcrmb7TTuY6c2BD8r0s2Q0S7fjbZV6M= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1501 Return-Path: nathaniel.l.desimone@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Abdul, I do agree with you that logically it seems to be the right thing to not in= stall the local APIC NMI structure if we install the X2APIC NMI structure i= nstead. However, I went and took a look at some of our internal closed sour= ce code and it appears that even on X2APIC systems we actually install both= NMI structures. My immediate reaction was to simply consider that a bug, b= ut I am worried that this might have been done to workaround some buggy and= /or legacy OS behavior. I've been trying to find more history on it but tha= t behavior has been in our codebase for a very long time. IMHO it would be = extremely weird for an OS to support X2APIC and have some bug handling X2AP= IC NMI structures... but it is always best to check assumptions. Can you elaborate on any testing that you have done? Have you tested this c= hange on a real HW? If yes, which OS did you try booting? Have you tried an= y older OSes? Thanks, Nate -----Original Message----- From: devel@edk2.groups.io On Behalf Of Abdul Lateef= Attar via groups.io Sent: Friday, October 22, 2021 7:48 AM To: devel@edk2.groups.io Cc: Chiu, Chasel ; Desimone, Nathaniel L ; Liming Gao ; Dong, Eric Subject: [edk2-devel] [edk2-platforms] [PATCH v1 1/2] MinPlatformPkg: Updat= e APIC Table based on mode Detects the APIC mode by calling GetApicMode(). if current platform is in X2APIC mode sets the global mX2ApicEnabled. Also install the APIC NMI structure only if platform is not in X2APIC mode. Cc: Chasel Chiu Cc: Nate DeSimone Cc: Liming Gao Cc: Eric Dong Signed-off-by: Abdul Lateef Attar --- Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c | 35 ++++++++= ++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c b= /Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c index f5c4f2c3f1a9..032903029a95 100644 --- a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c +++ b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c @@ -3,6 +3,7 @@ =20 Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.
Copyright (c) Microsoft Corporation.
+Copyright (c) 2021, AMD Incorporated. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -947,21 +948,23 @@ InstallMadtFromScratch ( // // Build Local APIC NMI Structures // - LocalApciNmiStruct.Type =3D EFI_ACPI_6_3_LOCAL_APIC_NMI; - LocalApciNmiStruct.Length =3D sizeof (EFI_ACPI_6_3_LOCAL_APIC_NMI_STRUCT= URE); - LocalApciNmiStruct.AcpiProcessorUid =3D 0xFF; // Applies to all pro= cessors - LocalApciNmiStruct.Flags =3D 0x0005; // Flags - Edge-tigge= red, Active High - LocalApciNmiStruct.LocalApicLint =3D 0x1; + if (!mX2ApicEnabled) { + LocalApciNmiStruct.Type =3D EFI_ACPI_6_3_LOCAL_APIC_NMI; + LocalApciNmiStruct.Length =3D sizeof=20 + (EFI_ACPI_6_3_LOCAL_APIC_NMI_STRUCTURE); + LocalApciNmiStruct.AcpiProcessorUid =3D 0xFF; // Applies to all p= rocessors + LocalApciNmiStruct.Flags =3D 0x0005; // Flags - Edge-tig= gered, Active High + LocalApciNmiStruct.LocalApicLint =3D 0x1; =20 - ASSERT (MadtStructsIndex < MaxMadtStructCount); - Status =3D CopyStructure ( - &MadtTableHeader.Header, - (STRUCTURE_HEADER *) &LocalApciNmiStruct, - &MadtStructs[MadtStructsIndex++] - ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "CopyMadtStructure (APIC NMI) failed: %r\n", Stat= us)); - goto Done; + ASSERT (MadtStructsIndex < MaxMadtStructCount); + Status =3D CopyStructure ( + &MadtTableHeader.Header, + (STRUCTURE_HEADER *) &LocalApciNmiStruct, + &MadtStructs[MadtStructsIndex++] + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "CopyMadtStructure (APIC NMI) failed: %r\n",=20 + Status)); + goto Done; + } } =20 // @@ -1454,6 +1457,10 @@ InstallAcpiPlatform ( DEBUG ((DEBUG_INFO, "mNumberOfCpus - %d\n", mNumberOfCpus)); DEBUG ((DEBUG_INFO, "mNumberOfEnabledCPUs - %d\n", mNumberOfEnabledCPUs)= ); =20 + if (LOCAL_APIC_MODE_X2APIC =3D=3D GetApicMode ()) { + mX2ApicEnabled =3D TRUE; + } + DEBUG ((DEBUG_INFO, "mX2ApicEnabled - 0x%x\n", mX2ApicEnabled)); DEBUG ((DEBUG_INFO, "mForceX2ApicId - 0x%x\n", mForceX2ApicId)); =20 -- 2.25.1