From patchwork Wed Nov 24 20:53:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Tyshchenko X-Patchwork-Id: 12693586 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5CF73C433F5 for ; Wed, 24 Nov 2021 20:55:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=zKO/CMnAGYl0ceu7nfbDFpufraYT6zgV/OIuU0CHfTA=; b=m3eOHwFS6O0ruF 6E6xD7BmAKCBREKe8UHpM8HDCfR/pkgc5W9cIEB+pX8kuZj+T0wlBbwttnVgQFtlDNteu34kP2wch JP9PnbD7rwiIELLzA4wajAkAPdgFDw6/s5OM5qE8KI5UU6SjGeaYz/K2R+rYCoM3CLAPSeAIS0PXm cnXjM2ZkmZw5XVV/YCGWyawBFxzYDI5nl/yRFNQYCIM4rZVQ6AkJwtSwStVFvktEya+SG1gSs+CZh YicEYTJQzL3RYGmW2vYFX5/3+bGCMg6UXCFJcgkXRfR0s1ptJxLWwKH/BovUG4yuqfzMAc/Xn6jjg 5WxGLxiSHlYggKWnxg8A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mpzHE-005p5U-1e; Wed, 24 Nov 2021 20:54:00 +0000 Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mpzHA-005p4V-42 for linux-arm-kernel@lists.infradead.org; Wed, 24 Nov 2021 20:53:57 +0000 Received: by mail-lf1-x12e.google.com with SMTP id b1so10459820lfs.13 for ; Wed, 24 Nov 2021 12:53:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=wBAopcuMZHjciIHB7DxD67GWh0M8Q3KOr2lZGv2eaVQ=; b=EOVNOSIKB097eJDLI78+TDQKEJMxEAhF1DjiOYB9US8P5Va356lafZguv3Uj2gDwR4 Ctqcqmf+EkIuST9RZXpJNWUWuM0WLuR4We3+2VVX2B427CziLBQwhCPTe4sOW7IRYuiC aClHOn6gzPx4TxcdaotH3Mb+V+iLHfmsb4Mrw3XSVMV+ASZz4ooCS+JHbWRG/qeGNKZZ xmDf1Xf8QaKbD1D5kVTyzLNQM98Pv7HX/2NPj3KFIAMgfmVocJXKKdJpkwdRxkk1RjSY duz585QyMLv+6U/BdYsBk1KWN0oe+TJrOkDvnyGQMq78HyPglrUGXtLW4ohb1+5f6XIG efhQ== 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:mime-version :content-transfer-encoding; bh=wBAopcuMZHjciIHB7DxD67GWh0M8Q3KOr2lZGv2eaVQ=; b=6TOl8uq4EADuAAv7QeT9xK3pEg4DYQ/sUCMuWafJgzkKOx3qSwhgKWuA6EHwfzWgII AfzAO9+cEo0kHrfEQEIdpYuTR0WSPm4ENTBAOnsc/TorzNp8nu0oc93aR+jtur9QGsG5 VCZEe91HjVI0eQUEIwwFeiirxQ7ya4ph7Gcp+XRV6iq92cAKFqC0DowrQbWXvtim6cfv 4Zw3uLa9IrmHCwHNx3BK5ZWpGoIaHoU19esiw1u9d4wZHSI53S0bVQpQI4RHk5eFxCVP skolbkMoHeMikd0fvh65CwqlR9ANG0e12y7E5rWpCbrZZ2ufhDRwY48eX9NXw0pTmtku dPbQ== X-Gm-Message-State: AOAM531C1ZA0sYqvgniQXI+Y4hnDkDawsPdiRQOtLg6SvQvmQOddCPR6 7qW+B8h3ceBULMuFxdNXBdo= X-Google-Smtp-Source: ABdhPJyichwpAJNMAkydxI87GKxoZRWxO8uoBVnYkUCHsGmrt0hZCYLPXfYtuT9M9aREjB1c6odbSA== X-Received: by 2002:ac2:5310:: with SMTP id c16mr18736716lfh.580.1637787233851; Wed, 24 Nov 2021 12:53:53 -0800 (PST) Received: from otyshchenko.router ([212.22.223.21]) by smtp.gmail.com with ESMTPSA id j11sm97608ljc.9.2021.11.24.12.53.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Nov 2021 12:53:53 -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 0/6] xen: Add support of extended regions (safe ranges) on Arm Date: Wed, 24 Nov 2021 22:53:37 +0200 Message-Id: <1637787223-21129-1-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211124_125356_238544_2BA83DF8 X-CRM114-Status: GOOD ( 17.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Oleksandr Tyshchenko Hello all. You can find the RFC-V2 patch series at [1],[2]. The corresponding Xen support (for both Dom0 and DomU) is already committed and is available in mainline Xen since the following commit: 57f87857dc2de452a796d6bad4f476510efd2aba libxl/arm: Add handling of extended regions for DomU 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 ballooning out real RAM pages to obtain a physical address space for creating these mappings (which simply results in wasting domain memory and shattering super pages in P2M table). The problem is that we cannot follow Linux advise which memory ranges are unused on Arm as there might be some identity mappings in P2M table (stage 2) the guest is not aware of or not all device I/O regions might be known (registered) by the time the guest starts creating grant/foreign mappings. This is why we need some hints from the hypervisor which knows all details in advance to be able to choose extended regions (which won't clash with other resources). The extended regions are chosen at the domain creation time and advertised to it via "reg" property under hypervisor node in the guest device-tree [3]. 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, guest infers the presence of extended regions from the number of regions in "reg" property. Please note the following: - The ACPI case is not covered for now - patch series was created in a way to retain existing behavior on x86 The patch series is based on v5.16-rc2 and also available at [4], it was fully tested on Arm64. [1] https://lore.kernel.org/all/1627490656-1267-1-git-send-email-olekstysh@gmail.com/ https://lore.kernel.org/all/1627490656-1267-2-git-send-email-olekstysh@gmail.com/ [2] https://lore.kernel.org/all/1635264312-3796-1-git-send-email-olekstysh@gmail.com/ [3] https://xenbits.xen.org/gitweb/?p=xen.git;a=blob_plain;f=docs/misc/arm/device-tree/guest.txt;hb=refs/heads/master [4] https://github.com/otyshchenko1/linux/commits/map_opt_ml6 Oleksandr Tyshchenko (6): xen/unpopulated-alloc: Drop check for virt_addr_valid() in fill_list() arm/xen: Switch to use gnttab_setup_auto_xlat_frames() for DT xen/balloon: Bring alloc(free)_xenballooned_pages helpers back xen/unpopulated-alloc: Add mechanism to use Xen resource arm/xen: Read extended regions from DT and init Xen resource dt-bindings: xen: Clarify "reg" purpose Documentation/devicetree/bindings/arm/xen.txt | 12 ++- arch/arm/xen/enlighten.c | 132 ++++++++++++++++++++++++-- drivers/xen/Kconfig | 2 +- drivers/xen/balloon.c | 20 ++-- drivers/xen/unpopulated-alloc.c | 84 ++++++++++++++-- include/xen/balloon.h | 3 + include/xen/xen.h | 16 ++++ 7 files changed, 239 insertions(+), 30 deletions(-)