From patchwork Mon Oct 2 17:31:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 114633 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp924636qgn; Mon, 2 Oct 2017 10:34:09 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBYJ36g1MTr8GM+p/LKyZ/QnSLd5YyWvo9jbg1ognUuB80a1kDydab+xAzT6TCxt0F/gxY8 X-Received: by 10.36.127.146 with SMTP id r140mr19366232itc.79.1506965649119; Mon, 02 Oct 2017 10:34:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506965649; cv=none; d=google.com; s=arc-20160816; b=QgGzIhUv4UHuw3xDRK0G0ac7FDD5YE8n25m4NNvuEMO/P8/iRRThrc4j+4eKN2KnrB q4nwlw3wNZ4mb6ufg4BCZxVcIxf1QKhehkyhebFkvfG8t0nMXqQJ/CIrcygnpTfv3sPT ULdifjStWy9qEG3nclQ3kdAFSfFtt5bz7IF21EnAO/qcxiHfvqXRuAhWH1OxP35z5O8T kKtcT6O/mUPE12QBHky0KUe8zxSiiAEQqzyzWrF4i/hWeFIy9YMH29yg01S5eQdisqVd RpHcvqu2w52P2sXr7vkz04sJe+qsL5Uvlz9YDZG4VMdnGxhF47IKkDbjkmVR2l+ZdVNu h1aQ== 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=aNbr07D4jw9Dedp66fUgtaLyT8KF+CWZ4dVyx+hKYjE=; b=f/HLaYiU7+VEr5W68q0Nme8+f/HblZy7hQIAZTUs8h2C0u8VbLsB3U8VfVH/Jw2qpO s9LpkWDLDKbsMLhr09ilfd4k0H/h1HXVy9i86zwr8ABr5fCcs/ctULB4O6N+kiwpT4Yw xgl7od5IqULm6/KZUt9vl8EZfGKF0Uy0IlkTTUhPcm2XazW/6wWabbRQfLBpMSp5yeOF KObiUGn+MjHhT9Zjpp/T21atSJkceJUJardkD5XHv7gK9nyW9sRB0SvpGtbiTK+3IKi4 BEqQ8uswdmYjc3+VWMMmDSrK9gifyqq0XF2eA7gJNX0H/HSqwBATYYKcydBVseaCXAWC vuOQ== 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 h65si1028315ite.142.2017.10.02.10.34.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Oct 2017 10:34:09 -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 1dz4Zh-0003j5-8t; Mon, 02 Oct 2017 17:32:13 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dz4Zf-0003hD-T6 for xen-devel@lists.xen.org; Mon, 02 Oct 2017 17:32:11 +0000 Received: from [85.158.143.35] by server-8.bemta-6.messagelabs.com id 19/E4-17770-B1872D95; Mon, 02 Oct 2017 17:32:11 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCLMWRWlGSWpSXmKPExsVysyfVTVei4lK kwYvdGhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8byZY3sBcskKzqWnGJsYPws1MXIxSEksJlR 4seCg+wQzmlGiZNnf7F1MXJysAloStz5/IkJxBYRkJa49vkyI0gRs8B2Ronzc3+zgySEBVIkr i1fDdbAIqAq0fV5GlicV8BSYsuXe8wgtoSAvMSutousIDYnUPz2k0NgcSEBC4nTr2cwTWDkXs DIsIpRozi1qCy1SNfQSC+pKDM9oyQ3MTNH19DATC83tbg4MT01JzGpWC85P3cTI9DHDECwg/H yxoBDjJIcTEqivN75lyKF+JLyUyozEosz4otKc1KLDzHKcHAoSfAuKQPKCRalpqdWpGXmAIMN Ji3BwaMkwpsOkuYtLkjMLc5Mh0idYtTl6Lh59w+TEEtefl6qlDjvHpAiAZCijNI8uBGwwL/EK CslzMsIdJQQT0FqUW5mCar8K0ZxDkYlYd6DIFN4MvNK4Da9AjqCCeiIOV0XQI4oSURISTUw+v TxXfEoZC+TW6DAf8Pp4kpJ1wnMXA9eH86XPf5iut8fqXeC/9Ve+Oqs9vVkOzQvoTnEm/vghWj tk+n8Hzx/Xjb/LXnk/sOKbAXXpHNe+4SeTP8yeSnPuyOXji2wfxU0KdBUIu3WwbU6OxrOXJh9 ZdJxrhtCzZXOBY1GU54dSPzTqjIlf9Pei0osxRmJhlrMRcWJABeoTul3AgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-3.tower-21.messagelabs.com!1506965528!82191480!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 33410 invoked from network); 2 Oct 2017 17:32:08 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-3.tower-21.messagelabs.com with SMTP; 2 Oct 2017 17:32:08 -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 EDD671529; Mon, 2 Oct 2017 10:32:07 -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 BB3703F483; Mon, 2 Oct 2017 10:32:06 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 2 Oct 2017 18:31:50 +0100 Message-Id: <20171002173150.5404-10-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, Ross Lagerwall , Konrad Rzeszutek Wilk Subject: [Xen-devel] [PATCH v3 9/9] xen/arm: mm: Use memory flags for modify_xen_mappings rather than custom one 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" This will help to consolidate the page-table code and avoid different path depending on the action to perform. Signed-off-by: Julien Grall Reviewed-by: Andre Przywara Reviewed-by: Stefano Stabellini Reviewed-by: Konrad Rzeszutek Wilk --- Cc: Konrad Rzeszutek Wilk Cc: Ross Lagerwall arch_livepatch_secure is now the same as on x86. It might be possible to combine both, but I left that alone for now. Changes in v3: - Add Stefano's reviewed-by Changes in v2: - Add Andre's reviewed-by --- xen/arch/arm/livepatch.c | 6 +++--- xen/arch/arm/mm.c | 5 ++--- xen/include/asm-arm/page.h | 11 ----------- 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/xen/arch/arm/livepatch.c b/xen/arch/arm/livepatch.c index 3e53524365..279d52cc6c 100644 --- a/xen/arch/arm/livepatch.c +++ b/xen/arch/arm/livepatch.c @@ -146,15 +146,15 @@ int arch_livepatch_secure(const void *va, unsigned int pages, enum va_type type) switch ( type ) { case LIVEPATCH_VA_RX: - flags = PTE_RO; /* R set, NX clear */ + flags = PAGE_HYPERVISOR_RX; break; case LIVEPATCH_VA_RW: - flags = PTE_NX; /* R clear, NX set */ + flags = PAGE_HYPERVISOR_RW; break; case LIVEPATCH_VA_RO: - flags = PTE_NX | PTE_RO; /* R set, NX set */ + flags = PAGE_HYPERVISOR_RO; break; default: diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 57afedf0be..705bdd9cce 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -1041,8 +1041,8 @@ static int create_xen_entries(enum xenmap_operation op, else { pte = *entry; - pte.pt.ro = PTE_RO_MASK(flags); - pte.pt.xn = PTE_NX_MASK(flags); + pte.pt.ro = PAGE_RO_MASK(flags); + pte.pt.xn = PAGE_XN_MASK(flags); if ( !pte.pt.ro && !pte.pt.xn ) { printk("%s: Incorrect combination for addr=%lx\n", @@ -1085,7 +1085,6 @@ int destroy_xen_mappings(unsigned long v, unsigned long e) int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int flags) { - ASSERT((flags & (PTE_NX | PTE_RO)) == flags); return create_xen_entries(MODIFY, s, INVALID_MFN, (e - s) >> PAGE_SHIFT, flags); } diff --git a/xen/include/asm-arm/page.h b/xen/include/asm-arm/page.h index e2b3e402d0..e4be83a7bc 100644 --- a/xen/include/asm-arm/page.h +++ b/xen/include/asm-arm/page.h @@ -96,17 +96,6 @@ #define PAGE_HYPERVISOR_WC (_PAGE_DEVICE|MT_NORMAL_NC) /* - * Defines for changing the hypervisor PTE .ro and .nx bits. This is only to be - * used with modify_xen_mappings. - */ -#define _PTE_NX_BIT 0U -#define _PTE_RO_BIT 1U -#define PTE_NX (1U << _PTE_NX_BIT) -#define PTE_RO (1U << _PTE_RO_BIT) -#define PTE_NX_MASK(x) (((x) >> _PTE_NX_BIT) & 0x1U) -#define PTE_RO_MASK(x) (((x) >> _PTE_RO_BIT) & 0x1U) - -/* * Stage 2 Memory Type. * * These are valid in the MemAttr[3:0] field of an LPAE stage 2 page