foss-for-synopsys-dwc-arc-processors / linux

Helpful resources for users & developers of Linux kernel for ARC
22 stars 13 forks source link

Linux 5.18.7 oops when set CONFIG_ARC_HAS_PAE40=y #94

Closed wimowa closed 1 year ago

wimowa commented 1 year ago

Hi pals,

Sorry to bother you. Our dts file config memory as: memory@80000000 {

address-cells = <2>;

    #size-cells = <2>;
    device_type = "memory";
        reg = <0x0 0x80000000 0x0 0x40000000    /* 1 GB low mem */
               0x1 0x00000000 0x0 0x40000000>;  /* 1 GB highmem */

};

For Linux 5.6.13 with the following Configs: CONFIG_PHYS_ADDR_T_64BIT=y CONFIG_HIGHMEM=y CONFIG_ARC_HAS_PAE40=y Linux works well. We can login Shell.

But the same config on Linux 5.18 is not working. We will encounter the following panics:

IDENTITY : ARCVER [0x54] ARCNUM [0x0] CHIPID [ 0x0] processor [0] : HS48 R4.00a (ARCv2 ISA) Dual-Issue
Timers : Timer0 Timer1 RTC [UP 64-bit]
ISA Extn : atomic ll64 unalign mpy[opt 9] div_rem
BPU : full match, cache:2048, Predict Table:16384 Return stk: 8 MMU [v5] : 8k PAGE, 2M Super Page (not used) , swalk 2 lvl, JTLB 1024 (256x4), uDTLB 8, uITLB 4, PAE40
I-Cache : 64K, 4way/set, 64B Line, VIPT aliasing D-Cache : 64K, 2way/set, 64B Line, PIPT SLC : 512K, 128B Line Peripherals : 0xf0000000 Vector Table : 0x90000000 FPU : SP
DEBUG : smaRT ActionPoint 8/full Extn [ECC] : IC DC MMU

Zone ranges: Normal [mem 0x0000000000000000-0x00000000bfffffff] HighMem empty Movable zone start for each node Early memory node ranges node 0: [mem 0x0000000000000000-0x000000003fffffff] node 0: [mem 0x0000000080000000-0x00000000bfffffff] Initmem setup node 0 [mem 0x0000000000000000-0x00000000bfffffff] On node 0, zone Normal: 1024 pages in unavailable ranges pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768 pcpu-alloc: [0] 0
Built 1 zonelists, mobility grouping on. Total pages: 260224 Kernel command line: earlycon=uart8250,mmio32,0xf0104000,921600n8 console=ttyS0, 921600n8 debug print-fatal-signals=1 uio_pdrv_genirq.of_id=generic-uio root=/dev/ram0 rootwait console=ttyS0,115200n8 Dentry cache hash table entries: 262144 (order: 7, 1048576 bytes, linear) Inode-cache hash table entries: 131072 (order: 6, 524288 bytes, linear)

mem auto-init: stack:off, heap alloc:off, heap free:off Memory: 2073432K/2097152K available (2833K kernel code, 585K rwdata, 688K rodata, 6736K init, 220K bss, 23720K reserved, 0K cma-reserved, 0K highmem) mm_slab.c->create_kmalloc_cache: create_kalloc_cache:0 set_free_obj:slab=bf5f2000,freelist=0x3f801f82 idx=0

Oops Path: (null) CPU: 0 PID: 0 Comm: swapper Not tainted 5.18.7 #3 Invalid Read @ 0x3f801f82 by insn @ set_free_obj+0x32/0x54 ECR: 0x00050100 EFA: 0x3f801f82 ERET: 0x90944312 STAT: 0x0008005e [ K DE ] BTA: 0x90942fec SP: 0x90a09f44 FP: 0x909ca278 BLK: set_free_obj+0x36/0x54 LPS: 0x90875b68 LPE: 0x90875b70 LPC: 0x00000000 r00: 0x909ca108 r01: 0x90a74990 r02: 0x3f801f82 r03: 0x00000000 r04: 0x908cfc8c r05: 0x00000000 r06: 0x5f746573 r07: 0x65657266 r08: 0x6a626f5f r09: 0x616c733a r10: 0x66623d62 r11: 0x30326635 r12: 0xffffefff

Stack Trace: set_free_obj+0x32/0x54 cache_alloc_refill+0x492/0x688 kmem_cache_alloc+0x90/0xf0 create_kmalloc_cache+0x36/0xc4

So did I configure something wrong on the DTS file???

Any ideas?

Thank you. Best Regards, Sophie

wimowa commented 1 year ago

By the way, when I disable PAE40, Linux5.18 also work well....

wimowa commented 1 year ago

Hi pals, I have found the root cause. Just need to set the descending as TRUE in function: free_area_init(~) for our case. Sorry to bother.

Best Regards, sophie

abrodkin commented 1 year ago

@wimowa do you mean the following change?

diff --git a/arch/arc/mm/init.c b/arch/arc/mm/init.c
index ce4e939a7f07..b79a99f0bc09 100644
--- a/arch/arc/mm/init.c
+++ b/arch/arc/mm/init.c
@@ -76,7 +76,7 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)

 bool arch_has_descending_max_zone_pfns(void)
 {
-       return !IS_ENABLED(CONFIG_ARC_HAS_PAE40);
+       return true;
 }

 /*
abrodkin commented 1 year ago

@wimowa there's something wrong!

First of all, could you please double-check your .dts and preferably paste here its memory nodes description completely? From your initial message I see that:

memory@80000000 {
    #address-cells = <2>;
    #size-cells = <2>;
    device_type = "memory";
    reg = <0x0 0x80000000 0x0 0x40000000 /* 1 GB low mem /
           0x1 0x00000000 0x0 0x40000000>; / 1 GB highmem */
};

and

Zone ranges:
Normal [mem 0x0000000000000000-0x00000000bfffffff]
HighMem empty  <-- SEE "empty"

To me it looks like you commented out PAE's memory node. Try this:

    memory {
        device_type = "memory";
        /* CONFIG_LINUX_RAM_BASE needs to match low mem start */
        reg = <0x0 0x80000000 0x0 0x40000000    /* 1 GB low mem */
               0x1 0x00000000 0x0 0x40000000>;  /* 1 GB highmem */
    };

and let me know if it works better for you.

That's what I see on my side:

Linux version 5.19.7 (abrodkin@abrodkin-5550) (arc-elf32-gcc (ARCompact/ARCv2 ISA elf32 toolchain - build 581) 10.2.0, GNU ld (ARCompact/ARCv2 ISA elf32 toolchain - build 581) 2.36.1) #3 PREEMPT Tue Sep 6 16:57:41 PDT 2022
Memory @ 80000000 [1024M]
Memory @ 100000000 [1024M]
OF: fdt: Machine model: snps,zebu_hs
earlycon: uart8250 at MMIO32 0x00000000f0000000 (options '115200n8')
printk: bootconsole [uart8250] enabled
archs-intc      : 15 priority levels (default 1)

IDENTITY        : ARCVER [0x53] ARCNUM [0x0] CHIPID [0xffff]
processor [0]   : HS38 R3.0 (ARCv2 ISA)
Timers          : Timer0 Timer1 RTC [UP 64-bit]
ISA Extn        : atomic ll64 unalign mpy[opt 9] div_rem
BPU             : partial match, cache:2048, Predict Table:16384 Return stk: 8
MMU [v4]        : 8k PAGE, 2M Super Page (not used) , swalk 2 lvl, JTLB 512 (128x4), uDTLB 8, uITLB 4, PAE40
I-Cache         : 32K, 4way/set, 64B Line, VIPT
D-Cache         : 16K, 2way/set, 64B Line, PIPT
Peripherals     : 0xc0000000
Vector Table    : 0x80000000
DEBUG           : ActionPoint 4/full

Zone ranges:
  Normal   [mem 0x0000000080000000-0x00000000bfffffff]
  HighMem  [mem 0x00000000c0000000-0x000000013fffffff]
Movable zone start for each node
Early memory node ranges
  node   0: [mem 0x0000000080000000-0x00000000bfffffff]
  node   0: [mem 0x0000000100000000-0x000000013fffffff]
Initmem setup node 0 [mem 0x0000000080000000-0x000000013fffffff]
On node 0, zone HighMem: 1024 pages in unavailable ranges
pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
pcpu-alloc: [0] 0

