* [PATCH 0/2] UefiCpuPkg/PiSmmCpuDxeSmm: drop support for obsolete processors, fix error handling
@ 2023-03-10 12:48 Gerd Hoffmann
2023-03-10 12:48 ` [PATCH 1/2] UefiCpuPkg/PiSmmCpuDxeSmm: drop support for obsolete processors Gerd Hoffmann
2023-03-10 12:48 ` [PATCH 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: fix error handling Gerd Hoffmann
0 siblings, 2 replies; 6+ messages in thread
From: Gerd Hoffmann @ 2023-03-10 12:48 UTC (permalink / raw)
To: devel
Cc: Ray Ni, Oliver Steffen, Gerd Hoffmann, Rahul Kumar,
Pawel Polawski, Eric Dong
Gerd Hoffmann (2):
UefiCpuPkg/PiSmmCpuDxeSmm: drop support for obsolete processors
UefiCpuPkg/PiSmmCpuDxeSmm: fix error handling
UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)
--
2.39.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] UefiCpuPkg/PiSmmCpuDxeSmm: drop support for obsolete processors
2023-03-10 12:48 [PATCH 0/2] UefiCpuPkg/PiSmmCpuDxeSmm: drop support for obsolete processors, fix error handling Gerd Hoffmann
@ 2023-03-10 12:48 ` Gerd Hoffmann
2023-03-20 10:04 ` Ni, Ray
2023-03-10 12:48 ` [PATCH 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: fix error handling Gerd Hoffmann
1 sibling, 1 reply; 6+ messages in thread
From: Gerd Hoffmann @ 2023-03-10 12:48 UTC (permalink / raw)
To: devel
Cc: Ray Ni, Oliver Steffen, Gerd Hoffmann, Rahul Kumar,
Pawel Polawski, Eric Dong
It's highly unlikely the code ever runs on processors which are
almost 30 years old. Drop the code handling them.
Bugzilla: https://bugzilla.tianocore.org/show_bug.cgi?id=4345
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 20 +++++---------------
1 file changed, 5 insertions(+), 15 deletions(-)
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
index d2d0950f3b42..55a9f79da8eb 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
@@ -871,24 +871,14 @@ PiCpuSmmEntry (
//
DEBUG ((DEBUG_INFO, "PiCpuSmmEntry: gSmmBaseHobGuid not found!\n"));
//
+ // very old processors (i486 + pentium) need 32k not 4k alignment, exclude them.
+ //
+ ASSERT (FamilyId >= 6);
+ //
// Allocate buffer for all of the tiles.
//
- // Intel(R) 64 and IA-32 Architectures Software Developer's Manual
- // Volume 3C, Section 34.11 SMBASE Relocation
- // For Pentium and Intel486 processors, the SMBASE values must be
- // aligned on a 32-KByte boundary or the processor will enter shutdown
- // state during the execution of a RSM instruction.
- //
- // Intel486 processors: FamilyId is 4
- // Pentium processors : FamilyId is 5
- //
BufferPages = EFI_SIZE_TO_PAGES (SIZE_32KB + TileSize * (mMaxNumberOfCpus - 1));
- if ((FamilyId == 4) || (FamilyId == 5)) {
- Buffer = AllocateAlignedCodePages (BufferPages, SIZE_32KB);
- } else {
- Buffer = AllocateAlignedCodePages (BufferPages, SIZE_4KB);
- }
-
+ Buffer = AllocateAlignedCodePages (BufferPages, SIZE_4KB);
ASSERT (Buffer != NULL);
DEBUG ((DEBUG_INFO, "New Allcoated SMRAM SaveState Buffer (0x%08x, 0x%08x)\n", Buffer, EFI_PAGES_TO_SIZE (BufferPages)));
}
--
2.39.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: fix error handling
2023-03-10 12:48 [PATCH 0/2] UefiCpuPkg/PiSmmCpuDxeSmm: drop support for obsolete processors, fix error handling Gerd Hoffmann
2023-03-10 12:48 ` [PATCH 1/2] UefiCpuPkg/PiSmmCpuDxeSmm: drop support for obsolete processors Gerd Hoffmann
@ 2023-03-10 12:48 ` Gerd Hoffmann
2023-03-20 10:04 ` Ni, Ray
2023-03-22 1:55 ` Ni, Ray
1 sibling, 2 replies; 6+ messages in thread
From: Gerd Hoffmann @ 2023-03-10 12:48 UTC (permalink / raw)
To: devel
Cc: Ray Ni, Oliver Steffen, Gerd Hoffmann, Rahul Kumar,
Pawel Polawski, Eric Dong
ASSERT() is not proper handling of allocation failures, it gets compiled
out on RELEASE builds. Print a message and enter dead loop instead.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
index 55a9f79da8eb..2e41df1f1074 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
@@ -879,6 +879,12 @@ PiCpuSmmEntry (
//
BufferPages = EFI_SIZE_TO_PAGES (SIZE_32KB + TileSize * (mMaxNumberOfCpus - 1));
Buffer = AllocateAlignedCodePages (BufferPages, SIZE_4KB);
+ if (!Buffer) {
+ DEBUG ((DEBUG_ERROR, "Failed to allocate %d pages.\n", BufferPages));
+ CpuDeadLoop ();
+ return EFI_OUT_OF_RESOURCES;
+ }
+
ASSERT (Buffer != NULL);
DEBUG ((DEBUG_INFO, "New Allcoated SMRAM SaveState Buffer (0x%08x, 0x%08x)\n", Buffer, EFI_PAGES_TO_SIZE (BufferPages)));
}
--
2.39.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] UefiCpuPkg/PiSmmCpuDxeSmm: drop support for obsolete processors
2023-03-10 12:48 ` [PATCH 1/2] UefiCpuPkg/PiSmmCpuDxeSmm: drop support for obsolete processors Gerd Hoffmann
@ 2023-03-20 10:04 ` Ni, Ray
0 siblings, 0 replies; 6+ messages in thread
From: Ni, Ray @ 2023-03-20 10:04 UTC (permalink / raw)
To: Gerd Hoffmann, devel@edk2.groups.io
Cc: Oliver Steffen, Kumar, Rahul R, Pawel Polawski, Dong, Eric
Reviewed-by: Ray Ni <ray.ni@intel.com>
> -----Original Message-----
> From: Gerd Hoffmann <kraxel@redhat.com>
> Sent: Friday, March 10, 2023 8:49 PM
> To: devel@edk2.groups.io
> Cc: Ni, Ray <ray.ni@intel.com>; Oliver Steffen <osteffen@redhat.com>; Gerd
> Hoffmann <kraxel@redhat.com>; Kumar, Rahul R
> <rahul.r.kumar@intel.com>; Pawel Polawski <ppolawsk@redhat.com>;
> Dong, Eric <eric.dong@intel.com>
> Subject: [PATCH 1/2] UefiCpuPkg/PiSmmCpuDxeSmm: drop support for
> obsolete processors
>
> It's highly unlikely the code ever runs on processors which are
> almost 30 years old. Drop the code handling them.
>
> Bugzilla: https://bugzilla.tianocore.org/show_bug.cgi?id=4345
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
> UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 20 +++++---------------
> 1 file changed, 5 insertions(+), 15 deletions(-)
>
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
> b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
> index d2d0950f3b42..55a9f79da8eb 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
> @@ -871,24 +871,14 @@ PiCpuSmmEntry (
> //
> DEBUG ((DEBUG_INFO, "PiCpuSmmEntry: gSmmBaseHobGuid not
> found!\n"));
> //
> + // very old processors (i486 + pentium) need 32k not 4k alignment,
> exclude them.
> + //
> + ASSERT (FamilyId >= 6);
> + //
> // Allocate buffer for all of the tiles.
> //
> - // Intel(R) 64 and IA-32 Architectures Software Developer's Manual
> - // Volume 3C, Section 34.11 SMBASE Relocation
> - // For Pentium and Intel486 processors, the SMBASE values must be
> - // aligned on a 32-KByte boundary or the processor will enter shutdown
> - // state during the execution of a RSM instruction.
> - //
> - // Intel486 processors: FamilyId is 4
> - // Pentium processors : FamilyId is 5
> - //
> BufferPages = EFI_SIZE_TO_PAGES (SIZE_32KB + TileSize *
> (mMaxNumberOfCpus - 1));
> - if ((FamilyId == 4) || (FamilyId == 5)) {
> - Buffer = AllocateAlignedCodePages (BufferPages, SIZE_32KB);
> - } else {
> - Buffer = AllocateAlignedCodePages (BufferPages, SIZE_4KB);
> - }
> -
> + Buffer = AllocateAlignedCodePages (BufferPages, SIZE_4KB);
> ASSERT (Buffer != NULL);
> DEBUG ((DEBUG_INFO, "New Allcoated SMRAM SaveState Buffer (0x%08x,
> 0x%08x)\n", Buffer, EFI_PAGES_TO_SIZE (BufferPages)));
> }
> --
> 2.39.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: fix error handling
2023-03-10 12:48 ` [PATCH 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: fix error handling Gerd Hoffmann
@ 2023-03-20 10:04 ` Ni, Ray
2023-03-22 1:55 ` Ni, Ray
1 sibling, 0 replies; 6+ messages in thread
From: Ni, Ray @ 2023-03-20 10:04 UTC (permalink / raw)
To: Gerd Hoffmann, devel@edk2.groups.io
Cc: Oliver Steffen, Kumar, Rahul R, Pawel Polawski, Dong, Eric
Reviewed-by: Ray Ni <ray.ni@intel.com>
> -----Original Message-----
> From: Gerd Hoffmann <kraxel@redhat.com>
> Sent: Friday, March 10, 2023 8:49 PM
> To: devel@edk2.groups.io
> Cc: Ni, Ray <ray.ni@intel.com>; Oliver Steffen <osteffen@redhat.com>; Gerd
> Hoffmann <kraxel@redhat.com>; Kumar, Rahul R
> <rahul.r.kumar@intel.com>; Pawel Polawski <ppolawsk@redhat.com>;
> Dong, Eric <eric.dong@intel.com>
> Subject: [PATCH 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: fix error handling
>
> ASSERT() is not proper handling of allocation failures, it gets compiled
> out on RELEASE builds. Print a message and enter dead loop instead.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
> UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
> b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
> index 55a9f79da8eb..2e41df1f1074 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
> @@ -879,6 +879,12 @@ PiCpuSmmEntry (
> //
> BufferPages = EFI_SIZE_TO_PAGES (SIZE_32KB + TileSize *
> (mMaxNumberOfCpus - 1));
> Buffer = AllocateAlignedCodePages (BufferPages, SIZE_4KB);
> + if (!Buffer) {
> + DEBUG ((DEBUG_ERROR, "Failed to allocate %d pages.\n", BufferPages));
> + CpuDeadLoop ();
> + return EFI_OUT_OF_RESOURCES;
> + }
> +
> ASSERT (Buffer != NULL);
> DEBUG ((DEBUG_INFO, "New Allcoated SMRAM SaveState Buffer (0x%08x,
> 0x%08x)\n", Buffer, EFI_PAGES_TO_SIZE (BufferPages)));
> }
> --
> 2.39.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: fix error handling
2023-03-10 12:48 ` [PATCH 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: fix error handling Gerd Hoffmann
2023-03-20 10:04 ` Ni, Ray
@ 2023-03-22 1:55 ` Ni, Ray
1 sibling, 0 replies; 6+ messages in thread
From: Ni, Ray @ 2023-03-22 1:55 UTC (permalink / raw)
To: Gerd Hoffmann, devel@edk2.groups.io
Cc: Oliver Steffen, Kumar, Rahul R, Pawel Polawski, Dong, Eric
Just found "if (!Buffer)" doesn't follow EDK2 coding style.
I changed to "if (Buffer == NULL) {" in final merge PR.
> -----Original Message-----
> From: Gerd Hoffmann <kraxel@redhat.com>
> Sent: Friday, March 10, 2023 8:49 PM
> To: devel@edk2.groups.io
> Cc: Ni, Ray <ray.ni@intel.com>; Oliver Steffen <osteffen@redhat.com>;
> Gerd Hoffmann <kraxel@redhat.com>; Kumar, Rahul R
> <rahul.r.kumar@intel.com>; Pawel Polawski <ppolawsk@redhat.com>; Dong,
> Eric <eric.dong@intel.com>
> Subject: [PATCH 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: fix error handling
>
> ASSERT() is not proper handling of allocation failures, it gets compiled
> out on RELEASE builds. Print a message and enter dead loop instead.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
> UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
> b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
> index 55a9f79da8eb..2e41df1f1074 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
> @@ -879,6 +879,12 @@ PiCpuSmmEntry (
> //
> BufferPages = EFI_SIZE_TO_PAGES (SIZE_32KB + TileSize *
> (mMaxNumberOfCpus - 1));
> Buffer = AllocateAlignedCodePages (BufferPages, SIZE_4KB);
> + if (!Buffer) {
> + DEBUG ((DEBUG_ERROR, "Failed to allocate %d pages.\n", BufferPages));
> + CpuDeadLoop ();
> + return EFI_OUT_OF_RESOURCES;
> + }
> +
> ASSERT (Buffer != NULL);
> DEBUG ((DEBUG_INFO, "New Allcoated SMRAM SaveState Buffer (0x%08x,
> 0x%08x)\n", Buffer, EFI_PAGES_TO_SIZE (BufferPages)));
> }
> --
> 2.39.2
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-03-22 1:55 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-10 12:48 [PATCH 0/2] UefiCpuPkg/PiSmmCpuDxeSmm: drop support for obsolete processors, fix error handling Gerd Hoffmann
2023-03-10 12:48 ` [PATCH 1/2] UefiCpuPkg/PiSmmCpuDxeSmm: drop support for obsolete processors Gerd Hoffmann
2023-03-20 10:04 ` Ni, Ray
2023-03-10 12:48 ` [PATCH 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: fix error handling Gerd Hoffmann
2023-03-20 10:04 ` Ni, Ray
2023-03-22 1:55 ` Ni, Ray
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox