Linux IOMMU Development
 help / color / mirror / Atom feed
* [PATCH v3] cma: check for memory region overlapping
@ 2023-07-26 14:28 Binglei Wang
  2023-07-31 16:02 ` Christoph Hellwig
  2023-09-07 12:57 ` Robin Murphy
  0 siblings, 2 replies; 5+ messages in thread
From: Binglei Wang @ 2023-07-26 14:28 UTC (permalink / raw)
  To: hch, m.szyprowski, robin.murphy; +Cc: iommu, linux-kernel, l3b2w1

From: Binglei Wang <l3b2w1@gmail.com>

In the process of parsing the DTS, checks
whether the memory region specified by the DTS CMA node area
overlaps with the kernel text memory space reserved by memblock
before calling early_init_fdt_scan_reserved_mem.
Maybe it's better to have some warning prompts printed.

Signed-off-by: Binglei Wang <l3b2w1@gmail.com>
---

Notes:
    v3: fix compile error.
    v2: delete the logic code for handling return -EBUSY.
    v1: return -EBUSY when detect overlapping and handle the return case.

 kernel/dma/contiguous.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c
index 6ea80ae42..dc6d2af1e 100644
--- a/kernel/dma/contiguous.c
+++ b/kernel/dma/contiguous.c
@@ -410,6 +410,11 @@ static int __init rmem_cma_setup(struct reserved_mem *rmem)
 		return -EBUSY;
 	}
 
+	if (memblock_is_region_reserved(rmem->base, rmem->size)) {
+		pr_info("Reserved memory: overlap with other memblock reserved region\n");
+		return -EBUSY;
+	}
+
 	if (!of_get_flat_dt_prop(node, "reusable", NULL) ||
 	    of_get_flat_dt_prop(node, "no-map", NULL))
 		return -EINVAL;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v3] cma: check for memory region overlapping
  2023-07-26 14:28 [PATCH v3] cma: check for memory region overlapping Binglei Wang
@ 2023-07-31 16:02 ` Christoph Hellwig
  2023-09-07 12:57 ` Robin Murphy
  1 sibling, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2023-07-31 16:02 UTC (permalink / raw)
  To: Binglei Wang; +Cc: hch, m.szyprowski, robin.murphy, iommu, linux-kernel

Thanks,

applied to the dma-mapping tree for 6.6.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v3] cma: check for memory region overlapping
  2023-07-26 14:28 [PATCH v3] cma: check for memory region overlapping Binglei Wang
  2023-07-31 16:02 ` Christoph Hellwig
@ 2023-09-07 12:57 ` Robin Murphy
  2023-09-11  3:37   ` binglei wang
  2023-09-11  3:43   ` binglei wang
  1 sibling, 2 replies; 5+ messages in thread
From: Robin Murphy @ 2023-09-07 12:57 UTC (permalink / raw)
  To: Binglei Wang, hch, m.szyprowski; +Cc: iommu, linux-kernel

On 26/07/2023 3:28 pm, Binglei Wang wrote:
> From: Binglei Wang <l3b2w1@gmail.com>
> 
> In the process of parsing the DTS, checks
> whether the memory region specified by the DTS CMA node area
> overlaps with the kernel text memory space reserved by memblock
> before calling early_init_fdt_scan_reserved_mem.

This description bears no relation to what the code actually does. 
rmem_cma_setup() happens well after parsing the DTS, as it is that 
initial parsing process in fdt_scan_reserved_mem() which *makes* the 
memblock reservations in the first place. Thus, as the revert patch 
demonstrates, by the time we get here to start *using* the reserved 
region via fdt_init_reserved_mem(), it is always guaranteed to overlap a 
reserved region because it trivially overlaps with itself.

Furthermore, even if the bootloader does stupidly load a non-relocatable 
kernel into memory that it's described as reserved, the kernel text 
pages should not be available for CMA to allocate from - and if they 
were, that would be a far more fundamental bug elsewhere - so what is 
the exact problem you're trying to solve here?

Thanks,
Robin.

