| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | #include <xen/xen.h> |
|---|
| 2 | 3 | #include <xen/events.h> |
|---|
| 3 | 4 | #include <xen/grant_table.h> |
|---|
| .. | .. |
|---|
| 14 | 15 | #include <xen/xen-ops.h> |
|---|
| 15 | 16 | #include <asm/xen/hypervisor.h> |
|---|
| 16 | 17 | #include <asm/xen/hypercall.h> |
|---|
| 17 | | -#include <asm/xen/xen-ops.h> |
|---|
| 18 | 18 | #include <asm/system_misc.h> |
|---|
| 19 | 19 | #include <asm/efi.h> |
|---|
| 20 | 20 | #include <linux/interrupt.h> |
|---|
| .. | .. |
|---|
| 29 | 29 | #include <linux/cpu.h> |
|---|
| 30 | 30 | #include <linux/console.h> |
|---|
| 31 | 31 | #include <linux/pvclock_gtod.h> |
|---|
| 32 | +#include <linux/reboot.h> |
|---|
| 32 | 33 | #include <linux/time64.h> |
|---|
| 33 | 34 | #include <linux/timekeeping.h> |
|---|
| 34 | 35 | #include <linux/timekeeper_internal.h> |
|---|
| .. | .. |
|---|
| 36 | 37 | |
|---|
| 37 | 38 | #include <linux/mm.h> |
|---|
| 38 | 39 | |
|---|
| 39 | | -struct start_info _xen_start_info; |
|---|
| 40 | +static struct start_info _xen_start_info; |
|---|
| 40 | 41 | struct start_info *xen_start_info = &_xen_start_info; |
|---|
| 41 | 42 | EXPORT_SYMBOL(xen_start_info); |
|---|
| 42 | 43 | |
|---|
| .. | .. |
|---|
| 62 | 63 | uint32_t xen_start_flags; |
|---|
| 63 | 64 | EXPORT_SYMBOL(xen_start_flags); |
|---|
| 64 | 65 | |
|---|
| 65 | | -int xen_remap_domain_gfn_array(struct vm_area_struct *vma, |
|---|
| 66 | | - unsigned long addr, |
|---|
| 67 | | - xen_pfn_t *gfn, int nr, |
|---|
| 68 | | - int *err_ptr, pgprot_t prot, |
|---|
| 69 | | - unsigned domid, |
|---|
| 70 | | - struct page **pages) |
|---|
| 71 | | -{ |
|---|
| 72 | | - return xen_xlate_remap_gfn_array(vma, addr, gfn, nr, err_ptr, |
|---|
| 73 | | - prot, domid, pages); |
|---|
| 74 | | -} |
|---|
| 75 | | -EXPORT_SYMBOL_GPL(xen_remap_domain_gfn_array); |
|---|
| 76 | | - |
|---|
| 77 | | -/* Not used by XENFEAT_auto_translated guests. */ |
|---|
| 78 | | -int xen_remap_domain_gfn_range(struct vm_area_struct *vma, |
|---|
| 79 | | - unsigned long addr, |
|---|
| 80 | | - xen_pfn_t gfn, int nr, |
|---|
| 81 | | - pgprot_t prot, unsigned domid, |
|---|
| 82 | | - struct page **pages) |
|---|
| 83 | | -{ |
|---|
| 84 | | - return -ENOSYS; |
|---|
| 85 | | -} |
|---|
| 86 | | -EXPORT_SYMBOL_GPL(xen_remap_domain_gfn_range); |
|---|
| 87 | | - |
|---|
| 88 | 66 | int xen_unmap_domain_gfn_range(struct vm_area_struct *vma, |
|---|
| 89 | 67 | int nr, struct page **pages) |
|---|
| 90 | 68 | { |
|---|
| 91 | 69 | return xen_xlate_unmap_gfn_range(vma, nr, pages); |
|---|
| 92 | 70 | } |
|---|
| 93 | 71 | EXPORT_SYMBOL_GPL(xen_unmap_domain_gfn_range); |
|---|
| 94 | | - |
|---|
| 95 | | -/* Not used by XENFEAT_auto_translated guests. */ |
|---|
| 96 | | -int xen_remap_domain_mfn_array(struct vm_area_struct *vma, |
|---|
| 97 | | - unsigned long addr, |
|---|
| 98 | | - xen_pfn_t *mfn, int nr, |
|---|
| 99 | | - int *err_ptr, pgprot_t prot, |
|---|
| 100 | | - unsigned int domid, struct page **pages) |
|---|
| 101 | | -{ |
|---|
| 102 | | - return -ENOSYS; |
|---|
| 103 | | -} |
|---|
| 104 | | -EXPORT_SYMBOL_GPL(xen_remap_domain_mfn_array); |
|---|
| 105 | 72 | |
|---|
| 106 | 73 | static void xen_read_wallclock(struct timespec64 *ts) |
|---|
| 107 | 74 | { |
|---|
| .. | .. |
|---|
| 184 | 151 | pr_info("Xen: initializing cpu%d\n", cpu); |
|---|
| 185 | 152 | vcpup = per_cpu_ptr(xen_vcpu_info, cpu); |
|---|
| 186 | 153 | |
|---|
| 187 | | - info.mfn = virt_to_gfn(vcpup); |
|---|
| 154 | + info.mfn = percpu_to_gfn(vcpup); |
|---|
| 188 | 155 | info.offset = xen_offset_in_page(vcpup); |
|---|
| 189 | 156 | |
|---|
| 190 | 157 | err = HYPERVISOR_vcpu_op(VCPUOP_register_vcpu_info, xen_vcpu_nr(cpu), |
|---|
| .. | .. |
|---|
| 192 | 159 | BUG_ON(err); |
|---|
| 193 | 160 | per_cpu(xen_vcpu, cpu) = vcpup; |
|---|
| 194 | 161 | |
|---|
| 195 | | - xen_setup_runstate_info(cpu); |
|---|
| 162 | + if (!xen_kernel_unmapped_at_usr()) |
|---|
| 163 | + xen_setup_runstate_info(cpu); |
|---|
| 196 | 164 | |
|---|
| 197 | 165 | after_register_vcpu_info: |
|---|
| 198 | 166 | enable_percpu_irq(xen_events_irq, 0); |
|---|
| .. | .. |
|---|
| 214 | 182 | BUG_ON(rc); |
|---|
| 215 | 183 | } |
|---|
| 216 | 184 | |
|---|
| 217 | | -static void xen_restart(enum reboot_mode reboot_mode, const char *cmd) |
|---|
| 185 | +static int xen_restart(struct notifier_block *nb, unsigned long action, |
|---|
| 186 | + void *data) |
|---|
| 218 | 187 | { |
|---|
| 219 | 188 | xen_reboot(SHUTDOWN_reboot); |
|---|
| 189 | + |
|---|
| 190 | + return NOTIFY_DONE; |
|---|
| 220 | 191 | } |
|---|
| 221 | 192 | |
|---|
| 193 | +static struct notifier_block xen_restart_nb = { |
|---|
| 194 | + .notifier_call = xen_restart, |
|---|
| 195 | + .priority = 192, |
|---|
| 196 | +}; |
|---|
| 222 | 197 | |
|---|
| 223 | 198 | static void xen_power_off(void) |
|---|
| 224 | 199 | { |
|---|
| .. | .. |
|---|
| 275 | 250 | * see Documentation/devicetree/bindings/arm/xen.txt for the |
|---|
| 276 | 251 | * documentation of the Xen Device Tree format. |
|---|
| 277 | 252 | */ |
|---|
| 278 | | -#define GRANT_TABLE_PHYSADDR 0 |
|---|
| 279 | 253 | void __init xen_early_init(void) |
|---|
| 280 | 254 | { |
|---|
| 281 | 255 | of_scan_flat_dt(fdt_find_hyper_node, NULL); |
|---|
| .. | .. |
|---|
| 420 | 394 | return -EINVAL; |
|---|
| 421 | 395 | } |
|---|
| 422 | 396 | |
|---|
| 423 | | - xen_time_setup_guest(); |
|---|
| 397 | + if (!xen_kernel_unmapped_at_usr()) |
|---|
| 398 | + xen_time_setup_guest(); |
|---|
| 424 | 399 | |
|---|
| 425 | 400 | if (xen_initial_domain()) |
|---|
| 426 | 401 | pvclock_gtod_register_notifier(&xen_pvclock_gtod_notifier); |
|---|
| .. | .. |
|---|
| 437 | 412 | return -ENODEV; |
|---|
| 438 | 413 | |
|---|
| 439 | 414 | pm_power_off = xen_power_off; |
|---|
| 440 | | - arm_pm_restart = xen_restart; |
|---|
| 415 | + register_restart_handler(&xen_restart_nb); |
|---|
| 441 | 416 | if (!xen_initial_domain()) { |
|---|
| 442 | 417 | struct timespec64 ts; |
|---|
| 443 | 418 | xen_read_wallclock(&ts); |
|---|
| .. | .. |
|---|
| 468 | 443 | EXPORT_SYMBOL_GPL(HYPERVISOR_physdev_op); |
|---|
| 469 | 444 | EXPORT_SYMBOL_GPL(HYPERVISOR_vcpu_op); |
|---|
| 470 | 445 | EXPORT_SYMBOL_GPL(HYPERVISOR_tmem_op); |
|---|
| 471 | | -EXPORT_SYMBOL_GPL(HYPERVISOR_platform_op); |
|---|
| 446 | +EXPORT_SYMBOL_GPL(HYPERVISOR_platform_op_raw); |
|---|
| 472 | 447 | EXPORT_SYMBOL_GPL(HYPERVISOR_multicall); |
|---|
| 473 | 448 | EXPORT_SYMBOL_GPL(HYPERVISOR_vm_assist); |
|---|
| 474 | 449 | EXPORT_SYMBOL_GPL(HYPERVISOR_dm_op); |
|---|