[kvm-unit-tests PATCH v1 3/4] lib: s390x: functions for machine models

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* move existing macros for machine models to hardware.h
* add macros for all known machine models
* add machine_is_* functions
---
 lib/s390x/asm/arch_def.h |  3 --
 lib/s390x/hardware.h     | 82 ++++++++++++++++++++++++++++++++++++++++
 s390x/uv-host.c          |  4 +-
 3 files changed, 84 insertions(+), 5 deletions(-)

diff --git a/lib/s390x/asm/arch_def.h b/lib/s390x/asm/arch_def.h
index 40626d72..8d860ccf 100644
--- a/lib/s390x/asm/arch_def.h
+++ b/lib/s390x/asm/arch_def.h
@@ -219,9 +219,6 @@ static inline unsigned short stap(void)
 	return cpu_address;
 }
 
-#define MACHINE_Z15A	0x8561
-#define MACHINE_Z15B	0x8562
-
 static inline uint16_t get_machine_id(void)
 {
 	uint64_t cpuid;
diff --git a/lib/s390x/hardware.h b/lib/s390x/hardware.h
index 93f817ca..fb6565ad 100644
--- a/lib/s390x/hardware.h
+++ b/lib/s390x/hardware.h
@@ -13,6 +13,25 @@
 #define _S390X_HARDWARE_H_
 #include <asm/arch_def.h>
 
+#define MACHINE_Z900	0x2064
+#define MACHINE_Z800	0x2066
+#define MACHINE_Z990	0x2084
+#define MACHINE_Z890	0x2086
+#define MACHINE_Z9EC	0x2094
+#define MACHINE_Z9BC	0x2096
+#define MACHINE_Z10EC	0x2097
+#define MACHINE_Z10BC	0x2098
+#define MACHINE_Z196	0x2817
+#define MACHINE_Z114	0x2818
+#define MACHINE_ZEC12	0x2827
+#define MACHINE_ZBC12	0x2828
+#define MACHINE_Z13	0x2964
+#define MACHINE_Z13S	0x2965
+#define MACHINE_Z14	0x3906
+#define MACHINE_Z14ZR1	0x3907
+#define MACHINE_Z15	0x8561
+#define MACHINE_Z15T02	0x8562
+
 enum s390_host {
 	HOST_IS_UNKNOWN,
 	HOST_IS_LPAR,
@@ -44,4 +63,67 @@ static inline bool host_is_zvm6(void)
 	return detect_host() == HOST_IS_ZVM6;
 }
 
+static inline bool machine_is_z900(void)
+{
+	uint16_t machine = get_machine_id();
+
+	return machine == MACHINE_Z900 || machine == MACHINE_Z800;
+}
+
+static inline bool machine_is_z990(void)
+{
+	uint16_t machine = get_machine_id();
+
+	return machine == MACHINE_Z990 || machine == MACHINE_Z890;
+}
+
+static inline bool machine_is_z9(void)
+{
+	uint16_t machine = get_machine_id();
+
+	return machine == MACHINE_Z9EC || machine == MACHINE_Z9BC;
+}
+
+static inline bool machine_is_z10(void)
+{
+	uint16_t machine = get_machine_id();
+
+	return machine == MACHINE_Z10EC || machine == MACHINE_Z10BC;
+}
+
+static inline bool machine_is_z1xx(void)
+{
+	uint16_t machine = get_machine_id();
+
+	return machine == MACHINE_Z196 || machine == MACHINE_Z114;
+}
+
+static inline bool machine_is_z12(void)
+{
+	uint16_t machine = get_machine_id();
+
+	return machine == MACHINE_ZEC12 || machine == MACHINE_ZBC12;
+}
+
+static inline bool machine_is_z13(void)
+{
+	uint16_t machine = get_machine_id();
+
+	return machine == MACHINE_Z13 || machine == MACHINE_Z13S;
+}
+
+static inline bool machine_is_z14(void)
+{
+	uint16_t machine = get_machine_id();
+
+	return machine == MACHINE_Z14 || machine == MACHINE_Z14ZR1;
+}
+
+static inline bool machine_is_z15(void)
+{
+	uint16_t machine = get_machine_id();
+
+	return machine == MACHINE_Z15 || machine == MACHINE_Z15T02;
+}
+
 #endif  /* _S390X_HARDWARE_H_ */
diff --git a/s390x/uv-host.c b/s390x/uv-host.c
index de2e4850..d3018e3c 100644
--- a/s390x/uv-host.c
+++ b/s390x/uv-host.c
@@ -9,6 +9,7 @@
  */
 
 #include <libcflat.h>
+#include <hardware.h>
 #include <alloc.h>
 #include <vmalloc.h>
 #include <sclp.h>
@@ -111,7 +112,6 @@ static void test_config_destroy(void)
 static void test_cpu_destroy(void)
 {
 	int rc;
-	uint16_t machineid = get_machine_id();
 	struct uv_cb_nodata uvcb = {
 		.header.len = sizeof(uvcb),
 		.header.cmd = UVC_CMD_DESTROY_SEC_CPU,
@@ -126,7 +126,7 @@ static void test_cpu_destroy(void)
 	       "hdr invalid length");
 	uvcb.header.len += 8;
 
-	if (machineid != MACHINE_Z15A && machineid != MACHINE_Z15B) {
+	if (!machine_is_z15()) {
 		uvcb.handle += 1;
 		rc = uv_call(0, (uint64_t)&uvcb);
 		report(rc == 1 && uvcb.header.rc == UVC_RC_INV_CHANDLE, "invalid handle");
-- 
2.34.1




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Kernel Development]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Info]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Linux Media]     [Device Mapper]

  Powered by Linux