summaryrefslogtreecommitdiff
path: root/xen/arch/x86/include/asm/hypercall.h
blob: ec2edc771e9ddc5357cfd93dfe21728c85e6efa4 (plain)
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
/******************************************************************************
 * asm-x86/hypercall.h
 */

#ifndef __XEN_HYPERCALL_H__
#error "asm/hypercall.h should not be included directly - include xen/hypercall.h instead"
#endif

#ifndef __ASM_X86_HYPERCALL_H__
#define __ASM_X86_HYPERCALL_H__

#include <xen/types.h>
#include <public/physdev.h>
#include <public/event_channel.h>
#include <public/arch-x86/xen-mca.h> /* for do_mca */
#include <asm/paging.h>

#define __HYPERVISOR_paging_domctl_cont __HYPERVISOR_arch_1

#ifdef CONFIG_PV
void pv_hypercall(struct cpu_user_regs *regs);
#endif

void pv_ring1_init_hypercall_page(void *ptr);
void pv_ring3_init_hypercall_page(void *ptr);

/*
 * Both do_mmuext_op() and do_mmu_update():
 * We steal the m.s.b. of the @count parameter to indicate whether this
 * invocation of do_mmu_update() is resuming a previously preempted call.
 */
#define MMU_UPDATE_PREEMPTED          (~(~0U>>1))

#ifdef CONFIG_COMPAT

#include <compat/arch-x86/xen.h>
#include <compat/physdev.h>
#include <compat/platform.h>

extern int
compat_common_vcpu_op(
    int cmd, struct vcpu *v, XEN_GUEST_HANDLE_PARAM(void) arg);

#endif /* CONFIG_COMPAT */

static inline void clobber_regs64(struct cpu_user_regs *regs,
                                  unsigned int nargs)
{
#ifndef NDEBUG
    /* Deliberately corrupt used parameter regs. */
    switch ( nargs )
    {
    case 5: regs->r8  = 0xdeadbeefdeadf00dUL; fallthrough;
    case 4: regs->r10 = 0xdeadbeefdeadf00dUL; fallthrough;
    case 3: regs->rdx = 0xdeadbeefdeadf00dUL; fallthrough;
    case 2: regs->rsi = 0xdeadbeefdeadf00dUL; fallthrough;
    case 1: regs->rdi = 0xdeadbeefdeadf00dUL;
    }
#endif
}

static inline void clobber_regs32(struct cpu_user_regs *regs,
                                  unsigned int nargs)
{
#ifndef NDEBUG
    /* Deliberately corrupt used parameter regs. */
    switch ( nargs )
    {
    case 5: regs->edi = 0xdeadf00dU; fallthrough;
    case 4: regs->esi = 0xdeadf00dU; fallthrough;
    case 3: regs->edx = 0xdeadf00dU; fallthrough;
    case 2: regs->ecx = 0xdeadf00dU; fallthrough;
    case 1: regs->ebx = 0xdeadf00dU;
    }
#endif
}

#define clobber_regs(r, n, t, b) ({ \
    static const unsigned char t ## b[] = hypercall_args_ ## t ## b; \
    clobber_regs ## b(r, array_access_nospec(t ## b, n)); \
})

#endif /* __ASM_X86_HYPERCALL_H__ */