1. 08 5月, 2022 1 次提交
  2. 18 2月, 2022 1 次提交
  3. 15 1月, 2022 1 次提交
  4. 08 1月, 2022 1 次提交
    • S
      of/fdt: Don't worry about non-memory region overlap for no-map · da17d690
      Stephen Boyd 提交于
      In commit 8a5a75e5 ("of/fdt: Make sure no-map does not remove
      already reserved regions") we returned -EBUSY when trying to mark
      regions as no-map when they intersect with reserved memory. The goal was
      to find bad no-map reserved memory DT nodes that would unmap the kernel
      text/data sections.
      
      The problem is the reserved memory check will still trigger if the DT
      has a /memreserve/ that completely subsumes the no-map memory carveouts
      in the reserved memory node _and_ that region is also not part of the
      memory reg property. For example in sc7180.dtsi we have the following
      reserved-memory and memory node:
      
            memory@80000000 {
                /* We expect the bootloader to fill in the size */
                reg = <0 0x80000000 0 0>;
            };
      
            smem_mem: memory@80900000 {
                    reg = <0x0 0x80900000 0x0 0x200000>;
                    no-map;
            };
      
      and the memreserve filled in by the bootloader is
      
            /memreserve/ 0x80800000 0x400000;
      
      while the /memory node is transformed into
      
            memory@80000000 {
                /* The bootloader fills in the size, and adds another region */
                reg = <0 0x80000000 0 0x00800000>,
                      <0 0x80c00000 0 0x7f200000>;
            };
      
      The smem region is doubly reserved via /memreserve/ and by not being
      part of the /memory reg property. This leads to the following warning
      printed at boot.
      
       OF: fdt: Reserved memory: failed to reserve memory for node 'memory@80900000': base 0x0000000080900000, size 2 MiB
      
      Otherwise nothing really goes wrong because the smem region is not going
      to be mapped by the kernel's direct linear mapping given that it isn't
      part of the memory node. Therefore, let's only consider this to be a
      problem if we're trying to mark a region as no-map and it is actually
      memory that we're intending to keep out of the kernel's direct mapping
      but it's already been reserved.
      Acked-by: NMike Rapoport <rppt@kernel.org>
      Cc: Douglas Anderson <dianders@chromium.org>
      Cc: Nicolas Boichat <drinkcat@chromium.org>
      Cc: Quentin Perret <qperret@google.com>
      Cc: Jan Kiszka <jan.kiszka@siemens.com>
      Fixes: 8a5a75e5 ("of/fdt: Make sure no-map does not remove already reserved regions")
      Signed-off-by: NStephen Boyd <swboyd@chromium.org>
      Signed-off-by: NRob Herring <robh@kernel.org>
      Link: https://lore.kernel.org/r/20220107194233.2793146-1-swboyd@chromium.org
      da17d690
  5. 22 12月, 2021 2 次提交
    • P
      efi: apply memblock cap after memblock_add() · b398123b
      Pingfan Liu 提交于
      On arm64, during kdump kernel saves vmcore, it runs into the following bug:
      ...
      [   15.148919] usercopy: Kernel memory exposure attempt detected from SLUB object 'kmem_cache_node' (offset 0, size 4096)!
      [   15.159707] ------------[ cut here ]------------
      [   15.164311] kernel BUG at mm/usercopy.c:99!
      [   15.168482] Internal error: Oops - BUG: 0 [#1] SMP
      [   15.173261] Modules linked in: xfs libcrc32c crct10dif_ce ghash_ce sha2_ce sha256_arm64 sha1_ce sbsa_gwdt ast i2c_algo_bit drm_vram_helper drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops cec drm_ttm_helper ttm drm nvme nvme_core xgene_hwmon i2c_designware_platform i2c_designware_core dm_mirror dm_region_hash dm_log dm_mod overlay squashfs zstd_decompress loop
      [   15.206186] CPU: 0 PID: 542 Comm: cp Not tainted 5.16.0-rc4 #1
      [   15.212006] Hardware name: GIGABYTE R272-P30-JG/MP32-AR0-JG, BIOS F12 (SCP: 1.5.20210426) 05/13/2021
      [   15.221125] pstate: 60400009 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
      [   15.228073] pc : usercopy_abort+0x9c/0xa0
      [   15.232074] lr : usercopy_abort+0x9c/0xa0
      [   15.236070] sp : ffff8000121abba0
      [   15.239371] x29: ffff8000121abbb0 x28: 0000000000003000 x27: 0000000000000000
      [   15.246494] x26: 0000000080000400 x25: 0000ffff885c7000 x24: 0000000000000000
      [   15.253617] x23: 000007ff80400000 x22: ffff07ff80401000 x21: 0000000000000001
      [   15.260739] x20: 0000000000001000 x19: ffff07ff80400000 x18: ffffffffffffffff
      [   15.267861] x17: 656a626f2042554c x16: 53206d6f72662064 x15: 6574636574656420
      [   15.274983] x14: 74706d6574746120 x13: 2129363930342065 x12: 7a6973202c302074
      [   15.282105] x11: ffffc8b041d1b148 x10: 00000000ffff8000 x9 : ffffc8b04012812c
      [   15.289228] x8 : 00000000ffff7fff x7 : ffffc8b041d1b148 x6 : 0000000000000000
      [   15.296349] x5 : 0000000000000000 x4 : 0000000000007fff x3 : 0000000000000000
      [   15.303471] x2 : 0000000000000000 x1 : ffff07ff8c064800 x0 : 000000000000006b
      [   15.310593] Call trace:
      [   15.313027]  usercopy_abort+0x9c/0xa0
      [   15.316677]  __check_heap_object+0xd4/0xf0
      [   15.320762]  __check_object_size.part.0+0x160/0x1e0
      [   15.325628]  __check_object_size+0x2c/0x40
      [   15.329711]  copy_oldmem_page+0x7c/0x140
      [   15.333623]  read_from_oldmem.part.0+0xfc/0x1c0
      [   15.338142]  __read_vmcore.constprop.0+0x23c/0x350
      [   15.342920]  read_vmcore+0x28/0x34
      [   15.346309]  proc_reg_read+0xb4/0xf0
      [   15.349871]  vfs_read+0xb8/0x1f0
      [   15.353088]  ksys_read+0x74/0x100
      [   15.356390]  __arm64_sys_read+0x28/0x34
      ...
      
      This bug introduced by commit b261dba2 ("arm64: kdump: Remove custom
      linux,usable-memory-range handling"), which moves
      memblock_cap_memory_range() to fdt, but it breaches the rules that
      memblock_cap_memory_range() should come after memblock_add() etc as said
      in commit e888fa7b ("memblock: Check memory add/cap ordering").
      
      As a consequence, the virtual address set up by copy_oldmem_page() does
      not bail out from the test of virt_addr_valid() in check_heap_object(),
      and finally hits the BUG_ON().
      
      Since memblock allocator has no idea about when the memblock is fully
      populated, while efi_init() is aware, so tackling this issue by calling the
      interface early_init_dt_check_for_usable_mem_range() exposed by of/fdt.
      
      Fixes: b261dba2 ("arm64: kdump: Remove custom linux,usable-memory-range handling")
      Signed-off-by: NPingfan Liu <kernelfans@gmail.com>
      Cc: Rob Herring <robh+dt@kernel.org>
      Cc: Zhen Lei <thunder.leizhen@huawei.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Mike Rapoport <rppt@kernel.org>
      Cc: Geert Uytterhoeven <geert+renesas@glider.be>
      Cc: Frank Rowand <frowand.list@gmail.com>
      Cc: Ard Biesheuvel <ardb@kernel.org>
      Cc: Nick Terrell <terrelln@fb.com>
      Cc: linux-arm-kernel@lists.infradead.org
      To: devicetree@vger.kernel.org
      To: linux-efi@vger.kernel.org
      Acked-by: NArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: NRob Herring <robh@kernel.org>
      Link: https://lore.kernel.org/r/20211215021348.8766-1-kernelfans@gmail.com
      b398123b
    • Z
      of: fdt: Aggregate the processing of "linux,usable-memory-range" · 8347b417
      Zhen Lei 提交于
      Currently, we parse the "linux,usable-memory-range" property in
      early_init_dt_scan_chosen(), to obtain the specified memory range of the
      crash kernel. We then reserve the required memory after
      early_init_dt_scan_memory() has identified all available physical memory.
      Because the two pieces of code are separated far, the readability and
      maintainability are reduced. So bring them together.
      Suggested-by: NRob Herring <robh@kernel.org>
      Signed-off-by: NZhen Lei <thunder.leizhen@huawei.com>
      (change the prototype of early_init_dt_check_for_usable_mem_range(), in
      order to use it outside)
      Signed-off-by: NPingfan Liu <kernelfans@gmail.com>
      Tested-by: NDave Kleikamp <dave.kleikamp@oracle.com>
      Acked-by: NJohn Donnelly <john.p.donnelly@oracle.com>
      Reviewed-by: NRob Herring <robh@kernel.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      To: devicetree@vger.kernel.org
      To: linux-efi@vger.kernel.org
      Signed-off-by: NRob Herring <robh@kernel.org>
      8347b417
  6. 17 12月, 2021 3 次提交
  7. 02 11月, 2021 1 次提交
  8. 26 8月, 2021 1 次提交
  9. 25 8月, 2021 3 次提交
  10. 15 8月, 2021 2 次提交
  11. 04 8月, 2021 1 次提交
  12. 15 7月, 2021 1 次提交
  13. 17 6月, 2021 2 次提交
  14. 08 4月, 2021 1 次提交
  15. 28 3月, 2021 2 次提交
  16. 24 3月, 2021 1 次提交
    • L
      of: fdt: Demote kernel-doc abuses and fix function naming · a300dc86
      Lee Jones 提交于
      Fixes the following W=1 kernel build warning(s):
      
       drivers/of/fdt.c:478: warning: Function parameter or member 'node' not described in '__reserved_mem_reserve_reg'
       drivers/of/fdt.c:478: warning: Function parameter or member 'uname' not described in '__reserved_mem_reserve_reg'
       drivers/of/fdt.c:525: warning: Function parameter or member 'node' not described in '__reserved_mem_check_root'
       drivers/of/fdt.c:547: warning: Function parameter or member 'node' not described in '__fdt_scan_reserved_mem'
       drivers/of/fdt.c:547: warning: Function parameter or member 'uname' not described in '__fdt_scan_reserved_mem'
       drivers/of/fdt.c:547: warning: Function parameter or member 'depth' not described in '__fdt_scan_reserved_mem'
       drivers/of/fdt.c:547: warning: Function parameter or member 'data' not described in '__fdt_scan_reserved_mem'
       drivers/of/fdt.c:547: warning: expecting prototype for fdt_scan_reserved_mem(). Prototype was for __fdt_scan_reserved_mem() instead
       drivers/of/fdt.c:663: warning: Function parameter or member 'parent' not described in 'of_scan_flat_dt_subnodes'
       drivers/of/fdt.c:708: warning: Function parameter or member 'node' not described in 'of_get_flat_dt_prop'
       drivers/of/fdt.c:708: warning: Function parameter or member 'name' not described in 'of_get_flat_dt_prop'
       drivers/of/fdt.c:708: warning: Function parameter or member 'size' not described in 'of_get_flat_dt_prop'
       drivers/of/fdt.c:758: warning: Function parameter or member 'node' not described in 'of_flat_dt_match'
       drivers/of/fdt.c:758: warning: Function parameter or member 'compat' not described in 'of_flat_dt_match'
       drivers/of/fdt.c:778: warning: Function parameter or member 'node' not described in 'of_get_flat_dt_phandle'
       drivers/of/fdt.c:778: warning: expecting prototype for of_get_flat_dt_prop(). Prototype was for of_get_flat_dt_phandle() instead
       drivers/of/fdt.c:955: warning: Function parameter or member 'node' not described in 'early_init_dt_scan_root'
       drivers/of/fdt.c:955: warning: Function parameter or member 'uname' not described in 'early_init_dt_scan_root'
       drivers/of/fdt.c:955: warning: Function parameter or member 'depth' not described in 'early_init_dt_scan_root'
       drivers/of/fdt.c:955: warning: Function parameter or member 'data' not described in 'early_init_dt_scan_root'
       drivers/of/fdt.c:991: warning: Function parameter or member 'node' not described in 'early_init_dt_scan_memory'
       drivers/of/fdt.c:991: warning: Function parameter or member 'uname' not described in 'early_init_dt_scan_memory'
       drivers/of/fdt.c:991: warning: Function parameter or member 'depth' not described in 'early_init_dt_scan_memory'
       drivers/of/fdt.c:991: warning: Function parameter or member 'data' not described in 'early_init_dt_scan_memory'
      
      Cc: Rob Herring <robh+dt@kernel.org>
      Cc: Frank Rowand <frowand.list@gmail.com>
      Cc: benh@kernel.crashing.org
      Cc: devicetree@vger.kernel.org
      Signed-off-by: NLee Jones <lee.jones@linaro.org>
      Signed-off-by: NRob Herring <robh@kernel.org>
      Link: https://lore.kernel.org/r/20210318104036.3175910-8-lee.jones@linaro.org
      a300dc86
  17. 16 1月, 2021 2 次提交
  18. 04 12月, 2020 1 次提交
  19. 29 5月, 2020 1 次提交
    • Q
      of/fdt: Remove redundant kbasename function call · 7536c7e0
      Qi Zheng 提交于
      For version 1 to 3 of the device tree, this is the node full
      path as a zero terminated string, starting with "/". The
      following equation will not hold, since the node name has
      been processed in the fdt_get_name().
      
      	*pathp == '/'
      
      For version 16 and later, this is the node unit name only
      (or an empty string for the root node). So the above
      equation will still not hold.
      
      So the kbasename() is redundant, just remove it.
      Signed-off-by: NQi Zheng <arch0.zheng@gmail.com>
      Signed-off-by: NRob Herring <robh@kernel.org>
      7536c7e0
  20. 20 5月, 2020 1 次提交
  21. 21 4月, 2020 1 次提交
  22. 18 10月, 2019 1 次提交
  23. 01 10月, 2019 1 次提交
  24. 27 8月, 2019 1 次提交
  25. 23 8月, 2019 1 次提交
    • H
      fdt: add support for rng-seed · 428826f5
      Hsin-Yi Wang 提交于
      Introducing a chosen node, rng-seed, which is an entropy that can be
      passed to kernel called very early to increase initial device
      randomness. Bootloader should provide this entropy and the value is
      read from /chosen/rng-seed in DT.
      
      Obtain of_fdt_crc32 for CRC check after early_init_dt_scan_nodes(),
      since early_init_dt_scan_chosen() would modify fdt to erase rng-seed.
      
      Add a new interface add_bootloader_randomness() for rng-seed use case.
      Depends on whether the seed is trustworthy, rng seed would be passed to
      add_hwgenerator_randomness(). Otherwise it would be passed to
      add_device_randomness(). Decision is controlled by kernel config
      RANDOM_TRUST_BOOTLOADER.
      Signed-off-by: NHsin-Yi Wang <hsinyi@chromium.org>
      Reviewed-by: NStephen Boyd <swboyd@chromium.org>
      Reviewed-by: NRob Herring <robh@kernel.org>
      Reviewed-by: Theodore Ts'o <tytso@mit.edu> # drivers/char/random.c
      Signed-off-by: NWill Deacon <will@kernel.org>
      428826f5
  26. 09 7月, 2019 1 次提交
  27. 18 6月, 2019 1 次提交
  28. 25 5月, 2019 2 次提交
  29. 30 4月, 2019 1 次提交
  30. 13 3月, 2019 1 次提交
    • M
      treewide: add checks for the return value of memblock_alloc*() · 8a7f97b9
      Mike Rapoport 提交于
      Add check for the return value of memblock_alloc*() functions and call
      panic() in case of error.  The panic message repeats the one used by
      panicing memblock allocators with adjustment of parameters to include
      only relevant ones.
      
      The replacement was mostly automated with semantic patches like the one
      below with manual massaging of format strings.
      
        @@
        expression ptr, size, align;
        @@
        ptr = memblock_alloc(size, align);
        + if (!ptr)
        + 	panic("%s: Failed to allocate %lu bytes align=0x%lx\n", __func__, size, align);
      
      [anders.roxell@linaro.org: use '%pa' with 'phys_addr_t' type]
        Link: http://lkml.kernel.org/r/20190131161046.21886-1-anders.roxell@linaro.org
      [rppt@linux.ibm.com: fix format strings for panics after memblock_alloc]
        Link: http://lkml.kernel.org/r/1548950940-15145-1-git-send-email-rppt@linux.ibm.com
      [rppt@linux.ibm.com: don't panic if the allocation in sparse_buffer_init fails]
        Link: http://lkml.kernel.org/r/20190131074018.GD28876@rapoport-lnx
      [akpm@linux-foundation.org: fix xtensa printk warning]
      Link: http://lkml.kernel.org/r/1548057848-15136-20-git-send-email-rppt@linux.ibm.comSigned-off-by: NMike Rapoport <rppt@linux.ibm.com>
      Signed-off-by: NAnders Roxell <anders.roxell@linaro.org>
      Reviewed-by: Guo Ren <ren_guo@c-sky.com>		[c-sky]
      Acked-by: Paul Burton <paul.burton@mips.com>		[MIPS]
      Acked-by: Heiko Carstens <heiko.carstens@de.ibm.com>	[s390]
      Reviewed-by: Juergen Gross <jgross@suse.com>		[Xen]
      Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>	[m68k]
      Acked-by: Max Filippov <jcmvbkbc@gmail.com>		[xtensa]
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christophe Leroy <christophe.leroy@c-s.fr>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Dennis Zhou <dennis@kernel.org>
      Cc: Greentime Hu <green.hu@gmail.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Guan Xuetao <gxt@pku.edu.cn>
      Cc: Guo Ren <guoren@kernel.org>
      Cc: Mark Salter <msalter@redhat.com>
      Cc: Matt Turner <mattst88@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Michal Simek <monstr@monstr.eu>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Richard Weinberger <richard@nod.at>
      Cc: Rich Felker <dalias@libc.org>
      Cc: Rob Herring <robh+dt@kernel.org>
      Cc: Rob Herring <robh@kernel.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Tony Luck <tony.luck@intel.com>
      Cc: Vineet Gupta <vgupta@synopsys.com>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      8a7f97b9