From nobody Sat May 4 12:15:10 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1556658252; cv=none; d=zoho.com; s=zohoarc; b=GXiz0t3irjjF0lM0g0pWzVd/GjHp8ynHZ6rZjG9E49vZERnDlxxciAY+wKnBaAqemKz6sHh7WCHgdnUU7tqpDK3OqX17mUKzFCQP+Qjs3xDeVW1qtV90AyJgTuJbn5ltVLhpunkdaYE3kaucA+MjW7/udw1ewrMy9W2OH5WJedE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556658252; 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:ARC-Authentication-Results; bh=blgFKHhQlcFEamzVtuGbjwYb3EqRj/e63GLurz+ohQQ=; b=TbvGFNw2FPZ/nFrTmuS9dM7tX59o8RzqEcL/oUJIFeaBYnflZl79j7/18FVfeZpwdurv6+abin6mykQS487KBdY/ElMl9BkzBv7qif1uNJ3G2FPkAa9JGh/kR8rVgzIQUFamyJ9CZy8Jefj4066XFyKzM1DpSLMoCB6lN9BFwoM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1556658251996275.96588583923506; Tue, 30 Apr 2019 14:04:11 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hLZty-0007er-Kn; Tue, 30 Apr 2019 21:02:58 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hLZtx-0007eg-Pc for xen-devel@lists.xenproject.org; Tue, 30 Apr 2019 21:02:57 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 5364d7e0-6b8b-11e9-843c-bc764e045a96; Tue, 30 Apr 2019 21:02:55 +0000 (UTC) Received: from sstabellini-ThinkPad-X260.xilinx.com (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0EF1D2081C; Tue, 30 Apr 2019 21:02:55 +0000 (UTC) X-Inumbo-ID: 5364d7e0-6b8b-11e9-843c-bc764e045a96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556658175; bh=B07q0EaNvzGUmvz2QxiHkU/wVi5bPU2YEgwaMLclBvA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sdJHjDC+MegTr98W6yZtaCrvIhDUiY+CLrbaQP5+F74T1IOLWGwoF7lU8oQKU67TE DdfgsmxgYQsaF7s45NDHON6zyigf3Ue6A73rjAs7ng+L51B0zwP3HZ7XWED34V/ixC ICBbuQuLnjKJ38y/Q1xCNQLLbaNb6OHD/GbJgYzM= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Tue, 30 Apr 2019 14:02:43 -0700 Message-Id: <1556658172-8824-1-git-send-email-sstabellini@kernel.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v2 01/10] xen: add a p2mt parameter to map_mmio_regions X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , julien.grall@arm.com, sstabellini@kernel.org, JBeulich@suse.com, andrew.cooper3@citrix.com MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Add a p2mt parameter to map_mmio_regions, pass p2m_mmio_direct_dev on ARM and p2m_mmio_direct on x86 -- no changes in behavior. On ARM, given the similarity between map_mmio_regions after the change and map_regions_p2mt, remove un/map_regions_p2mt. Signed-off-by: Stefano Stabellini CC: JBeulich@suse.com CC: andrew.cooper3@citrix.com --- Changes in v2: - new patch --- xen/arch/arm/acpi/domain_build.c | 4 ++-- xen/arch/arm/domain_build.c | 2 +- xen/arch/arm/gic-v2.c | 3 ++- xen/arch/arm/p2m.c | 18 +----------------- xen/arch/arm/platforms/exynos5.c | 6 ++++-- xen/arch/arm/platforms/omap5.c | 12 ++++++++---- xen/arch/arm/traps.c | 2 +- xen/arch/arm/vgic-v2.c | 2 +- xen/arch/arm/vgic/vgic-v2.c | 2 +- xen/arch/x86/hvm/dom0_build.c | 7 +++++-- xen/arch/x86/mm/p2m.c | 6 +++++- xen/common/domctl.c | 7 ++++++- xen/drivers/vpci/header.c | 3 ++- xen/include/asm-arm/p2m.h | 15 --------------- xen/include/xen/p2m-common.h | 3 ++- 15 files changed, 41 insertions(+), 51 deletions(-) diff --git a/xen/arch/arm/acpi/domain_build.c b/xen/arch/arm/acpi/domain_bu= ild.c index 5aae32a..f4ac91c 100644 --- a/xen/arch/arm/acpi/domain_build.c +++ b/xen/arch/arm/acpi/domain_build.c @@ -193,7 +193,7 @@ static void __init acpi_map_other_tables(struct domain = *d) { addr =3D acpi_gbl_root_table_list.tables[i].address; size =3D acpi_gbl_root_table_list.tables[i].length; - res =3D map_regions_p2mt(d, + res =3D map_mmio_regions(d, gaddr_to_gfn(addr), PFN_UP(size), maddr_to_mfn(addr), @@ -547,7 +547,7 @@ int __init prepare_acpi(struct domain *d, struct kernel= _info *kinfo) acpi_create_efi_mmap_table(d, &kinfo->mem, tbl_add); =20 /* Map the EFI and ACPI tables to Dom0 */ - rc =3D map_regions_p2mt(d, + rc =3D map_mmio_regions(d, gaddr_to_gfn(d->arch.efi_acpi_gpa), PFN_UP(d->arch.efi_acpi_len), virt_to_mfn(d->arch.efi_acpi_table), diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index d983677..1f808b2 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1171,7 +1171,7 @@ static int __init map_range_to_domain(const struct dt= _device_node *dev, =20 if ( need_mapping ) { - res =3D map_regions_p2mt(d, + res =3D map_mmio_regions(d, gaddr_to_gfn(addr), PFN_UP(len), maddr_to_mfn(addr), diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c index 256988c..d2ef361 100644 --- a/xen/arch/arm/gic-v2.c +++ b/xen/arch/arm/gic-v2.c @@ -701,7 +701,8 @@ static int gicv2_map_hwdown_extra_mappings(struct domai= n *d) =20 ret =3D map_mmio_regions(d, gaddr_to_gfn(v2m_data->addr), PFN_UP(v2m_data->size), - maddr_to_mfn(v2m_data->addr)); + maddr_to_mfn(v2m_data->addr), + p2m_mmio_direct_dev); if ( ret ) { printk(XENLOG_ERR "GICv2: Map v2m frame to d%d failed.\n", diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index c38bd7e..e44c932 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -1331,7 +1331,7 @@ static inline int p2m_remove_mapping(struct domain *d, return rc; } =20 -int map_regions_p2mt(struct domain *d, +int map_mmio_regions(struct domain *d, gfn_t gfn, unsigned long nr, mfn_t mfn, @@ -1340,22 +1340,6 @@ int map_regions_p2mt(struct domain *d, return p2m_insert_mapping(d, gfn, nr, mfn, p2mt); } =20 -int unmap_regions_p2mt(struct domain *d, - gfn_t gfn, - unsigned long nr, - mfn_t mfn) -{ - return p2m_remove_mapping(d, gfn, nr, mfn); -} - -int map_mmio_regions(struct domain *d, - gfn_t start_gfn, - unsigned long nr, - mfn_t mfn) -{ - return p2m_insert_mapping(d, start_gfn, nr, mfn, p2m_mmio_direct_dev); -} - int unmap_mmio_regions(struct domain *d, gfn_t start_gfn, unsigned long nr, diff --git a/xen/arch/arm/platforms/exynos5.c b/xen/arch/arm/platforms/exyn= os5.c index 6560507..97cd080 100644 --- a/xen/arch/arm/platforms/exynos5.c +++ b/xen/arch/arm/platforms/exynos5.c @@ -83,11 +83,13 @@ static int exynos5250_specific_mapping(struct domain *d) { /* Map the chip ID */ map_mmio_regions(d, gaddr_to_gfn(EXYNOS5_PA_CHIPID), 1, - maddr_to_mfn(EXYNOS5_PA_CHIPID)); + maddr_to_mfn(EXYNOS5_PA_CHIPID), + p2m_mmio_direct_dev); =20 /* Map the PWM region */ map_mmio_regions(d, gaddr_to_gfn(EXYNOS5_PA_TIMER), 2, - maddr_to_mfn(EXYNOS5_PA_TIMER)); + maddr_to_mfn(EXYNOS5_PA_TIMER), + p2m_mmio_direct_dev); =20 return 0; } diff --git a/xen/arch/arm/platforms/omap5.c b/xen/arch/arm/platforms/omap5.c index aee24e4..c5701df 100644 --- a/xen/arch/arm/platforms/omap5.c +++ b/xen/arch/arm/platforms/omap5.c @@ -99,19 +99,23 @@ static int omap5_specific_mapping(struct domain *d) { /* Map the PRM module */ map_mmio_regions(d, gaddr_to_gfn(OMAP5_PRM_BASE), 2, - maddr_to_mfn(OMAP5_PRM_BASE)); + maddr_to_mfn(OMAP5_PRM_BASE), + p2m_mmio_direct_dev); =20 /* Map the PRM_MPU */ map_mmio_regions(d, gaddr_to_gfn(OMAP5_PRCM_MPU_BASE), 1, - maddr_to_mfn(OMAP5_PRCM_MPU_BASE)); + maddr_to_mfn(OMAP5_PRCM_MPU_BASE), + p2m_mmio_direct_dev); =20 /* Map the Wakeup Gen */ map_mmio_regions(d, gaddr_to_gfn(OMAP5_WKUPGEN_BASE), 1, - maddr_to_mfn(OMAP5_WKUPGEN_BASE)); + maddr_to_mfn(OMAP5_WKUPGEN_BASE), + p2m_mmio_direct_dev); =20 /* Map the on-chip SRAM */ map_mmio_regions(d, gaddr_to_gfn(OMAP5_SRAM_PA), 32, - maddr_to_mfn(OMAP5_SRAM_PA)); + maddr_to_mfn(OMAP5_SRAM_PA), + p2m_mmio_direct_dev); =20 return 0; } diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index d8b9a8a..afae5a1 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -1887,7 +1887,7 @@ static bool try_map_mmio(gfn_t gfn) if ( !iomem_access_permitted(d, mfn_x(mfn), mfn_x(mfn) + 1) ) return false; =20 - return !map_regions_p2mt(d, gfn, 1, mfn, p2m_mmio_direct_c); + return !map_mmio_regions(d, gfn, 1, mfn, p2m_mmio_direct_c); } =20 static void do_trap_stage2_abort_guest(struct cpu_user_regs *regs, diff --git a/xen/arch/arm/vgic-v2.c b/xen/arch/arm/vgic-v2.c index 64b141f..1543625 100644 --- a/xen/arch/arm/vgic-v2.c +++ b/xen/arch/arm/vgic-v2.c @@ -691,7 +691,7 @@ static int vgic_v2_domain_init(struct domain *d) * region of the guest. */ ret =3D map_mmio_regions(d, gaddr_to_gfn(cbase), csize / PAGE_SIZE, - maddr_to_mfn(vbase)); + maddr_to_mfn(vbase), p2m_mmio_direct_dev); if ( ret ) return ret; =20 diff --git a/xen/arch/arm/vgic/vgic-v2.c b/xen/arch/arm/vgic/vgic-v2.c index b5ba4ac..04f34dd 100644 --- a/xen/arch/arm/vgic/vgic-v2.c +++ b/xen/arch/arm/vgic/vgic-v2.c @@ -309,7 +309,7 @@ int vgic_v2_map_resources(struct domain *d) * region of the guest. */ ret =3D map_mmio_regions(d, gaddr_to_gfn(cbase), csize / PAGE_SIZE, - maddr_to_mfn(vbase)); + maddr_to_mfn(vbase), p2m_mmio_direct_dev); if ( ret ) { gdprintk(XENLOG_ERR, "Unable to remap VGIC CPU to VCPU\n"); diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c index aa599f0..84776fc 100644 --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -79,8 +79,11 @@ static int __init modify_identity_mmio(struct domain *d,= unsigned long pfn, =20 for ( ; ; ) { - rc =3D map ? map_mmio_regions(d, _gfn(pfn), nr_pages, _mfn(pfn)) - : unmap_mmio_regions(d, _gfn(pfn), nr_pages, _mfn(pfn)); + if ( map ) + rc =3D map_mmio_regions(d, _gfn(pfn), nr_pages, _mfn(pfn), + p2m_mmio_direct); + else + rc =3D unmap_mmio_regions(d, _gfn(pfn), nr_pages, _mfn(pfn)); if ( rc =3D=3D 0 ) break; if ( rc < 0 ) diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index 9e81a30..a72f012 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -2264,12 +2264,16 @@ static unsigned int mmio_order(const struct domain = *d, int map_mmio_regions(struct domain *d, gfn_t start_gfn, unsigned long nr, - mfn_t mfn) + mfn_t mfn, + p2m_type_t p2mt) { int ret =3D 0; unsigned long i; unsigned int iter, order; =20 + if ( p2mt !=3D p2m_mmio_direct ) + return -EOPNOTSUPP; + if ( !paging_mode_translate(d) ) return 0; =20 diff --git a/xen/common/domctl.c b/xen/common/domctl.c index bade9a6..18a0f8f 100644 --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -927,6 +927,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_d= omctl) unsigned long nr_mfns =3D op->u.memory_mapping.nr_mfns; unsigned long mfn_end =3D mfn + nr_mfns - 1; int add =3D op->u.memory_mapping.add_mapping; + p2m_type_t p2mt; =20 ret =3D -EINVAL; if ( mfn_end < mfn || /* wrap? */ @@ -939,6 +940,10 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_= domctl) /* Must break hypercall up as this could take a while. */ if ( nr_mfns > 64 ) break; + + p2mt =3D p2m_mmio_direct_dev; +#else + p2mt =3D p2m_mmio_direct; #endif =20 ret =3D -EPERM; @@ -956,7 +961,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_d= omctl) "memory_map:add: dom%d gfn=3D%lx mfn=3D%lx nr=3D%lx\n", d->domain_id, gfn, mfn, nr_mfns); =20 - ret =3D map_mmio_regions(d, _gfn(gfn), nr_mfns, _mfn(mfn)); + ret =3D map_mmio_regions(d, _gfn(gfn), nr_mfns, _mfn(mfn), p2m= t); if ( ret < 0 ) printk(XENLOG_G_WARNING "memory_map:fail: dom%d gfn=3D%lx mfn=3D%lx nr=3D%l= x ret:%ld\n", diff --git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c index efb6ca9..6adfa55 100644 --- a/xen/drivers/vpci/header.c +++ b/xen/drivers/vpci/header.c @@ -52,7 +52,8 @@ static int map_range(unsigned long s, unsigned long e, vo= id *data, * - {un}map_mmio_regions doesn't support preemption. */ =20 - rc =3D map->map ? map_mmio_regions(map->d, _gfn(s), size, _mfn(s)) + rc =3D map->map ? map_mmio_regions(map->d, _gfn(s), size, _mfn(s), + p2m_mmio_direct) : unmap_mmio_regions(map->d, _gfn(s), size, _mfn(s)); if ( rc =3D=3D 0 ) { diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h index 041dea8..0218021 100644 --- a/xen/include/asm-arm/p2m.h +++ b/xen/include/asm-arm/p2m.h @@ -252,21 +252,6 @@ void p2m_toggle_cache(struct vcpu *v, bool was_enabled= ); =20 void p2m_flush_vm(struct vcpu *v); =20 -/* - * Map a region in the guest p2m with a specific p2m type. - * The memory attributes will be derived from the p2m type. - */ -int map_regions_p2mt(struct domain *d, - gfn_t gfn, - unsigned long nr, - mfn_t mfn, - p2m_type_t p2mt); - -int unmap_regions_p2mt(struct domain *d, - gfn_t gfn, - unsigned long nr, - mfn_t mfn); - int map_dev_mmio_region(struct domain *d, gfn_t gfn, unsigned long nr, diff --git a/xen/include/xen/p2m-common.h b/xen/include/xen/p2m-common.h index 58031a6..69c82cc 100644 --- a/xen/include/xen/p2m-common.h +++ b/xen/include/xen/p2m-common.h @@ -14,7 +14,8 @@ guest_physmap_remove_page(struct domain *d, gfn_t gfn, mf= n_t mfn, int map_mmio_regions(struct domain *d, gfn_t start_gfn, unsigned long nr, - mfn_t mfn); + mfn_t mfn, + p2m_type_t p2mt); int unmap_mmio_regions(struct domain *d, gfn_t start_gfn, unsigned long nr, --=20 1.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sat May 4 12:15:10 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1556658255; cv=none; d=zoho.com; s=zohoarc; b=ehOviTsZ2d6I548rc+pDXzIakmumr5aPyYqajswPMrY1qy4xW3e4xD8AnAd0FHEFfmmc9mQZMPx36Ag2ygel4ziRJaZr0QT+MQ/UoNXu0APh/1IMenGdFihnCI8zhyxIMYydFdP9YS9SxrMrAYSMzPRv3vEAHP6nCm1Fn4AqlWI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556658255; 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:ARC-Authentication-Results; bh=Rywjv6sCJqM3XWoHzII8VXsFRH2k2O/S7HyM4mVQyOQ=; b=nIulvXUwIErmeVlZ4wfdZVlBM4bF3jMCqLvhneeQ6latdBjv6PTIb10ZkO++cg5keobn51aKepRKevupKlFWsyxJVyUEIWsvbbjEPurW0ED4U0RvXVFMjsWxsdZWSqN2t/IXw73CBfe9huJpsyCJ0j1uY750upsNlmMeWN+UoyQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1556658255764712.9610874165437; Tue, 30 Apr 2019 14:04:15 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hLZu1-0007hH-16; Tue, 30 Apr 2019 21:03:01 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hLZtz-0007fT-AQ for xen-devel@lists.xenproject.org; Tue, 30 Apr 2019 21:02:59 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 53b5f6fa-6b8b-11e9-9b5b-6b811832b473; Tue, 30 Apr 2019 21:02:56 +0000 (UTC) Received: from sstabellini-ThinkPad-X260.xilinx.com (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 849FC21744; Tue, 30 Apr 2019 21:02:55 +0000 (UTC) X-Inumbo-ID: 53b5f6fa-6b8b-11e9-9b5b-6b811832b473 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556658175; bh=j6kJPk+WMrwDuJdbFuoWtwMssZHx+x0GH564Nr9L33A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ejXYas6O5Uxh62SKfb7nkm1+U/CRdT77igQm84VtvzBDsMEZwnhKqx+v6cChm4i/O R/06uaTk1jdoJcO1KqKu9rFE1uytHNutxHdVvKn6pR7hGVr7i4YQML9GxJYoBb+EmB dhaKYYxSnkEzZUP93tNL35ZsA1biynfJQtb4rlsg= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Tue, 30 Apr 2019 14:02:44 -0700 Message-Id: <1556658172-8824-2-git-send-email-sstabellini@kernel.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v2 02/10] xen: rename un/map_mmio_regions to un/map_regions X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , julien.grall@arm.com, sstabellini@kernel.org, JBeulich@suse.com, andrew.cooper3@citrix.com MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Now that map_mmio_regions takes a p2mt parameter, there is no need to keep "mmio" in the name. The p2mt parameter does a better job at expressing what the mapping is about. Let's save the environment 5 characters at a time. Also fix the comment on top of map_mmio_regions. Signed-off-by: Stefano Stabellini CC: JBeulich@suse.com CC: andrew.cooper3@citrix.com --- Changes in v2: - new patch --- xen/arch/arm/acpi/domain_build.c | 20 ++++++++++---------- xen/arch/arm/domain_build.c | 10 +++++----- xen/arch/arm/gic-v2.c | 8 ++++---- xen/arch/arm/p2m.c | 18 +++++++++--------- xen/arch/arm/platforms/exynos5.c | 12 ++++++------ xen/arch/arm/platforms/omap5.c | 24 ++++++++++++------------ xen/arch/arm/traps.c | 2 +- xen/arch/arm/vgic-v2.c | 4 ++-- xen/arch/arm/vgic/vgic-v2.c | 4 ++-- xen/arch/x86/hvm/dom0_build.c | 6 +++--- xen/arch/x86/mm/p2m.c | 18 +++++++++--------- xen/common/domctl.c | 4 ++-- xen/drivers/vpci/header.c | 8 ++++---- xen/include/xen/p2m-common.h | 26 ++++++++++++++------------ 14 files changed, 83 insertions(+), 81 deletions(-) diff --git a/xen/arch/arm/acpi/domain_build.c b/xen/arch/arm/acpi/domain_bu= ild.c index f4ac91c..f107f5a 100644 --- a/xen/arch/arm/acpi/domain_build.c +++ b/xen/arch/arm/acpi/domain_build.c @@ -193,11 +193,11 @@ static void __init acpi_map_other_tables(struct domai= n *d) { addr =3D acpi_gbl_root_table_list.tables[i].address; size =3D acpi_gbl_root_table_list.tables[i].length; - res =3D map_mmio_regions(d, - gaddr_to_gfn(addr), - PFN_UP(size), - maddr_to_mfn(addr), - p2m_mmio_direct_c); + res =3D map_regions(d, + gaddr_to_gfn(addr), + PFN_UP(size), + maddr_to_mfn(addr), + p2m_mmio_direct_c); if ( res ) { panic(XENLOG_ERR "Unable to map ACPI region 0x%"PRIx64 @@ -547,11 +547,11 @@ int __init prepare_acpi(struct domain *d, struct kern= el_info *kinfo) acpi_create_efi_mmap_table(d, &kinfo->mem, tbl_add); =20 /* Map the EFI and ACPI tables to Dom0 */ - rc =3D map_mmio_regions(d, - gaddr_to_gfn(d->arch.efi_acpi_gpa), - PFN_UP(d->arch.efi_acpi_len), - virt_to_mfn(d->arch.efi_acpi_table), - p2m_mmio_direct_c); + rc =3D map_regions(d, + gaddr_to_gfn(d->arch.efi_acpi_gpa), + PFN_UP(d->arch.efi_acpi_len), + virt_to_mfn(d->arch.efi_acpi_table), + p2m_mmio_direct_c); if ( rc !=3D 0 ) { printk(XENLOG_ERR "Unable to map EFI/ACPI table 0x%"PRIx64 diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 1f808b2..5e7f94c 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1171,11 +1171,11 @@ static int __init map_range_to_domain(const struct = dt_device_node *dev, =20 if ( need_mapping ) { - res =3D map_mmio_regions(d, - gaddr_to_gfn(addr), - PFN_UP(len), - maddr_to_mfn(addr), - mr_data->p2mt); + res =3D map_regions(d, + gaddr_to_gfn(addr), + PFN_UP(len), + maddr_to_mfn(addr), + mr_data->p2mt); =20 if ( res < 0 ) { diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c index d2ef361..ad2b368 100644 --- a/xen/arch/arm/gic-v2.c +++ b/xen/arch/arm/gic-v2.c @@ -699,10 +699,10 @@ static int gicv2_map_hwdown_extra_mappings(struct dom= ain *d) d->domain_id, v2m_data->addr, v2m_data->size, v2m_data->spi_start, v2m_data->nr_spis); =20 - ret =3D map_mmio_regions(d, gaddr_to_gfn(v2m_data->addr), - PFN_UP(v2m_data->size), - maddr_to_mfn(v2m_data->addr), - p2m_mmio_direct_dev); + ret =3D map_regions(d, gaddr_to_gfn(v2m_data->addr), + PFN_UP(v2m_data->size), + maddr_to_mfn(v2m_data->addr), + p2m_mmio_direct_dev); if ( ret ) { printk(XENLOG_ERR "GICv2: Map v2m frame to d%d failed.\n", diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index e44c932..d6529ca 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -1331,19 +1331,19 @@ static inline int p2m_remove_mapping(struct domain = *d, return rc; } =20 -int map_mmio_regions(struct domain *d, - gfn_t gfn, - unsigned long nr, - mfn_t mfn, - p2m_type_t p2mt) +int map_regions(struct domain *d, + gfn_t gfn, + unsigned long nr, + mfn_t mfn, + p2m_type_t p2mt) { return p2m_insert_mapping(d, gfn, nr, mfn, p2mt); } =20 -int unmap_mmio_regions(struct domain *d, - gfn_t start_gfn, - unsigned long nr, - mfn_t mfn) +int unmap_regions(struct domain *d, + gfn_t start_gfn, + unsigned long nr, + mfn_t mfn) { return p2m_remove_mapping(d, start_gfn, nr, mfn); } diff --git a/xen/arch/arm/platforms/exynos5.c b/xen/arch/arm/platforms/exyn= os5.c index 97cd080..261526e 100644 --- a/xen/arch/arm/platforms/exynos5.c +++ b/xen/arch/arm/platforms/exynos5.c @@ -82,14 +82,14 @@ static int exynos5_init_time(void) static int exynos5250_specific_mapping(struct domain *d) { /* Map the chip ID */ - map_mmio_regions(d, gaddr_to_gfn(EXYNOS5_PA_CHIPID), 1, - maddr_to_mfn(EXYNOS5_PA_CHIPID), - p2m_mmio_direct_dev); + map_regions(d, gaddr_to_gfn(EXYNOS5_PA_CHIPID), 1, + maddr_to_mfn(EXYNOS5_PA_CHIPID), + p2m_mmio_direct_dev); =20 /* Map the PWM region */ - map_mmio_regions(d, gaddr_to_gfn(EXYNOS5_PA_TIMER), 2, - maddr_to_mfn(EXYNOS5_PA_TIMER), - p2m_mmio_direct_dev); + map_regions(d, gaddr_to_gfn(EXYNOS5_PA_TIMER), 2, + maddr_to_mfn(EXYNOS5_PA_TIMER), + p2m_mmio_direct_dev); =20 return 0; } diff --git a/xen/arch/arm/platforms/omap5.c b/xen/arch/arm/platforms/omap5.c index c5701df..3575f6c 100644 --- a/xen/arch/arm/platforms/omap5.c +++ b/xen/arch/arm/platforms/omap5.c @@ -98,24 +98,24 @@ static int omap5_init_time(void) static int omap5_specific_mapping(struct domain *d) { /* Map the PRM module */ - map_mmio_regions(d, gaddr_to_gfn(OMAP5_PRM_BASE), 2, - maddr_to_mfn(OMAP5_PRM_BASE), - p2m_mmio_direct_dev); + map_regions(d, gaddr_to_gfn(OMAP5_PRM_BASE), 2, + maddr_to_mfn(OMAP5_PRM_BASE), + p2m_mmio_direct_dev); =20 /* Map the PRM_MPU */ - map_mmio_regions(d, gaddr_to_gfn(OMAP5_PRCM_MPU_BASE), 1, - maddr_to_mfn(OMAP5_PRCM_MPU_BASE), - p2m_mmio_direct_dev); + map_regions(d, gaddr_to_gfn(OMAP5_PRCM_MPU_BASE), 1, + maddr_to_mfn(OMAP5_PRCM_MPU_BASE), + p2m_mmio_direct_dev); =20 /* Map the Wakeup Gen */ - map_mmio_regions(d, gaddr_to_gfn(OMAP5_WKUPGEN_BASE), 1, - maddr_to_mfn(OMAP5_WKUPGEN_BASE), - p2m_mmio_direct_dev); + map_regions(d, gaddr_to_gfn(OMAP5_WKUPGEN_BASE), 1, + maddr_to_mfn(OMAP5_WKUPGEN_BASE), + p2m_mmio_direct_dev); =20 /* Map the on-chip SRAM */ - map_mmio_regions(d, gaddr_to_gfn(OMAP5_SRAM_PA), 32, - maddr_to_mfn(OMAP5_SRAM_PA), - p2m_mmio_direct_dev); + map_regions(d, gaddr_to_gfn(OMAP5_SRAM_PA), 32, + maddr_to_mfn(OMAP5_SRAM_PA), + p2m_mmio_direct_dev); =20 return 0; } diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index afae5a1..fee5517 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -1887,7 +1887,7 @@ static bool try_map_mmio(gfn_t gfn) if ( !iomem_access_permitted(d, mfn_x(mfn), mfn_x(mfn) + 1) ) return false; =20 - return !map_mmio_regions(d, gfn, 1, mfn, p2m_mmio_direct_c); + return !map_regions(d, gfn, 1, mfn, p2m_mmio_direct_c); } =20 static void do_trap_stage2_abort_guest(struct cpu_user_regs *regs, diff --git a/xen/arch/arm/vgic-v2.c b/xen/arch/arm/vgic-v2.c index 1543625..f33c56a 100644 --- a/xen/arch/arm/vgic-v2.c +++ b/xen/arch/arm/vgic-v2.c @@ -690,8 +690,8 @@ static int vgic_v2_domain_init(struct domain *d) * Map the gic virtual cpu interface in the gic cpu interface * region of the guest. */ - ret =3D map_mmio_regions(d, gaddr_to_gfn(cbase), csize / PAGE_SIZE, - maddr_to_mfn(vbase), p2m_mmio_direct_dev); + ret =3D map_regions(d, gaddr_to_gfn(cbase), csize / PAGE_SIZE, + maddr_to_mfn(vbase), p2m_mmio_direct_dev); if ( ret ) return ret; =20 diff --git a/xen/arch/arm/vgic/vgic-v2.c b/xen/arch/arm/vgic/vgic-v2.c index 04f34dd..b03af84 100644 --- a/xen/arch/arm/vgic/vgic-v2.c +++ b/xen/arch/arm/vgic/vgic-v2.c @@ -308,8 +308,8 @@ int vgic_v2_map_resources(struct domain *d) * Map the gic virtual cpu interface in the gic cpu interface * region of the guest. */ - ret =3D map_mmio_regions(d, gaddr_to_gfn(cbase), csize / PAGE_SIZE, - maddr_to_mfn(vbase), p2m_mmio_direct_dev); + ret =3D map_regions(d, gaddr_to_gfn(cbase), csize / PAGE_SIZE, + maddr_to_mfn(vbase), p2m_mmio_direct_dev); if ( ret ) { gdprintk(XENLOG_ERR, "Unable to remap VGIC CPU to VCPU\n"); diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c index 84776fc..800faaa 100644 --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -80,10 +80,10 @@ static int __init modify_identity_mmio(struct domain *d= , unsigned long pfn, for ( ; ; ) { if ( map ) - rc =3D map_mmio_regions(d, _gfn(pfn), nr_pages, _mfn(pfn), - p2m_mmio_direct); + rc =3D map_regions(d, _gfn(pfn), nr_pages, _mfn(pfn), + p2m_mmio_direct); else - rc =3D unmap_mmio_regions(d, _gfn(pfn), nr_pages, _mfn(pfn)); + rc =3D unmap_regions(d, _gfn(pfn), nr_pages, _mfn(pfn)); if ( rc =3D=3D 0 ) break; if ( rc < 0 ) diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index a72f012..d976ce9 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -2261,11 +2261,11 @@ static unsigned int mmio_order(const struct domain = *d, =20 #define MAP_MMIO_MAX_ITER 64 /* pretty arbitrary */ =20 -int map_mmio_regions(struct domain *d, - gfn_t start_gfn, - unsigned long nr, - mfn_t mfn, - p2m_type_t p2mt) +int map_regions(struct domain *d, + gfn_t start_gfn, + unsigned long nr, + mfn_t mfn, + p2m_type_t p2mt) { int ret =3D 0; unsigned long i; @@ -2298,10 +2298,10 @@ int map_mmio_regions(struct domain *d, return i =3D=3D nr ? 0 : i ?: ret; } =20 -int unmap_mmio_regions(struct domain *d, - gfn_t start_gfn, - unsigned long nr, - mfn_t mfn) +int unmap_regions(struct domain *d, + gfn_t start_gfn, + unsigned long nr, + mfn_t mfn) { int ret =3D 0; unsigned long i; diff --git a/xen/common/domctl.c b/xen/common/domctl.c index 18a0f8f..140f979 100644 --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -961,7 +961,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_d= omctl) "memory_map:add: dom%d gfn=3D%lx mfn=3D%lx nr=3D%lx\n", d->domain_id, gfn, mfn, nr_mfns); =20 - ret =3D map_mmio_regions(d, _gfn(gfn), nr_mfns, _mfn(mfn), p2m= t); + ret =3D map_regions(d, _gfn(gfn), nr_mfns, _mfn(mfn), p2mt); if ( ret < 0 ) printk(XENLOG_G_WARNING "memory_map:fail: dom%d gfn=3D%lx mfn=3D%lx nr=3D%l= x ret:%ld\n", @@ -973,7 +973,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_d= omctl) "memory_map:remove: dom%d gfn=3D%lx mfn=3D%lx nr=3D%lx\= n", d->domain_id, gfn, mfn, nr_mfns); =20 - ret =3D unmap_mmio_regions(d, _gfn(gfn), nr_mfns, _mfn(mfn)); + ret =3D unmap_regions(d, _gfn(gfn), nr_mfns, _mfn(mfn)); if ( ret < 0 && is_hardware_domain(current->domain) ) printk(XENLOG_ERR "memory_map: error %ld removing dom%d access to [%l= x,%lx]\n", diff --git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c index 6adfa55..7b25acc 100644 --- a/xen/drivers/vpci/header.c +++ b/xen/drivers/vpci/header.c @@ -46,15 +46,15 @@ static int map_range(unsigned long s, unsigned long e, = void *data, /* * ARM TODOs: * - On ARM whether the memory is prefetchable or not should be pa= ssed - * to map_mmio_regions in order to decide which memory attributes + * to map_regions in order to decide which memory attributes * should be used. * - * - {un}map_mmio_regions doesn't support preemption. + * - {un}map_regions doesn't support preemption. */ =20 - rc =3D map->map ? map_mmio_regions(map->d, _gfn(s), size, _mfn(s), + rc =3D map->map ? map_regions(map->d, _gfn(s), size, _mfn(s), p2m_mmio_direct) - : unmap_mmio_regions(map->d, _gfn(s), size, _mfn(s)); + : unmap_regions(map->d, _gfn(s), size, _mfn(s)); if ( rc =3D=3D 0 ) { *c +=3D size; diff --git a/xen/include/xen/p2m-common.h b/xen/include/xen/p2m-common.h index 69c82cc..728c9a4 100644 --- a/xen/include/xen/p2m-common.h +++ b/xen/include/xen/p2m-common.h @@ -8,18 +8,20 @@ int __must_check guest_physmap_remove_page(struct domain *d, gfn_t gfn, mfn_t mfn, unsigned int page_order); =20 -/* Map MMIO regions in the p2m: start_gfn and nr describe the range in - * * the guest physical address space to map, starting from the machine - * * frame number mfn. */ -int map_mmio_regions(struct domain *d, - gfn_t start_gfn, - unsigned long nr, - mfn_t mfn, - p2m_type_t p2mt); -int unmap_mmio_regions(struct domain *d, - gfn_t start_gfn, - unsigned long nr, - mfn_t mfn); +/* + * Map memory regions in the p2m: start_gfn and nr describe the range in + * the guest physical address space to map, starting from the machine + * frame number mfn. + */ +int map_regions(struct domain *d, + gfn_t start_gfn, + unsigned long nr, + mfn_t mfn, + p2m_type_t p2mt); +int unmap_regions(struct domain *d, + gfn_t start_gfn, + unsigned long nr, + mfn_t mfn); =20 /* * Populate-on-Demand --=20 1.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sat May 4 12:15:10 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1556658253; cv=none; d=zoho.com; s=zohoarc; b=D2t9/uwdJv+vL9xL8mwm6gc8gflV0rii1+vfU2Vfj5VDtRg8UrKHxTRbt91VSDV9QW8HQqswj307yTfSLz6wT+VFqEza1LT2EfDKrheliaW6VE3WbURu16oxpa+i6bZgiSK7Fa6KljUvJGLhcXlw+KyOxf1gzvKH00eZjQDNL4w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556658253; 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:ARC-Authentication-Results; bh=nYBlNRIjHw8mTGOAkA+kqGjdvvjFEqJciq5vhFbugiA=; b=hhikS6HPDLwRQymoaIU1db1tCF33NUlhHj1ghsNNn3ueDLeW3Va/Fu5Pvmzn5cwUSqFgOMuYyG/UpB9q4YiSs2r5Hk7AI2IV7lqKhBK0xTkvAWEdyL8q5+o+Vc7WWNH1JOKfURMCWlM+LANdprDnQpkaXh5uvBsUZ+bw/z59dns= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1556658253244215.00837603180014; Tue, 30 Apr 2019 14:04:13 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hLZu0-0007gl-Lq; Tue, 30 Apr 2019 21:03:00 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hLZtz-0007fJ-77 for xen-devel@lists.xenproject.org; Tue, 30 Apr 2019 21:02:59 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 53ffc230-6b8b-11e9-a359-9f8f3d6ac666; Tue, 30 Apr 2019 21:02:56 +0000 (UTC) Received: from sstabellini-ThinkPad-X260.xilinx.com (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 066B321783; Tue, 30 Apr 2019 21:02:55 +0000 (UTC) X-Inumbo-ID: 53ffc230-6b8b-11e9-a359-9f8f3d6ac666 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556658176; bh=VD5hMCcIL+KBa3Ge7Mupl8cu5cYos4MOl+WoJBhT3JA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VWJqRJ2AvUvc9qOY1nilefqIufGKQouR+mZ8ZVYhNRoTAiGecQyfMa0XqKQHEZb26 zsXv9GZPvoy8iQO4SB9+3TkGhV2b2MS+OxRtSnJ6mVDl2JF7SRHAj+G++kZqSbuv7F fF2pZ/oOefFVzKdJLLjUb5+cemx1lqBUrigFbgro= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Tue, 30 Apr 2019 14:02:45 -0700 Message-Id: <1556658172-8824-3-git-send-email-sstabellini@kernel.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v2 03/10] xen: extend XEN_DOMCTL_memory_mapping to handle memory policy X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , julien.grall@arm.com, sstabellini@kernel.org, JBeulich@suse.com, andrew.cooper3@citrix.com MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Reuse the existing padding field to pass memory policy information. On Arm, the caller can specify whether the memory should be mapped as device nGRE, which is the default and the only possibility today, or cacheable memory write-back. On x86, the only option is uncachable. The current behavior becomes the default (numerically '0'). On ARM, map device nGRE as p2m_mmio_direct_dev (as it is already done today) and WB cacheable memory as p2m_mmio_direct_c. On x86, return error if the memory policy requested is not MEMORY_POLICY_X86_UC. Signed-off-by: Stefano Stabellini CC: JBeulich@suse.com CC: andrew.cooper3@citrix.com --- Changes in v2: - rebase - use p2m_mmio_direct_c - use EOPNOTSUPP - rename cache_policy to memory policy - rename MEMORY_POLICY_DEVMEM to MEMORY_POLICY_ARM_DEV_nGRE - rename MEMORY_POLICY_MEMORY to MEMORY_POLICY_ARM_MEM_WB - add MEMORY_POLICY_X86_UC - add MEMORY_POLICY_DEFAULT and use it --- xen/common/domctl.c | 23 +++++++++++++++++++++-- xen/include/public/domctl.h | 14 +++++++++++++- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/xen/common/domctl.c b/xen/common/domctl.c index 140f979..9f62ead 100644 --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -928,6 +928,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_d= omctl) unsigned long mfn_end =3D mfn + nr_mfns - 1; int add =3D op->u.memory_mapping.add_mapping; p2m_type_t p2mt; + uint32_t memory_policy =3D op->u.memory_mapping.memory_policy; =20 ret =3D -EINVAL; if ( mfn_end < mfn || /* wrap? */ @@ -958,9 +959,27 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_= domctl) if ( add ) { printk(XENLOG_G_DEBUG - "memory_map:add: dom%d gfn=3D%lx mfn=3D%lx nr=3D%lx\n", - d->domain_id, gfn, mfn, nr_mfns); + "memory_map:add: dom%d gfn=3D%lx mfn=3D%lx nr=3D%lx cac= he=3D%u\n", + d->domain_id, gfn, mfn, nr_mfns, memory_policy); =20 + switch ( memory_policy ) + { +#ifdef CONFIG_ARM + case MEMORY_POLICY_ARM_MEM_WB: + p2mt =3D p2m_mmio_direct_c; + break; + case MEMORY_POLICY_ARM_DEV_nGRE: + p2mt =3D p2m_mmio_direct_dev; + break; +#endif +#ifdef CONFIG_X86 + case MEMORY_POLICY_X86_UC: + p2mt =3D p2m_mmio_direct; + break; +#endif + default: + return -EOPNOTSUPP; + } ret =3D map_regions(d, _gfn(gfn), nr_mfns, _mfn(mfn), p2mt); if ( ret < 0 ) printk(XENLOG_G_WARNING diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index 19486d5..9330387 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -571,12 +571,24 @@ struct xen_domctl_bind_pt_irq { */ #define DPCI_ADD_MAPPING 1 #define DPCI_REMOVE_MAPPING 0 +/* + * Default memory policy. Corresponds to: + * Arm: MEMORY_POLICY_ARM_DEV_nGRE + * x86: MEMORY_POLICY_X86_UC + */ +#define MEMORY_POLICY_DEFAULT 0 +/* x86 only. Memory type UNCACHABLE */ +#define MEMORY_POLICY_X86_UC 0 +/* Arm only. Outer Shareable, Device-nGRE memory */ +#define MEMORY_POLICY_ARM_DEV_nGRE 0 +/* Arm only. Outer Shareable, Outer/Inner Write-Back Cacheable memory */ +#define MEMORY_POLICY_ARM_MEM_WB 1 struct xen_domctl_memory_mapping { uint64_aligned_t first_gfn; /* first page (hvm guest phys page) in ran= ge */ uint64_aligned_t first_mfn; /* first page (machine page) in range */ uint64_aligned_t nr_mfns; /* number of pages in range (>0) */ uint32_t add_mapping; /* add or remove mapping */ - uint32_t padding; /* padding for 64-bit aligned structure */ + uint32_t memory_policy; /* cacheability of the memory mapping */ }; =20 =20 --=20 1.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sat May 4 12:15:10 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1556658248; cv=none; d=zoho.com; s=zohoarc; b=QKVTYKvfAjKoBVTHVMKLTm6ZZ/f6jAG1DGdBeHN0MoZHX61hnVQ12qFKGFiffR2Q8y8lGa7HBxYHzngoWrWvnxCmtqTjXxnCdr5V6QXSYoUxiRmDo+6pFA9gtpefvJGEZsfsyHC57/9ybfCVeQegG+zWONvTvCdnU7SfUVXRngE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556658248; 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:ARC-Authentication-Results; bh=MRNNLr6F+LufpcXyb5Krkvi46dWYNqwAs/YytUGaChg=; b=egeOdDZA+1xZG/8F54r5uIP1A5ab4nwLS8lYq3o0OBBIEw9UyESyu59BmststdYAJ3R+6DAOvR+AWqyK6ARB1wAvqHqtARIHZ5c1scn0K9qX4P4s+qjWnobRwX5D/oV+oKR6KwsuTjRyXDQklJ9MwDMpXEHMx29/3n0smHqBax0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1556658248712843.5897558453368; Tue, 30 Apr 2019 14:04:08 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hLZty-0007f6-U3; Tue, 30 Apr 2019 21:02:58 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hLZty-0007em-3r for xen-devel@lists.xenproject.org; Tue, 30 Apr 2019 21:02:58 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 54450349-6b8b-11e9-843c-bc764e045a96; Tue, 30 Apr 2019 21:02:57 +0000 (UTC) Received: from sstabellini-ThinkPad-X260.xilinx.com (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 76EB12177B; Tue, 30 Apr 2019 21:02:56 +0000 (UTC) X-Inumbo-ID: 54450349-6b8b-11e9-843c-bc764e045a96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556658176; bh=NQUyl3rKiLRTUqRGxZzyFAIOHiSK54kIHSS6xSLVyDs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PoPYOHhiR+3jNmcwUSL8eYtb3Yny0nHuyqA0PGlanbrR/PG+JzfbFT471d5tGvAut Nvzve+YZQ7b6hDtXNrGXsdE0bj5jf19Ih/L+SVNo3mTh+skGyF2BJ4Szp2QCosPA2g ril0H8Nj9isc8U+XWqRnlxr/G1+ntTwWIBmFZr60= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Tue, 30 Apr 2019 14:02:46 -0700 Message-Id: <1556658172-8824-4-git-send-email-sstabellini@kernel.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v2 04/10] libxc: introduce xc_domain_mem_map_policy X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , julien.grall@arm.com, sstabellini@kernel.org, ian.jackson@eu.citrix.com, wei.liu2@citrix.com MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Introduce a new libxc function that makes use of the new memory_policy parameter added to the XEN_DOMCTL_memory_mapping hypercall. The parameter values are the same for the XEN_DOMCTL_memory_mapping hypercall (0 is MEMORY_POLICY_DEFAULT). Pass MEMORY_POLICY_DEFAULT by default -- no changes in behavior. We could extend xc_domain_memory_mapping, but QEMU makes use of it, so it is easier and less disruptive to introduce a new libxc function and change the implementation of xc_domain_memory_mapping to call into it. Signed-off-by: Stefano Stabellini CC: ian.jackson@eu.citrix.com CC: wei.liu2@citrix.com --- Changes in v2: - rename cache_policy to memory policy - rename MEMORY_POLICY_DEVMEM to MEMORY_POLICY_ARM_DEV_nGRE - rename MEMORY_POLICY_MEMORY to MEMORY_POLICY_ARM_MEM_WB - introduce xc_domain_mem_map_policy --- tools/libxc/include/xenctrl.h | 8 ++++++++ tools/libxc/xc_domain.c | 24 ++++++++++++++++++++---- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h index 49a6b2a..16ff286 100644 --- a/tools/libxc/include/xenctrl.h +++ b/tools/libxc/include/xenctrl.h @@ -1714,6 +1714,14 @@ int xc_deassign_dt_device(xc_interface *xch, uint32_t domid, char *path); =20 +int xc_domain_mem_map_policy(xc_interface *xch, + uint32_t domid, + unsigned long first_gfn, + unsigned long first_mfn, + unsigned long nr_mfns, + uint32_t add_mapping, + uint32_t memory_policy); + int xc_domain_memory_mapping(xc_interface *xch, uint32_t domid, unsigned long first_gfn, diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c index 05d771f..02f5778 100644 --- a/tools/libxc/xc_domain.c +++ b/tools/libxc/xc_domain.c @@ -2042,13 +2042,14 @@ failed: return -1; } =20 -int xc_domain_memory_mapping( +int xc_domain_mem_map_policy( xc_interface *xch, uint32_t domid, unsigned long first_gfn, unsigned long first_mfn, unsigned long nr_mfns, - uint32_t add_mapping) + uint32_t add_mapping, + uint32_t memory_policy) { DECLARE_DOMCTL; xc_dominfo_t info; @@ -2070,6 +2071,7 @@ int xc_domain_memory_mapping( domctl.cmd =3D XEN_DOMCTL_memory_mapping; domctl.domain =3D domid; domctl.u.memory_mapping.add_mapping =3D add_mapping; + domctl.u.memory_mapping.memory_policy =3D memory_policy; max_batch_sz =3D nr_mfns; do { @@ -2105,8 +2107,9 @@ int xc_domain_memory_mapping( * Errors here are ignored. */ if ( ret && add_mapping !=3D DPCI_REMOVE_MAPPING ) - xc_domain_memory_mapping(xch, domid, first_gfn, first_mfn, nr_mfns, - DPCI_REMOVE_MAPPING); + xc_domain_mem_map_policy(xch, domid, first_gfn, first_mfn, nr_mfns, + DPCI_REMOVE_MAPPING, + MEMORY_POLICY_DEFAULT); =20 /* We might get E2BIG so many times that we never advance. */ if ( !done && !ret ) @@ -2115,6 +2118,19 @@ int xc_domain_memory_mapping( return ret; } =20 +int xc_domain_memory_mapping( + xc_interface *xch, + uint32_t domid, + unsigned long first_gfn, + unsigned long first_mfn, + unsigned long nr_mfns, + uint32_t add_mapping) +{ + return xc_domain_mem_map_policy(xch, domid, first_gfn, first_mfn, + nr_mfns, add_mapping, + MEMORY_POLICY_DEFAULT); +} + int xc_domain_ioport_mapping( xc_interface *xch, uint32_t domid, --=20 1.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sat May 4 12:15:10 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1556658254; cv=none; d=zoho.com; s=zohoarc; b=TXaWOH6CiVoF9PwetEXOWqEOi70GoXyVSS0sIL9NMKnrIO0F1GdvsJzbu7VvG8LCIZ0oGXSZdWcM6foWSnzZhf0CTmHA1JQVPtuOlOxbcg2Yfb8PhsERgAUk9eKeqnn1wZpcfgZxxp9ztS/6cCdvhrOsd388WXJLltQ/H8sFKlA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556658254; 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:ARC-Authentication-Results; bh=SMutVhPUwVc/SDNPn6pRxsvDeoyF25AAPT0KOqEpFMQ=; b=QGjb1If171UPCwbobZH/H9y3hBdRF55LnlpuAtLhteiEz+HAsTQfAdMZOx5x8Oqcs09PGif37rWWtvaCvUAINaLewXMAhKpNfbuEE43ypuj/QxnfFzFKsvIXetwXHwXDdrNsCSBeE8eKyJ91ilgX3diPZzq1t8w8cVY3hkYJGfs= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1556658254852430.02823951379344; Tue, 30 Apr 2019 14:04:14 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hLZu0-0007gO-Bz; Tue, 30 Apr 2019 21:03:00 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hLZtz-0007fA-40 for xen-devel@lists.xenproject.org; Tue, 30 Apr 2019 21:02:59 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 5493ddf8-6b8b-11e9-864f-c3c12dfa35a3; Tue, 30 Apr 2019 21:02:57 +0000 (UTC) Received: from sstabellini-ThinkPad-X260.xilinx.com (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ED113217D4; Tue, 30 Apr 2019 21:02:56 +0000 (UTC) X-Inumbo-ID: 5493ddf8-6b8b-11e9-864f-c3c12dfa35a3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556658177; bh=/KzwmMHcUZr+ZQbrHigLZctPcmSGXv9IFLUWU57xvyY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=olRoOH/AQOwS9u1+WbhXnyVa7DePykcS84+sV+HKX3SgMkGR3N5a/VM4VXSLbehuW jEVUkPPpueyl6CY7E5fM6uTdXKYfUQTI/gc7u835K+HgWH6RRWt4Fct257AN6VTj3V dpsofv4AqXoLDPMdx9EcjDIdfYmRA7DF2yQiz030= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Tue, 30 Apr 2019 14:02:47 -0700 Message-Id: <1556658172-8824-5-git-send-email-sstabellini@kernel.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v2 05/10] libxl/xl: add memory policy option to iomem X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , julien.grall@arm.com, sstabellini@kernel.org, ian.jackson@eu.citrix.com, wei.liu2@citrix.com MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Add a new memory policy option for the iomem parameter. Possible values are: - arm_devmem, device nGRE, the default on ARM - arm_memory, WB cachable memory - x86_uc: uncachable memory, the default on x86 Store the parameter in a new field in libxl_iomem_range. Pass the memory policy option to xc_domain_mem_map_policy. Signed-off-by: Stefano Stabellini CC: ian.jackson@eu.citrix.com CC: wei.liu2@citrix.com --- Changes in v2: - add #define LIBXL_HAVE_MEMORY_POLICY - ability to part the memory policy parameter even if gfn is not passed - rename cache_policy to memory policy - rename MEMORY_POLICY_DEVMEM to MEMORY_POLICY_ARM_DEV_nGRE - rename MEMORY_POLICY_MEMORY to MEMORY_POLICY_ARM_MEM_WB - rename memory to arm_memory and devmem to arm_devmem - expand the non-security support status to non device passthrough iomem configurations - rename iomem options - add x86 specific iomem option --- SUPPORT.md | 2 +- docs/man/xl.cfg.5.pod.in | 7 ++++++- tools/libxl/libxl.h | 5 +++++ tools/libxl/libxl_create.c | 21 +++++++++++++++++++-- tools/libxl/libxl_types.idl | 9 +++++++++ tools/xl/xl_parse.c | 22 +++++++++++++++++++++- 6 files changed, 61 insertions(+), 5 deletions(-) diff --git a/SUPPORT.md b/SUPPORT.md index e4fb15b..f29a299 100644 --- a/SUPPORT.md +++ b/SUPPORT.md @@ -649,7 +649,7 @@ to be used in addition to QEMU. =20 Status: Experimental =20 -### ARM/Non-PCI device passthrough +### ARM/Non-PCI device passthrough and other iomem configurations =20 Status: Supported, not security supported =20 diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in index c7d70e6..c85857e 100644 --- a/docs/man/xl.cfg.5.pod.in +++ b/docs/man/xl.cfg.5.pod.in @@ -1222,7 +1222,7 @@ is given in hexadecimal format and may either be a ra= nge, e.g. C<2f8-2ff> It is recommended to only use this option for trusted VMs under administrator's control. =20 -=3Ditem B +=3Ditem B =20 Allow auto-translated domains to access specific hardware I/O memory pages. =20 @@ -1233,6 +1233,11 @@ B is not specified, the mapping will be perform= ed using B as a start in the guest's address space, therefore performing a 1:1 mapping by default. All of these values must be given in hexadecimal format. +B for ARM platforms: + - "arm_devmem" for Device nGRE, the default on ARM + - "arm_memory" for Outer Shareable Write-Back Cacheable Memory +B can be for x86 platforms: + - "x86_uc" for Uncachable Memory, the default on x86 =20 Note that the IOMMU won't be updated with the mappings specified with this option. This option therefore should not be used to pass through any diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index 482499a..2366331 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -379,6 +379,11 @@ #define LIBXL_HAVE_BUILDINFO_BOOTLOADER_ARGS 1 =20 /* + * Support specifying memory policy information for memory mappings. + */ +#define LIBXL_HAVE_MEMORY_POLICY 1 + +/* * LIBXL_HAVE_EXTENDED_VKB indicates that libxl_device_vkb has extended fi= elds: * - unique_id; * - feature_disable_keyboard; diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 89fe80f..a6c5e30 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -415,6 +415,21 @@ static void init_console_info(libxl__gc *gc, Only 'channels' when mapped to consoles have a string name. */ } =20 +static uint32_t libxl__memory_policy_to_xc(libxl_memory_policy c) +{ + switch (c) { + case LIBXL_MEMORY_POLICY_ARM_MEM_WB: + return MEMORY_POLICY_ARM_MEM_WB; + case LIBXL_MEMORY_POLICY_ARM_DEV_NGRE: + return MEMORY_POLICY_ARM_DEV_nGRE; + case LIBXL_MEMORY_POLICY_X86_UC: + return MEMORY_POLICY_X86_UC; + case LIBXL_MEMORY_POLICY_DEFAULT: + default: + return MEMORY_POLICY_DEFAULT; + } +} + int libxl__domain_build(libxl__gc *gc, libxl_domain_config *d_config, uint32_t domid, @@ -1369,9 +1384,11 @@ static void domcreate_launch_dm(libxl__egc *egc, lib= xl__multidev *multidev, ret =3D ERROR_FAIL; goto error_out; } - ret =3D xc_domain_memory_mapping(CTX->xch, domid, + ret =3D xc_domain_mem_map_policy(CTX->xch, domid, io->gfn, io->start, - io->number, 1); + io->number, 1, + libxl__memory_policy_to_xc( + io->memory_policy)); if (ret < 0) { LOGED(ERROR, domid, "failed to map to domain iomem range %"PRIx64"-%"PRIx64 diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl index cb4702f..4db8a62 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -272,6 +272,13 @@ libxl_ioport_range =3D Struct("ioport_range", [ ("number", uint32), ]) =20 +libxl_memory_policy =3D Enumeration("memory_policy", [ + (0, "default"), + (1, "ARM_Dev_nGRE"), + (2, "ARM_Mem_WB"), + (3, "x86_UC"), + ], init_val =3D "LIBXL_MEMORY_POLICY_DEFAULT") + libxl_iomem_range =3D Struct("iomem_range", [ # start host frame number to be mapped to the guest ("start", uint64), @@ -279,6 +286,8 @@ libxl_iomem_range =3D Struct("iomem_range", [ ("number", uint64), # guest frame number used as a start for the mapping ("gfn", uint64, {'init_val': "LIBXL_INVALID_GFN"}), + # memory_policy of the memory region + ("memory_policy", libxl_memory_policy), ]) =20 libxl_vga_interface_info =3D Struct("vga_interface_info", [ diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c index 352cd21..ed56931 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -1883,6 +1883,7 @@ void parse_config_data(const char *config_source, } for (i =3D 0; i < num_iomem; i++) { int used; + const char *mempolicy; =20 buf =3D xlu_cfg_get_listitem (iomem, i); if (!buf) { @@ -1895,11 +1896,30 @@ void parse_config_data(const char *config_source, &b_info->iomem[i].start, &b_info->iomem[i].number, &used, &b_info->iomem[i].gfn, &used); - if (ret < 2 || buf[used] !=3D '\0') { + if (ret < 2) { fprintf(stderr, "xl: Invalid argument parsing iomem: %s\n", buf); exit(1); } + mempolicy =3D &buf[used]; + if (strlen(mempolicy) > 1) { + mempolicy++; + if (!strcmp(mempolicy, "arm_devmem")) + b_info->iomem[i].memory_policy =3D + LIBXL_MEMORY_POLICY_ARM_DEV_NGRE; + else if (!strcmp(mempolicy, "x86_uc")) + b_info->iomem[i].memory_policy =3D + LIBXL_MEMORY_POLICY_X86_UC; + else if (!strcmp(mempolicy, "arm_memory")) + b_info->iomem[i].memory_policy =3D + LIBXL_MEMORY_POLICY_ARM_MEM_WB; + else { + fprintf(stderr, + "xl: Invalid iomem memory policy parameter: %s= \n", + mempolicy); + exit(1); + } + } } } =20 --=20 1.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sat May 4 12:15:10 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1556658489; cv=none; d=zoho.com; s=zohoarc; b=QmVze6JqY/N6O/1b4AVDj3Pc34JmG9fZdbGOvNrVv2nD3SXUoXwLbvEXlqyfnFBK3m3MSzVUkPasv8kVARfiVyJSc8fvilHdcfn86PP58VhRPzu8LLnP1j44vV4Hz8irz6sS8mpr+Cla/jMgRv+i8VUWDI7jCxQdBvzGGKGVyoY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556658489; 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:ARC-Authentication-Results; bh=sRi5reu0FR7Pb20zQqzyeXdSRUVAPbGlkBY3xPCx7kc=; b=Rq/pL4Kcd7lDbxWAG5q6/yFQq0/CfaKBKYGJIN+MbouKD36t++uyPkxP0R7vOenaDkN/xhhv7q1XsFH6H7M9/NAEacmUitvKw+DTRVbDJiyJe+2GqUXPI5od1dZ0EBRvNNBrNR1NE/3XXo2wfEDHJmcWEPi/y9EwWPOFtpRn1MQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1556658489728441.9296799712888; Tue, 30 Apr 2019 14:08:09 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hLZxs-0000MI-OT; Tue, 30 Apr 2019 21:07:00 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hLZxr-0000MB-S2 for xen-devel@lists.xenproject.org; Tue, 30 Apr 2019 21:06:59 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 54c6d320-6b8b-11e9-87ac-1fc2ba82c803; Tue, 30 Apr 2019 21:02:58 +0000 (UTC) Received: from sstabellini-ThinkPad-X260.xilinx.com (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6A80D217D6; Tue, 30 Apr 2019 21:02:57 +0000 (UTC) X-Inumbo-ID: 54c6d320-6b8b-11e9-87ac-1fc2ba82c803 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556658177; bh=mDmgj+zPtn+AKbS1JChR6ZLHxHQ50ygJNrJz20vO0xg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G1zVapUaz3Gcdm8KW4Ra9Oi5o7mb+biWzQbiNRaGneGWmdpjVpKK6VRwog6VqK91e qP45ApnVMnANuYI1dnpz7o/9xVbgpWBRYBndf5ET6AI+KJ6y6noUK6bAHevXnZOY6Z MG0ysSfZVcCVraZWa0+HKKpNcFnjpvjsj0w2dac4= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Tue, 30 Apr 2019 14:02:48 -0700 Message-Id: <1556658172-8824-6-git-send-email-sstabellini@kernel.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v2 06/10] xen/arm: extend device_tree_for_each_node X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , julien.grall@arm.com, sstabellini@kernel.org MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Add two new paramters to device_tree_for_each_node: node and depth. Node is the node to start the search from and depth is the min depth of the search. Passing 0, 0 triggers the old behavior. Signed-off-by: Stefano Stabellini --- Changes in v2: - new --- xen/arch/arm/acpi/boot.c | 2 +- xen/arch/arm/bootfdt.c | 12 ++++++------ xen/include/xen/device_tree.h | 5 +++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c index 9b29769..cfc85c2 100644 --- a/xen/arch/arm/acpi/boot.c +++ b/xen/arch/arm/acpi/boot.c @@ -248,7 +248,7 @@ int __init acpi_boot_table_init(void) */ if ( param_acpi_off || ( !param_acpi_force && device_tree_for_each_node(device_tree_flat= tened, - dt_scan_depth1_nodes, N= ULL))) + 0, 0, dt_scan_depth1_nodes, NULL))) goto disable; =20 /* diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c index 891b4b6..e7b08ed 100644 --- a/xen/arch/arm/bootfdt.c +++ b/xen/arch/arm/bootfdt.c @@ -77,6 +77,8 @@ static u32 __init device_tree_get_u32(const void *fdt, in= t node, /** * device_tree_for_each_node - iterate over all device tree nodes * @fdt: flat device tree. + * @node: node to start the search from + * @depth: min depth of the search * @func: function to call for each node. * @data: data to pass to @func. * @@ -86,17 +88,15 @@ static u32 __init device_tree_get_u32(const void *fdt, = int node, * returns a value different from 0, that value is returned immediately. */ int __init device_tree_for_each_node(const void *fdt, + int node, int depth, device_tree_node_func func, void *data) { - int node; - int depth; u32 address_cells[DEVICE_TREE_MAX_DEPTH]; u32 size_cells[DEVICE_TREE_MAX_DEPTH]; - int ret; + int ret, min_depth =3D depth; =20 - for ( node =3D 0, depth =3D 0; - node >=3D0 && depth >=3D 0; + for ( ; node >=3D0 && depth >=3D min_depth; node =3D fdt_next_node(fdt, node, &depth) ) { const char *name =3D fdt_get_name(fdt, node, NULL); @@ -357,7 +357,7 @@ size_t __init boot_fdt_info(const void *fdt, paddr_t pa= ddr) =20 add_boot_module(BOOTMOD_FDT, paddr, fdt_totalsize(fdt), false); =20 - device_tree_for_each_node((void *)fdt, early_scan_node, NULL); + device_tree_for_each_node((void *)fdt, 0, 0, early_scan_node, NULL); early_print_info(); =20 return fdt_totalsize(fdt); diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index 7408a6c..4ff78ba 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -159,8 +159,9 @@ typedef int (*device_tree_node_func)(const void *fdt, extern const void *device_tree_flattened; =20 int device_tree_for_each_node(const void *fdt, - device_tree_node_func func, - void *data); + int node, int depth, + device_tree_node_func func, + void *data); =20 /** * dt_unflatten_host_device_tree - Unflatten the host device tree --=20 1.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sat May 4 12:15:10 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1556658248; cv=none; d=zoho.com; s=zohoarc; b=EhIPc5/x/7hpPq3Ay9UMcg7xLI7dwjOu5u85ntlrUk6MBkNQzZXQDe9M7uQgYBjcpSzO1sI9ty6TLZY0457XtY1oLEq1ipmqc2u4NhzHctX7A0+W7gmXYOiS3ub3ISQYZ305Y0vPnVxx7QCnSXA0PlfAsfuKds68nQ/Zz13bU34= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556658248; 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:ARC-Authentication-Results; bh=nMxdXWpq2BNOoS+Wb652mkeXl08NtPCXXzm5kOKNScQ=; b=I2QN5vdMmNGk667zNFTqajGghMsHhsJ3ivEH9WpQVvOosDJeuFPgre5TD7JFM+er2rkezNcRJZo4KUQW4bBZlLIds2CmrHfgUtC2sDryRm/7xpdTWnTHm0HUugShxYzfrSCC6WSwcGBwOm2G7nV8yEbZhGXGWlLvgZpCpPKlQuY= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1556658248719270.8045022955778; Tue, 30 Apr 2019 14:04:08 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hLZu1-0007hs-C8; Tue, 30 Apr 2019 21:03:01 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hLZtz-0007fc-Fr for xen-devel@lists.xenproject.org; Tue, 30 Apr 2019 21:02:59 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 54f87a72-6b8b-11e9-843c-bc764e045a96; Tue, 30 Apr 2019 21:02:58 +0000 (UTC) Received: from sstabellini-ThinkPad-X260.xilinx.com (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C4EB5217D7; Tue, 30 Apr 2019 21:02:57 +0000 (UTC) X-Inumbo-ID: 54f87a72-6b8b-11e9-843c-bc764e045a96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556658178; bh=Ck4HAdpRo/MJVybB0NXOKUYB51jhM+Sseutc5JUzyu4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ce13DguK4B/HWhRk2ucZWpdLgiwx1EQXfNCL0ytZuDo2p7JptkdxgPhNZx3QVEw8a NLU4iOJU1U7AACVHgYLtmdRzXKZm2F54XUb9QM8JUoXbHR2vM1EdwmUJ7BH5gaejin gpcuDC9zJCW7DRqRtyrXnuSMqLZq6xjtAW1aME14= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Tue, 30 Apr 2019 14:02:49 -0700 Message-Id: <1556658172-8824-7-git-send-email-sstabellini@kernel.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v2 07/10] xen/arm: make process_memory_node a device_tree_node_func X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , julien.grall@arm.com, sstabellini@kernel.org MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Change the signature of process_memory_node to match device_tree_node_func. Signed-off-by: Stefano Stabellini --- Changes in v2: - new --- xen/arch/arm/bootfdt.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c index e7b08ed..b6600ab 100644 --- a/xen/arch/arm/bootfdt.c +++ b/xen/arch/arm/bootfdt.c @@ -124,9 +124,10 @@ int __init device_tree_for_each_node(const void *fdt, return 0; } =20 -static void __init process_memory_node(const void *fdt, int node, - const char *name, - u32 address_cells, u32 size_cells) +static int __init process_memory_node(const void *fdt, int node, + const char *name, int depth, + u32 address_cells, u32 size_cells, + void *data) { const struct fdt_property *prop; int i; @@ -139,14 +140,14 @@ static void __init process_memory_node(const void *fd= t, int node, { printk("fdt: node `%s': invalid #address-cells or #size-cells", name); - return; + return 0; } =20 prop =3D fdt_get_property(fdt, node, "reg", NULL); if ( !prop ) { printk("fdt: node `%s': missing `reg' property\n", name); - return; + return 0; } =20 cell =3D (const __be32 *)prop->data; @@ -161,6 +162,8 @@ static void __init process_memory_node(const void *fdt,= int node, bootinfo.mem.bank[bootinfo.mem.nr_banks].size =3D size; bootinfo.mem.nr_banks++; } + + return 0; } =20 static void __init process_multiboot_node(const void *fdt, int node, @@ -293,7 +296,8 @@ static int __init early_scan_node(const void *fdt, void *data) { if ( device_tree_node_matches(fdt, node, "memory") ) - process_memory_node(fdt, node, name, address_cells, size_cells); + process_memory_node(fdt, node, name, depth, address_cells, size_ce= lls, + NULL); else if ( depth <=3D 3 && (device_tree_node_compatible(fdt, node, "xen= ,multiboot-module" ) || device_tree_node_compatible(fdt, node, "multiboot,module" ))) process_multiboot_node(fdt, node, name, address_cells, size_cells); --=20 1.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sat May 4 12:15:10 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1556658250; cv=none; d=zoho.com; s=zohoarc; b=oZfgsUMxCt43S4VnWL2yi87sYq3unP6Rcrdy4ScJTrOZTXzvmga8TVGtQ3G7rxUIEF2sFU1wfzuko/DEup7DwjELMXcwUApBDMkAblEGu9546OVavrD6Kx9W9FQVTnt+orrZfiZLJDUHv8sOvfgypWnh7vP6Ao+mydPmkpNlrKY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556658250; 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:ARC-Authentication-Results; bh=Vhlj58v2EToChPXkwDq3gW3hDlDbSvtLBjmMH2Y9knE=; b=YSXqJbsOChc/225eOI/ke0nmmeKufvLgUm1dN0gEbPqgo335+NtGT4waAPOq6lGQZVOD+nqzIKzC6hLzlF3uZrZiBjpMOIHJXL3gqz8w4ArUC+0EHcsfU95PHWBErfuF8ij4aW7pL/MLK9MleNZ7PDvEt2BF6IGil4B/mMlxE2s= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1556658250865387.2382455147151; Tue, 30 Apr 2019 14:04:10 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hLZu1-0007io-V3; Tue, 30 Apr 2019 21:03:01 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hLZtz-0007g4-Ne for xen-devel@lists.xenproject.org; Tue, 30 Apr 2019 21:02:59 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 5531cc97-6b8b-11e9-843c-bc764e045a96; Tue, 30 Apr 2019 21:02:58 +0000 (UTC) Received: from sstabellini-ThinkPad-X260.xilinx.com (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2C36D217D8; Tue, 30 Apr 2019 21:02:58 +0000 (UTC) X-Inumbo-ID: 5531cc97-6b8b-11e9-843c-bc764e045a96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556658178; bh=FAZZyHHfGbFiBpqqe0yUwxuFp4/ZYC23e6I7iDyTAPQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sw5X8FBFwlbY9YZDIxLH+Yensm/0ADxghYxcFXvdnl2Fs+8V6w4Ebgwx8Osi7nYIX YKPZG9/tSdbtp0SQMqy5d+igf1VpuuXrmabWAt1PiELYmYiWFJSdmk7+VvpTl/QOu1 Jb1WTXXu2tbP+dW74i6heRM3ohVaT415m6ZrZlno= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Tue, 30 Apr 2019 14:02:50 -0700 Message-Id: <1556658172-8824-8-git-send-email-sstabellini@kernel.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v2 08/10] xen/arm: keep track of reserved-memory regions X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , julien.grall@arm.com, sstabellini@kernel.org MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) As we parse the device tree in Xen, keep track of the reserved-memory regions as they need special treatment (follow-up patches will make use of the stored information.) Reuse process_memory_node to add reserved-memory regions to the bootinfo.reserved_mem array. Remove the warning if there is no reg in process_memory_node because it is a normal condition for reserved-memory. Signed-off-by: Stefano Stabellini --- Not done: create an e820-like structure on ARM. Changes in v2: - call process_memory_node from process_reserved_memory_node to avoid duplication --- xen/arch/arm/bootfdt.c | 30 ++++++++++++++++++++++-------- xen/include/asm-arm/setup.h | 1 + 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c index b6600ab..9355a6e 100644 --- a/xen/arch/arm/bootfdt.c +++ b/xen/arch/arm/bootfdt.c @@ -135,6 +135,8 @@ static int __init process_memory_node(const void *fdt, = int node, const __be32 *cell; paddr_t start, size; u32 reg_cells =3D address_cells + size_cells; + struct meminfo *mem; + bool reserved =3D (bool)data; =20 if ( address_cells < 1 || size_cells < 1 ) { @@ -143,29 +145,39 @@ static int __init process_memory_node(const void *fdt= , int node, return 0; } =20 + if ( reserved ) + mem =3D &bootinfo.reserved_mem; + else + mem =3D &bootinfo.mem; + prop =3D fdt_get_property(fdt, node, "reg", NULL); if ( !prop ) - { - printk("fdt: node `%s': missing `reg' property\n", name); return 0; - } =20 cell =3D (const __be32 *)prop->data; banks =3D fdt32_to_cpu(prop->len) / (reg_cells * sizeof (u32)); =20 - for ( i =3D 0; i < banks && bootinfo.mem.nr_banks < NR_MEM_BANKS; i++ ) + for ( i =3D 0; i < banks && mem->nr_banks < NR_MEM_BANKS; i++ ) { device_tree_get_reg(&cell, address_cells, size_cells, &start, &siz= e); if ( !size ) continue; - bootinfo.mem.bank[bootinfo.mem.nr_banks].start =3D start; - bootinfo.mem.bank[bootinfo.mem.nr_banks].size =3D size; - bootinfo.mem.nr_banks++; + mem->bank[mem->nr_banks].start =3D start; + mem->bank[mem->nr_banks].size =3D size; + mem->nr_banks++; } =20 return 0; } =20 +static int __init process_reserved_memory_node(const void *fdt, int node, + const char *name, int depth, + u32 address_cells, u32 size= _cells) +{ + device_tree_for_each_node(fdt, node, depth, process_memory_node, (void= *)true); + return 0; +} + static void __init process_multiboot_node(const void *fdt, int node, const char *name, u32 address_cells, u32 size_cell= s) @@ -297,7 +309,9 @@ static int __init early_scan_node(const void *fdt, { if ( device_tree_node_matches(fdt, node, "memory") ) process_memory_node(fdt, node, name, depth, address_cells, size_ce= lls, - NULL); + (void*)false); + else if ( device_tree_node_matches(fdt, node, "reserved-memory") ) + process_reserved_memory_node(fdt, node, name, depth, address_cells= , size_cells); else if ( depth <=3D 3 && (device_tree_node_compatible(fdt, node, "xen= ,multiboot-module" ) || device_tree_node_compatible(fdt, node, "multiboot,module" ))) process_multiboot_node(fdt, node, name, address_cells, size_cells); diff --git a/xen/include/asm-arm/setup.h b/xen/include/asm-arm/setup.h index 48187e1..5c3fc2d 100644 --- a/xen/include/asm-arm/setup.h +++ b/xen/include/asm-arm/setup.h @@ -66,6 +66,7 @@ struct bootcmdlines { =20 struct bootinfo { struct meminfo mem; + struct meminfo reserved_mem; struct bootmodules modules; struct bootcmdlines cmdlines; #ifdef CONFIG_ACPI --=20 1.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sat May 4 12:15:10 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1556658252; cv=none; d=zoho.com; s=zohoarc; b=QS+WYGzUyF+XFPVcZ5lGDw33JhDwt/sc91liT5PnLzcJAykQVqfrmfZ446NZZL/VwZ268wc1m8ZgRurYLUCQXGGqukFArckav+K4+Qqfnz5Zu7gGaEQ0w63vhSxI9uysKjOQfWy+a1hPJCpbBBcyg0vyd+bfsBiS3W4knYcJsVY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556658252; 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:ARC-Authentication-Results; bh=clioHif/BmUZslOXAyrpmZ+hDbQGcYX7SfP18CTOn6o=; b=brCI+bNv0KS1Dw6YpXstjdAfPeXpBgcX+yU12AhdyKAqv+ydDCMvXP9OfjUpDL7rtSEm8HI5fKKXDY+tSRs3S3Lyqt0G/MoxElol+kxSbZ1hM7ptN15XmKoGEIloS8JuGIJBD/GzI46lwk67gYfFrhL1U6RmcIuSQ8ytjTaWQ/E= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1556658252252724.3050576188173; Tue, 30 Apr 2019 14:04:12 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hLZu2-0007jQ-CF; Tue, 30 Apr 2019 21:03:02 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hLZu0-0007gU-Hu for xen-devel@lists.xenproject.org; Tue, 30 Apr 2019 21:03:00 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 55718702-6b8b-11e9-b7b5-1b0fe93ad1c4; Tue, 30 Apr 2019 21:02:59 +0000 (UTC) Received: from sstabellini-ThinkPad-X260.xilinx.com (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 885C221743; Tue, 30 Apr 2019 21:02:58 +0000 (UTC) X-Inumbo-ID: 55718702-6b8b-11e9-b7b5-1b0fe93ad1c4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556658178; bh=8/4xOiePn9z3SrdryWW11nW/8QK/e4NhxngmXpkEtp4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=avpozdf3Ngal5mDVzPmkEKGD688CCc4+nB9sUCCwvVTsrgPmVJFOc1/ohSqpRZwQ0 Zim42WWomCH++3IrHtxT2xFacA7aC1/XFQSx3k0P4iOkP/WuSzLxvuc1EoxjG0wiuP gfVg5Sonhqafmj1avTl6/7SHL3ipzq2Vf4KX2m8U= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Tue, 30 Apr 2019 14:02:51 -0700 Message-Id: <1556658172-8824-9-git-send-email-sstabellini@kernel.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v2 09/10] xen/arm: map reserved-memory regions as normal memory in dom0 X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , julien.grall@arm.com, sstabellini@kernel.org MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) reserved-memory regions should be mapped as normal memory. At the moment, they get remapped as device memory in dom0 because Xen doesn't know any better. Add an explicit check for it. reserved-memory regions overlap with memory nodes. The overlapping memory is reserved-memory and should be handled accordingly: consider_modules and dt_unreserved_regions should skip these regions the same way they are already skipping mem-reserve regions. Signed-off-by: Stefano Stabellini --- Changes in v2: - fix commit message: full overlap - remove check_reserved_memory - extend consider_modules and dt_unreserved_regions --- xen/arch/arm/domain_build.c | 7 +++++++ xen/arch/arm/setup.c | 36 +++++++++++++++++++++++++++++++++--- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 5e7f94c..e5d488d 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1408,6 +1408,13 @@ static int __init handle_node(struct domain *d, stru= ct kernel_info *kinfo, "WARNING: Path %s is reserved, skip the node as we may re-u= se the path.\n", path); =20 + /* + * reserved-memory ranges should be mapped as normal memory in the + * p2m. + */ + if ( !strcmp(dt_node_name(node), "reserved-memory") ) + p2mt =3D p2m_mmio_direct_c; + res =3D handle_device(d, node, p2mt); if ( res) return res; diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index ccb0f18..908b52c 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -204,6 +204,19 @@ void __init dt_unreserved_regions(paddr_t s, paddr_t e, } } =20 + for ( ; i - nr < bootinfo.reserved_mem.nr_banks; i++ ) + { + paddr_t r_s =3D bootinfo.reserved_mem.bank[i - nr].start; + paddr_t r_e =3D r_s + bootinfo.reserved_mem.bank[i - nr].size; + + if ( s < r_e && r_s < e ) + { + dt_unreserved_regions(r_e, e, cb, i+1); + dt_unreserved_regions(s, r_s, cb, i+1); + return; + } + } + cb(s, e); } =20 @@ -390,7 +403,7 @@ static paddr_t __init consider_modules(paddr_t s, paddr= _t e, { const struct bootmodules *mi =3D &bootinfo.modules; int i; - int nr_rsvd; + int nr; =20 s =3D (s+align-1) & ~(align-1); e =3D e & ~(align-1); @@ -416,9 +429,9 @@ static paddr_t __init consider_modules(paddr_t s, paddr= _t e, =20 /* Now check any fdt reserved areas. */ =20 - nr_rsvd =3D fdt_num_mem_rsv(device_tree_flattened); + nr =3D fdt_num_mem_rsv(device_tree_flattened); =20 - for ( ; i < mi->nr_mods + nr_rsvd; i++ ) + for ( ; i < mi->nr_mods + nr; i++ ) { paddr_t mod_s, mod_e; =20 @@ -440,6 +453,23 @@ static paddr_t __init consider_modules(paddr_t s, padd= r_t e, return consider_modules(s, mod_s, size, align, i+1); } } + + /* Now check for reserved-memory regions */ + nr +=3D mi->nr_mods; + for ( ; i - nr < bootinfo.reserved_mem.nr_banks; i++ ) + { + paddr_t r_s =3D bootinfo.reserved_mem.bank[i - nr].start; + paddr_t r_e =3D r_s + bootinfo.reserved_mem.bank[i - nr].size; + + if ( s < r_e && r_s < e ) + { + r_e =3D consider_modules(r_e, e, size, align, i+1); + if ( r_e ) + return r_e; + + return consider_modules(s, r_s, size, align, i+1); + } + } return e; } #endif --=20 1.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sat May 4 12:15:10 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1556658262; cv=none; d=zoho.com; s=zohoarc; b=JN7VmFRG6GUdFACTW6HV/uuB3asAGwDm73uVHZqIJKKmcTBEFtjjS54umPosJfJlrddfzfbLXCbJ1BiFy5Ile3pQncMnDZXuS3ozhIQ0HcIdtukCnXPafrWgihua9XERWzXeL+XIvpSIx2JRaaupNl/B489ZZJSg9RZ2HQtpSoI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556658262; 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:ARC-Authentication-Results; bh=jv68gOYxRHzPnEs/1XHdZCceGk5qVG20J3iil3gbtlA=; b=N/zbhi+uySCOuMVlnbYijjJ974n479zTCxfc23w0quudqU0rkzLQZRB7EwAWF+6ThNTQnwK4DPAmZEeqJBFczOCaaMIjrh8CV9LKNlUJH3XasQv1KcWcbGM3vGvjQxQcBrgl4UEj23W6xX5e9Hw2TQtnqFK1/UDvJyYfezohKl0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1556658262991111.17936303043496; Tue, 30 Apr 2019 14:04:22 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hLZu2-0007jz-PG; Tue, 30 Apr 2019 21:03:02 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hLZu1-0007h5-1B for xen-devel@lists.xenproject.org; Tue, 30 Apr 2019 21:03:01 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 55a3a1be-6b8b-11e9-843c-bc764e045a96; Tue, 30 Apr 2019 21:02:59 +0000 (UTC) Received: from sstabellini-ThinkPad-X260.xilinx.com (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E28DC21744; Tue, 30 Apr 2019 21:02:58 +0000 (UTC) X-Inumbo-ID: 55a3a1be-6b8b-11e9-843c-bc764e045a96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556658179; bh=za6Exya73K7slM0wbPXGyWU791U1dzjVrB9Mqj71bKg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uhWpDVuybrBDmJCFgsrHD4soAXHAnI2/aU77dNRlSHiuVTLXOtbcgFoox9FBY2wvS tZngt+KiJLWp5MinRiGTEWiMkWzZ9VgH/6n+AwYDn24zdriqzuBjbdNvxEaNz9RjhI UU2ELBowTEXvIUXWhU9XKVKIhQD6XhHgLQSSpfl0= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Tue, 30 Apr 2019 14:02:52 -0700 Message-Id: <1556658172-8824-10-git-send-email-sstabellini@kernel.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v2 10/10] xen/arm: add reserved-memory regions to the dom0 memory node X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , julien.grall@arm.com, sstabellini@kernel.org MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Reserved memory regions are automatically remapped to dom0. Their device tree nodes are also added to dom0 device tree. However, the dom0 memory node is not currently extended to cover the reserved memory regions ranges as required by the spec. This commit fixes it. Signed-off-by: Stefano Stabellini --- xen/arch/arm/domain_build.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index e5d488d..fa1ca20 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -643,7 +643,8 @@ static int __init make_memory_node(const struct domain = *d, { int res, i; int reg_size =3D addrcells + sizecells; - int nr_cells =3D reg_size*kinfo->mem.nr_banks; + int nr_cells =3D reg_size * (kinfo->mem.nr_banks + (is_hardware_domain= (d) ? + bootinfo.reserved_mem.nr_banks : 0)); __be32 reg[NR_MEM_BANKS * 4 /* Worst case addrcells + sizecells */]; __be32 *cells; =20 @@ -673,6 +674,20 @@ static int __init make_memory_node(const struct domain= *d, dt_child_set_range(&cells, addrcells, sizecells, start, size); } =20 + if ( is_hardware_domain(d) ) + { + for ( i =3D 0; i < bootinfo.reserved_mem.nr_banks; i++ ) + { + u64 start =3D bootinfo.reserved_mem.bank[i].start; + u64 size =3D bootinfo.reserved_mem.bank[i].size; + + dt_dprintk(" Bank %d: %#"PRIx64"->%#"PRIx64"\n", + i, start, start + size); + + dt_child_set_range(&cells, addrcells, sizecells, start, size); + } + } + res =3D fdt_property(fdt, "reg", reg, nr_cells * sizeof(*reg)); if ( res ) return res; --=20 1.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel