From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (NAM02-DM3-obe.outbound.protection.outlook.com [40.107.95.40]) by mx.groups.io with SMTP id smtpd.web08.11838.1645455578254898199 for ; Mon, 21 Feb 2022 06:59:38 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amd.com header.s=selector1 header.b=1BckWjGJ; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: 40.107.95.40, mailfrom: brijesh.singh@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WUCsw93xDtB0ku38QUoQE3CwjDHpijlLCnnhh/g/nZ+JkIODh6EISewHWrgHg14wmM76blFeONxrL+RST/TgItkrUl67Qo5nvoadw4e6Zqg6h9U9KRJRNEBhFzLTZ+wW3agKIchlBP023PhGQXqV+oDCgz0Jh8ZrhpSFPLzPewRLM6V4hO+fvCvumvF8EoYvAbibp+Fw1in5ZdkpRKaSqR6/OICVpg7pd1ICefye21Z4YrQ1Vo2AkqWntfZNzubr2n1/W7I+NmcH2lNraUQPvzeHc/+4XkS/CXF0OCEAG+l9Hh8efu3iOMFbk6iOSMSaQEsmi89K93K8EJWopTBvKw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7nL/wTebHe4z+JvJcbKTaQmAkOzJj2fR/4TAQHVXCew=; b=fKCKk32xt2jGhI43KGHwUxz2OG0+CU4vuW7OcyjWAbexqjjuLUkUT7Qswt/KT4DMGOeqO42+A0Nsji2MndzcsIrrdWuqZd7xin+M5Yn72GmBNp4zlIzhoHBZktIKdDqdDpJ+kvemQSqI3Tut2sUgbTGiRfMJazT/8OBngj1zESQEDAc7ieUanzrfCEzg1doq/69DDKNuSqvUoML5ZFgTxQDo2Y0nY4MR/0W1CQt7YKi26K8oMZxNXgTYK+Rabp/ldWIb7yXZCEeaFCWrg0XBuKXWT02wjb65ZjcaD2WrdO355iTWUrr672WVrFSKg9I2iIYdZtLxvQR3G80OK7lZpQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7nL/wTebHe4z+JvJcbKTaQmAkOzJj2fR/4TAQHVXCew=; b=1BckWjGJ1FCyB7AI87gvx00hfh2YgXAsaE+RV9FMzLMG0vDEAy5TMqubFukB4Rg0YGxIVrp7pCmIUzgS7plaBCLwVUXKFU0QeaUqTKx01wg6xM0xLw0k4XuCG6/UoZG09xezUcY0Mb2jL5/YU0I3d+QzsxrjAadNh2vWLZeIla8= Received: from DM5PR21CA0026.namprd21.prod.outlook.com (2603:10b6:3:ed::12) by CH2PR12MB3944.namprd12.prod.outlook.com (2603:10b6:610:21::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.25; Mon, 21 Feb 2022 14:59:36 +0000 Received: from DM6NAM11FT059.eop-nam11.prod.protection.outlook.com (2603:10b6:3:ed:cafe::b5) by DM5PR21CA0026.outlook.office365.com (2603:10b6:3:ed::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.6 via Frontend Transport; Mon, 21 Feb 2022 14:59:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT059.mail.protection.outlook.com (10.13.172.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4995.15 via Frontend Transport; Mon, 21 Feb 2022 14:59:35 +0000 Received: from sbrijesh-desktop.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Mon, 21 Feb 2022 08:59:34 -0600 From: "Brijesh Singh" To: CC: James Bottomley , Min Xu , "Jiewen Yao" , Tom Lendacky , "Jordan Justen" , Ard Biesheuvel , Erdem Aktas , "Michael Roth" , Gerd Hoffmann , , Brijesh Singh Subject: [PATCH v2 0/2] SEV BaseMemEncryptLib cleanup Date: Mon, 21 Feb 2022 08:59:12 -0600 Message-ID: <20220221145914.1972322-1-brijesh.singh@amd.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Return-Path: brijesh.singh@amd.com X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b12d1f5b-e905-4b06-af61-08d9f54ac6a2 X-MS-TrafficTypeDiagnostic: CH2PR12MB3944:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ahgb9nvy6I1HSpinYede1ZMt+Mhbn59A11Mihjx4ZaNkj7FkNNBvUEMo3Ds3hHGZrkc6GcN9HkqF9mXmig6t44KOrWAeNmcR3eNaXE81iAs1oP4jhZIjGwdtOsojB3RkDJwEIuG1eEWcuSA59qgTI2tbdGoSikLD9fWDW8RY/p5YT4vQ2pmUOAMLh1s1wN4uO5ilCeENadAPYgG5SkQRKoWhMWiwxVepaeYZ7haP4XUjyR0XlP2q6v0A2sya/Yt1IFk2A/febmVKe/7OnCiBYVyufGCOumFYwYKTpSDdIMbG12p8hhcdme0Hxr99DZ/JKfyhiyy9L31Y3Agpt4b+xKjZlLClvhAiWlqxAr/Kq4Yx1OIxvUtl2KKrW1ZH0kphAZfNMbRffoonIjq8uilIOvbLv7QPvVFwat8ASmIvreWpk71LhJ+AZgBDSExuK1JYvRFD+RegHGfB+KTQF1sd36oQq1BN/bRPuapuLgB4pE99dz2vL+NhOlKHGO+ecHUVMLz70PZybLobuZlrCc7DzHF/3r4XUre2pYBPT/UUNhv+n56dpFxsah0PcxGE5+/w/6aZVph2Z5vnIk498iA7IYdiiBMu+eX/RklwG0sMDz6ds+I9bd++VLGKMZmxUfX6XryeMjCOviQsCKQJSeRIIz8XX8hc1mr0OjEHtmvOCzNXBTk1GziYBpWkdcTj846X7Gz9eL04+myFIMuzJ8zMV/WRFkm1cXmDKClZGdj1RUACZ7OpXZRiqQm9QWiXvW5qhI8BFta3xQjCMcyos0HHG8izavtdRHEYyUFRHMFFr0Q= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(46966006)(36840700001)(26005)(426003)(336012)(86362001)(2616005)(316002)(81166007)(16526019)(19627235002)(356005)(54906003)(186003)(6916009)(70586007)(70206006)(1076003)(4326008)(8676002)(36756003)(966005)(47076005)(6666004)(8936002)(82310400004)(2906002)(40460700003)(36860700001)(5660300002)(508600001)(44832011)(7696005)(83380400001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Feb 2022 14:59:35.7633 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b12d1f5b-e905-4b06-af61-08d9f54ac6a2 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT059.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB3944 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain This is the first of cleanup for SEV MemEncryptLib. The library uses the CPUID followed by the MSR read to determine whether SEV is enabled. Now that we have a workarea concept, the logic can be simplified to store the msr status in workarea and use that to build PCDs and then later simply use the PCDs instead of going through the CPUID and RDMSR. The complete branch is available at https://github.com/codomania/edk2/tree/sev-workarea-cleanup The series also fixes one of the issue raised in the bug https://bugzilla.tianocore.org/show_bug.cgi?id=3D3582 Changes since v1: * Cache the PCD reads so that we can avoid reading PCD while performing th= e virtual pointer conversion. Brijesh Singh (2): OvmfPkg/ResetVector: cache the SEV status MSR value in workarea OvmfPkg/BaseMemEncryptLib: use the SEV_STATUS MSR value from workarea .../DxeMemEncryptSevLib.inf | 1 + .../PeiMemEncryptSevLib.inf | 1 + .../SecMemEncryptSevLib.inf | 1 + OvmfPkg/Include/WorkArea.h | 12 +- .../DxeMemEncryptSevLibInternal.c | 145 ++++++++---------- .../PeiMemEncryptSevLibInternal.c | 139 ++++++----------- .../SecMemEncryptSevLibInternal.c | 80 +++++----- OvmfPkg/Sec/AmdSev.c | 2 +- OvmfPkg/ResetVector/Ia32/AmdSev.asm | 38 +++-- OvmfPkg/ResetVector/Ia32/Flat32ToFlat64.asm | 3 +- OvmfPkg/ResetVector/ResetVector.nasmb | 3 + 11 files changed, 194 insertions(+), 231 deletions(-) --=20 2.25.1