Re: [PATCH v4 02/14] arm: add support for folded p4d page tables

2020-05-11 Thread Mike Rapoport
Hi Marek,

On Mon, May 11, 2020 at 08:36:41AM +0200, Marek Szyprowski wrote:
> Hi Mike,
> 
> On 08.05.2020 19:42, Mike Rapoport wrote:
> > On Fri, May 08, 2020 at 08:53:27AM +0200, Marek Szyprowski wrote:
> >> On 07.05.2020 18:11, Mike Rapoport wrote:
> >>> On Thu, May 07, 2020 at 02:16:56PM +0200, Marek Szyprowski wrote:
>  On 14.04.2020 17:34, Mike Rapoport wrote:
> > From: Mike Rapoport 
> >
> > Implement primitives necessary for the 4th level folding, add walks of 
> > p4d
> > level where appropriate, and remove __ARCH_USE_5LEVEL_HACK.
> >
> > Signed-off-by: Mike Rapoport 
> > Can you please try the patch below:
> >
> > diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
> > index 963b5284d284..f86b3d17928e 100644
> > --- a/arch/arm/mm/init.c
> > +++ b/arch/arm/mm/init.c
> > @@ -571,7 +571,7 @@ static inline void section_update(unsigned long addr, 
> > pmdval_t mask,
> >   {
> > pmd_t *pmd;
> >   
> > -   pmd = pmd_off_k(addr);
> > +   pmd = pmd_offset(pud_offset(p4d_offset(pgd_offset(mm, addr), addr), 
> > addr), addr);
> >   
> >   #ifdef CONFIG_ARM_LPAE
> > pmd[0] = __pmd((pmd_val(pmd[0]) & mask) | prot);
> This fixes kexec issue! Thanks!
> 
> 
> Feel free to add:
> 
> Reported-by: Marek Szyprowski 
> Fixes: 218f1c390557 ("arm: add support for folded p4d page tables")
> Tested-by: Marek Szyprowski 

Thanks for testing!

The patch is still in mmotm tree, so I don't think "Fixes" apply.

Andrew, would you like me to send the fix as a formal patch or will pick
it up as a fixup?

> Best regards
> -- 
> Marek Szyprowski, PhD
> Samsung R Institute Poland
> 

-- 
Sincerely yours,
Mike.


Re: [PATCH v4 02/14] arm: add support for folded p4d page tables

2020-05-11 Thread Marek Szyprowski
Hi Mike,

On 08.05.2020 19:42, Mike Rapoport wrote:
> On Fri, May 08, 2020 at 08:53:27AM +0200, Marek Szyprowski wrote:
>> On 07.05.2020 18:11, Mike Rapoport wrote:
>>> On Thu, May 07, 2020 at 02:16:56PM +0200, Marek Szyprowski wrote:
 On 14.04.2020 17:34, Mike Rapoport wrote:
> From: Mike Rapoport 
>
> Implement primitives necessary for the 4th level folding, add walks of p4d
> level where appropriate, and remove __ARCH_USE_5LEVEL_HACK.
>
> Signed-off-by: Mike Rapoport 
 Today I've noticed that kexec is broken on ARM 32bit. Bisecting between
 current linux-next and v5.7-rc1 pointed to this commit. I've tested this
 on Odroid XU4 and Raspberry Pi4 boards. Here is the relevant log:

 # kexec --kexec-syscall -l zImage --append "$(cat /proc/cmdline)"
 memory_range[0]:0x4000..0xbe9f
 memory_range[0]:0x4000..0xbe9f
 # kexec -e
 kexec_core: Starting new kernel
 8<--- cut here ---
 Unable to handle kernel paging request at virtual address c010f1f4
 pgd = c6817793
 [c010f1f4] *pgd=441e(bad)
 Internal error: Oops: 80d [#1] PREEMPT ARM
 Modules linked in:
 CPU: 0 PID: 1329 Comm: kexec Tainted: G    W
 5.7.0-rc3-00127-g6cba81ed0f62 #611
 Hardware name: Samsung Exynos (Flattened Device Tree)
 PC is at machine_kexec+0x40/0xfc
>>> Any chance you have the debug info in this kernel?
>>> scripts/faddr2line would come handy here.
>> # ./scripts/faddr2line --list vmlinux machine_kexec+0x40
>> machine_kexec+0x40/0xf8:
>>
>> machine_kexec at arch/arm/kernel/machine_kexec.c:182
>>    177    reboot_code_buffer =
>> page_address(image->control_code_page);
>>    178
>>    179    /* Prepare parameters for reboot_code_buffer*/
>>    180    set_kernel_text_rw();
>>    181    kexec_start_address = image->start;
>>   >182<   kexec_indirection_page = page_list;
>>    183    kexec_mach_type = machine_arch_type;
>>    184    kexec_boot_atags = image->arch.kernel_r2;
>>    185
>>    186    /* copy our kernel relocation code to the control code
>> page */
>>    187    reboot_entry = fncpy(reboot_code_buffer,
> Can you please try the patch below:
>
> diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
> index 963b5284d284..f86b3d17928e 100644
> --- a/arch/arm/mm/init.c
> +++ b/arch/arm/mm/init.c
> @@ -571,7 +571,7 @@ static inline void section_update(unsigned long addr, 
> pmdval_t mask,
>   {
>   pmd_t *pmd;
>   
> - pmd = pmd_off_k(addr);
> + pmd = pmd_offset(pud_offset(p4d_offset(pgd_offset(mm, addr), addr), 
> addr), addr);
>   
>   #ifdef CONFIG_ARM_LPAE
>   pmd[0] = __pmd((pmd_val(pmd[0]) & mask) | prot);
This fixes kexec issue! Thanks!


Feel free to add:

Reported-by: Marek Szyprowski 
Fixes: 218f1c390557 ("arm: add support for folded p4d page tables")
Tested-by: Marek Szyprowski 

Best regards
-- 
Marek Szyprowski, PhD
Samsung R Institute Poland



Re: [PATCH v4 02/14] arm: add support for folded p4d page tables

2020-05-08 Thread Mike Rapoport
On Fri, May 08, 2020 at 08:53:27AM +0200, Marek Szyprowski wrote:
> Hi Mike,
> 
> On 07.05.2020 18:11, Mike Rapoport wrote:
> > On Thu, May 07, 2020 at 02:16:56PM +0200, Marek Szyprowski wrote:
> >> On 14.04.2020 17:34, Mike Rapoport wrote:
> >>> From: Mike Rapoport 
> >>>
> >>> Implement primitives necessary for the 4th level folding, add walks of p4d
> >>> level where appropriate, and remove __ARCH_USE_5LEVEL_HACK.
> >>>
> >>> Signed-off-by: Mike Rapoport 
> >> Today I've noticed that kexec is broken on ARM 32bit. Bisecting between
> >> current linux-next and v5.7-rc1 pointed to this commit. I've tested this
> >> on Odroid XU4 and Raspberry Pi4 boards. Here is the relevant log:
> >>
> >> # kexec --kexec-syscall -l zImage --append "$(cat /proc/cmdline)"
> >> memory_range[0]:0x4000..0xbe9f
> >> memory_range[0]:0x4000..0xbe9f
> >> # kexec -e
> >> kexec_core: Starting new kernel
> >> 8<--- cut here ---
> >> Unable to handle kernel paging request at virtual address c010f1f4
> >> pgd = c6817793
> >> [c010f1f4] *pgd=441e(bad)
> >> Internal error: Oops: 80d [#1] PREEMPT ARM
> >> Modules linked in:
> >> CPU: 0 PID: 1329 Comm: kexec Tainted: G    W
> >> 5.7.0-rc3-00127-g6cba81ed0f62 #611
> >> Hardware name: Samsung Exynos (Flattened Device Tree)
> >> PC is at machine_kexec+0x40/0xfc
> > Any chance you have the debug info in this kernel?
> > scripts/faddr2line would come handy here.
> 
> # ./scripts/faddr2line --list vmlinux machine_kexec+0x40
> machine_kexec+0x40/0xf8:
> 
> machine_kexec at arch/arm/kernel/machine_kexec.c:182
>   177    reboot_code_buffer = 
> page_address(image->control_code_page);
>   178
>   179    /* Prepare parameters for reboot_code_buffer*/
>   180    set_kernel_text_rw();
>   181    kexec_start_address = image->start;
>  >182<   kexec_indirection_page = page_list;
>   183    kexec_mach_type = machine_arch_type;
>   184    kexec_boot_atags = image->arch.kernel_r2;
>   185
>   186    /* copy our kernel relocation code to the control code 
> page */
>   187    reboot_entry = fncpy(reboot_code_buffer,

Can you please try the patch below:

diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 963b5284d284..f86b3d17928e 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -571,7 +571,7 @@ static inline void section_update(unsigned long addr, 
pmdval_t mask,
 {
pmd_t *pmd;
 
-   pmd = pmd_off_k(addr);
+   pmd = pmd_offset(pud_offset(p4d_offset(pgd_offset(mm, addr), addr), 
addr), addr);
 
 #ifdef CONFIG_ARM_LPAE
pmd[0] = __pmd((pmd_val(pmd[0]) & mask) | prot);

>  > ...
> 
> Best regards
> -- 
> Marek Szyprowski, PhD
> Samsung R Institute Poland
> 

-- 
Sincerely yours,
Mike.


Re: [PATCH v4 02/14] arm: add support for folded p4d page tables

2020-05-08 Thread Marek Szyprowski
Hi Mike,

On 07.05.2020 18:11, Mike Rapoport wrote:
> On Thu, May 07, 2020 at 02:16:56PM +0200, Marek Szyprowski wrote:
>> On 14.04.2020 17:34, Mike Rapoport wrote:
>>> From: Mike Rapoport 
>>>
>>> Implement primitives necessary for the 4th level folding, add walks of p4d
>>> level where appropriate, and remove __ARCH_USE_5LEVEL_HACK.
>>>
>>> Signed-off-by: Mike Rapoport 
>> Today I've noticed that kexec is broken on ARM 32bit. Bisecting between
>> current linux-next and v5.7-rc1 pointed to this commit. I've tested this
>> on Odroid XU4 and Raspberry Pi4 boards. Here is the relevant log:
>>
>> # kexec --kexec-syscall -l zImage --append "$(cat /proc/cmdline)"
>> memory_range[0]:0x4000..0xbe9f
>> memory_range[0]:0x4000..0xbe9f
>> # kexec -e
>> kexec_core: Starting new kernel
>> 8<--- cut here ---
>> Unable to handle kernel paging request at virtual address c010f1f4
>> pgd = c6817793
>> [c010f1f4] *pgd=441e(bad)
>> Internal error: Oops: 80d [#1] PREEMPT ARM
>> Modules linked in:
>> CPU: 0 PID: 1329 Comm: kexec Tainted: G    W
>> 5.7.0-rc3-00127-g6cba81ed0f62 #611
>> Hardware name: Samsung Exynos (Flattened Device Tree)
>> PC is at machine_kexec+0x40/0xfc
> Any chance you have the debug info in this kernel?
> scripts/faddr2line would come handy here.

# ./scripts/faddr2line --list vmlinux machine_kexec+0x40
machine_kexec+0x40/0xf8:

machine_kexec at arch/arm/kernel/machine_kexec.c:182
  177    reboot_code_buffer = 
page_address(image->control_code_page);
  178
  179    /* Prepare parameters for reboot_code_buffer*/
  180    set_kernel_text_rw();
  181    kexec_start_address = image->start;
 >182<   kexec_indirection_page = page_list;
  183    kexec_mach_type = machine_arch_type;
  184    kexec_boot_atags = image->arch.kernel_r2;
  185
  186    /* copy our kernel relocation code to the control code 
page */
  187    reboot_entry = fncpy(reboot_code_buffer,

 > ...

Best regards
-- 
Marek Szyprowski, PhD
Samsung R Institute Poland



Re: [PATCH v4 02/14] arm: add support for folded p4d page tables

2020-05-07 Thread Mike Rapoport
Hi,

On Thu, May 07, 2020 at 02:16:56PM +0200, Marek Szyprowski wrote:
> Hi
> 
> On 14.04.2020 17:34, Mike Rapoport wrote:
> > From: Mike Rapoport 
> >
> > Implement primitives necessary for the 4th level folding, add walks of p4d
> > level where appropriate, and remove __ARCH_USE_5LEVEL_HACK.
> >
> > Signed-off-by: Mike Rapoport 
> 
> Today I've noticed that kexec is broken on ARM 32bit. Bisecting between 
> current linux-next and v5.7-rc1 pointed to this commit. I've tested this 
> on Odroid XU4 and Raspberry Pi4 boards. Here is the relevant log:
> 
> # kexec --kexec-syscall -l zImage --append "$(cat /proc/cmdline)"
> memory_range[0]:0x4000..0xbe9f
> memory_range[0]:0x4000..0xbe9f
> # kexec -e
> kexec_core: Starting new kernel
> 8<--- cut here ---
> Unable to handle kernel paging request at virtual address c010f1f4
> pgd = c6817793
> [c010f1f4] *pgd=441e(bad)
> Internal error: Oops: 80d [#1] PREEMPT ARM
> Modules linked in:
> CPU: 0 PID: 1329 Comm: kexec Tainted: G    W 
> 5.7.0-rc3-00127-g6cba81ed0f62 #611
> Hardware name: Samsung Exynos (Flattened Device Tree)
> PC is at machine_kexec+0x40/0xfc

Any chance you have the debug info in this kernel?
scripts/faddr2line would come handy here.

> LR is at 0x
> pc : []    lr : []    psr: 6013
> sp : ebc13e60  ip : 40008000  fp : 0001
> r10: 0058  r9 : fee1dead  r8 : 0001
> r7 : c121387c  r6 : 6c224000  r5 : ece40c00  r4 : ec222000
> r3 : c010f1f4  r2 : c110  r1 : c110  r0 : 418d
> Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
> Control: 10c5387d  Table: 6bc14059  DAC: 0051
> Process kexec (pid: 1329, stack limit = 0x366bb4dc)
> Stack: (0xebc13e60 to 0xebc14000)
> ...
> [] (machine_kexec) from [] (kernel_kexec+0x74/0x7c)
> [] (kernel_kexec) from [] (__do_sys_reboot+0x1f8/0x210)
> [] (__do_sys_reboot) from [] (ret_fast_syscall+0x0/0x28)
> Exception stack(0xebc13fa8 to 0xebc13ff0)
> ...
> ---[ end trace 3e8d6c81723c778d ]---
> 1329 Segmentation fault  ./kexec -e
> 
> > ---
> >   arch/arm/include/asm/pgtable.h |  1 -
> >   arch/arm/lib/uaccess_with_memcpy.c |  7 +-
> >   arch/arm/mach-sa1100/assabet.c |  2 +-
> >   arch/arm/mm/dump.c | 29 +-
> >   arch/arm/mm/fault-armv.c   |  7 +-
> >   arch/arm/mm/fault.c| 22 ++--
> >   arch/arm/mm/idmap.c|  3 ++-
> >   arch/arm/mm/init.c |  2 +-
> >   arch/arm/mm/ioremap.c  | 12 ++---
> >   arch/arm/mm/mm.h   |  2 +-
> >   arch/arm/mm/mmu.c  | 35 +-
> >   arch/arm/mm/pgd.c  | 40 --
> >   12 files changed, 125 insertions(+), 37 deletions(-)
> >
> > ...
> 
> Best regards
> -- 
> Marek Szyprowski, PhD
> Samsung R Institute Poland
> 

-- 
Sincerely yours,
Mike.


Re: [PATCH v4 02/14] arm: add support for folded p4d page tables

2020-05-07 Thread Marek Szyprowski
Hi

On 14.04.2020 17:34, Mike Rapoport wrote:
> From: Mike Rapoport 
>
> Implement primitives necessary for the 4th level folding, add walks of p4d
> level where appropriate, and remove __ARCH_USE_5LEVEL_HACK.
>
> Signed-off-by: Mike Rapoport 

Today I've noticed that kexec is broken on ARM 32bit. Bisecting between 
current linux-next and v5.7-rc1 pointed to this commit. I've tested this 
on Odroid XU4 and Raspberry Pi4 boards. Here is the relevant log:

# kexec --kexec-syscall -l zImage --append "$(cat /proc/cmdline)"
memory_range[0]:0x4000..0xbe9f
memory_range[0]:0x4000..0xbe9f
# kexec -e
kexec_core: Starting new kernel
8<--- cut here ---
Unable to handle kernel paging request at virtual address c010f1f4
pgd = c6817793
[c010f1f4] *pgd=441e(bad)
Internal error: Oops: 80d [#1] PREEMPT ARM
Modules linked in:
CPU: 0 PID: 1329 Comm: kexec Tainted: G    W 
5.7.0-rc3-00127-g6cba81ed0f62 #611
Hardware name: Samsung Exynos (Flattened Device Tree)
PC is at machine_kexec+0x40/0xfc
LR is at 0x
pc : []    lr : []    psr: 6013
sp : ebc13e60  ip : 40008000  fp : 0001
r10: 0058  r9 : fee1dead  r8 : 0001
r7 : c121387c  r6 : 6c224000  r5 : ece40c00  r4 : ec222000
r3 : c010f1f4  r2 : c110  r1 : c110  r0 : 418d
Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
Control: 10c5387d  Table: 6bc14059  DAC: 0051
Process kexec (pid: 1329, stack limit = 0x366bb4dc)
Stack: (0xebc13e60 to 0xebc14000)
...
[] (machine_kexec) from [] (kernel_kexec+0x74/0x7c)
[] (kernel_kexec) from [] (__do_sys_reboot+0x1f8/0x210)
[] (__do_sys_reboot) from [] (ret_fast_syscall+0x0/0x28)
Exception stack(0xebc13fa8 to 0xebc13ff0)
...
---[ end trace 3e8d6c81723c778d ]---
1329 Segmentation fault  ./kexec -e

> ---
>   arch/arm/include/asm/pgtable.h |  1 -
>   arch/arm/lib/uaccess_with_memcpy.c |  7 +-
>   arch/arm/mach-sa1100/assabet.c |  2 +-
>   arch/arm/mm/dump.c | 29 +-
>   arch/arm/mm/fault-armv.c   |  7 +-
>   arch/arm/mm/fault.c| 22 ++--
>   arch/arm/mm/idmap.c|  3 ++-
>   arch/arm/mm/init.c |  2 +-
>   arch/arm/mm/ioremap.c  | 12 ++---
>   arch/arm/mm/mm.h   |  2 +-
>   arch/arm/mm/mmu.c  | 35 +-
>   arch/arm/mm/pgd.c  | 40 --
>   12 files changed, 125 insertions(+), 37 deletions(-)
>
> ...

Best regards
-- 
Marek Szyprowski, PhD
Samsung R Institute Poland