From patchwork Tue Dec 17 16:27:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 22600 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f199.google.com (mail-ob0-f199.google.com [209.85.214.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 426C423FC6 for ; Tue, 17 Dec 2013 16:28:20 +0000 (UTC) Received: by mail-ob0-f199.google.com with SMTP id gq1sf22729408obb.6 for ; Tue, 17 Dec 2013 08:28: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=c2tbVezBuAjPlUi4YO1DBhJ41aoVoCrxV1eFPeww2Mw=; b=QYlsdUtvzUgXPBX9oikleep42JphkfaD8S/ZzQ2/4pwI/7biHMtd2JNUh5ezurbbH9 sIn8U7llT3GX3n5zSxhZSkXVdoVBKIU60NQ11W0t9nBXCgjcMODJXPql+h4Dfh33Il3l NCLEUPcgLZJpJhZnk150H6aDuvYbMzaZf9+960V/1EcbP7GqnV4LRVIQ5dVAC0cbRzQC PWlBljtIZHRMHcKbH8NZDqCzsY6vYZsOh6YaemHKjv8G7xwJk282ovw9HFxF2MJeomkZ sfLOQykwPPSL9XXvG0S8SQ6xnhUqk10LZ/cnIzABofDFn+GvpOTzk9X8iHoVcZ0bN6cH DKqg== X-Gm-Message-State: ALoCoQm5nkM2C8sbn7a+GOrI0TII8wncvavfhfbEFmYQ8yp6RSqw+vUW63t/MXy6FvqGQo+gqhxd X-Received: by 10.182.114.73 with SMTP id je9mr8458364obb.23.1387297699790; Tue, 17 Dec 2013 08:28:19 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.3.228 with SMTP id f4ls2568575qef.85.gmail; Tue, 17 Dec 2013 08:28:19 -0800 (PST) X-Received: by 10.52.191.98 with SMTP id gx2mr793501vdc.71.1387297699675; Tue, 17 Dec 2013 08:28:19 -0800 (PST) Received: from mail-vb0-f46.google.com (mail-vb0-f46.google.com [209.85.212.46]) by mx.google.com with ESMTPS id ed9si5040685vcb.81.2013.12.17.08.28.19 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 17 Dec 2013 08:28:19 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.46 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.46; Received: by mail-vb0-f46.google.com with SMTP id w20so4234313vbb.19 for ; Tue, 17 Dec 2013 08:28:19 -0800 (PST) X-Received: by 10.52.36.14 with SMTP id m14mr794827vdj.79.1387297699577; Tue, 17 Dec 2013 08:28: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 u4csp79563vcz; Tue, 17 Dec 2013 08:28:18 -0800 (PST) X-Received: by 10.14.193.132 with SMTP id k4mr23687682een.55.1387297698198; Tue, 17 Dec 2013 08:28:18 -0800 (PST) Received: from mail-ee0-f47.google.com (mail-ee0-f47.google.com [74.125.83.47]) by mx.google.com with ESMTPS id f8si5306939eep.99.2013.12.17.08.28.17 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 17 Dec 2013 08:28:18 -0800 (PST) Received-SPF: neutral (google.com: 74.125.83.47 is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=74.125.83.47; Received: by mail-ee0-f47.google.com with SMTP id e51so2519407eek.6 for ; Tue, 17 Dec 2013 08:28:17 -0800 (PST) X-Received: by 10.14.5.12 with SMTP id 12mr24120467eek.9.1387297697792; Tue, 17 Dec 2013 08:28:17 -0800 (PST) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id e3sm54411471eeg.11.2013.12.17.08.28.12 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Dec 2013 08:28:14 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Cc: patches@linaro.org, ian.campbell@citrix.com, ian.jackson@eu.citrix.com, Julien Grall Subject: [PATCH v6 03/10] xen/arm: Implement p2m_type_t as an enum Date: Tue, 17 Dec 2013 16:27:51 +0000 Message-Id: <1387297678-17762-4-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1387297678-17762-1-git-send-email-julien.grall@linaro.org> References: <1387297678-17762-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.212.46 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 */