diff mbox series

[kvm-unit-tests,v2,5/5] lib: s390x: stidp wrapper and move get_machine_id

Message ID 20220331160419.333157-6-imbrenda@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series lib: s390x: Refactor and rename vm.[ch] | expand

Commit Message

Claudio Imbrenda March 31, 2022, 4:04 p.m. UTC
Refactor get_machine_id in arch_def.h into a simple wrapper around
stidp, add back get_machine_id in hardware.h using the stidp wrapper.

Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
---
 lib/s390x/asm/arch_def.h | 4 +---
 lib/s390x/hardware.h     | 5 +++++
 2 files changed, 6 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/lib/s390x/asm/arch_def.h b/lib/s390x/asm/arch_def.h
index 8d860ccf..bab3c374 100644
--- a/lib/s390x/asm/arch_def.h
+++ b/lib/s390x/asm/arch_def.h
@@ -219,13 +219,11 @@  static inline unsigned short stap(void)
 	return cpu_address;
 }
 
-static inline uint16_t get_machine_id(void)
+static inline uint64_t stidp(void)
 {
 	uint64_t cpuid;
 
 	asm volatile("stidp %0" : "=Q" (cpuid));
-	cpuid = cpuid >> 16;
-	cpuid &= 0xffff;
 
 	return cpuid;
 }
diff --git a/lib/s390x/hardware.h b/lib/s390x/hardware.h
index af20be18..01eeb261 100644
--- a/lib/s390x/hardware.h
+++ b/lib/s390x/hardware.h
@@ -25,6 +25,11 @@  enum s390_host {
 
 enum s390_host detect_host(void);
 
+static inline uint16_t get_machine_id(void)
+{
+	return stidp() >> 16;
+}
+
 static inline bool host_is_tcg(void)
 {
 	return detect_host() == HOST_IS_TCG;