#include <xen/event.h>
#include <xen/guest_access.h>
#include <xen/hypercall.h>
+#include <xen/nospec.h>
#include <xen/sched.h>
#include <asm/hap.h>
struct xen_dm_op_set_mem_type *data)
{
xen_pfn_t last_pfn = data->first_pfn + data->nr - 1;
- unsigned int iter = 0;
+ unsigned int iter = 0, mem_type;
int rc = 0;
/* Interface types to internal p2m types */
unlikely(data->mem_type == HVMMEM_unused) )
return -EINVAL;
- if ( data->mem_type == HVMMEM_ioreq_server )
+ mem_type = array_index_nospec(data->mem_type, ARRAY_SIZE(memtype));
+
+ if ( mem_type == HVMMEM_ioreq_server )
{
unsigned int flags;
if ( p2m_is_shared(t) )
rc = -EAGAIN;
- else if ( !allow_p2m_type_change(t, memtype[data->mem_type]) )
+ else if ( !allow_p2m_type_change(t, memtype[mem_type]) )
rc = -EINVAL;
else
- rc = p2m_change_type_one(d, pfn, t, memtype[data->mem_type]);
+ rc = p2m_change_type_one(d, pfn, t, memtype[mem_type]);
put_gfn(d, pfn);
goto out;
}
+ op.op = array_index_nospec(op.op, ARRAY_SIZE(op_size));
+
if ( op_args->buf[0].size < offset + op_size[op.op] )
goto out;
return -E2BIG;
args.domid = domid;
- args.nr_bufs = nr_bufs;
+ args.nr_bufs = array_index_nospec(nr_bufs, ARRAY_SIZE(args.buf) + 1);
for ( i = 0; i < args.nr_bufs; i++ )
{
return -E2BIG;
args.domid = domid;
- args.nr_bufs = nr_bufs;
+ args.nr_bufs = array_index_nospec(nr_bufs, ARRAY_SIZE(args.buf) + 1);
if ( copy_from_guest_offset(&args.buf[0], bufs, 0, args.nr_bufs) )
return -EFAULT;
*/
#include <xen/lib.h>
#include <xen/hypercall.h>
+#include <xen/nospec.h>
#include <asm/hvm/support.h>
BUILD_BUG_ON(ARRAY_SIZE(hvm_hypercall_table) >
ARRAY_SIZE(hypercall_args_table));
- if ( (eax >= ARRAY_SIZE(hvm_hypercall_table)) ||
- !hvm_hypercall_table[eax].native )
+ if ( eax >= ARRAY_SIZE(hvm_hypercall_table) )
+ {
+ regs->rax = -ENOSYS;
+ return HVM_HCALL_completed;
+ }
+
+ eax = array_index_nospec(eax, ARRAY_SIZE(hvm_hypercall_table));
+
+ if ( !hvm_hypercall_table[eax].native )
{
regs->rax = -ENOSYS;
return HVM_HCALL_completed;
#include <xen/guest_access.h> /* copy_from_guest() */
#include <xen/mem_access.h>
+#include <xen/nospec.h>
#include <xen/vm_event.h>
#include <xen/event.h>
#include <public/vm_event.h>
switch ( xaccess )
{
case 0 ... ARRAY_SIZE(memaccess) - 1:
+ xaccess = array_index_nospec(xaccess, ARRAY_SIZE(memaccess));
*paccess = memaccess[xaccess];
break;
case XENMEM_access_default:
#include <xen/compiler.h>
#include <xen/hypercall.h>
+#include <xen/nospec.h>
#include <xen/trace.h>
#define HYPERCALL(x) \
BUILD_BUG_ON(ARRAY_SIZE(pv_hypercall_table) >
ARRAY_SIZE(hypercall_args_table));
- if ( (eax >= ARRAY_SIZE(pv_hypercall_table)) ||
- !pv_hypercall_table[eax].native )
+ if ( eax >= ARRAY_SIZE(pv_hypercall_table) )
+ {
+ regs->rax = -ENOSYS;
+ return;
+ }
+
+ eax = array_index_nospec(eax, ARRAY_SIZE(pv_hypercall_table));
+
+ if ( !pv_hypercall_table[eax].native )
{
regs->rax = -ENOSYS;
return;