|
From: Andreas A. <ar...@li...> - 2019-08-07 10:54:09
|
On Tue, Aug 06 2019, Mark Wielaard wrote:
> Hi,
>
> On Tue, 2019-08-06 at 11:54 +0200, Mark Wielaard wrote:
>> Sorry, this is a bit old, but I am finally testing this and on a z13
>> setup (no z14) this part causes trouble [...]
>
> We discussed this a bit on irc and it seems I got confused a bit by the
> precise s390x facilities available on the machine I am using (which is
> a remote build machine to which I don't have direct access).
>
> The issue doesn't seem to be with this patch. But with the specific
> setup of the machine, it is a RHEL7 based setup, where it seems the
> kernel doesn't setup the vector capability, but the machine does have
> the vx facility.
>
> That seems to cause our tests prereq to think it can run the vector
> instructions, but when the actual vector* tests run the instructions
> fail because the kernel hasn't enabled them.
Right. That kind of discrepancy is specific to certain hardware
features that need support by the hypervisor and OS. VX is one of
those, because it requires additional registers to be maintained.
> So it seems we need to make tests/s390x_features s390x-vx smarter.
Yes, we should. I suggest the patch below. Instead of relying on the
CPU facility list, the patch checks the HWCAP, where the kernel
officially indicates full VX support. Any thoughts?
--
Andreas
-- >8 --
Subject: [PATCH] s390x: Fix vector facility (vx) check in test suite
When checking the prereqisuites of running a vector test case, it is not
sufficient to check for the appropriate CPU facility bit. It must also be
verified that the kernel and hypervisor(s) have actually enabled the
vector facility. There are various ways of checking this. E.g., we could
try executing a vector instruction and handle any signals. Or we can
check the HWCAP for the appropriate bit. This patch does the latter.
---
tests/s390x_features.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/tests/s390x_features.c b/tests/s390x_features.c
index ce6c4ab26..c17331839 100644
--- a/tests/s390x_features.c
+++ b/tests/s390x_features.c
@@ -10,6 +10,17 @@
#include <fcntl.h> // open
#include <unistd.h> // lseek
#include <sys/stat.h> // S_IRUSR
+#include <features.h>
+
+// Features that need kernel support should be checked against HWCAP instead of
+// the CPU facility list. In this case we use 'getauxval' if available -- which
+// should be the case with glibc versions >= 2.16.
+#if __GLIBC_PREREQ(2, 16)
+#include <sys/auxv.h>
+#define GET_HWCAP() getauxval(AT_HWCAP)
+#else
+#define GET_HWCAP() 0UL
+#endif
// This file determines s390x features a processor supports.
//
@@ -246,7 +257,7 @@ static int go(char *feature, char *cpu)
} else if (strcmp(feature, "s390x-highw") == 0 ) {
match = facilities[0] & FAC_BIT(45);
} else if (strcmp(feature, "s390x-vx") == 0 ) {
- match = facilities[2] & FAC_BIT(0);
+ match = GET_HWCAP() & 0x800;
} else if (strcmp(feature, "s390x-msa5") == 0 ) {
match = facilities[0] & FAC_BIT(57); /* message security assist 5 facility */
} else if (strcmp(feature, "s390x-mi2") == 0 ) {
--
2.17.0
|