xref: /openbmc/linux/arch/x86/xen/xen-ops.h (revision 16f6ccde74a6f8538c62f127f17207c75f4dba7a)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
29702785aSThomas Gleixner #ifndef XEN_OPS_H
39702785aSThomas Gleixner #define XEN_OPS_H
49702785aSThomas Gleixner 
59702785aSThomas Gleixner #include <linux/init.h>
6ee7686bcSJeremy Fitzhardinge #include <linux/clocksource.h>
7ee523ca1SJeremy Fitzhardinge #include <linux/irqreturn.h>
8e04d0d07SIsaku Yamahata #include <xen/xen-ops.h>
99702785aSThomas Gleixner 
109702785aSThomas Gleixner /* These are code, but not functions.  Defined in entry.S */
119702785aSThomas Gleixner extern const char xen_failsafe_callback[];
129702785aSThomas Gleixner 
13b75b7f8eSPeter Zijlstra void xen_entry_SYSENTER_compat(void);
14f0feed10SJuergen Gross #ifdef CONFIG_X86_64
15b75b7f8eSPeter Zijlstra void xen_entry_SYSCALL_64(void);
16b75b7f8eSPeter Zijlstra void xen_entry_SYSCALL_compat(void);
17f0feed10SJuergen Gross #endif
18f0feed10SJuergen Gross 
1938341432SJeremy Fitzhardinge extern void *xen_initial_gdt;
2038341432SJeremy Fitzhardinge 
210e91398fSJeremy Fitzhardinge struct trap_info;
229702785aSThomas Gleixner void xen_copy_trap_info(struct trap_info *traps);
239702785aSThomas Gleixner 
24602aa0efSJuergen Gross DECLARE_PER_CPU_ALIGNED(struct vcpu_info, xen_vcpu_info);
259702785aSThomas Gleixner DECLARE_PER_CPU(unsigned long, xen_cr3);
269f79991dSJeremy Fitzhardinge DECLARE_PER_CPU(unsigned long, xen_current_cr3);
279702785aSThomas Gleixner 
289702785aSThomas Gleixner extern struct start_info *xen_start_info;
29a0d695c8SJeremy Fitzhardinge extern struct shared_info xen_dummy_shared_info;
309702785aSThomas Gleixner extern struct shared_info *HYPERVISOR_shared_info;
319702785aSThomas Gleixner 
32d04b1ae5SJuergen Gross extern bool xen_fifo_events;
33d04b1ae5SJuergen Gross 
34d5edbc1fSJeremy Fitzhardinge void xen_setup_mfn_list_list(void);
35fa24ba62SIan Campbell void xen_build_mfn_list_list(void);
36319f3ba5SJeremy Fitzhardinge void xen_setup_machphys_mapping(void);
373699aad0SKonrad Rzeszutek Wilk void xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn);
386c2681c8SJuergen Gross void __init xen_reserve_special_pages(void);
3904414baaSJuergen Gross void __init xen_pt_check_e820(void);
40319f3ba5SJeremy Fitzhardinge 
41aa8532c3SDavid Vrabel void xen_mm_pin_all(void);
42aa8532c3SDavid Vrabel void xen_mm_unpin_all(void);
4370e61199SJuergen Gross #ifdef CONFIG_X86_64
4470e61199SJuergen Gross void __init xen_relocate_p2m(void);
4570e61199SJuergen Gross #endif
46149fbd6aSJuergen Gross void __init xen_do_remap_nonram(void);
47149fbd6aSJuergen Gross void __init xen_add_remap_nonram(phys_addr_t maddr, phys_addr_t paddr,
48149fbd6aSJuergen Gross 				 unsigned long size);
4941f2e477SJeremy Fitzhardinge 
50242d0c3cSJuergen Gross void __init xen_chk_is_e820_usable(phys_addr_t start, phys_addr_t size,
51242d0c3cSJuergen Gross 				   const char *component);
525b8e7d80SJuergen Gross unsigned long __ref xen_chk_extra_mem(unsigned long pfn);
535b8e7d80SJuergen Gross void __init xen_inv_extra_mem(void);
541f3ac86bSJuergen Gross void __init xen_remap_memory(void);
559ddac5b7SJuergen Gross phys_addr_t __init xen_find_free_area(phys_addr_t size);
569702785aSThomas Gleixner char * __init xen_memory_setup(void);
579702785aSThomas Gleixner void __init xen_arch_setup(void);
58079c4baaSJan Beulich void xen_banner(void);
59e2a81bafSJeremy Fitzhardinge void xen_enable_sysenter(void);
606fcac6d3SJeremy Fitzhardinge void xen_enable_syscall(void);
619c7a7942SJeremy Fitzhardinge void xen_vcpu_restore(void);
629702785aSThomas Gleixner 
63e9daff24SKonrad Rzeszutek Wilk void xen_hvm_init_shared_info(void);
64512b109eSStefano Stabellini void xen_unplug_emulated_devices(void);
6538e20b07SSheng Yang 
66d451bb7aSJeremy Fitzhardinge void __init xen_build_dynamic_phys_to_machine(void);
67054954ebSJuergen Gross void __init xen_vmalloc_p2m_tree(void);
68d451bb7aSJeremy Fitzhardinge 
690d1edf46SJeremy Fitzhardinge void xen_init_irq_ops(void);
709702785aSThomas Gleixner void xen_setup_timer(int cpu);
71be012920SIan Campbell void xen_setup_runstate_info(int cpu);
72d68d82afSAlex Nixon void xen_teardown_timer(int cpu);
739702785aSThomas Gleixner void xen_setup_cpu_clockevents(void);
742229f70bSJoao Martins void xen_save_time_memory_area(void);
752229f70bSJoao Martins void xen_restore_time_memory_area(void);
767b25b9cbSPavel Tatashin void xen_init_time_ops(void);
777b25b9cbSPavel Tatashin void xen_hvm_init_time_ops(void);
789702785aSThomas Gleixner 
79f0d73394SJeremy Fitzhardinge bool xen_vcpu_stolen(int vcpu);
80f0d73394SJeremy Fitzhardinge 
8112ad6cfcSJuergen Gross void xen_vcpu_setup(int cpu);
82ad73fd59SAnkur Arora void xen_vcpu_info_reset(int cpu);
8337af46efSAl Viro void xen_setup_vcpu_info_placement(void);
849702785aSThomas Gleixner 
85a9e7062dSJeremy Fitzhardinge #ifdef CONFIG_SMP
86a9e7062dSJeremy Fitzhardinge void xen_smp_init(void);
8799bbb3a8SStefano Stabellini void __init xen_hvm_smp_init(void);
889702785aSThomas Gleixner 
89b78936e1SMike Travis extern cpumask_var_t xen_cpu_initialized_map;
90a9e7062dSJeremy Fitzhardinge #else
xen_smp_init(void)91a9e7062dSJeremy Fitzhardinge static inline void xen_smp_init(void) {}
xen_hvm_smp_init(void)9299bbb3a8SStefano Stabellini static inline void xen_hvm_smp_init(void) {}
93a9e7062dSJeremy Fitzhardinge #endif
940e91398fSJeremy Fitzhardinge 
95b4ecc126SJeremy Fitzhardinge #ifdef CONFIG_PARAVIRT_SPINLOCKS
96b4ecc126SJeremy Fitzhardinge void __init xen_init_spinlocks(void);
97148f9bb8SPaul Gortmaker void xen_init_lock_cpu(int cpu);
98b4ecc126SJeremy Fitzhardinge void xen_uninit_lock_cpu(int cpu);
99b4ecc126SJeremy Fitzhardinge #else
xen_init_spinlocks(void)100b4ecc126SJeremy Fitzhardinge static inline void xen_init_spinlocks(void)
101b4ecc126SJeremy Fitzhardinge {
102b4ecc126SJeremy Fitzhardinge }
xen_init_lock_cpu(int cpu)103b4ecc126SJeremy Fitzhardinge static inline void xen_init_lock_cpu(int cpu)
104b4ecc126SJeremy Fitzhardinge {
105b4ecc126SJeremy Fitzhardinge }
xen_uninit_lock_cpu(int cpu)106b4ecc126SJeremy Fitzhardinge static inline void xen_uninit_lock_cpu(int cpu)
107b4ecc126SJeremy Fitzhardinge {
108b4ecc126SJeremy Fitzhardinge }
109b4ecc126SJeremy Fitzhardinge #endif
1109702785aSThomas Gleixner 
111c2419b4aSJeremy Fitzhardinge struct dom0_vga_console_info;
112c2419b4aSJeremy Fitzhardinge 
113934ef33eSJan Beulich #ifdef CONFIG_XEN_DOM0
114934ef33eSJan Beulich void __init xen_init_vga(const struct dom0_vga_console_info *, size_t size,
115934ef33eSJan Beulich 			 struct screen_info *);
116c2419b4aSJeremy Fitzhardinge #else
xen_init_vga(const struct dom0_vga_console_info * info,size_t size,struct screen_info * si)117c2419b4aSJeremy Fitzhardinge static inline void __init xen_init_vga(const struct dom0_vga_console_info *info,
118934ef33eSJan Beulich 				       size_t size, struct screen_info *si)
119c2419b4aSJeremy Fitzhardinge {
120c2419b4aSJeremy Fitzhardinge }
121c2419b4aSJeremy Fitzhardinge #endif
122c2419b4aSJeremy Fitzhardinge 
1234d1ab432SJan Beulich void xen_add_preferred_consoles(void);
1244d1ab432SJan Beulich 
125fc5fee86SJason A. Donenfeld void __init xen_init_apic(void);
126fc5fee86SJason A. Donenfeld 
127c7341d6aSDaniel Kiper #ifdef CONFIG_XEN_EFI
12872813bfbSRoger Pau Monne extern void xen_efi_init(struct boot_params *boot_params);
129c7341d6aSDaniel Kiper #else
xen_efi_init(struct boot_params * boot_params)13072813bfbSRoger Pau Monne static inline void __init xen_efi_init(struct boot_params *boot_params)
131c7341d6aSDaniel Kiper {
132c7341d6aSDaniel Kiper }
133c7341d6aSDaniel Kiper #endif
134c7341d6aSDaniel Kiper 
135edcb5cf8SJuergen Gross __visible void xen_irq_enable_direct(void);
136edcb5cf8SJuergen Gross __visible void xen_irq_disable_direct(void);
137edcb5cf8SJuergen Gross __visible unsigned long xen_save_fl_direct(void);
1389702785aSThomas Gleixner 
13955aedddbSPeter Zijlstra __visible unsigned long xen_read_cr2(void);
14055aedddbSPeter Zijlstra __visible unsigned long xen_read_cr2_direct(void);
14155aedddbSPeter Zijlstra 
142997409d3SJeremy Fitzhardinge /* These are not functions, and cannot be called normally */
143eb86b5fdSAndi Kleen __visible void xen_iret(void);
144e2a81bafSJeremy Fitzhardinge 
145f09f6d19SDonald Dutile extern int xen_panic_handler_init(void);
146f09f6d19SDonald Dutile 
14798f2a47aSVitaly Kuznetsov int xen_cpuhp_setup(int (*cpu_up_prepare_cb)(unsigned int),
14898f2a47aSVitaly Kuznetsov 		    int (*cpu_dead_cb)(unsigned int));
14998f2a47aSVitaly Kuznetsov 
15098f2a47aSVitaly Kuznetsov void xen_pin_vcpu(int cpu);
15198f2a47aSVitaly Kuznetsov 
15298f2a47aSVitaly Kuznetsov void xen_emergency_restart(void);
153fb9b7b4bSArnd Bergmann void xen_force_evtchn_callback(void);
154fb9b7b4bSArnd Bergmann 
1559963236dSVitaly Kuznetsov #ifdef CONFIG_XEN_PV
1569963236dSVitaly Kuznetsov void xen_pv_pre_suspend(void);
1579963236dSVitaly Kuznetsov void xen_pv_post_suspend(int suspend_cancelled);
158fb9b7b4bSArnd Bergmann void xen_start_kernel(struct start_info *si);
1599963236dSVitaly Kuznetsov #else
xen_pv_pre_suspend(void)1609963236dSVitaly Kuznetsov static inline void xen_pv_pre_suspend(void) {}
xen_pv_post_suspend(int suspend_cancelled)1619963236dSVitaly Kuznetsov static inline void xen_pv_post_suspend(int suspend_cancelled) {}
1629963236dSVitaly Kuznetsov #endif
1639963236dSVitaly Kuznetsov 
1649963236dSVitaly Kuznetsov #ifdef CONFIG_XEN_PVHVM
1659963236dSVitaly Kuznetsov void xen_hvm_post_suspend(int suspend_cancelled);
1669963236dSVitaly Kuznetsov #else
xen_hvm_post_suspend(int suspend_cancelled)1679963236dSVitaly Kuznetsov static inline void xen_hvm_post_suspend(int suspend_cancelled) {}
1689963236dSVitaly Kuznetsov #endif
16998f2a47aSVitaly Kuznetsov 
1704cd44fd3SRoger Pau Monne /*
1714cd44fd3SRoger Pau Monne  * The maximum amount of extra memory compared to the base size.  The
1724cd44fd3SRoger Pau Monne  * main scaling factor is the size of struct page.  At extreme ratios
1734cd44fd3SRoger Pau Monne  * of base:extra, all the base memory can be filled with page
1744cd44fd3SRoger Pau Monne  * structures for the extra memory, leaving no space for anything
1754cd44fd3SRoger Pau Monne  * else.
1764cd44fd3SRoger Pau Monne  *
1774cd44fd3SRoger Pau Monne  * 10x seems like a reasonable balance between scaling flexibility and
1784cd44fd3SRoger Pau Monne  * leaving a practically usable system.
1794cd44fd3SRoger Pau Monne  */
1804cd44fd3SRoger Pau Monne #define EXTRA_MEM_RATIO		(10)
1814cd44fd3SRoger Pau Monne 
1824cd44fd3SRoger Pau Monne void xen_add_extra_mem(unsigned long start_pfn, unsigned long n_pfns);
1834cd44fd3SRoger Pau Monne 
184*31f29270SJuergen Gross #ifdef CONFIG_XEN_PV
185*31f29270SJuergen Gross void xen_hypercall_pv(void);
186*31f29270SJuergen Gross #endif
187*31f29270SJuergen Gross void xen_hypercall_hvm(void);
188*31f29270SJuergen Gross void xen_hypercall_amd(void);
189*31f29270SJuergen Gross void xen_hypercall_intel(void);
190*31f29270SJuergen Gross void xen_hypercall_setfunc(void);
191*31f29270SJuergen Gross void *__xen_hypercall_setfunc(void);
192*31f29270SJuergen Gross 
1939702785aSThomas Gleixner #endif /* XEN_OPS_H */
194