If Makefile cannot find any of the vmlinux's in its VMLINUX_BTF_PATHS list,
it tries to run btftool incorrectly, with VMLINUX_BTF unset:
bpftool btf dump file $(VMLINUX_BTF) format c
Such that the keyword 'format' is misinterpreted as the path to vmlinux.
The resulting build error message is fairly cryptic:
GEN vmlinux.h
Error: failed to load BTF from format: No such file or directory
This patch makes the failure reason clearer by yielding this instead:
Makefile:...: *** cannot find a vmlinux for VMLINUX_BTF at any of
"{paths}". Stop.
Fixes: acbd06206bbb ("selftests/bpf: Add vmlinux.h selftest exercising tracing of syscalls")
Cc: stable(a)vger.kernel.org # 5.7+
Signed-off-by: Kamal Mostafa <kamal(a)canonical.com>
---
tools/testing/selftests/bpf/Makefile | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index 542768f5195b..93ed34ef6e3f 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -196,6 +196,9 @@ $(BUILD_DIR)/libbpf $(BUILD_DIR)/bpftool $(BUILD_DIR)/resolve_btfids $(INCLUDE_D
$(INCLUDE_DIR)/vmlinux.h: $(VMLINUX_BTF) | $(BPFTOOL) $(INCLUDE_DIR)
ifeq ($(VMLINUX_H),)
$(call msg,GEN,,$@)
+ifeq ($(VMLINUX_BTF),)
+$(error cannot find a vmlinux for VMLINUX_BTF at any of "$(VMLINUX_BTF_PATHS)")
+endif
$(Q)$(BPFTOOL) btf dump file $(VMLINUX_BTF) format c > $@
else
$(call msg,CP,,$@)
--
2.17.1
The existing code attempted to handle numbers by doing a strto[u]l(),
ignoring the field width, and then bitshifting the field out of the
converted value. If the string contains a run of valid digits longer
than will fit in a long or long long, this would overflow and no amount
of bitshifting can recover the correct value.
This patch fixes vsscanf to obey number field widths when parsing
the number.
A new _parse_integer_limit() is added that takes a limit for the number
of characters to parse. The number field conversion in vsscanf is changed
to use this new function.
The cases of a base prefix or leading '-' that is >= the maximum field
width is handled such that the result of a sccanf is consistent with the
observed behaviour of userland sscanf.
Signed-off-by: Richard Fitzgerald <rf(a)opensource.cirrus.com>
---
lib/kstrtox.c | 13 +++++--
lib/kstrtox.h | 2 ++
lib/vsprintf.c | 93 ++++++++++++++++++++++++++++++--------------------
3 files changed, 68 insertions(+), 40 deletions(-)
diff --git a/lib/kstrtox.c b/lib/kstrtox.c
index a14ccf905055..0ac2ee8bd9d0 100644
--- a/lib/kstrtox.c
+++ b/lib/kstrtox.c
@@ -39,20 +39,22 @@ const char *_parse_integer_fixup_radix(const char *s, unsigned int *base)
/*
* Convert non-negative integer string representation in explicitly given radix
- * to an integer.
+ * to an integer. A maximum of max_chars characters will be converted.
+ *
* Return number of characters consumed maybe or-ed with overflow bit.
* If overflow occurs, result integer (incorrect) is still returned.
*
* Don't you dare use this function.
*/
-unsigned int _parse_integer(const char *s, unsigned int base, unsigned long long *p)
+unsigned int _parse_integer_limit(const char *s, unsigned int base,
+ unsigned long long *p, size_t max_chars)
{
unsigned long long res;
unsigned int rv;
res = 0;
rv = 0;
- while (1) {
+ for (; max_chars > 0; max_chars--) {
unsigned int c = *s;
unsigned int lc = c | 0x20; /* don't tolower() this line */
unsigned int val;
@@ -82,6 +84,11 @@ unsigned int _parse_integer(const char *s, unsigned int base, unsigned long long
return rv;
}
+unsigned int _parse_integer(const char *s, unsigned int base, unsigned long long *p)
+{
+ return _parse_integer_limit(s, base, p, INT_MAX);
+}
+
static int _kstrtoull(const char *s, unsigned int base, unsigned long long *res)
{
unsigned long long _res;
diff --git a/lib/kstrtox.h b/lib/kstrtox.h
index 3b4637bcd254..4c6536f85cac 100644
--- a/lib/kstrtox.h
+++ b/lib/kstrtox.h
@@ -4,6 +4,8 @@
#define KSTRTOX_OVERFLOW (1U << 31)
const char *_parse_integer_fixup_radix(const char *s, unsigned int *base);
+unsigned int _parse_integer_limit(const char *s, unsigned int base,
+ unsigned long long *res, size_t max_chars);
unsigned int _parse_integer(const char *s, unsigned int base, unsigned long long *res);
#endif
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 14c9a6af1b23..21145da468e0 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -53,29 +53,47 @@
#include <linux/string_helpers.h>
#include "kstrtox.h"
-/**
- * simple_strtoull - convert a string to an unsigned long long
- * @cp: The start of the string
- * @endp: A pointer to the end of the parsed string will be placed here
- * @base: The number base to use
- *
- * This function has caveats. Please use kstrtoull instead.
- */
-unsigned long long simple_strtoull(const char *cp, char **endp, unsigned int base)
+static unsigned long long simple_strntoull(const char *startp, size_t max_chars,
+ char **endp, unsigned int base)
{
- unsigned long long result;
+ const char *cp;
+ unsigned long long result = 0ULL;
unsigned int rv;
- cp = _parse_integer_fixup_radix(cp, &base);
- rv = _parse_integer(cp, base, &result);
+ if (max_chars == 0) {
+ cp = startp;
+ goto out;
+ }
+
+ cp = _parse_integer_fixup_radix(startp, &base);
+ if ((cp - startp) >= max_chars) {
+ cp = startp + max_chars;
+ goto out;
+ }
+
+ max_chars -= (cp - startp);
+ rv = _parse_integer_limit(cp, base, &result, max_chars);
/* FIXME */
cp += (rv & ~KSTRTOX_OVERFLOW);
-
+out:
if (endp)
*endp = (char *)cp;
return result;
}
+
+/**
+ * simple_strtoull - convert a string to an unsigned long long
+ * @cp: The start of the string
+ * @endp: A pointer to the end of the parsed string will be placed here
+ * @base: The number base to use
+ *
+ * This function has caveats. Please use kstrtoull instead.
+ */
+unsigned long long simple_strtoull(const char *cp, char **endp, unsigned int base)
+{
+ return simple_strntoull(cp, UINT_MAX, endp, base);
+}
EXPORT_SYMBOL(simple_strtoull);
/**
@@ -88,7 +106,7 @@ EXPORT_SYMBOL(simple_strtoull);
*/
unsigned long simple_strtoul(const char *cp, char **endp, unsigned int base)
{
- return simple_strtoull(cp, endp, base);
+ return simple_strntoull(cp, UINT_MAX, endp, base);
}
EXPORT_SYMBOL(simple_strtoul);
@@ -109,6 +127,19 @@ long simple_strtol(const char *cp, char **endp, unsigned int base)
}
EXPORT_SYMBOL(simple_strtol);
+static long long simple_strntoll(const char *cp, size_t max_chars, char **endp,
+ unsigned int base)
+{
+ /*
+ * simple_strntoull safely handles receiving max_chars==0 in the
+ * case we start with max_chars==1 and find a '-' prefix.
+ */
+ if (*cp == '-' && max_chars > 0)
+ return -simple_strntoull(cp + 1, max_chars - 1, endp, base);
+
+ return simple_strntoull(cp, max_chars, endp, base);
+}
+
/**
* simple_strtoll - convert a string to a signed long long
* @cp: The start of the string
@@ -119,10 +150,7 @@ EXPORT_SYMBOL(simple_strtol);
*/
long long simple_strtoll(const char *cp, char **endp, unsigned int base)
{
- if (*cp == '-')
- return -simple_strtoull(cp + 1, endp, base);
-
- return simple_strtoull(cp, endp, base);
+ return simple_strntoll(cp, UINT_MAX, endp, base);
}
EXPORT_SYMBOL(simple_strtoll);
@@ -3433,8 +3461,11 @@ int vsscanf(const char *buf, const char *fmt, va_list args)
str = skip_spaces(str);
digit = *str;
- if (is_sign && digit == '-')
+ if (is_sign && digit == '-') {
+ if (field_width == 1)
+ break;
digit = *(str + 1);
+ }
if (!digit
|| (base == 16 && !isxdigit(digit))
@@ -3444,25 +3475,13 @@ int vsscanf(const char *buf, const char *fmt, va_list args)
break;
if (is_sign)
- val.s = qualifier != 'L' ?
- simple_strtol(str, &next, base) :
- simple_strtoll(str, &next, base);
+ val.s = simple_strntoll(str,
+ field_width > 0 ? field_width : UINT_MAX,
+ &next, base);
else
- val.u = qualifier != 'L' ?
- simple_strtoul(str, &next, base) :
- simple_strtoull(str, &next, base);
-
- if (field_width > 0 && next - str > field_width) {
- if (base == 0)
- _parse_integer_fixup_radix(str, &base);
- while (next - str > field_width) {
- if (is_sign)
- val.s = div_s64(val.s, base);
- else
- val.u = div_u64(val.u, base);
- --next;
- }
- }
+ val.u = simple_strntoull(str,
+ field_width > 0 ? field_width : UINT_MAX,
+ &next, base);
switch (qualifier) {
case 'H': /* that's 'hh' in format */
--
2.20.1
Hi Linus,
Please pull this Kselftest fixes update for Linux 5.11-rc1.
This Kselftest fixes update for Linux 5.11-rc1 consists of build error
fixes for clone3 and rseq tests.
diff is attached.
thanks,
-- Shuah
----------------------------------------------------------------
The following changes since commit 0477e92881850d44910a7e94fc2c46f96faa131f:
Linux 5.10-rc7 (2020-12-06 14:25:12 -0800)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
tags/linux-kselftest-fixes-5.11-rc1
for you to fetch changes up to 88f4ede44c585b24674dd99841040b2a1a856a76:
selftests/clone3: Fix build error (2020-12-07 14:34:55 -0700)
----------------------------------------------------------------
linux-kselftest-fixes-5.11-rc1
This Kselftest fixes update for Linux 5.11-rc1 consists of build error
fixes for clone3 and rseq tests.
----------------------------------------------------------------
Xingxing Su (2):
rseq/selftests: Fix MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ build
error under other arch.
selftests/clone3: Fix build error
tools/testing/selftests/clone3/Makefile | 2 +-
tools/testing/selftests/rseq/param_test.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------
Hi Linus,
Please pull the following Kselftest update for Linux 5.11-rc1.
This kselftest update for Linux 5.11-rc1 consists of:
- Much needed gpio test Makefile cleanup to various problems with
test dependencies and build errors from Michael Ellerman
- Enabling vDSO test on non x86 platforms from Vincenzo Frascino
- Fix intel_pstate to replace deprecated ftime() usages with
clock_gettime() from Tommi Rantala
- cgroup test build fix on older releases from Sachin Sant
- A couple of spelling mistake fixes
diff is attached.
thanks,
-- Shuah
----------------------------------------------------------------
The following changes since commit 3650b228f83adda7e5ee532e2b90429c03f7b9ec:
Linux 5.10-rc1 (2020-10-25 15:14:11 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
tags/linux-kselftest-next-5.11-rc1
for you to fetch changes up to c2e46f6b3e3551558d44c4dc518b9667cb0d5f8b:
selftests/cgroup: Fix build on older distros (2020-11-10 15:13:25 -0700)
----------------------------------------------------------------
linux-kselftest-next-5.11-rc1
This kselftest update for Linux 5.11-rc1 consists of:
- Much needed gpio test Makefile cleanup to various problems with
test dependencies and build errors from Michael Ellerman
- Enabling vDSO test on non x86 platforms from Vincenzo Frascino
- Fix intel_pstate to replace deprecated ftime() usages with
clock_gettime() from Tommi Rantala
- cgroup test build fix on older releases from Sachin Sant
- A couple of spelling mistake fixes
----------------------------------------------------------------
Hangbin Liu (1):
selftests/run_kselftest.sh: fix dry-run typo
Michael Ellerman (5):
selftests/gpio: Use TEST_GEN_PROGS_EXTENDED
selftests/gpio: Move include of lib.mk up
selftests/gpio: Fix build when source tree is read only
selftests/gpio: Add to CLEAN rule rather than overriding
selftests/memfd: Fix implicit declaration warnings
Sachin Sant (1):
selftests/cgroup: Fix build on older distros
Tommi Rantala (1):
selftests: intel_pstate: ftime() is deprecated
Vincenzo Frascino (5):
kselftest: Enable vDSO test on non x86 platforms
kselftest: Extend vDSO selftest
kselftest: Extend vDSO selftest to clock_getres
kselftest: Move test_vdso to the vDSO test suite
kselftest: Extend vdso correctness test to clock_gettime64
Wang Qing (1):
tool: selftests: fix spelling typo of 'writting'
tools/testing/selftests/Makefile | 1 +
tools/testing/selftests/cgroup/cgroup_util.c | 4 +-
tools/testing/selftests/gpio/Makefile | 25 +--
tools/testing/selftests/intel_pstate/aperf.c | 22 +-
tools/testing/selftests/memfd/fuse_test.c | 2 +-
tools/testing/selftests/memfd/memfd_test.c | 2 +-
tools/testing/selftests/run_kselftest.sh | 2 +-
tools/testing/selftests/vDSO/Makefile | 16 +-
tools/testing/selftests/vDSO/vdso_config.h | 92 ++++++++
tools/testing/selftests/vDSO/vdso_test_abi.c | 244
+++++++++++++++++++++
.../selftests/vDSO/vdso_test_clock_getres.c | 124 +++++++++++
.../test_vdso.c => vDSO/vdso_test_correctness.c} | 115 +++++++++-
tools/testing/selftests/vm/userfaultfd.c | 4 +-
tools/testing/selftests/x86/Makefile | 2 +-
14 files changed, 621 insertions(+), 34 deletions(-)
create mode 100644 tools/testing/selftests/vDSO/vdso_config.h
create mode 100644 tools/testing/selftests/vDSO/vdso_test_abi.c
create mode 100644 tools/testing/selftests/vDSO/vdso_test_clock_getres.c
rename tools/testing/selftests/{x86/test_vdso.c =>
vDSO/vdso_test_correctness.c} (73%)
----------------------------------------------------------------
Hi Linus,
Please pull the following KUnit update for Linux 5.11-rc1.
This kunit update for Linux 5.11-rc1 consists of:
-- documentation update and fix to kunit_tool to parse diagnostic
messages correctly from David Gow
-- Support for Parameterized Testing and fs/ext4 test updates to use
KUnit parameterized testing feature from Arpitha Raghunandan
-- Helper to derive file names depending on --build_dir argument
from Andy Shevchenko
Please note that fs/ext4 test change is included in this update
along with the KUnit framework support it depends on.
diff is attached.
thanks,
-- Shuah
----------------------------------------------------------------
The following changes since commit b65054597872ce3aefbc6a666385eabdf9e288da:
Linux 5.10-rc6 (2020-11-29 15:50:50 -0800)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
tags/linux-kselftest-kunit-5.11-rc1
for you to fetch changes up to 5f6b99d0287de2c2d0b5e7abcb0092d553ad804a:
fs: ext4: Modify inode-test.c to use KUnit parameterized testing
feature (2020-12-02 16:07:25 -0700)
----------------------------------------------------------------
linux-kselftest-kunit-5.11-rc1
This kunit update for Linux 5.11-rc1 consists of:
-- documentation update and fix to kunit_tool to parse diagnostic
messages correctly from David Gow
-- Support for Parameterized Testing and fs/ext4 test updates to use
KUnit parameterized testing feature from Arpitha Raghunandan
-- Helper to derive file names depending on --build_dir argument
from Andy Shevchenko
----------------------------------------------------------------
Andy Shevchenko (1):
kunit: Introduce get_file_path() helper
Arpitha Raghunandan (2):
kunit: Support for Parameterized Testing
fs: ext4: Modify inode-test.c to use KUnit parameterized testing
feature
Daniel Latypov (1):
Documentation: kunit: provide guidance for testing many inputs
David Gow (1):
kunit: kunit_tool: Correctly parse diagnostic messages
Documentation/dev-tools/kunit/usage.rst | 83 ++++++++-
fs/ext4/inode-test.c | 320
++++++++++++++++----------------
include/kunit/test.h | 51 +++++
lib/kunit/test.c | 59 ++++--
tools/testing/kunit/kunit_kernel.py | 24 +--
tools/testing/kunit/kunit_parser.py | 7 +-
6 files changed, 351 insertions(+), 193 deletions(-)
----------------------------------------------------------------
hello,
i have worked on to fix depreciated api issue from
tools/testing/selftests/intel_pstate/aerf.c
i met with the following error related...
--------------x------------------x----------------->
$pwd
/home/jeffrin/UP/linux-kselftest/tools/testing/selftests/intel_pstate
$make
gcc -Wall -D_GNU_SOURCE aperf.c /home/jeffrin/UP/linux-
kselftest/tools/testing/selftests/kselftest_harness.h
/home/jeffrin/UP/linux-kselftest/tools/testing/selftests/kselftest.h -
lm -o /home/jeffrin/UP/linux-
kselftest/tools/testing/selftests/intel_pstate/aperf
aperf.c: In function ‘main’:
aperf.c:58:2: warning: ‘ftime’ is deprecated [-Wdeprecated-
declarations]
58 | ftime(&before);
| ^~~~~
In file included from aperf.c:9:
/usr/include/x86_64-linux-gnu/sys/timeb.h:39:12: note: declared here
39 | extern int ftime (struct timeb *__timebuf)
| ^~~~~
aperf.c:67:2: warning: ‘ftime’ is deprecated [-Wdeprecated-
declarations]
67 | ftime(&after);
| ^~~~~
In file included from aperf.c:9:
/usr/include/x86_64-linux-gnu/sys/timeb.h:39:12: note: declared here
39 | extern int ftime (struct timeb *__timebuf)
| ^~~~~
$
----------------x---------------x---------------------->
from ftime manual i found that it is depreciated...
This function is deprecated, and will be removed in a future version
of the GNU C library. Use clock_gettime(2) instead.
now clock_gettime gives new data structure.
struct timespec {
time_t tv_sec; /* seconds */
long tv_nsec; /* nanoseconds */
};
i worked on with the new data structure and some errors that came
along.
typical final output looks good but values of runtime and typical
frequency
does not look normal during "sudo bash run.sh".
output of "git diff" and a portion of output of "sudo bash run.sh".
is attached.
--
software engineer
rajagiri school of engineering and technology - autonomous
Hi!
This is the second version of the work to make TSC migration more accurate,
as was defined by Paulo at:
https://www.spinics.net/lists/kvm/msg225525.html
I omitted most of the semi-offtopic points I raised related to TSC
in the previous RFC where we can continue the discussion.
I do want to raise another thing that I almost forgot.
On AMD systems, the Linux kernel will mark the guest tsc as
unstable unless invtsc is set which is set on recent AMD
hardware.
Take a look at 'unsynchronized_tsc()' to verify this.
This is another thing that IMHO should be fixed at least when
running under KVM.
Note that I forgot to mention that
X86_FEATURE_TSC_RELIABLE also short-circuits this code,
thus giving another reason to enable it under KVM.
Changes from V1:
- added KVM_TSC_STATE_TIMESTAMP_VALID instead of testing ns == 0
- allow diff < 0, because it is still better that capping it to 0
- updated tsc_msr_test unit test to cover this feature
- refactoring
Patches to enable this feature in qemu are in the process of
being sent to qemu-devel mailing list.
Best regards,
Maxim Levitsky
Maxim Levitsky (3):
KVM: x86: implement KVM_{GET|SET}_TSC_STATE
KVM: x86: introduce KVM_X86_QUIRK_TSC_HOST_ACCESS
kvm/selftests: update tsc_msrs_test to cover
KVM_X86_QUIRK_TSC_HOST_ACCESS
Documentation/virt/kvm/api.rst | 65 +++++++++++++
arch/x86/include/uapi/asm/kvm.h | 1 +
arch/x86/kvm/x86.c | 92 ++++++++++++++++++-
include/uapi/linux/kvm.h | 15 +++
.../selftests/kvm/x86_64/tsc_msrs_test.c | 79 ++++++++++++++--
5 files changed, 237 insertions(+), 15 deletions(-)
--
2.26.2
The cleanup function in this script that tries to delete hv-1 / hv-2
vm-1 / vm-2 netns will generate some uncessary error messages:
Cannot remove namespace file "/run/netns/hv-2": No such file or directory
Cannot remove namespace file "/run/netns/vm-1": No such file or directory
Cannot remove namespace file "/run/netns/vm-2": No such file or directory
Redirect it to /dev/null like other commands in the cleanup function
to reduce confusion.
Signed-off-by: Po-Hsu Lin <po-hsu.lin(a)canonical.com>
---
tools/testing/selftests/net/test_vxlan_under_vrf.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/net/test_vxlan_under_vrf.sh b/tools/testing/selftests/net/test_vxlan_under_vrf.sh
index 09f9ed9..534c8b7 100755
--- a/tools/testing/selftests/net/test_vxlan_under_vrf.sh
+++ b/tools/testing/selftests/net/test_vxlan_under_vrf.sh
@@ -50,7 +50,7 @@ cleanup() {
ip link del veth-tap 2>/dev/null || true
for ns in hv-1 hv-2 vm-1 vm-2; do
- ip netns del $ns || true
+ ip netns del $ns 2>/dev/null || true
done
}
--
2.7.4