1. 29 10月, 2020 9 次提交
  2. 28 10月, 2020 11 次提交
    • A
      ARM: p2v: reduce p2v alignment requirement to 2 MiB · 9443076e
      Ard Biesheuvel 提交于
      The ARM kernel's linear map starts at PAGE_OFFSET, which maps to a
      physical address (PHYS_OFFSET) that is platform specific, and is
      discovered at boot. Since we don't want to slow down translations
      between physical and virtual addresses by keeping the offset in a
      variable in memory, we implement this by patching the code performing
      the translation, and putting the offset between PAGE_OFFSET and the
      start of physical RAM directly into the instruction opcodes.
      
      As we only patch up to 8 bits of offset, yielding 4 GiB >> 8 == 16 MiB
      of granularity, we have to round up PHYS_OFFSET to the next multiple if
      the start of physical RAM is not a multiple of 16 MiB. This wastes some
      physical RAM, since the memory that was skipped will now live below
      PAGE_OFFSET, making it inaccessible to the kernel.
      
      We can improve this by changing the patchable sequences and the patching
      logic to carry more bits of offset: 11 bits gives us 4 GiB >> 11 == 2 MiB
      of granularity, and so we will never waste more than that amount by
      rounding up the physical start of DRAM to the next multiple of 2 MiB.
      (Note that 2 MiB granularity guarantees that the linear mapping can be
      created efficiently, whereas less than 2 MiB may result in the linear
      mapping needing another level of page tables)
      
      This helps Zhen Lei's scenario, where the start of DRAM is known to be
      occupied. It also helps EFI boot, which relies on the firmware's page
      allocator to allocate space for the decompressed kernel as low as
      possible. And if the KASLR patches ever land for 32-bit, it will give
      us 3 more bits of randomization of the placement of the kernel inside
      the linear region.
      
      For the ARM code path, it simply comes down to using two add/sub
      instructions instead of one for the carryless version, and patching
      each of them with the correct immediate depending on the rotation
      field. For the LPAE calculation, which has to deal with a carry, it
      patches the MOVW instruction with up to 12 bits of offset (but we only
      need 11 bits anyway)
      
      For the Thumb2 code path, patching more than 11 bits of displacement
      would be somewhat cumbersome, but the 11 bits we need fit nicely into
      the second word of the u16[2] opcode, so we simply update the immediate
      assignment and the left shift to create an addend of the right magnitude.
      Suggested-by: NZhen Lei <thunder.leizhen@huawei.com>
      Acked-by: NNicolas Pitre <nico@fluxnic.net>
      Acked-by: NLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      9443076e
    • A
      ARM: p2v: switch to MOVW for Thumb2 and ARM/LPAE · e8e00f5a
      Ard Biesheuvel 提交于
      In preparation for reducing the phys-to-virt minimum relative alignment
      from 16 MiB to 2 MiB, switch to patchable sequences involving MOVW
      instructions that can more easily be manipulated to carry a 12-bit
      immediate. Note that the non-LPAE ARM sequence is not updated: MOVW
      may not be supported on non-LPAE platforms, and the sequence itself
      can be updated more easily to apply the 12 bits of displacement.
      
      For Thumb2, which has many more versions of opcodes, switch to a sequence
      that can be patched by the same patching code for both versions. Note
      that the Thumb2 opcodes for MOVW and MVN are unambiguous, and have no
      rotation bits in their immediate fields, so there is no need to use
      placeholder constants in the asm blocks.
      
      While at it, drop the 'volatile' qualifiers from the asm blocks: the
      code does not have any side effects that are invisible to the compiler,
      so it is free to omit these sequences if the outputs are not used.
      Suggested-by: NRussell King <linux@armlinux.org.uk>
      Acked-by: NNicolas Pitre <nico@fluxnic.net>
      Reviewed-by: NLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      e8e00f5a
    • A
      ARM: p2v: simplify __fixup_pv_table() · 0e3db6c9
      Ard Biesheuvel 提交于
      Declutter the code in __fixup_pv_table() by using the new adr_l/str_l
      macros to take PC relative references to external symbols, and by
      using the value of PHYS_OFFSET passed in r8 to calculate the p2v
      offset.
      Acked-by: NNicolas Pitre <nico@fluxnic.net>
      Reviewed-by: NLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      0e3db6c9
    • A
      ARM: p2v: use relative references in patch site arrays · 2730e8ea
      Ard Biesheuvel 提交于
      Free up a register in the p2v patching code by switching to relative
      references, which don't require keeping the phys-to-virt displacement
      live in a register.
      Acked-by: NNicolas Pitre <nico@fluxnic.net>
      Reviewed-by: NLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      2730e8ea
    • A
      ARM: p2v: drop redundant 'type' argument from __pv_stub · 0869f3b9
      Ard Biesheuvel 提交于
      We always pass the same value for 'type' so pull it into the __pv_stub
      macro itself.
      Acked-by: NNicolas Pitre <nico@fluxnic.net>
      Reviewed-by: NLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      0869f3b9
    • A
      ARM: p2v: factor out BE8 handling · 7a94849e
      Ard Biesheuvel 提交于
      The big and little endian versions of the ARM p2v patching routine only
      differ in the values of the constants, so factor those out into macros
      so that we only have one version of the logic sequence to maintain.
      Acked-by: NNicolas Pitre <nico@fluxnic.net>
      Reviewed-by: NLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      7a94849e
    • A
      ARM: p2v: factor out shared loop processing · 4b16421c
      Ard Biesheuvel 提交于
      The ARM and Thumb2 versions of the p2v patching loop have some overlap
      at the end of the loop, so factor that out. As numeric labels are not
      required to be unique, and may therefore be ambiguous, use named local
      labels for the start and end of the loop instead.
      Acked-by: NNicolas Pitre <nico@fluxnic.net>
      Reviewed-by: NLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      4b16421c
    • A
      ARM: p2v: move patching code to separate assembler source file · eae78e1a
      Ard Biesheuvel 提交于
      Move the phys2virt patching code into a separate .S file before doing
      some work on it.
      Suggested-by: NNicolas Pitre <nico@fluxnic.net>
      Reviewed-by: NLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      eae78e1a
    • A
      ARM: module: add support for place relative relocations · 22f2d230
      Ard Biesheuvel 提交于
      When using the new adr_l/ldr_l/str_l macros to refer to external symbols
      from modules, the linker may emit place relative ELF relocations that
      need to be fixed up by the module loader. So add support for these.
      Reviewed-by: NNicolas Pitre <nico@fluxnic.net>
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      22f2d230
    • A
      ARM: assembler: introduce adr_l, ldr_l and str_l macros · 0b167463
      Ard Biesheuvel 提交于
      Like arm64, ARM supports position independent code sequences that
      produce symbol references with a greater reach than the ordinary
      adr/ldr instructions. Since on ARM, the adrl pseudo-instruction is
      only supported in ARM mode (and not at all when using Clang), having
      a adr_l macro like we do on arm64 is useful, and increases symmetry
      as well.
      
      Currently, we use open coded instruction sequences involving literals
      and arithmetic operations. Instead, we can use movw/movt pairs on v7
      CPUs, circumventing the D-cache entirely.
      
      E.g., on v7+ CPUs, we can emit a PC-relative reference as follows:
      
             movw         <reg>, #:lower16:<sym> - (1f + 8)
             movt         <reg>, #:upper16:<sym> - (1f + 8)
        1:   add          <reg>, <reg>, pc
      
      For older CPUs, we can emit the literal into a subsection, allowing it
      to be emitted out of line while retaining the ability to perform
      arithmetic on label offsets.
      
      E.g., on pre-v7 CPUs, we can emit a PC-relative reference as follows:
      
             ldr          <reg>, 2f
        1:   add          <reg>, <reg>, pc
             .subsection  1
        2:   .long        <sym> - (1b + 8)
             .previous
      
      This is allowed by the assembler because, unlike ordinary sections,
      subsections are combined into a single section in the object file, and
      so the label references are not true cross-section references that are
      visible as relocations. (Subsections have been available in binutils
      since 2004 at least, so they should not cause any issues with older
      toolchains.)
      
      So use the above to implement the macros mov_l, adr_l, ldr_l and str_l,
      all of which will use movw/movt pairs on v7 and later CPUs, and use
      PC-relative literals otherwise.
      Reviewed-by: NNicolas Pitre <nico@fluxnic.net>
      Reviewed-by: NLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      0b167463
    • A
      ARM: p2v: fix handling of LPAE translation in BE mode · 4e79f021
      Ard Biesheuvel 提交于
      When running in BE mode on LPAE hardware with a PA-to-VA translation
      that exceeds 4 GB, we patch bits 39:32 of the offset into the wrong
      byte of the opcode. So fix that, by rotating the offset in r0 to the
      right by 8 bits, which will put the 8-bit immediate in bits 31:24.
      
      Note that this will also move bit #22 in its correct place when
      applying the rotation to the constant #0x400000.
      
      Fixes: d9a790df ("ARM: 7883/1: fix mov to mvn conversion in case of 64 bit phys_addr_t and BE")
      Acked-by: NNicolas Pitre <nico@fluxnic.net>
      Reviewed-by: NLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      4e79f021
  3. 26 10月, 2020 16 次提交
  4. 25 10月, 2020 4 次提交
    • H
      i2c: core: Restore acpi_walk_dep_device_list() getting called after registering the ACPI i2c devs · 8058d699
      Hans de Goede 提交于
      Commit 21653a41 ("i2c: core: Call i2c_acpi_install_space_handler()
      before i2c_acpi_register_devices()")'s intention was to only move the
      acpi_install_address_space_handler() call to the point before where
      the ACPI declared i2c-children of the adapter where instantiated by
      i2c_acpi_register_devices().
      
      But i2c_acpi_install_space_handler() had a call to
      acpi_walk_dep_device_list() hidden (that is I missed it) at the end
      of it, so as an unwanted side-effect now acpi_walk_dep_device_list()
      was also being called before i2c_acpi_register_devices().
      
      Move the acpi_walk_dep_device_list() call to the end of
      i2c_acpi_register_devices(), so that it is once again called *after*
      the i2c_client-s hanging of the adapter have been created.
      
      This fixes the Microsoft Surface Go 2 hanging at boot.
      
      Fixes: 21653a41 ("i2c: core: Call i2c_acpi_install_space_handler() before i2c_acpi_register_devices()")
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=209627Reported-by: NRainer Finke <rainer@finke.cc>
      Reported-by: NKieran Bingham <kieran.bingham@ideasonboard.com>
      Suggested-by: NMaximilian Luz <luzmaximilian@gmail.com>
      Tested-by: NKieran Bingham <kieran.bingham@ideasonboard.com>
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NWolfram Sang <wsa@kernel.org>
      8058d699
    • L
      Merge tag 'block-5.10-2020-10-24' of git://git.kernel.dk/linux-block · d7691390
      Linus Torvalds 提交于
      Pull block fixes from Jens Axboe:
      
       - NVMe pull request from Christoph
           - rdma error handling fixes (Chao Leng)
           - fc error handling and reconnect fixes (James Smart)
           - fix the qid displace when tracing ioctl command (Keith Busch)
           - don't use BLK_MQ_REQ_NOWAIT for passthru (Chaitanya Kulkarni)
           - fix MTDT for passthru (Logan Gunthorpe)
           - blacklist Write Same on more devices (Kai-Heng Feng)
           - fix an uninitialized work struct (zhenwei pi)"
      
       - lightnvm out-of-bounds fix (Colin)
      
       - SG allocation leak fix (Doug)
      
       - rnbd fixes (Gioh, Guoqing, Jack)
      
       - zone error translation fixes (Keith)
      
       - kerneldoc markup fix (Mauro)
      
       - zram lockdep fix (Peter)
      
       - Kill unused io_context members (Yufen)
      
       - NUMA memory allocation cleanup (Xianting)
      
       - NBD config wakeup fix (Xiubo)
      
      * tag 'block-5.10-2020-10-24' of git://git.kernel.dk/linux-block: (27 commits)
        block: blk-mq: fix a kernel-doc markup
        nvme-fc: shorten reconnect delay if possible for FC
        nvme-fc: wait for queues to freeze before calling update_hr_hw_queues
        nvme-fc: fix error loop in create_hw_io_queues
        nvme-fc: fix io timeout to abort I/O
        null_blk: use zone status for max active/open
        nvmet: don't use BLK_MQ_REQ_NOWAIT for passthru
        nvmet: cleanup nvmet_passthru_map_sg()
        nvmet: limit passthru MTDS by BIO_MAX_PAGES
        nvmet: fix uninitialized work for zero kato
        nvme-pci: disable Write Zeroes on Sandisk Skyhawk
        nvme: use queuedata for nvme_req_qid
        nvme-rdma: fix crash due to incorrect cqe
        nvme-rdma: fix crash when connect rejected
        block: remove unused members for io_context
        blk-mq: remove the calling of local_memory_node()
        zram: Fix __zram_bvec_{read,write}() locking order
        skd_main: remove unused including <linux/version.h>
        sgl_alloc_order: fix memory leak
        lightnvm: fix out-of-bounds write to array devices->info[]
        ...
      d7691390
    • L
      Merge tag 'io_uring-5.10-2020-10-24' of git://git.kernel.dk/linux-block · af004187
      Linus Torvalds 提交于
      Pull io_uring fixes from Jens Axboe:
      
       - fsize was missed in previous unification of work flags
      
       - Few fixes cleaning up the flags unification creds cases (Pavel)
      
       - Fix NUMA affinities for completely unplugged/replugged node for io-wq
      
       - Two fallout fixes from the set_fs changes. One local to io_uring, one
         for the splice entry point that io_uring uses.
      
       - Linked timeout fixes (Pavel)
      
       - Removal of ->flush() ->files work-around that we don't need anymore
         with referenced files (Pavel)
      
       - Various cleanups (Pavel)
      
      * tag 'io_uring-5.10-2020-10-24' of git://git.kernel.dk/linux-block:
        splice: change exported internal do_splice() helper to take kernel offset
        io_uring: make loop_rw_iter() use original user supplied pointers
        io_uring: remove req cancel in ->flush()
        io-wq: re-set NUMA node affinities if CPUs come online
        io_uring: don't reuse linked_timeout
        io_uring: unify fsize with def->work_flags
        io_uring: fix racy REQ_F_LINK_TIMEOUT clearing
        io_uring: do poll's hash_node init in common code
        io_uring: inline io_poll_task_handler()
        io_uring: remove extra ->file check in poll prep
        io_uring: make cached_cq_overflow non atomic_t
        io_uring: inline io_fail_links()
        io_uring: kill ref get/drop in personality init
        io_uring: flags-based creds init in queue
      af004187
    • L
      Merge tag 'libata-5.10-2020-10-24' of git://git.kernel.dk/linux-block · cb6b2897
      Linus Torvalds 提交于
      Pull libata fixes from Jens Axboe:
       "Two minor libata fixes:
      
         - Fix a DMA boundary mask regression for sata_rcar (Geert)
      
         - kerneldoc markup fix (Mauro)"
      
      * tag 'libata-5.10-2020-10-24' of git://git.kernel.dk/linux-block:
        ata: fix some kernel-doc markups
        ata: sata_rcar: Fix DMA boundary mask
      cb6b2897