From nobody Thu May 9 00:26:20 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1586912600; cv=none; d=zohomail.com; s=zohoarc; b=Jj2dbQP7LE1bP2SXUdCC53THyE9SNgSqBtbLUVtGsdbomGFqr+wGxvC8VCp1XB4+ElyZsJ7ReIbcF9Ep6j9vyyxZn4voVZJKhCEkt7UDTUNqlklnFTDNQpq+Sn9A5snc2z0sd1pO0T5SxGCxKM+BiA2aXNgn6XCQj3r2sdYOngw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586912600; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=h+GZFA3LbsJ1qduUJMzZx191W5i+Pig7ShYx5EWWCGs=; b=E8CsXasrTPouYXKI6NOkBInagmobdRKSff6ooXkvKscUbTmuJvMZaIbr1iwjiC4veWcRdZXwMscO86UIIpsbbCGsOBAG+rOnaHKZ0Yb2S2c/s3CQOeKxtPFr8SvZo12hRE4vX+WTyacqKXUsn5+jQAafShA2AYke2mKiNJLB6n8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=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 1586912600494633.4304890462165; Tue, 14 Apr 2020 18:03:20 -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 1jOWSC-0001BX-7X; Wed, 15 Apr 2020 01:03:00 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jOWSA-0001BP-FG for xen-devel@lists.xenproject.org; Wed, 15 Apr 2020 01:02:58 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id d85ab3c2-7eb4-11ea-83d8-bc764e2007e4; Wed, 15 Apr 2020 01:02:58 +0000 (UTC) Received: from sstabellini-ThinkPad-T480s.hsd1.ca.comcast.net (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F091B2072D; Wed, 15 Apr 2020 01:02:56 +0000 (UTC) X-Inumbo-ID: d85ab3c2-7eb4-11ea-83d8-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586912577; bh=wF9us2YMoPDg0/9cb4wsozJ6he+zFTvLWGF9kUPj4ls=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vbQLujcor6mYBLEyfu+PJcPRNRQfRbuzqSb6gqx/y3YBZ83w7hiDcrG01Kqxto946 8uTCjm8hjxs+HWqTIZjAdZl0pGfkJZg+OSZtUnFe4yz9g+ZTNK5cuubIPqzgrvhuak 2O+fQ7NMYANdRnN2k8zzdJOMYuJMG+5/4YPYfKgQ= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Subject: [PATCH 01/12] xen: introduce xen_dom_flags Date: Tue, 14 Apr 2020 18:02:44 -0700 Message-Id: <20200415010255.10081-1-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: sstabellini@kernel.org, julien@xen.org, Wei Liu , George Dunlap , andrew.cooper3@citrix.com, Ian Jackson , Dario Faggioli , jbeulich@suse.com, Stefano Stabellini , Volodymyr_Babchuk@epam.com, =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) We are passing an extra special boolean flag at domain creation to specify whether we want to the domain to be privileged (i.e. dom0) or not. Another flag will be introduced later in this series. Introduce a new struct xen_dom_flags and move the privileged flag to it. Other flags will be added to struct xen_dom_flags. Signed-off-by: Stefano Stabellini CC: andrew.cooper3@citrix.com CC: jbeulich@suse.com CC: George Dunlap CC: Ian Jackson CC: Wei Liu CC: "Roger Pau Monn=C3=A9" CC: George Dunlap CC: Dario Faggioli --- xen/arch/arm/domain.c | 3 ++- xen/arch/arm/domain_build.c | 3 ++- xen/arch/arm/setup.c | 3 ++- xen/arch/x86/domain.c | 3 ++- xen/arch/x86/setup.c | 3 ++- xen/common/domain.c | 13 +++++++------ xen/common/domctl.c | 3 ++- xen/common/sched/core.c | 3 ++- xen/include/xen/domain.h | 7 ++++++- xen/include/xen/sched.h | 2 +- 10 files changed, 28 insertions(+), 15 deletions(-) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 6627be2922..b906a38b6b 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -669,7 +669,8 @@ int arch_sanitise_domain_config(struct xen_domctl_creat= edomain *config) } =20 int arch_domain_create(struct domain *d, - struct xen_domctl_createdomain *config) + struct xen_domctl_createdomain *config, + struct xen_dom_flags *flags) { int rc, count =3D 0; =20 diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 4307087536..20e62a9fc4 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -2467,6 +2467,7 @@ void __init create_domUs(void) .max_grant_frames =3D 64, .max_maptrack_frames =3D 1024, }; + struct xen_dom_flags flags =3D { false }; =20 if ( !dt_device_is_compatible(node, "xen,domain") ) continue; @@ -2491,7 +2492,7 @@ void __init create_domUs(void) GUEST_VPL011_SPI - 32 + 1); } =20 - d =3D domain_create(++max_init_domid, &d_cfg, false); + d =3D domain_create(++max_init_domid, &d_cfg, &flags); if ( IS_ERR(d) ) panic("Error creating domain %s\n", dt_node_name(node)); =20 diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 7968cee47d..9ccb3f7385 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -787,6 +787,7 @@ void __init start_xen(unsigned long boot_phys_offset, .max_maptrack_frames =3D -1, }; int rc; + struct xen_dom_flags flags =3D { true }; =20 dcache_line_bytes =3D read_dcache_line_bytes(); =20 @@ -955,7 +956,7 @@ void __init start_xen(unsigned long boot_phys_offset, if ( iommu_enabled ) dom0_cfg.flags |=3D XEN_DOMCTL_CDF_iommu; =20 - dom0 =3D domain_create(0, &dom0_cfg, true); + dom0 =3D domain_create(0, &dom0_cfg, &flags); if ( IS_ERR(dom0) || (alloc_dom0_vcpu0(dom0) =3D=3D NULL) ) panic("Error creating domain 0\n"); =20 diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index a008d7df1c..b92776f824 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -529,7 +529,8 @@ static bool emulation_flags_ok(const struct domain *d, = uint32_t emflags) } =20 int arch_domain_create(struct domain *d, - struct xen_domctl_createdomain *config) + struct xen_domctl_createdomain *config, + struct xen_dom_flags *flags) { bool paging_initialised =3D false; uint32_t emflags; diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 885919d5c3..e61114858b 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -706,6 +706,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) .max_maptrack_frames =3D -1, }; const char *hypervisor_name; + struct xen_dom_flags flags =3D { !pv_shim }; =20 /* Critical region without IDT or TSS. Any fault is deadly! */ =20 @@ -1761,7 +1762,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) dom0_cfg.flags |=3D XEN_DOMCTL_CDF_iommu; =20 /* Create initial domain 0. */ - dom0 =3D domain_create(get_initial_domain_id(), &dom0_cfg, !pv_shim); + dom0 =3D domain_create(get_initial_domain_id(), &dom0_cfg, &flags); if ( IS_ERR(dom0) || (alloc_dom0_vcpu0(dom0) =3D=3D NULL) ) panic("Error creating domain 0\n"); =20 diff --git a/xen/common/domain.c b/xen/common/domain.c index 3dcd73f67c..dd53475cc3 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -341,7 +341,7 @@ static int sanitise_domain_config(struct xen_domctl_cre= atedomain *config) =20 struct domain *domain_create(domid_t domid, struct xen_domctl_createdomain *config, - bool is_priv) + struct xen_dom_flags *flags) { struct domain *d, **pd, *old_hwdom =3D NULL; enum { INIT_watchdog =3D 1u<<1, @@ -363,7 +363,7 @@ struct domain *domain_create(domid_t domid, ASSERT(is_system_domain(d) ? config =3D=3D NULL : config !=3D NULL); =20 /* Sort out our idea of is_control_domain(). */ - d->is_privileged =3D is_priv; + d->is_privileged =3D flags ? flags->is_priv : false; =20 /* Sort out our idea of is_hardware_domain(). */ if ( domid =3D=3D 0 || domid =3D=3D hardware_domid ) @@ -443,7 +443,7 @@ struct domain *domain_create(domid_t domid, radix_tree_init(&d->pirq_tree); } =20 - if ( (err =3D arch_domain_create(d, config)) !=3D 0 ) + if ( (err =3D arch_domain_create(d, config, flags)) !=3D 0 ) goto fail; init_status |=3D INIT_arch; =20 @@ -547,6 +547,7 @@ struct domain *domain_create(domid_t domid, =20 void __init setup_system_domains(void) { + struct xen_dom_flags flags =3D { false }; /* * Initialise our DOMID_XEN domain. * Any Xen-heap pages that we will allow to be mapped will have @@ -554,7 +555,7 @@ void __init setup_system_domains(void) * Hidden PCI devices will also be associated with this domain * (but be [partly] controlled by Dom0 nevertheless). */ - dom_xen =3D domain_create(DOMID_XEN, NULL, false); + dom_xen =3D domain_create(DOMID_XEN, NULL, &flags); if ( IS_ERR(dom_xen) ) panic("Failed to create d[XEN]: %ld\n", PTR_ERR(dom_xen)); =20 @@ -564,7 +565,7 @@ void __init setup_system_domains(void) * array. Mappings occur at the priv of the caller. * Quarantined PCI devices will be associated with this domain. */ - dom_io =3D domain_create(DOMID_IO, NULL, false); + dom_io =3D domain_create(DOMID_IO, NULL, &flags); if ( IS_ERR(dom_io) ) panic("Failed to create d[IO]: %ld\n", PTR_ERR(dom_io)); =20 @@ -573,7 +574,7 @@ void __init setup_system_domains(void) * Initialise our COW domain. * This domain owns sharable pages. */ - dom_cow =3D domain_create(DOMID_COW, NULL, false); + dom_cow =3D domain_create(DOMID_COW, NULL, &flags); if ( IS_ERR(dom_cow) ) panic("Failed to create d[COW]: %ld\n", PTR_ERR(dom_cow)); #endif diff --git a/xen/common/domctl.c b/xen/common/domctl.c index a69b3b59a8..cb8d25500a 100644 --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -364,6 +364,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_d= omctl) bool_t copyback =3D 0; struct xen_domctl curop, *op =3D &curop; struct domain *d; + struct xen_dom_flags flags =3D{ false }; =20 if ( copy_from_guest(op, u_domctl, 1) ) return -EFAULT; @@ -515,7 +516,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_d= omctl) rover =3D dom; } =20 - d =3D domain_create(dom, &op->u.createdomain, false); + d =3D domain_create(dom, &op->u.createdomain, &flags); if ( IS_ERR(d) ) { ret =3D PTR_ERR(d); diff --git a/xen/common/sched/core.c b/xen/common/sched/core.c index 626861a3fe..6457c71ce1 100644 --- a/xen/common/sched/core.c +++ b/xen/common/sched/core.c @@ -2888,6 +2888,7 @@ void __init scheduler_init(void) { struct domain *idle_domain; int i; + struct xen_dom_flags flags =3D { false }; =20 scheduler_enable(); =20 @@ -2957,7 +2958,7 @@ void __init scheduler_init(void) sched_ratelimit_us =3D SCHED_DEFAULT_RATELIMIT_US; } =20 - idle_domain =3D domain_create(DOMID_IDLE, NULL, false); + idle_domain =3D domain_create(DOMID_IDLE, NULL, &flags); BUG_ON(IS_ERR(idle_domain)); BUG_ON(nr_cpu_ids > ARRAY_SIZE(idle_vcpu)); idle_domain->vcpu =3D idle_vcpu; diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h index 7e51d361de..4423e34500 100644 --- a/xen/include/xen/domain.h +++ b/xen/include/xen/domain.h @@ -63,8 +63,13 @@ void arch_vcpu_destroy(struct vcpu *v); int map_vcpu_info(struct vcpu *v, unsigned long gfn, unsigned offset); void unmap_vcpu_info(struct vcpu *v); =20 +struct xen_dom_flags { + bool is_priv; +}; + int arch_domain_create(struct domain *d, - struct xen_domctl_createdomain *config); + struct xen_domctl_createdomain *config, + struct xen_dom_flags *flags); =20 void arch_domain_destroy(struct domain *d); =20 diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 195e7ee583..4112f1ffc9 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -594,7 +594,7 @@ int arch_sanitise_domain_config(struct xen_domctl_creat= edomain *config); */ struct domain *domain_create(domid_t domid, struct xen_domctl_createdomain *config, - bool is_priv); + struct xen_dom_flags *flags); =20 /* * rcu_lock_domain_by_id() is more efficient than get_domain_by_id(). --=20 2.17.1 From nobody Thu May 9 00:26:20 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1586912600; cv=none; d=zohomail.com; s=zohoarc; b=HHghwfIxeWaKY36Cs9QbdrFJFTkVqD2pvuuTidrwfcPhDoosQ6Sjh6i2oNskfsT86+wf1EQMRoRD1dbIrx2+tJdStlLugPLsFpljq3++gTwfk6xdkQUyAcPLlfZx6dLQ9IWz5EDGVgccLKZD2goLcTWpA2LzoIdvBWGsycSRQzc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586912600; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BF3yEJ1/SgtM7Kzw/1MGVSJ4AVLBhK4e96hjF0z5ZDI=; b=Gi/N9cFYpE546cDUfdRQ9sf/VTQwfBPjf8Ts0LTrfmmLlphWo+xNBM9U60rDox05tdQv4RdCX+R0QvDlQhQ0MfixgSoJ2FTlUZxl4bh3pJ6XjtshZOwxKLP+p5fRkKIMc4VGeTOEjvBWdFbaLuQZwnGrhyX0Fs7E+Hs5HzzB5mU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=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 1586912600425159.5363352867804; Tue, 14 Apr 2020 18:03:20 -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 1jOWSF-0001Cy-UQ; Wed, 15 Apr 2020 01:03:03 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jOWSF-0001Cn-En for xen-devel@lists.xenproject.org; Wed, 15 Apr 2020 01:03:03 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id d8bd8db2-7eb4-11ea-83d8-bc764e2007e4; Wed, 15 Apr 2020 01:02:58 +0000 (UTC) Received: from sstabellini-ThinkPad-T480s.hsd1.ca.comcast.net (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BD1A320774; Wed, 15 Apr 2020 01:02:57 +0000 (UTC) X-Inumbo-ID: d8bd8db2-7eb4-11ea-83d8-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586912578; bh=o7ggJLBOOkXOXw9bb9MmuF9lECpxcldnKeYW5Qgwn6A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D9YZe7/B+m7worXC3EBZu5bVhXwDQiuOE6IJ326Nk1HGMg1iw7B3cIxEd3//nx9Jv JSQBlpy9F9ZWEcPIvsp3U64X/H5fbLJGXzdAv2n2AZmhWaw19whIXdSADoH0BgZsKB fe/1q/a4nO67fAmrt2kHj/86wQSLpsP01CIeWtHQ= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Subject: [PATCH 02/12] xen/arm: introduce arch_xen_dom_flags and direct_map Date: Tue, 14 Apr 2020 18:02:45 -0700 Message-Id: <20200415010255.10081-2-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: sstabellini@kernel.org, julien@xen.org, Wei Liu , George Dunlap , andrew.cooper3@citrix.com, Ian Jackson , jbeulich@suse.com, Stefano Stabellini , Volodymyr_Babchuk@epam.com, =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Introduce a new field in struct xen_dom_flags to store arch-specific flags. Add an ARM-specific flag to specify that the domain should be directly mapped (guest physical addresses =3D=3D physical addresses). Also, add a direct_map flag under struct arch_domain and use it to implement is_domain_direct_mapped. Signed-off-by: Stefano Stabellini CC: andrew.cooper3@citrix.com CC: jbeulich@suse.com CC: George Dunlap CC: Ian Jackson CC: Wei Liu CC: "Roger Pau Monn=C3=A9" Acked-by: Jan Beulich --- xen/arch/arm/domain.c | 1 + xen/arch/arm/domain_build.c | 1 + xen/arch/arm/setup.c | 2 +- xen/include/asm-arm/domain.h | 9 ++++++++- xen/include/asm-x86/domain.h | 2 ++ xen/include/xen/domain.h | 1 + 6 files changed, 14 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index b906a38b6b..59eae36de7 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -682,6 +682,7 @@ int arch_domain_create(struct domain *d, return 0; =20 ASSERT(config !=3D NULL); + d->arch.direct_map =3D flags !=3D NULL ? flags->arch.is_direct_map : f= alse; =20 /* p2m_init relies on some value initialized by the IOMMU subsystem */ if ( (rc =3D iommu_domain_init(d, config->iommu_opts)) !=3D 0 ) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 20e62a9fc4..2ec7453aa3 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -2527,6 +2527,7 @@ int __init construct_dom0(struct domain *d) =20 iommu_hwdom_init(d); =20 + d->arch.direct_map =3D true; d->max_pages =3D ~0U; =20 kinfo.unassigned_mem =3D dom0_mem; diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 9ccb3f7385..5434548e7b 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -787,7 +787,7 @@ void __init start_xen(unsigned long boot_phys_offset, .max_maptrack_frames =3D -1, }; int rc; - struct xen_dom_flags flags =3D { true }; + struct xen_dom_flags flags =3D { true, .arch.is_direct_map =3D true }; =20 dcache_line_bytes =3D read_dcache_line_bytes(); =20 diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h index d39477a939..7a498921bf 100644 --- a/xen/include/asm-arm/domain.h +++ b/xen/include/asm-arm/domain.h @@ -32,7 +32,7 @@ enum domain_type { #endif =20 /* The hardware domain has always its memory direct mapped. */ -#define is_domain_direct_mapped(d) ((d) =3D=3D hardware_domain) +#define is_domain_direct_mapped(d) ((d)->arch.direct_map !=3D false) =20 struct vtimer { struct vcpu *v; @@ -98,8 +98,15 @@ struct arch_domain #ifdef CONFIG_TEE void *tee; #endif + + bool direct_map; } __cacheline_aligned; =20 +struct arch_xen_dom_flags +{ + bool is_direct_map; +}; + struct arch_vcpu { struct { diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h index 105adf96eb..52199ed5b9 100644 --- a/xen/include/asm-x86/domain.h +++ b/xen/include/asm-x86/domain.h @@ -418,6 +418,8 @@ struct arch_domain uint32_t emulation_flags; } __cacheline_aligned; =20 +struct arch_xen_dom_flags {}; + #ifdef CONFIG_HVM #define X86_EMU_LAPIC XEN_X86_EMU_LAPIC #define X86_EMU_HPET XEN_X86_EMU_HPET diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h index 4423e34500..7227e6ca98 100644 --- a/xen/include/xen/domain.h +++ b/xen/include/xen/domain.h @@ -65,6 +65,7 @@ void unmap_vcpu_info(struct vcpu *v); =20 struct xen_dom_flags { bool is_priv; + struct arch_xen_dom_flags arch; }; =20 int arch_domain_create(struct domain *d, --=20 2.17.1 From nobody Thu May 9 00:26:20 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1586912598; cv=none; d=zohomail.com; s=zohoarc; b=gELmHxqx23qPrvE6ByY18azlVbQvU0M2xs4jS1P+vKW03ep/xGr7JDxmjZ82QT/0zEqJxFDceH4G8V9tsUSn2becYq/Eb0OD6xTs/BmKRgqDsC/Y2Gj1IsiVxxmfCS3lCHHH1OHQJLejn++Dk6aD3Y+T4yzRZS28UJS+oA/NScU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586912598; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=cE9op642K1RGpnMpBZIKjoRpOnVewkvFx/LhGCmLQ7k=; b=ZVa+QBpC99Mdyntuw8jUgjp7E59NbmYwPhAfe9nn9UMG3jHfTQ5UiJnjUGYwagbKw8z/4/va0Td2H4R90GyHUthwXGrRFqGkd8/nqjhNswqkgttOOjJttrqr6eg8j1RN+UBRDBVspjq38PXPN2ro3VyBOhFWrxzulTLfWZQh6Ts= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=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 158691259836548.727660322728184; Tue, 14 Apr 2020 18:03:18 -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 1jOWSD-0001C7-Ix; Wed, 15 Apr 2020 01: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 1jOWSC-0001BW-7z for xen-devel@lists.xenproject.org; Wed, 15 Apr 2020 01:03:00 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id d8674d46-7eb4-11ea-89ec-12813bfff9fa; Wed, 15 Apr 2020 01:02:59 +0000 (UTC) Received: from sstabellini-ThinkPad-T480s.hsd1.ca.comcast.net (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 506B120787; Wed, 15 Apr 2020 01:02:58 +0000 (UTC) X-Inumbo-ID: d8674d46-7eb4-11ea-89ec-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586912578; bh=YfCOD/krweRwr+m0KM00qRltE3yb4U9K6JqnMq8B/LA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E6vlUiEQIJ8wbywo5ASO6NY0rjUvrS4xDtaM0szQDkyAZAx1CeKpyZBSFVpufidIc w93SVAifJ3BXdbNHJpx+JdfNMCa9x8hvD+OHgRcKqegjg+eljNO3jJBNr7lPui8BK6 LVVYKX7JoKEXYMwBrXVD66ZCMf6ZxlR2ECZvIeGs= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Subject: [PATCH 03/12] xen/arm: introduce 1:1 mapping for domUs Date: Tue, 14 Apr 2020 18:02:46 -0700 Message-Id: <20200415010255.10081-3-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: 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: Volodymyr_Babchuk@epam.com, sstabellini@kernel.org, julien@xen.org, Stefano Stabellini Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In some cases it is desirable to map domU memory 1:1 (guest physical =3D=3D physical.) For instance, because we want to assign a device to the domU but the IOMMU is not present or cannot be used. In these cases, other mechanisms should be used for DMA protection, e.g. a MPU. This patch introduces a new device tree option for dom0less guests to request a domain to be directly mapped. It also specifies the memory ranges. This patch documents the new attribute and parses it at boot time. (However, the implementation of 1:1 mapping is missing and just BUG() out at the moment.) Finally the patch sets the new direct_map flag for DomU domains. Signed-off-by: Stefano Stabellini --- docs/misc/arm/device-tree/booting.txt | 13 +++++++ docs/misc/arm/passthrough-noiommu.txt | 35 ++++++++++++++++++ xen/arch/arm/domain_build.c | 52 +++++++++++++++++++++++++-- 3 files changed, 98 insertions(+), 2 deletions(-) create mode 100644 docs/misc/arm/passthrough-noiommu.txt diff --git a/docs/misc/arm/device-tree/booting.txt b/docs/misc/arm/device-t= ree/booting.txt index 5243bc7fd3..fce5f7ed5a 100644 --- a/docs/misc/arm/device-tree/booting.txt +++ b/docs/misc/arm/device-tree/booting.txt @@ -159,6 +159,19 @@ with the following properties: used, or GUEST_VPL011_SPI+1 if vpl011 is enabled, whichever is greater. =20 +- direct-map + + Optional. An array of integer pairs specifying addresses and sizes. + direct_map requests the memory of the domain to be 1:1 mapped with + the memory ranges specified as argument. Only sizes that are a + power of two number of pages are allowed. + +- #direct-map-addr-cells and #direct-map-size-cells + + The number of cells to use for the addresses and for the sizes in + direct-map. Default and maximum are 2 cells for both addresses and + sizes. + - #address-cells and #size-cells =20 Both #address-cells and #size-cells need to be specified because diff --git a/docs/misc/arm/passthrough-noiommu.txt b/docs/misc/arm/passthro= ugh-noiommu.txt new file mode 100644 index 0000000000..d2bfaf26c3 --- /dev/null +++ b/docs/misc/arm/passthrough-noiommu.txt @@ -0,0 +1,35 @@ +Request Device Assignment without IOMMU support +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Add xen,force-assign-without-iommu; to the device tree snippet + + ethernet: ethernet@ff0e0000 { + compatible =3D "cdns,zynqmp-gem"; + xen,path =3D "/amba/ethernet@ff0e0000"; + xen,reg =3D <0x0 0xff0e0000 0x1000 0x0 0xff0e0000>; + xen,force-assign-without-iommu; + +Optionally, if none of the domains require an IOMMU, then it could be +disabled (not recommended). For instance by adding status =3D "disabled"; +under the smmu node: + + smmu@fd800000 { + compatible =3D "arm,mmu-500"; + status =3D "disabled"; + + +Request 1:1 memory mapping for the dom0-less domain +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D + +Add a direct-map property under the appropriate /chosen/domU node with +the memory ranges you want to assign to your domain. If you are using +imagebuilder, you can add to boot.source something like the following: + + fdt set /chosen/domU0 direct-map <0x0 0x10000000 0x0 0x10000000 0x0 0x= 60000000 0x0 0x10000000> + +Which will assign the ranges: + + 0x10000000 - 0x20000000 + 0x60000000 - 0x70000000 + +to the first dom0less domU. diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 2ec7453aa3..a2bb411568 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -2435,7 +2435,51 @@ static int __init construct_domU(struct domain *d, /* type must be set before allocate memory */ d->arch.type =3D kinfo.type; #endif - allocate_memory(d, &kinfo); + + if ( !is_domain_direct_mapped(d) ) + allocate_memory(d, &kinfo); + else + { + struct membank banks[NR_MEM_BANKS]; + const struct dt_property *prop; + u32 direct_map_len, direct_map_addr_len =3D 2, direct_map_size_len= =3D 2; + unsigned int i; + __be32 *p; + + prop =3D dt_find_property(node, "direct-map", &direct_map_len); + BUG_ON(!prop); + + dt_property_read_u32(node, + "#direct-map-addr-cells", + &direct_map_addr_len); + dt_property_read_u32(node, + "#direct-map-size-cells", + &direct_map_size_len); + BUG_ON(direct_map_size_len > 2 || direct_map_addr_len > 2); + + for ( i =3D 0, p =3D prop->value; + i < direct_map_len / + (4 * (direct_map_addr_len + direct_map_size_len)); + i++) + { + int j; + + banks[i].start =3D 0; + for ( j =3D 0; j < direct_map_addr_len; j++, p++ ) + banks[i].start |=3D __be32_to_cpu(*p) << (32*j); + + banks[i].size =3D 0; + for ( j =3D 0; j < direct_map_size_len; j++, p++ ) + banks[i].size |=3D __be32_to_cpu(*p) << (32*j); + + printk(XENLOG_DEBUG + "direct_map start=3D%#"PRIpaddr" size=3D%#"PRIpaddr"\n", + banks[i].start, banks[i].size); + } + + /* reserve_memory_11(d, &kinfo, &banks[0], i); */ + BUG(); + } =20 rc =3D prepare_dtb_domU(d, &kinfo); if ( rc < 0 ) @@ -2455,6 +2499,7 @@ void __init create_domUs(void) { struct dt_device_node *node; const struct dt_device_node *chosen =3D dt_find_node_by_path("/chosen"= ); + u32 direct_map =3D 0; =20 BUG_ON(chosen =3D=3D NULL); dt_for_each_child_node(chosen, node) @@ -2476,8 +2521,11 @@ void __init create_domUs(void) panic("Missing property 'cpus' for domain %s\n", dt_node_name(node)); =20 - if ( dt_find_compatible_node(node, NULL, "multiboot,device-tree") ) + dt_find_property(node, "direct-map", &direct_map); + if ( dt_find_compatible_node(node, NULL, "multiboot,device-tree") = && + !direct_map ) d_cfg.flags |=3D XEN_DOMCTL_CDF_iommu; + flags.arch.is_direct_map =3D direct_map !=3D 0; =20 if ( !dt_property_read_u32(node, "nr_spis", &d_cfg.arch.nr_spis) ) { --=20 2.17.1 From nobody Thu May 9 00:26:20 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1586912608; cv=none; d=zohomail.com; s=zohoarc; b=i0rZjtuKwQTp6Nyeh6WXB7wNaZI9ymZMQg49Jhykfso/GQ/tLg2Tg22qwUeh98Gok8A/6bKzSFPBtIkiXoyQfrc6EpjGUd3wIRU4jiU4jjxAAcHAdcYidNv+vI6oDWSbchA89zQGhimlTTynt+aAZgXbIbiI8AqMOkIgvf2TwEw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586912608; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=BO1SkeFZDwQid1DnYnNWIGoRYAWPjcQagFivRN0W8rw=; b=UwL2yHbXnrp2HC77Ll3wllltnZWwBPyn6v/MRt4ybX2qNBnPmZWzYJhSJCRfS0cNl0BIlCRsZrJHE64wrMhy6mmVZuTl3m5bClSaIm5oQsU9jp8LehWFhGKK0k9WXH6uVHLIrJY7s7dQWjoYj/c6DKlYrkFLg7Cd2CCjAGlQTi8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=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 1586912608876180.0278278850783; Tue, 14 Apr 2020 18:03:28 -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 1jOWSL-0001Ft-Qw; Wed, 15 Apr 2020 01:03:09 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jOWSK-0001FQ-FS for xen-devel@lists.xenproject.org; Wed, 15 Apr 2020 01:03:08 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id d93f8b0a-7eb4-11ea-b4f4-bc764e2007e4; Wed, 15 Apr 2020 01:02:59 +0000 (UTC) Received: from sstabellini-ThinkPad-T480s.hsd1.ca.comcast.net (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A5AD72083B; Wed, 15 Apr 2020 01:02:58 +0000 (UTC) X-Inumbo-ID: d93f8b0a-7eb4-11ea-b4f4-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586912579; bh=YV7d8M1BR8baRsXNvbLsTI5FkEiel89KL9GK6xJVhRk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xea7/ciO1nz2/OVyRSuWlcKWtX9VHsqi0YcK0pKXrNW3WohMbZp62cZvsAySHk6lC lmVpXdQLoNORTEVTgpatQy3ZqT1yG4D0fHlow0JPbSIfdpBzChQhsDQEuzplpYEUMS eqaojGPaKVpVoUE8Nmsb9xPuEFXHcMdPUfuDpWWo= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Subject: [PATCH 04/12] xen: split alloc_heap_pages in two halves for reusability Date: Tue, 14 Apr 2020 18:02:47 -0700 Message-Id: <20200415010255.10081-4-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: 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: sstabellini@kernel.org, julien@xen.org, Wei Liu , andrew.cooper3@citrix.com, Ian Jackson , George Dunlap , jbeulich@suse.com, Stefano Stabellini , Volodymyr_Babchuk@epam.com Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This patch splits the implementation of alloc_heap_pages into two halves so that the second half can be reused by the next patch. Signed-off-by: Stefano Stabellini CC: andrew.cooper3@citrix.com CC: jbeulich@suse.com CC: George Dunlap CC: Ian Jackson CC: Wei Liu --- Comments are welcome. I am not convinced that this is the right way to split it. Please let me know if you have any suggestions. --- xen/common/page_alloc.c | 94 +++++++++++++++++++++++------------------ 1 file changed, 53 insertions(+), 41 deletions(-) diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 10b7aeca48..79ae64d4b8 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -911,54 +911,18 @@ static struct page_info *get_free_buddy(unsigned int = zone_lo, } } =20 -/* Allocate 2^@order contiguous pages. */ -static struct page_info *alloc_heap_pages( - unsigned int zone_lo, unsigned int zone_hi, - unsigned int order, unsigned int memflags, - struct domain *d) +static void __alloc_heap_pages(struct page_info **pgo, + unsigned int order, + unsigned int memflags, + struct domain *d) { nodeid_t node; unsigned int i, buddy_order, zone, first_dirty; unsigned long request =3D 1UL << order; - struct page_info *pg; bool need_tlbflush =3D false; uint32_t tlbflush_timestamp =3D 0; unsigned int dirty_cnt =3D 0; - - /* Make sure there are enough bits in memflags for nodeID. */ - BUILD_BUG_ON((_MEMF_bits - _MEMF_node) < (8 * sizeof(nodeid_t))); - - ASSERT(zone_lo <=3D zone_hi); - ASSERT(zone_hi < NR_ZONES); - - if ( unlikely(order > MAX_ORDER) ) - return NULL; - - spin_lock(&heap_lock); - - /* - * Claimed memory is considered unavailable unless the request - * is made by a domain with sufficient unclaimed pages. - */ - if ( (outstanding_claims + request > total_avail_pages) && - ((memflags & MEMF_no_refcount) || - !d || d->outstanding_pages < request) ) - { - spin_unlock(&heap_lock); - return NULL; - } - - pg =3D get_free_buddy(zone_lo, zone_hi, order, memflags, d); - /* Try getting a dirty buddy if we couldn't get a clean one. */ - if ( !pg && !(memflags & MEMF_no_scrub) ) - pg =3D get_free_buddy(zone_lo, zone_hi, order, - memflags | MEMF_no_scrub, d); - if ( !pg ) - { - /* No suitable memory blocks. Fail the request. */ - spin_unlock(&heap_lock); - return NULL; - } + struct page_info *pg =3D *pgo; =20 node =3D phys_to_nid(page_to_maddr(pg)); zone =3D page_to_zone(pg); @@ -984,6 +948,7 @@ static struct page_info *alloc_heap_pages( first_dirty =3D 0; /* We've moved past original first_dirt= y */ } } + *pgo =3D pg; =20 ASSERT(avail[node][zone] >=3D request); avail[node][zone] -=3D request; @@ -1062,6 +1027,53 @@ static struct page_info *alloc_heap_pages( if ( need_tlbflush ) filtered_flush_tlb_mask(tlbflush_timestamp); =20 +} + +/* Allocate 2^@order contiguous pages. */ +static struct page_info *alloc_heap_pages( + unsigned int zone_lo, unsigned int zone_hi, + unsigned int order, unsigned int memflags, + struct domain *d) +{ + unsigned long request =3D 1UL << order; + struct page_info *pg; + + /* Make sure there are enough bits in memflags for nodeID. */ + BUILD_BUG_ON((_MEMF_bits - _MEMF_node) < (8 * sizeof(nodeid_t))); + + ASSERT(zone_lo <=3D zone_hi); + ASSERT(zone_hi < NR_ZONES); + + if ( unlikely(order > MAX_ORDER) ) + return NULL; + + spin_lock(&heap_lock); + + /* + * Claimed memory is considered unavailable unless the request + * is made by a domain with sufficient unclaimed pages. + */ + if ( (outstanding_claims + request > total_avail_pages) && + ((memflags & MEMF_no_refcount) || + !d || d->outstanding_pages < request) ) + { + spin_unlock(&heap_lock); + return NULL; + } + + pg =3D get_free_buddy(zone_lo, zone_hi, order, memflags, d); + /* Try getting a dirty buddy if we couldn't get a clean one. */ + if ( !pg && !(memflags & MEMF_no_scrub) ) + pg =3D get_free_buddy(zone_lo, zone_hi, order, + memflags | MEMF_no_scrub, d); + if ( !pg ) + { + /* No suitable memory blocks. Fail the request. */ + spin_unlock(&heap_lock); + return NULL; + } + + __alloc_heap_pages(&pg, order, memflags, d); return pg; } =20 --=20 2.17.1 From nobody Thu May 9 00:26:20 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1586912600; cv=none; d=zohomail.com; s=zohoarc; b=dibqCN96Wi+/V8YyyUdG2Q66r/yHy/LMG8mQxiLXNt3k+Rjzn+ZpPIXQLdeACFgYCI9r2fZHGubkcDPOjyEEhiBw0y/mYnpwQ/Vd4Mav9+1cSTl1vqxvqaHeWziYqWs+dvQp7qsG4e+HgGzwnmmhLmnhpBjj5k8O7wUb9ilmuzY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586912600; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=aGHjCSmjzoKSaAl9oq5AGr4IfUvzRv6stSYYAuHtZDA=; b=fQXUc6mcPIIhuUpQXXPCpij5S7BPLXcl1bnkw9ctoHMSLmo5Z8KJfabr+90IshFFiEki9qn2D1jmMv2PjssC4oxRbZjr/ULhTww4f15G5BERe4bmRyayvDTl5641Ny8vsJKPwX5KIBHHMA81aJ5gGegLfc5PbowAnHfiAdSJ7w0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=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 1586912600027156.025984331754; Tue, 14 Apr 2020 18:03:20 -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 1jOWSI-0001EO-Eb; Wed, 15 Apr 2020 01:03:06 +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 1jOWSH-0001Dc-4a for xen-devel@lists.xenproject.org; Wed, 15 Apr 2020 01:03:05 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id d991c32a-7eb4-11ea-89ec-12813bfff9fa; Wed, 15 Apr 2020 01:03:00 +0000 (UTC) Received: from sstabellini-ThinkPad-T480s.hsd1.ca.comcast.net (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3258D20857; Wed, 15 Apr 2020 01:02:59 +0000 (UTC) X-Inumbo-ID: d991c32a-7eb4-11ea-89ec-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586912579; bh=7207g/eifnxKqKtgIrYV/hVTptHqGaliYQujFgsQjjk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p7wsTRFGJteqpd8bB4jmalT0FlD99CipBIjKuN9ha085Mqo28nY3jZw6t/7AzH4lw Cu05jMJBobNGGrKl3p2GfTcCRu9RtOgGIl30NrGalMa/VYl3xIdn412RaP/Arfr/4S lqRElwR96hQiL3GjuN4fG0uTnCo2agjibJsM74hg= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Subject: [PATCH 05/12] xen: introduce reserve_heap_pages Date: Tue, 14 Apr 2020 18:02:48 -0700 Message-Id: <20200415010255.10081-5-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: 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: sstabellini@kernel.org, julien@xen.org, Wei Liu , andrew.cooper3@citrix.com, Ian Jackson , George Dunlap , jbeulich@suse.com, Stefano Stabellini , Volodymyr_Babchuk@epam.com Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Introduce a function named reserve_heap_pages (similar to alloc_heap_pages) that allocates a requested memory range. Call __alloc_heap_pages for the implementation. Change __alloc_heap_pages so that the original page doesn't get modified, giving back unneeded memory top to bottom rather than bottom to top. Also introduce a function named reserve_domheap_pages, similar to alloc_domheap_pages, that checks memflags before calling reserve_heap_pages. It also assign_pages to the domain on success. Signed-off-by: Stefano Stabellini CC: andrew.cooper3@citrix.com CC: jbeulich@suse.com CC: George Dunlap CC: Ian Jackson CC: Wei Liu --- xen/common/page_alloc.c | 72 ++++++++++++++++++++++++++++++++++++++--- xen/include/xen/mm.h | 2 ++ 2 files changed, 69 insertions(+), 5 deletions(-) diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 79ae64d4b8..3a9c1a291b 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -911,7 +911,7 @@ static struct page_info *get_free_buddy(unsigned int zo= ne_lo, } } =20 -static void __alloc_heap_pages(struct page_info **pgo, +static void __alloc_heap_pages(struct page_info *pg, unsigned int order, unsigned int memflags, struct domain *d) @@ -922,7 +922,7 @@ static void __alloc_heap_pages(struct page_info **pgo, bool need_tlbflush =3D false; uint32_t tlbflush_timestamp =3D 0; unsigned int dirty_cnt =3D 0; - struct page_info *pg =3D *pgo; + struct page_info *pg_start =3D pg; =20 node =3D phys_to_nid(page_to_maddr(pg)); zone =3D page_to_zone(pg); @@ -934,10 +934,10 @@ static void __alloc_heap_pages(struct page_info **pgo, while ( buddy_order !=3D order ) { buddy_order--; + pg =3D pg_start + (1U << buddy_order); page_list_add_scrub(pg, node, zone, buddy_order, (1U << buddy_order) > first_dirty ? first_dirty : INVALID_DIRTY_IDX); - pg +=3D 1U << buddy_order; =20 if ( first_dirty !=3D INVALID_DIRTY_IDX ) { @@ -948,7 +948,7 @@ static void __alloc_heap_pages(struct page_info **pgo, first_dirty =3D 0; /* We've moved past original first_dirt= y */ } } - *pgo =3D pg; + pg =3D pg_start; =20 ASSERT(avail[node][zone] >=3D request); avail[node][zone] -=3D request; @@ -1073,7 +1073,42 @@ static struct page_info *alloc_heap_pages( return NULL; } =20 - __alloc_heap_pages(&pg, order, memflags, d); + __alloc_heap_pages(pg, order, memflags, d); + return pg; +} + +static struct page_info *reserve_heap_pages(struct domain *d, + paddr_t start, + unsigned int order, + unsigned int memflags) +{ + nodeid_t node; + unsigned int zone; + struct page_info *pg; + + if ( unlikely(order > MAX_ORDER) ) + return NULL; + + spin_lock(&heap_lock); + + /* + * Claimed memory is considered unavailable unless the request + * is made by a domain with sufficient unclaimed pages. + */ + if ( (outstanding_claims + (1UL << order) > total_avail_pages) && + ((memflags & MEMF_no_refcount) || + !d || d->outstanding_pages < (1UL << order)) ) + { + spin_unlock(&heap_lock); + return NULL; + } + + pg =3D maddr_to_page(start); + node =3D phys_to_nid(start); + zone =3D page_to_zone(pg); + page_list_del(pg, &heap(node, zone, order)); + + __alloc_heap_pages(pg, order, memflags, d); return pg; } =20 @@ -2385,6 +2420,33 @@ struct page_info *alloc_domheap_pages( return pg; } =20 +struct page_info *reserve_domheap_pages( + struct domain *d, paddr_t start, unsigned int order, unsigned int memf= lags) +{ + struct page_info *pg =3D NULL; + + ASSERT(!in_irq()); + + if ( memflags & MEMF_no_owner ) + memflags |=3D MEMF_no_refcount; + else if ( (memflags & MEMF_no_refcount) && d ) + { + ASSERT(!(memflags & MEMF_no_refcount)); + return NULL; + } + + pg =3D reserve_heap_pages(d, start, order, memflags); + + if ( d && !(memflags & MEMF_no_owner) && + assign_pages(d, pg, order, memflags) ) + { + free_heap_pages(pg, order, memflags & MEMF_no_scrub); + return NULL; + } + + return pg; +} + void free_domheap_pages(struct page_info *pg, unsigned int order) { struct domain *d =3D page_get_owner(pg); diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index 9b62087be1..35407e1b68 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -199,6 +199,8 @@ void get_outstanding_claims(uint64_t *free_pages, uint6= 4_t *outstanding_pages); void init_domheap_pages(paddr_t ps, paddr_t pe); struct page_info *alloc_domheap_pages( struct domain *d, unsigned int order, unsigned int memflags); +struct page_info *reserve_domheap_pages( + struct domain *d, paddr_t start, unsigned int order, unsigned int memf= lags); void free_domheap_pages(struct page_info *pg, unsigned int order); unsigned long avail_domheap_pages_region( unsigned int node, unsigned int min_width, unsigned int max_width); --=20 2.17.1 From nobody Thu May 9 00:26:20 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1586912612; cv=none; d=zohomail.com; s=zohoarc; b=Ujh8jUYb21sxJ7wE1YzjoYDY/G3nKWy3xxXUqO1jYOrR6Ce5RR5h3LYB5NUqar4K8ni3SdACgQs8vi19fuTjv6xV3idHSzo00CVAH8XWaaYjCOSIY7k/63q1cmFiDbTsxoRDlOtbQ8CkE8mmlH+tvdLRfsiBf2UuIhXNPnWR5Ig= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586912612; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=3pPQiJE62VYjtW96fZIE5jk5OJwoBu/QYIByVOQy0Qs=; b=Lglm8pqdpguz+g1cREQvxkNbfrGnrt5MRLmd5i+/bvZWUsUK8tUCyk+XNPH0cruwO6bE2lF4hhANYAIGcWWOfWHe6Knii8cJ9p9/HxOokz8SftigENtw6cHT+BgBFs27MGClBw0wyQKS76DR9w/Zn5OuxBxeHACUY33mCJ0GyyU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=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 1586912612136784.0371698342208; Tue, 14 Apr 2020 18:03:32 -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 1jOWSQ-0001Iz-Jo; Wed, 15 Apr 2020 01:03:14 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jOWSP-0001IG-Fr for xen-devel@lists.xenproject.org; Wed, 15 Apr 2020 01:03:13 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id d9c69c80-7eb4-11ea-b58d-bc764e2007e4; Wed, 15 Apr 2020 01:03:00 +0000 (UTC) Received: from sstabellini-ThinkPad-T480s.hsd1.ca.comcast.net (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B0CA32076C; Wed, 15 Apr 2020 01:02:59 +0000 (UTC) X-Inumbo-ID: d9c69c80-7eb4-11ea-b58d-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586912579; bh=FMlXcRXt/zCRQA/cD6Iv2GQCYoMd2JYd4wrOKCkm6KU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zly7T+H4CPDzIclXBWdJhaKJ541truZ27Mnbq0DENiut9D0fbBRJcs3piPJzKhm0f lhBfbBVfvIaUkKWXz8UPA0jz7641V9MPQEE3ITAyQvRV0g62rqkkwlYtHBu+NPfDc5 wp2KmgdxUCWPRgXVf9Qbjt61XWE0cXCauoVHp4Yo= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Subject: [PATCH 06/12] xen/arm: reserve 1:1 memory for direct_map domUs Date: Tue, 14 Apr 2020 18:02:49 -0700 Message-Id: <20200415010255.10081-6-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: 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: Volodymyr_Babchuk@epam.com, sstabellini@kernel.org, julien@xen.org, Stefano Stabellini Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Use reserve_domheap_pages to implement the direct-map ranges allocation for DomUs. Signed-off-by: Stefano Stabellini --- xen/arch/arm/domain_build.c | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index a2bb411568..627e0c5e8e 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -198,6 +198,40 @@ fail: return false; } =20 +static void __init reserve_memory_11(struct domain *d, + struct kernel_info *kinfo, + struct membank *banks, + unsigned int nr_banks) +{ + unsigned int i, order; + struct page_info *pg; + =20 + kinfo->mem.nr_banks =3D 0; + + for ( i =3D 0; i < nr_banks; i++ ) + { + order =3D get_order_from_bytes(banks[i].size); + pg =3D reserve_domheap_pages(d, banks[i].start, order, 0); + if ( pg =3D=3D NULL || !insert_11_bank(d, kinfo, pg, order) ) + { + printk(XENLOG_ERR + "%pd: cannot reserve memory start=3D%#"PRIpaddr" size= =3D%#"PRIpaddr"\n", + d, banks[i].start, banks[i].size); + BUG(); + } + } + + for( i =3D 0; i < kinfo->mem.nr_banks; i++ ) + { + printk("BANK[%d] %#"PRIpaddr"-%#"PRIpaddr" (%ldMB)\n", + i, + kinfo->mem.bank[i].start, + kinfo->mem.bank[i].start + kinfo->mem.bank[i].size, + /* Don't want format this as PRIpaddr (16 digit hex) */ + (unsigned long)(kinfo->mem.bank[i].size >> 20)); + } +} + /* * This is all pretty horrible. * @@ -2477,8 +2511,7 @@ static int __init construct_domU(struct domain *d, banks[i].start, banks[i].size); } =20 - /* reserve_memory_11(d, &kinfo, &banks[0], i); */ - BUG(); + reserve_memory_11(d, &kinfo, &banks[0], i); } =20 rc =3D prepare_dtb_domU(d, &kinfo); --=20 2.17.1 From nobody Thu May 9 00:26:20 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1586912604; cv=none; d=zohomail.com; s=zohoarc; b=NhoaD1TzXZg17Zr/mEXwIISyLfrlRDCTxa4mQKnJLJS/CC3/GIec6JYrbUQKofncSpI6zdaVHQNZXt1m63ibhZu4z7a96YPBPwjVD0EVNvsVv6cHsePz62LFTNyT0jsyys72AfzcYl1j70wMfMowIeYEw5FjVGFNBdnOz3q1OlA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586912604; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=/h7OjtdDtDFk8NI9iw83QKRYZ1sMBL8Z1C991RCuZ/E=; b=SMHsqOj8NAtvrdXP0NB1KkNbbF7Cc0ATc9mfmSB4vBztEV93VCqxZ7iVpyMJCcf9iNvb7KO1X/8mingIh9KrHgqZ270GM2HHImR+yXnOdEGlPax8TDjVlCefWzwEu1UofxpeWFPz30EoQCIeJINWWdIbofQLqAoDdMwDmTzsuC8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=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 1586912604517145.30161021010963; Tue, 14 Apr 2020 18:03:24 -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 1jOWSN-0001Gp-66; Wed, 15 Apr 2020 01:03:11 +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 1jOWSM-0001GC-4U for xen-devel@lists.xenproject.org; Wed, 15 Apr 2020 01:03:10 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id d991c32b-7eb4-11ea-89ec-12813bfff9fa; Wed, 15 Apr 2020 01:03:00 +0000 (UTC) Received: from sstabellini-ThinkPad-T480s.hsd1.ca.comcast.net (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 157EB2087E; Wed, 15 Apr 2020 01:03:00 +0000 (UTC) X-Inumbo-ID: d991c32b-7eb4-11ea-89ec-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586912580; bh=NlKdqK0InViPQ1RlBoqs8f8gr+feCFyOn6w13VpIxiU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XLqpvddxuHUSAvmG2krEq5LBfd6lPKYtV9Fjg9poRf3URL45tHF+2LTpMVubFqoea BgTHu6IWfipWrmlF6wKpEJC5LQcpX8UWmpVD/S4/52YdNPBsoj+cGzy+5PpUXcQJVw D16m5BdA959RRubXCDUuesoSlP/YdayR7pl63MV0= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Subject: [PATCH 07/12] xen/arm: new vgic: rename vgic_cpu/dist_base to c/dbase Date: Tue, 14 Apr 2020 18:02:50 -0700 Message-Id: <20200415010255.10081-7-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: 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: Volodymyr_Babchuk@epam.com, sstabellini@kernel.org, julien@xen.org, Stefano Stabellini Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" To be uniform with the old vgic. Name uniformity will become immediately useful in the following patch. In vgic_v2_map_resources, use the fields in struct vgic_dist rather than local variables. Signed-off-by: Stefano Stabellini --- xen/arch/arm/vgic/vgic-init.c | 4 ++-- xen/arch/arm/vgic/vgic-v2.c | 16 ++++++++-------- xen/include/asm-arm/new_vgic.h | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/xen/arch/arm/vgic/vgic-init.c b/xen/arch/arm/vgic/vgic-init.c index 62ae553699..ea739d081e 100644 --- a/xen/arch/arm/vgic/vgic-init.c +++ b/xen/arch/arm/vgic/vgic-init.c @@ -112,8 +112,8 @@ int domain_vgic_register(struct domain *d, int *mmio_co= unt) BUG(); } =20 - d->arch.vgic.vgic_dist_base =3D VGIC_ADDR_UNDEF; - d->arch.vgic.vgic_cpu_base =3D VGIC_ADDR_UNDEF; + d->arch.vgic.dbase =3D VGIC_ADDR_UNDEF; + d->arch.vgic.cbase =3D VGIC_ADDR_UNDEF; d->arch.vgic.vgic_redist_base =3D VGIC_ADDR_UNDEF; =20 return 0; diff --git a/xen/arch/arm/vgic/vgic-v2.c b/xen/arch/arm/vgic/vgic-v2.c index b5ba4ace87..09cb92039a 100644 --- a/xen/arch/arm/vgic/vgic-v2.c +++ b/xen/arch/arm/vgic/vgic-v2.c @@ -258,7 +258,7 @@ void vgic_v2_enable(struct vcpu *vcpu) int vgic_v2_map_resources(struct domain *d) { struct vgic_dist *dist =3D &d->arch.vgic; - paddr_t cbase, csize; + paddr_t csize; paddr_t vbase; int ret; =20 @@ -268,7 +268,7 @@ int vgic_v2_map_resources(struct domain *d) */ if ( is_hardware_domain(d) ) { - d->arch.vgic.vgic_dist_base =3D gic_v2_hw_data.dbase; + d->arch.vgic.dbase =3D gic_v2_hw_data.dbase; /* * For the hardware domain, we always map the whole HW CPU * interface region in order to match the device tree (the "reg" @@ -276,13 +276,13 @@ int vgic_v2_map_resources(struct domain *d) * Note that we assume the size of the CPU interface is always * aligned to PAGE_SIZE. */ - cbase =3D gic_v2_hw_data.cbase; + d->arch.vgic.cbase =3D gic_v2_hw_data.cbase; csize =3D gic_v2_hw_data.csize; vbase =3D gic_v2_hw_data.vbase; } else { - d->arch.vgic.vgic_dist_base =3D GUEST_GICD_BASE; + d->arch.vgic.dbase =3D GUEST_GICD_BASE; /* * The CPU interface exposed to the guest is always 8kB. We may * need to add an offset to the virtual CPU interface base @@ -290,13 +290,13 @@ int vgic_v2_map_resources(struct domain *d) * region. */ BUILD_BUG_ON(GUEST_GICC_SIZE !=3D SZ_8K); - cbase =3D GUEST_GICC_BASE; + d->arch.vgic.cbase =3D GUEST_GICC_BASE; csize =3D GUEST_GICC_SIZE; vbase =3D gic_v2_hw_data.vbase + gic_v2_hw_data.aliased_offset; } =20 =20 - ret =3D vgic_register_dist_iodev(d, gaddr_to_gfn(dist->vgic_dist_base), + ret =3D vgic_register_dist_iodev(d, gaddr_to_gfn(dist->dbase), VGIC_V2); if ( ret ) { @@ -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)); + ret =3D map_mmio_regions(d, gaddr_to_gfn(d->arch.vgic.cbase), + csize / PAGE_SIZE, maddr_to_mfn(vbase)); if ( ret ) { gdprintk(XENLOG_ERR, "Unable to remap VGIC CPU to VCPU\n"); diff --git a/xen/include/asm-arm/new_vgic.h b/xen/include/asm-arm/new_vgic.h index 97d622bff6..e3319900ab 100644 --- a/xen/include/asm-arm/new_vgic.h +++ b/xen/include/asm-arm/new_vgic.h @@ -115,11 +115,11 @@ struct vgic_dist { unsigned int nr_spis; =20 /* base addresses in guest physical address space: */ - paddr_t vgic_dist_base; /* distributor */ + paddr_t dbase; /* distributor */ union { /* either a GICv2 CPU interface */ - paddr_t vgic_cpu_base; + paddr_t cbase; /* or a number of GICv3 redistributor regions */ struct { --=20 2.17.1 From nobody Thu May 9 00:26:20 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1586912609; cv=none; d=zohomail.com; s=zohoarc; b=Qzb4WF+2YdE9SIgwAg2GsIcfLDpftiNA/vyfYbEOg0Atd4m+UduzAoakxRQNv5V+nlLFYgmq8d7zg5rY0KEJVhx93GwYxDkYR+dmhy2uklCUwm88ILejWmQYopytdFR/6bfGvUWECt3f4cauanJhamTfPFtVOrjvWHtlVRP4Du0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586912609; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=bRgXq1a+8//g6+YnBSLS206ZbkZ3wnoIw65vVILW11c=; b=nCBJx8pJCpEIXCN2KozWzGuTc+yODXdVGnn5Olw4dkXUzs5hXdFcEYgwAHHmuBH/UXevAwq6OsWvS7EwY4DA6ukH8HbndAXHPTo9AhpdvCbCZrjVPqr8iXP5j8xNmy0/WuBgvb1DFblCS8yhMk3d/Z8QNNuZ6X0L3q8JGHD1SDE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=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 1586912609049888.5315663020725; Tue, 14 Apr 2020 18:03:29 -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 1jOWST-0001Kp-0w; Wed, 15 Apr 2020 01:03:17 +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 1jOWSR-0001JV-4v for xen-devel@lists.xenproject.org; Wed, 15 Apr 2020 01:03:15 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id da3083ca-7eb4-11ea-89ec-12813bfff9fa; Wed, 15 Apr 2020 01:03:01 +0000 (UTC) Received: from sstabellini-ThinkPad-T480s.hsd1.ca.comcast.net (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 69B81208FE; Wed, 15 Apr 2020 01:03:00 +0000 (UTC) X-Inumbo-ID: da3083ca-7eb4-11ea-89ec-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586912580; bh=ZzU/KCsWFqwH+c4W+Sd0RSn1ZEn5hNAtQGIHQMy5tEk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VqWqFsZR6RwDPloWnP4LyDoX02kf0vE9iKyZaguCe9gybtsSJRC2cRPSOagrTHmNH 5JeJsG0LKR1YfyruQjIm9ORndgRSKuInwXNxCm9xBq4B+IJxXCMZWBBVxPK8/A2kjz 5ANwSqaclTnIZVZDTBVcIe5iphX+0/NFxdgyphCg= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Subject: [PATCH 08/12] xen/arm: if is_domain_direct_mapped use native addresses for GICv2 Date: Tue, 14 Apr 2020 18:02:51 -0700 Message-Id: <20200415010255.10081-8-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: 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: Volodymyr_Babchuk@epam.com, sstabellini@kernel.org, julien@xen.org, Stefano Stabellini Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Today we use native addresses to map the GICv2 for Dom0 and fixed addresses for DomUs. This patch changes the behavior so that native addresses are used for any domain that is_domain_direct_mapped. Signed-off-by: Stefano Stabellini --- xen/arch/arm/domain_build.c | 10 +++++++--- xen/arch/arm/vgic-v2.c | 12 ++++++------ xen/arch/arm/vgic/vgic-v2.c | 2 +- xen/include/asm-arm/vgic.h | 1 + 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 627e0c5e8e..303bee60f6 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1643,8 +1643,12 @@ static int __init make_gicv2_domU_node(struct kernel= _info *kinfo) int res =3D 0; __be32 reg[(GUEST_ROOT_ADDRESS_CELLS + GUEST_ROOT_SIZE_CELLS) * 2]; __be32 *cells; + struct domain *d =3D kinfo->d; + char buf[38]; =20 - res =3D fdt_begin_node(fdt, "interrupt-controller@"__stringify(GUEST_G= ICD_BASE)); + snprintf(buf, sizeof(buf), "interrupt-controller@%"PRIx64, + d->arch.vgic.dbase); + res =3D fdt_begin_node(fdt, buf); if ( res ) return res; =20 @@ -1666,9 +1670,9 @@ static int __init make_gicv2_domU_node(struct kernel_= info *kinfo) =20 cells =3D ®[0]; dt_child_set_range(&cells, GUEST_ROOT_ADDRESS_CELLS, GUEST_ROOT_SIZE_C= ELLS, - GUEST_GICD_BASE, GUEST_GICD_SIZE); + d->arch.vgic.dbase, GUEST_GICD_SIZE); dt_child_set_range(&cells, GUEST_ROOT_ADDRESS_CELLS, GUEST_ROOT_SIZE_C= ELLS, - GUEST_GICC_BASE, GUEST_GICC_SIZE); + d->arch.vgic.cbase, GUEST_GICC_SIZE); =20 res =3D fdt_property(fdt, "reg", reg, sizeof(reg)); if (res) diff --git a/xen/arch/arm/vgic-v2.c b/xen/arch/arm/vgic-v2.c index 64b141fea5..9a74e2ed38 100644 --- a/xen/arch/arm/vgic-v2.c +++ b/xen/arch/arm/vgic-v2.c @@ -650,14 +650,14 @@ static int vgic_v2_vcpu_init(struct vcpu *v) static int vgic_v2_domain_init(struct domain *d) { int ret; - paddr_t cbase, csize; + paddr_t csize; paddr_t vbase; =20 /* * The hardware domain gets the hardware address. * Guests get the virtual platform layout. */ - if ( is_hardware_domain(d) ) + if ( is_domain_direct_mapped(d) ) { d->arch.vgic.dbase =3D vgic_v2_hw.dbase; /* @@ -667,7 +667,7 @@ static int vgic_v2_domain_init(struct domain *d) * Note that we assume the size of the CPU interface is always * aligned to PAGE_SIZE. */ - cbase =3D vgic_v2_hw.cbase; + d->arch.vgic.cbase =3D vgic_v2_hw.cbase; csize =3D vgic_v2_hw.csize; vbase =3D vgic_v2_hw.vbase; } @@ -681,7 +681,7 @@ static int vgic_v2_domain_init(struct domain *d) * region. */ BUILD_BUG_ON(GUEST_GICC_SIZE !=3D SZ_8K); - cbase =3D GUEST_GICC_BASE; + d->arch.vgic.cbase =3D GUEST_GICC_BASE; csize =3D GUEST_GICC_SIZE; vbase =3D vgic_v2_hw.vbase + vgic_v2_hw.aliased_offset; } @@ -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)); + ret =3D map_mmio_regions(d, gaddr_to_gfn(d->arch.vgic.cbase), + csize / PAGE_SIZE, maddr_to_mfn(vbase)); if ( ret ) return ret; =20 diff --git a/xen/arch/arm/vgic/vgic-v2.c b/xen/arch/arm/vgic/vgic-v2.c index 09cb92039a..275dd8bea9 100644 --- a/xen/arch/arm/vgic/vgic-v2.c +++ b/xen/arch/arm/vgic/vgic-v2.c @@ -266,7 +266,7 @@ int vgic_v2_map_resources(struct domain *d) * The hardware domain gets the hardware address. * Guests get the virtual platform layout. */ - if ( is_hardware_domain(d) ) + if ( is_domain_direct_mapped(d) ) { d->arch.vgic.dbase =3D gic_v2_hw_data.dbase; /* diff --git a/xen/include/asm-arm/vgic.h b/xen/include/asm-arm/vgic.h index ce1e3c4bbd..f151d98773 100644 --- a/xen/include/asm-arm/vgic.h +++ b/xen/include/asm-arm/vgic.h @@ -152,6 +152,7 @@ struct vgic_dist { struct pending_irq *pending_irqs; /* Base address for guest GIC */ paddr_t dbase; /* Distributor base address */ + paddr_t cbase; /* CPU interface base address */ #ifdef CONFIG_GICV3 /* GIC V3 addressing */ /* List of contiguous occupied by the redistributors */ --=20 2.17.1 From nobody Thu May 9 00:26:20 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1586912617; cv=none; d=zohomail.com; s=zohoarc; b=W7qsukN4SeSnAr8A0n70jAhZE+ohiJDPLY7JXLGMhvZ7pV59GxQ56jHX+IRxqCFZXmWoU+C5WUPyHCVv5bj3F6Y9oDCqvGoyX9LqzAzzRcS/om3Nz8PFeisf8pI84XDvBULLJh6tKdjtXlt2/+J346HlbU14tJKUaUurmmekBK8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586912617; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=eBqjuXV2OtQ8gmAEIJzRbyNmW423Wx3OQz4Z1uyIdc0=; b=SY9TqQA23C43l26gZ6BtlS0SbMSMtxebjgd74Q5IatosjwgOX5krjHkVqjNn4Ar0cK0yLKVvOTX1CE0ynuSQLkKQDqXbwozal6+da9aB6c5xr7MNX4vjs5VvTWsGbNGakx12VkUHujMzPC+aiFxPYgYFOxNRq1FuqXK9YHtVzAM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=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 1586912617353503.7093910916833; Tue, 14 Apr 2020 18:03:37 -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 1jOWSX-0001QG-VG; Wed, 15 Apr 2020 01:03:21 +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 1jOWSW-0001OQ-5o for xen-devel@lists.xenproject.org; Wed, 15 Apr 2020 01:03:20 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id da691cc6-7eb4-11ea-89ec-12813bfff9fa; Wed, 15 Apr 2020 01:03:01 +0000 (UTC) Received: from sstabellini-ThinkPad-T480s.hsd1.ca.comcast.net (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BC7CD2078B; Wed, 15 Apr 2020 01:03:00 +0000 (UTC) X-Inumbo-ID: da691cc6-7eb4-11ea-89ec-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586912581; bh=Lmbmicx/WeDeC0BE2JzU8fS5QlIfGd8kH2D1wqE2U5A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LJPUFIKBgND+ioK8OLEosJp2bpg2BbKzFmwLRUAwE5Uvv8T6MTQs+28V79gFgNLEN Mr3ixv0GaRnMnPAAdgnxsLggRUxZhT5q6IyfKzgHumUa5oeOXMlq1z+20/vRZZKXEq NUu03aghfahwoEshb+RapkcW9Mgi0L8Cqr4UYZPA= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Subject: [PATCH 09/12] xen/arm: if is_domain_direct_mapped use native addresses for GICv3 Date: Tue, 14 Apr 2020 18:02:52 -0700 Message-Id: <20200415010255.10081-9-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: 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: Volodymyr_Babchuk@epam.com, sstabellini@kernel.org, julien@xen.org, Stefano Stabellini Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Today we use native addresses to map the GICv3 for Dom0 and fixed addresses for DomUs. This patch changes the behavior so that native addresses are used for any domain that is_domain_direct_mapped. The patch has to introduce one #ifndef CONFIG_NEW_VGIC because the new vgic doesn't support GICv3. Signed-off-by: Stefano Stabellini --- xen/arch/arm/domain_build.c | 12 +++++++++--- xen/arch/arm/vgic-v3.c | 18 ++++++++++++++---- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 303bee60f6..beec0a144c 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1697,8 +1697,12 @@ static int __init make_gicv3_domU_node(struct kernel= _info *kinfo) int res =3D 0; __be32 reg[(GUEST_ROOT_ADDRESS_CELLS + GUEST_ROOT_SIZE_CELLS) * 2]; __be32 *cells; + struct domain *d =3D kinfo->d; + char buf[38]; =20 - res =3D fdt_begin_node(fdt, "interrupt-controller@"__stringify(GUEST_G= ICV3_GICD_BASE)); + snprintf(buf, sizeof(buf), "interrupt-controller@%"PRIx64, + d->arch.vgic.dbase); + res =3D fdt_begin_node(fdt, buf); if ( res ) return res; =20 @@ -1720,9 +1724,11 @@ static int __init make_gicv3_domU_node(struct kernel= _info *kinfo) =20 cells =3D ®[0]; dt_child_set_range(&cells, GUEST_ROOT_ADDRESS_CELLS, GUEST_ROOT_SIZE_C= ELLS, - GUEST_GICV3_GICD_BASE, GUEST_GICV3_GICD_SIZE); + d->arch.vgic.dbase, GUEST_GICV3_GICD_SIZE); +#if defined(CONFIG_GICV3) && !defined(CONFIG_NEW_VGIC) dt_child_set_range(&cells, GUEST_ROOT_ADDRESS_CELLS, GUEST_ROOT_SIZE_C= ELLS, - GUEST_GICV3_GICR0_BASE, GUEST_GICV3_GICR0_SIZE); + d->arch.vgic.rdist_regions[0].base, GUEST_GICV3_GIC= R0_SIZE); +#endif =20 res =3D fdt_property(fdt, "reg", reg, sizeof(reg)); if (res) diff --git a/xen/arch/arm/vgic-v3.c b/xen/arch/arm/vgic-v3.c index 4e60ba15cc..4cf430f865 100644 --- a/xen/arch/arm/vgic-v3.c +++ b/xen/arch/arm/vgic-v3.c @@ -1677,13 +1677,25 @@ static int vgic_v3_domain_init(struct domain *d) * Domain 0 gets the hardware address. * Guests get the virtual platform layout. */ - if ( is_hardware_domain(d) ) + if ( is_domain_direct_mapped(d) ) { unsigned int first_cpu =3D 0; + unsigned int nr_rdist_regions; =20 d->arch.vgic.dbase =3D vgic_v3_hw.dbase; =20 - for ( i =3D 0; i < vgic_v3_hw.nr_rdist_regions; i++ ) + if ( is_hardware_domain(d) ) + { + nr_rdist_regions =3D vgic_v3_hw.nr_rdist_regions; + d->arch.vgic.intid_bits =3D vgic_v3_hw.intid_bits; + } + else + { + nr_rdist_regions =3D 1; + d->arch.vgic.intid_bits =3D 10; + } + + for ( i =3D 0; i < nr_rdist_regions; i++ ) { paddr_t size =3D vgic_v3_hw.regions[i].size; =20 @@ -1706,8 +1718,6 @@ static int vgic_v3_domain_init(struct domain *d) * exposing unused region as they will not get emulated. */ d->arch.vgic.nr_regions =3D i + 1; - - d->arch.vgic.intid_bits =3D vgic_v3_hw.intid_bits; } else { --=20 2.17.1 From nobody Thu May 9 00:26:20 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1586912616; cv=none; d=zohomail.com; s=zohoarc; b=PmgII61x8rdXNKulslhnuc2PIJ8QMareVk7tQeQVhdpduhwWYv3TBRBy20d9J2HZlCw4sBIxiISgSKHyP794QAfrpzUks2jk6l2BJ4XiX6NkpCsB/Xmf3ixvm2JftgKAn++X7WCKGpMx9Fu0W5HrUVc7mpzbdjUP7xQOnx/vyn4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586912616; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=kof3QJH1t7XXGq+Idhk0RSAvsAwH1bbmvMFFGa3tmJI=; b=FSx409To/RM/ZZaGb0kFvQl3K39LQr36hJAlGv3pJ00IgBWFZt+C0TyVu+WTVCm13TUtSRpwAxeOLdRU7Z/FuhJ/yXZSXwW52nt1qrT/diZnXdSrJvG+Omt6IXsplRnbnw1ThEGcJQKvljX6Qha5RoEBlAetPffaB2MCThPjU8k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=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 1586912616945409.991580936526; Tue, 14 Apr 2020 18:03:36 -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 1jOWSV-0001Np-Ih; Wed, 15 Apr 2020 01:03:19 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jOWSU-0001Mm-Gh for xen-devel@lists.xenproject.org; Wed, 15 Apr 2020 01:03:18 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id da98d66e-7eb4-11ea-b4f4-bc764e2007e4; Wed, 15 Apr 2020 01:03:01 +0000 (UTC) Received: from sstabellini-ThinkPad-T480s.hsd1.ca.comcast.net (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2166920774; Wed, 15 Apr 2020 01:03:01 +0000 (UTC) X-Inumbo-ID: da98d66e-7eb4-11ea-b4f4-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586912581; bh=ISak1Imoj+Ly2asoLD52bHxG9S9gcN2rOOIhbYo1CLs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=biYVLT8sFYsz1xY5aBEJJzLGhQcM1Mnhjtv1e9WY807HLywbMTeqCCZ7XfDNJI0Oh dRWuihqa/IpTAlnVaaMMB+YRfVJpnpwepiLH21vCPl/qLop+EsVl3ExQjbvOUlU+zT WNf+vYrA6H76LVIRyXX2hWuZldAJaXOeCi5PUA2E= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Subject: [PATCH 10/12] xen/arm: if is_domain_direct_mapped use native UART address for vPL011 Date: Tue, 14 Apr 2020 18:02:53 -0700 Message-Id: <20200415010255.10081-10-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: 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: Volodymyr_Babchuk@epam.com, sstabellini@kernel.org, julien@xen.org, Stefano Stabellini Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We always use a fix address to map the vPL011 to domains. The address could be a problem for domains that are directly mapped. Instead, for domains that are directly mapped, reuse the address of the physical UART on the platform to avoid potential clashes. Signed-off-by: Stefano Stabellini --- xen/arch/arm/domain_build.c | 13 ++++++++----- xen/arch/arm/vpl011.c | 12 +++++++++--- xen/include/asm-arm/domain.h | 1 + 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index beec0a144c..9bc0b810a7 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1768,8 +1768,11 @@ static int __init make_vpl011_uart_node(struct kerne= l_info *kinfo) gic_interrupt_t intr; __be32 reg[GUEST_ROOT_ADDRESS_CELLS + GUEST_ROOT_SIZE_CELLS]; __be32 *cells; + struct domain *d =3D kinfo->d; + char buf[27]; =20 - res =3D fdt_begin_node(fdt, "sbsa-uart@"__stringify(GUEST_PL011_BASE)); + snprintf(buf, sizeof(buf), "sbsa-uart@%"PRIx64, d->arch.vpl011_addr); + res =3D fdt_begin_node(fdt, buf); if ( res ) return res; =20 @@ -1779,7 +1782,7 @@ static int __init make_vpl011_uart_node(struct kernel= _info *kinfo) =20 cells =3D ®[0]; dt_child_set_range(&cells, GUEST_ROOT_ADDRESS_CELLS, - GUEST_ROOT_SIZE_CELLS, GUEST_PL011_BASE, + GUEST_ROOT_SIZE_CELLS, d->arch.vpl011_addr, GUEST_PL011_SIZE); =20 res =3D fdt_property(fdt, "reg", reg, sizeof(reg)); @@ -2524,6 +2527,9 @@ static int __init construct_domU(struct domain *d, reserve_memory_11(d, &kinfo, &banks[0], i); } =20 + if ( kinfo.vpl011 ) + rc =3D domain_vpl011_init(d, NULL); + rc =3D prepare_dtb_domU(d, &kinfo); if ( rc < 0 ) return rc; @@ -2532,9 +2538,6 @@ static int __init construct_domU(struct domain *d, if ( rc < 0 ) return rc; =20 - if ( kinfo.vpl011 ) - rc =3D domain_vpl011_init(d, NULL); - return rc; } =20 diff --git a/xen/arch/arm/vpl011.c b/xen/arch/arm/vpl011.c index 895f436cc4..44173a76fd 100644 --- a/xen/arch/arm/vpl011.c +++ b/xen/arch/arm/vpl011.c @@ -347,7 +347,7 @@ static int vpl011_mmio_read(struct vcpu *v, void *priv) { struct hsr_dabt dabt =3D info->dabt; - uint32_t vpl011_reg =3D (uint32_t)(info->gpa - GUEST_PL011_BASE); + uint32_t vpl011_reg =3D (uint32_t)(info->gpa - v->domain->arch.vpl011_= addr); struct vpl011 *vpl011 =3D &v->domain->arch.vpl011; struct domain *d =3D v->domain; unsigned long flags; @@ -430,7 +430,7 @@ static int vpl011_mmio_write(struct vcpu *v, void *priv) { struct hsr_dabt dabt =3D info->dabt; - uint32_t vpl011_reg =3D (uint32_t)(info->gpa - GUEST_PL011_BASE); + uint32_t vpl011_reg =3D (uint32_t)(info->gpa - v->domain->arch.vpl011_= addr); struct vpl011 *vpl011 =3D &v->domain->arch.vpl011; struct domain *d =3D v->domain; unsigned long flags; @@ -622,10 +622,16 @@ int domain_vpl011_init(struct domain *d, struct vpl01= 1_init_info *info) { int rc; struct vpl011 *vpl011 =3D &d->arch.vpl011; + const struct vuart_info *uart =3D serial_vuart_info(SERHND_DTUART); =20 if ( vpl011->backend.dom.ring_buf ) return -EINVAL; =20 + if ( is_domain_direct_mapped(d) && uart !=3D NULL ) + d->arch.vpl011_addr =3D uart->base_addr; + else + d->arch.vpl011_addr =3D GUEST_PL011_BASE; + /* * info is NULL when the backend is in Xen. * info is !=3D NULL when the backend is in a domain. @@ -673,7 +679,7 @@ int domain_vpl011_init(struct domain *d, struct vpl011_= init_info *info) spin_lock_init(&vpl011->lock); =20 register_mmio_handler(d, &vpl011_mmio_handler, - GUEST_PL011_BASE, GUEST_PL011_SIZE, NULL); + d->arch.vpl011_addr, GUEST_PL011_SIZE, NULL); =20 return 0; =20 diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h index 7a498921bf..52741895c8 100644 --- a/xen/include/asm-arm/domain.h +++ b/xen/include/asm-arm/domain.h @@ -100,6 +100,7 @@ struct arch_domain #endif =20 bool direct_map; + paddr_t vpl011_addr; } __cacheline_aligned; =20 struct arch_xen_dom_flags --=20 2.17.1 From nobody Thu May 9 00:26:20 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1586912618; cv=none; d=zohomail.com; s=zohoarc; b=h3y3E8NzeTDh4WfsGsnZxHS8V682rx45TR1a8Ka3dxydiobj3j8y9Wp/AwXlusnPWebKEdkbysszGl+XixqES/OLSXfO1PQdm8CEEGZj/LFrnQzzOZwlyaqJAPbqtcozNvvHibInkAsONs/cHVStkHQgihQKx7DkTORPiYpkzjY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586912618; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=3JkPSm4RVKi4gS3f40hYCEqbKMYrqf2YyjLf3AuRhRo=; b=i/P8iUxNkGp6FwZ/OwaX7M9CAJBagfwwADBuMDzsIKhzClZnmXZWX1Fp5xk6wQm7LCs2e1Yv4X/xOzOBGg0rBOXtNG440MKaS4d3ChWRf2VRDRgbf7oSEGbs3zuZ8Y6IEw4+ybsiGPdMgCp6mVK/1D2N7tHHBnYPc7leNc9RUiA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=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 1586912618924768.4283141172185; Tue, 14 Apr 2020 18:03:38 -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 1jOWSc-0001Vj-PU; Wed, 15 Apr 2020 01:03:26 +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 1jOWSb-0001Ty-51 for xen-devel@lists.xenproject.org; Wed, 15 Apr 2020 01:03:25 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id da691cc7-7eb4-11ea-89ec-12813bfff9fa; Wed, 15 Apr 2020 01:03:02 +0000 (UTC) Received: from sstabellini-ThinkPad-T480s.hsd1.ca.comcast.net (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 710A020936; Wed, 15 Apr 2020 01:03:01 +0000 (UTC) X-Inumbo-ID: da691cc7-7eb4-11ea-89ec-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586912581; bh=M3mtuPpEn22GeE50cx6N0881izwzd4quzv104vMzFfg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y4Bds0ycsmoxzcYjuu7OsHu5scVsagsNNWhTxdJxA3UzS4VXkzQVX1gtf16K+pT0C EujAoCXu6f9tdHNkM1m3eLInwHaT1nfmtJzch8OE57qrxMvXxuk6AxUuFyDVwaIA6v dzCI8ezkbrBcBrKW4e2RlvikiZL7jpamaOvpcidQ= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Subject: [PATCH 11/12] xen/arm: if xen_force don't try to setup the IOMMU Date: Tue, 14 Apr 2020 18:02:54 -0700 Message-Id: <20200415010255.10081-11-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: 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: Volodymyr_Babchuk@epam.com, sstabellini@kernel.org, julien@xen.org, Stefano Stabellini Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If xen_force (which means xen,force-assign-without-iommu was requested) don't try to add the device to the IOMMU. Return early instead. Signed-off-by: Stefano Stabellini --- xen/arch/arm/domain_build.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 9bc0b810a7..d0fc497d07 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1884,12 +1884,14 @@ static int __init handle_passthrough_prop(struct ke= rnel_info *kinfo, if ( res < 0 ) return res; =20 + if ( xen_force ) + return 0; + res =3D iommu_add_dt_device(node); if ( res < 0 ) return res; =20 - /* If xen_force, we allow assignment of devices without IOMMU protecti= on. */ - if ( xen_force && !dt_device_is_protected(node) ) + if ( !dt_device_is_protected(node) ) return 0; =20 return iommu_assign_dt_device(kinfo->d, node); --=20 2.17.1 From nobody Thu May 9 00:26:20 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1586912624; cv=none; d=zohomail.com; s=zohoarc; b=b4KIAIEXCcQXaAn7IltAed295xVpPtcgqhzB4L2QAOj7aaR6yM+Mm7/M0GGrfRmg2MQT920/VzS3hty29z2LfHllOq3OKvJ8TmGgLqG/oUfeXALV70nMBrDXCaB88pSN+xT74KJcWdxHjWu34zfaewteeKMBUDugrEEeiBFUXOU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586912624; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=/pgXi/y5TlGFjWhTEodrJlaFGZIT4RhM2Y4sZhLrCAc=; b=lpDUTYT64eoigZ+HlZupuTyLebl6jWd1PxogjgMHCP+5LANdRDrSFTQ9OlSAd+3HQpqymzrROnIYp7q6rcx+1Vbj6EieIMxxOkriE4ZiFBs4ac4pzaQGb1/h+2r4e9hKz/XRG7onNnySHoY4XjMiyE6PTicKQ1k1OPg0D5Vf5qo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=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 1586912624446831.4583210165447; Tue, 14 Apr 2020 18:03:44 -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 1jOWSa-0001Sx-Cb; Wed, 15 Apr 2020 01:03:24 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jOWSZ-0001Rz-Gx for xen-devel@lists.xenproject.org; Wed, 15 Apr 2020 01:03:23 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id db025530-7eb4-11ea-b58d-bc764e2007e4; Wed, 15 Apr 2020 01:03:02 +0000 (UTC) Received: from sstabellini-ThinkPad-T480s.hsd1.ca.comcast.net (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CAF3D20787; Wed, 15 Apr 2020 01:03:01 +0000 (UTC) X-Inumbo-ID: db025530-7eb4-11ea-b58d-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586912582; bh=xC9W/4oLDuoIZtmDlnuiRW23B9RMI1gQZH5SwKKFaVk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0dp9DHp2jHw/sPPiaFpgucYy8LGFeesqq+1J5QFa+9mJbTH3HX1/zXFi1nFXnH1mv dD96TMTIU9TE94LmUXVRhDyWrAIUvn8CN8lr6Hn5ZKA2mZv6DgiWEhbQZp2q9qP7DY nqQ7EwTkgPUDPqFyGceQyYup5IjABiKr/SFJSF4Y= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Subject: [PATCH 12/12] xen/arm: call iomem_permit_access for passthrough devices Date: Tue, 14 Apr 2020 18:02:55 -0700 Message-Id: <20200415010255.10081-12-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: 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: Volodymyr_Babchuk@epam.com, sstabellini@kernel.org, julien@xen.org, Stefano Stabellini Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" iomem_permit_access should be called for MMIO regions of devices assigned to a domain. Currently it is not called for MMIO regions of passthrough devices of Dom0less guests. This patch fixes it. Signed-off-by: Stefano Stabellini --- xen/arch/arm/domain_build.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index d0fc497d07..d3d42eef5d 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1846,6 +1846,17 @@ static int __init handle_passthrough_prop(struct ker= nel_info *kinfo, return -EINVAL; } =20 + res =3D iomem_permit_access(kinfo->d, paddr_to_pfn(mstart), + paddr_to_pfn(PAGE_ALIGN(mstart + size - = 1))); + if ( res ) + { + printk(XENLOG_ERR "Unable to permit to dom%d access to" + " 0x%"PRIx64" - 0x%"PRIx64"\n", + kinfo->d->domain_id, + mstart & PAGE_MASK, PAGE_ALIGN(mstart + size) - 1); + return res; + } + res =3D map_regions_p2mt(kinfo->d, gaddr_to_gfn(gstart), PFN_DOWN(size), --=20 2.17.1