Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'for-linus-4.5-rc0-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip

Pull xen updates from David Vrabel:
"Xen features and fixes for 4.5-rc0:

- Stolen ticks and PV wallclock support for arm/arm64

- Add grant copy ioctl to gntdev device"

* tag 'for-linus-4.5-rc0-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip:
xen/gntdev: add ioctl for grant copy
x86/xen: don't reset vcpu_info on a cancelled suspend
xen/gntdev: constify mmu_notifier_ops structures
xen/grant-table: constify gnttab_ops structure
xen/time: use READ_ONCE
xen/x86: convert remaining timespec to timespec64 in xen_pvclock_gtod_notify
xen/x86: support XENPF_settime64
xen/arm: set the system time in Xen via the XENPF_settime64 hypercall
xen/arm: introduce xen_read_wallclock
arm: extend pvclock_wall_clock with sec_hi
xen: introduce XENPF_settime64
xen/arm: introduce HYPERVISOR_platform_op on arm and arm64
xen: rename dom0_op to platform_op
xen/arm: account for stolen ticks
arm64: introduce CONFIG_PARAVIRT, PARAVIRT_TIME_ACCOUNTING and pv_time_ops
arm: introduce CONFIG_PARAVIRT, PARAVIRT_TIME_ACCOUNTING and pv_time_ops
missing include asm/paravirt.h in cputime.c
xen: move xen_setup_runstate_info and get_runstate_snapshot to drivers/xen/time.c

