From: Jeremi Piotrowski <jpiotrowski@linux.microsoft.com>
To: linux-kernel@vger.kernel.org
Cc: Jeremi Piotrowski <jpiotrowski@linux.microsoft.com>,
"Brijesh Singh" <brijesh.singh@amd.com>,
"Tom Lendacky" <thomas.lendacky@amd.com>,
"Kalra, Ashish" <ashish.kalra@amd.com>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Ingo Molnar" <mingo@redhat.com>,
"Borislav Petkov" <bp@alien8.de>,
"Dave Hansen" <dave.hansen@linux.intel.com>,
x86@kernel.org
Subject: [PATCH v1 3/8] x86/psp: Register PSP platform device when ASP table is present
Date: Mon, 23 Jan 2023 15:22:45 +0000 [thread overview]
Message-ID: <20230123152250.26413-4-jpiotrowski@linux.microsoft.com> (raw)
In-Reply-To: <20230123152250.26413-1-jpiotrowski@linux.microsoft.com>
The ASP table contains the memory location of the register window for
communication with the Platform Security Processor. The device is not
exposed as an acpi node, so it is necessary to probe for the table and
register a platform_device to represent it in the kernel.
At least conceptually, the same PSP may be exposed on the PCIe bus as
well, in which case it would be necessary to choose whether to use a PCI
BAR or the register window defined in ASPT for communication. There is
no advantage to using the ACPI and there are no known bare-metal systems
that expose the ASP table, so device registration is restricted to the
only systems known to provide an ASPT: Hyper-V VMs. Hyper-V VMs also do
not expose the PSP over PCIe.
This is a skeleton device at this point, as the ccp driver is not yet
prepared to correctly probe it. Interrupt configuration will come later
on as well.
Signed-off-by: Jeremi Piotrowski <jpiotrowski@linux.microsoft.com>
---
arch/x86/kernel/Makefile | 2 +-
arch/x86/kernel/psp.c | 39 +++++++++++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+), 1 deletion(-)
create mode 100644 arch/x86/kernel/psp.c
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index f901658d9f7c..e2e19f2d08a7 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -139,7 +139,7 @@ obj-$(CONFIG_UNWINDER_ORC) += unwind_orc.o
obj-$(CONFIG_UNWINDER_FRAME_POINTER) += unwind_frame.o
obj-$(CONFIG_UNWINDER_GUESS) += unwind_guess.o
-obj-$(CONFIG_AMD_MEM_ENCRYPT) += sev.o
+obj-$(CONFIG_AMD_MEM_ENCRYPT) += psp.o sev.o
obj-$(CONFIG_CFI_CLANG) += cfi.o
diff --git a/arch/x86/kernel/psp.c b/arch/x86/kernel/psp.c
new file mode 100644
index 000000000000..d404df47cc04
--- /dev/null
+++ b/arch/x86/kernel/psp.c
@@ -0,0 +1,39 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <linux/platform_data/psp.h>
+#include <linux/platform_device.h>
+#include <asm/hypervisor.h>
+
+static struct platform_device psp_device = {
+ .name = "psp",
+ .id = PLATFORM_DEVID_NONE,
+};
+
+static int __init psp_init_platform_device(void)
+{
+ struct psp_platform_data pdata = {};
+ struct resource res[1];
+ int err;
+
+ /*
+ * The ACPI PSP interface is mutually exclusive with the PCIe interface,
+ * but there is no reason to use the ACPI interface over the PCIe one.
+ * Restrict probing ACPI PSP to platforms known to only expose the ACPI
+ * interface, which at this time is SNP-host capable Hyper-V VMs.
+ */
+ if (!hypervisor_is_type(X86_HYPER_MS_HYPERV))
+ return -ENODEV;
+
+ err = acpi_parse_aspt(res, &pdata);
+ if (err)
+ return err;
+ err = platform_device_add_resources(&psp_device, res, 1);
+ if (err)
+ return err;
+
+ err = platform_device_register(&psp_device);
+ if (err)
+ return err;
+ return 0;
+}
+device_initcall(psp_init_platform_device);
--
2.25.1
next prev parent reply other threads:[~2023-01-23 15:24 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-23 15:22 [PATCH v1 0/8] Support ACPI PSP on Hyper-V Jeremi Piotrowski
2023-01-23 15:22 ` [PATCH v1 1/8] include/acpi: add definition of ASPT table Jeremi Piotrowski
2023-01-23 19:56 ` Rafael J. Wysocki
2023-01-24 16:05 ` Jeremi Piotrowski
2023-01-23 15:22 ` [PATCH v1 2/8] ACPI: ASPT: Add helper to parse table Jeremi Piotrowski
2023-01-23 15:22 ` Jeremi Piotrowski [this message]
2023-01-31 18:49 ` [PATCH v1 3/8] x86/psp: Register PSP platform device when ASP table is present Tom Lendacky
2023-02-01 14:09 ` Jeremi Piotrowski
2023-02-01 14:57 ` Tom Lendacky
2023-01-23 15:22 ` [PATCH v1 4/8] x86/psp: Add IRQ support Jeremi Piotrowski
2023-01-31 19:45 ` Tom Lendacky
2023-01-23 15:22 ` [PATCH v1 5/8] crypto: cpp - Bind to psp platform device on x86 Jeremi Piotrowski
2023-01-31 19:51 ` Tom Lendacky
2023-02-08 12:48 ` Jeremi Piotrowski
2023-01-23 15:22 ` [PATCH v1 6/8] crypto: ccp - Add vdata for platform device Jeremi Piotrowski
2023-01-31 20:36 ` Tom Lendacky
2023-02-01 19:24 ` Jeremi Piotrowski
2023-02-06 19:13 ` Tom Lendacky
2023-02-08 12:45 ` Jeremi Piotrowski
2023-02-08 17:23 ` Tom Lendacky
2023-01-23 15:22 ` [PATCH v1 7/8] crypto: ccp - Skip DMA coherency check for platform psp Jeremi Piotrowski
2023-01-31 20:42 ` Tom Lendacky
2023-02-08 12:56 ` Jeremi Piotrowski
2023-01-23 15:22 ` [PATCH v1 8/8] crypto: ccp - Allow platform device to be psp master device Jeremi Piotrowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230123152250.26413-4-jpiotrowski@linux.microsoft.com \
--to=jpiotrowski@linux.microsoft.com \
--cc=ashish.kalra@amd.com \
--cc=bp@alien8.de \
--cc=brijesh.singh@amd.com \
--cc=dave.hansen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=thomas.lendacky@amd.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox