Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
mariux64
/
linux
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
1
Pull requests
0
Actions
Projects
0
Wiki
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security
Insights
Files
5ead97c
Documentation
arch
block
crypto
drivers
fs
include
acpi
asm-alpha
asm-arm
asm-arm26
asm-avr32
asm-blackfin
asm-cris
asm-frv
asm-generic
asm-h8300
asm-i386
mach-bigsmp
mach-default
mach-es7000
mach-generic
mach-numaq
mach-summit
mach-visws
mach-voyager
xen
hypercall.h
hypervisor.h
interface.h
8253pit.h
Kbuild
a.out.h
acpi.h
agp.h
alternative-asm.i
alternative.h
apic.h
apicdef.h
arch_hooks.h
atomic.h
auxvec.h
bitops.h
boot.h
bootparam.h
bug.h
bugs.h
byteorder.h
cache.h
cacheflush.h
checksum.h
cmpxchg.h
cpu.h
cpufeature.h
cputime.h
current.h
debugreg.h
delay.h
desc.h
device.h
div64.h
dma-mapping.h
dma.h
dmi.h
dwarf2.h
e820.h
edac.h
elf.h
emergency-restart.h
errno.h
fb.h
fcntl.h
fixmap.h
floppy.h
frame.i
futex.h
genapic.h
hardirq.h
highmem.h
hpet.h
hw_irq.h
hypertransport.h
i387.h
i8253.h
i8259.h
ide.h
intel_arch_perfmon.h
io.h
io_apic.h
ioctl.h
ioctls.h
ipc.h
ipcbuf.h
irq.h
irq_regs.h
irqflags.h
ist.h
k8.h
kdebug.h
kexec.h
kmap_types.h
kprobes.h
ldt.h
linkage.h
local.h
math_emu.h
mc146818rtc.h
mca.h
mca_dma.h
mce.h
mman.h
mmu.h
mmu_context.h
mmx.h
mmzone.h
module.h
mpspec.h
mpspec_def.h
msgbuf.h
msidef.h
msr-index.h
msr.h
mtrr.h
mutex.h
namei.h
nmi.h
numa.h
numaq.h
page.h
param.h
paravirt.h
parport.h
pci-direct.h
pci.h
percpu.h
pgalloc.h
pgtable-2level-defs.h
pgtable-2level.h
pgtable-3level-defs.h
pgtable-3level.h
pgtable.h
poll.h
posix_types.h
processor-flags.h
processor.h
ptrace-abi.h
ptrace.h
reboot.h
reboot_fixups.h
required-features.h
resource.h
rtc.h
rwlock.h
rwsem.h
scatterlist.h
seccomp.h
sections.h
segment.h
semaphore.h
sembuf.h
serial.h
setup.h
shmbuf.h
shmparam.h
sigcontext.h
siginfo.h
signal.h
smp.h
socket.h
sockios.h
sparsemem.h
spinlock.h
spinlock_types.h
srat.h
stacktrace.h
stat.h
statfs.h
string.h
suspend.h
sync_bitops.h
system.h
termbits.h
termios.h
therm_throt.h
thread_info.h
time.h
timer.h
timex.h
tlb.h
tlbflush.h
topology.h
tsc.h
types.h
uaccess.h
ucontext.h
unaligned.h
unistd.h
unwind.h
user.h
vga.h
vic.h
vm86.h
vmi.h
vmi_time.h
voyager.h
xor.h
asm-ia64
asm-m32r
asm-m68k
asm-m68knommu
asm-mips
asm-parisc
asm-powerpc
asm-ppc
asm-s390
asm-sh
asm-sh64
asm-sparc
asm-sparc64
asm-um
asm-v850
asm-x86_64
asm-xtensa
crypto
keys
linux
math-emu
media
mtd
net
pcmcia
rdma
rxrpc
scsi
sound
video
xen
Kbuild
init
ipc
kernel
lib
mm
net
scripts
security
sound
usr
.gitignore
.mailmap
COPYING
CREDITS
Kbuild
MAINTAINERS
Makefile
README
REPORTING-BUGS
Breadcrumbs
linux
/
include
/
asm-i386
/
xen
/
hypercall.h
Copy path
Blame
Blame
Latest commit
History
History
413 lines (368 loc) · 10.7 KB
Breadcrumbs
linux
/
include
/
asm-i386
/
xen
/
hypercall.h
Top
File metadata and controls
Code
Blame
413 lines (368 loc) · 10.7 KB
Raw
/****************************************************************************** * hypercall.h * * Linux-specific hypervisor handling. * * Copyright (c) 2002-2004, K A Fraser * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version 2 * as published by the Free Software Foundation; or, when distributed * separately from the Linux kernel or incorporated into other * software packages, subject to the following license: * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this source file (the "Software"), to deal in the Software without * restriction, including without limitation the rights to use, copy, modify, * merge, publish, distribute, sublicense, and/or sell copies of the Software, * and to permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ #ifndef __HYPERCALL_H__ #define __HYPERCALL_H__ #include <linux/errno.h> #include <linux/string.h> #include <xen/interface/xen.h> #include <xen/interface/sched.h> #include <xen/interface/physdev.h> extern struct { char _entry[32]; } hypercall_page[]; #define _hypercall0(type, name) \ ({ \ long __res; \ asm volatile ( \ "call %[call]" \ : "=a" (__res) \ : [call] "m" (hypercall_page[__HYPERVISOR_##name]) \ : "memory" ); \ (type)__res; \ }) #define _hypercall1(type, name, a1) \ ({ \ long __res, __ign1; \ asm volatile ( \ "call %[call]" \ : "=a" (__res), "=b" (__ign1) \ : "1" ((long)(a1)), \ [call] "m" (hypercall_page[__HYPERVISOR_##name]) \ : "memory" ); \ (type)__res; \ }) #define _hypercall2(type, name, a1, a2) \ ({ \ long __res, __ign1, __ign2; \ asm volatile ( \ "call %[call]" \ : "=a" (__res), "=b" (__ign1), "=c" (__ign2) \ : "1" ((long)(a1)), "2" ((long)(a2)), \ [call] "m" (hypercall_page[__HYPERVISOR_##name]) \ : "memory" ); \ (type)__res; \ }) #define _hypercall3(type, name, a1, a2, a3) \ ({ \ long __res, __ign1, __ign2, __ign3; \ asm volatile ( \ "call %[call]" \ : "=a" (__res), "=b" (__ign1), "=c" (__ign2), \ "=d" (__ign3) \ : "1" ((long)(a1)), "2" ((long)(a2)), \ "3" ((long)(a3)), \ [call] "m" (hypercall_page[__HYPERVISOR_##name]) \ : "memory" ); \ (type)__res; \ }) #define _hypercall4(type, name, a1, a2, a3, a4) \ ({ \ long __res, __ign1, __ign2, __ign3, __ign4; \ asm volatile ( \ "call %[call]" \ : "=a" (__res), "=b" (__ign1), "=c" (__ign2), \ "=d" (__ign3), "=S" (__ign4) \ : "1" ((long)(a1)), "2" ((long)(a2)), \ "3" ((long)(a3)), "4" ((long)(a4)), \ [call] "m" (hypercall_page[__HYPERVISOR_##name]) \ : "memory" ); \ (type)__res; \ }) #define _hypercall5(type, name, a1, a2, a3, a4, a5) \ ({ \ long __res, __ign1, __ign2, __ign3, __ign4, __ign5; \ asm volatile ( \ "call %[call]" \ : "=a" (__res), "=b" (__ign1), "=c" (__ign2), \ "=d" (__ign3), "=S" (__ign4), "=D" (__ign5) \ : "1" ((long)(a1)), "2" ((long)(a2)), \ "3" ((long)(a3)), "4" ((long)(a4)), \ "5" ((long)(a5)), \ [call] "m" (hypercall_page[__HYPERVISOR_##name]) \ : "memory" ); \ (type)__res; \ }) static inline int HYPERVISOR_set_trap_table(struct trap_info *table) { return _hypercall1(int, set_trap_table, table); } static inline int HYPERVISOR_mmu_update(struct mmu_update *req, int count, int *success_count, domid_t domid) { return _hypercall4(int, mmu_update, req, count, success_count, domid); } static inline int HYPERVISOR_mmuext_op(struct mmuext_op *op, int count, int *success_count, domid_t domid) { return _hypercall4(int, mmuext_op, op, count, success_count, domid); } static inline int HYPERVISOR_set_gdt(unsigned long *frame_list, int entries) { return _hypercall2(int, set_gdt, frame_list, entries); } static inline int HYPERVISOR_stack_switch(unsigned long ss, unsigned long esp) { return _hypercall2(int, stack_switch, ss, esp); } static inline int HYPERVISOR_set_callbacks(unsigned long event_selector, unsigned long event_address, unsigned long failsafe_selector, unsigned long failsafe_address) { return _hypercall4(int, set_callbacks, event_selector, event_address, failsafe_selector, failsafe_address); } static inline int HYPERVISOR_fpu_taskswitch(int set) { return _hypercall1(int, fpu_taskswitch, set); } static inline int HYPERVISOR_sched_op(int cmd, unsigned long arg) { return _hypercall2(int, sched_op, cmd, arg); } static inline long HYPERVISOR_set_timer_op(u64 timeout) { unsigned long timeout_hi = (unsigned long)(timeout>>32); unsigned long timeout_lo = (unsigned long)timeout; return _hypercall2(long, set_timer_op, timeout_lo, timeout_hi); } static inline int HYPERVISOR_set_debugreg(int reg, unsigned long value) { return _hypercall2(int, set_debugreg, reg, value); } static inline unsigned long HYPERVISOR_get_debugreg(int reg) { return _hypercall1(unsigned long, get_debugreg, reg); } static inline int HYPERVISOR_update_descriptor(u64 ma, u64 desc) { return _hypercall4(int, update_descriptor, ma, ma>>32, desc, desc>>32); } static inline int HYPERVISOR_memory_op(unsigned int cmd, void *arg) { return _hypercall2(int, memory_op, cmd, arg); } static inline int HYPERVISOR_multicall(void *call_list, int nr_calls) { return _hypercall2(int, multicall, call_list, nr_calls); } static inline int HYPERVISOR_update_va_mapping(unsigned long va, pte_t new_val, unsigned long flags) { unsigned long pte_hi = 0; #ifdef CONFIG_X86_PAE pte_hi = new_val.pte_high; #endif return _hypercall4(int, update_va_mapping, va, new_val.pte_low, pte_hi, flags); } static inline int HYPERVISOR_event_channel_op(int cmd, void *arg) { int rc = _hypercall2(int, event_channel_op, cmd, arg); if (unlikely(rc == -ENOSYS)) { struct evtchn_op op; op.cmd = cmd; memcpy(&op.u, arg, sizeof(op.u)); rc = _hypercall1(int, event_channel_op_compat, &op); memcpy(arg, &op.u, sizeof(op.u)); } return rc; } static inline int HYPERVISOR_xen_version(int cmd, void *arg) { return _hypercall2(int, xen_version, cmd, arg); } static inline int HYPERVISOR_console_io(int cmd, int count, char *str) { return _hypercall3(int, console_io, cmd, count, str); } static inline int HYPERVISOR_physdev_op(int cmd, void *arg) { int rc = _hypercall2(int, physdev_op, cmd, arg); if (unlikely(rc == -ENOSYS)) { struct physdev_op op; op.cmd = cmd; memcpy(&op.u, arg, sizeof(op.u)); rc = _hypercall1(int, physdev_op_compat, &op); memcpy(arg, &op.u, sizeof(op.u)); } return rc; } static inline int HYPERVISOR_grant_table_op(unsigned int cmd, void *uop, unsigned int count) { return _hypercall3(int, grant_table_op, cmd, uop, count); } static inline int HYPERVISOR_update_va_mapping_otherdomain(unsigned long va, pte_t new_val, unsigned long flags, domid_t domid) { unsigned long pte_hi = 0; #ifdef CONFIG_X86_PAE pte_hi = new_val.pte_high; #endif return _hypercall5(int, update_va_mapping_otherdomain, va, new_val.pte_low, pte_hi, flags, domid); } static inline int HYPERVISOR_vm_assist(unsigned int cmd, unsigned int type) { return _hypercall2(int, vm_assist, cmd, type); } static inline int HYPERVISOR_vcpu_op(int cmd, int vcpuid, void *extra_args) { return _hypercall3(int, vcpu_op, cmd, vcpuid, extra_args); } static inline int HYPERVISOR_suspend(unsigned long srec) { return _hypercall3(int, sched_op, SCHEDOP_shutdown, SHUTDOWN_suspend, srec); } static inline int HYPERVISOR_nmi_op(unsigned long op, unsigned long arg) { return _hypercall2(int, nmi_op, op, arg); } static inline void MULTI_update_va_mapping(struct multicall_entry *mcl, unsigned long va, pte_t new_val, unsigned long flags) { mcl->op = __HYPERVISOR_update_va_mapping; mcl->args[0] = va; #ifdef CONFIG_X86_PAE mcl->args[1] = new_val.pte_low; mcl->args[2] = new_val.pte_high; #else mcl->args[1] = new_val.pte_low; mcl->args[2] = 0; #endif mcl->args[3] = flags; } static inline void MULTI_grant_table_op(struct multicall_entry *mcl, unsigned int cmd, void *uop, unsigned int count) { mcl->op = __HYPERVISOR_grant_table_op; mcl->args[0] = cmd; mcl->args[1] = (unsigned long)uop; mcl->args[2] = count; } static inline void MULTI_update_va_mapping_otherdomain(struct multicall_entry *mcl, unsigned long va, pte_t new_val, unsigned long flags, domid_t domid) { mcl->op = __HYPERVISOR_update_va_mapping_otherdomain; mcl->args[0] = va; #ifdef CONFIG_X86_PAE mcl->args[1] = new_val.pte_low; mcl->args[2] = new_val.pte_high; #else mcl->args[1] = new_val.pte_low; mcl->args[2] = 0; #endif mcl->args[3] = flags; mcl->args[4] = domid; } static inline void MULTI_update_descriptor(struct multicall_entry *mcl, u64 maddr, struct desc_struct desc) { mcl->op = __HYPERVISOR_update_descriptor; mcl->args[0] = maddr; mcl->args[1] = maddr >> 32; mcl->args[2] = desc.a; mcl->args[3] = desc.b; } static inline void MULTI_memory_op(struct multicall_entry *mcl, unsigned int cmd, void *arg) { mcl->op = __HYPERVISOR_memory_op; mcl->args[0] = cmd; mcl->args[1] = (unsigned long)arg; } static inline void MULTI_mmu_update(struct multicall_entry *mcl, struct mmu_update *req, int count, int *success_count, domid_t domid) { mcl->op = __HYPERVISOR_mmu_update; mcl->args[0] = (unsigned long)req; mcl->args[1] = count; mcl->args[2] = (unsigned long)success_count; mcl->args[3] = domid; } static inline void MULTI_mmuext_op(struct multicall_entry *mcl, struct mmuext_op *op, int count, int *success_count, domid_t domid) { mcl->op = __HYPERVISOR_mmuext_op; mcl->args[0] = (unsigned long)op; mcl->args[1] = count; mcl->args[2] = (unsigned long)success_count; mcl->args[3] = domid; } static inline void MULTI_set_gdt(struct multicall_entry *mcl, unsigned long *frames, int entries) { mcl->op = __HYPERVISOR_set_gdt; mcl->args[0] = (unsigned long)frames; mcl->args[1] = entries; } static inline void MULTI_stack_switch(struct multicall_entry *mcl, unsigned long ss, unsigned long esp) { mcl->op = __HYPERVISOR_stack_switch; mcl->args[0] = ss; mcl->args[1] = esp; } #endif /* __HYPERCALL_H__ */
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
You can’t perform that action at this time.