1 #ifndef _X86_64_REGS_H 2 #define _X86_64_REGS_H 3 4 #include <xen/types.h> 5 #include <public/xen.h> 6 7 #define ring_0(r) (((r)->cs & 3) == 0) 8 #define ring_1(r) (((r)->cs & 3) == 1) 9 #define ring_2(r) (((r)->cs & 3) == 2) 10 #define ring_3(r) (((r)->cs & 3) == 3) 11 12 #define guest_kernel_mode(v, r) \ 13 (!is_pv_32bit_vcpu(v) ? \ 14 (ring_3(r) && ((v)->arch.flags & TF_kernel_mode)) : \ 15 (ring_1(r))) 16 17 #define permit_softint(dpl, v, r) \ 18 ((dpl) >= (guest_kernel_mode(v, r) ? 1 : 3)) 19 20 /* Check for null trap callback handler: Is the EIP null? */ 21 #define null_trap_bounce(v, tb) \ 22 (!is_pv_32bit_vcpu(v) ? ((tb)->eip == 0) : (((tb)->cs & ~3) == 0)) 23 24 /* Number of bytes of on-stack execution state to be context-switched. */ 25 /* NB. Segment registers and bases are not saved/restored on x86/64 stack. */ 26 #define CTXT_SWITCH_STACK_BYTES (offsetof(struct cpu_user_regs, es)) 27 28 #endif 29