From patchwork Fri Dec 13 19:37:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 22357 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f70.google.com (mail-oa0-f70.google.com [209.85.219.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 84CD6202E2 for ; Fri, 13 Dec 2013 19:38:13 +0000 (UTC) Received: by mail-oa0-f70.google.com with SMTP id m1sf8531124oag.5 for ; Fri, 13 Dec 2013 11:38:13 -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=EMvbLi0HEq6Atj6bEqsz3AqHMHZ6mPMfTYzo8X78qajyUG4yJq7DPOt8OU+cGDAn22 LLGSoWu5WWnxmhrM16SFfIuwR78gFYqIGONNGyYfPR/5QUyLTEItN9iOVOihVMG/V8Ef AMn9RLi+vPZ4j2DfwTb+RmLyJddKbumxjnFfujAzLq43f4CC49IZYrHzaPBT9L8MaGjz wQCsYQtyrRuSqHVYIleH0XGAG84w3fHCOT6vGFSNkA0jobhMn1JG3s7LT4sUwAMs6yNz WKJefxyxnDPmUQS9VJttTkhAoQ1RHflag9t3jtspCU/Xs9TPJ7/pZTbRHcz6ntTG+cwI MVZQ== X-Gm-Message-State: ALoCoQkfdcECxO7x5TMx4xz/CvqAwyPToVdQtKBzHhxo1LwJiKIjGqU+r+AH4siAPoXj8bTYdGzL X-Received: by 10.42.112.2 with SMTP id w2mr1366432icp.14.1386963493133; Fri, 13 Dec 2013 11:38:13 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.85.129 with SMTP id h1ls1097757qez.15.gmail; Fri, 13 Dec 2013 11:38:13 -0800 (PST) X-Received: by 10.52.157.232 with SMTP id wp8mr1672513vdb.4.1386963492977; Fri, 13 Dec 2013 11:38:12 -0800 (PST) Received: from mail-ve0-f176.google.com (mail-ve0-f176.google.com [209.85.128.176]) by mx.google.com with ESMTPS id vr9si1077682vcb.51.2013.12.13.11.38.12 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Dec 2013 11:38:12 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.176 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.176; Received: by mail-ve0-f176.google.com with SMTP id oz11so1689872veb.7 for ; Fri, 13 Dec 2013 11:38:12 -0800 (PST) X-Received: by 10.220.74.69 with SMTP id t5mr1998116vcj.18.1386963492885; Fri, 13 Dec 2013 11:38:12 -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 u4csp64188vcz; Fri, 13 Dec 2013 11:38:12 -0800 (PST) X-Received: by 10.15.54.72 with SMTP id s48mr4524583eew.3.1386963491704; Fri, 13 Dec 2013 11:38:11 -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 5si3146422eei.123.2013.12.13.11.38.11 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Dec 2013 11:38:11 -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 c41so1062678eek.36 for ; Fri, 13 Dec 2013 11:38:11 -0800 (PST) X-Received: by 10.14.114.71 with SMTP id b47mr4697740eeh.26.1386963491302; Fri, 13 Dec 2013 11:38:11 -0800 (PST) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id m1sm10199792eeg.0.2013.12.13.11.38.08 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Dec 2013 11:38:10 -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 v4 04/11] xen/arm: Implement p2m_type_t as an enum Date: Fri, 13 Dec 2013 19:37:34 +0000 Message-Id: <1386963461-6520-5-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1386963461-6520-1-git-send-email-julien.grall@linaro.org> References: <1386963461-6520-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.176 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 */