From: Vincent Cheng <vincent.cheng.xh(a)renesas.com>
This series adds adjust phase to the PTP Hardware Clock device interface.
Some PTP hardware clocks have a write phase mode that has
a built-in hardware filtering capability. The write phase mode
utilizes a phase offset control word instead of a frequency offset
control word. Add adjust phase function to take advantage of this
capability.
Changes since v1:
- As suggested by Richard Cochran:
1. ops->adjphase is new so need to check for non-null function pointer.
2. Kernel coding style uses lower_case_underscores.
3. Use existing PTP clock API for delayed worker.
Vincent Cheng (3):
ptp: Add adjphase function to support phase offset control.
ptp: Add adjust_phase to ptp_clock_caps capability.
ptp: ptp_clockmatrix: Add adjphase() to support PHC write phase mode.
drivers/ptp/ptp_chardev.c | 1 +
drivers/ptp/ptp_clock.c | 3 ++
drivers/ptp/ptp_clockmatrix.c | 92 +++++++++++++++++++++++++++++++++++
drivers/ptp/ptp_clockmatrix.h | 8 ++-
include/linux/ptp_clock_kernel.h | 6 ++-
include/uapi/linux/ptp_clock.h | 4 +-
tools/testing/selftests/ptp/testptp.c | 6 ++-
7 files changed, 114 insertions(+), 6 deletions(-)
--
2.7.4
Hi Linus,
Please pull the following Kselftest update for Linux 5.20-rc1.
This Kselftest update for Linux 5.20-rc1 consists of:
- timers test build fixes and cleanups for new tool chains
- removing khdr from kselftest framework and main Makefile
- changes to test output messages to improve reports
Please not that this update also included main Makefile change
to kselftest build logic in it.
diff is attached.
thanks,
-- Shuah
----------------------------------------------------------------
The following changes since commit 03c765b0e3b4cb5063276b086c76f7a612856a9a:
Linux 5.19-rc4 (2022-06-26 14:22:10 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest tags/linux-kselftest-next-5.20-rc1
for you to fetch changes up to 4062eba9f3d072e72645860fbc5d160428a75c50:
Makefile: replace headers_install with headers for kselftest (2022-07-26 18:06:33 -0600)
----------------------------------------------------------------
linux-kselftest-next-5.20-rc1
This Kselftest update for Linux 5.20-rc1 consists of:
- timers test build fixes and cleanups for new tool chains
- removing khdr from kselftest framework and main Makefile
- changes to test output messages to improve reports
----------------------------------------------------------------
Gautam (2):
kselftests: Enable the echo command to print newlines in Makefile
kselftests/damon: add support for cases where debugfs cannot be read
Gautam Menghani (3):
selftests: Make the usage formatting consistent in kselftest_deps.sh
selftests/drivers/gpu: Add error messages to drm_mm.sh
selftests/kcmp: Make the test output consistent and clear
Guillaume Tucker (6):
selftests: drop khdr make target
selftests: stop using KSFT_KHDR_INSTALL
selftests: drop KSFT_KHDR_INSTALL make target
Makefile: add headers_install to kselftest targets
selftests/landlock: drop deprecated headers dependency
Makefile: replace headers_install with headers for kselftest
Johannes Holland (1):
selftests/tpm2: increase timeout for kselftests
Soumya Negi (1):
selftests: drivers/dma-buf: Improve message in selftest summary
Wolfram Sang (9):
selftests: timers: valid-adjtimex: build fix for newer toolchains
selftests: timers: fix declarations of main()
selftests: timers: nanosleep: adapt to kselftest framework
selftests: timers: inconsistency-check: adapt to kselftest framework
selftests: timers: clocksource-switch: fix passing errors from child
selftests: timers: clocksource-switch: sort includes
selftests: timers: clocksource-switch: add command line switch to skip sanity check
selftests: timers: clocksource-switch: add 'runtime' command line parameter
selftests: timers: clocksource-switch: adapt to kselftest framework
Xiang wangx (1):
userfaultfd/selftests: Fix typo in comment
Zan Aziz (1):
selftests:timers: globals don't need initialization to 0
Makefile | 4 +-
tools/testing/selftests/Makefile | 30 +--------
tools/testing/selftests/arm64/mte/Makefile | 1 -
tools/testing/selftests/arm64/signal/Makefile | 1 -
.../testing/selftests/arm64/signal/test_signals.h | 4 +-
tools/testing/selftests/damon/_chk_dependency.sh | 10 +++
tools/testing/selftests/drivers/dma-buf/udmabuf.c | 3 +-
tools/testing/selftests/drivers/gpu/drm_mm.sh | 4 +-
.../selftests/drivers/s390x/uvdevice/Makefile | 1 -
tools/testing/selftests/futex/functional/Makefile | 1 -
tools/testing/selftests/kcmp/kcmp_test.c | 6 +-
tools/testing/selftests/kselftest_deps.sh | 2 +-
tools/testing/selftests/kvm/Makefile | 1 -
tools/testing/selftests/landlock/Makefile | 10 +--
tools/testing/selftests/lib.mk | 38 ------------
tools/testing/selftests/net/Makefile | 1 -
tools/testing/selftests/net/mptcp/Makefile | 1 -
tools/testing/selftests/tc-testing/Makefile | 1 -
tools/testing/selftests/timers/adjtick.c | 2 +-
.../testing/selftests/timers/alarmtimer-suspend.c | 2 +-
tools/testing/selftests/timers/change_skew.c | 2 +-
.../testing/selftests/timers/clocksource-switch.c | 71 ++++++++++++++--------
.../testing/selftests/timers/inconsistency-check.c | 32 +++++-----
tools/testing/selftests/timers/nanosleep.c | 18 +++---
tools/testing/selftests/timers/raw_skew.c | 2 +-
tools/testing/selftests/timers/skew_consistency.c | 2 +-
tools/testing/selftests/timers/valid-adjtimex.c | 2 +-
tools/testing/selftests/tpm2/settings | 1 +
tools/testing/selftests/vm/Makefile | 1 -
tools/testing/selftests/vm/userfaultfd.c | 2 +-
30 files changed, 111 insertions(+), 145 deletions(-)
create mode 100644 tools/testing/selftests/tpm2/settings
----------------------------------------------------------------
While the sdhci-of-aspeed KUnit tests do work when builtin, and do work
when KUnit itself is being built as a module, the two together break.
This is because the KUnit tests (understandably) depend on KUnit, so a
built-in test cannot build if KUnit is a module.
Fix this by adding a dependency on (MMC_SDHCI_OF_ASPEED=m || KUNIT=y),
which only excludes this one problematic configuration.
This was reported on a nasty openrisc-randconfig run by the kernel test
robot, though for some reason (compiler optimisations removing the test
code?) I wasn't able to reproduce it locally on x86:
https://lore.kernel.org/linux-mm/202207140122.fzhlf60k-lkp@intel.com/T/
Fixes: 291cd54e5b05 ("mmc: sdhci-of-aspeed: test: Use kunit_test_suite() macro")
Reported-by: kernel test robot <lkp(a)intel.com>
Signed-off-by: David Gow <davidgow(a)google.com>
---
drivers/mmc/host/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
index 10c563999d3d..e63608834411 100644
--- a/drivers/mmc/host/Kconfig
+++ b/drivers/mmc/host/Kconfig
@@ -171,6 +171,7 @@ config MMC_SDHCI_OF_ASPEED
config MMC_SDHCI_OF_ASPEED_TEST
bool "Tests for the ASPEED SDHCI driver" if !KUNIT_ALL_TESTS
depends on MMC_SDHCI_OF_ASPEED && KUNIT
+ depends on (MMC_SDHCI_OF_ASPEED=m || KUNIT=y)
default KUNIT_ALL_TESTS
help
Enable KUnit tests for the ASPEED SDHCI driver. Select this
--
2.37.0.170.g444d1eabd0-goog
While creating a LSM BPF MAC policy to block user namespace creation, we
used the LSM cred_prepare hook because that is the closest hook to prevent
a call to create_user_ns().
The calls look something like this:
cred = prepare_creds()
security_prepare_creds()
call_int_hook(cred_prepare, ...
if (cred)
create_user_ns(cred)
We noticed that error codes were not propagated from this hook and
introduced a patch [1] to propagate those errors.
The discussion notes that security_prepare_creds()
is not appropriate for MAC policies, and instead the hook is
meant for LSM authors to prepare credentials for mutation. [2]
Ultimately, we concluded that a better course of action is to introduce
a new security hook for LSM authors. [3]
This patch set first introduces a new security_create_user_ns() function
and userns_create LSM hook, then marks the hook as sleepable in BPF.
Links:
1. https://lore.kernel.org/all/20220608150942.776446-1-fred@cloudflare.com/
2. https://lore.kernel.org/all/87y1xzyhub.fsf@email.froward.int.ebiederm.org/
3. https://lore.kernel.org/all/9fe9cd9f-1ded-a179-8ded-5fde8960a586@cloudflare…
Past discussions:
V2: https://lore.kernel.org/all/20220707223228.1940249-1-fred@cloudflare.com/
V1: https://lore.kernel.org/all/20220621233939.993579-1-fred@cloudflare.com/
Changes since v2:
- Rename create_user_ns hook to userns_create
- Use user_namespace as an object opposed to a generic namespace object
- s/domB_t/domA_t in commit message
Changes since v1:
- Add selftests/bpf: Add tests verifying bpf lsm create_user_ns hook patch
- Add selinux: Implement create_user_ns hook patch
- Change function signature of security_create_user_ns() to only take
struct cred
- Move security_create_user_ns() call after id mapping check in
create_user_ns()
- Update documentation to reflect changes
Frederick Lawler (4):
security, lsm: Introduce security_create_user_ns()
bpf-lsm: Make bpf_lsm_userns_create() sleepable
selftests/bpf: Add tests verifying bpf lsm userns_create hook
selinux: Implement userns_create hook
include/linux/lsm_hook_defs.h | 1 +
include/linux/lsm_hooks.h | 4 +
include/linux/security.h | 6 ++
kernel/bpf/bpf_lsm.c | 1 +
kernel/user_namespace.c | 5 ++
security/security.c | 5 ++
security/selinux/hooks.c | 9 ++
security/selinux/include/classmap.h | 2 +
.../selftests/bpf/prog_tests/deny_namespace.c | 88 +++++++++++++++++++
.../selftests/bpf/progs/test_deny_namespace.c | 39 ++++++++
10 files changed, 160 insertions(+)
create mode 100644 tools/testing/selftests/bpf/prog_tests/deny_namespace.c
create mode 100644 tools/testing/selftests/bpf/progs/test_deny_namespace.c
--
2.30.2
Hi Linus,
Please pull the following KUnit update for Linux 5.20-rc1.
This KUnit update for Linux 5.20-rc1 consists of several fixes and an
important feature to discourage running KUnit tests on production
systems. Running tests on a production system could leave the system
in a bad state. This new feature adds:
- adds a new taint type, TAINT_TEST to signal that a test has been run.
This should discourage people from running these tests on production
systems, and to make it easier to tell if tests have been run
accidentally (by loading the wrong configuration, etc.)
- several documentation and tool enhancements and fixes.
Please note that this KUnit update touches drivers, lib, kernel files
for the TAINT_TEST feature.
diff is attached.
thanks,
-- Shuah
----------------------------------------------------------------
The following changes since commit f2906aa863381afb0015a9eb7fefad885d4e5a56:
Linux 5.19-rc1 (2022-06-05 17:18:54 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest tags/linux-kselftest-kunit-5.20-rc1
for you to fetch changes up to 4c392516accfe51a1aaf80ed163517646f8f0476:
Documentation: KUnit: Fix example with compilation error (2022-07-28 13:06:35 -0600)
----------------------------------------------------------------
linux-kselftest-kunit-5.20-rc1
This KUnit update for Linux 5.20-rc1 consists of several fixes and an
important feature to discourage running KUnit tests on production
systems. Running tests on a production system could leave the system
in a bad state. This new feature adds:
- adds a new taint type, TAINT_TEST to signal that a test has been run.
This should discourage people from running these tests on production
systems, and to make it easier to tell if tests have been run
accidentally (by loading the wrong configuration, etc.)
- several documentation and tool enhancements and fixes.
----------------------------------------------------------------
Daniel Latypov (13):
kunit: use kmemdup in kunit_filter_tests(), take suite as const
kunit: tool: drop unused load_config argument
kunit: tool: redo how we construct and mock LinuxSourceTree
kunit: tool: refactoring printing logic into kunit_printer.py
kunit: tool: cosmetic: don't specify duplicate kernel cmdline options
kunit: tool: simplify creating LinuxSourceTreeOperations
kunit: tool: introduce --qemu_args
kunit: tool: refactor internal kconfig handling, allow overriding
kunit: add coverage_uml.config to enable GCOV on UML
kunit: tool: make --kunitconfig repeatable, blindly concat
Documentation: kunit: fix example run_kunit func to allow spaces in args
kunit: flatten kunit_suite*** to kunit_suite** in .kunit_test_suites
clk: explicitly disable CONFIG_UML_PCI_OVER_VIRTIO in .kunitconfig
David Gow (12):
panic: Taint kernel if tests are run
kunit: Taint the kernel when KUnit tests are run
apparmor: test: Remove some casts which are no-longer required
kunit: tool: Enable virtio/PCI by default on UML
Documentation: kunit: Cleanup run_wrapper, fix x-ref
module: panic: Taint the kernel when selftest modules load
selftest: Taint kernel when test module loaded
thunderbolt: test: Use kunit_test_suite() macro
nitro_enclaves: test: Use kunit_test_suite() macro
mmc: sdhci-of-aspeed: test: Use kunit_test_suite() macro
kunit: executor: Fix a memory leak on failure in kunit_filter_tests
kcsan: test: Add a .kunitconfig to run KCSAN tests
Jeremy Kerr (1):
kunit: unify module and builtin suite definitions
Mauro Carvalho Chehab (1):
kunit: test.h: fix a kernel-doc markup
Maíra Canal (1):
Documentation: KUnit: Fix example with compilation error
Sadiya Kazi (1):
Documentation: kunit: Add CLI args for kunit_tool
Documentation/admin-guide/tainted-kernels.rst | 1 +
Documentation/dev-tools/kselftest.rst | 9 +
Documentation/dev-tools/kunit/run_wrapper.rst | 81 ++++++++-
Documentation/dev-tools/kunit/running_tips.rst | 5 +-
Documentation/dev-tools/kunit/usage.rst | 2 +-
drivers/clk/.kunitconfig | 1 +
drivers/mmc/host/Kconfig | 5 +-
drivers/mmc/host/sdhci-of-aspeed-test.c | 8 +-
drivers/mmc/host/sdhci-of-aspeed.c | 34 +---
drivers/thunderbolt/Kconfig | 6 +-
drivers/thunderbolt/domain.c | 3 -
drivers/thunderbolt/tb.h | 8 -
drivers/thunderbolt/test.c | 12 +-
drivers/virt/nitro_enclaves/Kconfig | 5 +-
drivers/virt/nitro_enclaves/ne_misc_dev.c | 27 ---
drivers/virt/nitro_enclaves/ne_misc_dev_test.c | 5 +-
include/kunit/test.h | 63 ++-----
include/linux/module.h | 5 +
include/linux/panic.h | 3 +-
kernel/kcsan/.kunitconfig | 24 +++
kernel/module/main.c | 13 ++
kernel/panic.c | 1 +
lib/kunit/executor.c | 125 ++++----------
lib/kunit/executor_test.c | 144 +++++-----------
lib/kunit/test.c | 58 ++++++-
scripts/mod/modpost.c | 3 +
security/apparmor/policy_unpack_test.c | 12 +-
tools/testing/kunit/configs/arch_uml.config | 5 +
tools/testing/kunit/configs/coverage_uml.config | 11 ++
tools/testing/kunit/kunit.py | 83 +++++----
tools/testing/kunit/kunit_config.py | 54 +++---
tools/testing/kunit/kunit_kernel.py | 104 +++++++-----
tools/testing/kunit/kunit_parser.py | 63 +++----
tools/testing/kunit/kunit_printer.py | 48 ++++++
tools/testing/kunit/kunit_tool_test.py | 214 +++++++++++++++---------
tools/testing/selftests/kselftest_module.h | 4 +
36 files changed, 657 insertions(+), 592 deletions(-)
create mode 100644 kernel/kcsan/.kunitconfig
create mode 100644 tools/testing/kunit/configs/arch_uml.config
create mode 100644 tools/testing/kunit/configs/coverage_uml.config
create mode 100644 tools/testing/kunit/kunit_printer.py
----------------------------------------------------------------
Currently, in order to compare memory blocks in KUnit, the KUNIT_EXPECT_EQ or
KUNIT_EXPECT_FALSE macros are used in conjunction with the memcmp function,
such as:
KUNIT_EXPECT_EQ(test, memcmp(foo, bar, size), 0);
Although this usage produces correct results for the test cases, if the
expectation fails the error message is not very helpful, indicating only the
return of the memcmp function.
Therefore, create a new set of macros KUNIT_EXPECT_MEMEQ and
KUNIT_EXPECT_MEMNEQ that compare memory blocks until a determined size. In
case of expectation failure, those macros print the hex dump of the memory
blocks, making it easier to debug test failures for memory blocks.
For example, if I am using the KUNIT_EXPECT_MEMEQ macro and apply the
following diff (introducing a test failure) to the
drm/tests/drm_format_helper.c:
diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c
index 3106abb3bead..942aa131a768 100644
--- a/drivers/gpu/drm/tests/drm_format_helper_test.c
+++ b/drivers/gpu/drm/tests/drm_format_helper_test.c
@@ -131,9 +131,9 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
.rgb565_result = {
.dst_pitch = 10,
.expected = {
- 0x0A33, 0x1260, 0xA800, 0x0000, 0x0000,
- 0x6B8E, 0x0A33, 0x1260, 0x0000, 0x0000,
- 0xA800, 0x6B8E, 0x0A33, 0x0000, 0x0000,
+ 0x0A31, 0x1260, 0xA800, 0x0000, 0x0000,
+ 0x6B81, 0x0A33, 0x1260, 0x0000, 0x0000,
+ 0xA801, 0x6B8E, 0x0A33, 0x0000, 0x0000,
},
.expected_swab = {
0x330A, 0x6012, 0x00A8, 0x0000, 0x0000,}}}
I will get a test failure with the following form:
➜ ./tools/testing/kunit/kunit.py run --kunitconfig=drivers/gpu/drm/tests \
--kconfig_add CONFIG_UML_PCI_OVER_VIRTIO=y --kconfig_add CONFIG_VIRTIO_UML=y \
'drm_format_helper_test'
[...]
[18:15:35] ================= xrgb8888_to_rgb565_test ==================
[18:15:35] [PASSED] single_pixel_source_buffer
[18:15:35] [PASSED] single_pixel_clip_rectangle
[18:15:35] [PASSED] well_known_colors
[18:15:35] # xrgb8888_to_rgb565_test: EXPECTATION FAILED at drivers/gpu/drm/tests/drm_format_helper_test.c:248
[18:15:35] Expected dst == result->expected, but
[18:15:35] dst ==
[18:15:35] <33> 0a 60 12 00 a8 00 00 00 00 <8e> 6b 33 0a 60 12
[18:15:35] 00 00 00 00 <00> a8 8e 6b 33 0a 00 00 00 00
[18:15:35] result->expected ==
[18:15:35] <31> 0a 60 12 00 a8 00 00 00 00 <81> 6b 33 0a 60 12
[18:15:35] 00 00 00 00 <01> a8 8e 6b 33 0a 00 00 00 00
[18:15:35] not ok 4 - destination_pitch
[18:15:35] [FAILED] destination_pitch
[18:15:35] # Subtest: xrgb8888_to_rgb565_test
[18:15:35] # xrgb8888_to_rgb565_test: pass:3 fail:1 skip:0 total:4
[18:15:35] not ok 2 - xrgb8888_to_rgb565_test
[...]
[18:15:35] ============= [FAILED] drm_format_helper_test ==============
[18:15:35] ============================================================
[18:15:35] Testing complete. Ran 8 tests: passed: 7, failed: 1
[18:15:35] Elapsed time: 3.148s total, 0.002s configuring, 3.031s building, 0.090s running
Noticed that, with the hex dump, it is possible to check which bytes are
making the test fail. So, it is easier to debug the cause of the failure.
Moreover, on this v2, the differed bytes are marked with a <>, to ease the
identication of the differences. The bytes are not ideally aligned, but the
marks, suggested by Daniel, are very helpful.
The first patch of the series introduces the KUNIT_EXPECT_MEMEQ and
KUNIT_EXPECT_MEMNEQ. The second patch adds an example of memory block
expectations on the kunit-example-test.c. And the last patch replaces the
KUNIT_EXPECT_EQ for KUNIT_EXPECT_MEMEQ on the existing occurrences.
Best Regards,
- Maíra Canal
v1 -> v2: https://lore.kernel.org/linux-kselftest/2a0dcd75-5461-5266-2749-808f638f4c5…
- Change "determinated" to "specified" (Daniel Latypov).
- Change the macro KUNIT_EXPECT_ARREQ to KUNIT_EXPECT_MEMEQ, in order to make
it easier for users to infer the right size unit (Daniel Latypov).
- Mark the different bytes on the failure message with a <> (Daniel Latypov).
- Replace a constant number of array elements for ARRAY_SIZE() (André Almeida).
- Rename "array" and "expected" variables to "array1" and "array2" (Daniel Latypov).
Maíra Canal (3):
kunit: Introduce KUNIT_EXPECT_MEMEQ and KUNIT_EXPECT_MEMNEQ macros
kunit: Add KUnit memory block assertions to the example_all_expect_macros_test
kunit: Use KUNIT_EXPECT_MEMEQ macro
.../gpu/drm/tests/drm_format_helper_test.c | 6 +-
include/kunit/assert.h | 35 +++++++++
include/kunit/test.h | 76 +++++++++++++++++++
lib/kunit/assert.c | 54 +++++++++++++
lib/kunit/kunit-example-test.c | 7 ++
net/core/dev_addr_lists_test.c | 4 +-
6 files changed, 177 insertions(+), 5 deletions(-)
--
2.37.1
Currently, in order to compare arrays in KUnit, the KUNIT_EXPECT_EQ or
KUNIT_EXPECT_FALSE macros are used in conjunction with the memcmp function,
such as:
KUNIT_EXPECT_EQ(test, memcmp(foo, bar, size), 0);
Although this usage produces correct results for the test cases, if the
expectation fails the error message is not very helpful, indicating only the
return of the memcmp function.
Therefore, create a new set of macros KUNIT_EXPECT_ARREQ and
KUNIT_EXPECT_ARRNEQ that compare memory blocks until a determined size. In
case of expectation failure, those macros print the hex dump of the memory
blocks, making it easier to debug test failures for arrays.
For example, if I am using the KUNIT_EXPECT_ARREQ macro and apply the
following diff (introducing a test failure) to the
drm/tests/drm_format_helper.c:
diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c
index 3106abb3bead..942aa131a768 100644
--- a/drivers/gpu/drm/tests/drm_format_helper_test.c
+++ b/drivers/gpu/drm/tests/drm_format_helper_test.c
@@ -131,9 +131,9 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
.rgb565_result = {
.dst_pitch = 10,
.expected = {
- 0x0A33, 0x1260, 0xA800, 0x0000, 0x0000,
- 0x6B8E, 0x0A33, 0x1260, 0x0000, 0x0000,
- 0xA800, 0x6B8E, 0x0A33, 0x0000, 0x0000,
+ 0x0A31, 0x1260, 0xA800, 0x0000, 0x0000,
+ 0x6B81, 0x0A33, 0x1260, 0x0000, 0x0000,
+ 0xA801, 0x6B8E, 0x0A33, 0x0000, 0x0000,
},
.expected_swab = {
0x330A, 0x6012, 0x00A8, 0x0000, 0x0000,}}}
I will get a test failure with the following form:
➜ ./tools/testing/kunit/kunit.py run --kunitconfig=drivers/gpu/drm/tests \
--kconfig_add CONFIG_UML_PCI_OVER_VIRTIO=y --kconfig_add CONFIG_VIRTIO_UML=y \
'drm_format_helper_test'
[...]
[12:38:20] ================= xrgb8888_to_rgb565_test ==================
[12:38:20] [PASSED] single_pixel_source_buffer
[12:38:20] [PASSED] single_pixel_clip_rectangle
[12:38:20] [PASSED] well_known_colors
[12:38:20] # xrgb8888_to_rgb565_test: EXPECTATION FAILED at drivers/gpu/drm/tests/drm_format_helper_test.c:248
[12:38:20] Expected dst == result->expected, but
[12:38:20] dst ==
[12:38:20] 00000000: 33 0a 60 12 00 a8 00 00 00 00 8e 6b 33 0a 60 12
[12:38:20] 00000010: 00 00 00 00 00 a8 8e 6b 33 0a 00 00 00 00
[12:38:20] result->expected ==
[12:38:20] 00000000: 31 0a 60 12 00 a8 00 00 00 00 81 6b 33 0a 60 12
[12:38:20] 00000010: 00 00 00 00 01 a8 8e 6b 33 0a 00 00 00 00
[12:38:20] not ok 4 - destination_pitch
[12:38:20] [FAILED] destination_pitch
[12:38:20] # Subtest: xrgb8888_to_rgb565_test
[12:38:20] # xrgb8888_to_rgb565_test: pass:3 fail:1 skip:0 total:4
[12:38:20] not ok 2 - xrgb8888_to_rgb565_test
[...]
[12:38:20] ============= [FAILED] drm_format_helper_test ==============
[12:38:20] ============================================================
[12:38:20] Testing complete. Ran 8 tests: passed: 7, failed: 1
[12:38:20] Elapsed time: 3.713s total, 0.002s configuring, 3.546s building, 0.135s running
Noticed that, with the hex dump, it is possible to check which bytes are
making the test fail. So, it is easier to debug the cause of the failure.
The first patch of the series introduces the KUNIT_EXPECT_ARREQ and
KUNIT_EXPECT_ARRNEQ. The second patch adds an example of array expectations
on the kunit-example-test.c. And the last patch replaces the KUNIT_EXPECT_EQ
for KUNIT_EXPECT_ARREQ on the existing occurrences.
Best Regards,
- Maíra Canal
Maíra Canal (3):
kunit: Introduce KUNIT_EXPECT_ARREQ and KUNIT_EXPECT_ARRNEQ macros
kunit: add KUnit array assertions to the example_all_expect_macros_test
kunit: use KUNIT_EXPECT_ARREQ macro
.../gpu/drm/tests/drm_format_helper_test.c | 6 +-
include/kunit/assert.h | 35 +++++++++
include/kunit/test.h | 76 +++++++++++++++++++
lib/kunit/assert.c | 43 +++++++++++
lib/kunit/kunit-example-test.c | 7 ++
net/core/dev_addr_lists_test.c | 4 +-
6 files changed, 166 insertions(+), 5 deletions(-)
--
2.37.1
This series is based on torvalds/master.
The series is split up like so:
- Patch 1 is a simple fixup which we should take in any case (even by itself).
- Patches 2-6 add the feature, configurable selftest support, and docs.
Why not ...?
============
- Why not /proc/[pid]/userfaultfd? The proposed use case for this is for one
process to open a userfaultfd which can intercept another process' page
faults. This seems to me like exactly what CAP_SYS_PTRACE is for, though, so I
think this use case can simply use a syscall without the powers CAP_SYS_PTRACE
grants being "too much".
- Why not use a syscall? Access to syscalls is generally controlled by
capabilities. We don't have a capability which is used for userfaultfd access
without also granting more / other permissions as well, and adding a new
capability was rejected [1].
- It's possible a LSM could be used to control access instead. I suspect
adding a brand new one just for this would be rejected, but I think some
existing ones like SELinux can be used to filter syscall access. Enabling
SELinux for large production deployments which don't already use it is
likely to be a huge undertaking though, and I don't think this use case by
itself is enough to motivate that kind of architectural change.
Changelog
=========
v3->v4:
- Picked up an Acked-by on 5/5.
- Updated cover letter to cover "why not ...".
- Refactored userfaultfd_allowed() into userfaultfd_syscall_allowed(). [Peter]
- Removed obsolete comment from a previous version. [Peter]
- Refactored userfaultfd_open() in selftest. [Peter]
- Reworded admin-guide documentation. [Mike, Peter]
- Squashed 2 commits adding /dev/userfaultfd to selftest and making selftest
configurable. [Peter]
- Added "syscall" test modifier (the default behavior) to selftest. [Peter]
v2->v3:
- Rebased onto linux-next/akpm-base, in order to be based on top of the
run_vmtests.sh refactor which was merged previously.
- Picked up some Reviewed-by's.
- Fixed ioctl definition (_IO instead of _IOWR), and stopped using
compat_ptr_ioctl since it is unneeded for ioctls which don't take a pointer.
- Removed the "handle_kernel_faults" bool, simplifying the code. The result is
logically equivalent, but simpler.
- Fixed userfaultfd selftest so it returns KSFT_SKIP appropriately.
- Reworded documentation per Shuah's feedback on v2.
- Improved example usage for userfaultfd selftest.
v1->v2:
- Add documentation update.
- Test *both* userfaultfd(2) and /dev/userfaultfd via the selftest.
[1]: https://lore.kernel.org/lkml/686276b9-4530-2045-6bd8-170e5943abe4@schaufler…
Axel Rasmussen (5):
selftests: vm: add hugetlb_shared userfaultfd test to run_vmtests.sh
userfaultfd: add /dev/userfaultfd for fine grained access control
userfaultfd: selftests: modify selftest to use /dev/userfaultfd
userfaultfd: update documentation to describe /dev/userfaultfd
selftests: vm: add /dev/userfaultfd test cases to run_vmtests.sh
Documentation/admin-guide/mm/userfaultfd.rst | 41 +++++++++++-
Documentation/admin-guide/sysctl/vm.rst | 3 +
fs/userfaultfd.c | 69 ++++++++++++++++----
include/uapi/linux/userfaultfd.h | 4 ++
tools/testing/selftests/vm/run_vmtests.sh | 11 +++-
tools/testing/selftests/vm/userfaultfd.c | 69 +++++++++++++++++---
6 files changed, 169 insertions(+), 28 deletions(-)
--
2.37.0.170.g444d1eabd0-goog