Skip to content

Commit 5e1cdb8

Browse files
Oleksandr Tyshchenkojgross1
authored andcommitted
arm/xen: Switch to use gnttab_setup_auto_xlat_frames() for DT
Read the start address of the grant table space from DT (region 0). This patch mostly restores behaviour before commit 3cf4095 ("arm/xen: Use xen_xlate_map_ballooned_pages to setup grant table") but trying not to break the ACPI support added after that commit. So the patch touches DT part only and leaves the ACPI part with xen_xlate_map_ballooned_pages(). Also in order to make a code more resilient use a fallback to xen_xlate_map_ballooned_pages() if grant table region wasn't found. This is a preparation for using Xen extended region feature where unused regions of guest physical address space (provided by the hypervisor) will be used to create grant/foreign/whatever mappings instead of wasting real RAM pages from the domain memory for establishing these mappings. The immediate benefit of this change: - Avoid superpage shattering in Xen P2M when establishing stage-2 mapping (GFN <-> MFN) for the grant table space - Avoid wasting real RAM pages (reducing the amount of memory usuable) for mapping grant table space - The grant table space is always mapped at the exact same place (region 0 is reserved for the grant table) Signed-off-by: Oleksandr Tyshchenko <[email protected]> Reviewed-by: Stefano Stabellini <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Juergen Gross <[email protected]>
1 parent fbf3a5c commit 5e1cdb8

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

arch/arm/xen/enlighten.c

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ unsigned long xen_released_pages;
5959
struct xen_memory_region xen_extra_mem[XEN_EXTRA_MEM_MAX_REGIONS] __initdata;
6060

6161
static __read_mostly unsigned int xen_events_irq;
62+
static __read_mostly phys_addr_t xen_grant_frames;
63+
64+
#define GRANT_TABLE_INDEX 0
6265

6366
uint32_t xen_start_flags;
6467
EXPORT_SYMBOL(xen_start_flags);
@@ -303,6 +306,7 @@ static void __init xen_acpi_guest_init(void)
303306
static void __init xen_dt_guest_init(void)
304307
{
305308
struct device_node *xen_node;
309+
struct resource res;
306310

307311
xen_node = of_find_compatible_node(NULL, NULL, "xen,xen");
308312
if (!xen_node) {
@@ -311,13 +315,19 @@ static void __init xen_dt_guest_init(void)
311315
}
312316

313317
xen_events_irq = irq_of_parse_and_map(xen_node, 0);
318+
319+
if (of_address_to_resource(xen_node, GRANT_TABLE_INDEX, &res)) {
320+
pr_err("Xen grant table region is not found\n");
321+
return;
322+
}
323+
xen_grant_frames = res.start;
314324
}
315325

316326
static int __init xen_guest_init(void)
317327
{
318328
struct xen_add_to_physmap xatp;
319329
struct shared_info *shared_info_page = NULL;
320-
int cpu;
330+
int rc, cpu;
321331

322332
if (!xen_domain())
323333
return 0;
@@ -370,12 +380,16 @@ static int __init xen_guest_init(void)
370380
for_each_possible_cpu(cpu)
371381
per_cpu(xen_vcpu_id, cpu) = cpu;
372382

373-
xen_auto_xlat_grant_frames.count = gnttab_max_grant_frames();
374-
if (xen_xlate_map_ballooned_pages(&xen_auto_xlat_grant_frames.pfn,
375-
&xen_auto_xlat_grant_frames.vaddr,
376-
xen_auto_xlat_grant_frames.count)) {
383+
if (!xen_grant_frames) {
384+
xen_auto_xlat_grant_frames.count = gnttab_max_grant_frames();
385+
rc = xen_xlate_map_ballooned_pages(&xen_auto_xlat_grant_frames.pfn,
386+
&xen_auto_xlat_grant_frames.vaddr,
387+
xen_auto_xlat_grant_frames.count);
388+
} else
389+
rc = gnttab_setup_auto_xlat_frames(xen_grant_frames);
390+
if (rc) {
377391
free_percpu(xen_vcpu_info);
378-
return -ENOMEM;
392+
return rc;
379393
}
380394
gnttab_init();
381395

0 commit comments

Comments
 (0)