Xen Test Framework
traps.h
Go to the documentation of this file.
1#ifndef XTF_X86_TRAPS_H
2#define XTF_X86_TRAPS_H
3
4#include <xtf/compiler.h>
5#include <arch/regs.h>
6#include <arch/lib.h>
7#include <arch/page.h>
8
9#include <xen/xen.h>
11
12/*
13 * Arch-specific function to initialise the exception entry points, etc.
14 */
15void arch_init_traps(void);
16
17/*
18 * Return the correct %ss/%esp from an exception. In 32bit if no stack switch
19 * occurs, an exception frame doesn't contain this information.
20 */
21static inline unsigned long cpu_regs_sp(const struct cpu_regs *regs)
22{
23#ifdef __x86_64__
24 return regs->_sp;
25#else
26 unsigned int cs = read_cs();
27
28 if ( (regs->cs & 3) > (cs & 3) )
29 return regs->_sp;
30
31 return _u(regs) + offsetof(struct cpu_regs, _sp);
32#endif
33}
34
35static inline unsigned int cpu_regs_ss(const struct cpu_regs *regs)
36{
37#ifdef __x86_64__
38 return regs->_ss;
39#else
40 unsigned int cs = read_cs();
41
42 if ( (regs->cs & 3) > (cs & 3) )
43 return regs->_ss;
44
45 return read_ss();
46#endif
47}
48
49extern uint8_t boot_stack[3 * PAGE_SIZE];
51
54
55/*
56 * Parameters for fine tuning the exec_user_*() behaviour.
57 */
58extern unsigned long exec_user_cs, exec_user_ss;
59extern unsigned long exec_user_efl_and_mask;
60extern unsigned long exec_user_efl_or_mask;
61
62#endif /* XTF_X86_TRAPS_H */
63
64/*
65 * Local variables:
66 * mode: C
67 * c-file-style: "BSD"
68 * c-basic-offset: 4
69 * tab-width: 4
70 * indent-tabs-mode: nil
71 * End:
72 */
static unsigned int read_cs(void)
Definition: lib.h:124
static unsigned int read_ss(void)
Definition: lib.h:169
unsigned long exec_user_ss
Definition: traps.h:58
uint8_t user_stack[PAGE_SIZE]
Definition: setup.c:22
void arch_init_traps(void)
Definition: traps.c:86
unsigned long exec_user_cs
Definition: traps.c:12
unsigned long exec_user_efl_and_mask
Definition: traps.c:14
static unsigned long cpu_regs_sp(const struct cpu_regs *regs)
Definition: traps.h:21
xen_pvh_start_info_t * pvh_start_info
Definition: traps.c:11
xen_pv_start_info_t * pv_start_info
Definition: traps.c:14
unsigned long exec_user_efl_or_mask
Definition: traps.c:16
uint8_t boot_stack[3 *PAGE_SIZE]
Definition: setup.c:21
static unsigned int cpu_regs_ss(const struct cpu_regs *regs)
Definition: traps.h:35
#define _u(v)
Express an arbitrary value v as unsigned long.
Definition: numbers.h:53
#define PAGE_SIZE
Definition: page.h:11
#define offsetof(t, m)
Definition: stddef.h:14
__UINT8_TYPE__ uint8_t
Definition: stdint.h:14