1 // SPDX-License-Identifier: GPL-2.0
2 #include <asm/paravirt.h>
4 #ifdef CONFIG_PARAVIRT_XXL
5 DEF_NATIVE(irq
, irq_disable
, "cli");
6 DEF_NATIVE(irq
, irq_enable
, "sti");
7 DEF_NATIVE(irq
, restore_fl
, "push %eax; popf");
8 DEF_NATIVE(irq
, save_fl
, "pushf; pop %eax");
9 DEF_NATIVE(cpu
, iret
, "iret");
10 DEF_NATIVE(mmu
, read_cr2
, "mov %cr2, %eax");
11 DEF_NATIVE(mmu
, write_cr3
, "mov %eax, %cr3");
12 DEF_NATIVE(mmu
, read_cr3
, "mov %cr3, %eax");
14 unsigned paravirt_patch_ident_64(void *insnbuf
, unsigned len
)
16 /* arg in %edx:%eax, return in %edx:%eax */
21 #if defined(CONFIG_PARAVIRT_SPINLOCKS)
22 DEF_NATIVE(lock
, queued_spin_unlock
, "movb $0, (%eax)");
23 DEF_NATIVE(lock
, vcpu_is_preempted
, "xor %eax, %eax");
26 extern bool pv_is_native_spin_unlock(void);
27 extern bool pv_is_native_vcpu_is_preempted(void);
29 unsigned native_patch(u8 type
, void *ibuf
, unsigned long addr
, unsigned len
)
31 #define PATCH_SITE(ops, x) \
32 case PARAVIRT_PATCH(ops.x): \
33 return paravirt_patch_insns(ibuf, len, start_##ops##_##x, end_##ops##_##x)
36 #ifdef CONFIG_PARAVIRT_XXL
37 PATCH_SITE(irq
, irq_disable
);
38 PATCH_SITE(irq
, irq_enable
);
39 PATCH_SITE(irq
, restore_fl
);
40 PATCH_SITE(irq
, save_fl
);
41 PATCH_SITE(cpu
, iret
);
42 PATCH_SITE(mmu
, read_cr2
);
43 PATCH_SITE(mmu
, read_cr3
);
44 PATCH_SITE(mmu
, write_cr3
);
46 #if defined(CONFIG_PARAVIRT_SPINLOCKS)
47 case PARAVIRT_PATCH(lock
.queued_spin_unlock
):
48 if (pv_is_native_spin_unlock())
49 return paravirt_patch_insns(ibuf
, len
,
50 start_lock_queued_spin_unlock
,
51 end_lock_queued_spin_unlock
);
54 case PARAVIRT_PATCH(lock
.vcpu_is_preempted
):
55 if (pv_is_native_vcpu_is_preempted())
56 return paravirt_patch_insns(ibuf
, len
,
57 start_lock_vcpu_is_preempted
,
58 end_lock_vcpu_is_preempted
);
66 return paravirt_patch_default(type
, ibuf
, addr
, len
);