summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Lendacky <thomas.lendacky@amd.com>2022-04-20 09:14:13 -0500
committerBorislav Petkov <bp@suse.de>2022-04-21 11:48:24 +0200
commit2bf93ffbb97e0614cfc431d2ea33b7eae7481eb2 (patch)
tree795262f066a0700d17988258d9bb17332ffeccea
parent6044d159b5d826259a7397d42fa3ad0bfc4dbd13 (diff)
downloadlinux-2bf93ffbb97e0614cfc431d2ea33b7eae7481eb2.tar.bz2
virt: sevguest: Change driver name to reflect generic SEV support
During patch review, it was decided the SNP guest driver name should not be SEV-SNP specific, but should be generic for use with anything SEV. However, this feedback was missed and the driver name, and many of the driver functions and structures, are SEV-SNP name specific. Rename the driver to "sev-guest" (to match the misc device that is created) and update some of the function and structure names, too. While in the file, adjust the one pr_err() message to be a dev_err() message so that the message, if issued, uses the driver name. Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com> Signed-off-by: Borislav Petkov <bp@suse.de> Link: https://lore.kernel.org/r/307710bb5515c9088a19fd0b930268c7300479b2.1650464054.git.thomas.lendacky@amd.com
-rw-r--r--arch/x86/include/asm/sev.h2
-rw-r--r--arch/x86/kernel/sev.c10
-rw-r--r--drivers/virt/coco/sevguest/sevguest.c39
3 files changed, 27 insertions, 24 deletions
diff --git a/arch/x86/include/asm/sev.h b/arch/x86/include/asm/sev.h
index 9c2d33f1cfee..6e3dda4f82b5 100644
--- a/arch/x86/include/asm/sev.h
+++ b/arch/x86/include/asm/sev.h
@@ -95,7 +95,7 @@ struct snp_req_data {
unsigned int data_npages;
};
-struct snp_guest_platform_data {
+struct sev_guest_platform_data {
u64 secrets_gpa;
};
diff --git a/arch/x86/kernel/sev.c b/arch/x86/kernel/sev.c
index f01f4550e2c6..2fa87a07ab30 100644
--- a/arch/x86/kernel/sev.c
+++ b/arch/x86/kernel/sev.c
@@ -2166,8 +2166,8 @@ e_restore_irq:
}
EXPORT_SYMBOL_GPL(snp_issue_guest_request);
-static struct platform_device guest_req_device = {
- .name = "snp-guest",
+static struct platform_device sev_guest_device = {
+ .name = "sev-guest",
.id = -1,
};
@@ -2197,7 +2197,7 @@ static u64 get_secrets_page(void)
static int __init snp_init_platform_device(void)
{
- struct snp_guest_platform_data data;
+ struct sev_guest_platform_data data;
u64 gpa;
if (!cc_platform_has(CC_ATTR_GUEST_SEV_SNP))
@@ -2208,10 +2208,10 @@ static int __init snp_init_platform_device(void)
return -ENODEV;
data.secrets_gpa = gpa;
- if (platform_device_add_data(&guest_req_device, &data, sizeof(data)))
+ if (platform_device_add_data(&sev_guest_device, &data, sizeof(data)))
return -ENODEV;
- if (platform_device_register(&guest_req_device))
+ if (platform_device_register(&sev_guest_device))
return -ENODEV;
pr_info("SNP guest platform device initialized.\n");
diff --git a/drivers/virt/coco/sevguest/sevguest.c b/drivers/virt/coco/sevguest/sevguest.c
index 15f069ec8f0b..18c3231a816d 100644
--- a/drivers/virt/coco/sevguest/sevguest.c
+++ b/drivers/virt/coco/sevguest/sevguest.c
@@ -1,14 +1,12 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
- * AMD Secure Encrypted Virtualization Nested Paging (SEV-SNP) guest request interface
+ * AMD Secure Encrypted Virtualization (SEV) guest driver interface
*
* Copyright (C) 2021 Advanced Micro Devices, Inc.
*
* Author: Brijesh Singh <brijesh.singh@amd.com>
*/
-#define pr_fmt(fmt) "SNP: GUEST: " fmt
-
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/types.h>
@@ -574,7 +572,7 @@ static void free_shared_pages(void *buf, size_t sz)
__free_pages(virt_to_page(buf), get_order(sz));
}
-static void *alloc_shared_pages(size_t sz)
+static void *alloc_shared_pages(struct device *dev, size_t sz)
{
unsigned int npages = PAGE_ALIGN(sz) >> PAGE_SHIFT;
struct page *page;
@@ -586,7 +584,7 @@ static void *alloc_shared_pages(size_t sz)
ret = set_memory_decrypted((unsigned long)page_address(page), npages);
if (ret) {
- pr_err("failed to mark page shared, ret=%d\n", ret);
+ dev_err(dev, "failed to mark page shared, ret=%d\n", ret);
__free_pages(page, get_order(sz));
return NULL;
}
@@ -627,10 +625,10 @@ static u8 *get_vmpck(int id, struct snp_secrets_page_layout *layout, u32 **seqno
return key;
}
-static int __init snp_guest_probe(struct platform_device *pdev)
+static int __init sev_guest_probe(struct platform_device *pdev)
{
struct snp_secrets_page_layout *layout;
- struct snp_guest_platform_data *data;
+ struct sev_guest_platform_data *data;
struct device *dev = &pdev->dev;
struct snp_guest_dev *snp_dev;
struct miscdevice *misc;
@@ -639,7 +637,7 @@ static int __init snp_guest_probe(struct platform_device *pdev)
if (!dev->platform_data)
return -ENODEV;
- data = (struct snp_guest_platform_data *)dev->platform_data;
+ data = (struct sev_guest_platform_data *)dev->platform_data;
layout = (__force void *)ioremap_encrypted(data->secrets_gpa, PAGE_SIZE);
if (!layout)
return -ENODEV;
@@ -667,15 +665,15 @@ static int __init snp_guest_probe(struct platform_device *pdev)
snp_dev->layout = layout;
/* Allocate the shared page used for the request and response message. */
- snp_dev->request = alloc_shared_pages(sizeof(struct snp_guest_msg));
+ snp_dev->request = alloc_shared_pages(dev, sizeof(struct snp_guest_msg));
if (!snp_dev->request)
goto e_unmap;
- snp_dev->response = alloc_shared_pages(sizeof(struct snp_guest_msg));
+ snp_dev->response = alloc_shared_pages(dev, sizeof(struct snp_guest_msg));
if (!snp_dev->response)
goto e_free_request;
- snp_dev->certs_data = alloc_shared_pages(SEV_FW_BLOB_MAX_SIZE);
+ snp_dev->certs_data = alloc_shared_pages(dev, SEV_FW_BLOB_MAX_SIZE);
if (!snp_dev->certs_data)
goto e_free_response;
@@ -698,7 +696,7 @@ static int __init snp_guest_probe(struct platform_device *pdev)
if (ret)
goto e_free_cert_data;
- dev_info(dev, "Initialized SNP guest driver (using vmpck_id %d)\n", vmpck_id);
+ dev_info(dev, "Initialized SEV guest driver (using vmpck_id %d)\n", vmpck_id);
return 0;
e_free_cert_data:
@@ -712,7 +710,7 @@ e_unmap:
return ret;
}
-static int __exit snp_guest_remove(struct platform_device *pdev)
+static int __exit sev_guest_remove(struct platform_device *pdev)
{
struct snp_guest_dev *snp_dev = platform_get_drvdata(pdev);
@@ -725,16 +723,21 @@ static int __exit snp_guest_remove(struct platform_device *pdev)
return 0;
}
-static struct platform_driver snp_guest_driver = {
- .remove = __exit_p(snp_guest_remove),
+/*
+ * This driver is a common SEV guest interface driver and meant to support
+ * any SEV guest API. As such, even though it has been introduced along with
+ * the SEV-SNP support, it is named "sev-guest".
+ */
+static struct platform_driver sev_guest_driver = {
+ .remove = __exit_p(sev_guest_remove),
.driver = {
- .name = "snp-guest",
+ .name = "sev-guest",
},
};
-module_platform_driver_probe(snp_guest_driver, snp_guest_probe);
+module_platform_driver_probe(sev_guest_driver, sev_guest_probe);
MODULE_AUTHOR("Brijesh Singh <brijesh.singh@amd.com>");
MODULE_LICENSE("GPL");
MODULE_VERSION("1.0.0");
-MODULE_DESCRIPTION("AMD SNP Guest Driver");
+MODULE_DESCRIPTION("AMD SEV Guest Driver");