Revert broken C0_Pagegrain[PG_IEC] support.
cover Revert broken C0_Pagegrain[PG_IEC] support.
From: David Daney <[email protected]>
The two patches reverted here break eXecute-Inhibit (XI) memory protection support. Before the patches we get SIGSEGV when attempting to execute in non-executable memory, after the patches we loop forever in handle_tlbl.
It is probably possible to make C0_Pagegrain[PG_IEC] work, but I think the most prudent thing is to revert these patches, and then only reapply something that works after it has been well tested.
David Daney (2):
Revert "MIPS: Use dedicated exception handler if CPU supports RI/XI
exceptions"
Revert "MIPS: kernel: cpu-probe: Detect unique RI/XI exceptions"
arch/mips/include/asm/mipsregs.h | 1 - arch/mips/kernel/cpu-probe.c | 9 --------- arch/mips/kernel/traps.c | 7 ------- arch/mips/mm/tlbex.c | 4 ++-- 4 files changed, 2 insertions(+), 19 deletions(-)
Signature · 1 line
1.7.11.7
PATCH 1/2 Revert "MIPS: Use dedicated exception handler if CPU supports RI/XI exceptions"
From: David Daney <[email protected]>
This reverts commit 5890f70f15c52d0204a578422f8da828a0ba1096.
The patch was not tested, It sets PG_IEC in cpu-probe. But this value is clobbered in tlb_init() so the system is never configured to take the RIXI specific exceptions, and we end up in an endless loop in handle_tlbl because that code is not expecting the XI condition.
--- arch/mips/kernel/traps.c | 7 ------- arch/mips/mm/tlbex.c | 4 ++-- 2 files changed, 2 insertions(+), 9 deletions(-)
arch/mips/kernel/traps.c +0 -7
@@ -90,7 +90,6 @@ extern asmlinkage void handle_mt(void); extern asmlinkage void handle_dsp(void); extern asmlinkage void handle_mcheck(void); extern asmlinkage void handle_reserved(void); -extern void tlb_do_page_fault_0 (void );void (*board_be_init)(void );int (*board_be_handler)(struct pt_regs *regs,int is_fixup);
@@ -2205,12 +2204,6 @@ void __init trap_init(void)set_except_vector (15 , handle_fpe);set_except_vector (16 , handle_ftlb); - -if (cpu_has_rixiex) { -set_except_vector (19 , tlb_do_page_fault_0); -set_except_vector (20 , tlb_do_page_fault_0); - } -set_except_vector (21 , handle_msa);set_except_vector (22 , handle_mdmx);
arch/mips/mm/tlbex.c +2 -2
@@ -1934,7 +1934,7 @@ static void build_r4000_tlb_load_handler(void)if (m4kc_tlbp_war ())build_tlb_probe_entry (&p); -if (cpu_has_rixi && !cpu_has_rixiex) { +if (cpu_has_rixi) {/* * If the page is not _PAGE_VALID, RI or XI could not * have triggered it. Skip the expensive test..
@@ -2001,7 +2001,7 @@ static void build_r4000_tlb_load_handler(void)build_pte_present (&p, &r, wr.r1, wr.r2, wr.r3, label_nopage_tlbl);build_tlb_probe_entry (&p); -if (cpu_has_rixi && !cpu_has_rixiex) { +if (cpu_has_rixi) {/* * If the page is not _PAGE_VALID, RI or XI could not * have triggered it. Skip the expensive test..
Signature · 1 line
1.7.11.7
PATCH 2/2 Revert "MIPS: kernel: cpu-probe: Detect unique RI/XI exceptions"
In reply to David DaneyFrom: David Daney <[email protected]>
This reverts commit 6575b1d4173eaeff6742a2c6dcbd835bb052952b.
It sets PG_IEC in cpu-probe. But this value is clobbered in tlb_init() so the system is never configured to take the RIXI specific exceptions. Caos ensues.
--- arch/mips/include/asm/mipsregs.h | 1 - arch/mips/kernel/cpu-probe.c | 9 --------- 2 files changed, 10 deletions(-)
arch/mips/include/asm/mipsregs.h +0 -1
@@ -265,7 +265,6 @@#define PG_XIE (_ULCAST_(1) << 30)#define PG_ELPA (_ULCAST_(1) << 29)#define PG_ESP (_ULCAST_(1) << 28) -#define PG_IEC (_ULCAST_(1) << 27)/* * R4x00 interrupt enable / cause bits
arch/mips/kernel/cpu-probe.c +0 -9
@@ -531,15 +531,6 @@ static void decode_configs(struct cpuinfo_mips *c)mips_probe_watch_registers (c); -if (cpu_has_rixi) { -/* Enable the RIXI exceptions */ -write_c0_pagegrain (read_c0_pagegrain () |PG_IEC ); -back_to_back_c0_hazard (); -/* Verify the IEC bit is set */ -if (read_c0_pagegrain () &PG_IEC ) - c->options |=MIPS_CPU_RIXIEX ; - } -#ifndef CONFIG_MIPS_CPS if (cpu_has_mips_r2) { c->core =get_ebase_cpunum ();
Signature · 1 line
1.7.11.7
Quoted 16 lines · David Daney
From: David Daney <[email protected]>
The two patches reverted here break eXecute-Inhibit (XI) memory protection support. Before the patches we get SIGSEGV when attempting to execute in non-executable memory, after the patches we loop forever in
handle_tlbl.It is probably possible to make C0_Pagegrain[PG_IEC] work, but I think the most prudent thing is to revert these patches, and then only reapply something that works after it has been well tested.
David Daney (2):
Revert "MIPS: Use dedicated exception handler if CPU supports RI/XI
exceptions"
Revert "MIPS: kernel: cpu-probe: Detect unique RI/XI exceptions"
Quoted 6 lines
arch/mips/include/asm/mipsregs.h | 1 - arch/mips/kernel/cpu-probe.c | 9 --------- arch/mips/kernel/traps.c | 7 ------- arch/mips/mm/tlbex.c | 4 ++-- 4 files changed, 2 insertions(+), 19 deletions(-)
Well, it may be have sense just to fix tlb_init() instead.
Quoted 17 lines · Leonid Yegoshin
Quoted 16 lines · David Daney
From: David Daney <[email protected]>
The two patches reverted here break eXecute-Inhibit (XI) memory protection support. Before the patches we get SIGSEGV when attempting to execute in non-executable memory, after the patches we loop forever in
handle_tlbl.It is probably possible to make C0_Pagegrain[PG_IEC] work, but I think the most prudent thing is to revert these patches, and then only reapply something that works after it has been well tested.
David Daney (2):
Revert "MIPS: Use dedicated exception handler if CPU supports RI/XI
exceptions"
Revert "MIPS: kernel: cpu-probe: Detect unique RI/XI exceptions"
Quoted 7 lines
Quoted 6 lines
arch/mips/include/asm/mipsregs.h | 1 - arch/mips/kernel/cpu-probe.c | 9 --------- arch/mips/kernel/traps.c | 7 ------- arch/mips/mm/tlbex.c | 4 ++-- 4 files changed, 2 insertions(+), 19 deletions(-)Well, it may be have sense just to fix
tlb_init()instead.
arch/mips/mm/tlb-r4k.c +1 -1
@@ -602,7 +602,7 @@ void __cpuinit tlb_init(void)#ifdef CONFIG_64BIT pg |=PG_ELPA ;#endif -write_c0_pagegrain (pg); +write_c0_pagegrain (pg |read_c0_pagegrain ()); }mtc0_tlbw_hazard ();
Quoted 38 lines · Leonid Yegoshin
Date: Fri, 19 Dec 2014 16:49:28 -0800
From: Leonid Yegoshin <[email protected]>
To: David Daney <[email protected]>, [email protected],
[email protected]
Subject: Re: [PATCH 0/2] Revert broken C0_Pagegrain[PG_IEC] support.
Content-Type: text/plain; charset="windows-1252"; format=flowedQuoted 24 lines · Leonid Yegoshin
Quoted 16 lines · David Daney
From: David Daney <[email protected]>
The two patches reverted here break eXecute-Inhibit (XI) memory protection support. Before the patches we get SIGSEGV when attempting to execute in non-executable memory, after the patches we loop forever in
handle_tlbl.It is probably possible to make C0_Pagegrain[PG_IEC] work, but I think the most prudent thing is to revert these patches, and then only reapply something that works after it has been well tested.
David Daney (2):
Revert "MIPS: Use dedicated exception handler if CPU supports RI/XI
exceptions"
Revert "MIPS: kernel: cpu-probe: Detect unique RI/XI exceptions"Quoted 6 lines
arch/mips/include/asm/mipsregs.h | 1 - arch/mips/kernel/cpu-probe.c | 9 --------- arch/mips/kernel/traps.c | 7 ------- arch/mips/mm/tlbex.c | 4 ++-- 4 files changed, 2 insertions(+), 19 deletions(-)Well, it may be have sense just to fix
tlb_init()instead.arch/mips/mm/tlb-r4k.c +0
-0
arch/mips/mm/tlb-r4k.c void __cpuinit tlb_init(void) · line 605
Quoted 5 lines
arch/mips/mm/tlb-r4k.c +1
-1@@ -602,7 +602,7 @@ void __cpuinit tlb_init(void)#ifdef CONFIG_64BIT pg |=PG_ELPA ;#endif -write_c0_pagegrain (pg); +write_c0_pagegrain (pg |read_c0_pagegrain ());
Simpler:
set_c0_pagegrain(pg);
Ralf
Quoted 34 lines · Ralf Baechle
Quoted 33 lines · Leonid Yegoshin
Date: Fri, 19 Dec 2014 16:49:28 -0800
From: Leonid Yegoshin <[email protected]>
To: David Daney <[email protected]>, [email protected],
[email protected]
Subject: Re: [PATCH 0/2] Revert broken C0_Pagegrain[PG_IEC] support.
Content-Type: text/plain; charset="windows-1252"; format=flowedQuoted 24 lines · Leonid Yegoshin
Quoted 16 lines · David Daney
From: David Daney <[email protected]>
The two patches reverted here break eXecute-Inhibit (XI) memory protection support. Before the patches we get SIGSEGV when attempting to execute in non-executable memory, after the patches we loop forever in
handle_tlbl.It is probably possible to make C0_Pagegrain[PG_IEC] work, but I think the most prudent thing is to revert these patches, and then only reapply something that works after it has been well tested.
David Daney (2):
Revert "MIPS: Use dedicated exception handler if CPU supports RI/XI
exceptions"
Revert "MIPS: kernel: cpu-probe: Detect unique RI/XI exceptions"Quoted 6 lines
arch/mips/include/asm/mipsregs.h | 1 - arch/mips/kernel/cpu-probe.c | 9 --------- arch/mips/kernel/traps.c | 7 ------- arch/mips/mm/tlbex.c | 4 ++-- 4 files changed, 2 insertions(+), 19 deletions(-)Well, it may be have sense just to fix
tlb_init()instead.
Quoted 13 lines
arch/mips/mm/tlb-r4k.c void __cpuinit tlb_init(void) · line 605
Quoted 10 lines
arch/mips/mm/tlb-r4k.c +1
-1@@ -602,7 +602,7 @@ void __cpuinit tlb_init(void)#ifdef CONFIG_64BIT pg |=PG_ELPA ;#endif -write_c0_pagegrain (pg); +write_c0_pagegrain (pg |read_c0_pagegrain ());Simpler:
set_c0_pagegrain(pg);
No. That is exactly how it was broken before.
It is possible that you would want:
if (cpu_has_rixiex) pg |= PG_IEC; set_c0_pagegrain(pg);
But that wasn't really tested. It seems to work though.
I will send another patch.
David Daney
Quoted 4 lines
Ralf
Quoted 58 lines · David Daney
Quoted 47 lines · Ralf Baechle
Quoted 39 lines · Leonid Yegoshin
Date: Fri, 19 Dec 2014 16:49:28 -0800
From: Leonid Yegoshin <[email protected]>
To: David Daney <[email protected]>, [email protected],
[email protected]
Subject: Re: [PATCH 0/2] Revert broken C0_Pagegrain[PG_IEC] support.
Content-Type: text/plain; charset="windows-1252"; format=flowedQuoted 25 lines · Leonid Yegoshin
Quoted 17 lines · David Daney
From: David Daney <[email protected]>
The two patches reverted here break eXecute-Inhibit (XI) memory protection support. Before the patches we get SIGSEGV when attempting to execute in non-executable memory, after the patches we loop forever in
handle_tlbl.It is probably possible to make C0_Pagegrain[PG_IEC] work, but I think the most prudent thing is to revert these patches, and then only reapply something that works after it has been well tested.
David Daney (2):
Revert "MIPS: Use dedicated exception handler if CPU supports
RI/XI
exceptions"
Revert "MIPS: kernel: cpu-probe: Detect unique RI/XI exceptions"Quoted 6 lines
arch/mips/include/asm/mipsregs.h | 1 - arch/mips/kernel/cpu-probe.c | 9 --------- arch/mips/kernel/traps.c | 7 ------- arch/mips/mm/tlbex.c | 4 ++-- 4 files changed, 2 insertions(+), 19 deletions(-)Well, it may be have sense just to fix
tlb_init()instead.arch/mips/mm/tlb-r4k.c +0
-0arch/mips/mm/tlb-r4k.c void __cpuinit tlb_init(void) · line 605
Quoted 5 lines
arch/mips/mm/tlb-r4k.c +1
-1@@ -602,7 +602,7 @@ void __cpuinit tlb_init(void)#ifdef CONFIG_64BIT pg |=PG_ELPA ;#endif -write_c0_pagegrain (pg); +write_c0_pagegrain (pg |read_c0_pagegrain ());Simpler:
Quoted 1 line
set_c0_pagegrain(pg);No. That is exactly how it was broken before.
It is possible that you would want:
if (cpu_has_rixiex) pg |= PG_IEC; set_c0_pagegrain(pg);
Quoted 5 lines
But that wasn't really tested. It seems to work though.
I will send another patch.
David Daney
Well, to honest, it is extensively tested on MIPS R6 because it have PG_IEC read-only == 1 (non-switchable OFF) And on other cores which has no PG_IEC at all, of course.
As for your concern about set_c0_pagegrain(pg) - it sets 2 or 3 bits in pagegrain but doesn't clear the rest which was before with a single write_c0_pagegrain(pg) and any switchable bit comes down.
Quoted 17 lines · Leonid Yegoshin
Quoted 16 lines · David Daney
From: David Daney <[email protected]>
The two patches reverted here break eXecute-Inhibit (XI) memory protection support. Before the patches we get SIGSEGV when attempting to execute in non-executable memory, after the patches we loop forever in
handle_tlbl.It is probably possible to make C0_Pagegrain[PG_IEC] work, but I think the most prudent thing is to revert these patches, and then only reapply something that works after it has been well tested.
David Daney (2):
Revert "MIPS: Use dedicated exception handler if CPU supports RI/XI
exceptions"
Revert "MIPS: kernel: cpu-probe: Detect unique RI/XI exceptions"
Quoted 7 lines
Quoted 6 lines
arch/mips/include/asm/mipsregs.h | 1 - arch/mips/kernel/cpu-probe.c | 9 --------- arch/mips/kernel/traps.c | 7 ------- arch/mips/mm/tlbex.c | 4 ++-- 4 files changed, 2 insertions(+), 19 deletions(-)Well, it may be have sense just to fix
tlb_init()instead.
I have more confidence in going back to a working configuration. My simple tests on OCTEON tell me that it is working again.
Somebody adding working support for C0_Pagegrain[PG_IEC] would want to do much more testing across many different CPUs to be able to assert that it was tested and working.
I would be happy to test any patches adding this support on a variety of different OCTEON CPU cores, but I don't have access to anything MIPS/img may have that supports this feature.
David Daney.