switch ( reg )
{
case 0 ... 3:
- *val = curr->arch.dr[reg];
+ *val = array_access_nospec(curr->arch.dr, reg);
break;
case 4:
ASSERT(modrm_reg < ARRAY_SIZE(byte_reg_offsets));
- /* For safety in release builds. Debug builds will hit the ASSERT() */
+ /* Note that this also acts as array_access_nospec() stand-in. */
modrm_reg &= ARRAY_SIZE(byte_reg_offsets) - 1;
return (void *)regs + byte_reg_offsets[modrm_reg];
b = insn_fetch_type(uint8_t);
opcode |= MASK_INSR(0x8f08 + ext - ext_8f08,
X86EMUL_OPC_EXT_MASK);
- d = xop_table[ext - ext_8f08];
+ d = array_access_nospec(xop_table, ext - ext_8f08);
}
else
{
#define x86_emulate x86_emulate_wrapper
#endif
+#ifdef __XEN__
+# include <xen/nospec.h>
+#else
+# define array_access_nospec(arr, idx) arr[idx]
+#endif
+
/* Map GPRs by ModRM encoding to their offset within struct cpu_user_regs. */
extern const uint8_t cpu_user_regs_gpr_offsets[X86_NR_GPRS];
ASSERT(modrm < ARRAY_SIZE(cpu_user_regs_gpr_offsets));
- /* For safety in release builds. Debug builds will hit the ASSERT() */
+ /* Note that this also acts as array_access_nospec() stand-in. */
modrm &= ARRAY_SIZE(cpu_user_regs_gpr_offsets) - 1;
return (void *)regs + cpu_user_regs_gpr_offsets[modrm];
#include <asm/types.h>
#include <asm/cpufeature.h>
#include <asm/desc.h>
-#include <asm/x86_emulate.h>
#endif
#include <asm/x86-defns.h>