This patch fixes an encoding bug in emit_stx for BPF_B when the source
register is BPF_REG_FP.
The current implementation for BPF_STX BPF_B in emit_stx saves one REX
byte when the operands can be encoded using Mod-R/M alone. The lower 8
bits of registers %rax, %rbx, %rcx, and %rdx can be accessed without using
a REX prefix via %al, %bl, %cl, and %dl, respectively. Other registers,
(e.g., %rsi, %rdi, %rbp, %rsp) require a REX prefix to use their 8-bit
equivalents (%sil, %dil, %bpl, %spl).
The current code checks if the source for BPF_STX BPF_B is BPF_REG_1
or BPF_REG_2 (which map to %rdi and %rsi), in which case it emits the
required REX prefix. However, it misses the case when the source is
BPF_REG_FP (mapped to %rbp).
The result is that BPF_STX BPF_B with BPF_REG_FP as the source operand
will read from register %ch instead of the correct %bpl. This patch fixes
the problem by fixing and refactoring the check on which registers need
the extra REX byte. Since no BPF registers map to %rsp, there is no need
to handle %spl.
Fixes: 622582786c9e0 ("net: filter: x86: internal BPF JIT")
Signed-off-by: Xi Wang <xi.wang(a)gmail.com>
Signed-off-by: Luke Nelson <luke.r.nels(a)gmail.com>
---
arch/x86/net/bpf_jit_comp.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
index 5ea7c2cf7ab4..42b6709e6dc7 100644
--- a/arch/x86/net/bpf_jit_comp.c
+++ b/arch/x86/net/bpf_jit_comp.c
@@ -158,6 +158,19 @@ static bool is_ereg(u32 reg)
BIT(BPF_REG_AX));
}
+/*
+ * is_ereg_8l() == true if BPF register 'reg' is mapped to access x86-64
+ * lower 8-bit registers dil,sil,bpl,spl,r8b..r15b, which need extra byte
+ * of encoding. al,cl,dl,bl have simpler encoding.
+ */
+static bool is_ereg_8l(u32 reg)
+{
+ return is_ereg(reg) ||
+ (1 << reg) & (BIT(BPF_REG_1) |
+ BIT(BPF_REG_2) |
+ BIT(BPF_REG_FP));
+}
+
static bool is_axreg(u32 reg)
{
return reg == BPF_REG_0;
@@ -598,9 +611,8 @@ static void emit_stx(u8 **pprog, u32 size, u32 dst_reg, u32 src_reg, int off)
switch (size) {
case BPF_B:
/* Emit 'mov byte ptr [rax + off], al' */
- if (is_ereg(dst_reg) || is_ereg(src_reg) ||
- /* We have to add extra byte for x86 SIL, DIL regs */
- src_reg == BPF_REG_1 || src_reg == BPF_REG_2)
+ if (is_ereg(dst_reg) || is_ereg_8l(src_reg))
+ /* Add extra byte for eregs or SIL,DIL,BPL in src_reg */
EMIT2(add_2mod(0x40, dst_reg, src_reg), 0x88);
else
EMIT1(0x88);
--
2.17.1
From: Heikki Krogerus <heikki.krogerus(a)linux.intel.com>
Previously, kobjects were released before the associated kobj_types;
this can cause a kobject deallocation to fail when the kobject has
children; an example of this is in software_node_unregister_nodes(); it
calls release on the parent before children meaning that children can be
released after the parent, which may be needed for removal.
So, take a reference to the parent before we delete a node to ensure
that the parent is not released before the children.
Reported-by: Naresh Kamboju <naresh.kamboju(a)linaro.org>
Fixes: 7589238a8cf3 ("Revert "software node: Simplify software_node_release() function"")
Link: https://lore.kernel.org/linux-kselftest/CAFd5g44s5NQvT8TG_x4rwbqoa7zWzkV0TX…
Co-developed-by: Brendan Higgins <brendanhiggins(a)google.com>
Signed-off-by: Brendan Higgins <brendanhiggins(a)google.com>
---
This patch is based on the diff written by Heikki linked above.
Heikki, can you either reply with a Signed-off-by? Otherwise, I can
resend with me as the author and I will list you as the Co-developed-by.
Sorry for all the CCs: I just want to make sure everyone who was a party
to the original bug sees this.
---
lib/kobject.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/lib/kobject.c b/lib/kobject.c
index 83198cb37d8d..5921e2470b46 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -663,6 +663,7 @@ EXPORT_SYMBOL(kobject_get_unless_zero);
*/
static void kobject_cleanup(struct kobject *kobj)
{
+ struct kobject *parent = kobj->parent;
struct kobj_type *t = get_ktype(kobj);
const char *name = kobj->name;
@@ -680,6 +681,9 @@ static void kobject_cleanup(struct kobject *kobj)
kobject_uevent(kobj, KOBJ_REMOVE);
}
+ /* make sure the parent is not released before the (last) child */
+ kobject_get(parent);
+
/* remove from sysfs if the caller did not do it */
if (kobj->state_in_sysfs) {
pr_debug("kobject: '%s' (%p): auto cleanup kobject_del\n",
@@ -693,6 +697,8 @@ static void kobject_cleanup(struct kobject *kobj)
t->release(kobj);
}
+ kobject_put(parent);
+
/* free name if we allocated it */
if (name) {
pr_debug("kobject: '%s': free name\n", name);
base-commit: 8632e9b5645bbc2331d21d892b0d6961c1a08429
--
2.26.0.110.g2183baf09c-goog
From: Colin Ian King <colin.king(a)canonical.com>
There a are several spelling mistakes in various messages. Fix these.
There are three spelling mistakes in various messages. Fix these.
Signed-off-by: Colin Ian King <colin.king(a)canonical.com>
---
tools/testing/selftests/vm/khugepaged.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/tools/testing/selftests/vm/khugepaged.c b/tools/testing/selftests/vm/khugepaged.c
index 490055290d7f..399a67d54e52 100644
--- a/tools/testing/selftests/vm/khugepaged.c
+++ b/tools/testing/selftests/vm/khugepaged.c
@@ -537,7 +537,7 @@ static void collapse_max_ptes_none(void)
p = alloc_mapping();
fill_memory(p, 0, (hpage_pmd_nr - max_ptes_none - 1) * page_size);
- if (wait_for_scan("Do not collapse with max_ptes_none exeeded", p))
+ if (wait_for_scan("Do not collapse with max_ptes_none exceeded", p))
fail("Timeout");
else if (check_huge(p))
fail("Fail");
@@ -576,7 +576,7 @@ static void collapse_swapin_single_pte(void)
goto out;
}
- if (wait_for_scan("Collapse with swaping in single PTE entry", p))
+ if (wait_for_scan("Collapse with swapping in single PTE entry", p))
fail("Timeout");
else if (check_huge(p))
success("OK");
@@ -607,7 +607,7 @@ static void collapse_max_ptes_swap(void)
goto out;
}
- if (wait_for_scan("Do not collapse with max_ptes_swap exeeded", p))
+ if (wait_for_scan("Do not collapse with max_ptes_swap exceeded", p))
fail("Timeout");
else if (check_huge(p))
fail("Fail");
@@ -654,14 +654,14 @@ static void collapse_single_pte_entry_compound(void)
fail("Fail");
madvise(p, hpage_pmd_size, MADV_NOHUGEPAGE);
- printf("Split huge page leaving single PTE mapping compount page...");
+ printf("Split huge page leaving single PTE mapping compound page...");
madvise(p + page_size, hpage_pmd_size - page_size, MADV_DONTNEED);
if (!check_huge(p))
success("OK");
else
fail("Fail");
- if (wait_for_scan("Collapse PTE table with single PTE mapping compount page", p))
+ if (wait_for_scan("Collapse PTE table with single PTE mapping compound page", p))
fail("Timeout");
else if (check_huge(p))
success("OK");
@@ -685,7 +685,7 @@ static void collapse_full_of_compound(void)
else
fail("Fail");
- printf("Split huge page leaving single PTE page table full of compount pages...");
+ printf("Split huge page leaving single PTE page table full of compound pages...");
madvise(p, page_size, MADV_NOHUGEPAGE);
madvise(p, hpage_pmd_size, MADV_NOHUGEPAGE);
if (!check_huge(p))
@@ -908,7 +908,7 @@ static void collapse_max_ptes_shared()
else
fail("Fail");
- if (wait_for_scan("Do not collapse with max_ptes_shared exeeded", p))
+ if (wait_for_scan("Do not collapse with max_ptes_shared exceeded", p))
fail("Timeout");
else if (!check_huge(p))
success("OK");
--
2.25.1
This series adds basic self tests for HMM and are intended for Jason
Gunthorpe's rdma tree since I believe he is planning to make some HMM
related changes that this can help test.
Changes v8 -> v9:
Rebased to linux-5.7.0-rc1.
Moved include/uapi/linux/test_hmm.h to lib/test_hmm_uapi.h
Added calls to release_mem_region() to free device private addresses
Applied Jason's suggested changes for v8.
Added a check for no VMA read access before migrating to device private
memory.
Changes v7 -> v8:
Rebased to Jason's rdma/hmm tree, plus Jason's 6 patch series
"Small hmm_range_fault() cleanups".
Applied a number of changes from Jason's comments.
Changes v6 -> v7:
Rebased to linux-5.6.0-rc6
Reverted back to just using mmu_interval_notifier_insert() and making
this series only introduce HMM self tests.
Changes v5 -> v6:
Rebased to linux-5.5.0-rc6
Refactored mmu interval notifier patches
Converted nouveau to use the new mmu interval notifier API
Changes v4 -> v5:
Added mmu interval notifier insert/remove/update callable from the
invalidate() callback
Updated HMM tests to use the new core interval notifier API
Changes v1 -> v4:
https://lore.kernel.org/linux-mm/20191104222141.5173-1-rcampbell@nvidia.com
Ralph Campbell (3):
mm/hmm/test: add selftest driver for HMM
mm/hmm/test: add selftests for HMM
MAINTAINERS: add HMM selftests
MAINTAINERS | 3 +
lib/Kconfig.debug | 13 +
lib/Makefile | 1 +
lib/test_hmm.c | 1175 ++++++++++++++++++++
lib/test_hmm_uapi.h | 59 +
tools/testing/selftests/vm/.gitignore | 1 +
tools/testing/selftests/vm/Makefile | 3 +
tools/testing/selftests/vm/config | 2 +
tools/testing/selftests/vm/hmm-tests.c | 1359 ++++++++++++++++++++++++
tools/testing/selftests/vm/run_vmtests | 16 +
tools/testing/selftests/vm/test_hmm.sh | 97 ++
11 files changed, 2729 insertions(+)
create mode 100644 lib/test_hmm.c
create mode 100644 lib/test_hmm_uapi.h
create mode 100644 tools/testing/selftests/vm/hmm-tests.c
create mode 100755 tools/testing/selftests/vm/test_hmm.sh
--
2.25.2
Hello Brendan Higgins,
The patch 5f3e06208920: "kunit: test: add support for test abort"
from Sep 23, 2019, leads to the following static checker warning:
lib/kunit/try-catch.c:93 kunit_try_catch_run()
misplaced newline? ' # %s: Unknown error: %d
lib/kunit/try-catch.c
58 void kunit_try_catch_run(struct kunit_try_catch *try_catch, void *context)
59 {
60 DECLARE_COMPLETION_ONSTACK(try_completion);
61 struct kunit *test = try_catch->test;
62 struct task_struct *task_struct;
63 int exit_code, time_remaining;
64
65 try_catch->context = context;
66 try_catch->try_completion = &try_completion;
67 try_catch->try_result = 0;
68 task_struct = kthread_run(kunit_generic_run_threadfn_adapter,
69 try_catch,
70 "kunit_try_catch_thread");
71 if (IS_ERR(task_struct)) {
72 try_catch->catch(try_catch->context);
73 return;
74 }
75
76 time_remaining = wait_for_completion_timeout(&try_completion,
77 kunit_test_timeout());
78 if (time_remaining == 0) {
79 kunit_err(test, "try timed out\n");
^^
The kunit_log() macro adds its own newline. Most of the callers add
a newline. It should be the callers add a newline because that's how
everything else works in the kernel.
The dev_printk() stuff will sometimes add a newline, but never a
duplicate newline. In other words, it's slightly complicated. But
basically the caller should add a newline.
80 try_catch->try_result = -ETIMEDOUT;
81 }
82
83 exit_code = try_catch->try_result;
84
85 if (!exit_code)
86 return;
87
88 if (exit_code == -EFAULT)
89 try_catch->try_result = 0;
90 else if (exit_code == -EINTR)
91 kunit_err(test, "wake_up_process() was never called\n");
^^
92 else if (exit_code)
93 kunit_err(test, "Unknown error: %d\n", exit_code);
^^
94
95 try_catch->catch(try_catch->context);
96 }
regards,
dan carpenter
> It should set config->test_fs instead of config->test_driver as NULL
> after kfree_const(config->test_fs) to avoid potential double free.
I suggest to improve this change description.
* How do you think about a wording variant like the following?
Reset the member “test_fs” of the test configuration after a call
of the function “kfree_const” to a null pointer so that a double
memory release will not be performed.
* Would you like to add the tag “Fixes”?
Regards,
Markus
From: "Steven Rostedt (VMware)" <rostedt(a)goodmis.org>
[ Upstream commit b43e78f65b1d35fd3e13c7b23f9b64ea83c9ad3a ]
As the ftrace selftests can run for a long period of time, disable the
timeout that the general selftests have. If a selftest hangs, then it
probably means the machine will hang too.
Link: https://lore.kernel.org/r/alpine.LSU.2.21.1911131604170.18679@pobox.suse.cz
Suggested-by: Miroslav Benes <mbenes(a)suse.cz>
Tested-by: Miroslav Benes <mbenes(a)suse.cz>
Reviewed-by: Miroslav Benes <mbenes(a)suse.cz>
Signed-off-by: Steven Rostedt (VMware) <rostedt(a)goodmis.org>
Signed-off-by: Sasha Levin <sashal(a)kernel.org>
---
tools/testing/selftests/ftrace/settings | 1 +
1 file changed, 1 insertion(+)
create mode 100644 tools/testing/selftests/ftrace/settings
diff --git a/tools/testing/selftests/ftrace/settings b/tools/testing/selftests/ftrace/settings
new file mode 100644
index 0000000000000..e7b9417537fbc
--- /dev/null
+++ b/tools/testing/selftests/ftrace/settings
@@ -0,0 +1 @@
+timeout=0
--
2.20.1
From: "Steven Rostedt (VMware)" <rostedt(a)goodmis.org>
[ Upstream commit b43e78f65b1d35fd3e13c7b23f9b64ea83c9ad3a ]
As the ftrace selftests can run for a long period of time, disable the
timeout that the general selftests have. If a selftest hangs, then it
probably means the machine will hang too.
Link: https://lore.kernel.org/r/alpine.LSU.2.21.1911131604170.18679@pobox.suse.cz
Suggested-by: Miroslav Benes <mbenes(a)suse.cz>
Tested-by: Miroslav Benes <mbenes(a)suse.cz>
Reviewed-by: Miroslav Benes <mbenes(a)suse.cz>
Signed-off-by: Steven Rostedt (VMware) <rostedt(a)goodmis.org>
Signed-off-by: Sasha Levin <sashal(a)kernel.org>
---
tools/testing/selftests/ftrace/settings | 1 +
1 file changed, 1 insertion(+)
create mode 100644 tools/testing/selftests/ftrace/settings
diff --git a/tools/testing/selftests/ftrace/settings b/tools/testing/selftests/ftrace/settings
new file mode 100644
index 0000000000000..e7b9417537fbc
--- /dev/null
+++ b/tools/testing/selftests/ftrace/settings
@@ -0,0 +1 @@
+timeout=0
--
2.20.1
Hi,
My name is felix. I have a quick and easy business offer that
will benefit us both immensely. The amount involved is over 9.4
Milli0n in US d0llars.
I await your immediate reply so that I can give full details.
Rgds
Felix
This introduces a test case to check memory slots with overlapped
regions on the guest address cannot be added. The cases checked
are described in the block comment upon test_overlap_memory_regions()
(see the patch 01).
I didn't see the need to calcute the addresses on compile/run-time, so I
just left them hard-coded (remember: aligned 1M to work on s390x).
It works on x86_64, aarch64, and s390x.
The patch is based on queue branch.
Ah, I did some cosmetic changes on test_add_max_memory_regions() too. If
it is not OK to be in a single patch...let me know.
Wainer dos Santos Moschetta (1):
selftests: kvm: Add overlapped memory regions test
.../selftests/kvm/set_memory_region_test.c | 75 ++++++++++++++++++-
1 file changed, 74 insertions(+), 1 deletion(-)
--
2.17.2
Hi,
This new patch series brings some improvements while simplifying the
code, fixes some bugs and adds more tests:
Use a bitfield of layers to properly manage superset and subset of
access rights, whatever their order in the stack of layers [1].
Allow to open pipes and similar special files through /proc/self/fd, as
well as internal filesystems such as nsfs through /proc/self/ns, because
disconnected path cannot be evaluated. Such special filesystems could
be handled with a future evolution.
For the sake of simplicity, forbid reparenting when linking or renaming
to protect against possible privilege escalation. This could happen by
changing the hierarchy of a file or directory in relation to an enforced
access policy (from the set of layers). This will be relaxed in the
future with more complex code.
Rename the unlink and rmdir access rights to a more generic ones:
remove_dir and remove_file. Indeed it makes sense to also use them for
the action of renaming a file or a directory, which may lead to the
removal of the source file or directory. Replace the link_to,
rename_from and rename_to access rights with remove_file, remove_dir and
make_* .
Add multiple tests to check semantic, and improve test coverage for
security/landlock to 94.1% of lines (best possible with deterministic
user space tests).
Add current limitations to documentation: file renaming and linking,
OverlayFS and special filesystems (e.g. nsfs).
The previously identified memory accounting limitation can already be
solved with the (kernel) Memory Resource Controller from cgroup.
The SLOC count is 1267 for security/landlock/ and 1643 for
tools/testing/selftest/landlock/ .
The compiled documentation is available here:
https://landlock.io/linux-doc/landlock-v16/security/landlock/index.html
This series can be applied on top of v5.7-rc1. This can be tested with
CONFIG_SECURITY_LANDLOCK and CONFIG_SAMPLE_LANDLOCK. This patch series
can be found in a Git repository here:
https://github.com/landlock-lsm/linux/commits/landlock-v16
I would really appreciate constructive comments on this patch series.
# Landlock LSM
The goal of Landlock is to enable to restrict ambient rights (e.g.
global filesystem access) for a set of processes. Because Landlock is a
stackable LSM [2], it makes possible to create safe security sandboxes
as new security layers in addition to the existing system-wide
access-controls. This kind of sandbox is expected to help mitigate the
security impact of bugs or unexpected/malicious behaviors in user-space
applications. Landlock empowers any process, including unprivileged
ones, to securely restrict themselves.
Landlock is inspired by seccomp-bpf but instead of filtering syscalls
and their raw arguments, a Landlock rule can restrict the use of kernel
objects like file hierarchies, according to the kernel semantic.
Landlock also takes inspiration from other OS sandbox mechanisms: XNU
Sandbox, FreeBSD Capsicum or OpenBSD Pledge/Unveil.
Previous version:
https://lore.kernel.org/lkml/20200326202731.693608-1-mic@digikod.net/
[1] https://lore.kernel.org/lkml/e07fe473-1801-01cc-12ae-b3167f95250e@digikod.n…
[2] https://lore.kernel.org/lkml/50db058a-7dde-441b-a7f9-f6837fe8b69f@schaufler…
Regards,
Mickaël Salaün (10):
landlock: Add object management
landlock: Add ruleset and domain management
landlock: Set up the security framework and manage credentials
landlock: Add ptrace restrictions
fs,landlock: Support filesystem access-control
landlock: Add syscall implementation
arch: Wire up landlock() syscall
selftests/landlock: Add initial tests
samples/landlock: Add a sandbox manager example
landlock: Add user and kernel documentation
Documentation/security/index.rst | 1 +
Documentation/security/landlock/index.rst | 18 +
Documentation/security/landlock/kernel.rst | 69 +
Documentation/security/landlock/user.rst | 268 +++
MAINTAINERS | 12 +
arch/alpha/kernel/syscalls/syscall.tbl | 1 +
arch/arm/tools/syscall.tbl | 1 +
arch/arm64/include/asm/unistd.h | 2 +-
arch/arm64/include/asm/unistd32.h | 2 +
arch/ia64/kernel/syscalls/syscall.tbl | 1 +
arch/m68k/kernel/syscalls/syscall.tbl | 1 +
arch/microblaze/kernel/syscalls/syscall.tbl | 1 +
arch/mips/kernel/syscalls/syscall_n32.tbl | 1 +
arch/mips/kernel/syscalls/syscall_n64.tbl | 1 +
arch/mips/kernel/syscalls/syscall_o32.tbl | 1 +
arch/parisc/kernel/syscalls/syscall.tbl | 1 +
arch/powerpc/kernel/syscalls/syscall.tbl | 1 +
arch/s390/kernel/syscalls/syscall.tbl | 1 +
arch/sh/kernel/syscalls/syscall.tbl | 1 +
arch/sparc/kernel/syscalls/syscall.tbl | 1 +
arch/x86/entry/syscalls/syscall_32.tbl | 1 +
arch/x86/entry/syscalls/syscall_64.tbl | 1 +
arch/xtensa/kernel/syscalls/syscall.tbl | 1 +
fs/super.c | 2 +
include/linux/fs.h | 5 +
include/linux/landlock.h | 22 +
include/linux/syscalls.h | 3 +
include/uapi/asm-generic/unistd.h | 4 +-
include/uapi/linux/landlock.h | 296 +++
kernel/sys_ni.c | 3 +
samples/Kconfig | 7 +
samples/Makefile | 1 +
samples/landlock/.gitignore | 1 +
samples/landlock/Makefile | 15 +
samples/landlock/sandboxer.c | 228 +++
security/Kconfig | 11 +-
security/Makefile | 2 +
security/landlock/Kconfig | 18 +
security/landlock/Makefile | 4 +
security/landlock/common.h | 20 +
security/landlock/cred.c | 46 +
security/landlock/cred.h | 58 +
security/landlock/fs.c | 601 ++++++
security/landlock/fs.h | 42 +
security/landlock/object.c | 66 +
security/landlock/object.h | 91 +
security/landlock/ptrace.c | 120 ++
security/landlock/ptrace.h | 14 +
security/landlock/ruleset.c | 344 ++++
security/landlock/ruleset.h | 161 ++
security/landlock/setup.c | 39 +
security/landlock/setup.h | 18 +
security/landlock/syscall.c | 501 +++++
tools/testing/selftests/Makefile | 1 +
tools/testing/selftests/landlock/.gitignore | 4 +
tools/testing/selftests/landlock/Makefile | 29 +
tools/testing/selftests/landlock/common.h | 42 +
tools/testing/selftests/landlock/config | 5 +
tools/testing/selftests/landlock/test_base.c | 156 ++
tools/testing/selftests/landlock/test_fs.c | 1696 +++++++++++++++++
.../testing/selftests/landlock/test_ptrace.c | 291 +++
tools/testing/selftests/landlock/true.c | 5 +
62 files changed, 5353 insertions(+), 7 deletions(-)
create mode 100644 Documentation/security/landlock/index.rst
create mode 100644 Documentation/security/landlock/kernel.rst
create mode 100644 Documentation/security/landlock/user.rst
create mode 100644 include/linux/landlock.h
create mode 100644 include/uapi/linux/landlock.h
create mode 100644 samples/landlock/.gitignore
create mode 100644 samples/landlock/Makefile
create mode 100644 samples/landlock/sandboxer.c
create mode 100644 security/landlock/Kconfig
create mode 100644 security/landlock/Makefile
create mode 100644 security/landlock/common.h
create mode 100644 security/landlock/cred.c
create mode 100644 security/landlock/cred.h
create mode 100644 security/landlock/fs.c
create mode 100644 security/landlock/fs.h
create mode 100644 security/landlock/object.c
create mode 100644 security/landlock/object.h
create mode 100644 security/landlock/ptrace.c
create mode 100644 security/landlock/ptrace.h
create mode 100644 security/landlock/ruleset.c
create mode 100644 security/landlock/ruleset.h
create mode 100644 security/landlock/setup.c
create mode 100644 security/landlock/setup.h
create mode 100644 security/landlock/syscall.c
create mode 100644 tools/testing/selftests/landlock/.gitignore
create mode 100644 tools/testing/selftests/landlock/Makefile
create mode 100644 tools/testing/selftests/landlock/common.h
create mode 100644 tools/testing/selftests/landlock/config
create mode 100644 tools/testing/selftests/landlock/test_base.c
create mode 100644 tools/testing/selftests/landlock/test_fs.c
create mode 100644 tools/testing/selftests/landlock/test_ptrace.c
create mode 100644 tools/testing/selftests/landlock/true.c
--
2.26.1
This patchset contains everything needed to integrate KASAN and KUnit.
KUnit will be able to:
(1) Fail tests when an unexpected KASAN error occurs
(2) Pass tests when an expected KASAN error occurs
Convert KASAN tests to KUnit with the exception of copy_user_test
because KUnit is unable to test those.
Add documentation on how to run the KASAN tests with KUnit and what to
expect when running these tests.
Depends on "[PATCH v3 kunit-next 0/2] kunit: extend kunit resources
API" patchset [1]
Changes from v4:
- KASAN no longer will panic on errors if both panic_on_warn and
kasan_multishot are enabled.
- As a result, the KASAN tests will no-longer disable panic_on_warn.
- This also means panic_on_warn no-longer needs to be exported.
- The use of temporary "kasan_data" variables has been cleaned up
somewhat.
- A potential refcount/resource leak should multiple KASAN errors
appear during an assertion was fixed.
- Some wording changes to the KASAN test Kconfig entries.
Changes from v3:
- KUNIT_SET_KASAN_DATA and KUNIT_DO_EXPECT_KASAN_FAIL have been
combined and included in KUNIT_DO_EXPECT_KASAN_FAIL() instead.
- Reordered logic in kasan_update_kunit_status() in report.c to be
easier to read.
- Added comment to not use the name "kasan_data" for any kunit tests
outside of KUNIT_EXPECT_KASAN_FAIL().
Changes since v2:
- Due to Alan's changes in [1], KUnit can be built as a module.
- The name of the tests that could not be run with KUnit has been
changed to be more generic: test_kasan_module.
- Documentation on how to run the new KASAN tests and what to expect
when running them has been added.
- Some variables and functions are now static.
- Now save/restore panic_on_warn in a similar way to kasan_multi_shot
and renamed the init/exit functions to be more generic to accommodate.
- Due to [2] in kasan_strings, kasan_memchr, and
kasan_memcmp will fail if CONFIG_AMD_MEM_ENCRYPT is enabled so return
early and print message explaining this circumstance.
- Changed preprocessor checks to C checks where applicable.
Changes since v1:
- Make use of Alan Maguire's suggestion to use his patch that allows
static resources for integration instead of adding a new attribute to
the kunit struct
- All KUNIT_EXPECT_KASAN_FAIL statements are local to each test
- The definition of KUNIT_EXPECT_KASAN_FAIL is local to the
test_kasan.c file since it seems this is the only place this will
be used.
- Integration relies on KUnit being builtin
- copy_user_test has been separated into its own file since KUnit
is unable to test these. This can be run as a module just as before,
using CONFIG_TEST_KASAN_USER
- The addition to the current task has been separated into its own
patch as this is a significant enough change to be on its own.
[1] https://lore.kernel.org/linux-kselftest/1585313122-26441-1-git-send-email-a…
[2] https://bugzilla.kernel.org/show_bug.cgi?id=206337
Patricia Alfonso (4):
Add KUnit Struct to Current Task
KUnit: KASAN Integration
KASAN: Port KASAN Tests to KUnit
KASAN: Testing Documentation
Documentation/dev-tools/kasan.rst | 70 ++++
include/kunit/test.h | 5 +
include/linux/kasan.h | 6 +
include/linux/sched.h | 4 +
lib/Kconfig.kasan | 18 +-
lib/Makefile | 3 +-
lib/kunit/test.c | 13 +-
lib/test_kasan.c | 668 +++++++++++++-----------------
lib/test_kasan_module.c | 76 ++++
mm/kasan/report.c | 34 +-
10 files changed, 504 insertions(+), 393 deletions(-)
create mode 100644 lib/test_kasan_module.c
--
2.26.0.110.g2183baf09c-goog
This series adds basic self tests for HMM and are intended for Jason
Gunthorpe's rdma tree which has a number of HMM patches applied.
Changes v7 -> v8:
Rebased to Jason's rdma/hmm tree, plus Jason's 6 patch series
"Small hmm_range_fault() cleanups".
Applied a number of changes from Jason's comments.
Changes v6 -> v7:
Rebased to linux-5.6.0-rc6
Reverted back to just using mmu_interval_notifier_insert() and making
this series only introduce HMM self tests.
Changes v5 -> v6:
Rebased to linux-5.5.0-rc6
Refactored mmu interval notifier patches
Converted nouveau to use the new mmu interval notifier API
Changes v4 -> v5:
Added mmu interval notifier insert/remove/update callable from the
invalidate() callback
Updated HMM tests to use the new core interval notifier API
Changes v1 -> v4:
https://lore.kernel.org/linux-mm/20191104222141.5173-1-rcampbell@nvidia.com
Ralph Campbell (3):
mm/hmm/test: add selftest driver for HMM
mm/hmm/test: add selftests for HMM
MAINTAINERS: add HMM selftests
MAINTAINERS | 3 +
include/uapi/linux/test_hmm.h | 59 ++
lib/Kconfig.debug | 12 +
lib/Makefile | 1 +
lib/test_hmm.c | 1177 +++++++++++++++++++++
tools/testing/selftests/vm/.gitignore | 1 +
tools/testing/selftests/vm/Makefile | 3 +
tools/testing/selftests/vm/config | 2 +
tools/testing/selftests/vm/hmm-tests.c | 1353 ++++++++++++++++++++++++
tools/testing/selftests/vm/run_vmtests | 16 +
tools/testing/selftests/vm/test_hmm.sh | 97 ++
11 files changed, 2724 insertions(+)
create mode 100644 include/uapi/linux/test_hmm.h
create mode 100644 lib/test_hmm.c
create mode 100644 tools/testing/selftests/vm/hmm-tests.c
create mode 100755 tools/testing/selftests/vm/test_hmm.sh
--
2.20.1
When kunit tests are run on native (i.e. non-UML) environments, the results
of test execution are often intermixed with dmesg output. This patch
series attempts to solve this by providing a debugfs representation
of the results of the last test run, available as
/sys/kernel/debug/kunit/<testsuite>/results
Changes since v7:
- renamed KUNIT_INDENT[2] to KUNIT_SUBTEST_INDENT, KUNIT_SUBSUBTEST_INDENT
and added more description to their definitions to clarify why they
are defined as they are (Shuah)
- defined KUNIT_SUBSUBTEST_INDENT directly as 8 spaces to avoid
checkpatch error (Shuah)
Changes since v6:
- fixed regexp parsing in kunit_parser.py to ensure test results are read
successfully with 4-space indentation (Brendan, patch 3)
Changes since v5:
- replaced undefined behaviour use of snprintf(buf, ..., buf) in
kunit_log() with a function to append string to existing log
(Frank, patch 1)
- added clarification on log size limitations to documentation
(Frank, patch 4)
Changes since v4:
- added suite-level log expectations to kunit log test (Brendan, patch 2)
- added log expectations (of it being NULL) for case where
CONFIG_KUNIT_DEBUGFS=n to kunit log test (patch 2)
- added patch 3 which replaces subtest tab indentation with 4 space
indentation as per TAP 14 spec (Frank, patch 3)
Changes since v3:
- added CONFIG_KUNIT_DEBUGFS to support conditional compilation of debugfs
representation, including string logging (Frank, patch 1)
- removed unneeded NULL check for test_case in
kunit_suite_for_each_test_case() (Frank, patch 1)
- added kunit log test to verify logging multiple strings works
(Frank, patch 2)
- rephrased description of results file (Frank, patch 3)
Changes since v2:
- updated kunit_status2str() to kunit_status_to_string() and made it
static inline in include/kunit/test.h (Brendan)
- added log string to struct kunit_suite and kunit_case, with log
pointer in struct kunit pointing at the case log. This allows us
to collect kunit_[err|info|warning]() messages at the same time
as we printk() them. This solves for the most part the sharing
of log messages between test execution and debugfs since we
just print the suite log (which contains the test suite preamble)
and the individual test logs. The only exception is the suite-level
status, which we cannot store in the suite log as it would mean
we'd print the suite and its status prior to the suite's results.
(Brendan, patch 1)
- dropped debugfs-based kunit run patch for now so as not to cause
problems with tests currently under development (Brendan)
- fixed doc issues with code block (Brendan, patch 3)
Changes since v1:
- trimmed unneeded include files in lib/kunit/debugfs.c (Greg)
- renamed global debugfs functions to be prefixed with kunit_ (Greg)
- removed error checking for debugfs operations (Greg)
Alan Maguire (4):
kunit: add debugfs /sys/kernel/debug/kunit/<suite>/results display
kunit: add log test
kunit: subtests should be indented 4 spaces according to TAP
kunit: update documentation to describe debugfs representation
Documentation/dev-tools/kunit/usage.rst | 14 +++
include/kunit/test.h | 63 ++++++++++++--
lib/kunit/Kconfig | 8 ++
lib/kunit/Makefile | 4 +
lib/kunit/assert.c | 79 ++++++++---------
lib/kunit/debugfs.c | 116 +++++++++++++++++++++++++
lib/kunit/debugfs.h | 30 +++++++
lib/kunit/kunit-test.c | 44 +++++++++-
lib/kunit/test.c | 148 +++++++++++++++++++++++++-------
tools/testing/kunit/kunit_parser.py | 10 +--
10 files changed, 430 insertions(+), 86 deletions(-)
create mode 100644 lib/kunit/debugfs.c
create mode 100644 lib/kunit/debugfs.h
--
1.8.3.1
Hi!
Shuah please consider applying to the kselftest tree.
This set is an attempt to make running tests for different
sets of data easier. The direct motivation is the tls
test which we'd like to run for TLS 1.2 and TLS 1.3,
but currently there is no easy way to invoke the same
tests with different parameters.
Tested all users of kselftest_harness.h.
v2:
- don't run tests by fixture
- don't pass params as an explicit argument
v3:
- go back to the orginal implementation with an extra
parameter, and running by fixture (Kees);
- add LIST_APPEND helper (Kees);
- add a dot between fixture and param name (Kees);
- rename the params to variants (Tim);
v4:
- whitespace fixes.
v5 (Kees):
- move a comment;
- remove a temporary variable;
- reword the commit message on patch 4.
v1: https://lore.kernel.org/netdev/20200313031752.2332565-1-kuba@kernel.org/
v2: https://lore.kernel.org/netdev/20200314005501.2446494-1-kuba@kernel.org/
v3: https://lore.kernel.org/netdev/20200316225647.3129354-1-kuba@kernel.org/
v4: https://lore.kernel.org/netdev/20200317010419.3268916-1-kuba@kernel.org/
Jakub Kicinski (5):
kselftest: factor out list manipulation to a helper
kselftest: create fixture objects
kselftest: run tests by fixture
kselftest: add fixture variants
selftests: tls: run all tests for TLS 1.2 and TLS 1.3
Documentation/dev-tools/kselftest.rst | 3 +-
tools/testing/selftests/kselftest_harness.h | 234 +++++++++++++++-----
tools/testing/selftests/net/tls.c | 93 ++------
3 files changed, 202 insertions(+), 128 deletions(-)
--
2.25.1
> Traced event can trigger 'snapshot' operation(i.e. calls snapshot_trigger()
I suggest to improve the change description.
* Adjustment:
… operation (i. e. …
* Will the tag “Fixes” become relevant?
Regards,
Markus
Fix warnings at 'make htmldocs', and formatting issues in the resulting
documentation.
- test.h: Fix annotation in kernel-doc parameter description.
- Documentation/*.rst: Fixing formatting issues, and a duplicate label
issue due to usage of sphinx.ext.autosectionlabel and identical labels
within one document (sphinx warning)
NB: checkpatch.pl will complain about flow control statements (i.e. usage
of "return") within the macro kunit_test_suites(suites_list...).
v2: Several documentation fixes
v3: Do not touch API documentation index
v4: Replace macro argument in test.h by named variadic argument
Signed-off-by: Lothar Rubusch <l.rubusch(a)gmail.com>
---
Documentation/dev-tools/kunit/start.rst | 13 ++++++++-----
Documentation/dev-tools/kunit/usage.rst | 4 ++--
include/kunit/test.h | 12 ++++++------
3 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/Documentation/dev-tools/kunit/start.rst b/Documentation/dev-tools/kunit/start.rst
index e1c5ce80ce12..bb112cf70624 100644
--- a/Documentation/dev-tools/kunit/start.rst
+++ b/Documentation/dev-tools/kunit/start.rst
@@ -32,15 +32,17 @@ test targets as well. The ``.kunitconfig`` should also contain any other config
options required by the tests.
A good starting point for a ``.kunitconfig`` is the KUnit defconfig:
+
.. code-block:: bash
cd $PATH_TO_LINUX_REPO
cp arch/um/configs/kunit_defconfig .kunitconfig
You can then add any other Kconfig options you wish, e.g.:
+
.. code-block:: none
- CONFIG_LIST_KUNIT_TEST=y
+ CONFIG_LIST_KUNIT_TEST=y
:doc:`kunit_tool <kunit-tool>` will ensure that all config options set in
``.kunitconfig`` are set in the kernel ``.config`` before running the tests.
@@ -54,8 +56,8 @@ using.
other tools (such as make menuconfig) to adjust other config options.
-Running the tests
------------------
+Running the tests (KUnit Wrapper)
+---------------------------------
To make sure that everything is set up correctly, simply invoke the Python
wrapper from your kernel repo:
@@ -105,8 +107,9 @@ have config options ending in ``_KUNIT_TEST``.
KUnit and KUnit tests can be compiled as modules: in this case the tests in a
module will be run when the module is loaded.
-Running the tests
------------------
+
+Running the tests (w/o KUnit Wrapper)
+-------------------------------------
Build and run your kernel as usual. Test output will be written to the kernel
log in `TAP <https://testanything.org/>`_ format.
diff --git a/Documentation/dev-tools/kunit/usage.rst b/Documentation/dev-tools/kunit/usage.rst
index 473a2361ec37..3c3fe8b5fecc 100644
--- a/Documentation/dev-tools/kunit/usage.rst
+++ b/Documentation/dev-tools/kunit/usage.rst
@@ -595,7 +595,7 @@ able to run one test case per invocation.
KUnit debugfs representation
============================
When kunit test suites are initialized, they create an associated directory
-in /sys/kernel/debug/kunit/<test-suite>. The directory contains one file
+in ``/sys/kernel/debug/kunit/<test-suite>``. The directory contains one file
- results: "cat results" displays results of each test case and the results
of the entire suite for the last test run.
@@ -604,4 +604,4 @@ The debugfs representation is primarily of use when kunit test suites are
run in a native environment, either as modules or builtin. Having a way
to display results like this is valuable as otherwise results can be
intermixed with other events in dmesg output. The maximum size of each
-results file is KUNIT_LOG_SIZE bytes (defined in include/kunit/test.h).
+results file is KUNIT_LOG_SIZE bytes (defined in ``include/kunit/test.h``).
diff --git a/include/kunit/test.h b/include/kunit/test.h
index 9b0c46a6ca1f..47e61e1d5337 100644
--- a/include/kunit/test.h
+++ b/include/kunit/test.h
@@ -175,7 +175,7 @@ struct kunit_suite {
void (*exit)(struct kunit *test);
struct kunit_case *test_cases;
- /* private - internal use only */
+ /* private: internal use only */
struct dentry *debugfs;
char *log;
};
@@ -232,12 +232,12 @@ void __kunit_test_suites_exit(struct kunit_suite **suites);
* kunit_test_suites() - used to register one or more &struct kunit_suite
* with KUnit.
*
- * @suites: a statically allocated list of &struct kunit_suite.
+ * @suites_list...: a statically allocated list of &struct kunit_suite.
*
- * Registers @suites with the test framework. See &struct kunit_suite for
+ * Registers @suites_list with the test framework. See &struct kunit_suite for
* more information.
*
- * When builtin, KUnit tests are all run as late_initcalls; this means
+ * When builtin, KUnit tests are all run as late_initcalls; this means
* that they cannot test anything where tests must run at a different init
* phase. One significant restriction resulting from this is that KUnit
* cannot reliably test anything that is initialize in the late_init phase;
@@ -253,8 +253,8 @@ void __kunit_test_suites_exit(struct kunit_suite **suites);
* tests from the same place, and at the very least to do so after
* everything else is definitely initialized.
*/
-#define kunit_test_suites(...) \
- static struct kunit_suite *suites[] = { __VA_ARGS__, NULL}; \
+#define kunit_test_suites(suites_list...) \
+ static struct kunit_suite *suites[] = {suites_list, NULL}; \
static int kunit_test_suites_init(void) \
{ \
return __kunit_test_suites_init(suites); \
--
2.20.1
Add test which adds a tree of software_nodes, checks that the nodes
exist, and then removes the tree. This exercises a bug reported by
Naresh Kamboju <naresh.kamboju(a)linaro.org>, and pretty much just takes a
test case from the test_printf Kselftest module and refocusses it on
adding and then removing a tree of software_nodes.
Signed-off-by: Brendan Higgins <brendanhiggins(a)google.com>
---
I am not sure if this should be rolled into the property entry test, or
should be moved somewhere else; nevertheless, testing the software node
API seems like a good idea and this seems like a good place to start.
---
drivers/base/test/Kconfig | 14 ++++++++
drivers/base/test/Makefile | 2 ++
drivers/base/test/software-node-test.c | 46 ++++++++++++++++++++++++++
3 files changed, 62 insertions(+)
create mode 100644 drivers/base/test/software-node-test.c
diff --git a/drivers/base/test/Kconfig b/drivers/base/test/Kconfig
index 305c7751184a..b42f385fe233 100644
--- a/drivers/base/test/Kconfig
+++ b/drivers/base/test/Kconfig
@@ -11,3 +11,17 @@ config TEST_ASYNC_DRIVER_PROBE
config KUNIT_DRIVER_PE_TEST
bool "KUnit Tests for property entry API"
depends on KUNIT=y
+config KUNIT_DRIVER_SOFTWARE_NODE_TEST
+ bool "KUnit Tests for software node API"
+ depends on KUNIT=y
+ help
+ This builds the software node API tests.
+
+ KUnit tests run during boot and output the results to the debug log
+ in TAP format (http://testanything.org/). Only useful for kernel devs
+ and are not for inclusion into a production build.
+
+ For more information on KUnit and unit tests in general please refer
+ to the KUnit documentation in Documentation/dev-tools/kunit/.
+
+ If unsure, say N.
diff --git a/drivers/base/test/Makefile b/drivers/base/test/Makefile
index 3ca56367c84b..63325e8a5288 100644
--- a/drivers/base/test/Makefile
+++ b/drivers/base/test/Makefile
@@ -2,3 +2,5 @@
obj-$(CONFIG_TEST_ASYNC_DRIVER_PROBE) += test_async_driver_probe.o
obj-$(CONFIG_KUNIT_DRIVER_PE_TEST) += property-entry-test.o
+
+obj-$(CONFIG_KUNIT_DRIVER_SOFTWARE_NODE_TEST) += software-node-test.o
diff --git a/drivers/base/test/software-node-test.c b/drivers/base/test/software-node-test.c
new file mode 100644
index 000000000000..0609cbd9aa0a
--- /dev/null
+++ b/drivers/base/test/software-node-test.c
@@ -0,0 +1,46 @@
+// SPDX-License-Identifier: GPL-2.0
+// Unit tests for software node API
+//
+// Copyright 2020 Google LLC.
+
+#include <kunit/test.h>
+#include <linux/property.h>
+#include <linux/types.h>
+
+static void software_node_test_register_nodes(struct kunit *test)
+{
+ const struct software_node softnodes[] = {
+ { .name = "first", },
+ { .name = "second", .parent = &softnodes[0], },
+ { .name = "third", .parent = &softnodes[1], },
+ {}
+ };
+ const char * const full_name = "first/second/third";
+ char *buf;
+
+ buf = kunit_kzalloc(test, strlen(full_name), GFP_KERNEL);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, buf);
+
+ KUNIT_ASSERT_EQ(test, software_node_register_nodes(softnodes), 0);
+
+ /* Check that all the nodes exist. */
+ KUNIT_ASSERT_EQ(test,
+ (size_t)sprintf(buf, "%pfw",
+ software_node_fwnode(&softnodes[2])),
+ strlen(full_name));
+ KUNIT_EXPECT_STREQ(test, buf, full_name);
+
+ software_node_unregister_nodes(softnodes);
+}
+
+static struct kunit_case software_node_test_cases[] = {
+ KUNIT_CASE(software_node_test_register_nodes),
+ {}
+};
+
+static struct kunit_suite software_node_test_suite = {
+ .name = "software-node",
+ .test_cases = software_node_test_cases,
+};
+
+kunit_test_suite(software_node_test_suite);
base-commit: 8632e9b5645bbc2331d21d892b0d6961c1a08429
--
2.26.0.110.g2183baf09c-goog
From: Tim Bird <tim.bird(a)sony.com>
Add ksft-compile-test.sh. This is a program used to test
cross-compilation and installation of selftest tests.
See the test usage for help
This program currently tests 3 scenarios out of a larger matrix
of possibly interesting scenarios. For each scenario, it conducts
multiple tests for correctness. This version tests:
1) does the test compile
2) is the kernel source directory clean after the compile
3) does the test install operation succeed
4) does the test run script reference the test
Signed-off-by: Tim Bird <tim.bird(a)sony.com>
---
MAINTAINERS | 6 +
tools/testing/selftests/ksft-compile-test.sh | 567 +++++++++++++++++++++++++++
2 files changed, 573 insertions(+)
create mode 100755 tools/testing/selftests/ksft-compile-test.sh
diff --git a/MAINTAINERS b/MAINTAINERS
index cc1d18c..a6289c7 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -9127,6 +9127,12 @@ S: Maintained
F: tools/testing/selftests/
F: Documentation/dev-tools/kselftest*
+KERNEL SELFTEST SELFTEST
+M: Tim Bird <tim.bird(a)sony.com>
+L: linux-kselftest(a)vger.kernel.org
+S: Maintained
+F: tools/testing/selftests/ksft-compile-test.sh
+
KERNEL UNIT TESTING FRAMEWORK (KUnit)
M: Brendan Higgins <brendanhiggins(a)google.com>
L: linux-kselftest(a)vger.kernel.org
diff --git a/tools/testing/selftests/ksft-compile-test.sh b/tools/testing/selftests/ksft-compile-test.sh
new file mode 100755
index 0000000..e36e858
--- /dev/null
+++ b/tools/testing/selftests/ksft-compile-test.sh
@@ -0,0 +1,567 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0-only OR MIT
+#
+# ksft-compile-test.sh - test compiling Linux kernel selftests under lots of
+# different configurations. This is used to check that cross-compilation
+# and install works properly for a newly submitted test target, and
+# also that changes to existing test Makefiles don't regress with regard to
+# this functionality.
+#
+# Copyright 2020 Sony Corporation
+#
+# Here are the things that Shuah Kahn asked for on 3/6/2020
+# 1. Cross-compilation & relocatable build support
+# 2. Generates objects in objdir/kselftest without cluttering main objdir
+# 3. Leave source directory clean
+# 4. Installs correctly in objdir/kselftest/kselftest_install and adds
+# itself to run_kselftest.sh script generated during install.
+#
+# Would be nice to make sure other features also work:
+# 5. can use absolute, relative, or current directory for output directory
+# 6. can use ~ in output directory path
+#
+# matrix of build combinations:
+# dimensions:
+# cwd: top-level, build-dir, tools/testing/selftests/<target>
+# change-dir: <none>, -C tools/testing/selftests (selftests)
+# make-target: <none>, kselftest-install, install
+# output-dir: <none>, KBUILD_OUTPUT-rel, KBUILD_OUTPUT-abs, O-rel, O-abs
+#
+# NOTE: you should not put your output directory inside your source directory
+# Parts of the kbuild system don't like this.
+#
+# The test matrix is not full:
+# <cwd>,<change-dir>,<make target>,<output-dir>
+# top, none, kselftest-install, none
+# top, none, kselftest-install, KBO-rel
+# 2 top, none, kselftest-install, KBO-abs
+# top, none, kselftest-install, O-rel
+# 1 top, none, kselftest-install, O-abs
+# top, selftests, none , none
+# top, selftests, none , KBO-rel
+# 3 top, selftests, none , KBO-abs
+# top, selftests, none , O-rel
+# 4 top, selftests, none , O-abs
+# build-dir, none, kselftest-install, none
+# build-dir, none, kselftest-install, KBO-rel
+# build-dir, none, kselftest-install, KBO-abs
+# build-dir, none, kselftest-install, O-rel
+# build-dir, none, kselftest-install, O-abs
+# build-dir, selftests, none, none
+# build-dir, selftests, none, KBO-rel
+# build-dir, selftests, none, KBO-abs
+# build-dir, selftests, none, kselftest-install, O-rel
+# build-dir, selftests, none, O-abs
+# 5 target, none, none, none
+# 6 target, none, install, none
+# target, none, none, KBO-rel
+# target, none, install, KBO-rel
+# target, none, none, KBO-abs
+# target, none, install, KBO-abs
+# target, none, none, O-rel
+# target, none, install, O-rel
+# target, none, none, O-abs
+# target, none, install, O-abs
+#
+# 1 = Shuah preferred test (top-level, kselftest-install, with O=)
+# 3 = Fuego (Tim's) default build style
+#
+# To do for this test:
+#
+
+usage() {
+ cat <<HERE
+Usage: ksft-compile-test.sh [-h|--help] [TARGETS="<targets>"] [<options>]
+
+compile_test.sh will test building selftest programs in the indicated
+target areas. The script tests various output-directory configurations.
+
+OPTIONS
+ -h, --help Show this usage help.
+ TARGETS="<targets>" Indicate the set of targets to test. <targets> is a
+ space-separated list of testing areas from
+ tools/testing/selftests/Makefile
+ O=<dir> Indicate a directory to use for output. Normally, the
+ program creates a temporary directory for testing, and
+ removes it when done. This sets -p, to avoid removing
+ the directory at the end of the test. Using O= with an
+ existing directory can save time (the kernel does not
+ need to be rebuilt). The directory must already exist.
+ -c <config-file> Specify a configuration file for the kernel.
+ If not specified, an appropriate defconfig will be used.
+ -p, --preserve Preserve files when this test completes.
+ If not specified, test will remove working files when
+ it completes.
+ -l <log-file> Specify the file to use for log output. All test output
+ goes to STDOUT (and STDERR) A subset of output
+ is placed in the logfile. If not specified, the
+ filename 'compile-test-log-<timestamp>.txt' is used.
+ -s, --summary Show summary of results at end of test.
+ -e <extra-data-file> Put contents of <extra-data-file> in the header of
+ the logfile (and in test output). This allows a CI
+ system to add additional information about the build
+ system, toolchain, etc. used for the test.
+ -C <kernel-src-dir> Use the indicated directory (instead of current
+ working directory) as the kernel source dir.
+
+ENVIRONMENT
+ Set ARCH and CROSS_COMPILE to values appropriate for your environment
+ (the same as for a Linux kernel image build)
+
+ You can use a TARGETS environment variable, instead of the TARGETS=
+ command line option.
+
+OUTPUT
+ Program output is in TAP13 format. The exit code indicates if the test was
+ 100% successful (SKIPS are counted as failures).
+HERE
+ exit 1
+}
+
+INDENT=3
+DEBUG=1
+
+dprint() {
+ if [ $DEBUG = 1 ] ; then
+ echo "$1"
+ fi
+}
+
+# parse command line options
+CONFIG_FILE=use_defconfig
+PRESERVE_FILES=0
+LOGFILE="$(pwd)/compile-test-log-$(date -Iseconds).txt"
+SHOW_SUMMARY=0
+SRC_TOP="$(realpath $(pwd))"
+
+while [ -n "$1" ] ; do
+ case $1 in
+ -h|--help)
+ usage
+ ;;
+ TARGETS=*)
+ TARGETS="${1#TARGETS=}"
+ export TARGETS
+ shift
+ ;;
+ O=*)
+ OUTPUT_DIR="${1#O=}"
+ shift
+ export OUTPUT_DIR
+ PRESERVE_FILES=1
+ if [ ! -d "$OUTPUT_DIR" ] ; then
+ echo "Error: output directory $OUTPUT_DIR does not exist"
+ echo "Use '-h' to get program usage"
+ exit 1
+ fi
+ ;;
+ -c)
+ CONFIG_FILE="$2"
+ shift 2
+ if [ ! -f ${CONFIG_FILE} ] ; then
+ echo "Error: Can't read specified config file $CONFIG_FILE"
+ echo "Use '-h' to get program usage"
+ exit 1
+ fi
+ ;;
+ -p|--preserve)
+ PRESERVE_FILES=1
+ shift
+ ;;
+ -l)
+ LOGFILE=="$2"
+ shift 2
+ if [ -z "$LOGFILE" ] ; then
+ echo "Error: No log-file specified with -l"
+ echo "Use '-h' to get program usage"
+ exit 1
+ fi
+ echo "Using logfile $LOGFILE"
+ ;;
+ -s|--summary)
+ SHOW_SUMMARY=1
+ shift
+ ;;
+ -e)
+ EXTRA_DATA_FILE="$2"
+ shift 2
+ if [ -z "$EXTRA_DATA_FILE" ] ; then
+ echo "Error: No <extra-data-file> specified with -e"
+ echo "Use '-h' to get program usage"
+ exit 1
+ fi
+ if [ ! -f "$EXTRA_DATA_FILE" ] ; then
+ echo "Error: Extra data file '$EXTRA_DATA_FILE' does not exist"
+ echo "Use '-h' to get program usage"
+ exit 1
+ fi
+ echo "Using extra data file $EXTRA_DATA_FILE"
+ ;;
+ -C)
+ SRC_TOP="$(realpath $2)"
+ shift 2
+ if [ ! -d $SRC_TOP ] ; then
+ echo "Error: Kernel source dir '$SRC_TOP' does not exist"
+ echo "Use '-h' to get program usage"
+ exit 1
+ fi
+ if [ ! -f "$SRC_TOP/MAINTAINERS" ] ; then
+ echo "Error: $SRC_TOP doesn't seem to be a kernel source tree."
+ echo "Missing MAINTAINERS file."
+ exit 1
+ fi
+ echo "Using kernel source tree: $SRC_TOP"
+ cd $SRC_TOP
+ ;;
+ *)
+ echo "Error: Unknown option '$1'"
+ echo "Use '-h' to get program usage"
+ exit 1
+ ;;
+ esac
+done
+
+# for debugging option parsing
+dprint "TARGETS=$TARGETS"
+dprint "CONFIG_FILE=$CONFIG_FILE"
+dprint "LOGFILE=$LOGFILE"
+dprint "PRESERVE_FILES=$PRESERVE_FILES"
+dprint "OUTPUT_DIR=$OUTPUT_DIR"
+dprint "SRC_TOP=$SRC_TOP"
+
+#### logging routines
+# log_msg - put a single-line message in the logfile (and STDOUT)
+log_msg() {
+ echo "$1" | tee -a $LOGFILE
+}
+
+# log_result - put TAP-syntax prefix and description to logfile
+# $1 = result to log
+# $2 = result description (usually "$test_id", but may include SKIP)
+# Uses global TEST_NUM
+log_result() {
+ if [ $1 = 0 ] ; then
+ log_msg "ok $TEST_NUM $2"
+ else
+ log_msg "not ok $TEST_NUM $2"
+ fi
+}
+
+# log_cmd - put output of command into logfile
+# $1 - command to execute
+log_cmd() {
+ RETCODE=/tmp/$$-${RANDOM}
+ touch $RETCODE
+ bash -c "{ $1; echo \$? >$RETCODE ; } 2>&1 | tee -a $LOGFILE"
+ RESULT=$(cat $RETCODE)
+ rm -f $RETCODE
+ return $RESULT
+}
+
+# log_cmd_indented - put output of command into logfile, indented by INDENT
+# $1 - command to execute
+# Uses global INDENT
+log_cmd_indented() {
+ RETCODE=/tmp/$$-${RANDOM}
+ TMPOUT=/tmp/$$-${RANDOM}
+ touch $RETCODE
+ bash -c "{ $1; echo \$? >$RETCODE ; } 2>&1 | tee -a $TMPOUT"
+ RESULT=$(cat $RETCODE)
+
+ # could use sed here instead of pr, if needed
+ cat $TMPOUT | pr -to $INDENT >>$LOGFILE
+
+ rm -f $RETCODE $TMPOUT
+ return $RESULT
+}
+
+# do some sanity checks before we get started
+test_pre_check() {
+ # are we in the top directory of a kernel source tree?
+ if [ ! -f "MAINTAINERS" ] ; then
+ echo "Error: We're not in a kernel source tree (no MAINTAINERS file)"
+ echo "Use '-h' to get program usage"
+ exit 1
+ fi
+
+ if [ -z $ARCH ] ; then
+ ARCH_ARGS=""
+ else
+ ARCH_ARGS="ARCH=$ARCH"
+ fi
+ export ARCH_ARGS
+
+ if [ -z "$CROSS_COMPILE" -a -n "$ARCH_ARGS" ] ; then
+ echo "Warning: no CROSS_COMPILE prefix defined, but ARCH $ARCH specified"
+ echo "Usually, if you specify an ARCH you need to specify CROSS_COMPILE"
+ echo "Use '-h' to get program usage"
+ fi
+}
+
+# prepare for tests
+# on completion, following should be set:
+# INDENT, TARGET_LIST, NUM_MAKE_JOBS, KBUILD_DIR_REL, KBUILD_DIR_ABS
+# Uses: ARCH
+test_setup() {
+ echo "In test setup"
+
+ # read target list from test variable, if defined
+ if [ -n "${TARGETS}" ] ; then
+ TARGET_LIST="${TARGETS}"
+ else
+ # use hardcoded kselftest target list for now
+ TARGET_LIST="android arm64 bpf breakpoints capabilities cgroup \
+ clone3 cpufreq cpu-hotplug drivers/dma-buf efivarfs exec \
+ filesystems filesystems/binderfs filesystems/epoll firmware \
+ ftrace futex gpio intel_pstate ipc ir kcmp kexec kvm lib \
+ livepatch lkdtm membarrier memfd memory-hotplug mount mqueue \
+ net net/mptcp netfilter networking/timestamping nsfs pidfd \
+ powerpc proc pstore ptrace openat2 rseq rtc seccomp sigaltstack \
+ size sparc64 splice static_keys sync sysctl timens timers tmpfs \
+ tpm2 user vm x86 zram"
+ # FIXTHIS - query kernel for kselftest full target list
+ #TARGET_LIST=$(make --no-print-directory -s \
+ # -C tools/testing/selftests show_targets)
+ fi
+
+ # get number of parallel jobs to start in make
+ proc_count=$(cat /proc/cpuinfo | grep processor | wc -l)
+ NUM_MAKE_JOBS=$(( proc_count / 2 ))
+ if [ $NUM_MAKE_JOBS -lt 1 ] ; then
+ NUM_MAKE_JOBS=1
+ fi
+
+ if [ -z "$OUTPUT_DIR" ] ; then
+ # make output dir
+ tmp1=$(mktemp -d ../ksft-XXXXXX)
+ export KBUILD_DIR_REL="$tmp1"
+ export KBUILD_DIR_ABS=$(realpath $tmp1)
+ else
+ export KBUILD_DIR_REL=$(realpath --relative-to=$(pwd) $OUTPUT_DIR)
+ export KBUILD_DIR_ABS=$(realpath $OUTPUT_DIR)
+ fi
+ mkdir -p $KBUILD_DIR_ABS
+
+ # for setup, use KBUILD_OUTPUT environment var for output dir
+ KBUILD_OUTPUT=$KBUILD_DIR_ABS
+
+ if [ $CONFIG_FILE = "use_defconfig" ] ; then
+ make $ARCH_ARGS defconfig
+ else
+ cp $CONFIG_FILE $KBUILD_OUTPUT/.config
+ fi
+ make $ARCH_ARGS oldconfig
+
+ # this should only be needed once
+ make $ARCH_ARGS -j $NUM_MAKE_JOBS headers_install
+
+ make $ARCH_ARGS -j $NUM_MAKE_JOBS vmlinux
+}
+
+#
+# $1 = KBUILD_DIR
+# $2 = target
+check_output_dir() {
+ install_result=0
+ log_msg "# Contents of kselftest_install directory:"
+ if [ -d $1/kselftest/kselftest_install ] ; then
+ pushd $1/kselftest/kselftest_install >/dev/null
+
+ log_cmd_indented "ls -lR"
+ log_msg "# File types:"
+ log_cmd_indented "find . -type f | xargs file -n | \
+ sed \"s/BuildID.*, //\""
+
+ # check that run scripts has the target
+ if ! grep "^cd $2" run_kselftest.sh 2>&1 >/dev/null ; then
+ log_mesg "# Missing target $2 in run_kselftest.sh"
+ install_result=1
+ fi
+
+ popd >/dev/null
+ else
+ log_msg "# Missing $KBUILD_OUTPUT/kselftest/kselftest_install directory"
+ install_result=1
+ fi
+ return $install_result
+}
+
+# do_test - perform one test combination
+# $1 = method (string for use in test_id)
+# $2 = target
+# $3 = compile args
+# $4 = install args (if any)
+# $5 = clean args
+#
+# Uses: ARCH_ARGS, KBUILD_DIR and LOGFILE (indirectly), and SRC_TOP
+# Uses and sets: TEST_NUM
+#
+do_test() {
+ method=$1
+ target=$2
+ COMPILE_ARGS=$3
+ INSTALL_ARGS=$4
+ CLEAN_ARGS=$4
+
+ TARGET_DIR=$SRC_TOP/tools/testing/selftests/$target
+
+ SRC_LS_FILE1="$(mktemp)"
+ SRC_LS_FILE2="$(mktemp)"
+ ls -lR $TARGET_DIR >$SRC_LS_FILE1
+
+ test_id="$target compile $method"
+ TEST_NUM=$(( TEST_NUM + 1 ))
+ log_msg "# $TEST_NUM $test_id"
+
+ # do the compile
+ log_cmd_indented "make $ARCH_ARGS TARGETS=\"$target\" $COMPILE_ARGS"
+ compile_result=$?
+
+ log_result $compile_result "$test_id"
+
+ # check that nothing changed in the src directory
+ test_id="$target src tree clean after compile $method"
+ TEST_NUM=$(( TEST_NUM + 1 ))
+ log_msg "# $TEST_NUM $test_id"
+
+ ls -lR $TARGET_DIR >$SRC_LS_FILE2
+ log_cmd_indented "diff -u $SRC_LS_FILE1 $SRC_LS_FILE2"
+ src_clean_result=$?
+
+ if [ $src_clean_result != 0 ] ; then
+ log_msg "# File or directory changes found in $TARGET_DIR"
+ fi
+
+ log_result $src_clean_result "$test_id"
+ rm $SRC_LS_FILE1
+ rm $SRC_LS_FILE2
+
+ test_id="$target install $method"
+ TEST_NUM=$(( TEST_NUM + 1 ))
+ log_msg "# $TEST_NUM $test_id"
+
+ if [ -n "INSTALL_ARGS" ] ; then
+ # skip the install test if it didn't compile
+ if [ $compile_result != 0 ] ; then
+ install_result=$compile_result
+ reason="compile failed"
+ log_result $install_result "$test_id # SKIP - $reason"
+
+ else
+ # now do install
+ log_cmd_indented "make $ARCH_ARGS TARGETS=\"$target\" $INSTALL_ARGS"
+ install_result=$?
+ log_result $install_result "$test_id"
+ fi
+ else
+ install_result=$compile_result
+ log_result $install_result "$test_id"
+ fi
+
+ test_id="$target check install output $method"
+ TEST_NUM=$(( TEST_NUM + 1 ))
+ log_msg "# $TEST_NUM $test_id"
+
+ # check results
+ if [ $install_result = 0 ] ; then
+ check_output_dir $KBUILD_DIR $target
+ install_output_result=$?
+ log_result $install_output_result "$test_id"
+ else
+ log_result $install_result "$test_id # SKIP - install failed"
+ fi
+
+ # clean up after test
+ make $ARCH_ARGS TARGETS=\"$target\" $CLEAN_ARGS
+
+ # clear out install directory for next test
+ rm -rf $KBUILD_DIR/kselftest/kselftest_install
+ mkdir -p $KBUILD_DIR/kselftest/kselftest_install
+}
+
+test_run() {
+ export KBUILD_DIR=$KBUILD_DIR_ABS
+ NUM_SCENARIOS=3
+ TESTS_PER_SCENARIO=4
+
+ # output the header
+ log_msg "ARCH=$ARCH"
+ log_msg "CROSS_COMPILE=$CROSS_COMPILE"
+ if [ -f "$EXTRA_DATA_FILE" ] ; then
+ log_msg "=== Test Details ==="
+ log_cmd "cat $EXTRA_DATA_FILE"
+ log_msg "==="
+ fi
+ log_msg "TAP VERSION 13"
+
+ target_count=$(echo $TARGET_LIST | wc -w)
+ export test_count=$(( target_count * $NUM_SCENARIOS * $TESTS_PER_SCENARIO ))
+ log_msg "1..$test_count"
+
+ # disable 'stop-on-error'
+ set +e
+
+ export TEST_NUM=0
+ for target in $TARGET_LIST ; do
+ echo "########## Doing tests for target $target ##########"
+
+ # clean out directory to force a re-build
+ make $ARCH_ARGS TARGETS=\"$target\" -C tools/testing/selftests clean
+
+ ### MATRIX SCENARIO: KBUILD_OUTPUT,-C
+ export KBUILD_OUTPUT="$KBUILD_DIR"
+ method="KBUILD_OUTPUT,-C"
+ COMPILE_ARGS="-C tools/testing/selftests"
+ INSTALL_ARGS="$COMPILE_ARGS install"
+ CLEAN_ARGS="$COMPILE_ARGS clean"
+ do_test "$method" $target "$COMPILE_ARGS" "$INSTALL_ARGS" "$CLEAN_ARGS"
+
+ ### MATRIX SCENARIO: O,-C
+ unset KBUILD_OUTPUT
+ O_TMP="$KBUILD_DIR"
+ method="O,-C"
+ COMPILE_ARGS="-C tools/testing/selftests O=$O_TMP"
+ INSTALL_ARGS="$COMPILE_ARGS install"
+ CLEAN_ARGS="$COMPILE_ARGS clean"
+ do_test "$method" $target "$COMPILE_ARGS" "$INSTALL_ARGS" "$CLEAN_ARGS"
+
+ ### MATRIX SCENARIO: O,top
+ method="O,top"
+ COMPILE_ARGS="O=$O_TMP kselftest-install"
+ INSTALL_ARGS=""
+ CLEAN_ARGS="O=$O_TMP kselftest-clean"
+ do_test "$method" $target "$COMPILE_ARGS" "$INSTALL_ARGS" "$CLEAN_ARGS"
+
+ done
+ set -e
+}
+
+test_cleanup() {
+ echo "In test cleanup"
+ if [ -z "$OUTPUT_DIR" ] ; then
+ if [ "$PRESERVE_FILES" = 0 ] ; then
+ rm -rf $KBUILD_DIR_ABS
+ else
+ echo "Build data was left in directory $KBUILD_DIR_ABS"
+ fi
+ else
+ echo "Not removing files in user-specified output dir $OUTPUT_DIR"
+ fi
+}
+
+# this is main()
+test_pre_check
+test_setup
+dprint "TARGET_LIST=$TARGET_LIST"
+test_run
+test_cleanup
+
+echo "Done. Log file is in $LOGFILE"
+
+if [ "$SHOW_SUMMARY" = 1 ] ; then
+ ok_count=$(grep ^ok $LOGFILE | wc -l)
+ fail_count=$(grep "^not ok" $LOGFILE | grep -v SKIP | wc -l)
+ skip_count=$(grep "^not ok" $LOGFILE | grep SKIP | wc -l)
+ total=$(( ok_count + fail_count + skip_count ))
+ echo "OK: $ok_count, FAIL: $fail_count, SKIP: $skip_count, TOTAL: $total"
+fi
--
2.1.4
This series introduces a new KVM selftest (mem_slot_test) that goal
is to verify memory slots can be added up to the maximum allowed. An
extra slot is attempted which should occur on error.
The patch 01 is needed so that the VM fd can be accessed from the
test code (for the ioctl call attempting to add an extra slot).
I ran the test successfully on x86_64, aarch64, and s390x. This
is why it is enabled to build on those arches.
- Changelog -
v4 -> v5:
- Initialize the guest_addr and mem_reg_size variables on definition
[krish.sadhukhan]
v3 -> v4:
- Discarded mem_reg_flags variable. Simply using 0 instead [drjones]
- Discarded kvm_region pointer. Instead passing a compound literal in
the ioctl [drjones]
- All variables are declared on the declaration block [drjones]
v2 -> v3:
- Keep alphabetical order of .gitignore and Makefile [drjones]
- Use memory region flags equals to zero [drjones]
- Changed mmap() assert from 'mem != NULL' to 'mem != MAP_FAILED' [drjones]
- kvm_region is declared along side other variables and malloc()'ed
later [drjones]
- Combined two asserts into a single 'ret == -1 && errno == EINVAL'
[drjones]
v1 -> v2:
- Rebased to queue
- vm_get_fd() returns int instead of unsigned int (patch 01) [drjones]
- Removed MEM_REG_FLAGS and GUEST_VM_MODE defines [drjones]
- Replaced DEBUG() with pr_info() [drjones]
- Calculate number of guest pages with vm_calc_num_guest_pages()
[drjones]
- Using memory region of 1 MB sized (matches mininum needed
for s390x)
- Removed the increment of guest_addr after the loop [drjones]
- Added assert for the errno when adding a slot beyond-the-limit [drjones]
- Prefer KVM_MEM_READONLY flag but on s390x it switch to KVM_MEM_LOG_DIRTY_PAGES,
so ensure the coverage of both flags. Also somewhat tests the KVM_CAP_READONLY_MEM capability check [drjones]
- Moved the test logic to test_add_max_slots(), this allows to more easily add new cases in the "suite".
v1: https://lore.kernel.org/kvm/20200330204310.21736-1-wainersm@redhat.com
Wainer dos Santos Moschetta (2):
selftests: kvm: Add vm_get_fd() in kvm_util
selftests: kvm: Add mem_slot_test test
tools/testing/selftests/kvm/.gitignore | 1 +
tools/testing/selftests/kvm/Makefile | 3 +
.../testing/selftests/kvm/include/kvm_util.h | 1 +
tools/testing/selftests/kvm/lib/kvm_util.c | 5 ++
tools/testing/selftests/kvm/mem_slot_test.c | 69 +++++++++++++++++++
5 files changed, 79 insertions(+)
create mode 100644 tools/testing/selftests/kvm/mem_slot_test.c
--
2.17.2
After successfully running the IPC msgque test once, subsequent runs
result in a test failure:
$ sudo ./run_kselftest.sh
TAP version 13
1..1
# selftests: ipc: msgque
# Failed to get stats for IPC queue with id 0
# Failed to dump queue: -22
# Bail out!
# # Pass 0 Fail 0 Xfail 0 Xpass 0 Skip 0 Error 0
not ok 1 selftests: ipc: msgque # exit=1
The dump_queue() function loops through the possible message queue index
values using calls to msgctl(kern_id, MSG_STAT, ...) where kern_id
represents the index value. The first time the test is ran, the initial
index value of 0 is valid and the test is able to complete. The index
value of 0 is not valid in subsequent test runs and the loop attempts to
try index values of 1, 2, 3, and so on until a valid index value is
found that corresponds to the message queue created earlier in the test.
The msgctl() syscall returns -1 and sets errno to EINVAL when invalid
index values are used. The test failure is caused by incorrectly
comparing errno to -EINVAL when cycling through possible index values.
Fix invalid test failures on subsequent runs of the msgque test by
correctly comparing errno values to a non-negated EINVAL.
Fixes: 3a665531a3b7 ("selftests: IPC message queue copy feature test")
Signed-off-by: Tyler Hicks <tyhicks(a)linux.microsoft.com>
---
tools/testing/selftests/ipc/msgque.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/ipc/msgque.c b/tools/testing/selftests/ipc/msgque.c
index 4c156aeab6b8..5ec4d9e18806 100644
--- a/tools/testing/selftests/ipc/msgque.c
+++ b/tools/testing/selftests/ipc/msgque.c
@@ -137,7 +137,7 @@ int dump_queue(struct msgque_data *msgque)
for (kern_id = 0; kern_id < 256; kern_id++) {
ret = msgctl(kern_id, MSG_STAT, &ds);
if (ret < 0) {
- if (errno == -EINVAL)
+ if (errno == EINVAL)
continue;
printf("Failed to get stats for IPC queue with id %d\n",
kern_id);
--
2.17.1
Fix warnings at 'make htmldocs', and formatting issues in the resulting
documentation.
- test.h: Fix some typos in kernel-doc parameter description.
- Documentation/*.rst: Fixing formatting issues, and a duplicate label
issue, since using sphinx.ext.autosectionlabel in conf.py, referes to
headers are generated automatically and sphinx will not complain about
identical headers among documents anymore.
The downside is, automatically generated header labels within one
document now cannot be overwritten manually anymore. Thus duplicate
headers within one document have to have different wording, i.e. this
patch modifies some headers.
- Documentation/api/*: Flipping over to a page "API" containing a single
link to another page "API" seems like a formatting issue. The patch
removes one level of indirection.
v2: Several documentation fixes
v3: Do not touch API documentation index
Signed-off-by: Lothar Rubusch <l.rubusch(a)gmail.com>
---
Documentation/dev-tools/kunit/start.rst | 13 ++++++++-----
Documentation/dev-tools/kunit/usage.rst | 4 ++--
include/kunit/test.h | 7 ++++---
3 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/Documentation/dev-tools/kunit/start.rst b/Documentation/dev-tools/kunit/start.rst
index e1c5ce80ce12..bb112cf70624 100644
--- a/Documentation/dev-tools/kunit/start.rst
+++ b/Documentation/dev-tools/kunit/start.rst
@@ -32,15 +32,17 @@ test targets as well. The ``.kunitconfig`` should also contain any other config
options required by the tests.
A good starting point for a ``.kunitconfig`` is the KUnit defconfig:
+
.. code-block:: bash
cd $PATH_TO_LINUX_REPO
cp arch/um/configs/kunit_defconfig .kunitconfig
You can then add any other Kconfig options you wish, e.g.:
+
.. code-block:: none
- CONFIG_LIST_KUNIT_TEST=y
+ CONFIG_LIST_KUNIT_TEST=y
:doc:`kunit_tool <kunit-tool>` will ensure that all config options set in
``.kunitconfig`` are set in the kernel ``.config`` before running the tests.
@@ -54,8 +56,8 @@ using.
other tools (such as make menuconfig) to adjust other config options.
-Running the tests
------------------
+Running the tests (KUnit Wrapper)
+---------------------------------
To make sure that everything is set up correctly, simply invoke the Python
wrapper from your kernel repo:
@@ -105,8 +107,9 @@ have config options ending in ``_KUNIT_TEST``.
KUnit and KUnit tests can be compiled as modules: in this case the tests in a
module will be run when the module is loaded.
-Running the tests
------------------
+
+Running the tests (w/o KUnit Wrapper)
+-------------------------------------
Build and run your kernel as usual. Test output will be written to the kernel
log in `TAP <https://testanything.org/>`_ format.
diff --git a/Documentation/dev-tools/kunit/usage.rst b/Documentation/dev-tools/kunit/usage.rst
index 473a2361ec37..3c3fe8b5fecc 100644
--- a/Documentation/dev-tools/kunit/usage.rst
+++ b/Documentation/dev-tools/kunit/usage.rst
@@ -595,7 +595,7 @@ able to run one test case per invocation.
KUnit debugfs representation
============================
When kunit test suites are initialized, they create an associated directory
-in /sys/kernel/debug/kunit/<test-suite>. The directory contains one file
+in ``/sys/kernel/debug/kunit/<test-suite>``. The directory contains one file
- results: "cat results" displays results of each test case and the results
of the entire suite for the last test run.
@@ -604,4 +604,4 @@ The debugfs representation is primarily of use when kunit test suites are
run in a native environment, either as modules or builtin. Having a way
to display results like this is valuable as otherwise results can be
intermixed with other events in dmesg output. The maximum size of each
-results file is KUNIT_LOG_SIZE bytes (defined in include/kunit/test.h).
+results file is KUNIT_LOG_SIZE bytes (defined in ``include/kunit/test.h``).
diff --git a/include/kunit/test.h b/include/kunit/test.h
index 9b0c46a6ca1f..b8a8434443b0 100644
--- a/include/kunit/test.h
+++ b/include/kunit/test.h
@@ -175,7 +175,7 @@ struct kunit_suite {
void (*exit)(struct kunit *test);
struct kunit_case *test_cases;
- /* private - internal use only */
+ /* private: internal use only */
struct dentry *debugfs;
char *log;
};
@@ -232,12 +232,13 @@ void __kunit_test_suites_exit(struct kunit_suite **suites);
* kunit_test_suites() - used to register one or more &struct kunit_suite
* with KUnit.
*
- * @suites: a statically allocated list of &struct kunit_suite.
+ * @...: a statically allocated list of &struct kunit_suite, assigned
+ * to the pointer @suites.
*
* Registers @suites with the test framework. See &struct kunit_suite for
* more information.
*
- * When builtin, KUnit tests are all run as late_initcalls; this means
+ * When builtin, KUnit tests are all run as late_initcalls; this means
* that they cannot test anything where tests must run at a different init
* phase. One significant restriction resulting from this is that KUnit
* cannot reliably test anything that is initialize in the late_init phase;
--
2.20.1
+Sai
On 4/13/2020 2:43 AM, David Binderman wrote:
> Hello there,
>
> Source code is
>
> while (fgets(temp, 1024, fp)) {
>
> but
>
> char *token_array[8], temp[512];
>
> Use of compiler flag -D_FORTIFY_SOURCE=2 would have found the problem.
> For example:
>
> # include <stdio.h>
>
> extern void g( int);
>
> void
> f( FILE * fp)
> {
> char buf[ 100];
>
> while (fgets( buf, 200, fp) != 0)
> {
> g( 1);
> }
> }
>
> gives
>
> $ /home/dcb/gcc/results/bin/gcc -c -g -O2 -D_FORTIFY_SOURCE=2 apr13c.cc
> In file included from /usr/include/stdio.h:867,
> from apr13c.cc:2:
> In function ‘char* fgets(char*, int, FILE*)’,
> inlined from ‘void f(FILE*)’ at apr13c.cc:11:14:
> /usr/include/bits/stdio2.h:263:26: warning: call to ‘__fgets_chk_warn’ declared with attribute warning: fgets called with bigger size than length of destination buffer [-Wattribute-warning]
>
> I suggest switch on compiler flag -D_FORTIFY_SOURCE=2 in
> all development builds.
>
Thank you very much for catching this David.
Sai: could you include this fix in your upcoming series of fixes? Using
the pattern of "fgets(buf, sizeof(buf), ...)" instead of hard coding the
size should be helpful here.
Reinette
While running seccomp_bpf, kill_after_ptrace() gets stuck if we run it
via /usr/bin/timeout (that is the default), until the timeout expires.
This is because /usr/bin/timeout is preventing to properly deliver
signals to ptrace'd children (SIGSYS in this case).
This problem can be easily reproduced by running:
$ sudo make TARGETS=seccomp kselftest
...
# [ RUN ] TRACE_syscall.skip_a#
not ok 1 selftests: seccomp: seccomp_bpf # TIMEOUT
The test is hanging at this point until the timeout expires and then it
reports the timeout error.
Prevent this problem by passing --foreground to /usr/bin/timeout,
allowing to properly deliver signals to children processes.
Signed-off-by: Andrea Righi <andrea.righi(a)canonical.com>
---
tools/testing/selftests/kselftest/runner.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/kselftest/runner.sh b/tools/testing/selftests/kselftest/runner.sh
index e84d901f8567..676b3a8b114d 100644
--- a/tools/testing/selftests/kselftest/runner.sh
+++ b/tools/testing/selftests/kselftest/runner.sh
@@ -33,7 +33,7 @@ tap_timeout()
{
# Make sure tests will time out if utility is available.
if [ -x /usr/bin/timeout ] ; then
- /usr/bin/timeout "$kselftest_timeout" "$1"
+ /usr/bin/timeout --foreground "$kselftest_timeout" "$1"
else
"$1"
fi
--
2.25.1
Fix warnings at 'make htmldocs', and formatting issues in the resulting
documentation.
- test.h: Fix some typos in kernel-doc parameter description.
- Documentation/*.rst: Fixing formatting issues, and a duplicate label
issue, since using sphinx.ext.autosectionlabel in conf.py, referes to
headers are generated automatically and sphinx will not complain about
identical headers among documents anymore.
The downside is, automatically generated header labels within one
document now cannot be overwritten manually anymore. Thus duplicate
headers within one document have to have different wording, i.e. this
patch modifies some headers.
- Documentation/api/*: Flipping over to a page "API" containing a single
link to another page "API" seems like a formatting issue. The patch
removes one level of indirection.
Signed-off-by: Lothar Rubusch <l.rubusch(a)gmail.com>
---
Documentation/dev-tools/kunit/api/index.rst | 16 ----------------
Documentation/dev-tools/kunit/index.rst | 4 ++--
Documentation/dev-tools/kunit/start.rst | 13 ++++++++-----
Documentation/dev-tools/kunit/usage.rst | 4 ++--
include/kunit/test.h | 5 +++--
5 files changed, 15 insertions(+), 27 deletions(-)
delete mode 100644 Documentation/dev-tools/kunit/api/index.rst
diff --git a/Documentation/dev-tools/kunit/api/index.rst b/Documentation/dev-tools/kunit/api/index.rst
deleted file mode 100644
index 9b9bffe5d41a..000000000000
--- a/Documentation/dev-tools/kunit/api/index.rst
+++ /dev/null
@@ -1,16 +0,0 @@
-.. SPDX-License-Identifier: GPL-2.0
-
-=============
-API Reference
-=============
-.. toctree::
-
- test
-
-This section documents the KUnit kernel testing API. It is divided into the
-following sections:
-
-================================= ==============================================
-:doc:`test` documents all of the standard testing API
- excluding mocking or mocking related features.
-================================= ==============================================
diff --git a/Documentation/dev-tools/kunit/index.rst b/Documentation/dev-tools/kunit/index.rst
index e93606ecfb01..640bba1f4896 100644
--- a/Documentation/dev-tools/kunit/index.rst
+++ b/Documentation/dev-tools/kunit/index.rst
@@ -10,7 +10,7 @@ KUnit - Unit Testing for the Linux Kernel
start
usage
kunit-tool
- api/index
+ api/test
faq
What is KUnit?
@@ -88,6 +88,6 @@ How do I use it?
* :doc:`start` - for new users of KUnit
* :doc:`usage` - for a more detailed explanation of KUnit features
-* :doc:`api/index` - for the list of KUnit APIs used for testing
+* :doc:`api/test` - for the list of KUnit APIs used for testing
* :doc:`kunit-tool` - for more information on the kunit_tool helper script
* :doc:`faq` - for answers to some common questions about KUnit
diff --git a/Documentation/dev-tools/kunit/start.rst b/Documentation/dev-tools/kunit/start.rst
index e1c5ce80ce12..bb112cf70624 100644
--- a/Documentation/dev-tools/kunit/start.rst
+++ b/Documentation/dev-tools/kunit/start.rst
@@ -32,15 +32,17 @@ test targets as well. The ``.kunitconfig`` should also contain any other config
options required by the tests.
A good starting point for a ``.kunitconfig`` is the KUnit defconfig:
+
.. code-block:: bash
cd $PATH_TO_LINUX_REPO
cp arch/um/configs/kunit_defconfig .kunitconfig
You can then add any other Kconfig options you wish, e.g.:
+
.. code-block:: none
- CONFIG_LIST_KUNIT_TEST=y
+ CONFIG_LIST_KUNIT_TEST=y
:doc:`kunit_tool <kunit-tool>` will ensure that all config options set in
``.kunitconfig`` are set in the kernel ``.config`` before running the tests.
@@ -54,8 +56,8 @@ using.
other tools (such as make menuconfig) to adjust other config options.
-Running the tests
------------------
+Running the tests (KUnit Wrapper)
+---------------------------------
To make sure that everything is set up correctly, simply invoke the Python
wrapper from your kernel repo:
@@ -105,8 +107,9 @@ have config options ending in ``_KUNIT_TEST``.
KUnit and KUnit tests can be compiled as modules: in this case the tests in a
module will be run when the module is loaded.
-Running the tests
------------------
+
+Running the tests (w/o KUnit Wrapper)
+-------------------------------------
Build and run your kernel as usual. Test output will be written to the kernel
log in `TAP <https://testanything.org/>`_ format.
diff --git a/Documentation/dev-tools/kunit/usage.rst b/Documentation/dev-tools/kunit/usage.rst
index 473a2361ec37..3c3fe8b5fecc 100644
--- a/Documentation/dev-tools/kunit/usage.rst
+++ b/Documentation/dev-tools/kunit/usage.rst
@@ -595,7 +595,7 @@ able to run one test case per invocation.
KUnit debugfs representation
============================
When kunit test suites are initialized, they create an associated directory
-in /sys/kernel/debug/kunit/<test-suite>. The directory contains one file
+in ``/sys/kernel/debug/kunit/<test-suite>``. The directory contains one file
- results: "cat results" displays results of each test case and the results
of the entire suite for the last test run.
@@ -604,4 +604,4 @@ The debugfs representation is primarily of use when kunit test suites are
run in a native environment, either as modules or builtin. Having a way
to display results like this is valuable as otherwise results can be
intermixed with other events in dmesg output. The maximum size of each
-results file is KUNIT_LOG_SIZE bytes (defined in include/kunit/test.h).
+results file is KUNIT_LOG_SIZE bytes (defined in ``include/kunit/test.h``).
diff --git a/include/kunit/test.h b/include/kunit/test.h
index 9b0c46a6ca1f..16d548b795b5 100644
--- a/include/kunit/test.h
+++ b/include/kunit/test.h
@@ -175,7 +175,7 @@ struct kunit_suite {
void (*exit)(struct kunit *test);
struct kunit_case *test_cases;
- /* private - internal use only */
+ /* private: internal use only */
struct dentry *debugfs;
char *log;
};
@@ -232,7 +232,8 @@ void __kunit_test_suites_exit(struct kunit_suite **suites);
* kunit_test_suites() - used to register one or more &struct kunit_suite
* with KUnit.
*
- * @suites: a statically allocated list of &struct kunit_suite.
+ * @...: a statically allocated list of &struct kunit_suite, assigned
+ * to the pointer @suites.
*
* Registers @suites with the test framework. See &struct kunit_suite for
* more information.
--
2.20.1
The second patch was already posted independently but because
of the changes in the first patch, the second one now depends
on it. Hence posting it now as a part of this series.
The last version (v2) of the second patch can be found at:
https://patchwork.ozlabs.org/patch/1225969/
Sandipan Das (2):
selftests: vm: Do not override definition of ARCH
selftests: vm: Fix 64-bit test builds for powerpc64le
tools/testing/selftests/vm/Makefile | 4 ++--
tools/testing/selftests/vm/run_vmtests | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
--
2.17.1
From: Daniel Latypov <dlatypov(a)google.com>
kunit parses .config in the `build_reconfig()` of `run_tests()`.
Problematically, the current regex '^CONFIG_\w+=\S+$' does not allow for
spaces anywhere after the "=", even the option is a string.
So kunit will refuse to run if the existing .config has something like
CONFIG_CMDLINE="something and_something_else"
even if kunit.py will drop this entry when it regenerates the .config!
So relax the regex to allow entries that match `CONFIG_\w+=".*"` as a
minimal change. The question remains as to whether we should do any
validation of the string after the "=", however.
Signed-off-by: Daniel Latypov <dlatypov(a)google.com>
Signed-off-by: Brendan Higgins <brendanhiggins(a)google.com>
---
tools/testing/kunit/kunit_config.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/kunit/kunit_config.py b/tools/testing/kunit/kunit_config.py
index e75063d603b5..0733796b0e32 100644
--- a/tools/testing/kunit/kunit_config.py
+++ b/tools/testing/kunit/kunit_config.py
@@ -10,7 +10,7 @@ import collections
import re
CONFIG_IS_NOT_SET_PATTERN = r'^# CONFIG_(\w+) is not set$'
-CONFIG_PATTERN = r'^CONFIG_(\w+)=(\S+)$'
+CONFIG_PATTERN = r'^CONFIG_(\w+)=(".*"|\S+)$'
KconfigEntryBase = collections.namedtuple('KconfigEntry', ['name', 'value'])
base-commit: c0cc271173b2e1c2d8d0ceaef14e4dfa79eefc0d
--
2.26.0.110.g2183baf09c-goog
This series introduces a new KVM selftest (mem_slot_test) that goal
is to verify memory slots can be added up to the maximum allowed. An
extra slot is attempted which should occur on error.
The patch 01 is needed so that the VM fd can be accessed from the
test code (for the ioctl call attempting to add an extra slot).
I ran the test successfully on x86_64, aarch64, and s390x. This
is why it is enabled to build on those arches.
- Changelog -
v3 -> v4:
- Discarded mem_reg_flags variable. Simply using 0 instead [drjones]
- Discarded kvm_region pointer. Instead passing a compound literal in
the ioctl [drjones]
- All variables are declared on the declaration block [drjones]
v2 -> v3:
- Keep alphabetical order of .gitignore and Makefile [drjones]
- Use memory region flags equals to zero [drjones]
- Changed mmap() assert from 'mem != NULL' to 'mem != MAP_FAILED' [drjones]
- kvm_region is declared along side other variables and malloc()'ed
later [drjones]
- Combined two asserts into a single 'ret == -1 && errno == EINVAL'
[drjones]
v1 -> v2:
- Rebased to queue
- vm_get_fd() returns int instead of unsigned int (patch 01) [drjones]
- Removed MEM_REG_FLAGS and GUEST_VM_MODE defines [drjones]
- Replaced DEBUG() with pr_info() [drjones]
- Calculate number of guest pages with vm_calc_num_guest_pages()
[drjones]
- Using memory region of 1 MB sized (matches mininum needed
for s390x)
- Removed the increment of guest_addr after the loop [drjones]
- Added assert for the errno when adding a slot beyond-the-limit [drjones]
- Prefer KVM_MEM_READONLY flag but on s390x it switch to KVM_MEM_LOG_DIRTY_PAGES,
so ensure the coverage of both flags. Also somewhat tests the KVM_CAP_READONLY_MEM capability check [drjones]
- Moved the test logic to test_add_max_slots(), this allows to more easily add new cases in the "suite".
v1: https://lore.kernel.org/kvm/20200330204310.21736-1-wainersm@redhat.com
Wainer dos Santos Moschetta (2):
selftests: kvm: Add vm_get_fd() in kvm_util
selftests: kvm: Add mem_slot_test test
tools/testing/selftests/kvm/.gitignore | 1 +
tools/testing/selftests/kvm/Makefile | 3 +
.../testing/selftests/kvm/include/kvm_util.h | 1 +
tools/testing/selftests/kvm/lib/kvm_util.c | 5 ++
tools/testing/selftests/kvm/mem_slot_test.c | 76 +++++++++++++++++++
5 files changed, 86 insertions(+)
create mode 100644 tools/testing/selftests/kvm/mem_slot_test.c
--
2.17.2
Avoid using /usr/bin/timeout unnecessarily if timeout is set to 0
(disabled) in the "settings" file for a specific test.
NOTE: without this change (and adding timeout=0 in the corresponding
settings file - tools/testing/selftests/seccomp/settings) the
seccomp_bpf selftest is always failing with a timeout event during the
syscall_restart step.
Signed-off-by: Andrea Righi <andrea.righi(a)canonical.com>
---
tools/testing/selftests/kselftest/runner.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/kselftest/runner.sh b/tools/testing/selftests/kselftest/runner.sh
index e84d901f8567..2cd3c8def0f6 100644
--- a/tools/testing/selftests/kselftest/runner.sh
+++ b/tools/testing/selftests/kselftest/runner.sh
@@ -32,7 +32,7 @@ tap_prefix()
tap_timeout()
{
# Make sure tests will time out if utility is available.
- if [ -x /usr/bin/timeout ] ; then
+ if [ -x /usr/bin/timeout ] && [ $kselftest_timeout -gt 0 ] ; then
/usr/bin/timeout "$kselftest_timeout" "$1"
else
"$1"
--
2.25.1
Fix several sphinx warnings at 'make htmldocs'
- privately declared members not correctly declared as such
- 'suits' actually is not a function parameter, change declaration to fix
warning but keep information in comment
Signed-off-by: Lothar Rubusch <l.rubusch(a)gmail.com>
---
include/kunit/test.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/kunit/test.h b/include/kunit/test.h
index 9b0c46a6ca1f..fe4ea388528b 100644
--- a/include/kunit/test.h
+++ b/include/kunit/test.h
@@ -175,7 +175,7 @@ struct kunit_suite {
void (*exit)(struct kunit *test);
struct kunit_case *test_cases;
- /* private - internal use only */
+ /* private: internal use only. */
struct dentry *debugfs;
char *log;
};
@@ -232,7 +232,7 @@ void __kunit_test_suites_exit(struct kunit_suite **suites);
* kunit_test_suites() - used to register one or more &struct kunit_suite
* with KUnit.
*
- * @suites: a statically allocated list of &struct kunit_suite.
+ * suites - a statically allocated list of &struct kunit_suite.
*
* Registers @suites with the test framework. See &struct kunit_suite for
* more information.
--
2.20.1
From: Tim Bird <tim.bird(a)sony.com>
It is useful for CI systems to be able to query the list
of targets provided by kselftest by default, so that they
can construct their own loop over the targets if desired.
Signed-off-by: Tim Bird <tim.bird(a)sony.com>
---
tools/testing/selftests/Makefile | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index 63430e2..9955e71 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -246,4 +246,7 @@ clean:
$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
done;
+show_targets:
+ @echo $(TARGETS)
+
.PHONY: khdr all run_tests hotplug run_hotplug clean_hotplug run_pstore_crash install clean
--
2.1.4
Hello,
I'm running kselftest on Ubuntu 16.04lts.
Details:
deepa@deepa-Inspiron-3576:/usr/src/linux-headers-4.15.0-88/Documentation$
uname -a
Linux deepa-Inspiron-3576 4.15.0-91-generic #92~16.04.1-Ubuntu SMP Fri
Feb 28 14:57:22 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Command:
deepa@deepa-Inspiron-3576:/usr/src/linux-headers-4.15.0-91-generic$
make -C tools/testing/selftests
Error:
make: Entering directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests'
make[1]: Entering directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/android'
Makefile:7: ../lib.mk: No such file or directory
make[1]: *** No rule to make target '../lib.mk'. Stop.
make[1]: Leaving directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/android'
make[1]: Entering directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/bpf'
Makefile:25: ../lib.mk: No such file or directory
/bin/sh: 1: llc: not found
make[1]: *** No rule to make target '../lib.mk'. Stop.
make[1]: Leaving directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/bpf'
make[1]: Entering directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/breakpoints'
Makefile:15: ../lib.mk: No such file or directory
make[1]: *** No rule to make target '../lib.mk'. Stop.
make[1]: Leaving directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/breakpoints'
make[1]: Entering directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/capabilities'
Makefile:8: ../lib.mk: No such file or directory
make[1]: *** No rule to make target '../lib.mk'. Stop.
make[1]: Leaving directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/capabilities'
make[1]: Entering directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/cpufreq'
Makefile:7: ../lib.mk: No such file or directory
make[1]: *** No rule to make target '../lib.mk'. Stop.
make[1]: Leaving directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/cpufreq'
make[1]: Entering directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/cpu-hotplug'
Makefile:6: ../lib.mk: No such file or directory
make[1]: *** No rule to make target '../lib.mk'. Stop.
make[1]: Leaving directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/cpu-hotplug'
make[1]: Entering directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/efivarfs'
Makefile:6: ../lib.mk: No such file or directory
make[1]: *** No rule to make target '../lib.mk'. Stop.
make[1]: Leaving directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/efivarfs'
make[1]: Entering directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/exec'
Makefile:11: ../lib.mk: No such file or directory
make[1]: *** No rule to make target '../lib.mk'. Stop.
make[1]: Leaving directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/exec'
make[1]: Entering directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/filesystems'
Makefile:7: ../lib.mk: No such file or directory
make[1]: *** No rule to make target '../lib.mk'. Stop.
make[1]: Leaving directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/filesystems'
make[1]: Entering directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/firmware'
Makefile:8: ../lib.mk: No such file or directory
make[1]: *** No rule to make target '../lib.mk'. Stop.
make[1]: Leaving directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/firmware'
make[1]: Entering directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/ftrace'
Makefile:8: ../lib.mk: No such file or directory
make[1]: *** No rule to make target '../lib.mk'. Stop.
make[1]: Leaving directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/ftrace'
make[1]: Entering directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/futex'
Makefile:8: ../lib.mk: No such file or directory
make[1]: *** No rule to make target '../lib.mk'. Stop.
make[1]: Leaving directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/futex'
make[1]: Entering directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/gpio'
Makefile:13: ../lib.mk: No such file or directory
make[1]: *** No rule to make target '../lib.mk'. Stop.
make[1]: Leaving directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/gpio'
make[1]: Entering directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/intel_pstate'
Makefile:11: ../lib.mk: No such file or directory
make[1]: *** No rule to make target '../lib.mk'. Stop.
make[1]: Leaving directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/intel_pstate'
make[1]: Entering directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/ipc'
Makefile:17: ../lib.mk: No such file or directory
make[1]: *** No rule to make target '../lib.mk'. Stop.
make[1]: Leaving directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/ipc'
make[1]: Entering directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/kcmp'
Makefile:7: ../lib.mk: No such file or directory
make[1]: *** No rule to make target '../lib.mk'. Stop.
make[1]: Leaving directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/kcmp'
make[1]: Entering directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/lib'
Makefile:8: ../lib.mk: No such file or directory
make[1]: *** No rule to make target '../lib.mk'. Stop.
make[1]: Leaving directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/lib'
make[1]: Entering directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/membarrier'
Makefile:5: ../lib.mk: No such file or directory
make[1]: *** No rule to make target '../lib.mk'. Stop.
make[1]: Leaving directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/membarrier'
make[1]: Entering directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/memfd'
Makefile:13: ../lib.mk: No such file or directory
make[1]: *** No rule to make target '../lib.mk'. Stop.
make[1]: Leaving directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/memfd'
make[1]: Entering directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/memory-hotplug'
Makefile:4: ../lib.mk: No such file or directory
make[1]: *** No rule to make target '../lib.mk'. Stop.
make[1]: Leaving directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/memory-hotplug'
make[1]: Entering directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/mount'
Makefile:8: ../lib.mk: No such file or directory
make[1]: *** No rule to make target '../lib.mk'. Stop.
make[1]: Leaving directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/mount'
make[1]: Entering directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/mqueue'
Makefile:6: ../lib.mk: No such file or directory
make[1]: *** No rule to make target '../lib.mk'. Stop.
make[1]: Leaving directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/mqueue'
make[1]: Entering directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/net'
Makefile:14: ../lib.mk: No such file or directory
make[1]: *** No rule to make target '../lib.mk'. Stop.
make[1]: Leaving directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/net'
make[1]: Entering directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/netfilter'
Makefile:6: ../lib.mk: No such file or directory
make[1]: *** No rule to make target '../lib.mk'. Stop.
make[1]: Leaving directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/netfilter'
make[1]: Entering directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/nsfs'
Makefile:5: ../lib.mk: No such file or directory
make[1]: *** No rule to make target '../lib.mk'. Stop.
make[1]: Leaving directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/nsfs'
make[1]: Entering directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/powerpc'
Makefile:40: ../lib.mk: No such file or directory
make[1]: *** No rule to make target '../lib.mk'. Stop.
make[1]: Leaving directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/powerpc'
make[1]: Entering directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/pstore'
Makefile:11: ../lib.mk: No such file or directory
make[1]: *** No rule to make target '../lib.mk'. Stop.
make[1]: Leaving directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/pstore'
make[1]: Entering directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/ptrace'
Makefile:5: ../lib.mk: No such file or directory
make[1]: *** No rule to make target '../lib.mk'. Stop.
make[1]: Leaving directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/ptrace'
make[1]: Entering directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/seccomp'
Makefile:4: ../lib.mk: No such file or directory
make[1]: *** No rule to make target '../lib.mk'. Stop.
make[1]: Leaving directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/seccomp'
make[1]: Entering directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/sigaltstack'
Makefile:4: ../lib.mk: No such file or directory
make[1]: *** No rule to make target '../lib.mk'. Stop.
make[1]: Leaving directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/sigaltstack'
make[1]: Entering directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/size'
Makefile:5: ../lib.mk: No such file or directory
make[1]: *** No rule to make target '../lib.mk'. Stop.
make[1]: Leaving directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/size'
make[1]: Entering directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/splice'
Makefile:5: ../lib.mk: No such file or directory
make[1]: *** No rule to make target '../lib.mk'. Stop.
make[1]: Leaving directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/splice'
make[1]: Entering directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/static_keys'
Makefile:8: ../lib.mk: No such file or directory
make[1]: *** No rule to make target '../lib.mk'. Stop.
make[1]: Leaving directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/static_keys'
make[1]: Entering directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/sync'
Makefile:8: ../lib.mk: No such file or directory
make[1]: *** No rule to make target '../lib.mk'. Stop.
make[1]: Leaving directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/sync'
make[1]: Entering directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/sysctl'
Makefile:9: ../lib.mk: No such file or directory
make[1]: *** No rule to make target '../lib.mk'. Stop.
make[1]: Leaving directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/sysctl'
make[1]: Entering directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/timers'
Makefile:17: ../lib.mk: No such file or directory
make[1]: *** No rule to make target '../lib.mk'. Stop.
make[1]: Leaving directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/timers'
make[1]: Entering directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/user'
Makefile:8: ../lib.mk: No such file or directory
make[1]: *** No rule to make target '../lib.mk'. Stop.
make[1]: Leaving directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/user'
make[1]: Entering directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/vm'
Makefile:28: ../lib.mk: No such file or directory
make[1]: *** No rule to make target '../lib.mk'. Stop.
make[1]: Leaving directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/vm'
make[1]: Entering directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/x86'
Makefile:4: ../lib.mk: No such file or directory
make[1]: *** No rule to make target '../lib.mk'. Stop.
make[1]: Leaving directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/x86'
make[1]: Entering directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/zram'
Makefile:8: ../lib.mk: No such file or directory
make[1]: *** No rule to make target '../lib.mk'. Stop.
make[1]: Leaving directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests/zram'
Makefile:73: recipe for target 'all' failed
make: *** [all] Error 2
make: Leaving directory
'/usr/src/linux-headers-4.15.0-91/tools/testing/selftests'
Can you please help us fix?
Is there an archive available for linux-kselftest? We could check it
once before posting it to this group.Just to avoid duplicates.
Thanks,
Deepa
On Tue, 7 Apr 2020 at 22:09, Greg Kroah-Hartman
<gregkh(a)linuxfoundation.org> wrote:
>
> This is the start of the stable review cycle for the 5.6.3 release.
> There are 30 patches in this series, all will be posted as a response
> to this one. If anyone has any issues with these being applied, please
> let me know.
>
> Responses should be made by Thu, 09 Apr 2020 15:46:32 +0000.
> Anything received after that time might be too late.
>
> The whole patch series can be found in one patch at:
> https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.6.3-rc2.…
> or in the git tree and branch at:
> git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-5.6.y
> and the diffstat can be found below.
>
> thanks,
>
> greg k-h
Results from Linaro’s test farm.
No regressions on arm64, arm, x86_64, and i386.
There are three kernel warnings on stable-rc 5.6 two of them are also
present in Linus's tree.
So these reported issues are not the release blockers.
The Source of these warnings are reported while running kselftests.
1) This warning reported on the mailing list and discussion is active.
Warning reported on x86_64, i386, arm and arm64.
[ 346.741358] kselftest: Running tests in lib
[ 346.872415] test_printf: loaded.
[ 346.876442] BUG: kernel NULL pointer dereference, address: 00000000
[ 346.882703] #PF: supervisor read access in kernel mode
[ 346.887844] #PF: error_code(0x0000) - not-present page
[ 346.892990] *pde = 00000000
[ 346.895877] Oops: 0000 [#1] SMP
[ 346.899025] CPU: 1 PID: 6060 Comm: modprobe Tainted: G W
5.6.3-rc2 #1
[ 346.906772] Hardware name: Supermicro SYS-5019S-ML/X11SSH-F, BIOS
2.0b 07/27/2017
[ 346.914261] EIP: ida_free+0x61/0x130
ref:
https://lore.kernel.org/linux-kselftest/CAFd5g46Bwd8HS9-xjHLh_rB59Nfw8iAnM6…
2) This warning is reported on the mailing list and waiting for response,
warning reported on i386 kernel image running x86_64 device.
[ 166.488084] ------------[ cut here ]------------
[ 166.492749] WARNING: CPU: 2 PID: 1456 at
/usr/src/kernel/kernel/locking/lockdep.c:1119
lockdep_register_key+0xb0/0xf0
[ 166.503357] Modules linked in: algif_hash af_alg
x86_pkg_temp_thermal fuse [last unloaded: test_bpf]
[ 166.512481] CPU: 2 PID: 1456 Comm: ip Not tainted 5.6.3-rc2 #1
[ 166.518306] Hardware name: Supermicro SYS-5019S-ML/X11SSH-F, BIOS
2.0b 07/27/2017
[ 166.525776] EIP: lockdep_register_key+0xb0/0xf0
ref:
https://lore.kernel.org/netdev/CA+G9fYt7-R-_fVDeiwj=sVvBQ-456Pm1oFFtM5Hm_94…
3) This warning is only noticed on stable rc 5.6 and 5.5 seen only on arm64.
This needs to be investigated.
[ 386.349099] kselftest: Running tests in ftrace
[ 393.984018]
[ 393.984290] =============================
[ 393.984781] WARNING: suspicious RCU usage
[ 393.988690] 5.6.3-rc2 #1 Not tainted
[ 393.992679] -----------------------------
[ 393.996327] /usr/src/kernel/include/trace/events/ipi.h:36
suspicious rcu_dereference_check() usage!
[ 394.000241]
[ 394.000241] other info that might help us debug this:
[ 394.000241]
[ 394.009094]
[ 394.009094] RCU used illegally from idle CPU!
[ 394.009094] rcu_scheduler_active = 2, debug_locks = 1
[ 394.017084] RCU used illegally from extended quiescent state!
[ 394.028187] 1 lock held by swapper/3/0:
[ 394.033826] #0: ffff80001237b6a8 (max_trace_lock){....}, at:
check_critical_timing+0x7c/0x1a8
ref:
https://lore.kernel.org/linux-kselftest/CA+G9fYtYRc_mKPDN-Gryw7fhjPNGBUP=Ke…
Summary
------------------------------------------------------------------------
kernel: 5.6.3-rc2
git repo: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
git branch: linux-5.6.y
git commit: f106acd0db7c11e0208a2ecbeb0f7c52fc6c455a
git describe: v5.6.2-31-gf106acd0db7c
Test details: https://qa-reports.linaro.org/lkft/linux-stable-rc-5.6-oe/build/v5.6.2-31-g…
No regressions (compared to build v5.6.2)
No fixes (compared to build v5.6.2)
Ran 22476 total tests in the following environments and test suites.
Environments
--------------
- dragonboard-410c
- hi6220-hikey
- i386
- juno-r2
- nxp-ls2088
- qemu_arm
- qemu_arm64
- qemu_i386
- qemu_x86_64
- x15
- x86
- x86-kasan
Test Suites
-----------
* build
* install-android-platform-tools-r2600
* install-android-platform-tools-r2800
* kselftest
* kvm-unit-tests
* libgpiod
* libhugetlbfs
* linux-log-parser
* ltp-cap_bounds-tests
* ltp-commands-tests
* ltp-cpuhotplug-tests
* ltp-crypto-tests
* ltp-cve-tests
* ltp-dio-tests
* ltp-fcntl-locktests-tests
* ltp-filecaps-tests
* ltp-fs-tests
* ltp-fs_bind-tests
* ltp-fs_perms_simple-tests
* ltp-fsx-tests
* ltp-hugetlb-tests
* ltp-io-tests
* ltp-ipc-tests
* ltp-math-tests
* ltp-nptl-tests
* ltp-pty-tests
* ltp-sched-tests
* ltp-securebits-tests
* perf
* v4l2-compliance
* ltp-containers-tests
* ltp-mm-tests
* ltp-open-posix-tests
* ltp-syscalls-tests
* network-basic-tests
* spectre-meltdown-checker-test
--
Linaro LKFT
https://lkft.linaro.org
This series introduces a new KVM selftest (mem_slot_test) that goal
is to verify memory slots can be added up to the maximum allowed. An
extra slot is attempted which should occur on error.
The patch 01 is needed so that the VM fd can be accessed from the
test code (for the ioctl call attempting to add an extra slot).
I ran the test successfully on x86_64, aarch64, and s390x. This
is why it is enabled to build on those arches.
- Changelog -
v2 -> v3:
- Keep alphabetical order of .gitignore and Makefile [drjones]
- Use memory region flags equals to zero [drjones]
- Changed mmap() assert from 'mem != NULL' to 'mem != MAP_FAILED' [drjones]
- kvm_region is declared along side other variables and malloc()'ed
later [drjones]
- Combined two asserts into a single 'ret == -1 && errno == EINVAL'
[drjones]
v1 -> v2:
- Rebased to queue
- vm_get_fd() returns int instead of unsigned int (patch 01) [drjones]
- Removed MEM_REG_FLAGS and GUEST_VM_MODE defines [drjones]
- Replaced DEBUG() with pr_info() [drjones]
- Calculate number of guest pages with vm_calc_num_guest_pages()
[drjones]
- Using memory region of 1 MB sized (matches mininum needed
for s390x)
- Removed the increment of guest_addr after the loop [drjones]
- Added assert for the errno when adding a slot beyond-the-limit [drjones]
- Prefer KVM_MEM_READONLY flag but on s390x it switch to KVM_MEM_LOG_DIRTY_PAGES,
so ensure the coverage of both flags. Also somewhat tests the KVM_CAP_READONLY_MEM capability check [drjones]
- Moved the test logic to test_add_max_slots(), this allows to more easily add new cases in the "suite".
v1: https://lore.kernel.org/kvm/20200330204310.21736-1-wainersm@redhat.com
Wainer dos Santos Moschetta (2):
selftests: kvm: Add vm_get_fd() in kvm_util
selftests: kvm: Add mem_slot_test test
tools/testing/selftests/kvm/.gitignore | 1 +
tools/testing/selftests/kvm/Makefile | 3 +
.../testing/selftests/kvm/include/kvm_util.h | 1 +
tools/testing/selftests/kvm/lib/kvm_util.c | 5 ++
tools/testing/selftests/kvm/mem_slot_test.c | 85 +++++++++++++++++++
5 files changed, 95 insertions(+)
create mode 100644 tools/testing/selftests/kvm/mem_slot_test.c
--
2.17.2
This series introduces a new KVM selftest (mem_slot_test) that goal
is to verify memory slots can be added up to the maximum allowed. An
extra slot is attempted which should occur on error.
The patch 01 is needed so that the VM fd can be accessed from the
test code (for the ioctl call attempting to add an extra slot).
I ran the test successfully on x86_64, aarch64, and s390x. This
is why it is enabled to build on those arches.
v1: https://lore.kernel.org/kvm/20200330204310.21736-1-wainersm@redhat.com
Changes v1 -> v2:
- Rebased to queue
- vm_get_fd() returns int instead of unsigned int (patch 01) [drjones]
- Removed MEM_REG_FLAGS and GUEST_VM_MODE defines [drjones]
- Replaced DEBUG() with pr_info() [drjones]
- Calculate number of guest pages with vm_calc_num_guest_pages()
[drjones]
- Using memory region of 1 MB sized (matches mininum needed
for s390x)
- Removed the increment of guest_addr after the loop [drjones]
- Added assert for the errno when adding a slot beyond-the-limit [drjones]
- Prefer KVM_MEM_READONLY flag but on s390x it switch to KVM_MEM_LOG_DIRTY_PAGES,
so ensure the coverage of both flags. Also somewhat tests the KVM_CAP_READONLY_MEM capability check [drjones]
- Moved the test logic to test_add_max_slots(), this allows to more easily add new cases in the "suite".
Wainer dos Santos Moschetta (2):
selftests: kvm: Add vm_get_fd() in kvm_util
selftests: kvm: Add mem_slot_test test
tools/testing/selftests/kvm/.gitignore | 1 +
tools/testing/selftests/kvm/Makefile | 3 +
.../testing/selftests/kvm/include/kvm_util.h | 1 +
tools/testing/selftests/kvm/lib/kvm_util.c | 5 ++
tools/testing/selftests/kvm/mem_slot_test.c | 85 +++++++++++++++++++
5 files changed, 95 insertions(+)
create mode 100644 tools/testing/selftests/kvm/mem_slot_test.c
--
2.17.2
From: Alan Maguire <alan.maguire(a)oracle.com>
[ Upstream commit 83a9b6f639e9f6b632337f9776de17d51d969c77 ]
Many systems build/test up-to-date kernels with older libcs, and
an older glibc (2.17) lacks the definition of SOL_DCCP in
/usr/include/bits/socket.h (it was added in the 4.6 timeframe).
Adding the definition to the test program avoids a compilation
failure that gets in the way of building tools/testing/selftests/net.
The test itself will work once the definition is added; either
skipping due to DCCP not being configured in the kernel under test
or passing, so there are no other more up-to-date glibc dependencies
here it seems beyond that missing definition.
Fixes: 11fb60d1089f ("selftests: net: reuseport_addr_any: add DCCP")
Signed-off-by: Alan Maguire <alan.maguire(a)oracle.com>
Signed-off-by: David S. Miller <davem(a)davemloft.net>
Signed-off-by: Sasha Levin <sashal(a)kernel.org>
---
tools/testing/selftests/net/reuseport_addr_any.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tools/testing/selftests/net/reuseport_addr_any.c b/tools/testing/selftests/net/reuseport_addr_any.c
index c6233935fed14..b8475cb29be7a 100644
--- a/tools/testing/selftests/net/reuseport_addr_any.c
+++ b/tools/testing/selftests/net/reuseport_addr_any.c
@@ -21,6 +21,10 @@
#include <sys/socket.h>
#include <unistd.h>
+#ifndef SOL_DCCP
+#define SOL_DCCP 269
+#endif
+
static const char *IP4_ADDR = "127.0.0.1";
static const char *IP6_ADDR = "::1";
static const char *IP4_MAPPED6 = "::ffff:127.0.0.1";
--
2.20.1
From: Alan Maguire <alan.maguire(a)oracle.com>
[ Upstream commit 83a9b6f639e9f6b632337f9776de17d51d969c77 ]
Many systems build/test up-to-date kernels with older libcs, and
an older glibc (2.17) lacks the definition of SOL_DCCP in
/usr/include/bits/socket.h (it was added in the 4.6 timeframe).
Adding the definition to the test program avoids a compilation
failure that gets in the way of building tools/testing/selftests/net.
The test itself will work once the definition is added; either
skipping due to DCCP not being configured in the kernel under test
or passing, so there are no other more up-to-date glibc dependencies
here it seems beyond that missing definition.
Fixes: 11fb60d1089f ("selftests: net: reuseport_addr_any: add DCCP")
Signed-off-by: Alan Maguire <alan.maguire(a)oracle.com>
Signed-off-by: David S. Miller <davem(a)davemloft.net>
Signed-off-by: Sasha Levin <sashal(a)kernel.org>
---
tools/testing/selftests/net/reuseport_addr_any.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tools/testing/selftests/net/reuseport_addr_any.c b/tools/testing/selftests/net/reuseport_addr_any.c
index c6233935fed14..b8475cb29be7a 100644
--- a/tools/testing/selftests/net/reuseport_addr_any.c
+++ b/tools/testing/selftests/net/reuseport_addr_any.c
@@ -21,6 +21,10 @@
#include <sys/socket.h>
#include <unistd.h>
+#ifndef SOL_DCCP
+#define SOL_DCCP 269
+#endif
+
static const char *IP4_ADDR = "127.0.0.1";
static const char *IP6_ADDR = "::1";
static const char *IP4_MAPPED6 = "::ffff:127.0.0.1";
--
2.20.1
This patchset contains everything needed to integrate KASAN and KUnit.
KUnit will be able to:
(1) Fail tests when an unexpected KASAN error occurs
(2) Pass tests when an expected KASAN error occurs
Convert KASAN tests to KUnit with the exception of copy_user_test
because KUnit is unable to test those.
Add documentation on how to run the KASAN tests with KUnit and what to
expect when running these tests.
Depends on "[PATCH v3 kunit-next 0/2] kunit: extend kunit resources
API" patchset [1]
[1] https://lore.kernel.org/linux-kselftest/1585313122-26441-1-git-send-email-a…
Changes from v3:
- KUNIT_SET_KASAN_DATA and KUNIT_DO_EXPECT_KASAN_FAIL have been
combined and included in KUNIT_DO_EXPECT_KASAN_FAIL() instead.
- Reordered logic in kasan_update_kunit_status() in report.c to be
easier to read.
- Added comment to not use the name "kasan_data" for any kunit tests
outside of KUNIT_EXPECT_KASAN_FAIL().
Patricia Alfonso (4):
Add KUnit Struct to Current Task
KUnit: KASAN Integration
KASAN: Port KASAN Tests to KUnit
KASAN: Testing Documentation
Documentation/dev-tools/kasan.rst | 70 +++
include/kunit/test.h | 5 +
include/linux/kasan.h | 6 +
include/linux/sched.h | 4 +
lib/Kconfig.kasan | 15 +-
lib/Makefile | 3 +-
lib/kunit/test.c | 13 +-
lib/test_kasan.c | 680 +++++++++++++-----------------
lib/test_kasan_module.c | 76 ++++
mm/kasan/report.c | 30 ++
10 files changed, 511 insertions(+), 391 deletions(-)
create mode 100644 lib/test_kasan_module.c
--
2.26.0.292.g33ef6b2f38-goog
The following 4 tests in timers can take longer than the default 45
seconds that added in commit 852c8cbf (selftests/kselftest/runner.sh:
Add 45 second timeout per test) to run:
* nsleep-lat - 2m7.350s
* set-timer-lat - 2m0.66s
* inconsistency-check - 1m45.074s
* raw_skew - 2m0.013s
Thus they will be marked as failed with the current 45s setting:
not ok 3 selftests: timers: nsleep-lat # TIMEOUT
not ok 4 selftests: timers: set-timer-lat # TIMEOUT
not ok 6 selftests: timers: inconsistency-check # TIMEOUT
not ok 7 selftests: timers: raw_skew # TIMEOUT
Disable the timeout setting for timers can make these tests finish
properly:
ok 3 selftests: timers: nsleep-lat
ok 4 selftests: timers: set-timer-lat
ok 6 selftests: timers: inconsistency-check
ok 7 selftests: timers: raw_skew
https://bugs.launchpad.net/bugs/1864626
Signed-off-by: Po-Hsu Lin <po-hsu.lin(a)canonical.com>
---
tools/testing/selftests/timers/Makefile | 1 +
tools/testing/selftests/timers/settings | 1 +
2 files changed, 2 insertions(+)
create mode 100644 tools/testing/selftests/timers/settings
diff --git a/tools/testing/selftests/timers/Makefile b/tools/testing/selftests/timers/Makefile
index 7656c7c..0e73a16 100644
--- a/tools/testing/selftests/timers/Makefile
+++ b/tools/testing/selftests/timers/Makefile
@@ -13,6 +13,7 @@ DESTRUCTIVE_TESTS = alarmtimer-suspend valid-adjtimex adjtick change_skew \
TEST_GEN_PROGS_EXTENDED = $(DESTRUCTIVE_TESTS)
+TEST_FILES := settings
include ../lib.mk
diff --git a/tools/testing/selftests/timers/settings b/tools/testing/selftests/timers/settings
new file mode 100644
index 0000000..e7b9417
--- /dev/null
+++ b/tools/testing/selftests/timers/settings
@@ -0,0 +1 @@
+timeout=0
--
2.7.4
Summary
------------------------------------------------------------------------
kernel: 5.6.0
git repo: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
git branch: master
git commit: b2e2a818a01717ba15c74fd355f76822b81a95f6
git describe: next-20200406
Test details: https://qa-reports.linaro.org/lkft/linux-next-oe/build/next-20200406
Regressions (compared to build next-20200405)
------------------------------------------------------------------------
No regressions
Fixes (compared to build next-20200405)
------------------------------------------------------------------------
No fixes
In total:
------------------------------------------------------------------------
Ran 0 total tests in the following environments and test suites.
pass 0
fail 0
xfail 0
skip 0
Environments
--------------
- x15 - arm
Test Suites
-----------
Failures
------------------------------------------------------------------------
x15:
Skips
------------------------------------------------------------------------
No skips
--
Linaro LKFT
https://lkft.linaro.org
A lot of ftrace testcases get failure if ftrace_enabled is disabled by default
because ftrace_enabled is a big on/off switch for the whole function tracer.
Signed-off-by: Xiao Yang <yangx.jy(a)cn.fujitsu.com>
---
tools/testing/selftests/ftrace/test.d/functions | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tools/testing/selftests/ftrace/test.d/functions b/tools/testing/selftests/ftrace/test.d/functions
index 5d4550591ff9..54c18275bd7f 100644
--- a/tools/testing/selftests/ftrace/test.d/functions
+++ b/tools/testing/selftests/ftrace/test.d/functions
@@ -1,3 +1,6 @@
+enable_ftrace() { # enable function tracer
+ echo 1 > /proc/sys/kernel/ftrace_enabled
+}
clear_trace() { # reset trace output
echo > trace
@@ -88,6 +91,7 @@ initialize_ftrace() { # Reset ftrace to initial-state
# As the initial state, ftrace will be set to nop tracer,
# no events, no triggers, no filters, no function filters,
# no probes, and tracing on.
+ enable_ftrace
disable_tracing
reset_tracer
reset_trigger
--
2.23.0
This patchset contains everything needed to integrate KASAN and KUnit.
KUnit will be able to:
(1) Fail tests when an unexpected KASAN error occurs
(2) Pass tests when an expected KASAN error occurs
Convert KASAN tests to KUnit with the exception of copy_user_test
because KUnit is unable to test those.
Add documentation on how to run the KASAN tests with KUnit and what to
expect when running these tests.
Depends on [1].
Changes since v2:
- Due to Alan's changes in [1], KUnit can be built as a module.
- The name of the tests that could not be run with KUnit has been
changed to be more generic: test_kasan_module.
- Documentation on how to run the new KASAN tests and what to expect
when running them has been added.
- Some variables and functions are now static.
- Now save/restore panic_on_warn in a similar way to kasan_multi_shot
and renamed the init/exit functions to be more generic to accommodate.
- Due to [2] in kasan_strings, kasan_memchr, and
kasan_memcmp will fail if CONFIG_AMD_MEM_ENCRYPT is enabled so return
early and print message explaining this circumstance.
- Changed preprocessor checks to C checks where applicable.
[1] https://lore.kernel.org/linux-kselftest/1585313122-26441-1-git-send-email-a…
[2] https://bugzilla.kernel.org/show_bug.cgi?id=206337
Patricia Alfonso (4):
Add KUnit Struct to Current Task
KUnit: KASAN Integration
KASAN: Port KASAN Tests to KUnit
KASAN: Testing Documentation
Documentation/dev-tools/kasan.rst | 70 +++
include/kunit/test.h | 5 +
include/linux/kasan.h | 6 +
include/linux/sched.h | 4 +
lib/Kconfig.kasan | 15 +-
lib/Makefile | 3 +-
lib/kunit/test.c | 13 +-
lib/test_kasan.c | 686 +++++++++++++-----------------
lib/test_kasan_module.c | 76 ++++
mm/kasan/report.c | 33 ++
10 files changed, 521 insertions(+), 390 deletions(-)
create mode 100644 lib/test_kasan_module.c
--
2.26.0.rc2.310.g2932bb562d-goog
From: Colin Ian King <colin.king(a)canonical.com>
Currently pointer 'suite' is dereferenced when variable success
is being initialized before the pointer is null checked. Fix this
by only dereferencing suite after is has been null checked.
Addresses-Coverity: ("Dereference before null check")
Fixes: e2219db280e3 ("kunit: add debugfs /sys/kernel/debug/kunit/<suite>/results display")
Signed-off-by: Colin Ian King <colin.king(a)canonical.com>
---
lib/kunit/debugfs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/kunit/debugfs.c b/lib/kunit/debugfs.c
index 9214c493d8b7..05547642f37c 100644
--- a/lib/kunit/debugfs.c
+++ b/lib/kunit/debugfs.c
@@ -52,12 +52,13 @@ static void debugfs_print_result(struct seq_file *seq,
static int debugfs_print_results(struct seq_file *seq, void *v)
{
struct kunit_suite *suite = (struct kunit_suite *)seq->private;
- bool success = kunit_suite_has_succeeded(suite);
+ bool success;
struct kunit_case *test_case;
if (!suite || !suite->log)
return 0;
+ success = kunit_suite_has_succeeded(suite);
seq_printf(seq, "%s", suite->log);
kunit_suite_for_each_test_case(suite, test_case)
--
2.25.1
This series introduces a new KVM selftest (mem_slot_test) that goal
is to verify memory slots can be added up to the maximum allowed. An
extra slot is attempted which should occur on error.
The patch 01 is needed so that the VM fd can be accessed from the
test code (for the ioctl call attempting to add an extra slot).
I ran the test successfully on x86_64, aarch64, and s390x. This
is why it is enabled to build on those arches.
Finally, I hope it is useful test!
Wainer dos Santos Moschetta (2):
selftests: kvm: Add vm_get_fd() in kvm_util
selftests: kvm: Add mem_slot_test test
tools/testing/selftests/kvm/.gitignore | 1 +
tools/testing/selftests/kvm/Makefile | 3 +
.../testing/selftests/kvm/include/kvm_util.h | 1 +
tools/testing/selftests/kvm/lib/kvm_util.c | 5 +
tools/testing/selftests/kvm/mem_slot_test.c | 92 +++++++++++++++++++
5 files changed, 102 insertions(+)
create mode 100644 tools/testing/selftests/kvm/mem_slot_test.c
--
2.17.2
Hi Linus,
Please pull the following Kselftest Kunit update for Linux 5.7-rc1.
This kunit update for Linux-5.7-rc1 consists of:
- debugfs support for displaying kunit test suite results; this is
especially useful for module-loaded tests to allow disentangling of
test result display from other dmesg events. CONFIG_KUNIT_DEBUGFS
enables/disables the debugfs support.
- Several fixes and improvements to kunit framework and tool.
diff is attached.
thanks,
-- Shuah
----------------------------------------------------------------
The following changes since commit 2c523b344dfa65a3738e7039832044aa133c75fb:
Linux 5.6-rc5 (2020-03-08 17:44:44 -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.7-rc1
for you to fetch changes up to e23349af9ee25a5760112a2f8476b94a4ec86f1c:
kunit: tool: add missing test data file content (2020-03-26 14:11:12
-0600)
----------------------------------------------------------------
linux-kselftest-kunit-5.7-rc1
This kunit update for Linux-5.7-rc1 consists of:
- debugfs support for displaying kunit test suite results; this is
especially useful for module-loaded tests to allow disentangling of
test result display from other dmesg events. CONFIG_KUNIT_DEBUGFS
enables/disables the debugfs support.
- Several fixes and improvements to kunit framework and tool.
----------------------------------------------------------------
Alan Maguire (4):
kunit: add debugfs /sys/kernel/debug/kunit/<suite>/results display
kunit: add log test
kunit: subtests should be indented 4 spaces according to TAP
kunit: update documentation to describe debugfs representation
Brendan Higgins (1):
kunit: tool: add missing test data file content
David Gow (4):
kunit: Always print actual pointer values in asserts
kunit: kunit_tool: Allow .kunitconfig to disable config items
Fix linked-list KUnit test when run multiple times
Documentation: kunit: Make the KUnit documentation less UML-specific
Greg Thelen (1):
kunit: add --make_options
Heidi Fahim (2):
kunit: kunit_parser: make parser more robust
kunit: Run all KUnit tests through allyesconfig
Documentation/dev-tools/kunit/index.rst | 40 +++---
Documentation/dev-tools/kunit/kunit-tool.rst | 7 +
Documentation/dev-tools/kunit/start.rst | 80 +++++++++--
Documentation/dev-tools/kunit/usage.rst | 14 ++
include/kunit/test.h | 63 +++++++--
lib/kunit/Kconfig | 8 ++
lib/kunit/Makefile | 4 +
lib/kunit/assert.c | 79 +++++------
lib/kunit/debugfs.c | 116 ++++++++++++++++
lib/kunit/debugfs.h | 30 +++++
lib/kunit/kunit-test.c | 44 +++++-
lib/kunit/test.c | 148
++++++++++++++++-----
lib/list-test.c | 4 +-
tools/testing/kunit/.gitattributes | 1 +
tools/testing/kunit/configs/broken_on_uml.config | 41 ++++++
tools/testing/kunit/kunit.py | 38 ++++--
tools/testing/kunit/kunit_config.py | 41 ++++--
tools/testing/kunit/kunit_kernel.py | 84 ++++++++----
tools/testing/kunit/kunit_parser.py | 51 +++----
tools/testing/kunit/kunit_tool_test.py | 108 ++++++++++++---
.../kunit/test_data/test_config_printk_time.log | Bin 0 -> 1584 bytes
.../test_data/test_interrupted_tap_output.log | Bin 0 -> 1982 bytes
.../test_data/test_kernel_panic_interrupt.log | Bin 0 -> 1321 bytes
.../kunit/test_data/test_multiple_prefixes.log | Bin 0 -> 1832 bytes
.../test_output_with_prefix_isolated_correctly.log | Bin 0 -> 1655 bytes
.../kunit/test_data/test_pound_no_prefix.log | Bin 0 -> 1193 bytes
tools/testing/kunit/test_data/test_pound_sign.log | Bin 0 -> 1656 bytes
27 files changed, 799 insertions(+), 202 deletions(-)
create mode 100644 lib/kunit/debugfs.c
create mode 100644 lib/kunit/debugfs.h
create mode 100644 tools/testing/kunit/.gitattributes
create mode 100644 tools/testing/kunit/configs/broken_on_uml.config
create mode 100644
tools/testing/kunit/test_data/test_config_printk_time.log
create mode 100644
tools/testing/kunit/test_data/test_interrupted_tap_output.log
create mode 100644
tools/testing/kunit/test_data/test_kernel_panic_interrupt.log
create mode 100644
tools/testing/kunit/test_data/test_multiple_prefixes.log
create mode 100644
tools/testing/kunit/test_data/test_output_with_prefix_isolated_correctly.log
create mode 100644 tools/testing/kunit/test_data/test_pound_no_prefix.log
create mode 100644 tools/testing/kunit/test_data/test_pound_sign.log
----------------------------------------------------------------
Hi Linus,
Please pull the following Kselftest update for Linux 5.7-rc1.
This kselftest update Linux 5.7-rc1 consists of:
- resctrl_tests for resctrl file system. resctrl isn't included in the
default TARGETS list in kselftest Makefile. It can be run manually.
- Kselftest harness improvements.
- Kselftest framework and individual test fixes to support runs on
Kernel CI rings and other environments that use relocatable build
and install features.
- Minor cleanups and typo fixes.
diff is attached.
thanks,
-- Shuah
----------------------------------------------------------------
The following changes since commit bb6d3fb354c5ee8d6bde2d576eb7220ea09862b9:
Linux 5.6-rc1 (2020-02-09 16:08:48 -0800)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
tags/linux-kselftest-5.7-rc1
for you to fetch changes up to 1056d3d2c97e47397d0037cbbdf24235ae8f88cb:
selftests: enforce local header dependency in lib.mk (2020-03-26
15:29:55 -0600)
----------------------------------------------------------------
linux-kselftest-5.7-rc1
This kselftest update Linux 5.7-rc1 consists of:
- resctrl_tests for resctrl file system. resctrl isn't included in the
default TARGETS list in kselftest Makefile. It can be run manually.
- Kselftest harness improvements.
- Kselftest framework and individual test fixes to support runs on
Kernel CI rings and other environments that use relocatable build
and install features.
- Minor cleanups and typo fixes.
----------------------------------------------------------------
Babu Moger (3):
selftests/resctrl: Add vendor detection mechanism
selftests/resctrl: Use cache index3 id for AMD schemata masks
selftests/resctrl: Disable MBA and MBM tests for AMD
Colin Ian King (1):
selftests/resctrl: fix spelling mistake "Errror" -> "Error"
Fenghua Yu (6):
selftests/resctrl: Add README for resctrl tests
selftests/resctrl: Add MBM test
selftests/resctrl: Add MBA test
selftests/resctrl: Add Cache QoS Monitoring (CQM) selftest
selftests/resctrl: Add Cache Allocation Technology (CAT) selftest
selftests/resctrl: Add the test in MAINTAINERS
Kees Cook (3):
selftests/seccomp: Adjust test fixture counts
selftests/harness: Move test child waiting logic
selftests/harness: Handle timeouts cleanly
Masanari Iida (1):
selftests/ftrace: Fix typo in trigger-multihist.tc
Sai Praneeth Prakhya (4):
selftests/resctrl: Add basic resctrl file system operations and data
selftests/resctrl: Read memory bandwidth from perf IMC counter
and from resctrl file system
selftests/resctrl: Add callback to start a benchmark
selftests/resctrl: Add built in benchmark
Shuah Khan (6):
selftests: Fix kselftest O=objdir build from cluttering top level
objdir
selftests: android: ion: Fix ionmap_test compile error
selftests: android: Fix custom install from skipping test progs
selftests: Fix seccomp to support relocatable build (O=objdir)
selftests: Fix memfd to support relocatable build (O=objdir)
selftests: enforce local header dependency in lib.mk
YueHaibing (1):
selftests/timens: Remove duplicated include <time.h>
MAINTAINERS | 1 +
tools/testing/selftests/Makefile | 4 +-
tools/testing/selftests/android/Makefile | 2 +-
tools/testing/selftests/android/ion/Makefile | 2 +-
.../ftrace/test.d/trigger/trigger-multihist.tc | 2 +-
tools/testing/selftests/kselftest_harness.h | 144 ++--
tools/testing/selftests/lib.mk | 3 +-
tools/testing/selftests/memfd/Makefile | 9 +-
tools/testing/selftests/resctrl/Makefile | 17 +
tools/testing/selftests/resctrl/README | 53 ++
tools/testing/selftests/resctrl/cache.c | 272 ++++++++
tools/testing/selftests/resctrl/cat_test.c | 250 +++++++
tools/testing/selftests/resctrl/cqm_test.c | 176 +++++
tools/testing/selftests/resctrl/fill_buf.c | 213 ++++++
tools/testing/selftests/resctrl/mba_test.c | 171 +++++
tools/testing/selftests/resctrl/mbm_test.c | 145 ++++
tools/testing/selftests/resctrl/resctrl.h | 107 +++
tools/testing/selftests/resctrl/resctrl_tests.c | 202 ++++++
tools/testing/selftests/resctrl/resctrl_val.c | 744
+++++++++++++++++++++
tools/testing/selftests/resctrl/resctrlfs.c | 722
++++++++++++++++++++
tools/testing/selftests/seccomp/Makefile | 17 +-
tools/testing/selftests/seccomp/seccomp_bpf.c | 10 +-
tools/testing/selftests/timens/exec.c | 1 -
tools/testing/selftests/timens/procfs.c | 1 -
tools/testing/selftests/timens/timens.c | 1 -
tools/testing/selftests/timens/timer.c | 1 -
26 files changed, 3191 insertions(+), 79 deletions(-)
create mode 100644 tools/testing/selftests/resctrl/Makefile
create mode 100644 tools/testing/selftests/resctrl/README
create mode 100644 tools/testing/selftests/resctrl/cache.c
create mode 100644 tools/testing/selftests/resctrl/cat_test.c
create mode 100644 tools/testing/selftests/resctrl/cqm_test.c
create mode 100644 tools/testing/selftests/resctrl/fill_buf.c
create mode 100644 tools/testing/selftests/resctrl/mba_test.c
create mode 100644 tools/testing/selftests/resctrl/mbm_test.c
create mode 100644 tools/testing/selftests/resctrl/resctrl.h
create mode 100644 tools/testing/selftests/resctrl/resctrl_tests.c
create mode 100644 tools/testing/selftests/resctrl/resctrl_val.c
create mode 100644 tools/testing/selftests/resctrl/resctrlfs.c
----------------------------------------------------------------
On Mon, Mar 30, 2020 at 5:19 PM Liu Yiding <liuyd.fnst(a)cn.fujitsu.com> wrote:
>
>
> On 3/30/20 2:09 PM, Andrii Nakryiko wrote:
> > On 3/29/20 5:48 PM, Liu Yiding wrote:
> >> Add attachment.
> >>
> >
> > Your BTF seems to be invalid. It has struct perf_ibs, which has a
> > first field `struct pmu pmu` field with valid-looking size of 296
> > bytes, **but** the type that field points to is not a complete `struct
> > pmu` definition, but rather just forward declaration. The way it is it
> > shouldn't be even compilable, because forward declaration of a struct
> > doesn't specify the size of a struct, so compiler should have rejected
> > it. So it must be that either DWARF generated by compiler isn't
> > correct, or there is DWARF -> BTF conversion bug somewhere. Are you
> > using any special DWARF Kconfig settings? Maybe you can share your
> > full .config and I might try to repro it on my machine.
> >
>
> >> Are you using any special DWARF Kconfig settings?
>
> Sorry, i'm a newbie at this. I don't know which settings are related to
> DWARF.
>
> Just search keywords.
>
> ```
>
> liuyd@localhost:~$ cat config-5.6.0-rc5 | grep DWARF
> # CONFIG_DEBUG_INFO_DWARF4 is not set
>
> ```
>
> I built attached config on a clear ubuntu machine. Error could be
> reproduced. So you are right, there is a conflict between kconfigs.
>
>
> >> Maybe you can share your full .config and I might try to repro it on
> my machine.
>
> Thanks a lot. I attached the broken config.
Thanks a lot! I think it's due to DEBUG_INFO_REDUCED which produces
not entirely correct DWARF. I'm asking Slava to disable this config
when BTF is requested in [0].
[0] https://lore.kernel.org/bpf/CAEf4BzadnfAwfa1D0jZb=01Ou783GpK_U7PAYeEJca-L9k…
>
>
> > But either way, that warning you get is a valid one, it should be
> > illegal to have non-pointer forward-declared struct as a type for a
> > struct member.
> >
> >>
> >> On 3/30/20 8:46 AM, Liu Yiding wrote:
> >>> Something wrong with my smtp and this email missed.
> >>>
> >>> Send again.
> >>>
> >>>
> >>> On 3/27/20 11:09 AM, Liu Yiding wrote:
> >>>> Hi, Andrii.
> >>>>
> >>>> Thanks for your prompt reply!
> >>>>
> >>>> Please check attatchment for my_btf.bin.
> >>>>
> >>>>
> >>>> On 3/27/20 4:28 AM, Andrii Nakryiko wrote:
> >>>>> Would you be able to share BTF of vmlinux that is used to generate
> >>>>> vmlinux.h? Please run in verbose mode: `make V=1` and search for
> >>>>> `bpftool btf dump file` command. It should point either to
> >>>>> /sys/kernel/btf/vmlinux or some other location, depending on how
> >>>>> things are set up on your side.
> >>>>>
> >>>>> If it's /sys/kernel/btf/vmlinux, you can just `cat
> >>>>> /sys/kernel/btf/vmlinux > my_btf.bin`. If it's some other file,
> >>>>> easiest would be to just share that file. If not, it's possible to
> >>>>> extract .BTF ELF section, let me know if you need help with that.
> >>>>
> >
> >
> >
> --
> Best Regards.
> Liu Yiding
>
>
>
This patchset contains everything needed to integrate KASAN and KUnit.
KUnit will be able to:
(1) Fail tests when an unexpected KASAN error occurs
(2) Pass tests when an expected KASAN error occurs
KASAN Tests have been converted to KUnit with the exception of
copy_user_test because KUnit is unable to test those. I am working on
documentation on how to use these new tests to be included in the next
version of this patchset.
Changes since v1:
- Make use of Alan Maguire's suggestion to use his patch that allows
static resources for integration instead of adding a new attribute to
the kunit struct
- All KUNIT_EXPECT_KASAN_FAIL statements are local to each test
- The definition of KUNIT_EXPECT_KASAN_FAIL is local to the
test_kasan.c file since it seems this is the only place this will
be used.
- Integration relies on KUnit being builtin
- copy_user_test has been separated into its own file since KUnit
is unable to test these. This can be run as a module just as before,
using CONFIG_TEST_KASAN_USER
- The addition to the current task has been separated into its own
patch as this is a significant enough change to be on its own.
Patricia Alfonso (3):
Add KUnit Struct to Current Task
KUnit: KASAN Integration
KASAN: Port KASAN Tests to KUnit
include/kunit/test.h | 10 +
include/linux/sched.h | 4 +
lib/Kconfig.kasan | 13 +-
lib/Makefile | 1 +
lib/kunit/test.c | 10 +-
lib/test_kasan.c | 639 +++++++++++++++----------------------
lib/test_kasan_copy_user.c | 75 +++++
mm/kasan/report.c | 33 ++
8 files changed, 400 insertions(+), 385 deletions(-)
create mode 100644 lib/test_kasan_copy_user.c
--
2.25.1.696.g5e7596f4ac-goog
Memory protection keys enables an application to protect its address
space from inadvertent access by its own code.
This feature is now enabled on powerpc and has been available since
4.16-rc1. The patches move the selftests to arch neutral directory
and enhance their test coverage.
Tested on powerpc64 and x86_64 (Skylake-SP).
Link to development branch:
https://github.com/sandip4n/linux/tree/pkey-selftests
Resending this based on feedback from maintainers who felt this
can go in via the -mm tree. This has no other changes from the
last version (v18) apart from being rebased.
Changelog
---------
Link to previous version (v18):
https://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=155970
v19:
(1) Rebased on top of latest master.
v18:
(1) Fixed issues with x86 multilib builds based on
feedback from Dave.
(2) Moved patch 2 to the end of the series.
v17:
(1) Fixed issues with i386 builds when running on x86_64
based on feedback from Dave.
(2) Replaced patch 6 from previous version with patch 7.
This addresses u64 format specifier related concerns
that Michael had raised in v15.
v16:
(1) Rebased on top of latest master.
(2) Switched to u64 instead of using an arch-dependent
pkey_reg_t type for references to the pkey register
based on suggestions from Dave, Michal and Michael.
(3) Removed build time determination of page size based
on suggestion from Michael.
(4) Fixed comment before the definition of __page_o_noops()
from patch 13 ("selftests/vm/pkeys: Introduce powerpc
support").
v15:
(1) Rebased on top of latest master.
(2) Addressed review comments from Dave Hansen.
(3) Moved code for getting or setting pkey bits to new
helpers. These changes replace patch 7 of v14.
(4) Added a fix which ensures that the correct count of
reserved keys is used across different platforms.
(5) Added a fix which ensures that the correct page size
is used as powerpc supports both 4K and 64K pages.
v14:
(1) Incorporated another round of comments from Dave Hansen.
v13:
(1) Incorporated comments for Dave Hansen.
(2) Added one more test for correct pkey-0 behavior.
v12:
(1) Fixed the offset of pkey field in the siginfo structure for
x86_64 and powerpc. And tries to use the actual field
if the headers have it defined.
v11:
(1) Fixed a deadlock in the ptrace testcase.
v10 and prior:
(1) Moved the testcase to arch neutral directory.
(2) Split the changes into incremental patches.
Desnes A. Nunes do Rosario (1):
selftests/vm/pkeys: Fix number of reserved powerpc pkeys
Ram Pai (16):
selftests/x86/pkeys: Move selftests to arch-neutral directory
selftests/vm/pkeys: Rename all references to pkru to a generic name
selftests/vm/pkeys: Move generic definitions to header file
selftests/vm/pkeys: Fix pkey_disable_clear()
selftests/vm/pkeys: Fix assertion in pkey_disable_set/clear()
selftests/vm/pkeys: Fix alloc_random_pkey() to make it really random
selftests/vm/pkeys: Introduce generic pkey abstractions
selftests/vm/pkeys: Introduce powerpc support
selftests/vm/pkeys: Fix assertion in test_pkey_alloc_exhaust()
selftests/vm/pkeys: Improve checks to determine pkey support
selftests/vm/pkeys: Associate key on a mapped page and detect access
violation
selftests/vm/pkeys: Associate key on a mapped page and detect write
violation
selftests/vm/pkeys: Detect write violation on a mapped
access-denied-key page
selftests/vm/pkeys: Introduce a sub-page allocator
selftests/vm/pkeys: Test correct behaviour of pkey-0
selftests/vm/pkeys: Override access right definitions on powerpc
Sandipan Das (5):
selftests: vm: pkeys: Use sane types for pkey register
selftests: vm: pkeys: Add helpers for pkey bits
selftests: vm: pkeys: Use the correct huge page size
selftests: vm: pkeys: Use the correct page size on powerpc
selftests: vm: pkeys: Fix multilib builds for x86
Thiago Jung Bauermann (2):
selftests/vm/pkeys: Move some definitions to arch-specific header
selftests/vm/pkeys: Make gcc check arguments of sigsafe_printf()
tools/testing/selftests/vm/.gitignore | 1 +
tools/testing/selftests/vm/Makefile | 73 ++
tools/testing/selftests/vm/pkey-helpers.h | 225 ++++++
tools/testing/selftests/vm/pkey-powerpc.h | 136 ++++
tools/testing/selftests/vm/pkey-x86.h | 181 +++++
.../selftests/{x86 => vm}/protection_keys.c | 696 ++++++++++--------
tools/testing/selftests/x86/.gitignore | 1 -
tools/testing/selftests/x86/Makefile | 2 +-
tools/testing/selftests/x86/pkey-helpers.h | 219 ------
9 files changed, 1002 insertions(+), 532 deletions(-)
create mode 100644 tools/testing/selftests/vm/pkey-helpers.h
create mode 100644 tools/testing/selftests/vm/pkey-powerpc.h
create mode 100644 tools/testing/selftests/vm/pkey-x86.h
rename tools/testing/selftests/{x86 => vm}/protection_keys.c (74%)
delete mode 100644 tools/testing/selftests/x86/pkey-helpers.h
--
2.17.1
Hi,
This new patch series brings improvements, fix some bugs but mainly
simplify the code.
The object, rule and ruleset management are simplified at the expense of
a less aggressive memory freeing (contributed by Jann Horn [1]). There
is now less use of RCU for an improved readability. Access checks that
can be reached by file-descriptor-based syscalls are removed for now
(truncate, getattr, lock, chmod, chown, chgrp, ioctl). This will be
handle in a future evolution of Landlock, but right now the goal is to
lighten the code to ease review. The SLOC count for security/landlock/
was 1542 with the previous patch series while the current series shrinks
it to 1273.
The other main improvement is the addition of rule layer levels to
ensure that a nested sandbox cannot bypass the access restrictions set
by its parents.
The syscall is now wired for all architectures and the tests passed for
x86_32 and x86_64.
The compiled documentation is available here:
https://landlock.io/linux-doc/landlock-v15/security/landlock/index.html
This series can be applied on top of v5.6-rc7. This can be tested with
CONFIG_SECURITY_LANDLOCK and CONFIG_SAMPLE_LANDLOCK. This patch series
can be found in a Git repository here:
https://github.com/landlock-lsm/linux/commits/landlock-v15
I would really appreciate constructive comments on the design and the code.
# Landlock LSM
The goal of Landlock is to enable to restrict ambient rights (e.g.
global filesystem access) for a set of processes. Because Landlock is a
stackable LSM [2], it makes possible to create safe security sandboxes
as new security layers in addition to the existing system-wide
access-controls. This kind of sandbox is expected to help mitigate the
security impact of bugs or unexpected/malicious behaviors in user-space
applications. Landlock empowers any process, including unprivileged
ones, to securely restrict themselves.
Landlock is inspired by seccomp-bpf but instead of filtering syscalls
and their raw arguments, a Landlock rule can restrict the use of kernel
objects like file hierarchies, according to the kernel semantic.
Landlock also takes inspiration from other OS sandbox mechanisms: XNU
Sandbox, FreeBSD Capsicum or OpenBSD Pledge/Unveil.
# Current limitations
## Path walk
Landlock need to use dentries to identify a file hierarchy, which is
needed for composable and unprivileged access-controls. This means that
path resolution/walking (handled with inode_permission()) is not
supported, yet. The same limitation also apply to readlink(2). This
could be filled with a future extension first of the LSM framework. The
Landlock userspace ABI can handle such change with new options (e.g. to
the struct landlock_ruleset).
## UnionFS
An UnionFS super-block use a set of upper and lower directories. Access
request to a file in one of these hierarchy trigger a call to
ovl_path_real() which generate another access request according to the
matching hierarchy. Because such super-block is not aware of its current
mount point, OverlayFS can't create a dedicated mnt_parent for each of
the upper and lower directories mount clones. It is then not currently
possible to track the source of such indirect access-request, and then
not possible to identify a unified OverlayFS hierarchy.
## Memory limits
There is currently no limit on the memory usage. Any idea to leverage
an existing mechanism (e.g. rlimit)?
# Changes since v14
* Simplify the object, rule and ruleset management at the expense of a
less aggressive memory freeing.
* Remove access checks that may be required for FD-only requests:
truncate, getattr, lock, chmod, chown, chgrp, ioctl.
* Add the notion of rule layer level to ensure that a nested sandbox
cannot bypass the access restrictions set by its parent.
* Wire up the syscall for all architectures.
* Clean up the code and add more documentation.
* Some improvements and bug fixes.
# Changes since v13
* Revamp of the LSM: remove the need for eBPF and seccomp(2).
* Implement a full filesystem access-control.
* Take care of the backward compatibility issues, especially for
security features, following a best-effort approach.
Previous version:
https://lore.kernel.org/lkml/20200224160215.4136-1-mic@digikod.net/
[1] https://lore.kernel.org/lkml/CAG48ez21bEn0wL1bbmTiiu8j9jP5iEWtHOwz4tURUJ+ki…
[2] https://lore.kernel.org/lkml/50db058a-7dde-441b-a7f9-f6837fe8b69f@schaufler…
Regards,
Mickaël Salaün (10):
landlock: Add object management
landlock: Add ruleset and domain management
landlock: Set up the security framework and manage credentials
landlock: Add ptrace restrictions
fs,landlock: Support filesystem access-control
landlock: Add syscall implementation
arch: Wire up landlock() syscall
selftests/landlock: Add initial tests
samples/landlock: Add a sandbox manager example
landlock: Add user and kernel documentation
Documentation/security/index.rst | 1 +
Documentation/security/landlock/index.rst | 18 +
Documentation/security/landlock/kernel.rst | 69 +
Documentation/security/landlock/user.rst | 227 +++
MAINTAINERS | 12 +
arch/alpha/kernel/syscalls/syscall.tbl | 1 +
arch/arm/tools/syscall.tbl | 1 +
arch/arm64/include/asm/unistd.h | 2 +-
arch/arm64/include/asm/unistd32.h | 2 +
arch/ia64/kernel/syscalls/syscall.tbl | 1 +
arch/m68k/kernel/syscalls/syscall.tbl | 1 +
arch/microblaze/kernel/syscalls/syscall.tbl | 1 +
arch/mips/kernel/syscalls/syscall_n32.tbl | 1 +
arch/mips/kernel/syscalls/syscall_n64.tbl | 1 +
arch/mips/kernel/syscalls/syscall_o32.tbl | 1 +
arch/parisc/kernel/syscalls/syscall.tbl | 1 +
arch/powerpc/kernel/syscalls/syscall.tbl | 1 +
arch/s390/kernel/syscalls/syscall.tbl | 1 +
arch/sh/kernel/syscalls/syscall.tbl | 1 +
arch/sparc/kernel/syscalls/syscall.tbl | 1 +
arch/x86/entry/syscalls/syscall_32.tbl | 1 +
arch/x86/entry/syscalls/syscall_64.tbl | 1 +
arch/xtensa/kernel/syscalls/syscall.tbl | 1 +
fs/super.c | 2 +
include/linux/fs.h | 5 +
include/linux/landlock.h | 22 +
include/linux/syscalls.h | 3 +
include/uapi/asm-generic/unistd.h | 4 +-
include/uapi/linux/landlock.h | 311 ++++
kernel/sys_ni.c | 3 +
samples/Kconfig | 7 +
samples/Makefile | 1 +
samples/landlock/.gitignore | 1 +
samples/landlock/Makefile | 15 +
samples/landlock/sandboxer.c | 217 +++
security/Kconfig | 11 +-
security/Makefile | 2 +
security/landlock/Kconfig | 18 +
security/landlock/Makefile | 4 +
security/landlock/common.h | 20 +
security/landlock/cred.c | 46 +
security/landlock/cred.h | 55 +
security/landlock/fs.c | 561 ++++++++
security/landlock/fs.h | 42 +
security/landlock/object.c | 66 +
security/landlock/object.h | 92 ++
security/landlock/ptrace.c | 120 ++
security/landlock/ptrace.h | 14 +
security/landlock/ruleset.c | 352 +++++
security/landlock/ruleset.h | 182 +++
security/landlock/setup.c | 39 +
security/landlock/setup.h | 18 +
security/landlock/syscall.c | 521 +++++++
tools/testing/selftests/Makefile | 1 +
tools/testing/selftests/landlock/.gitignore | 4 +
tools/testing/selftests/landlock/Makefile | 26 +
tools/testing/selftests/landlock/common.h | 42 +
tools/testing/selftests/landlock/config | 5 +
tools/testing/selftests/landlock/test_base.c | 113 ++
tools/testing/selftests/landlock/test_fs.c | 1249 +++++++++++++++++
.../testing/selftests/landlock/test_ptrace.c | 294 ++++
tools/testing/selftests/landlock/true.c | 5 +
62 files changed, 4833 insertions(+), 7 deletions(-)
create mode 100644 Documentation/security/landlock/index.rst
create mode 100644 Documentation/security/landlock/kernel.rst
create mode 100644 Documentation/security/landlock/user.rst
create mode 100644 include/linux/landlock.h
create mode 100644 include/uapi/linux/landlock.h
create mode 100644 samples/landlock/.gitignore
create mode 100644 samples/landlock/Makefile
create mode 100644 samples/landlock/sandboxer.c
create mode 100644 security/landlock/Kconfig
create mode 100644 security/landlock/Makefile
create mode 100644 security/landlock/common.h
create mode 100644 security/landlock/cred.c
create mode 100644 security/landlock/cred.h
create mode 100644 security/landlock/fs.c
create mode 100644 security/landlock/fs.h
create mode 100644 security/landlock/object.c
create mode 100644 security/landlock/object.h
create mode 100644 security/landlock/ptrace.c
create mode 100644 security/landlock/ptrace.h
create mode 100644 security/landlock/ruleset.c
create mode 100644 security/landlock/ruleset.h
create mode 100644 security/landlock/setup.c
create mode 100644 security/landlock/setup.h
create mode 100644 security/landlock/syscall.c
create mode 100644 tools/testing/selftests/landlock/.gitignore
create mode 100644 tools/testing/selftests/landlock/Makefile
create mode 100644 tools/testing/selftests/landlock/common.h
create mode 100644 tools/testing/selftests/landlock/config
create mode 100644 tools/testing/selftests/landlock/test_base.c
create mode 100644 tools/testing/selftests/landlock/test_fs.c
create mode 100644 tools/testing/selftests/landlock/test_ptrace.c
create mode 100644 tools/testing/selftests/landlock/true.c
--
2.26.0.rc2
Hi,
This new version of Landlock is a major revamp of the previous series
[1], hence the RFC tag. The three main changes are the replacement of
eBPF with a dedicated safe management of access rules, the replacement
of the use of seccomp(2) with a dedicated syscall, and the management of
filesystem access-control (back from the v10).
As discussed in [2], eBPF may be too powerful and dangerous to be put in
the hand of unprivileged and potentially malicious processes, especially
because of side-channel attacks against access-controls or other parts
of the kernel.
Thanks to this new implementation (1540 SLOC), designed from the ground
to be used by unprivileged processes, this series enables a process to
sandbox itself without requiring CAP_SYS_ADMIN, but only the
no_new_privs constraint (like seccomp). Not relying on eBPF also
enables to improve performances, especially for stacked security
policies thanks to mergeable rulesets.
The compiled documentation is available here:
https://landlock.io/linux-doc/landlock-v14/security/landlock/index.html
This series can be applied on top of v5.6-rc3. This can be tested with
CONFIG_SECURITY_LANDLOCK and CONFIG_SAMPLE_LANDLOCK. This patch series
can be found in a Git repository here:
https://github.com/landlock-lsm/linux/commits/landlock-v14
I would really appreciate constructive comments on the design and the code.
# Landlock LSM
The goal of Landlock is to enable to restrict ambient rights (e.g.
global filesystem access) for a set of processes. Because Landlock is a
stackable LSM [3], it makes possible to create safe security sandboxes
as new security layers in addition to the existing system-wide
access-controls. This kind of sandbox is expected to help mitigate the
security impact of bugs or unexpected/malicious behaviors in user-space
applications. Landlock empower any process, including unprivileged ones,
to securely restrict themselves.
Landlock is inspired by seccomp-bpf but instead of filtering syscalls
and their raw arguments, a Landlock rule can restrict the use of kernel
objects like file hierarchies, according to the kernel semantic.
Landlock also takes inspiration from other OS sandbox mechanisms: XNU
Sandbox, FreeBSD Capsicum or OpenBSD Pledge/Unveil.
# Current limitations
## Path walk
Landlock need to use dentries to identify a file hierarchy, which is
needed for composable and unprivileged access-controls. This means that
path resolution/walking (handled with inode_permission()) is not
supported, yet. This could be filled with a future extension first of
the LSM framework. The Landlock userspace ABI can handle such change
with new option (e.g. to the struct landlock_ruleset).
## UnionFS
An UnionFS super-block use a set of upper and lower directories. An
access request to a file in one of these hierarchy trigger a call to
ovl_path_real() which generate another access request according to the
matching hierarchy. Because such super-block is not aware of its current
mount point, OverlayFS can't create a dedicated mnt_parent for each of
the upper and lower directories mount clones. It is then not currently
possible to track the source of such indirect access-request, and then
not possible to identify a unified OverlayFS hierarchy.
## Syscall
Because it is only tested on x86_64, the syscall is only wired up for
this architecture. The whole x86 family (and probably all the others)
will be supported in the next patch series.
## Memory limits
There is currently no limit on the memory usage. Any idea to leverage
an existing mechanism (e.g. rlimit)?
# Changes since v13
* Revamp of the LSM: remove the need for eBPF and seccomp(2).
* Implement a full filesystem access-control.
* Take care of the backward compatibility issues, especially for
this security features.
Previous version:
https://lore.kernel.org/lkml/20191104172146.30797-1-mic@digikod.net/
[1] https://lore.kernel.org/lkml/20191104172146.30797-1-mic@digikod.net/
[2] https://lore.kernel.org/lkml/a6b61f33-82dc-0c1c-7a6c-1926343ef63e@digikod.n…
[3] https://lore.kernel.org/lkml/50db058a-7dde-441b-a7f9-f6837fe8b69f@schaufler…
Regards,
Mickaël Salaün (10):
landlock: Add object and rule management
landlock: Add ruleset and domain management
landlock: Set up the security framework and manage credentials
landlock: Add ptrace restrictions
fs,landlock: Support filesystem access-control
landlock: Add syscall implementation
arch: Wire up landlock() syscall
selftests/landlock: Add initial tests
samples/landlock: Add a sandbox manager example
landlock: Add user and kernel documentation
Documentation/security/index.rst | 1 +
Documentation/security/landlock/index.rst | 18 +
Documentation/security/landlock/kernel.rst | 44 ++
Documentation/security/landlock/user.rst | 233 +++++++
MAINTAINERS | 12 +
arch/x86/entry/syscalls/syscall_64.tbl | 1 +
fs/super.c | 2 +
include/linux/landlock.h | 22 +
include/linux/syscalls.h | 3 +
include/uapi/asm-generic/unistd.h | 4 +-
include/uapi/linux/landlock.h | 315 +++++++++
samples/Kconfig | 7 +
samples/Makefile | 1 +
samples/landlock/.gitignore | 1 +
samples/landlock/Makefile | 15 +
samples/landlock/sandboxer.c | 226 +++++++
security/Kconfig | 11 +-
security/Makefile | 2 +
security/landlock/Kconfig | 16 +
security/landlock/Makefile | 4 +
security/landlock/cred.c | 47 ++
security/landlock/cred.h | 55 ++
security/landlock/fs.c | 591 +++++++++++++++++
security/landlock/fs.h | 42 ++
security/landlock/object.c | 341 ++++++++++
security/landlock/object.h | 134 ++++
security/landlock/ptrace.c | 118 ++++
security/landlock/ptrace.h | 14 +
security/landlock/ruleset.c | 463 +++++++++++++
security/landlock/ruleset.h | 106 +++
security/landlock/setup.c | 38 ++
security/landlock/setup.h | 20 +
security/landlock/syscall.c | 470 +++++++++++++
tools/testing/selftests/Makefile | 1 +
tools/testing/selftests/landlock/.gitignore | 3 +
tools/testing/selftests/landlock/Makefile | 13 +
tools/testing/selftests/landlock/config | 4 +
tools/testing/selftests/landlock/test.h | 40 ++
tools/testing/selftests/landlock/test_base.c | 80 +++
tools/testing/selftests/landlock/test_fs.c | 624 ++++++++++++++++++
.../testing/selftests/landlock/test_ptrace.c | 293 ++++++++
41 files changed, 4429 insertions(+), 6 deletions(-)
create mode 100644 Documentation/security/landlock/index.rst
create mode 100644 Documentation/security/landlock/kernel.rst
create mode 100644 Documentation/security/landlock/user.rst
create mode 100644 include/linux/landlock.h
create mode 100644 include/uapi/linux/landlock.h
create mode 100644 samples/landlock/.gitignore
create mode 100644 samples/landlock/Makefile
create mode 100644 samples/landlock/sandboxer.c
create mode 100644 security/landlock/Kconfig
create mode 100644 security/landlock/Makefile
create mode 100644 security/landlock/cred.c
create mode 100644 security/landlock/cred.h
create mode 100644 security/landlock/fs.c
create mode 100644 security/landlock/fs.h
create mode 100644 security/landlock/object.c
create mode 100644 security/landlock/object.h
create mode 100644 security/landlock/ptrace.c
create mode 100644 security/landlock/ptrace.h
create mode 100644 security/landlock/ruleset.c
create mode 100644 security/landlock/ruleset.h
create mode 100644 security/landlock/setup.c
create mode 100644 security/landlock/setup.h
create mode 100644 security/landlock/syscall.c
create mode 100644 tools/testing/selftests/landlock/.gitignore
create mode 100644 tools/testing/selftests/landlock/Makefile
create mode 100644 tools/testing/selftests/landlock/config
create mode 100644 tools/testing/selftests/landlock/test.h
create mode 100644 tools/testing/selftests/landlock/test_base.c
create mode 100644 tools/testing/selftests/landlock/test_fs.c
create mode 100644 tools/testing/selftests/landlock/test_ptrace.c
--
2.25.0
On 3/29/20 5:48 PM, Liu Yiding wrote:
> Add attachment.
>
Your BTF seems to be invalid. It has struct perf_ibs, which has a first
field `struct pmu pmu` field with valid-looking size of 296 bytes,
**but** the type that field points to is not a complete `struct pmu`
definition, but rather just forward declaration. The way it is it
shouldn't be even compilable, because forward declaration of a struct
doesn't specify the size of a struct, so compiler should have rejected
it. So it must be that either DWARF generated by compiler isn't correct,
or there is DWARF -> BTF conversion bug somewhere. Are you using any
special DWARF Kconfig settings? Maybe you can share your full .config
and I might try to repro it on my machine.
But either way, that warning you get is a valid one, it should be
illegal to have non-pointer forward-declared struct as a type for a
struct member.
>
> On 3/30/20 8:46 AM, Liu Yiding wrote:
>> Something wrong with my smtp and this email missed.
>>
>> Send again.
>>
>>
>> On 3/27/20 11:09 AM, Liu Yiding wrote:
>>> Hi, Andrii.
>>>
>>> Thanks for your prompt reply!
>>>
>>> Please check attatchment for my_btf.bin.
>>>
>>>
>>> On 3/27/20 4:28 AM, Andrii Nakryiko wrote:
>>>> Would you be able to share BTF of vmlinux that is used to generate
>>>> vmlinux.h? Please run in verbose mode: `make V=1` and search for
>>>> `bpftool btf dump file` command. It should point either to
>>>> /sys/kernel/btf/vmlinux or some other location, depending on how
>>>> things are set up on your side.
>>>>
>>>> If it's /sys/kernel/btf/vmlinux, you can just `cat
>>>> /sys/kernel/btf/vmlinux > my_btf.bin`. If it's some other file,
>>>> easiest would be to just share that file. If not, it's possible to
>>>> extract .BTF ELF section, let me know if you need help with that.
>>>
Something wrong with my smtp and this email missed.
Send again.
On 3/27/20 11:09 AM, Liu Yiding wrote:
> Hi, Andrii.
>
> Thanks for your prompt reply!
>
> Please check attatchment for my_btf.bin.
>
>
> On 3/27/20 4:28 AM, Andrii Nakryiko wrote:
>> Would you be able to share BTF of vmlinux that is used to generate
>> vmlinux.h? Please run in verbose mode: `make V=1` and search for
>> `bpftool btf dump file` command. It should point either to
>> /sys/kernel/btf/vmlinux or some other location, depending on how
>> things are set up on your side.
>>
>> If it's /sys/kernel/btf/vmlinux, you can just `cat
>> /sys/kernel/btf/vmlinux > my_btf.bin`. If it's some other file,
>> easiest would be to just share that file. If not, it's possible to
>> extract .BTF ELF section, let me know if you need help with that.
>
--
Best Regards.
Liu Yiding
From: "Steven Rostedt (VMware)" <rostedt(a)goodmis.org>
A new file was added to the tracing directory that will allow a user to
place a PID into it and the task associated to that PID will not be traced
by the function tracer. If the function-fork option is enabled, then neither
will the children of that task be traced by the function tracer.
Cc: linux-kselftest(a)vger.kernel.org
Cc: Shuah Khan <skhan(a)linuxfoundation.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt(a)goodmis.org>
---
.../test.d/ftrace/func-filter-notrace-pid.tc | 108 ++++++++++++++++++
1 file changed, 108 insertions(+)
create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/func-filter-notrace-pid.tc
diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-notrace-pid.tc b/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-notrace-pid.tc
new file mode 100644
index 000000000000..8aa46a2ea133
--- /dev/null
+++ b/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-notrace-pid.tc
@@ -0,0 +1,108 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+# description: ftrace - function pid notrace filters
+# flags: instance
+
+# Make sure that function pid matching filter with notrace works.
+
+if ! grep -q function available_tracers; then
+ echo "no function tracer configured"
+ exit_unsupported
+fi
+
+if [ ! -f set_ftrace_notrace_pid ]; then
+ echo "set_ftrace_notrace_pid not found? Is function tracer not set?"
+ exit_unsupported
+fi
+
+if [ ! -f set_ftrace_filter ]; then
+ echo "set_ftrace_filter not found? Is function tracer not set?"
+ exit_unsupported
+fi
+
+do_function_fork=1
+
+if [ ! -f options/function-fork ]; then
+ do_function_fork=0
+ echo "no option for function-fork found. Option will not be tested."
+fi
+
+read PID _ < /proc/self/stat
+
+if [ $do_function_fork -eq 1 ]; then
+ # default value of function-fork option
+ orig_value=`grep function-fork trace_options`
+fi
+
+do_reset() {
+ if [ $do_function_fork -eq 0 ]; then
+ return
+ fi
+
+ echo > set_ftrace_notrace_pid
+ echo $orig_value > trace_options
+}
+
+fail() { # msg
+ do_reset
+ echo $1
+ exit_fail
+}
+
+do_test() {
+ disable_tracing
+
+ echo do_execve* > set_ftrace_filter
+ echo *do_fork >> set_ftrace_filter
+
+ echo $PID > set_ftrace_notrace_pid
+ echo function > current_tracer
+
+ if [ $do_function_fork -eq 1 ]; then
+ # don't allow children to be traced
+ echo nofunction-fork > trace_options
+ fi
+
+ enable_tracing
+ yield
+
+ count_pid=`cat trace | grep -v ^# | grep $PID | wc -l`
+ count_other=`cat trace | grep -v ^# | grep -v $PID | wc -l`
+
+ # count_pid should be 0
+ if [ $count_pid -ne 0 -o $count_other -eq 0 ]; then
+ fail "PID filtering not working? traced task = $count_pid; other tasks = $count_other "
+ fi
+
+ disable_tracing
+ clear_trace
+
+ if [ $do_function_fork -eq 0 ]; then
+ return
+ fi
+
+ # allow children to be traced
+ echo function-fork > trace_options
+
+ # With pid in both set_ftrace_pid and set_ftrace_notrace_pid
+ # there should not be any tasks traced.
+
+ echo $PID > set_ftrace_pid
+
+ enable_tracing
+ yield
+
+ count_pid=`cat trace | grep -v ^# | grep $PID | wc -l`
+ count_other=`cat trace | grep -v ^# | grep -v $PID | wc -l`
+
+ # both should be zero
+ if [ $count_pid -ne 0 -o $count_other -ne 0 ]; then
+ fail "PID filtering not following fork? traced task = $count_pid; other tasks = $count_other "
+ fi
+}
+
+do_test
+
+do_reset
+
+exit 0
--
2.25.1
From: "Steven Rostedt (VMware)" <rostedt(a)goodmis.org>
The ftrace selftest "ftrace - test for function traceon/off triggers"
enables all events and reads the trace file. Now that the trace file does
not disable tracing, and will attempt to continually read new data that is
added, the selftest gets stuck reading the trace file. This is because the
data added to the trace file will fill up quicker than the reading of it.
By only enabling scheduling events, the read can keep up with the writes.
Instead of enabling all events, only enable the scheduler events.
Link: http://lkml.kernel.org/r/20200318111345.0516642e@gandalf.local.home
Cc: Shuah Khan <skhan(a)linuxfoundation.org>
Cc: linux-kselftest(a)vger.kernel.org
Acked-by: Masami Hiramatsu <mhiramat(a)kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt(a)goodmis.org>
---
.../selftests/ftrace/test.d/ftrace/func_traceonoff_triggers.tc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/func_traceonoff_triggers.tc b/tools/testing/selftests/ftrace/test.d/ftrace/func_traceonoff_triggers.tc
index 0c04282d33dd..1947387fe976 100644
--- a/tools/testing/selftests/ftrace/test.d/ftrace/func_traceonoff_triggers.tc
+++ b/tools/testing/selftests/ftrace/test.d/ftrace/func_traceonoff_triggers.tc
@@ -41,7 +41,7 @@ fi
echo '** ENABLE EVENTS'
-echo 1 > events/enable
+echo 1 > events/sched/enable
echo '** ENABLE TRACING'
enable_tracing
--
2.25.1
Hi, Andrii.
I noticed you had added runqslower tool to tools/bpf, so drop this
problem to you.
Now i failed to run bpf tests since i can't build runqslower.
Testing env: "Debian GNU/Linux 9 (stretch)"
kernel: 5.6.0-rc5
gcc: gcc 6.3
clang: clang-11.
Description: Build runqslower failed due to build error "incomplete
type" and libbpf show unsupported BTF_KIND:7.
Whole build log please see the attatchment.
Error info
```
root@vm-snb-144 ~/linus/tools/bpf# make
Auto-detecting system features:
... libbfd: [ on ]
... disassembler-four-args: [ OFF ]
[snip]
INSTALL bpftool
LINK bpf_asm
GEN vmlinux.h
libbpf: unsupported BTF_KIND:7 (Many unsupported errors)
libbpf: unsupported BTF_KIND:7
libbpf: unsupported BTF_KIND:7
[snip]
(Many incomplete type errors)
.output/vmlinux.h:8401:18: error: field has incomplete type 'struct
idt_bits'
struct idt_bits bits;
^
.output/vmlinux.h:8396:8: note: forward declaration of 'struct idt_bits'
struct idt_bits;
^
.output/vmlinux.h:8598:21: error: field has incomplete type 'struct
trace_entry'
struct trace_entry ent;
^
.output/vmlinux.h:8595:8: note: forward declaration of 'struct trace_entry'
struct trace_entry;
^
.output/vmlinux.h:9006:25: error: array has incomplete element type
'struct cyc2ns_data'
struct cyc2ns_data data[2];
^
.output/vmlinux.h:3669:8: note: forward declaration of 'struct cyc2ns_data'
struct cyc2ns_data;
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
Makefile:56: recipe for target '.output/runqslower.bpf.o' failed
make[1]: *** [.output/runqslower.bpf.o] Error 1
Makefile:119: recipe for target 'runqslower' failed
make: *** [runqslower] Error 2
```
--
Best Regards.
Liu Yiding
Changes for commit 9c4e6b1a7027f ("mm, mlock, vmscan: no more skipping pagevecs")
break this test expectations on the behavior of mlock syscall family immediately
inserting the recently faulted pages into the UNEVICTABLE_LRU, when MCL_ONFAULT is
passed to the syscall as part of its flag-set.
There is no functional error introduced by the aforementioned commit,
but it opens up a time window where the recently faulted and locked pages
might yet not be put back into the UNEVICTABLE_LRU, thus causing a
subsequent and immediate PFN flag check for the UNEVICTABLE bit
to trip on false-negative errors, as it happens with this test.
This patch fix the false negative by forcefully resorting to a code path that
will call a CPU pagevec drain right after the fault but before the PFN flag
check takes place, sorting out the race that way.
Fixes: 9c4e6b1a7027f ("mm, mlock, vmscan: no more skipping pagevecs")
Signed-off-by: Rafael Aquini <aquini(a)redhat.com>
---
tools/testing/selftests/vm/mlock2-tests.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/tools/testing/selftests/vm/mlock2-tests.c b/tools/testing/selftests/vm/mlock2-tests.c
index 637b6d0ac0d0..26dc320ca3c9 100644
--- a/tools/testing/selftests/vm/mlock2-tests.c
+++ b/tools/testing/selftests/vm/mlock2-tests.c
@@ -7,6 +7,7 @@
#include <sys/time.h>
#include <sys/resource.h>
#include <stdbool.h>
+#include <sched.h>
#include "mlock2.h"
#include "../kselftest.h"
@@ -328,6 +329,22 @@ static int test_mlock_lock()
return ret;
}
+/*
+ * After commit 9c4e6b1a7027f ("mm, mlock, vmscan: no more skipping pagevecs")
+ * changes made by calls to mlock* family might not be immediately reflected
+ * on the LRUs, thus checking the PFN flags might race against pagevec drain.
+ *
+ * In order to sort out that race, and get the after fault checks consistent,
+ * the "quick and dirty" trick below is required in order to force a call to
+ * lru_add_drain_all() to get the recently MLOCK_ONFAULT pages moved to
+ * the unevictable LRU, as expected by the checks in this selftest.
+ */
+static void force_lru_add_drain_all(void)
+{
+ sched_yield();
+ system("echo 1 > /proc/sys/vm/compact_memory");
+}
+
static int onfault_check(char *map)
{
unsigned long page_size = getpagesize();
@@ -343,6 +360,9 @@ static int onfault_check(char *map)
}
*map = 'a';
+
+ force_lru_add_drain_all();
+
page1_flags = get_pageflags((unsigned long)map);
page2_flags = get_pageflags((unsigned long)map + page_size);
@@ -465,6 +485,8 @@ static int test_lock_onfault_of_present()
goto unmap;
}
+ force_lru_add_drain_all();
+
page1_flags = get_pageflags((unsigned long)map);
page2_flags = get_pageflags((unsigned long)map + page_size);
page1_flags = get_kpageflags(page1_flags & PFN_MASK);
--
2.24.1
I attempted to build KVM selftests on a specified dir, unfortunately
neither "make O=/path/to/mydir TARGETS=kvm" in tools/testing/selftests, nor
"make OUTPUT=/path/to/mydir" in tools/testing/selftests/kvm work.
This series aims to fix them.
Patch 1 fixes the issue that output directory is not exist.
Patch 2 and 3 are the preparation for kvm to get the right path of
installed linux headers.
Patch 4 and 6 prepare the INSTALL_HDR_PATH to tell sub TARGET where the
linux headers are installed.
Patch 5 fixes the issue that with OUTPUT specified, it still make the
linux tree dirty.
I only test the sub TARGET of kvm.
In theory, it won't break other TARGET of selftests.
Changes in v2:
- fix the no directory issue in lib.mk
- make kvm fixes seperate patch
- Add the patch to fix linux src tree not clean issue
v1:
https://lore.kernel.org/kvm/20200315093425.33600-1-xiaoyao.li@intel.com/
Xiaoyao Li (6):
selftests: Create directory when OUTPUT specified
selftests: kvm: Include lib.mk earlier
selftests: kvm: Use the default linux header path only when
INSTALL_HDR_PATH not defined
selftests: Create variable INSTALL_HDR_PATH if need to install linux
headers to $(OUTPUT)/usr
selftests: Generate build output of linux headers to
$(OUTPUT)/linux-header-build
selftests: export INSTALL_HDR_PATH if using "O" to specify output dir
tools/testing/selftests/Makefile | 6 +++++-
tools/testing/selftests/kvm/Makefile | 9 +++++----
tools/testing/selftests/lib.mk | 19 ++++++++++++++++++-
3 files changed, 28 insertions(+), 6 deletions(-)
--
2.20.1
Add local header dependency in lib.mk. This enforces the dependency
blindly even when a test doesn't include the file, with the benefit
of a simpler common logic without requiring individual tests to have
special rule for it.
Signed-off-by: Shuah Khan <skhan(a)linuxfoundation.org>
---
tools/testing/selftests/lib.mk | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index 3ed0134a764d..b0556c752443 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -137,7 +137,8 @@ endif
# Selftest makefiles can override those targets by setting
# OVERRIDE_TARGETS = 1.
ifeq ($(OVERRIDE_TARGETS),)
-$(OUTPUT)/%:%.c
+LOCAL_HDRS := $(selfdir)/kselftest_harness.h $(selfdir)/kselftest.h
+$(OUTPUT)/%:%.c $(LOCAL_HDRS)
$(LINK.c) $^ $(LDLIBS) -o $@
$(OUTPUT)/%.o:%.S
--
2.20.1
Fix seccomp relocatable builds. This is a simple fix to use the
right lib.mk variable TEST_GEN_PROGS. Local header dependency
is addressed in a change to lib.mk as a framework change that
enforces the dependency without requiring changes to individual
tests.
The following use-cases work with this change:
In seccomp directory:
make all and make clean
>From top level from main Makefile:
make kselftest-install O=objdir ARCH=arm64 HOSTCC=gcc \
CROSS_COMPILE=aarch64-linux-gnu- TARGETS=seccomp
Signed-off-by: Shuah Khan <skhan(a)linuxfoundation.org>
---
Changes since v3:
Simplified logic based on comments from Kees and Michael
tools/testing/selftests/seccomp/Makefile | 17 +++--------------
1 file changed, 3 insertions(+), 14 deletions(-)
diff --git a/tools/testing/selftests/seccomp/Makefile b/tools/testing/selftests/seccomp/Makefile
index 1760b3e39730..0ebfe8b0e147 100644
--- a/tools/testing/selftests/seccomp/Makefile
+++ b/tools/testing/selftests/seccomp/Makefile
@@ -1,17 +1,6 @@
# SPDX-License-Identifier: GPL-2.0
-all:
-
-include ../lib.mk
-
-.PHONY: all clean
-
-BINARIES := seccomp_bpf seccomp_benchmark
CFLAGS += -Wl,-no-as-needed -Wall
+LDFLAGS += -lpthread
-seccomp_bpf: seccomp_bpf.c ../kselftest_harness.h
- $(CC) $(CFLAGS) $(LDFLAGS) $< -lpthread -o $@
-
-TEST_PROGS += $(BINARIES)
-EXTRA_CLEAN := $(BINARIES)
-
-all: $(BINARIES)
+TEST_GEN_PROGS := seccomp_bpf seccomp_benchmark
+include ../lib.mk
--
2.20.1
When kunit tests are run on native (i.e. non-UML) environments, the results
of test execution are often intermixed with dmesg output. This patch
series attempts to solve this by providing a debugfs representation
of the results of the last test run, available as
/sys/kernel/debug/kunit/<testsuite>/results
Changes since v6:
- fixed regexp parsing in kunit_parser.py to ensure test results are read
successfully with 4-space indentation (Brendan, patch 3)
Changes since v5:
- replaced undefined behaviour use of snprintf(buf, ..., buf) in
kunit_log() with a function to append string to existing log
(Frank, patch 1)
- added clarification on log size limitations to documentation
(Frank, patch 4)
Changes since v4:
- added suite-level log expectations to kunit log test (Brendan, patch 2)
- added log expectations (of it being NULL) for case where
CONFIG_KUNIT_DEBUGFS=n to kunit log test (patch 2)
- added patch 3 which replaces subtest tab indentation with 4 space
indentation as per TAP 14 spec (Frank, patch 3)
Changes since v3:
- added CONFIG_KUNIT_DEBUGFS to support conditional compilation of debugfs
representation, including string logging (Frank, patch 1)
- removed unneeded NULL check for test_case in
kunit_suite_for_each_test_case() (Frank, patch 1)
- added kunit log test to verify logging multiple strings works
(Frank, patch 2)
- rephrased description of results file (Frank, patch 3)
Changes since v2:
- updated kunit_status2str() to kunit_status_to_string() and made it
static inline in include/kunit/test.h (Brendan)
- added log string to struct kunit_suite and kunit_case, with log
pointer in struct kunit pointing at the case log. This allows us
to collect kunit_[err|info|warning]() messages at the same time
as we printk() them. This solves for the most part the sharing
of log messages between test execution and debugfs since we
just print the suite log (which contains the test suite preamble)
and the individual test logs. The only exception is the suite-level
status, which we cannot store in the suite log as it would mean
we'd print the suite and its status prior to the suite's results.
(Brendan, patch 1)
- dropped debugfs-based kunit run patch for now so as not to cause
problems with tests currently under development (Brendan)
- fixed doc issues with code block (Brendan, patch 3)
Changes since v1:
- trimmed unneeded include files in lib/kunit/debugfs.c (Greg)
- renamed global debugfs functions to be prefixed with kunit_ (Greg)
- removed error checking for debugfs operations (Greg)
Alan Maguire (4):
kunit: add debugfs /sys/kernel/debug/kunit/<suite>/results display
kunit: add log test
kunit: subtests should be indented 4 spaces according to TAP
kunit: update documentation to describe debugfs representation
Documentation/dev-tools/kunit/usage.rst | 14 +++
include/kunit/test.h | 59 +++++++++++--
lib/kunit/Kconfig | 8 ++
lib/kunit/Makefile | 4 +
lib/kunit/assert.c | 79 ++++++++---------
lib/kunit/debugfs.c | 116 +++++++++++++++++++++++++
lib/kunit/debugfs.h | 30 +++++++
lib/kunit/kunit-test.c | 45 +++++++++-
lib/kunit/test.c | 147 +++++++++++++++++++++++++-------
tools/testing/kunit/kunit_parser.py | 10 +--
10 files changed, 426 insertions(+), 86 deletions(-)
create mode 100644 lib/kunit/debugfs.c
create mode 100644 lib/kunit/debugfs.h
--
1.8.3.1
KUnit assertions and expectations will print the values being tested. If
these are pointers (e.g., KUNIT_EXPECT_PTR_EQ(test, a, b)), these
pointers are currently printed with the %pK format specifier, which -- to
prevent information leaks which may compromise, e.g., ASLR -- are often
either hashed or replaced with ____ptrval____ or similar, making debugging
tests difficult.
By replacing %pK with %px as Documentation/core-api/printk-formats.rst
suggests, we disable this security feature for KUnit assertions and
expectations, allowing the actual pointer values to be printed. Given
that KUnit is not intended for use in production kernels, and the
pointers are only printed on failing tests, this seems like a worthwhile
tradeoff.
Signed-off-by: David Gow <davidgow(a)google.com>
---
This seems like the best way of solving this problem to me, but if
anyone has a better solution I'd love to hear it.
Note also that this does trigger two checkpatch.pl warnings, which warn
that the change will potentially cause the kernel memory layout to be
exposed. Since that's the whole point of the change, they probably
sohuld stay there.
lib/kunit/assert.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/kunit/assert.c b/lib/kunit/assert.c
index 86013d4cf891..a87960409bd4 100644
--- a/lib/kunit/assert.c
+++ b/lib/kunit/assert.c
@@ -110,10 +110,10 @@ void kunit_binary_ptr_assert_format(const struct kunit_assert *assert,
binary_assert->left_text,
binary_assert->operation,
binary_assert->right_text);
- string_stream_add(stream, "\t\t%s == %pK\n",
+ string_stream_add(stream, "\t\t%s == %px\n",
binary_assert->left_text,
binary_assert->left_value);
- string_stream_add(stream, "\t\t%s == %pK",
+ string_stream_add(stream, "\t\t%s == %px",
binary_assert->right_text,
binary_assert->right_value);
kunit_assert_print_msg(assert, stream);
--
2.24.0.432.g9d3f5f5b63-goog
Rework kunit_tool in order to allow .kunitconfig files to better enforce
that disabled items in .kunitconfig are disabled in the generated
.config.
Previously, kunit_tool simply enforced that any line present in
.kunitconfig was also present in .config, but this could cause problems
if a config option was disabled in .kunitconfig, but not listed in .config
due to (for example) having disabled dependencies.
To fix this, re-work the parser to track config names and values, and
require values to match unless they are explicitly disabled with the
"CONFIG_x is not set" comment (or by setting its value to 'n'). Those
"disabled" values will pass validation if omitted from the .config, but
not if they have a different value.
Signed-off-by: David Gow <davidgow(a)google.com>
---
tools/testing/kunit/kunit_config.py | 41 ++++++++++++++++++++------
tools/testing/kunit/kunit_tool_test.py | 22 +++++++-------
2 files changed, 43 insertions(+), 20 deletions(-)
diff --git a/tools/testing/kunit/kunit_config.py b/tools/testing/kunit/kunit_config.py
index ebf3942b23f5..e75063d603b5 100644
--- a/tools/testing/kunit/kunit_config.py
+++ b/tools/testing/kunit/kunit_config.py
@@ -9,16 +9,18 @@
import collections
import re
-CONFIG_IS_NOT_SET_PATTERN = r'^# CONFIG_\w+ is not set$'
-CONFIG_PATTERN = r'^CONFIG_\w+=\S+$'
-
-KconfigEntryBase = collections.namedtuple('KconfigEntry', ['raw_entry'])
+CONFIG_IS_NOT_SET_PATTERN = r'^# CONFIG_(\w+) is not set$'
+CONFIG_PATTERN = r'^CONFIG_(\w+)=(\S+)$'
+KconfigEntryBase = collections.namedtuple('KconfigEntry', ['name', 'value'])
class KconfigEntry(KconfigEntryBase):
def __str__(self) -> str:
- return self.raw_entry
+ if self.value == 'n':
+ return r'# CONFIG_%s is not set' % (self.name)
+ else:
+ return r'CONFIG_%s=%s' % (self.name, self.value)
class KconfigParseError(Exception):
@@ -38,7 +40,17 @@ class Kconfig(object):
self._entries.append(entry)
def is_subset_of(self, other: 'Kconfig') -> bool:
- return self.entries().issubset(other.entries())
+ for a in self.entries():
+ found = False
+ for b in other.entries():
+ if a.name != b.name:
+ continue
+ if a.value != b.value:
+ return False
+ found = True
+ if a.value != 'n' and found == False:
+ return False
+ return True
def write_to_file(self, path: str) -> None:
with open(path, 'w') as f:
@@ -54,9 +66,20 @@ class Kconfig(object):
line = line.strip()
if not line:
continue
- elif config_matcher.match(line) or is_not_set_matcher.match(line):
- self._entries.append(KconfigEntry(line))
- elif line[0] == '#':
+
+ match = config_matcher.match(line)
+ if match:
+ entry = KconfigEntry(match.group(1), match.group(2))
+ self.add_entry(entry)
+ continue
+
+ empty_match = is_not_set_matcher.match(line)
+ if empty_match:
+ entry = KconfigEntry(empty_match.group(1), 'n')
+ self.add_entry(entry)
+ continue
+
+ if line[0] == '#':
continue
else:
raise KconfigParseError('Failed to parse: ' + line)
diff --git a/tools/testing/kunit/kunit_tool_test.py b/tools/testing/kunit/kunit_tool_test.py
index ce47e87b633a..984588d6ba95 100755
--- a/tools/testing/kunit/kunit_tool_test.py
+++ b/tools/testing/kunit/kunit_tool_test.py
@@ -37,7 +37,7 @@ class KconfigTest(unittest.TestCase):
self.assertTrue(kconfig0.is_subset_of(kconfig0))
kconfig1 = kunit_config.Kconfig()
- kconfig1.add_entry(kunit_config.KconfigEntry('CONFIG_TEST=y'))
+ kconfig1.add_entry(kunit_config.KconfigEntry('TEST', 'y'))
self.assertTrue(kconfig1.is_subset_of(kconfig1))
self.assertTrue(kconfig0.is_subset_of(kconfig1))
self.assertFalse(kconfig1.is_subset_of(kconfig0))
@@ -51,15 +51,15 @@ class KconfigTest(unittest.TestCase):
expected_kconfig = kunit_config.Kconfig()
expected_kconfig.add_entry(
- kunit_config.KconfigEntry('CONFIG_UML=y'))
+ kunit_config.KconfigEntry('UML', 'y'))
expected_kconfig.add_entry(
- kunit_config.KconfigEntry('CONFIG_MMU=y'))
+ kunit_config.KconfigEntry('MMU', 'y'))
expected_kconfig.add_entry(
- kunit_config.KconfigEntry('CONFIG_TEST=y'))
+ kunit_config.KconfigEntry('TEST', 'y'))
expected_kconfig.add_entry(
- kunit_config.KconfigEntry('CONFIG_EXAMPLE_TEST=y'))
+ kunit_config.KconfigEntry('EXAMPLE_TEST', 'y'))
expected_kconfig.add_entry(
- kunit_config.KconfigEntry('# CONFIG_MK8 is not set'))
+ kunit_config.KconfigEntry('MK8', 'n'))
self.assertEqual(kconfig.entries(), expected_kconfig.entries())
@@ -68,15 +68,15 @@ class KconfigTest(unittest.TestCase):
expected_kconfig = kunit_config.Kconfig()
expected_kconfig.add_entry(
- kunit_config.KconfigEntry('CONFIG_UML=y'))
+ kunit_config.KconfigEntry('UML', 'y'))
expected_kconfig.add_entry(
- kunit_config.KconfigEntry('CONFIG_MMU=y'))
+ kunit_config.KconfigEntry('MMU', 'y'))
expected_kconfig.add_entry(
- kunit_config.KconfigEntry('CONFIG_TEST=y'))
+ kunit_config.KconfigEntry('TEST', 'y'))
expected_kconfig.add_entry(
- kunit_config.KconfigEntry('CONFIG_EXAMPLE_TEST=y'))
+ kunit_config.KconfigEntry('EXAMPLE_TEST', 'y'))
expected_kconfig.add_entry(
- kunit_config.KconfigEntry('# CONFIG_MK8 is not set'))
+ kunit_config.KconfigEntry('MK8', 'n'))
expected_kconfig.write_to_file(kconfig_path)
--
2.25.1.696.g5e7596f4ac-goog
This series extends the kselftests for the vDSO library making sure: that
they compile correctly on non x86 platforms, that they can be cross
compiled and introducing new tests that verify the correctness of the
library.
The so extended vDSO kselftests have been verified on all the platforms
supported by the unified vDSO library [1].
The only new patch that this series introduces is the first one, patch 2 and
patch 3 have already been reviewed in past as part of other series [2] [3].
[1] https://lore.kernel.org/lkml/20190621095252.32307-1-vincenzo.frascino@arm.c…
[2] https://lore.kernel.org/lkml/20190621095252.32307-26-vincenzo.frascino@arm.…
[3] https://lore.kernel.org/lkml/20190523112116.19233-4-vincenzo.frascino@arm.c…
Cc: Shuah Khan <shuah(a)kernel.org>
Cc: Thomas Gleixner <tglx(a)linutronix.de>
Cc: Andy Lutomirski <luto(a)kernel.org>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino(a)arm.com>
Vincenzo Frascino (3):
kselftest: Enable vDSO test on non x86 platforms
kselftest: Extend vDSO selftest
kselftest: Extend vDSO selftest to clock_getres
tools/testing/selftests/Makefile | 1 +
tools/testing/selftests/vDSO/Makefile | 6 +-
.../selftests/vDSO/vdso_clock_getres.c | 124 +++++++++
tools/testing/selftests/vDSO/vdso_config.h | 90 +++++++
tools/testing/selftests/vDSO/vdso_full_test.c | 244 ++++++++++++++++++
5 files changed, 463 insertions(+), 2 deletions(-)
create mode 100644 tools/testing/selftests/vDSO/vdso_clock_getres.c
create mode 100644 tools/testing/selftests/vDSO/vdso_config.h
create mode 100644 tools/testing/selftests/vDSO/vdso_full_test.c
--
2.25.2
I attempted to build KVM selftests on a specified dir, unfortunately
neither "make O=~/mydir TARGETS=kvm" in tools/testing/selftests, nor
"make OUTPUT=~/mydir" in tools/testing/selftests/kvm work.
This series aims to make both work.
Xiaoyao Li (2):
kvm: selftests: Fix no directory error when OUTPUT specified
selftests: export INSTALL_HDR_PATH if using "O" to specify output dir
tools/testing/selftests/Makefile | 6 +++++-
tools/testing/selftests/kvm/Makefile | 3 ++-
2 files changed, 7 insertions(+), 2 deletions(-)
--
2.20.1
Fix seccomp relocatable builds. This is a simple fix to use the right
lib.mk variable TEST_GEN_PROGS with dependency on kselftest_harness.h
header, and defining LDFLAGS for pthread lib.
Removes custom clean rule which is no longer necessary with the use of
TEST_GEN_PROGS.
Uses $(OUTPUT) defined in lib.mk to handle build relocation.
The following use-cases work with this change:
In seccomp directory:
make all and make clean
>From top level from main Makefile:
make kselftest-install O=objdir ARCH=arm64 HOSTCC=gcc \
CROSS_COMPILE=aarch64-linux-gnu- TARGETS=seccomp
Signed-off-by: Shuah Khan <skhan(a)linuxfoundation.org>
---
Changes since v2:
-- Using TEST_GEN_PROGS is sufficient to generate objects.
Addresses review comments from Kees Cook.
tools/testing/selftests/seccomp/Makefile | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/tools/testing/selftests/seccomp/Makefile b/tools/testing/selftests/seccomp/Makefile
index 1760b3e39730..a0388fd2c3f2 100644
--- a/tools/testing/selftests/seccomp/Makefile
+++ b/tools/testing/selftests/seccomp/Makefile
@@ -1,17 +1,15 @@
# SPDX-License-Identifier: GPL-2.0
-all:
-
-include ../lib.mk
+CFLAGS += -Wl,-no-as-needed -Wall
+LDFLAGS += -lpthread
.PHONY: all clean
-BINARIES := seccomp_bpf seccomp_benchmark
-CFLAGS += -Wl,-no-as-needed -Wall
+include ../lib.mk
+
+# OUTPUT set by lib.mk
+TEST_GEN_PROGS := $(OUTPUT)/seccomp_bpf $(OUTPUT)/seccomp_benchmark
-seccomp_bpf: seccomp_bpf.c ../kselftest_harness.h
- $(CC) $(CFLAGS) $(LDFLAGS) $< -lpthread -o $@
+$(TEST_GEN_PROGS): ../kselftest_harness.h
-TEST_PROGS += $(BINARIES)
-EXTRA_CLEAN := $(BINARIES)
+all: $(TEST_GEN_PROGS)
-all: $(BINARIES)
--
2.20.1
A test data file for one of the kunit_tool unit tests was missing; add
it in so that unit tests can run properly.
Signed-off-by: Brendan Higgins <brendanhiggins(a)google.com>
---
Shuah, this is a fix for a broken test. Can you apply this for 5.7?
---
.../testing/kunit/test_data/test_pound_sign.log | Bin 0 -> 1656 bytes
1 file changed, 0 insertions(+), 0 deletions(-)
diff --git a/tools/testing/kunit/test_data/test_pound_sign.log b/tools/testing/kunit/test_data/test_pound_sign.log
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..28ffa5ba03bfa81ea02ea9d38e7de7acf3dd9e5d 100644
GIT binary patch
literal 1656
zcmah}U2EGg6n$=g#f7|Vtj^>lPBOzDM#o@mlt9+Kgd${FPEBlGBgsqs?{^h<Y3h$o
zFBaGLocpP>13GNVmW<8=R3_K%5Q9W*u~4upWe`4q(jqBTdcAw?ZG=v-jA5@FZ|^*5
zoU$NALGF+lEFssq<A{~zdHR7p&7+U(X~E!_yGM{l@40vQ%(~pazHH!+GB!sI;iCKZ
zY69Cjp-?V{LrnyMQ5I_>Rp5<1_i#FmdPY1z2tkYI|M1-7PdS}Ub_h8eK~m)?&(I;{
zd<2<NV1vyl7BWOggn_Hc5ba`wRu)R=x;oPiRuheYD}$9XJTpphG^wKX*mr|pw(;#T
zTvPxWb#R&-VC|~9KeFD0ooNCooO~P|@vNKL)n#t&WQm2JSh%gFRMuv7!M#yqYailx
z8TM&AUN~yqVM$ThVIE55OcVU4mW$eHC#dHEeUvCiE1wT#?U%cS^A_HAK$VqiIBG75
z($V`G!unJPuo@k2@gj4y7$WV7g73Ls@d32giPqc=`3mz^u|IR`05hOx29+=__XXIv
z%Xf#6<%P11b*dyatBVv$thED!=x%_Ts?sj1OY%b*t$Y}rODc$J2is^#<A~w+w`~mf
zCs_oC7u=9pAjzurLE}*e38}&1-KX^pd*7wM-Q35(VDtTJOgeOnB`K*rii#c_+)*qi
zNQ+5Dqv>MG0wcp<uf!}(SCXw)kqXk>xCSP@rQbRs58c`TmTbn>%WO@TFp;w*gB6RU
km;Ljlo8cvfMVVCc>`K4bOfE$-fO&T9$C>+RbV7Fh7t6}$ApigX
literal 0
HcmV?d00001
base-commit: 021ed9f551da33449a5238e45e849913422671d7
--
2.25.1.696.g5e7596f4ac-goog
Repeating patch 2/2's commit log:
When a selftest would timeout before, the program would just fall over
and no accounting of failures would be reported (i.e. it would result in
an incomplete TAP report). Instead, add an explicit SIGALRM handler to
cleanly catch and report the timeout.
Before:
[==========] Running 2 tests from 2 test cases.
[ RUN ] timeout.finish
[ OK ] timeout.finish
[ RUN ] timeout.too_long
Alarm clock
After:
[==========] Running 2 tests from 2 test cases.
[ RUN ] timeout.finish
[ OK ] timeout.finish
[ RUN ] timeout.too_long
timeout.too_long: Test terminated by timeout
[ FAIL ] timeout.too_long
[==========] 1 / 2 tests passed.
[ FAILED ]
Thanks!
-Kees
v2:
- fix typo in subject prefix
v1: https://lore.kernel.org/lkml/20200311211733.21211-1-keescook@chromium.org
Kees Cook (2):
selftests/harness: Move test child waiting logic
selftests/harness: Handle timeouts cleanly
tools/testing/selftests/kselftest_harness.h | 144 ++++++++++++++------
1 file changed, 99 insertions(+), 45 deletions(-)
--
2.20.1
A recent RFC patch set [1] suggests some additional functionality
may be needed around kunit resources. It seems to require
1. support for resources without allocation
2. support for lookup of such resources
3. support for access to resources across multiple kernel threads
The proposed changes here are designed to address these needs.
The idea is we first generalize the API to support adding
resources with static data; then from there we support named
resources. The latter support is needed because if we are
in a different thread context and only have the "struct kunit *"
to work with, we need a way to identify a resource in lookup.
[1] https://lkml.org/lkml/2020/2/26/1286
Changes since v1:
- reformatted longer parameter lists to have one parameter per-line
(Brendan, patch 1)
- fixed phrasing in various comments to clarify allocation of memory
and added comment to kunit resource tests to clarify why
kunit_put_resource() is used there (Brendan, patch 1)
- changed #define to static inline function (Brendan, patch 2)
- simplified kunit_add_named_resource() to use more of existing
code for non-named resource (Brendan, patch 2)
Alan Maguire (2):
kunit: generalize kunit_resource API beyond allocated resources
kunit: add support for named resources
include/kunit/test.h | 159 +++++++++++++++++++++++++++-------
lib/kunit/kunit-test.c | 111 +++++++++++++++++++-----
lib/kunit/string-stream.c | 14 ++-
lib/kunit/test.c | 211 ++++++++++++++++++++++++++++++++--------------
4 files changed, 371 insertions(+), 124 deletions(-)
--
1.8.3.1
Many systems build/test up-to-date kernels with older libcs, and
an older glibc (2.17) lacks the definition of SOL_DCCP in
/usr/include/bits/socket.h (it was added in the 4.6 timeframe).
Adding the definition to the test program avoids a compilation
failure that gets in the way of building tools/testing/selftests/net.
The test itself will work once the definition is added; either
skipping due to DCCP not being configured in the kernel under test
or passing, so there are no other more up-to-date glibc dependencies
here it seems beyond that missing definition.
Fixes: 11fb60d1089f ("selftests: net: reuseport_addr_any: add DCCP")
Signed-off-by: Alan Maguire <alan.maguire(a)oracle.com>
---
tools/testing/selftests/net/reuseport_addr_any.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tools/testing/selftests/net/reuseport_addr_any.c b/tools/testing/selftests/net/reuseport_addr_any.c
index c623393..b8475cb2 100644
--- a/tools/testing/selftests/net/reuseport_addr_any.c
+++ b/tools/testing/selftests/net/reuseport_addr_any.c
@@ -21,6 +21,10 @@
#include <sys/socket.h>
#include <unistd.h>
+#ifndef SOL_DCCP
+#define SOL_DCCP 269
+#endif
+
static const char *IP4_ADDR = "127.0.0.1";
static const char *IP6_ADDR = "::1";
static const char *IP4_MAPPED6 = "::ffff:127.0.0.1";
--
1.8.3.1
From: "Steven Rostedt (VMware)" <rostedt(a)goodmis.org>
The ftrace selftest "ftrace - test for function traceon/off triggers"
enables all events and reads the trace file. Now that the trace file does
not disable tracing, and will attempt to continually read new data that is
added, the selftest gets stuck reading the trace file. This is because the
data added to the trace file will fill up quicker than the reading of it.
By only enabling scheduling events, the read can keep up with the writes.
Instead of enabling all events, only enable the scheduler events.
Link: http://lkml.kernel.org/r/20200318111345.0516642e@gandalf.local.home
Cc: Shuah Khan <skhan(a)linuxfoundation.org>
Cc: linux-kselftest(a)vger.kernel.org
Acked-by: Masami Hiramatsu <mhiramat(a)kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt(a)goodmis.org>
---
.../selftests/ftrace/test.d/ftrace/func_traceonoff_triggers.tc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/func_traceonoff_triggers.tc b/tools/testing/selftests/ftrace/test.d/ftrace/func_traceonoff_triggers.tc
index 0c04282d33dd..1947387fe976 100644
--- a/tools/testing/selftests/ftrace/test.d/ftrace/func_traceonoff_triggers.tc
+++ b/tools/testing/selftests/ftrace/test.d/ftrace/func_traceonoff_triggers.tc
@@ -41,7 +41,7 @@ fi
echo '** ENABLE EVENTS'
-echo 1 > events/enable
+echo 1 > events/sched/enable
echo '** ENABLE TRACING'
enable_tracing
--
2.25.1
On Wed, Mar 18, 2020 at 9:13 AM Steven Rostedt <rostedt(a)goodmis.org> wrote:
>
>
> From: "Steven Rostedt (VMware)" <rostedt(a)goodmis.org>
>
> The ftrace selftest "ftrace - test for function traceon/off triggers"
> enables all events and reads the trace file. Now that the trace file does
> not disable tracing, and will attempt to continually read new data that is
> added, the selftest gets stuck reading the trace file. This is because the
> data added to the trace file will fill up quicker than the reading of it.
>
> By only enabling scheduling events, the read can keep up with the writes.
> Instead of enabling all events, only enable the scheduler events.
>
> Signed-off-by: Steven Rostedt (VMware) <rostedt(a)goodmis.org>
> ---
> .../selftests/ftrace/test.d/ftrace/func_traceonoff_triggers.tc | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
+ linux-kselttest and my LF email.
thanks,
-- Shuah
If the 'name' array in check_vgem() was not initialized to null, the
value of name[4] may be random. Which will cause strcmp(name, "vgem")
failed.
Signed-off-by: Leon He <leon.he(a)unisoc.com>
---
tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
index cd5e1f6..21f3d19 100644
--- a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
+++ b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
@@ -22,7 +22,7 @@
static int check_vgem(int fd)
{
drm_version_t version = { 0 };
- char name[5];
+ char name[5] = { 0 };
int ret;
version.name_len = 4;
--
2.7.4
Hi!
Shuah please consider applying to the kselftest tree.
This set is an attempt to make running tests for different
sets of data easier. The direct motivation is the tls
test which we'd like to run for TLS 1.2 and TLS 1.3,
but currently there is no easy way to invoke the same
tests with different parameters.
Tested all users of kselftest_harness.h.
v2:
- don't run tests by fixture
- don't pass params as an explicit argument
v3:
- go back to the orginal implementation with an extra
parameter, and running by fixture (Kees);
- add LIST_APPEND helper (Kees);
- add a dot between fixture and param name (Kees);
- rename the params to variants (Tim);
v1: https://lore.kernel.org/netdev/20200313031752.2332565-1-kuba@kernel.org/
v2: https://lore.kernel.org/netdev/20200314005501.2446494-1-kuba@kernel.org/
Jakub Kicinski (6):
selftests/seccomp: use correct FIXTURE macro
kselftest: factor out list manipulation to a helper
kselftest: create fixture objects
kselftest: run tests by fixture
kselftest: add fixture variants
selftests: tls: run all tests for TLS 1.2 and TLS 1.3
Documentation/dev-tools/kselftest.rst | 3 +-
tools/testing/selftests/kselftest_harness.h | 233 ++++++++++++++----
tools/testing/selftests/net/tls.c | 93 ++-----
tools/testing/selftests/seccomp/seccomp_bpf.c | 10 +-
4 files changed, 206 insertions(+), 133 deletions(-)
--
2.24.1
Hi!
Shuah please consider applying to the kselftest tree.
This set is an attempt to make running tests for different
sets of data easier. The direct motivation is the tls
test which we'd like to run for TLS 1.2 and TLS 1.3,
but currently there is no easy way to invoke the same
tests with different parameters.
Tested all users of kselftest_harness.h.
v2:
- don't run tests by fixture
- don't pass params as an explicit argument
v3:
- go back to the orginal implementation with an extra
parameter, and running by fixture (Kees);
- add LIST_APPEND helper (Kees);
- add a dot between fixture and param name (Kees);
- rename the params to variants (Tim);
v4:
- whitespace fixes.
v1: https://lore.kernel.org/netdev/20200313031752.2332565-1-kuba@kernel.org/
v2: https://lore.kernel.org/netdev/20200314005501.2446494-1-kuba@kernel.org/
v3: https://lore.kernel.org/netdev/20200316225647.3129354-1-kuba@kernel.org/
Jakub Kicinski (5):
kselftest: factor out list manipulation to a helper
kselftest: create fixture objects
kselftest: run tests by fixture
kselftest: add fixture variants
selftests: tls: run all tests for TLS 1.2 and TLS 1.3
Documentation/dev-tools/kselftest.rst | 3 +-
tools/testing/selftests/kselftest_harness.h | 236 +++++++++++++++-----
tools/testing/selftests/net/tls.c | 93 ++------
3 files changed, 204 insertions(+), 128 deletions(-)
--
2.24.1
Hi!
This set is an attempt to make running tests for different
sets of data easier. The direct motivation is the tls
test which we'd like to run for TLS 1.2 and TLS 1.3,
but currently there is no easy way to invoke the same
tests with different parameters.
Tested all users of kselftest_harness.h.
v2:
- don't run tests by fixture
- don't pass params as an explicit argument
Note that we loose a little bit of type safety
without passing parameters as an explicit argument.
If user puts the name of the wrong fixture as argument
to CURRENT_FIXTURE() it will happily cast the type.
Jakub Kicinski (4):
selftests/seccomp: use correct FIXTURE macro
kselftest: create fixture objects
kselftest: add fixture parameters
selftests: tls: run all tests for TLS 1.2 and TLS 1.3
Documentation/dev-tools/kselftest.rst | 3 +-
tools/testing/selftests/kselftest_harness.h | 156 ++++++++++++++++--
tools/testing/selftests/net/tls.c | 93 ++---------
tools/testing/selftests/seccomp/seccomp_bpf.c | 10 +-
4 files changed, 168 insertions(+), 94 deletions(-)
--
2.24.1
Hi!
This set is an attempt to make running tests for different
sets of data easier. The direct motivation is the tls
test which we'd like to run for TLS 1.2 and TLS 1.3,
but currently there is no easy way to invoke the same
tests with different parameters.
Tested all users of kselftest_harness.h.
Jakub Kicinski (5):
selftests/seccomp: use correct FIXTURE macro
kselftest: create fixture objects
kselftest: run tests by fixture
kselftest: add fixture parameters
selftests: tls: run all tests for TLS 1.2 and TLS 1.3
Documentation/dev-tools/kselftest.rst | 3 +-
tools/testing/selftests/kselftest_harness.h | 228 +++++++++++++++---
tools/testing/selftests/net/tls.c | 93 ++-----
tools/testing/selftests/seccomp/seccomp_bpf.c | 10 +-
4 files changed, 213 insertions(+), 121 deletions(-)
--
2.24.1
Remove some of the outmoded "Why KUnit" rationale, and move some
UML-specific information to the kunit_tool page. Also update the Getting
Started guide to mention running tests without the kunit_tool wrapper.
Signed-off-by: David Gow <davidgow(a)google.com>
Reviewed-by: Frank Rowand <frank.rowand(a)sony.com>
---
Sorry: I missed a couple of issues in the last version. They're fixed
here, and I think this should be ready to go.
Changelog:
v4:
- Fix typo: s/offsers/offers
- Talk about KUnit tests running on most "architectures" instead of
"kernel configurations.
v3:
https://lore.kernel.org/linux-kselftest/20200214235723.254228-1-davidgow@go…
- Added a note that KUnit can be used with UML, both with and without
kunit_tool to replace the section moved to kunit_tool.
v2:
https://lore.kernel.org/linux-kselftest/f99a3d4d-ad65-5fd1-3407-db33f378b1f…
- Reinstated the "Why Kunit?" section, minus the comparison with other
testing frameworks (covered in the FAQ), and the description of UML.
- Moved the description of UML into to kunit_tool page.
- Tidied up the wording around how KUnit is built and run to make it
work
without the UML description.
v1:
https://lore.kernel.org/linux-kselftest/9c703dea-a9e1-94e2-c12d-3cb0a09e75a…
- Initial patch
Documentation/dev-tools/kunit/index.rst | 40 ++++++----
Documentation/dev-tools/kunit/kunit-tool.rst | 7 ++
Documentation/dev-tools/kunit/start.rst | 80 ++++++++++++++++----
3 files changed, 99 insertions(+), 28 deletions(-)
diff --git a/Documentation/dev-tools/kunit/index.rst b/Documentation/dev-tools/kunit/index.rst
index d16a4d2c3a41..e93606ecfb01 100644
--- a/Documentation/dev-tools/kunit/index.rst
+++ b/Documentation/dev-tools/kunit/index.rst
@@ -17,14 +17,23 @@ What is KUnit?
==============
KUnit is a lightweight unit testing and mocking framework for the Linux kernel.
-These tests are able to be run locally on a developer's workstation without a VM
-or special hardware.
KUnit is heavily inspired by JUnit, Python's unittest.mock, and
Googletest/Googlemock for C++. KUnit provides facilities for defining unit test
cases, grouping related test cases into test suites, providing common
infrastructure for running tests, and much more.
+KUnit consists of a kernel component, which provides a set of macros for easily
+writing unit tests. Tests written against KUnit will run on kernel boot if
+built-in, or when loaded if built as a module. These tests write out results to
+the kernel log in `TAP <https://testanything.org/>`_ format.
+
+To make running these tests (and reading the results) easier, KUnit offers
+:doc:`kunit_tool <kunit-tool>`, which builds a `User Mode Linux
+<http://user-mode-linux.sourceforge.net>`_ kernel, runs it, and parses the test
+results. This provides a quick way of running KUnit tests during development,
+without requiring a virtual machine or separate hardware.
+
Get started now: :doc:`start`
Why KUnit?
@@ -36,21 +45,20 @@ allow all possible code paths to be tested in the code under test; this is only
possible if the code under test is very small and does not have any external
dependencies outside of the test's control like hardware.
-Outside of KUnit, there are no testing frameworks currently
-available for the kernel that do not require installing the kernel on a test
-machine or in a VM and all require tests to be written in userspace running on
-the kernel; this is true for Autotest, and kselftest, disqualifying
-any of them from being considered unit testing frameworks.
+KUnit provides a common framework for unit tests within the kernel.
+
+KUnit tests can be run on most architectures, and most tests are architecture
+independent. All built-in KUnit tests run on kernel startup. Alternatively,
+KUnit and KUnit tests can be built as modules and tests will run when the test
+module is loaded.
-KUnit addresses the problem of being able to run tests without needing a virtual
-machine or actual hardware with User Mode Linux. User Mode Linux is a Linux
-architecture, like ARM or x86; however, unlike other architectures it compiles
-to a standalone program that can be run like any other program directly inside
-of a host operating system; to be clear, it does not require any virtualization
-support; it is just a regular program.
+.. note::
-Alternatively, kunit and kunit tests can be built as modules and tests will
-run when the test module is loaded.
+ KUnit can also run tests without needing a virtual machine or actual
+ hardware under User Mode Linux. User Mode Linux is a Linux architecture,
+ like ARM or x86, which compiles the kernel as a Linux executable. KUnit
+ can be used with UML either by building with ``ARCH=um`` (like any other
+ architecture), or by using :doc:`kunit_tool <kunit-tool>`.
KUnit is fast. Excluding build time, from invocation to completion KUnit can run
several dozen tests in only 10 to 20 seconds; this might not sound like a big
@@ -81,3 +89,5 @@ How do I use it?
* :doc:`start` - for new users of KUnit
* :doc:`usage` - for a more detailed explanation of KUnit features
* :doc:`api/index` - for the list of KUnit APIs used for testing
+* :doc:`kunit-tool` - for more information on the kunit_tool helper script
+* :doc:`faq` - for answers to some common questions about KUnit
diff --git a/Documentation/dev-tools/kunit/kunit-tool.rst b/Documentation/dev-tools/kunit/kunit-tool.rst
index 50d46394e97e..949af2da81e5 100644
--- a/Documentation/dev-tools/kunit/kunit-tool.rst
+++ b/Documentation/dev-tools/kunit/kunit-tool.rst
@@ -12,6 +12,13 @@ the Linux kernel as UML (`User Mode Linux
<http://user-mode-linux.sourceforge.net/>`_), running KUnit tests, parsing
the test results and displaying them in a user friendly manner.
+kunit_tool addresses the problem of being able to run tests without needing a
+virtual machine or actual hardware with User Mode Linux. User Mode Linux is a
+Linux architecture, like ARM or x86; however, unlike other architectures it
+compiles the kernel as a standalone Linux executable that can be run like any
+other program directly inside of a host operating system. To be clear, it does
+not require any virtualization support: it is just a regular program.
+
What is a kunitconfig?
======================
diff --git a/Documentation/dev-tools/kunit/start.rst b/Documentation/dev-tools/kunit/start.rst
index 4e1d24db6b13..e1c5ce80ce12 100644
--- a/Documentation/dev-tools/kunit/start.rst
+++ b/Documentation/dev-tools/kunit/start.rst
@@ -9,11 +9,10 @@ Installing dependencies
KUnit has the same dependencies as the Linux kernel. As long as you can build
the kernel, you can run KUnit.
-KUnit Wrapper
-=============
-Included with KUnit is a simple Python wrapper that helps format the output to
-easily use and read KUnit output. It handles building and running the kernel, as
-well as formatting the output.
+Running tests with the KUnit Wrapper
+====================================
+Included with KUnit is a simple Python wrapper which runs tests under User Mode
+Linux, and formats the test results.
The wrapper can be run with:
@@ -21,22 +20,42 @@ The wrapper can be run with:
./tools/testing/kunit/kunit.py run --defconfig
-For more information on this wrapper (also called kunit_tool) checkout the
+For more information on this wrapper (also called kunit_tool) check out the
:doc:`kunit-tool` page.
Creating a .kunitconfig
-=======================
-The Python script is a thin wrapper around Kbuild. As such, it needs to be
-configured with a ``.kunitconfig`` file. This file essentially contains the
-regular Kernel config, with the specific test targets as well.
-
+-----------------------
+If you want to run a specific set of tests (rather than those listed in the
+KUnit defconfig), you can provide Kconfig options in the ``.kunitconfig`` file.
+This file essentially contains the regular Kernel config, with the specific
+test targets as well. The ``.kunitconfig`` should also contain any other config
+options required by the tests.
+
+A good starting point for a ``.kunitconfig`` is the KUnit defconfig:
.. code-block:: bash
cd $PATH_TO_LINUX_REPO
cp arch/um/configs/kunit_defconfig .kunitconfig
-Verifying KUnit Works
----------------------
+You can then add any other Kconfig options you wish, e.g.:
+.. code-block:: none
+
+ CONFIG_LIST_KUNIT_TEST=y
+
+:doc:`kunit_tool <kunit-tool>` will ensure that all config options set in
+``.kunitconfig`` are set in the kernel ``.config`` before running the tests.
+It'll warn you if you haven't included the dependencies of the options you're
+using.
+
+.. note::
+ Note that removing something from the ``.kunitconfig`` will not trigger a
+ rebuild of the ``.config`` file: the configuration is only updated if the
+ ``.kunitconfig`` is not a subset of ``.config``. This means that you can use
+ other tools (such as make menuconfig) to adjust other config options.
+
+
+Running the tests
+-----------------
To make sure that everything is set up correctly, simply invoke the Python
wrapper from your kernel repo:
@@ -62,6 +81,41 @@ followed by a list of tests that are run. All of them should be passing.
Because it is building a lot of sources for the first time, the
``Building KUnit kernel`` step may take a while.
+Running tests without the KUnit Wrapper
+=======================================
+
+If you'd rather not use the KUnit Wrapper (if, for example, you need to
+integrate with other systems, or use an architecture other than UML), KUnit can
+be included in any kernel, and the results read out and parsed manually.
+
+.. note::
+ KUnit is not designed for use in a production system, and it's possible that
+ tests may reduce the stability or security of the system.
+
+
+
+Configuring the kernel
+----------------------
+
+In order to enable KUnit itself, you simply need to enable the ``CONFIG_KUNIT``
+Kconfig option (it's under Kernel Hacking/Kernel Testing and Coverage in
+menuconfig). From there, you can enable any KUnit tests you want: they usually
+have config options ending in ``_KUNIT_TEST``.
+
+KUnit and KUnit tests can be compiled as modules: in this case the tests in a
+module will be run when the module is loaded.
+
+Running the tests
+-----------------
+
+Build and run your kernel as usual. Test output will be written to the kernel
+log in `TAP <https://testanything.org/>`_ format.
+
+.. note::
+ It's possible that there will be other lines and/or data interspersed in the
+ TAP output.
+
+
Writing your first test
=======================
--
2.25.1.481.gfbce0eb801-goog
When a selftest would timeout before, the program would just fall over
and no accounting of failures would be reported (i.e. it would result in
an incomplete TAP report). Instead, add an explicit SIGALRM handler to
cleanly catch and report the timeout.
Before:
[==========] Running 2 tests from 2 test cases.
[ RUN ] timeout.finish
[ OK ] timeout.finish
[ RUN ] timeout.too_long
Alarm clock
After:
[==========] Running 2 tests from 2 test cases.
[ RUN ] timeout.finish
[ OK ] timeout.finish
[ RUN ] timeout.too_long
timeout.too_long: Test terminated by timeout
[ FAIL ] timeout.too_long
[==========] 1 / 2 tests passed.
[ FAILED ]
-Kees
Kees Cook (2):
selftests/seccomp: Move test child waiting logic
selftests/harness: Handle timeouts cleanly
tools/testing/selftests/kselftest_harness.h | 144 ++++++++++++++------
1 file changed, 99 insertions(+), 45 deletions(-)
--
2.20.1
I was working on fixing the cross-compilation for the selftests/vm tests.
Currently, there are two issues in my testing:
1) problem: required library missing from some cross-compile environments:
tools/testing/selftests/vm/mlock-random-test.c requires libcap
be installed. The target line for mlock-random-test in
tools/testing/selftests/vm/Makefile looks like this:
$(OUTPUT)/mlock-random-test: LDLIBS += -lcap
and mlock-random-test.c has this include line:
#include <sys/capability.h>
this is confusing, since this is different from the header file
linux/capability.h. It is associated with the capability library (libcap)
and not the kernel. In any event, on some distros and in some
cross-compile SDKs the package containing these files is not installed
by default.
Once this library is installed, things progress farther. Using an Ubuntu
system, you can install the cross version of this library (for arm64) by doing:
$ sudo apt install libcap-dev:arm64
1) solution:
I would like to add some meta-data about this build dependency, by putting
something in the settings file as a hint to CI build systems. Specifically, I'd like to
create the file 'tools/testing/selftests/vm/settings', with the content:
NEED_LIB=cap
We already use settings for other meta-data about a test (right now, just a
non-default timeout value), but I don't want to create a new file or syntax
for this build dependency data.
Let me know what you think.
I may follow up with some script in the kernel source tree to check these
dependencies, independent of any CI system. I have such a script in Fuego
that I could submit, but it would need some work to fit into the kernel build
flow for kselftest. The goal would be to provide a nicely formatted warning,
with a recommendation for a package install. But that's more work than
I think is needed right now just to let developers know there's a build dependency
here.
2) problem: reference to source-relative header file
the Makefile for vm uses a relative path for include directories.
Specifically, it has the line:
CFLAGS = -Wall -I ../../../../../usr/include $(EXTRA_CFLAGS)
I believe this needs to reference kernel include files from the
output directory, not the source directory.
With the relative include directory path, the program userfaultfd.c
gets compilation error like this:
userfaultfd.c:267:21: error: 'UFFD_API_RANGE_IOCTLS_BASIC' undeclared here (not in a function)
.expected_ioctls = UFFD_API_RANGE_IOCTLS_BASIC,
^
userfaultfd.c: In function 'uffd_poll_thread':
userfaultfd.c:529:8: error: 'UFFD_EVENT_FORK' undeclared (first use in this function)
case UFFD_EVENT_FORK:
^
userfaultfd.c:529:8: note: each undeclared identifier is reported only once for each function it appears in
userfaultfd.c:531:18: error: 'union <anonymous>' has no member named 'fork'
uffd = msg.arg.fork.ufd;
^
2) incomplete solution:
I originally changed this line to read:
CFLAGS = -Wall -I $(KBUILD_OUTPUT)/usr/include $(EXTRA_CFLAGS)
This works when the output directory is specified using KBUILD_OUTPUT,
but not when the output directory is specified using O=
I'm not sure what happens when the output directory is specified
with a non-source-tree current working directory.
In any event, while researching a proper solution to this, I found
the following in tools/testing/selftests/Makefile:
If compiling with ifneq ($(O),)
BUILD := $(O)
else
ifneq ($(KBUILD_OUTPUT),)
BUILD := $(KBUILD_OUTPUT)/kselftest
else
BUILD := $(shell pwd)
DEFAULT_INSTALL_HDR_PATH := 1
endif
endif
This doesn't seem right. It looks like the selftests Makefile treats a directory
passed in using O= different from one specified using KBUILD_OUTPUT
or the current working directory.
In the KBUILD_OUTPUT case, you get an extra 'kselftest' directory layer
that you don't get for the other two.
In contrast, the kernel top-level Makefile has this:
ifeq ("$(origin O)", "command line")
KBUILD_OUTPUT := $(O)
endif
(and from then on, the top-level Makefile appears to only use KBUILD_OUTPUT)
This makes it look like the rest of the kernel build system treats O= and KBUILD_OUTPUT
identically.
Am I missing something, or is there a flaw in the O=/KBUILD_OUTPUT handling in
kselftest? Please let me know and I'll try to work out an appropriate fix for
cross-compiling the vm tests.
-- Tim
Hi Shuah,
We discussed collecting and uploading all syzkaller reproducers
somewhere. You wanted to see how they look. I've uploaded all current
reproducers here:
https://github.com/dvyukov/syzkaller-repros
Minimalistic build/run scripts are included.
+some testing mailing lists too as this can be used as a test suite
If you have any potential uses for this, you are welcome to use it.
But then we probably need to find some more official and shared place
for them than my private github.
The test programs can also be bulk updated if necessary, because all
of this is auto-generated.
Thanks
From: SeongJae Park <sjpark(a)amazon.de>
Deletions of configs in the '.kunitconfig' is not applied because kunit
rebuilds '.config' only if the '.config' is not a subset of the
'.kunitconfig'. To allow the deletions to applied, this commit modifies
the '.config' rebuild condition to addtionally check the modified times
of those files.
Signed-off-by: SeongJae Park <sjpark(a)amazon.de>
---
tools/testing/kunit/kunit_kernel.py | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/tools/testing/kunit/kunit_kernel.py b/tools/testing/kunit/kunit_kernel.py
index cc5d844ecca1..a3a5d6c7e66d 100644
--- a/tools/testing/kunit/kunit_kernel.py
+++ b/tools/testing/kunit/kunit_kernel.py
@@ -111,17 +111,22 @@ class LinuxSourceTree(object):
return True
def build_reconfig(self, build_dir):
- """Creates a new .config if it is not a subset of the .kunitconfig."""
+ """Creates a new .config if it is not a subset of, or older than the .kunitconfig."""
kconfig_path = get_kconfig_path(build_dir)
if os.path.exists(kconfig_path):
existing_kconfig = kunit_config.Kconfig()
existing_kconfig.read_from_file(kconfig_path)
- if not self._kconfig.is_subset_of(existing_kconfig):
- print('Regenerating .config ...')
- os.remove(kconfig_path)
- return self.build_config(build_dir)
- else:
+ subset = self._kconfig.is_subset_of(existing_kconfig)
+
+ kunitconfig_mtime = os.path.getmtime(kunitconfig_path)
+ kconfig_mtime = os.path.getmtime(kconfig_path)
+ older = kconfig_mtime < kunitconfig_mtime
+
+ if subset and not older:
return True
+ print('Regenerating .config ...')
+ os.remove(kconfig_path)
+ return self.build_config(build_dir)
else:
print('Generating .config ...')
return self.build_config(build_dir)
--
2.17.1
A recent RFC patch set [1] suggests some additional functionality
may be needed around kunit resources. It seems to require
1. support for resources without allocation
2. support for lookup of such resources
3. support for access to resources across multiple kernel threads
The proposed changes here are designed to address these needs.
The idea is we first generalize the API to support adding
resources with static data; then from there we support named
resources. The latter support is needed because if we are
in a different thread context and only have the "struct kunit *"
to work with, we need a way to identify a resource in lookup.
[1] https://lkml.org/lkml/2020/2/26/1286
Alan Maguire (2):
kunit: generalize kunit_resource API beyond allocated resources
kunit: add support for named resources
include/kunit/test.h | 145 ++++++++++++++++++++++------
lib/kunit/kunit-test.c | 103 ++++++++++++++++----
lib/kunit/string-stream.c | 14 ++-
lib/kunit/test.c | 234 +++++++++++++++++++++++++++++++++-------------
4 files changed, 375 insertions(+), 121 deletions(-)
--
1.8.3.1
When kunit tests are run on native (i.e. non-UML) environments, the results
of test execution are often intermixed with dmesg output. This patch
series attempts to solve this by providing a debugfs representation
of the results of the last test run, available as
/sys/kernel/debug/kunit/<testsuite>/results
Changes since v5:
- replaced undefined behaviour use of snprintf(buf, ..., buf) in kunit_log()
with a function to append string to existing log (Frank, patch 1)
- added clarification on log size limitations to documentation
(Frank, patch 4)
Changes since v4:
- added suite-level log expectations to kunit log test (Brendan, patch 2)
- added log expectations (of it being NULL) for case where
CONFIG_KUNIT_DEBUGFS=n to kunit log test (patch 2)
- added patch 3 which replaces subtest tab indentation with 4 space
indentation as per TAP 14 spec (Frank, patch 3)
Changes since v3:
- added CONFIG_KUNIT_DEBUGFS to support conditional compilation of debugfs
representation, including string logging (Frank, patch 1)
- removed unneeded NULL check for test_case in
kunit_suite_for_each_test_case() (Frank, patch 1)
- added kunit log test to verify logging multiple strings works
(Frank, patch 2)
- rephrased description of results file (Frank, patch 3)
Changes since v2:
- updated kunit_status2str() to kunit_status_to_string() and made it
static inline in include/kunit/test.h (Brendan)
- added log string to struct kunit_suite and kunit_case, with log
pointer in struct kunit pointing at the case log. This allows us
to collect kunit_[err|info|warning]() messages at the same time
as we printk() them. This solves for the most part the sharing
of log messages between test execution and debugfs since we
just print the suite log (which contains the test suite preamble)
and the individual test logs. The only exception is the suite-level
status, which we cannot store in the suite log as it would mean
we'd print the suite and its status prior to the suite's results.
(Brendan, patch 1)
- dropped debugfs-based kunit run patch for now so as not to cause
problems with tests currently under development (Brendan)
- fixed doc issues with code block (Brendan, patch 3)
Changes since v1:
- trimmed unneeded include files in lib/kunit/debugfs.c (Greg)
- renamed global debugfs functions to be prefixed with kunit_ (Greg)
- removed error checking for debugfs operations (Greg)
Alan Maguire (4):
kunit: add debugfs /sys/kernel/debug/kunit/<suite>/results display
kunit: add log test
kunit: subtests should be indented 4 spaces according to TAP
kunit: update documentation to describe debugfs representation
Documentation/dev-tools/kunit/usage.rst | 14 +++
include/kunit/test.h | 59 +++++++++++--
lib/kunit/Kconfig | 8 ++
lib/kunit/Makefile | 4 +
lib/kunit/assert.c | 79 ++++++++---------
lib/kunit/debugfs.c | 116 +++++++++++++++++++++++++
lib/kunit/debugfs.h | 30 +++++++
lib/kunit/kunit-test.c | 45 +++++++++-
lib/kunit/test.c | 147 +++++++++++++++++++++++++-------
9 files changed, 421 insertions(+), 81 deletions(-)
create mode 100644 lib/kunit/debugfs.c
create mode 100644 lib/kunit/debugfs.h
--
1.8.3.1
This patch set has several miscellaneous fixes to resctrl selftest tool. Some
fixes are minor in nature while other are major fixes.
The minor fixes are
1. Typos, comment format
2. Fix MBA feature detection
3. Fix a bug while selecting sibling cpu
4. Remove unnecessary use of variable arguments
5. Change MBM/MBA results reporting format from absolute values to percentage
The major fixes are changing CAT and CQM test cases. CAT test wasn't testing
CAT as it isn't using the cache it's allocated, hence, change the test case to
test noisy neighbor use case. CAT guarantees a user specified amount of cache
for a process or a group of processes, hence test this use case. The updated
test case checks if critical process is impacted by noisy neighbor or not. If
it's impacted the test fails.
The present CQM test assumes that all the allocated memory (size less than LLC
size) for a process will fit into cache and there won't be any overlappings.
While this is mostly true, it cannot be *always* true by the nature of how cache
works i.e. two addresses could index into same cache line. Hence, change CQM
test such that it now uses CAT. Allocate a specific amount of cache using CAT
and check if CQM reports more than what CAT has allocated.
Fenghua Yu (1):
selftests/resctrl: Fix missing options "-n" and "-p"
Reinette Chatre (4):
selftests/resctrl: Fix feature detection
selftests/resctrl: Fix typo
selftests/resctrl: Fix typo in help text
selftests/resctrl: Ensure sibling CPU is not same as original CPU
Sai Praneeth Prakhya (8):
selftests/resctrl: Fix MBA/MBM results reporting format
selftests/resctrl: Don't use variable argument list for setup function
selftests/resctrl: Fix typos
selftests/resctrl: Modularize fill_buf for new CAT test case
selftests/resctrl: Change Cache Allocation Technology (CAT) test
selftests/resctrl: Change Cache Quality Monitoring (CQM) test
selftests/resctrl: Dynamically select buffer size for CAT test
selftests/resctrl: Cleanup fill_buff after changing CAT test
tools/testing/selftests/resctrl/cache.c | 179 ++++++++-----
tools/testing/selftests/resctrl/cat_test.c | 322 +++++++++++++-----------
tools/testing/selftests/resctrl/cqm_test.c | 210 +++++++++-------
tools/testing/selftests/resctrl/fill_buf.c | 113 ++++++---
tools/testing/selftests/resctrl/mba_test.c | 32 ++-
tools/testing/selftests/resctrl/mbm_test.c | 33 ++-
tools/testing/selftests/resctrl/resctrl.h | 19 +-
tools/testing/selftests/resctrl/resctrl_tests.c | 26 +-
tools/testing/selftests/resctrl/resctrl_val.c | 22 +-
tools/testing/selftests/resctrl/resctrlfs.c | 52 +++-
10 files changed, 592 insertions(+), 416 deletions(-)
--
2.7.4
Fix seccomp relocatable builds. This is a simple fix to use the
right lib.mk variable TEST_CUSTOM_PROGS to continue to do custom
build to preserve dependency on kselftest_harness.h local header.
This change applies cutom rule to seccomp_bpf seccomp_benchmark
for a simpler logic.
Uses $(OUTPUT) defined in lib.mk to handle build relocation.
The following use-cases work with this change:
In seccomp directory:
make all and make clean
>From top level from main Makefile:
make kselftest-install O=objdir ARCH=arm64 HOSTCC=gcc \
CROSS_COMPILE=aarch64-linux-gnu- TARGETS=seccomp
Signed-off-by: Shuah Khan <skhan(a)linuxfoundation.org>
---
tools/testing/selftests/seccomp/Makefile | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/tools/testing/selftests/seccomp/Makefile b/tools/testing/selftests/seccomp/Makefile
index 1760b3e39730..355bcbc0394a 100644
--- a/tools/testing/selftests/seccomp/Makefile
+++ b/tools/testing/selftests/seccomp/Makefile
@@ -1,17 +1,16 @@
# SPDX-License-Identifier: GPL-2.0
-all:
-
-include ../lib.mk
+CFLAGS += -Wl,-no-as-needed -Wall
+LDFLAGS += -lpthread
.PHONY: all clean
-BINARIES := seccomp_bpf seccomp_benchmark
-CFLAGS += -Wl,-no-as-needed -Wall
+include ../lib.mk
+
+# OUTPUT set by lib.mk
+TEST_CUSTOM_PROGS := $(OUTPUT)/seccomp_bpf $(OUTPUT)/seccomp_benchmark
-seccomp_bpf: seccomp_bpf.c ../kselftest_harness.h
- $(CC) $(CFLAGS) $(LDFLAGS) $< -lpthread -o $@
+$(TEST_CUSTOM_PROGS): ../kselftest_harness.h
-TEST_PROGS += $(BINARIES)
-EXTRA_CLEAN := $(BINARIES)
+all: $(TEST_CUSTOM_PROGS)
-all: $(BINARIES)
+EXTRA_CLEAN := $(TEST_CUSTOM_PROGS)
--
2.20.1
Add RSEQ, restartable sequence, support and related selftest to RISCV.
The Kconfig option HAVE_REGS_AND_STACK_ACCESS_API is also required by
RSEQ because RSEQ will modify the content of pt_regs.sepc through
instruction_pointer_set() during the fixup procedure. In order to select
the config HAVE_REGS_AND_STACK_ACCESS_API, the missing APIs for accessing
pt_regs are also added in this patch set.
The relevant RSEQ tests in kselftest require the Binutils patch "RISC-V:
Fix linker problems with TLS copy relocs" to avoid placing
PREINIT_ARRAY and TLS variable of librseq.so at the same address.
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=3e7bd7f…
A segmental fault will happen if the Binutils misses this patch.
Vincent Chen (3):
riscv: add required functions to enable HAVE_REGS_AND_STACK_ACCESS_API
riscv: Add support for restartable sequence
rseq/selftests: Add support for riscv
arch/riscv/Kconfig | 2 +
arch/riscv/include/asm/ptrace.h | 29 +-
arch/riscv/kernel/entry.S | 4 +
arch/riscv/kernel/ptrace.c | 99 +++++
arch/riscv/kernel/signal.c | 3 +
tools/testing/selftests/rseq/param_test.c | 23 ++
tools/testing/selftests/rseq/rseq-riscv.h | 622 ++++++++++++++++++++++++++++++
tools/testing/selftests/rseq/rseq.h | 2 +
8 files changed, 783 insertions(+), 1 deletion(-)
create mode 100644 tools/testing/selftests/rseq/rseq-riscv.h
--
2.7.4
> -----Original Message-----
> From: Shuah Khan
>
> On 2/28/20 10:50 AM, Bird, Tim wrote:
> >
> >
> >> -----Original Message-----
> >> From: Shuah Khan
> >>
> >> Integrating Kselftest into Kernel CI rings depends on Kselftest build
> >> and install framework to support Kernel CI use-cases. I am kicking off
> >> an effort to support Kselftest runs in Kernel CI rings. Running these
> >> tests in Kernel CI rings will help quality of kernel releases, both
> >> stable and mainline.
> >>
> >> What is required for full support?
> >>
> >> 1. Cross-compilation & relocatable build support
> >> 2. Generates objects in objdir/kselftest without cluttering main objdir
> >> 3. Leave source directory clean
> >> 4. Installs correctly in objdir/kselftest/kselftest_install and adds
> >> itself to run_kselftest.sh script generated during install.
> >>
> >> Note that install step is necessary for all files to be installed for
> >> run time support.
> >>
> >> I looked into the current status and identified problems. The work is
> >> minimal to add full support. Out of 80+ tests, 7 fail to cross-build
> >> and 1 fails to install correctly.
> >>
> >> List is below:
> >>
> >> Tests fails to build: bpf, capabilities, kvm, memfd, mqueue, timens, vm
> >> Tests fail to install: android (partial failure)
> >> Leaves source directory dirty: bpf, seccomp
> >>
> >> I have patches ready for the following issues:
> >>
> >> Kselftest objects (test dirs) clutter top level object directory.
> >> seccomp_bpf generates objects in the source directory.
> >>
> >> I created a topic branch to collect all the patches:
> >>
> >> https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git/?…
> >>
> >> I am going to start working on build problems. If anybody is
> >> interested in helping me with this effort, don't hesitate to
> >> contact me. I first priority is fixing build and install and
> >> then look into tests that leave the source directory dirty.
> >
> > I'm interested in this. I'd like the same cleanups in order to run
> > kselftest in Fuego, and I can try it with additional toolchains
> > and boards. Unfortunately, in terms of running tests, almost all
> > the boards in my lab are running old kernels. So the tests results
> > aren't useful for upstream work. But I can still test
> > compilation and install issues, for the kselftest tests themselves.
> >
>
> Testing compilation and install issues is very valuable. This is one
> area that hasn't been test coverage compared to running tests. So it
> great if you can help with build/install on linux-next to catch
> problems in new tests. I am finding that older tests have been stable
> and as new tests come in, we tend to miss catching these types of
> problems.
>
> Especially cross-builds and installs on arm64 and others.
OK. I've got 2 different arm64 compilers, with wildly different SDK setups,
so hopefully this will be useful.
> >>
> >> Detailed report can be found here:
> >>
> >> https://drive.google.com/file/d/11nnWOKIzzOrE4EiucZBn423lzSU_eNNv/view?usp=…
> >
> > Is there anything you'd like me to look at specifically? Do you want me to start
> > at the bottom of the list and work up? I could look at 'vm' or 'timens'.
> >
>
> Yes you can start with vm and timens.
I wrote a test for Fuego and ran into a few interesting issues. Also, I have a question
about the best place to start, and your preference for reporting results. Your feedback
on any of this would be appreciated:
Here are some issues and questions I ran into:
1) overwriting of CC in lib.mk
This line in tools/testing/selftests/lib.mk caused me some grief:
CC := $(CROSS_COMPILE)gcc
One of my toolchains pre-defines CC with a bunch of extra flags, so this didn't work for
that tolchain.
I'm still debugging this. I'm not sure why the weird definition of CC works for the rest
of the kernel but not with kselftest. But I may submit some kind of patch to make this
CC assignment conditional (that is, only do the assignment if it's not already defined)
Let me know what you think.
2) ability to get list of targets would be nice
It would be nice if there were a mechanism to get the list of default targets from
kselftest. I added the following for my own tests, so that I don't have to hard-code
my loop over the individual selftests:
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index 63430e2..9955e71 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -246,4 +246,7 @@ clean:
$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
done;
+show_targets:
+ @echo $(TARGETS)
+
.PHONY: khdr all run_tests hotplug run_hotplug clean_hotplug run_pstore_crash install clean
This is pretty simple. I can submit this as a proper patch, if you're willing to take
something like it, and we can discuss details if you'd rather see this done another way.
3) different ways to invoke kselftest
There are a number of different ways to invoke kselftest. I'm currently using the
'-C' method for both building and installing.
make ARCH=$ARCHITECTURE TARGETS="$target" -C tools/testing/selftests
make ARCH=$ARCHITECTURE TARGETS="$target" -C tools/testing/selftests install
I think, there there are now targets for kselftest in the top-level Makefile.
Do you have a preferred method you'd like me to test? Or would you like
me to run my tests with multiple methods?
And I'm using a KBUILD_OUTPUT environment variable, rather than O=.
Let me know if you'd like me to build a matrix of these different build methods.
4) what tree(s) would you like me to test?
I think you mentioned that you'd like to see the tests against 'linux-next'.
Right now I've been doing tests against the 'torvalds' mainline tree, and
the 'linux-kselftest' tree, master branch. Let me know if there are other
branches or trees you like me to test.
5) where would you like test results?
In the short term, I'm testing the compile and install of the tests
and working on the ones that fail for me (I'm getting 17 or 18
failures, depending on the toolchain I'm using, for some of my boards).
However, I'm still debugging my setup, I hope I can drop that down
to the same one's you are seeing shortly.
Longer-term I plan to set up a CI loop for these tests for Fuego, and publish some
kind of matrix results and reports on my own server (https://birdcloud.org/)
I'm generating HTML tables now that work with Fuego's Jenkins
configuration, but I could send the data elsewhere if desired.
This is still under construction. Would you like me to publish results also to
kcidb, or some other repository? I might be able to publish my
results to Kernelci, but I'll end up with a customized report for kselftest,
that will allow drilling down to see output for individual compile or
install failures. I'm not sure how much of that would be supported in
the KernelCI interface. But I recognize you'd probably not like to
have to go to multiple places to see results.
Also, in terms of periodic results do you want any e-mails
sent to the Linux-kselftest list? I thought I'd hold off for now,
and wait for the compile/install fixes to settle down, so that
future e-mails would only report regressions or issues with new tests.
We can discuss this later, as I don't plan to do this quite
yet (and would only do an e-mail after checking with you anyway).
Thanks for any feedback you can provide.
-- Tim
P.S. Also, please let me know who is working on this on the KernelCI
side (if it's not Kevin), so I can CC them on future discussions.
Hi Linus,
Please pull the following Keselftest update for Linux 5.6-rc5.
This Kselftest update for Linux 5.6-rc5 consists of a cleanup patch
to undo changes to global .gitignore that added selftests/lkdtm
objects and add them to a local selftests/lkdtm/.gitignore.
Summary of Linus's comments on local vs. global gitignore scope:
- Keep local gitignore patterns in local files.
- Put only global gitignore patterns in the top-level gitignore file.
Local scope keeps things much better separated. It also incidentally
means that if a directory gets renamed, the gitignore file continues
to work unless in the case of renaming the actual files themselves that
are named in the gitignore.
Diff is attached.
I took the liberty to include summary of your comments on local vs
global gitignore scope in the commit message.
thanks,
-- Shuah
----------------------------------------------------------------
The following changes since commit ef89d0545132d685f73da6f58b7e7fe002536f91:
selftests/rseq: Fix out-of-tree compilation (2020-02-20 08:57:12 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
tags/linux-kselftest-5.6-rc5
for you to fetch changes up to f3a60268f5cec7dae0e9713f5fc65aecc3734c09:
selftest/lkdtm: Use local .gitignore (2020-03-02 08:39:39 -0700)
----------------------------------------------------------------
linux-kselftest-5.6-rc5
This Kselftest update for Linux 5.6-rc5 consists of a cleanup patch
to undo changes to global .gitignore that added selftests/lkdtm
objects and add them to a local selftests/lkdtm/.gitignore.
Summary of Linus's comments on local vs. global gitignore scope:
- Keep local gitignore patterns in local files.
- Put only global gitignore patterns in the top-level gitignore file.
Local scope keeps things much better separated. It also incidentally
means that if a directory gets renamed, the gitignore file continues
to work unless in the case of renaming the actual files themselves that
are named in the gitignore.
----------------------------------------------------------------
Christophe Leroy (1):
selftest/lkdtm: Use local .gitignore
.gitignore | 4 ----
tools/testing/selftests/lkdtm/.gitignore | 2 ++
2 files changed, 2 insertions(+), 4 deletions(-)
create mode 100644 tools/testing/selftests/lkdtm/.gitignore
----------------------------------------------------------------
Hello,
This patchset implements a new futex operation, called FUTEX_WAIT_MULTIPLE,
which allows a thread to wait on several futexes at the same time, and be
awoken by any of them.
The use case lies in the Wine implementation of the Windows NT interface
WaitMultipleObjects. This Windows API function allows a thread to sleep
waiting on the first of a set of event sources (mutexes, timers, signal,
console input, etc) to signal. Considering this is a primitive
synchronization operation for Windows applications, being able to quickly
signal events on the producer side, and quickly go to sleep on the
consumer side is essential for good performance of those running over Wine.
Since this API exposes a mechanism to wait on multiple objects, and
we might have multiple waiters for each of these events, a M->N
relationship, the current Linux interfaces fell short on performance
evaluation of large M,N scenarios. We experimented, for instance, with
eventfd, which has performance problems discussed below, but we also
experimented with userspace solutions, like making each consumer wait on
a condition variable guarding the entire list of objects, and then
waking up multiple variables on the producer side, but this is
prohibitively expensive since we either need to signal many condition
variables or share that condition variable among multiple waiters, and
then verify for the event being signaled in userspace, which means
dealing with often false positive wakes ups.
The natural interface to implement the behavior we want, also
considering that one of the waitable objects is a mutex itself, would be
the futex interface. Therefore, this patchset proposes a mechanism for
a thread to wait on multiple futexes at once, and wake up on the first
futex that was awaken.
In particular, using futexes in our Wine use case reduced the CPU
utilization by 4% for the game Beat Saber and by 1.5% for the game
Shadow of Tomb Raider, both running over Proton (a Wine based solution
for Windows emulation), when compared to the eventfd interface. This
implementation also doesn't rely of file descriptors, so it doesn't risk
overflowing the resource.
In time, we are also proposing modifications to glibc and libpthread to
make this feature available for Linux native multithreaded applications
using libpthread, which can benefit from the behavior of waiting on any
of a group of futexes.
Technically, the existing FUTEX_WAIT implementation can be easily
reworked by using futex_wait_multiple() with a count of one, and I
have a patch showing how it works. I'm not proposing it, since
futex is such a tricky code, that I'd be more comfortable to have
FUTEX_WAIT_MULTIPLE running upstream for a couple development cycles,
before considering modifying FUTEX_WAIT.
The patch series includes an extensive set of kselftests validating
the behavior of the interface. We also implemented support[1] on
Syzkaller and survived the fuzzy testing.
Finally, if you'd rather pull directly a branch with this set you can
find it here:
https://gitlab.collabora.com/tonyk/linux/commits/futex-dev-v3
The RFC for this patch can be found here:
https://lkml.org/lkml/2019/7/30/1399
=== Performance of eventfd ===
Polling on several eventfd contexts with semaphore semantics would
provide us with the exact semantics we are looking for. However, as
shown below, in a scenario with sufficient producers and consumers, the
eventfd interface itself becomes a bottleneck, in particular because
each thread will compete to acquire a sequence of waitqueue locks for
each eventfd context in the poll list. In addition, in the uncontended
case, where the producer is ready for consumption, eventfd still
requires going into the kernel on the consumer side.
When a write or a read operation in an eventfd file succeeds, it will try
to wake up all threads that are waiting to perform some operation to
the file. The lock (ctx->wqh.lock) that hold the access to the file value
(ctx->count) is the same lock used to control access the waitqueue. When
all those those thread woke, they will compete to get this lock. Along
with that, the poll() also manipulates the waitqueue and need to hold
this same lock. This lock is specially hard to acquire when poll() calls
poll_freewait(), where it tries to free all waitqueues associated with
this poll. While doing that, it will compete with a lot of read and
write operations that have been waken.
In our use case, with a huge number of parallel reads, writes and polls,
this lock is a bottleneck and hurts the performance of applications. Our
implementation of futex, however, decrease the calls of spin lock by more
than 80% in some user applications.
Finally, eventfd operates on file descriptors, which is a limited
resource that has shown its limitation in our use cases. Despite the
Windows interface not waiting on more than 64 objects at once, we still
have multiple waiters at the same time, and we were easily able to
exhaust the FD limits on applications like games.
Thanks,
André
[1] https://github.com/andrealmeid/syzkaller/tree/futex-wait-multiple
Gabriel Krisman Bertazi (4):
futex: Implement mechanism to wait on any of several futexes
selftests: futex: Add FUTEX_WAIT_MULTIPLE timeout test
selftests: futex: Add FUTEX_WAIT_MULTIPLE wouldblock test
selftests: futex: Add FUTEX_WAIT_MULTIPLE wake up test
include/uapi/linux/futex.h | 20 +
kernel/futex.c | 358 +++++++++++++++++-
.../selftests/futex/functional/.gitignore | 1 +
.../selftests/futex/functional/Makefile | 3 +-
.../futex/functional/futex_wait_multiple.c | 173 +++++++++
.../futex/functional/futex_wait_timeout.c | 38 +-
.../futex/functional/futex_wait_wouldblock.c | 28 +-
.../testing/selftests/futex/functional/run.sh | 3 +
.../selftests/futex/include/futextest.h | 22 ++
9 files changed, 639 insertions(+), 7 deletions(-)
create mode 100644 tools/testing/selftests/futex/functional/futex_wait_multiple.c
--
2.25.0