Skip to content

Commit 75ec613

Browse files
Hariharan Marifrankjaa
authored andcommitted
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 <[email protected]> Signed-off-by: Hariharan Mari <[email protected]> Reviewed-by: Janosch Frank <[email protected]> Reviewed-by: Christoph Schlameuss <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Janosch Frank <[email protected]> Message-ID: <[email protected]>
1 parent d1dbab5 commit 75ec613

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tools/testing/selftests/kvm/s390x/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)