From nobody Mon Nov 25 03:39:55 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 4BF6970804 for ; Sat, 23 Nov 2024 02:42:23 +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=1732329745; cv=none; b=dyKPbtMXJ296rFbhzYyuZmXu6czruoO5sjZcXv4NmMTlNicgf+cf3qX3reGK7MRmZyggPh/CoRtmKsma5fPOb5gdqOKK1n8xNB/2OlvJapuOMzBP28RnhssNjZn70nNPp6lObQdjr2u91IpomZgrDZiyJX2VrUtsKRTZEBsthw8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732329745; c=relaxed/simple; bh=E70cW8Xw5ro15xoETh9JVhOPG/66AkkqX42fR6dpKnU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Vkf17I2yHsb0XNvurRcBJqD14/raHE0ouBkpfm2N2DqXNpUInedFnRK/FtqMBa77s7TcdrQgV4OmzkimBluWpaA41XdksAPM+PLnOUMRszbibRBVnY9oXgqeJaUyqS4cerPt+2XPX5qajRRAU1aMMkritG3PWl9lLRjQoEhg3cg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--mmaurer.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=iBlWZlT1; 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--mmaurer.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="iBlWZlT1" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6eedb7b9455so33147317b3.0 for ; Fri, 22 Nov 2024 18:42:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1732329742; x=1732934542; 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=qjZqp4IoL0KyqiTVwJH117KupI+sKpsSnEXGEf7A6k8=; b=iBlWZlT1K3bF85XreVwu8AHanu5rDlSBbuP9RdWD4b9cuUYG86llR8YTycHt7/cw3J y+7KlHhvmScfCF5xrd16aCr/B17t7mN+0rfQR+imXmS7FgOWXDrnV8QmVtb6xPuk7FcC tjjSJdKcqQpVMlCY1cJL9yo6Os2+CvwsUi+NoosFXjR7lpnixpIFTs7LTqxsYGJkdllW VINVpHnuOX93nLAKIq/zW4xoJFqYnYhlwJz9IAOXNHxaK9V3M8xtxzWIEDM6Eh1elEYH 0myNU1wR7Oyo40TkJf1n3Bwsqih73HC3dKNKyHwOK5LJ15DZz5pv/f+R17o2+aPDXC8q 4bVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732329742; x=1732934542; 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=qjZqp4IoL0KyqiTVwJH117KupI+sKpsSnEXGEf7A6k8=; b=A4OyfhzwQR6dzGpCz2gyv/S+S84c+Zbzw5x0umFLy48N4eOfCYlKvNGafzPz7mrDkl Q3cn+c6mLZDl8eYH/xAYpBfxKNM7AalC1UZjZmIoV+pzfb6le2MyTG4318AHoG/gh0g/ YeJ+PVMKAULTSOHAbZVnP/SHHoX9Nld90zk/e3Twu6nD6rlk77rxTdrBMhqJ4jTF5cd+ kel8qjboFF0Y6ZN774rpyNuHi0P1O0VNic8indCg0nyGarF3oAodtn/O3yqrkglNDJqR RWgxaQt85MTwpb25HhQLALWYLAqZVwK9IUycMuGmZB12xp1nUBfh2vUPNsrHaaZFSATr SqyA== X-Forwarded-Encrypted: i=1; AJvYcCWhpQIyjGkWhwKDqoqp3xR3QSlXLwYl7V2asmRkqgMYG4NEvqcdAYPFWzsismlINi3dJpdiVKL46ekbBRg=@vger.kernel.org X-Gm-Message-State: AOJu0YxjLWfmHSJ0zTtmYzF2vqkRkX753GRxRNB/FDVwoDGh8dUP7nDv 00RB6TajP3mizng/dKT5gWwlN4c/85H8DygmuI4tu0AdZTiXi1WYjEK9jaij9JCVpwb2+xLbgx4 M/AOeag== X-Google-Smtp-Source: AGHT+IEYfeF7tWWhEOHN9DEuYSPktxzlkbMWxVRw/ZgbuKKnn0fgAzmvVNJdek/aWY1ojtQn6DCYmI3h6IPQ X-Received: from anyblade.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:1791]) (user=mmaurer job=sendgmr) by 2002:a05:690c:2e90:b0:6e3:f32:5fc8 with SMTP id 00721157ae682-6eee089340fmr281427b3.1.1732329742509; Fri, 22 Nov 2024 18:42:22 -0800 (PST) Date: Sat, 23 Nov 2024 02:42:17 +0000 In-Reply-To: <20241123-extended-modversions-v10-0-0fa754ffdee3@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241123-extended-modversions-v10-0-0fa754ffdee3@google.com> X-Mailer: b4 0.15-dev Message-ID: <20241123-extended-modversions-v10-3-0fa754ffdee3@google.com> Subject: [PATCH v10 3/5] modules: Allow extended modversions without basic MODVERSIONS From: Matthew Maurer To: Michael Ellerman , Nicholas Piggin , Christophe Leroy , Naveen N Rao , Madhavan Srinivasan , Luis Chamberlain , Petr Pavlu , Sami Tolvanen , Daniel Gomez , Masahiro Yamada , Nathan Chancellor , Nicolas Schier , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , "=?utf-8?q?Bj=C3=B6rn_Roy_Baron?=" , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Jonathan Corbet Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, linux-kbuild@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-doc@vger.kernel.org, Matthew Maurer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable If you know that your kernel modules will only ever be loaded by a newer kernel, you can disable BASIC_MODVERSIONS to save space. This also allows easy creation of test modules to seee how tooling will respond to modules that only have the new format. Signed-off-by: Matthew Maurer --- kernel/module/Kconfig | 15 +++++++++++++++ scripts/Makefile.modpost | 1 + scripts/mod/modpost.c | 19 +++++++++++-------- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/kernel/module/Kconfig b/kernel/module/Kconfig index a31c617cd67d3d66b24d2fba34cbd5cc9c53ab78..35545bc1d96016f95fe4e95e887= 6159a4a4d616d 100644 --- a/kernel/module/Kconfig +++ b/kernel/module/Kconfig @@ -218,6 +218,21 @@ config EXTENDED_MODVERSIONS The most likely reason you would enable this is to enable Rust support. If unsure, say N. =20 +config BASIC_MODVERSIONS + bool "Basic Module Versioning Support" + depends on MODVERSIONS + default MODVERSIONS + help + This enables basic MODVERSIONS support, allowing older tools or + kernels to potentially load modules. + + Disabling this may cause older `modprobe` or `kmod` to be unable + to read MODVERSIONS information from built modules. With this + disabled, older kernels may treat this module as unversioned. + + This is enabled by default when MODVERSIONS are enabled. + If unsure, say Y. + config MODULE_SRCVERSION_ALL bool "Source checksum for all modules" help diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 40426fc6350985780c0092beb49c6cc29b9eff62..d7d45067d08b94a82451d66a64e= ae29b6826e139 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -43,6 +43,7 @@ MODPOST =3D $(objtree)/scripts/mod/modpost modpost-args =3D \ $(if $(CONFIG_MODULES),-M) \ $(if $(CONFIG_MODVERSIONS),-m) \ + $(if $(CONFIG_BASIC_MODVERSIONS),-b) \ $(if $(CONFIG_EXTENDED_MODVERSIONS),-x) \ $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a) \ $(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \ diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index bd38f33fd41fbd98bce34f8924b2fb0ac04297ee..ed52f9aa45a490bba706ffb2caa= 3e238e4697814 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -32,6 +32,8 @@ static bool module_enabled; static bool modversions; /* Is CONFIG_MODULE_SRCVERSION_ALL set? */ static bool all_versions; +/* Is CONFIG_BASIC_MODVERSIONS set? */ +static bool basic_modversions; /* Is CONFIG_EXTENDED_MODVERSIONS set? */ static bool extended_modversions; /* If we are modposting external module set to 1 */ @@ -1836,10 +1838,8 @@ static void add_extended_versions(struct buffer *b, = struct module *mod) if (!s->module) continue; if (!s->crc_valid) { - /* - * We already warned on this when producing the legacy - * modversions table. - */ + warn("\"%s\" [%s.ko] has no CRC!\n", + s->name, mod->name); continue; } buf_printf(b, "\t%#8x,\n", s->crc); @@ -1853,8 +1853,8 @@ static void add_extended_versions(struct buffer *b, s= truct module *mod) continue; if (!s->crc_valid) { /* - * We already warned on this when producing the legacy - * modversions table. + * We already warned on this when producing the crc + * table. * We need to skip its name too, as the indexes in * both tables need to align. */ @@ -1872,7 +1872,7 @@ static void add_versions(struct buffer *b, struct mod= ule *mod) { struct symbol *s; =20 - if (!modversions) + if (!basic_modversions) return; =20 buf_printf(b, "\n"); @@ -2184,7 +2184,7 @@ int main(int argc, char **argv) LIST_HEAD(dump_lists); struct dump_list *dl, *dl2; =20 - while ((opt =3D getopt(argc, argv, "ei:MmnT:to:au:WwENd:x")) !=3D -1) { + while ((opt =3D getopt(argc, argv, "ei:MmnT:to:au:WwENd:xb")) !=3D -1) { switch (opt) { case 'e': external_module =3D true; @@ -2233,6 +2233,9 @@ int main(int argc, char **argv) case 'd': missing_namespace_deps =3D optarg; break; + case 'b': + basic_modversions =3D true; + break; case 'x': extended_modversions =3D true; break; --=20 2.47.0.371.ga323438b13-goog