@@ -348,11 +348,23 @@ extern struct paravirt_patch_template pv_ops;
348
348
#define paravirt_clobber (clobber ) \
349
349
[paravirt_clobber] "i" (clobber)
350
350
351
+ /*
352
+ * Generate some code, and mark it as patchable by the
353
+ * apply_paravirt() alternate instruction patcher.
354
+ */
355
+ #define _paravirt_alt (insn_string , type , clobber ) \
356
+ "771:\n\t" insn_string "\n" "772:\n" \
357
+ ".pushsection .parainstructions,\"a\"\n" \
358
+ _ASM_ALIGN "\n" \
359
+ _ASM_PTR " 771b\n" \
360
+ " .byte " type "\n" \
361
+ " .byte 772b-771b\n" \
362
+ " .short " clobber "\n" \
363
+ ".popsection\n"
364
+
351
365
/* Generate patchable code, with the default asm parameters. */
352
- #define paravirt_call \
353
- "PARAVIRT_CALL type=\"%c[paravirt_typenum]\"" \
354
- " clobber=\"%c[paravirt_clobber]\"" \
355
- " pv_opptr=\"%c[paravirt_opptr]\";"
366
+ #define paravirt_alt (insn_string ) \
367
+ _paravirt_alt(insn_string, "%c[paravirt_typenum]", "%c[paravirt_clobber]")
356
368
357
369
/* Simple instruction patching code. */
358
370
#define NATIVE_LABEL (a ,x ,b ) "\n\t.globl " a #x "_" #b "\n" a #x "_" #b ":\n\t"
@@ -372,6 +384,16 @@ unsigned native_patch(u8 type, void *ibuf, unsigned long addr, unsigned len);
372
384
373
385
int paravirt_disable_iospace (void );
374
386
387
+ /*
388
+ * This generates an indirect call based on the operation type number.
389
+ * The type number, computed in PARAVIRT_PATCH, is derived from the
390
+ * offset into the paravirt_patch_template structure, and can therefore be
391
+ * freely converted back into a structure offset.
392
+ */
393
+ #define PARAVIRT_CALL \
394
+ ANNOTATE_RETPOLINE_SAFE \
395
+ "call *%c[paravirt_opptr];"
396
+
375
397
/*
376
398
* These macros are intended to wrap calls through one of the paravirt
377
399
* ops structs, so that they can be later identified and patched at
@@ -509,7 +531,7 @@ int paravirt_disable_iospace(void);
509
531
/* since this condition will never hold */ \
510
532
if (sizeof (rettype ) > sizeof (unsigned long )) { \
511
533
asm volatile (pre \
512
- paravirt_call \
534
+ paravirt_alt ( PARAVIRT_CALL ) \
513
535
post \
514
536
: call_clbr , ASM_CALL_CONSTRAINT \
515
537
: paravirt_type (op ), \
@@ -519,7 +541,7 @@ int paravirt_disable_iospace(void);
519
541
__ret = (rettype)((((u64)__edx) << 32) | __eax); \
520
542
} else { \
521
543
asm volatile(pre \
522
- paravirt_call \
544
+ paravirt_alt(PARAVIRT_CALL) \
523
545
post \
524
546
: call_clbr, ASM_CALL_CONSTRAINT \
525
547
: paravirt_type(op), \
@@ -546,7 +568,7 @@ int paravirt_disable_iospace(void);
546
568
PVOP_VCALL_ARGS ; \
547
569
PVOP_TEST_NULL (op ); \
548
570
asm volatile (pre \
549
- paravirt_call \
571
+ paravirt_alt ( PARAVIRT_CALL ) \
550
572
post \
551
573
: call_clbr , ASM_CALL_CONSTRAINT \
552
574
: paravirt_type (op ), \
@@ -664,26 +686,6 @@ struct paravirt_patch_site {
664
686
extern struct paravirt_patch_site __parainstructions [],
665
687
__parainstructions_end [];
666
688
667
- #else /* __ASSEMBLY__ */
668
-
669
- /*
670
- * This generates an indirect call based on the operation type number.
671
- * The type number, computed in PARAVIRT_PATCH, is derived from the
672
- * offset into the paravirt_patch_template structure, and can therefore be
673
- * freely converted back into a structure offset.
674
- */
675
- .macro PARAVIRT_CALL type :req clobber :req pv_opptr :req
676
- 771 : ANNOTATE_RETPOLINE_SAFE
677
- call * \pv_opptr
678
- 772 : .pushsection .parainstructions ,"a"
679
- _ASM_ALIGN
680
- _ASM_PTR 771b
681
- .byte \type
682
- .byte 772b - 771b
683
- .short \clobber
684
- .popsection
685
- .endm
686
-
687
689
#endif /* __ASSEMBLY__ */
688
690
689
691
#endif /* _ASM_X86_PARAVIRT_TYPES_H */
0 commit comments