From nobody Thu Mar 28 14:54:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1637787265; cv=none; d=zohomail.com; s=zohoarc; b=VYEw+hQ/XryQ/yPO+1e8ULrHr4X8MQlekA4ifEl/0H4yDEEJVoaSRC6Qn0lcat3Rpo8mNUURDS6cCky1Yt1GhVcAkC4yfqv/jAQy3h7PPE/Ie6mVRvyFBebAxV3vZLTJi2LBdnHovbsbE6bQ58fMp7puR9Ro4nmBJm0b35X59jQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637787265; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=2+gPEFaRRl8eqNS/Y7LbhXO/rInityndJKkrLyh8HGc=; b=ADiiNlKR6qbNodt4afjOpGwag+g7kNClsgVtj/Ft6BtNiQiJxtUzLPD/S8iBEbuFfZb4LaASnVNnZryDLrDxx+JomlKBCn6HR3vH1hsaRgSLVtMbE6x8E77EsZ/nuZAwZGFpyq6JRkvThzCoIsZlASjl5t9QHzjE2fUoFIXisZg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1637787265424687.2327576786378; Wed, 24 Nov 2021 12:54:25 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.230547.398551 (Exim 4.92) (envelope-from ) id 1mpzHD-0006Z5-4p; Wed, 24 Nov 2021 20:53:59 +0000 Received: by outflank-mailman (output) from mailman id 230547.398551; Wed, 24 Nov 2021 20:53:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mpzHD-0006Yy-1V; Wed, 24 Nov 2021 20:53:59 +0000 Received: by outflank-mailman (input) for mailman id 230547; Wed, 24 Nov 2021 20:53:57 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mpzHB-0006Ij-Cr for xen-devel@lists.xenproject.org; Wed, 24 Nov 2021 20:53:57 +0000 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [2a00:1450:4864:20::12b]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id a324125d-4d68-11ec-a9d2-d9f7a1cc8784; Wed, 24 Nov 2021 21:53:55 +0100 (CET) Received: by mail-lf1-x12b.google.com with SMTP id c32so10584617lfv.4 for ; Wed, 24 Nov 2021 12:53:55 -0800 (PST) Received: from otyshchenko.router ([212.22.223.21]) by smtp.gmail.com with ESMTPSA id j11sm97608ljc.9.2021.11.24.12.53.53 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Nov 2021 12:53:54 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: a324125d-4d68-11ec-a9d2-d9f7a1cc8784 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2+gPEFaRRl8eqNS/Y7LbhXO/rInityndJKkrLyh8HGc=; b=IwvGIOlmD0oLisHuoxC0LwTIm8NUw9yKPbrPmZLK8GGePIHRwcp+OPgQg9/dFz2RM+ hiUSYru4os/gS4+2xDQ891EiT8Es/5YWqw9BDywwm1RY5ncIMObRrKeQgjYVgm8B6mkI UveLsDorJ+JQODSdlevg+ZACcmr+4Hinld08AA5HcR8ehyfrQ1nMgCkaYC5qAhWQSESz 3y9fkpnDMP0RELGxwKQ9ofXdvltdwEWn94VpY5+xp5Y4y0Fk5nCw4RjtsfYxeAgV94kC dkhG+TFfzQBAPGrBfx14mFdmFl4LmT6G97wesoZyIx3ogxjn4o/PvrkXx/cU5UZSOZr6 qyTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2+gPEFaRRl8eqNS/Y7LbhXO/rInityndJKkrLyh8HGc=; b=m2O+7BByOZcpzVllj0Xqd7GxOEhcbtcCOdAdHr9Z3uAX2gqdYu6lvTHFVK+O4nzA66 JsXKLBkN4u75wuj8SC0mRZQnzguTesp/v0iw7MDz6+xITA6xda6mnoSvJLkEo/3QxCDs pipLw3nKDeI0XlmwMs+iyXe/jSEc9hY1ZDlvARnUkXn/bBS2aq9kzZ/PuRYMhDyQXGr4 Gu9HflN02dhPRScTD39KEjzTc+edf942OmcTVvK6RLhjnDhIRQsZOqvu4KzELOb/zv7X s5QWkH9W7+8fZKd3bgYUazd/yPLsCl644s+Zh2ilBeAiR0Uu5ykM6kLfJbZQGPKoRO1Y kdjA== X-Gm-Message-State: AOAM5316ULt+dmQjtIIvbljjttldCAGWF/TFPavQuuzEUO2YylrFv++a W3mQlvmAS++iYXqtuPicWUg2BIlt24VMgQ== X-Google-Smtp-Source: ABdhPJzgTBl/5RrVAWHSyUlG+h2B5h/aX5PT6dG7/gd2BKTy6uPSUT4F9O8nlmLnMgGhSJ12GFeJ4g== X-Received: by 2002:a05:6512:22d2:: with SMTP id g18mr17528659lfu.244.1637787234615; Wed, 24 Nov 2021 12:53:54 -0800 (PST) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Cc: Oleksandr Tyshchenko , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Julien Grall Subject: [PATCH V3 1/6] xen/unpopulated-alloc: Drop check for virt_addr_valid() in fill_list() Date: Wed, 24 Nov 2021 22:53:38 +0200 Message-Id: <1637787223-21129-2-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1637787223-21129-1-git-send-email-olekstysh@gmail.com> References: <1637787223-21129-1-git-send-email-olekstysh@gmail.com> X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1637787267472100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Oleksandr Tyshchenko If memremap_pages() succeeds the range is guaranteed to have proper page table, there is no need for an additional virt_addr_valid() check. Signed-off-by: Oleksandr Tyshchenko Reviewed-by: Boris Ostrovsky --- Changes RFC -> V2: - new patch, instead of "[RFC PATCH 1/2] arm64: mm: Make virt_addr_valid to check for pfn_vali= d again" Changes V2 -> V3: - add Boris' R-b --- drivers/xen/unpopulated-alloc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/xen/unpopulated-alloc.c b/drivers/xen/unpopulated-allo= c.c index 87e6b7d..a03dc5b 100644 --- a/drivers/xen/unpopulated-alloc.c +++ b/drivers/xen/unpopulated-alloc.c @@ -85,7 +85,6 @@ static int fill_list(unsigned int nr_pages) for (i =3D 0; i < alloc_pages; i++) { struct page *pg =3D virt_to_page(vaddr + PAGE_SIZE * i); =20 - BUG_ON(!virt_addr_valid(vaddr + PAGE_SIZE * i)); pg->zone_device_data =3D page_list; page_list =3D pg; list_count++; --=20 2.7.4 From nobody Thu Mar 28 14:54:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1637787266; cv=none; d=zohomail.com; s=zohoarc; b=fHXuWhXXiKeFyzE6cbyzU3nsTeUnhFeBK1WxK7dH6Nvyr94n6nRsdmCQLOqaxz+4XxgQieweE+tpqTEW5zYaMg9kkQVF741BVsec0ifdq2GlrMFpkRYxer5Eb4NDgWtTSUcEBHoddPyZMj7eRKaEC+OYhsW/vLpLKMsSnETK1hE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637787266; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=I5Ua+XOo9ED8QtDOWHq4o6dMZ+6zt8B38QrRs94d3jQ=; b=FwCrzjlJar5Rw5t/oOhxb4BjQznO0XIZv+ywvgQSzhlNiln6plXy/Jr5fkHcOap/RczhqEGzNDH/vmkryLeR+sz2OxhKb2i5Mkx9FwNi0idjfQNgX8qZ6B6qKK5p8iqsxhPHUJCyFlZc3kkD8CNdUMW1HoZJ+2Vm/gTLXRjpbgs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1637787266100969.4623910618168; Wed, 24 Nov 2021 12:54:26 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.230549.398561 (Exim 4.92) (envelope-from ) id 1mpzHD-0006fm-Os; Wed, 24 Nov 2021 20:53:59 +0000 Received: by outflank-mailman (output) from mailman id 230549.398561; Wed, 24 Nov 2021 20:53:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mpzHD-0006eC-Ho; Wed, 24 Nov 2021 20:53:59 +0000 Received: by outflank-mailman (input) for mailman id 230549; Wed, 24 Nov 2021 20:53:57 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mpzHB-0006Ij-Qo for xen-devel@lists.xenproject.org; Wed, 24 Nov 2021 20:53:57 +0000 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [2a00:1450:4864:20::12f]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id a385885a-4d68-11ec-a9d2-d9f7a1cc8784; Wed, 24 Nov 2021 21:53:55 +0100 (CET) Received: by mail-lf1-x12f.google.com with SMTP id m27so10495085lfj.12 for ; Wed, 24 Nov 2021 12:53:55 -0800 (PST) Received: from otyshchenko.router ([212.22.223.21]) by smtp.gmail.com with ESMTPSA id j11sm97608ljc.9.2021.11.24.12.53.54 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Nov 2021 12:53:55 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: a385885a-4d68-11ec-a9d2-d9f7a1cc8784 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=I5Ua+XOo9ED8QtDOWHq4o6dMZ+6zt8B38QrRs94d3jQ=; b=N719U68AvD57cSsDPqL5VUMkg/l6W7dFaBn0ds0pOblImoqD4O8SZtTVbiKUWXvfVM QwgG8Z6Ro3SdIlXgsHzI0FIZjBoGs6sAhbvkMgKp55HqgPCIvBZ/bDrqp+nLkExXIDXk 85VfW8+LD7yFAUgUpvJ/2m018THtiaHbBxWJqD8iahLuB6p5h86QVJOti4p/Vko/73Z+ qaK9Vh/scmIZQ9BMI7l50DJ1kbaNGmaBXek6irskc4a0CJq/yZOsKvS2cCwp3ouJixdO l2ac3Q50aoO+804982jn926QvZK1sKU0l7f4bskWWYtjonKnDPp3c5jE7tbHdbSGR8QN +RFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=I5Ua+XOo9ED8QtDOWHq4o6dMZ+6zt8B38QrRs94d3jQ=; b=e9G7dXKebUWbBWV3ZXBwko4Nc8JT4gpT/EEL3qa2BHDvH4ti5EYWBV+jGCrBFdRi83 Rfaoyi2IyfXhVzhlwvFxpr8/cE4hO8j680yrR07sCluYucCgfAyt3Jx/YCdxWl8Cpz/m b89CIbQBreri7yImM8Rwb+WhjTD9UIZ6zNV2z/61s7RCf04080OLhV2l4lA5VtDJCukh a0dy9kKA6z2y6UTVL0BjUzOdJ6m9OAbEr8wFKVURuortUyEa7uvPJ5dnre+2jjvx2dQF jJZfgp2T0qx3GDYehl/dzXVeSecLQikSjBwswOY9CSTo8XOlZrk3f8cup0wP3MZkz7Px +bCg== X-Gm-Message-State: AOAM533PE6dJzTOfJHuPjdo9dOBIqxXMByL7AfFt4fr3FDbLZMRI40Vj CcCOWvJbnky1v6HxjjrprtkxJO3ptlOrVQ== X-Google-Smtp-Source: ABdhPJwpqCkahz5EbzD+MVB6XyFKIyWyAaQlqRXN5qpJziSHo0yhzGV2dme1YXtZkarUALEtZaAUbg== X-Received: by 2002:a05:6512:20d4:: with SMTP id u20mr18715939lfr.339.1637787235341; Wed, 24 Nov 2021 12:53:55 -0800 (PST) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Oleksandr Tyshchenko , Stefano Stabellini , Russell King , Julien Grall Subject: [PATCH V3 2/6] arm/xen: Switch to use gnttab_setup_auto_xlat_frames() for DT Date: Wed, 24 Nov 2021 22:53:39 +0200 Message-Id: <1637787223-21129-3-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1637787223-21129-1-git-send-email-olekstysh@gmail.com> References: <1637787223-21129-1-git-send-email-olekstysh@gmail.com> X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1637787267620100005 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Oleksandr Tyshchenko Read the start address of the grant table space from DT (region 0). This patch mostly restores behaviour before commit 3cf4095d7446 ("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 Reviewed-by: Stefano Stabellini --- Changes RFC -> V2: - new patch Changes V2 -> V3: - add __read_mostly specifier to xen_grant_frames - retain a fallback to xen_xlate_map_ballooned_pages() if xen_grant_frames is invalid - process xen_events_irq before xen_grant_frames in xen_dt_guest_init() - update patch description --- arch/arm/xen/enlighten.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c index 7619fbf..3fb3384 100644 --- a/arch/arm/xen/enlighten.c +++ b/arch/arm/xen/enlighten.c @@ -59,6 +59,9 @@ unsigned long xen_released_pages; struct xen_memory_region xen_extra_mem[XEN_EXTRA_MEM_MAX_REGIONS] __initda= ta; =20 static __read_mostly unsigned int xen_events_irq; +static __read_mostly phys_addr_t xen_grant_frames; + +#define GRANT_TABLE_INDEX 0 =20 uint32_t xen_start_flags; EXPORT_SYMBOL(xen_start_flags); @@ -303,6 +306,7 @@ static void __init xen_acpi_guest_init(void) static void __init xen_dt_guest_init(void) { struct device_node *xen_node; + struct resource res; =20 xen_node =3D of_find_compatible_node(NULL, NULL, "xen,xen"); if (!xen_node) { @@ -311,13 +315,19 @@ static void __init xen_dt_guest_init(void) } =20 xen_events_irq =3D irq_of_parse_and_map(xen_node, 0); + + if (of_address_to_resource(xen_node, GRANT_TABLE_INDEX, &res)) { + pr_err("Xen grant table region is not found\n"); + return; + } + xen_grant_frames =3D res.start; } =20 static int __init xen_guest_init(void) { struct xen_add_to_physmap xatp; struct shared_info *shared_info_page =3D NULL; - int cpu; + int rc, cpu; =20 if (!xen_domain()) return 0; @@ -370,12 +380,16 @@ static int __init xen_guest_init(void) for_each_possible_cpu(cpu) per_cpu(xen_vcpu_id, cpu) =3D cpu; =20 - xen_auto_xlat_grant_frames.count =3D gnttab_max_grant_frames(); - if (xen_xlate_map_ballooned_pages(&xen_auto_xlat_grant_frames.pfn, - &xen_auto_xlat_grant_frames.vaddr, - xen_auto_xlat_grant_frames.count)) { + if (!acpi_disabled || !xen_grant_frames) { + xen_auto_xlat_grant_frames.count =3D gnttab_max_grant_frames(); + rc =3D xen_xlate_map_ballooned_pages(&xen_auto_xlat_grant_frames.pfn, + &xen_auto_xlat_grant_frames.vaddr, + xen_auto_xlat_grant_frames.count); + } else + rc =3D gnttab_setup_auto_xlat_frames(xen_grant_frames); + if (rc) { free_percpu(xen_vcpu_info); - return -ENOMEM; + return rc; } gnttab_init(); =20 --=20 2.7.4 From nobody Thu Mar 28 14:54:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1637787266; cv=none; d=zohomail.com; s=zohoarc; b=XulTVmniH0Nbn4W4YokwwDVsguQGahYIIZOHU7cdzMcouFeP3tnWfKXbwIH8UW4z+vCvnED5lsvQEbDT8HC4glSMIkpgkGR4MegeqAGOai4GgzNPCMfYQ/rFWM/QKDEinsAOFGwkB6ol4rU3DWR/bKmIyNxzWqskHhKDBJri1Xk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637787266; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=bBzcwXnF7StEF2GaOPBNcx1Wl0n3Nu3jkY6wILUpfDk=; b=FcxDswhBqZBKI5KILg8Hi7MoNNjz2eDVHPumyfLsosIQ+QQkX94J+O1pnHArWW4c2IVAryKA2MfYuDKA6Sh9YuMCZwt49BSaOyUNpaIc2Rs988fwJaJEUymuvY1SbhXCwbyUFhdUUvoIQSyG2tRInssIxu2Rhxnv42UAIuwPwM4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1637787266395466.9052948386243; Wed, 24 Nov 2021 12:54:26 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.230548.398558 (Exim 4.92) (envelope-from ) id 1mpzHD-0006cf-Gq; Wed, 24 Nov 2021 20:53:59 +0000 Received: by outflank-mailman (output) from mailman id 230548.398558; Wed, 24 Nov 2021 20:53:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mpzHD-0006am-8d; Wed, 24 Nov 2021 20:53:59 +0000 Received: by outflank-mailman (input) for mailman id 230548; Wed, 24 Nov 2021 20:53:57 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mpzHB-0006Ii-C9 for xen-devel@lists.xenproject.org; Wed, 24 Nov 2021 20:53:57 +0000 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [2a00:1450:4864:20::133]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id a4025026-4d68-11ec-9787-a32c541c8605; Wed, 24 Nov 2021 21:53:56 +0100 (CET) Received: by mail-lf1-x133.google.com with SMTP id r26so10535214lfn.8 for ; Wed, 24 Nov 2021 12:53:56 -0800 (PST) Received: from otyshchenko.router ([212.22.223.21]) by smtp.gmail.com with ESMTPSA id j11sm97608ljc.9.2021.11.24.12.53.55 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Nov 2021 12:53:55 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: a4025026-4d68-11ec-9787-a32c541c8605 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bBzcwXnF7StEF2GaOPBNcx1Wl0n3Nu3jkY6wILUpfDk=; b=hNSawdtIKqKkXOdFHN2uTZ0q0K/gYr/34I9n/95muvOE5k4g8r+/1VT/CEy0n8w4yR mj7aGi00URp6vPVAr3zzo3ZJS82dif3B1J3L2dF9gRosbTigq5HX/z0BdZBEHbPLZ2ko GDWMNBuqcmEkLkmPC9CEM01MzlukwawY1hbayiZATGlp+CoVm1Lr7iq6wk2W88noX3VJ h+wTXLNwR8grH/ovbjNGU8Jia0Iu9rImbPH5g/o26POuEJdgKdP0NzDrZf9f70bq65Yc fCyX8tWWRf0Ro8Tef40cCZtJ61FnNnVIuFocKr5I+1pdq3wdVxSS06cpqfiFNU8/BPDo gUSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bBzcwXnF7StEF2GaOPBNcx1Wl0n3Nu3jkY6wILUpfDk=; b=gZqLEnENOwEgUhbjJ3NOxieBMPBmyVHsDx9FyVIKRXSCCSEWq3oEqSKZpyfuG7ICci lt7icV9R5RkFz4vHI0DmTYxKHvdpBSgRk8AuSyTI4wlIohnYv3Lre5+4lpMM1l7KeZuz B7/ZZ7RCLYwuWDOWNLCDxDWZ0mLFJ/0p6EssE/1doah2NhGnFwkIYgyZtFwhph4FC0xu BPhTtjP8LjU7TQ/XoFgdaYR1X/YHAyw3ytn8+1BBDXW4p99GjJzBU0UGyPlQomShn/eD uQfpGE9MDtW/BhmWw+kOMwraYhhiaXye6kljTP41gPpvNr5JF5CsQ8LJFsd4HzCPB8wC ez4w== X-Gm-Message-State: AOAM5327lYWd1y1ZTsZrXVJXVKi6hDECgpicF7Md97q2TQqIbLUkyGCw OviuLQL7QuaC37OKffz08tY4HGKyb+IgYQ== X-Google-Smtp-Source: ABdhPJyAtC2rXXgB00e51jXJeM37wdOSE76oQzRhOwTYzttgAcdt/wMbcWS+vs/AGA/z25Ivcp2rgQ== X-Received: by 2002:a05:6512:3f0f:: with SMTP id y15mr18956817lfa.263.1637787236043; Wed, 24 Nov 2021 12:53:56 -0800 (PST) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Cc: Oleksandr Tyshchenko , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Julien Grall Subject: [PATCH V3 3/6] xen/balloon: Bring alloc(free)_xenballooned_pages helpers back Date: Wed, 24 Nov 2021 22:53:40 +0200 Message-Id: <1637787223-21129-4-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1637787223-21129-1-git-send-email-olekstysh@gmail.com> References: <1637787223-21129-1-git-send-email-olekstysh@gmail.com> X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1637787267662100007 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Oleksandr Tyshchenko This patch rolls back some of the changes introduced by commit 121f2faca2c0a "xen/balloon: rename alloc/free_xenballooned_pages" in order to make possible to still allocate xenballooned pages if CONFIG_XEN_UNPOPULATED_ALLOC is enabled. On Arm the unpopulated pages will be allocated on top of extended regions provided by Xen via device-tree (the subsequent patches will add required bits to support unpopulated-alloc feature on Arm). The problem is that extended regions feature has been introduced into Xen quite recently (during 4.16 release cycle). So this effectively means that Linux must only use unpopulated-alloc on Arm if it is running on "new Xen" which advertises these regions. But, it will only be known after parsing the "hypervisor" node at boot time, so before doing that we cannot assume anything. In order to keep working if CONFIG_XEN_UNPOPULATED_ALLOC is enabled and the extended regions are not advertised (Linux is running on "old Xen", etc) we need the fallback to alloc_xenballooned_pages(). This way we wouldn't reduce the amount of memory usable (wasting RAM pages) for any of the external mappings anymore (and eliminate XSA-300) with "new Xen", but would be still functional ballooning out RAM pages with "old Xen". Also rename alloc(free)_xenballooned_pages to xen_alloc(free)_ballooned_pag= es and make xen_alloc(free)_unpopulated_pages static inline in xen.h if CONFIG_XEN_UNPOPULATED_ALLOC is disabled. Signed-off-by: Oleksandr Tyshchenko Reviewed-by: Stefano Stabellini --- @Stefano, I decided to retain your R-b after making a minor change (make xen_alloc(free)_unpopulated_pages static inline in xen.h if CONFIG_XEN_UNPOPULATED_ALLOC is disabled). Please let me know if you think otherwise. Changes V2 -> V3: - new patch --- drivers/xen/balloon.c | 20 +++++++++----------- include/xen/balloon.h | 3 +++ include/xen/xen.h | 14 ++++++++++++++ 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c index ba2ea11..a2c4fc49 100644 --- a/drivers/xen/balloon.c +++ b/drivers/xen/balloon.c @@ -581,7 +581,6 @@ void balloon_set_new_target(unsigned long target) } EXPORT_SYMBOL_GPL(balloon_set_new_target); =20 -#ifndef CONFIG_XEN_UNPOPULATED_ALLOC static int add_ballooned_pages(unsigned int nr_pages) { enum bp_state st; @@ -610,12 +609,12 @@ static int add_ballooned_pages(unsigned int nr_pages) } =20 /** - * xen_alloc_unpopulated_pages - get pages that have been ballooned out + * xen_alloc_ballooned_pages - get pages that have been ballooned out * @nr_pages: Number of pages to get * @pages: pages returned * @return 0 on success, error otherwise */ -int xen_alloc_unpopulated_pages(unsigned int nr_pages, struct page **pages) +int xen_alloc_ballooned_pages(unsigned int nr_pages, struct page **pages) { unsigned int pgno =3D 0; struct page *page; @@ -652,23 +651,23 @@ int xen_alloc_unpopulated_pages(unsigned int nr_pages= , struct page **pages) return 0; out_undo: mutex_unlock(&balloon_mutex); - xen_free_unpopulated_pages(pgno, pages); + xen_free_ballooned_pages(pgno, pages); /* - * NB: free_xenballooned_pages will only subtract pgno pages, but since + * NB: xen_free_ballooned_pages will only subtract pgno pages, but since * target_unpopulated is incremented with nr_pages at the start we need * to remove the remaining ones also, or accounting will be screwed. */ balloon_stats.target_unpopulated -=3D nr_pages - pgno; return ret; } -EXPORT_SYMBOL(xen_alloc_unpopulated_pages); +EXPORT_SYMBOL(xen_alloc_ballooned_pages); =20 /** - * xen_free_unpopulated_pages - return pages retrieved with get_ballooned_= pages + * xen_free_ballooned_pages - return pages retrieved with get_ballooned_pa= ges * @nr_pages: Number of pages * @pages: pages to return */ -void xen_free_unpopulated_pages(unsigned int nr_pages, struct page **pages) +void xen_free_ballooned_pages(unsigned int nr_pages, struct page **pages) { unsigned int i; =20 @@ -687,9 +686,9 @@ void xen_free_unpopulated_pages(unsigned int nr_pages, = struct page **pages) =20 mutex_unlock(&balloon_mutex); } -EXPORT_SYMBOL(xen_free_unpopulated_pages); +EXPORT_SYMBOL(xen_free_ballooned_pages); =20 -#if defined(CONFIG_XEN_PV) +#if defined(CONFIG_XEN_PV) && !defined(CONFIG_XEN_UNPOPULATED_ALLOC) static void __init balloon_add_region(unsigned long start_pfn, unsigned long pages) { @@ -712,7 +711,6 @@ static void __init balloon_add_region(unsigned long sta= rt_pfn, balloon_stats.total_pages +=3D extra_pfn_end - start_pfn; } #endif -#endif =20 static int __init balloon_init(void) { diff --git a/include/xen/balloon.h b/include/xen/balloon.h index e93d4f0..f78a6cc 100644 --- a/include/xen/balloon.h +++ b/include/xen/balloon.h @@ -26,6 +26,9 @@ extern struct balloon_stats balloon_stats; =20 void balloon_set_new_target(unsigned long target); =20 +int xen_alloc_ballooned_pages(unsigned int nr_pages, struct page **pages); +void xen_free_ballooned_pages(unsigned int nr_pages, struct page **pages); + #ifdef CONFIG_XEN_BALLOON void xen_balloon_init(void); #else diff --git a/include/xen/xen.h b/include/xen/xen.h index 9f031b5..86c5b37 100644 --- a/include/xen/xen.h +++ b/include/xen/xen.h @@ -52,7 +52,21 @@ bool xen_biovec_phys_mergeable(const struct bio_vec *vec= 1, extern u64 xen_saved_max_mem_size; #endif =20 +#ifdef CONFIG_XEN_UNPOPULATED_ALLOC int xen_alloc_unpopulated_pages(unsigned int nr_pages, struct page **pages= ); void xen_free_unpopulated_pages(unsigned int nr_pages, struct page **pages= ); +#else +#include +static inline int xen_alloc_unpopulated_pages(unsigned int nr_pages, + struct page **pages) +{ + return xen_alloc_ballooned_pages(nr_pages, pages); +} +static inline void xen_free_unpopulated_pages(unsigned int nr_pages, + struct page **pages) +{ + xen_free_ballooned_pages(nr_pages, pages); +} +#endif =20 #endif /* _XEN_XEN_H */ --=20 2.7.4 From nobody Thu Mar 28 14:54:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1637787266; cv=none; d=zohomail.com; s=zohoarc; b=H22mI1/uf8Tjd6re3QYhskhBDnaoXPfaZbaEL21oh4SU0TG5gOghBjrShuAVquSRSFGsqL6k7yzIhKJb4ooPDVVoZdVxBVIXoO4JFjwuJwzjcXLmXIPAz4i9TVi+lJ0dvxnf5vg1hrqSKg+0qLytCaze+Mofd+xmQNw1TqFof7A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637787266; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=nydXLX52YwrHL717y8JqACIh70K6s4jPJYJ5FVkEQUc=; b=npPO/wAC3qfmNm6ltzUgLgiMmofuayGGXwAlNQ++mPuilaG5WsrebP24Pre0T6lsYlbJ7La38awR7inhMjiBDOA7LtNoPxwQiEFBLXZ1v9R1ibFKmG5ggltgyQ1vfyVEitlFgkKCkkVnHNxsoAz9BzvjdLVtG4Yue8yUcJ8mzyA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1637787266276238.35452467039022; Wed, 24 Nov 2021 12:54:26 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.230550.398569 (Exim 4.92) (envelope-from ) id 1mpzHE-0006ou-8m; Wed, 24 Nov 2021 20:54:00 +0000 Received: by outflank-mailman (output) from mailman id 230550.398569; Wed, 24 Nov 2021 20:54:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mpzHD-0006lt-U4; Wed, 24 Nov 2021 20:53:59 +0000 Received: by outflank-mailman (input) for mailman id 230550; Wed, 24 Nov 2021 20:53:58 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mpzHC-0006Ii-7a for xen-devel@lists.xenproject.org; Wed, 24 Nov 2021 20:53:58 +0000 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [2a00:1450:4864:20::135]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id a46d192c-4d68-11ec-9787-a32c541c8605; Wed, 24 Nov 2021 21:53:57 +0100 (CET) Received: by mail-lf1-x135.google.com with SMTP id r26so10535265lfn.8 for ; Wed, 24 Nov 2021 12:53:57 -0800 (PST) Received: from otyshchenko.router ([212.22.223.21]) by smtp.gmail.com with ESMTPSA id j11sm97608ljc.9.2021.11.24.12.53.56 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Nov 2021 12:53:56 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: a46d192c-4d68-11ec-9787-a32c541c8605 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nydXLX52YwrHL717y8JqACIh70K6s4jPJYJ5FVkEQUc=; b=S0/Hy1VQztqXfLaIdZ7NRLcy4Cgt6AjxC+os3QZfoymrzkANGOjalWy4PtASDhqR04 pm2YGuGHn9XAoNxspfeD2BLjYJYjVd35jWL8n4aUjcM6uMr+LmjP2bpqByxIQ3+jnDtl GpbI92uRpPAX2LTIrua/vR8eVu4Oa8D/DrLbUKeDp5zhCz7PJcw1fDQLKjGOKrYlgfAz Cgad1nVB+6DyjxeTHMuA7GpiLVQvKd/xwkSzmYVmATePlD+6UnEAtovn99Y/+3LL8+0T a2eSjaZ9kJ7aim9YZugUpe9w2xjQ64bl/BKq8E/eqb7shRsHSxrlf4LEoRsQ65dFIOhP swDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nydXLX52YwrHL717y8JqACIh70K6s4jPJYJ5FVkEQUc=; b=F/BB67iDsyFxOf6lirEEeGmSTdgJp7U5xYOwgAU8XyXkjFDRw4XUb3/66qn794spW0 3edgCMzGXyT/hg45FuhzqRxMllLNtgu6m5sjix5L/cXp38bO9nNpVZjIRBz0RbZpy30h Xt2uSxcQ0Z7KLcDGkzmw5TwutVz1DXJaQhrwZ7DJ8W89bPYQD+m+lbUl1AFaKVa+l2z2 dHhLmcxCQ3Y5iURLOA3XxlfO5gH+lhSUm/2P1EIIjKlddUjqYTyLHhcB2Henpoxr30at tcIX6u4FoPJbt6SIKqIsdUelYyYMdXtCyRZiYqT3ly3x5uAyntc0yHq0LOFtmzeOHMop Spvg== X-Gm-Message-State: AOAM530jm2SkDc/FCJCc5ErneTXrJtE0no2tUIwQ+jHKB0BAOxhjUXH/ oOmYScRkuH8wg+mJ8JF+GuAuOYBSOx8bFw== X-Google-Smtp-Source: ABdhPJwxLBaQ/pthWYqMY7rBHUSim2HWNTWs+jYcNptICKdkjq/HMfAIPtaj2d48/TFdo6Z2j08r6A== X-Received: by 2002:a05:6512:3602:: with SMTP id f2mr18457888lfs.399.1637787236781; Wed, 24 Nov 2021 12:53:56 -0800 (PST) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Cc: Oleksandr Tyshchenko , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Julien Grall Subject: [PATCH V3 4/6] xen/unpopulated-alloc: Add mechanism to use Xen resource Date: Wed, 24 Nov 2021 22:53:41 +0200 Message-Id: <1637787223-21129-5-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1637787223-21129-1-git-send-email-olekstysh@gmail.com> References: <1637787223-21129-1-git-send-email-olekstysh@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1637787267669100009 From: Oleksandr Tyshchenko The main reason of this change is that unpopulated-alloc code cannot be used in its current form on Arm, but there is a desire to reuse it to avoid wasting real RAM pages for the grant/foreign mappings. The problem is that system "iomem_resource" is used for the address space allocation, but the really unallocated space can't be figured out precisely by the domain on Arm without hypervisor involvement. For example, not all device I/O regions are known by the time domain starts creating grant/foreign mappings. And following the advise from "iomem_resource" we might end up reusing these regions by a mistake. So, the hypervisor which maintains the P2M for the domain is in the best position to provide unused regions of guest physical address space which could be safely used to create grant/foreign mappings. Introduce new helper arch_xen_unpopulated_init() which purpose is to create specific Xen resource based on the memory regions provided by the hypervisor to be used as unused space for Xen scratch pages. If arch doesn't define arch_xen_unpopulated_init() the default "iomem_resource" will be used. Update the arguments list of allocate_resource() in fill_list() to always allocate a region from the hotpluggable range (maximum possible addressable physical memory range for which the linear mapping could be created). If arch doesn't define arch_get_mappable_range() the default range (0,-1) will be used. The behaviour on x86 won't be changed by current patch as both arch_xen_unpopulated_init() and arch_get_mappable_range() are not implemented for it. Also fallback to allocate xenballooned pages (balloon out RAM pages) if we do not have any suitable resource to work with (target_resource is invalid) and as the result we won't be able to provide unpopulated pages on a request. Signed-off-by: Oleksandr Tyshchenko Reviewed-by: Stefano Stabellini --- Please note the following: for V3 arch_xen_unpopulated_init() was moved to init() as was agreed and gained __init specifier. So the target_resource is initialized there. With current patch series applied if CONFIG_XEN_UNPOPULATED_ALLOC is enabled: 1. On Arm, under normal circumstances, the xen_alloc_unpopulated_pages() won't be called =E2=80=9Cbefore=E2=80=9D arch_xen_unpopulated_init(). It wi= ll only be called "before" when either ACPI is in use or something wrong happened with DT (and we failed to read xen_grant_frames), so we fallback to xen_xlate_map_ballooned_pages() in arm/xen/enlighten.c:xen_guest_init(), please see "arm/xen: Switch to use gnttab_setup_auto_xlat_frames() for DT" for details. But in that case, I think, it doesn't matter much whether xen_alloc_unpopulated_pages() is called "before" of "after" target_resource initialization, as we don't have extended regions in place the target_resou= rce will remain invalid even after initialization, so xen_alloc_ballooned_pages= () will be used in both scenarios. 2. On x86, I am not quite sure which modes use unpopulated-alloc (PVH?), but it looks like xen_alloc_unpopulated_pages() can (and will) be called =E2=80=9Cbefore=E2=80=9D arch_xen_unpopulated_init(). At least, I see that xen_xlate_map_ballooned_pages() is called in x86/xen/grant-table.c:xen_pvh_gnttab_setup(). According to the initcall levels for both xen_pvh_gnttab_setup() and init() I expect the former to be called earlier. If it is true, the sentence in the commit description which mentions that =E2=80=9Cbehaviour on x86 is not changed=E2=80=9D is not precise. I do= n=E2=80=99t think it would be correct to fallback to xen_alloc_ballooned_pages() just because we haven=E2=80=99t initialized target_resource yet (on x86 it is ju= st assigning it iomem_resource), at least this doesn't look like an expected behaviour and unlikely would be welcome. I am wondering whether it would be better to move arch_xen_unpopulated_init= () to a dedicated init() marked with an appropriate initcall level (early_init= call?) to make sure it will always be called *before* xen_xlate_map_ballooned_page= s(). What do you think? Changes RFC -> V2: - new patch, instead of "[RFC PATCH 2/2] xen/unpopulated-alloc: Query hypervisor to provide una= llocated space" Changes V2 -> V3: - update patch description and comments in code - modify arch_xen_unpopulated_init() to pass target_resource as an argum= ent and update default helper to assign iomem_resource to it, also drop xen_resource as it will be located in arch code in the future - allocate region from hotpluggable range instead of hardcoded range (0,= -1) in fill_list() - use %pR specifier in error message - do not call unpopulated_init() at runtime from xen_alloc_unpopulated_p= ages(), drop an extra helper and call arch_xen_unpopulated_init() directly fro= m __init() - include linux/ioport.h instead of forward declaration of struct resour= ce - replace insert_resource() with request_resource() in fill_list() - add __init specifier to arch_xen_unpopulated_init() --- drivers/xen/unpopulated-alloc.c | 83 +++++++++++++++++++++++++++++++++++++= ---- include/xen/xen.h | 2 + 2 files changed, 78 insertions(+), 7 deletions(-) diff --git a/drivers/xen/unpopulated-alloc.c b/drivers/xen/unpopulated-allo= c.c index a03dc5b..07d3578 100644 --- a/drivers/xen/unpopulated-alloc.c +++ b/drivers/xen/unpopulated-alloc.c @@ -8,6 +8,7 @@ =20 #include =20 +#include #include #include =20 @@ -15,13 +16,29 @@ static DEFINE_MUTEX(list_lock); static struct page *page_list; static unsigned int list_count; =20 +static struct resource *target_resource; + +/* + * If arch is not happy with system "iomem_resource" being used for + * the region allocation it can provide it's own view by creating specific + * Xen resource with unused regions of guest physical address space provid= ed + * by the hypervisor. + */ +int __weak __init arch_xen_unpopulated_init(struct resource **res) +{ + *res =3D &iomem_resource; + + return 0; +} + static int fill_list(unsigned int nr_pages) { struct dev_pagemap *pgmap; - struct resource *res; + struct resource *res, *tmp_res =3D NULL; void *vaddr; unsigned int i, alloc_pages =3D round_up(nr_pages, PAGES_PER_SECTION); - int ret =3D -ENOMEM; + struct range mhp_range; + int ret; =20 res =3D kzalloc(sizeof(*res), GFP_KERNEL); if (!res) @@ -30,14 +47,40 @@ static int fill_list(unsigned int nr_pages) res->name =3D "Xen scratch"; res->flags =3D IORESOURCE_MEM | IORESOURCE_BUSY; =20 - ret =3D allocate_resource(&iomem_resource, res, - alloc_pages * PAGE_SIZE, 0, -1, + mhp_range =3D mhp_get_pluggable_range(true); + + ret =3D allocate_resource(target_resource, res, + alloc_pages * PAGE_SIZE, mhp_range.start, mhp_range.end, PAGES_PER_SECTION * PAGE_SIZE, NULL, NULL); if (ret < 0) { pr_err("Cannot allocate new IOMEM resource\n"); goto err_resource; } =20 + /* + * Reserve the region previously allocated from Xen resource to avoid + * re-using it by someone else. + */ + if (target_resource !=3D &iomem_resource) { + tmp_res =3D kzalloc(sizeof(*tmp_res), GFP_KERNEL); + if (!res) { + ret =3D -ENOMEM; + goto err_insert; + } + + tmp_res->name =3D res->name; + tmp_res->start =3D res->start; + tmp_res->end =3D res->end; + tmp_res->flags =3D res->flags; + + ret =3D request_resource(&iomem_resource, tmp_res); + if (ret < 0) { + pr_err("Cannot request resource %pR (%d)\n", tmp_res, ret); + kfree(tmp_res); + goto err_insert; + } + } + pgmap =3D kzalloc(sizeof(*pgmap), GFP_KERNEL); if (!pgmap) { ret =3D -ENOMEM; @@ -95,6 +138,11 @@ static int fill_list(unsigned int nr_pages) err_memremap: kfree(pgmap); err_pgmap: + if (tmp_res) { + release_resource(tmp_res); + kfree(tmp_res); + } +err_insert: release_resource(res); err_resource: kfree(res); @@ -112,6 +160,14 @@ int xen_alloc_unpopulated_pages(unsigned int nr_pages,= struct page **pages) unsigned int i; int ret =3D 0; =20 + /* + * Fallback to default behavior if we do not have any suitable resource + * to allocate required region from and as the result we won't be able to + * construct pages. + */ + if (!target_resource) + return xen_alloc_ballooned_pages(nr_pages, pages); + mutex_lock(&list_lock); if (list_count < nr_pages) { ret =3D fill_list(nr_pages - list_count); @@ -159,6 +215,11 @@ void xen_free_unpopulated_pages(unsigned int nr_pages,= struct page **pages) { unsigned int i; =20 + if (!target_resource) { + xen_free_ballooned_pages(nr_pages, pages); + return; + } + mutex_lock(&list_lock); for (i =3D 0; i < nr_pages; i++) { pages[i]->zone_device_data =3D page_list; @@ -169,9 +230,11 @@ void xen_free_unpopulated_pages(unsigned int nr_pages,= struct page **pages) } EXPORT_SYMBOL(xen_free_unpopulated_pages); =20 -#ifdef CONFIG_XEN_PV static int __init init(void) { + int ret; + +#ifdef CONFIG_XEN_PV unsigned int i; =20 if (!xen_domain()) @@ -196,8 +259,14 @@ static int __init init(void) list_count++; } } +#endif =20 - return 0; + ret =3D arch_xen_unpopulated_init(&target_resource); + if (ret) { + pr_err("xen:unpopulated: Cannot initialize target resource\n"); + target_resource =3D NULL; + } + + return ret; } subsys_initcall(init); -#endif diff --git a/include/xen/xen.h b/include/xen/xen.h index 86c5b37..a99bab8 100644 --- a/include/xen/xen.h +++ b/include/xen/xen.h @@ -55,6 +55,8 @@ extern u64 xen_saved_max_mem_size; #ifdef CONFIG_XEN_UNPOPULATED_ALLOC int xen_alloc_unpopulated_pages(unsigned int nr_pages, struct page **pages= ); void xen_free_unpopulated_pages(unsigned int nr_pages, struct page **pages= ); +#include +int arch_xen_unpopulated_init(struct resource **res); #else #include static inline int xen_alloc_unpopulated_pages(unsigned int nr_pages, --=20 2.7.4 From nobody Thu Mar 28 14:54:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1637787266; cv=none; d=zohomail.com; s=zohoarc; b=kgDfYJkvq1y3jzl15283YyU/XZjsTi+ukZ1uhS62nSqvlbmP2Nm02p/wniXFuUJgLQozlgKYU5Bvnnki+3vNfhFDeXXtEyvfveLRkHjTbotWQmjpSAbY9P4FODGuiUp/jhfWRqoMH/GQ2oXZdvBSjQcY+eus2QuT6ysXgw+XfK0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637787266; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=6BK2WZwb7zq+nPDby6saZ0ECEZqzY7Q9bsnh/xJVDtQ=; b=CJHjtWnLy4sAhw282RCBFj/mZt9F+EC3BYJ1LhKVy6lnSnLo62MFKmGpowgFmo6DnNyh2hEtIA8dQcU+S5zD+Edes2gAWjeduC0Kq1l2pmzEVc5eEhmPEqvyMdMdUoF+jTCHIQ1vWmm2AWXtS0c01jwJ4yW3RbfYvQ6MIaECzl0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1637787266349682.6471316550036; Wed, 24 Nov 2021 12:54:26 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.230551.398574 (Exim 4.92) (envelope-from ) id 1mpzHE-0006t4-J0; Wed, 24 Nov 2021 20:54:00 +0000 Received: by outflank-mailman (output) from mailman id 230551.398574; Wed, 24 Nov 2021 20:54:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mpzHE-0006ru-7u; Wed, 24 Nov 2021 20:54:00 +0000 Received: by outflank-mailman (input) for mailman id 230551; Wed, 24 Nov 2021 20:53:58 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mpzHC-0006Ii-Se for xen-devel@lists.xenproject.org; Wed, 24 Nov 2021 20:53:58 +0000 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [2a00:1450:4864:20::12a]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id a4d87cc0-4d68-11ec-9787-a32c541c8605; Wed, 24 Nov 2021 21:53:58 +0100 (CET) Received: by mail-lf1-x12a.google.com with SMTP id r26so10535304lfn.8 for ; Wed, 24 Nov 2021 12:53:57 -0800 (PST) Received: from otyshchenko.router ([212.22.223.21]) by smtp.gmail.com with ESMTPSA id j11sm97608ljc.9.2021.11.24.12.53.56 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Nov 2021 12:53:57 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: a4d87cc0-4d68-11ec-9787-a32c541c8605 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6BK2WZwb7zq+nPDby6saZ0ECEZqzY7Q9bsnh/xJVDtQ=; b=DkhUoPEN5m+YhS0lj/KCPaF95+pgtJLV5AHPKag6SzOXvNY8l/RXclREtUmZBRXscQ w5L+m8mw81fWWD6/E4znSDcSPnrJzgzHKoUFBsWENKP80jotPoLGwbYn3R5HifysInuH Uivjr6j/0kWaIam3Hs3m3s2HMrn2zjLLGFrIEbkq3A7k71iyLEBAspL/4RH9/Lq6907o LEQBmA6woloWkcHZ/v7JD/WbkdPUzyNd+wxQIV09bGMkL6ruQjYv9JYLVHD793Sf4syE f1SmLonhVWMSayC5fvRhjuy+cDukmAAXmCFj+yvwpbZI7hO2YJDJJ/g9zI+SXXsdRtu1 ht+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6BK2WZwb7zq+nPDby6saZ0ECEZqzY7Q9bsnh/xJVDtQ=; b=to21QupI2Pu2XPkQjp8/SSeDV+7e00CSx6iKvLhh0lNsbWUdysHLceu+I+f9yraKTq sqGdKuK2z7+xPQEbT8Xduca+/6OsSq5oNtUWVOLZs37R0QLkLZ1URtR23fNgGojaC6Oz C0S5qdYk+4viaNEdu8/Iib9yqXOX0VrJjgwUEXTDwgjva0MuwD7bVPYBfX/vXvyesSAv HTRd7OnT0m2lorPMRAqXtvbKCF66NDmMDbMBVUDWf1i0bDDjq6KeKUEgi6ICmxS4Cvtn FoObICGLxX5t3h37nxccRRheWgTAmxYEPoAKUis4pvO/+wbjfbbS6A3YojsTn2tvH16k 2d9Q== X-Gm-Message-State: AOAM531wSq15HJ+ofS9MwZ//wh5ZZJQVSz32Dhdc+V1Spq781PXWO2tZ rFvuaWy2MawYaY4yBRSoV/f+df1CmrgalQ== X-Google-Smtp-Source: ABdhPJxBc8gDofCcpBfj+VeGAsm146fKsnDAoZr0N7d3GVfA5RjaGuaXAWpczZc9US5dPuW598oREg== X-Received: by 2002:a05:6512:3763:: with SMTP id z3mr18059562lft.315.1637787237574; Wed, 24 Nov 2021 12:53:57 -0800 (PST) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Oleksandr Tyshchenko , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Russell King , Julien Grall Subject: [PATCH V3 5/6] arm/xen: Read extended regions from DT and init Xen resource Date: Wed, 24 Nov 2021 22:53:42 +0200 Message-Id: <1637787223-21129-6-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1637787223-21129-1-git-send-email-olekstysh@gmail.com> References: <1637787223-21129-1-git-send-email-olekstysh@gmail.com> X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1637787267652100006 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Oleksandr Tyshchenko This patch implements arch_xen_unpopulated_init() on Arm where the extended regions (if any) are gathered from DT and inserted into specific Xen resource to be used as unused address space for Xen scratch pages by unpopulated-alloc code. The extended region (safe range) is a region of guest physical address space which is unused and could be safely used to create grant/foreign mappings instead of wasting real RAM pages from the domain memory for establishing these mappings. The extended regions are chosen by the hypervisor at the domain creation time and advertised to it via "reg" property under hypervisor node in the guest device-tree. As region 0 is reserved for grant table space (always present), the indexes for extended regions are 1...N. If arch_xen_unpopulated_init() fails for some reason the default behaviour will be restored (allocate xenballooned pages). This patch also removes XEN_UNPOPULATED_ALLOC dependency on x86. Signed-off-by: Oleksandr Tyshchenko Reviewed-by: Stefano Stabellini --- Changes RFC -> V2: - new patch, instead of "[RFC PATCH 2/2] xen/unpopulated-alloc: Query hypervisor to provide una= llocated space" Changes V2 -> V3: - update comments in code - drop the checks that a region is within the hotpluggable range, now the common code takes care of - update arch_xen_unpopulated_init() according to interface change, move xen_resource here, etc - use %pR specifier in error message - bait out in arch_xen_unpopulated_init() if !acpi_disabled - update checks in second loop in arch_xen_unpopulated_init() for the sake of clarity --- arch/arm/xen/enlighten.c | 106 +++++++++++++++++++++++++++++++++++++++++++= ++++ drivers/xen/Kconfig | 2 +- 2 files changed, 107 insertions(+), 1 deletion(-) diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c index 3fb3384..019caa6 100644 --- a/arch/arm/xen/enlighten.c +++ b/arch/arm/xen/enlighten.c @@ -62,6 +62,7 @@ static __read_mostly unsigned int xen_events_irq; static __read_mostly phys_addr_t xen_grant_frames; =20 #define GRANT_TABLE_INDEX 0 +#define EXT_REGION_INDEX 1 =20 uint32_t xen_start_flags; EXPORT_SYMBOL(xen_start_flags); @@ -303,6 +304,111 @@ static void __init xen_acpi_guest_init(void) #endif } =20 +#ifdef CONFIG_XEN_UNPOPULATED_ALLOC +/* + * A type-less specific Xen resource which contains extended regions + * (unused regions of guest physical address space provided by the hypervi= sor). + */ +static struct resource xen_resource =3D { + .name =3D "Xen unused space", +}; + +int __init arch_xen_unpopulated_init(struct resource **res) +{ + struct device_node *np; + struct resource *regs, *tmp_res; + uint64_t min_gpaddr =3D -1, max_gpaddr =3D 0; + unsigned int i, nr_reg =3D 0; + int rc; + + if (!xen_domain()) + return -ENODEV; + + if (!acpi_disabled) + return -ENODEV; + + np =3D of_find_compatible_node(NULL, NULL, "xen,xen"); + if (WARN_ON(!np)) + return -ENODEV; + + /* Skip region 0 which is reserved for grant table space */ + while (of_get_address(np, nr_reg + EXT_REGION_INDEX, NULL, NULL)) + nr_reg++; + + if (!nr_reg) { + pr_err("No extended regions are found\n"); + return -EINVAL; + } + + regs =3D kcalloc(nr_reg, sizeof(*regs), GFP_KERNEL); + if (!regs) + return -ENOMEM; + + /* + * Create resource from extended regions provided by the hypervisor to be + * used as unused address space for Xen scratch pages. + */ + for (i =3D 0; i < nr_reg; i++) { + rc =3D of_address_to_resource(np, i + EXT_REGION_INDEX, ®s[i]); + if (rc) + goto err; + + if (max_gpaddr < regs[i].end) + max_gpaddr =3D regs[i].end; + if (min_gpaddr > regs[i].start) + min_gpaddr =3D regs[i].start; + } + + xen_resource.start =3D min_gpaddr; + xen_resource.end =3D max_gpaddr; + + /* + * Mark holes between extended regions as unavailable. The rest of that + * address space will be available for the allocation. + */ + for (i =3D 1; i < nr_reg; i++) { + resource_size_t start, end; + + /* There is an overlap between regions */ + if (regs[i - 1].end + 1 > regs[i].start) { + rc =3D -EINVAL; + goto err; + } + + /* There is no hole between regions */ + if (regs[i - 1].end + 1 =3D=3D regs[i].start) + continue; + + start =3D regs[i - 1].end + 1; + end =3D regs[i].start - 1; + + tmp_res =3D kzalloc(sizeof(*tmp_res), GFP_KERNEL); + if (!tmp_res) { + rc =3D -ENOMEM; + goto err; + } + + tmp_res->name =3D "Unavailable space"; + tmp_res->start =3D start; + tmp_res->end =3D end; + + rc =3D insert_resource(&xen_resource, tmp_res); + if (rc) { + pr_err("Cannot insert resource %pR (%d)\n", tmp_res, rc); + kfree(tmp_res); + goto err; + } + } + + *res =3D &xen_resource; + +err: + kfree(regs); + + return rc; +} +#endif + static void __init xen_dt_guest_init(void) { struct device_node *xen_node; diff --git a/drivers/xen/Kconfig b/drivers/xen/Kconfig index a1b11c62..553b614 100644 --- a/drivers/xen/Kconfig +++ b/drivers/xen/Kconfig @@ -321,7 +321,7 @@ config XEN_FRONT_PGDIR_SHBUF =20 config XEN_UNPOPULATED_ALLOC bool "Use unpopulated memory ranges for guest mappings" - depends on X86 && ZONE_DEVICE + depends on ZONE_DEVICE default XEN_BACKEND || XEN_GNTDEV || XEN_DOM0 help Use unpopulated memory ranges in order to create mappings for guest --=20 2.7.4 From nobody Thu Mar 28 14:54:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1637787265; cv=none; d=zohomail.com; s=zohoarc; b=XBeb4WpmJtax/byhI7ZTycw8+3zmZ7INzkEEiFPy0grpI5Uv54Wwguc0T+nkx5G4GOxxW7HwZTNKb4CY4pv7MEB0i8E1HKt78T2NXYeLUuiZaKPrVA81AHLz8gjRUX9jstd4bsJGj041jHmnfhB8VpI+rd/UaOuwbVWis+TAMlk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637787265; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=4IyNvYikGx/k9tdDU8szk4MiN32bXrdjaPGV4oWEMDs=; b=MMawEQCfpcl3pGQ/anLg8VD//OWNMqXhFuY0V07SmrMtei92JnQzep9ipvnJFdnfPTrbkZiGo0Mlp5sH4re18JgrXnyGV0lNnudseAryR497O3S2/mVEjl7BxPQF5j3EFB28CN5W/BxiZiB4b6rgPLfu4MVD18UtGOTAEK8ewIQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1637787265420395.48402136931213; Wed, 24 Nov 2021 12:54:25 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.230552.398587 (Exim 4.92) (envelope-from ) id 1mpzHF-0007CP-E3; Wed, 24 Nov 2021 20:54:01 +0000 Received: by outflank-mailman (output) from mailman id 230552.398587; Wed, 24 Nov 2021 20:54:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mpzHF-00079N-1E; Wed, 24 Nov 2021 20:54:01 +0000 Received: by outflank-mailman (input) for mailman id 230552; Wed, 24 Nov 2021 20:53:59 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mpzHD-0006Ij-Hw for xen-devel@lists.xenproject.org; Wed, 24 Nov 2021 20:53:59 +0000 Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [2a00:1450:4864:20::234]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id a551efa8-4d68-11ec-a9d2-d9f7a1cc8784; Wed, 24 Nov 2021 21:53:58 +0100 (CET) Received: by mail-lj1-x234.google.com with SMTP id l9so8085216ljq.5 for ; Wed, 24 Nov 2021 12:53:58 -0800 (PST) Received: from otyshchenko.router ([212.22.223.21]) by smtp.gmail.com with ESMTPSA id j11sm97608ljc.9.2021.11.24.12.53.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Nov 2021 12:53:58 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: a551efa8-4d68-11ec-a9d2-d9f7a1cc8784 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4IyNvYikGx/k9tdDU8szk4MiN32bXrdjaPGV4oWEMDs=; b=n18cstBkdjX7c+UShE1M0pp9AYFZa32iOb6HZ8rdrt8352PocjOxC7sjVmfskpFFXJ cP7FvZ6BWua0oznO+XQuZiW0mLUpmRy/h+zuw8dCqT/V+JNfFBCfu/u5oiBnVWhVtKiD R0+SnwDYwNlsoJhw/nYxYgSSU94QG+gmJGIwNvZB7CPivO3tHkuFA7PMxidgOT42knwb 8+rQr70H2QlDBFrCqfUR21+P6rOWVBDezxc6r+nKLjN9Sgrj8z8x9gKvTIgM25fwD6pT f/T2ppOTcyjYvVgFEMcfRXKpWsQYSP/Q7CFluriF7V92BmHfr0hnGQmJkYIyOT12Uqji MVwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4IyNvYikGx/k9tdDU8szk4MiN32bXrdjaPGV4oWEMDs=; b=U+ASQf4MLyhXy33AQZd4Hx1OcUXwDeKc1XNGkjrTAlT4Uo+tBxU42BG/DIFgi8UJ++ xOrH9XLA56VP6/+JT0pLr8JzP1RupLOWwJYI/p9j/tF1aZCfYK9hdU135kmAs9v5iJo4 3H7avEUXm4V/bAL/0UReNLu6IFe9Deh9WthwT/uLFbphjS1QN6d+45LH6+A+Rlq1jhec lQHexPRfOtSh7k6KiTUdnc6iEeZbmSOh+riljtiSW/0UVD0Mru4wLW1B6a50A3Djqa8S imv+YHp1L9wmQBUMdzmcLC7dw/o19Xzx6JrmWwyL5gSij91LZgMwz+Wy6KZET1gA+2nD RWaw== X-Gm-Message-State: AOAM532jFepp36erTlN8Yob6Xcol3Q92ovG21Yvzr6s1FvvFXYCpn/Oz xbFTrdOa+p5k28g9VupdNI9mXIw/NkMFpA== X-Google-Smtp-Source: ABdhPJzbg9X4RTlpGwA/0nX9yg4bi5EiUdsWZuy6cXGIhElPKfsHllDQlnKAQo4feHXv3B9QBwXKpA== X-Received: by 2002:a2e:3c0c:: with SMTP id j12mr19053688lja.402.1637787238288; Wed, 24 Nov 2021 12:53:58 -0800 (PST) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Rob Herring Cc: Oleksandr Tyshchenko , Stefano Stabellini , Julien Grall Subject: [PATCH V3 6/6] dt-bindings: xen: Clarify "reg" purpose Date: Wed, 24 Nov 2021 22:53:43 +0200 Message-Id: <1637787223-21129-7-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1637787223-21129-1-git-send-email-olekstysh@gmail.com> References: <1637787223-21129-1-git-send-email-olekstysh@gmail.com> X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1637787267477100002 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Oleksandr Tyshchenko Xen on Arm has gained new support recently to calculate and report extended regions (unused address space) safe to use for external mappings. These regions are reported via "reg" property under "hypervisor" node in the guest device-tree. As region 0 is reserved for grant table space (always present), the indexes for extended regions are 1...N. No device-tree bindings update is needed (except clarifying the text) as guest infers the presence of extended regions from the number of regions in "reg" property. Signed-off-by: Oleksandr Tyshchenko Reviewed-by: Stefano Stabellini --- According to the recent update to Xen's guest.txt: https://xenbits.xen.org/gitweb/?p=3Dxen.git;a=3Dblob_plain;f=3Ddocs/misc/ar= m/device-tree/guest.txt;hb=3Drefs/heads/master Changes V2 -> V3: - new patch --- Documentation/devicetree/bindings/arm/xen.txt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/arm/xen.txt b/Documentation/= devicetree/bindings/arm/xen.txt index db5c56d..156fe10b 100644 --- a/Documentation/devicetree/bindings/arm/xen.txt +++ b/Documentation/devicetree/bindings/arm/xen.txt @@ -7,10 +7,14 @@ the following properties: compatible =3D "xen,xen-", "xen,xen"; where is the version of the Xen ABI of the platform. =20 -- reg: specifies the base physical address and size of a region in - memory where the grant table should be mapped to, using an - HYPERVISOR_memory_op hypercall. The memory region is large enough to map - the whole grant table (it is larger or equal to gnttab_max_grant_frames(= )). +- reg: specifies the base physical address and size of the regions in memo= ry + where the special resources should be mapped to, using an HYPERVISOR_mem= ory_op + hypercall. + Region 0 is reserved for mapping grant table, it must be always present. + The memory region is large enough to map the whole grant table (it is la= rger + or equal to gnttab_max_grant_frames()). + Regions 1...N are extended regions (unused address space) for mapping fo= reign + GFNs and grants, they might be absent if there is nothing to expose. This property is unnecessary when booting Dom0 using ACPI. =20 - interrupts: the interrupt used by Xen to inject event notifications. --=20 2.7.4