Skip to content

Commit 1462eb3

Browse files
author
Peter Zijlstra
committed
x86/xen: Rework the xen_{cpu,irq,mmu}_opsarrays
In order to allow objtool to make sense of all the various paravirt functions, it needs to either parse whole pv_ops[] tables, or observe individual assignments in the form: bf87: 48 c7 05 00 00 00 00 00 00 00 00 movq $0x0,0x0(%rip) bf92 <xen_init_spinlocks+0x5f> bf8a: R_X86_64_PC32 pv_ops+0x268 As is, xen_cpu_ops[] is at offset +0 in pv_ops[] and could thus be parsed as a 'normal' pv_ops[] table, however xen_irq_ops[] and xen_mmu_ops[] are not. Worse, both the latter two are compiled into the individual assignment for by current GCC, but that's not something one can rely on. Therefore, convert all three into full pv_ops[] tables. This has the benefit of not needing to teach objtool about the offsets and resulting in more conservative code-gen. Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Juergen Gross <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 847d931 commit 1462eb3

File tree

3 files changed

+90
-83
lines changed

3 files changed

+90
-83
lines changed

arch/x86/xen/enlighten_pv.c

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,52 +1050,54 @@ static const struct pv_info xen_info __initconst = {
10501050
.name = "Xen",
10511051
};
10521052

1053-
static const struct pv_cpu_ops xen_cpu_ops __initconst = {
1054-
.cpuid = xen_cpuid,
1053+
static const typeof(pv_ops) xen_cpu_ops __initconst = {
1054+
.cpu = {
1055+
.cpuid = xen_cpuid,
10551056

1056-
.set_debugreg = xen_set_debugreg,
1057-
.get_debugreg = xen_get_debugreg,
1057+
.set_debugreg = xen_set_debugreg,
1058+
.get_debugreg = xen_get_debugreg,
10581059

1059-
.read_cr0 = xen_read_cr0,
1060-
.write_cr0 = xen_write_cr0,
1060+
.read_cr0 = xen_read_cr0,
1061+
.write_cr0 = xen_write_cr0,
10611062

1062-
.write_cr4 = xen_write_cr4,
1063+
.write_cr4 = xen_write_cr4,
10631064

1064-
.wbinvd = native_wbinvd,
1065+
.wbinvd = native_wbinvd,
10651066

1066-
.read_msr = xen_read_msr,
1067-
.write_msr = xen_write_msr,
1067+
.read_msr = xen_read_msr,
1068+
.write_msr = xen_write_msr,
10681069

1069-
.read_msr_safe = xen_read_msr_safe,
1070-
.write_msr_safe = xen_write_msr_safe,
1070+
.read_msr_safe = xen_read_msr_safe,
1071+
.write_msr_safe = xen_write_msr_safe,
10711072

1072-
.read_pmc = xen_read_pmc,
1073+
.read_pmc = xen_read_pmc,
10731074

1074-
.load_tr_desc = paravirt_nop,
1075-
.set_ldt = xen_set_ldt,
1076-
.load_gdt = xen_load_gdt,
1077-
.load_idt = xen_load_idt,
1078-
.load_tls = xen_load_tls,
1079-
.load_gs_index = xen_load_gs_index,
1075+
.load_tr_desc = paravirt_nop,
1076+
.set_ldt = xen_set_ldt,
1077+
.load_gdt = xen_load_gdt,
1078+
.load_idt = xen_load_idt,
1079+
.load_tls = xen_load_tls,
1080+
.load_gs_index = xen_load_gs_index,
10801081

1081-
.alloc_ldt = xen_alloc_ldt,
1082-
.free_ldt = xen_free_ldt,
1082+
.alloc_ldt = xen_alloc_ldt,
1083+
.free_ldt = xen_free_ldt,
10831084

1084-
.store_tr = xen_store_tr,
1085+
.store_tr = xen_store_tr,
10851086

1086-
.write_ldt_entry = xen_write_ldt_entry,
1087-
.write_gdt_entry = xen_write_gdt_entry,
1088-
.write_idt_entry = xen_write_idt_entry,
1089-
.load_sp0 = xen_load_sp0,
1087+
.write_ldt_entry = xen_write_ldt_entry,
1088+
.write_gdt_entry = xen_write_gdt_entry,
1089+
.write_idt_entry = xen_write_idt_entry,
1090+
.load_sp0 = xen_load_sp0,
10901091

10911092
#ifdef CONFIG_X86_IOPL_IOPERM
1092-
.invalidate_io_bitmap = xen_invalidate_io_bitmap,
1093-
.update_io_bitmap = xen_update_io_bitmap,
1093+
.invalidate_io_bitmap = xen_invalidate_io_bitmap,
1094+
.update_io_bitmap = xen_update_io_bitmap,
10941095
#endif
1095-
.io_delay = xen_io_delay,
1096+
.io_delay = xen_io_delay,
10961097

1097-
.start_context_switch = paravirt_start_context_switch,
1098-
.end_context_switch = xen_end_context_switch,
1098+
.start_context_switch = paravirt_start_context_switch,
1099+
.end_context_switch = xen_end_context_switch,
1100+
},
10991101
};
11001102

11011103
static void xen_restart(char *msg)
@@ -1231,7 +1233,7 @@ asmlinkage __visible void __init xen_start_kernel(void)
12311233

12321234
/* Install Xen paravirt ops */
12331235
pv_info = xen_info;
1234-
pv_ops.cpu = xen_cpu_ops;
1236+
pv_ops.cpu = xen_cpu_ops.cpu;
12351237
paravirt_iret = xen_iret;
12361238
xen_init_irq_ops();
12371239

arch/x86/xen/irq.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,20 @@ static void xen_halt(void)
9494
xen_safe_halt();
9595
}
9696

