From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (NAM12-BN8-obe.outbound.protection.outlook.com [40.107.237.72]) by mx.groups.io with SMTP id smtpd.web11.6703.1596837252245180166 for ; Fri, 07 Aug 2020 14:54:12 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=Gs7sT+db; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.237.72, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oJb9n7diZzNVOd4gEXDnSjZQAo9/L4iBy7sRHCQaXQTZYQGKBRoiXb4DtaAmU+l1l5zENbWXfg4qEK7Rol9Fvw6jzHsX2waxuHrbeRizNx8g+QBMO/1sGVeRmZ1J5WprGxW9W2eS+fArZGt3krCkT5qdMOv6J67CgKHqFsGUecyuzSAvEOeqo9/7lzMr0J15d8HkBOELOOr5zwmS7jWKFWSFSk56YjKtQW9h4keqrjpgYjDwD2A8dDBZ9Fx4aKn4BPJKJARymyDUc5XwHxfd2LUWp8rdIhRlSXiep44ghC1r+79wW2CeA+Je5x9iDEf1n7k2pXf6hRGqT4aePvLyiw== 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=y42cNfhmfyz07xseYeQYH9zbpfMlzMLWf83yCfosPcg=; b=fVZmLk39gw/pZNg6DUxksn6Y3SQh7K5p0GMCLygLiAqrQgGue5VSOs2STiT+BOn1foWvHhXFaCkYLzJGoOHAFKGvCIY6Hi1lqsgwsDll1JHbb5qU0xSE6InI3xrXbwMXNEkYEEFXLxu08pfq0E6o+VrfkmWawwOGjBaxkUNmCZyB1XDW373y51rYRTBgDK3dreEiYs0rg/4nA5hDCeGTtbdhhYjZtra7XJJJHzFO6aTZgnV+fplx/MdBcD35CoTZK4ECDWa0Fjtzp88lDWVsEXcssBcUSy8ZU2S06e07O/XZDfIfQL/VYkV5uRFEFaFs3i5gMk17lRjC0z7Cp0GAOA== 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=y42cNfhmfyz07xseYeQYH9zbpfMlzMLWf83yCfosPcg=; b=Gs7sT+dbDpFgRIYV8QcxToNQl1LtGZRMZ76BzZtoe5K2Bb4LvV1dZmOaofSQYjBjk0HZ9NP8FCwEM28rEey8fLiDG6sxMSEeEgrTbvIDFdDOnEigdR49clcrBKm+M/TsBaL2PUiPiVPCgahiWOIEtK88o8SeFHi8PPGK8MJqzuE= Authentication-Results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=amd.com; Received: from CY4PR12MB1352.namprd12.prod.outlook.com (2603:10b6:903:3a::13) by CY4PR12MB1222.namprd12.prod.outlook.com (2603:10b6:903:3b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.18; Fri, 7 Aug 2020 21:54:10 +0000 Received: from CY4PR12MB1352.namprd12.prod.outlook.com ([fe80::9181:78bf:bf0:702b]) by CY4PR12MB1352.namprd12.prod.outlook.com ([fe80::9181:78bf:bf0:702b%5]) with mapi id 15.20.3239.024; Fri, 7 Aug 2020 21:54:10 +0000 From: "Lendacky, Thomas" To: devel@edk2.groups.io Subject: [PATCH v14 40/46] UefiCpuPkg: Add a 16-bit protected mode code segment descriptor Date: Fri, 7 Aug 2020 16:53:53 -0500 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-ClientProxiedBy: DM6PR07CA0038.namprd07.prod.outlook.com (2603:10b6:5:74::15) To CY4PR12MB1352.namprd12.prod.outlook.com (2603:10b6:903:3a::13) Return-Path: thomas.lendacky@amd.com MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from tlendack-t1.amd.com (165.204.77.1) by DM6PR07CA0038.namprd07.prod.outlook.com (2603:10b6:5:74::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.15 via Frontend Transport; Fri, 7 Aug 2020 21:54:09 +0000 X-Mailer: git-send-email 2.27.0 X-Originating-IP: [165.204.77.1] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: bc1b4461-1182-47d4-a924-08d83b1c6a19 X-MS-TrafficTypeDiagnostic: CY4PR12MB1222: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: p6rAzdcWCcQ5AgDg7wrUP3ri+FxoapwV0vyvjJQ2GiqD1XUAjEs763h8KRrL0Kg2tmrvIeeC2zh7WPpHoj1WE1cjf1+T29EOWxNz8xoCrJAjEc5rhSmhpv5oVXucB9dz5tRky8THqatrjpiahVMrQZObzBO/NWsfE/X9KG/nG6HI1Mv3ZqciHMFZk5F/Xbcb7eCS0VNoXgpFloPvvcbwnAFOO6Hk8g5eLI/Hs8++TjvsZ3HXdVEAzsCiDzV9GdLrmjZjGUUe3Z9bdmXUTa2fxa3B2vPiCCrwHVwybaykVd6PJ/EkYY3FEOUydTKZwaiEOLXDntpmEkXFuymxQShAgDcpCeUoSO23JFQdGUkXM/TQHrC5WiZL0v58iSt24RdYvTzXpaEOGky+HndqfgyPrTZfMS5ob37QuzS2iZwma9WeydwKMH/+63F/v/z7nIbY3X+c+ghnaalYwcSLafrWiw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY4PR12MB1352.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(39860400002)(396003)(346002)(366004)(136003)(376002)(83380400001)(52116002)(966005)(8936002)(7696005)(66476007)(36756003)(478600001)(66946007)(2906002)(66556008)(316002)(8676002)(956004)(2616005)(6916009)(6666004)(86362001)(5660300002)(186003)(6486002)(16526019)(26005)(136400200001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 4sDT1zO6PstobNjLHA6pbQQAcdADXk0ULAoauR2XaIpzbWWzI6zRX6LeChETVtalFdDsbJ0/OGD7W9EKBGXN9mAN2AWNmqp02YgL7fceye+NY7VwXkbaj6pwz5jlMhNCRD2duhn0G2HnlHv7kZLNkYo9VoSOqHs3a+380GkaRXf3hLEs4bOyCnVkz0QzWFm+UG/fb1ru9BM5VnNIZ0oV2iMpThFrf4EU+YDJL58FDZulR2e3x+t0B9finX5cBGOtK+uFFg5ndsJEQRUtZtkJ7tq54EABgLe+/LTVcHHTVClre8N2qnHymRG8wnJ8vw7CasaM7dIesK8msxz28o1jF5J9ooCdX9jW09OncpbxOaRI/80xRM2Em5bVYh3utMW+dTYA9/OrzSgAyCm0LcXKM+ktXGB8Hf65r3D74KqUgZxM5uwjjNBF/CITovGUDQuMCRZg6xSQzPEzuLL4zpy0gS0QTxwoR+wuI0PlbE9zlQOFoXsJsUI6YRdhzd2o0s7jgOG3nuC/90lj3Z1vmU1rFD4HG2aqy/xjLSPPIu8uYAep46q/UsE4yipBEVNzqtJVxwCaJ1Wx4rhKPjcA2bHTvn0SGW3kd+u+lYH4VWytu16/CBlcUvzT28AuTFcwWUP0sgURRAKo6P76Wh0PZ6txsQ== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: bc1b4461-1182-47d4-a924-08d83b1c6a19 X-MS-Exchange-CrossTenant-AuthSource: CY4PR12MB1352.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2020 21:54:10.0143 (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: YB2QsWGq9aqqwdVbUXFOKpm1/8yKPSBZd5AE0AiA8Yqn8HD/SQyNRW3yj8tyoAakPlH6xsQCQGZcXZrOm7UiZg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1222 Content-Type: text/plain; charset="us-ascii" 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 Reviewed-by: Eric Dong 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 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 =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.27.0