From: Janosch Frank <frankja@linux.ibm.com>
To: kvm@vger.kernel.org
Cc: thuth@redhat.com, linux-s390@vger.kernel.org, david@redhat.com,
borntraeger@de.ibm.com, imbrenda@linux.ibm.com
Subject: [kvm-unit-tests PATCH 1/5] s390x: Add test_bit to library
Date: Tue, 17 Nov 2020 10:42:11 -0500 [thread overview]
Message-ID: <20201117154215.45855-2-frankja@linux.ibm.com> (raw)
In-Reply-To: <20201117154215.45855-1-frankja@linux.ibm.com>
Query/feature bits are commonly tested via MSB bit numbers on
s390. Let's add test bit functions, so we don't need to copy code to
test query bits.
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
---
lib/s390x/asm/bitops.h | 16 ++++++++++++++++
lib/s390x/asm/facility.h | 3 ++-
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/lib/s390x/asm/bitops.h b/lib/s390x/asm/bitops.h
index e7cdda9..a272dd7 100644
--- a/lib/s390x/asm/bitops.h
+++ b/lib/s390x/asm/bitops.h
@@ -7,4 +7,20 @@
#define BITS_PER_LONG 64
+static inline bool test_bit(unsigned long nr,
+ const volatile unsigned long *ptr)
+{
+ const volatile unsigned char *addr;
+
+ addr = ((const volatile unsigned char *)ptr);
+ addr += (nr ^ (BITS_PER_LONG - 8)) >> 3;
+ return (*addr >> (nr & 7)) & 1;
+}
+
+static inline bool test_bit_inv(unsigned long nr,
+ const volatile unsigned long *ptr)
+{
+ return test_bit(nr ^ (BITS_PER_LONG - 1), ptr);
+}
+
#endif
diff --git a/lib/s390x/asm/facility.h b/lib/s390x/asm/facility.h
index def2705..5593c2d 100644
--- a/lib/s390x/asm/facility.h
+++ b/lib/s390x/asm/facility.h
@@ -13,13 +13,14 @@
#include <libcflat.h>
#include <asm/facility.h>
#include <asm/arch_def.h>
+#include <bitops.h>
#define NB_STFL_DOUBLEWORDS 32
extern uint64_t stfl_doublewords[];
static inline bool test_facility(int nr)
{
- return stfl_doublewords[nr / 64] & (0x8000000000000000UL >> (nr % 64));
+ return test_bit_inv(nr, stfl_doublewords);
}
static inline void stfl(void)
--
2.25.1
next prev parent reply other threads:[~2020-11-17 15:43 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-17 15:42 [kvm-unit-tests PATCH 0/5] s390x: Add SIE library and simple test Janosch Frank
2020-11-17 15:42 ` Janosch Frank [this message]
2020-11-18 17:43 ` [kvm-unit-tests PATCH 1/5] s390x: Add test_bit to library Cornelia Huck
2020-11-19 8:26 ` Thomas Huth
2020-11-19 8:32 ` Janosch Frank
2020-11-17 15:42 ` [kvm-unit-tests PATCH 2/5] s390x: Consolidate sclp read info Janosch Frank
2020-11-18 17:46 ` Cornelia Huck
2020-11-19 8:41 ` Thomas Huth
2020-11-19 8:52 ` Janosch Frank
2020-11-17 15:42 ` [kvm-unit-tests PATCH 3/5] s390x: SCLP feature checking Janosch Frank
2020-11-18 17:50 ` Cornelia Huck
2020-11-19 8:16 ` Janosch Frank
2020-11-19 9:15 ` Thomas Huth
2020-11-19 9:21 ` Janosch Frank
2020-11-17 15:42 ` [kvm-unit-tests PATCH 4/5] s390x: sie: Add SIE to lib Janosch Frank
2020-11-17 15:42 ` [kvm-unit-tests PATCH 5/5] s390x: sie: Add first SIE test Janosch Frank
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=20201117154215.45855-2-frankja@linux.ibm.com \
--to=frankja@linux.ibm.com \
--cc=borntraeger@de.ibm.com \
--cc=david@redhat.com \
--cc=imbrenda@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=thuth@redhat.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