From: "Nate DeSimone" <nathaniel.l.desimone@intel.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>,
"abdattar@amd.com" <abdattar@amd.com>
Cc: "Chiu, Chasel" <chasel.chiu@intel.com>,
Liming Gao <gaoliming@byosoft.com.cn>,
"Dong, Eric" <eric.dong@intel.com>
Subject: Re: [edk2-devel] [edk2-platforms] [PATCH v1 1/2] MinPlatformPkg: Update APIC Table based on mode
Date: Wed, 27 Oct 2021 08:16:45 +0000 [thread overview]
Message-ID: <MW4PR11MB582199BB18657DEADC8F4294CD859@MW4PR11MB5821.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20211022144746.10671-2-abdattar@amd.com>
Hi Abdul,
I do agree with you that logically it seems to be the right thing to not install the local APIC NMI structure if we install the X2APIC NMI structure instead. However, I went and took a look at some of our internal closed source 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, but 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 that 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 X2APIC NMI structures... but it is always best to check assumptions.
Can you elaborate on any testing that you have done? Have you tested this change on a real HW? If yes, which OS did you try booting? Have you tried any older OSes?
Thanks,
Nate
-----Original Message-----
From: devel@edk2.groups.io <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 <chasel.chiu@intel.com>; Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>; Dong, Eric <eric.dong@intel.com>
Subject: [edk2-devel] [edk2-platforms] [PATCH v1 1/2] MinPlatformPkg: Update 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 <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Eric Dong <eric.dong@intel.com>
Signed-off-by: Abdul Lateef Attar <abdattar@amd.com>
---
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 @@
Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.<BR>
Copyright (c) Microsoft Corporation.<BR>
+Copyright (c) 2021, AMD Incorporated. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -947,21 +948,23 @@ InstallMadtFromScratch (
//
// Build Local APIC NMI Structures
//
- LocalApciNmiStruct.Type = EFI_ACPI_6_3_LOCAL_APIC_NMI;
- LocalApciNmiStruct.Length = sizeof (EFI_ACPI_6_3_LOCAL_APIC_NMI_STRUCTURE);
- LocalApciNmiStruct.AcpiProcessorUid = 0xFF; // Applies to all processors
- LocalApciNmiStruct.Flags = 0x0005; // Flags - Edge-tiggered, Active High
- LocalApciNmiStruct.LocalApicLint = 0x1;
+ if (!mX2ApicEnabled) {
+ LocalApciNmiStruct.Type = EFI_ACPI_6_3_LOCAL_APIC_NMI;
+ LocalApciNmiStruct.Length = sizeof
+ (EFI_ACPI_6_3_LOCAL_APIC_NMI_STRUCTURE);
+ LocalApciNmiStruct.AcpiProcessorUid = 0xFF; // Applies to all processors
+ LocalApciNmiStruct.Flags = 0x0005; // Flags - Edge-tiggered, Active High
+ LocalApciNmiStruct.LocalApicLint = 0x1;
- ASSERT (MadtStructsIndex < MaxMadtStructCount);
- Status = CopyStructure (
- &MadtTableHeader.Header,
- (STRUCTURE_HEADER *) &LocalApciNmiStruct,
- &MadtStructs[MadtStructsIndex++]
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "CopyMadtStructure (APIC NMI) failed: %r\n", Status));
- goto Done;
+ ASSERT (MadtStructsIndex < MaxMadtStructCount);
+ Status = CopyStructure (
+ &MadtTableHeader.Header,
+ (STRUCTURE_HEADER *) &LocalApciNmiStruct,
+ &MadtStructs[MadtStructsIndex++]
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "CopyMadtStructure (APIC NMI) failed: %r\n",
+ Status));
+ goto Done;
+ }
}
//
@@ -1454,6 +1457,10 @@ InstallAcpiPlatform (
DEBUG ((DEBUG_INFO, "mNumberOfCpus - %d\n", mNumberOfCpus));
DEBUG ((DEBUG_INFO, "mNumberOfEnabledCPUs - %d\n", mNumberOfEnabledCPUs));
+ if (LOCAL_APIC_MODE_X2APIC == GetApicMode ()) {
+ mX2ApicEnabled = TRUE;
+ }
+
DEBUG ((DEBUG_INFO, "mX2ApicEnabled - 0x%x\n", mX2ApicEnabled));
DEBUG ((DEBUG_INFO, "mForceX2ApicId - 0x%x\n", mForceX2ApicId));
--
2.25.1
next prev parent reply other threads:[~2021-10-27 8:16 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-22 14:47 [edk2-[PATCH v1 0/2] APIC table updates Abdul Lateef Attar
2021-10-22 14:47 ` [edk2-platforms] [PATCH v1 1/2] MinPlatformPkg: Update APIC Table based on mode Abdul Lateef Attar
2021-10-27 8:16 ` Nate DeSimone [this message]
2021-10-27 16:33 ` [edk2-devel] " Attar, AbdulLateef (Abdul Lateef)
2021-10-28 2:48 ` Nate DeSimone
2021-10-28 12:50 ` Attar, AbdulLateef (Abdul Lateef)
2021-10-29 21:59 ` Nate DeSimone
2021-10-22 14:47 ` [edk2-platforms] [PATCH v1 2/2] MinPlatformPkg: AcpiProcessorUid for multi-socket Abdul Lateef Attar
2021-10-27 8:16 ` [edk2-devel] " Nate DeSimone
2021-10-27 8:16 ` [edk2-[PATCH v1 0/2] APIC table updates Nate DeSimone
2021-10-28 4:05 ` Attar, AbdulLateef (Abdul Lateef)
2021-11-02 21:42 ` Nate DeSimone
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=MW4PR11MB582199BB18657DEADC8F4294CD859@MW4PR11MB5821.namprd11.prod.outlook.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox