--- /dev/null
+Fix broken hashmap implementation to ensure that hash_bits returns value fitting in
+given bits (for bits > 0): multiplier is long long, so shift bits must be based on
+long long, not __WORDSIZE.
+--- linux-5.7/tools/lib/bpf/hashmap.h.orig 2020-06-01 01:49:15.000000000 +0200
++++ linux-5.7/tools/lib/bpf/hashmap.h 2020-06-21 15:22:07.298466419 +0200
+@@ -10,17 +10,12 @@
+
+ #include <stdbool.h>
+ #include <stddef.h>
+-#ifdef __GLIBC__
+-#include <bits/wordsize.h>
+-#else
+-#include <bits/reg.h>
+-#endif
+ #include "libbpf_internal.h"
+
+ static inline size_t hash_bits(size_t h, int bits)
+ {
+ /* shuffle bits and return requested number of upper bits */
+- return (h * 11400714819323198485llu) >> (__WORDSIZE - bits);
++ return (h * 11400714819323198485llu) >> (__SIZEOF_LONG_LONG__ * 8 - bits);
+ }
+
+ typedef size_t (*hashmap_hash_fn)(const void *key, void *ctx);
%undefine with_multilib
%endif
-%define basever 5.6
-%define postver .5
+%define basever 5.7
+%define postver .0
Summary: Assortment of tools for the Linux kernel
Summary(pl.UTF-8): Zestaw narzędzi dla jądra Linuksa
Name: kernel-tools
License: GPL v2
Group: Applications/System
Source0: https://www.kernel.org/pub/linux/kernel/v5.x/linux-%{basever}.tar.xz
-# Source0-md5: 7b9199ec5fa563ece9ed585ffb17798f
+# Source0-md5: f63ed18935914e1ee3e04c2a0ce1ba3b
Source1: cpupower.service
Source2: cpupower.config
%if "%{postver}" != ".0"
Patch2: regex.patch
Patch3: %{name}-perf-update.patch
Patch4: %{name}-perf-gtk2.patch
+Patch5: %{name}-bpf-hashmap.patch
URL: https://www.kernel.org/
BuildRequires: bison
BuildRequires: docutils
%patch2 -p1
%patch3 -p1
%patch4 -p1
+%patch5 -p1
%{__sed} -i -e '/^CFLAGS = /s/ -g / $(OPTFLAGS) /' tools/hv/Makefile
%{__sed} -i -e '/^CFLAGS+=/s/ -O1 / $(OPTFLAGS) /' tools/thermal/tmon/Makefile