97-
static const struct pv_irq_ops xen_irq_ops __initconst = {
98-
.save_fl = PV_CALLEE_SAVE(xen_save_fl),
99-
.irq_disable = PV_CALLEE_SAVE(xen_irq_disable),
100-
.irq_enable = PV_CALLEE_SAVE(xen_irq_enable),
97+
static const typeof(pv_ops) xen_irq_ops __initconst = {
98+
.irq = {
10199

102-
.safe_halt = xen_safe_halt,
103-
.halt = xen_halt,
100+
.save_fl = PV_CALLEE_SAVE(xen_save_fl),
101+
.irq_disable = PV_CALLEE_SAVE(xen_irq_disable),
102+
.irq_enable = PV_CALLEE_SAVE(xen_irq_enable),
103+
104+
.safe_halt = xen_safe_halt,
105+
.halt = xen_halt,
106+
},
104107
};
105108

106109
void __init xen_init_irq_ops(void)
107110
{
108-
pv_ops.irq = xen_irq_ops;
111+
pv_ops.irq = xen_irq_ops.irq;
109112
x86_init.irqs.intr_init = xen_init_IRQ;
110113
}

arch/x86/xen/mmu_pv.c

Lines changed: 46 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2076,75 +2076,77 @@ static void xen_leave_lazy_mmu(void)
20762076
preempt_enable();
20772077
}
20782078

