/usr/include/xenomai/asm-x86/bits/shadow.h is in libxenomai-dev 2.6.3-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | /*
* Copyright (C) 2001-2007 Philippe Gerum <rpm@xenomai.org>.
*
* Xenomai is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Xenomai is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Xenomai; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#ifndef _XENO_ASM_X86_BITS_SHADOW_H
#define _XENO_ASM_X86_BITS_SHADOW_H
#define _XENO_ASM_X86_BITS_SHADOW_H
#ifndef __KERNEL__
#error "Pure kernel header included from user-space!"
#endif
static inline void xnarch_init_shadow_tcb(xnarchtcb_t * tcb,
struct xnthread *thread,
const char *name)
{
struct task_struct *task = current;
tcb->user_task = task;
tcb->active_task = NULL;
tcb->spp = &task->thread.x86reg_sp;
#ifdef CONFIG_X86_64
tcb->ipp = &task->thread.rip; /* <!> raw naming intended. */
#else
tcb->ipp = &task->thread.x86reg_ip;
#endif
tcb->fpup = x86_fpustate_ptr(&task->thread);
tcb->entry = NULL;
tcb->cookie = NULL;
tcb->self = thread;
tcb->imask = 0;
tcb->name = name;
}
static inline int xnarch_local_syscall(struct pt_regs *regs)
{
return -ENOSYS;
}
static void xnarch_schedule_tail(struct task_struct *prev)
{
#ifdef CONFIG_X86_32
wrap_switch_iobitmap(prev, rthal_processor_id());
#endif
}
#ifdef XNARCH_HAVE_MAYDAY
static inline void xnarch_setup_mayday_page(void *page)
{
#ifdef CONFIG_X86_64
/*
* We want this code to appear at the top of the MAYDAY page:
*
* b8 2b 02 00 0c mov $<mux_code>,%eax
* 0f 05 syscall
* 0f 0b ud2a
*
* We intentionally don't mess with EFLAGS here, so that we
* don't have to save/restore it in handle/fixup code.
*/
static const struct __attribute__ ((__packed__)) {
struct __attribute__ ((__packed__)) {
u8 op;
u32 imm;
} mov_eax;
u16 syscall;
u16 bug;
} code = {
.mov_eax = {
.op = 0xb8,
.imm = __xn_mux_code(0, __xn_sys_mayday)
},
.syscall = 0x050f,
.bug = 0x0b0f,
};
memcpy(page, &code, sizeof(code));
#else /* CONFIG_X86_32 */
/*
* We want this code to appear at the top of the MAYDAY page:
*
* b8 2b 02 00 0c mov $<mux_code>,%eax
* if HAVE_SEP
* 65 ff 15 10 00 00 00 call *%gs:0x10
* else
* cd 80 int $0x80
* endif
* 0f 0b ud2a
*
* We intentionally don't mess with EFLAGS here, so that we
* don't have to save/restore it in handle/fixup code.
*
* Also note that if SEP is present, we always assume NPTL on
* the user side.
*/
static const struct __attribute__ ((__packed__)) {
struct __attribute__ ((__packed__)) {
u8 op;
u32 imm;
} mov_eax;
struct __attribute__ ((__packed__)) {
u8 op[3];
u32 moffs;
} syscall;
u16 bug;
} code_sep = {
.mov_eax = {
.op = 0xb8,
.imm = __xn_mux_code(0, __xn_sys_mayday)
},
.syscall = {
.op = {
0x65, 0xff, 0x15
},
.moffs = 0x10
},
.bug = 0x0b0f,
};
static const struct __attribute__ ((__packed__)) {
struct __attribute__ ((__packed__)) {
u8 op;
u32 imm;
} mov_eax;
u16 syscall;
u16 bug;
} code_nosep = {
.mov_eax = {
.op = 0xb8,
.imm = __xn_mux_code(0, __xn_sys_mayday)
},
.syscall = 0x80cd,
.bug = 0x0b0f,
};
if (cpu_has_sep)
memcpy(page, &code_sep, sizeof(code_sep));
else
memcpy(page, &code_nosep, sizeof(code_nosep));
#endif /* CONFIG_X86_32 */
/* no cache flush required. */
}
static inline void xnarch_call_mayday(struct task_struct *p)
{
rthal_return_intercept(p);
}
static inline void xnarch_handle_mayday(struct xnarchtcb *tcb,
struct pt_regs *regs,
unsigned long tramp)
{
tcb->mayday.sp = regs->x86reg_sp;
tcb->mayday.ip = regs->x86reg_ip;
tcb->mayday.ax = regs->x86reg_ax;
regs->x86reg_ip = tramp;
}
static inline void xnarch_fixup_mayday(struct xnarchtcb *tcb,
struct pt_regs *regs)
{
regs->x86reg_ip = tcb->mayday.ip;
regs->x86reg_ax = tcb->mayday.ax;
regs->x86reg_sp = tcb->mayday.sp;
}
#endif /* XNARCH_HAVE_MAYDAY */
#endif /* !_XENO_ASM_X86_BITS_SHADOW_H */
|