> Maybe it's better to have some warning prompts printed.
> 
> Signed-off-by: Binglei Wang <l3b2w1@gmail.com>
> ---
> 
> Notes:
>      v3: fix compile error.
>      v2: delete the logic code for handling return -EBUSY.
>      v1: return -EBUSY when detect overlapping and handle the return case.
> 
>   kernel/dma/contiguous.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c
> index 6ea80ae42..dc6d2af1e 100644
> --- a/kernel/dma/contiguous.c
> +++ b/kernel/dma/contiguous.c
> @@ -410,6 +410,11 @@ static int __init rmem_cma_setup(struct reserved_mem *rmem)
>   		return -EBUSY;
>   	}
>   
> +	if (memblock_is_region_reserved(rmem->base, rmem->size)) {
> +		pr_info("Reserved memory: overlap with other memblock reserved region\n");
> +		return -EBUSY;
> +	}
> +
>   	if (!of_get_flat_dt_prop(node, "reusable", NULL) ||
>   	    of_get_flat_dt_prop(node, "no-map", NULL))
>   		return -EINVAL;

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v3] cma: check for memory region overlapping
  2023-09-07 12:57 ` Robin Murphy
@ 2023-09-11  3:37   ` binglei wang
  2023-09-11  3:43   ` binglei wang
  1 sibling, 0 replies; 5+ messages in thread
From: binglei wang @ 2023-09-11  3:37 UTC (permalink / raw)
  To: Robin Murphy; +Cc: hch, m.szyprowski, iommu, linux-kernel


[-- Attachment #1.1: Type: text/plain, Size: 8797 bytes --]

Hi Murphy:

Thanks for your reply.

This patch just want to print a warning message when detecting that dts cma
area overlaps with kernel code/data memory region.
If overlapping detected, it will fall back to default cma area selected by
kernel automatically.
The attachment is the full startup log.

for example cma setup in dts as follow:
        reserved-memory {
                #address-cells = <0x00000002>;
                #size-cells = <0x00000002>;
                ranges;
                phandle = <0x0000014e>;
                linux,cma {
                        compatible = "shared-dma-pool";
                        inactive;
                        reusable;
                        reg = <0x00000000 0x81000000 0x00000000
0x01000000>; // this area will be reserved successfully.
                        linux,cma-default;
                };
        };

when system boot, we get panic "Unable to handle kernel write to read-only
memory at virtual address ffff0000010c0000"

[    0.000000] Booting Linux on physical CPU 0x0000000201 [0x700f3034]
[    0.000000] Linux version 6.5.2 (linux@ubuntu) (aarch64-linux-gnu-gcc
(Linaro GCC 7.5-2019.12) 7.5.0, GNU ld (Linaro_Binutils-2019.12)
2.28.2.20170706) #2 SMP PREEMPT Mon Sep 11 10:45:07 CST 2023
[    0.000000] KASLR disabled due to lack of seed
[    0.000000] Machine model: E2000Q DEMO DDR4
[    0.000000] earlycon: pl11 at MMIO 0x000000002800d000 (options '')
[    0.000000] printk: bootconsole [pl11] enabled
[    0.000000] efi: UEFI not found.
[    0.000000] Reserved memory: created CMA memory pool at
0x0000000081000000, size 16 MiB
[    0.000000] OF: reserved mem: initialized node linux,cma, compatible id
shared-dma-pool
[    0.000000] OF: reserved mem: 0x0000000081000000..0x0000000081ffffff
(16384 KiB) map reusable linux,cma
[    0.000000] NUMA: No NUMA configuration found
[    0.000000] NUMA: Faking a node at [mem
0x0000000080000000-0x00000000fbffffff]
[    0.000000] NUMA: NODE_DATA [mem 0xfbbfb9c0-0xfbbfdfff]
[    0.000000] Zone ranges:
[    0.000000]   DMA      [mem 0x0000000080000000-0x00000000fbffffff]
[    0.000000]   DMA32    empty
[    0.000000]   Normal   empty
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000080000000-0x00000000fbffffff]
[    0.000000] Initmem setup node 0 [mem
0x0000000080000000-0x00000000fbffffff]
[    0.000000] On node 0, zone DMA: 16384 pages in unavailable ranges
......
[    1.854067] Unable to handle kernel write to read-only memory at virtual
address ffff0000010c0000
[    1.862342] Initramfs unpacking failed: invalid magic at start of
compressed archive
[    1.862937] Mem abort info:
[    1.873450]   ESR = 0x000000009600004e
[    1.877191]   EC = 0x25: DABT (current EL), IL = 32 bits
[    1.882494]   SET = 0, FnV = 0
[    1.885539]   EA = 0, S1PTW = 0
[    1.888668]   FSC = 0x0e: level 2 permission fault
[    1.893450] Data abort info:
[    1.896319]   ISV = 0, ISS = 0x0000004e, ISS2 = 0x00000000
[    1.898409] Freeing initrd memory: 117760K
[    1.901794]   CM = 0, WnR = 1, TnD = 0, TagAccess = 0
[    1.901797]   GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
[    1.901799] swapper pgtable: 4k pages, 48-bit VAs, pgdp=0000000081b59000
[    1.901802] [ffff0000010c0000] pgd=18000000fbff7803,
p4d=18000000fbff7803, pud=18000000fbff6803, pmd=0060000081000f81
[    1.933524] Internal error: Oops: 000000009600004e [#1] PREEMPT SMP
[    1.939780] Modules linked in:
[    1.942825] CPU: 2 PID: 1 Comm: swapper/0 Tainted: G S
6.5.2 #2
[    1.950124] Hardware name: E2000Q DEMO DDR4 (DT)
[    1.954730] pstate: 40000005 (nZcv daif -PAN -UAO -TCO -DIT -SSBS
BTYPE=--)
[    1.961681] pc : __memset+0x16c/0x188
[    1.965339] lr : dma_direct_alloc+0xfc/0x344
[    1.969602] sp : ffff80008004b870
[    1.972905] x29: ffff80008004b870 x28: ffff0000038ba480 x27:
ffff800081520a90
[    1.980033] x26: ffff000002f19010 x25: ffff800080195d74 x24:
fffffc0000043000
[    1.987160] x23: ffff000002f19010 x22: ffff0000010c0000 x21:
0000000000017000
[    1.994287] x20: ffff80008004b9e0 x19: ffff800081ad2000 x18:
fffffc0000044008
[    2.001413] x17: 0000000000000040 x16: 0000000000000001 x15:
fffffc0000000000
[    2.008540] x14: 00000000f0000080 x13: 00000000f0000000 x12:
ffff800081ad3000
[    2.015667] x11: 0000000000000129 x10: 0000000000000008 x9 :
0000000000000000
[    2.022794] x8 : ffff0000010c0000 x7 : 0000000000000000 x6 :
000000000000003f
[    2.029921] x5 : 0000000000000040 x4 : 0000000000000000 x3 :
0000000000000004
[    2.037047] x2 : 0000000000016fc0 x1 : 0000000000000000 x0 :
ffff0000010c0000
[    2.044174] Call trace:
[    2.046610]  __memset+0x16c/0x188
[    2.049915]  dma_alloc_attrs+0x88/0x104
[    2.053741]  dmam_alloc_attrs+0x70/0xc8
[    2.057568]  ahci_port_start+0xa4/0x238
[    2.061396]  ata_host_start.part.36+0x100/0x21c
[    2.065918]  ata_host_activate+0x6c/0x148
[    2.069917]  ahci_host_activate+0x18c/0x1f0
[    2.074090]  ahci_platform_init_host+0x2b0/0x2f0
[    2.078697]  ahci_probe+0xb8/0xe0
[    2.082003]  platform_probe+0x68/0xd8
[    2.085656]  really_probe+0x150/0x2a4
[    2.089308]  __driver_probe_device+0x7c/0x130
[    2.093653]  driver_probe_device+0x38/0x114
[    2.097825]  __driver_attach+0xac/0x134
[    2.101649]  bus_for_each_dev+0x7c/0xdc
[    2.105477]  driver_attach+0x24/0x30
[    2.109042]  bus_add_driver+0xf0/0x20c
[    2.112782]  driver_register+0x60/0x128
[    2.116607]  __platform_driver_register+0x28/0x34
[    2.121301]  ahci_driver_init+0x1c/0x28
[    2.125128]  do_one_initcall+0x60/0x1d4
[    2.128955]  kernel_init_freeable+0x1d8/0x2a0
[    2.133304]  kernel_init+0x24/0x130
[    2.136783]  ret_from_fork+0x10/0x20
[    2.140350] Code: 91010108 54ffff4a 8b040108 cb050042 (d50b7428)
[    2.146433] ---[ end trace 0000000000000000 ]---
[    2.151061] Kernel panic - not syncing: Attempted to kill init!
exitcode=0x0000000b
[    2.158706] SMP: stopping secondary CPUs
[    2.162620] Kernel Offset: 0x80000 from 0xffff800080000000
[    2.168094] PHYS_OFFSET: 0x80000000
[    2.171570] CPU features: 0x00000000,80010000,0800421b
[    2.176697] Memory Limit: none
[    2.179741] ---[ end Kernel panic - not syncing: Attempted to kill init!
exitcode=0x0000000b ]---

Best wishes.
Binglei Wang.

Robin Murphy <robin.murphy@arm.com> 于2023年9月7日周四 20:57写道:

> On 26/07/2023 3:28 pm, Binglei Wang wrote:
> > From: Binglei Wang <l3b2w1@gmail.com>
> >
> > In the process of parsing the DTS, checks
> > whether the memory region specified by the DTS CMA node area
> > overlaps with the kernel text memory space reserved by memblock
> > before calling early_init_fdt_scan_reserved_mem.
>
> This description bears no relation to what the code actually does.
> rmem_cma_setup() happens well after parsing the DTS, as it is that
> initial parsing process in fdt_scan_reserved_mem() which *makes* the
> memblock reservations in the first place. Thus, as the revert patch
> demonstrates, by the time we get here to start *using* the reserved
> region via fdt_init_reserved_mem(), it is always guaranteed to overlap a
> reserved region because it trivially overlaps with itself.
>
> Furthermore, even if the bootloader does stupidly load a non-relocatable
> kernel into memory that it's described as reserved, the kernel text
> pages should not be available for CMA to allocate from - and if they
> were, that would be a far more fundamental bug elsewhere - so what is
> the exact problem you're trying to solve here?
>
> Thanks,
> Robin.
>
> > Maybe it's better to have some warning prompts printed.
> >
> > Signed-off-by: Binglei Wang <l3b2w1@gmail.com>
> > ---
> >
> > Notes:
> >      v3: fix compile error.
> >      v2: delete the logic code for handling return -EBUSY.
> >      v1: return -EBUSY when detect overlapping and handle the return
> case.
> >
> >   kernel/dma/contiguous.c | 5 +++++
> >   1 file changed, 5 insertions(+)
> >
> > diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c
> > index 6ea80ae42..dc6d2af1e 100644
> > --- a/kernel/dma/contiguous.c
> > +++ b/kernel/dma/contiguous.c
> > @@ -410,6 +410,11 @@ static int __init rmem_cma_setup(struct
> reserved_mem *rmem)
> >               return -EBUSY;
> >       }
> >
> > +     if (memblock_is_region_reserved(rmem->base, rmem->size)) {
> > +             pr_info("Reserved memory: overlap with other memblock
> reserved region\n");
> > +             return -EBUSY;
> > +     }
> > +
> >       if (!of_get_flat_dt_prop(node, "reusable", NULL) ||
> >           of_get_flat_dt_prop(node, "no-map", NULL))
> >               return -EINVAL;
>

[-- Attachment #1.2: Type: text/html, Size: 10324 bytes --]

[-- Attachment #2: cma.log --]
[-- Type: application/octet-stream, Size: 28208 bytes --]

[    0.000000] Booting Linux on physical CPU 0x0000000201 [0x700f3034]
[    0.000000] Linux version 6.5.2 (linux@ubuntu) (aarch64-linux-gnu-gcc (Linaro GCC 7.5-2019.12) 7.5.0, GNU ld (Linaro_Binutils-2019.12) 2.28.2.20170706) #2 SMP PREEMPT Mon Sep 11 10:45:07 CST 2023
[    0.000000] KASLR disabled due to lack of seed
[    0.000000] Machine model: E2000Q DEMO DDR4
[    0.000000] earlycon: pl11 at MMIO 0x000000002800d000 (options '')
[    0.000000] printk: bootconsole [pl11] enabled
[    0.000000] efi: UEFI not found.
[    0.000000] Reserved memory: created CMA memory pool at 0x0000000081000000, size 16 MiB
[    0.000000] OF: reserved mem: initialized node linux,cma, compatible id shared-dma-pool
[    0.000000] OF: reserved mem: 0x0000000081000000..0x0000000081ffffff (16384 KiB) map reusable linux,cma
[    0.000000] NUMA: No NUMA configuration found
[    0.000000] NUMA: Faking a node at [mem 0x0000000080000000-0x00000000fbffffff]
[    0.000000] NUMA: NODE_DATA [mem 0xfbbfb9c0-0xfbbfdfff]
[    0.000000] Zone ranges:
[    0.000000]   DMA      [mem 0x0000000080000000-0x00000000fbffffff]
[    0.000000]   DMA32    empty
[    0.000000]   Normal   empty
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000080000000-0x00000000fbffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000080000000-0x00000000fbffffff]
[    0.000000] On node 0, zone DMA: 16384 pages in unavailable ranges
[    0.000000] psci: probing for conduit method from DT.
[    0.000000] psci: PSCIv1.1 detected in firmware.
[    0.000000] psci: Using standard PSCI v0.2 function IDs
[    0.000000] psci: MIGRATE_INFO_TYPE not supported.
[    0.000000] psci: SMC Calling Convention v1.2
[    0.000000] percpu: Embedded 22 pages/cpu s50408 r8192 d31512 u90112
[    0.000000] pcpu-alloc: s50408 r8192 d31512 u90112 alloc=22*4096
[    0.000000] pcpu-alloc: [0] 0 [0] 1 [0] 2 [0] 3
[    0.000000] Detected VIPT I-cache on CPU0
[    0.000000] CPU features: detected: GIC system register CPU interface
[    0.000000] CPU features: detected: Kernel page table isolation (KPTI)
[    0.000000] alternatives: applying boot alternatives
[    0.000000] Kernel command line: rdinit=/linuxrc loglevel=10 earlycon=pl011,0x2800d000 debug rootfstype=tmpfs dyndbg="file * +p" console=ttyAMA1,115200 a
[    0.000000] Unknown kernel command line parameters "a dyndbg=file * +p", will be passed to user space.
[    0.000000] Dentry cache hash table entries: 262144 (order: 9, 2097152 bytes, linear)
[    0.000000] Inode-cache hash table entries: 131072 (order: 8, 1048576 bytes, linear)
[    0.000000] Fallback order for Node 0: 0
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 499968
[    0.000000] Policy zone: DMA
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] software IO TLB: area num 4.
[    0.000000] software IO TLB: mapped [mem 0x00000000f5800000-0x00000000f9800000] (64MB)
[    0.000000] Memory: 1765816K/2031616K available (16896K kernel code, 4162K rwdata, 10476K rodata, 8960K init, 622K bss, 249416K reserved, 16384K cma-reserved)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
[    0.000000] rcu: Preemptible hierarchical RCU implementation.
[    0.000000] rcu:     RCU event tracing is enabled.
[    0.000000] rcu:     RCU restricting CPUs from NR_CPUS=256 to nr_cpu_ids=4.
[    0.000000]  Trampoline variant of Tasks RCU enabled.
[    0.000000]  Tracing variant of Tasks RCU enabled.
[    0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 25 jiffies.
[    0.000000] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=4
[    0.000000] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0
[    0.000000] GICv3: GIC: Using split EOI/Deactivate mode
[    0.000000] GICv3: 256 SPIs implemented
[    0.000000] GICv3: 0 Extended SPIs implemented
[    0.000000] Root IRQ handler: gic_handle_irq
[    0.000000] GICv3: GICv3 features: 16 PPIs
[    0.000000] GICv3: CPU0: found redistributor 201 region 0:0x00000000308e0000
[    0.000000] ITS [mem 0x30820000-0x3083ffff]
[    0.000000] ITS@0x0000000030820000: allocated 65536 Devices @82c80000 (flat, esz 8, psz 64K, shr 0)
[    0.000000] ITS: using cache flushing for cmd queue
[    0.000000] GICv3: using LPI property table @0x0000000082c40000
[    0.000000] GIC: using cache flushing for LPI property table
[    0.000000] GICv3: CPU0: using allocated LPI pending table @0x0000000082c50000
[    0.000000] rcu: srcu_init: Setting srcu_struct sizes based on contention.
[    0.000000] arch_timer: cp15 timer(s) running at 50.00MHz (phys).
[    0.000000] clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0xb8812736b, max_idle_ns: 440795202655 ns
[    0.000000] sched_clock: 56 bits at 50MHz, resolution 20ns, wraps every 4398046511100ns
[    0.008698] Console: colour dummy device 80x25
[    0.013240] Calibrating delay loop (skipped), value calculated using timer frequency.. 100.00 BogoMIPS (lpj=200000)
[    0.023771] pid_max: default: 32768 minimum: 301
[    0.028480] LSM: initializing lsm=capability,integrity
[    0.033741] Mount-cache hash table entries: 4096 (order: 3, 32768 bytes, linear)
[    0.041206] Mountpoint-cache hash table entries: 4096 (order: 3, 32768 bytes, linear)
[    0.050438] RCU Tasks: Setting shift to 2 and lim to 1 rcu_task_cb_adjust=1.
[    0.057648] RCU Tasks Trace: Setting shift to 2 and lim to 1 rcu_task_cb_adjust=1.
[    0.065445] rcu: Hierarchical SRCU implementation.
[    0.070288] rcu:     Max phase no-delay instances is 1000.
[    0.075764] Platform MSI: gic-its@30820000 domain created
[    0.081333] PCI/MSI: /interrupt-controller@30800000/gic-its@30820000 domain created
[    0.089118] fsl-mc MSI: gic-its@30820000 domain created
[    0.095285] EFI services will not be available.
[    0.100098] smp: Bringing up secondary CPUs ...
[    0.115289] Detected VIPT I-cache on CPU1
[    0.115356] GICv3: CPU1: found redistributor 200 region 0:0x00000000308c0000
[    0.115370] GICv3: CPU1: using allocated LPI pending table @0x0000000082c60000
[    0.115409] CPU1: Booted secondary processor 0x0000000200 [0x700f3034]
[    0.126121] Detected PIPT I-cache on CPU2
[    0.126130] CPU features: SANITY CHECK: Unexpected variation in SYS_ID_AA64ISAR0_EL1. Boot CPU: 0x00011100012120, CPU2: 0x00000100012120
[    0.126143] CPU features: SANITY CHECK: Unexpected variation in SYS_MVFR0_EL1. Boot CPU: 0x00000010110222, CPU2: 0x00000010111222
[    0.126147] CPU features: Unsupported CPU feature variation detected.
[    0.126172] GICv3: CPU2: found redistributor 0 region 0:0x0000000030880000
[    0.126179] GICv3: CPU2: using allocated LPI pending table @0x0000000082c70000
[    0.126200] CPU2: Booted secondary processor 0x0000000000 [0x701f6643]
[    0.136800] Detected PIPT I-cache on CPU3
[    0.136806] CPU features: SANITY CHECK: Unexpected variation in SYS_ID_AA64ISAR0_EL1. Boot CPU: 0x00011100012120, CPU3: 0x00000100012120
[    0.136816] CPU features: SANITY CHECK: Unexpected variation in SYS_MVFR0_EL1. Boot CPU: 0x00000010110222, CPU3: 0x00000010111222
[    0.136837] GICv3: CPU3: found redistributor 100 region 0:0x00000000308a0000
[    0.136844] GICv3: CPU3: using allocated LPI pending table @0x0000000082d00000
[    0.136860] CPU3: Booted secondary processor 0x0000000100 [0x701f6643]
[    0.136914] smp: Brought up 1 node, 4 CPUs
[    0.270529] SMP: Total of 4 processors activated.
[    0.275275] CPU features: detected: 32-bit EL0 Support
[    0.280462] CPU features: detected: 32-bit EL1 Support
[    0.285642] CPU features: detected: CRC32 instructions
[    0.293640] CPU: All CPU(s) started at EL2
[    0.297810] alternatives: applying system-wide alternatives
[    0.305082] devtmpfs: initialized
[    0.312368] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[    0.322229] futex hash table entries: 1024 (order: 4, 65536 bytes, linear)
[    0.329674] pinctrl core: initialized pinctrl subsystem
[    0.336190] DMI not present or invalid.
[    0.340702] NET: Registered PF_NETLINK/PF_ROUTE protocol family
[    0.347463] DMA: preallocated 256 KiB GFP_KERNEL pool for atomic allocations
[    0.354669] DMA: preallocated 256 KiB GFP_KERNEL|GFP_DMA pool for atomic allocations
[    0.362567] DMA: preallocated 256 KiB GFP_KERNEL|GFP_DMA32 pool for atomic allocations
[    0.370622] audit: initializing netlink subsys (disabled)
[    0.376167] audit: type=2000 audit(0.212:1): state=initialized audit_enabled=0 res=1
[    0.377032] thermal_sys: Registered thermal governor 'step_wise'
[    0.383990] thermal_sys: Registered thermal governor 'power_allocator'
[    0.390102] cpuidle: using governor menu
[    0.400899] hw-breakpoint: found 6 breakpoint and 4 watchpoint registers.
[    0.407813] ASID allocator initialised with 32768 entries
[    0.414766] Serial: AMBA PL011 UART driver
[    0.420741] OF: /soc/gpio@28034000/porta: could not get #gpio-cells for /interrupt-controller@30800000/gic-its@30820000
[    0.431742] OF: /soc/gpio@28035000/porta: could not get #gpio-cells for /interrupt-controller@30800000/gic-its@30820000
[    0.442730] OF: /soc/gpio@28036000/porta: could not get #gpio-cells for /interrupt-controller@30800000/gic-its@30820000
[    0.453643] OF: /soc/gpio@28037000/porta: could not get #gpio-cells for /interrupt-controller@30800000/gic-its@30820000
[    0.464553] OF: /soc/gpio@28038000/porta: could not get #gpio-cells for /interrupt-controller@30800000/gic-its@30820000
[    0.475465] OF: /soc/gpio@28039000/porta: could not get #gpio-cells for /interrupt-controller@30800000/gic-its@30820000
[    0.488457] 2800d000.uart: ttyAMA1 at MMIO 0x2800d000 (irq = 14, base_baud = 0) is a PL011 rev3
[    0.497275] printk: console [ttyAMA1] enabled
[    0.497275] printk: console [ttyAMA1] enabled
[    0.506015] printk: bootconsole [pl11] disabled
[    0.506015] printk: bootconsole [pl11] disabled
[    0.516806] 2800e000.uart: ttyAMA2 at MMIO 0x2800e000 (irq = 15, base_baud = 0) is a PL011 rev3
[    0.534641] Modules: 22432 pages in range for non-PLT usage
[    0.534650] Modules: 513952 pages in range for PLT usage
[    0.540713] HugeTLB: registered 1.00 GiB page size, pre-allocated 0 pages
[    0.552816] HugeTLB: 0 KiB vmemmap can be freed for a 1.00 GiB page
[    0.559079] HugeTLB: registered 32.0 MiB page size, pre-allocated 0 pages
[    0.565860] HugeTLB: 0 KiB vmemmap can be freed for a 32.0 MiB page
[    0.572121] HugeTLB: registered 2.00 MiB page size, pre-allocated 0 pages
[    0.578902] HugeTLB: 0 KiB vmemmap can be freed for a 2.00 MiB page
[    0.585164] HugeTLB: registered 64.0 KiB page size, pre-allocated 0 pages
[    0.591945] HugeTLB: 0 KiB vmemmap can be freed for a 64.0 KiB page
[    0.599368] ACPI: Interpreter disabled.
[    0.604683] iommu: Default domain type: Translated
[    0.609487] iommu: DMA domain TLB invalidation policy: strict mode
[    0.615908] SCSI subsystem initialized
[    0.619738] libata version 3.00 loaded.
[    0.623729] usbcore: registered new interface driver usbfs
[    0.629230] usbcore: registered new interface driver hub
[    0.634563] usbcore: registered new device driver usb
[    0.640246] pps_core: LinuxPPS API ver. 1 registered
[    0.645213] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[    0.654347] PTP clock support registered
[    0.658361] EDAC MC: Ver: 3.0.0
[    0.662045] scmi_core: SCMI protocol bus registered
[    0.667412] FPGA manager framework
[    0.670877] Advanced Linux Sound Architecture Driver Initialized.
[    0.677862] vgaarb: loaded
[    0.681172] clocksource: Switched to clocksource arch_sys_counter
[    0.687471] VFS: Disk quotas dquot_6.6.0
[    0.691419] VFS: Dquot-cache hash table entries: 512 (order 0, 4096 bytes)
[    0.698428] pnp: PnP ACPI: disabled
[    0.706815] NET: Registered PF_INET protocol family
[    0.711830] IP idents hash table entries: 32768 (order: 6, 262144 bytes, linear)
[    0.720448] tcp_listen_portaddr_hash hash table entries: 1024 (order: 2, 16384 bytes, linear)
[    0.729008] Table-perturb hash table entries: 65536 (order: 6, 262144 bytes, linear)
[    0.736761] TCP established hash table entries: 16384 (order: 5, 131072 bytes, linear)
[    0.744758] TCP bind hash table entries: 16384 (order: 7, 524288 bytes, linear)
[    0.752381] TCP: Hash tables configured (established 16384 bind 16384)
[    0.759022] UDP hash table entries: 1024 (order: 3, 32768 bytes, linear)
[    0.765763] UDP-Lite hash table entries: 1024 (order: 3, 32768 bytes, linear)
[    0.773034] NET: Registered PF_UNIX/PF_LOCAL protocol family
[    0.778928] RPC: Registered named UNIX socket transport module.
[    0.784855] RPC: Registered udp transport module.
[    0.789555] RPC: Registered tcp transport module.
[    0.794254] RPC: Registered tcp-with-tls transport module.
[    0.799734] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.806180] PCI: CLS 0 bytes, default 64
[    0.810282] Unpacking initramfs...
[    0.821310] kvm [1]: IPA Size Limit: 40 bits
[    0.826330] kvm [1]: vgic-v2@30860000
[    0.829999] kvm [1]: GIC system register CPU interface enabled
[    0.835836] kvm [1]: vgic interrupt IRQ9
[    0.839766] kvm [1]: Hyp mode initialized successfully
[    0.845580] Initialise system trusted keyrings
[    0.850151] workingset: timestamp_bits=42 max_order=19 bucket_order=0
[    0.856746] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.862745] NFS: Registering the id_resolver key type
[    0.867808] Key type id_resolver registered
[    0.871984] Key type id_legacy registered
[    0.875994] nfs4filelayout_init: NFSv4 File Layout Driver Registering...
[    0.882690] nfs4flexfilelayout_init: NFSv4 Flexfile Layout Driver Registering...
[    0.890167] 9p: Installing v9fs 9p2000 file system support
[    0.905118] Key type asymmetric registered
[    0.909208] Asymmetric key parser 'x509' registered
[    0.914100] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 245)
[    0.921488] io scheduler mq-deadline registered
[    0.926011] io scheduler kyber registered
[    0.930029] io scheduler bfq registered
[    0.938142] pci-host-generic 40000000.pcie: host bridge /soc/pcie@40000000 ranges:
[    0.945732] pci-host-generic 40000000.pcie:       IO 0x0050000000..0x0050efffff -> 0x0000000000
[    0.954433] pci-host-generic 40000000.pcie:      MEM 0x0058000000..0x007fffffff -> 0x0058000000
[    0.963127] pci-host-generic 40000000.pcie:      MEM 0x1000000000..0x1fffffffff -> 0x1000000000
[    0.971840] pci-host-generic 40000000.pcie: Memory resource size exceeds max for 32 bits
[    0.979945] pci-host-generic 40000000.pcie: ECAM at [mem 0x40000000-0x4fffffff] for [bus 00-ff]
[    0.988761] pci-host-generic 40000000.pcie: PCI host bridge to bus 0000:00
[    0.995631] pci_bus 0000:00: root bus resource [bus 00-ff]
[    1.001109] pci_bus 0000:00: root bus resource [io  0x0000-0xefffff]
[    1.007455] pci_bus 0000:00: root bus resource [mem 0x58000000-0x7fffffff]
[    1.014321] pci_bus 0000:00: root bus resource [mem 0x1000000000-0x1fffffffff]
[    1.021547] pci 0000:00:00.0: [1db7:dc01] type 01 class 0x060400
[    1.027551] pci 0000:00:00.0: reg 0x10: [mem 0x58000000-0x58000fff]
[    1.033842] pci 0000:00:00.0: supports D1 D2
[    1.038105] pci 0000:00:00.0: PME# supported from D0 D1 D2 D3hot D3cold
[    1.044821] pci 0000:00:01.0: [1db7:dc01] type 01 class 0x060400
[    1.050831] pci 0000:00:01.0: reg 0x10: [mem 0x1000000000-0x10000fffff 64bit pref]
[    1.058420] pci 0000:00:01.0: supports D1 D2
[    1.062682] pci 0000:00:01.0: PME# supported from D0 D1 D2 D3hot D3cold
[    1.069376] pci 0000:00:02.0: [1db7:dc01] type 01 class 0x060400
[    1.075382] pci 0000:00:02.0: reg 0x10: [mem 0x1000100000-0x10001fffff 64bit pref]
[    1.082976] pci 0000:00:02.0: supports D1 D2
[    1.087238] pci 0000:00:02.0: PME# supported from D0 D1 D2 D3hot D3cold
[    1.093931] pci 0000:00:03.0: [1db7:dc01] type 01 class 0x060400
[    1.099938] pci 0000:00:03.0: reg 0x10: [mem 0x1000200000-0x10002fffff 64bit pref]
[    1.107531] pci 0000:00:03.0: supports D1 D2
[    1.111793] pci 0000:00:03.0: PME# supported from D0 D1 D2 D3hot D3cold
[    1.118504] pci 0000:00:04.0: [1db7:dc01] type 01 class 0x060400
[    1.124532] pci 0000:00:04.0: reg 0x10: [mem 0x1000300000-0x10003fffff 64bit pref]
[    1.132129] pci 0000:00:04.0: supports D1 D2
[    1.136391] pci 0000:00:04.0: PME# supported from D0 D1 D2 D3hot D3cold
[    1.143091] pci 0000:00:05.0: [1db7:dc01] type 01 class 0x060400
[    1.149097] pci 0000:00:05.0: reg 0x10: [mem 0x1000400000-0x10004fffff 64bit pref]
[    1.156691] pci 0000:00:05.0: supports D1 D2
[    1.160953] pci 0000:00:05.0: PME# supported from D0 D1 D2 D3hot D3cold
[    1.168036] pci 0000:01:00.0: [1f0a:6801] type 00 class 0x020000
[    1.174070] pci 0000:01:00.0: reg 0x10: [mem 0x58100000-0x58103fff 64bit]
[    1.180889] pci 0000:01:00.0: reg 0x20: [io  0x1000-0x10ff]
[    1.186589] pci 0000:01:00.0: supports D1
[    1.190590] pci 0000:01:00.0: PME# supported from D0 D1 D3hot D3cold
[    1.205210] pci_bus 0000:01: busn_res: [bus 01-ff] end is updated to 01
[    1.211878] pci_bus 0000:02: busn_res: [bus 02-ff] end is updated to 02
[    1.218537] pci_bus 0000:03: busn_res: [bus 03-ff] end is updated to 03
[    1.225195] pci_bus 0000:04: busn_res: [bus 04-ff] end is updated to 04
[    1.231866] pci 0000:05:00.0: [1f0a:6801] type 00 class 0x020000
[    1.237898] pci 0000:05:00.0: reg 0x10: [mem 0x58200000-0x58203fff 64bit]
[    1.244717] pci 0000:05:00.0: reg 0x20: [io  0x2000-0x20ff]
[    1.250419] pci 0000:05:00.0: supports D1
[    1.254421] pci 0000:05:00.0: PME# supported from D0 D1 D3hot D3cold
[    1.269210] pci_bus 0000:05: busn_res: [bus 05-ff] end is updated to 05
[    1.275885] pci 0000:06:00.0: [1f0a:6801] type 00 class 0x020000
[    1.281919] pci 0000:06:00.0: reg 0x10: [mem 0x58300000-0x58303fff 64bit]
[    1.288739] pci 0000:06:00.0: reg 0x20: [io  0x3000-0x30ff]
[    1.294442] pci 0000:06:00.0: supports D1
[    1.298443] pci 0000:06:00.0: PME# supported from D0 D1 D3hot D3cold
[    1.313209] pci_bus 0000:06: busn_res: [bus 06-ff] end is updated to 06
[    1.319838] pci 0000:00:00.0: BAR 14: assigned [mem 0x58000000-0x581fffff]
[    1.326709] pci 0000:00:00.0: BAR 15: assigned [mem 0x1000000000-0x10001fffff 64bit pref]
[    1.334880] pci 0000:00:01.0: BAR 0: assigned [mem 0x1000200000-0x10002fffff 64bit pref]
[    1.342964] pci 0000:00:01.0: BAR 14: assigned [mem 0x58200000-0x583fffff]
[    1.349831] pci 0000:00:01.0: BAR 15: assigned [mem 0x1000300000-0x10004fffff 64bit pref]
[    1.358000] pci 0000:00:02.0: BAR 0: assigned [mem 0x1000500000-0x10005fffff 64bit pref]
[    1.366084] pci 0000:00:02.0: BAR 14: assigned [mem 0x58400000-0x585fffff]
[    1.372951] pci 0000:00:02.0: BAR 15: assigned [mem 0x1000600000-0x10007fffff 64bit pref]
[    1.381119] pci 0000:00:03.0: BAR 0: assigned [mem 0x1000800000-0x10008fffff 64bit pref]
[    1.389203] pci 0000:00:03.0: BAR 14: assigned [mem 0x58600000-0x587fffff]
[    1.396070] pci 0000:00:03.0: BAR 15: assigned [mem 0x1000900000-0x1000afffff 64bit pref]
[    1.404240] pci 0000:00:04.0: BAR 0: assigned [mem 0x1000b00000-0x1000bfffff 64bit pref]
[    1.412325] pci 0000:00:04.0: BAR 14: assigned [mem 0x58800000-0x589fffff]
[    1.419191] pci 0000:00:04.0: BAR 15: assigned [mem 0x1000c00000-0x1000dfffff 64bit pref]
[    1.427359] pci 0000:00:05.0: BAR 0: assigned [mem 0x1000e00000-0x1000efffff 64bit pref]
[    1.435443] pci 0000:00:05.0: BAR 14: assigned [mem 0x58a00000-0x58bfffff]
[    1.442313] pci 0000:00:05.0: BAR 15: assigned [mem 0x1000f00000-0x10010fffff 64bit pref]
[    1.450482] pci 0000:00:00.0: BAR 0: assigned [mem 0x58c00000-0x58c00fff]
[    1.457262] pci 0000:00:00.0: BAR 13: assigned [io  0x1000-0x1fff]
[    1.463434] pci 0000:00:01.0: BAR 13: assigned [io  0x2000-0x2fff]
[    1.469605] pci 0000:00:02.0: BAR 13: assigned [io  0x3000-0x3fff]
[    1.475776] pci 0000:00:03.0: BAR 13: assigned [io  0x4000-0x4fff]
[    1.481948] pci 0000:00:04.0: BAR 13: assigned [io  0x5000-0x5fff]
[    1.488119] pci 0000:00:05.0: BAR 13: assigned [io  0x6000-0x6fff]
[    1.494295] pci 0000:01:00.0: BAR 0: assigned [mem 0x58000000-0x58003fff 64bit]
[    1.501608] pci 0000:01:00.0: BAR 4: assigned [io  0x1000-0x10ff]
[    1.507699] pci 0000:00:00.0: PCI bridge to [bus 01]
[    1.512658] pci 0000:00:00.0:   bridge window [io  0x1000-0x1fff]
[    1.518745] pci 0000:00:00.0:   bridge window [mem 0x58000000-0x581fffff]
[    1.525524] pci 0000:00:00.0:   bridge window [mem 0x1000000000-0x10001fffff 64bit pref]
[    1.533606] pci 0000:00:01.0: PCI bridge to [bus 02]
[    1.538562] pci 0000:00:01.0:   bridge window [io  0x2000-0x2fff]
[    1.544647] pci 0000:00:01.0:   bridge window [mem 0x58200000-0x583fffff]
[    1.551427] pci 0000:00:01.0:   bridge window [mem 0x1000300000-0x10004fffff 64bit pref]
[    1.559509] pci 0000:00:02.0: PCI bridge to [bus 03]
[    1.564464] pci 0000:00:02.0:   bridge window [io  0x3000-0x3fff]
[    1.570551] pci 0000:00:02.0:   bridge window [mem 0x58400000-0x585fffff]
[    1.577331] pci 0000:00:02.0:   bridge window [mem 0x1000600000-0x10007fffff 64bit pref]
[    1.585414] pci 0000:00:03.0: PCI bridge to [bus 04]
[    1.590369] pci 0000:00:03.0:   bridge window [io  0x4000-0x4fff]
[    1.596454] pci 0000:00:03.0:   bridge window [mem 0x58600000-0x587fffff]
[    1.603234] pci 0000:00:03.0:   bridge window [mem 0x1000900000-0x1000afffff 64bit pref]
[    1.611318] pci 0000:05:00.0: BAR 0: assigned [mem 0x58800000-0x58803fff 64bit]
[    1.618632] pci 0000:05:00.0: BAR 4: assigned [io  0x5000-0x50ff]
[    1.624725] pci 0000:00:04.0: PCI bridge to [bus 05]
[    1.629681] pci 0000:00:04.0:   bridge window [io  0x5000-0x5fff]
[    1.635767] pci 0000:00:04.0:   bridge window [mem 0x58800000-0x589fffff]
[    1.642546] pci 0000:00:04.0:   bridge window [mem 0x1000c00000-0x1000dfffff 64bit pref]
[    1.650630] pci 0000:06:00.0: BAR 0: assigned [mem 0x58a00000-0x58a03fff 64bit]
[    1.657944] pci 0000:06:00.0: BAR 4: assigned [io  0x6000-0x60ff]
[    1.664032] pci 0000:00:05.0: PCI bridge to [bus 06]
[    1.668988] pci 0000:00:05.0:   bridge window [io  0x6000-0x6fff]
[    1.675073] pci 0000:00:05.0:   bridge window [mem 0x58a00000-0x58bfffff]
[    1.681852] pci 0000:00:05.0:   bridge window [mem 0x1000f00000-0x10010fffff 64bit pref]
[    1.690123] pcieport 0000:00:00.0: PME: Signaling with IRQ 17
[    1.696033] pcieport 0000:00:00.0: AER: enabled with IRQ 17
[    1.701774] pcieport 0000:00:01.0: PME: Signaling with IRQ 18
[    1.707667] pcieport 0000:00:01.0: AER: enabled with IRQ 18
[    1.713404] pcieport 0000:00:02.0: PME: Signaling with IRQ 19
[    1.719317] pcieport 0000:00:02.0: AER: enabled with IRQ 19
[    1.725058] pcieport 0000:00:03.0: PME: Signaling with IRQ 20
[    1.730963] pcieport 0000:00:03.0: AER: enabled with IRQ 20
[    1.736705] pcieport 0000:00:04.0: PME: Signaling with IRQ 21
[    1.742615] pcieport 0000:00:04.0: AER: enabled with IRQ 21
[    1.748350] pcieport 0000:00:05.0: PME: Signaling with IRQ 22
[    1.754267] pcieport 0000:00:05.0: AER: enabled with IRQ 22
[    1.760710] EINJ: ACPI disabled.
[    1.775044] Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
[    1.782850] SuperH (H)SCI(F) driver initialized
[    1.787596] msm_serial: driver initialized
[    1.791974] STM32 USART driver initialized
[    1.799578] loop: module loaded
[    1.803267] megasas: 07.725.01.00-rc1
[    1.807214] ahci 31a40000.sata: supply ahci not found, using dummy regulator
[    1.814312] ahci 31a40000.sata: supply phy not found, using dummy regulator
[    1.821287] ahci 31a40000.sata: supply target not found, using dummy regulator
[    1.828583] ahci 31a40000.sata: SSS flag set, parallel bus scan disabled
[    1.835286] ahci 31a40000.sata: AHCI 0001.0301 32 slots 1 ports 6 Gbps 0x1 impl platform mode
[    1.843804] ahci 31a40000.sata: flags: 64bit ncq sntf stag pm led clo only pmp pio slum part ccc sadm sds apst
[    1.854067] Unable to handle kernel write to read-only memory at virtual address ffff0000010c0000
[    1.862342] Initramfs unpacking failed: invalid magic at start of compressed archive
[    1.862937] Mem abort info:
[    1.873450]   ESR = 0x000000009600004e
[    1.877191]   EC = 0x25: DABT (current EL), IL = 32 bits
[    1.882494]   SET = 0, FnV = 0
[    1.885539]   EA = 0, S1PTW = 0
[    1.888668]   FSC = 0x0e: level 2 permission fault
[    1.893450] Data abort info:
[    1.896319]   ISV = 0, ISS = 0x0000004e, ISS2 = 0x00000000
[    1.898409] Freeing initrd memory: 117760K
[    1.901794]   CM = 0, WnR = 1, TnD = 0, TagAccess = 0
[    1.901797]   GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
[    1.901799] swapper pgtable: 4k pages, 48-bit VAs, pgdp=0000000081b59000
[    1.901802] [ffff0000010c0000] pgd=18000000fbff7803, p4d=18000000fbff7803, pud=18000000fbff6803, pmd=0060000081000f81
[    1.933524] Internal error: Oops: 000000009600004e [#1] PREEMPT SMP
[    1.939780] Modules linked in:
[    1.942825] CPU: 2 PID: 1 Comm: swapper/0 Tainted: G S                 6.5.2 #2
[    1.950124] Hardware name: E2000Q DEMO DDR4 (DT)
[    1.954730] pstate: 40000005 (nZcv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[    1.961681] pc : __memset+0x16c/0x188
[    1.965339] lr : dma_direct_alloc+0xfc/0x344
[    1.969602] sp : ffff80008004b870
[    1.972905] x29: ffff80008004b870 x28: ffff0000038ba480 x27: ffff800081520a90
[    1.980033] x26: ffff000002f19010 x25: ffff800080195d74 x24: fffffc0000043000
[    1.987160] x23: ffff000002f19010 x22: ffff0000010c0000 x21: 0000000000017000
[    1.994287] x20: ffff80008004b9e0 x19: ffff800081ad2000 x18: fffffc0000044008
[    2.001413] x17: 0000000000000040 x16: 0000000000000001 x15: fffffc0000000000
[    2.008540] x14: 00000000f0000080 x13: 00000000f0000000 x12: ffff800081ad3000
[    2.015667] x11: 0000000000000129 x10: 0000000000000008 x9 : 0000000000000000
[    2.022794] x8 : ffff0000010c0000 x7 : 0000000000000000 x6 : 000000000000003f
[    2.029921] x5 : 0000000000000040 x4 : 0000000000000000 x3 : 0000000000000004
[    2.037047] x2 : 0000000000016fc0 x1 : 0000000000000000 x0 : ffff0000010c0000
[    2.044174] Call trace:
[    2.046610]  __memset+0x16c/0x188
[    2.049915]  dma_alloc_attrs+0x88/0x104
[    2.053741]  dmam_alloc_attrs+0x70/0xc8
[    2.057568]  ahci_port_start+0xa4/0x238
[    2.061396]  ata_host_start.part.36+0x100/0x21c
[    2.065918]  ata_host_activate+0x6c/0x148
[    2.069917]  ahci_host_activate+0x18c/0x1f0
[    2.074090]  ahci_platform_init_host+0x2b0/0x2f0
[    2.078697]  ahci_probe+0xb8/0xe0
[    2.082003]  platform_probe+0x68/0xd8
[    2.085656]  really_probe+0x150/0x2a4
[    2.089308]  __driver_probe_device+0x7c/0x130
[    2.093653]  driver_probe_device+0x38/0x114
[    2.097825]  __driver_attach+0xac/0x134
[    2.101649]  bus_for_each_dev+0x7c/0xdc
[    2.105477]  driver_attach+0x24/0x30
[    2.109042]  bus_add_driver+0xf0/0x20c
[    2.112782]  driver_register+0x60/0x128
[    2.116607]  __platform_driver_register+0x28/0x34
[    2.121301]  ahci_driver_init+0x1c/0x28
[    2.125128]  do_one_initcall+0x60/0x1d4
[    2.128955]  kernel_init_freeable+0x1d8/0x2a0
[    2.133304]  kernel_init+0x24/0x130
[    2.136783]  ret_from_fork+0x10/0x20
[    2.140350] Code: 91010108 54ffff4a 8b040108 cb050042 (d50b7428)
[    2.146433] ---[ end trace 0000000000000000 ]---
[    2.151061] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
[    2.158706] SMP: stopping secondary CPUs
[    2.162620] Kernel Offset: 0x80000 from 0xffff800080000000
[    2.168094] PHYS_OFFSET: 0x80000000
[    2.171570] CPU features: 0x00000000,80010000,0800421b
[    2.176697] Memory Limit: none
[    2.179741] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b ]---

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v3] cma: check for memory region overlapping
  2023-09-07 12:57 ` Robin Murphy
  2023-09-11  3:37   ` binglei wang
@ 2023-09-11  3:43   ` binglei wang
  1 sibling, 0 replies; 5+ messages in thread
