__maybe_unused \
__noinline \
__noreturn \
+ __transparent \
__used \
__user_data \
__user_page_aligned_bss \
return val;
}
-static inline void write_dr0(unsigned long linear)
+static inline void write_dr0(addr_t linear)
{
- asm volatile ("mov %0, %%dr0" :: "r" (linear));
+ asm volatile ("mov %0, %%dr0" :: "r" (linear.val));
}
static inline unsigned long read_dr1(void)
return val;
}
-static inline void write_dr1(unsigned long linear)
+static inline void write_dr1(addr_t linear)
{
- asm volatile ("mov %0, %%dr1" :: "r" (linear));
+ asm volatile ("mov %0, %%dr1" :: "r" (linear.val));
}
static inline unsigned long read_dr2(void)
return val;
}
-static inline void write_dr2(unsigned long linear)
+static inline void write_dr2(addr_t linear)
{
- asm volatile ("mov %0, %%dr2" :: "r" (linear));
+ asm volatile ("mov %0, %%dr2" :: "r" (linear.val));
}
static inline unsigned long read_dr3(void)
return val;
}
-static inline void write_dr3(unsigned long linear)
+static inline void write_dr3(addr_t linear)
{
- asm volatile ("mov %0, %%dr3" :: "r" (linear));
+ asm volatile ("mov %0, %%dr3" :: "r" (linear.val));
}
static inline unsigned long read_dr6(void)
#define __packed __attribute__((__packed__))
#define __printf(f, v) __attribute__((__format__(__printf__, f, v)))
#define __maybe_unused __attribute__((__unused__))
+#define __transparent __attribute__((__transparent_union__))
#define __used __attribute__((__used__))
#define __weak __attribute__((__weak__))
*/
extern char zeroptr[];
+/**
+ * Type (ab)use for helpers which take a linear address, and would like to
+ * accept it in either pointer or integer form.
+ *
+ * Useful for programming hardware registers and datastructures to point to a
+ * specific C object/function, given the flat memory layout.
+ */
+typedef union {
+ unsigned long val;
+ void *ptr;
+} __attribute__((__transparent_union__)) addr_t;
+
#endif /* !__ASSEMBLY__ */
#endif /* XTF_TYPES_H */
write_dr7(0);
/* Point %dr0 at dummy, %dr7 set with %dr0 enabled. */
- write_dr0(_u(&dummy));
+ write_dr0(&dummy);
dr7 = X86_DR7_GE | DR7_SYM(0, G, RW, 32);
/*
{
unsigned int ss = read_ss();
- write_dr0(_u(&ss));
+ write_dr0(&ss);
unsigned long dr7 = DR7_SYM(0, L, G, RW, 32) | X86_DR7_LE | X86_DR7_GE;
exp, _p(exp), fault, _p(fault));
/* Prime the user code for its exploit attempt. */
- write_dr0(_u(&user_ss));
+ write_dr0(&user_ss);
printk("Testing native syscall\n");
exec_user_void(user_syscall);
write_dr6(X86_DR6_BD);
/* Data breakpoint for `ss`, working around Xen's %dr7 latching bug. */
- write_dr0(_u(&ss));
+ write_dr0(&ss);
write_dr7(dr7);
write_dr7(dr7);