From patchwork Mon Oct 2 17:31:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 114635 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp924667qgn; Mon, 2 Oct 2017 10:34:11 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCCVh3s+MRKM8vGccn4GWYxDiBDwfnCsm66+Vh0TSz3uIsT6jxYe54VBHMO2q5uqkEKdjVp X-Received: by 10.36.85.134 with SMTP id e128mr21125686itb.58.1506965651345; Mon, 02 Oct 2017 10:34:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506965651; cv=none; d=google.com; s=arc-20160816; b=l/L3Vaf8sRTDnbWK088XToLOHPyRVmxP/OFh1kq76B1c5xZb0ShfAzwfwoqS/kD3XR +nXg5X6F6fgnIMdi5Sw4LRm/r4nrxNPSvwRJz6dP1BRZw4dZdOxXqqhq6Jz7R2ZcrGgo AxlrxSTg30mZhewilpmJ+5nLkwOyriegXJ1zO4LFrBYWUINSaRBjSJTlsoE7T1C9cL/v T8t3U3Yp1Q5yn7trwSAq516ODY2+pwBWcwdIo1O2YR04pgKGu47zYHUUNbr4yVTH1euQ 92AAe9RG9AH9PYzpU7lDlGfT7G6X7TX1oJ00N9dfKE7FupYvqweHvHv5aury4fTVzH8d bXzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=2NUHK99gK36ea9jwnyEoAIjQ2ax087J+w6Z5KXNnS3w=; b=AifGKvl0r1zxVxkzTvFTpPHp+hFzJac0ZV0i0QD0Hoi+kZWM3YOjQWAGxf2Js+VT8t dK7QRSXOuGGslHDabQOiaMlD85A7CXJG9bmiCuAE/HyqsB13YRZtPPma6VHBIKRadwUO dB4SvL4UTnLq/hMNkBe3L4lh7rHbsr5MrbmPw6WjY/g6K4kkXIpya3N3VMintm76FQEk ljDEumPqUcjgShGyGFxJAHJkAQv+0Pgvxk87hvmJyHlyx733F7qCmt/v4erJhG9dfFL+ LYhvJ8wqdONCkkMDIXEmXZK0f8p72LRotjR68bb4i6tD6GqfL75oWrnpPmvQm5LoV6Qv IEtg== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id x18si5564916ita.27.2017.10.02.10.34.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Oct 2017 10:34:11 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dz4Zc-0003dq-MG; Mon, 02 Oct 2017 17:32:08 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dz4Zb-0003bd-BC for xen-devel@lists.xen.org; Mon, 02 Oct 2017 17:32:07 +0000 Received: from [85.158.143.35] by server-6.bemta-6.messagelabs.com id FD/6B-03423-61872D95; Mon, 02 Oct 2017 17:32:06 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrELMWRWlGSWpSXmKPExsVysyfVTVes4lK kwdXljBZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8beldvYC94JVRzefpe5gfEBfxcjF4eQwGZG ib/tDUwQzmlGica3PexdjJwcbAKaEnc+f2ICsUUEpCWufb7MCGIzC0RKHP7wA6iGg0NYwEli5 rRokDCLgKrE5K6LLCA2r4CFxKNnd8FaJQTkJXa1XWQFsTkFLCVuPznEDGILAdWcfj2DaQIj9w JGhlWMGsWpRWWpRbpGJnpJRZnpGSW5iZk5uoYGZnq5qcXFiempOYlJxXrJ+bmbGIH+ZQCCHYz 7PkYeYpTkYFIS5fXOvxQpxJeUn1KZkVicEV9UmpNafIhRhoNDSYL3ehlQTrAoNT21Ii0zBxho MGkJDh4lEd57IGne4oLE3OLMdIjUKUZdjo6bd/8wCbHk5eelSonzGpUDFQmAFGWU5sGNgAX9J UZZKWFeRqCjhHgKUotyM0tQ5V8xinMwKgnz/gFZxZOZVwK36RXQEUxAR8zpugByREkiQkqqgZ Hzyhf9+33zv+mKXKnucFrgMcP1oJeJc9DacB/ZK77lTVsadyqoXuvj6zVYfLKxQqrU0/xkkcV TBf0JJlXn9snMWfBu8uy9YXduCz9qPDJHi8E/Y9MLhhd/f+zQ3PtKX62StcYqekVSCGv7pne3 5x5dz6w/+8dxPbVpZuEnrijqz/octXvmpmlKLMUZiYZazEXFiQAtejKYdQIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-13.tower-21.messagelabs.com!1506965525!79800911!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG, UPPERCASE_25_50 X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 24900 invoked from network); 2 Oct 2017 17:32:05 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-13.tower-21.messagelabs.com with SMTP; 2 Oct 2017 17:32:05 -0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 529901529; Mon, 2 Oct 2017 10:32:05 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 675E33F483; Mon, 2 Oct 2017 10:32:04 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 2 Oct 2017 18:31:48 +0100 Message-Id: <20171002173150.5404-8-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171002173150.5404-1-julien.grall@arm.com> References: <20171002173150.5404-1-julien.grall@arm.com> Cc: andre.przywara@arm.com, Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v3 7/9] xen/arm: mm: Embed permission in the flags X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Currently, it is not possible to specify the permission of a new mapping. It would be necessary to use the function modify_xen_mappings with a different set of flags. Introduce a couple of new flags for the permissions (Non-eXecutable, Read-Only) and also provides definition that combine the memory attribute and permission for common combinations. PAGE_HYPERVISOR is now an alias to PAGE_HYPERVISOR_RW (read-write, non-executable mappings). This does not affect the current mapping using PAGE_HYPERVISOR because Xen is currently forcing all the mapping to be non-executable by default (see mfn_to_xen_entry). A follow-up patch will change modify_xen_mappings to use the new flags. Signed-off-by: Julien Grall --- Changes in v3: - Add a comment about _PAGE_DEVICE and _PAGE_NORMAL Changes in v2: - Update the commit message --- xen/include/asm-arm/page.h | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/xen/include/asm-arm/page.h b/xen/include/asm-arm/page.h index aa3e83f5b4..e2b3e402d0 100644 --- a/xen/include/asm-arm/page.h +++ b/xen/include/asm-arm/page.h @@ -69,12 +69,31 @@ * Layout of the flags used for updating the hypervisor page tables * * [0:2] Memory Attribute Index + * [3:4] Permission flags */ #define PAGE_AI_MASK(x) ((x) & 0x7U) -#define PAGE_HYPERVISOR (MT_NORMAL) -#define PAGE_HYPERVISOR_NOCACHE (MT_DEVICE_nGnRE) -#define PAGE_HYPERVISOR_WC (MT_NORMAL_NC) +#define _PAGE_XN_BIT 3 +#define _PAGE_RO_BIT 4 +#define _PAGE_XN (1U << _PAGE_XN_BIT) +#define _PAGE_RO (1U << _PAGE_RO_BIT) +#define PAGE_XN_MASK(x) (((x) >> _PAGE_XN_BIT) & 0x1U) +#define PAGE_RO_MASK(x) (((x) >> _PAGE_RO_BIT) & 0x1U) + +/* + * _PAGE_DEVICE and _PAGE_NORMAL are conveniences defines. They are not + * meant to be used outside of the headers. + */ +#define _PAGE_DEVICE _PAGE_XN +#define _PAGE_NORMAL MT_NORMAL + +#define PAGE_HYPERVISOR_RO (_PAGE_NORMAL|_PAGE_RO|_PAGE_XN) +#define PAGE_HYPERVISOR_RX (_PAGE_NORMAL|_PAGE_RO) +#define PAGE_HYPERVISOR_RW (_PAGE_NORMAL|_PAGE_XN) + +#define PAGE_HYPERVISOR PAGE_HYPERVISOR_RW +#define PAGE_HYPERVISOR_NOCACHE (_PAGE_DEVICE|MT_DEVICE_nGnRE) +#define PAGE_HYPERVISOR_WC (_PAGE_DEVICE|MT_NORMAL_NC) /* * Defines for changing the hypervisor PTE .ro and .nx bits. This is only to be