From patchwork Mon Oct 9 13:23:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 115215 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp2557342qgn; Mon, 9 Oct 2017 06:26:02 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBSmPGEW4bUI8on6cQ+krPD6ILZW1tVjMt7VnpXX7V4KBgZGuLaTyaleW5ympDBwyXOAJLj X-Received: by 10.36.253.11 with SMTP id m11mr14988236ith.12.1507555561956; Mon, 09 Oct 2017 06:26:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507555561; cv=none; d=google.com; s=arc-20160816; b=OkBDMoA5L1GS8krk3ixlOeztUDpWeva3jwFprdLv4y6CLjID9MvoLjRfpmEr3uf9s8 kD4uWqnlvvVa5RGH5g6KcdgAmmtELCb0mRvgxTYzKmE1g4pgHbGo7QUJneUzWwce/Bi8 Cmk63rLuCAgnHFsBW+wlSkY2FP79iSEzdAnXCKqFz5jmpsPChrgi3NglaiAOHbMYwS+b T9LEx4dgwq8pXZglJ3zWM89nJ90+TLqOQmfwPRVfeFzOpb1Z9TOg8ypCI0W21GhUZD+N bX+pc2nrWHT+Y8CJVcJHt90ehxrAB1+bZz9Gv2mudhHh7QXTlqN2EuvEoJoHB9cBxWMp opeA== 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=vIWoTV1wZaqhuBPXGrQanttxhvxsLnnL188ECebI7RljYNdJtgRR53h2FFR4uOIyJw JUnPXzVZUcKijguPjznHkex/T6ado4iHsXlEcxZW3C3K/akCy3TV79syGMGMcFXx2srx gjouGzmsKtfGmtyXyCjPhvH1kq4XzjlN7czym+pSVY495VNIkynwrB2fYZ+MShuRpuAR YbRoa/l0x5iOgckY+PLG7k8FqxIfi8e/3uNOEXvoluDXZNu4kkjtof36gW6lbU0YJdNs yQS2YodX5yVaZjdoUaE+y2DV5BCVgBPKM2PZubp/YXsaivhnFfpkFcZI3KwTXowccvnU t+sA== 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 r131si6785059itr.68.2017.10.09.06.26.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Oct 2017 06:26: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 1e1Y2C-0007y6-TX; Mon, 09 Oct 2017 13:23:52 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e1Y2B-0007xd-DO for xen-devel@lists.xen.org; Mon, 09 Oct 2017 13:23:51 +0000 Received: from [193.109.254.147] by server-8.bemta-6.messagelabs.com id 17/9B-14596-6687BD95; Mon, 09 Oct 2017 13:23:50 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrOLMWRWlGSWpSXmKPExsVysyfVTTe14na kwYUTJhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8a796UFe3wqOj49ZWlg/GrVxcjFISSwmVHi yrdHrBDOaUaJa9NbGbsYOTnYBDQl7nz+xARiiwhIS1z7fBksziwQKXH4ww/2LkYODmGBAIn3W +JBwiwCqhJflvwHK+EVsJDYdauRDcSWEJCX2NV2kRXE5hSwlJi2eToziC0EVHP5ww7WCYzcCx gZVjFqFKcWlaUW6RqZ6CUVZaZnlOQmZuboGhqY6eWmFhcnpqfmJCYV6yXn525iBHqXAQh2MO7 7GHmIUZKDSUmUd0rB7UghvqT8lMqMxOKM+KLSnNTiQ4wyHBxKErz/y4BygkWp6akVaZk5wDCD SUtw8CiJ8IaWA6V5iwsSc4sz0yFSpxiNOR7duPuHiaPjJpAUYsnLz0uVEuf1BSkVACnNKM2DG wQL/0uMslLCvIxApwnxFKQW5WaWoMq/YhTnYFQS5s0AmcKTmVcCt+8V0ClMQKcwFt8AOaUkES El1cBoeT9ZY9dckwiPv982rtzqUnhFapVu+sWrGfY6jrGqEQ/u9ltrHHUp//u/qVmwP1nxhIb 02lWquoriDCycess8J/Ep5K3l2Llzp2ldvVjvq+uujV5p1xQ/iok8uRIeu1Gq7vTz7Nx3J/4a srS8LFv+2M4munHRU9sDPNrr1ZjMV35/+2FmUo0SS3FGoqEWc1FxIgBsBl2AegIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-6.tower-27.messagelabs.com!1507555429!110972737!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 8490 invoked from network); 9 Oct 2017 13:23:49 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-6.tower-27.messagelabs.com with SMTP; 9 Oct 2017 13:23:49 -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 E3CD61529; Mon, 9 Oct 2017 06:23:48 -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 D47703F578; Mon, 9 Oct 2017 06:23:47 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 9 Oct 2017 14:23:32 +0100 Message-Id: <20171009132341.1678-2-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171009132341.1678-1-julien.grall@arm.com> References: <20171009132341.1678-1-julien.grall@arm.com> Cc: andre.przywara@arm.com, Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v4 01/10] 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 Reviewed-by: Stefano Stabellini --- 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 9 13:23:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 115216 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp2557373qgn; Mon, 9 Oct 2017 06:26:03 -0700 (PDT) X-Google-Smtp-Source: AOwi7QACcofdo5WUY8s9Gg3ZlrD4gLhwFYwtqGZBfeb7ydqoIp1g4MpW84Sgr1VwV2DQKGOGeNtD X-Received: by 10.107.180.3 with SMTP id d3mr1979305iof.46.1507555563298; Mon, 09 Oct 2017 06:26:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507555563; cv=none; d=google.com; s=arc-20160816; b=iXHhgWx2Rslhc+yWsTMTFdWqS7rYH4AJbuo+XuXcl4dbltCIoyjPiB6gZdg4c0pCnC oWxRsuMYdj8mnUY1MEzP5RaFExlRNl3HBBAWQyKck9+OTWqActETP4ZCYL9kxbNVMREk 2d6B7slPt0afCHnPJtVYhciP7kY+po1thHuPmpKPugOh2T/Hi6qd1VFqvf2Neib5aVob Y11jcP2jctVxl1QnB1ykIiu98NRBnLDSjcGb9SbtRHoUCpZH2xNHV4rDdcmKoVH1/89H mOmfSVERstl90sDyFYHzNdnj97xGk2r6WkRS7zw6neCi+ywNYWguls/kQAw53Ov1k0yY jieg== 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=dQzfeW09TMErR5SMwlTTSRJEisWEbvNWkyFiaH0WJLavY7iL1NM3H4GgLk02OK066O zdVk/6JW1ne9hrbm1mp4AlkzChm9tMMOSv29nZhvZgX8QnQF4OtgcCAYq4IOClLi2+Hc caVTC5+LQ6R5c/JrrFNMkzWBxbuD67E/Mn6StQBDpzHEto5t1uprQP9ihWxY3J1KiKPx TlONGnte/3Kbqu/4xsAO632b7a0Oprm07NiofOXCzmUmiTVsE4HrypO8iBbRx37Xxw18 Twdfyl/7H7dPpcWIXIs/O+6dDHHf5ThC+Mvy09QNh1ppnqj7huRsT5TjR8h1rPYnlvfk xC1A== 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 m184si6251416ioa.80.2017.10.09.06.26.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Oct 2017 06:26:03 -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 1e1Y2D-0007yH-44; Mon, 09 Oct 2017 13:23:53 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e1Y2C-0007xj-40 for xen-devel@lists.xen.org; Mon, 09 Oct 2017 13:23:52 +0000 Received: from [85.158.139.211] by server-16.bemta-5.messagelabs.com id 36/91-01766-7687BD95; Mon, 09 Oct 2017 13:23:51 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMLMWRWlGSWpSXmKPExsVysyfVTTet4na kwa9ec4slHxezODB6HN39mymAMYo1My8pvyKBNWPlxUmsBadFKtZfeczWwNgm0MXIxSEksJlR 4u3+LSwQzmlGiS+tk5i6GDk52AQ0Je58/gRmiwhIS1z7fJkRxGYWiJQ4/OEHO4gtLOAtMbP5E FicRUBV4tCbW2A2r4CFxKueZjYQW0JAXmJX20VWEJtTwFJi2ubpzCC2EFDN5Q87WCcwci9gZF jFqFGcWlSWWqRrZKmXVJSZnlGSm5iZo2toYKqXm1pcnJiempOYVKyXnJ+7iRHo4XoGBsYdjJe 3+B1ilORgUhLlnVJwO1KILyk/pTIjsTgjvqg0J7X4EKMMB4eSBK99OVBOsCg1PbUiLTMHGGow aQkOHiUR3lCQNG9xQWJucWY6ROoUoy5Hx827f5iEWPLy81KlxHmvlwEVCYAUZZTmwY2Ahf0lR lkpYV5GBgYGIZ6C1KLczBJU+VeM4hyMSsK8n0Cm8GTmlcBtegV0BBPQEYzFN0COKElESEk1MD LcfnKuXvSNcLHIslcq0oEvc/sFW1yrs+Xsz9/dl57Y7X9pRrxDRNFb9Ukn4l8f5np/rLx3NYe W6eIpVpsPy51dcjf7aIuX+9q+Qt6/L3JXOaxZ9mr2n4UTD3Q++ba+er3Obx7DB+dMHrKyau87 qq08I7t42Ux3TefjIqt3L54Y+3PL4cwuHiclluKMREMt5qLiRAA4i13zdgIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-15.tower-206.messagelabs.com!1507555430!92122566!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 65372 invoked from network); 9 Oct 2017 13:23:50 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-15.tower-206.messagelabs.com with SMTP; 9 Oct 2017 13:23:50 -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 199491435; Mon, 9 Oct 2017 06:23:50 -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 2E03F3F578; Mon, 9 Oct 2017 06:23:49 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 9 Oct 2017 14:23:33 +0100 Message-Id: <20171009132341.1678-3-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171009132341.1678-1-julien.grall@arm.com> References: <20171009132341.1678-1-julien.grall@arm.com> Cc: andre.przywara@arm.com, Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v4 02/10] 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 9 13:23:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 115214 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp2557329qgn; Mon, 9 Oct 2017 06:26:01 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDa3nTOP2JwVkx25imeB0Thm+Q/G5JO/LBZa5sxBzUWYN07So/5jtPSt3GMibtObZ85uvob X-Received: by 10.36.104.75 with SMTP id v72mr13390380itb.81.1507555561260; Mon, 09 Oct 2017 06:26:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507555561; cv=none; d=google.com; s=arc-20160816; b=MKsfcEv0E704jHrd2VmS6hg42lFZW3totjoEp7VetntubwnL5ui8smrq1daF/5nAdx sWh0yl+DNokTHUugwC2BZ2u+clIAsxjqPK96xpf4RcFUw78aJoG9yGY5hABA4cvGIfm/ BrrMRA+S0LglInkYhlqlA53k2xiyuaaOPDWlAcHo/+7spXBEDReMigKJxdiqJvergX9+ 3hsmzXZ52mKXVeb+TADPQtExJ4EseGZEoB9ldIjSFloKpEL9ieNZ4clE0dWFcTHtuDcI FzV3Rch0WG0MExEhzdb9w54SybYrlnm3wmwwrS+vtE1RPQk+Lqi194ILV4nONx94pVyL FvDw== 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=0yBxZ/5OPaHwGzCM5VayUeGun4WGUl29jnau/LC2X6ehuTFIz8BjWQXhTGdHCb/9pz BTZuq5xKvqAdj19gAzuLG0QNa/iT1aIjAq67Oa2NCa8IpQeRJytcmExfSkhLJU8UHZwl zyvoHqU9ygEynSqOCO5/OrsuIrQT5gIegDg+f/2DrNXFRixuSCqy7NVIwV6jtcLXz0Ya 4TZ2B7z/TmeBcWvSdPUAyN765cqBJ8owh6IhOTIVgrc9Nuv5ok6pfAB+Y8iJnbijJjlB KttpDTAMJns24npj7MW3By7nNcOBhwUUScsI/dkdUzBu6kKMxa6Ns2vPABDwg/uP/Cum VB2w== 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 w67si7422702itc.129.2017.10.09.06.26.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Oct 2017 06:26: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 1e1Y2H-0007zv-Tp; Mon, 09 Oct 2017 13:23:57 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e1Y2F-0007y0-Tw for xen-devel@lists.xen.org; Mon, 09 Oct 2017 13:23:56 +0000 Received: from [85.158.143.35] by server-10.bemta-6.messagelabs.com id 6E/7A-03761-B687BD95; Mon, 09 Oct 2017 13:23:55 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrILMWRWlGSWpSXmKPExsVysyfVTTe94na kwbalNhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8bRGTEFF0Urvlw4ztjAuJ2/i5GLQ0hgM6PE yj19bBDOaUaJD3+msnYxcnKwCWhK3Pn8iQnEFhGQlrj2+TIjiM0sEClx+MMPdhBbGMh+sP8iG 4jNIqAqsbDtApjNK2AhMW/NYWYQW0JAXmJX20WwmZwClhLTNk8HiwsB1Vz+sIN1AiP3AkaGVY zqxalFZalFuuZ6SUWZ6RkluYmZObqGBmZ6uanFxYnpqTmJScV6yfm5mxiB3mUAgh2MMy/7H2K U5GBSEuWdUnA7UogvKT+lMiOxOCO+qDQntfgQowwHh5IEr305UE6wKDU9tSItMwcYZjBpCQ4e JRHeUJA0b3FBYm5xZjpE6hSjLkfHzbt/mIRY8vLzUqXEeX1BigRAijJK8+BGwEL+EqOslDAvI 9BRQjwFqUW5mSWo8q8YxTkYlYR5M0Cm8GTmlcBtegV0BBPQEYzFN0COKElESEk1MEbVyoYocX 2a9aTi2u671u19hxZFz1NjbJ1bfSZx++mcM8a836dcfnUh7PSdncvrw87WsX6Niey0cerd7n7 nzrLpRUtfzn/iNfOzjvbED3e4Ts84p+nk/qXx24InvsebZ/T937Nb+1ATo1EKc7ZARecO6YNf DNI0JnxXKTcLzSp63u7cZ6UZ+luJpTgj0VCLuag4EQBr0wO2dAIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-11.tower-21.messagelabs.com!1507555431!73173855!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 19709 invoked from network); 9 Oct 2017 13:23:51 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-11.tower-21.messagelabs.com with SMTP; 9 Oct 2017 13:23:51 -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 4371F1529; Mon, 9 Oct 2017 06:23:51 -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 580E43F578; Mon, 9 Oct 2017 06:23:50 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 9 Oct 2017 14:23:34 +0100 Message-Id: <20171009132341.1678-4-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171009132341.1678-1-julien.grall@arm.com> References: <20171009132341.1678-1-julien.grall@arm.com> Cc: andre.przywara@arm.com, Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v4 03/10] 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 9 13:23:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 115211 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp2557210qgn; Mon, 9 Oct 2017 06:25:55 -0700 (PDT) X-Google-Smtp-Source: AOwi7QD74JHQB9/KZcsUdtRs37zVWPJBG3K0HL0xihoct+Imbb2NYNTCTy9QrhUk9HU9DJzDWqY9 X-Received: by 10.36.173.33 with SMTP id c33mr13831151itf.5.1507555555415; Mon, 09 Oct 2017 06:25:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507555555; cv=none; d=google.com; s=arc-20160816; b=EncYR85epF7iDLGHjDPN89UtNEFE5YdjTYld8kdg6rtxx3GLMZXBeqL6fI6QPWBFJS qJ/f06tB5HCSw0QBC2bpweZSWSkyLBMv7SIxqhTG80gH9ie98jyiWIuJlk0+z4LhoXnP OjD9ke0rsN1hA+luG4Sv/v2W4AoDpyNwfOE4+eQojJCaujEJl4KgnqYrTahnCnRWHonV cDBAcM5iz4lT3yduC5zqitimJZl/jTLeY+8kRf3s3Akqmk6fgapDph5tXfSAi9zy01W0 b4dZZxbts/Jng7fsHr1SExYzdc+uDG49xfau4bKeNULLalidV0AjA6u0byMCNhpUEBO3 S/jg== 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=Lsya0oufdz5aJA6FaDNHSlQRk9iUXTk/T+Y2PVMa36e7QuVEEvm2AWbU9ktqLuwKNF RU/++fe6DvUJMS/6tk0QTCOrYNXBe1L7mKNKNZtltrgX/I+3c6IkTiejWlveyKkng6OA BcOQctM/AzlWJ3kUpARC+JPURo8aN+WrQnocBHJkHIHzM8bmthQ1/irFtJwwhhCizAZN H5TtnXHbxB39SEtNldB0Toj5ac5hfrEGJ/JhdEcd9pKyGHN/oyHNhAFHD4f7rtcJFaYs wVhcLMoZ60dBidGXJUl03pKaDJfMYUMUq2lp0TFE28ABIxdoZrjR0h/4ur4w7gcpLPxR Fyeg== 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 d11si6379517ioc.15.2017.10.09.06.25.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Oct 2017 06:25:55 -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 1e1Y2F-0007yd-Ao; Mon, 09 Oct 2017 13:23:55 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e1Y2E-0007yS-GL for xen-devel@lists.xen.org; Mon, 09 Oct 2017 13:23:54 +0000 Received: from [85.158.139.211] by server-7.bemta-5.messagelabs.com id FE/CD-02216-9687BD95; Mon, 09 Oct 2017 13:23:53 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMLMWRWlGSWpSXmKPExsVysyfVTTez4na kwbtHPBZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8acXY2sBU85K+b92M7WwPiWvYuRi0NIYDOj xP6L59ggnNOMEq0bmlm7GDk52AQ0Je58/sQEYosISEtc+3yZEcRmFoiUOPzhBzuILSwQLXHw3 XywOIuAqsSGNU1gvbwCFhJPLqwFi0sIyEvsarsIFucUsJSYtnk6M4gtBFRz+cMO1gmM3AsYGV YxahSnFpWlFukaWeglFWWmZ5TkJmbm6BoamOrlphYXJ6an5iQmFesl5+duYgR6uJ6BgXEHY98 qv0OMkhxMSqK8UwpuRwrxJeWnVGYkFmfEF5XmpBYfYpTh4FCS4LUvB8oJFqWmp1akZeYAQw0m LcHBoyTCW14KlOYtLkjMLc5Mh0idYtTl6Lh59w+TEEtefl6qlDivL8gMAZCijNI8uBGwsL/EK CslzMvIwMAgxFOQWpSbWYIq/4pRnINRSZj3UxnQFJ7MvBK4Ta+AjmACOoKx+AbIESWJCCmpBk b+tLZStcOmhtXdHckLqr5fD2w3eKFS88MoLiLgrdbfJ+WfVDVj26JWJkc7X0ljkjRXSJXm8OM snPn48Pp/Yotevlrz9cJG3jlir4TKPZ/VJ/KK1k7wjLqsUDN3f4mjkXDlkXKtf1ZdtcLvOPLW f3baUbZsYY2QuMaKH+zea3/4r+Xr29zwSImlOCPRUIu5qDgRAKkaZ652AgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-11.tower-206.messagelabs.com!1507555432!86354615!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 41184 invoked from network); 9 Oct 2017 13:23:53 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-11.tower-206.messagelabs.com with SMTP; 9 Oct 2017 13:23:53 -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 6D4E51435; Mon, 9 Oct 2017 06:23:52 -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 81DBF3F578; Mon, 9 Oct 2017 06:23:51 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 9 Oct 2017 14:23:35 +0100 Message-Id: <20171009132341.1678-5-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171009132341.1678-1-julien.grall@arm.com> References: <20171009132341.1678-1-julien.grall@arm.com> Cc: andre.przywara@arm.com, Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v4 04/10] 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 9 13:23:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 115212 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp2557220qgn; Mon, 9 Oct 2017 06:25:56 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCfyxDzwMH6n8IuUGseo+BjoO3IV9lr2IcoqjwjKww1j4C9KmkAqfFbTMM3SNJjwcnQ5I2x X-Received: by 10.107.181.196 with SMTP id e187mr13176497iof.178.1507555556021; Mon, 09 Oct 2017 06:25:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507555556; cv=none; d=google.com; s=arc-20160816; b=ymmI1YHIvLj1Rz0n233GT5/GWz4/HgVqG7/5qswpAJYIpxbnfsmmmctu3YCoIn7xn4 /qq7gXu/M8cE8mbb5decz7SM+36baPALLsmi6HJcUhZCqEnw5dgRr3gmQT2JLQz72nJT 6/zifV24QcMn0URoAO6cVryQ94LhRZspz+lUWxLWV4wa+G3fmhI+23MiNNyCnCrKK6El C3GMmN60UqYZyCQSs4sqgC+P55xxaqb5DLHeIi0XVoxkhDY2gIiLsLcQ8cu4cHUJK3nk Bn4M8t1k+N7t/05gq81pwtHseXzziCkxAvNabON5C8WX0kJQw+fTMnhMkdEPgRhCycti PKJA== 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=y+lIwwnG8jplymGGm2n1+aV6hlWwQWMIAc0akjOG8V8CCP1ZVgxDXVkUC3tScbTIle 8btkLTFGnN9/LfGEe4XM3cMuYU5QUi8t1gBPETY/M04/6TDz2D8qjPNdNTBljKccGv+a qYGHk9h2SMRKoduevb9g9F3fMerR+2kn3BCgkNfdVA+bD9aNHn6ImBNI+mmD1+7UywuB Z2tXFNTvBbFGHwz+5g13tM82yOfuqkk9l66iiaGqG03EIxp3eJY9f7dsr1AujO0YVAY/ slbAw6iGVLWoTVst6zs8ST1uiM98DtoKD4glwKddSeSEeQ3YNW995RmWvV4NXAQWE2cz IZcQ== 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 e10si3932864itf.116.2017.10.09.06.25.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Oct 2017 06:25:56 -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 1e1Y2G-0007z5-I7; Mon, 09 Oct 2017 13:23:56 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e1Y2F-0007y0-6B for xen-devel@lists.xen.org; Mon, 09 Oct 2017 13:23:55 +0000 Received: from [193.109.254.147] by server-10.bemta-6.messagelabs.com id 03/7A-03761-A687BD95; Mon, 09 Oct 2017 13:23:54 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrILMWRWlGSWpSXmKPExsVysyfVTTer4na kQfd1YYslHxezODB6HN39mymAMYo1My8pvyKBNeP5553MBTv4K/ZPvsrSwPiUs4uRi0NIYDOj RMPZ7YwQzmlGiamv2li6GDk52AQ0Je58/sQEYosISEtc+3yZEcRmFoiUOPzhB3sXIweHsECox MO73CBhFgFVifetr5hBbF4BC4lVa9vAyiUE5CV2tV1kBbE5BSwlpm2eDlYjBFRz+cMO1gmM3A sYGVYxqhenFpWlFuma6iUVZaZnlOQmZuboGhqY6eWmFhcnpqfmJCYV6yXn525iBHqXAQh2ME6 /7H+IUZKDSUmUd0rB7UghvqT8lMqMxOKM+KLSnNTiQ4wyHBxKErz/y4BygkWp6akVaZk5wDCD SUtw8CiJ8IaWA6V5iwsSc4sz0yFSpxh1OTpu3v3DJMSSl5+XKiXOex1khgBIUUZpHtwIWMhfY pSVEuZlBDpKiKcgtSg3swRV/hWjOAejkjDvJ5ApPJl5JXCbXgEdwQR0BGPxDZAjShIRUlINjD LhHn+WWmRLXhb93pfV+FDqlnqSe/rDK62ude9SPOumLlDMcvVftVJjKkcZ/5IlEaeKorQZTN5 9kxRR7jvPdnR7a2+hYqznEfG8ddG7zR16VetfPfQ7V1hjU3N7+85pHGL3/8Q9Cp1/dVcl5/7U qoy/j13/+j7KMGQ/taqjSPKBw9+96xzTlViKMxINtZiLihMBEEohE3QCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-14.tower-27.messagelabs.com!1507555433!98352872!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 30768 invoked from network); 9 Oct 2017 13:23:54 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-14.tower-27.messagelabs.com with SMTP; 9 Oct 2017 13:23:54 -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 9741F1529; Mon, 9 Oct 2017 06:23:53 -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 ABC013F578; Mon, 9 Oct 2017 06:23:52 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 9 Oct 2017 14:23:36 +0100 Message-Id: <20171009132341.1678-6-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171009132341.1678-1-julien.grall@arm.com> References: <20171009132341.1678-1-julien.grall@arm.com> Cc: andre.przywara@arm.com, Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v4 05/10] 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 9 13:23:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 115209 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp2557203qgn; Mon, 9 Oct 2017 06:25:55 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDtKh0NKFhoKBqH6Mo8y4I85lJZt+uZQydg5FmaCqLg0NTxUO6q+hezt9xzfMydVpx+D/OU X-Received: by 10.107.104.3 with SMTP id d3mr13279764ioc.105.1507555555089; Mon, 09 Oct 2017 06:25:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507555555; cv=none; d=google.com; s=arc-20160816; b=Pw0B+XS00G9UcmZi9rECrjilcRmTEWNoW+bphbGlSF1+MRa8SudzOmCrc1hglgEpG7 c71rcTlcxLFEItkJYO+vQs1KOpjTeda/3I6VXt6gX9y5BEOfghBiZi+YMlNCSROyx99R cheo8wvkRJiIU2luomWPlu/LVuQ+SznxoOLknp6oW8hutTThx6YIid5Kz4owEp3PqOpK 110JZpc4wrpyIdRQxp0PUgorrS1Jz52DM5gDPWmn7H8+SbGRVp19XoNmyCC0v6gAh8VV 5EvDujPv61wJQmQC0FluGLU6vdYBM+M5oJ6akp1JZM0DH/BRSrWsshX4r5AZl8tqHf/e OogQ== 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=68hNK+TYfYg71QxrK8HpG7+VhKU6xxUIv237B091CSU=; b=I13AO8KzIEDUHhx4CxIEnIHwDVgeCfEe+NaAF1DmG7BMIlBhLoJDHfPFplq9zj4JAi oy9sYOYOsABEssEMeFaROdZ/NgVGAyfruXNvHBjJXAAs79FoOlq1wSjzfFqsmaxF+mc7 qwMCp1Byz+nAwEZKmXbf2kALGcwnwEVA9LchF2qDjTs+u3f2Pomez++0Nn5YhgeNysIc 5Yd0RJHL6OM6XwvGKIs57IyDVy30UFv9rlbNM36gssnRB4xU8tLlEUSY7JmN5mCRhzUJ by1hHuIFO8yXjgMyUu3wGTKzpe3qjBnQBTvx/aP5Tpko0/9L0II4U5sv0miThZzJDPey O6Aw== 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 16si2035382iom.58.2017.10.09.06.25.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Oct 2017 06:25:55 -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 1e1Y2J-00080e-Bx; Mon, 09 Oct 2017 13:23:59 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e1Y2I-00080F-LT for xen-devel@lists.xen.org; Mon, 09 Oct 2017 13:23:58 +0000 Received: from [193.109.254.147] by server-9.bemta-6.messagelabs.com id 69/F4-03428-E687BD95; Mon, 09 Oct 2017 13:23:58 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrJLMWRWlGSWpSXmKPExsVysyfVTTe74na kwfpGWYslHxezODB6HN39mymAMYo1My8pvyKBNaN18xrGgucSFWt/P2BtYDwm0sXIxSEksJlR 4sjUbWwQzmlGiZubXzB2MXJysAloStz5/IkJxBYRkJa49vkyWJxZIFLi8Icf7CC2sECKxIy9j 8HiLAKqEu82QvTyClhIrPl4AcyWEJCX2NV2kRXE5hSwlJi2eToziC0EVHP5ww7WCYzcCxgZVj FqFKcWlaUW6Rob6iUVZaZnlOQmZuboGhqY6eWmFhcnpqfmJCYV6yXn525iBHqYAQh2MDYtCjz EKMnBpCTKO6XgdqQQX1J+SmVGYnFGfFFpTmrxIUYZDg4lCV77cqCcYFFqempFWmYOMNRg0hIc PEoivKEgad7igsTc4sx0iNQpRmOORzfu/mHi6LgJJIVY8vLzUqXEeX1BSgVASjNK8+AGwWLgE qOslDAvI9BpQjwFqUW5mSWo8q8YxTkYlYR5M0Cm8GTmlcDtewV0ChPQKYzFN0BOKUlESEk1MG b7nG5pYMsQsG21N7i0LMRnedtfkU+FWswKH3/JWrPmVNxq65+QcWid+3PrA6fMmPd57ZyzWqn 79bcDS21jbT5y5Ak+cZI/905mxacJ091cUl6H7vIs7Tz+4rqxee9jWTEJMbZta3n72940NScJ Gmt1td/1Tg4yytv99HJMs1ZBl+f1oN5+JZbijERDLeai4kQAr1NwZ3wCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-12.tower-27.messagelabs.com!1507555435!109330537!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 53984 invoked from network); 9 Oct 2017 13:23:55 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-12.tower-27.messagelabs.com with SMTP; 9 Oct 2017 13:23:55 -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 C16BA1435; Mon, 9 Oct 2017 06:23:54 -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 D58E73F578; Mon, 9 Oct 2017 06:23:53 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 9 Oct 2017 14:23:37 +0100 Message-Id: <20171009132341.1678-7-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171009132341.1678-1-julien.grall@arm.com> References: <20171009132341.1678-1-julien.grall@arm.com> Cc: andre.przywara@arm.com, Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v4 06/10] xen/arm: mm: Use PAGE_HYPERVISOR_* instead of MT_* when calling set_fixmap 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" At the moment, PAGE_HYPERVISOR_* and MT_* have exactly the same value. In a follow-up patch the former will be extended to carry more information. It looks like the caller of set_fixmap are mixing the both. Stay consistent and only use PAGE_HYPERVISOR_*. This is also match the behavior of create_xen_entries and would potentially allow to share some part in the future. Also rename the parameter 'attributes' to 'flags' so it is clearer what is the interface. Signed-off-by: Julien Grall Acked-by: Stefano Stabellini --- Changes in v4: - Patch added. --- xen/arch/arm/kernel.c | 2 +- xen/arch/arm/mm.c | 4 ++-- xen/arch/arm/platforms/vexpress.c | 3 ++- xen/drivers/video/arm_hdlcd.c | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/xen/arch/arm/kernel.c b/xen/arch/arm/kernel.c index a12baa86e7..c2755a9ab9 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_NORMAL_NC); + set_fixmap(FIXMAP_MISC, maddr_to_mfn(paddr), PAGE_HYPERVISOR_WC); 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 39bade63f5..70a03015ec 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -329,9 +329,9 @@ static inline lpae_t mfn_to_xen_entry(mfn_t mfn, unsigned attr) } /* Map a 4k page in a fixmap entry */ -void set_fixmap(unsigned map, mfn_t mfn, unsigned attributes) +void set_fixmap(unsigned map, mfn_t mfn, unsigned int flags) { - lpae_t pte = mfn_to_xen_entry(mfn, attributes); + lpae_t pte = mfn_to_xen_entry(mfn, flags); pte.pt.table = 1; /* 4k mappings always have this bit set */ pte.pt.xn = 1; write_pte(xen_fixmap + third_table_offset(FIXMAP_ADDR(map)), pte); diff --git a/xen/arch/arm/platforms/vexpress.c b/xen/arch/arm/platforms/vexpress.c index df2c4b5bec..39b6bcc70e 100644 --- a/xen/arch/arm/platforms/vexpress.c +++ b/xen/arch/arm/platforms/vexpress.c @@ -65,7 +65,8 @@ 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_DEVICE_nGnRE); + set_fixmap(FIXMAP_MISC, maddr_to_mfn(V2M_SYS_MMIO_BASE), + PAGE_HYPERVISOR_NOCACHE); 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 1175399dbc..e1174b223f 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_DEVICE_nGnRE); + set_fixmap(FIXMAP_MISC, maddr_to_mfn(hdlcd_start), PAGE_HYPERVISOR_NOCACHE); HDLCD[HDLCD_COMMAND] = 0; HDLCD[HDLCD_LINELENGTH] = videomode->xres * bytes_per_pixel; From patchwork Mon Oct 9 13:23:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 115213 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp2557287qgn; Mon, 9 Oct 2017 06:25:58 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBz5xvBtgzT0gl5Rjm0qCFmSZfTtLQiOQFVr5ItRQ34qEDguFeETmNgIFzhAEvsl0KLxx4J X-Received: by 10.107.161.80 with SMTP id k77mr13920268ioe.206.1507555558711; Mon, 09 Oct 2017 06:25:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507555558; cv=none; d=google.com; s=arc-20160816; b=hVAaySac4LIWLETTOe5XMH1HJEkE898oQMz7LwmaGlgd9pmXiJytFUs2mMqMUyXvS5 zxCCA4cnCw7EylkXJBn82iSV/B3niIfji6skxvyKM/gWe/dEZMAsfA5Z3vDvBv7lBudf XyxYxApibRPzwNS2WyY8mkQ3mM+rhF4YvcJ9EonXlW+LeucPKJFh1leD+A7IDU4gyNwK f/Rrad4+v7OR8ORQ5o2XzbK4TZmXkzClZPnKQen0xFFwbU8jstaEWDYm+V3pyrFJM7uD vC7QUQvRL+K61OhFOU/6HLYCi561RxBbEIdUsGDYCxtlUm3mCvaalTVCSag6X6k/Fksx oXUg== 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=PhC7j3IXC9MG9VOxl2D8EZbjZXYlDTSG+91UEWWAUbI=; b=Rc4Cts/1p+u8X/4pH39JlMU/Mz6Fdwa5t9XwH+Ncewv8ToOTne4iUEVPEqLFY/abCZ DtDByNG06WuLZjiFI2VorSISA5Dk/+wd289uYBSyvb6O6liEx8VLpD8z5H/hvy54REit 2NY7KoZkI54XL28z2u8g3qI7GOzTMRKAbX/aRPyxMfHvnORvDZK7CNxtN0mOQ7XKU5yC UP7Zv11HnL4Gir6SFRufh4KeagjpxlOWAxRGdAgg+hecxjoBY1OKtFDYObX5Db7ka34E 6+hQgqPiVfZOo0JkSauilgykn4Gc2ZqYLXMtrG14JsRDpO/o27WJmBr3lXqBq7K5+qex OVcg== 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 z2si7201882iti.153.2017.10.09.06.25.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Oct 2017 06:25:58 -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 1e1Y2I-000809-4k; Mon, 09 Oct 2017 13:23:58 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e1Y2H-0007zj-Nm for xen-devel@lists.xen.org; Mon, 09 Oct 2017 13:23:57 +0000 Received: from [193.109.254.147] by server-11.bemta-6.messagelabs.com id 87/12-03638-D687BD95; Mon, 09 Oct 2017 13:23:57 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMLMWRWlGSWpSXmKPExsVysyfVTTen4na kwb9ZGhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8bMudfYC+4IVZybNYWtgfE0XxcjF4eQwGZG iUVdf9ggnNOMEi3nDjF1MXJysAloStz5/AnMFhGQlrj2+TIjiM0sEClx+MMPdhBbWCBB4ua5F 2A1LAKqEld/QtTzClhIbHvfBWZLCMhL7Gq7yApicwpYSkzbPJ0ZxBYCqrn8YQfrBEbuBYwMqx g1ilOLylKLdI0M9JKKMtMzSnITM3N0DQ3M9HJTi4sT01NzEpOK9ZLzczcxAj3MAAQ7GH8tCzj EKMnBpCTKO6XgdqQQX1J+SmVGYnFGfFFpTmrxIUYZDg4lCV77cqCcYFFqempFWmYOMNRg0hIc PEoivKEgad7igsTc4sx0iNQpRl2Ojpt3/zAJseTl56VKifP6ghQJgBRllObBjYCF/SVGWSlhX kago4R4ClKLcjNLUOVfMYpzMCoJ834qA5rCk5lXArfpFdARTEBHMBbfADmiJBEhJdXAOOHoRb V1Mcb7bS/sm/aUPfud4kcZyes6VxaJ/9x9VNvKcElk6r8fv/V7XyWyPD62tvfzJ96ph7MZKiu keU03P/2ziUEq6VXep7aKrv8nFTeu3bxhsijL0vvKh29K95n36DMJP1VMSXv++/C88yphr6p3 S14O1Z6hkyZ9UP9Y6PyplQ0vV0/mlVBiKc5INNRiLipOBABpsUuJdgIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-7.tower-27.messagelabs.com!1507555436!106195016!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 59104 invoked from network); 9 Oct 2017 13:23:56 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-7.tower-27.messagelabs.com with SMTP; 9 Oct 2017 13:23:56 -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 EC60C1529; Mon, 9 Oct 2017 06:23:55 -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 0B2F83F578; Mon, 9 Oct 2017 06:23:54 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 9 Oct 2017 14:23:38 +0100 Message-Id: <20171009132341.1678-8-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171009132341.1678-1-julien.grall@arm.com> References: <20171009132341.1678-1-julien.grall@arm.com> Cc: andre.przywara@arm.com, Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v4 07/10] 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 v4: - Use PAGE_AI_MASK in set_fixmap 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 | 4 ++-- xen/include/asm-arm/page.h | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 70a03015ec..c1dad61a20 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -331,7 +331,7 @@ static inline lpae_t mfn_to_xen_entry(mfn_t mfn, unsigned attr) /* Map a 4k page in a fixmap entry */ void set_fixmap(unsigned map, mfn_t mfn, unsigned int flags) { - lpae_t pte = mfn_to_xen_entry(mfn, flags); + lpae_t pte = mfn_to_xen_entry(mfn, PAGE_AI_MASK(flags)); pte.pt.table = 1; /* 4k mappings always have this bit set */ pte.pt.xn = 1; write_pte(xen_fixmap + third_table_offset(FIXMAP_ADDR(map)), pte); @@ -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 9 13:23:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 115210 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp2557208qgn; Mon, 9 Oct 2017 06:25:55 -0700 (PDT) X-Google-Smtp-Source: AOwi7QD0QU2d2DgUh3+BdC1kj1P/H39hoEiBSgPy3cRCUHsRslvqhgnb4Fjyo1VO4iQg2bHLckpo X-Received: by 10.107.46.163 with SMTP id u35mr12539297iou.276.1507555554826; Mon, 09 Oct 2017 06:25:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507555554; cv=none; d=google.com; s=arc-20160816; b=Arg6Pm4upkwFku1vTxuhXpCpsrMvBLj/4YAWo93UUXrnlq7cXzMkzUo3+ffC/lv+6g JTxqBzVR0fQ+4ruDy1P6kRKyFyhN7ES7mN82jTOsey4NBjw38OwG733kxti7X5kefIn7 RRcc/C0z1uXz5+rcNsPcF2X6lJdLAykYFPwW6zy08KBMwVtGzP7UOSDXh74EoMbRnIBr s9hZ1OvWQ8w7T/wHdZSsGjMcVsRIfveziJexuXQ3rDpquucFPqlGKdn0yCzqAFo3+AFi dpK8etXQKNSgqzx3XPHAIdgtQS3cEnhS6yFRJDb7w52Bfhd1X+xpLGXn4vpee7t9m3eK 4/iA== 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=r8lMdwzCsO7aiJ/Et1OXpXktYlYStnzfrTxh7Hkte5s8psBoWUMhlzlFxNquMBA5zY mVrd2jSR99ZNM1OHU6JxFRvLWPmJx0WNWQ0u3NKo8t39XdFm0dPhK1i1AmoQFFB7C7fU VhBptcNsJKqG+c7dNKVAR3c1QnOdXB1IGh1Lq8rzWMVotqCKjfD7rdTsRTl3m3YUQhlX ZloI/8qV7XJKD70BGK4hG+a466jtQR0MAWLDtVVX+q3LsTgq9XAt4OmB5rbKZolGraCW ofC8kNCLqqwmec9cbzNhuMXpiWaykpw968vRkjtgwYmzSi2wgsV3uGEn/4PRBWqwz0ms 27Bw== 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 b1si7153857ite.15.2017.10.09.06.25.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Oct 2017 06:25:54 -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 1e1Y2K-000811-Iz; Mon, 09 Oct 2017 13:24:00 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e1Y2J-00080T-7p for xen-devel@lists.xen.org; Mon, 09 Oct 2017 13:23:59 +0000 Received: from [85.158.139.211] by server-9.bemta-5.messagelabs.com id 06/94-02040-E687BD95; Mon, 09 Oct 2017 13:23:58 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMLMWRWlGSWpSXmKPExsVysyfVTTe34na kwdtmC4slHxezODB6HN39mymAMYo1My8pvyKBNWPvym3sBe+EKg5vv8vcwPiAv4uRi0NIYDOj ROvZCewQzmlGiS2brrJ0MXJysAloStz5/IkJxBYRkJa49vkyI4jNLBApcfjDD3YQW1jARWLzt 71gNouAqsSqx3fAangFLCT6t+xgBrElBOQldrVdZAWxOQUsJaZtng4WFwKqufxhB+sERu4FjA yrGDWKU4vKUot0jSz0kooy0zNKchMzc3QNDUz1clOLixPTU3MSk4r1kvNzNzECPVzPwMC4g7F vld8hRkkOJiVR3ikFtyOF+JLyUyozEosz4otKc1KLDzHKcHAoSfB+LQfKCRalpqdWpGXmAEMN Ji3BwaMkwhsKkuYtLkjMLc5Mh0idYtTl6Lh59w+TEEtefl6qlDjvcZAiAZCijNI8uBGwsL/EK CslzMvIwMAgxFOQWpSbWYIq/4pRnINRSZj3UxnQFJ7MvBK4Ta+AjmACOoKx+AbIESWJCCmpBs bEqhl+qlfYQ+Yq3zz5/oHCrs4Sz2KVL4m+awrflTV+S1fYY3P+shCzFpeghXRsUnBxoPsvk67 zrzvPhof9FD02jfFEoHb7t7y73MInzksZsd99nTNfee2W10/3BN7tOPpdamb/ioqjtdxbi2sX 3NXwvLP0wuJ4leUXlW4/PXib4bYj11/r6CVKLMUZiYZazEXFiQDPDElgdgIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-13.tower-206.messagelabs.com!1507555437!90638675!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 39245 invoked from network); 9 Oct 2017 13:23:57 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-13.tower-206.messagelabs.com with SMTP; 9 Oct 2017 13:23:57 -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 2234B15AD; Mon, 9 Oct 2017 06:23:57 -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 36B713F578; Mon, 9 Oct 2017 06:23:56 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 9 Oct 2017 14:23:39 +0100 Message-Id: <20171009132341.1678-9-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171009132341.1678-1-julien.grall@arm.com> References: <20171009132341.1678-1-julien.grall@arm.com> Cc: andre.przywara@arm.com, Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v4 08/10] 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 Reviewed-by: Stefano Stabellini --- 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 9 13:23:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 115208 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp2557183qgn; Mon, 9 Oct 2017 06:25:54 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDmjDzzeQc6TLEdvtj6PqdhmeUYxBM6fV1jYz1+t/lI9XuLa8puHXpXFfEQWZbBtXdDP4Ui X-Received: by 10.107.22.65 with SMTP id 62mr13923288iow.269.1507555554182; Mon, 09 Oct 2017 06:25:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507555554; cv=none; d=google.com; s=arc-20160816; b=lgUJbC5IXWUVuC8W6vzvPLXOh98hKtaoV/k0jyvp1VrkS1LeJBj1gmnVkRZDdC3++m vwzW1pW3RSkO5NsLJJriJ0NsyEVVuagk5/Rs8Pajk3D6V6e2cZkg9dcxlpgcwT6/QMt0 BfY8obTszf+1RleAHAIYWLZt5K4r8ArQi2zbXnx70pV07LBQXSpeGxtlmUJz8iYR/ocM zXOWrohBIOydbWt5f0zNN4nOIiiKgSST0rUJH+izBV1C+AtvPgYdOBKJi1UN5wpq+N0T y9mnPhu1LLgVzCAWvp5yNrhzseWnJE8HZbVDENzi3UDQT6jXQM/SFrTcSHGdOPBxVd8C NWVg== 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=qYsqsWihHS+Unmrh2YeAASdUgneFBivoMKiMjnvLPEM=; b=rS5z9k7FjUqDL2MkQBWo33sLEgbTnW2N9J21RYvQrlTtmiySmkcVLEv3poxb7HI5O6 /gCcxbhlLyOWSzVIHCWhERL0d4KGRMa65NyQPuKJ+4MGDbaHFZ4aldhNtdLZWI3oLPc1 ixO4PxOI0hlqdkY0vDhcl0JkQCnVZjKwI6qOWid3L9towFD9nHVJZsTCF+V9WRn7PrHZ ir4Fblje/QHg8cOCJnklt2sQcpp/KgrLXmDVsqrq/8eARe+xV2qVyzfuoCKrvMH1O/se fNAU6LcA72Lgc2ItaLK/rJfM40RxIro9DkuSlYQ8pScqB1NOHCnap00a0zZVtlQ859VH mJ2A== 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 n130si6979388itn.51.2017.10.09.06.25.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Oct 2017 06:25:54 -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 1e1Y2L-00082l-QU; Mon, 09 Oct 2017 13:24:01 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e1Y2K-00080x-G9 for xen-devel@lists.xen.org; Mon, 09 Oct 2017 13:24:00 +0000 Received: from [85.158.137.68] by server-9.bemta-3.messagelabs.com id 5E/49-02039-F687BD95; Mon, 09 Oct 2017 13:23:59 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrJLMWRWlGSWpSXmKPExsVysyfVTTe/4na kwcNvLBZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8an++sZC3rYK37s38vYwNjK2sXIxSEksJlR Yta5dVDOaUaJxhPn2bsYOTnYBDQl7nz+xARiiwhIS1z7fJkRxGYWiJQ4/OEHWI2wQITEpVXzW EBsFgFVibOn9oDFeQUsJf7sBtnAySEhIC+xq+0imM0JFJ+2eToziC0kYCFx+cMO1gmM3AsYGV YxahSnFpWlFukameslFWWmZ5TkJmbm6BoaGOvlphYXJ6an5iQmFesl5+duYgR6uJ6BgXEHY8t ev0OMkhxMSqK8UwpuRwrxJeWnVGYkFmfEF5XmpBYfYpTh4FCS4K0sB8oJFqWmp1akZeYAQw0m LcHBoyTCW14KlOYtLkjMLc5Mh0idYjTmuPHw+h8mjo6bd/8wCbHk5eelSonz+oJMEgApzSjNg xsEi4FLjLJSwryMDAwMQjwFqUW5mSWo8q8YxTkYlYR5M0Cm8GTmlcDtewV0ChPQKYzFN0BOKU lESEk1ME548M54p8rp+dvvpT2XerijuveJpKc896257Ekh9YZyWml2pg+PObnPZlMJ1uLfxFK eb29x6djKWbpcqulZPIUS2RefV4sHhNt+Ef60vel9w7yi92sj7nFUbJgVpHaHPeDG/xDrY0fS 3PXDRbQderJyy14yfNxt6Zo3a9e9vspVpSEfCv/fVWIpzkg01GIuKk4EAI4rOdp8AgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-16.tower-31.messagelabs.com!1507555438!101816037!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 53155 invoked from network); 9 Oct 2017 13:23:58 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-16.tower-31.messagelabs.com with SMTP; 9 Oct 2017 13:23: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 4C23F1435; Mon, 9 Oct 2017 06:23: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 609583F578; Mon, 9 Oct 2017 06:23:57 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 9 Oct 2017 14:23:40 +0100 Message-Id: <20171009132341.1678-10-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171009132341.1678-1-julien.grall@arm.com> References: <20171009132341.1678-1-julien.grall@arm.com> Cc: andre.przywara@arm.com, Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v4 09/10] 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 Reviewed-by: Stefano Stabellini --- 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 c1dad61a20..2329ccee83 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 9 13:23:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 115217 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp2557454qgn; Mon, 9 Oct 2017 06:26:07 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDiLwl0Z5+72/9g8P/PL4NHMPevNxAlVYy7x2JieNNxeigQZAmOUqsmwd3ihtGiUEuCbOt8 X-Received: by 10.36.73.14 with SMTP id z14mr14072498ita.60.1507555567605; Mon, 09 Oct 2017 06:26:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507555567; cv=none; d=google.com; s=arc-20160816; b=GLZothDCH1HWAr/0di76PtWdrlEzqdLx2dHD7nQsvQiuo6ArFtqMdRcsOLSHvLnYUa zinHIo/8e2hQAyFijOL9M7yJa4uWCJxqGWJ0X1gDtd9v7ZC8ttP9GjyzYcv7jZcb7Y+4 omdwSbrP5m9QaM3EYD2tKecWqDxy6mqPQRMmaF0FUsnYzijHHbMt3RvnXhQLonxojq39 0oFe3EhWAJllrsNf30J5MxmT6/Ahh7FcG8qzPZA+2gVq+Cf+QV15fzociuHnt0czdNS+ wwzYfDkTvs9JTf240xILGO9PIC0LjqiOB6RMYSbg7T4KHCxUGn73mIKNnW2nN0RtW3j4 UOCw== 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=HArgUzRWWYv5TBL051/UqmlqyBqc1SKbLJFQwYlqcGc=; b=e1EA4KT58xDL8SQ/C3D6P9Mg1K2dEkohufND5h6tmo6Z3hb5jfIPzN3VwSMTUt6fOA QXuLQ3ZlCL4X7TA/EVP5r6fLoJd+EPLUzWguikDF47jl470U7ueqyCh+HtzaR0YVs6CG X2ei98/SW+ro3YTXcW8xkGmaLtIZM7rXxZfur0cpxmZUeecc7sVPk/m0s/6pP32jlaKZ Oq0q57K1VbTsCrxb0URoJMPmVP8lMq2fiZSDtVqJAKrcgvq0SSt6i2kYsHDXCBO/+qWa 2Sa3UG2BerwgyclTgTe5FbOcg4kUTs9Vyzeba+9XKl60wEtlsnx356m7FXIYIypwIz1u fxUA== 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 v92si6461714iov.5.2017.10.09.06.26.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Oct 2017 06:26: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 1e1Y2T-00088m-18; Mon, 09 Oct 2017 13:24:09 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e1Y2R-000873-QU for xen-devel@lists.xen.org; Mon, 09 Oct 2017 13:24:07 +0000 Received: from [85.158.143.35] by server-5.bemta-6.messagelabs.com id 04/4F-03453-7787BD95; Mon, 09 Oct 2017 13:24:07 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCLMWRWlGSWpSXmKPExsVysyfVTbeg4na kwa8GeYslHxezODB6HN39mymAMYo1My8pvyKBNaP/2VuWgplSFd8nLmFvYDwr3MXIxSEksJlR 4s6fWWwQzmlGiYf7TjJ3MXJysAloStz5/IkJxBYRkJa49vkyI0gRs8B2Ronzc3+zgySEBdIkd mzaxQZiswioSsx7/hDM5hWwlPgwcwMjiC0hIC+xq+0iK4jNCRSftnk62AIhAQuJyx92sE5g5F 7AyLCKUaM4tagstUjX2FgvqSgzPaMkNzEzR9fQwEwvN7W4ODE9NScxqVgvOT93EyPQxwxAsIN x5/rAQ4ySHExKorxTCm5HCvEl5adUZiQWZ8QXleakFh9ilOHgUJLgrSwHygkWpaanVqRl5gCD DSYtwcGjJMLbD5LmLS5IzC3OTIdInWLU5ei4efcPkxBLXn5eqpQ473GQIgGQoozSPLgRsMC/x CgrJczLCHSUEE9BalFuZgmq/CtGcQ5GJWHeT2VAU3gy80rgNr0COoIJ6AjG4hsgR5QkIqSkGh iDTv77yWw/YSvXmkD5PqGZ+kvl1Q6V6RwxfFP2hrFI1SRRwKd28qY4jgLJ8gURB59PnKm40p+ xTbBn3zX5N97GLx885/sR6VLYxf3tecER7z09PldvfA6q2HrZuycjM+meHMethyJaz+f9NuIp XBo5dcfqxMB/aUHP16fpr3/YdNlqQW63VKQSS3FGoqEWc1FxIgD0SL5kdwIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-6.tower-21.messagelabs.com!1507555440!53249268!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 43220 invoked from network); 9 Oct 2017 13:24:00 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-6.tower-21.messagelabs.com with SMTP; 9 Oct 2017 13:24: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 BDA381529; Mon, 9 Oct 2017 06:23: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 8AFED3F578; Mon, 9 Oct 2017 06:23:58 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 9 Oct 2017 14:23:41 +0100 Message-Id: <20171009132341.1678-11-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171009132341.1678-1-julien.grall@arm.com> References: <20171009132341.1678-1-julien.grall@arm.com> Cc: andre.przywara@arm.com, Julien Grall , sstabellini@kernel.org, Ross Lagerwall , Konrad Rzeszutek Wilk Subject: [Xen-devel] [PATCH v4 10/10] 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 v4: - Add Konrad's reviewed-by 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 2329ccee83..3c328e2df5 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