From e97b3797960aca504845358776d248c5ad12cca6 Mon Sep 17 00:00:00 2001 From: Sergii Dmytruk Date: Wed, 27 Nov 2024 16:16:00 +0200 Subject: [PATCH] talos2: port 2 more Linux patches to 6.6.16 Signed-off-by: Sergii Dmytruk Signed-off-by: Thierry Laurion --- ...nfig-enable-inclusion-of-drivers-fir.patch | 24 +++++ ...re-google-expose-CBMEM-as-sysfs-file.patch | 91 +++++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 patches/linux-6.6.16-openpower/0006-arch-powerpc-Kconfig-enable-inclusion-of-drivers-fir.patch create mode 100644 patches/linux-6.6.16-openpower/0007-drivers-firmware-google-expose-CBMEM-as-sysfs-file.patch diff --git a/patches/linux-6.6.16-openpower/0006-arch-powerpc-Kconfig-enable-inclusion-of-drivers-fir.patch b/patches/linux-6.6.16-openpower/0006-arch-powerpc-Kconfig-enable-inclusion-of-drivers-fir.patch new file mode 100644 index 00000000..95c56601 --- /dev/null +++ b/patches/linux-6.6.16-openpower/0006-arch-powerpc-Kconfig-enable-inclusion-of-drivers-fir.patch @@ -0,0 +1,24 @@ +From 6fca185285b3c355511885cdb4344a758550c9ba Mon Sep 17 00:00:00 2001 +From: Krystian Hebel +Date: Wed, 8 Mar 2023 13:53:10 +0100 +Subject: [PATCH 6/7] arch/powerpc/Kconfig: enable inclusion of + drivers/firmware + +Signed-off-by: Krystian Hebel +--- + arch/powerpc/Kconfig | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig +index 2fe51e0ad..76cfc1277 100644 +--- a/arch/powerpc/Kconfig ++++ b/arch/powerpc/Kconfig +@@ -1309,3 +1309,5 @@ config PPC_LIB_RHEAP + source "arch/powerpc/kvm/Kconfig" + + source "kernel/livepatch/Kconfig" ++ ++source "drivers/firmware/Kconfig" +-- +2.47.1 + diff --git a/patches/linux-6.6.16-openpower/0007-drivers-firmware-google-expose-CBMEM-as-sysfs-file.patch b/patches/linux-6.6.16-openpower/0007-drivers-firmware-google-expose-CBMEM-as-sysfs-file.patch new file mode 100644 index 00000000..107f72ff --- /dev/null +++ b/patches/linux-6.6.16-openpower/0007-drivers-firmware-google-expose-CBMEM-as-sysfs-file.patch @@ -0,0 +1,91 @@ +From 9cdaa84d65888ea288860426a70f36737a6640c6 Mon Sep 17 00:00:00 2001 +From: Krystian Hebel +Date: Tue, 28 Mar 2023 18:31:21 +0200 +Subject: [PATCH 7/7] drivers/firmware/google: expose CBMEM as sysfs file + +Signed-off-by: Krystian Hebel +--- + drivers/firmware/google/Kconfig | 8 ++++++ + drivers/firmware/google/coreboot_table.c | 33 ++++++++++++++++++++++++ + 2 files changed, 41 insertions(+) + +diff --git a/drivers/firmware/google/Kconfig b/drivers/firmware/google/Kconfig +index 41b78f5cb..cb0443f9c 100644 +--- a/drivers/firmware/google/Kconfig ++++ b/drivers/firmware/google/Kconfig +@@ -44,6 +44,14 @@ config GOOGLE_COREBOOT_TABLE + device tree node /firmware/coreboot. + If unsure say N. + ++config GOOGLE_COREBOOT_CBMEM ++ bool "Expose CBMEM as file" ++ depends on GOOGLE_COREBOOT_TABLE ++ help ++ This option exposes raw contents of coreboot's CBMEM to be consumed ++ by userspace tools. Path to file: /sys/firmware/cbmem. ++ If unsure say N. ++ + config GOOGLE_MEMCONSOLE + tristate + depends on GOOGLE_MEMCONSOLE_X86_LEGACY || GOOGLE_MEMCONSOLE_COREBOOT +diff --git a/drivers/firmware/google/coreboot_table.c b/drivers/firmware/google/coreboot_table.c +index 33ae94745..06d6db594 100644 +--- a/drivers/firmware/google/coreboot_table.c ++++ b/drivers/firmware/google/coreboot_table.c +@@ -81,6 +81,18 @@ void coreboot_driver_unregister(struct coreboot_driver *driver) + } + EXPORT_SYMBOL(coreboot_driver_unregister); + ++#ifdef CONFIG_GOOGLE_COREBOOT_CBMEM ++static ssize_t cbmem_read(struct file *filp, struct kobject *kobp, ++ struct bin_attribute *bin_attr, char *buf, ++ loff_t pos, size_t count) ++{ ++ return memory_read_from_buffer(buf, count, &pos, ++ bin_attr->private, bin_attr->size); ++} ++ ++static BIN_ATTR_RO(cbmem, 0); ++#endif ++ + static int coreboot_table_populate(struct device *dev, void *ptr) + { + int i, ret; +@@ -167,6 +179,20 @@ static int coreboot_table_probe(struct platform_device *pdev) + + memunmap(ptr); + ++#ifdef CONFIG_GOOGLE_COREBOOT_CBMEM ++ res = platform_get_resource(pdev, IORESOURCE_MEM, 1); ++ if (res && res->start && res->end && resource_size(res)) { ++ bin_attr_cbmem.size = resource_size(res); ++ bin_attr_cbmem.private = memremap(res->start, ++ resource_size(res), ++ MEMREMAP_WB); ++ if (sysfs_create_bin_file(firmware_kobj, &bin_attr_cbmem)) { ++ bin_attr_cbmem.size = 0; ++ bin_attr_cbmem.private = NULL; ++ } ++ } ++#endif ++ + return ret; + } + +@@ -178,6 +204,13 @@ static int __cb_dev_unregister(struct device *dev, void *dummy) + + static int coreboot_table_remove(struct platform_device *pdev) + { ++#ifdef CONFIG_GOOGLE_COREBOOT_CBMEM ++ if (bin_attr_cbmem.private) { ++ sysfs_remove_bin_file(firmware_kobj, &bin_attr_cbmem); ++ memunmap(bin_attr_cbmem.private); ++ } ++#endif ++ + bus_for_each_dev(&coreboot_bus_type, NULL, NULL, __cb_dev_unregister); + return 0; + } +-- +2.47.1 +