From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (NAM11-BN8-obe.outbound.protection.outlook.com []) by mx.groups.io with SMTP id smtpd.web12.504.1587577397852627360 for ; Wed, 22 Apr 2020 10:43:22 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=LQGv93ux; spf=none, err=SPF record not found (domain: amd.com, ip: , mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gV2zH4X3fHdscBvd1W/jPhGN1wDAAjifdyknWyxyqh0LO7ps3eWBAnrkGtnRN6+B9L93gJqlmyJg4JifkgOWD53y76oRU5HIzGgvc4vNaJdzMVRvrISFPcLJtmOwKqINhGfce9/bpfY616cJ2hbobJWw9WWG3Cal+zmWs+UCDlgFOkdOnjxW9q8LlxixjD8yQ4H9uP9c/ZwxL3Fk1F1AfIVjCFLfk4y/tzNR9s8NrdajoKR5wuVbTFXL1Rfsx+FrxalAVpZj705JYbng4ozryInv05ryxfPb/JET/iBGKteiLOknNzCZSLyRtYMYC1sJXOO5AOYdxvyuxM5eDQVveQ== 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=BCXW0VlBNxFKe7TLdmP2duy+TVugjwUt5Ezd1A2+LX4=; b=WzHlSBIvns1zzQdfXyJ/gck5M2XKvtZ8p3364Jb0qu0AHAZlS3dxZVcVtML7q9OHvj03GLdyq7S4a+t8E1MMe8rwOkNY5EuSwqAQsvXCEnWN2inzCeXicK03CfN3sDTfIrAZnYbWtaJpy7Tp9GB1p0ZgR98jyH5s3/+jPhxlmYI6iK0YCMg46u1pcD7SZcmwKPCobh+Y7xDsBVF4p2RBeLs/2/Z0c87w4V2m7BrICnX3B0GAqsV+lquQcW8u6kgKB7+Yd6x8oxOZp0OnsMxPZRfOjD18PDNhTGjQwxEMi2chUHKxw+n4FhrshABoEaztp+MQzocqmoihrMyYCPGTBA== 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=BCXW0VlBNxFKe7TLdmP2duy+TVugjwUt5Ezd1A2+LX4=; b=LQGv93uxIM5WRTvAfjaCnjSGO2iDyWhH12OjLlumjN0HFmeJtF+RqGaFjGW3uhDkyolN/TD2/ctUnYrmqnIbppsn2hBMeDKhHZEh9q9ScsRtelKae0aL0gf7bDhEgh3DfO7vsG8IdqpVHTP6OXfe/OZJSkAXdyk4c2B6GAH0o/Q= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Thomas.Lendacky@amd.com; Received: from DM6PR12MB3163.namprd12.prod.outlook.com (2603:10b6:5:15e::26) by DM6PR12MB3673.namprd12.prod.outlook.com (2603:10b6:5:1c5::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2921.29; Wed, 22 Apr 2020 17:43:19 +0000 Received: from DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::9ae:cb95:c925:d5bf]) by DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::9ae:cb95:c925:d5bf%4]) with mapi id 15.20.2921.030; Wed, 22 Apr 2020 17:43:19 +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 , Brijesh Singh Subject: [PATCH v7 38/43] UefiCpuPkg: Add a 16-bit protected mode code segment descriptor Date: Wed, 22 Apr 2020 12:41:53 -0500 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: DM5PR04CA0060.namprd04.prod.outlook.com (2603:10b6:3:ef::22) To DM6PR12MB3163.namprd12.prod.outlook.com (2603:10b6:5:15e::26) 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 DM5PR04CA0060.namprd04.prod.outlook.com (2603:10b6:3:ef::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2937.13 via Frontend Transport; Wed, 22 Apr 2020 17:42:52 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [165.204.77.1] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: dc3b87d2-6292-4a39-300e-08d7e6e4957b X-MS-TrafficTypeDiagnostic: DM6PR12MB3673:|DM6PR12MB3673: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-Forefront-PRVS: 03818C953D X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB3163.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(10009020)(4636009)(346002)(136003)(396003)(366004)(39860400002)(376002)(16526019)(186003)(8936002)(8676002)(956004)(4326008)(316002)(6916009)(86362001)(2616005)(36756003)(26005)(52116002)(7696005)(5660300002)(2906002)(478600001)(81156014)(966005)(66556008)(66946007)(66476007)(6486002)(54906003)(136400200001);DIR:OUT;SFP:1101; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 38VsS3XoiX7aiWZSv49juVNTm/+UwwKdyxNXmBnOR4JEvjIaN4dZ4kTcBhdE2OOKAGPEfdM8TbcvvxoHAZQaqxOocOjjSTNeliauEKFKYTLJykVBeem0fa2GBmfBm1Mzxie7u2TRNTVnxvyUev7nDc8JdOKKO1CAz+bf+inWXrAux9Buy7DuqbMchq9Xq/g6HXu3CoKO8U3XBPyaXNAjt9F1K/R3CmjFIFy2uK57JmAHrPf9ZdvwVGjerACpTjqGamN794crf9CXveY6YDyikWDhJR3sH/MkGiMp4wW4uOq7ibegugePHCD8+9senFo1cZI2lkhiAyBnG4tXrvS/KUd28mqnLe4WIXbMspCbqsIZ7u9NVjhSnkQJNxSbl/BepqNPAM6td7+8Z7LuhLejsEO9TXgkkr8LJX+RqQGGdsuQ16jAH3EZsybb6PDr36QSIl3trXwGytiWcNPenrky7WGs5L7ST0HDd0/ifsak86Di3FhHeRoJ4/ZqZXgLIvkwTQcP9tTJrns5NeZxBuavE01aG0xNo6MeQKohT6F7r7GqWzD7xgX5UnzXzQrCcCgaui1g4DxSOGmPgDIOY2cM5w== X-MS-Exchange-AntiSpam-MessageData: X6N6GtwBn3A5MOYtHfwc/Y1QoJ+sYOV1oYQC6if4BbTrRqrHl++R5O6DcZM5aLgBFbgwFjap1XMJ1WoNs9AystpZ8PRm2uFIGmwPT+Ub1TmfLY57KePSN4R/E5zjFIpk7rPzHx/bQ0QxBKkqf/GobA== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: dc3b87d2-6292-4a39-300e-08d7e6e4957b X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2020 17:42:53.2644 (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: 2caljcSa7JCtVcd3O1U4xH+CfKIgkoD3tdFt6MW4VN0o2OiAy1g1eeekb0OXzEQwJUVRNRuhtzD69y28DS+LCQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3673 Content-Type: text/plain 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 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 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_LIMIT(0xf) + DB 0 ; base 31:24 + GDT_END: -- 2.17.1