diff mbox series

[kvm-unit-tests,v1,1/2] lib/s390x: move TOD clock related functions to library

Message ID 20220826084944.19466-2-nrb@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series s390x: Add migration test for guest TOD clock | expand

Commit Message

Nico Boehr Aug. 26, 2022, 8:49 a.m. UTC
The TOD-clock related functions can be useful for other tests beside the
sck test, hence move them to the library.

Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
---
 lib/s390x/asm/time.h | 48 ++++++++++++++++++++++++++++++++++++++++++++
 s390x/sck.c          | 32 -----------------------------
 2 files changed, 48 insertions(+), 32 deletions(-)

Comments

Claudio Imbrenda Oct. 6, 2022, 10:50 a.m. UTC | #1
On Fri, 26 Aug 2022 10:49:43 +0200
Nico Boehr <nrb@linux.ibm.com> wrote:

> The TOD-clock related functions can be useful for other tests beside the
> sck test, hence move them to the library.
> 
> Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
> ---
>  lib/s390x/asm/time.h | 48 ++++++++++++++++++++++++++++++++++++++++++++
>  s390x/sck.c          | 32 -----------------------------
>  2 files changed, 48 insertions(+), 32 deletions(-)
> 
> diff --git a/lib/s390x/asm/time.h b/lib/s390x/asm/time.h
> index 7652a151e87a..81b57e2b4894 100644
> --- a/lib/s390x/asm/time.h
> +++ b/lib/s390x/asm/time.h
> @@ -28,6 +28,54 @@ static inline uint64_t get_clock_ms(void)
>  	return get_clock_us() / 1000;
>  }
>  
> +static inline int sck(uint64_t *time)
> +{
> +	int cc;
> +
> +	asm volatile(
> +		"	sck %[time]\n"
> +		"	ipm %[cc]\n"
> +		"	srl %[cc],28\n"
> +		: [cc] "=d"(cc)
> +		: [time] "Q"(*time)
> +		: "cc"
> +	);
> +
> +	return cc;
> +}
> +
> +static inline int stck(uint64_t *time)
> +{
> +	int cc;
> +
> +	asm volatile(
> +		"	stck %[time]\n"
> +		"	ipm %[cc]\n"
> +		"	srl %[cc],28\n"
> +		: [cc] "=d" (cc), [time] "=Q" (*time)
> +		:
> +		: "cc", "memory"
> +	);
> +
> +	return cc;
> +}
> +
> +static inline int stckf(uint64_t *time)
> +{
> +	int cc;
> +
> +	asm volatile(
> +		"	stckf %[time]\n"
> +		"	ipm %[cc]\n"
> +		"	srl %[cc],28\n"
> +		: [cc] "=d" (cc), [time] "=Q" (*time)
> +		:
> +		: "cc", "memory"
> +	);
> +
> +	return cc;
> +}

please put these functions before all the other inline functions, and
then fix get_clock_us to use the wrapper instead of the (broken) inline
asm

> +
>  static inline void udelay(unsigned long us)
>  {
>  	unsigned long startclk = get_clock_us();
> diff --git a/s390x/sck.c b/s390x/sck.c
> index 88d52b74a586..dff496187602 100644
> --- a/s390x/sck.c
> +++ b/s390x/sck.c
> @@ -12,38 +12,6 @@
>  #include <asm/interrupt.h>
>  #include <asm/time.h>
>  
> -static inline int sck(uint64_t *time)
> -{
> -	int cc;
> -
> -	asm volatile(
> -		"	sck %[time]\n"
> -		"	ipm %[cc]\n"
> -		"	srl %[cc],28\n"
> -		: [cc] "=d"(cc)
> -		: [time] "Q"(*time)
> -		: "cc"
> -	);
> -
> -	return cc;
> -}
> -
> -static inline int stck(uint64_t *time)
> -{
> -	int cc;
> -
> -	asm volatile(
> -		"	stck %[time]\n"
> -		"	ipm %[cc]\n"
> -		"	srl %[cc],28\n"
> -		: [cc] "=d" (cc), [time] "=Q" (*time)
> -		:
> -		: "cc", "memory"
> -	);
> -
> -	return cc;
> -}
> -
>  static void test_priv(void)
>  {
>  	uint64_t time_to_set_privileged = 0xfacef00dcafe0000,
Nico Boehr Oct. 11, 2022, 11:44 a.m. UTC | #2
Quoting Claudio Imbrenda (2022-10-06 12:50:14)
[...]
> > diff --git a/lib/s390x/asm/time.h b/lib/s390x/asm/time.h
> > index 7652a151e87a..81b57e2b4894 100644
[...]
> > +static inline int sck(uint64_t *time)
[...]
> > +static inline int stck(uint64_t *time)
[...]
> > +static inline int stckf(uint64_t *time)
[...]
> 
> please put these functions before all the other inline functions, and
> then fix get_clock_us to use the wrapper instead of the (broken) inline
> asm

Yes, this makes sense, thanks.
diff mbox series

Patch

diff --git a/lib/s390x/asm/time.h b/lib/s390x/asm/time.h
index 7652a151e87a..81b57e2b4894 100644
--- a/lib/s390x/asm/time.h
+++ b/lib/s390x/asm/time.h
@@ -28,6 +28,54 @@  static inline uint64_t get_clock_ms(void)
 	return get_clock_us() / 1000;
 }
 
+static inline int sck(uint64_t *time)
+{
+	int cc;
+
+	asm volatile(
+		"	sck %[time]\n"
+		"	ipm %[cc]\n"
+		"	srl %[cc],28\n"
+		: [cc] "=d"(cc)
+		: [time] "Q"(*time)
+		: "cc"
+	);
+
+	return cc;
+}
+
+static inline int stck(uint64_t *time)
+{
+	int cc;
+
+	asm volatile(
+		"	stck %[time]\n"
+		"	ipm %[cc]\n"
+		"	srl %[cc],28\n"
+		: [cc] "=d" (cc), [time] "=Q" (*time)
+		:
+		: "cc", "memory"
+	);
+
+	return cc;
+}
+
+static inline int stckf(uint64_t *time)
+{
+	int cc;
+
+	asm volatile(
+		"	stckf %[time]\n"
+		"	ipm %[cc]\n"
+		"	srl %[cc],28\n"
+		: [cc] "=d" (cc), [time] "=Q" (*time)
+		:
+		: "cc", "memory"
+	);
+
+	return cc;
+}
+
 static inline void udelay(unsigned long us)
 {
 	unsigned long startclk = get_clock_us();
diff --git a/s390x/sck.c b/s390x/sck.c
index 88d52b74a586..dff496187602 100644
--- a/s390x/sck.c
+++ b/s390x/sck.c
@@ -12,38 +12,6 @@ 
 #include <asm/interrupt.h>
 #include <asm/time.h>
 
-static inline int sck(uint64_t *time)
-{
-	int cc;
-
-	asm volatile(
-		"	sck %[time]\n"
-		"	ipm %[cc]\n"
-		"	srl %[cc],28\n"
-		: [cc] "=d"(cc)
-		: [time] "Q"(*time)
-		: "cc"
-	);
-
-	return cc;
-}
-
-static inline int stck(uint64_t *time)
-{
-	int cc;
-
-	asm volatile(
-		"	stck %[time]\n"
-		"	ipm %[cc]\n"
-		"	srl %[cc],28\n"
-		: [cc] "=d" (cc), [time] "=Q" (*time)
-		:
-		: "cc", "memory"
-	);
-
-	return cc;
-}
-
 static void test_priv(void)
 {
 	uint64_t time_to_set_privileged = 0xfacef00dcafe0000,