ANDROID: modules: re-introduce the MODULE_SCMVERSION config

Config MODULE_SCMVERSION introduces a new module attribute --
`scmversion` -- which can be used to identify a given module's SCM
version.  This is very useful for developers that update their kernel
independently from their kernel modules or vice-versa since the SCM
version provided by UTS_RELEASE (`uname -r`) will now differ from the
module's vermagic attribute.

For example, we have a CI setup that tests new kernel changes on the
hikey960 and db845c devices without updating their kernel modules. When
these tests fail, we need to be able to identify the exact device
configuration the test was using. By including MODULE_SCMVERSION, we can
identify the exact kernel and modules' SCM versions for debugging the
failures.

Additionally, by exposing the SCM version via the sysfs node
/sys/module/MODULENAME/scmversion, one can also verify the SCM versions
of the modules loaded from the initramfs. Currently, modinfo can only
retrieve module attributes from the module's ko on disk and not from the
actual module that is loaded in RAM.

You can retrieve the SCM version in two ways,

1) By using modinfo:
    > modinfo -F scmversion MODULENAME
2) By module sysfs node:
    > cat /sys/module/MODULENAME/scmversion

Bug: 180027765
Bug: 236871190
Link: https://lore.kernel.org/all/20210121213641.3477522-1-willmcvicker@google.com/
Signed-off-by: Will McVicker <willmcvicker@google.com>
Signed-off-by: Yifan Hong <elsk@google.com>
Change-Id: Iad77caff63c4ddef3a3c92182cdacb0b90b124c7
This commit is contained in:
Will McVicker
2020-11-19 13:46:37 -08:00
committed by Yifan Hong
parent 3ee567fc88
commit 1bf5e5e70d
6 changed files with 71 additions and 1 deletions
+1
View File
@@ -387,6 +387,7 @@ struct module {
struct module_attribute *modinfo_attrs;
const char *version;
const char *srcversion;
const char *scmversion;
struct kobject *holders_dir;
/* Exported symbols */