Skip to content

Commit 0b8d366

Browse files
jgross1suryasaimadhu
authored andcommitted
x86/paravirt: Simplify paravirt macros
The central pvops call macros ____PVOP_CALL() and ____PVOP_VCALL() are looking very similar now. The main differences are using PVOP_VCALL_ARGS or PVOP_CALL_ARGS, which are identical, and the return value handling. So drop PVOP_VCALL_ARGS and instead of ____PVOP_VCALL() just use (void)____PVOP_CALL(long, ...). Note that it isn't easily possible to just redefine ____PVOP_VCALL() to use ____PVOP_CALL() instead, as this would require further hiding of commas in macro parameters. Signed-off-by: Juergen Gross <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 33634e4 commit 0b8d366

File tree

1 file changed

+12
-29
lines changed

1 file changed

+12
-29
lines changed

arch/x86/include/asm/paravirt_types.h

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -408,11 +408,9 @@ int paravirt_disable_iospace(void);
408408
* makes sure the incoming and outgoing types are always correct.
409409
*/
410410
#ifdef CONFIG_X86_32
411-
#define PVOP_VCALL_ARGS \
411+
#define PVOP_CALL_ARGS \
412412
unsigned long __eax = __eax, __edx = __edx, __ecx = __ecx;
413413

414-
#define PVOP_CALL_ARGS PVOP_VCALL_ARGS
415-
416414
#define PVOP_CALL_ARG1(x) "a" ((unsigned long)(x))
417415
#define PVOP_CALL_ARG2(x) "d" ((unsigned long)(x))
418416
#define PVOP_CALL_ARG3(x) "c" ((unsigned long)(x))
@@ -428,12 +426,10 @@ int paravirt_disable_iospace(void);
428426
#define VEXTRA_CLOBBERS
429427
#else /* CONFIG_X86_64 */
430428
/* [re]ax isn't an arg, but the return val */
431-
#define PVOP_VCALL_ARGS \
429+
#define PVOP_CALL_ARGS \
432430
unsigned long __edi = __edi, __esi = __esi, \
433431
__edx = __edx, __ecx = __ecx, __eax = __eax;
434432

435-
#define PVOP_CALL_ARGS PVOP_VCALL_ARGS
436-
437433
#define PVOP_CALL_ARG1(x) "D" ((unsigned long)(x))
438434
#define PVOP_CALL_ARG2(x) "S" ((unsigned long)(x))
439435
#define PVOP_CALL_ARG3(x) "d" ((unsigned long)(x))
@@ -458,59 +454,46 @@ int paravirt_disable_iospace(void);
458454
#define PVOP_TEST_NULL(op) ((void)pv_ops.op)
459455
#endif
460456

461-
#define PVOP_RETMASK(rettype) \
457+
#define PVOP_RETVAL(rettype) \
462458
({ unsigned long __mask = ~0UL; \
459+
BUILD_BUG_ON(sizeof(rettype) > sizeof(unsigned long)); \
463460
switch (sizeof(rettype)) { \
464461
case 1: __mask = 0xffUL; break; \
465462
case 2: __mask = 0xffffUL; break; \
466463
case 4: __mask = 0xffffffffUL; break; \
467464
default: break; \
468465
} \
469-
__mask; \
466+
__mask & __eax; \
470467
})
471468

472469

473-
#define ____PVOP_CALL(rettype, op, clbr, call_clbr, extra_clbr, ...) \
470+
#define ____PVOP_CALL(ret, op, clbr, call_clbr, extra_clbr, ...) \
474471
({ \
475472
PVOP_CALL_ARGS; \
476473
PVOP_TEST_NULL(op); \
477-
BUILD_BUG_ON(sizeof(rettype) > sizeof(unsigned long)); \
478474
asm volatile(paravirt_alt(PARAVIRT_CALL) \
479475
: call_clbr, ASM_CALL_CONSTRAINT \
480476
: paravirt_type(op), \
481477
paravirt_clobber(clbr), \
482478
##__VA_ARGS__ \
483479
: "memory", "cc" extra_clbr); \
484-
(rettype)(__eax & PVOP_RETMASK(rettype)); \
480+
ret; \
485481
})
486482

487483
#define __PVOP_CALL(rettype, op, ...) \
488-
____PVOP_CALL(rettype, op, CLBR_ANY, PVOP_CALL_CLOBBERS, \
489-
EXTRA_CLOBBERS, ##__VA_ARGS__)
484+
____PVOP_CALL(PVOP_RETVAL(rettype), op, CLBR_ANY, \
485+
PVOP_CALL_CLOBBERS, EXTRA_CLOBBERS, ##__VA_ARGS__)
490486

491487
#define __PVOP_CALLEESAVE(rettype, op, ...) \
492-
____PVOP_CALL(rettype, op.func, CLBR_RET_REG, \
488+
____PVOP_CALL(PVOP_RETVAL(rettype), op.func, CLBR_RET_REG, \
493489
PVOP_CALLEE_CLOBBERS, , ##__VA_ARGS__)
494490

495-
496-
#define ____PVOP_VCALL(op, clbr, call_clbr, extra_clbr, ...) \
497-
({ \
498-
PVOP_VCALL_ARGS; \
499-
PVOP_TEST_NULL(op); \
500-
asm volatile(paravirt_alt(PARAVIRT_CALL) \
501-
: call_clbr, ASM_CALL_CONSTRAINT \
502-
: paravirt_type(op), \
503-
paravirt_clobber(clbr), \
504-
##__VA_ARGS__ \
505-
: "memory", "cc" extra_clbr); \
506-
})
507-
508491
#define __PVOP_VCALL(op, ...) \
509-
____PVOP_VCALL(op, CLBR_ANY, PVOP_VCALL_CLOBBERS, \
492+
(void)____PVOP_CALL(, op, CLBR_ANY, PVOP_VCALL_CLOBBERS, \
510493
VEXTRA_CLOBBERS, ##__VA_ARGS__)
511494

512495
#define __PVOP_VCALLEESAVE(op, ...) \
513-
____PVOP_VCALL(op.func, CLBR_RET_REG, \
496+
(void)____PVOP_CALL(, op.func, CLBR_RET_REG, \
514497
PVOP_VCALLEE_CLOBBERS, , ##__VA_ARGS__)
515498

516499

0 commit comments

Comments
 (0)