1. 13 Dec, 2022 5 commits
    • Linus Torvalds's avatar
      Merge tag 'linux-kselftest-kunit-next-6.2-rc1' of... · e2ed78d5
      Linus Torvalds authored
      Merge tag 'linux-kselftest-kunit-next-6.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
      
      Pull KUnit updates from Shuah Khan:
       "Several enhancements, fixes, clean-ups, documentation updates,
        improvements to logging and KTAP compliance of KUnit test output:
      
         - log numbers in decimal and hex
      
         - parse KTAP compliant test output
      
         - allow conditionally exposing static symbols to tests when KUNIT is
           enabled
      
         - make static symbols visible during kunit testing
      
         - clean-ups to remove unused structure definition"
      
      * tag 'linux-kselftest-kunit-next-6.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: (29 commits)
        Documentation: dev-tools: Clarify requirements for result description
        apparmor: test: make static symbols visible during kunit testing
        kunit: add macro to allow conditionally exposing static symbols to tests
        kunit: tool: make parser preserve whitespace when printing test log
        Documentation: kunit: Fix "How Do I Use This" / "Next Steps" sections
        kunit: tool: don't include KTAP headers and the like in the test log
        kunit: improve KTAP compliance of KUnit test output
        kunit: tool: parse KTAP compliant test output
        mm: slub: test: Use the kunit_get_current_test() function
        kunit: Use the static key when retrieving the current test
        kunit: Provide a static key to check if KUnit is actively running tests
        kunit: tool: make --json do nothing if --raw_ouput is set
        kunit: tool: tweak error message when no KTAP found
        kunit: remove KUNIT_INIT_MEM_ASSERTION macro
        Documentation: kunit: Remove redundant 'tips.rst' page
        Documentation: KUnit: reword description of assertions
        Documentation: KUnit: make usage.rst a superset of tips.rst, remove duplication
        kunit: eliminate KUNIT_INIT_*_ASSERT_STRUCT macros
        kunit: tool: remove redundant file.close() call in unit test
        kunit: tool: unit tests all check parser errors, standardize formatting a bit
        ...
      e2ed78d5
    • Linus Torvalds's avatar
      Merge tag 'linux-kselftest-next-6.2-rc1' of... · 23a68d14
      Linus Torvalds authored
      Merge tag 'linux-kselftest-next-6.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
      
      Pull Kselftest updates from Shuah Khan:
       "Several fixes and enhancements to existing tests and a few new tests:
      
         - add new amd-pstate tests and fix and enhance existing ones
      
         - add new watchdog tests and enhance existing ones to improve
           coverage
      
         - fixes to ftrace, splice_read, rtc, and efivars tests
      
         - fixes to handle egrep obsolescence in the latest grep release
      
         - miscellaneous spelling and SPDX fixes"
      
      * tag 'linux-kselftest-next-6.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: (24 commits)
        selftests/ftrace: Use long for synthetic event probe test
        selftests/tpm2: Split async tests call to separate shell script runner
        selftests: splice_read: Fix sysfs read cases
        selftests: ftrace: Use "grep -E" instead of "egrep"
        selftests: gpio: Use "grep -E" instead of "egrep"
        selftests: kselftest_deps: Use "grep -E" instead of "egrep"
        selftests/efivarfs: Add checking of the test return value
        cpufreq: amd-pstate: fix spdxcheck warnings for amd-pstate-ut.c
        selftests: rtc: skip when RTC is not present
        selftests/ftrace: event_triggers: wait longer for test_event_enable
        selftests/vDSO: Add riscv getcpu & gettimeofday test
        Documentation: amd-pstate: Add tbench and gitsource test introduction
        selftests: amd-pstate: Trigger gitsource benchmark and test cpus
        selftests: amd-pstate: Trigger tbench benchmark and test cpus
        selftests: amd-pstate: Split basic.sh into run.sh and basic.sh.
        selftests: amd-pstate: Rename amd-pstate-ut.sh to basic.sh.
        selftests/ftrace: Convert tracer tests to use 'requires' to specify program dependency
        selftests/ftrace: Add check for ping command for trigger tests
        selftests/watchdog: Fix spelling mistake "Temeprature" -> "Temperature"
        selftests/watchdog: add test for WDIOC_GETTEMP
        ...
      23a68d14
    • Linus Torvalds's avatar
      Merge tag 'random-6.2-rc1-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/crng/random · 268325bd
      Linus Torvalds authored
      Pull random number generator updates from Jason Donenfeld:
      
       - Replace prandom_u32_max() and various open-coded variants of it,
         there is now a new family of functions that uses fast rejection
         sampling to choose properly uniformly random numbers within an
         interval:
      
             get_random_u32_below(ceil) - [0, ceil)
             get_random_u32_above(floor) - (floor, U32_MAX]
             get_random_u32_inclusive(floor, ceil) - [floor, ceil]
      
         Coccinelle was used to convert all current users of
         prandom_u32_max(), as well as many open-coded patterns, resulting in
         improvements throughout the tree.
      
         I'll have a "late" 6.1-rc1 pull for you that removes the now unused
         prandom_u32_max() function, just in case any other trees add a new
         use case of it that needs to converted. According to linux-next,
         there may be two trivial cases of prandom_u32_max() reintroductions
         that are fixable with a 's/.../.../'. So I'll have for you a final
         conversion patch doing that alongside the removal patch during the
         second week.
      
         This is a treewide change that touches many files throughout.
      
       - More consistent use of get_random_canary().
      
       - Updates to comments, documentation, tests, headers, and
         simplification in configuration.
      
       - The arch_get_random*_early() abstraction was only used by arm64 and
         wasn't entirely useful, so this has been replaced by code that works
         in all relevant contexts.
      
       - The kernel will use and manage random seeds in non-volatile EFI
         variables, refreshing a variable with a fresh seed when the RNG is
         initialized. The RNG GUID namespace is then hidden from efivarfs to
         prevent accidental leakage.
      
         These changes are split into random.c infrastructure code used in the
         EFI subsystem, in this pull request, and related support inside of
         EFISTUB, in Ard's EFI tree. These are co-dependent for full
         functionality, but the order of merging doesn't matter.
      
       - Part of the infrastructure added for the EFI support is also used for
         an improvement to the way vsprintf initializes its siphash key,
         replacing an sleep loop wart.
      
       - The hardware RNG framework now always calls its correct random.c
         input function, add_hwgenerator_randomness(), rather than sometimes
         going through helpers better suited for other cases.
      
       - The add_latent_entropy() function has long been called from the fork
         handler, but is a no-op when the latent entropy gcc plugin isn't
         used, which is fine for the purposes of latent entropy.
      
         But it was missing out on the cycle counter that was also being mixed
         in beside the latent entropy variable. So now, if the latent entropy
         gcc plugin isn't enabled, add_latent_entropy() will expand to a call
         to add_device_randomness(NULL, 0), which adds a cycle counter,
         without the absent latent entropy variable.
      
       - The RNG is now reseeded from a delayed worker, rather than on demand
         when used. Always running from a worker allows it to make use of the
         CPU RNG on platforms like S390x, whose instructions are too slow to
         do so from interrupts. It also has the effect of adding in new inputs
         more frequently with more regularity, amounting to a long term
         transcript of random values. Plus, it helps a bit with the upcoming
         vDSO implementation (which isn't yet ready for 6.2).
      
       - The jitter entropy algorithm now tries to execute on many different
         CPUs, round-robining, in hopes of hitting even more memory latencies
         and other unpredictable effects. It also will mix in a cycle counter
         when the entropy timer fires, in addition to being mixed in from the
         main loop, to account more explicitly for fluctuations in that timer
         firing. And the state it touches is now kept within the same cache
         line, so that it's assured that the different execution contexts will
         cause latencies.
      
      * tag 'random-6.2-rc1-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/crng/random: (23 commits)
        random: include <linux/once.h> in the right header
        random: align entropy_timer_state to cache line
        random: mix in cycle counter when jitter timer fires
        random: spread out jitter callback to different CPUs
        random: remove extraneous period and add a missing one in comments
        efi: random: refresh non-volatile random seed when RNG is initialized
        vsprintf: initialize siphash key using notifier
        random: add back async readiness notifier
        random: reseed in delayed work rather than on-demand
        random: always mix cycle counter in add_latent_entropy()
        hw_random: use add_hwgenerator_randomness() for early entropy
        random: modernize documentation comment on get_random_bytes()
        random: adjust comment to account for removed function
        random: remove early archrandom abstraction
        random: use random.trust_{bootloader,cpu} command line option only
        stackprotector: actually use get_random_canary()
        stackprotector: move get_random_canary() into stackprotector.h
        treewide: use get_random_u32_inclusive() when possible
        treewide: use get_random_u32_{above,below}() instead of manual loop
        treewide: use get_random_u32_below() instead of deprecated function
        ...
      268325bd
    • Linus Torvalds's avatar
      Merge branch 'for-6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/dennis/percpu · ca1443c7
      Linus Torvalds authored
      Pull percpu updates from Dennis Zhou:
       "Baoquan was nice enough to run some clean ups for percpu"
      
      * 'for-6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/dennis/percpu:
        mm/percpu: remove unused PERCPU_DYNAMIC_EARLY_SLOTS
        mm/percpu.c: remove the lcm code since block size is fixed at page size
        mm/percpu: replace the goto with break
        mm/percpu: add comment to state the empty populated pages accounting
        mm/percpu: Update the code comment when creating new chunk
        mm/percpu: use list_first_entry_or_null in pcpu_reclaim_populated()
        mm/percpu: remove unused pcpu_map_extend_chunks
      ca1443c7
    • Linus Torvalds's avatar
      Merge tag 'livepatching-for-6.2' of... · e1a1ccef
      Linus Torvalds authored
      Merge tag 'livepatching-for-6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/livepatching/livepatching
      
      Pull livepatching update from Petr Mladek:
      
       - code cleanup
      
      * tag 'livepatching-for-6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/livepatching/livepatching:
        livepatch: Move the result-invariant calculation out of the loop
      e1a1ccef
  2. 12 Dec, 2022 35 commits
    • Linus Torvalds's avatar
      Merge tag 'cgroup-for-6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup · a312a8cc
      Linus Torvalds authored
      Pull cgroup updates from Tejun Heo:
       "Nothing too interesting:
      
         - Add CONFIG_DEBUG_GROUP_REF which makes cgroup refcnt operations
           kprobable
      
         - A couple cpuset optimizations
      
         - Other misc changes including doc and test updates"
      
      * tag 'cgroup-for-6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup:
        cgroup: remove rcu_read_lock()/rcu_read_unlock() in critical section of spin_lock_irq()
        cgroup/cpuset: Improve cpuset_css_alloc() description
        kselftest/cgroup: Add cleanup() to test_cpuset_prs.sh
        cgroup/cpuset: Optimize cpuset_attach() on v2
        cgroup/cpuset: Skip spread flags update on v2
        kselftest/cgroup: Fix gathering number of CPUs
        cgroup: cgroup refcnt functions should be exported when CONFIG_DEBUG_CGROUP_REF
        cgroup: Implement DEBUG_CGROUP_REF
      a312a8cc
    • Linus Torvalds's avatar
      Merge tag 'sched-core-2022-12-12' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · bf57ae21
      Linus Torvalds authored
      Pull scheduler updates from Ingo Molnar:
      
       - Implement persistent user-requested affinity: introduce
         affinity_context::user_mask and unconditionally preserve the
         user-requested CPU affinity masks, for long-lived tasks to better
         interact with cpusets & CPU hotplug events over longer timespans,
         without destroying the original affinity intent if the underlying
         topology changes.
      
       - Uclamp updates: fix relationship between uclamp and fits_capacity()
      
       - PSI fixes
      
       - Misc fixes & updates
      
      * tag 'sched-core-2022-12-12' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        sched: Clear ttwu_pending after enqueue_task()
        sched/psi: Use task->psi_flags to clear in CPU migration
        sched/psi: Stop relying on timer_pending() for poll_work rescheduling
        sched/psi: Fix avgs_work re-arm in psi_avgs_work()
        sched/psi: Fix possible missing or delayed pending event
        sched: Always clear user_cpus_ptr in do_set_cpus_allowed()
        sched: Enforce user requested affinity
        sched: Always preserve the user requested cpumask
        sched: Introduce affinity_context
        sched: Add __releases annotations to affine_move_task()
        sched/fair: Check if prev_cpu has highest spare cap in feec()
        sched/fair: Consider capacity inversion in util_fits_cpu()
        sched/fair: Detect capacity inversion
        sched/uclamp: Cater for uclamp in find_energy_efficient_cpu()'s early exit condition
        sched/uclamp: Make cpu_overutilized() use util_fits_cpu()
        sched/uclamp: Make asym_fits_capacity() use util_fits_cpu()
        sched/uclamp: Make select_idle_capacity() use util_fits_cpu()
        sched/uclamp: Fix fits_capacity() check in feec()
        sched/uclamp: Make task_fits_capacity() use util_fits_cpu()
        sched/uclamp: Fix relationship between uclamp and migration margin
      bf57ae21
    • Linus Torvalds's avatar
      Merge tag 'perf-core-2022-12-12' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · add76959
      Linus Torvalds authored
      Pull perf events updates from Ingo Molnar:
      
       - Thoroughly rewrite the data structures that implement perf task
         context handling, with the goal of fixing various quirks and
         unfeatures both in already merged, and in upcoming proposed code.
      
         The old data structure is the per task and per cpu
         perf_event_contexts:
      
               task_struct::perf_events_ctxp[] <-> perf_event_context <-> perf_cpu_context
                    ^                                 |    ^     |           ^
                    `---------------------------------'    |     `--> pmu ---'
                                                           v           ^
                                                      perf_event ------'
      
         In this new design this is replaced with a single task context and a
         single CPU context, plus intermediate data-structures:
      
               task_struct::perf_event_ctxp -> perf_event_context <- perf_cpu_context
                    ^                           |   ^ ^
                    `---------------------------'   | |
                                                    | |    perf_cpu_pmu_context <--.
                                                    | `----.    ^                  |
                                                    |      |    |                  |
                                                    |      v    v                  |
                                                    | ,--> perf_event_pmu_context  |
                                                    | |                            |
                                                    | |                            |
                                                    v v                            |
                                               perf_event ---> pmu ----------------'
      
         [ See commit bd275681 for more details. ]
      
         This rewrite was developed by Peter Zijlstra and Ravi Bangoria.
      
       - Optimize perf_tp_event()
      
       - Update the Intel uncore PMU driver, extending it with UPI topology
         discovery on various hardware models.
      
       - Misc fixes & cleanups
      
      * tag 'perf-core-2022-12-12' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (25 commits)
        perf/x86/intel/uncore: Fix reference count leak in __uncore_imc_init_box()
        perf/x86/intel/uncore: Fix reference count leak in snr_uncore_mmio_map()
        perf/x86/intel/uncore: Fix reference count leak in hswep_has_limit_sbox()
        perf/x86/intel/uncore: Fix reference count leak in sad_cfg_iio_topology()
        perf/x86/intel/uncore: Make set_mapping() procedure void
        perf/x86/intel/uncore: Update sysfs-devices-mapping file
        perf/x86/intel/uncore: Enable UPI topology discovery for Sapphire Rapids
        perf/x86/intel/uncore: Enable UPI topology discovery for Icelake Server
        perf/x86/intel/uncore: Get UPI NodeID and GroupID
        perf/x86/intel/uncore: Enable UPI topology discovery for Skylake Server
        perf/x86/intel/uncore: Generalize get_topology() for SKX PMUs
        perf/x86/intel/uncore: Disable I/O stacks to PMU mapping on ICX-D
        perf/x86/intel/uncore: Clear attr_update properly
        perf/x86/intel/uncore: Introduce UPI topology type
        perf/x86/intel/uncore: Generalize IIO topology support
        perf/core: Don't allow grouping events from different hw pmus
        perf/amd/ibs: Make IBS a core pmu
        perf: Fix function pointer case
        perf/x86/amd: Remove the repeated declaration
        perf: Fix possible memleak in pmu_dev_alloc()
        ...
      add76959
    • Linus Torvalds's avatar
      Merge tag 'locking-core-2022-12-12' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 617fe4fa
      Linus Torvalds authored
      Pull locking updates from Ingo Molnar:
       "Two changes in this cycle:
      
         - a micro-optimization in static_key_slow_inc_cpuslocked()
      
         - fix futex death-notification wakeup bug"
      
      * tag 'locking-core-2022-12-12' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        futex: Resend potentially swallowed owner death notification
        jump_label: Use atomic_try_cmpxchg() in static_key_slow_inc_cpuslocked()
      617fe4fa
    • Linus Torvalds's avatar
      Merge tag 'x86_alternatives_for_v6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 2f60f830
      Linus Torvalds authored
      Pull x86 alternative update from Borislav Petkov:
       "A single alternatives patching fix for modules:
      
         - Have alternatives patch the same sections in modules as in vmlinux"
      
      * tag 'x86_alternatives_for_v6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        x86/alternative: Consistently patch SMP locks in vmlinux and modules
      2f60f830
    • Linus Torvalds's avatar
      Merge tag 'ras_core_for_v6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 9196a0ba
      Linus Torvalds authored
      Pull x86 RAS updates from Borislav Petkov:
      
       - Fix confusing output from /sys/kernel/debug/ras/daemon_active
      
       - Add another MCE severity error case to the Intel error severity table
         to promote UC and AR errors to panic severity and remove the
         corresponding code condition doing that.
      
       - Make sure the thresholding and deferred error interrupts on AMD SMCA
         systems clear the all registers reporting an error so that there are
         no multiple errors logged for the same event
      
      * tag 'ras_core_for_v6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        RAS: Fix return value from show_trace()
        x86/mce: Use severity table to handle uncorrected errors in kernel
        x86/MCE/AMD: Clear DFR errors found in THR handler
      9196a0ba
    • Linus Torvalds's avatar
      Merge tag 'edac_updates_for_6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/ras/ras · 7adcadb9
      Linus Torvalds authored
      Pull EDAC updates from Borislav Petkov:
      
       - Make ghes_edac a simple module like the rest of the EDAC drivers and
         drop the forced built-in only configuration by disentangling it from
         GHES (Jia He)
      
       - The usual small cleanups and improvements all over EDAC land
      
      * tag 'edac_updates_for_6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/ras/ras:
        EDAC/i10nm: fix refcount leak in pci_get_dev_wrapper()
        EDAC/i5400: Fix typo in comment: vaious -> various
        EDAC/mc_sysfs: Increase legacy channel support to 12
        MAINTAINERS: Make Mauro EDAC reviewer
        MAINTAINERS: Make Manivannan Sadhasivam the maintainer of qcom_edac
        EDAC/igen6: Return the correct error type when not the MC owner
        apei/ghes: Use xchg_release() for updating new cache slot instead of cmpxchg()
        EDAC: Check for GHES preference in the chipset-specific EDAC drivers
        EDAC/ghes: Make ghes_edac a proper module
        EDAC/ghes: Prepare to make ghes_edac a proper module
        EDAC/ghes: Add a notifier for reporting memory errors
        efi/cper: Export several helpers for ghes_edac to use
        EDAC/i5000: Mark as BROKEN
      7adcadb9
    • Linus Torvalds's avatar
      Merge tag 'x86_fpu_for_6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 40deb5e4
      Linus Torvalds authored
      Pull x86 fpu updates from Dave Hansen:
       "There are two little fixes in here, one to give better XSAVE warnings
        and another to address some undefined behavior in offsetof().
      
        There is also a collection of patches to fix some issues with ptrace
        and the protection keys register (PKRU). PKRU is a real oddity because
        it is exposed in the XSAVE-related ABIs, but it is generally managed
        without using XSAVE in the kernel. This fix thankfully came with a
        selftest to ward off future regressions.
      
        Summary:
      
         - Clarify XSAVE consistency warnings
      
         - Fix up ptrace interface to protection keys register (PKRU)
      
         - Avoid undefined compiler behavior with TYPE_ALIGN"
      
      * tag 'x86_fpu_for_6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        x86/fpu: Use _Alignof to avoid undefined behavior in TYPE_ALIGN
        selftests/vm/pkeys: Add a regression test for setting PKRU through ptrace
        x86/fpu: Emulate XRSTOR's behavior if the xfeatures PKRU bit is not set
        x86/fpu: Allow PKRU to be (once again) written by ptrace.
        x86/fpu: Add a pkru argument to copy_uabi_to_xstate()
        x86/fpu: Add a pkru argument to copy_uabi_from_kernel_to_xstate().
        x86/fpu: Take task_struct* in copy_sigframe_from_user_to_xstate()
        x86/fpu/xstate: Fix XSTATE_WARN_ON() to emit relevant diagnostics
      40deb5e4
    • Linus Torvalds's avatar
      Merge tag 'x86_splitlock_for_6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 1cab145a
      Linus Torvalds authored
      Pull x86 splitlock updates from Dave Hansen:
       "Add a sysctl to control the split lock misery mode.
      
        This enables users to reduce the penalty inflicted on split lock
        users. There are some proprietary, binary-only games which became
        entirely unplayable with the old penalty.
      
        Anyone opting into the new mode is, of course, more exposed to the DoS
        nasitness inherent with split locks, but they can play their games
        again"
      
      * tag 'x86_splitlock_for_6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        x86/split_lock: Add sysctl to control the misery mode
      1cab145a
    • Linus Torvalds's avatar
      Merge tag 'x86_cache_for_6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 287f037d
      Linus Torvalds authored
      Pull x86 cache resource control updates from Dave Hansen:
       "These declare the resource control (rectrl) MSRs a bit more normally
        and clean up an unnecessary structure member:
      
         - Remove unnecessary arch_has_empty_bitmaps structure memory
      
         - Move rescrtl MSR defines into msr-index.h, like normal MSRs"
      
      * tag 'x86_cache_for_6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        x86/resctrl: Move MSR defines into msr-index.h
        x86/resctrl: Remove arch_has_empty_bitmaps
      287f037d
    • Linus Torvalds's avatar
      Merge tag 'x86_tdx_for_6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · a89ef2aa
      Linus Torvalds authored
      Pull x86 tdx updates from Dave Hansen:
       "This includes a single chunk of new functionality for TDX guests which
        allows them to talk to the trusted TDX module software and obtain an
        attestation report.
      
        This report can then be used to prove the trustworthiness of the guest
        to a third party and get access to things like storage encryption
        keys"
      
      * tag 'x86_tdx_for_6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        selftests/tdx: Test TDX attestation GetReport support
        virt: Add TDX guest driver
        x86/tdx: Add a wrapper to get TDREPORT0 from the TDX Module
      a89ef2aa
    • Linus Torvalds's avatar
      Merge tag 'x86_sgx_for_6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 2da68a77
      Linus Torvalds authored
      Pull x86 sgx updates from Dave Hansen:
       "The biggest deal in this series is support for a new hardware feature
        that allows enclaves to detect and mitigate single-stepping attacks.
      
        There's also a minor performance tweak and a little piece of the
        kmap_atomic() -> kmap_local() transition.
      
        Summary:
      
         - Introduce a new SGX feature (Asynchrounous Exit Notification) for
           bare-metal enclaves and KVM guests to mitigate single-step attacks
      
         - Increase batching to speed up enclave release
      
         - Replace kmap/kunmap_atomic() calls"
      
      * tag 'x86_sgx_for_6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        x86/sgx: Replace kmap/kunmap_atomic() calls
        KVM/VMX: Allow exposing EDECCSSA user leaf function to KVM guest
        x86/sgx: Allow enclaves to use Asynchrounous Exit Notification
        x86/sgx: Reduce delay and interference of enclave release
      2da68a77
    • Linus Torvalds's avatar
      Merge tag 'cxl-for-6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl · c1f0fcd8
      Linus Torvalds authored
      Pull cxl updates from Dan Williams:
       "Compute Express Link (CXL) updates for 6.2.
      
        While it may seem backwards, the CXL update this time around includes
        some focus on CXL 1.x enabling where the work to date had been with
        CXL 2.0 (VH topologies) in mind.
      
        First generation CXL can mostly be supported via BIOS, similar to DDR,
        however it became clear there are use cases for OS native CXL error
        handling and some CXL 3.0 endpoint features can be deployed on CXL 1.x
        hosts (Restricted CXL Host (RCH) topologies). So, this update brings
        RCH topologies into the Linux CXL device model.
      
        In support of the ongoing CXL 2.0+ enabling two new core kernel
        facilities are added.
      
        One is the ability for the kernel to flag collisions between userspace
        access to PCI configuration registers and kernel accesses. This is
        brought on by the PCIe Data-Object-Exchange (DOE) facility, a hardware
        mailbox over config-cycles.
      
        The other is a cpu_cache_invalidate_memregion() API that maps to
        wbinvd_on_all_cpus() on x86. To prevent abuse it is disabled in guest
        VMs and architectures that do not support it yet. The CXL paths that
        need it, dynamic memory region creation and security commands (erase /
        unlock), are disabled when it is not present.
      
        As for the CXL 2.0+ this cycle the subsystem gains support Persistent
        Memory Security commands, error handling in response to PCIe AER
        notifications, and support for the "XOR" host bridge interleave
        algorithm.
      
        Summary:
      
         - Add the cpu_cache_invalidate_memregion() API for cache flushing in
           response to physical memory reconfiguration, or memory-side data
           invalidation from operations like secure erase or memory-device
           unlock.
      
         - Add a facility for the kernel to warn about collisions between
           kernel and userspace access to PCI configuration registers
      
         - Add support for Restricted CXL Host (RCH) topologies (formerly CXL
           1.1)
      
         - Add handling and reporting of CXL errors reported via the PCIe AER
           mechanism
      
         - Add support for CXL Persistent Memory Security commands
      
         - Add support for the "XOR" algorithm for CXL host bridge interleave
      
         - Rework / simplify CXL to NVDIMM interactions
      
         - Miscellaneous cleanups and fixes"
      
      * tag 'cxl-for-6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl: (71 commits)
        cxl/region: Fix memdev reuse check
        cxl/pci: Remove endian confusion
        cxl/pci: Add some type-safety to the AER trace points
        cxl/security: Drop security command ioctl uapi
        cxl/mbox: Add variable output size validation for internal commands
        cxl/mbox: Enable cxl_mbox_send_cmd() users to validate output size
        cxl/security: Fix Get Security State output payload endian handling
        cxl: update names for interleave ways conversion macros
        cxl: update names for interleave granularity conversion macros
        cxl/acpi: Warn about an invalid CHBCR in an existing CHBS entry
        tools/testing/cxl: Require cache invalidation bypass
        cxl/acpi: Fail decoder add if CXIMS for HBIG is missing
        cxl/region: Fix spelling mistake "memergion" -> "memregion"
        cxl/regs: Fix sparse warning
        cxl/acpi: Set ACPI's CXL _OSC to indicate RCD mode support
        tools/testing/cxl: Add an RCH topology
        cxl/port: Add RCD endpoint port enumeration
        cxl/mem: Move devm_cxl_add_endpoint() from cxl_core to cxl_mem
        tools/testing/cxl: Add XOR Math support to cxl_test
        cxl/acpi: Support CXL XOR Interleave Math (CXIMS)
        ...
      c1f0fcd8
    • Linus Torvalds's avatar
      Merge tag 'thermal-6.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm · 691806e9
      Linus Torvalds authored
      Pull thermal control updates from Rafael Wysocki:
       "These include thermal core fixes to protect thermal device operations
        against thermal device removal, other thermal core fixes and updates
        of Intel thermal control drivers.
      
        Specifics:
      
         - Fix race conditions related to thermal device operations that are
           not protected against thermal device removal (Guenter Roeck)
      
         - Fix error code in __thermal_cooling_device_register() (Dan
           Carpenter)
      
         - Validate new cooling device state (coming from user space) in
           cur_state_store() and reuse the max_state value from cooling device
           structure in the sysfs interface (Viresh Kumar)
      
         - Fix some possible name leaks in error paths in the thermal control
           core code (Yang Yingliang)
      
         - Detect TCC lock bit set in the intel_tcc_cooling driver and make it
           refuse to update the TCC offset in that case (Zhang Rui)
      
         - Add TCC cooling support for RaptorLake-S (Zhang Rui)
      
         - Prevent accidental clearing of HFI status by one of the other
           drivers using the same status register (Srinivas Pandruvada)
      
         - Protect clearing of thermal status bits in Intel thermal control
           drivers (Srinivas Pandruvada)
      
         - Allow the HFI thermal control driver to ACK an HFI event for the
           previously observed timestamp (Srinivas Pandruvada)
      
         - Remove a pointless die_id check from the HFI thermal driver and
           adjust the definition a data structure used by it (Ricardo Neri)"
      
      * tag 'thermal-6.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
        thermal: intel: hfi: Remove a pointless die_id check
        thermal: core: fix some possible name leaks in error paths
        thermal: intel: hfi: ACK HFI for the same timestamp
        thermal: intel: Protect clearing of thermal status bits
        thermal: intel: Prevent accidental clearing of HFI status
        thermal/core: Protect thermal device operations against thermal device removal
        thermal/core: Remove thermal_zone_set_trips()
        thermal/core: Protect sysfs accesses to thermal operations with thermal zone mutex
        thermal/core: Protect hwmon accesses to thermal operations with thermal zone mutex
        thermal/core: Introduce locked version of thermal_zone_device_update
        thermal/core: Move parameter validation from __thermal_zone_get_temp to thermal_zone_get_temp
        thermal/core: Ensure that thermal device is registered in thermal_zone_get_temp
        thermal/core: Delete device under thermal device zone lock
        thermal/core: Destroy thermal zone device mutex in release function
        thermal: intel: intel_tcc_cooling: Add TCC cooling support for RaptorLake-S
        thermal: intel: intel_tcc_cooling: Detect TCC lock bit
        thermal: intel: hfi: Improve the type of hfi_features::nr_table_pages
        thermal/core: fix error code in __thermal_cooling_device_register()
        thermal: sysfs: Reuse cdev->max_state
        thermal: Validate new state in cur_state_store()
      691806e9
    • Linus Torvalds's avatar
      Merge tag 'acpi-6.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm · 456ed864
      Linus Torvalds authored
      Pull ACPI and PNP updates from Rafael Wysocki:
       "These include new code (for instance, support for the FFH address
        space type and support for new firmware data structures in ACPICA),
        some new quirks (mostly related to backlight handling and I2C
        enumeration), a number of fixes and a fair amount of cleanups all
        over.
      
        Specifics:
      
         - Update the ACPICA code in the kernel to the 20221020 upstream
           version and fix a couple of issues in it:
            - Make acpi_ex_load_op() match upstream implementation (Rafael
              Wysocki)
            - Add support for loong_arch-specific APICs in MADT (Huacai Chen)
            - Add support for fixed PCIe wake event (Huacai Chen)
            - Add EBDA pointer sanity checks (Vit Kabele)
            - Avoid accessing VGA memory when EBDA < 1KiB (Vit Kabele)
            - Add CCEL table support to both compiler/disassembler (Kuppuswamy
              Sathyanarayanan)
            - Add a couple of new UUIDs to the known UUID list (Bob Moore)
            - Add support for FFH Opregion special context data (Sudeep
              Holla)
            - Improve warning message for "invalid ACPI name" (Bob Moore)
            - Add support for CXL 3.0 structures (CXIMS & RDPAS) in the CEDT
              table (Alison Schofield)
            - Prepare IORT support for revision E.e (Robin Murphy)
            - Finish support for the CDAT table (Bob Moore)
            - Fix error code path in acpi_ds_call_control_method() (Rafael
              Wysocki)
            - Fix use-after-free in acpi_ut_copy_ipackage_to_ipackage() (Li
              Zetao)
            - Update the version of the ACPICA code in the kernel (Bob Moore)
      
         - Use ZERO_PAGE(0) instead of empty_zero_page in the ACPI device
           enumeration code (Giulio Benetti)
      
         - Change the return type of the ACPI driver remove callback to void
           and update its users accordingly (Dawei Li)
      
         - Add general support for FFH address space type and implement the
           low- level part of it for ARM64 (Sudeep Holla)
      
         - Fix stale comments in the ACPI tables parsing code and make it
           print more messages related to MADT (Hanjun Guo, Huacai Chen)
      
         - Replace invocations of generic library functions with more kernel-
           specific counterparts in the ACPI sysfs interface (Christophe
           JAILLET, Xu Panda)
      
         - Print full name paths of ACPI power resource objects during
           enumeration (Kane Chen)
      
         - Eliminate a compiler warning regarding a missing function prototype
           in the ACPI power management code (Sudeep Holla)
      
         - Fix and clean up the ACPI processor driver (Rafael Wysocki, Li
           Zhong, Colin Ian King, Sudeep Holla)
      
         - Add quirk for the HP Pavilion Gaming 15-cx0041ur to the ACPI EC
           driver (Mia Kanashi)
      
         - Add some mew ACPI backlight handling quirks and update some
           existing ones (Hans de Goede)
      
         - Make the ACPI backlight driver prefer the native backlight control
           over vendor backlight control when possible (Hans de Goede)
      
         - Drop unsetting ACPI APEI driver data on remove (Uwe Kleine-König)
      
         - Use xchg_release() instead of cmpxchg() for updating new GHES cache
           slots (Ard Biesheuvel)
      
         - Clean up the ACPI APEI code (Sudeep Holla, Christophe JAILLET, Jay
           Lu)
      
         - Add new I2C device enumeration quirks for Medion Lifetab S10346 and
           Lenovo Yoga Tab 3 Pro (YT3-X90F) (Hans de Goede)
      
         - Make the ACPI battery driver notify user space about adding new
           battery hooks and removing the existing ones (Armin Wolf)
      
         - Modify the pfr_update and pfr_telemetry drivers to use ACPI_FREE()
           for freeing acpi_object structures to help diagnostics (Wang
           ShaoBo)
      
         - Make the ACPI fan driver use sysfs_emit_at() in its sysfs interface
           code (ye xingchen)
      
         - Fix the _FIF package extraction failure handling in the ACPI fan
           driver (Hanjun Guo)
      
         - Fix the PCC mailbox handling error code path (Huisong Li)
      
         - Avoid using PCC Opregions if there is no platform interrupt
           allocated for this purpose (Huisong Li)
      
         - Use sysfs_emit() instead of scnprintf() in the ACPI PAD driver and
           CPPC library (ye xingchen)
      
         - Fix some kernel-doc issues in the ACPI GSI processing code
           (Xiongfeng Wang)
      
         - Fix name memory leak in pnp_alloc_dev() (Yang Yingliang)
      
         - Do not disable PNP devices on suspend when they cannot be
           re-enabled on resume (Hans de Goede)
      
         - Clean up the ACPI thermal driver a bit (Rafael Wysocki)"
      
      * tag 'acpi-6.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (67 commits)
        ACPI: x86: Add skip i2c clients quirk for Medion Lifetab S10346
        ACPI: APEI: EINJ: Refactor available_error_type_show()
        ACPI: APEI: EINJ: Fix formatting errors
        ACPI: processor: perflib: Adjust acpi_processor_notify_smm() return value
        ACPI: processor: perflib: Rearrange acpi_processor_notify_smm()
        ACPI: processor: perflib: Rearrange unregistration routine
        ACPI: processor: perflib: Drop redundant parentheses
        ACPI: processor: perflib: Adjust white space
        ACPI: processor: idle: Drop unnecessary statements and parens
        ACPI: thermal: Adjust critical.flags.valid check
        ACPI: fan: Convert to use sysfs_emit_at() API
        ACPICA: Fix use-after-free in acpi_ut_copy_ipackage_to_ipackage()
        ACPI: battery: Call power_supply_changed() when adding hooks
        ACPI: use sysfs_emit() instead of scnprintf()
        ACPI: x86: Add skip i2c clients quirk for Lenovo Yoga Tab 3 Pro (YT3-X90F)
        ACPI: APEI: Remove a useless include
        PNP: Do not disable devices on suspend when they cannot be re-enabled on resume
        ACPI: processor: Silence missing prototype warnings
        ACPI: processor_idle: Silence missing prototype warnings
        ACPI: PM: Silence missing prototype warning
        ...
      456ed864
    • Linus Torvalds's avatar
      Merge tag 'pm-6.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm · 045e222d
      Linus Torvalds authored
      Pull power management updates from Rafael Wysocki:
       "These include two new drivers (cpufreq driver for Apple SoC CPU
        P-states and the SCMI Powercap based power capping driver), other new
        hardware support and driver extensions (Qualcomm cpufreq driver and
        its DT bindings, TI cpufreq driver, intel_pstate, intel-uncore-freq),
        a bunch of fixes and cleanups all over and a cpupower utility update
        including new features related to RAPL support.
      
        Specifics:
      
         - Fix nasty and hard to debug race condition introduced by mistake in
           the runtime PM core code and clean up that code somewhat on top of
           the fix (Rafael Wysocki)
      
         - Generalize of_perf_domain_get_sharing_cpumask phandle format
           (Hector Martin)
      
         - Add new cpufreq driver for Apple SoC CPU P-states (Hector Martin)
      
         - Update Qualcomm cpufreq driver (Manivannan Sadhasivam, Chen Hui):
            - CPU clock provider support
            - Generic cleanups or reorganization
            - Potential memleak fix
            - Fix of the return value of cpufreq_driver->get()
      
         - Update Qualcomm cpufreq driver's DT bindings (Manivannan
           Sadhasivam, Rob Herring, Melody Olvera):
            - Support for CPU clock provider
            - Missing cache-related properties fixes
            - Support for QDU1000/QRU1000
      
         - Add support for ti,am625 SoC and enable build of ti-cpufreq for
           ARCH_K3 (Dave Gerlach, and Vibhore Vardhan)
      
         - Use flexible array to simplify memory allocation in the tegra186
           cpufreq driver (Christophe JAILLET)
      
         - Convert cpufreq statistics code to use sysfs_emit_at() (ye
           xingchen)
      
         - Allow intel_pstate to use no-HWP mode on Sapphire Rapids (Giovanni
           Gherdovich)
      
         - Add missing pci_dev_put() to the amd_freq_sensitivity cpufreq
           driver (Xiongfeng Wang)
      
         - Initialize the kobj_unregister completion before calling
           kobject_init_and_add() in the cpufreq core code (Yongqiang Liu)
      
         - Defer setting boost MSRs in the ACPI cpufreq driver (Stuart Hayes,
           Nathan Chancellor)
      
         - Make intel_pstate accept initial EPP value of 0x80 (Srinivas
           Pandruvada)
      
         - Make read-only array sys_clk_src in the SPEAr cpufreq driver static
           (Colin Ian King)
      
         - Make array speeds in the longhaul cpufreq driver static (Colin Ian
           King)
      
         - Use str_enabled_disabled() helper in the ACPI cpufreq driver (Andy
           Shevchenko)
      
         - Drop a reference to CVS from cpufreq documentation (Conghui Wang)
      
         - Improve kernel messages printed by the PSCI cpuidle driver (Ulf
           Hansson)
      
         - Make the DT cpuidle driver return the correct number of parsed idle
           states, clean it up and clarify a comment in it (Ulf Hansson)
      
         - Modify the tasks freezing code to avoid using pr_cont() and refine
           an error message printed by it (Rafael Wysocki)
      
         - Make the hibernation core code complain about memory map mismatches
           during resume to help diagnostics (Xueqin Luo)
      
         - Fix mistake in a kerneldoc comment in the hibernation code
           (xiongxin)
      
         - Reverse the order of performance and enabling operations in the
           generic power domains code (Abel Vesa)
      
         - Power off[on] domains in hibernate .freeze[thaw]_noirq hook of in
           the generic power domains code (Abel Vesa)
      
         - Consolidate genpd_restore_noirq() and genpd_resume_noirq() (Shawn
           Guo)
      
         - Pass generic PM noirq hooks to genpd_finish_suspend() (Shawn Guo)
      
         - Drop generic power domain status manipulation during hibernate
           restore (Shawn Guo)
      
         - Fix compiler warnings with make W=1 in the idle_inject power
           capping driver (Srinivas Pandruvada)
      
         - Use kstrtobool() instead of strtobool() in the power capping sysfs
           interface (Christophe JAILLET)
      
         - Add SCMI Powercap based power capping driver (Cristian Marussi)
      
         - Add Emerald Rapids support to the intel-uncore-freq driver (Artem
           Bityutskiy)
      
         - Repair slips in kernel-doc comments in the generic notifier code
           (Lukas Bulwahn)
      
         - Fix several DT issues in the OPP library reorganize code around
           opp-microvolt-<named> DT property (Viresh Kumar)
      
         - Allow any of opp-microvolt, opp-microamp, or opp-microwatt
           properties to be present without the others present (James
           Calligeros)
      
         - Fix clock-latency-ns property in DT example (Serge Semin)
      
         - Add a private governor_data for devfreq governors (Kant Fan)
      
         - Reorganize devfreq code to use device_match_of_node() and
           devm_platform_get_and_ioremap_resource() instead of open coding
           them (ye xingchen, Minghao Chi)
      
         - Make cpupower choose base_cpu to display default cpupower details
           instead of picking CPU 0 (Saket Kumar Bhaskar)
      
         - Add Georgian translation to cpupower documentation (Zurab
           Kargareteli)
      
         - Introduce powercap intel-rapl library, powercap-info command, and
           RAPL monitor into cpupower (Thomas Renninger)"
      
      * tag 'pm-6.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (64 commits)
        PM: runtime: Adjust white space in the core code
        cpufreq: Remove CVS version control contents from documentation
        cpufreq: stats: Convert to use sysfs_emit_at() API
        cpufreq: ACPI: Only set boost MSRs on supported CPUs
        PM: sleep: Refine error message in try_to_freeze_tasks()
        PM: sleep: Avoid using pr_cont() in the tasks freezing code
        PM: runtime: Relocate rpm_callback() right after __rpm_callback()
        PM: runtime: Do not call __rpm_callback() from rpm_idle()
        PM / devfreq: event: use devm_platform_get_and_ioremap_resource()
        PM / devfreq: event: Use device_match_of_node()
        PM / devfreq: Use device_match_of_node()
        powercap: idle_inject: Fix warnings with make W=1
        PM: hibernate: Complain about memory map mismatches during resume
        dt-bindings: cpufreq: cpufreq-qcom-hw: Add QDU1000/QRU1000 cpufreq
        cpufreq: tegra186: Use flexible array to simplify memory allocation
        cpupower: rapl monitor - shows the used power consumption in uj for each rapl domain
        cpupower: Introduce powercap intel-rapl library and powercap-info command
        cpupower: Add Georgian translation
        cpufreq: intel_pstate: Add Sapphire Rapids support in no-HWP mode
        cpufreq: amd_freq_sensitivity: Add missing pci_dev_put()
        ...
      045e222d
    • Mark Brown's avatar
      Documentation: dev-tools: Clarify requirements for result description · 054be257
      Mark Brown authored
      Currently the KTAP specification says that a test result line is
      
        <result> <number> [<description>][ # [<directive>] [<diagnostic data>]]
      
      and the description of a test can be "any sequence of words
      (can't include #)" which specifies that there may be more than
      one word but does not specify anything other than those words
      which might be used to separate the words which probably isn't
      what we want.  Given that practically we have tests using a range
      of separators for words including combinations of spaces and
      combinations of other symbols like underscores or punctuation
      let's just clarify that the description can contain any character
      other than # (marking the start of the directive/diagnostic) or
      newline (marking the end of this test result).
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Reviewed-by: default avatarDavid Gow <davidgow@google.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      054be257
    • Rae Moar's avatar
      apparmor: test: make static symbols visible during kunit testing · b11e51dd
      Rae Moar authored
      Use macros, VISIBLE_IF_KUNIT and EXPORT_SYMBOL_IF_KUNIT, to allow
      static symbols to be conditionally set to be visible during
      apparmor_policy_unpack_test, which removes the need to include the testing
      file in the implementation file.
      
      Change the namespace of the symbols that are now conditionally visible (by
      adding the prefix aa_) to avoid confusion with symbols of the same name.
      
      Allow the test to be built as a module and namespace the module name from
      policy_unpack_test to apparmor_policy_unpack_test to improve clarity of
      the module name.
      
      Provide an example of how static symbols can be dealt with in testing.
      Signed-off-by: default avatarRae Moar <rmoar@google.com>
      Reviewed-by: default avatarDavid Gow <davidgow@google.com>
      Acked-by: default avatarJohn Johansen <john.johansen@canonical.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      b11e51dd
    • Rae Moar's avatar
      kunit: add macro to allow conditionally exposing static symbols to tests · 9c988fae
      Rae Moar authored
      Create two macros:
      
      VISIBLE_IF_KUNIT - A macro that sets symbols to be static if CONFIG_KUNIT
      is not enabled. Otherwise if CONFIG_KUNIT is enabled there is no change to
      the symbol definition.
      
      EXPORT_SYMBOL_IF_KUNIT(symbol) - Exports symbol into
      EXPORTED_FOR_KUNIT_TESTING namespace only if CONFIG_KUNIT is enabled. Must
      use MODULE_IMPORT_NS(EXPORTED_FOR_KUNIT_TESTING) in test file in order to
      use symbols.
      Signed-off-by: default avatarRae Moar <rmoar@google.com>
      Reviewed-by: default avatarJohn Johansen <john.johansen@canonical.com>
      Reviewed-by: default avatarDavid Gow <davidgow@google.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      9c988fae
    • Daniel Latypov's avatar
      kunit: tool: make parser preserve whitespace when printing test log · c2bb92bc
      Daniel Latypov authored
      Currently, kunit_parser.py is stripping all leading whitespace to make
      parsing easier. But this means we can't accurately show kernel output
      for failing tests or when the kernel crashes.
      
      Embarassingly, this affects even KUnit's own output, e.g.
      [13:40:46] Expected 2 + 1 == 2, but
      [13:40:46] 2 + 1 == 3 (0x3)
      [13:40:46] not ok 1 example_simple_test
      [13:40:46] [FAILED] example_simple_test
      
      After this change, here's what the output in context would look like
      [13:40:46] =================== example (4 subtests) ===================
      [13:40:46] # example_simple_test: initializing
      [13:40:46] # example_simple_test: EXPECTATION FAILED at lib/kunit/kunit-example-test.c:29
      [13:40:46] Expected 2 + 1 == 2, but
      [13:40:46]     2 + 1 == 3 (0x3)
      [13:40:46] [FAILED] example_simple_test
      [13:40:46] [SKIPPED] example_skip_test
      [13:40:46] [SKIPPED] example_mark_skipped_test
      [13:40:46] [PASSED] example_all_expect_macros_test
      [13:40:46]     # example: initializing suite
      [13:40:46] # example: pass:1 fail:1 skip:2 total:4
      [13:40:46] # Totals: pass:1 fail:1 skip:2 total:4
      [13:40:46] ===================== [FAILED] example =====================
      
      This example shows one minor cosmetic defect this approach has.
      The test counts lines prevent us from dedenting the suite-level output.
      But at the same time, any form of non-KUnit output would do the same
      unless it happened to be indented as well.
      Signed-off-by: default avatarDaniel Latypov <dlatypov@google.com>
      Reviewed-by: default avatarDavid Gow <davidgow@google.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      c2bb92bc
    • David Gow's avatar
      Documentation: kunit: Fix "How Do I Use This" / "Next Steps" sections · a81fe7ec
      David Gow authored
      The "How Do I Use This" section of index.rst and "Next Steps" section of
      start.rst were just copies of the table of contents, and therefore
      weren't really useful either when looking a sphinx generated output
      (which already had the TOC visible) or when reading the source (where
      it's just a list of files that ls could give you).
      
      Instead, provide a small number of concrete next steps, and a bit more
      description about what the pages contain.
      
      This also removes the broken reference to 'tips.rst', which was
      previously removed.
      
      Fixed git am whitespace complaints during commit:
      Shuah Khan <skhan@linuxfoundation.org>
      
      Fixes: 4399c737a97d ("Documentation: kunit: Remove redundant 'tips.rst' page")
      Signed-off-by: default avatarDavid Gow <davidgow@google.com>
      Reviewed-by: default avatarSadiya Kazi <sadiyakazi@google.com>
      Reviewed-by: default avatarBagas Sanjaya <bagasdotme@gmail.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      a81fe7ec
    • Daniel Latypov's avatar
      kunit: tool: don't include KTAP headers and the like in the test log · 5937e0c0
      Daniel Latypov authored
      We print the "test log" on failure.
      This is meant to be all the kernel output that happened during the test.
      
      But we also include the special KTAP lines in it, which are often
      redundant.
      
      E.g. we include the "not ok" line in the log, right before we print
      that the test case failed...
      [13:51:48] Expected 2 + 1 == 2, but
      [13:51:48] 2 + 1 == 3 (0x3)
      [13:51:48] not ok 1 example_simple_test
      [13:51:48] [FAILED] example_simple_test
      
      More full example after this patch:
      [13:51:48] =================== example (4 subtests) ===================
      [13:51:48] # example_simple_test: initializing
      [13:51:48] # example_simple_test: EXPECTATION FAILED at lib/kunit/kunit-example-test.c:29
      [13:51:48] Expected 2 + 1 == 2, but
      [13:51:48] 2 + 1 == 3 (0x3)
      [13:51:48] [FAILED] example_simple_test
      Signed-off-by: default avatarDaniel Latypov <dlatypov@google.com>
      Reviewed-by: default avatarDavid Gow <davidgow@google.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      5937e0c0
    • Rae Moar's avatar
      kunit: improve KTAP compliance of KUnit test output · 6c738b52
      Rae Moar authored
      Change KUnit test output to better comply with KTAP v1 specifications
      found here: https://kernel.org/doc/html/latest/dev-tools/ktap.html.
      1) Use "KTAP version 1" instead of "TAP version 14" as test output header
      2) Remove '-' between test number and test name on test result lines
      2) Add KTAP version lines to each subtest header as well
      
      Note that the new KUnit output still includes the “# Subtest” line now
      located after the KTAP version line. This does not completely match the
      KTAP v1 spec but since it is classified as a diagnostic line, it is not
      expected to be disruptive or break any existing parsers. This
      “# Subtest” line comes from the TAP 14 spec
      (https://testanything.org/tap-version-14-specification.html) and it is
      used to define the test name before the results.
      
      Original output:
      
       TAP version 14
       1..1
         # Subtest: kunit-test-suite
         1..3
         ok 1 - kunit_test_1
         ok 2 - kunit_test_2
         ok 3 - kunit_test_3
       # kunit-test-suite: pass:3 fail:0 skip:0 total:3
       # Totals: pass:3 fail:0 skip:0 total:3
       ok 1 - kunit-test-suite
      
      New output:
      
       KTAP version 1
       1..1
         KTAP version 1
         # Subtest: kunit-test-suite
         1..3
         ok 1 kunit_test_1
         ok 2 kunit_test_2
         ok 3 kunit_test_3
       # kunit-test-suite: pass:3 fail:0 skip:0 total:3
       # Totals: pass:3 fail:0 skip:0 total:3
       ok 1 kunit-test-suite
      Signed-off-by: default avatarRae Moar <rmoar@google.com>
      Reviewed-by: default avatarDaniel Latypov <dlatypov@google.com>
      Reviewed-by: default avatarDavid Gow <davidgow@google.com>
      Tested-by: default avatarAnders Roxell <anders.roxell@linaro.org>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      6c738b52
    • Rae Moar's avatar
      kunit: tool: parse KTAP compliant test output · 434498a6
      Rae Moar authored
      Change the KUnit parser to be able to parse test output that complies with
      the KTAP version 1 specification format found here:
      https://kernel.org/doc/html/latest/dev-tools/ktap.html. Ensure the parser
      is able to parse tests with the original KUnit test output format as
      well.
      
      KUnit parser now accepts any of the following test output formats:
      
      Original KUnit test output format:
      
       TAP version 14
       1..1
         # Subtest: kunit-test-suite
         1..3
         ok 1 - kunit_test_1
         ok 2 - kunit_test_2
         ok 3 - kunit_test_3
       # kunit-test-suite: pass:3 fail:0 skip:0 total:3
       # Totals: pass:3 fail:0 skip:0 total:3
       ok 1 - kunit-test-suite
      
      KTAP version 1 test output format:
      
       KTAP version 1
       1..1
         KTAP version 1
         1..3
         ok 1 kunit_test_1
         ok 2 kunit_test_2
         ok 3 kunit_test_3
       ok 1 kunit-test-suite
      
      New KUnit test output format (changes made in the next patch of
      this series):
      
       KTAP version 1
       1..1
         KTAP version 1
         # Subtest: kunit-test-suite
         1..3
         ok 1 kunit_test_1
         ok 2 kunit_test_2
         ok 3 kunit_test_3
       # kunit-test-suite: pass:3 fail:0 skip:0 total:3
       # Totals: pass:3 fail:0 skip:0 total:3
       ok 1 kunit-test-suite
      Signed-off-by: default avatarRae Moar <rmoar@google.com>
      Reviewed-by: default avatarDaniel Latypov <dlatypov@google.com>
      Reviewed-by: default avatarDavid Gow <davidgow@google.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      434498a6
    • David Gow's avatar
      mm: slub: test: Use the kunit_get_current_test() function · 909c6475
      David Gow authored
      Use the newly-added function kunit_get_current_test() instead of
      accessing current->kunit_test directly. This function uses a static key
      to return more quickly when KUnit is enabled, but no tests are actively
      running. There should therefore be a negligible performance impact to
      enabling the slub KUnit tests.
      
      Other than the performance improvement, this should be a no-op.
      
      Cc: Oliver Glitta <glittao@gmail.com>
      Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>
      Cc: Christoph Lameter <cl@linux.com>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarDavid Gow <davidgow@google.com>
      Acked-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Acked-by: default avatarHyeonggon Yoo <42.hyeyoo@gmail.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      909c6475
    • David Gow's avatar
      kunit: Use the static key when retrieving the current test · 91e93592
      David Gow authored
      In order to detect if a KUnit test is running, and to access its
      context, the 'kunit_test' member of the current task_struct is used.
      Usually, this is accessed directly or via the kunit_fail_current_task()
      function.
      
      In order to speed up the case where no test is running, add a wrapper,
      kunit_get_current_test(), which uses the static key to fail early.
      Equally, Speed up kunit_fail_current_test() by using the static key.
      
      This should make it convenient for code to call this
      unconditionally in fakes or error paths, without worrying that this will
      slow the code down significantly.
      
      If CONFIG_KUNIT=n (or m), this compiles away to nothing. If
      CONFIG_KUNIT=y, it will compile down to a NOP (on most architectures) if
      no KUnit test is currently running.
      
      Note that kunit_get_current_test() does not work if KUnit is built as a
      module. This mirrors the existing restriction on kunit_fail_current_test().
      
      Note that the definition of kunit_fail_current_test() still wraps an
      empty, inline function if KUnit is not built-in. This is to ensure that
      the printf format string __attribute__ will still work.
      
      Also update the documentation to suggest users use the new
      kunit_get_current_test() function, update the example, and to describe
      the behaviour when KUnit is disabled better.
      
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Sadiya Kazi <sadiyakazi@google.com>
      Signed-off-by: default avatarDavid Gow <davidgow@google.com>
      Reviewed-by: default avatarDaniel Latypov <dlatypov@google.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      91e93592
    • David Gow's avatar
      kunit: Provide a static key to check if KUnit is actively running tests · 908d0c17
      David Gow authored
      KUnit does a few expensive things when enabled. This hasn't been a
      problem because KUnit was only enabled on test kernels, but with a few
      people enabling (but not _using_) KUnit on production systems, we need a
      runtime way of handling this.
      
      Provide a 'kunit_running' static key (defaulting to false), which allows
      us to hide any KUnit code behind a static branch. This should reduce the
      performance impact (on other code) of having KUnit enabled to a single
      NOP when no tests are running.
      
      Note that, while it looks unintuitive, tests always run entirely within
      __kunit_test_suites_init(), so it's safe to decrement the static key at
      the end of this function, rather than in __kunit_test_suites_exit(),
      which is only there to clean up results in debugfs.
      Signed-off-by: default avatarDavid Gow <davidgow@google.com>
      Reviewed-by: default avatarDaniel Latypov <dlatypov@google.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      908d0c17
    • Daniel Latypov's avatar
      kunit: tool: make --json do nothing if --raw_ouput is set · 309e22ef
      Daniel Latypov authored
      When --raw_output is set (to any value), we don't actually parse the
      test results. So asking to print the test results as json doesn't make
      sense.
      
      We internally create a fake test with one passing subtest, so --json
      would actually print out something misleading.
      
      This patch:
      * Rewords the flag descriptions so hopefully this is more obvious.
      * Also updates --raw_output's description to note the default behavior
        is to print out only "KUnit" results (actually any KTAP results)
      * also renames and refactors some related logic for clarity (e.g.
        test_result => test, it's a kunit_parser.Test object).
      
      Notably, this patch does not make it an error to specify --json and
      --raw_output together. This is an edge case, but I know of at least one
      wrapper around kunit.py that always sets --json. You'd never be able to
      use --raw_output with that wrapper.
      Signed-off-by: default avatarDaniel Latypov <dlatypov@google.com>
      Reviewed-by: default avatarDavid Gow <davidgow@google.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      309e22ef
    • Daniel Latypov's avatar
      kunit: tool: tweak error message when no KTAP found · 0a7d5c30
      Daniel Latypov authored
      We currently tell people we "couldn't find any KTAP output" with no
      indication as to what this might mean.
      
      After this patch, we get:
      
      $ ./tools/testing/kunit/kunit.py parse /dev/null
      ============================================================
      [ERROR] Test: <missing>: Could not find any KTAP output. Did any KUnit tests run?
      ============================================================
      Testing complete. Ran 0 tests: errors: 1
      
      Note: we could try and generate a more verbose message like
      > Please check .kunit/test.log to see the raw kernel output.
      or the like, but we'd need to know what the build dir was to know where
      test.log actually lives.
      
      This patch tries to make a more minimal improvement.
      Signed-off-by: default avatarDaniel Latypov <dlatypov@google.com>
      Reviewed-by: default avatarDavid Gow <davidgow@google.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      0a7d5c30
    • Daniel Latypov's avatar
      kunit: remove KUNIT_INIT_MEM_ASSERTION macro · 34c68f43
      Daniel Latypov authored
      Commit 870f63b7cd78 ("kunit: eliminate KUNIT_INIT_*_ASSERT_STRUCT
      macros") removed all the other macros of this type.
      
      But it raced with commit b8a926be ("kunit: Introduce
      KUNIT_EXPECT_MEMEQ and KUNIT_EXPECT_MEMNEQ macros"), which added another
      instance.
      
      Remove KUNIT_INIT_MEM_ASSERTION and just use the generic
      KUNIT_INIT_ASSERT macro instead.
      Rename the `size` arg to avoid conflicts by appending a "_" (like we did
      in the previous commit).
      Signed-off-by: default avatarDaniel Latypov <dlatypov@google.com>
      Reviewed-by: default avatarDavid Gow <davidgow@google.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      34c68f43
    • David Gow's avatar
      Documentation: kunit: Remove redundant 'tips.rst' page · a5b9abaa
      David Gow authored
      The contents of 'tips.rst' was mostly included in 'usage.rst' way back in
      commit 95357439 ("Documentation: KUnit: Rework writing page to focus on writing tests"),
      but the tips page remained behind as well.
      
      The parent patches in this series fill in the gaps, so now 'tips.rst' is
      redundant.
      Therefore, delete 'tips.rst'.
      
      While I regret breaking any links to 'tips' which might exist
      externally, it's confusing to have two subtly different versions of the
      same content around.
      Signed-off-by: default avatarDavid Gow <davidgow@google.com>
      Signed-off-by: default avatarDaniel Latypov <dlatypov@google.com>
      Reviewed-by: default avatarSadiya Kazi <sadiyakazi@google.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      a5b9abaa
    • Daniel Latypov's avatar
      Documentation: KUnit: reword description of assertions · ec0a42a1
      Daniel Latypov authored
      The existing wording implies that kunit_kmalloc_array() is "the method
      under test". We're actually testing the sort() function in that example.
      This is because the example was changed in commit 95357439
      ("Documentation: KUnit: Rework writing page to focus on writing tests"),
      but the wording was not.
      
      Also add a `note` telling people they can use the KUNIT_ASSERT_EQ()
      macros from any function. Some users might be coming from a framework
      like gUnit where that'll compile but silently do the wrong thing.
      Signed-off-by: default avatarDaniel Latypov <dlatypov@google.com>
      Reviewed-by: default avatarSadiya Kazi <sadiyakazi@google.com>
      Reviewed-by: default avatarDavid Gow <davidgow@google.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      ec0a42a1
    • Daniel Latypov's avatar
      Documentation: KUnit: make usage.rst a superset of tips.rst, remove duplication · 65c48a48
      Daniel Latypov authored
      usage.rst had most of the content of the tips.rst page copied over.
      But it's missing https://www.kernel.org/doc/html/v6.0/dev-tools/kunit/tips.html#customizing-error-messages
      Copy it over so we can retire tips.rst w/o losing content.
      
      And in that process, it also gained a duplicate section about how
      KUNIT_ASSERT_*() exit the test case early. Remove that.
      Signed-off-by: default avatarDaniel Latypov <dlatypov@google.com>
      Reviewed-by: default avatarSadiya Kazi <sadiyakazi@google.com>
      Reviewed-by: default avatarDavid Gow <davidgow@google.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      65c48a48
    • Daniel Latypov's avatar
      kunit: eliminate KUNIT_INIT_*_ASSERT_STRUCT macros · 697365c0
      Daniel Latypov authored
      These macros exist because passing an initializer list to other macros
      is hard.
      
      The goal of these macros is to generate a line like
        struct $ASSERT_TYPE __assertion = $APPROPRIATE_INITIALIZER;
      e.g.
        struct kunit_unary_assertion __assertion = {
      	  .condition = "foo()",
      	  .expected_true = true
        };
      
      But the challenge is you can't pass `{.condition=..., .expect_true=...}`
      as a macro argument, since the comma means you're actually passing two
      arguments, `{.condition=...` and `.expect_true=....}`.
      So we'd made custom macros for each different initializer-list shape.
      
      But we can work around this with the following generic macro
        #define KUNIT_INIT_ASSERT(initializers...) { initializers }
      
      Note: this has the downside that we have to rename some macros arguments
      to not conflict with the struct field names (e.g. `expected_true`).
      It's a bit gross, but probably worth reducing the # of macros.
      Signed-off-by: default avatarDaniel Latypov <dlatypov@google.com>
      Reviewed-by: default avatarDavid Gow <davidgow@google.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      697365c0
    • Daniel Latypov's avatar
      kunit: tool: remove redundant file.close() call in unit test · 101e32a0
      Daniel Latypov authored
      We're using a `with` block above, so the file object is already closed.
      Signed-off-by: default avatarDaniel Latypov <dlatypov@google.com>
      Reviewed-by: default avatarDavid Gow <davidgow@google.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      101e32a0