From patchwork Mon Oct 2 17:31:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 114637 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp924672qgn; Mon, 2 Oct 2017 10:34:12 -0700 (PDT) X-Google-Smtp-Source: AOwi7QC6+q0pVDjVBJEPtX+DkDauQ7knOOKUXZsF5SX1CSQvqFsKBnsvtCnt9B3Jg96Vqa5b01BH X-Received: by 10.36.120.206 with SMTP id p197mr19820086itc.54.1506965651926; 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=PxRTS6eajI7MIInzNCsEViQW8T4xtimOiSrRAc/rHIWm1w9QrinBOLUPK5dM98TiaZ L/YF2zgVTlFgwsvYSgv6W+W0GpP8Ye0iIpG7/B98JvujI7LgKynkUJLc65/dPsR4hH3d F9asB//ASGTE77AoHTOg82ixrEarpeWA/yDow0PVO63hCS9qi6pLdQohur9gts6Zgsow j4DpqVF2ZRbB7vb0zdyaVFkLq71QWoioaJTHPAuk9lEA5t7voRisjb0f5G4W71lqMAWR pVO9IXxsUqDorTCI/FzjhWAnwFsgwnjjkKbUb6QArOdK9909Bjrnm9cIwC9aeQu+czEH BvYw== 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=ruUubyqLrBpe6d3iy2issVhCl6PkGicTpogC16gWjUo=; b=0Ri+JEE5Tq8h6GD6n41NVvZYpMNTZ4Dm1pgtKkgc3ZC0T/D+Kz32tWmJKWM8/zFE08 8ACPsZDSF6FLgxJtl6ebJslKbL6WkWjET9lYdciBgk04QkU1ZAVC/RFYyrNRmkvfKuoh bmFXcHbkM+j8pfQUw/JpVzj9e42CbqihZMmmyFMCE4QyPl/E/2pLAVQUf08CCRPFaUqL tyJvFUz1e3tDq1h761iILFx8SlsuBAXlCXr/qI6xmj6uJheQ6FhOCpJAbQrxYqW0YFAd QsIAPzkCNDk0CXxOJj6es/td5ppgcUyZH/7xaTPxZz4+8r7lyGLUoos4Q73pwOSPvBYn MUww== 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 z72si7113938iof.325.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 1dz4ZX-0003Z6-4W; Mon, 02 Oct 2017 17:32:03 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dz4ZU-0003Yb-UU for xen-devel@lists.xen.org; Mon, 02 Oct 2017 17:32:01 +0000 Received: from [85.158.143.35] by server-5.bemta-6.messagelabs.com id 0D/19-03454-01872D95; Mon, 02 Oct 2017 17:32:00 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrBLMWRWlGSWpSXmKPExsVysyfVTZe/4lK kwaefAhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8a796UFe3wqOj49ZWlg/GrVxcjFISSwmVGi 5cF5RgjnNKPEh8b7LF2MnBxsApoSdz5/YgKxRQSkJa59vswIYjMLREoc/vCDHcQWFvCTePW+C 6yGRUBVou3qAbBeXgELiambVoHVSwjIS+xqu8gKYnMKWErcfnKIGcQWAqo5/XoG0wRG7gWMDK sYNYpTi8pSi3SNDPSSijLTM0pyEzNzdA0NzPRyU4uLE9NTcxKTivWS83M3MQL9ywAEOxh/LQs 4xCjJwaQkyuudfylSiC8pP6UyI7E4I76oNCe1+BCjDAeHkgSvWDlQTrAoNT21Ii0zBxhoMGkJ Dh4lEd57ZUBp3uKCxNzizHSI1ClGY45HN+7+YeLouAkkhVjy8vNSpcR5jUAmCYCUZpTmwQ2CR cAlRlkpYV5GoNOEeApSi3IzS1DlXzGKczAqCfP+AVnIk5lXArfvFdApTECnzOm6AHJKSSJCSq qBkdvwUfwN/7yfS09ca6qtkA7YabPvpMaWoze4zlU0rdwj815ly+U3y8N/+K/OKw00kj79P/N Qr9Gyj6nHj9T/MU4s92JZmnpoz322smfi7NqLHmiYVf0LfFLG5tRR1BQnbrQz4OtyI86NZ9yr eBKnH2zfZDX/0tWZb31U3pSHcmd2hGgeXfBokRJLcUaioRZzUXEiALJPFcJ7AgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-12.tower-21.messagelabs.com!1506965518!85651693!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 29701 invoked from network); 2 Oct 2017 17:31:58 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-12.tower-21.messagelabs.com with SMTP; 2 Oct 2017 17:31:58 -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 4C6F71596; Mon, 2 Oct 2017 10:31:58 -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 348303F483; Mon, 2 Oct 2017 10:31:57 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 2 Oct 2017 18:31:42 +0100 Message-Id: <20171002173150.5404-2-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 1/9] xen/arm: page: Use ARMv8 naming to improve readability 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 is based on the Linux ARMv8 naming scheme (see arch/arm64/mm/proc.S). Each type will contain "NORMAL" or "DEVICE" to make clear whether each attribute targets device or normal memory. Signed-off-by: Julien Grall --- Changes in v3: - The ai '000' is named MT_DEVICE_nGnRnE and not MT_DEVICE_nGnRE. The definition is still valid. - Expand the comment to point to "Device Memory" section in the ARM ARM. Changes in v2: * Move the patch before "xen/arm: page: Clean-up the definition of MAIRVAL" --- xen/arch/arm/kernel.c | 2 +- xen/arch/arm/mm.c | 28 ++++++++++++++-------------- xen/arch/arm/platforms/vexpress.c | 2 +- xen/drivers/video/arm_hdlcd.c | 2 +- xen/include/asm-arm/page.h | 35 +++++++++++++++++++---------------- 5 files changed, 36 insertions(+), 33 deletions(-) diff --git a/xen/arch/arm/kernel.c b/xen/arch/arm/kernel.c index 9c183f96da..a12baa86e7 100644 --- a/xen/arch/arm/kernel.c +++ b/xen/arch/arm/kernel.c @@ -54,7 +54,7 @@ void copy_from_paddr(void *dst, paddr_t paddr, unsigned long len) s = paddr & (PAGE_SIZE-1); l = min(PAGE_SIZE - s, len); - set_fixmap(FIXMAP_MISC, maddr_to_mfn(paddr), MT_BUFFERABLE); + set_fixmap(FIXMAP_MISC, maddr_to_mfn(paddr), MT_NORMAL_NC); memcpy(dst, src + s, l); clean_dcache_va_range(dst, l); diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 9a37f29ce6..f41c6ce6f1 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -290,7 +290,7 @@ static inline lpae_t mfn_to_xen_entry(mfn_t mfn, unsigned attr) switch ( attr ) { - case MT_BUFFERABLE: + case MT_NORMAL_NC: /* * ARM ARM: Overlaying the shareability attribute (DDI * 0406C.b B3-1376 to 1377) @@ -305,8 +305,8 @@ static inline lpae_t mfn_to_xen_entry(mfn_t mfn, unsigned attr) */ e.pt.sh = LPAE_SH_OUTER; break; - case MT_UNCACHED: - case MT_DEV_SHARED: + case MT_DEVICE_nGnRnE: + case MT_DEVICE_nGnRE: /* * Shareability is ignored for non-Normal memory, Outer is as * good as anything. @@ -369,7 +369,7 @@ static void __init create_mappings(lpae_t *second, count = nr_mfns / LPAE_ENTRIES; p = second + second_linear_offset(virt_offset); - pte = mfn_to_xen_entry(_mfn(base_mfn), MT_WRITEALLOC); + pte = mfn_to_xen_entry(_mfn(base_mfn), MT_NORMAL); if ( granularity == 16 * LPAE_ENTRIES ) pte.pt.contig = 1; /* These maps are in 16-entry contiguous chunks. */ for ( i = 0; i < count; i++ ) @@ -422,7 +422,7 @@ void *map_domain_page(mfn_t mfn) else if ( map[slot].pt.avail == 0 ) { /* Commandeer this 2MB slot */ - pte = mfn_to_xen_entry(_mfn(slot_mfn), MT_WRITEALLOC); + pte = mfn_to_xen_entry(_mfn(slot_mfn), MT_NORMAL); pte.pt.avail = 1; write_pte(map + slot, pte); break; @@ -543,7 +543,7 @@ static inline lpae_t pte_of_xenaddr(vaddr_t va) { paddr_t ma = va + phys_offset; - return mfn_to_xen_entry(maddr_to_mfn(ma), MT_WRITEALLOC); + return mfn_to_xen_entry(maddr_to_mfn(ma), MT_NORMAL); } /* Map the FDT in the early boot page table */ @@ -652,7 +652,7 @@ void __init setup_pagetables(unsigned long boot_phys_offset, paddr_t xen_paddr) /* Initialise xen second level entries ... */ /* ... Xen's text etc */ - pte = mfn_to_xen_entry(maddr_to_mfn(xen_paddr), MT_WRITEALLOC); + pte = mfn_to_xen_entry(maddr_to_mfn(xen_paddr), MT_NORMAL); pte.pt.xn = 0;/* Contains our text mapping! */ xen_second[second_table_offset(XEN_VIRT_START)] = pte; @@ -669,7 +669,7 @@ void __init setup_pagetables(unsigned long boot_phys_offset, paddr_t xen_paddr) /* ... Boot Misc area for xen relocation */ dest_va = BOOT_RELOC_VIRT_START; - pte = mfn_to_xen_entry(maddr_to_mfn(xen_paddr), MT_WRITEALLOC); + pte = mfn_to_xen_entry(maddr_to_mfn(xen_paddr), MT_NORMAL); /* Map the destination in xen_second. */ xen_second[second_table_offset(dest_va)] = pte; /* Map the destination in boot_second. */ @@ -700,7 +700,7 @@ void __init setup_pagetables(unsigned long boot_phys_offset, paddr_t xen_paddr) unsigned long va = XEN_VIRT_START + (i << PAGE_SHIFT); if ( !is_kernel(va) ) break; - pte = mfn_to_xen_entry(mfn, MT_WRITEALLOC); + pte = mfn_to_xen_entry(mfn, MT_NORMAL); pte.pt.table = 1; /* 4k mappings always have this bit set */ if ( is_kernel_text(va) || is_kernel_inittext(va) ) { @@ -771,7 +771,7 @@ int init_secondary_pagetables(int cpu) for ( i = 0; i < DOMHEAP_SECOND_PAGES; i++ ) { pte = mfn_to_xen_entry(virt_to_mfn(domheap+i*LPAE_ENTRIES), - MT_WRITEALLOC); + MT_NORMAL); pte.pt.table = 1; write_pte(&first[first_table_offset(DOMHEAP_VIRT_START+i*FIRST_SIZE)], pte); } @@ -869,13 +869,13 @@ void __init setup_xenheap_mappings(unsigned long base_mfn, mfn_t first_mfn = alloc_boot_pages(1, 1); clear_page(mfn_to_virt(first_mfn)); - pte = mfn_to_xen_entry(first_mfn, MT_WRITEALLOC); + pte = mfn_to_xen_entry(first_mfn, MT_NORMAL); pte.pt.table = 1; write_pte(p, pte); first = mfn_to_virt(first_mfn); } - pte = mfn_to_xen_entry(_mfn(mfn), MT_WRITEALLOC); + pte = mfn_to_xen_entry(_mfn(mfn), MT_NORMAL); /* TODO: Set pte.pt.contig when appropriate. */ write_pte(&first[first_table_offset(vaddr)], pte); @@ -915,7 +915,7 @@ void __init setup_frametable_mappings(paddr_t ps, paddr_t pe) for ( i = 0; i < nr_second; i++ ) { clear_page(mfn_to_virt(mfn_add(second_base, i))); - pte = mfn_to_xen_entry(mfn_add(second_base, i), MT_WRITEALLOC); + pte = mfn_to_xen_entry(mfn_add(second_base, i), MT_NORMAL); pte.pt.table = 1; write_pte(&xen_first[first_table_offset(FRAMETABLE_VIRT_START)+i], pte); } @@ -969,7 +969,7 @@ static int create_xen_table(lpae_t *entry) if ( p == NULL ) return -ENOMEM; clear_page(p); - pte = mfn_to_xen_entry(virt_to_mfn(p), MT_WRITEALLOC); + pte = mfn_to_xen_entry(virt_to_mfn(p), MT_NORMAL); pte.pt.table = 1; write_pte(entry, pte); return 0; diff --git a/xen/arch/arm/platforms/vexpress.c b/xen/arch/arm/platforms/vexpress.c index 9badbc079d..df2c4b5bec 100644 --- a/xen/arch/arm/platforms/vexpress.c +++ b/xen/arch/arm/platforms/vexpress.c @@ -65,7 +65,7 @@ int vexpress_syscfg(int write, int function, int device, uint32_t *data) uint32_t *syscfg = (uint32_t *) FIXMAP_ADDR(FIXMAP_MISC); int ret = -1; - set_fixmap(FIXMAP_MISC, maddr_to_mfn(V2M_SYS_MMIO_BASE), MT_DEV_SHARED); + set_fixmap(FIXMAP_MISC, maddr_to_mfn(V2M_SYS_MMIO_BASE), MT_DEVICE_nGnRE); if ( syscfg[V2M_SYS_CFGCTRL/4] & V2M_SYS_CFG_START ) goto out; diff --git a/xen/drivers/video/arm_hdlcd.c b/xen/drivers/video/arm_hdlcd.c index 5fa7f518b1..1175399dbc 100644 --- a/xen/drivers/video/arm_hdlcd.c +++ b/xen/drivers/video/arm_hdlcd.c @@ -227,7 +227,7 @@ void __init video_init(void) /* uses FIXMAP_MISC */ set_pixclock(videomode->pixclock); - set_fixmap(FIXMAP_MISC, maddr_to_mfn(hdlcd_start), MT_DEV_SHARED); + set_fixmap(FIXMAP_MISC, maddr_to_mfn(hdlcd_start), MT_DEVICE_nGnRE); HDLCD[HDLCD_COMMAND] = 0; HDLCD[HDLCD_LINELENGTH] = videomode->xres * bytes_per_pixel; diff --git a/xen/include/asm-arm/page.h b/xen/include/asm-arm/page.h index 30fcfa0778..3d0bc6db81 100644 --- a/xen/include/asm-arm/page.h +++ b/xen/include/asm-arm/page.h @@ -25,15 +25,18 @@ * LPAE Memory region attributes. Indexed by the AttrIndex bits of a * LPAE entry; the 8-bit fields are packed little-endian into MAIR0 and MAIR1. * + * See section "Device memory" B2.7.2 in ARM DDI 0487B.a for more + * details about the meaning of *G*R*E. + * * ai encoding - * MT_UNCACHED 000 0000 0000 -- Strongly Ordered - * MT_BUFFERABLE 001 0100 0100 -- Non-Cacheable - * MT_WRITETHROUGH 010 1010 1010 -- Write-through - * MT_WRITEBACK 011 1110 1110 -- Write-back - * MT_DEV_SHARED 100 0000 0100 -- Device + * MT_DEVICE_nGnRnE 000 0000 0000 -- Strongly Ordered/Device nGnRnE + * MT_NORMAL_NC 001 0100 0100 -- Non-Cacheable + * MT_NORMAL_WT 010 1010 1010 -- Write-through + * MT_NORMAL_WB 011 1110 1110 -- Write-back + * MT_DEVICE_nGnRE 100 0000 0100 -- Device nGnRE * ?? 101 * reserved 110 - * MT_WRITEALLOC 111 1111 1111 -- Write-back write-allocate + * MT_NORMAL 111 1111 1111 -- Write-back write-allocate */ #define MAIR0VAL 0xeeaa4400 #define MAIR1VAL 0xff000004 @@ -47,16 +50,16 @@ * registers, as defined above. * */ -#define MT_UNCACHED 0x0 -#define MT_BUFFERABLE 0x1 -#define MT_WRITETHROUGH 0x2 -#define MT_WRITEBACK 0x3 -#define MT_DEV_SHARED 0x4 -#define MT_WRITEALLOC 0x7 - -#define PAGE_HYPERVISOR (MT_WRITEALLOC) -#define PAGE_HYPERVISOR_NOCACHE (MT_DEV_SHARED) -#define PAGE_HYPERVISOR_WC (MT_BUFFERABLE) +#define MT_DEVICE_nGnRnE 0x0 +#define MT_NORMAL_NC 0x1 +#define MT_NORMAL_WT 0x2 +#define MT_NORMAL_WB 0x3 +#define MT_DEVICE_nGnRE 0x4 +#define MT_NORMAL 0x7 + +#define PAGE_HYPERVISOR (MT_NORMAL) +#define PAGE_HYPERVISOR_NOCACHE (MT_DEVICE_nGnRE) +#define PAGE_HYPERVISOR_WC (MT_NORMAL_NC) /* * Defines for changing the hypervisor PTE .ro and .nx bits. This is only to be From patchwork Mon Oct 2 17:31:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 114636 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp924666qgn; Mon, 2 Oct 2017 10:34:11 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCMVB/LxTP1IY6xqFaymqPi6Vc/YpByNN7JDg2LNj9KMorLCEqA070PtTUixFDvKPyLqys2 X-Received: by 10.36.17.193 with SMTP id 184mr4233359itf.68.1506965651214; 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=E2V9og7dGybm9j/Ui7boa2yAsf0BP5lERohjGXws1OtXGuFjJE0FW8rxjITizF1f29 8llRvn/GfDvDjvA6fmk2y7aMuAHmD+hITyf8sfixFDAbbWnbVKtMsazku0Gt4UoaJNn5 zMJn7seExzgrfQRCDMTwCElJEr/p26L03C34jOnScjaPYvGn1ifAHAq31DIuGpkSBCTC x9+o89XCaUq8WjSKjBRGYcH22wLaoZm8Sb7VyTlbKm59gvtCaiTUquZcDOGDgbBQ/7Mu reqUg5FD+eH5ToiHB00iOG5cFnCPCJKJ5Unf/HG2dxx32jlk6elbvQI5ypdA60zN5Do9 IpPQ== 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=KpbqpBL6iXu1hKiDxUxdIkPzD+6w/7u80UJjKieeyGY=; b=qeMt8n6lAdc+uFaqLxsksaJsqxdV0saQ+J08qD9idm1ZnOIRO03cpDTV5aiJGj9Cmh VbYW8yKlmbAUM2R7sAcc2uPvH1GBoij3Zwsyl37aZPjBg3MY2LTedsJ+Ewusgr6Q0Ccl uXt2rviqGsc4W1q7f7n68cTL3Ahnhs24OXLcIlH30FQNolIyd0HUPxL5k4p1CwMJiw4x KICyGkc4dBvmYOoNw2LOfXiJ9uIiV2pmOVGaS2sVi6IMN4FJK5SW87PvYiDlNKIqSE5+ i590FA/GkQANmb0bHFiUm96VHNIGKfOTnKLTWrEDGK0WihmPLDZ+KNauQxzD1+zWOGRr axFQ== 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 e10si234457itf.1.2017.10.02.10.34.03 (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 1dz4ZX-0003ZK-Cn; Mon, 02 Oct 2017 17:32:03 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dz4ZV-0003Ys-Ma for xen-devel@lists.xen.org; Mon, 02 Oct 2017 17:32:01 +0000 Received: from [85.158.137.68] by server-3.bemta-3.messagelabs.com id 29/10-02046-01872D95; Mon, 02 Oct 2017 17:32:00 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrELMWRWlGSWpSXmKPExsVysyfVTVeg4lK kwcpmfoslHxezODB6HN39mymAMYo1My8pvyKBNWPlxUmsBadFKtZfeczWwNgm0MXIxSEksJlR 4v3bFqYuRk4g5zSjxNG5QiA2m4CmxJ3Pn8DiIgLSEtc+X2YEsZkFIiUOf/jBDmILC3hKNFxvB rNZBFQl/mydxgxi8wpYSPzZ8B6sXkJAXmJX20VWEJtTwFLi9pNDzBC7LCROv57BNIGRewEjwy pGjeLUorLUIl1DQ72kosz0jJLcxMwcXUMDY73c1OLixPTUnMSkYr3k/NxNjED/MgDBDsbVv50 OMUpyMCmJ8nrnX4oU4kvKT6nMSCzOiC8qzUktPsQow8GhJMF7vQwoJ1iUmp5akZaZAww0mLQE B4+SCO89kDRvcUFibnFmOkTqFKMuR8fNu3+YhFjy8vNSpcR5jcqBigRAijJK8+BGwIL+EqOsl DAvI9BRQjwFqUW5mSWo8q8YxTkYlYR5/4Cs4snMK4Hb9AroCCagI+Z0XQA5oiQRISXVwDifa/ UHR481MQcCRBIkDr6p1561uGrjR/skHr9jCfHhckd4ij/X6l4LcWdV/BtovHvWm9+NqndF8zO m6MxJ5bfTvsG2NFMhvs6ZaXNAmdJ7w9Olwr9vHRA4tIldVakmmFWuqnLK7iUL9yVKOC1stOSy W/6SY2Ndpd3DZ8armBuPM5mG/2R2UmIpzkg01GIuKk4EAJKAMVF1AgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-3.tower-31.messagelabs.com!1506965519!117534550!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests=UPPERCASE_25_50 X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 19765 invoked from network); 2 Oct 2017 17:32:00 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-3.tower-31.messagelabs.com with SMTP; 2 Oct 2017 17:32:00 -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 7614F1529; Mon, 2 Oct 2017 10:31:59 -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 8AB8F3F483; Mon, 2 Oct 2017 10:31:58 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 2 Oct 2017 18:31:43 +0100 Message-Id: <20171002173150.5404-3-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 2/9] xen/arm: page: Clean-up the definition of MAIRVAL 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 MAIRVAL is defined in term of MAIR0VAL and MAIR1VAL which are both hardcoded value. This makes quite difficult to understand the value written in both registers. Rework the definition by using value of each attribute shifted by their associated index. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v3: - s/above/below/ in the comment - Add Stefano's reviewed-by Changes in v2: - Move this patch after "xen/arm: page: Use ARMv8 naming to improve readability" --- xen/include/asm-arm/page.h | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/xen/include/asm-arm/page.h b/xen/include/asm-arm/page.h index 3d0bc6db81..0ae1a2587b 100644 --- a/xen/include/asm-arm/page.h +++ b/xen/include/asm-arm/page.h @@ -22,6 +22,21 @@ #define LPAE_SH_INNER 0x3 /* + * Attribute Indexes. + * + * These are valid in the AttrIndx[2:0] field of an LPAE stage 1 page + * table entry. They are indexes into the bytes of the MAIR* + * registers, as defined below. + * + */ +#define MT_DEVICE_nGnRnE 0x0 +#define MT_NORMAL_NC 0x1 +#define MT_NORMAL_WT 0x2 +#define MT_NORMAL_WB 0x3 +#define MT_DEVICE_nGnRE 0x4 +#define MT_NORMAL 0x7 + +/* * LPAE Memory region attributes. Indexed by the AttrIndex bits of a * LPAE entry; the 8-bit fields are packed little-endian into MAIR0 and MAIR1. * @@ -38,24 +53,17 @@ * reserved 110 * MT_NORMAL 111 1111 1111 -- Write-back write-allocate */ -#define MAIR0VAL 0xeeaa4400 -#define MAIR1VAL 0xff000004 -#define MAIRVAL (MAIR0VAL|MAIR1VAL<<32) +#define MAIR(attr, mt) (_AC(attr, ULL) << ((mt) * 8)) -/* - * Attribute Indexes. - * - * These are valid in the AttrIndx[2:0] field of an LPAE stage 1 page - * table entry. They are indexes into the bytes of the MAIR* - * registers, as defined above. - * - */ -#define MT_DEVICE_nGnRnE 0x0 -#define MT_NORMAL_NC 0x1 -#define MT_NORMAL_WT 0x2 -#define MT_NORMAL_WB 0x3 -#define MT_DEVICE_nGnRE 0x4 -#define MT_NORMAL 0x7 +#define MAIRVAL (MAIR(0x00, MT_DEVICE_nGnRnE)| \ + MAIR(0x44, MT_NORMAL_NC) | \ + MAIR(0xaa, MT_NORMAL_WT) | \ + MAIR(0xee, MT_NORMAL_WB) | \ + MAIR(0x04, MT_DEVICE_nGnRE) | \ + MAIR(0xff, MT_NORMAL)) + +#define MAIR0VAL (MAIRVAL & 0xffffffff) +#define MAIR1VAL (MAIRVAL >> 32) #define PAGE_HYPERVISOR (MT_NORMAL) #define PAGE_HYPERVISOR_NOCACHE (MT_DEVICE_nGnRE) From patchwork Mon Oct 2 17:31:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 114630 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp924536qgn; Mon, 2 Oct 2017 10:34:02 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBNxgdOCfSERvyyGncqBct+ReH3h0vVPL+E/8XdDFnaTqCDbBTrmwTJc03VJaJ1vgmMvNGo X-Received: by 10.36.46.140 with SMTP id i134mr18640031ita.137.1506965642100; Mon, 02 Oct 2017 10:34:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506965642; cv=none; d=google.com; s=arc-20160816; b=aQFTt1OhEeEmDJZxwaDq3k1XtPCQeRuZH7a9q3sC1mAaq7LJZiAAmd5zP0/4WF0BuG FRsglM48LjQCiGdcSG9KQAK4wRqa0bS9xGlkXIofBkzzLyvq0UDgdUfD1/U+ZJXcoeGl BJt6IHTK2XEly7gVsj3Lh9PCh3aSRdUqZ/tgOiWCVl9vsz3ZBuHpJD2VTLdhfnHbM7Ze PPfu/5A+s90x6jtlpA85GYTUUu4EZ/kNp2vT5gJp5/6lreUaU2RkaURX7e9aOo6DYqiO MZyTvvnKxWoKCZS1xZoX5B+Ur3+vpXgZ10+0BKaNcu2fLSQ1n9pwsxgASOyVwL4RNvtx YfLA== 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=Wcs+rxlnlRcfLRDyfRRQ5EqZMD7/EOdUrI+npvrjWcU=; b=MTXWRcvjqp7gb/FDdP4/WwJdyttCAFxuIHn5Kopu+77CgAGiR+M6r9xDcEEB31EzFK cY2eZq5cZeOe8XgbkZ40dIPIpmqvHs/zJdOfaDRXYvdihE5rHabckKuGQVqm/20BnTKn n9CdYEha1PcAscbDa+WR+oh28rygfhuez3vDDYSk99teFs1rLlY+PfEzxMZJtk43RkUy rl7sxyDizvuGrS3QZdqH84yPWkZS0WTI2Lmydbewz2ob1lcVPUIe7qmC/khhp8hVUfNK WGZ+zy/1PBoBRjd/O9Ff9VlEIdSiKrKnr/P+f9iL0VccVTR4Zf7CSVNG8nNkzqM95xgY vO5A== 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 k9si4178087ith.76.2017.10.02.10.34.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Oct 2017 10:34:02 -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 1dz4ZX-0003Zp-Ov; Mon, 02 Oct 2017 17:32:03 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dz4ZW-0003Yb-5Y for xen-devel@lists.xen.org; Mon, 02 Oct 2017 17:32:02 +0000 Received: from [193.109.254.147] by server-5.bemta-6.messagelabs.com id 8E/29-03454-11872D95; Mon, 02 Oct 2017 17:32:01 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrILMWRWlGSWpSXmKPExsVysyfVTVew4lK kwa3/4hZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8bRGTEFF0Urvlw4ztjAuJ2/i5GLQ0hgM6PE +V972CCc04wSyyfPY+li5ORgE9CUuPP5ExOILSIgLXHt82VGEJtZIFLi8Icf7F2MHBzCAuESV 19EgYRZBFQlbr9tYgWxeQUsJF5dXswOYksIyEvsarsIFucUsJS4/eQQM4gtBFRz+vUMpgmM3A sYGVYxahSnFpWlFukaGeolFWWmZ5TkJmbm6BoamOnlphYXJ6an5iQmFesl5+duYgR6lwEIdjD +WRZwiFGSg0lJlNc7/1KkEF9SfkplRmJxRnxRaU5q8SFGGQ4OJQne62VAOcGi1PTUirTMHGCY waQlOHiURHgjy4HSvMUFibnFmekQqVOMuhwdN+/+YRJiycvPS5US5zUCKRIAKcoozYMbAQv5S 4yyUsK8jEBHCfEUpBblZpagyr9iFOdgVBLm/QNyCU9mXgncpldARzABHTGn6wLIESWJCCmpBk YTtYNeq5/MqXivx8r5zaH9VF6P5pfaqp7dJR/ZzS68vbffQXrfjwzNiYv4bh8UXsYoerlqatz mX+muM5ujXDj2amb1aNzI6dxxiyPoq9s+oQnsfiKps1vubFnzqaJ6w8fn7mUxeilr+I5dNJvJ JHc3fbPi63WLjQyCv07nmzan8Fyo+7/C7CwlluKMREMt5qLiRABYRcrodAIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-16.tower-27.messagelabs.com!1506965520!119253324!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 52338 invoked from network); 2 Oct 2017 17:32:01 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-16.tower-27.messagelabs.com with SMTP; 2 Oct 2017 17:32:01 -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 9FCCB1596; Mon, 2 Oct 2017 10:32:00 -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 B47483F483; Mon, 2 Oct 2017 10:31:59 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 2 Oct 2017 18:31:44 +0100 Message-Id: <20171002173150.5404-4-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 3/9] xen/arm: mm: Rename and clarify AP[1] in the stage-1 page table 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" The description of AP[1] in Xen is based on testing rather than the ARM ARM. Per the ARM ARM, on EL2 stage-1 page table, AP[1] is RES1 as the translation regime applies to only one exception level (see D4.4.4 and G4.6.1 in ARM DDI 0487B.a). Update the comment and also rename the field to match the description in the ARM ARM. Signed-off-by: Julien Grall Reviewed-by: Andre Przywara Acked-by: Stefano Stabellini --- Changes in v3: - Add Stefano's acked-by Changes in v2: - Add Andre's reviewed-by --- xen/arch/arm/mm.c | 10 +++++----- xen/include/asm-arm/lpae.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index f41c6ce6f1..73677902d4 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -273,7 +273,7 @@ static inline lpae_t mfn_to_xen_entry(mfn_t mfn, unsigned attr) .table = 0, /* Set to 1 for links and 4k maps */ .ai = attr, .ns = 1, /* Hyp mode is in the non-secure world */ - .user = 1, /* See below */ + .up = 1, /* See below */ .ro = 0, /* Assume read-write */ .af = 1, /* No need for access tracking */ .ng = 1, /* Makes TLB flushes easier */ @@ -282,10 +282,10 @@ static inline lpae_t mfn_to_xen_entry(mfn_t mfn, unsigned attr) .avail = 0, /* Reference count for domheap mapping */ }}; /* - * Setting the User bit is strange, but the ATS1H[RW] instructions - * don't seem to work otherwise, and since we never run on Xen - * pagetables in User mode it's OK. If this changes, remember - * to update the hard-coded values in head.S too. + * For EL2 stage-1 page table, up (aka AP[1]) is RES1 as the translation + * regime applies to only one exception level (see D4.4.4 and G4.6.1 + * in ARM DDI 0487B.a). If this changes, remember to update the + * hard-coded values in head.S too. */ switch ( attr ) diff --git a/xen/include/asm-arm/lpae.h b/xen/include/asm-arm/lpae.h index 118ee5ae1a..b30853e79d 100644 --- a/xen/include/asm-arm/lpae.h +++ b/xen/include/asm-arm/lpae.h @@ -35,7 +35,7 @@ typedef struct __packed { */ unsigned long ai:3; /* Attribute Index */ unsigned long ns:1; /* Not-Secure */ - unsigned long user:1; /* User-visible */ + unsigned long up:1; /* Unpriviledged access */ unsigned long ro:1; /* Read-Only */ unsigned long sh:2; /* Shareability */ unsigned long af:1; /* Access Flag */ From patchwork Mon Oct 2 17:31:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 114629 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp924515qgn; Mon, 2 Oct 2017 10:34:01 -0700 (PDT) X-Google-Smtp-Source: AOwi7QClZ9hvHlqauK1dnbnZVCGs7Y+hgnfVsQBOUGi3Ax3YYJgr5WW2bBNxhsN3n6/dRa4svu3t X-Received: by 10.107.150.76 with SMTP id y73mr25019403iod.132.1506965641394; Mon, 02 Oct 2017 10:34:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506965641; cv=none; d=google.com; s=arc-20160816; b=i5xwRs480ONrddLtxaraF2WeuzyImwhuMSjoZlVS2U0VkfHjXNgJjjpH9wZ28MTLR7 R8PbfOoLcU7flbtISap86iXHHxxfeBYgvQoYL91Lv8o8kejTMifq8t3QAj6s8hGuWp8j M9ypXca/2i1HNKQaGTpKmLHErY11TivUNfNhkDdLPeKpPpcFEsP+xk+yQKlzdm5NWNGG 8aEU/ITXTz78G8BHlOB/KDQjzVdonFHDpeVxvI1gZ2xgOuCawoFhUM3LWqPJKj9cUm8T pmoK72G6XCQtiwVxHQyW/sNTMgi3Ft5A03fbVco7lHYOC+kf1OmfX2U7OBLy7z6vbSCo Xr6w== 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=DiNPr/Us6MXRlGFxQGp+yNhrfuEagZyulkzG4+4UKy0=; b=A54zJn7Qfs3h3VWy1GPVDczSeu81LHNM+ED04RfLrVGj3ntL2dvlyotT9TOFtlgloR rH6rRk5LP6XtHE60sK96xSZnOr6U2/TxOup9DGeopNDhXhVi7Eedk3zfXFDCX+6rfTfb p5WAcfo42IM+NXOkXt4cbE9NztJQXotm7dbCEhQIIHKu3iyz0bW2tvO+EVr0HCoJ8HP8 J2sEfCdpbVmI68CJL4/8j70FzoL921n7SEumMncrqPec8Ue9X/cALGmRBpTtlo2UyjAo HTKSLiaH9ujAX5kK4LpNellP3YDtlbFam0pDHb0SrwCpz0+872tPMQgdhrYjvJsaO8RZ noUQ== 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 c92si10053566ioj.48.2017.10.02.10.34.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Oct 2017 10:34:01 -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 1dz4ZZ-0003aO-0A; Mon, 02 Oct 2017 17:32:05 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dz4ZX-0003ZH-Oz for xen-devel@lists.xen.org; Mon, 02 Oct 2017 17:32:03 +0000 Received: from [193.109.254.147] by server-3.bemta-6.messagelabs.com id 3D/1D-03093-31872D95; Mon, 02 Oct 2017 17:32:03 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMLMWRWlGSWpSXmKPExsVysyfVTVeo4lK kwe158hZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8acXY2sBU85K+b92M7WwPiWvYuRi0NIYDOj xIJvzcwQzmlGic2ds1i7GDk52AQ0Je58/sQEYosISEtc+3yZEcRmFoiUOPzhBzuILQxkN3zbw wJiswioSnw5fBTM5hWwkNh6/DHYHAkBeYldbRfBbE4BS4nbTw4xg9hCQDWnX89gmsDIvYCRYR WjRnFqUVlqka6RhV5SUWZ6RkluYmaOrqGBmV5uanFxYnpqTmJSsV5yfu4mRqCHGYBgB+P5tYG HGCU5mJREeb3zL0UK8SXlp1RmJBZnxBeV5qQWH2KU4eBQkuAVKwfKCRalpqdWpGXmAEMNJi3B waMkwnuvDCjNW1yQmFucmQ6ROsWoy9Fx8+4fJiGWvPy8VClx3j0gRQIgRRmleXAjYGF/iVFWS piXEegoIZ6C1KLczBJU+VeM4hyMSsK8B0Gm8GTmlcBtegV0BBPQEXO6LoAcUZKIkJJqYGTlyJ CMrD6yuYNv03m/74rR5udXVDat7tzk6iS9TXN5XmDe+veHJW+w8+XqGbxfacV0zTHF4JC73L8 Hit9mbVYzzH1vdk5x2Yw/SxNL+SVEn0nW/t35YFPfrh8G0c5TtzYZPGN3SGif9u2jfZy+yqrk le9y7gXO0A98nbJxapW5dMdZsYpf7EosxRmJhlrMRcWJAFoDFrF2AgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-10.tower-27.messagelabs.com!1506965522!96382442!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 16134 invoked from network); 2 Oct 2017 17:32:02 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-10.tower-27.messagelabs.com with SMTP; 2 Oct 2017 17:32:02 -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 C9AF31529; Mon, 2 Oct 2017 10:32:01 -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 DE3A23F483; Mon, 2 Oct 2017 10:32:00 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 2 Oct 2017 18:31:45 +0100 Message-Id: <20171002173150.5404-5-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 4/9] xen/arm: Switch to SYS_STATE_boot just after end_boot_allocator() 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" We should consider the early boot period to end when we stop using the boot allocator. This is inline with x86 and will be helpful to know whether we should allocate memory from the boot allocator or xenheap. Signed-off-by: Julien Grall Reviewed-by: Andre Przywara Reviewed-by: Stefano Stabellini --- Changes in v3: - Add Stefano's reviewed-by Changes in v2: - Add Andre's reviewed-by --- xen/arch/arm/setup.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 3df451ae6f..16a3b1be8e 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -757,6 +757,12 @@ void __init start_xen(unsigned long boot_phys_offset, end_boot_allocator(); + /* + * The memory subsystem has been initialized, we can now switch from + * early_boot -> boot. + */ + system_state = SYS_STATE_boot; + vm_init(); if ( acpi_disabled ) @@ -779,8 +785,6 @@ void __init start_xen(unsigned long boot_phys_offset, console_init_preirq(); console_init_ring(); - system_state = SYS_STATE_boot; - processor_id(); smp_init_cpus(); From patchwork Mon Oct 2 17:31:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 114634 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp924650qgn; Mon, 2 Oct 2017 10:34:09 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBUS52oOCK/jqTbrmBgCGg133k/JuWy+zONB2EKxYySxQg3FApS0tOXAD4WnNWIeY3cfhGX X-Received: by 10.107.28.138 with SMTP id c132mr24581318ioc.233.1506965649770; 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=pIJllkWhb6RzEgJnUG+Umrp5VSBLQw8fMxLmkvIjyLF/7IJpQgzkucotOYuWAjJY7w o8hw0snIWxU7jnYN4B70nMUG3fMCvOSkWztYWXuJSjYMmu5dX5pHl83mITvJlrDtU8tT vV/YgCsJJkAL9AVqXN3ccP19JnLYLIySyoNKgZrmQRUSlPHhHFKYQhdK7ERa/T9QljtH 0wiThvTBmpiOifUzYQ73UUjjztqeuF017jXPirjwCmA52ePUPXIAcTafimPQxCSNTlnR yZipU7AG9CwTk/8VoU59MN4m8MuiSkx2blBe2QpliasPPpbP/J++AhYa5Dt3UL8A2MNK 8AJw== 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=zw6LojWN1Lo/3OcdlHi6R9DqbAcqMNnpMYy5otuqS18=; b=ug1d62AmCKnOTXDTjx4/hcyauhQjKd7qQ4ifJM5rcFrea1WF+GIDVtn7jHB2CTjlGb 7zuZPUYv5VXG1FBT61dWizxl2em4ndP5H99Kv0xpHPFrb+Ovq27FEVoz4TxKUExWroJn MZrsgdxo/9YScXv3JR7HSqPMuPGjAPQT0ajkJFWx35SANe/ET8FSd0wV3VFkExlLvmKk E8U/ATcxA8x9kFlxasCyRK7d1+Yiw8SlV8DafpSmqgfR8pUfucFQKV1knnyq9GBznMYU g2MMSOLzr5cEgHy3M4yVauFPY9mCJ2AMR0UimGbHxUYeoHnXa0pkQBI4bII3gooKdCk8 rcCw== 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 v7si9315854iod.413.2017.10.02.10.34.09 (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 1dz4Za-0003bA-7U; Mon, 02 Oct 2017 17:32:06 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dz4ZY-0003aJ-Tm for xen-devel@lists.xen.org; Mon, 02 Oct 2017 17:32:05 +0000 Received: from [85.158.143.35] by server-1.bemta-6.messagelabs.com id E5/7A-03414-41872D95; Mon, 02 Oct 2017 17:32:04 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrELMWRWlGSWpSXmKPExsVysyfVTVe44lK kwfyjmhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8bzzzuZC3bwV+yffJWlgfEpZxcjF4eQwGZG ieVnj7NDOKcZJe7fusvcxcjJwSagKXHn8ycmEFtEQFri2ufLjCA2s0CkxOEPP9hBbGGBYIlTT bPA4iwCqhKLfm9gAbF5BSwkFn86zQpiSwjIS+xquwhmcwpYStx+cghsvhBQzenXM5gmMHIvYG RYxahenFpUllqka6yXVJSZnlGSm5iZo2toYKaXm1pcnJiempOYVKyXnJ+7iRHoXwYg2MHY8c/ pEKMkB5OSKK93/qVIIb6k/JTKjMTijPii0pzU4kOMMhwcShK8CeVAOcGi1PTUirTMHGCgwaQl OHiURHgjQdK8xQWJucWZ6RCpU4y6HB037/5hEmLJy89LlRLnNQIpEgApyijNgxsBC/pLjLJSw ryMQEcJ8RSkFuVmlqDKv2IU52BUEub9UwY0hSczrwRu0yugI5iAjpjTdQHkiJJEhJRUA2OBgI kC7+PGGOsoY7NfqWvC1SOnc3k8uHfb+v/cI8/qbhsv0zycFcK37kj5H6a0jbbbNSR9HrYa38n Z/++cReSKhw9DI80cqqexibvnW7okXbo817f9gDsnb4DZHxf3eYf/1Yaq/v12PDHn/DMngZ3G B/4smLAp8pnaytjQxbaRKTYdd5qStZVYijMSDbWYi4oTAU1MlW91AgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-9.tower-21.messagelabs.com!1506965523!85536619!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 59702 invoked from network); 2 Oct 2017 17:32:03 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-9.tower-21.messagelabs.com with SMTP; 2 Oct 2017 17:32:03 -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 F36741596; Mon, 2 Oct 2017 10:32:02 -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 13DFB3F483; Mon, 2 Oct 2017 10:32:01 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 2 Oct 2017 18:31:46 +0100 Message-Id: <20171002173150.5404-6-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 5/9] xen/arm: mm: Rename 'ai' into 'flags' in create_xen_entries 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" The parameter 'ai' is used either for attribute index or for permissions. Follow-up patch will rework that parameters to carry more information. So rename the parameter to 'flags'. Signed-off-by: Julien Grall Reviewed-by: Andre Przywara Reviewed-by: Stefano Stabellini --- Changes in v3: - Add Stefano's reviewed-by Changes in v2: - Add Andre's reviewed-by --- xen/arch/arm/mm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 73677902d4..39bade63f5 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -986,7 +986,7 @@ static int create_xen_entries(enum xenmap_operation op, unsigned long virt, mfn_t mfn, unsigned long nr_mfns, - unsigned int ai) + unsigned int flags) { int rc; unsigned long addr = virt, addr_end = addr + nr_mfns * PAGE_SIZE; @@ -1021,7 +1021,7 @@ static int create_xen_entries(enum xenmap_operation op, } if ( op == RESERVE ) break; - pte = mfn_to_xen_entry(mfn, ai); + pte = mfn_to_xen_entry(mfn, flags); pte.pt.table = 1; write_pte(entry, pte); break; @@ -1038,8 +1038,8 @@ static int create_xen_entries(enum xenmap_operation op, else { pte = *entry; - pte.pt.ro = PTE_RO_MASK(ai); - pte.pt.xn = PTE_NX_MASK(ai); + pte.pt.ro = PTE_RO_MASK(flags); + pte.pt.xn = PTE_NX_MASK(flags); if ( !pte.pt.ro && !pte.pt.xn ) { printk("%s: Incorrect combination for addr=%lx\n", From patchwork Mon Oct 2 17:31:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 114631 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp924589qgn; Mon, 2 Oct 2017 10:34:06 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCmZC5CNDkLPPtN3s+ZMSOoUjC2iA/sA//M5VvmMcDqrr9dbCTngWY02ncgtwdVCV8x/YhK X-Received: by 10.107.182.139 with SMTP id g133mr25245129iof.10.1506965646588; Mon, 02 Oct 2017 10:34:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506965646; cv=none; d=google.com; s=arc-20160816; b=Ml0gLN6A6ADh8aghsPjB08QhrLTxse2Xf3SZ4R9O0OFTCEGZ0DxiIxI/DIuQHm33J4 wmKSWGp3Z73DhfY8iFvNYdgJpjIgi/hrX4GogJE66ZdqB1UOYQWQX1Zxv0DApWfucEtL //u/rraFE7HPDThocem/z+QUz1s6t8bzyswMzLIL41QjBP9SlzWFC1SKqdznYFinzEwL 3vOC+6MeHOaxNjj9Zu9Xi/yvWHQtTMRrKBFGaBEeLK8zBILMp0pCl84i6rgZPZyKgdJQ OJcR4st/FOwILPvTpyKI0KxV+DzEkVSLwtbpHwosW/VnVRy+Dxp/2SaWYE8/e3WML/zx A02A== 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=vu9gSlv2fDjbY95cQ1rWp6UXu+KmVIRgrVAbNXvckog=; b=aWR0oZBkT9VApVf64ecdWanrXLIQ+w8JPqbsd2q/9uBXFRHKfAHjIk+zogAyzPa8wF A+27W2Cp46SbrLLBAe7AYFpo9xjLhNdQOmXPMHWZX4AjrRYkVafJuhDFmCunb1SGGwaN rat2GDCXr/RjaZuGzC5b/7QGAYb106O5xEjiNDeedTJ4TR5Y0g2E/Cwviu97s3mj2jqn 6N5JUOFn37d/Cy8t8KEtoFh37c1RNwb8q6SgASbgtSGLfcwBVAxTW/yAnMf4kbz/GsAU 4A2V1A2sddahvSUnWExXc9zSjLExPl1nS4rRg4wzIeAe3xwz8xnwZv+Q46+rYg0rckJe lXlA== 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 c35si2680357ioa.300.2017.10.02.10.34.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Oct 2017 10:34:06 -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 1dz4Zb-0003ck-Ey; Mon, 02 Oct 2017 17:32:07 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dz4Za-0003b4-AQ for xen-devel@lists.xen.org; Mon, 02 Oct 2017 17:32:06 +0000 Received: from [85.158.139.211] by server-11.bemta-5.messagelabs.com id 06/F0-01778-51872D95; Mon, 02 Oct 2017 17:32:05 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMLMWRWlGSWpSXmKPExsVysyfVTVe04lK kwbMeVoslHxezODB6HN39mymAMYo1My8pvyKBNeNe93bWgit8FZ/PXWJsYFzL3cXIxSEksJlR 4v7dC0wQzmlGiSUtd1m6GDk52AQ0Je58/sQEYosISEtc+3yZEcRmFoiUOPzhBzuILSwQJ3Hwz FqwehYBVYkl16czg9i8AhYSs9ctAuuVEJCX2NV2kRXE5hSwlLj95BBYjRBQzenXM5gmMHIvYG RYxahRnFpUllqka2Sml1SUmZ5RkpuYmaNraGCql5taXJyYnpqTmFSsl5yfu4kR6OF6BgbGHYy 3J/sdYpTkYFIS5fXOvxQpxJeUn1KZkVicEV9UmpNafIhRhoNDSYJXrBwoJ1iUmp5akZaZAww1 mLQEB4+SCG8kSJq3uCAxtzgzHSJ1ilGXo+Pm3T9MQix5+XmpUuK8RiBFAiBFGaV5cCNgYX+JU VZKmJeRgYFBiKcgtSg3swRV/hWjOAejkjDvnzKgKTyZeSVwm14BHcEEdMScrgsgR5QkIqSkGh gVSy/uyRVx6f0cp9ayiP3CkYJlmYs0cy+FCCckb/MJfK/jY1l1Tk238JCV+6Ssh1Pv3NW4Wj8 19FPqKb0DtbrT/0bdK+nazLMl9Z/81eWGEx+58fnrn7qheEvgvczzMhaXY++DN52qTk6Kdlmt uP95wKeM4+tDK6Zu0pvcr2V5/WNUknC55VklluKMREMt5qLiRADdvUHrdgIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-3.tower-206.messagelabs.com!1506965524!110628016!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 5686 invoked from network); 2 Oct 2017 17:32:04 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-3.tower-206.messagelabs.com with SMTP; 2 Oct 2017 17:32:04 -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 28FD715A2; Mon, 2 Oct 2017 10:32:04 -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 3DA523F483; Mon, 2 Oct 2017 10:32:03 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 2 Oct 2017 18:31:47 +0100 Message-Id: <20171002173150.5404-7-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 6/9] xen/arm: page: Describe the layout of flags used to update page tables 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, the flags used to update page tables (i.e PAGE_HYPERVISOR_*) only contains the memory attribute index. Follow-up patches will add more information in it. So document the current layout. At the same time introduce PAGE_AI_MASK to get the memory attribute index easily. Signed-off-by: Julien Grall Reviewed-by: Andre Przywara Reviewed-by: Stefano Stabellini --- Changes in v3: - Add Stefano's reviewed-by Changes in v2: - Slightly update the commit message to specify we describe the current layout. - Add Andre's reviewed-by --- xen/arch/arm/mm.c | 2 +- xen/include/asm-arm/page.h | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 39bade63f5..117f05a1d6 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -1021,7 +1021,7 @@ static int create_xen_entries(enum xenmap_operation op, } if ( op == RESERVE ) break; - pte = mfn_to_xen_entry(mfn, flags); + pte = mfn_to_xen_entry(mfn, PAGE_AI_MASK(flags)); pte.pt.table = 1; write_pte(entry, pte); break; diff --git a/xen/include/asm-arm/page.h b/xen/include/asm-arm/page.h index 0ae1a2587b..aa3e83f5b4 100644 --- a/xen/include/asm-arm/page.h +++ b/xen/include/asm-arm/page.h @@ -65,6 +65,13 @@ #define MAIR0VAL (MAIRVAL & 0xffffffff) #define MAIR1VAL (MAIRVAL >> 32) +/* + * Layout of the flags used for updating the hypervisor page tables + * + * [0:2] Memory Attribute Index + */ +#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) 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 From patchwork Mon Oct 2 17:31:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 114632 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp924604qgn; Mon, 2 Oct 2017 10:34:07 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBpGVCs1GlTa8WCIEPj4nvdoVYuVd/pZhVylzKcFvfl4bybCsCdpdZ9O92uLHupBUQUhlj5 X-Received: by 10.36.90.19 with SMTP id v19mr10988864ita.30.1506965647847; Mon, 02 Oct 2017 10:34:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506965647; cv=none; d=google.com; s=arc-20160816; b=QHuLqu5vGVNBkZpwLxX8Ao7fFX3wjav30BPdfslv6AzgGDFOb7VWqE8w0LEaGr9c33 wkPQQIWhn5uP0wxIFR+vPGSt8n0sSZxEBQhNNBC3kBpNn+U2jfiY1vFLnP4tZamdrTgt swQL8x92Mfz9YcdLwh+pIdSLQTnsByPsOTGHZHIZC7nWnKLXtaIcsrNiN5u+LXszP980 P115JoverRbQ+CdQVgLrj9yZOVLnmVVfKFgUcqSU62eBJNMD2RlqK/jJZ5h/jd4mMUsl 1S1sdT7/IMyp7qFxmVLIp5NfJs004yDJkIiuR68a2LqpOyEfXTx6XCTdVEbFTMZdrlY3 jfaQ== 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=VnVSUpTaaQ48OTw4OlsPcxkwpuYf59x8V3ESA/WBXV0=; b=fto/nF0uNCfwDQwUeuzSD1BzTZfyy5/69o1vNQFQGrSzbijzLJKrlEy2ZrmA2AuOJm FB5OzEKrgpqFVSqBKItRpwxIpcz1XeAAoBCe8TMP0/1WPr4M8397l2zz0PInxs8cidkK ftPxuKJcb+6Trze11jJhO2sU1gbm/DfzCckdxIPr67E9zGiZx2GVVMDB2zYR6xQ9+EbB kVwlvL+dvphQrGeUC++UINFQOF0CQrj5fdc6+jjxVAiNN34BKvYBoouql23pKmwcmayf 1NO3w57J4iv8S+rW5W3GXelK8+mtRNVW7HlPBKZX5zc86a1DYeUaQ5khFL/LPgaqKWIY 4Y7g== 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 i14si9409885ioo.368.2017.10.02.10.34.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Oct 2017 10:34:07 -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 1dz4Zf-0003gU-1S; Mon, 02 Oct 2017 17:32:11 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dz4Zd-0003eS-Ct for xen-devel@lists.xen.org; Mon, 02 Oct 2017 17:32:09 +0000 Received: from [85.158.143.35] by server-5.bemta-6.messagelabs.com id 48/69-03454-81872D95; Mon, 02 Oct 2017 17:32:08 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrJLMWRWlGSWpSXmKPExsVysyfVTVe84lK kwalL3BZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8b3zz+YC3rYK24tvMzWwNjK2sXIxSEksJlR YtHTXiYI5zSjxNR5XSxdjJwcbAKaEnc+f2ICsUUEpCWufb7MCGIzC0RKHP7wgx3EFhYIk9g35 yiYzSKgKvHhVQuYzStgIXHs/BmwORIC8hK72i6ygticApYSt58cYgaxhYBqTr+ewTSBkXsBI8 MqRo3i1KKy1CJdQ2O9pKLM9IyS3MTMHF1DAzO93NTi4sT01JzEpGK95PzcTYxADzMAwQ7GL8s CDjFKcjApifJ651+KFOJLyk+pzEgszogvKs1JLT7EKMPBoSTBe70MKCdYlJqeWpGWmQMMNZi0 BAePkgjvPZA0b3FBYm5xZjpE6hSjMceNh9f/MHF03Lz7h0mIJS8/L1VKnHcPSKkASGlGaR7cI FgMXGKUlRLmZQQ6TYinILUoN7MEVf4VozgHo5Iw70GQKTyZeSVw+14BncIEdMqcrgsgp5QkIq SkGhgjZ8kFNcnmZx1pS7LefkCfc/vU67U+Jx2c7zw5vC+6PGM//7dCtmyWvv3bNn25meT99LF x9+ndku8PRr5YJ5ugFuYldyKJ/XLU6cbJjD4tv5b53T3PvcFmpeNr9ifcU468UFZ1azq9aYbU kj0BujYMd9kq9p6WkDzdziobH9zuHlIZ/+KrxUslluKMREMt5qLiRADFJIV4fAIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-5.tower-21.messagelabs.com!1506965526!77678403!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 42344 invoked from network); 2 Oct 2017 17:32:07 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-5.tower-21.messagelabs.com with SMTP; 2 Oct 2017 17:32:07 -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 7C6121596; Mon, 2 Oct 2017 10:32:06 -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 910353F483; Mon, 2 Oct 2017 10:32:05 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 2 Oct 2017 18:31:49 +0100 Message-Id: <20171002173150.5404-9-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 8/9] xen/arm: mm: Handle permission flags when adding a new mapping 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, all the new mappings will be read-write non-executable. Allow the caller to use other permissions. Signed-off-by: Julien Grall --- Changes in v2: - Switch the runtime check to a BUG_ON() --- xen/arch/arm/mm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 117f05a1d6..57afedf0be 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -1022,6 +1022,9 @@ static int create_xen_entries(enum xenmap_operation op, if ( op == RESERVE ) break; pte = mfn_to_xen_entry(mfn, PAGE_AI_MASK(flags)); + pte.pt.ro = PAGE_RO_MASK(flags); + pte.pt.xn = PAGE_XN_MASK(flags); + BUG_ON(!pte.pt.ro && !pte.pt.xn); pte.pt.table = 1; write_pte(entry, pte); break; 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