From: Steffen Trumtrar <str@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 02/13] ARM: mmu: inherit pte flags from pmd
Date: Thu, 21 Jan 2021 12:29:47 +0100 [thread overview]
Message-ID: <20210121112958.25937-2-str@pengutronix.de> (raw)
In-Reply-To: <20210121112958.25937-1-str@pengutronix.de>
From: Sascha Hauer <s.hauer@pengutronix.de>
When creating a 2nd level page table from a section inherit the flags
from the section rather than assuming the section was mapped cached
previously. This fixes creating a 2nd level pagetable when the section
was mapped differently than we expected.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/cpu/mmu.c | 28 ++++++++++++++++++++++++----
1 file changed, 24 insertions(+), 4 deletions(-)
diff --git a/arch/arm/cpu/mmu.c b/arch/arm/cpu/mmu.c
index 6af228505d..6388e1bf14 100644
--- a/arch/arm/cpu/mmu.c
+++ b/arch/arm/cpu/mmu.c
@@ -138,6 +138,29 @@ static u32 *arm_create_pte(unsigned long virt, uint32_t flags)
return table;
}
+static u32 pmd_flags_to_pte(u32 pmd)
+{
+ u32 pte = 0;
+
+ if (pmd & PMD_SECT_BUFFERABLE)
+ pte |= PTE_BUFFERABLE;
+ if (pmd & PMD_SECT_CACHEABLE)
+ pte |= PTE_CACHEABLE;
+ if (pmd & PMD_SECT_nG)
+ pte |= PTE_EXT_NG;
+ if (pmd & PMD_SECT_XN)
+ pte |= PTE_EXT_XN;
+
+ /* TEX[2:0] */
+ pte |= PTE_EXT_TEX((pmd >> 12) & 7);
+ /* AP[1:0] */
+ pte |= ((pmd >> 10) & 0x3) << 4;
+ /* AP[2] */
+ pte |= ((pmd >> 15) & 0x1) << 9;
+
+ return pte;
+}
+
int arch_remap_range(void *start, size_t size, unsigned flags)
{
u32 addr = (u32)start;
@@ -206,11 +229,8 @@ int arch_remap_range(void *start, size_t size, unsigned flags)
* If PTE is not found it means that
* we needs to split this section and
* create a new page table for it
- *
- * NOTE: Here we assume that section
- * we just split was mapped as cached
*/
- table = arm_create_pte(addr, pte_flags_cached);
+ table = arm_create_pte(addr, pmd_flags_to_pte(*pgd));
pte = find_pte(addr);
BUG_ON(!pte);
}
--
2.20.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2021-01-21 11:30 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-21 11:29 [PATCH 01/13] ARM: add fncpy.h from linux v4.6 Steffen Trumtrar
2021-01-21 11:29 ` Steffen Trumtrar [this message]
2021-01-21 11:29 ` [PATCH 03/13] firmware: socfpga: set APPLYCFG after loading bitstream Steffen Trumtrar
2021-01-21 11:29 ` [PATCH 04/13] reset: add of_reset_control_get to header Steffen Trumtrar
2021-01-21 11:29 ` [PATCH 05/13] drivers: add fpga bridge framework Steffen Trumtrar
2021-01-21 11:29 ` [PATCH 06/13] drivers: fpga: add socfpga bridges Steffen Trumtrar
2021-01-21 11:29 ` [PATCH 07/13] firmware: socfpga: change function prefixes Steffen Trumtrar
2021-01-21 11:29 ` [PATCH 08/13] firmware: import fpga-mgr.h from linux Steffen Trumtrar
2021-01-21 11:29 ` [PATCH 09/13] of: kconfig: of_overlay uses firmwaremgr_load_file Steffen Trumtrar
2021-01-21 11:29 ` [PATCH 10/13] of: of_firmware: add support for fpga bridges Steffen Trumtrar
2021-01-25 9:52 ` Sascha Hauer
2021-01-26 8:47 ` Steffen Trumtrar
2021-01-26 11:02 ` Sascha Hauer
2021-01-21 11:29 ` [PATCH 11/13] commands: firmwareload: allow loading firmware from dt Steffen Trumtrar
2021-01-21 11:29 ` [PATCH 12/13] drivers: firmware: socfpga: remove bridges shutdown Steffen Trumtrar
2021-01-21 11:29 ` [PATCH 13/13] firmware: add support for compressed images Steffen Trumtrar
2021-01-25 9:56 ` [PATCH 01/13] ARM: add fncpy.h from linux v4.6 Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210121112958.25937-2-str@pengutronix.de \
--to=str@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox