From patchwork Fri May 31 04:30:30 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: 13681124 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2066.outbound.protection.outlook.com [40.107.244.66]) (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 08A9781730; Fri, 31 May 2024 04:34:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717130078; cv=fail; b=fx2QaxYAL1rTbAt7ix6FoejcIFvzM9C3gTt16vdBRnc/82IXb5adIVXJsQkCdfmvSXswpQfBaWYhYr2+7NOZdisW+1blrAXOsAaisAaOX6x36fe/YnsB4bDbrzaJxtrEOK5NiiFXOncWAtjadhlUYdjhIjk1FjlfITfo4AeTRiA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717130078; c=relaxed/simple; bh=cQGOlved0tQmJKoUYAdNx2BMn1EbWhqcNlTE0N0mVI0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BSj/ZwQtXymEBQf5zdX6nn74WL/MpwU6ElYibcbK+Y5Ue7ZLE3Ybm53E1N6C6ZZhnUWj/6JrJucDjedfMpK1pafhHxJAUt4nuE8IUpv4JRTIKgbS+E5Sn75qUrh8dIVsMr9+1yJqYlSTAL2LCPaPNQ5+PLwXfCRX0W9kwzn7Hzg= 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=D4YyPTRV; arc=fail smtp.client-ip=40.107.244.66 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="D4YyPTRV" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bM20h0yyZvmvhiI44rp215zV/6JOBKZgooCCHPnwuM1qEo/kxNvWQEjOuVJHdtH+JFUHWOujY90I6yFBGan9arvryE9XOVOvNCaZtc0478XNXe8WoQswklnnz0CSaJsQgJ/8vXbnO21P6XgyB2RgIzu/Jk2jpQkrGnWT05LeLaF2TKsjqK9A1DBZAv39wwKCE1DAxxmIFfktnb6YTP5+ny/ru7GJSEVRK6Q1bUqPIJSVc1ogTXViwBx5dola3FZ0K5KvEyyRiODc+jEl1GJ1YSye6K1mZf5x4i59y8AULDlbdT4hYP4Xji8nh2KgK8aEm/02OioF6jYdUIY/0blfHw== 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=BJGPFCKzNEwl3egjrviH4RCpCB7V93sRbJj49WF3LQM=; b=APYlB4n6pUyO+imFUppInP8ciC1BDBcbFoDsXLGYrz0UwSDZgjgO8+EcPsniDluleMIEvfzV8Irqh5LZGx7gSvrYLCdUTQo9QjfcMyo1S+HgQMMWi/srk/dFFvVsnTxVLEyVadetc1on2r98aZ7TDujN9h88QN6Yuo6PfylDMVhuD5Qj2SMUpEe8LSyPihXw4+c0/zpCX8mDb7nMbsJpRzqK9zaWAeUpQVV32fxzoIAsz6a4hX3VkoqyVxXKIhYTAuMzY5fX3MzXrziGoitmaIeJmjVelo3kopCtEmGMcm/guOc1cBnQWufvZrgeBsfaWopQqA7jFZMzgtRFbolpwg== 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=BJGPFCKzNEwl3egjrviH4RCpCB7V93sRbJj49WF3LQM=; b=D4YyPTRV+IkrCI9hx4bYiinYInhrEpCudBjNSWb+h065KjBNVFVEKwAPrrja0iK6kBRmcNKkY/Y4H1jEIyjX1IdFZpbKLLTKrDttki1EiBMwRuRLoS4NOKpVNLUS8Btd4tXfJseaaMWudO4vzgI/gAKvjXqKfBfbO/R0Li5xRlE= Received: from CH2PR17CA0019.namprd17.prod.outlook.com (2603:10b6:610:53::29) by IA0PR12MB7676.namprd12.prod.outlook.com (2603:10b6:208:432::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.25; Fri, 31 May 2024 04:34:32 +0000 Received: from DS3PEPF000099D5.namprd04.prod.outlook.com (2603:10b6:610:53:cafe::b3) by CH2PR17CA0019.outlook.office365.com (2603:10b6:610:53::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.18 via Frontend Transport; Fri, 31 May 2024 04:34:32 +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 DS3PEPF000099D5.mail.protection.outlook.com (10.167.17.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7633.15 via Frontend Transport; Fri, 31 May 2024 04:34:32 +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.35; Thu, 30 May 2024 23:34:03 -0500 From: Nikunj A Dadhania To: , , , , CC: , , , , , , Subject: [PATCH v9 16/24] x86/sev: Drop sev_guest_platform_data structure Date: Fri, 31 May 2024 10:00:30 +0530 Message-ID: <20240531043038.3370793-17-nikunj@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240531043038.3370793-1-nikunj@amd.com> References: <20240531043038.3370793-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: DS3PEPF000099D5:EE_|IA0PR12MB7676:EE_ X-MS-Office365-Filtering-Correlation-Id: 71de84fb-8915-46cb-5437-08dc812af7da X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|36860700004|376005|7416005|1800799015|82310400017; X-Microsoft-Antispam-Message-Info: mNCday6T2p5gKxF4RKv1jPVN8gBsVjO6CTo4QAOErve5XUGpKuIKsWp4qgECp51/pLKUHyOAcGVBsjZf5W5UlksH+n9WuRD6E56ohjLSQy126menS303fk6zEU/BuG4/b2GM47v+WI0v7WaNj34TmOk0v8fEWDoUFRPAtBW0R7uNo3Fi/J/6qxPmFpD3LjDAjEO+rPsw+K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FJgDOkcTS9LtP3C+qfc1uEExJQ3mclAHATi+eLMi9LG7iuzmaeGjTY8B1kdw3SszAG3hHw36LwS86oKmg2xpwWStSJXR76wkut2Tzdz0N3/uqXO8X2lIp7fCdTr8LlS6 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:(13230031)(36860700004)(376005)(7416005)(1800799015)(82310400017);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 May 2024 04:34:32.5720 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 71de84fb-8915-46cb-5437-08dc812af7da 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: DS3PEPF000099D5.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB7676 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/kernel/sev.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 f58052fd6cb3..128bf71302a3 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 /* @@ -324,7 +320,7 @@ u64 sev_get_status(void); void sev_show_status(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); @@ -393,8 +389,7 @@ static inline void sev_show_status(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/kernel/sev.c b/arch/x86/kernel/sev.c index 141a670d2a85..c56cb2f15ec7 100644 --- a/arch/x86/kernel/sev.c +++ b/arch/x86/kernel/sev.c @@ -2239,15 +2239,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; @@ -2597,11 +2591,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 41878bd968d5..8d026d485028 100644 --- a/drivers/virt/coco/sev-guest/sev-guest.c +++ b/drivers/virt/coco/sev-guest/sev-guest.c @@ -406,7 +406,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; @@ -415,11 +414,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; @@ -430,7 +424,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;