diff mbox series

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

Message ID 20220330144339.261419-5-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 30, 2022, 2:43 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>
---
 lib/s390x/asm/arch_def.h | 4 +---
 lib/s390x/hardware.h     | 5 +++++
 2 files changed, 6 insertions(+), 3 deletions(-)

Comments

Janosch Frank March 31, 2022, 3:24 p.m. UTC | #1
On 3/30/22 16:43, Claudio Imbrenda wrote:
> 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 --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 fb6565ad..8783ae9c 100644
> --- a/lib/s390x/hardware.h
> +++ b/lib/s390x/hardware.h
> @@ -43,6 +43,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;
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 fb6565ad..8783ae9c 100644
--- a/lib/s390x/hardware.h
+++ b/lib/s390x/hardware.h
@@ -43,6 +43,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;