Skip to content

Commit 09c38ad

Browse files
Hariharan Marifrankjaa
authored andcommitted
KVM: s390: Fix SORTL and DFLTCC instruction format error in __insn32_query
The __insn32_query() function incorrectly uses the RRF instruction format for both the SORTL (RRE format) and DFLTCC (RRF format) instructions. To fix this issue, add separate query functions for SORTL and DFLTCC that use the appropriate instruction formats. Additionally pass the query operand as a pointer to the entire array of 32 elements to slightly optimize performance and readability. Fixes: d668139 ("KVM: s390: provide query function for instructions returning 32 byte") Suggested-by: Heiko Carstens <[email protected]> Reviewed-by: Juergen Christ <[email protected]> Signed-off-by: Hariharan Mari <[email protected]> Signed-off-by: Janosch Frank <[email protected]>
1 parent 47ac09b commit 09c38ad

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

arch/s390/kvm/kvm-s390.c

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -348,20 +348,29 @@ static inline int plo_test_bit(unsigned char nr)
348348
return cc == 0;
349349
}
350350

351-
static __always_inline void __insn32_query(unsigned int opcode, u8 *query)
351+
static __always_inline void __sortl_query(u8 (*query)[32])
352352
{
353353
asm volatile(
354354
" lghi 0,0\n"
355-
" lgr 1,%[query]\n"
355+
" la 1,%[query]\n"
356356
/* Parameter registers are ignored */
357-
" .insn rrf,%[opc] << 16,2,4,6,0\n"
357+
" .insn rre,0xb9380000,2,4\n"
358+
: [query] "=R" (*query)
358359
:
359-
: [query] "d" ((unsigned long)query), [opc] "i" (opcode)
360-
: "cc", "memory", "0", "1");
360+
: "cc", "0", "1");
361361
}
362362

363-
#define INSN_SORTL 0xb938
364-
#define INSN_DFLTCC 0xb939
363+
static __always_inline void __dfltcc_query(u8 (*query)[32])
364+
{
365+
asm volatile(
366+
" lghi 0,0\n"
367+
" la 1,%[query]\n"
368+
/* Parameter registers are ignored */
369+
" .insn rrf,0xb9390000,2,4,6,0\n"
370+
: [query] "=R" (*query)
371+
:
372+
: "cc", "0", "1");
373+
}
365374

366375
static void __init kvm_s390_cpu_feat_init(void)
367376
{
@@ -415,10 +424,10 @@ static void __init kvm_s390_cpu_feat_init(void)
415424
kvm_s390_available_subfunc.kdsa);
416425

417426
if (test_facility(150)) /* SORTL */
418-
__insn32_query(INSN_SORTL, kvm_s390_available_subfunc.sortl);
427+
__sortl_query(&kvm_s390_available_subfunc.sortl);
419428

420429
if (test_facility(151)) /* DFLTCC */
421-
__insn32_query(INSN_DFLTCC, kvm_s390_available_subfunc.dfltcc);
430+
__dfltcc_query(&kvm_s390_available_subfunc.dfltcc);
422431

423432
if (MACHINE_HAS_ESOP)
424433
allow_cpu_feat(KVM_S390_VM_CPU_FEAT_ESOP);

0 commit comments

Comments
 (0)