OvmfPkg: SEC/SMM: Use 256 IDT Descriptors

This follows the update in UefiCpuPkg to use
256 IDT descriptors in SEC and SMM. This is
done to:
- Have a defined action when exceptions are
taken (use the common exception handler)
- Allow processing the stack cookie exception
gracefully instead of generating a #GP fault.

Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
This commit is contained in:
Oliver Smith-Denny 2026-02-26 13:12:37 -08:00 committed by mergify[bot]
parent 4512733ac8
commit 3bfe4fadff
2 changed files with 7 additions and 8 deletions

View file

@ -274,10 +274,10 @@ InitSmmIdt (
CONST EFI_PEI_SERVICES **PeiServices;
//
// There are 32 (not 255) entries in it since only processor
// generated exceptions will be handled.
// Populate 256 entries to ensure that a known state occurs
// for all possible exception vectors.
//
gcSmmInitIdtr.Limit = (sizeof (IA32_IDT_GATE_DESCRIPTOR) * 32) - 1;
gcSmmInitIdtr.Limit = (sizeof (IA32_IDT_GATE_DESCRIPTOR) * X86_CPU_INTERRUPT_NUM) - 1;
//
// Allocate for IDT.

View file

@ -33,11 +33,9 @@
#include <Register/Intel/Cpuid.h>
#include "AmdSev.h"
#define SEC_IDT_ENTRY_COUNT 34
typedef struct _SEC_IDT_TABLE {
EFI_PEI_SERVICES *PeiService;
IA32_IDT_GATE_DESCRIPTOR IdtTable[SEC_IDT_ENTRY_COUNT];
IA32_IDT_GATE_DESCRIPTOR IdtTable[X86_CPU_INTERRUPT_NUM];
} SEC_IDT_TABLE;
VOID
@ -844,7 +842,7 @@ SecCoreStartupWithStack (
//
IdtTableInStack.PeiService = NULL;
for (Index = 0; Index < SEC_IDT_ENTRY_COUNT; Index++) {
for (Index = 0; Index < X86_CPU_INTERRUPT_NUM; Index++) {
//
// Declare the local variables that actually move the data elements as
// volatile to prevent the optimizer from replacing this function with
@ -889,9 +887,10 @@ SecCoreStartupWithStack (
if (!SevEsIsEnabled ()) {
//
// For non SEV-ES guests, just load the IDTR.
// For non SEV-ES guests, now load the IDTR and initialize the exception handlers.
//
AsmWriteIdtr (&IdtDescriptor);
InitializeCpuExceptionHandlers (NULL);
} else {
//
// Under SEV-ES, the hypervisor can't modify CR0 and so can't enable