From nobody Tue May 7 02:11:19 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=1639080369; cv=none; d=zohomail.com; s=zohoarc; b=PBHT9jf0Eni7tD1EytyGoKgQxakHv+8ZqXonAzy8Rybxuy8TYtz+8nCLp40Z/y6wFZjLhxUXUK31YNkjqs14e9qKBc9rL/lCmuY0QRgj+9Ky3hOSTRVVA5lS8AqguNS99/kfZ/RBCSufFcq8VUe66rH24sVy5lCT24H4vszbSD0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639080369; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=CS9aK8CojMqdb/AcA3jHRSI+mrWqH9RveIgOpizvY9U=; b=W5YLUJqcxJXV2I2GoSLqFgTopi8yBtPi8jYdNmPv8LjSEy2jGSA5++Kqfrq3J5PN90Q8MRlzPA715yth/yEHfS5oMl1ox6P99hRH9I3baSv9TFdtO1WvDfiik1eyWJtWAD6vujcHp6m1kbN3xU6PLFkFN8kObysTkjgJc1dW5FM= 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 1639080369864469.14877602082004; Thu, 9 Dec 2021 12:06:09 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.243309.420884 (Exim 4.92) (envelope-from ) id 1mvPfl-0004bR-32; Thu, 09 Dec 2021 20:05:45 +0000 Received: by outflank-mailman (output) from mailman id 243309.420884; Thu, 09 Dec 2021 20:05:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mvPfk-0004aK-TZ; Thu, 09 Dec 2021 20:05:44 +0000 Received: by outflank-mailman (input) for mailman id 243309; Thu, 09 Dec 2021 20:05:43 +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 1mvPfj-0004Xd-Kc for xen-devel@lists.xenproject.org; Thu, 09 Dec 2021 20:05:43 +0000 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [2a00:1450:4864:20::12c]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 630f33d4-592b-11ec-a831-37629979565c; Thu, 09 Dec 2021 21:05:42 +0100 (CET) Received: by mail-lf1-x12c.google.com with SMTP id k37so14217604lfv.3 for ; Thu, 09 Dec 2021 12:05:42 -0800 (PST) Received: from otyshchenko.router ([212.22.223.21]) by smtp.gmail.com with ESMTPSA id o12sm87371lft.134.2021.12.09.12.05.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Dec 2021 12:05:41 -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: 630f33d4-592b-11ec-a831-37629979565c 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=CS9aK8CojMqdb/AcA3jHRSI+mrWqH9RveIgOpizvY9U=; b=nJ6YIRKoVQppvpal4aj4p6po8BZEoe2W0v2EiJOt2lz9DD/MZQz4YOGAFga6byn+PS bpoNN7jJzU6n+1ymG3q5nkDMcZyj6qh8VLD5qe9Y82B5S10kXdLAgf8PzlZT01cHKuhA JXaYSWqP6JLSTiUSi3EyD3xZ+LiV/d/6rJhFyPL5A2n9Qlamzj6EkCbfiO7uXKvO0fDC dDKM/bTNoo7nV/iChOSyPjaEfVz8kw6VsAW++5dxIl2Ed/EHaOmZKJK0QgUPBpIFINJw 0i+XdqKk7zJC+3HWynXOo7JID118X95q9twABJWbrjnKOuX9i34ZaQ8aTIjd0bmhB/4Y F9XA== 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=CS9aK8CojMqdb/AcA3jHRSI+mrWqH9RveIgOpizvY9U=; b=umZOmpncV5DvbBxEb6oHOlz9kOa+EJ59snXEfx5Oy291ItQ2SyfpA4uv77TgZwEYSy oIEQMnMakZNaEpl8r62MUXf88K8gTGBHVWCO/OoT235i7fmmzqmJmPXNyrNSJsLAFwyJ UUXiT3D5qA9Lpevd7tg9YwG6yTpv1PXK8BIcfcrLTqEq/vAJmyE2lUp8IUFvQ3UyYP/x MSqx+3NQ9OowqNvEkRhE3kboMCLfYs3/gfETBU5qREEQ8VDikS3ohNv7AaSr9YfesIVF S+/eF1KCXHHbSc3fNVIZj1JPf/fw30/YMs+WupmVeOHOyeiVbUUagxejl1BBvtz99CAh YdhA== X-Gm-Message-State: AOAM531GgODPNySFrr8+i1Qh1byPDdkoJ+9YYe+nAb/zIIXYplTOdTVv ohlsDRll3ak3kB0IxTBnh2C9f9oJS+7u4Q== X-Google-Smtp-Source: ABdhPJxerwr28Tg8c06W+QUK8C5H1O0rKZUkku9U1Odi1NykdsC2f8brvhJBN6XBJ2EuJVFZAjwx2Q== X-Received: by 2002:a05:6512:2312:: with SMTP id o18mr8160079lfu.333.1639080342265; Thu, 09 Dec 2021 12:05:42 -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 V4 1/6] xen/unpopulated-alloc: Drop check for virt_addr_valid() in fill_list() Date: Thu, 9 Dec 2021 22:05:31 +0200 Message-Id: <1639080336-26573-2-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1639080336-26573-1-git-send-email-olekstysh@gmail.com> References: <1639080336-26573-1-git-send-email-olekstysh@gmail.com> X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1639080370471100002 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 Changes V3 -> V4: - no changes --- 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 Tue May 7 02:11:19 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=1639080372; cv=none; d=zohomail.com; s=zohoarc; b=JIcg/fmjK7tCOX/wbsvV4VkcLAjwSlVfs8T8L0z7xevku3oNeL0TrQy1eOn2tTzFq7infSyS1P4qtn6xiElMVSDjemFSsQKD+2A7JFToKZeygpc6IcUohJIi1Z21iWUgc53fizBJK+iZYTZBc9L3bRr/K1TQaQgAylpD2KSZrpQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639080372; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=XoEU3DaXUqalCs6jzwcHq5Z2kR7REX3RsrqKMfGCo2w=; b=S2U2YMNAtgO1R7QFUGLsEoUyiFBl8MK0iy4nwdA5cqF4UOlf0L0bihuEsyjv7j4x2uy0LJpeZgtxTdNnnV3d93VlnzSKRpZXkKpbV8nx9jhBzkCIP2pFcnCjvMT26MCtFdga7U+9vnchMUlrkkSHBSxG3GRxlRFUQnSDxA8h5xA= 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 1639080372286323.3301687812683; Thu, 9 Dec 2021 12:06:12 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.243310.420900 (Exim 4.92) (envelope-from ) id 1mvPfm-00053k-9t; Thu, 09 Dec 2021 20:05:46 +0000 Received: by outflank-mailman (output) from mailman id 243310.420900; Thu, 09 Dec 2021 20:05:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mvPfm-00052l-5i; Thu, 09 Dec 2021 20:05:46 +0000 Received: by outflank-mailman (input) for mailman id 243310; Thu, 09 Dec 2021 20:05:45 +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 1mvPfl-0004Xd-7o for xen-devel@lists.xenproject.org; Thu, 09 Dec 2021 20:05:45 +0000 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [2a00:1450:4864:20::229]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 6416bcb1-592b-11ec-a831-37629979565c; Thu, 09 Dec 2021 21:05:44 +0100 (CET) Received: by mail-lj1-x229.google.com with SMTP id 207so10646554ljf.10 for ; Thu, 09 Dec 2021 12:05:44 -0800 (PST) Received: from otyshchenko.router ([212.22.223.21]) by smtp.gmail.com with ESMTPSA id o12sm87371lft.134.2021.12.09.12.05.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Dec 2021 12:05:42 -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: 6416bcb1-592b-11ec-a831-37629979565c 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=XoEU3DaXUqalCs6jzwcHq5Z2kR7REX3RsrqKMfGCo2w=; b=GlM2t+eQRjThRQMjBZpSdxLnDWzEbjJWVwRDusOaEx3MeX4FketF3biTqFzeEnAVU0 VhfKGEcuQp52HiEpPpvacBbuQwd87JvMTehJYvdAXf7KeOioUXb3WO3fCLID1qKZ7UBZ UTgdjk7vrs0SFE8l7HuLKFHyLrmDTcAD9cNMgKBWyA2U3xnLfBw1azVxQh+7gf79/OoO 1dQ4RbzOz6pbkTfeB0WK3PC7JrQpMMkPLByBqimCV2s9g1epLNijcmYesEuTP320tf69 StZYm2luPMAgllAQQSpglOUobSo4Wx1O+YEknSkfIltx1nSkiZfvAJ+J+cQWzBjsQ1vZ FzVg== 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=XoEU3DaXUqalCs6jzwcHq5Z2kR7REX3RsrqKMfGCo2w=; b=2gsRIBCqHKT/MQJ+AGEqyzsUvN9ndHp/Ghtd1RPgTS7CJGvbWPMBnEnL5xedea/719 J8sbIBqCBWni2jUjFMkeM9Lxopj49/uxDWNJlyEko8HwAjd6wo7BIDhHfNtC8MQaUBlZ ONdGtsObBQnj01OWF+Wd2EU9Jh7qFfyZ4r/byzznVkGvvqGYJOUDDd0IgcJYsaARLKji JT5jdqR4irb2XyMmj29cJSZ/8KQnCh7nfujNNOosWzXiMgkDhbJiVML3dGHLh3tYWo46 E/LyPzijMDwkla9U/6WI4fEldfmrXHoEocPkjjoqDSFJZKjlR9SK0c7kmDzdsMbeVAFK hY1Q== X-Gm-Message-State: AOAM5327OMK+6wQKZFXiuTHSMfhwoXlXrLrJ5x0veBDttf7PMoQS+XI3 oJYrwS67kITD5znvQ44PRO4A9NSicNvKPw== X-Google-Smtp-Source: ABdhPJwRwGnN2HYDLn4/ya4vANtMy2LFN1OiYbe33DChi+j/uEDELzNOeHtrWCUSzf5Mr+Zxr7NNrA== X-Received: by 2002:a2e:8ec7:: with SMTP id e7mr8517097ljl.430.1639080343851; Thu, 09 Dec 2021 12:05:43 -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 V4 2/6] arm/xen: Switch to use gnttab_setup_auto_xlat_frames() for DT Date: Thu, 9 Dec 2021 22:05:32 +0200 Message-Id: <1639080336-26573-3-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1639080336-26573-1-git-send-email-olekstysh@gmail.com> References: <1639080336-26573-1-git-send-email-olekstysh@gmail.com> X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1639080373186100001 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 Changes V3 -> V4: - add Stefano's R-b - remove first condition in "if (!acpi_disabled || !xen_grant_frames)" --- 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..49bb675 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 (!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 Tue May 7 02:11:19 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=1639080369; cv=none; d=zohomail.com; s=zohoarc; b=OQ1X4UPq7n4MDR8rVWtvVdjYTW5k5coGg6bumtUqkkhxRoBjycCn5XrI/96tjQbykcpk7crNNJr5Gn6vI2JliABPzR+Ei6raITzyxEIKmVlIBCpLzeYPTfVht0WjEthzb03MqmP/k33zVhp/Y6FgM+N4f6KKJWV53jcougq59Mo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639080369; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=S5p+2FMTZ9me3f7MgyffrybzDu1cB0H0WkSIssxF4tQ=; b=UstCpia9qyequtvI4UpK0jSZKL5Yhop4YkNn4JvEIYXySLT0mwRlXcclKq2utTU85+2Cp4ZVMUgl/0LfUA9cc+CjMUrppo/4QmOJCiaFZuKXs4GY/SW0Z4ha/er9SL6FBJPYA5Ym9pUKJD+3URoSO08ed+V9tvILNFw00whgjkc= 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 1639080369969699.813543746967; Thu, 9 Dec 2021 12:06:09 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.243311.420911 (Exim 4.92) (envelope-from ) id 1mvPfn-0005LD-I9; Thu, 09 Dec 2021 20:05:47 +0000 Received: by outflank-mailman (output) from mailman id 243311.420911; Thu, 09 Dec 2021 20:05:47 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mvPfn-0005Ka-E2; Thu, 09 Dec 2021 20:05:47 +0000 Received: by outflank-mailman (input) for mailman id 243311; Thu, 09 Dec 2021 20:05:46 +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 1mvPfl-0004Xd-VB for xen-devel@lists.xenproject.org; Thu, 09 Dec 2021 20:05:45 +0000 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [2a00:1450:4864:20::135]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 647a245a-592b-11ec-a831-37629979565c; Thu, 09 Dec 2021 21:05:44 +0100 (CET) Received: by mail-lf1-x135.google.com with SMTP id cf39so2064200lfb.8 for ; Thu, 09 Dec 2021 12:05:45 -0800 (PST) Received: from otyshchenko.router ([212.22.223.21]) by smtp.gmail.com with ESMTPSA id o12sm87371lft.134.2021.12.09.12.05.43 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Dec 2021 12:05:44 -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: 647a245a-592b-11ec-a831-37629979565c 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=S5p+2FMTZ9me3f7MgyffrybzDu1cB0H0WkSIssxF4tQ=; b=L+12IgIWe9epXxHZEYZ6HgwZbTEbj/L3wLIDxUpfg2E1xfGiWQMCwOe4aBrheOaE0z wACfBvNIMkXEf+nya8oleo9e8liD3Up08GRb4Pf37/nVLwjUKrMltKBaKTIRQizuPTHa kiB2eeFQVyRO63kGFUo/eHdq51GIFL/uNXEQrwXCo/A+hV/HCtFwDoXNyGsTEKlu6OmK enU+r1Tg1ZYL1MEeX5Ui3wMAW53n6E8DRTyEXCbfwpJxJDVvdGA6r445ekgReyO47/KG 4eMBCsKkqlUsop0XMggtfAv6ao4oSO6uuSiJshxVb2O+ztOTDIWehgeVPb4vaQXzfM9s kn+Q== 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=S5p+2FMTZ9me3f7MgyffrybzDu1cB0H0WkSIssxF4tQ=; b=tFJd13PsjAUFPt9h9emw15BStdFKsoSBlLX3SgRnz8R5jk3L/BVZunpfJDB0OMoZ52 uRGp501JinsTfqNCKeML3TnKDH20xn9FWRDRG5dHbCmPaJNMX0QgosFLCOwkx/oMWiBS 4kuuEdif2FuJnRS/cbQg005PPM3H94QhQktb1vkEiI7nlvR7Jx6zk2OxWSpDiZEVtlzC rf9q+87Lq3FV0l5vmENgosxSTIE49r1c6EjfADOKuTM0iacpHllDBBhEKducH61B3A69 smlB2zCy9IRUcur4n/ZwHgAPHcgLqAhTgxk7OTLVSo0GaR6VOyEde8Zsha/ARDSrrwKK 41Rw== X-Gm-Message-State: AOAM533wcbM9mrkRB9AY+C0DKt/Kw0XaQ46kVWa394rYNLDW4X23RpYR aiqJxr5Vr4CNbfHulZg3vJbpxau82l9+dQ== X-Google-Smtp-Source: ABdhPJzXmNpIc4USAluGA5qsH7ufiWxU3sy77PqmbLRlZ2c4zMxbHDRyt5AvEYyGUnPsWWW7TFMqdg== X-Received: by 2002:a05:6512:3052:: with SMTP id b18mr8189605lfb.424.1639080344638; Thu, 09 Dec 2021 12:05:44 -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 V4 3/6] xen/balloon: Bring alloc(free)_xenballooned_pages helpers back Date: Thu, 9 Dec 2021 22:05:33 +0200 Message-Id: <1639080336-26573-4-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1639080336-26573-1-git-send-email-olekstysh@gmail.com> References: <1639080336-26573-1-git-send-email-olekstysh@gmail.com> X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1639080370607100005 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 --- Changes V2 -> V3: - new patch Changes V3 -> V4: - no changes --- 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 Tue May 7 02:11:19 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=1639080375; cv=none; d=zohomail.com; s=zohoarc; b=nRGi4bQU+ngC+8JOvfxPL7n9U8K2Drm3Bbi20I97SkXfNlwNjtnZ0WgY1RTK1Yc7GwzsxWn0E1i6B86l/j/t568Z9rgsHLPdz3KKHCMzsQdK/0EUp4lUQKKgQ4eJIlXMKkYez+w6ghv7nsmvlx+pW84lUClOaFDN+XmTcy98Kjg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639080375; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=wUGrgrAhSp00M+b8z9JNtCABbdhrenjEQ9qiU7Kp+fE=; b=Xe/qvriMB+Y5QlgmnwfsFD2gsqibEerAXiEp8tstecaAa0KpNLQIhThMSY7DNkqZzdLdV6/AKhZeZx4WOrpYIfGO/FkxCYTzQY+kfY83piQSynD2yJVV+Co8oxKDC+aYNxQ570ySXqfuxXOX9LjFN7ErrMMSJsCpHpM0784dd8w= 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 1639080375786709.1142275619362; Thu, 9 Dec 2021 12:06:15 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.243312.420922 (Exim 4.92) (envelope-from ) id 1mvPfo-0005cN-V5; Thu, 09 Dec 2021 20:05:48 +0000 Received: by outflank-mailman (output) from mailman id 243312.420922; Thu, 09 Dec 2021 20:05:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mvPfo-0005bT-Ny; Thu, 09 Dec 2021 20:05:48 +0000 Received: by outflank-mailman (input) for mailman id 243312; Thu, 09 Dec 2021 20:05:46 +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 1mvPfm-0004Xc-PU for xen-devel@lists.xenproject.org; Thu, 09 Dec 2021 20:05:46 +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 653c11a9-592b-11ec-9d12-4777fae47e2b; Thu, 09 Dec 2021 21:05:45 +0100 (CET) Received: by mail-lf1-x133.google.com with SMTP id cf39so2064278lfb.8 for ; Thu, 09 Dec 2021 12:05:45 -0800 (PST) Received: from otyshchenko.router ([212.22.223.21]) by smtp.gmail.com with ESMTPSA id o12sm87371lft.134.2021.12.09.12.05.44 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Dec 2021 12:05:45 -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: 653c11a9-592b-11ec-9d12-4777fae47e2b 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=wUGrgrAhSp00M+b8z9JNtCABbdhrenjEQ9qiU7Kp+fE=; b=jWc9wxTYHdqYtFuA3EuCo7h3BpGS363+/BKxA5rQ3cK7v9JSmq+KDfWhMZ5nxffD78 O+IAzxYsXqzcb4CpKQY3zvXEk3wabMycLoHM9HUVF0hv4sKedWBrOhTj4sxrjCk6OJLh 2+5G4UMZ/DjD3K/ziMUEaEqkRprnYXh3SXr2zvFaOq/i6MZFzIWUFiC1if1dSuQsK3cB CsXMX7/5EaA5BLRTg+uda1C7EO5EitsbsN0mrbjVq2jH/IFyO6W/DXUNmA4Onw0OfyXl apoUCgdr6WTP+ko9G865vRawOTkNbQD4tDoeuqB+jjE5fERhUWBrFAtoGThXNyt0eDR1 UUTA== 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=wUGrgrAhSp00M+b8z9JNtCABbdhrenjEQ9qiU7Kp+fE=; b=IIF4EkZoxbUILk72XBhG9B0mUWQHNUk4th2p5gtXgu3+JA92hjn5YA8/nV1VQEtr5N oKAc+7pzZQ5hZ92/P2YjEzypWnxcTJ9vkpUlr4oXwDd1BaPuZS+ZQVmRVDxsIZJvIDu0 J5Fe8Bm//bfsPdYfYDFDlPjobk8kzN0PZvD0Jff1hvY2ZKTeQb3GA0El1bannE/ctkCP zIHvzCD8YJDk/czFZo3/Kx2LC9sGFWQDrSHLydC31RNsK5u8T8QbhwcJ8dooPZAbEeBq gT5Wmry+I5B/xoo/bK3FwIj47WR5HbrTGRB1urk0dgRMNZwEYrFUQi5Aa3iip/skdzvH nyQQ== X-Gm-Message-State: AOAM530wZ59Cv7cGiN/1m57t8tDVa+Wow2NfNIvJrbH2Z/vC4FZSwRYa mumV6G7eAUjgSqLD5kDToOQN1HNLQOPcAA== X-Google-Smtp-Source: ABdhPJwxNCCMm538u0QAdLmoN2XRwAivi00DvNgNn4UUQkZeWmYpD/N/YdNzX3nmLM69YRGUxPGnEw== X-Received: by 2002:a05:6512:3d16:: with SMTP id d22mr7845851lfv.523.1639080345433; Thu, 09 Dec 2021 12:05:45 -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 V4 4/6] xen/unpopulated-alloc: Add mechanism to use Xen resource Date: Thu, 9 Dec 2021 22:05:34 +0200 Message-Id: <1639080336-26573-5-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1639080336-26573-1-git-send-email-olekstysh@gmail.com> References: <1639080336-26573-1-git-send-email-olekstysh@gmail.com> X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1639080376388100003 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- 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() Changes V3 -> V4: - add Stefano's R-b - fix copy-paste error in fill_list(), must be "if (!tmp_res)" instead of "if (!res)" in string 66 - add unpopulated_init() with early initcall level specifically to call arch_xen_unpopulated_init() --- drivers/xen/unpopulated-alloc.c | 86 +++++++++++++++++++++++++++++++++++++= ++-- include/xen/xen.h | 2 + 2 files changed, 84 insertions(+), 4 deletions(-) diff --git a/drivers/xen/unpopulated-alloc.c b/drivers/xen/unpopulated-allo= c.c index a03dc5b..a8b4105 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 (!tmp_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; @@ -201,3 +262,20 @@ static int __init init(void) } subsys_initcall(init); #endif + +static int __init unpopulated_init(void) +{ + int ret; + + if (!xen_domain()) + return -ENODEV; + + 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; +} +early_initcall(unpopulated_init); 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 Tue May 7 02:11:19 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=1639080369; cv=none; d=zohomail.com; s=zohoarc; b=TWHl3gnuJrzr7aybgUnlliHhuUXDzA1lgB0iEmnqtxdAS3kXiMwIWCbwUFz1/4fOs7CU3oB0nXdOURqxPzPXGUPWFBubq+aztI5OYiom1gghVFLVqZmfzF4aUXwA3A5iphbtAoRm7G5B43jsiaxFSiJ5aI6kyV8f4vQefJoPPdE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639080369; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=R0fiIRx1tdommq9IGRl8CoXFpUaCu+zHn93/yFjWte8=; b=OfWfjddQ/4NzM2L1UirEq6XjXMCDIBKg5H/opTFVirki7GteoSqxnKC3wm/R+tjYNoxz0n3ewLBd2INCoYql/v4tCQCDZNRihldY5dNKUCcXUNG5I24OMDWUuf/3q7P/Q/t+N0aewoQ5TNRMukxW8JU9CaYCD+PB/WikVQtP3Pk= 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 1639080369810495.3470259982968; Thu, 9 Dec 2021 12:06:09 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.243313.420927 (Exim 4.92) (envelope-from ) id 1mvPfp-0005k3-H0; Thu, 09 Dec 2021 20:05:49 +0000 Received: by outflank-mailman (output) from mailman id 243313.420927; Thu, 09 Dec 2021 20:05:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mvPfp-0005iO-Bq; Thu, 09 Dec 2021 20:05:49 +0000 Received: by outflank-mailman (input) for mailman id 243313; Thu, 09 Dec 2021 20:05:48 +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 1mvPfn-0004Xd-Qu for xen-devel@lists.xenproject.org; Thu, 09 Dec 2021 20:05:47 +0000 Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [2a00:1450:4864:20::22f]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 65958a26-592b-11ec-a831-37629979565c; Thu, 09 Dec 2021 21:05:46 +0100 (CET) Received: by mail-lj1-x22f.google.com with SMTP id 13so10634523ljj.11 for ; Thu, 09 Dec 2021 12:05:47 -0800 (PST) Received: from otyshchenko.router ([212.22.223.21]) by smtp.gmail.com with ESMTPSA id o12sm87371lft.134.2021.12.09.12.05.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Dec 2021 12:05:45 -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: 65958a26-592b-11ec-a831-37629979565c 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=R0fiIRx1tdommq9IGRl8CoXFpUaCu+zHn93/yFjWte8=; b=n2HuGtve4aJvc3nlYM9Dz7ywy3oqNGSu7nskjkeAeor14V/8fpk08jcPSZ721Iao3+ hHMOlkXylq2GcKZg3j54/qELfoGkt4IfF7Qo67vwRASA0+tSnyQdbhQec0oO094ceoOm blC4EkWj08hh9wwV9eu1k0VwdU1YRxQotoEp8vFy3tBbAkM/m6nDspgP8lajWCCPDP9K Zs13Y+c8Q6Y45uH5mu1eQ9/7pLVa79Nq73lCQilGu9mxZ35DjtLRdGHH+Ds1TKs2eRZD ucoPlVDPHqDj9AbJ58Dnzo818RFf8QdDUDOHSwUBVLZXFXKiK9vJbqHFHGI07odQ0p19 A/iQ== 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=R0fiIRx1tdommq9IGRl8CoXFpUaCu+zHn93/yFjWte8=; b=q9gAhEhJ7TbdJa1pn42Qt0tv9HWo9Il7Uv1NK2/W2bI1XJ7SZIxXcnjccGuIkh2hUK ZPM6Jq4nfi9be+Ym2mFwFcHz5qdNFC+98tkK9o3oA42dh/LuZdiWw48MxOXABNI1RkTU pNwfejzoOmoXYoiNViIPYvP58Vw/IqVElD+RVKfuB/LcUqOom27WqPNMQZy5rv+DT4cK fBCz+rS+spMmN3L4swAZFlBZNIu9cj14nOzzMzVYnzt/yhn8UJd8W09+wkChN3leXsgx yCTwDv7srVJ4HdYa0v5pfFTKaBz4O9ftmy+F9KzQFJ7BKNBceacgKk5jGUXvORbDBP2c 5Gyg== X-Gm-Message-State: AOAM533Ryp0cvoi4Y2qoAgxVfrPTzyYsqLarp1T4pKiXrfeB/LRph0LB sLC0y6TAIQ5Ami6CArM9NVZgWo5oDGyxpA== X-Google-Smtp-Source: ABdhPJzHrcB9daArwNq3p6osXn8jy3zvVeJEP9xDadJPm3zUWm6zBrzFxOmGFuC7tp0ecBwfSVUZ8g== X-Received: by 2002:a05:651c:621:: with SMTP id k33mr8233705lje.359.1639080346196; Thu, 09 Dec 2021 12:05:46 -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 V4 5/6] arm/xen: Read extended regions from DT and init Xen resource Date: Thu, 9 Dec 2021 22:05:35 +0200 Message-Id: <1639080336-26573-6-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1639080336-26573-1-git-send-email-olekstysh@gmail.com> References: <1639080336-26573-1-git-send-email-olekstysh@gmail.com> X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1639080370416100001 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 Changes V3 -> V4: - add Stefano's R-b --- 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 49bb675..ec5b082 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 33e941e..120d32f 100644 --- a/drivers/xen/Kconfig +++ b/drivers/xen/Kconfig @@ -327,7 +327,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 Tue May 7 02:11:19 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=1639080373; cv=none; d=zohomail.com; s=zohoarc; b=Z+gfzE4fRaYtpne3Okv+dTn+IMWjNdF1703S8NFYPxzeeDIpfYDzb/S8Ig9m3Uzk32fX5qPcJJVik1PXL3qqDyzmlVTvNhKmRfHw2IIilyVk/hBRkeltPNXS/5xXWZLLNK2hsZ38tK4VD7l+U82M/j7luI4PYukQP6DtLEg+ruA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639080373; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=g9AJiL9uTfpDDMd7SS4C6nAmWL0XZo0V0ZfDFdYmLjY=; b=f01RNr5iJVQaAcTFe3lAfUWp+lzqjqtMhzZ9I3J/5d/1Vaf/oPAIBQWXeDN8pWJepfrRQBEmIOk2xatJvzIQcRG80E5HLTOHSi+byX6GoC3E5uKIWRtd1tI9YRkE98ZFFht/EUrFRKCuZVSbMN+3koC5GFu4ambNgOxj1jmvEDY= 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 1639080373145516.7598598915724; Thu, 9 Dec 2021 12:06:13 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.243314.420934 (Exim 4.92) (envelope-from ) id 1mvPfq-0005pt-3B; Thu, 09 Dec 2021 20:05:50 +0000 Received: by outflank-mailman (output) from mailman id 243314.420934; Thu, 09 Dec 2021 20:05:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mvPfp-0005p0-OB; Thu, 09 Dec 2021 20:05:49 +0000 Received: by outflank-mailman (input) for mailman id 243314; Thu, 09 Dec 2021 20:05:48 +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 1mvPfo-0004Xd-D9 for xen-devel@lists.xenproject.org; Thu, 09 Dec 2021 20:05:48 +0000 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [2a00:1450:4864:20::12c]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 65e21947-592b-11ec-a831-37629979565c; Thu, 09 Dec 2021 21:05:47 +0100 (CET) Received: by mail-lf1-x12c.google.com with SMTP id l22so14131942lfg.7 for ; Thu, 09 Dec 2021 12:05:47 -0800 (PST) Received: from otyshchenko.router ([212.22.223.21]) by smtp.gmail.com with ESMTPSA id o12sm87371lft.134.2021.12.09.12.05.46 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Dec 2021 12:05:46 -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: 65e21947-592b-11ec-a831-37629979565c 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=g9AJiL9uTfpDDMd7SS4C6nAmWL0XZo0V0ZfDFdYmLjY=; b=COAXXVLnmQmpr5BGzCN9BcuqWFvHw2ocxZLxo6ryJ5Lhw+xJPSJQG8U5fyMK+rUwSi EYiKUFWwRjqcCV5YBfFzHQXgooJ8gBMmNeHvmX/AgiZxPAVXkq9PVW+yvKPlmzOl4aYu W2uDd1pXtu8UqzUIkvBXbL2Ch/O5tKOkr88Ei7WEG/HFl30t6yY/I9V2vtZteJYlrLxv iWHYSmmfEP5O8RSy/8n2R2GZzIGviX+SR5pmTvEBaL0XRT/AWDwa2km8xegEcMSEcF2l kf/OIUNJdOMax5XXVTNReI1Ic72Mf3qeSkVeziNzAaC0ItMUN+asYzsXxndrXbw7kj4E Rwbg== 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=g9AJiL9uTfpDDMd7SS4C6nAmWL0XZo0V0ZfDFdYmLjY=; b=kwxC+Y06fyr8qJJEaemTlwwXroHsQQ1xisJW6/ckrM6izx9N7ZJ0oKpfVWuoIZ3So0 LG3tPtxB8dm6LRrZvgna2sJX1fSTzB0HRD6pdYA4g2ZCoRy5MeDSRkaO5VMirWtcuVrp 9UrkcyPcVtapoBN87xc2tXFujDb5ygL4D1HfGHnhJHn48ulV3YrGuYohPo8Uv5y8cWjX ktFzUtZbSxgfIcsfAciDbNSSqtYwW+UZOtXqrmQpRJ3B48YdbPSqu8R9itdRAbRmPP7i WZktHzUYM8VzqFnlqC1xEpo9o+dtzlrP5yysc3tuF48rDBmNjAZ17yRbWHvDqE1r2cuF x/GQ== X-Gm-Message-State: AOAM533fPKy5lTXikQskfbvFrkBZ9qyyhdLH9bIucQWzEpvn053goim6 WmL2aEt112UuKUoLz5vkH0rUDS+5JpIK0g== X-Google-Smtp-Source: ABdhPJyxDwm4qD0w1ssRjatqaxocOTEkFxXrsK+gDNk3bFfYXhmsC90Kh+C73THhn+OlTC99iNMRWQ== X-Received: by 2002:a05:6512:ea2:: with SMTP id bi34mr8469336lfb.12.1639080346992; Thu, 09 Dec 2021 12:05:46 -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 V4 6/6] dt-bindings: xen: Clarify "reg" purpose Date: Thu, 9 Dec 2021 22:05:36 +0200 Message-Id: <1639080336-26573-7-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1639080336-26573-1-git-send-email-olekstysh@gmail.com> References: <1639080336-26573-1-git-send-email-olekstysh@gmail.com> X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1639080375467100001 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. While at it, remove the following sentence: "This property is unnecessary when booting Dom0 using ACPI." for "reg" and "interrupts" properties as the initialization is not done via device-tree "hypervisor" node in that case anyway. Signed-off-by: Oleksandr Tyshchenko Reviewed-by: Stefano Stabellini Acked-by: Rob Herring --- Changes V2 -> V3: - new patch Changes V3 -> V4: - add Stefano's R-b and Rob's A-b - remove sentence about ACPI for "reg" and "interrupts" properties --- Documentation/devicetree/bindings/arm/xen.txt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Documentation/devicetree/bindings/arm/xen.txt b/Documentation/= devicetree/bindings/arm/xen.txt index db5c56d..61d77ac 100644 --- a/Documentation/devicetree/bindings/arm/xen.txt +++ b/Documentation/devicetree/bindings/arm/xen.txt @@ -7,15 +7,17 @@ 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(= )). - This property is unnecessary when booting Dom0 using ACPI. +- 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. =20 - interrupts: the interrupt used by Xen to inject event notifications. A GIC node is also required. - This property is unnecessary when booting Dom0 using ACPI. =20 To support UEFI on Xen ARM virtual platforms, Xen populates the FDT "uefi"= node under /hypervisor with following parameters: --=20 2.7.4