From: Claudio Imbrenda <imbrenda@linux.ibm.com>
To: Nico Boehr <nrb@linux.ibm.com>
Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, borntraeger@linux.ibm.com
Subject: Re: [kvm-unit-tests PATCH v2 1/2] lib/s390x: move TOD clock related functions to library
Date: Tue, 11 Oct 2022 17:41:35 +0200 [thread overview]
Message-ID: <20221011174135.1cdcd472@p-imbrenda> (raw)
In-Reply-To: <20221011151433.886294-2-nrb@linux.ibm.com>
On Tue, 11 Oct 2022 17:14:32 +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.
>
> While at it, add a wrapper for stckf and express get_clock_us() with
> stck() to reduce code duplication.
>
> Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
> ---
> lib/s390x/asm/time.h | 50 +++++++++++++++++++++++++++++++++++++++++++-
> s390x/sck.c | 32 ----------------------------
> 2 files changed, 49 insertions(+), 33 deletions(-)
>
> diff --git a/lib/s390x/asm/time.h b/lib/s390x/asm/time.h
> index d8d91d68a667..c5e1797fd29e 100644
> --- a/lib/s390x/asm/time.h
> +++ b/lib/s390x/asm/time.h
> @@ -18,11 +18,59 @@
>
> #define CPU_TIMER_SHIFT_US S390_CLOCK_SHIFT_US
>
> +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"
why do you need "memory" ?
(I know it was in the old code, but probably it should not have)
> + );
> +
> + 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"
same here
> + );
> +
> + return cc;
> +}
> +
> static inline uint64_t get_clock_us(void)
> {
> uint64_t clk;
>
> - asm volatile(" stck %0 " : : "Q"(clk) : "memory");
> + stck(&clk);
>
> return clk >> STCK_SHIFT_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,
next prev parent reply other threads:[~2022-10-11 15:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-11 15:14 [kvm-unit-tests PATCH v2 0/2] s390x: Add migration test for guest TOD clock Nico Boehr
2022-10-11 15:14 ` [kvm-unit-tests PATCH v2 1/2] lib/s390x: move TOD clock related functions to library Nico Boehr
2022-10-11 15:41 ` Claudio Imbrenda [this message]
2022-10-11 15:14 ` [kvm-unit-tests PATCH v2 2/2] s390x: add migration TOD clock test Nico Boehr
2022-10-11 15:49 ` Claudio Imbrenda
2022-10-11 15:58 ` [kvm-unit-tests PATCH v2 0/2] s390x: Add migration test for guest TOD clock Christian Borntraeger
2022-10-11 16:10 ` Claudio Imbrenda
2022-10-11 16:15 ` Christian Borntraeger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221011174135.1cdcd472@p-imbrenda \
--to=imbrenda@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=frankja@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=nrb@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox