From patchwork Mon Dec 16 17:37:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 22532 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f69.google.com (mail-yh0-f69.google.com [209.85.213.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D69C423FC6 for ; Mon, 16 Dec 2013 17:37:43 +0000 (UTC) Received: by mail-yh0-f69.google.com with SMTP id a41sf9990164yho.8 for ; Mon, 16 Dec 2013 09:37:43 -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=c2tbVezBuAjPlUi4YO1DBhJ41aoVoCrxV1eFPeww2Mw=; b=RrHK64tzXnSwKl4HBABj5KiR1kIUU7PBFNrD4v2BcUyJMYcty+pscFF6QjJbfaU4tV ZMtVHzwHPSZOS5qRsD6uedxkNxTdh2kYmtVe5NzbYvseEq0zz87huERE0FfmN6pQaTS3 pL8fTJe3zoH4SCfQkSGHDTCxjJPqxhlLefQbaAAE7jVAQ9fgefG3i9a+muQsBsGHxZ4g m78Hsr24LXNdw42k+O4KboFiZkcbjxXFUmxt/we4LUAJLF2aZm1FS0mYZTmi4nOBLNNH pIEWUgzHzgRdfTPcGVaf29m1ykBg6GLzPX0sX28QQP5OmMxnmFEBYAyWIlUAHm04gZzL MVFg== X-Gm-Message-State: ALoCoQkdsH7HcGon1HSKZHqye1Rp1lAVrMVwOMSQJ1FCZX0N5AiwgRLMtmc5mbTL9gjX+rk2/fKk X-Received: by 10.53.0.163 with SMTP id az3mr5633138vdd.5.1387215463673; Mon, 16 Dec 2013 09:37:43 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.71.142 with SMTP id v14ls2128657qeu.35.gmail; Mon, 16 Dec 2013 09:37:43 -0800 (PST) X-Received: by 10.220.79.136 with SMTP id p8mr807037vck.54.1387215463594; Mon, 16 Dec 2013 09:37:43 -0800 (PST) Received: from mail-ve0-f169.google.com (mail-ve0-f169.google.com [209.85.128.169]) by mx.google.com with ESMTPS id ce7si37212veb.70.2013.12.16.09.37.43 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 16 Dec 2013 09:37:43 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.169 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.169; Received: by mail-ve0-f169.google.com with SMTP id c14so3544975vea.14 for ; Mon, 16 Dec 2013 09:37:43 -0800 (PST) X-Received: by 10.58.217.169 with SMTP id oz9mr2487939vec.42.1387215463513; Mon, 16 Dec 2013 09:37:43 -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 u4csp6112vcz; Mon, 16 Dec 2013 09:37:43 -0800 (PST) X-Received: by 10.14.37.66 with SMTP id x42mr17827419eea.83.1387215462212; Mon, 16 Dec 2013 09:37:42 -0800 (PST) Received: from mail-ee0-f46.google.com (mail-ee0-f46.google.com [74.125.83.46]) by mx.google.com with ESMTPS id l2si1632964een.20.2013.12.16.09.37.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 16 Dec 2013 09:37:42 -0800 (PST) Received-SPF: neutral (google.com: 74.125.83.46 is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=74.125.83.46; Received: by mail-ee0-f46.google.com with SMTP id d49so2368580eek.33 for ; Mon, 16 Dec 2013 09:37:41 -0800 (PST) X-Received: by 10.15.44.4 with SMTP id y4mr17942575eev.71.1387215461680; Mon, 16 Dec 2013 09:37:41 -0800 (PST) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id e3sm44674680eeg.11.2013.12.16.09.37.39 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Dec 2013 09:37:39 -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 v5 03/10] xen/arm: Implement p2m_type_t as an enum Date: Mon, 16 Dec 2013 17:37:25 +0000 Message-Id: <1387215452-10951-4-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1387215452-10951-1-git-send-email-julien.grall@linaro.org> References: <1387215452-10951-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.169 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 v3: - s/ / / - Replace p2m by either pte or p2m entry - Fix compilation (unitialized value) - Add BUILD_BUG_ON (from patch #4) and fix it 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/arch/arm/p2m.c | 2 ++ xen/include/asm-arm/p2m.h | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 74636df..691cdfa 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -142,6 +142,8 @@ static lpae_t mfn_to_p2m_entry(unsigned long mfn, unsigned int mattr) .p2m.valid = 1, }; + BUILD_BUG_ON(p2m_max_real_type > (1 << 4)); + ASSERT(!(pa & ~PAGE_MASK)); ASSERT(!(pa & ~PADDR_MASK)); diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h index c660820..bc86a49 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 entry. + * The number of available bit per page in the pte 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 entry. + */ +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 */