* [PATCH 1/4] ARM: mmu: decouple VECTORS_BASE from Kconfig
2017-01-18 20:35 [PATCH 0/4] ARM: v7-A !MMU support, CONFIG_VECTORS_BASE removal (almost) afzal mohammed
@ 2017-01-18 20:37 ` afzal mohammed
2017-01-19 13:21 ` Afzal Mohammed
` (2 more replies)
2017-01-18 20:38 ` [PATCH 2/4] ARM: nommu: dynamic exception base address setting afzal mohammed
` (2 subsequent siblings)
3 siblings, 3 replies; 16+ messages in thread
From: afzal mohammed @ 2017-01-18 20:37 UTC (permalink / raw)
To: Russell King - ARM Linux
Cc: Vladimir Murzin, linux-arm-kernel, linux-kernel, afzal mohammed
For MMU configurations, VECTORS_BASE is always 0xffff0000, a macro
definition will suffice.
Once exception address is handled dynamically for no-MMU also (this
would involve taking care of region setup too), VECTORS_BASE can be
removed from Kconfig.
Suggested-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: afzal mohammed <afzal.mohd.ma@gmail.com>
---
Though there was no build error without inclusion of asm/memory.h, to
be on the safer side it has been added, to reduce chances of build
breakage in random configurations.
arch/arm/include/asm/memory.h | 2 ++
arch/arm/mach-berlin/platsmp.c | 3 ++-
arch/arm/mm/dump.c | 5 +++--
arch/arm/mm/init.c | 4 ++--
4 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
index 76cbd9c674df..9cc9f1dbc88e 100644
--- a/arch/arm/include/asm/memory.h
+++ b/arch/arm/include/asm/memory.h
@@ -83,6 +83,8 @@
#define IOREMAP_MAX_ORDER 24
#endif
+#define VECTORS_BASE 0xffff0000
+
#else /* CONFIG_MMU */
/*
diff --git a/arch/arm/mach-berlin/platsmp.c b/arch/arm/mach-berlin/platsmp.c
index 93f90688db18..578d41031abf 100644
--- a/arch/arm/mach-berlin/platsmp.c
+++ b/arch/arm/mach-berlin/platsmp.c
@@ -15,6 +15,7 @@
#include <asm/cacheflush.h>
#include <asm/cp15.h>
+#include <asm/memory.h>
#include <asm/smp_plat.h>
#include <asm/smp_scu.h>
@@ -75,7 +76,7 @@ static void __init berlin_smp_prepare_cpus(unsigned int max_cpus)
if (!cpu_ctrl)
goto unmap_scu;
- vectors_base = ioremap(CONFIG_VECTORS_BASE, SZ_32K);
+ vectors_base = ioremap(VECTORS_BASE, SZ_32K);
if (!vectors_base)
goto unmap_scu;
diff --git a/arch/arm/mm/dump.c b/arch/arm/mm/dump.c
index 9fe8e241335c..21192d6eda40 100644
--- a/arch/arm/mm/dump.c
+++ b/arch/arm/mm/dump.c
@@ -18,6 +18,7 @@
#include <linux/seq_file.h>
#include <asm/fixmap.h>
+#include <asm/memory.h>
#include <asm/pgtable.h>
struct addr_marker {
@@ -31,8 +32,8 @@ static struct addr_marker address_markers[] = {
{ 0, "vmalloc() Area" },
{ VMALLOC_END, "vmalloc() End" },
{ FIXADDR_START, "Fixmap Area" },
- { CONFIG_VECTORS_BASE, "Vectors" },
- { CONFIG_VECTORS_BASE + PAGE_SIZE * 2, "Vectors End" },
+ { VECTORS_BASE, "Vectors" },
+ { VECTORS_BASE + PAGE_SIZE * 2, "Vectors End" },
{ -1, NULL },
};
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 370581aeb871..cf47f86f79ed 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -27,6 +27,7 @@
#include <asm/cp15.h>
#include <asm/mach-types.h>
#include <asm/memblock.h>
+#include <asm/memory.h>
#include <asm/prom.h>
#include <asm/sections.h>
#include <asm/setup.h>
@@ -521,8 +522,7 @@ void __init mem_init(void)
" .data : 0x%p" " - 0x%p" " (%4td kB)\n"
" .bss : 0x%p" " - 0x%p" " (%4td kB)\n",
- MLK(UL(CONFIG_VECTORS_BASE), UL(CONFIG_VECTORS_BASE) +
- (PAGE_SIZE)),
+ MLK(UL(VECTORS_BASE), UL(VECTORS_BASE) + (PAGE_SIZE)),
#ifdef CONFIG_HAVE_TCM
MLK(DTCM_OFFSET, (unsigned long) dtcm_end),
MLK(ITCM_OFFSET, (unsigned long) itcm_end),
--
2.11.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 1/4] ARM: mmu: decouple VECTORS_BASE from Kconfig
2017-01-18 20:37 ` [PATCH 1/4] ARM: mmu: decouple VECTORS_BASE from Kconfig afzal mohammed
@ 2017-01-19 13:21 ` Afzal Mohammed
2017-01-19 14:07 ` kbuild test robot
2017-01-19 14:24 ` Russell King - ARM Linux
2 siblings, 0 replies; 16+ messages in thread
From: Afzal Mohammed @ 2017-01-19 13:21 UTC (permalink / raw)
To: Russell King - ARM Linux
Cc: Vladimir Murzin, Jisheng Zhang, Sebastian Hesselbarth,
linux-arm-kernel, linux-kernel
+ Marvell Berlin SoC maintainers - Sebastian, Jisheng
On Thu, Jan 19, 2017 at 02:07:39AM +0530, afzal mohammed wrote:
> For MMU configurations, VECTORS_BASE is always 0xffff0000, a macro
> definition will suffice.
>
> Once exception address is handled dynamically for no-MMU also (this
> would involve taking care of region setup too), VECTORS_BASE can be
> removed from Kconfig.
>
> Suggested-by: Russell King <rmk+kernel@arm.linux.org.uk>
> Signed-off-by: afzal mohammed <afzal.mohd.ma@gmail.com>
> ---
>
> Though there was no build error without inclusion of asm/memory.h, to
> be on the safer side it has been added, to reduce chances of build
> breakage in random configurations.
>
> arch/arm/include/asm/memory.h | 2 ++
> arch/arm/mach-berlin/platsmp.c | 3 ++-
> arch/arm/mm/dump.c | 5 +++--
> arch/arm/mm/init.c | 4 ++--
> 4 files changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
> index 76cbd9c674df..9cc9f1dbc88e 100644
> --- a/arch/arm/include/asm/memory.h
> +++ b/arch/arm/include/asm/memory.h
> @@ -83,6 +83,8 @@
> #define IOREMAP_MAX_ORDER 24
> #endif
>
> +#define VECTORS_BASE 0xffff0000
> +
> #else /* CONFIG_MMU */
>
> /*
> diff --git a/arch/arm/mach-berlin/platsmp.c b/arch/arm/mach-berlin/platsmp.c
> index 93f90688db18..578d41031abf 100644
> --- a/arch/arm/mach-berlin/platsmp.c
> +++ b/arch/arm/mach-berlin/platsmp.c
> @@ -15,6 +15,7 @@
>
> #include <asm/cacheflush.h>
> #include <asm/cp15.h>
> +#include <asm/memory.h>
> #include <asm/smp_plat.h>
> #include <asm/smp_scu.h>
>
> @@ -75,7 +76,7 @@ static void __init berlin_smp_prepare_cpus(unsigned int max_cpus)
> if (!cpu_ctrl)
> goto unmap_scu;
>
> - vectors_base = ioremap(CONFIG_VECTORS_BASE, SZ_32K);
> + vectors_base = ioremap(VECTORS_BASE, SZ_32K);
> if (!vectors_base)
> goto unmap_scu;
>
> diff --git a/arch/arm/mm/dump.c b/arch/arm/mm/dump.c
> index 9fe8e241335c..21192d6eda40 100644
> --- a/arch/arm/mm/dump.c
> +++ b/arch/arm/mm/dump.c
> @@ -18,6 +18,7 @@
> #include <linux/seq_file.h>
>
> #include <asm/fixmap.h>
> +#include <asm/memory.h>
> #include <asm/pgtable.h>
>
> struct addr_marker {
> @@ -31,8 +32,8 @@ static struct addr_marker address_markers[] = {
> { 0, "vmalloc() Area" },
> { VMALLOC_END, "vmalloc() End" },
> { FIXADDR_START, "Fixmap Area" },
> - { CONFIG_VECTORS_BASE, "Vectors" },
> - { CONFIG_VECTORS_BASE + PAGE_SIZE * 2, "Vectors End" },
> + { VECTORS_BASE, "Vectors" },
> + { VECTORS_BASE + PAGE_SIZE * 2, "Vectors End" },
> { -1, NULL },
> };
>
> diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
> index 370581aeb871..cf47f86f79ed 100644
> --- a/arch/arm/mm/init.c
> +++ b/arch/arm/mm/init.c
> @@ -27,6 +27,7 @@
> #include <asm/cp15.h>
> #include <asm/mach-types.h>
> #include <asm/memblock.h>
> +#include <asm/memory.h>
> #include <asm/prom.h>
> #include <asm/sections.h>
> #include <asm/setup.h>
> @@ -521,8 +522,7 @@ void __init mem_init(void)
> " .data : 0x%p" " - 0x%p" " (%4td kB)\n"
> " .bss : 0x%p" " - 0x%p" " (%4td kB)\n",
>
> - MLK(UL(CONFIG_VECTORS_BASE), UL(CONFIG_VECTORS_BASE) +
> - (PAGE_SIZE)),
> + MLK(UL(VECTORS_BASE), UL(VECTORS_BASE) + (PAGE_SIZE)),
> #ifdef CONFIG_HAVE_TCM
> MLK(DTCM_OFFSET, (unsigned long) dtcm_end),
> MLK(ITCM_OFFSET, (unsigned long) itcm_end),
> --
> 2.11.0
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 1/4] ARM: mmu: decouple VECTORS_BASE from Kconfig
2017-01-18 20:37 ` [PATCH 1/4] ARM: mmu: decouple VECTORS_BASE from Kconfig afzal mohammed
2017-01-19 13:21 ` Afzal Mohammed
@ 2017-01-19 14:07 ` kbuild test robot
2017-01-19 14:24 ` Russell King - ARM Linux
2 siblings, 0 replies; 16+ messages in thread
From: kbuild test robot @ 2017-01-19 14:07 UTC (permalink / raw)
To: afzal mohammed
Cc: kbuild-all, Russell King - ARM Linux, Vladimir Murzin,
linux-arm-kernel, linux-kernel, afzal mohammed
[-- Attachment #1: Type: text/plain, Size: 4244 bytes --]
Hi afzal,
[auto build test ERROR on linus/master]
[also build test ERROR on v4.10-rc4 next-20170119]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/afzal-mohammed/ARM-mmu-decouple-VECTORS_BASE-from-Kconfig/20170119-171424
config: arm-stm32_defconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm
Note: the linux-review/afzal-mohammed/ARM-mmu-decouple-VECTORS_BASE-from-Kconfig/20170119-171424 HEAD dd110acc21d40c8f50374de1e500a091d14f29c8 builds fine.
It only hurts bisectibility.
All error/warnings (new ones prefixed by >>):
arch/arm/mm/init.c: In function 'mem_init':
>> arch/arm/mm/init.c:525:11: error: 'VECTORS_BASEUL' undeclared (first use in this function)
MLK(UL(VECTORS_BASE), UL(VECTORS_BASE) + (PAGE_SIZE)),
^
arch/arm/mm/init.c:501:19: note: in definition of macro 'MLK'
#define MLK(b, t) b, t, ((t) - (b)) >> 10
^
>> include/uapi/linux/const.h:20:18: note: in expansion of macro '__AC'
#define _AC(X,Y) __AC(X,Y)
^~~~
>> arch/arm/include/asm/memory.h:29:15: note: in expansion of macro '_AC'
#define UL(x) _AC(x, UL)
^~~
>> include/linux/printk.h:297:36: note: in expansion of macro 'UL'
printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
^~~~~~~~~~~
>> arch/arm/mm/init.c:505:2: note: in expansion of macro 'pr_notice'
pr_notice("Virtual kernel memory layout:\n"
^~~~~~~~~
arch/arm/mm/init.c:525:11: note: each undeclared identifier is reported only once for each function it appears in
MLK(UL(VECTORS_BASE), UL(VECTORS_BASE) + (PAGE_SIZE)),
^
arch/arm/mm/init.c:501:19: note: in definition of macro 'MLK'
#define MLK(b, t) b, t, ((t) - (b)) >> 10
^
>> include/uapi/linux/const.h:20:18: note: in expansion of macro '__AC'
#define _AC(X,Y) __AC(X,Y)
^~~~
>> arch/arm/include/asm/memory.h:29:15: note: in expansion of macro '_AC'
#define UL(x) _AC(x, UL)
^~~
>> include/linux/printk.h:297:36: note: in expansion of macro 'UL'
printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
^~~~~~~~~~~
>> arch/arm/mm/init.c:505:2: note: in expansion of macro 'pr_notice'
pr_notice("Virtual kernel memory layout:\n"
^~~~~~~~~
vim +/VECTORS_BASEUL +525 arch/arm/mm/init.c
499 mem_init_print_info(NULL);
500
501 #define MLK(b, t) b, t, ((t) - (b)) >> 10
502 #define MLM(b, t) b, t, ((t) - (b)) >> 20
503 #define MLK_ROUNDUP(b, t) b, t, DIV_ROUND_UP(((t) - (b)), SZ_1K)
504
> 505 pr_notice("Virtual kernel memory layout:\n"
506 " vector : 0x%08lx - 0x%08lx (%4ld kB)\n"
507 #ifdef CONFIG_HAVE_TCM
508 " DTCM : 0x%08lx - 0x%08lx (%4ld kB)\n"
509 " ITCM : 0x%08lx - 0x%08lx (%4ld kB)\n"
510 #endif
511 " fixmap : 0x%08lx - 0x%08lx (%4ld kB)\n"
512 " vmalloc : 0x%08lx - 0x%08lx (%4ld MB)\n"
513 " lowmem : 0x%08lx - 0x%08lx (%4ld MB)\n"
514 #ifdef CONFIG_HIGHMEM
515 " pkmap : 0x%08lx - 0x%08lx (%4ld MB)\n"
516 #endif
517 #ifdef CONFIG_MODULES
518 " modules : 0x%08lx - 0x%08lx (%4ld MB)\n"
519 #endif
520 " .text : 0x%p" " - 0x%p" " (%4td kB)\n"
521 " .init : 0x%p" " - 0x%p" " (%4td kB)\n"
522 " .data : 0x%p" " - 0x%p" " (%4td kB)\n"
523 " .bss : 0x%p" " - 0x%p" " (%4td kB)\n",
524
> 525 MLK(UL(VECTORS_BASE), UL(VECTORS_BASE) + (PAGE_SIZE)),
526 #ifdef CONFIG_HAVE_TCM
527 MLK(DTCM_OFFSET, (unsigned long) dtcm_end),
528 MLK(ITCM_OFFSET, (unsigned long) itcm_end),
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 8634 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 1/4] ARM: mmu: decouple VECTORS_BASE from Kconfig
2017-01-18 20:37 ` [PATCH 1/4] ARM: mmu: decouple VECTORS_BASE from Kconfig afzal mohammed
2017-01-19 13:21 ` Afzal Mohammed
2017-01-19 14:07 ` kbuild test robot
@ 2017-01-19 14:24 ` Russell King - ARM Linux
2017-01-20 16:06 ` Afzal Mohammed
2017-01-22 3:27 ` Afzal Mohammed
2 siblings, 2 replies; 16+ messages in thread
From: Russell King - ARM Linux @ 2017-01-19 14:24 UTC (permalink / raw)
To: afzal mohammed; +Cc: Vladimir Murzin, linux-arm-kernel, linux-kernel
On Thu, Jan 19, 2017 at 02:07:39AM +0530, afzal mohammed wrote:
> diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
> index 76cbd9c674df..9cc9f1dbc88e 100644
> --- a/arch/arm/include/asm/memory.h
> +++ b/arch/arm/include/asm/memory.h
> @@ -83,6 +83,8 @@
> #define IOREMAP_MAX_ORDER 24
> #endif
>
> +#define VECTORS_BASE 0xffff0000
This should be UL(0xffff0000)
> - MLK(UL(CONFIG_VECTORS_BASE), UL(CONFIG_VECTORS_BASE) +
> - (PAGE_SIZE)),
> + MLK(UL(VECTORS_BASE), UL(VECTORS_BASE) + (PAGE_SIZE)),
which means you don't need it here, which will then fix the build error
reported by the 0-day builder.
--
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 1/4] ARM: mmu: decouple VECTORS_BASE from Kconfig
2017-01-19 14:24 ` Russell King - ARM Linux
@ 2017-01-20 16:06 ` Afzal Mohammed
2017-01-22 3:27 ` Afzal Mohammed
1 sibling, 0 replies; 16+ messages in thread
From: Afzal Mohammed @ 2017-01-20 16:06 UTC (permalink / raw)
To: Russell King - ARM Linux; +Cc: Vladimir Murzin, linux-arm-kernel, linux-kernel
Hi,
On Thu, Jan 19, 2017 at 02:24:24PM +0000, Russell King - ARM Linux wrote:
> On Thu, Jan 19, 2017 at 02:07:39AM +0530, afzal mohammed wrote:
> > +++ b/arch/arm/include/asm/memory.h
> > +#define VECTORS_BASE 0xffff0000
>
> This should be UL(0xffff0000)
> > - MLK(UL(CONFIG_VECTORS_BASE), UL(CONFIG_VECTORS_BASE) +
> > - (PAGE_SIZE)),
> > + MLK(UL(VECTORS_BASE), UL(VECTORS_BASE) + (PAGE_SIZE)),
>
> which means you don't need it here, which will then fix the build error
> reported by the 0-day builder.
Seems there is some confusion here,
VECTORS_BASE definition above in memory.h is enclosed within
CONFIG_MMU. Robot used a no-MMU defconfig, it didn't get a
VECTORS_BASE definition at this patch, causing the build error. Our
dear robot mentioned that my HEAD didn't break build, but
bisectability is broken at this point.
With "PATCH 3/4 ARM: nommu: display vectors base", the above is
changed to
#ifdef CONFIG_MMU
MLK(UL(VECTORS_BASE), UL(VECTORS_BASE) + (PAGE_SIZE)),
#else
...
#endif
thus making the series build again for no-MMU
One option to keep bisectability would be to squash this with PATCH
3/4, but i think a better & natural solution would be define
VECTORS_BASE outside of
#ifdef CONFIG_MMU
...
#else
...
#endif
and then in PATCH 3/4, move VECTORS_BASE to be inside
#ifdef CONFIG_MMU
...
#else
Regards
afzal
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 1/4] ARM: mmu: decouple VECTORS_BASE from Kconfig
2017-01-19 14:24 ` Russell King - ARM Linux
2017-01-20 16:06 ` Afzal Mohammed
@ 2017-01-22 3:27 ` Afzal Mohammed
1 sibling, 0 replies; 16+ messages in thread
From: Afzal Mohammed @ 2017-01-22 3:27 UTC (permalink / raw)
To: Russell King - ARM Linux; +Cc: Vladimir Murzin, linux-arm-kernel, linux-kernel
Hi,
On Thu, Jan 19, 2017 at 02:24:24PM +0000, Russell King - ARM Linux wrote:
> On Thu, Jan 19, 2017 at 02:07:39AM +0530, afzal mohammed wrote:
> > +#define VECTORS_BASE 0xffff0000
>
> This should be UL(0xffff0000)
This has been taken care in v2.
Regards
afzal
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 2/4] ARM: nommu: dynamic exception base address setting
2017-01-18 20:35 [PATCH 0/4] ARM: v7-A !MMU support, CONFIG_VECTORS_BASE removal (almost) afzal mohammed
2017-01-18 20:37 ` [PATCH 1/4] ARM: mmu: decouple VECTORS_BASE from Kconfig afzal mohammed
@ 2017-01-18 20:38 ` afzal mohammed
2017-01-19 13:59 ` Vladimir Murzin
2017-01-18 20:38 ` [PATCH 3/4] ARM: nommu: display vectors base afzal mohammed
2017-01-18 20:39 ` [PATCH 4/4] ARM: nommu: remove Hivecs configuration is asm afzal mohammed
3 siblings, 1 reply; 16+ messages in thread
From: afzal mohammed @ 2017-01-18 20:38 UTC (permalink / raw)
To: Russell King - ARM Linux
Cc: Vladimir Murzin, linux-arm-kernel, linux-kernel, afzal mohammed
No-MMU dynamic exception base address configuration on CP15
processors. In the case of low vectors, decision based on whether
security extensions are enabled & whether remap vectors to RAM
CONFIG option is selected.
For no-MMU without CP15, current default value of 0x0 is retained.
Signed-off-by: afzal mohammed <afzal.mohd.ma@gmail.com>
---
arch/arm/mm/nommu.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 62 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mm/nommu.c b/arch/arm/mm/nommu.c
index 2740967727e2..db8e784f20f3 100644
--- a/arch/arm/mm/nommu.c
+++ b/arch/arm/mm/nommu.c
@@ -11,6 +11,7 @@
#include <linux/kernel.h>
#include <asm/cacheflush.h>
+#include <asm/cp15.h>
#include <asm/sections.h>
#include <asm/page.h>
#include <asm/setup.h>
@@ -22,6 +23,8 @@
#include "mm.h"
+unsigned long vectors_base;
+
#ifdef CONFIG_ARM_MPU
struct mpu_rgn_info mpu_rgn_info;
@@ -278,15 +281,72 @@ static void sanity_check_meminfo_mpu(void) {}
static void __init mpu_setup(void) {}
#endif /* CONFIG_ARM_MPU */
+#ifdef CONFIG_CPU_CP15
+#ifdef CONFIG_CPU_HIGH_VECTOR
+static unsigned long __init setup_vectors_base(void)
+{
+ unsigned long reg = get_cr();
+
+ set_cr(reg | CR_V);
+ return 0xffff0000;
+}
+#else /* CONFIG_CPU_HIGH_VECTOR */
+/*
+ * ID_PRF1 bits (CP#15 ID_PFR1)
+ */
+#define ID_PFR1_SE (0x3 << 4) /* Security extension enable bits */
+
+/* Read processor feature register ID_PFR1 */
+static unsigned long get_id_pfr1(void)
+{
+ unsigned long val;
+
+ asm("mrc p15, 0, %0, c0, c1, 1" : "=r" (val) : : "cc");
+ return val;
+}
+
+/* Write exception base address to VBAR */
+static void set_vbar(unsigned long val)
+{
+ asm("mcr p15, 0, %0, c12, c0, 0" : : "r" (val) : "cc");
+}
+
+static bool __init security_extensions_enabled(void)
+{
+ return !!(get_id_pfr1() & ID_PFR1_SE);
+}
+
+static unsigned long __init setup_vectors_base(void)
+{
+ unsigned long base = 0, reg = get_cr();
+
+ set_cr(reg & ~CR_V);
+ if (security_extensions_enabled()) {
+ if (IS_ENABLED(CONFIG_REMAP_VECTORS_TO_RAM))
+ base = CONFIG_DRAM_BASE;
+ set_vbar(base);
+ } else if (IS_ENABLED(CONFIG_REMAP_VECTORS_TO_RAM)) {
+ if (CONFIG_DRAM_BASE != 0)
+ pr_err("Security extensions not enabled, vectors cannot be remapped to RAM, vectors base will be 0x00000000\n");
+ }
+
+ return base;
+}
+#endif /* CONFIG_CPU_HIGH_VECTOR */
+#endif /* CONFIG_CPU_CP15 */
+
void __init arm_mm_memblock_reserve(void)
{
#ifndef CONFIG_CPU_V7M
+#ifdef CONFIG_CPU_CP15
+ vectors_base = setup_vectors_base();
+#endif
/*
* Register the exception vector page.
* some architectures which the DRAM is the exception vector to trap,
* alloc_page breaks with error, although it is not NULL, but "0."
*/
- memblock_reserve(CONFIG_VECTORS_BASE, 2 * PAGE_SIZE);
+ memblock_reserve(vectors_base, 2 * PAGE_SIZE);
#else /* ifndef CONFIG_CPU_V7M */
/*
* There is no dedicated vector page on V7-M. So nothing needs to be
@@ -310,7 +370,7 @@ void __init sanity_check_meminfo(void)
*/
void __init paging_init(const struct machine_desc *mdesc)
{
- early_trap_init((void *)CONFIG_VECTORS_BASE);
+ early_trap_init((void *)vectors_base);
mpu_setup();
bootmem_init();
}
--
2.11.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 2/4] ARM: nommu: dynamic exception base address setting
2017-01-18 20:38 ` [PATCH 2/4] ARM: nommu: dynamic exception base address setting afzal mohammed
@ 2017-01-19 13:59 ` Vladimir Murzin
2017-01-20 16:20 ` Afzal Mohammed
0 siblings, 1 reply; 16+ messages in thread
From: Vladimir Murzin @ 2017-01-19 13:59 UTC (permalink / raw)
To: afzal mohammed, Russell King - ARM Linux; +Cc: linux-arm-kernel, linux-kernel
Hi,
On 18/01/17 20:38, afzal mohammed wrote:
> No-MMU dynamic exception base address configuration on CP15
> processors. In the case of low vectors, decision based on whether
> security extensions are enabled & whether remap vectors to RAM
> CONFIG option is selected.
>
> For no-MMU without CP15, current default value of 0x0 is retained.
>
> Signed-off-by: afzal mohammed <afzal.mohd.ma@gmail.com>
> ---
> arch/arm/mm/nommu.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 62 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/mm/nommu.c b/arch/arm/mm/nommu.c
> index 2740967727e2..db8e784f20f3 100644
> --- a/arch/arm/mm/nommu.c
> +++ b/arch/arm/mm/nommu.c
> @@ -11,6 +11,7 @@
> #include <linux/kernel.h>
>
> #include <asm/cacheflush.h>
> +#include <asm/cp15.h>
> #include <asm/sections.h>
> #include <asm/page.h>
> #include <asm/setup.h>
> @@ -22,6 +23,8 @@
>
> #include "mm.h"
>
> +unsigned long vectors_base;
> +
> #ifdef CONFIG_ARM_MPU
> struct mpu_rgn_info mpu_rgn_info;
>
> @@ -278,15 +281,72 @@ static void sanity_check_meminfo_mpu(void) {}
> static void __init mpu_setup(void) {}
> #endif /* CONFIG_ARM_MPU */
>
> +#ifdef CONFIG_CPU_CP15
> +#ifdef CONFIG_CPU_HIGH_VECTOR
> +static unsigned long __init setup_vectors_base(void)
> +{
> + unsigned long reg = get_cr();
> +
> + set_cr(reg | CR_V);
> + return 0xffff0000;
> +}
> +#else /* CONFIG_CPU_HIGH_VECTOR */
> +/*
> + * ID_PRF1 bits (CP#15 ID_PFR1)
> + */
> +#define ID_PFR1_SE (0x3 << 4) /* Security extension enable bits */
This bitfiled is 4 bits wide.
> +
> +/* Read processor feature register ID_PFR1 */
> +static unsigned long get_id_pfr1(void)
> +{
> + unsigned long val;
> +
> + asm("mrc p15, 0, %0, c0, c1, 1" : "=r" (val) : : "cc");
> + return val;
> +}
> +
> +/* Write exception base address to VBAR */
> +static void set_vbar(unsigned long val)
> +{
> + asm("mcr p15, 0, %0, c12, c0, 0" : : "r" (val) : "cc");
> +}
> +
> +static bool __init security_extensions_enabled(void)
> +{
> + return !!(get_id_pfr1() & ID_PFR1_SE);
> +}
> +
> +static unsigned long __init setup_vectors_base(void)
> +{
> + unsigned long base = 0, reg = get_cr();
> +
> + set_cr(reg & ~CR_V);
> + if (security_extensions_enabled()) {
You can use
cpuid_feature_extract(CPUID_EXT_PFR1, 4)
and add a comment explaining what we are looking for and why.
> + if (IS_ENABLED(CONFIG_REMAP_VECTORS_TO_RAM))
> + base = CONFIG_DRAM_BASE;
> + set_vbar(base);
> + } else if (IS_ENABLED(CONFIG_REMAP_VECTORS_TO_RAM)) {
> + if (CONFIG_DRAM_BASE != 0)
> + pr_err("Security extensions not enabled, vectors cannot be remapped to RAM, vectors base will be 0x00000000\n");
> + }
> +
> + return base;
> +}
> +#endif /* CONFIG_CPU_HIGH_VECTOR */
> +#endif /* CONFIG_CPU_CP15 */
> +
> void __init arm_mm_memblock_reserve(void)
> {
> #ifndef CONFIG_CPU_V7M
> +#ifdef CONFIG_CPU_CP15
> + vectors_base = setup_vectors_base();
> +#endif
alternatively it can be
unsigned long vector_base = IS_ENABLED(CONFIG_CPU_CP15) ? setup_vbar() : 0;
Thanks
Vladimir
> /*
> * Register the exception vector page.
> * some architectures which the DRAM is the exception vector to trap,
> * alloc_page breaks with error, although it is not NULL, but "0."
> */
> - memblock_reserve(CONFIG_VECTORS_BASE, 2 * PAGE_SIZE);
> + memblock_reserve(vectors_base, 2 * PAGE_SIZE);
> #else /* ifndef CONFIG_CPU_V7M */
> /*
> * There is no dedicated vector page on V7-M. So nothing needs to be
> @@ -310,7 +370,7 @@ void __init sanity_check_meminfo(void)
> */
> void __init paging_init(const struct machine_desc *mdesc)
> {
> - early_trap_init((void *)CONFIG_VECTORS_BASE);
> + early_trap_init((void *)vectors_base);
> mpu_setup();
> bootmem_init();
> }
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 2/4] ARM: nommu: dynamic exception base address setting
2017-01-19 13:59 ` Vladimir Murzin
@ 2017-01-20 16:20 ` Afzal Mohammed
2017-01-22 3:37 ` Afzal Mohammed
0 siblings, 1 reply; 16+ messages in thread
From: Afzal Mohammed @ 2017-01-20 16:20 UTC (permalink / raw)
To: Vladimir Murzin; +Cc: Russell King - ARM Linux, linux-arm-kernel, linux-kernel
Hi,
On Thu, Jan 19, 2017 at 01:59:09PM +0000, Vladimir Murzin wrote:
> On 18/01/17 20:38, afzal mohammed wrote:
> > +#define ID_PFR1_SE (0x3 << 4) /* Security extension enable bits */
>
> This bitfiled is 4 bits wide.
Since only 2 LSb's out of the 4 were enough to detect whether security
extensions were enabled, it was done so. i am going to use your below
suggestion & this would be taken care by that.
> > + if (security_extensions_enabled()) {
>
> You can use
>
> cpuid_feature_extract(CPUID_EXT_PFR1, 4)
>
> and add a comment explaining what we are looking for and why.
Yes, that is better, was not aware of this, did saw CPUID_EXT_PFR1 as
an unused macro.
> > +#ifdef CONFIG_CPU_CP15
> > + vectors_base = setup_vectors_base();
> > +#endif
>
> alternatively it can be
>
> unsigned long vector_base = IS_ENABLED(CONFIG_CPU_CP15) ? setup_vbar() : 0;
Yes that certainly is better.
Regards
afzal
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 2/4] ARM: nommu: dynamic exception base address setting
2017-01-20 16:20 ` Afzal Mohammed
@ 2017-01-22 3:37 ` Afzal Mohammed
0 siblings, 0 replies; 16+ messages in thread
From: Afzal Mohammed @ 2017-01-22 3:37 UTC (permalink / raw)
To: Vladimir Murzin; +Cc: Russell King - ARM Linux, linux-arm-kernel, linux-kernel
Hi,
On Fri, Jan 20, 2017 at 09:50:22PM +0530, Afzal Mohammed wrote:
> On Thu, Jan 19, 2017 at 01:59:09PM +0000, Vladimir Murzin wrote:
> > You can use
> >
> > cpuid_feature_extract(CPUID_EXT_PFR1, 4)
> >
> > and add a comment explaining what we are looking for and why.
W.r.t comments, tried to keep it concise, C tokens doing a part of it.
> Yes, that is better, was not aware of this, did saw CPUID_EXT_PFR1 as
> an unused macro.
> > > +#ifdef CONFIG_CPU_CP15
> > > + vectors_base = setup_vectors_base();
> > > +#endif
> >
> > alternatively it can be
> >
> > unsigned long vector_base = IS_ENABLED(CONFIG_CPU_CP15) ? setup_vbar() : 0;
>
> Yes that certainly is better.
Have kept the function name as setup_vector_base() as in addition to
setting up VBAR, V bit also has to be configured by it - so that
function name remains true to it's name.
v2 with changes has been posted.
Regards
afzal
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 3/4] ARM: nommu: display vectors base
2017-01-18 20:35 [PATCH 0/4] ARM: v7-A !MMU support, CONFIG_VECTORS_BASE removal (almost) afzal mohammed
2017-01-18 20:37 ` [PATCH 1/4] ARM: mmu: decouple VECTORS_BASE from Kconfig afzal mohammed
2017-01-18 20:38 ` [PATCH 2/4] ARM: nommu: dynamic exception base address setting afzal mohammed
@ 2017-01-18 20:38 ` afzal mohammed
2017-01-18 22:13 ` Russell King - ARM Linux
2017-01-18 20:39 ` [PATCH 4/4] ARM: nommu: remove Hivecs configuration is asm afzal mohammed
3 siblings, 1 reply; 16+ messages in thread
From: afzal mohammed @ 2017-01-18 20:38 UTC (permalink / raw)
To: Russell King - ARM Linux
Cc: Vladimir Murzin, linux-arm-kernel, linux-kernel, afzal mohammed
The exception base address is now dynamically estimated for no-MMU
case, display it.
Signed-off-by: afzal mohammed <afzal.mohd.ma@gmail.com>
---
arch/arm/mm/init.c | 5 +++++
arch/arm/mm/mm.h | 5 +++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index cf47f86f79ed..9e11f255c3bf 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -522,7 +522,12 @@ void __init mem_init(void)
" .data : 0x%p" " - 0x%p" " (%4td kB)\n"
" .bss : 0x%p" " - 0x%p" " (%4td kB)\n",
+#ifdef CONFIG_MMU
MLK(UL(VECTORS_BASE), UL(VECTORS_BASE) + (PAGE_SIZE)),
+#else
+ MLK_ROUNDUP(vectors_base, vectors_base + PAGE_SIZE),
+#endif
+
#ifdef CONFIG_HAVE_TCM
MLK(DTCM_OFFSET, (unsigned long) dtcm_end),
MLK(ITCM_OFFSET, (unsigned long) itcm_end),
diff --git a/arch/arm/mm/mm.h b/arch/arm/mm/mm.h
index ce727d47275c..546f09437fca 100644
--- a/arch/arm/mm/mm.h
+++ b/arch/arm/mm/mm.h
@@ -79,8 +79,9 @@ struct static_vm {
extern struct list_head static_vmlist;
extern struct static_vm *find_static_vm_vaddr(void *vaddr);
extern __init void add_static_vm_early(struct static_vm *svm);
-
-#endif
+#else /* CONFIG_MMU */
+extern unsigned long vectors_base;
+#endif /* CONFIG_MMU */
#ifdef CONFIG_ZONE_DMA
extern phys_addr_t arm_dma_limit;
--
2.11.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 3/4] ARM: nommu: display vectors base
2017-01-18 20:38 ` [PATCH 3/4] ARM: nommu: display vectors base afzal mohammed
@ 2017-01-18 22:13 ` Russell King - ARM Linux
2017-01-19 13:16 ` Afzal Mohammed
0 siblings, 1 reply; 16+ messages in thread
From: Russell King - ARM Linux @ 2017-01-18 22:13 UTC (permalink / raw)
To: afzal mohammed; +Cc: Vladimir Murzin, linux-arm-kernel, linux-kernel
On Thu, Jan 19, 2017 at 02:08:37AM +0530, afzal mohammed wrote:
> The exception base address is now dynamically estimated for no-MMU
> case, display it.
>
> Signed-off-by: afzal mohammed <afzal.mohd.ma@gmail.com>
> ---
> arch/arm/mm/init.c | 5 +++++
> arch/arm/mm/mm.h | 5 +++--
> 2 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
> index cf47f86f79ed..9e11f255c3bf 100644
> --- a/arch/arm/mm/init.c
> +++ b/arch/arm/mm/init.c
> @@ -522,7 +522,12 @@ void __init mem_init(void)
> " .data : 0x%p" " - 0x%p" " (%4td kB)\n"
> " .bss : 0x%p" " - 0x%p" " (%4td kB)\n",
>
> +#ifdef CONFIG_MMU
> MLK(UL(VECTORS_BASE), UL(VECTORS_BASE) + (PAGE_SIZE)),
> +#else
> + MLK_ROUNDUP(vectors_base, vectors_base + PAGE_SIZE),
I think MLK() will do here - no need to use the rounding-up version
as PAGE_SIZE is a multiple of 1k.
--
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 3/4] ARM: nommu: display vectors base
2017-01-18 22:13 ` Russell King - ARM Linux
@ 2017-01-19 13:16 ` Afzal Mohammed
2017-01-30 12:09 ` Russell King - ARM Linux
0 siblings, 1 reply; 16+ messages in thread
From: Afzal Mohammed @ 2017-01-19 13:16 UTC (permalink / raw)
To: Russell King - ARM Linux; +Cc: Vladimir Murzin, linux-arm-kernel, linux-kernel
Hi,
On Wed, Jan 18, 2017 at 10:13:15PM +0000, Russell King - ARM Linux wrote:
> On Thu, Jan 19, 2017 at 02:08:37AM +0530, afzal mohammed wrote:
> > + MLK_ROUNDUP(vectors_base, vectors_base + PAGE_SIZE),
>
> I think MLK() will do here - no need to use the rounding-up version
> as PAGE_SIZE is a multiple of 1k.
Yes, i will replace it.
Earlier, used MLK(), got some build error, now checking again, no
build error, i should have messed up something at that time.
Regards
afzal
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 3/4] ARM: nommu: display vectors base
2017-01-19 13:16 ` Afzal Mohammed
@ 2017-01-30 12:09 ` Russell King - ARM Linux
0 siblings, 0 replies; 16+ messages in thread
From: Russell King - ARM Linux @ 2017-01-30 12:09 UTC (permalink / raw)
To: Afzal Mohammed; +Cc: Vladimir Murzin, linux-arm-kernel, linux-kernel
On Thu, Jan 19, 2017 at 06:46:32PM +0530, Afzal Mohammed wrote:
> Hi,
>
> On Wed, Jan 18, 2017 at 10:13:15PM +0000, Russell King - ARM Linux wrote:
> > On Thu, Jan 19, 2017 at 02:08:37AM +0530, afzal mohammed wrote:
>
> > > + MLK_ROUNDUP(vectors_base, vectors_base + PAGE_SIZE),
> >
> > I think MLK() will do here - no need to use the rounding-up version
> > as PAGE_SIZE is a multiple of 1k.
>
> Yes, i will replace it.
>
> Earlier, used MLK(), got some build error, now checking again, no
> build error, i should have messed up something at that time.
Sorry for the delayed response.
With that change, you can get rid of this preprocessor conditional.
Arrange to have VECTORS_BASE defined to vectors_base in the nommu
part of asm/memory.h. You'll also need to move the extern of that
there too.
Thanks.
--
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 4/4] ARM: nommu: remove Hivecs configuration is asm
2017-01-18 20:35 [PATCH 0/4] ARM: v7-A !MMU support, CONFIG_VECTORS_BASE removal (almost) afzal mohammed
` (2 preceding siblings ...)
2017-01-18 20:38 ` [PATCH 3/4] ARM: nommu: display vectors base afzal mohammed
@ 2017-01-18 20:39 ` afzal mohammed
3 siblings, 0 replies; 16+ messages in thread
From: afzal mohammed @ 2017-01-18 20:39 UTC (permalink / raw)
To: Russell King - ARM Linux
Cc: Vladimir Murzin, linux-arm-kernel, linux-kernel, afzal mohammed
Now that exception based address is handled dynamically for
processors with CP15, remove Highvecs configuration in assembly.
Signed-off-by: afzal mohammed <afzal.mohd.ma@gmail.com>
---
arch/arm/kernel/head-nommu.S | 5 -----
1 file changed, 5 deletions(-)
diff --git a/arch/arm/kernel/head-nommu.S b/arch/arm/kernel/head-nommu.S
index 6b4eb27b8758..2e21e08de747 100644
--- a/arch/arm/kernel/head-nommu.S
+++ b/arch/arm/kernel/head-nommu.S
@@ -152,11 +152,6 @@ __after_proc_init:
#ifdef CONFIG_CPU_ICACHE_DISABLE
bic r0, r0, #CR_I
#endif
-#ifdef CONFIG_CPU_HIGH_VECTOR
- orr r0, r0, #CR_V
-#else
- bic r0, r0, #CR_V
-#endif
mcr p15, 0, r0, c1, c0, 0 @ write control reg
#elif defined (CONFIG_CPU_V7M)
/* For V7M systems we want to modify the CCR similarly to the SCTLR */
--
2.11.0
^ permalink raw reply related [flat|nested] 16+ messages in thread