Skip to content

Commit 4fa3b91

Browse files
hcahcaborntraeger
authored andcommitted
KVM: s390: get rid of register asm usage
Using register asm statements has been proven to be very error prone, especially when using code instrumentation where gcc may add function calls, which clobbers register contents in an unexpected way. Therefore get rid of register asm statements in kvm code, even though there is currently nothing wrong with them. This way we know for sure that this bug class won't be introduced here. Signed-off-by: Heiko Carstens <[email protected]> Reviewed-by: Christian Borntraeger <[email protected]> Reviewed-by: Thomas Huth <[email protected]> Reviewed-by: Cornelia Huck <[email protected]> Reviewed-by: Claudio Imbrenda <[email protected]> Link: https://lore.kernel.org/r/[email protected] [[email protected]: checkpatch strict fix] Signed-off-by: Christian Borntraeger <[email protected]>
1 parent 6efb943 commit 4fa3b91

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

arch/s390/kvm/kvm-s390.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -329,31 +329,31 @@ static void allow_cpu_feat(unsigned long nr)
329329

330330
static inline int plo_test_bit(unsigned char nr)
331331
{
332-
register unsigned long r0 asm("0") = (unsigned long) nr | 0x100;
332+
unsigned long function = (unsigned long)nr | 0x100;
333333
int cc;
334334

335335
asm volatile(
336+
" lgr 0,%[function]\n"
336337
/* Parameter registers are ignored for "test bit" */
337338
" plo 0,0,0,0(0)\n"
338339
" ipm %0\n"
339340
" srl %0,28\n"
340341
: "=d" (cc)
341-
: "d" (r0)
342-
: "cc");
342+
: [function] "d" (function)
343+
: "cc", "0");
343344
return cc == 0;
344345
}
345346

346347
static __always_inline void __insn32_query(unsigned int opcode, u8 *query)
347348
{
348-
register unsigned long r0 asm("0") = 0; /* query function */
349-
register unsigned long r1 asm("1") = (unsigned long) query;
350-
351349
asm volatile(
352-
/* Parameter regs are ignored */
350+
" lghi 0,0\n"
351+
" lgr 1,%[query]\n"
352+
/* Parameter registers are ignored */
353353
" .insn rrf,%[opc] << 16,2,4,6,0\n"
354354
:
355-
: "d" (r0), "a" (r1), [opc] "i" (opcode)
356-
: "cc", "memory");
355+
: [query] "d" ((unsigned long)query), [opc] "i" (opcode)
356+
: "cc", "memory", "0", "1");
357357
}
358358

359359
#define INSN_SORTL 0xb938

0 commit comments

Comments
 (0)