* [PATCH 1/2] virt: sevguest: Change driver name to reflect generic SEV support
2022-04-20 14:14 [PATCH 0/2] Provide consistent name of the SEV Guest driver Tom Lendacky
@ 2022-04-20 14:14 ` Tom Lendacky
2022-04-20 14:14 ` [PATCH 2/2] virt: sevguest: Rename the sevguest dir and files to sev-guest Tom Lendacky
1 sibling, 0 replies; 3+ messages in thread
From: Tom Lendacky @ 2022-04-20 14:14 UTC (permalink / raw)
To: linux-kernel, x86, linux-doc
Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen,
Jonathan Corbet, Joerg Roedel, Michael Roth
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>
---
arch/x86/include/asm/sev.h | 2 +-
arch/x86/kernel/sev.c | 10 +++----
drivers/virt/coco/sevguest/sevguest.c | 39 ++++++++++++++-------------
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 @@ int snp_issue_guest_request(u64 exit_code, struct snp_req_data *input, unsigned
}
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 aaa6134d1d40..f3b93bd92f2f 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 @@ static int __init snp_guest_probe(struct platform_device *pdev)
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");
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] virt: sevguest: Rename the sevguest dir and files to sev-guest
2022-04-20 14:14 [PATCH 0/2] Provide consistent name of the SEV Guest driver Tom Lendacky
2022-04-20 14:14 ` [PATCH 1/2] virt: sevguest: Change driver name to reflect generic SEV support Tom Lendacky
@ 2022-04-20 14:14 ` Tom Lendacky
1 sibling, 0 replies; 3+ messages in thread
From: Tom Lendacky @ 2022-04-20 14:14 UTC (permalink / raw)
To: linux-kernel, x86, linux-doc
Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen,
Jonathan Corbet, Joerg Roedel, Michael Roth
Rename the drivers/virt/coco/sevguest directory and files to sev-guest
so as to match the driver name.
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
---
Documentation/virt/index.rst | 2 +-
drivers/virt/Kconfig | 2 +-
drivers/virt/Makefile | 2 +-
drivers/virt/coco/{sevguest => sev-guest}/Kconfig | 2 +-
drivers/virt/coco/{sevguest => sev-guest}/Makefile | 2 +-
.../coco/{sevguest/sevguest.c => sev-guest/sev-guest.c} | 8 ++++----
.../coco/{sevguest/sevguest.h => sev-guest/sev-guest.h} | 0
7 files changed, 9 insertions(+), 9 deletions(-)
rename drivers/virt/coco/{sevguest => sev-guest}/Kconfig (87%)
rename drivers/virt/coco/{sevguest => sev-guest}/Makefile (50%)
rename drivers/virt/coco/{sevguest/sevguest.c => sev-guest/sev-guest.c} (98%)
rename drivers/virt/coco/{sevguest/sevguest.h => sev-guest/sev-guest.h} (100%)
diff --git a/Documentation/virt/index.rst b/Documentation/virt/index.rst
index 40ad0d20032e..492f0920b988 100644
--- a/Documentation/virt/index.rst
+++ b/Documentation/virt/index.rst
@@ -13,7 +13,7 @@ Linux Virtualization Support
guest-halt-polling
ne_overview
acrn/index
- coco/sevguest
+ coco/sev-guest
.. only:: html and subproject
diff --git a/drivers/virt/Kconfig b/drivers/virt/Kconfig
index 7d3273cfab27..0c1bba7c5c66 100644
--- a/drivers/virt/Kconfig
+++ b/drivers/virt/Kconfig
@@ -48,6 +48,6 @@ source "drivers/virt/nitro_enclaves/Kconfig"
source "drivers/virt/acrn/Kconfig"
-source "drivers/virt/coco/sevguest/Kconfig"
+source "drivers/virt/coco/sev-guest/Kconfig"
endif
diff --git a/drivers/virt/Makefile b/drivers/virt/Makefile
index 7b87a7ba1972..b2e6e864ebbe 100644
--- a/drivers/virt/Makefile
+++ b/drivers/virt/Makefile
@@ -9,4 +9,4 @@ obj-y += vboxguest/
obj-$(CONFIG_NITRO_ENCLAVES) += nitro_enclaves/
obj-$(CONFIG_ACRN_HSM) += acrn/
-obj-$(CONFIG_SEV_GUEST) += coco/sevguest/
+obj-$(CONFIG_SEV_GUEST) += coco/sev-guest/
diff --git a/drivers/virt/coco/sevguest/Kconfig b/drivers/virt/coco/sev-guest/Kconfig
similarity index 87%
rename from drivers/virt/coco/sevguest/Kconfig
rename to drivers/virt/coco/sev-guest/Kconfig
index 74ca1fe09437..f9db0799ae67 100644
--- a/drivers/virt/coco/sevguest/Kconfig
+++ b/drivers/virt/coco/sev-guest/Kconfig
@@ -11,4 +11,4 @@ config SEV_GUEST
userspace interface to communicate with the PSP to request the
attestation report and more.
- If you choose 'M' here, this module will be called sevguest.
+ If you choose 'M' here, this module will be called sev-guest.
diff --git a/drivers/virt/coco/sevguest/Makefile b/drivers/virt/coco/sev-guest/Makefile
similarity index 50%
rename from drivers/virt/coco/sevguest/Makefile
rename to drivers/virt/coco/sev-guest/Makefile
index b1ffb2b4177b..63d67c27723a 100644
--- a/drivers/virt/coco/sevguest/Makefile
+++ b/drivers/virt/coco/sev-guest/Makefile
@@ -1,2 +1,2 @@
# SPDX-License-Identifier: GPL-2.0-only
-obj-$(CONFIG_SEV_GUEST) += sevguest.o
+obj-$(CONFIG_SEV_GUEST) += sev-guest.o
diff --git a/drivers/virt/coco/sevguest/sevguest.c b/drivers/virt/coco/sev-guest/sev-guest.c
similarity index 98%
rename from drivers/virt/coco/sevguest/sevguest.c
rename to drivers/virt/coco/sev-guest/sev-guest.c
index f3b93bd92f2f..1fd4a0583e09 100644
--- a/drivers/virt/coco/sevguest/sevguest.c
+++ b/drivers/virt/coco/sev-guest/sev-guest.c
@@ -25,7 +25,7 @@
#include <asm/svm.h>
#include <asm/sev.h>
-#include "sevguest.h"
+#include "sev-guest.h"
#define DEVICE_NAME "sev-guest"
#define AAD_LEN 48
@@ -724,9 +724,9 @@ static int __exit sev_guest_remove(struct platform_device *pdev)
}
/*
- * 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".
+ * This driver is meant to be a common SEV guest interface driver and to
+ * support any SEV guest API. As such, even though it has been introduced
+ * with the SEV-SNP support, it is named "sev-guest".
*/
static struct platform_driver sev_guest_driver = {
.remove = __exit_p(sev_guest_remove),
diff --git a/drivers/virt/coco/sevguest/sevguest.h b/drivers/virt/coco/sev-guest/sev-guest.h
similarity index 100%
rename from drivers/virt/coco/sevguest/sevguest.h
rename to drivers/virt/coco/sev-guest/sev-guest.h
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread