From nobody Fri Nov 29 03:51:12 2024 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 31F4818B47B for ; Wed, 25 Sep 2024 15:02:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727276534; cv=none; b=Xip7LmexPjcabatQUvSnbYdIgR6/hGbpr0qCrX+4DlzPonSrDKi8fC7c/fLRrR/N1K3+ttUQqDvz+VfPGGIIELy20/Q3YNXg2khNc+Ww87XEt3Ayv3ehqUOotlQhMM7KEkJHmqLAuNKHSHGVznfV1I+ed7S9qW8OGFTRvtQwBEg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727276534; c=relaxed/simple; bh=uNZCRc4hsOOw5KhJ4tKlrDfm3UOmHFTj64isJZp8vsM=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=X09OuDCWFAlCR/D9HyW1R4y3sDDH3kqR3iJbkkOyaTRJ/661jGGhNJ1B3KvH80ycsFRhXXItF52k9eiYtQsSYufcXK+4cP2VwgVOs0jDgHTGyEh327u24jiScFQy7c/qmdj4/kKQuupIG4e2WeUO2d13naXKewAAdJ+nUdgEVFM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--ardb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=nxIGCpWp; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--ardb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="nxIGCpWp" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-690404fd230so104536047b3.3 for ; Wed, 25 Sep 2024 08:02:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1727276531; x=1727881331; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=lvBkJLcu5Sh3tnaE09NAZ6RZ9jqQeWc/oMvpiTXt3OQ=; b=nxIGCpWpXQtkzmZiT2xfm0JG0meclpO7fqtIS0vMPy6/xl9EzqqYQnCgItcc+41Ho1 sjXfycWXVDoJqWLb11VdvwsyfdYc4/6Y1LVocPC7AgWPDt4c93eMeMO7WlVPc81rLKyt Bof+HPEac3AeEo0dMHaQKjQDsT/bmtj2U4oWOQT9lh06ucxFU6fD62ramLaHiEgddcM4 j00atvuxOQf6JP2FD1ZlGGDRufRCCfOh34vPUrqcs4CXHdtvl4MKLtis3FK36myPwdoO uYjpx76fjwEgiSQdW4U0m4Zx0tXJCKo4tcc4NfZPtiTe5M8Utxlotp7ZlWdIJveDdAhg 08aQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727276531; x=1727881331; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=lvBkJLcu5Sh3tnaE09NAZ6RZ9jqQeWc/oMvpiTXt3OQ=; b=u/TdXX8FMGHnU5zno2vGqcIdZFrReo/Isg4TCkW2NpBi8XhpuGwLqjlNotEpXfWu5U f3affI+vYGRixPESlOCeRn7HOyK6SRcDsw9McV8Qdm4YXb6c2EwVbP1zUe8tGHecr9Vg xClrHGWHzLVboMg9j/TGG9QbXnA0iac0zK+ZdPbaFXYQ42ue/Djj/VuwYgXdIeWMDo6o GhaaRD+TsgP69nM5q70z2aWZWhXCXw3UnXL6fikwOGxiDcFtPRr++IGS018W0TwHGFbq yfhVBKQrnkCblzLrATecKxidavZejQD1jvEIbWj77S4TPJ1GykbuX7LQJQEG9AXWYe1z nu9w== X-Gm-Message-State: AOJu0YwVIlqvRENqA2p/bijGijlQ/apI3xbFBZrjzZpHeuYBo+PSvCDb MBRdZBF/dknjeK5eexXHp3N5KNoAIM6TS07oO31h92TxWN5MoGXERnO1l7Ux2869aw/lLcgOdKU teAh8HXhfJSi5nsNlfwLHLub2ZutvT9FVh9BsPBwOyUqQ3Qm8OTRQcDZCEfWeUCnbuu+KuMILgN S1fynkUjAv4ULLUuftBOLS4Um+p7huqQ== X-Google-Smtp-Source: AGHT+IENPFDDE4RBTdISjbf4G4pk2mGOjzo8FmXYzCFJ7WDt9ZFnIbiw80yVnuCNeltTBlMkQAqf4tvt X-Received: from palermo.c.googlers.com ([fda3:e722:ac3:cc00:7b:198d:ac11:8138]) (user=ardb job=sendgmr) by 2002:a05:690c:c9c:b0:6b0:d571:3540 with SMTP id 00721157ae682-6e21da796e6mr255067b3.6.1727276529787; Wed, 25 Sep 2024 08:02:09 -0700 (PDT) Date: Wed, 25 Sep 2024 17:01:08 +0200 In-Reply-To: <20240925150059.3955569-30-ardb+git@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240925150059.3955569-30-ardb+git@google.com> X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-Developer-Signature: v=1; a=openpgp-sha256; l=6334; i=ardb@kernel.org; h=from:subject; bh=rOkV7b1W8gqAvLsLoQ2i9zRn35wAefNGZsd9tIotAWg=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JIe2L6vYGW5mupTcMu0+/lmvg/R+5wEt4Wbk5z8ydQtZqX U8bN7/vKGVhEONgkBVTZBGY/ffdztMTpWqdZ8nCzGFlAhnCwMUpABO5Lc3wP3L7HcnzmyvvZR1M rS85onToQ4R+5Y7wJefSbJaqGNxXYmVkaHXklA3NNHruJrHYtjJMvdzeSUx0wZXnutnTlvEcNXD iBAA= X-Mailer: git-send-email 2.46.0.792.g87dc391469-goog Message-ID: <20240925150059.3955569-38-ardb+git@google.com> Subject: [RFC PATCH 08/28] scripts/kallsyms: Remove support for absolute per-CPU variables From: Ard Biesheuvel To: linux-kernel@vger.kernel.org Cc: Ard Biesheuvel , x86@kernel.org, "H. Peter Anvin" , Andy Lutomirski , Peter Zijlstra , Uros Bizjak , Dennis Zhou , Tejun Heo , Christoph Lameter , Mathieu Desnoyers , Paolo Bonzini , Vitaly Kuznetsov , Juergen Gross , Boris Ostrovsky , Greg Kroah-Hartman , Arnd Bergmann , Masahiro Yamada , Kees Cook , Nathan Chancellor , Keith Packard , Justin Stitt , Josh Poimboeuf , Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , linux-doc@vger.kernel.org, linux-pm@vger.kernel.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org, linux-efi@vger.kernel.org, linux-arch@vger.kernel.org, linux-sparse@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-perf-users@vger.kernel.org, rust-for-linux@vger.kernel.org, llvm@lists.linux.dev Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Ard Biesheuvel SMP on x86_64 no longer needs absolute per-CPU variables, so this support can be dropped from kallsyms as well, as no other architectures rely on this functionality. Signed-off-by: Ard Biesheuvel --- init/Kconfig | 4 -- kernel/kallsyms.c | 12 +---- scripts/kallsyms.c | 51 +++----------------- scripts/link-vmlinux.sh | 4 -- 4 files changed, 9 insertions(+), 62 deletions(-) diff --git a/init/Kconfig b/init/Kconfig index be8a9a786d3c..f6eeba81282d 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1835,10 +1835,6 @@ config KALLSYMS_ALL =20 Say N unless you really need all symbols, or kernel live patching. =20 -config KALLSYMS_ABSOLUTE_PERCPU - bool - depends on KALLSYMS - # end of the "standard kernel features (expert users)" menu =20 config ARCH_HAS_MEMBARRIER_CALLBACKS diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c index a9a0ca605d4a..4198f30aac3c 100644 --- a/kernel/kallsyms.c +++ b/kernel/kallsyms.c @@ -148,16 +148,8 @@ static unsigned int get_symbol_offset(unsigned long po= s) =20 unsigned long kallsyms_sym_address(int idx) { - /* values are unsigned offsets if --absolute-percpu is not in effect */ - if (!IS_ENABLED(CONFIG_KALLSYMS_ABSOLUTE_PERCPU)) - return kallsyms_relative_base + (u32)kallsyms_offsets[idx]; - - /* ...otherwise, positive offsets are absolute values */ - if (kallsyms_offsets[idx] >=3D 0) - return kallsyms_offsets[idx]; - - /* ...and negative offsets are relative to kallsyms_relative_base - 1 */ - return kallsyms_relative_base - 1 - kallsyms_offsets[idx]; + /* values are unsigned offsets */ + return kallsyms_relative_base + (u32)kallsyms_offsets[idx]; } =20 static unsigned int get_symbol_seq(int index) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 09757d300a05..9c34b9397872 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -5,7 +5,7 @@ * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * - * Usage: kallsyms [--all-symbols] [--absolute-percpu] in.map > out.S + * Usage: kallsyms [--all-symbols] in.map > out.S * * Table compression uses all the unused char codes on the symbols and * maps these to the most used substrings (tokens). For instance, it might @@ -37,7 +37,6 @@ struct sym_entry { unsigned long long addr; unsigned int len; unsigned int seq; - bool percpu_absolute; unsigned char sym[]; }; =20 @@ -62,7 +61,6 @@ static struct addr_range percpu_range =3D { static struct sym_entry **table; static unsigned int table_size, table_cnt; static int all_symbols; -static int absolute_percpu; =20 static int token_profit[0x10000]; =20 @@ -73,7 +71,7 @@ static unsigned char best_table_len[256]; =20 static void usage(void) { - fprintf(stderr, "Usage: kallsyms [--all-symbols] [--absolute-percpu] in.m= ap > out.S\n"); + fprintf(stderr, "Usage: kallsyms [--all-symbols] in.map > out.S\n"); exit(1); } =20 @@ -175,7 +173,6 @@ static struct sym_entry *read_symbol(FILE *in, char **b= uf, size_t *buf_len) sym->len =3D len; sym->sym[0] =3D type; strcpy(sym_name(sym), name); - sym->percpu_absolute =3D false; =20 return sym; } @@ -319,11 +316,6 @@ static int expand_symbol(const unsigned char *data, in= t len, char *result) return total; } =20 -static bool symbol_absolute(const struct sym_entry *s) -{ - return s->percpu_absolute; -} - static int compare_names(const void *a, const void *b) { int ret; @@ -457,20 +449,10 @@ static void write_src(void) long long offset; bool overflow; =20 - if (!absolute_percpu) { - offset =3D table[i]->addr - relative_base; - overflow =3D offset < 0 || offset > UINT_MAX; - } else if (symbol_absolute(table[i])) { - offset =3D table[i]->addr; - overflow =3D offset < 0 || offset > INT_MAX; - } else { - offset =3D relative_base - table[i]->addr - 1; - overflow =3D offset < INT_MIN || offset >=3D 0; - } + offset =3D table[i]->addr - relative_base; + overflow =3D (offset < 0 || offset > UINT_MAX); if (overflow) { - fprintf(stderr, "kallsyms failure: " - "%s symbol value %#llx out of range in relative mode\n", - symbol_absolute(table[i]) ? "absolute" : "relative", + fprintf(stderr, "kallsyms failure: symbol value %#llx out of range\n", table[i]->addr); exit(EXIT_FAILURE); } @@ -725,32 +707,16 @@ static void sort_symbols(void) qsort(table, table_cnt, sizeof(table[0]), compare_symbols); } =20 -static void make_percpus_absolute(void) -{ - unsigned int i; - - for (i =3D 0; i < table_cnt; i++) - if (symbol_in_range(table[i], &percpu_range, 1)) { - /* - * Keep the 'A' override for percpu symbols to - * ensure consistent behavior compared to older - * versions of this tool. - */ - table[i]->sym[0] =3D 'A'; - table[i]->percpu_absolute =3D true; - } -} - /* find the minimum non-absolute symbol address */ static void record_relative_base(void) { unsigned int i; =20 for (i =3D 0; i < table_cnt; i++) - if (table[i]->addr && !symbol_absolute(table[i])) { + if (table[i]->addr) { /* * The table is sorted by address. - * Take the first non-absolute symbol value. + * Take the first non-zero symbol value. */ relative_base =3D table[i]->addr; return; @@ -762,7 +728,6 @@ int main(int argc, char **argv) while (1) { static const struct option long_options[] =3D { {"all-symbols", no_argument, &all_symbols, 1}, - {"absolute-percpu", no_argument, &absolute_percpu, 1}, {}, }; =20 @@ -779,8 +744,6 @@ int main(int argc, char **argv) =20 read_map(argv[optind]); shrink_table(); - if (absolute_percpu) - make_percpus_absolute(); sort_symbols(); record_relative_base(); optimize_token_table(); diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index a9b3f34a78d2..df5f3fbb46f3 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh @@ -140,10 +140,6 @@ kallsyms() kallsymopt=3D"${kallsymopt} --all-symbols" fi =20 - if is_enabled CONFIG_KALLSYMS_ABSOLUTE_PERCPU; then - kallsymopt=3D"${kallsymopt} --absolute-percpu" - fi - info KSYMS "${2}.S" scripts/kallsyms ${kallsymopt} "${1}" > "${2}.S" =20 --=20 2.46.0.792.g87dc391469-goog