Skip to content

Commit 00aa319

Browse files
jgross1suryasaimadhu
authored andcommitted
x86/paravirt: Add new PVOP_ALT* macros to support pvops in ALTERNATIVEs
Instead of using paravirt patching for custom code sequences add support for using ALTERNATIVE handling combined with paravirt call patching. 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 ae755b5 commit 00aa319

File tree

1 file changed

+48
-1
lines changed

1 file changed

+48
-1
lines changed

arch/x86/include/asm/paravirt_types.h

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,44 +477,91 @@ int paravirt_disable_iospace(void);
477477
ret; \
478478
})
479479

480+
#define ____PVOP_ALT_CALL(ret, op, alt, cond, clbr, call_clbr, \
481+
extra_clbr, ...) \
482+
({ \
483+
PVOP_CALL_ARGS; \
484+
PVOP_TEST_NULL(op); \
485+
asm volatile(ALTERNATIVE(paravirt_alt(PARAVIRT_CALL), \
486+
alt, cond) \
487+
: call_clbr, ASM_CALL_CONSTRAINT \
488+
: paravirt_type(op), \
489+
paravirt_clobber(clbr), \
490+
##__VA_ARGS__ \
491+
: "memory", "cc" extra_clbr); \
492+
ret; \
493+
})
494+
480495
#define __PVOP_CALL(rettype, op, ...) \
481496
____PVOP_CALL(PVOP_RETVAL(rettype), op, CLBR_ANY, \
482497
PVOP_CALL_CLOBBERS, EXTRA_CLOBBERS, ##__VA_ARGS__)
483498

499+
#define __PVOP_ALT_CALL(rettype, op, alt, cond, ...) \
500+
____PVOP_ALT_CALL(PVOP_RETVAL(rettype), op, alt, cond, CLBR_ANY,\
501+
PVOP_CALL_CLOBBERS, EXTRA_CLOBBERS, \
502+
##__VA_ARGS__)
503+
484504
#define __PVOP_CALLEESAVE(rettype, op, ...) \
485505
____PVOP_CALL(PVOP_RETVAL(rettype), op.func, CLBR_RET_REG, \
486506
PVOP_CALLEE_CLOBBERS, , ##__VA_ARGS__)
487507

508+
#define __PVOP_ALT_CALLEESAVE(rettype, op, alt, cond, ...) \
509+
____PVOP_ALT_CALL(PVOP_RETVAL(rettype), op.func, alt, cond, \
510+
CLBR_RET_REG, PVOP_CALLEE_CLOBBERS, , ##__VA_ARGS__)
511+
512+
488513
#define __PVOP_VCALL(op, ...) \
489514
(void)____PVOP_CALL(, op, CLBR_ANY, PVOP_VCALL_CLOBBERS, \
490515
VEXTRA_CLOBBERS, ##__VA_ARGS__)
491516

517+
#define __PVOP_ALT_VCALL(op, alt, cond, ...) \
518+
(void)____PVOP_ALT_CALL(, op, alt, cond, CLBR_ANY, \
519+
PVOP_VCALL_CLOBBERS, VEXTRA_CLOBBERS, \
520+
##__VA_ARGS__)
521+
492522
#define __PVOP_VCALLEESAVE(op, ...) \
493523
(void)____PVOP_CALL(, op.func, CLBR_RET_REG, \
494-
PVOP_VCALLEE_CLOBBERS, , ##__VA_ARGS__)
524+
PVOP_VCALLEE_CLOBBERS, , ##__VA_ARGS__)
495525

526+
#define __PVOP_ALT_VCALLEESAVE(op, alt, cond, ...) \
527+
(void)____PVOP_ALT_CALL(, op.func, alt, cond, CLBR_RET_REG, \
528+
PVOP_VCALLEE_CLOBBERS, , ##__VA_ARGS__)
496529

497530

498531
#define PVOP_CALL0(rettype, op) \
499532
__PVOP_CALL(rettype, op)
500533
#define PVOP_VCALL0(op) \
501534
__PVOP_VCALL(op)
535+
#define PVOP_ALT_CALL0(rettype, op, alt, cond) \
536+
__PVOP_ALT_CALL(rettype, op, alt, cond)
537+
#define PVOP_ALT_VCALL0(op, alt, cond) \
538+
__PVOP_ALT_VCALL(op, alt, cond)
502539

503540
#define PVOP_CALLEE0(rettype, op) \
504541
__PVOP_CALLEESAVE(rettype, op)
505542
#define PVOP_VCALLEE0(op) \
506543
__PVOP_VCALLEESAVE(op)
544+
#define PVOP_ALT_CALLEE0(rettype, op, alt, cond) \
545+
__PVOP_ALT_CALLEESAVE(rettype, op, alt, cond)
546+
#define PVOP_ALT_VCALLEE0(op, alt, cond) \
547+
__PVOP_ALT_VCALLEESAVE(op, alt, cond)
507548

508549

509550
#define PVOP_CALL1(rettype, op, arg1) \
510551
__PVOP_CALL(rettype, op, PVOP_CALL_ARG1(arg1))
511552
#define PVOP_VCALL1(op, arg1) \
512553
__PVOP_VCALL(op, PVOP_CALL_ARG1(arg1))
554+
#define PVOP_ALT_VCALL1(op, arg1, alt, cond) \
555+
__PVOP_ALT_VCALL(op, alt, cond, PVOP_CALL_ARG1(arg1))
513556

514557
#define PVOP_CALLEE1(rettype, op, arg1) \
515558
__PVOP_CALLEESAVE(rettype, op, PVOP_CALL_ARG1(arg1))
516559
#define PVOP_VCALLEE1(op, arg1) \
517560
__PVOP_VCALLEESAVE(op, PVOP_CALL_ARG1(arg1))
561+
#define PVOP_ALT_CALLEE1(rettype, op, arg1, alt, cond) \
562+
__PVOP_ALT_CALLEESAVE(rettype, op, alt, cond, PVOP_CALL_ARG1(arg1))
563+
#define PVOP_ALT_VCALLEE1(op, arg1, alt, cond) \
564+
__PVOP_ALT_VCALLEESAVE(op, alt, cond, PVOP_CALL_ARG1(arg1))
518565

519566

520567
#define PVOP_CALL2(rettype, op, arg1, arg2) \

0 commit comments

Comments
 (0)