From nobody Wed Nov 27 17:36:15 2024 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2072.outbound.protection.outlook.com [40.107.92.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C3C3D18A92C; Wed, 9 Oct 2024 09:29:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.72 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728466166; cv=fail; b=qlq/Q3jCSJ2RQsN8y8xCihf7oFMAq8g8AxqwCVW9i10wYs+9+uBnmwvso3dHjV5prpUWcruEcGNR/YZ9UAvrNhvn0/oZngMyQCvES5GG5Pi2vxD7z0Q6/JZmizMl22qoSKoiQOWxEFnHzl/+qUhpZ1QT+jXXKH49nT0QeHMuNcc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728466166; c=relaxed/simple; bh=DSfxiI2nikeGJTAxShGmB6N/UCJ/9SYh3h7DOlVuTfA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZB6cTaGPpWHxBAtJ5eJ1FxOjlAVkr5g7VLS64f8EE66ssDiK6SUZ6YvZupnm17oIMNb00a2xrXUesKRaZJrgGZL4R4aerCBr3DppiYH+EHFpByItaQVigN/NkDckKaA+DvEzisBCJeN36wddv4+Jb/p0lJGu/Dnvhz6/Fy1dwsc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=EjBCO4lh; arc=fail smtp.client-ip=40.107.92.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="EjBCO4lh" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lm+6k6EWfdMp4fVyE77o4DLkQYv20SH8KS7CMWAluz5J49CJtgAgdnbySZLuF5AWAUOr55TX0XelyVYDDBvNW9XxJXtyLXNmBQwNK/TKBP+CxAatW6lJWreE1d6rX/6U2zjhf/SJcFC8uXdeflIvgz1Q/fBVLUdJPwGgwQPwj1/jWOJXe6rYBztBW0DisX1QiLrgponv4Ak/H1Tp6lKPH/rAQOoasxOzUt0GwRRrIcJSF2Rqq6QOKP/fIYcU9CF45LIh5XWYTD8JrhQUvayvBZima63UCzLP7Gr5DdLxSHKT3L8OhXcsb7MuZB6GUp2Z6V+c/xGs5X2ALcdxKR/nBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=d9SshTo6Lgdv1RfGyLJZNgzQSlTVoH5shPVaS/HcIHM=; b=xVIwiICOg9bDXuBkqOPzAvGedf+FUQWKY5GWZrLr3RNXBBnX+ZG8QdsXN9izvUAT0/0AZYpcW8X6utnLRvg2Zb+diJt0APwZUuB5nQ+GNyy6eSMdXsTGIlf9rp/2SsnUr/cm8Qaj/PuUdooyftkqO3KHE5jcWkq26Q9JBt45P+i/azNeatXzzYHyqbOe0xnG/uj7sjzQbr+SNJ3LWX6NNNJxowI3fZvtLqgYS2eqQaCGSNKx7N6tOSxuhJkdkcUn6sv6EQeh9NSaaYonXMuL9gZdLwPPFIzNMCJ8jIy3oXLwbVraEGVVt+4nn9Vcz8TY+WGV1jV56kOjJZWrgxpy4w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org 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 (0) 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=d9SshTo6Lgdv1RfGyLJZNgzQSlTVoH5shPVaS/HcIHM=; b=EjBCO4lhY7ZVDcNoNZrWeh2VuCbwb3DMHCqGhft6toipi9j6r4nVULeh+X637RWhkNiMuvpdJoi26tizMiy3vdXw9qqOnCKpommWvN4OYct1XApSJFrZlSx1iGQgHoS+acs9lSscmBlPi39f5z2xxDYPVyY7uBL3UAgSxeschyg= Received: from BLAPR05CA0040.namprd05.prod.outlook.com (2603:10b6:208:335::21) by SA3PR12MB9091.namprd12.prod.outlook.com (2603:10b6:806:395::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.16; Wed, 9 Oct 2024 09:29:21 +0000 Received: from BL02EPF00021F6D.namprd02.prod.outlook.com (2603:10b6:208:335:cafe::57) by BLAPR05CA0040.outlook.office365.com (2603:10b6:208:335::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.17 via Frontend Transport; Wed, 9 Oct 2024 09:29:21 +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; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL02EPF00021F6D.mail.protection.outlook.com (10.167.249.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8048.13 via Frontend Transport; Wed, 9 Oct 2024 09:29:21 +0000 Received: from gomati.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.2507.39; Wed, 9 Oct 2024 04:29:17 -0500 From: Nikunj A Dadhania To: , , , , CC: , , , , , , Subject: [PATCH v12 03/19] x86/sev: Cache the secrets page address Date: Wed, 9 Oct 2024 14:58:34 +0530 Message-ID: <20241009092850.197575-4-nikunj@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241009092850.197575-1-nikunj@amd.com> References: <20241009092850.197575-1-nikunj@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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-TrafficTypeDiagnostic: BL02EPF00021F6D:EE_|SA3PR12MB9091:EE_ X-MS-Office365-Filtering-Correlation-Id: fed8f367-be6d-4a61-1301-08dce844db5b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|7416014|376014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?5m4AnHZd5Y22moe0cpvvTqnnUYWEUppsDbSJiAU6Y/ivNfshliCbnwtE9dhB?= =?us-ascii?Q?UUA4OnDdaM20wyB6DLXCXwbBcvz5ksnHi9xG0zdlLJWyCWarQq6iAXK8WRb/?= =?us-ascii?Q?TQH5vhceBt17ndTvpExbbQpab5Ln4OjeX7f2CaezB8KV6/Gk3ivl2FiOXYbC?= =?us-ascii?Q?MJiKrK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f5WfELpaC/7rqKvKUFTs?= =?us-ascii?Q?SiOHUE11c1IihEVgtfJ4G6akudfiprKxZVCEKjmK2KcCrCR8PGB/m/W+8i7n?= =?us-ascii?Q?bUGfQnKCVNGQbEnFJkS2bJALybjD4r/hMUAKEDvhVgqUewf2HzjkH9QLRHV1?= =?us-ascii?Q?gp1azLTQTX6sYJTM6wXt4pfLAv+LDSJkDt31Byn2+oB0cuiLZmtUjXIG8tek?= =?us-ascii?Q?7CpeiBjjabBzgS3tk6dclUBP6x3q+QXANVgjfU7jeaEquXSGA7Vm/fhOYdNB?= =?us-ascii?Q?iGFHdXFD2YbGfr1jfRy7vDpLRhJmNzXK+A77m36HE33WDQelxf/M3Fb7RfNq?= =?us-ascii?Q?tXHPacgQMfHFm3OEMpivPTuQ4Pj9?= 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:(13230040)(82310400026)(7416014)(376014)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2024 09:29:21.4585 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fed8f367-be6d-4a61-1301-08dce844db5b 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: BL02EPF00021F6D.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB9091 Content-Type: text/plain; charset="utf-8" Instead of calling get_secrets_page(), which parses the CC blob every time to get the secrets page physical address (secrets_pa), save the secrets page physical address during snp_init() from the CC blob. Since get_secrets_page() is no longer used, remove the function. Signed-off-by: Nikunj A Dadhania Reviewed-by: Tom Lendacky --- arch/x86/coco/sev/core.c | 51 +++++++++------------------------------- 1 file changed, 11 insertions(+), 40 deletions(-) diff --git a/arch/x86/coco/sev/core.c b/arch/x86/coco/sev/core.c index de1df0cb45da..1b0facfe658b 100644 --- a/arch/x86/coco/sev/core.c +++ b/arch/x86/coco/sev/core.c @@ -92,6 +92,9 @@ static struct ghcb *boot_ghcb __section(".data"); /* Bitmap of SEV features supported by the hypervisor */ static u64 sev_hv_features __ro_after_init; =20 +/* Secrets page physical address from the CC blob */ +static u64 secrets_pa __ro_after_init; + /* #VC handler runtime per-CPU data */ struct sev_es_runtime_data { struct ghcb ghcb_page; @@ -722,45 +725,13 @@ void noinstr __sev_es_nmi_complete(void) __sev_put_ghcb(&state); } =20 -static u64 __init get_secrets_page(void) -{ - u64 pa_data =3D boot_params.cc_blob_address; - struct cc_blob_sev_info info; - void *map; - - /* - * The CC blob contains the address of the secrets page, check if the - * blob is present. - */ - if (!pa_data) - return 0; - - map =3D early_memremap(pa_data, sizeof(info)); - if (!map) { - pr_err("Unable to locate SNP secrets page: failed to map the Confidentia= l Computing blob.\n"); - return 0; - } - memcpy(&info, map, sizeof(info)); - early_memunmap(map, sizeof(info)); - - /* smoke-test the secrets page passed */ - if (!info.secrets_phys || info.secrets_len !=3D PAGE_SIZE) - return 0; - - return info.secrets_phys; -} - static u64 __init get_snp_jump_table_addr(void) { struct snp_secrets_page *secrets; void __iomem *mem; - u64 pa, addr; - - pa =3D get_secrets_page(); - if (!pa) - return 0; + u64 addr; =20 - mem =3D ioremap_encrypted(pa, PAGE_SIZE); + mem =3D ioremap_encrypted(secrets_pa, PAGE_SIZE); if (!mem) { pr_err("Unable to locate AP jump table address: failed to map the SNP se= crets page.\n"); return 0; @@ -2300,6 +2271,11 @@ bool __head snp_init(struct boot_params *bp) if (!cc_info) return false; =20 + if (cc_info->secrets_phys && cc_info->secrets_len =3D=3D PAGE_SIZE) + secrets_pa =3D cc_info->secrets_phys; + else + return false; + setup_cpuid_table(cc_info); =20 svsm_setup(cc_info); @@ -2513,16 +2489,11 @@ static struct platform_device sev_guest_device =3D { static int __init snp_init_platform_device(void) { struct sev_guest_platform_data data; - u64 gpa; =20 if (!cc_platform_has(CC_ATTR_GUEST_SEV_SNP)) return -ENODEV; =20 - gpa =3D get_secrets_page(); - if (!gpa) - return -ENODEV; - - data.secrets_gpa =3D gpa; + data.secrets_gpa =3D secrets_pa; if (platform_device_add_data(&sev_guest_device, &data, sizeof(data))) return -ENODEV; =20 --=20 2.34.1