@@ -9,8 +9,8 @@
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2.
*/
-#ifndef UV_H
-#define UV_H
+#ifndef ASM_S390X_UV_H
+#define ASM_S390X_UV_H
#define UVC_RC_EXECUTED 0x0001
#define UVC_RC_INV_CMD 0x0002
@@ -14,6 +14,7 @@
#include <asm/facility.h>
#include <asm/sigp.h>
#include "sclp.h"
+#include "uv.h"
#include "smp.h"
extern char ipl_args[];
@@ -38,6 +39,7 @@ void setup(void)
sclp_facilities_setup();
sclp_console_setup();
sclp_memory_setup();
+ uv_setup();
smp_setup();
}
new file mode 100644
@@ -0,0 +1,45 @@
+#include <libcflat.h>
+#include <bitops.h>
+#include <alloc.h>
+#include <alloc_page.h>
+#include <asm/page.h>
+#include <asm/arch_def.h>
+
+#include <asm/facility.h>
+#include <asm/uv.h>
+#include <uv.h>
+
+static struct uv_cb_qui uvcb_qui = {
+ .header.cmd = UVC_CMD_QUI,
+ .header.len = sizeof(uvcb_qui),
+};
+
+bool uv_os_is_guest(void)
+{
+ return test_facility(158) &&
+ uv_query_test_call(BIT_UVC_CMD_SET_SHARED_ACCESS) &&
+ uv_query_test_call(BIT_UVC_CMD_REMOVE_SHARED_ACCESS);
+}
+
+bool uv_os_is_host(void)
+{
+ return test_facility(158) && uv_query_test_call(BIT_UVC_CMD_INIT_UV);
+}
+
+bool uv_query_test_call(unsigned int nr)
+{
+ /* Query needs to be called first */
+ assert(uvcb_qui.header.rc);
+ assert(nr < BITS_PER_LONG * ARRAY_SIZE(uvcb_qui.inst_calls_list));
+
+ return test_bit_inv(nr, uvcb_qui.inst_calls_list);
+}
+
+int uv_setup(void)
+{
+ if (!test_facility(158))
+ return 0;
+
+ assert(!uv_call(0, (u64)&uvcb_qui));
+ return 1;
+}
new file mode 100644
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+#ifndef UV_H
+#define UV_H
+
+bool uv_os_is_guest(void);
+bool uv_os_is_host(void);
+bool uv_query_test_call(unsigned int nr);
+int uv_setup(void);
+
+#endif /* UV_H */
@@ -67,6 +67,7 @@ cflatobjs += lib/s390x/vm.o
cflatobjs += lib/s390x/css_dump.o
cflatobjs += lib/s390x/css_lib.o
cflatobjs += lib/s390x/malloc_io.o
+cflatobjs += lib/s390x/uv.o
OBJDIRS += lib/s390x