From patchwork Mon Dec 9 03:34:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 22150 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f199.google.com (mail-qc0-f199.google.com [209.85.216.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E759323FD2 for ; Mon, 9 Dec 2013 03:34:19 +0000 (UTC) Received: by mail-qc0-f199.google.com with SMTP id i17sf6580005qcy.2 for ; Sun, 08 Dec 2013 19:34:19 -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=v5ozzyMAaJhJ95RBlTg3MkRpWAoMfE6sMTt71kmDBBo=; b=ENiBUj2KfsAk8bTKO/j+2Y0F9LFsDelSg8RHnOV9DLMY3U6migSV707pN9j5wg28zv JT8HwtmC2Fs6dS9PjTb+ZjNN8pe5Qe1URbr1ECpJNXgfDKirYGmLrkr6GyA2ei+x8Tld 7GeqAj6PO9dY4drr+ml5+x36Ke5oaf+vKSejwUMcHe7bwYyMq7bW4iD+SUQSd8DRf+hw kyH3xQGaQTgchcUe2GXnzBTcJ6APANTKn36XbhRu9PhXDkxvuD8ZF5HWQhDSKn8/WogO 5JjO7khOEVMpZUKvwL2hY+58NxCsHhnzWymkp95Szt5VfoaktveKS8coWhuokDOyKUDb MNww== X-Gm-Message-State: ALoCoQmY3gOXiBSN5/xXDaMCJVxCNAQbLWZgEsUPYUd3LO62tiLfDngmzBlhSBns9svgTv6UPNtM X-Received: by 10.236.20.114 with SMTP id o78mr5077916yho.8.1386560059430; Sun, 08 Dec 2013 19:34:19 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.121.98 with SMTP id lj2ls1968554qeb.45.gmail; Sun, 08 Dec 2013 19:34:19 -0800 (PST) X-Received: by 10.58.181.165 with SMTP id dx5mr607593vec.52.1386560059306; Sun, 08 Dec 2013 19:34:19 -0800 (PST) Received: from mail-ve0-f175.google.com (mail-ve0-f175.google.com [209.85.128.175]) by mx.google.com with ESMTPS id at8si3178989vec.84.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: 209.85.128.175 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.175; Received: by mail-ve0-f175.google.com with SMTP id jx11so3075253veb.6 for ; Sun, 08 Dec 2013 19:34:19 -0800 (PST) X-Received: by 10.52.181.4 with SMTP id ds4mr518463vdc.51.1386560059220; Sun, 08 Dec 2013 19:34:19 -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 u4csp75722vcz; Sun, 8 Dec 2013 19:34:18 -0800 (PST) X-Received: by 10.14.119.136 with SMTP id n8mr4640624eeh.82.1386560058172; Sun, 08 Dec 2013 19:34:18 -0800 (PST) Received: from mail-ee0-f49.google.com (mail-ee0-f49.google.com [74.125.83.49]) by mx.google.com with ESMTPS id u49si7748900eep.1.2013.12.08.19.34.17 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 08 Dec 2013 19:34:18 -0800 (PST) Received-SPF: neutral (google.com: 74.125.83.49 is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=74.125.83.49; Received: by mail-ee0-f49.google.com with SMTP id c41so1272687eek.22 for ; Sun, 08 Dec 2013 19:34:17 -0800 (PST) X-Received: by 10.14.175.131 with SMTP id z3mr479797eel.65.1386560057770; Sun, 08 Dec 2013 19:34:17 -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.16 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Dec 2013 19:34:17 -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 03/10] xen/arm: Implement p2m_type_t as an enum Date: Mon, 9 Dec 2013 03:34:00 +0000 Message-Id: <1386560047-17500-4-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.175 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: , Until now, Xen doesn't know the type of the page (ram, foreign page, mmio,...). Introduce p2m_type_t with basic types: - p2m_invalid: Nothing is mapped here - p2m_ram_rw: Normal read/write guest RAM - p2m_ram_ro: Read-only guest RAM - p2m_mmio_direct: Read/write mapping of device memory - p2m_map_foreign: RAM page from foreign guest - p2m_grant_map_rw: Read/write grant mapping - p2m_grant_map_ro: Read-only grant mapping Signed-off-by: Julien Grall Acked-by: Ian Campbell --- Changes in v2: - Add comment for future improvement - Add p2m_max_real_type. Will be use later to check the size of the enum - Let the compiler choose the value for each name of the enum - Add grant mapping type --- xen/include/asm-arm/p2m.h | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h index 0c554a5..f621d15 100644 --- a/xen/include/asm-arm/p2m.h +++ b/xen/include/asm-arm/p2m.h @@ -20,6 +20,25 @@ struct p2m_domain { uint8_t vmid; }; +/* List of possible type for each page in the p2m + * The number of available bit per page in the p2m for this purpose is 4 bits. + * So it's possible to only have 16 fields. If we run out of value in the + * future, it's possible to use higher value for pseudo-type and don't store + * them in the p2m. + */ +typedef enum { + p2m_invalid = 0, /* Nothing mapped here */ + p2m_ram_rw, /* Normal read/write guest RAM */ + p2m_ram_ro, /* Read-only; writes are silently dropped */ + p2m_mmio_direct, /* Read/write mapping of genuine MMIO area */ + p2m_map_foreign, /* Ram pages from foreign domain */ + p2m_grant_map_rw, /* Read/write grant mapping */ + p2m_grant_map_ro, /* Read-only grant mapping */ + p2m_max_real_type, /* Types after this won't be store in the p2m */ +} p2m_type_t; + +#define p2m_is_foreign(_t) ((_t) == p2m_map_foreign) + /* Initialise vmid allocator */ void p2m_vmid_allocator_init(void); @@ -72,7 +91,6 @@ p2m_pod_decrease_reservation(struct domain *d, unsigned int order); /* Look up a GFN and take a reference count on the backing page. */ -typedef int p2m_type_t; typedef unsigned int p2m_query_t; #define P2M_ALLOC (1u<<0) /* Populate PoD and paged-out entries */ #define P2M_UNSHARE (1u<<1) /* Break CoW sharing */ @@ -108,7 +126,6 @@ static inline int get_page_and_type(struct page_info *page, return rc; } -#define p2m_is_foreign(_t) (0 && (_t)) static inline int xenmem_rem_foreign_from_p2m(struct domain *d, unsigned long gpfn) {