Skip to content

Commit a6b9dec

Browse files
committed
KVM: s390: selftests: Add regression tests for PLO subfunctions
JIRA: https://issues.redhat.com/browse/RHEL-113440 commit 75ec613 Author: Hariharan Mari <hari55@linux.ibm.com> Date: Fri Aug 23 15:05:08 2024 +0200 KVM: s390: selftests: Add regression tests for PLO subfunctions Extend the existing regression test framework for s390x CPU subfunctions to include tests for the Perform Locked Operation (PLO) subfunction functions. PLO was introduced in the very first 64-bit machine generation. Hence it is assumed PLO is always installed in the Z Arch. The test procedure follows the established pattern. Suggested-by: Janosch Frank <frankja@linux.ibm.com> Signed-off-by: Hariharan Mari <hari55@linux.ibm.com> Reviewed-by: Janosch Frank <frankja@linux.ibm.com> Reviewed-by: Christoph Schlameuss <schlameuss@linux.ibm.com> Link: https://lore.kernel.org/r/20240823130947.38323-6-hari55@linux.ibm.com Signed-off-by: Janosch Frank <frankja@linux.ibm.com> Message-ID: <20240823130947.38323-6-hari55@linux.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
1 parent 3c655f4 commit a6b9dec

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tools/testing/selftests/kvm/s390/cpumodel_subfuncs_test.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
#include "kvm_util.h"
2121

22+
#define PLO_FUNCTION_MAX 256
23+
2224
/* Query available CPU subfunctions */
2325
struct kvm_s390_vm_cpu_subfunc cpu_subfunc;
2426

@@ -33,6 +35,31 @@ static void get_cpu_machine_subfuntions(struct kvm_vm *vm,
3335
TEST_ASSERT(!r, "Get cpu subfunctions failed r=%d errno=%d", r, errno);
3436
}
3537

38+
static inline int plo_test_bit(unsigned char nr)
39+
{
40+
unsigned long function = nr | 0x100;
41+
int cc;
42+
43+
asm volatile(" lgr 0,%[function]\n"
44+
/* Parameter registers are ignored for "test bit" */
45+
" plo 0,0,0,0(0)\n"
46+
" ipm %0\n"
47+
" srl %0,28\n"
48+
: "=d" (cc)
49+
: [function] "d" (function)
50+
: "cc", "0");
51+
return cc == 0;
52+
}
53+
54+
/* Testing Perform Locked Operation (PLO) CPU subfunction's ASM block */
55+
static void test_plo_asm_block(u8 (*query)[32])
56+
{
57+
for (int i = 0; i < PLO_FUNCTION_MAX; ++i) {
58+
if (plo_test_bit(i))
59+
(*query)[i >> 3] |= 0x80 >> (i & 7);
60+
}
61+
}
62+
3663
/* Testing Crypto Compute Message Authentication Code (KMAC) CPU subfunction's ASM block */
3764
static void test_kmac_asm_block(u8 (*query)[16])
3865
{
@@ -196,6 +223,11 @@ struct testdef {
196223
testfunc_t test;
197224
int facility_bit;
198225
} testlist[] = {
226+
/*
227+
* PLO was introduced in the very first 64-bit machine generation.
228+
* Hence it is assumed PLO is always installed in Z Arch.
229+
*/
230+
{ "PLO", cpu_subfunc.plo, sizeof(cpu_subfunc.plo), test_plo_asm_block, 1 },
199231
/* MSA - Facility bit 17 */
200232
{ "KMAC", cpu_subfunc.kmac, sizeof(cpu_subfunc.kmac), test_kmac_asm_block, 17 },
201233
{ "KMC", cpu_subfunc.kmc, sizeof(cpu_subfunc.kmc), test_kmc_asm_block, 17 },

0 commit comments

Comments
 (0)