Hi Alexandre,
Thanks for your promptly response, I try to remove all HTML links and
resend the email again to avoid the security scanner to disrupt the
external link. Hope you can see this email without problems.
On 2024/5/3 8:20 PM, Joseph Jang wrote:
>
> On 02/05/2024 18:41:02-0700, Joseph Jang wrote:
> > Some platforms do not support WAKEUP service by default, we use a shell
> > script to check the absence of alarm content in /proc/driver/rtc.
>
> procfs for the RTC has been deprecated for a while, don't use it.
>
> Instead, you can use the RTC_PARAM_GET ioctl to get RTC_PARAM_FEATURES
> and then look at RTC_FEATURE_ALARM.
>
I found old version kernel doesn't support RTC_PARAM_GET ioctl. In order
support old version kernel testing, is it possible to use rtc procfs to
validate wakealarm function for old version kernel ?
Can I move this rtc alarm validation to
<linux_root>/tools/testing/selftests/rtc/rtctest.c ? So, we could try to
use RTC_PARAM_GET ioctl first and then roll back to use rtc procfs if
new RTC_PARAM_GET ioctl was not supported.
Thank you,
Joseph
> >
> > The script will validate /proc/driver/rtc when it is not empty and then
> > check if could find alarm content in it according to the rtc wakealarm
> > is supported or not.
> >
> > Requires commit 101ca8d05913b ("rtc: efi: Enable SET/GET WAKEUP services
> > as optional")
> >
> > Reviewed-by: Matthew R. Ochs <mochs(a)nvidia.com>
> > Signed-off-by: Joseph Jang <jjang(a)nvidia.com>
> > ---
> > tools/testing/selftests/Makefile | 1 +
> > tools/testing/selftests/rtc/property/Makefile | 5 ++++
> > .../selftests/rtc/property/rtc-alarm-test.sh | 27 +++++++++++++++++++
> > 3 files changed, 33 insertions(+)
> > create mode 100644 tools/testing/selftests/rtc/property/Makefile
> > create mode 100755 tools/testing/selftests/rtc/property/rtc-alarm-test.sh
> >
> > diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
> > index e1504833654d..f5d43e2132e8 100644
> > --- a/tools/testing/selftests/Makefile
> > +++ b/tools/testing/selftests/Makefile
> > @@ -80,6 +80,7 @@ TARGETS += riscv
> > TARGETS += rlimits
> > TARGETS += rseq
> > TARGETS += rtc
> > +TARGETS += rtc/property
> > TARGETS += rust
> > TARGETS += seccomp
> > TARGETS += sgx
> > diff --git a/tools/testing/selftests/rtc/property/Makefile
> b/tools/testing/selftests/rtc/property/Makefile
> > new file mode 100644
> > index 000000000000..c6f7aa4f0e29
> > --- /dev/null
> > +++ b/tools/testing/selftests/rtc/property/Makefile
> > @@ -0,0 +1,5 @@
> > +# SPDX-License-Identifier: GPL-2.0
> > +TEST_PROGS := rtc-alarm-test.sh
> > +
> > +include ../../lib.mk
> > +
> > diff --git a/tools/testing/selftests/rtc/property/rtc-alarm-test.sh
> b/tools/testing/selftests/rtc/property/rtc-alarm-test.sh
> > new file mode 100755
> > index 000000000000..3bee1dd5fbd0
> > --- /dev/null
> > +++ b/tools/testing/selftests/rtc/property/rtc-alarm-test.sh
> > @@ -0,0 +1,27 @@
> > +#!/bin/bash
> > +# SPDX-License-Identifier: GPL-2.0
> > +
> > +if [ ! -f /proc/driver/rtc ]; then
> > + echo "SKIP: the /proc/driver/rtc is empty."
> > + exit 4
> > +fi
> > +
> > +# Check if could find alarm content in /proc/driver/rtc according to
> > +# the rtc wakealarm is supported or not.
> > +if [ -n "$(ls /sys/class/rtc/rtc* | grep -i wakealarm)" ]; then
> > + if [ -n "$(grep -i alarm /proc/driver/rtc)" ]; then
> > + exit 0
> > + else
> > + echo "ERROR: The alarm content is not found."
> > + cat /proc/driver/rtc
> > + exit 1
> > + fi
> > +else
> > + if [ -n "$(grep -i alarm /proc/driver/rtc)" ]; then
> > + echo "ERROR: The alarm content is found."
> > + cat /proc/driver/rtc
> > + exit 1
> > + else
> > + exit 0
> > + fi
> > +fi
> > --
> > 2.34.1
> >
>
> --
> Alexandre Belloni, co-owner and COO, Bootlin
> Embedded Linux and Kernel engineering
>
In order to make sure SET/GET WAKEUP services as optional patch has been
integrated correctly, we have created a shell script to validate
/proc/driver/rtc when it is not empty and then check the absence of alarm
content in RTC metadata according to the rtc wakealarm is supported or not.
Joseph Jang (1):
selftest: rtc: Add support rtc alarm content check
tools/testing/selftests/Makefile | 1 +
tools/testing/selftests/rtc/property/Makefile | 5 ++++
.../selftests/rtc/property/rtc-alarm-test.sh | 27 +++++++++++++++++++
3 files changed, 33 insertions(+)
create mode 100644 tools/testing/selftests/rtc/property/Makefile
create mode 100755 tools/testing/selftests/rtc/property/rtc-alarm-test.sh
--
2.34.1
From: Jeff Xu <jeffxu(a)chromium.org>
This is followup on arm build failure reported by
Ryan Roberts [1]
I don't have right setup to repro the issue, so would need some
help to verify this in arm build.
[1] https://lore.kernel.org/lkml/f797fbde-ffb7-44b0-8af6-4ed2ec47eac1@arm.com/
Jeff Xu (1):
selftest mm/mseal: fix arm build
tools/testing/selftests/mm/mseal_test.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--
2.45.0.rc1.225.g2a3ae87e7f-goog
Hi,
As reported by Kernel Test Robot [1], some pidfd tests fail. This is
due to the use of vfork() which introduced some side effects.
Similarly, while making it more generic, a previous commit made some
Landlock file system tests flaky, and subject to the host's file system
mount configuration.
This series fixes all these side effects by replacing vfork() with
clone3() and CLONE_VFORK, which is cleaner (no arbitrary shared memory)
and makes the Kselftest framework more robust.
I tried different approaches and I found this one to be the cleaner and
less invasive for current test cases.
This fourth series add a patch from Sean Christopherson that fixes KVM
tests.
I successfully ran the following tests (using TEST_F and
fork/clone/clone3) with this series:
- landlock:fs_test
- landlock:net_test
- landlock:ptrace_test
- move_mount_set_group:move_mount_set_group_test
- net/af_unix:scm_pidfd
- perf_events:remove_on_exec
- pidfd:pidfd_getfd_test
- pidfd:pidfd_setns_test
- seccomp:seccomp_bpf
- user_events:abi_test
[1] https://lore.kernel.org/oe-lkp/202403291015.1fcfa957-oliver.sang@intel.com
Previous versions:
v1: https://lore.kernel.org/r/20240426172252.1862930-1-mic@digikod.net
v2: https://lore.kernel.org/r/20240429130931.2394118-1-mic@digikod.net
v3: https://lore.kernel.org/r/20240429191911.2552580-1-mic@digikod.net
Regards,
Mickaël Salaün (10):
selftests/pidfd: Fix config for pidfd_setns_test
selftests/landlock: Fix FS tests when run on a private mount point
selftests/harness: Fix fixture teardown
selftests/harness: Fix interleaved scheduling leading to race
conditions
selftests/landlock: Do not allocate memory in fixture data
selftests/harness: Constify fixture variants
selftests/pidfd: Fix wrong expectation
selftests/harness: Share _metadata between forked processes
selftests/harness: Fix vfork() side effects
selftests/harness: Fix TEST_F()'s exit codes
tools/testing/selftests/kselftest_harness.h | 123 +++++++++++++-----
tools/testing/selftests/landlock/fs_test.c | 83 +++++++-----
tools/testing/selftests/pidfd/config | 2 +
.../selftests/pidfd/pidfd_setns_test.c | 2 +-
4 files changed, 141 insertions(+), 69 deletions(-)
base-commit: e67572cd2204894179d89bd7b984072f19313b03
--
2.45.0
First of all, in order to build with clang at all, one must first apply
Valentin Obst's build fix for LLVM [1]. Once that is done, then when
building with clang, via:
make LLVM=1 -C tools/testing/selftests
...there are several warnings, and an error. This fixes all of those and
allows these tests to run and pass.
1. Fix linker error (undefined reference to memcpy) by providing a local
version of memcpy.
2. clang complains about using this form:
if (g = h & 0xf0000000)
...so factor out the assignment into a separate step.
3. The code is passing a signed const char* to elf_hash(), which expects
a const unsigned char *. There are several callers, so fix this at
the source by allowing the function to accept a signed argument, and
then converting to unsigned operations, once inside the function.
4. clang doesn't have __attribute__((externally_visible)) and generates
a warning to that effect. Fortunately, gcc 12 and gcc 13 do not seem
to require that attribute in order to build, run and pass tests here,
so remove it.
[1] https://lore.kernel.org/all/20240329-selftests-libmk-llvm-rfc-v1-1-2f9ed7d1…
Signed-off-by: John Hubbard <jhubbard(a)nvidia.com>
---
tools/testing/selftests/vDSO/parse_vdso.c | 16 +++++++++++-----
.../selftests/vDSO/vdso_standalone_test_x86.c | 18 ++++++++++++++++--
2 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/tools/testing/selftests/vDSO/parse_vdso.c b/tools/testing/selftests/vDSO/parse_vdso.c
index 413f75620a35..4ae417372e9e 100644
--- a/tools/testing/selftests/vDSO/parse_vdso.c
+++ b/tools/testing/selftests/vDSO/parse_vdso.c
@@ -55,14 +55,20 @@ static struct vdso_info
ELF(Verdef) *verdef;
} vdso_info;
-/* Straight from the ELF specification. */
-static unsigned long elf_hash(const unsigned char *name)
+/*
+ * Straight from the ELF specification...and then tweaked slightly, in order to
+ * avoid a few clang warnings.
+ */
+static unsigned long elf_hash(const char *name)
{
unsigned long h = 0, g;
- while (*name)
+ const unsigned char *uch_name = (const unsigned char *)name;
+
+ while (*uch_name)
{
- h = (h << 4) + *name++;
- if (g = h & 0xf0000000)
+ h = (h << 4) + *uch_name++;
+ g = h & 0xf0000000;
+ if (g)
h ^= g >> 24;
h &= ~g;
}
diff --git a/tools/testing/selftests/vDSO/vdso_standalone_test_x86.c b/tools/testing/selftests/vDSO/vdso_standalone_test_x86.c
index 8a44ff973ee1..27f6fdf11969 100644
--- a/tools/testing/selftests/vDSO/vdso_standalone_test_x86.c
+++ b/tools/testing/selftests/vDSO/vdso_standalone_test_x86.c
@@ -18,7 +18,7 @@
#include "parse_vdso.h"
-/* We need a libc functions... */
+/* We need some libc functions... */
int strcmp(const char *a, const char *b)
{
/* This implementation is buggy: it never returns -1. */
@@ -34,6 +34,20 @@ int strcmp(const char *a, const char *b)
return 0;
}
+/*
+ * The clang build needs this, although gcc does not.
+ * Stolen from lib/string.c.
+ */
+void *memcpy(void *dest, const void *src, size_t count)
+{
+ char *tmp = dest;
+ const char *s = src;
+
+ while (count--)
+ *tmp++ = *s++;
+ return dest;
+}
+
/* ...and two syscalls. This is x86-specific. */
static inline long x86_syscall3(long nr, long a0, long a1, long a2)
{
@@ -70,7 +84,7 @@ void to_base10(char *lastdig, time_t n)
}
}
-__attribute__((externally_visible)) void c_main(void **stack)
+void c_main(void **stack)
{
/* Parse the stack */
long argc = (long)*stack;
base-commit: f03359bca01bf4372cf2c118cd9a987a5951b1c8
prerequisite-patch-id: b901ece2a5b78503e2fb5480f20e304d36a0ea27
--
2.45.0
Hi,
Just a bunch of build and warnings fixes that show up when
building with clang. Some of these depend on each other, so
I'm sending them as a series.
Enjoy!
thanks,
John Hubbard
John Hubbard (7):
selftests/x86: fix Makefile dependencies to work with clang
selftests/x86: build test_FISTTP.c with clang
selftests/x86: build fsgsbase_restore.c with clang
selftests/x86: build sysret_rip.c with clang
selftests/x86: avoid -no-pie warnings from clang during compilation
selftests/x86: remove (or use) unused variables and functions
selftests/x86: fix printk() format warnings
tools/testing/selftests/x86/Makefile | 31 +++++++++++++++----
tools/testing/selftests/x86/amx.c | 16 ----------
.../testing/selftests/x86/clang_helpers_32.S | 11 +++++++
.../testing/selftests/x86/clang_helpers_64.S | 28 +++++++++++++++++
tools/testing/selftests/x86/fsgsbase.c | 6 ----
.../testing/selftests/x86/fsgsbase_restore.c | 11 +++----
tools/testing/selftests/x86/sigreturn.c | 2 +-
.../testing/selftests/x86/syscall_arg_fault.c | 1 -
tools/testing/selftests/x86/sysret_rip.c | 20 ++++--------
tools/testing/selftests/x86/test_FISTTP.c | 8 ++---
tools/testing/selftests/x86/test_vsyscall.c | 15 +++------
tools/testing/selftests/x86/vdso_restorer.c | 2 ++
12 files changed, 87 insertions(+), 64 deletions(-)
create mode 100644 tools/testing/selftests/x86/clang_helpers_32.S
create mode 100644 tools/testing/selftests/x86/clang_helpers_64.S
base-commit: f03359bca01bf4372cf2c118cd9a987a5951b1c8
prerequisite-patch-id: b901ece2a5b78503e2fb5480f20e304d36a0ea27
--
2.45.0
From: Willem de Bruijn <willemb(a)google.com>
Detect packets with ip_summed CHECKSUM_PARTIAL and skip these. These
should not exist, as the test sends individual packets between two
hosts. But if (HW) GRO is on, with randomized content sometimes
subsequent packets can be coalesced.
In this case the GSO packet checksum is converted to a pseudo checksum
in anticipation of sending out as TSO/USO. So the field will not match
the expected value.
Do not count these as test errors.
Signed-off-by: Willem de Bruijn <willemb(a)google.com>
---
tools/testing/selftests/net/csum.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/net/csum.c b/tools/testing/selftests/net/csum.c
index 90eb06fefa59..b9f3fc3c3426 100644
--- a/tools/testing/selftests/net/csum.c
+++ b/tools/testing/selftests/net/csum.c
@@ -682,7 +682,7 @@ static int recv_verify_packet_ipv6(void *nh, int len)
}
/* return whether auxdata includes TP_STATUS_CSUM_VALID */
-static bool recv_verify_packet_csum(struct msghdr *msg)
+static uint32_t recv_get_packet_csum_status(struct msghdr *msg)
{
struct tpacket_auxdata *aux = NULL;
struct cmsghdr *cm;
@@ -706,7 +706,7 @@ static bool recv_verify_packet_csum(struct msghdr *msg)
if (!aux)
error(1, 0, "cmsg: no auxdata");
- return aux->tp_status & TP_STATUS_CSUM_VALID;
+ return aux->tp_status;
}
static int recv_packet(int fd)
@@ -716,6 +716,7 @@ static int recv_packet(int fd)
char ctrl[CMSG_SPACE(sizeof(struct tpacket_auxdata))];
struct pkt *buf = (void *)_buf;
struct msghdr msg = {0};
+ uint32_t tp_status;
struct iovec iov;
int len, ret;
@@ -737,6 +738,17 @@ static int recv_packet(int fd)
if (len == -1)
error(1, errno, "recv p");
+ tp_status = recv_get_packet_csum_status(&msg);
+
+ /* GRO might coalesce randomized packets. Such GSO packets are
+ * then reinitialized for csum offload (CHECKSUM_PARTIAL), with
+ * a pseudo csum. Do not try to validate these checksums.
+ */
+ if (tp_status & TP_STATUS_CSUMNOTREADY) {
+ fprintf(stderr, "cmsg: GSO packet has partial csum: skip\n");
+ continue;
+ }
+
if (cfg_family == PF_INET6)
ret = recv_verify_packet_ipv6(buf, len);
else
@@ -753,7 +765,7 @@ static int recv_packet(int fd)
* Do not fail if kernel does not validate a good csum:
* Absence of validation does not imply invalid.
*/
- if (recv_verify_packet_csum(&msg) && cfg_bad_csum) {
+ if (tp_status & TP_STATUS_CSUM_VALID && cfg_bad_csum) {
fprintf(stderr, "cmsg: expected bad csum, pf_packet returns valid\n");
bad_validations++;
}
--
2.45.0.rc1.225.g2a3ae87e7f-goog