From patchwork Fri Jun 21 12:38:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nikunj A. Dadhania" X-Patchwork-Id: 13707555 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2054.outbound.protection.outlook.com [40.107.92.54]) (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 37BC5174EC5; Fri, 21 Jun 2024 12:40:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.54 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718973629; cv=fail; b=R30S7XGzM/Ra7Ud+rNhL1CxV6AIuF9nJEJLbR6OpgS/tGzd9IVlFdEqwVz8ST+ANzqZfwsCUQhkwpwca1XkNailjj6Viv2O20embEucbpKJdE3wa+xRVDdJvam9wJrD0k86mmTum79ino6lA5uJsjL0jfkAksgMoo4l4aKx6wjo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718973629; c=relaxed/simple; bh=1+3213QQ769gxx+1IShr/BrI9pCNudrk1GvzhlEViEg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=K4ketJJCNrxCBLQovNc+6kIHHNFKHlUKZOSrI/zBy1qq8PYHh0acGRr0/8hq+jBc5HqqQR5OvU+nt/FDZ1G1izGLExuK2JQQrzU/NfaCnoOUT2zK5yMWwmsQuwvSTDT9IHqoxCCxn5UdMMD+Q+OWKhZSx3Uhf9xRNy5aLNI1iFE= 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=HUeYX3+d; arc=fail smtp.client-ip=40.107.92.54 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="HUeYX3+d" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mWIYmCsyNuKnVRy6xOrnbeeWR0z84fOqOsdwpFBIA35nW8zQUMrKi2R8nHXlJ4qYt6Fj1I6SWXE4nHg4dwiHPAUnEfiwrlmjYH/bLVre0Sz5aPNqTxD9WuE0067Y6jDxn0TXtQ93MXxmXHw8goxi+bumOFwV6nMoOgzDfx+glZrw1mWGzYyt2/ran4h0B2oBhQWp5qSnIQfajBABGiyYU89HkCRTiLZUbHSUFS/ORSn6HWZl9IplvwHUxuCExblAOuE6rCzciWOlp9VtZ8aePwezFvY9RMnrs8EH7AkmpbiMcTGIfVIXJX/zfgjej9JWDB2tgVNdGmyY/yWNm+X6cA== 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=YcD3QQjTZ665rMp9/oJhPT+mMUI2guKQwU1ndHc7nMg=; b=WKhmh43ocu9X3chbXBBXIU+k0K5f1h8K+g4G/g2yhITKQLR4Bm02m1iTwX+2LulCaW3CGGp5fjw/bTaD+pqs/VGJxegd53vU5X9/ZzzXnSgVNMz4xlD+dHFoQqabpzB95yX8DvI4drlUTffIDdAGJJ0kIzYnCOE6MUC2lAndToN7tSuxYYAZw8eyBR1xK2MChRnFeB1bfFmrDGW8oxGlrUxiHZeTEk496ULbKKhNkSOiDsa2cl1QS4tlaAEWA6PDUpR//Unto682DV5dz3ownrXOywfCq76TZ8s2IOJvNLr+p6kzr3B/AyvbZM/D6xnO0G5Z1n7HUYOuSQdsIuBCsQ== 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=YcD3QQjTZ665rMp9/oJhPT+mMUI2guKQwU1ndHc7nMg=; b=HUeYX3+d6ggcXiF88vFsFQKl23YtpD8+3ctYAGnMpTLUPfZBSA+1vS3aHNTshk0/rMcduAQoxX/tYrAZ0mw9MrDW3BkhZvu/HAezqsVniBUGzF8g9UzaAIxyeJFRjuybTBM0RidDWEQGC6zMQZ7lq8s3wOb2KEAA1DzSxibtqKE= Received: from DM5PR07CA0078.namprd07.prod.outlook.com (2603:10b6:4:ad::43) by MW4PR12MB7440.namprd12.prod.outlook.com (2603:10b6:303:223::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.37; Fri, 21 Jun 2024 12:40:24 +0000 Received: from DS3PEPF0000C380.namprd04.prod.outlook.com (2603:10b6:4:ad:cafe::ca) by DM5PR07CA0078.outlook.office365.com (2603:10b6:4:ad::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.37 via Frontend Transport; Fri, 21 Jun 2024 12:40:24 +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 DS3PEPF0000C380.mail.protection.outlook.com (10.167.23.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7677.15 via Frontend Transport; Fri, 21 Jun 2024 12:40:24 +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; Fri, 21 Jun 2024 07:40:20 -0500 From: Nikunj A Dadhania To: , , , , CC: , , , , , , Subject: [PATCH v10 16/24] x86/sev: Drop sev_guest_platform_data structure Date: Fri, 21 Jun 2024 18:08:55 +0530 Message-ID: <20240621123903.2411843-17-nikunj@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240621123903.2411843-1-nikunj@amd.com> References: <20240621123903.2411843-1-nikunj@amd.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF0000C380:EE_|MW4PR12MB7440:EE_ X-MS-Office365-Filtering-Correlation-Id: 1cdc0265-6296-4661-c4f6-08dc91ef527d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230037|36860700010|376011|82310400023|7416011|1800799021; X-Microsoft-Antispam-Message-Info: FNGHpjD6q+TyigrnIqY1dwGKsaCN12jlhac3MQKBD1+jK5v+HlyplrG/ejtprPrB8hbtD4fPLmK+MJYZMXI0z6eGmkcw1QLQg7Xwa2kg3rjHfqvqlZaDesBS/diCkPpezuCwGvyTfw5bHWRrarZFBINpmeUNJH6y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0yMNi5fBcxbT5K9e6f/O97YHnHxG3qgudzvkRA0Eodti1tDTUVF3gOOcGYlgZXyBpJdW0OutY5am+dZq2306hhtZvf/9SMdtWDFQ193z9m/kmVZnvsGsSGS7f1b40APabmoDYXFIS2hfqQv2UAvoB1+0FvbfIq2AzCyaflqNxbp0dqVjBPSpr/Qq6S3vFq1jyJSsJEw== 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:(13230037)(36860700010)(376011)(82310400023)(7416011)(1800799021);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2024 12:40:24.5859 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1cdc0265-6296-4661-c4f6-08dc91ef527d 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: DS3PEPF0000C380.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7440 SEV guest platform data structure was used to pass the secrets page physical address. As the SNP guest messaging initialization routines are local and secrets page address is cached in sev.c, use that instead of sending it to the SEV guest driver and getting the same address back. Signed-off-by: Nikunj A Dadhania --- arch/x86/include/asm/sev.h | 9 ++------- arch/x86/coco/sev/core.c | 10 ++-------- drivers/virt/coco/sev-guest/sev-guest.c | 8 +------- 3 files changed, 5 insertions(+), 22 deletions(-) diff --git a/arch/x86/include/asm/sev.h b/arch/x86/include/asm/sev.h index cdd37ad9e4b8..c5ead3230d18 100644 --- a/arch/x86/include/asm/sev.h +++ b/arch/x86/include/asm/sev.h @@ -116,10 +116,6 @@ struct snp_req_data { unsigned long resp_gpa; }; -struct sev_guest_platform_data { - u64 secrets_gpa; -}; - #define VMPCK_MAX_NUM 4 /* @@ -443,7 +439,7 @@ void sev_show_status(void); void snp_update_svsm_ca(void); bool snp_assign_vmpck(struct snp_guest_dev *snp_dev, unsigned int vmpck_id); bool snp_is_vmpck_empty(struct snp_guest_dev *snp_dev); -int snp_guest_messaging_init(struct snp_guest_dev *snp_dev, u64 secrets_gpa); +int snp_guest_messaging_init(struct snp_guest_dev *snp_dev); void snp_guest_messaging_exit(struct snp_guest_dev *snp_dev); int snp_send_guest_request(struct snp_guest_dev *snp_dev, struct snp_guest_req *req, struct snp_guest_request_ioctl *rio); @@ -520,8 +516,7 @@ static inline void snp_update_svsm_ca(void) { } static inline bool snp_assign_vmpck(struct snp_guest_dev *snp_dev, unsigned int vmpck_id) { return false; } static inline bool snp_is_vmpck_empty(struct snp_guest_dev *snp_dev) { return true; } -static inline int -snp_guest_messaging_init(struct snp_guest_dev *snp_dev, u64 secrets_gpa) { return -EINVAL; } +static inline int snp_guest_messaging_init(struct snp_guest_dev *snp_dev) { return -EINVAL; } static inline void snp_guest_messaging_exit(struct snp_guest_dev *snp_dev) { } static inline int snp_send_guest_request(struct snp_guest_dev *snp_dev, struct snp_guest_req *req, struct snp_guest_request_ioctl *rio) { return -EINVAL; } diff --git a/arch/x86/coco/sev/core.c b/arch/x86/coco/sev/core.c index 8bf573d44b0c..e0b79e292fcf 100644 --- a/arch/x86/coco/sev/core.c +++ b/arch/x86/coco/sev/core.c @@ -2489,15 +2489,9 @@ static struct platform_device sev_guest_device = { static int __init snp_init_platform_device(void) { - struct sev_guest_platform_data data; - if (!cc_platform_has(CC_ATTR_GUEST_SEV_SNP)) return -ENODEV; - data.secrets_gpa = secrets_pa; - if (platform_device_add_data(&sev_guest_device, &data, sizeof(data))) - return -ENODEV; - if (platform_device_register(&sev_guest_device)) return -ENODEV; @@ -2902,11 +2896,11 @@ int snp_send_guest_request(struct snp_guest_dev *snp_dev, } EXPORT_SYMBOL_GPL(snp_send_guest_request); -int snp_guest_messaging_init(struct snp_guest_dev *snp_dev, u64 secrets_gpa) +int snp_guest_messaging_init(struct snp_guest_dev *snp_dev) { int ret = -ENOMEM; - snp_dev->secrets = (__force void *)ioremap_encrypted(secrets_gpa, PAGE_SIZE); + snp_dev->secrets = (__force void *)ioremap_encrypted(secrets_pa, PAGE_SIZE); if (!snp_dev->secrets) { pr_err("Failed to map SNP secrets page.\n"); return ret; diff --git a/drivers/virt/coco/sev-guest/sev-guest.c b/drivers/virt/coco/sev-guest/sev-guest.c index 0631271e5b9c..76be49da08de 100644 --- a/drivers/virt/coco/sev-guest/sev-guest.c +++ b/drivers/virt/coco/sev-guest/sev-guest.c @@ -591,7 +591,6 @@ static void unregister_sev_tsm(void *data) static int __init sev_guest_probe(struct platform_device *pdev) { - struct sev_guest_platform_data *data; struct device *dev = &pdev->dev; struct snp_guest_dev *snp_dev; struct miscdevice *misc; @@ -600,11 +599,6 @@ static int __init sev_guest_probe(struct platform_device *pdev) if (!cc_platform_has(CC_ATTR_GUEST_SEV_SNP)) return -ENODEV; - if (!dev->platform_data) - return -ENODEV; - - data = (struct sev_guest_platform_data *)dev->platform_data; - snp_dev = devm_kzalloc(&pdev->dev, sizeof(struct snp_guest_dev), GFP_KERNEL); if (!snp_dev) return -ENOMEM; @@ -619,7 +613,7 @@ static int __init sev_guest_probe(struct platform_device *pdev) return ret; } - if (snp_guest_messaging_init(snp_dev, data->secrets_gpa)) { + if (snp_guest_messaging_init(snp_dev)) { dev_err(dev, "Unable to setup SNP Guest messaging using VMPCK%u\n", snp_dev->vmpck_id); return ret;