+677 -131
+20
arch/arm/Kconfig
··· 1824 1824 config IOMMU_HELPER 1825 1825 def_bool SWIOTLB 1826 1826 1827 + config PARAVIRT 1828 + bool "Enable paravirtualization code" 1829 + help 1830 + This changes the kernel so it can modify itself when it is run 1831 + under a hypervisor, potentially improving performance significantly 1832 + over full virtualization. 1833 + 1834 + config PARAVIRT_TIME_ACCOUNTING 1835 + bool "Paravirtual steal time accounting" 1836 + select PARAVIRT 1837 + default n 1838 + help 1839 + Select this option to enable fine granularity task steal time 1840 + accounting. Time spent executing other tasks in parallel with 1841 + the current vCPU is discounted from the vCPU power. To account for 1842 + that, there can be a small performance impact. 1843 + 1844 + If in doubt, say N here. 1845 + 1827 1846 config XEN_DOM0 1828 1847 def_bool y 1829 1848 depends on XEN ··· 1856 1837 select ARCH_DMA_ADDR_T_64BIT 1857 1838 select ARM_PSCI 1858 1839 select SWIOTLB_XEN 1840 + select PARAVIRT 1859 1841 help 1860 1842 Say Y if you want to run Linux in a Virtual Machine on Xen on ARM. 1861 1843
+20
arch/arm/include/asm/paravirt.h
··· 1 + #ifndef _ASM_ARM_PARAVIRT_H 2 + #define _ASM_ARM_PARAVIRT_H 3 + 4 + #ifdef CONFIG_PARAVIRT 5 + struct static_key; 6 + extern struct static_key paravirt_steal_enabled; 7 + extern struct static_key paravirt_steal_rq_enabled; 8 + 9 + struct pv_time_ops { 10 + unsigned long long (*steal_clock)(int cpu); 11 + }; 12 + extern struct pv_time_ops pv_time_ops; 13 + 14 + static inline u64 paravirt_steal_clock(int cpu) 15 + { 16 + return pv_time_ops.steal_clock(cpu); 17 + } 18 + #endif 19 + 20 + #endif
+7
arch/arm/include/asm/xen/hypercall.h
··· 35 35 36 36 #include <xen/interface/xen.h> 37 37 #include <xen/interface/sched.h> 38 + #include <xen/interface/platform.h> 38 39 39 40 long privcmd_call(unsigned call, unsigned long a1, 40 41 unsigned long a2, unsigned long a3, ··· 50 49 int HYPERVISOR_physdev_op(int cmd, void *arg); 51 50 int HYPERVISOR_vcpu_op(int cmd, int vcpuid, void *extra_args); 52 51 int HYPERVISOR_tmem_op(void *arg); 52 + int HYPERVISOR_platform_op_raw(void *arg); 53 + static inline int HYPERVISOR_platform_op(struct xen_platform_op *op) 54 + { 55 + op->interface_version = XENPF_INTERFACE_VERSION; 56 + return HYPERVISOR_platform_op_raw(op); 57 + } 53 58 int HYPERVISOR_multicall(struct multicall_entry *calls, uint32_t nr); 54 59 55 60 static inline int
+3
arch/arm/include/asm/xen/interface.h
··· 27 27 (hnd).p = val; \ 28 28 } while (0) 29 29 30 + #define __HYPERVISOR_platform_op_raw __HYPERVISOR_platform_op 31 + 30 32 #ifndef __ASSEMBLY__ 31 33 /* Explicitly size integers that represent pfns in the interface with 32 34 * Xen so that we can have one ABI that works for 32 and 64 bit guests. ··· 78 76 u32 version; 79 77 u32 sec; 80 78 u32 nsec; 79 + u32 sec_hi; 81 80 } __attribute__((__packed__)); 82 81 #endif 83 82
+1
arch/arm/kernel/Makefile
··· 81 81 ifneq ($(CONFIG_ARCH_EBSA110),y) 82 82 obj-y += io.o 83 83 endif 84 + obj-$(CONFIG_PARAVIRT) += paravirt.o 84 85 85 86 head-y := head$(MMUEXT).o 86 87 obj-$(CONFIG_DEBUG_LL) += debug.o
+25
arch/arm/kernel/paravirt.c
··· 1 + /* 2 + * This program is free software; you can redistribute it and/or modify 3 + * it under the terms of the GNU General Public License version 2 as 4 + * published by the Free Software Foundation. 5 + * 6 + * This program is distributed in the hope that it will be useful, 7 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 8 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 + * GNU General Public License for more details. 10 + * 11 + * Copyright (C) 2013 Citrix Systems 12 + * 13 + * Author: Stefano Stabellini <stefano.stabellini@eu.citrix.com> 14 + */ 15 + 16 + #include <linux/export.h> 17 + #include <linux/jump_label.h> 18 + #include <linux/types.h> 19 + #include <asm/paravirt.h> 20 + 21 + struct static_key paravirt_steal_enabled; 22 + struct static_key paravirt_steal_rq_enabled; 23 + 24 + struct pv_time_ops pv_time_ops; 25 + EXPORT_SYMBOL_GPL(pv_time_ops);
+95
arch/arm/xen/enlighten.c
··· 12 12 #include <xen/page.h> 13 13 #include <xen/interface/sched.h> 14 14 #include <xen/xen-ops.h> 15 + #include <asm/paravirt.h> 15 16 #include <asm/xen/hypervisor.h> 16 17 #include <asm/xen/hypercall.h> 17 18 #include <asm/system_misc.h> ··· 26 25 #include <linux/cpufreq.h> 27 26 #include <linux/cpu.h> 28 27 #include <linux/console.h> 28 + #include <linux/pvclock_gtod.h> 29 + #include <linux/time64.h> 30 + #include <linux/timekeeping.h> 31 + #include <linux/timekeeper_internal.h> 29 32 30 33 #include <linux/mm.h> 31 34 ··· 84 79 } 85 80 EXPORT_SYMBOL_GPL(xen_unmap_domain_gfn_range); 86 81 82 + static unsigned long long xen_stolen_accounting(int cpu) 83 + { 84 + struct vcpu_runstate_info state; 85 + 86 + BUG_ON(cpu != smp_processor_id()); 87 + 88 + xen_get_runstate_snapshot(&state); 89 + 90 + WARN_ON(state.state != RUNSTATE_running); 91 + 92 + return state.time[RUNSTATE_runnable] + state.time[RUNSTATE_offline]; 93 + } 94 + 95 + static void xen_read_wallclock(struct timespec64 *ts) 96 + { 97 + u32 version; 98 + struct timespec64 now, ts_monotonic; 99 + struct shared_info *s = HYPERVISOR_shared_info; 100 + struct pvclock_wall_clock *wall_clock = &(s->wc); 101 + 102 + /* get wallclock at system boot */ 103 + do { 104 + version = wall_clock->version; 105 + rmb(); /* fetch version before time */ 106 + now.tv_sec = ((uint64_t)wall_clock->sec_hi << 32) | wall_clock->sec; 107 + now.tv_nsec = wall_clock->nsec; 108 + rmb(); /* fetch time before checking version */ 109 + } while ((wall_clock->version & 1) || (version != wall_clock->version)); 110 + 111 + /* time since system boot */ 112 + ktime_get_ts64(&ts_monotonic); 113 + *ts = timespec64_add(now, ts_monotonic); 114 + } 115 + 116 + static int xen_pvclock_gtod_notify(struct notifier_block *nb, 117 + unsigned long was_set, void *priv) 118 + { 119 + /* Protected by the calling core code serialization */ 120 + static struct timespec64 next_sync; 121 + 122 + struct xen_platform_op op; 123 + struct timespec64 now, system_time; 124 + struct timekeeper *tk = priv; 125 + 126 + now.tv_sec = tk->xtime_sec; 127 + now.tv_nsec = (long)(tk->tkr_mono.xtime_nsec >> tk->tkr_mono.shift); 128 + system_time = timespec64_add(now, tk->wall_to_monotonic); 129 + 130 + /* 131 + * We only take the expensive HV call when the clock was set 132 + * or when the 11 minutes RTC synchronization time elapsed. 133 + */ 134 + if (!was_set && timespec64_compare(&now, &next_sync) < 0) 135 + return NOTIFY_OK; 136 + 137 + op.cmd = XENPF_settime64; 138 + op.u.settime64.mbz = 0; 139 + op.u.settime64.secs = now.tv_sec; 140 + op.u.settime64.nsecs = now.tv_nsec; 141 + op.u.settime64.system_time = timespec64_to_ns(&system_time); 142 + (void)HYPERVISOR_platform_op(&op); 143 + 144 + /* 145 + * Move the next drift compensation time 11 minutes 146 + * ahead. That's emulating the sync_cmos_clock() update for 147 + * the hardware RTC. 148 + */ 149 + next_sync = now; 150 + next_sync.tv_sec += 11 * 60; 151 + 152 + return NOTIFY_OK; 153 + } 154 + 155 + static struct notifier_block xen_pvclock_gtod_notifier = { 156 + .notifier_call = xen_pvclock_gtod_notify, 157 + }; 158 + 87 159 static void xen_percpu_init(void) 88 160 { 89 161 struct vcpu_register_vcpu_info info; ··· 185 103 err = HYPERVISOR_vcpu_op(VCPUOP_register_vcpu_info, cpu, &info); 186 104 BUG_ON(err); 187 105 per_cpu(xen_vcpu, cpu) = vcpup; 106 + 107 + xen_setup_runstate_info(cpu); 188 108 189 109 after_register_vcpu_info: 190 110 enable_percpu_irq(xen_events_irq, 0); ··· 355 271 356 272 register_cpu_notifier(&xen_cpu_notifier); 357 273 274 + pv_time_ops.steal_clock = xen_stolen_accounting; 275 + static_key_slow_inc(&paravirt_steal_enabled); 276 + if (xen_initial_domain()) 277 + pvclock_gtod_register_notifier(&xen_pvclock_gtod_notifier); 278 + 358 279 return 0; 359 280 } 360 281 early_initcall(xen_guest_init); ··· 371 282 372 283 pm_power_off = xen_power_off; 373 284 arm_pm_restart = xen_restart; 285 + if (!xen_initial_domain()) { 286 + struct timespec64 ts; 287 + xen_read_wallclock(&ts); 288 + do_settimeofday64(&ts); 289 + } 374 290 375 291 return 0; 376 292 } ··· 401 307 EXPORT_SYMBOL_GPL(HYPERVISOR_physdev_op); 402 308 EXPORT_SYMBOL_GPL(HYPERVISOR_vcpu_op); 403 309 EXPORT_SYMBOL_GPL(HYPERVISOR_tmem_op); 310 + EXPORT_SYMBOL_GPL(HYPERVISOR_platform_op); 404 311 EXPORT_SYMBOL_GPL(HYPERVISOR_multicall); 405 312 EXPORT_SYMBOL_GPL(privcmd_call);
+1
arch/arm/xen/hypercall.S
··· 89 89 HYPERCALL2(physdev_op); 90 90 HYPERCALL3(vcpu_op); 91 91 HYPERCALL1(tmem_op); 92 + HYPERCALL1(platform_op_raw); 92 93 HYPERCALL2(multicall); 93 94 94 95 ENTRY(privcmd_call)
+20
arch/arm64/Kconfig
··· 555 555 and the task is only allowed to execute a few safe syscalls 556 556 defined by each seccomp mode. 557 557 558 + config PARAVIRT 559 + bool "Enable paravirtualization code" 560 + help 561 + This changes the kernel so it can modify itself when it is run 562 + under a hypervisor, potentially improving performance significantly 563 + over full virtualization. 564 + 565 + config PARAVIRT_TIME_ACCOUNTING 566 + bool "Paravirtual steal time accounting" 567 + select PARAVIRT 568 + default n 569 + help 570 + Select this option to enable fine granularity task steal time 571 + accounting. Time spent executing other tasks in parallel with 572 + the current vCPU is discounted from the vCPU power. To account for 573 + that, there can be a small performance impact. 574 + 575 + If in doubt, say N here. 576 + 558 577 config XEN_DOM0 559 578 def_bool y 560 579 depends on XEN ··· 582 563 bool "Xen guest support on ARM64" 583 564 depends on ARM64 && OF 584 565 select SWIOTLB_XEN 566 + select PARAVIRT 585 567 help 586 568 Say Y if you want to run Linux in a Virtual Machine on Xen on ARM64. 587 569
+20
arch/arm64/include/asm/paravirt.h
··· 1 + #ifndef _ASM_ARM64_PARAVIRT_H 2 + #define _ASM_ARM64_PARAVIRT_H 3 + 4 + #ifdef CONFIG_PARAVIRT 5 + struct static_key; 6 + extern struct static_key paravirt_steal_enabled; 7 + extern struct static_key paravirt_steal_rq_enabled; 8 + 9 + struct pv_time_ops { 10 + unsigned long long (*steal_clock)(int cpu); 11 + }; 12 + extern struct pv_time_ops pv_time_ops; 13 + 14 + static inline u64 paravirt_steal_clock(int cpu) 15 + { 16 + return pv_time_ops.steal_clock(cpu); 17 + } 18 + #endif 19 + 20 + #endif
+1
arch/arm64/kernel/Makefile
··· 41 41 arm64-obj-$(CONFIG_PCI) += pci.o 42 42 arm64-obj-$(CONFIG_ARMV8_DEPRECATED) += armv8_deprecated.o 43 43 arm64-obj-$(CONFIG_ACPI) += acpi.o 44 + arm64-obj-$(CONFIG_PARAVIRT) += paravirt.o 44 45 45 46 obj-y += $(arm64-obj-y) vdso/ 46 47 obj-m += $(arm64-obj-m)
+25
arch/arm64/kernel/paravirt.c
··· 1 + /* 2 + * This program is free software; you can redistribute it and/or modify 3 + * it under the terms of the GNU General Public License version 2 as 4 + * published by the Free Software Foundation. 5 + * 6 + * This program is distributed in the hope that it will be useful, 7 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 8 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 + * GNU General Public License for more details. 10 + * 11 + * Copyright (C) 2013 Citrix Systems 12 + * 13 + * Author: Stefano Stabellini <stefano.stabellini@eu.citrix.com> 14 + */ 15 + 16 + #include <linux/export.h> 17 + #include <linux/jump_label.h> 18 + #include <linux/types.h> 19 + #include <asm/paravirt.h> 20 + 21 + struct static_key paravirt_steal_enabled; 22 + struct static_key paravirt_steal_rq_enabled; 23 + 24 + struct pv_time_ops pv_time_ops; 25 + EXPORT_SYMBOL_GPL(pv_time_ops);
+1
arch/arm64/xen/hypercall.S
··· 80 80 HYPERCALL2(physdev_op); 81 81 HYPERCALL3(vcpu_op); 82 82 HYPERCALL1(tmem_op); 83 + HYPERCALL1(platform_op_raw); 83 84 HYPERCALL2(multicall); 84 85 85 86 ENTRY(privcmd_call)
+3 -3
arch/x86/include/asm/xen/hypercall.h
··· 310 310 } 311 311 312 312 static inline int 313 - HYPERVISOR_dom0_op(struct xen_platform_op *platform_op) 313 + HYPERVISOR_platform_op(struct xen_platform_op *op) 314 314 { 315 - platform_op->interface_version = XENPF_INTERFACE_VERSION; 316 - return _hypercall1(int, dom0_op, platform_op); 315 + op->interface_version = XENPF_INTERFACE_VERSION; 316 + return _hypercall1(int, platform_op, op); 317 317 } 318 318 319 319 static inline int
+1 -1
arch/x86/xen/apic.c
··· 64 64 if (reg != APIC_ID) 65 65 return 0; 66 66 67 - ret = HYPERVISOR_dom0_op(&op); 67 + ret = HYPERVISOR_platform_op(&op); 68 68 if (ret) 69 69 return 0; 70 70
+4 -4
arch/x86/xen/enlighten.c
··· 415 415 416 416 set_xen_guest_handle(op.u.set_pminfo.pdc, buf); 417 417 418 - if ((HYPERVISOR_dom0_op(&op) == 0) && 418 + if ((HYPERVISOR_platform_op(&op) == 0) && 419 419 (buf[2] & (ACPI_PDC_C_C1_FFH | ACPI_PDC_C_C2C3_FFH))) { 420 420 cpuid_leaf5_ecx_val = cx; 421 421 cpuid_leaf5_edx_val = dx; ··· 1365 1365 info->params.length = sizeof(info->params); 1366 1366 set_xen_guest_handle(op.u.firmware_info.u.disk_info.edd_params, 1367 1367 &info->params); 1368 - ret = HYPERVISOR_dom0_op(&op); 1368 + ret = HYPERVISOR_platform_op(&op); 1369 1369 if (ret) 1370 1370 break; 1371 1371 ··· 1383 1383 op.u.firmware_info.type = XEN_FW_DISK_MBR_SIGNATURE; 1384 1384 for (nr = 0; nr < EDD_MBR_SIG_MAX; nr++) { 1385 1385 op.u.firmware_info.index = nr; 1386 - ret = HYPERVISOR_dom0_op(&op); 1386 + ret = HYPERVISOR_platform_op(&op); 1387 1387 if (ret) 1388 1388 break; 1389 1389 mbr_signature[nr] = op.u.firmware_info.u.disk_mbr_signature.mbr_signature; ··· 1690 1690 xen_start_info->console.domU.mfn = 0; 1691 1691 xen_start_info->console.domU.evtchn = 0; 1692 1692 1693 - if (HYPERVISOR_dom0_op(&op) == 0) 1693 + if (HYPERVISOR_platform_op(&op) == 0) 1694 1694 boot_params.kbd_status = op.u.firmware_info.u.kbd_shift_flags; 1695 1695 1696 1696 /* Make sure ACS will be enabled */
+2 -1
arch/x86/xen/suspend.c
··· 34 34 { 35 35 #ifdef CONFIG_XEN_PVHVM 36 36 int cpu; 37 - xen_hvm_init_shared_info(); 37 + if (!suspend_cancelled) 38 + xen_hvm_init_shared_info(); 38 39 xen_callback_vector(); 39 40 xen_unplug_emulated_devices(); 40 41 if (xen_feature(XENFEAT_hvm_safe_pvclock)) {
+31 -84
arch/x86/xen/time.c
··· 16 16 #include <linux/gfp.h> 17 17 #include <linux/slab.h> 18 18 #include <linux/pvclock_gtod.h> 19 + #include <linux/timekeeper_internal.h> 19 20 20 21 #include <asm/pvclock.h> 21 22 #include <asm/xen/hypervisor.h> ··· 33 32 #define TIMER_SLOP 100000 34 33 #define NS_PER_TICK (1000000000LL / HZ) 35 34 36 - /* runstate info updated by Xen */ 37 - static DEFINE_PER_CPU(struct vcpu_runstate_info, xen_runstate); 38 - 39 35 /* snapshots of runstate info */ 40 36 static DEFINE_PER_CPU(struct vcpu_runstate_info, xen_runstate_snapshot); 41 37 42 38 /* unused ns of stolen time */ 43 39 static DEFINE_PER_CPU(u64, xen_residual_stolen); 44 - 45 - /* return an consistent snapshot of 64-bit time/counter value */ 46 - static u64 get64(const u64 *p) 47 - { 48 - u64 ret; 49 - 50 - if (BITS_PER_LONG < 64) { 51 - u32 *p32 = (u32 *)p; 52 - u32 h, l; 53 - 54 - /* 55 - * Read high then low, and then make sure high is 56 - * still the same; this will only loop if low wraps 57 - * and carries into high. 58 - * XXX some clean way to make this endian-proof? 59 - */ 60 - do { 61 - h = p32[1]; 62 - barrier(); 63 - l = p32[0]; 64 - barrier(); 65 - } while (p32[1] != h); 66 - 67 - ret = (((u64)h) << 32) | l; 68 - } else 69 - ret = *p; 70 - 71 - return ret; 72 - } 73 - 74 - /* 75 - * Runstate accounting 76 - */ 77 - static void get_runstate_snapshot(struct vcpu_runstate_info *res) 78 - { 79 - u64 state_time; 80 - struct vcpu_runstate_info *state; 81 - 82 - BUG_ON(preemptible()); 83 - 84 - state = this_cpu_ptr(&xen_runstate); 85 - 86 - /* 87 - * The runstate info is always updated by the hypervisor on 88 - * the current CPU, so there's no need to use anything 89 - * stronger than a compiler barrier when fetching it. 90 - */ 91 - do { 92 - state_time = get64(&state->state_entry_time); 93 - barrier(); 94 - *res = *state; 95 - barrier(); 96 - } while (get64(&state->state_entry_time) != state_time); 97 - } 98 - 99 - /* return true when a vcpu could run but has no real cpu to run on */ 100 - bool xen_vcpu_stolen(int vcpu) 101 - { 102 - return per_cpu(xen_runstate, vcpu).state == RUNSTATE_runnable; 103 - } 104 - 105 - void xen_setup_runstate_info(int cpu) 106 - { 107 - struct vcpu_register_runstate_memory_area area; 108 - 109 - area.addr.v = &per_cpu(xen_runstate, cpu); 110 - 111 - if (HYPERVISOR_vcpu_op(VCPUOP_register_runstate_memory_area, 112 - cpu, &area)) 113 - BUG(); 114 - } 115 40 116 41 static void do_stolen_accounting(void) 117 42 { ··· 46 119 s64 runnable, offline, stolen; 47 120 cputime_t ticks; 48 121 49 - get_runstate_snapshot(&state); 122 + xen_get_runstate_snapshot(&state); 50 123 51 124 WARN_ON(state.state != RUNSTATE_running); 52 125 ··· 121 194 unsigned long was_set, void *priv) 122 195 { 123 196 /* Protected by the calling core code serialization */ 124 - static struct timespec next_sync; 197 + static struct timespec64 next_sync; 125 198 126 199 struct xen_platform_op op; 127 - struct timespec now; 200 + struct timespec64 now; 201 + struct timekeeper *tk = priv; 202 + static bool settime64_supported = true; 203 + int ret; 128 204 129 - now = __current_kernel_time(); 205 + now.tv_sec = tk->xtime_sec; 206 + now.tv_nsec = (long)(tk->tkr_mono.xtime_nsec >> tk->tkr_mono.shift); 130 207 131 208 /* 132 209 * We only take the expensive HV call when the clock was set 133 210 * or when the 11 minutes RTC synchronization time elapsed. 134 211 */ 135 - if (!was_set && timespec_compare(&now, &next_sync) < 0) 212 + if (!was_set && timespec64_compare(&now, &next_sync) < 0) 136 213 return NOTIFY_OK; 137 214 138 - op.cmd = XENPF_settime; 139 - op.u.settime.secs = now.tv_sec; 140 - op.u.settime.nsecs = now.tv_nsec; 141 - op.u.settime.system_time = xen_clocksource_read(); 215 + again: 216 + if (settime64_supported) { 217 + op.cmd = XENPF_settime64; 218 + op.u.settime64.mbz = 0; 219 + op.u.settime64.secs = now.tv_sec; 220 + op.u.settime64.nsecs = now.tv_nsec; 221 + op.u.settime64.system_time = xen_clocksource_read(); 222 + } else { 223 + op.cmd = XENPF_settime32; 224 + op.u.settime32.secs = now.tv_sec; 225 + op.u.settime32.nsecs = now.tv_nsec; 226 + op.u.settime32.system_time = xen_clocksource_read(); 227 + } 142 228 143 - (void)HYPERVISOR_dom0_op(&op); 229 + ret = HYPERVISOR_platform_op(&op); 230 + 231 + if (ret == -ENOSYS && settime64_supported) { 232 + settime64_supported = false; 233 + goto again; 234 + } 235 + if (ret < 0) 236 + return NOTIFY_BAD; 144 237 145 238 /* 146 239 * Move the next drift compensation time 11 minutes
+1 -1
drivers/xen/Makefile
··· 1 1 obj-$(CONFIG_HOTPLUG_CPU) += cpu_hotplug.o 2 2 obj-$(CONFIG_X86) += fallback.o 3 - obj-y += grant-table.o features.o balloon.o manage.o preempt.o 3 + obj-y += grant-table.o features.o balloon.o manage.o preempt.o time.o 4 4 obj-y += events/ 5 5 obj-y += xenbus/ 6 6
+1 -1
drivers/xen/acpi.c
··· 58 58 bits, val_a, val_b)) 59 59 return -1; 60 60 61 - HYPERVISOR_dom0_op(&op); 61 + HYPERVISOR_platform_op(&op); 62 62 return 1; 63 63 } 64 64
+15 -15
drivers/xen/efi.c
··· 42 42 { 43 43 struct xen_platform_op op = INIT_EFI_OP(get_time); 44 44 45 - if (HYPERVISOR_dom0_op(&op) < 0) 45 + if (HYPERVISOR_platform_op(&op) < 0) 46 46 return EFI_UNSUPPORTED; 47 47 48 48 if (tm) { ··· 67 67 BUILD_BUG_ON(sizeof(*tm) != sizeof(efi_data(op).u.set_time)); 68 68 memcpy(&efi_data(op).u.set_time, tm, sizeof(*tm)); 69 69 70 - if (HYPERVISOR_dom0_op(&op) < 0) 70 + if (HYPERVISOR_platform_op(&op) < 0) 71 71 return EFI_UNSUPPORTED; 72 72 73 73 return efi_data(op).status; ··· 79 79 { 80 80 struct xen_platform_op op = INIT_EFI_OP(get_wakeup_time); 81 81 82 - if (HYPERVISOR_dom0_op(&op) < 0) 82 + if (HYPERVISOR_platform_op(&op) < 0) 83 83 return EFI_UNSUPPORTED; 84 84 85 85 if (tm) { ··· 108 108 else 109 109 efi_data(op).misc |= XEN_EFI_SET_WAKEUP_TIME_ENABLE_ONLY; 110 110 111 - if (HYPERVISOR_dom0_op(&op) < 0) 111 + if (HYPERVISOR_platform_op(&op) < 0) 112 112 return EFI_UNSUPPORTED; 113 113 114 114 return efi_data(op).status; ··· 129 129 efi_data(op).u.get_variable.size = *data_size; 130 130 set_xen_guest_handle(efi_data(op).u.get_variable.data, data); 131 131 132 - if (HYPERVISOR_dom0_op(&op) < 0) 132 + if (HYPERVISOR_platform_op(&op) < 0) 133 133 return EFI_UNSUPPORTED; 134 134 135 135 *data_size = efi_data(op).u.get_variable.size; ··· 152 152 memcpy(&efi_data(op).u.get_next_variable_name.vendor_guid, vendor, 153 153 sizeof(*vendor)); 154 154 155 - if (HYPERVISOR_dom0_op(&op) < 0) 155 + if (HYPERVISOR_platform_op(&op) < 0) 156 156 return EFI_UNSUPPORTED; 157 157 158 158 *name_size = efi_data(op).u.get_next_variable_name.size; ··· 178 178 efi_data(op).u.set_variable.size = data_size; 179 179 set_xen_guest_handle(efi_data(op).u.set_variable.data, data); 180 180 181 - if (HYPERVISOR_dom0_op(&op) < 0) 181 + if (HYPERVISOR_platform_op(&op) < 0) 182 182 return EFI_UNSUPPORTED; 183 183 184 184 return efi_data(op).status; ··· 196 196 197 197 efi_data(op).u.query_variable_info.attr = attr; 198 198 199 - if (HYPERVISOR_dom0_op(&op) < 0) 199 + if (HYPERVISOR_platform_op(&op) < 0) 200 200 return EFI_UNSUPPORTED; 201 201 202 202 *storage_space = efi_data(op).u.query_variable_info.max_store_size; ··· 210 210 { 211 211 struct xen_platform_op op = INIT_EFI_OP(get_next_high_monotonic_count); 212 212 213 - if (HYPERVISOR_dom0_op(&op) < 0) 213 + if (HYPERVISOR_platform_op(&op) < 0) 214 214 return EFI_UNSUPPORTED; 215 215 216 216 *count = efi_data(op).misc; ··· 232 232 efi_data(op).u.update_capsule.capsule_count = count; 233 233 efi_data(op).u.update_capsule.sg_list = sg_list; 234 234 235 - if (HYPERVISOR_dom0_op(&op) < 0) 235 + if (HYPERVISOR_platform_op(&op) < 0) 236 236 return EFI_UNSUPPORTED; 237 237 238 238 return efi_data(op).status; ··· 252 252 capsules); 253 253 efi_data(op).u.query_capsule_capabilities.capsule_count = count; 254 254 255 - if (HYPERVISOR_dom0_op(&op) < 0) 255 + if (HYPERVISOR_platform_op(&op) < 0) 256 256 return EFI_UNSUPPORTED; 257 257 258 258 *max_size = efi_data(op).u.query_capsule_capabilities.max_capsule_size; ··· 331 331 }; 332 332 union xenpf_efi_info *info = &op.u.firmware_info.u.efi_info; 333 333 334 - if (!xen_initial_domain() || HYPERVISOR_dom0_op(&op) < 0) 334 + if (!xen_initial_domain() || HYPERVISOR_platform_op(&op) < 0) 335 335 return NULL; 336 336 337 337 /* Here we know that Xen runs on EFI platform. */ ··· 347 347 info->vendor.bufsz = sizeof(vendor); 348 348 set_xen_guest_handle(info->vendor.name, vendor); 349 349 350 - if (HYPERVISOR_dom0_op(&op) == 0) { 350 + if (HYPERVISOR_platform_op(&op) == 0) { 351 351 efi_systab_xen.fw_vendor = __pa_symbol(vendor); 352 352 efi_systab_xen.fw_revision = info->vendor.revision; 353 353 } else ··· 357 357 op.u.firmware_info.type = XEN_FW_EFI_INFO; 358 358 op.u.firmware_info.index = XEN_FW_EFI_VERSION; 359 359 360 - if (HYPERVISOR_dom0_op(&op) == 0) 360 + if (HYPERVISOR_platform_op(&op) == 0) 361 361 efi_systab_xen.hdr.revision = info->version; 362 362 363 363 op.cmd = XENPF_firmware_info; 364 364 op.u.firmware_info.type = XEN_FW_EFI_INFO; 365 365 op.u.firmware_info.index = XEN_FW_EFI_RT_VERSION; 366 366 367 - if (HYPERVISOR_dom0_op(&op) == 0) 367 + if (HYPERVISOR_platform_op(&op) == 0) 368 368 efi.runtime_version = info->version; 369 369 370 370 return &efi_systab_xen;
+204 -1
drivers/xen/gntdev.c
··· 518 518 mutex_unlock(&priv->lock); 519 519 } 520 520 521 - static struct mmu_notifier_ops gntdev_mmu_ops = { 521 + static const struct mmu_notifier_ops gntdev_mmu_ops = { 522 522 .release = mn_release, 523 523 .invalidate_page = mn_invl_page, 524 524 .invalidate_range_start = mn_invl_range_start, ··· 748 748 return rc; 749 749 } 750 750 751 + #define GNTDEV_COPY_BATCH 24 752 + 753 + struct gntdev_copy_batch { 754 + struct gnttab_copy ops[GNTDEV_COPY_BATCH]; 755 + struct page *pages[GNTDEV_COPY_BATCH]; 756 + s16 __user *status[GNTDEV_COPY_BATCH]; 757 + unsigned int nr_ops; 758 + unsigned int nr_pages; 759 + }; 760 + 761 + static int gntdev_get_page(struct gntdev_copy_batch *batch, void __user *virt, 762 + bool writeable, unsigned long *gfn) 763 + { 764 + unsigned long addr = (unsigned long)virt; 765 + struct page *page; 766 + unsigned long xen_pfn; 767 + int ret; 768 + 769 + ret = get_user_pages_fast(addr, 1, writeable, &page); 770 + if (ret < 0) 771 + return ret; 772 + 773 + batch->pages[batch->nr_pages++] = page; 774 + 775 + xen_pfn = page_to_xen_pfn(page) + XEN_PFN_DOWN(addr & ~PAGE_MASK); 776 + *gfn = pfn_to_gfn(xen_pfn); 777 + 778 + return 0; 779 + } 780 + 781 + static void gntdev_put_pages(struct gntdev_copy_batch *batch) 782 + { 783 + unsigned int i; 784 + 785 + for (i = 0; i < batch->nr_pages; i++) 786 + put_page(batch->pages[i]); 787 + batch->nr_pages = 0; 788 + } 789 + 790 + static int gntdev_copy(struct gntdev_copy_batch *batch) 791 + { 792 + unsigned int i; 793 + 794 + gnttab_batch_copy(batch->ops, batch->nr_ops); 795 + gntdev_put_pages(batch); 796 + 797 + /* 798 + * For each completed op, update the status if the op failed 799 + * and all previous ops for the segment were successful. 800 + */ 801 + for (i = 0; i < batch->nr_ops; i++) { 802 + s16 status = batch->ops[i].status; 803 + s16 old_status; 804 + 805 + if (status == GNTST_okay) 806 + continue; 807 + 808 + if (__get_user(old_status, batch->status[i])) 809 + return -EFAULT; 810 + 811 + if (old_status != GNTST_okay) 812 + continue; 813 + 814 + if (__put_user(status, batch->status[i])) 815 + return -EFAULT; 816 + } 817 + 818 + batch->nr_ops = 0; 819 + return 0; 820 + } 821 + 822 + static int gntdev_grant_copy_seg(struct gntdev_copy_batch *batch, 823 + struct gntdev_grant_copy_segment *seg, 824 + s16 __user *status) 825 + { 826 + uint16_t copied = 0; 827 + 828 + /* 829 + * Disallow local -> local copies since there is only space in 830 + * batch->pages for one page per-op and this would be a very 831 + * expensive memcpy(). 832 + */ 833 + if (!(seg->flags & (GNTCOPY_source_gref | GNTCOPY_dest_gref))) 834 + return -EINVAL; 835 + 836 + /* Can't cross page if source/dest is a grant ref. */ 837 + if (seg->flags & GNTCOPY_source_gref) { 838 + if (seg->source.foreign.offset + seg->len > XEN_PAGE_SIZE) 839 + return -EINVAL; 840 + } 841 + if (seg->flags & GNTCOPY_dest_gref) { 842 + if (seg->dest.foreign.offset + seg->len > XEN_PAGE_SIZE) 843 + return -EINVAL; 844 + } 845 + 846 + if (put_user(GNTST_okay, status)) 847 + return -EFAULT; 848 + 849 + while (copied < seg->len) { 850 + struct gnttab_copy *op; 851 + void __user *virt; 852 + size_t len, off; 853 + unsigned long gfn; 854 + int ret; 855 + 856 + if (batch->nr_ops >= GNTDEV_COPY_BATCH) { 857 + ret = gntdev_copy(batch); 858 + if (ret < 0) 859 + return ret; 860 + } 861 + 862 + len = seg->len - copied; 863 + 864 + op = &batch->ops[batch->nr_ops]; 865 + op->flags = 0; 866 + 867 + if (seg->flags & GNTCOPY_source_gref) { 868 + op->source.u.ref = seg->source.foreign.ref; 869 + op->source.domid = seg->source.foreign.domid; 870 + op->source.offset = seg->source.foreign.offset + copied; 871 + op->flags |= GNTCOPY_source_gref; 872 + } else { 873 + virt = seg->source.virt + copied; 874 + off = (unsigned long)virt & ~XEN_PAGE_MASK; 875 + len = min(len, (size_t)XEN_PAGE_SIZE - off); 876 + 877 + ret = gntdev_get_page(batch, virt, false, &gfn); 878 + if (ret < 0) 879 + return ret; 880 + 881 + op->source.u.gmfn = gfn; 882 + op->source.domid = DOMID_SELF; 883 + op->source.offset = off; 884 + } 885 + 886 + if (seg->flags & GNTCOPY_dest_gref) { 887 + op->dest.u.ref = seg->dest.foreign.ref; 888 + op->dest.domid = seg->dest.foreign.domid; 889 + op->dest.offset = seg->dest.foreign.offset + copied; 890 + op->flags |= GNTCOPY_dest_gref; 891 + } else { 892 + virt = seg->dest.virt + copied; 893 + off = (unsigned long)virt & ~XEN_PAGE_MASK; 894 + len = min(len, (size_t)XEN_PAGE_SIZE - off); 895 + 896 + ret = gntdev_get_page(batch, virt, true, &gfn); 897 + if (ret < 0) 898 + return ret; 899 + 900 + op->dest.u.gmfn = gfn; 901 + op->dest.domid = DOMID_SELF; 902 + op->dest.offset = off; 903 + } 904 + 905 + op->len = len; 906 + copied += len; 907 + 908 + batch->status[batch->nr_ops] = status; 909 + batch->nr_ops++; 910 + } 911 + 912 + return 0; 913 + } 914 + 915 + static long gntdev_ioctl_grant_copy(struct gntdev_priv *priv, void __user *u) 916 + { 917 + struct ioctl_gntdev_grant_copy copy; 918 + struct gntdev_copy_batch batch; 919 + unsigned int i; 920 + int ret = 0; 921 + 922 + if (copy_from_user(&copy, u, sizeof(copy))) 923 + return -EFAULT; 924 + 925 + batch.nr_ops = 0; 926 + batch.nr_pages = 0; 927 + 928 + for (i = 0; i < copy.count; i++) { 929 + struct gntdev_grant_copy_segment seg; 930 + 931 + if (copy_from_user(&seg, &copy.segments[i], sizeof(seg))) { 932 + ret = -EFAULT; 933 + goto out; 934 + } 935 + 936 + ret = gntdev_grant_copy_seg(&batch, &seg, &copy.segments[i].status); 937 + if (ret < 0) 938 + goto out; 939 + 940 + cond_resched(); 941 + } 942 + if (batch.nr_ops) 943 + ret = gntdev_copy(&batch); 944 + return ret; 945 + 946 + out: 947 + gntdev_put_pages(&batch); 948 + return ret; 949 + } 950 + 751 951 static long gntdev_ioctl(struct file *flip, 752 952 unsigned int cmd, unsigned long arg) 753 953 { ··· 966 766 967 767 case IOCTL_GNTDEV_SET_UNMAP_NOTIFY: 968 768 return gntdev_ioctl_notify(priv, ptr); 769 + 770 + case IOCTL_GNTDEV_GRANT_COPY: 771 + return gntdev_ioctl_grant_copy(priv, ptr); 969 772 970 773 default: 971 774 pr_debug("priv %p, unknown cmd %x\n", priv, cmd);
+2 -2
drivers/xen/grant-table.c
··· 128 128 int result; 129 129 }; 130 130 131 - static struct gnttab_ops *gnttab_interface; 131 + static const struct gnttab_ops *gnttab_interface; 132 132 133 133 static int grant_table_version; 134 134 static int grefs_per_grant_frame; ··· 1013 1013 return rc; 1014 1014 } 1015 1015 1016 - static struct gnttab_ops gnttab_v1_ops = { 1016 + static const struct gnttab_ops gnttab_v1_ops = { 1017 1017 .map_frames = gnttab_map_frames_v1, 1018 1018 .unmap_frames = gnttab_unmap_frames_v1, 1019 1019 .update_entry = gnttab_update_entry_v1,
+4 -4
drivers/xen/pcpu.c
··· 78 78 .u.cpu_ol.cpuid = cpu_id, 79 79 }; 80 80 81 - return HYPERVISOR_dom0_op(&op); 81 + return HYPERVISOR_platform_op(&op); 82 82 } 83 83 84 84 static int xen_pcpu_up(uint32_t cpu_id) ··· 89 89 .u.cpu_ol.cpuid = cpu_id, 90 90 }; 91 91 92 - return HYPERVISOR_dom0_op(&op); 92 + return HYPERVISOR_platform_op(&op); 93 93 } 94 94 95 95 static ssize_t show_online(struct device *dev, ··· 277 277 .u.pcpu_info.xen_cpuid = cpu, 278 278 }; 279 279 280 - ret = HYPERVISOR_dom0_op(&op); 280 + ret = HYPERVISOR_platform_op(&op); 281 281 if (ret) 282 282 return ret; 283 283 ··· 364 364 op.cmd = XENPF_get_cpuinfo; 365 365 while (cpu_id <= max_id) { 366 366 op.u.pcpu_info.xen_cpuid = cpu_id; 367 - if (HYPERVISOR_dom0_op(&op)) { 367 + if (HYPERVISOR_platform_op(&op)) { 368 368 cpu_id++; 369 369 continue; 370 370 }
+88
drivers/xen/time.c
··· 1 + /* 2 + * Xen stolen ticks accounting. 3 + */ 4 + #include <linux/kernel.h> 5 + #include <linux/kernel_stat.h> 6 + #include <linux/math64.h> 7 + #include <linux/gfp.h> 8 + 9 + #include <asm/xen/hypervisor.h> 10 + #include <asm/xen/hypercall.h> 11 + 12 + #include <xen/events.h> 13 + #include <xen/features.h> 14 + #include <xen/interface/xen.h> 15 + #include <xen/interface/vcpu.h> 16 + #include <xen/xen-ops.h> 17 + 18 + /* runstate info updated by Xen */ 19 + static DEFINE_PER_CPU(struct vcpu_runstate_info, xen_runstate); 20 + 21 + /* return an consistent snapshot of 64-bit time/counter value */ 22 + static u64 get64(const u64 *p) 23 + { 24 + u64 ret; 25 + 26 + if (BITS_PER_LONG < 64) { 27 + u32 *p32 = (u32 *)p; 28 + u32 h, l, h2; 29 + 30 + /* 31 + * Read high then low, and then make sure high is 32 + * still the same; this will only loop if low wraps 33 + * and carries into high. 34 + * XXX some clean way to make this endian-proof? 35 + */ 36 + do { 37 + h = READ_ONCE(p32[1]); 38 + l = READ_ONCE(p32[0]); 39 + h2 = READ_ONCE(p32[1]); 40 + } while(h2 != h); 41 + 42 + ret = (((u64)h) << 32) | l; 43 + } else 44 + ret = READ_ONCE(*p); 45 + 46 + return ret; 47 + } 48 + 49 + /* 50 + * Runstate accounting 51 + */ 52 + void xen_get_runstate_snapshot(struct vcpu_runstate_info *res) 53 + { 54 + u64 state_time; 55 + struct vcpu_runstate_info *state; 56 + 57 + BUG_ON(preemptible()); 58 + 59 + state = this_cpu_ptr(&xen_runstate); 60 + 61 + /* 62 + * The runstate info is always updated by the hypervisor on 63 + * the current CPU, so there's no need to use anything 64 + * stronger than a compiler barrier when fetching it. 65 + */ 66 + do { 67 + state_time = get64(&state->state_entry_time); 68 + *res = READ_ONCE(*state); 69 + } while (get64(&state->state_entry_time) != state_time); 70 + } 71 + 72 + /* return true when a vcpu could run but has no real cpu to run on */ 73 + bool xen_vcpu_stolen(int vcpu) 74 + { 75 + return per_cpu(xen_runstate, vcpu).state == RUNSTATE_runnable; 76 + } 77 + 78 + void xen_setup_runstate_info(int cpu) 79 + { 80 + struct vcpu_register_runstate_memory_area area; 81 + 82 + area.addr.v = &per_cpu(xen_runstate, cpu); 83 + 84 + if (HYPERVISOR_vcpu_op(VCPUOP_register_runstate_memory_area, 85 + cpu, &area)) 86 + BUG(); 87 + } 88 +
+1 -1
drivers/xen/xen-acpi-cpuhotplug.c
··· 206 206 op.u.cpu_add.acpi_id = pr->acpi_id; 207 207 op.u.cpu_add.pxm = pxm; 208 208 209 - cpu_id = HYPERVISOR_dom0_op(&op); 209 + cpu_id = HYPERVISOR_platform_op(&op); 210 210 if (cpu_id < 0) 211 211 pr_err(PREFIX "Failed to hotadd CPU for acpi_id %d\n", 212 212 pr->acpi_id);
+2 -2
drivers/xen/xen-acpi-pad.c
··· 36 36 op.u.core_parking.type = XEN_CORE_PARKING_SET; 37 37 op.u.core_parking.idle_nums = idle_nums; 38 38 39 - return HYPERVISOR_dom0_op(&op); 39 + return HYPERVISOR_platform_op(&op); 40 40 } 41 41 42 42 static int xen_acpi_pad_idle_cpus_num(void) ··· 46 46 op.cmd = XENPF_core_parking; 47 47 op.u.core_parking.type = XEN_CORE_PARKING_GET; 48 48 49 - return HYPERVISOR_dom0_op(&op) 49 + return HYPERVISOR_platform_op(&op) 50 50 ?: op.u.core_parking.idle_nums; 51 51 } 52 52
+4 -4
drivers/xen/xen-acpi-processor.c
··· 116 116 set_xen_guest_handle(op.u.set_pminfo.power.states, dst_cx_states); 117 117 118 118 if (!no_hypercall) 119 - ret = HYPERVISOR_dom0_op(&op); 119 + ret = HYPERVISOR_platform_op(&op); 120 120 121 121 if (!ret) { 122 122 pr_debug("ACPI CPU%u - C-states uploaded.\n", _pr->acpi_id); ··· 244 244 } 245 245 246 246 if (!no_hypercall) 247 - ret = HYPERVISOR_dom0_op(&op); 247 + ret = HYPERVISOR_platform_op(&op); 248 248 249 249 if (!ret) { 250 250 struct acpi_processor_performance *perf; ··· 302 302 info = &op.u.pcpu_info; 303 303 info->xen_cpuid = 0; 304 304 305 - ret = HYPERVISOR_dom0_op(&op); 305 + ret = HYPERVISOR_platform_op(&op); 306 306 if (ret) 307 307 return NR_CPUS; 308 308 ··· 310 310 last_cpu = op.u.pcpu_info.max_present; 311 311 for (i = 0; i <= last_cpu; i++) { 312 312 info->xen_cpuid = i; 313 - ret = HYPERVISOR_dom0_op(&op); 313 + ret = HYPERVISOR_platform_op(&op); 314 314 if (ret) 315 315 continue; 316 316 max_acpi_id = max(info->acpi_id, max_acpi_id);
+2 -2
drivers/xen/xenfs/xensyms.c
··· 31 31 32 32 symnum = symdata->symnum; 33 33 34 - ret = HYPERVISOR_dom0_op(&xs->op); 34 + ret = HYPERVISOR_platform_op(&xs->op); 35 35 if (ret < 0) 36 36 return ret; 37 37 ··· 50 50 set_xen_guest_handle(symdata->name, xs->name); 51 51 symdata->symnum--; /* Rewind */ 52 52 53 - ret = HYPERVISOR_dom0_op(&xs->op); 53 + ret = HYPERVISOR_platform_op(&xs->op); 54 54 if (ret < 0) 55 55 return ret; 56 56 }
+50
include/uapi/xen/gntdev.h
··· 144 144 __u32 event_channel_port; 145 145 }; 146 146 147 + struct gntdev_grant_copy_segment { 148 + union { 149 + void __user *virt; 150 + struct { 151 + grant_ref_t ref; 152 + __u16 offset; 153 + domid_t domid; 154 + } foreign; 155 + } source, dest; 156 + __u16 len; 157 + 158 + __u16 flags; /* GNTCOPY_* */ 159 + __s16 status; /* GNTST_* */ 160 + }; 161 + 162 + /* 163 + * Copy between grant references and local buffers. 164 + * 165 + * The copy is split into @count @segments, each of which can copy 166 + * to/from one grant reference. 167 + * 168 + * Each segment is similar to struct gnttab_copy in the hypervisor ABI 169 + * except the local buffer is specified using a virtual address 170 + * (instead of a GFN and offset). 171 + * 172 + * The local buffer may cross a Xen page boundary -- the driver will 173 + * split segments into multiple ops if required. 174 + * 175 + * Returns 0 if all segments have been processed and @status in each 176 + * segment is valid. Note that one or more segments may have failed 177 + * (status != GNTST_okay). 178 + * 179 + * If the driver had to split a segment into two or more ops, @status 180 + * includes the status of the first failed op for that segment (or 181 + * GNTST_okay if all ops were successful). 182 + * 183 + * If -1 is returned, the status of all segments is undefined. 184 + * 185 + * EINVAL: A segment has local buffers for both source and 186 + * destination. 187 + * EINVAL: A segment crosses the boundary of a foreign page. 188 + * EFAULT: A segment's local buffer is not accessible. 189 + */ 190 + #define IOCTL_GNTDEV_GRANT_COPY \ 191 + _IOC(_IOC_NONE, 'G', 8, sizeof(struct ioctl_gntdev_grant_copy)) 192 + struct ioctl_gntdev_grant_copy { 193 + unsigned int count; 194 + struct gntdev_grant_copy_segment __user *segments; 195 + }; 196 + 147 197 /* Clear (set to zero) the byte specified by index */ 148 198 #define UNMAP_NOTIFY_CLEAR_BYTE 0x1 149 199 /* Send an interrupt on the indicated event channel */
+14 -4
include/xen/interface/platform.h
··· 35 35 * Set clock such that it would read <secs,nsecs> after 00:00:00 UTC, 36 36 * 1 January, 1970 if the current system time was <system_time>. 37 37 */ 38 - #define XENPF_settime 17 39 - struct xenpf_settime { 38 + #define XENPF_settime32 17 39 + struct xenpf_settime32 { 40 40 /* IN variables. */ 41 41 uint32_t secs; 42 42 uint32_t nsecs; 43 43 uint64_t system_time; 44 44 }; 45 - DEFINE_GUEST_HANDLE_STRUCT(xenpf_settime_t); 45 + DEFINE_GUEST_HANDLE_STRUCT(xenpf_settime32_t); 46 + #define XENPF_settime64 62 47 + struct xenpf_settime64 { 48 + /* IN variables. */ 49 + uint64_t secs; 50 + uint32_t nsecs; 51 + uint32_t mbz; 52 + uint64_t system_time; 53 + }; 54 + DEFINE_GUEST_HANDLE_STRUCT(xenpf_settime64_t); 46 55 47 56 /* 48 57 * Request memory range (@mfn, @mfn+@nr_mfns-1) to have type @type. ··· 504 495 uint32_t cmd; 505 496 uint32_t interface_version; /* XENPF_INTERFACE_VERSION */ 506 497 union { 507 - struct xenpf_settime settime; 498 + struct xenpf_settime32 settime32; 499 + struct xenpf_settime64 settime64; 508 500 struct xenpf_add_memtype add_memtype; 509 501 struct xenpf_del_memtype del_memtype; 510 502 struct xenpf_read_memtype read_memtype;
+1 -1
include/xen/interface/xen.h
··· 48 48 #define __HYPERVISOR_set_callbacks 4 49 49 #define __HYPERVISOR_fpu_taskswitch 5 50 50 #define __HYPERVISOR_sched_op_compat 6 51 - #define __HYPERVISOR_dom0_op 7 51 + #define __HYPERVISOR_platform_op 7 52 52 #define __HYPERVISOR_set_debugreg 8 53 53 #define __HYPERVISOR_get_debugreg 9 54 54 #define __HYPERVISOR_update_descriptor 10
+5
include/xen/xen-ops.h
··· 5 5 #include <linux/notifier.h> 6 6 #include <linux/efi.h> 7 7 #include <asm/xen/interface.h> 8 + #include <xen/interface/vcpu.h> 8 9 9 10 DECLARE_PER_CPU(struct vcpu_info *, xen_vcpu); 10 11 ··· 18 17 19 18 void xen_resume_notifier_register(struct notifier_block *nb); 20 19 void xen_resume_notifier_unregister(struct notifier_block *nb); 20 + 21 + bool xen_vcpu_stolen(int vcpu); 22 + void xen_setup_runstate_info(int cpu); 23 + void xen_get_runstate_snapshot(struct vcpu_runstate_info *res); 21 24 22 25 int xen_setup_shutdown_event(void); 23 26
+3
kernel/sched/cputime.c
··· 5 5 #include <linux/static_key.h> 6 6 #include <linux/context_tracking.h> 7 7 #include "sched.h" 8 + #ifdef CONFIG_PARAVIRT 9 + #include <asm/paravirt.h> 10 + #endif 8 11 9 12 10 13 #ifdef CONFIG_IRQ_TIME_ACCOUNTING