summaryrefslogtreecommitdiff
path: root/xen/arch/x86/include/asm/pv/traps.h
blob: 404f5b169ca8c888491b4f87db6edc032d178a84 (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
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * pv/traps.h
 *
 * PV guest traps interface definitions
 *
 * Copyright (C) 2017 Wei Liu <wei.liu2@citrix.com>
 */

#ifndef __X86_PV_TRAPS_H__
#define __X86_PV_TRAPS_H__

#ifdef CONFIG_PV

#include <public/xen.h>

void pv_trap_init(void);

int pv_raise_nmi(struct vcpu *v);

int pv_emulate_privileged_op(struct cpu_user_regs *regs);
void pv_emulate_gate_op(struct cpu_user_regs *regs);
bool pv_emulate_invalid_op(struct cpu_user_regs *regs);

static inline bool pv_trap_callback_registered(const struct vcpu *v,
                                               uint8_t vector)
{
    return v->arch.pv.trap_ctxt[vector].address;
}

#else  /* !CONFIG_PV */

#include <xen/errno.h>

static inline void pv_trap_init(void) {}

static inline int pv_raise_nmi(struct vcpu *v) { return -EOPNOTSUPP; }

static inline int pv_emulate_privileged_op(struct cpu_user_regs *regs) { return 0; }
static inline void pv_emulate_gate_op(struct cpu_user_regs *regs) {}
static inline bool pv_emulate_invalid_op(struct cpu_user_regs *regs) { return true; }

static inline bool pv_trap_callback_registered(const struct vcpu *v,
                                               uint8_t vector)
{
    return false;
}
#endif /* CONFIG_PV */

#endif /* __X86_PV_TRAPS_H__ */

/*
 * Local variables:
 * mode: C
 * c-file-style: "BSD"
 * c-basic-offset: 4
 * tab-width: 4
 * indent-tabs-mode: nil
 * End:
 */