From: binglei wang @ 2023-09-11  3:43 UTC (permalink / raw)
  To: Robin Murphy; +Cc: hch, m.szyprowski, iommu, linux-kernel

Hi Murphy:

Thanks for your reply.

This patch just want to print a warning message when detecting that
dts cma area overlaps with kernel code/data memory region.
If overlapping detected, it will fall back to default cma area
selected by kernel automatically.
The attachment is the full startup log.

for example cma setup in dts as follow:
        reserved-memory {
                #address-cells = <0x00000002>;
                #size-cells = <0x00000002>;
                ranges;
                phandle = <0x0000014e>;
                linux,cma {
                        compatible = "shared-dma-pool";
                        inactive;
                        reusable;
                        reg = <0x00000000 0x81000000 0x00000000
0x01000000>; // this area will be reserved successfully.
                        linux,cma-default;
                };
        };

when system boot, we get panic "Unable to handle kernel write to
read-only memory at virtual address ffff0000010c0000"

[    0.000000] Booting Linux on physical CPU 0x0000000201 [0x700f3034]
[    0.000000] Linux version 6.5.2 (linux@ubuntu)
(aarch64-linux-gnu-gcc (Linaro GCC 7.5-2019.12) 7.5.0, GNU ld
(Linaro_Binutils-2019.12) 2.28.2.20170706) #2 SMP PREEMPT Mon Sep 11
10:45:07 CST 2023
[    0.000000] KASLR disabled due to lack of seed
[    0.000000] Machine model: E2000Q DEMO DDR4
[    0.000000] earlycon: pl11 at MMIO 0x000000002800d000 (options '')
[    0.000000] printk: bootconsole [pl11] enabled
[    0.000000] efi: UEFI not found.
[    0.000000] Reserved memory: created CMA memory pool at
0x0000000081000000, size 16 MiB
[    0.000000] OF: reserved mem: initialized node linux,cma,
compatible id shared-dma-pool
[    0.000000] OF: reserved mem:
0x0000000081000000..0x0000000081ffffff (16384 KiB) map reusable
linux,cma
[    0.000000] NUMA: No NUMA configuration found
[    0.000000] NUMA: Faking a node at [mem
0x0000000080000000-0x00000000fbffffff]
[    0.000000] NUMA: NODE_DATA [mem 0xfbbfb9c0-0xfbbfdfff]
[    0.000000] Zone ranges:
[    0.000000]   DMA      [mem 0x0000000080000000-0x00000000fbffffff]
[    0.000000]   DMA32    empty
[    0.000000]   Normal   empty
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000080000000-0x00000000fbffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000080000000-0x00000000fbffffff]
[    0.000000] On node 0, zone DMA: 16384 pages in unavailable ranges
......
[    1.854067] Unable to handle kernel write to read-only memory at
virtual address ffff0000010c0000
[    1.862342] Initramfs unpacking failed: invalid magic at start of
compressed archive
[    1.862937] Mem abort info:
[    1.873450]   ESR = 0x000000009600004e
[    1.877191]   EC = 0x25: DABT (current EL), IL = 32 bits
[    1.882494]   SET = 0, FnV = 0
[    1.885539]   EA = 0, S1PTW = 0
[    1.888668]   FSC = 0x0e: level 2 permission fault
[    1.893450] Data abort info:
[    1.896319]   ISV = 0, ISS = 0x0000004e, ISS2 = 0x00000000
[    1.898409] Freeing initrd memory: 117760K
[    1.901794]   CM = 0, WnR = 1, TnD = 0, TagAccess = 0
[    1.901797]   GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
[    1.901799] swapper pgtable: 4k pages, 48-bit VAs, pgdp=0000000081b59000
[    1.901802] [ffff0000010c0000] pgd=18000000fbff7803,
p4d=18000000fbff7803, pud=18000000fbff6803, pmd=0060000081000f81
[    1.933524] Internal error: Oops: 000000009600004e [#1] PREEMPT SMP
[    1.939780] Modules linked in:
[    1.942825] CPU: 2 PID: 1 Comm: swapper/0 Tainted: G S
   6.5.2 #2
[    1.950124] Hardware name: E2000Q DEMO DDR4 (DT)
[    1.954730] pstate: 40000005 (nZcv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[    1.961681] pc : __memset+0x16c/0x188
[    1.965339] lr : dma_direct_alloc+0xfc/0x344
[    1.969602] sp : ffff80008004b870
[    1.972905] x29: ffff80008004b870 x28: ffff0000038ba480 x27: ffff800081520a90
[    1.980033] x26: ffff000002f19010 x25: ffff800080195d74 x24: fffffc0000043000
[    1.987160] x23: ffff000002f19010 x22: ffff0000010c0000 x21: 0000000000017000
[    1.994287] x20: ffff80008004b9e0 x19: ffff800081ad2000 x18: fffffc0000044008
[    2.001413] x17: 0000000000000040 x16: 0000000000000001 x15: fffffc0000000000
[    2.008540] x14: 00000000f0000080 x13: 00000000f0000000 x12: ffff800081ad3000
[    2.015667] x11: 0000000000000129 x10: 0000000000000008 x9 : 0000000000000000
[    2.022794] x8 : ffff0000010c0000 x7 : 0000000000000000 x6 : 000000000000003f
[    2.029921] x5 : 0000000000000040 x4 : 0000000000000000 x3 : 0000000000000004
[    2.037047] x2 : 0000000000016fc0 x1 : 0000000000000000 x0 : ffff0000010c0000
[    2.044174] Call trace:
[    2.046610]  __memset+0x16c/0x188
[    2.049915]  dma_alloc_attrs+0x88/0x104
[    2.053741]  dmam_alloc_attrs+0x70/0xc8
[    2.057568]  ahci_port_start+0xa4/0x238
[    2.061396]  ata_host_start.part.36+0x100/0x21c
[    2.065918]  ata_host_activate+0x6c/0x148
[    2.069917]  ahci_host_activate+0x18c/0x1f0
[    2.074090]  ahci_platform_init_host+0x2b0/0x2f0
[    2.078697]  ahci_probe+0xb8/0xe0
[    2.082003]  platform_probe+0x68/0xd8
[    2.085656]  really_probe+0x150/0x2a4
[    2.089308]  __driver_probe_device+0x7c/0x130
[    2.093653]  driver_probe_device+0x38/0x114
[    2.097825]  __driver_attach+0xac/0x134
[    2.101649]  bus_for_each_dev+0x7c/0xdc
[    2.105477]  driver_attach+0x24/0x30
[    2.109042]  bus_add_driver+0xf0/0x20c
[    2.112782]  driver_register+0x60/0x128
[    2.116607]  __platform_driver_register+0x28/0x34
[    2.121301]  ahci_driver_init+0x1c/0x28
[    2.125128]  do_one_initcall+0x60/0x1d4
[    2.128955]  kernel_init_freeable+0x1d8/0x2a0
[    2.133304]  kernel_init+0x24/0x130
[    2.136783]  ret_from_fork+0x10/0x20
[    2.140350] Code: 91010108 54ffff4a 8b040108 cb050042 (d50b7428)
[    2.146433] ---[ end trace 0000000000000000 ]---
[    2.151061] Kernel panic - not syncing: Attempted to kill init!
exitcode=0x0000000b
[    2.158706] SMP: stopping secondary CPUs
[    2.162620] Kernel Offset: 0x80000 from 0xffff800080000000
[    2.168094] PHYS_OFFSET: 0x80000000
[    2.171570] CPU features: 0x00000000,80010000,0800421b
[    2.176697] Memory Limit: none
[    2.179741] ---[ end Kernel panic - not syncing: Attempted to kill
init! exitcode=0x0000000b ]---

Best wishes.
Binglei Wang.


Robin Murphy <robin.murphy@arm.com> 于2023年9月7日周四 20:57写道:
>
> On 26/07/2023 3:28 pm, Binglei Wang wrote:
> > From: Binglei Wang <l3b2w1@gmail.com>
> >
> > In the process of parsing the DTS, checks
> > whether the memory region specified by the DTS CMA node area
> > overlaps with the kernel text memory space reserved by memblock
> > before calling early_init_fdt_scan_reserved_mem.
>
> This description bears no relation to what the code actually does.
> rmem_cma_setup() happens well after parsing the DTS, as it is that
> initial parsing process in fdt_scan_reserved_mem() which *makes* the
> memblock reservations in the first place. Thus, as the revert patch
> demonstrates, by the time we get here to start *using* the reserved
> region via fdt_init_reserved_mem(), it is always guaranteed to overlap a
> reserved region because it trivially overlaps with itself.
>
> Furthermore, even if the bootloader does stupidly load a non-relocatable
> kernel into memory that it's described as reserved, the kernel text
> pages should not be available for CMA to allocate from - and if they
> were, that would be a far more fundamental bug elsewhere - so what is
> the exact problem you're trying to solve here?
>
> Thanks,
> Robin.
>
> > Maybe it's better to have some warning prompts printed.
> >
> > Signed-off-by: Binglei Wang <l3b2w1@gmail.com>
> > ---
> >
> > Notes:
> >      v3: fix compile error.
> >      v2: delete the logic code for handling return -EBUSY.
> >      v1: return -EBUSY when detect overlapping and handle the return case.
> >
> >   kernel/dma/contiguous.c | 5 +++++
> >   1 file changed, 5 insertions(+)
> >
> > diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c
> > index 6ea80ae42..dc6d2af1e 100644
> > --- a/kernel/dma/contiguous.c
> > +++ b/kernel/dma/contiguous.c
> > @@ -410,6 +410,11 @@ static int __init rmem_cma_setup(struct reserved_mem *rmem)
> >               return -EBUSY;
> >       }
> >
> > +     if (memblock_is_region_reserved(rmem->base, rmem->size)) {
> > +             pr_info("Reserved memory: overlap with other memblock reserved region\n");
> > +             return -EBUSY;
> > +     }
> > +
> >       if (!of_get_flat_dt_prop(node, "reusable", NULL) ||
> >           of_get_flat_dt_prop(node, "no-map", NULL))
> >               return -EINVAL;

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-09-11  3:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-26 14:28 [PATCH v3] cma: check for memory region overlapping Binglei Wang
2023-07-31 16:02 ` Christoph Hellwig
2023-09-07 12:57 ` Robin Murphy
2023-09-11  3:37   ` binglei wang
2023-09-11  3:43   ` binglei wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox