diff --git a/drivers/xen/gnttab.c b/drivers/xen/gnttab.c index 2308cfaf8b1448..aea46f0ad2e4e5 100644 --- a/drivers/xen/gnttab.c +++ b/drivers/xen/gnttab.c @@ -343,12 +343,12 @@ static int gnttab_init(void) put_free_entry(gref); } - for (i = 0; i < NR_GRANT_FRAMES; i++) { + for (i = NR_GRANT_FRAMES; i; i--) { xatp.domid = DOMID_SELF; xatp.size = 0; xatp.space = XENMAPSPACE_grant_table; - xatp.idx = i; - xatp.gpfn = xen_virt_to_gfn(Z_TOPLEVEL_ROM_NAME(grant_tables).phys_addr) + i; + xatp.idx = i - 1; + xatp.gpfn = xen_virt_to_gfn(Z_TOPLEVEL_ROM_NAME(grant_tables).phys_addr) + (i - 1); rc = HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp); __ASSERT(!rc, "add_to_physmap failed; status = %d\n", rc); }