Reviewed-by: Eric Dong <eric.d...@intel.com>

> -----Original Message-----
> From: Tom Lendacky <thomas.lenda...@amd.com>
> Sent: Friday, June 5, 2020 9:28 PM
> To: devel@edk2.groups.io
> Cc: Brijesh Singh <brijesh.si...@amd.com>; Ard Biesheuvel
> <ard.biesheu...@arm.com>; Dong, Eric <eric.d...@intel.com>; Justen,
> Jordan L <jordan.l.jus...@intel.com>; Laszlo Ersek <ler...@redhat.com>;
> Gao, Liming <liming....@intel.com>; Kinney, Michael D
> <michael.d.kin...@intel.com>; Ni, Ray <ray...@intel.com>
> Subject: [PATCH v9 40/46] UefiCpuPkg: Add a 16-bit protected mode code
> segment descriptor
> 
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2198
> 
> A hypervisor is not allowed to update an SEV-ES guests register state, so
> when booting an SEV-ES guest AP, the hypervisor is not allowed to set the
> RIP to the guest requested value. Instead, an SEV-ES AP must be transition
> from 64-bit long mode to 16-bit real mode in response to an INIT-SIPI-SIPI
> sequence. This requires a 16-bit code segment descriptor.
> For PEI, create this descriptor in the reset vector GDT table. For DXE, create
> this descriptor from the newly reserved entry at location 0x28.
> 
> Cc: Eric Dong <eric.d...@intel.com>
> Cc: Ray Ni <ray...@intel.com>
> Cc: Laszlo Ersek <ler...@redhat.com>
> Signed-off-by: Tom Lendacky <thomas.lenda...@amd.com>
> ---
>  UefiCpuPkg/CpuDxe/CpuGdt.h                          | 4 ++--
>  UefiCpuPkg/CpuDxe/CpuGdt.c                          | 8 ++++----
>  UefiCpuPkg/ResetVector/Vtf0/Ia16/Real16ToFlat32.asm | 9 +++++++++
>  3 files changed, 15 insertions(+), 6 deletions(-)
> 
> diff --git a/UefiCpuPkg/CpuDxe/CpuGdt.h b/UefiCpuPkg/CpuDxe/CpuGdt.h
> index 3a0210b2f172..1c94487cbee8 100644
> --- a/UefiCpuPkg/CpuDxe/CpuGdt.h
> +++ b/UefiCpuPkg/CpuDxe/CpuGdt.h
> @@ -36,7 +36,7 @@ struct _GDT_ENTRIES {
>    GDT_ENTRY LinearCode;   GDT_ENTRY SysData;   GDT_ENTRY SysCode;-
> GDT_ENTRY Spare4;+  GDT_ENTRY SysCode16;   GDT_ENTRY LinearData64;
> GDT_ENTRY LinearCode64;   GDT_ENTRY Spare5;@@ -49,7 +49,7 @@ struct
> _GDT_ENTRIES {
>  #define LINEAR_CODE_SEL   OFFSET_OF (GDT_ENTRIES, LinearCode)
> #define SYS_DATA_SEL      OFFSET_OF (GDT_ENTRIES, SysData) #define
> SYS_CODE_SEL      OFFSET_OF (GDT_ENTRIES, SysCode)-#define SPARE4_SEL
> OFFSET_OF (GDT_ENTRIES, Spare4)+#define SYS_CODE16_SEL    OFFSET_OF
> (GDT_ENTRIES, SysCode16) #define LINEAR_DATA64_SEL OFFSET_OF
> (GDT_ENTRIES, LinearData64) #define LINEAR_CODE64_SEL OFFSET_OF
> (GDT_ENTRIES, LinearCode64) #define SPARE5_SEL        OFFSET_OF
> (GDT_ENTRIES, Spare5)diff --git a/UefiCpuPkg/CpuDxe/CpuGdt.c
> b/UefiCpuPkg/CpuDxe/CpuGdt.c
> index 64efadeba601..a1ab543f2da5 100644
> --- a/UefiCpuPkg/CpuDxe/CpuGdt.c
> +++ b/UefiCpuPkg/CpuDxe/CpuGdt.c
> @@ -70,14 +70,14 @@ STATIC GDT_ENTRIES GdtTemplate = {
>      0x0,   },   //-  // SPARE4_SEL+  // SYS_CODE16_SEL   //   {-    0x0,     
>        // limit
> 15:0+    0x0FFFF,        // limit 15:0     0x0,            // base 15:0     
> 0x0,            // base
> 23:16-    0x0,            // type-    0x0,            // limit 19:16, flags+  
>   0x09A,          //
> present, ring 0, code, execute/read+    0x08F,          // page-granular, 
> 16-bit
> 0x0,            // base 31:24   },   //diff --git
> a/UefiCpuPkg/ResetVector/Vtf0/Ia16/Real16ToFlat32.asm
> b/UefiCpuPkg/ResetVector/Vtf0/Ia16/Real16ToFlat32.asm
> index ce4ebfffb688..0e79a3984b16 100644
> --- a/UefiCpuPkg/ResetVector/Vtf0/Ia16/Real16ToFlat32.asm
> +++ b/UefiCpuPkg/ResetVector/Vtf0/Ia16/Real16ToFlat32.asm
> @@ -129,5 +129,14 @@ LINEAR_CODE64_SEL   equ $-GDT_BASE
>      DB      0            ; base 31:24 %endif +; linear code segment
> descriptor+LINEAR_CODE16_SEL     equ $-GDT_BASE+    DW      0xffff       ; 
> limit
> 15:0+    DW      0            ; base 15:0+    DB      0            ; base 
> 23:16+    DB
> PRESENT_FLAG(1)|DPL(0)|SYSTEM_FLAG(1)|DESC_TYPE(CODE32_TYPE)+
> DB
> GRANULARITY_FLAG(1)|DEFAULT_SIZE32(0)|CODE64_FLAG(0)|UPPER_LIMI
> T(0xf)+    DB      0            ; base 31:24+ GDT_END: --
> 2.27.0


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#61318): https://edk2.groups.io/g/devel/message/61318
Mute This Topic: https://groups.io/mt/74698711/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to