summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2024-11-06 22:06:17 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2024-11-06 22:06:17 +0000
commitac2153fa3867c51627f932e6ebc1684009830e0f (patch)
tree7579d1c6b09a63a3b527d59afe976624d9d7bd1a
parent4fb7289361467a5745494a5c5bba4bd7c85a4508 (diff)
vmd(8) logs psp(4) firmware version.
On vmd startup, log the AMD SEV PSP API and build number. from hshoexer@; OK mlarkin@
-rw-r--r--usr.sbin/vmd/psp.c18
-rw-r--r--usr.sbin/vmd/sev.c4
-rw-r--r--usr.sbin/vmd/vmd.h4
3 files changed, 20 insertions, 6 deletions
diff --git a/usr.sbin/vmd/psp.c b/usr.sbin/vmd/psp.c
index 2de8cf4ac0b..4c1cfdab617 100644
--- a/usr.sbin/vmd/psp.c
+++ b/usr.sbin/vmd/psp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: psp.c,v 1.3 2024/11/05 23:16:46 bluhm Exp $ */
+/* $OpenBSD: psp.c,v 1.4 2024/11/06 22:06:16 bluhm Exp $ */
/*
* Copyright (c) 2023, 2024 Hans-Joerg Hoexer <hshoexer@genua.de>
@@ -42,7 +42,8 @@ extern struct vmd *env;
* Retrieve platform state.
*/
int
-psp_get_pstate(uint16_t *state)
+psp_get_pstate(uint16_t *state, uint8_t *major, uint8_t *minor,
+ uint8_t *build, uint8_t *seves)
{
struct psp_platform_status pst;
@@ -53,6 +54,14 @@ psp_get_pstate(uint16_t *state)
if (state)
*state = pst.state;
+ if (major)
+ *major = pst.api_major;
+ if (minor)
+ *minor = pst.api_minor;
+ if (build)
+ *build = (pst.cfges_build >> 24) & 0xff;
+ if (seves)
+ *seves = pst.cfges_build & 0x1;
return (0);
}
@@ -318,6 +327,8 @@ psp_reset(void)
void
psp_setup(void)
{
+ uint8_t major, minor, build;
+
env->vmd_psp_fd = open(PSP_NODE, O_RDWR);
if (env->vmd_psp_fd == -1) {
if (errno != ENXIO)
@@ -327,4 +338,7 @@ psp_setup(void)
if (psp_reset() < 0)
fatalx("%s: failed to reset PSP", __func__);
+ if (psp_get_pstate(NULL, &major, &minor, &build, NULL) < 0)
+ fatalx("%s: failed to get platform state", __func__);
+ log_info("PSP api %hhu.%hhu, build %hhu", major, minor, build);
}
diff --git a/usr.sbin/vmd/sev.c b/usr.sbin/vmd/sev.c
index 89272c8b3ad..d5216461392 100644
--- a/usr.sbin/vmd/sev.c
+++ b/usr.sbin/vmd/sev.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sev.c,v 1.4 2024/09/26 01:45:13 jsg Exp $ */
+/* $OpenBSD: sev.c,v 1.5 2024/11/06 22:06:16 bluhm Exp $ */
/*
* Copyright (c) 2023, 2024 Hans-Joerg Hoexer <hshoexer@genua.de>
@@ -49,7 +49,7 @@ sev_init(struct vmd_vm *vm)
if (!vcp->vcp_sev)
return (0);
- if (psp_get_pstate(&pstate)) {
+ if (psp_get_pstate(&pstate, NULL, NULL, NULL, NULL)) {
log_warnx("%s: failed to get platform state", __func__);
return (-1);
}
diff --git a/usr.sbin/vmd/vmd.h b/usr.sbin/vmd/vmd.h
index fee378b5d49..613d846edf0 100644
--- a/usr.sbin/vmd/vmd.h
+++ b/usr.sbin/vmd/vmd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: vmd.h,v 1.129 2024/11/05 23:16:46 bluhm Exp $ */
+/* $OpenBSD: vmd.h,v 1.130 2024/11/06 22:06:16 bluhm Exp $ */
/*
* Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org>
@@ -586,7 +586,7 @@ __dead void vionet_main(int, int);
__dead void vioblk_main(int, int);
/* psp.c */
-int psp_get_pstate(uint16_t *);
+int psp_get_pstate(uint16_t *, uint8_t *, uint8_t *, uint8_t *, uint8_t *);
int psp_df_flush(void);
int psp_get_gstate(uint32_t, uint32_t *, uint32_t *, uint8_t *);
int psp_launch_start(uint32_t *);