Merge branch 'clockevents/4.21' of http://git.linaro.org/people/daniel.lezcano/linux...
[linux/fpc-iii.git] / arch / x86 / kernel / paravirt_patch_32.c
blobde138d3912e45972b432832793a015b39886c2bc
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 */
17 return 0;
19 #endif
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");
24 #endif
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)
35 switch (type) {
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);
45 #endif
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);
52 break;
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);
59 break;
60 #endif
62 default:
63 break;
65 #undef PATCH_SITE
66 return paravirt_patch_default(type, ibuf, addr, len);