Hi Linus,
Please pull the following Kselftest fixes update for Linux 6.1-rc4.
This Kselftest fixes update for Linux 6.1-rc4 consists of fixes to
pidfd test.
diff is attached.
thanks,
-- Shuah
----------------------------------------------------------------
The following changes since commit cb05c81ada76a30a25a5f79b249375e33473af33:
selftests/ftrace: fix dynamic_events dependency check (2022-10-18 14:27:23 -0600)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest tags/linux-kselftest-fixes-6.1-rc4
for you to fetch changes up to 89c1017aac67ca81973b7c8eac5d021315811a93:
selftests/pidfd_test: Remove the erroneous ',' (2022-11-02 03:09:57 -0600)
----------------------------------------------------------------
linux-kselftest-fixes-6.1-rc4
This Kselftest fixes update for Linux 6.1-rc4 consists of fixes to
pidfd test.
----------------------------------------------------------------
Li Zhijian (2):
ksefltests: pidfd: Fix wait_states: Test terminated by timeout
selftests: pidfd: Fix compling warnings
Zhao Gongyi (1):
selftests/pidfd_test: Remove the erroneous ','
tools/testing/selftests/pidfd/Makefile | 2 +-
tools/testing/selftests/pidfd/pidfd_test.c | 4 +++-
tools/testing/selftests/pidfd/pidfd_wait.c | 12 +++++++++++-
3 files changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------
Since we're using Python 3.7+, we can use dataclasses to tersen the
code.
It also lets us create pre-populated TestCounts() objects and compare
them in our unit test. (Before, you could only create empty ones).
Signed-off-by: Daniel Latypov <dlatypov(a)google.com>
Reviewed-by: David Gow <davidgow(a)google.com>
---
v1 -> v2: just rebased onto linux-kselftest/kunit
---
tools/testing/kunit/kunit_parser.py | 25 ++++++++-----------------
tools/testing/kunit/kunit_tool_test.py | 4 +---
2 files changed, 9 insertions(+), 20 deletions(-)
diff --git a/tools/testing/kunit/kunit_parser.py b/tools/testing/kunit/kunit_parser.py
index 94dba66feec5..a56c75a973b5 100644
--- a/tools/testing/kunit/kunit_parser.py
+++ b/tools/testing/kunit/kunit_parser.py
@@ -10,6 +10,7 @@
# Author: Rae Moar <rmoar(a)google.com>
from __future__ import annotations
+from dataclasses import dataclass
import re
import sys
@@ -71,27 +72,17 @@ class TestStatus(Enum):
NO_TESTS = auto()
FAILURE_TO_PARSE_TESTS = auto()
+@dataclass
class TestCounts:
"""
Tracks the counts of statuses of all test cases and any errors within
a Test.
-
- Attributes:
- passed : int - the number of tests that have passed
- failed : int - the number of tests that have failed
- crashed : int - the number of tests that have crashed
- skipped : int - the number of tests that have skipped
- errors : int - the number of errors in the test and subtests
- """
- def __init__(self):
- """Creates TestCounts object with counts of all test
- statuses and test errors set to 0.
- """
- self.passed = 0
- self.failed = 0
- self.crashed = 0
- self.skipped = 0
- self.errors = 0
+ """
+ passed: int = 0
+ failed: int = 0
+ crashed: int = 0
+ skipped: int = 0
+ errors: int = 0
def __str__(self) -> str:
"""Returns the string representation of a TestCounts object."""
diff --git a/tools/testing/kunit/kunit_tool_test.py b/tools/testing/kunit/kunit_tool_test.py
index 7dcd67003b23..440a273f1d21 100755
--- a/tools/testing/kunit/kunit_tool_test.py
+++ b/tools/testing/kunit/kunit_tool_test.py
@@ -182,9 +182,7 @@ class KUnitParserTest(unittest.TestCase):
kunit_parser.extract_tap_lines(
file.readlines()))
# A missing test plan is not an error.
- self.assertEqual(0, result.counts.errors)
- # All tests should be accounted for.
- self.assertEqual(10, result.counts.total())
+ self.assertEqual(result.counts, kunit_parser.TestCounts(passed=10, errors=0))
self.assertEqual(
kunit_parser.TestStatus.SUCCESS,
result.status)
base-commit: 29ad37f740d302d0f27374edaf85fe8978e45ba9
--
2.38.1.431.g37b22c650d-goog
Since we're using Python 3.7+, we can use dataclasses to tersen the
code.
It also lets us create pre-populated TestCounts() objects and compare
them in our unit test. (Before, you could only create empty ones).
Signed-off-by: Daniel Latypov <dlatypov(a)google.com>
---
tools/testing/kunit/kunit_parser.py | 25 ++++++++-----------------
tools/testing/kunit/kunit_tool_test.py | 4 +---
2 files changed, 9 insertions(+), 20 deletions(-)
diff --git a/tools/testing/kunit/kunit_parser.py b/tools/testing/kunit/kunit_parser.py
index 1ae873e3e341..f022966858f2 100644
--- a/tools/testing/kunit/kunit_parser.py
+++ b/tools/testing/kunit/kunit_parser.py
@@ -10,6 +10,7 @@
# Author: Rae Moar <rmoar(a)google.com>
from __future__ import annotations
+from dataclasses import dataclass
import re
import sys
@@ -67,27 +68,17 @@ class TestStatus(Enum):
NO_TESTS = auto()
FAILURE_TO_PARSE_TESTS = auto()
+@dataclass
class TestCounts:
"""
Tracks the counts of statuses of all test cases and any errors within
a Test.
-
- Attributes:
- passed : int - the number of tests that have passed
- failed : int - the number of tests that have failed
- crashed : int - the number of tests that have crashed
- skipped : int - the number of tests that have skipped
- errors : int - the number of errors in the test and subtests
- """
- def __init__(self):
- """Creates TestCounts object with counts of all test
- statuses and test errors set to 0.
- """
- self.passed = 0
- self.failed = 0
- self.crashed = 0
- self.skipped = 0
- self.errors = 0
+ """
+ passed: int = 0
+ failed: int = 0
+ crashed: int = 0
+ skipped: int = 0
+ errors: int = 0
def __str__(self) -> str:
"""Returns the string representation of a TestCounts object."""
diff --git a/tools/testing/kunit/kunit_tool_test.py b/tools/testing/kunit/kunit_tool_test.py
index e2cd2cc2e98f..9fa4babb2506 100755
--- a/tools/testing/kunit/kunit_tool_test.py
+++ b/tools/testing/kunit/kunit_tool_test.py
@@ -179,9 +179,7 @@ class KUnitParserTest(unittest.TestCase):
kunit_parser.extract_tap_lines(
file.readlines()))
# A missing test plan is not an error.
- self.assertEqual(0, result.counts.errors)
- # All tests should be accounted for.
- self.assertEqual(10, result.counts.total())
+ self.assertEqual(result.counts, kunit_parser.TestCounts(passed=10, errors=0))
self.assertEqual(
kunit_parser.TestStatus.SUCCESS,
result.status)
base-commit: 5aaef24b5c6d4246b2cac1be949869fa36577737
--
2.38.1.273.g43a17bfeac-goog
This patchset is for fixing (patch 1) the syzbot-reported
slab-out-of-bounds write in dbgfs_rm_context_write[1], and adding a
selftest for the bug (patch 2).
[1] https://lore.kernel.org/damon/000000000000ede3ac05ec4abf8e@google.com/
SeongJae Park (2):
mm/damon/dbgfs: check if rm_contexts input is for a real context
selftests/damon: test non-context inputs to rm_contexts file
mm/damon/dbgfs.c | 7 +++++++
tools/testing/selftests/damon/Makefile | 1 +
.../damon/debugfs_rm_non_contexts.sh | 19 +++++++++++++++++++
3 files changed, 27 insertions(+)
create mode 100755 tools/testing/selftests/damon/debugfs_rm_non_contexts.sh
--
2.25.1
This RFC patch series implement KUnit support for i915 driver,
using the already-existing tests inside i915 selftests.
On this version, mock selftest can now run in qemu with:
$ ./tools/testing/kunit/kunit.py run --arch=x86_64 \
--kunitconfig=drivers/gpu/drm/i915/selftests
The tests which depends on having a real i915 hardware will be skipped.
All selftests will run on bare metal, by modprobing test-i915 module.
The output can be parsed (with a hack) using kunit.py:
$ (echo "[ 0.000000] TAP version 14"; dmesg)>logs; ./tools/testing/kunit/kunit.py parse logs
[14:29:06] ============================================================
[14:29:06] ============ i915 mock selftests (18 subtests) =============
[14:29:06] [PASSED] mock_sanitycheck
[14:29:06] [PASSED] mock_shmem
[14:29:06] [PASSED] mock_fence
[14:29:06] [PASSED] mock_scatterlist
[14:29:06] [PASSED] mock_syncmap
[14:29:06] [PASSED] mock_uncore
[14:29:06] [PASSED] mock_ring
[14:29:06] [PASSED] mock_engine
[14:29:06] [PASSED] mock_timelines
[14:29:06] [PASSED] mock_requests
[14:29:06] [PASSED] mock_objects
[14:29:06] [PASSED] mock_phys
[14:29:06] [PASSED] mock_dmabuf
[14:29:06] [PASSED] mock_vma
[14:29:06] [PASSED] mock_evict
[14:29:06] [PASSED] mock_gtt
[14:29:06] [PASSED] mock_hugepages
[14:29:06] [PASSED] mock_memory_region
[14:29:06] =============== [PASSED] i915 mock selftests ===============
[14:29:06] ============ i915 live selftests (36 subtests) =============
[14:29:06] [PASSED] live_sanitycheck
[14:29:06] [PASSED] live_uncore
[14:29:06] [PASSED] live_workarounds
[14:29:06] [PASSED] live_gt_engines
[14:29:06] [PASSED] live_gt_timelines
[14:29:06] [PASSED] live_gt_contexts
[14:29:06] [PASSED] live_gt_lrc
[14:29:06] [PASSED] live_gt_mocs
[14:29:06] [PASSED] live_gt_pm
[14:29:06] [PASSED] live_gt_heartbeat
[14:29:06] [PASSED] live_requests
[14:29:06] [PASSED] live_migrate
[14:29:06] [PASSED] live_active
[14:29:06] [PASSED] live_objects
[14:29:06] i915: Performing live_mman selftests with st_random_seed=0x1e5d7be5 st_timeout=500
[14:29:06] test_i915: Setting dangerous option KUnit live_mman - tainting kernel
[14:29:06] test_i915: Running live_mman on 0000:00:02.0
[14:29:06] Test called without an user context!
[14:29:06] # live_mman: EXPECTATION FAILED at drivers/gpu/drm/i915/selftests/i915_kunit.c:110
[14:29:06] Expected ret == 0, but
[14:29:06] ret == -22
[14:29:06] not ok 15 - live_mman
[14:29:06] [FAILED] live_mman
[14:29:06] [PASSED] live_dmabuf
[14:29:06] [PASSED] live_vma
[14:29:06] [PASSED] live_coherency
[14:29:06] [PASSED] live_gtt
[14:29:06] [PASSED] live_gem
[14:29:06] [PASSED] live_evict
[14:29:06] [PASSED] live_hugepages
[14:29:06] [PASSED] live_gem_contexts
[14:29:06] [PASSED] live_client
[14:29:06] [PASSED] live_gem_migrate
[14:29:06] [PASSED] live_reset
[14:29:06] [PASSED] live_memory_region
[14:29:06] [PASSED] live_hangcheck
[14:29:06] [PASSED] live_execlists
[14:29:06] [PASSED] live_ring_submission
[14:29:06] [PASSED] live_perf
[14:29:06] [PASSED] live_slpc
[14:29:06] [PASSED] live_guc
[14:29:06] [PASSED] live_guc_multi_lrc
[14:29:06] [PASSED] live_guc_hang
[14:29:06] [PASSED] live_late_gt_pm
[14:29:06] test_i915: 0000:00:02.0: it is a i915 device.
[14:29:06] # Subtest: i915 live selftests
[14:29:06] 1..36
[14:29:06] # i915 live selftests: pass:35 fail:1 skip:0 total:36
[14:29:06] # Totals: pass:35 fail:1 skip:0 total:36
[14:29:06] not ok 2 - i915 live selftests
[14:29:06] =============== [FAILED] i915 live selftests ===============
[14:29:06] ============= i915 perf selftests (4 subtests) =============
[14:29:06] [PASSED] perf_engine_cs
[14:29:06] [PASSED] perf_request
[14:29:06] [PASSED] perf_migrate
[14:29:06] [PASSED] perf_region
[14:29:06] =============== [PASSED] i915 perf selftests ===============
[14:29:06] ============================================================
[14:29:06] Testing complete. Ran 58 tests: passed: 57, failed: 1
It is worth noticing that the mmap tests will fail while running via
KUnit. The reason is that such tests depend on having an user
context allocated at current->mm. While modprobing i915 with
selftests enabled allocates it - this is done by Kernel fork() logic),
modprobing test-i915 doesn't. So, such tests won't run.
We probably need to modify kunit core in order for it to call
mm_alloc() internally before starting the tests.
Comments?
PS.: the current approach is getting only the final results of the
selftests. I opted for this strategy as we need to support i915 selftests,
as those are used by Intel DRM CI bot. A more intrusive change could
be done in the future, in order to export all tests called via SUBTESTS()
macro.
It also makes sense to add filtering capabilities to the module, as this ends
being needed during development phase, where some tests might fail
on newer hardware.
---
v2:
- changes outside KUnit module moved to separate patches;
- added support for running live and perf selftests on bare metal;
- made the KUnit test logic identical to i915 selftest.
Mauro Carvalho Chehab (8):
drm/i915: export all selftest functions
drm/i915: place selftest preparation on a separate function
drm/i915: allow running mock selftests via Kunit
drm/i915: add support to run KUnit tests on bare metal
drm/i915: add live selftests to KUnit
drm/i915: add perf selftests to KUnit
drm/i915: now that all functions are used, remove __maybe_unused
drm/i915: check if current->mm is not NULL
drivers/gpu/drm/i915/Kconfig | 15 +
drivers/gpu/drm/i915/Makefile | 5 +
.../gpu/drm/i915/gem/selftests/huge_pages.c | 2 +
.../i915/gem/selftests/i915_gem_client_blt.c | 1 +
.../i915/gem/selftests/i915_gem_coherency.c | 1 +
.../drm/i915/gem/selftests/i915_gem_context.c | 1 +
.../drm/i915/gem/selftests/i915_gem_dmabuf.c | 2 +
.../drm/i915/gem/selftests/i915_gem_migrate.c | 1 +
.../drm/i915/gem/selftests/i915_gem_mman.c | 6 +
.../drm/i915/gem/selftests/i915_gem_object.c | 2 +
.../drm/i915/gem/selftests/i915_gem_phys.c | 1 +
drivers/gpu/drm/i915/gt/selftest_context.c | 1 +
drivers/gpu/drm/i915/gt/selftest_engine.c | 1 +
drivers/gpu/drm/i915/gt/selftest_engine_cs.c | 2 +
.../drm/i915/gt/selftest_engine_heartbeat.c | 1 +
drivers/gpu/drm/i915/gt/selftest_execlists.c | 1 +
drivers/gpu/drm/i915/gt/selftest_gt_pm.c | 2 +
drivers/gpu/drm/i915/gt/selftest_hangcheck.c | 1 +
drivers/gpu/drm/i915/gt/selftest_lrc.c | 1 +
drivers/gpu/drm/i915/gt/selftest_migrate.c | 2 +
drivers/gpu/drm/i915/gt/selftest_mocs.c | 1 +
drivers/gpu/drm/i915/gt/selftest_reset.c | 1 +
drivers/gpu/drm/i915/gt/selftest_ring.c | 1 +
.../drm/i915/gt/selftest_ring_submission.c | 1 +
drivers/gpu/drm/i915/gt/selftest_slpc.c | 1 +
drivers/gpu/drm/i915/gt/selftest_timeline.c | 2 +
.../gpu/drm/i915/gt/selftest_workarounds.c | 1 +
drivers/gpu/drm/i915/gt/st_shmem_utils.c | 1 +
drivers/gpu/drm/i915/gt/uc/selftest_guc.c | 1 +
.../drm/i915/gt/uc/selftest_guc_hangcheck.c | 1 +
.../drm/i915/gt/uc/selftest_guc_multi_lrc.c | 1 +
drivers/gpu/drm/i915/i915_selftest.h | 2 +
drivers/gpu/drm/i915/selftests/.kunitconfig | 12 +
drivers/gpu/drm/i915/selftests/i915_active.c | 1 +
drivers/gpu/drm/i915/selftests/i915_gem.c | 1 +
.../gpu/drm/i915/selftests/i915_gem_evict.c | 2 +
drivers/gpu/drm/i915/selftests/i915_gem_gtt.c | 2 +
drivers/gpu/drm/i915/selftests/i915_kunit.c | 260 ++++++++++++++++++
drivers/gpu/drm/i915/selftests/i915_perf.c | 1 +
drivers/gpu/drm/i915/selftests/i915_request.c | 3 +
.../gpu/drm/i915/selftests/i915_selftest.c | 24 +-
.../gpu/drm/i915/selftests/i915_sw_fence.c | 1 +
drivers/gpu/drm/i915/selftests/i915_syncmap.c | 1 +
drivers/gpu/drm/i915/selftests/i915_vma.c | 2 +
.../drm/i915/selftests/intel_memory_region.c | 3 +
drivers/gpu/drm/i915/selftests/intel_uncore.c | 2 +
drivers/gpu/drm/i915/selftests/scatterlist.c | 1 +
47 files changed, 371 insertions(+), 8 deletions(-)
create mode 100644 drivers/gpu/drm/i915/selftests/.kunitconfig
create mode 100644 drivers/gpu/drm/i915/selftests/i915_kunit.c
--
2.38.1
Recently while trying to fix some unit tests I found a CVE in SVM nested code.
In 'shutdown_interception' vmexit handler we call kvm_vcpu_reset.
However if running nested and L1 doesn't intercept shutdown, we will still end
up running this function and trigger a bug in it.
The bug is that this function resets the 'vcpu->arch.hflags' without properly
leaving the nested state, which leaves the vCPU in inconsistent state, which
later triggers a kernel panic in SVM code.
The same bug can likely be triggered by sending INIT via local apic to a vCPU
which runs a nested guest.
On VMX we are lucky that the issue can't happen because VMX always intercepts
triple faults, thus triple fault in L2 will always be redirected to L1.
Plus the 'handle_triple_fault' of VMX doesn't reset the vCPU.
INIT IPI can't happen on VMX either because INIT events are masked while in
VMX mode.
First 4 patches in this series address the above issue, and are
already posted on the list with title,
('nSVM: fix L0 crash if L2 has shutdown condtion which L1 doesn't intercept')
I addressed the review feedback and also added a unit test to hit this issue.
In addition to these patches I noticed that KVM doesn't honour SHUTDOWN intercept bit
of L1 on SVM, and I included a fix to do so - its only for correctness
as a normal hypervisor should always intercept SHUTDOWN.
A unit test on the other hand might want to not do so.
I also extendted the triple_fault_test selftest to hit this issue.
Finaly I found another security issue, I found a way to
trigger a kernel non rate limited printk on SVM from the guest, and
last patch in the series fixes that.
A unit test I posted to kvm-unit-tests project hits this issue, so
no selftest was added.
Best regards,
Maxim Levitsky
Maxim Levitsky (9):
KVM: x86: nSVM: leave nested mode on vCPU free
KVM: x86: nSVM: harden svm_free_nested against freeing vmcb02 while
still in use
KVM: x86: add kvm_leave_nested
KVM: x86: forcibly leave nested mode on vCPU reset
KVM: selftests: move idt_entry to header
kvm: selftests: add svm nested shutdown test
KVM: x86: allow L1 to not intercept triple fault
KVM: selftests: add svm part to triple_fault_test
KVM: x86: remove exit_int_info warning in svm_handle_exit
arch/x86/kvm/svm/nested.c | 12 +++-
arch/x86/kvm/svm/svm.c | 10 +--
arch/x86/kvm/vmx/nested.c | 4 +-
arch/x86/kvm/x86.c | 29 ++++++--
tools/testing/selftests/kvm/.gitignore | 1 +
tools/testing/selftests/kvm/Makefile | 1 +
.../selftests/kvm/include/x86_64/processor.h | 13 ++++
.../selftests/kvm/lib/x86_64/processor.c | 13 ----
.../kvm/x86_64/svm_nested_shutdown_test.c | 71 +++++++++++++++++++
.../kvm/x86_64/triple_fault_event_test.c | 71 ++++++++++++++-----
10 files changed, 174 insertions(+), 51 deletions(-)
create mode 100644 tools/testing/selftests/kvm/x86_64/svm_nested_shutdown_test.c
--
2.34.3