From c5beeb728615d38d620362f1ddf590a91e18a848 Mon Sep 17 00:00:00 2001 From: Grygorii Strashko Date: Mon, 10 Jun 2024 13:08:10 +0300 Subject: [PATCH] drivers: xen: gnttab: process gnttabs in reverse order The Xen extends domain grant tables every time domain requests gnttab basing on gnttab idx. If idx > xen_current_max_gnttab_idx the Xen extends grant table so that idx <= xen_current_max_gnttab_idx. The growing grant tables on every hypercall is a bit costly operation and it also results in the bunch of log messages: (XEN) xen-source/xen/common/grant_table.c:1909:d0v0 Expanding d0 \ grant table from 1 to 2 frames This patch changes gnttab processing from gnttab max_idx to low_idx, so the first hypercall has the largest index, ensuring that the grant table will grow only once. It also reduces number of log messages. Signed-off-by: Grygorii Strashko Acked-by: Volodymyr Babchuk --- drivers/xen/gnttab.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/xen/gnttab.c b/drivers/xen/gnttab.c index 2308cfaf8b14483..aea46f0ad2e4e55 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); }