From patchwork Fri Dec 13 20:18:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 22365 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f197.google.com (mail-ob0-f197.google.com [209.85.214.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 56678202E2 for ; Fri, 13 Dec 2013 20:18:08 +0000 (UTC) Received: by mail-ob0-f197.google.com with SMTP id vb8sf8294370obc.4 for ; Fri, 13 Dec 2013 12:18:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=rBjOUqqqteQzQGm9Esbe/Q1n1P7X9ogZS2rPIMMheB0=; b=YasFqk74+K/uNx3MzkjWSe+XE6AlPYLgX8JSIhSKcqmX8fhA83FlyEIzlgPrk71fP6 kPMAFpjtb/nXuQHU88rARnwh+ObWZvFvYSAoE/0HdNPYsVou1OBirNqONl5LxBONQ1wQ BirBh7jFU40rmcY/2IoBygKIyzxpnu+TIoGYDoaIo992cJuGX8zdTxtP8oeDKTyH1h7m UGnL63nmXWf1X4zeCGmWtxR7ZIbIEJ+X7B2Wul/f+Vv/Va/2sdN9pU3TkQ40qk0pDaZm R788i2UAF318tC04J5Ybtz6aSIkfmX7kjLAzWp41KGuij+mgrpngkTr9Tm6DZycpGeY7 E/ag== X-Gm-Message-State: ALoCoQn3j9rPRHN+A5kXmghGADfzXFnpifdK06Ji3S/1nQfpYbEcHV1+0I1nojgD7okEX8IYVJK+ X-Received: by 10.43.102.136 with SMTP id de8mr1453372icc.20.1386965888481; Fri, 13 Dec 2013 12:18:08 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.0.106 with SMTP id 10ls1125238qed.55.gmail; Fri, 13 Dec 2013 12:18:08 -0800 (PST) X-Received: by 10.58.120.48 with SMTP id kz16mr916289veb.72.1386965888371; Fri, 13 Dec 2013 12:18:08 -0800 (PST) Received: from mail-ve0-f182.google.com (mail-ve0-f182.google.com [209.85.128.182]) by mx.google.com with ESMTPS id er6si1095472vdc.114.2013.12.13.12.18.08 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Dec 2013 12:18:08 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.182; Received: by mail-ve0-f182.google.com with SMTP id jy13so1784163veb.27 for ; Fri, 13 Dec 2013 12:18:08 -0800 (PST) X-Received: by 10.220.97.69 with SMTP id k5mr2012783vcn.45.1386965888195; Fri, 13 Dec 2013 12:18:08 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp66473vcz; Fri, 13 Dec 2013 12:18:07 -0800 (PST) X-Received: by 10.15.44.4 with SMTP id y4mr4615346eev.71.1386965886783; Fri, 13 Dec 2013 12:18:06 -0800 (PST) Received: from mail-ee0-f47.google.com (mail-ee0-f47.google.com [74.125.83.47]) by mx.google.com with ESMTPS id i1si3277593eev.47.2013.12.13.12.18.06 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Dec 2013 12:18:06 -0800 (PST) Received-SPF: neutral (google.com: 74.125.83.47 is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=74.125.83.47; Received: by mail-ee0-f47.google.com with SMTP id e51so910358eek.6 for ; Fri, 13 Dec 2013 12:18:06 -0800 (PST) X-Received: by 10.14.179.130 with SMTP id h2mr4839583eem.34.1386965885362; Fri, 13 Dec 2013 12:18:05 -0800 (PST) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id e3sm10505615eeg.11.2013.12.13.12.18.03 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Dec 2013 12:18:03 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Cc: patches@linaro.org, ian.campbell@citrix.com, tim@xen.org, stefano.stabellini@citrix.com, Julien Grall , Keir Fraser , Jan Beulich Subject: [PATCH v2] xen/arm: Allow balooning working with 1:1 memory mapping Date: Fri, 13 Dec 2013 20:18:01 +0000 Message-Id: <1386965881-12151-1-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , With the lake of iommu, dom0 must have a 1:1 memory mapping for all these guest physical address. When the ballon decides to give back a page to the kernel, this page must have the same address as previously. Otherwise, we will loose the 1:1 mapping and will break DMA-capable devices. Signed-off-by: Julien Grall Cc: Keir Fraser Cc: Jan Beulich --- Release: This is a bug that prevents DMA-capable devices to work after a guest has started. Changes in v2 - Drop CONFIG_ARM and add is_dom0_mapped_11 --- xen/arch/arm/domain_build.c | 5 +++++ xen/common/memory.c | 32 ++++++++++++++++++++++++++++++-- xen/include/asm-arm/domain.h | 2 ++ xen/include/asm-x86/domain.h | 2 ++ 4 files changed, 39 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index faff88e..72e24e6 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -65,6 +65,11 @@ struct vcpu *__init alloc_dom0_vcpu0(void) return alloc_vcpu(dom0, 0, 0); } +int is_dom0_mapped_11(void) +{ + return dom0_11_mapping; +} + static void allocate_memory_11(struct domain *d, struct kernel_info *kinfo) { paddr_t start; diff --git a/xen/common/memory.c b/xen/common/memory.c index 61791a4..43edd08 100644 --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -90,7 +90,7 @@ static void increase_reservation(struct memop_args *a) static void populate_physmap(struct memop_args *a) { - struct page_info *page; + struct page_info *page = NULL; unsigned long i, j; xen_pfn_t gpfn, mfn; struct domain *d = a->domain; @@ -122,7 +122,29 @@ static void populate_physmap(struct memop_args *a) } else { - page = alloc_domheap_pages(d, a->extent_order, a->memflags); + if ( d == dom0 && is_dom0_mapped_11() ) + { + mfn = gpfn; + if (!mfn_valid(mfn)) + { + gdprintk(XENLOG_INFO, "Invalid mfn 0x%"PRI_xen_pfn"\n", + mfn); + goto out; + } + + page = mfn_to_page(mfn); + if ( !get_page(page, d) ) + { + gdprintk(XENLOG_INFO, + "mfn 0x%"PRI_xen_pfn" doesn't belong to dom0\n", + mfn); + goto out; + } + put_page(page); + } + else + page = alloc_domheap_pages(d, a->extent_order, a->memflags); + if ( unlikely(page == NULL) ) { if ( !opt_tmem || (a->extent_order != 0) ) @@ -270,6 +292,12 @@ static void decrease_reservation(struct memop_args *a) && p2m_pod_decrease_reservation(a->domain, gmfn, a->extent_order) ) continue; + /* With the lake for iommu on some ARM platform, dom0 must retrieve + * the same pfn when the hypercall populate_physmap is called. + */ + if ( a->domain == dom0 && is_dom0_mapped_11() ) + continue; + for ( j = 0; j < (1 << a->extent_order); j++ ) if ( !guest_remove_page(a->domain, gmfn + j) ) goto out; diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h index 28d39a0..8a328d3 100644 --- a/xen/include/asm-arm/domain.h +++ b/xen/include/asm-arm/domain.h @@ -86,6 +86,8 @@ enum domain_type { #define is_pv64_domain(d) (0) #endif +int is_dom0_mapped_11(void); + struct vtimer { struct vcpu *v; int irq; diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h index 9d39061..618aa48 100644 --- a/xen/include/asm-x86/domain.h +++ b/xen/include/asm-x86/domain.h @@ -16,6 +16,8 @@ #define is_pv_32on64_domain(d) (is_pv_32bit_domain(d)) #define is_pv_32on64_vcpu(v) (is_pv_32on64_domain((v)->domain)) +#define is_dom0_mapped_11() (0) + #define is_hvm_pv_evtchn_domain(d) (has_hvm_container_domain(d) && \ d->arch.hvm_domain.irq.callback_via_type == HVMIRQ_callback_vector) #define is_hvm_pv_evtchn_vcpu(v) (is_hvm_pv_evtchn_domain(v->domain))