1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * pv/traps.h 4 * 5 * PV guest traps interface definitions 6 * 7 * Copyright (C) 2017 Wei Liu <wei.liu2@citrix.com> 8 */ 9 10 #ifndef __X86_PV_TRAPS_H__ 11 #define __X86_PV_TRAPS_H__ 12 13 #ifdef CONFIG_PV 14 15 #include <public/xen.h> 16 17 int pv_raise_nmi(struct vcpu *v); 18 19 int pv_emulate_privileged_op(struct cpu_user_regs *regs); 20 void pv_emulate_gate_op(struct cpu_user_regs *regs); 21 bool pv_emulate_invalid_op(struct cpu_user_regs *regs); 22 pv_trap_callback_registered(const struct vcpu * v,uint8_t vector)23static inline bool pv_trap_callback_registered(const struct vcpu *v, 24 uint8_t vector) 25 { 26 return v->arch.pv.trap_ctxt[vector].address; 27 } 28 29 #else /* !CONFIG_PV */ 30 31 #include <xen/errno.h> 32 pv_raise_nmi(struct vcpu * v)33static inline int pv_raise_nmi(struct vcpu *v) { return -EOPNOTSUPP; } 34 pv_emulate_privileged_op(struct cpu_user_regs * regs)35static inline int pv_emulate_privileged_op(struct cpu_user_regs *regs) { return 0; } pv_emulate_gate_op(struct cpu_user_regs * regs)36static inline void pv_emulate_gate_op(struct cpu_user_regs *regs) {} pv_emulate_invalid_op(struct cpu_user_regs * regs)37static inline bool pv_emulate_invalid_op(struct cpu_user_regs *regs) { return true; } 38 pv_trap_callback_registered(const struct vcpu * v,uint8_t vector)39static inline bool pv_trap_callback_registered(const struct vcpu *v, 40 uint8_t vector) 41 { 42 return false; 43 } 44 #endif /* CONFIG_PV */ 45 46 #endif /* __X86_PV_TRAPS_H__ */ 47 48 /* 49 * Local variables: 50 * mode: C 51 * c-file-style: "BSD" 52 * c-basic-offset: 4 53 * tab-width: 4 54 * indent-tabs-mode: nil 55 * End: 56 */ 57