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 [40.107.236.41]) by mx.groups.io with SMTP id smtpd.web10.1352.1632163583824013575 for ; Mon, 20 Sep 2021 11:46:24 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amd.com header.s=selector1 header.b=AKvEuz4o; 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.236.41, mailfrom: brijesh.singh@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mMdgVTnY67WR4PQnMUrNIZxLGK9e9BKaCg89GjweLtniBdoNtRepfjh5bD99lW8mOWMdoWuyHp7Oji1riFGjjw/hj0m/2xPn9mWJRfPy0/MPCxfH8aQagflVuMkKgTl9ubhROmFnM5a6UfbOv915xYr8rGFEb2i12asfkuYevX6CQHD3N+0izyKnaKBRBd7jh8WjBEJSOFVjU5WgHHJ7NwWVNwbnXgJY/sZQ6AuUpdNd/FtZVUP/ppPyUrcB/KkUcODGqUPzrrmKPy3AeHc3krsCq5jeUveRmk1IhnaOII4jPqXJ1/kLwaB+xHHnF/88c98o2vvecHa10j3tHXzn5Q== 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; bh=AINumP86uSNPlYoT8Fq5kGXANP8TRYHU1Ca47I3OecI=; b=DDUM1AToJRACOy1VR0hAhd5JeDkVZN7g8pm8J+b6JmM13CQyjYjdCGnr3snqQUgKDPhSEsjybiOW2gYgAuGtRvvtL8mTGET1bHBVlas509NndMXHA2NnZ0JPwLCmcuqq0uerYh9lD0js9NNMHiTUFQQUTPZJ5McL23kVQ6OMXupwUlIXh3Cbs/41qtzQTzzxIoYfT7deri3VFFbdc+gcTE5cCXezNDjHxYv4Lx4SuluKYtCsx7nctxquPcxZCCRcNovhSlf/1+950BacOOimD1ADI7rUE16R12BUrYYmg5Z11/aE8LiG9dcQQz0mcznB/6t4W0MlmqWJdW7kYGuQZw== 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=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AINumP86uSNPlYoT8Fq5kGXANP8TRYHU1Ca47I3OecI=; b=AKvEuz4ov+S+M1khRurDbLN1M9tpmNu6Qee9Wdp51yNXCV8dyVoentndRgZSIZ6WFY4421lk7gr7AMW12QfTkDgWCnxMRVhVgaLe8RwTXD2Q49AVJqnhJ5HKDNN0RDMnvtZd7Lj1uN/nx4bvCh1i2yMMlquqt5HrUBSChiWr8oU= 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 SN6PR12MB2718.namprd12.prod.outlook.com (2603:10b6:805:6f::22) by SA0PR12MB4512.namprd12.prod.outlook.com (2603:10b6:806:71::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Mon, 20 Sep 2021 18:46:21 +0000 Received: from SN6PR12MB2718.namprd12.prod.outlook.com ([fe80::78b7:7336:d363:9be3]) by SN6PR12MB2718.namprd12.prod.outlook.com ([fe80::78b7:7336:d363:9be3%6]) with mapi id 15.20.4523.018; Mon, 20 Sep 2021 18:46:21 +0000 From: "Brijesh Singh" To: devel@edk2.groups.io CC: James Bottomley , Min Xu , Jiewen Yao , Tom Lendacky , Jordan Justen , Ard Biesheuvel , Erdem Aktas , Michael Roth , Gerd Hoffmann , Brijesh Singh , Michael Roth Subject: [PATCH v8 03/32] OvmfPkg/ResetVector: move clearing GHCB in SecMain Date: Mon, 20 Sep 2021 13:45:35 -0500 Message-ID: <20210920184604.31590-4-brijesh.singh@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210920184604.31590-1-brijesh.singh@amd.com> References: <20210920184604.31590-1-brijesh.singh@amd.com> X-ClientProxiedBy: SN4PR0201CA0034.namprd02.prod.outlook.com (2603:10b6:803:2e::20) To SN6PR12MB2718.namprd12.prod.outlook.com (2603:10b6:805:6f::22) Return-Path: brijesh.singh@amd.com MIME-Version: 1.0 Received: from sbrijesh-desktop.amd.com (165.204.77.1) by SN4PR0201CA0034.namprd02.prod.outlook.com (2603:10b6:803:2e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Mon, 20 Sep 2021 18:46:20 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 415f924f-e9b1-446e-6fa3-08d97c66f06f X-MS-TrafficTypeDiagnostic: SA0PR12MB4512: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VKFLydxpWe65372IKAxgdjW44cIo7GVnezFakhvCyW8EIyl5JskY64SLTR8Vm1bHoopU48MBE21+J1BVOKxJ/Lh9u9sIJfnPCwsBTyO8JqZyPvuNeybiW59j4PM5GHU23CZG+mLcGDx7PuOa2LeFwLcP+Pr/wVrJh+vqVJ8ghqKD5+Hhyt+q0mEwzEgMfiEiLOb6fbL8amRsx8xqHQzcNs6YrQLAxL0SWZ2iDoQnyEyWzvc1UlHmkDsOu/ikmbxIjyC30N3PG8U6ZBGEPZXszFfTnCKCSi+lZKSzRhqIDjgmWtmtxrlXQC47eS+gIx1n2CMjj+ZnYiU7tqATcMRDJfnNht84Zr9+P5dog7uFPgXaWjyt4rbXNP6cUKTFSvzGWW+B28xW5EG60Ptco3uUPwblSy09XkTLSF062SMHGSuTS5aK2LjaVgQyofUD5Qw9qsSMF70JPpGHXEraNShtBAFk4xN80OYOfFM+KaoBOdy8fzwIJn8g/w+MoSEUJkaqmbUCAZSl0ZEN3Q/2z9bq8jZj59J6httelassnngAhs3avEzMqK4N5vLzUsY7FKGPRdVZedJgArwrueeoHrSguQrHemIAoth5s9h80AzB+pe/mRus9rtdqjLChoBit2o/IsxpSH3mgxvuanWNGieWJGNKv5vjU/cyYsHUp7kk1H38GdEBjpKtq2m8TgNpeIGCGTIMeI0mAXLT4Pmreqy55gh7lfvROBCvZzZ/vbAxMER7d4xIXyq9oQ6bWKXBvGAj2fhNeF7/urGSkEBDURofRhJCxU6KmlmTc3viqp4ftq8= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR12MB2718.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(136003)(376002)(346002)(39860400002)(396003)(19627235002)(316002)(26005)(6666004)(2616005)(83380400001)(38350700002)(6916009)(86362001)(66556008)(7696005)(1076003)(956004)(966005)(2906002)(36756003)(5660300002)(54906003)(4326008)(6486002)(66476007)(8676002)(38100700002)(52116002)(8936002)(66946007)(44832011)(478600001)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?IwDWM1OlrN/bWQN7ubgLNpYQcjPvimZSjV5/an6qGGydwk13/jMMfKGjhMS9?= =?us-ascii?Q?WtAWAlJyuPVxD8ZWrWzBkNcg2nYy/YNV2XVPZ1rcozRbo8wJe0vvbtXZKnq7?= =?us-ascii?Q?JLdyHNTblGdNeswVqqH2+2mb/MjKFAbc+VE5ddgtXfC5XaniDjwEp18RaP6W?= =?us-ascii?Q?91ZBDutyE7Ezb7Pdo53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?= =?us-ascii?Q?xKYpNoCWfWg7kLG8E35JT7D7RszrrqkxfZIu8DcvTreJon4eo0modd53xXb+?= =?us-ascii?Q?9R+wHbtCPpunJ9e2DXn3b4S1yjLBLoyZqcC/jKCkm2QEoERyu1SgiShn0p7p?= =?us-ascii?Q?xnIMjg6qLg26l4aGtANg9SDt36BYMP3NOv6OraWScnTpact24Bda3m9YtE7o?= =?us-ascii?Q?dD7+NLVp2vgL19kVj7UxHLAGznpq2eIBX106VfAI8zJSOmJuOwQu6bsy4uBd?= =?us-ascii?Q?4miL+45i2rGwbZoodhfcejfV?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 415f924f-e9b1-446e-6fa3-08d97c66f06f X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB2718.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Sep 2021 18:46:21.3368 (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: N0ReZ4nEwsj9NAsJD2Ky3DeZdvFtIsR2OeS5bD8sPtikHJrIkvNPBNK3WcR2Qcz5tGu+uxOGVorqO5OdrBbDnw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4512 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3275 In preparation for SEV-SNP support move clearing of the GHCB memory from the ResetVector/AmdSev.asm to SecMain/AmdSev.c. The GHCB page is not accessed until SevEsProtocolCheck() switch to full GHCB. So, the move does not make any changes in the code flow or logic. The move will simplify the SEV-SNP support. Cc: Michael Roth Cc: James Bottomley Cc: Min Xu Cc: Jiewen Yao Cc: Tom Lendacky Cc: Jordan Justen Cc: Ard Biesheuvel Cc: Erdem Aktas Cc: Gerd Hoffmann Signed-off-by: Brijesh Singh --- OvmfPkg/Sec/AmdSev.c | 2 +- OvmfPkg/ResetVector/Ia32/AmdSev.asm | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/OvmfPkg/Sec/AmdSev.c b/OvmfPkg/Sec/AmdSev.c index 3b4adaae32c7..7f74e8bfe88e 100644 --- a/OvmfPkg/Sec/AmdSev.c +++ b/OvmfPkg/Sec/AmdSev.c @@ -95,7 +95,7 @@ SevEsProtocolCheck ( AsmWriteMsr64 (MSR_SEV_ES_GHCB, Msr.GhcbPhysicalAddress); =20 Ghcb =3D Msr.Ghcb; - SetMem (Ghcb, sizeof (*Ghcb), 0); + SetMem (Ghcb, FixedPcdGet32 (PcdOvmfSecGhcbSize), 0); =20 // // Set the version to the maximum that can be supported diff --git a/OvmfPkg/ResetVector/Ia32/AmdSev.asm b/OvmfPkg/ResetVector/Ia32= /AmdSev.asm index 250ac8d8b180..48d9178168b0 100644 --- a/OvmfPkg/ResetVector/Ia32/AmdSev.asm +++ b/OvmfPkg/ResetVector/Ia32/AmdSev.asm @@ -177,12 +177,6 @@ pageTableEntries4kLoop: mov ecx, (GHCB_BASE & 0x1F_FFFF) >> 12 mov [ecx * 8 + GHCB_PT_ADDR + 4], strict dword 0 =20 - mov ecx, GHCB_SIZE / 4 - xor eax, eax -clearGhcbMemoryLoop: - mov dword[ecx * 4 + GHCB_BASE - 4], eax - loop clearGhcbMemoryLoop - SevClearPageEncMaskForGhcbPageExit: OneTimeCallRet SevClearPageEncMaskForGhcbPage =20 --=20 2.25.1