From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=0kGK5pUf; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.75.84, mailfrom: thomas.lendacky@amd.com) Received: from NAM02-BL2-obe.outbound.protection.outlook.com (NAM02-BL2-obe.outbound.protection.outlook.com [40.107.75.84]) by groups.io with SMTP; Thu, 19 Sep 2019 12:53:34 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jksQNvfeRRVo3KfY1efzoHgL8P4wSnW2fH3POxPstTyGvCQZR1A4H2lpKXnANkNnZ2GoQps8QvKA0NsS02gz1RhmzTjRlk44BQP2Hxk4ThSQaCAblcyY+tCgSVRr4ndYPRrJAaYwz5Kx5WlLUXRxYkUncwA4z/giGRaXL/GkqKHrvfRgH6pw1tTfS83F6lpu7LLvvzngO3FS1RuqhWofakWVPNajFwOLpTI6MbZmVGHkDo76qRJm2+ua8IqZ5XAzlNnksFSrcZenuCVomqA6zKRYOJJrnaesFouYyF0a6uFbfDCYR7XjIPvOQB6PuUwEqLBwwXOwWLS3fl2R1X9j8g== 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-SenderADCheck; bh=Nsx5zK7VDJQOuE0A1QPRiMXxppl5JOWaxgzvCQaVGBA=; b=NuvKQjxwT+DrfFOPGwyIS3EW4ozb0EfDqxjQpWj7joYNEoQ7h4HAK3cRkzu5aqPvZxLz5uc6oy7JjVOK3Oi2puDVDP46NitrewA3XHPueze9C6mbpGkB4YtGSbYWr/+ooah3tWuvWo3CSD/AoINhBjiRA19Yg2KTyOQslpLMIwGlbKUS3s8BjHdw9Qly8hEs99THwaLiXdjNEEjoXzoJfEuc143mbFKpes5mK3VqPP+xnSUK31jrqJ//9AafGgmox3GN9t6T96tz2GCZ/ZwiUtUuWILHQSqpIz2oFz6J0CKEFGawRNREvmkH2EBhcPai04THTWA5N96k6/iElEoH5w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Nsx5zK7VDJQOuE0A1QPRiMXxppl5JOWaxgzvCQaVGBA=; b=0kGK5pUfhJfZ8l+mWG/jkNmfXUC/CpYnD7J5cilxm9qqHK5YbDA7SrmM9EjdnBn08AZ6Q4sULuNLcZPH06hTomGTBnBZwTnQl5ejPzrj4u/qqSWesPpndhq8E8fykZXW+cEiT0xexJnw1o2FqhE0YDnO1P9iETmfj25wSFL8h3w= Received: from DM6PR12MB3163.namprd12.prod.outlook.com (20.179.104.150) by DM6PR12MB3372.namprd12.prod.outlook.com (20.178.198.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.22; Thu, 19 Sep 2019 19:53:33 +0000 Received: from DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::400e:f0c3:7ca:2fcc]) by DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::400e:f0c3:7ca:2fcc%6]) with mapi id 15.20.2284.009; Thu, 19 Sep 2019 19:53:33 +0000 From: "Lendacky, Thomas" To: "devel@edk2.groups.io" CC: Jordan Justen , Laszlo Ersek , Ard Biesheuvel , Michael D Kinney , Liming Gao , Eric Dong , Ray Ni , "Singh, Brijesh" Subject: [RFC PATCH v2 36/44] UefiCpuPkg: Add a 16-bit protected mode code segment descriptor Thread-Topic: [RFC PATCH v2 36/44] UefiCpuPkg: Add a 16-bit protected mode code segment descriptor Thread-Index: AQHVbyPacosZqZf/p0KaFHkP5//L6g== Date: Thu, 19 Sep 2019 19:53:04 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.17.1 x-clientproxiedby: SN4PR0501CA0146.namprd05.prod.outlook.com (2603:10b6:803:2c::24) To DM6PR12MB3163.namprd12.prod.outlook.com (2603:10b6:5:182::22) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Thomas.Lendacky@amd.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [165.204.78.1] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 9544882e-57b5-492c-4ba8-08d73d3afc65 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600167)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020);SRVR:DM6PR12MB3372; x-ms-traffictypediagnostic: DM6PR12MB3372: x-ms-exchange-purlcount: 1 x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:5797; x-forefront-prvs: 016572D96D x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(4636009)(396003)(39860400002)(376002)(366004)(136003)(346002)(199004)(189003)(386003)(71200400001)(52116002)(14444005)(86362001)(14454004)(256004)(76176011)(99286004)(966005)(66446008)(64756008)(478600001)(66556008)(6666004)(118296001)(66946007)(66476007)(71190400001)(66066001)(5660300002)(6306002)(6512007)(5640700003)(476003)(2616005)(36756003)(11346002)(446003)(8676002)(6506007)(8936002)(1730700003)(81166006)(81156014)(2501003)(26005)(186003)(102836004)(50226002)(54906003)(486006)(6436002)(6486002)(2351001)(316002)(6116002)(3846002)(7736002)(305945005)(25786009)(2906002)(6916009)(4326008);DIR:OUT;SFP:1101;SCL:1;SRVR:DM6PR12MB3372;H:DM6PR12MB3163.namprd12.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: y+0We0PBO3IJpKDK5rfy+WrsZOAYiU+Q6iTvqeYFKA3MVODZHMdLFWWv++tMn20lqAp2fbNzIej5aoEMSUFmM62WC9wo/RAjFrYRP1aOSEtffMNdCnYbRwi6pvXyT/BP4vZ9tS+JL4G52UZVMFWY9oFRqP9dpRmzM41woLe/QxhVBORtNd38IV0NpPiy2BSybX6LGem2i3BTK6nYnZ/jk6ePDl5dLPu32dZFONgxCG9/G8xWqN7rBPmGNW38RRYOb4uzw1UrTBkwENJQXkdJvf+kEgFQdCo1GuwBaGem2BOTCreb696mZFzMiMLx9kZwZv/DeFjObmHuuw5NFDoXgqEjdjb+CD3GSzhcjioMcbJ9hzR1XHJ9dG8ZrRqWFWgYGXFGlOXr2Hc19E2gAJVSn5k6/WkA3M9dniyqbijDuqk= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9544882e-57b5-492c-4ba8-08d73d3afc65 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Sep 2019 19:53:04.9947 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: dne4yFpvqgGjjsDKlLZwm9LtZb6DW2IrDmkFfM6ZX94PG+1BcuYi1hYaXVczfA99y0/HctYpCF5tEGsmN0LzXQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3372 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable From: Tom Lendacky BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2198 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 Cc: Ray Ni Cc: Laszlo Ersek Signed-off-by: Tom Lendacky --- 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 e5c36f37b96a..80e224b47fcd 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 87fd6955f24b..6a80829be884 100644 --- a/UefiCpuPkg/CpuDxe/CpuGdt.c +++ b/UefiCpuPkg/CpuDxe/CpuGdt.c @@ -70,14 +70,14 @@ STATIC GDT_ENTRIES GdtTemplate =3D { 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/UefiCpuP= kg/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 =20 +; 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_LIM= IT(0xf) + DB 0 ; base 31:24 + GDT_END: =20 --=20 2.17.1