From patchwork Mon Dec 9 03:34: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: 22151 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f197.google.com (mail-ie0-f197.google.com [209.85.223.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 03C8B23FD2 for ; Mon, 9 Dec 2013 03:34:20 +0000 (UTC) Received: by mail-ie0-f197.google.com with SMTP id e14sf12128328iej.8 for ; Sun, 08 Dec 2013 19:34:20 -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:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=d5fURRGQQq7OtDIC/BrJhx99jaonelQecPpvKaiakX8=; b=FzdQFu6IFJ+NTjDxk+1jr1iMtZ4U6/rse+FYRjejEC1id/ypd5gn9cywJ8o4pALw8C hsM/9gFSRs6p2nArXPGtvgOgBQHUXvY+Mzg0LnsEoUlpvEAwwMJJXrj5d/yRW+OPlEQl riWGXN/GYfNobrZgPI/1eJekZF5q2LyIfmqZGHogBHTHNUi8De1J08ouyVUUnp0E31di WGtrOxazN8E2x0us2O625jPFGKQ+DPVIIKsitcDT1MIUWy6nwhsoTdzUEmVdw6Lotn5E ocyVNaGNUGMZWDbJCnJhK5YuGpW5CxNHX0fwdcbclCFVI1EnXCwHstu8bxX4PS6J8zFr RrbQ== X-Gm-Message-State: ALoCoQkn5LofYOlDl0o+xFDoKm2PDA72qRLAqx0ULYYPrOl0Ld3JMUgX68nJTnov3lzD43wLoooU X-Received: by 10.42.85.148 with SMTP id q20mr4806008icl.22.1386560060727; Sun, 08 Dec 2013 19:34:20 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.3.165 with SMTP id d5ls1963021qed.77.gmail; Sun, 08 Dec 2013 19:34:20 -0800 (PST) X-Received: by 10.52.28.6 with SMTP id x6mr8432015vdg.3.1386560060578; Sun, 08 Dec 2013 19:34:20 -0800 (PST) Received: from mail-ve0-f171.google.com (mail-ve0-f171.google.com [209.85.128.171]) by mx.google.com with ESMTPS id mj10si3175845vcb.87.2013.12.08.19.34.20 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 08 Dec 2013 19:34:20 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.171 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.171; Received: by mail-ve0-f171.google.com with SMTP id pa12so3104871veb.16 for ; Sun, 08 Dec 2013 19:34:20 -0800 (PST) X-Received: by 10.52.248.229 with SMTP id yp5mr552139vdc.46.1386560060492; Sun, 08 Dec 2013 19:34:20 -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 u4csp75724vcz; Sun, 8 Dec 2013 19:34:20 -0800 (PST) X-Received: by 10.14.211.69 with SMTP id v45mr5345564eeo.75.1386560059551; Sun, 08 Dec 2013 19:34:19 -0800 (PST) Received: from mail-ee0-f54.google.com (mail-ee0-f54.google.com [74.125.83.54]) by mx.google.com with ESMTPS id s8si7676407eeh.248.2013.12.08.19.34.19 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 08 Dec 2013 19:34:19 -0800 (PST) Received-SPF: neutral (google.com: 74.125.83.54 is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=74.125.83.54; Received: by mail-ee0-f54.google.com with SMTP id e51so1290320eek.13 for ; Sun, 08 Dec 2013 19:34:19 -0800 (PST) X-Received: by 10.14.7.2 with SMTP id 2mr10840767eeo.16.1386560059023; Sun, 08 Dec 2013 19:34:19 -0800 (PST) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id g7sm23681234eet.12.2013.12.08.19.34.17 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Dec 2013 19:34:18 -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 Subject: [PATCH v2 04/10] xen/arm: Store p2m type in each page of the guest Date: Mon, 9 Dec 2013 03:34:01 +0000 Message-Id: <1386560047-17500-5-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1386560047-17500-1-git-send-email-julien.grall@linaro.org> References: <1386560047-17500-1-git-send-email-julien.grall@linaro.org> 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.171 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: , Use the field 'avail' to store the type of the page. Rename it to 'p2mt' for convenience. The information stored in this field will be retrieved in a future patch to hange the behaviour when the page is removed. Also introduce guest_physmap_add_entry to map and set a specific p2m type for a page. Signed-off-by: Julien Grall --- Changes in v2: - Rename 'avail' field to 'p2mt' in the p2m structure - Add BUILD_BUG_ON to check if the enum value will fit in the field - Implement grant mapping type --- xen/arch/arm/p2m.c | 58 ++++++++++++++++++++++++++++++++------------ xen/include/asm-arm/p2m.h | 18 +++++++++++--- xen/include/asm-arm/page.h | 2 +- 3 files changed, 58 insertions(+), 20 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 8f8b47e..e43804c 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -124,7 +124,8 @@ int p2m_pod_decrease_reservation(struct domain *d, return -ENOSYS; } -static lpae_t mfn_to_p2m_entry(unsigned long mfn, unsigned int mattr) +static lpae_t mfn_to_p2m_entry(unsigned long mfn, unsigned int mattr, + p2m_type_t t) { paddr_t pa = ((paddr_t) mfn) << PAGE_SHIFT; lpae_t e = (lpae_t) { @@ -132,12 +133,34 @@ static lpae_t mfn_to_p2m_entry(unsigned long mfn, unsigned int mattr) .p2m.af = 1, .p2m.sh = LPAE_SH_OUTER, .p2m.read = 1, - .p2m.write = 1, .p2m.mattr = mattr, .p2m.table = 1, .p2m.valid = 1, + .p2m.p2mt = t, }; + BUILD_BUG_ON(p2m_max_real_type > (2 << 4)); + + switch (t) + { + case p2m_grant_map_rw: + e.p2m.xn = 1; + /* Fallthrough */ + case p2m_ram_rw: + case p2m_mmio_direct: + case p2m_map_foreign: + e.p2m.write = 1; + break; + + case p2m_grant_map_ro: + e.p2m.xn = 1; + /* Fallthrough */ + case p2m_invalid: + case p2m_ram_ro: + default: + e.p2m.write = 0; + } + ASSERT(!(pa & ~PAGE_MASK)); ASSERT(!(pa & ~PADDR_MASK)); @@ -167,7 +190,7 @@ static int p2m_create_table(struct domain *d, clear_page(p); unmap_domain_page(p); - pte = mfn_to_p2m_entry(page_to_mfn(page), MATTR_MEM); + pte = mfn_to_p2m_entry(page_to_mfn(page), MATTR_MEM, p2m_invalid); write_pte(entry, pte); @@ -185,7 +208,8 @@ static int create_p2m_entries(struct domain *d, paddr_t start_gpaddr, paddr_t end_gpaddr, paddr_t maddr, - int mattr) + int mattr, + p2m_type_t t) { int rc, flush; struct p2m_domain *p2m = &d->arch.p2m; @@ -260,14 +284,15 @@ static int create_p2m_entries(struct domain *d, goto out; } - pte = mfn_to_p2m_entry(page_to_mfn(page), mattr); + pte = mfn_to_p2m_entry(page_to_mfn(page), mattr, t); write_pte(&third[third_table_offset(addr)], pte); } break; case INSERT: { - lpae_t pte = mfn_to_p2m_entry(maddr >> PAGE_SHIFT, mattr); + lpae_t pte = mfn_to_p2m_entry(maddr >> PAGE_SHIFT, + mattr, t); write_pte(&third[third_table_offset(addr)], pte); maddr += PAGE_SIZE; } @@ -302,7 +327,8 @@ int p2m_populate_ram(struct domain *d, paddr_t start, paddr_t end) { - return create_p2m_entries(d, ALLOCATE, start, end, 0, MATTR_MEM); + return create_p2m_entries(d, ALLOCATE, start, end, + 0, MATTR_MEM, p2m_ram_rw); } int map_mmio_regions(struct domain *d, @@ -310,18 +336,20 @@ int map_mmio_regions(struct domain *d, paddr_t end_gaddr, paddr_t maddr) { - return create_p2m_entries(d, INSERT, start_gaddr, end_gaddr, maddr, MATTR_DEV); + return create_p2m_entries(d, INSERT, start_gaddr, end_gaddr, + maddr, MATTR_DEV, p2m_mmio_direct); } -int guest_physmap_add_page(struct domain *d, - unsigned long gpfn, - unsigned long mfn, - unsigned int page_order) +int guest_physmap_add_entry(struct domain *d, + unsigned long gpfn, + unsigned long mfn, + unsigned long page_order, + p2m_type_t t) { return create_p2m_entries(d, INSERT, pfn_to_paddr(gpfn), - pfn_to_paddr(gpfn + (1<