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 void pv_trap_init(void); 18 19 int pv_raise_nmi(struct vcpu *v); 20 21 int pv_emulate_privileged_op(struct cpu_user_regs *regs); 22 void pv_emulate_gate_op(struct cpu_user_regs *regs); 23 bool pv_emulate_invalid_op(struct cpu_user_regs *regs); 24 pv_trap_callback_registered(const struct vcpu * v,uint8_t vector)25static inline bool pv_trap_callback_registered(const struct vcpu *v, 26 uint8_t vector) 27 { 28 return v->arch.pv.trap_ctxt[vector].address; 29 } 30 31 #else /* !CONFIG_PV */ 32 33 #include <xen/errno.h> 34 pv_trap_init(void)35static inline void pv_trap_init(void) {} 36 pv_raise_nmi(struct vcpu * v)37static inline int pv_raise_nmi(struct vcpu *v) { return -EOPNOTSUPP; } 38 pv_emulate_privileged_op(struct cpu_user_regs * regs)39static inline int pv_emulate_privileged_op(struct cpu_user_regs *regs) { return 0; } pv_emulate_gate_op(struct cpu_user_regs * regs)40static inline void pv_emulate_gate_op(struct cpu_user_regs *regs) {} pv_emulate_invalid_op(struct cpu_user_regs * regs)41static inline bool pv_emulate_invalid_op(struct cpu_user_regs *regs) { return true; } 42 pv_trap_callback_registered(const struct vcpu * v,uint8_t vector)43static inline bool pv_trap_callback_registered(const struct vcpu *v, 44 uint8_t vector) 45 { 46 return false; 47 } 48 #endif /* CONFIG_PV */ 49 50 #endif /* __X86_PV_TRAPS_H__ */ 51 52 /* 53 * Local variables: 54 * mode: C 55 * c-file-style: "BSD" 56 * c-basic-offset: 4 57 * tab-width: 4 58 * indent-tabs-mode: nil 59 * End: 60 */ 61