typedef u32 uprobe_opcode_t;
+static inline u32 swap_get_float(struct pt_regs *regs, unsigned long n)
+{
+ u32 *ptr;
+ register unsigned long w0 asm ("w0");
+
+ switch (n) {
+ case 0:
+ asm volatile("fmov w0, s0");
+ break;
+ case 1:
+ asm volatile("fmov w0, s1");
+ break;
+ case 2:
+ asm volatile("fmov w0, s2");
+ break;
+ case 3:
+ asm volatile("fmov w0, s3");
+ break;
+ case 4:
+ asm volatile("fmov w0, s4");
+ break;
+ case 5:
+ asm volatile("fmov w0, s5");
+ break;
+ case 6:
+ asm volatile("fmov w0, s6");
+ break;
+ case 7:
+ asm volatile("fmov w0, s7");
+ break;
+ default:
+ w0 = 0;
+ ptr = (u32 *)((u64 *)regs->sp + n - 8);
+ if (get_user(w0, ptr))
+ pr_err("failed to dereference a pointer\n");
+
+ break;
+ }
+
+ return w0;
+}
+
+static inline u64 swap_get_double(struct pt_regs *regs, unsigned long n)
+{
+ u64 *ptr;
+ register unsigned long x0 asm ("x0");
+
+ switch (n) {
+ case 0:
+ asm volatile("fmov x0, d0");
+ break;
+ case 1:
+ asm volatile("fmov x0, d1");
+ break;
+ case 2:
+ asm volatile("fmov x0, d2");
+ break;
+ case 3:
+ asm volatile("fmov x0, d3");
+ break;
+ case 4:
+ asm volatile("fmov x0, d4");
+ break;
+ case 5:
+ asm volatile("fmov x0, d5");
+ break;
+ case 6:
+ asm volatile("fmov x0, d6");
+ break;
+ case 7:
+ asm volatile("fmov x0, d7");
+ break;
+ default:
+ x0 = 0;
+ ptr = (u64 *)regs->sp + n - 8;
+ if (get_user(x0, ptr))
+ pr_err("failed to dereference a pointer\n");
+
+ break;
+ }
+
+ return x0;
+}
+
static inline u32 swap_get_urp_float(struct pt_regs *regs)
{
- WARN(1, "not implemented"); /* FIXME: to implement */
- return 0;
+ return swap_get_float(regs, 0);
}
static inline u64 swap_get_urp_double(struct pt_regs *regs)
{
- WARN(1, "not implemented"); /* FIXME: to implement */
- return 0;
+ return swap_get_double(regs, 0);
}
-static inline unsigned long swap_get_uarg(struct pt_regs *regs, unsigned long n)
+static inline unsigned long swap_get_uarg_arm64(struct pt_regs *regs,
+ unsigned long n)
{
- if (compat_user_mode(regs)) {
- return swap_get_uarg_arm(regs, n);
+ u64 *ptr, val;
+
+ if (n < 8)
+ return regs->regs[n];
+
+ ptr = (u64 *)regs->sp + n - 8;
+ if (get_user(val, ptr))
+ pr_err("failed to dereference a pointer, ptr=%p\n", ptr);
+
+ return val;
+}
+
+static inline void swap_put_uarg_arm64(struct pt_regs *regs, unsigned long n,
+ unsigned long val)
+{
+ if (n < 8) {
+ regs->regs[n] = val;
} else {
- WARN(1, "not implemented"); /* FIXME: to implement */
- return 0x12345678;
+ u64 *ptr = (u64 *)regs->sp + n - 8;
+ if (put_user(val, ptr))
+ pr_err("Failed to dereference a pointer, ptr=%p\n", ptr);
}
}
+static inline unsigned long swap_get_uarg(struct pt_regs *regs, unsigned long n)
+{
+ if (compat_user_mode(regs))
+ return swap_get_uarg_arm(regs, n);
+ else
+ return swap_get_uarg_arm64(regs, n);
+}
+
static inline void swap_put_uarg(struct pt_regs *regs, unsigned long n,
unsigned long val)
{