Skip to content
Snippets Groups Projects
  1. Sep 11, 2021
  2. Sep 08, 2021
  3. Sep 06, 2021
  4. Sep 02, 2021
  5. Sep 01, 2021
  6. Aug 26, 2021
    • Max Gurtovoy's avatar
      PCI / VFIO: Add 'override_only' support for VFIO PCI sub system · cc6711b0
      Max Gurtovoy authored
      
      Expose an 'override_only' helper macro (i.e.
      PCI_DRIVER_OVERRIDE_DEVICE_VFIO) for VFIO PCI sub system and add the
      required code to prefix its matching entries with "vfio_" in
      modules.alias file.
      
      It allows VFIO device drivers to include match entries in the
      modules.alias file produced by kbuild that are not used for normal
      driver autoprobing and module autoloading. Drivers using these match
      entries can be connected to the PCI device manually, by userspace, using
      the existing driver_override sysfs.
      
      For example the resulting modules.alias may have:
      
        alias pci:v000015B3d00001021sv*sd*bc*sc*i* mlx5_core
        alias vfio_pci:v000015B3d00001021sv*sd*bc*sc*i* mlx5_vfio_pci
        alias vfio_pci:v*d*sv*sd*bc*sc*i* vfio_pci
      
      In this example mlx5_core and mlx5_vfio_pci match to the same PCI
      device. The kernel will autoload and autobind to mlx5_core but the
      kernel and udev mechanisms will ignore mlx5_vfio_pci.
      
      When userspace wants to change a device to the VFIO subsystem it can
      implement a generic algorithm:
      
         1) Identify the sysfs path to the device:
          /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0
      
         2) Get the modalias string from the kernel:
          $ cat /sys/bus/pci/devices/0000:01:00.0/modalias
          pci:v000015B3d00001021sv000015B3sd00000001bc02sc00i00
      
         3) Prefix it with vfio_:
          vfio_pci:v000015B3d00001021sv000015B3sd00000001bc02sc00i00
      
         4) Search modules.alias for the above string and select the entry that
            has the fewest *'s:
          alias vfio_pci:v000015B3d00001021sv*sd*bc*sc*i* mlx5_vfio_pci
      
         5) modprobe the matched module name:
          $ modprobe mlx5_vfio_pci
      
         6) cat the matched module name to driver_override:
          echo mlx5_vfio_pci > /sys/bus/pci/devices/0000:01:00.0/driver_override
      
         7) unbind device from original module
           echo 0000:01:00.0 > /sys/bus/pci/devices/0000:01:00.0/driver/unbind
      
         8) probe PCI drivers (or explicitly bind to mlx5_vfio_pci)
          echo 0000:01:00.0 > /sys/bus/pci/drivers_probe
      
      The algorithm is independent of bus type. In future the other buses with
      VFIO device drivers, like platform and ACPI, can use this algorithm as
      well.
      
      This patch is the infrastructure to provide the information in the
      modules.alias to userspace. Convert the only VFIO pci_driver which results
      in one new line in the modules.alias:
      
        alias vfio_pci:v*d*sv*sd*bc*sc*i* vfio_pci
      
      Later series introduce additional HW specific VFIO PCI drivers, such as
      mlx5_vfio_pci.
      
      Signed-off-by: default avatarMax Gurtovoy <mgurtovoy@nvidia.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      Acked-by: Bjorn Helgaas <bhelgaas@google.com>  # for pci.h
      Signed-off-by: default avatarYishai Hadas <yishaih@nvidia.com>
      Link: https://lore.kernel.org/r/20210826103912.128972-11-yishaih@nvidia.com
      
      
      Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
      cc6711b0
  7. Aug 23, 2021
  8. Aug 15, 2021
    • Christophe Leroy's avatar
      powerpc/bug: Provide better flexibility to WARN_ON/__WARN_FLAGS() with asm goto · 1e688dd2
      Christophe Leroy authored
      
      Using asm goto in __WARN_FLAGS() and WARN_ON() allows more
      flexibility to GCC.
      
      For that add an entry to the exception table so that
      program_check_exception() knowns where to resume execution
      after a WARNING.
      
      Here are two exemples. The first one is done on PPC32 (which
      benefits from the previous patch), the second is on PPC64.
      
      	unsigned long test(struct pt_regs *regs)
      	{
      		int ret;
      
      		WARN_ON(regs->msr & MSR_PR);
      
      		return regs->gpr[3];
      	}
      
      	unsigned long test9w(unsigned long a, unsigned long b)
      	{
      		if (WARN_ON(!b))
      			return 0;
      		return a / b;
      	}
      
      Before the patch:
      
      	000003a8 <test>:
      	 3a8:	81 23 00 84 	lwz     r9,132(r3)
      	 3ac:	71 29 40 00 	andi.   r9,r9,16384
      	 3b0:	40 82 00 0c 	bne     3bc <test+0x14>
      	 3b4:	80 63 00 0c 	lwz     r3,12(r3)
      	 3b8:	4e 80 00 20 	blr
      
      	 3bc:	0f e0 00 00 	twui    r0,0
      	 3c0:	80 63 00 0c 	lwz     r3,12(r3)
      	 3c4:	4e 80 00 20 	blr
      
      	0000000000000bf0 <.test9w>:
      	 bf0:	7c 89 00 74 	cntlzd  r9,r4
      	 bf4:	79 29 d1 82 	rldicl  r9,r9,58,6
      	 bf8:	0b 09 00 00 	tdnei   r9,0
      	 bfc:	2c 24 00 00 	cmpdi   r4,0
      	 c00:	41 82 00 0c 	beq     c0c <.test9w+0x1c>
      	 c04:	7c 63 23 92 	divdu   r3,r3,r4
      	 c08:	4e 80 00 20 	blr
      
      	 c0c:	38 60 00 00 	li      r3,0
      	 c10:	4e 80 00 20 	blr
      
      After the patch:
      
      	000003a8 <test>:
      	 3a8:	81 23 00 84 	lwz     r9,132(r3)
      	 3ac:	71 29 40 00 	andi.   r9,r9,16384
      	 3b0:	40 82 00 0c 	bne     3bc <test+0x14>
      	 3b4:	80 63 00 0c 	lwz     r3,12(r3)
      	 3b8:	4e 80 00 20 	blr
      
      	 3bc:	0f e0 00 00 	twui    r0,0
      
      	0000000000000c50 <.test9w>:
      	 c50:	7c 89 00 74 	cntlzd  r9,r4
      	 c54:	79 29 d1 82 	rldicl  r9,r9,58,6
      	 c58:	0b 09 00 00 	tdnei   r9,0
      	 c5c:	7c 63 23 92 	divdu   r3,r3,r4
      	 c60:	4e 80 00 20 	blr
      
      	 c70:	38 60 00 00 	li      r3,0
      	 c74:	4e 80 00 20 	blr
      
      In the first exemple, we see GCC doesn't need to duplicate what
      happens after the trap.
      
      In the second exemple, we see that GCC doesn't need to emit a test
      and a branch in the likely path in addition to the trap.
      
      We've got some WARN_ON() in .softirqentry.text section so it needs
      to be added in the OTHER_TEXT_SECTIONS in modpost.c
      
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/389962b1b702e3c78d169e59bcfac56282889173.1618331882.git.christophe.leroy@csgroup.eu
      1e688dd2
  9. Aug 12, 2021
  10. Aug 10, 2021
  11. Aug 09, 2021
  12. Aug 08, 2021
  13. Aug 05, 2021
  14. Aug 04, 2021
    • Hui Su's avatar
      scripts/tracing: fix the bug that can't parse raw_trace_func · 1c0cec64
      Hui Su authored
      Since commit 77271ce4 ("tracing: Add irq, preempt-count and need resched info
      to default trace output"), the default trace output format has been changed to:
                <idle>-0       [009] d.h. 22420.068695: _raw_spin_lock_irqsave <-hrtimer_interrupt
                <idle>-0       [000] ..s. 22420.068695: _nohz_idle_balance <-run_rebalance_domains
                <idle>-0       [011] d.h. 22420.068695: account_process_tick <-update_process_times
      
      origin trace output format:(before v3.2.0)
           # tracer: nop
           #
           #           TASK-PID    CPU#    TIMESTAMP  FUNCTION
           #              | |       |          |         |
                migration/0-6     [000]    50.025810: rcu_note_context_switch <-__schedule
                migration/0-6     [000]    50.025812: trace_rcu_utilization <-rcu_note_context_switch
                migration/0-6     [000]    50.025813: rcu_sched_qs <-rcu_note_context_switch
                migration/0-6     [000]    50.025815: rcu_preempt_qs <-rcu_note_context_switch
                migration/0-6     [000]    50.025817: trace_rcu_utilization <-rcu_note_context_switch
                migration/0-6     [000]    50.025818: debug_lockdep_rcu_enabled <-__schedule
                migration/0-6     [000]    50.025820: debug_lockdep_rcu_enabled <-__schedule
      
      The draw_functrace.py(introduced in v2.6.28) can't parse the new version format trace_func,
      So we need modify draw_functrace.py to adapt the new version trace output format.
      
      Link: https://lkml.kernel.org/r/20210611022107.608787-1-suhui@zeku.com
      
      
      
      Cc: stable@vger.kernel.org
      Fixes: 77271ce4 tracing: Add irq, preempt-count and need resched info to default trace output
      Signed-off-by: default avatarHui Su <suhui@zeku.com>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      1c0cec64
    • Nathan Chancellor's avatar
      scripts/recordmcount.pl: Remove check_objcopy() and $can_use_local · b18b851b
      Nathan Chancellor authored
      When building ARCH=riscv allmodconfig with llvm-objcopy, the objcopy
      version warning from this script appears:
      
      WARNING: could not find objcopy version or version is less than 2.17.
              Local function references are disabled.
      
      The check_objcopy() function in scripts/recordmcount.pl is set up to
      parse GNU objcopy's version string, not llvm-objcopy's, which triggers
      the warning.
      
      Commit 799c4341 ("kbuild: thin archives make default for all archs")
      made binutils 2.20 mandatory and commit ba64beb1 ("kbuild: check the
      minimum assembler version in Kconfig") enforces this at configuration
      time so just remove check_objcopy() and $can_use_local instead, assuming
      --globalize-symbol is always available.
      
      llvm-objcopy has supported --globalize-symbol since LLVM 7.0.0 in 2018
      and the minimum version for building the kernel with LLVM is 10.0.1 so
      there is no issue introduced:
      
      Link: https://github.com/llvm/llvm-project/commit/ee5be798dae30d5f9414b01f76ff807edbc881aa
      Link: https://lkml.kernel.org/r/20210802210307.3202472-1-nathan@kernel.org
      
      
      
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      b18b851b
  15. Jul 21, 2021
  16. Jul 19, 2021
    • Reiner Huober's avatar
      module: combine constructors in module linker script · 4c5afb74
      Reiner Huober authored
      
      The constructor code for modules must be aware of init code inside
      different sections.
      
      Newer GCC compilers write constructors in more than one section,
      e.g. ".ctors.65435". These must be combined into a single
      ".ctors" section. In the module loader, only the ".ctors" section
      is searched and the constructors therein are initialized, when
      CONFIG_CONSTRUCTORS=y is set. Other constructors are ignored.
      
      This change combines all ".ctors.*" and the ".ctors" section, if any,
      in <module>.ko into a single ."ctors" section.
      
      For code coverage in GCC, this is necessary to show the
      code coverage for modules, since code coverage uses such
      constructors when initializing a module in newer version of GCC.
      
      Signed-off-by: default avatarReiner Huober <reiner.huober@nokia.com>
      Signed-off-by: default avatarJessica Yu <jeyu@kernel.org>
      4c5afb74
  17. Jul 18, 2021
    • Lecopzer Chen's avatar
      Kbuild: lto: fix module versionings mismatch in GNU make 3.X · 1d11053d
      Lecopzer Chen authored
      When building modules(CONFIG_...=m), I found some of module versions
      are incorrect and set to 0.
      This can be found in build log for first clean build which shows
      
      WARNING: EXPORT symbol "XXXX" [drivers/XXX/XXX.ko] version generation failed,
      symbol will not be versioned.
      
      But in second build(incremental build), the WARNING disappeared and the
      module version becomes valid CRC and make someone who want to change
      modules without updating kernel image can't insert their modules.
      
      The problematic code is
      +	$(foreach n, $(filter-out FORCE,$^),				\
      +		$(if $(wildcard $(n).symversions),			\
      +			; cat $(n).symversions >> $@.symversions))
      
      For example:
        rm -f fs/notify/built-in.a.symversions    ; rm -f fs/notify/built-in.a; \
      llvm-ar cDPrST fs/notify/built-in.a fs/notify/fsnotify.o \
      fs/notify/notification.o fs/notify/group.o ...
      
      `foreach n` shows nothing to `cat` into $(n).symversions because
      `if $(wildcard $(n).symversions)` return nothing, but actually
      they do exist during this line was executed.
      
      -rw-r--r-- 1 root root 168580 Jun 13 19:10 fs/notify/fsnotify.o
      -rw-r--r-- 1 root root    111 Jun 13 19:10 fs/notify/fsnotify.o.symversions
      
      The reason is the $(n).symversions are generated at runtime, but
      Makefile wildcard function expends and checks the file exist or not
      during parsing the Makefile.
      
      Thus fix this by use `test` shell command to check the file
      existence in runtime.
      
      Rebase from both:
      1. [https://lore.kernel.org/lkml/20210616080252.32046-1-lecopzer.chen@mediatek.com/]
      2. [https://lore.kernel.org/lkml/20210702032943.7865-1-lecopzer.chen@mediatek.com/
      
      ]
      
      Fixes: 38e89184 ("kbuild: lto: fix module versioning")
      Co-developed-by: default avatarSami Tolvanen <samitolvanen@google.com>
      Signed-off-by: default avatarLecopzer Chen <lecopzer.chen@mediatek.com>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      1d11053d
    • Mikulas Patocka's avatar
      scripts/setlocalversion: fix a bug when LOCALVERSION is empty · 5df99bec
      Mikulas Patocka authored
      
      The commit 042da426 ("scripts/setlocalversion: simplify the short
      version part") reduces indentation. Unfortunately, it also changes behavior
      in a subtle way - if the user has empty "LOCALVERSION" variable, the plus
      sign is appended to the kernel version. It wasn't appended before.
      
      This patch reverts to the old behavior - we append the plus sign only if
      the LOCALVERSION variable is not set.
      
      Fixes: 042da426 ("scripts/setlocalversion: simplify the short version part")
      Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      5df99bec
Loading