return compat_physdev_op(cmd, arg);
}
-#ifndef NDEBUG
-static const unsigned char hypercall_args_64[] = hypercall_args_hvm64;
-static const unsigned char hypercall_args_32[] = hypercall_args_hvm32;
-#endif
-
int hvm_hypercall(struct cpu_user_regs *regs)
{
struct vcpu *curr = current;
regs->r10, regs->r8);
if ( !curr->hcall_preempted && regs->rax != -ENOSYS )
- clobber_regs(regs, get_nargs(hypercall_args_64, eax));
+ clobber_regs(regs, eax, hvm, 64);
}
else
{
curr->hcall_compat = false;
if ( !curr->hcall_preempted && regs->eax != -ENOSYS )
- clobber_regs32(regs, get_nargs(hypercall_args_32, eax));
+ clobber_regs(regs, eax, hvm, 32);
}
hvmemul_cache_restore(curr, token);
#endif /* CONFIG_COMPAT */
-#ifndef NDEBUG
-static inline unsigned int _get_nargs(const unsigned char *tbl, unsigned int c)
-{
- return tbl[c];
-}
-#define get_nargs(t, c) _get_nargs(t, array_index_nospec(c, ARRAY_SIZE(t)))
-#else
-#define get_nargs(tbl, c) 0
-#endif
-
-static inline void clobber_regs(struct cpu_user_regs *regs,
- unsigned int nargs)
+static inline void clobber_regs64(struct cpu_user_regs *regs,
+ unsigned int nargs)
{
#ifndef NDEBUG
/* Deliberately corrupt used parameter regs. */
#endif
}
+#define clobber_regs(r, n, t, b) ({ \
+ static const unsigned char t ## b[] = hypercall_args_ ## t ## b; \
+ clobber_regs ## b(r, array_access_nospec(t ## b, n)); \
+})
+
#endif /* __ASM_X86_HYPERCALL_H__ */
#include <asm/multicall.h>
#include <irq_vectors.h>
-#ifndef NDEBUG
-static const unsigned char hypercall_args_64[] = hypercall_args_pv64;
-#ifdef CONFIG_PV32
-static const unsigned char hypercall_args_32[] = hypercall_args_pv32;
-#endif
-#endif
-
/* Forced inline to cause 'compat' to be evaluated at compile time. */
static void always_inline
_pv_hypercall(struct cpu_user_regs *regs, bool compat)
call_handlers_pv64(eax, regs->rax, rdi, rsi, rdx, r10, r8);
if ( !curr->hcall_preempted && regs->rax != -ENOSYS )
- clobber_regs(regs, get_nargs(hypercall_args_64, eax));
+ clobber_regs(regs, eax, pv, 64);
}
#ifdef CONFIG_PV32
else
curr->hcall_compat = false;
if ( !curr->hcall_preempted && regs->eax != -ENOSYS )
- clobber_regs32(regs, get_nargs(hypercall_args_32, eax));
+ clobber_regs(regs, eax, pv, 32);
}
#endif /* CONFIG_PV32 */