Note populated HighMem zone!

wimowa commented 1 year ago

Hi abrodkin, Sorry for the dts typo. This is the right setting: memory@00000000 {

address-cells = <2>;

    #size-cells = <2>;
    device_type = "memory";
        reg = <0x0 0x80000000 0x0 0x40000000    /* 1 GB low mem */
               0x0 0x00000000 0x0 0x40000000>;  /* 1 GB highmem */
};

For 0x0000-0000 ~ 0x4000-0000: user mode used.
For 0x8000-0000 ~ 0xC000-0000: kernel mode used.

The new debug log as: IDENTITY : ARCVER [0x54] ARCNUM [0x0] CHIPID [ 0x0] processor [0] : HS48 R4.00a (ARCv2 ISA) Dual-Issue
Timers : Timer0 Timer1 RTC [UP 64-bit]
ISA Extn : atomic ll64 unalign mpy[opt 9] div_rem
BPU : full match, cache:2048, Predict Table:16384 Return stk: 8

   MMU [v5]      : 8k PAGE, 2M Super Page (not used) , swalk 2 lvl, JTLB 1024 (256x4), uDTLB 8, uITLB 4, PAE40  
   I-Cache       : 64K, 4way/set, 64B Line, VIPT aliasing 
   D-Cache       : 64K, 2way/set, 64B Line, PIPT 
   SLC           : 512K, 128B Line 
   Peripherals   : 0xf0000000 
   Vector Table  : 0x90000000 
   FPU           : SP  
   DEBUG         : smaRT ActionPoint 8/full 
   Extn [ECC]    : IC DC MMU  

   [Sophie] setup_arch_memory+, low_mem_start=0x80000000, low_mem_sz=0x40000000

   [Sophie]    max_low_pfn=0x60000 
   [Sophie]    max_zone_pfn[ZONE_NORMAL]=0x60000 
   [Sophie]    high_mem_start=0x0, high_mem_sz=0x40000000 
   [Sophie]    max_zone_pfn[ZONE_HIGHMEM]=0x20000 
   [Sophie]    max_high_pfn[0x20000], high_memory=0x0 
   [Sophie] bef free_area_init() 

   [Sophie]:free_area_init()+ 
   [Sophie]   start_pfn=0x0, descending=0 
   [Sophie]   zone=0, max_zone_pfn[]=0x393216, start_pfn=0x0, end_pfn=0x393216 

   [Sophie]   zone=1, max_zone_pfn[]=0x131072, start_pfn=0x393216, end_pfn=0x393216

   [Sophie]   Zone=1-name:HighMem, EMPTY???? Check Here. 
   [Sophie]   find_zone_movable_pfns_for_nodes+ 

   [Sophie]:free_area_init:   Zone ranges: 
   ***:   Normal   [mem 0x0000000000000000-0x00000000bfffffff] 
   ***:   HighMem  empty 

   ***: Movable zone start for each node 

   Early memory node ranges 
     node   0: [mem 0x0000000000000000-0x000000003fffffff] 
     node   0: [mem 0x0000000080000000-0x00000000bfffffff] 
   Initmem setup node 0 [mem 0x0000000000000000-0x00000000bfffffff] 

==> so unfortunately, our seeting meet the followinf comments: /*

BR.

abrodkin commented 1 year ago

@wimowa could you please post very beginning of the boot log? It should look something like that:

Linux version 5.19.7-dirty (abrodkin@abrodkin-5550) (arc-elf32-gcc (ARCompact/ARCv2 ISA elf32 toolchain - build 581) 10.2.0, GNU ld (ARCompact/ARCv2 ISA elf32 toolchain - build 581) 2.36.1) #7 SMP PREEMPT Tue Sep 6 17:24:56 PDT 2022
Memory @ 80000000 [1024M]
Memory @ 100000000 [1024M]
...

Also may I see your kernel's config option CONFIG_ARC_BUILTIN_DTB_NAME? You may get it with:

$ cat .config | grep DTB
CONFIG_ARC_BUILTIN_DTB_NAME="haps_hs_idu"

And then matching .dts file. I'm afraid that you might be using wrong .dts file which has no additional node for PAE region.