From patchwork Thu Dec 5 15:42:07 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 22074 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f70.google.com (mail-pb0-f70.google.com [209.85.160.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9B0B1202E0 for ; Thu, 5 Dec 2013 15:42:33 +0000 (UTC) Received: by mail-pb0-f70.google.com with SMTP id rq2sf50839848pbb.1 for ; Thu, 05 Dec 2013 07:42:32 -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=3s53Gj9w0cc0Et8KXRV3RtSSun+YYkV5QsPhF1Rb+oI=; b=Wyqo904JradVZkRneUNwo7omzpTcK6ZQ6Y4K0G8GkFw1Cg9Mh8lNVEEoMjV/VC5HBs nGTom4I5e83dctidWQ/NIe/c0R5lnBg14apTtn4GvhpnqgM1WptGNGT2OexqTm6SrQuU mk2hD27CrWk9iPv3d0ucFa+GFG62zfFQEJgoSSnIl9d2+c6trJcwkAAMhOrTr4FysEX6 KhBUYI0GnPfHnCl69PBU/iOsSrKiLtOzlu7Xy8Trj8RhEaCEJxCuIZO2I9Zz+mNFHuPt CYTIoBFkpjsH66lKgCEQ4Pm2+yzZHoa1godIESKK5fMY8uTyppWRmKytESpLGGzSQ7X/ g3hg== X-Gm-Message-State: ALoCoQnUjmPahmMprZz7YiWcmR4ykc1LO0PsjL0ewYYCX4+ZvPH7f/pzMucRzCWDS282QJ5Dt1Sm X-Received: by 10.69.17.225 with SMTP id gh1mr1011149pbd.8.1386258152795; Thu, 05 Dec 2013 07:42:32 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.116.42 with SMTP id jt10ls790193qeb.66.gmail; Thu, 05 Dec 2013 07:42:32 -0800 (PST) X-Received: by 10.220.47.10 with SMTP id l10mr3716543vcf.32.1386258152566; Thu, 05 Dec 2013 07:42:32 -0800 (PST) Received: from mail-ve0-f180.google.com (mail-ve0-f180.google.com [209.85.128.180]) by mx.google.com with ESMTPS id qp9si34858847vcb.75.2013.12.05.07.42.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 05 Dec 2013 07:42:32 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.180 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.180; Received: by mail-ve0-f180.google.com with SMTP id jz11so13548198veb.25 for ; Thu, 05 Dec 2013 07:42:32 -0800 (PST) X-Received: by 10.52.162.168 with SMTP id yb8mr19489957vdb.8.1386258152362; Thu, 05 Dec 2013 07:42:32 -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 u4csp24840vcz; Thu, 5 Dec 2013 07:42:31 -0800 (PST) X-Received: by 10.180.187.229 with SMTP id fv5mr12711853wic.24.1386258151539; Thu, 05 Dec 2013 07:42:31 -0800 (PST) Received: from mail-wg0-f53.google.com (mail-wg0-f53.google.com [74.125.82.53]) by mx.google.com with ESMTPS id x4si34779377wjf.112.2013.12.05.07.42.31 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 05 Dec 2013 07:42:31 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.53 is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=74.125.82.53; Received: by mail-wg0-f53.google.com with SMTP id k14so14440260wgh.32 for ; Thu, 05 Dec 2013 07:42:31 -0800 (PST) X-Received: by 10.194.84.72 with SMTP id w8mr17635426wjy.55.1386258150935; Thu, 05 Dec 2013 07:42:30 -0800 (PST) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id w20sm7350575wia.5.2013.12.05.07.42.29 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Dec 2013 07:42:30 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Cc: patches@linaro.org, ian.campbell@citrix.com, time@xen.org, stefano.stabellini@citrix.com, Julien Grall Subject: [PATCH 4/8] xen/arm: Store p2m type in each page of the guest Date: Thu, 5 Dec 2013 15:42:07 +0000 Message-Id: <1386258131-755-5-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1386258131-755-1-git-send-email-julien.grall@linaro.org> References: <1386258131-755-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.180 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. This information will be retrieved in a future patch to change 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 --- xen/arch/arm/p2m.c | 49 +++++++++++++++++++++++++++++++-------------- xen/include/asm-arm/p2m.h | 18 +++++++++++++---- 2 files changed, 48 insertions(+), 19 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 8f8b47e..5449a35 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,25 @@ 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.avail = t, /* Use avail to store p2m type */ }; + switch (t) + { + case p2m_ram_rw: + case p2m_mmio_direct: + case p2m_map_foreign: + e.p2m.write = 1; + break; + case p2m_invalid: + case p2m_ram_ro: + default: + e.p2m.write = 0; + } + ASSERT(!(pa & ~PAGE_MASK)); ASSERT(!(pa & ~PADDR_MASK)); @@ -167,7 +181,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 +199,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 +275,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 +318,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 +327,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<