2079-
static const struct pv_mmu_ops xen_mmu_ops __initconst = {
2080-
.read_cr2 = __PV_IS_CALLEE_SAVE(xen_read_cr2),
2081-
.write_cr2 = xen_write_cr2,
2079+
static const typeof(pv_ops) xen_mmu_ops __initconst = {
2080+
.mmu = {
2081+
.read_cr2 = __PV_IS_CALLEE_SAVE(xen_read_cr2),
2082+
.write_cr2 = xen_write_cr2,
20822083

2083-
.read_cr3 = xen_read_cr3,
2084-
.write_cr3 = xen_write_cr3_init,
2084+
.read_cr3 = xen_read_cr3,
2085+
.write_cr3 = xen_write_cr3_init,
20852086

2086-
.flush_tlb_user = xen_flush_tlb,
2087-
.flush_tlb_kernel = xen_flush_tlb,
2088-
.flush_tlb_one_user = xen_flush_tlb_one_user,
2089-
.flush_tlb_multi = xen_flush_tlb_multi,
2090-
.tlb_remove_table = tlb_remove_table,
2087+
.flush_tlb_user = xen_flush_tlb,
2088+
.flush_tlb_kernel = xen_flush_tlb,
2089+
.flush_tlb_one_user = xen_flush_tlb_one_user,
2090+
.flush_tlb_multi = xen_flush_tlb_multi,
2091+
.tlb_remove_table = tlb_remove_table,
20912092

2092-
.pgd_alloc = xen_pgd_alloc,
2093-
.pgd_free = xen_pgd_free,
2093+
.pgd_alloc = xen_pgd_alloc,
2094+
.pgd_free = xen_pgd_free,
20942095

2095-
.alloc_pte = xen_alloc_pte_init,
2096-
.release_pte = xen_release_pte_init,
2097-
.alloc_pmd = xen_alloc_pmd_init,
2098-
.release_pmd = xen_release_pmd_init,
2096+
.alloc_pte = xen_alloc_pte_init,
2097+
.release_pte = xen_release_pte_init,
2098+
.alloc_pmd = xen_alloc_pmd_init,
2099+
.release_pmd = xen_release_pmd_init,
20992100

2100-
.set_pte = xen_set_pte_init,
2101-
.set_pmd = xen_set_pmd_hyper,
2101+
.set_pte = xen_set_pte_init,
2102+
.set_pmd = xen_set_pmd_hyper,
21022103

2103-
.ptep_modify_prot_start = xen_ptep_modify_prot_start,
2104-
.ptep_modify_prot_commit = xen_ptep_modify_prot_commit,
2104+
.ptep_modify_prot_start = xen_ptep_modify_prot_start,
2105+
.ptep_modify_prot_commit = xen_ptep_modify_prot_commit,
21052106

2106-
.pte_val = PV_CALLEE_SAVE(xen_pte_val),
2107-
.pgd_val = PV_CALLEE_SAVE(xen_pgd_val),
2107+
.pte_val = PV_CALLEE_SAVE(xen_pte_val),
2108+
.pgd_val = PV_CALLEE_SAVE(xen_pgd_val),
21082109

2109-
.make_pte = PV_CALLEE_SAVE(xen_make_pte_init),
2110-
.make_pgd = PV_CALLEE_SAVE(xen_make_pgd),
2110+
.make_pte = PV_CALLEE_SAVE(xen_make_pte_init),
2111+
.make_pgd = PV_CALLEE_SAVE(xen_make_pgd),
21112112

2112-
.set_pud = xen_set_pud_hyper,
2113+
.set_pud = xen_set_pud_hyper,
21132114

2114-
.make_pmd = PV_CALLEE_SAVE(xen_make_pmd),
2115-
.pmd_val = PV_CALLEE_SAVE(xen_pmd_val),
2115+
.make_pmd = PV_CALLEE_SAVE(xen_make_pmd),
2116+
.pmd_val = PV_CALLEE_SAVE(xen_pmd_val),
21162117

2117-
.pud_val = PV_CALLEE_SAVE(xen_pud_val),
2118-
.make_pud = PV_CALLEE_SAVE(xen_make_pud),
2119-
.set_p4d = xen_set_p4d_hyper,
2118+
.pud_val = PV_CALLEE_SAVE(xen_pud_val),
2119+
.make_pud = PV_CALLEE_SAVE(xen_make_pud),
2120+
.set_p4d = xen_set_p4d_hyper,
21202121

2121-
.alloc_pud = xen_alloc_pmd_init,
2122-
.release_pud = xen_release_pmd_init,
2122+
.alloc_pud = xen_alloc_pmd_init,
2123+
.release_pud = xen_release_pmd_init,
21232124

21242125
#if CONFIG_PGTABLE_LEVELS >= 5
2125-
.p4d_val = PV_CALLEE_SAVE(xen_p4d_val),
2126-
.make_p4d = PV_CALLEE_SAVE(xen_make_p4d),
2126+
.p4d_val = PV_CALLEE_SAVE(xen_p4d_val),
2127+
.make_p4d = PV_CALLEE_SAVE(xen_make_p4d),
21272128
#endif
21282129

2129-
.activate_mm = xen_activate_mm,
2130-
.dup_mmap = xen_dup_mmap,
2131-
.exit_mmap = xen_exit_mmap,
2130+
.activate_mm = xen_activate_mm,
2131+
.dup_mmap = xen_dup_mmap,
2132+
.exit_mmap = xen_exit_mmap,
21322133

2133-
.lazy_mode = {
2134-
.enter = paravirt_enter_lazy_mmu,
2135-
.leave = xen_leave_lazy_mmu,
2136-
.flush = paravirt_flush_lazy_mmu,
2137-
},
2134+
.lazy_mode = {
2135+
.enter = paravirt_enter_lazy_mmu,
2136+
.leave = xen_leave_lazy_mmu,
2137+
.flush = paravirt_flush_lazy_mmu,
2138+
},
21382139

2139-
.set_fixmap = xen_set_fixmap,
2140+
.set_fixmap = xen_set_fixmap,
2141+
},
21402142
};
21412143

21422144
void __init xen_init_mmu_ops(void)
21432145
{
21442146
x86_init.paging.pagetable_init = xen_pagetable_init;
21452147
x86_init.hyper.init_after_bootmem = xen_after_bootmem;
21462148

2147-
pv_ops.mmu = xen_mmu_ops;
2149+
pv_ops.mmu = xen_mmu_ops.mmu;
21482150

21492151
memset(dummy_mapping, 0xff, PAGE_SIZE);
21502152
}

0 commit comments

Comments
 (0)