From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (NAM12-DM6-obe.outbound.protection.outlook.com [40.107.243.63]) by mx.groups.io with SMTP id smtpd.web10.1396.1589993812542578844 for ; Wed, 20 May 2020 09:56:52 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=cBaew9Ht; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.243.63, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k/in9DBUigYCeM/Xyrmjz5omJpDIjwPlD4Hu7ao+IDMFs/sY96f8lKBhSJ/ay+IlSWONEBoVeb6WR2764PKzEzKPMK29wEcyAV2PC/Klu/xKu2xywD1+2NHmlFtRnxUi2SSUVKweSr9teOwPxXiRK4ubfmyWNSRqorHSvMqQyt/6G84oBelkVcNF13gBA/hle/f40Pt9zCmzcWsFY5Filfud3GRNho2GG0si/KpNRQep2f57Js3+S8CUfIs0SE2LEDaeGwVhN9Ew86j+0dZNB/LnW9RDHoaM9z/J4PUobSlf9fUk79wb6CQf6FxH/tHkHgVnWnGvJXAApzd1Bpthug== 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=IyLG5XGXB6Vh8XrUAvUEIHH+ig+dVXn/M25ISeHVbJ3MKN3znbVCLPIHZfjoH8hIii6niZawG3ONUD/Bl/jEyhVSE0m+8DYMoICbxUf/fYqF3dVFd4zg45D5bIeFoP1SKOQoLSepmZETrD070J1nR/WX4vewF6RuLDL18VN/PKE5fFDngatu0YVMy3JIDu4ck1A6keM8jAA1Q5p7fkSS/rTGeMdKGb1XLHAymCm0WElWj5eX9sy8lTckcEW8LIQ1pVkNvHpAJMGRIq3IzLToWeNuO2Du7z1klQJLVIUVqL+9Ju/n/Z5EUF6hUBiicaGkqQamhaMV0XzgcY+ERmAeLQ== 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=cBaew9Ht9oW4e8XI5SIdiNb7cDN49F6sR/sseg7jT8tVQ4te08BAmn+DQ6UCAD0kGOtfQGXgqlGpzUTDxuxWbULiKJ5a8fJe4AkANQaA9AWJbRXlKMQdqbayutZMuiyd+aX4jsfBxzTT1EkGCBaV91ZQ8kXT5AVlRsDE4zgulXs= 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 DM5PR12MB1355.namprd12.prod.outlook.com (2603:10b6:3:6e::7) by DM5PR12MB1243.namprd12.prod.outlook.com (2603:10b6:3:74::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.25; Wed, 20 May 2020 16:56:50 +0000 Received: from DM5PR12MB1355.namprd12.prod.outlook.com ([fe80::4ce1:9947:9681:c8b1]) by DM5PR12MB1355.namprd12.prod.outlook.com ([fe80::4ce1:9947:9681:c8b1%10]) with mapi id 15.20.3000.034; Wed, 20 May 2020 16:56:50 +0000 From: "Lendacky, Thomas" To: devel@edk2.groups.io Subject: [PATCH v8 40/46] UefiCpuPkg: Add a 16-bit protected mode code segment descriptor Date: Wed, 20 May 2020 11:56:33 -0500 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: DM6PR08CA0026.namprd08.prod.outlook.com (2603:10b6:5:80::39) To DM5PR12MB1355.namprd12.prod.outlook.com (2603:10b6:3:6e::7) 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 DM6PR08CA0026.namprd08.prod.outlook.com (2603:10b6:5:80::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.23 via Frontend Transport; Wed, 20 May 2020 16:56:50 +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: 6bf64227-f9c3-453c-9c72-08d7fcdeca4a X-MS-TrafficTypeDiagnostic: DM5PR12MB1243: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-Forefront-PRVS: 04097B7F7F X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: a2SKRvW+MZ9uIJwLjmNe7LgwuSUaIiusaCKdOSjJO1Ano6iRBsQxvQiHz/2fhPbtlryi8E1SVC58JIWvrVusWXAImyfguw2dj78epPbV83DfrwTxVqZ4XKCIw7sTXKyQle49e3grDVyRtkkPEd+PFj4iSGTJFSl1/mP7PC2Gn1yrnb9+Q4o+QqBHlQoM5nqj4CRGbmCwzdmVQ6obX3cDCrChwsOziE5MPyBGhjgbMVFKEgy2T6REZBMsVwRlT0F84MOaKJ5BWcWi2O2kfeAZcF79oWnlDXJaooAxNMIw2zNjLZOKYvPd08Q0psW1M/btSUj0gOVmyBjOl9UWmFcigMd6GktTLf8eR+WpzS9RwJdshASkd6ZmB1EYclW2EeX/6A3KY/N4IZB+fbtd9fGUN+duKf/bINZ0BMsbs53VB7F0EpOsGo5YERSqQWJcxHbbKkt083VVBSuBIL1yrEHFWwEwuf+n6CtaEAzErXoYls26Hg9d3M/c+3ZTFNIn9AIv5eoM5hdQytentM9QtDUfrwvYbdP5ea9YDVM6vfskE9aZfly82Hv2RgaWVKTlUHEYteo76x9+ovJpcSXyjsKUYg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR12MB1355.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(39860400002)(136003)(396003)(366004)(376002)(346002)(7696005)(52116002)(6666004)(316002)(966005)(26005)(478600001)(36756003)(8676002)(2906002)(186003)(8936002)(16526019)(5660300002)(6486002)(2616005)(66476007)(66556008)(66946007)(86362001)(956004)(6916009)(136400200001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: y2ZdOUj7BZ9WHWrrcgdYqvScCoGElCy0wtPGI1JtJahPDV9wGb3+Ng9IFGFi+JwPJCWc44mwUr+2B/i1SUKqtbF1V6yClPE8lQC6Yhz305Obwl/M/fwvYFNwfsPcVBc9cvjwA1Ok7ZabvechsyUKPxDgBWKGdRlJ25jB6hCTfHle+/XHnvN1F5EnM8jSKHNe7bTEpTMqQeZ2jiMS99RRIynRrh4RcK9tagniV6TzgvF1qafsRAZN22DOgc+7iJHxaoFOqicfABLBJLqCN2UsnuhxQlabMRh26XaEEAhMjv7wlVGxH8hyJ1UBOOH/um9Skxej8vj4YoyoUSTya2K6Ac5w5Oq6lSPvxYCEsL+xpjVKmnwDsV7MrtDTfv92t0aUyR9m4jOcKUyTSGcoPVR7DOjEQBc7kg4hN/eCNMifqnb8xw4NBZHbsVoUCkdmdBFPvQdX6BbGyrMdR7+S9UcxqyQI5+oS6FjviiJPSc/NXVc= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6bf64227-f9c3-453c-9c72-08d7fcdeca4a X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2020 16:56:50.5190 (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: Yaxl41bw5cIBNzxK0yLTGSJb/s9V37hCCzRhMrWfl7EhcMgqtEj4c+sObV4abSAGVS2l/xewWNlolQXRTpte7w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1243 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