Merge pull request #1802 from tlaurion/talos_2-kernel_version_bump_to_6.6.16

talos-2: kernel version bump to 6.6.16
This commit is contained in:
Thierry Laurion 2024-11-29 14:19:25 -05:00 committed by GitHub
commit 99157f2291
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 1433 additions and 398 deletions

View File

@ -4,7 +4,7 @@ CONFIG_TARGET_ARCH=ppc64
export CONFIG_COREBOOT=y
export CONFIG_COREBOOT_VERSION=talos_2
export CONFIG_LINUX_VERSION=5.5-openpower
export CONFIG_LINUX_VERSION=6.6.16-openpower
CONFIG_COREBOOT_CONFIG=config/coreboot-talos-2.config
CONFIG_COREBOOT_ROM=coreboot.rom.signed.ecc

File diff suppressed because it is too large Load Diff

View File

@ -19,10 +19,10 @@ linux_hash := 9c4ebf21fe949f80fbcfbbd6e7fe181040d325e89475e230ab53ef01f9d55605
else ifeq "$(CONFIG_LINUX_VERSION)" "5.4.69"
linux_version := 5.4.69
linux_hash := a8b31d716b397303a183e42ad525ff2871024a43e3ea530d0fdf73b7f9d27da7
else ifeq "$(CONFIG_LINUX_VERSION)" "5.5-openpower"
linux_version := 5.5
linux_patch_version := 5.5-openpower
linux_hash := a6fbd4ee903c128367892c2393ee0d9657b6ed3ea90016d4dc6f1f6da20b2330
else ifeq "$(CONFIG_LINUX_VERSION)" "6.6.16-openpower"
linux_version := 6.6.16
linux_patch_version := 6.6.16-openpower
linux_hash := b21d5795a3bead4f112916423222faa8a0f519e4201df343e3eb88dc9e4aaa30
#
# linuxboot systems should *NOT* use 5.10.5 until a proper review has
# been done. This is because `0000-efi_bds.patch` did not cleanly port

View File

@ -0,0 +1,29 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Brian King <brking@linux.vnet.ibm.com>
Date: Wed, 25 Oct 2017 10:42:59 +1100
Subject: [PATCH 1/2] xhci: Reset controller on xhci shutdown
Fixes kexec boot. Without a hard reset, some USB chips will fail to
initialize in a kexec booted kernel.
Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Signed-off-by: Joel Stanley <joel@jms.id.au>
---
drivers/usb/host/xhci.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 473b0b64dd57..ca0c642ce935 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -812,6 +812,9 @@ void xhci_shutdown(struct usb_hcd *hcd)
xhci_dbg_trace(xhci, trace_xhci_dbg_init,
"xhci_shutdown completed - status = %x",
readl(&xhci->op_regs->status));
+
+ /* TI XHCI controllers do not come back after kexec without this hack */
+ pci_reset_function_locked(to_pci_dev(hcd->self.sysdev));
}
EXPORT_SYMBOL_GPL(xhci_shutdown);

View File

@ -0,0 +1,23 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Joel Stanley <joel@jms.id.au>
Date: Thu, 15 Jul 2021 17:21:55 +0930
Subject: [PATCH 2/2] Release OpenPower kernel
Signed-off-by: Joel Stanley <joel@jms.id.au>
---
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 92accf2ddc08..18dcc81a67e4 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@
VERSION = 6
PATCHLEVEL = 6
SUBLEVEL = 16
-EXTRAVERSION =
+EXTRAVERSION = -openpower1
NAME = Hurr durr I'ma ninja sloth
# *DOCUMENTATION*

View File

@ -0,0 +1,138 @@
From 39017ede41e6286e232c18cdf8b6b600dd751696 Mon Sep 17 00:00:00 2001
From: Timothy Pearson <tpearson@raptorengineering.com>
Date: Fri, 9 Feb 2024 16:22:29 -0600
Subject: [PATCH] drm/ast: Add option to initialize palette on driver load
Non-x86 systems, such as OpenPOWER and ARM machines, do not execute the ASPEED-
provided option ROM on system start. As a result, the VGA palette registers
remain uninitialized, leading to odd colors and generally hard to read output
on the VGA port.
Add a new module option, ast_resetpalette, to enable loading a linear greyscale
palette into the VGA RAMDAC. This option is intended for use by the first Linux
kernel to load after initial power on, such as the skiroot kernel on OpenPOWER
systems.
Signed-off-by: Timothy Pearson <tpearson@raptorengineering.com>
---
drivers/gpu/drm/ast/ast_drv.c | 4 ++++
drivers/gpu/drm/ast/ast_drv.h | 14 ++++++++++++++
drivers/gpu/drm/ast/ast_main.c | 8 ++++++++
drivers/gpu/drm/ast/ast_mode.c | 14 --------------
4 files changed, 26 insertions(+), 14 deletions(-)
diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
index e1224ef4ad83..d46dc88ccbe9 100644
--- a/drivers/gpu/drm/ast/ast_drv.c
+++ b/drivers/gpu/drm/ast/ast_drv.c
@@ -1,5 +1,6 @@
/*
* Copyright 2012 Red Hat Inc.
+ * Copyright 2024 Raptor Engineering, LLC.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
@@ -40,9 +41,12 @@
#include "ast_drv.h"
static int ast_modeset = -1;
+int ast_resetpalette = -1;
MODULE_PARM_DESC(modeset, "Disable/Enable modesetting");
+MODULE_PARM_DESC(resetpalette, "Disable/Enable palette reset on load");
module_param_named(modeset, ast_modeset, int, 0400);
+module_param_named(resetpalette, ast_resetpalette, int, 0400);
/*
* DRM driver
diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h
index f7053f2972bb..61b6ae0dfbf3 100644
--- a/drivers/gpu/drm/ast/ast_drv.h
+++ b/drivers/gpu/drm/ast/ast_drv.h
@@ -340,6 +340,20 @@ static inline void ast_set_index_reg_mask(struct ast_device *ast, u32 base, u8 i
ast_set_index_reg(ast, base, index, tmp);
}
+static inline void ast_load_palette_index(struct ast_device *ast,
+ u8 index, u8 red, u8 green,
+ u8 blue)
+{
+ ast_io_write8(ast, AST_IO_DAC_INDEX_WRITE, index);
+ ast_io_read8(ast, AST_IO_SEQ_PORT);
+ ast_io_write8(ast, AST_IO_DAC_DATA, red);
+ ast_io_read8(ast, AST_IO_SEQ_PORT);
+ ast_io_write8(ast, AST_IO_DAC_DATA, green);
+ ast_io_read8(ast, AST_IO_SEQ_PORT);
+ ast_io_write8(ast, AST_IO_DAC_DATA, blue);
+ ast_io_read8(ast, AST_IO_SEQ_PORT);
+}
+
#define AST_VIDMEM_SIZE_8M 0x00800000
#define AST_VIDMEM_SIZE_16M 0x01000000
#define AST_VIDMEM_SIZE_32M 0x02000000
diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c
index dae365ed3969..ada259761b0e 100644
--- a/drivers/gpu/drm/ast/ast_main.c
+++ b/drivers/gpu/drm/ast/ast_main.c
@@ -1,5 +1,6 @@
/*
* Copyright 2012 Red Hat Inc.
+ * Copyright 2024 Raptor Engineering, LLC.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
@@ -35,6 +36,8 @@
#include "ast_drv.h"
+extern int ast_resetpalette;
+
static bool ast_is_vga_enabled(struct drm_device *dev)
{
struct ast_device *ast = to_ast_device(dev);
@@ -432,6 +435,7 @@ struct ast_device *ast_device_create(const struct drm_driver *drv,
struct ast_device *ast;
bool need_post = false;
int ret = 0;
+ int index = 0;
ast = devm_drm_dev_alloc(&pdev->dev, drv, struct ast_device, base);
if (IS_ERR(ast))
@@ -517,5 +521,9 @@ struct ast_device *ast_device_create(const struct drm_driver *drv,
if (ret)
return ERR_PTR(ret);
+ if (ast_resetpalette == 1)
+ for (index = 0x00; index < 0x100; index++)
+ ast_load_palette_index(ast, index, index, index, index);
+
return ast;
}
diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
index 3de0f457fff6..81bed5eeb87b 100644
--- a/drivers/gpu/drm/ast/ast_mode.c
+++ b/drivers/gpu/drm/ast/ast_mode.c
@@ -51,20 +51,6 @@
#define AST_LUT_SIZE 256
-static inline void ast_load_palette_index(struct ast_device *ast,
- u8 index, u8 red, u8 green,
- u8 blue)
-{
- ast_io_write8(ast, AST_IO_DAC_INDEX_WRITE, index);
- ast_io_read8(ast, AST_IO_SEQ_PORT);
- ast_io_write8(ast, AST_IO_DAC_DATA, red);
- ast_io_read8(ast, AST_IO_SEQ_PORT);
- ast_io_write8(ast, AST_IO_DAC_DATA, green);
- ast_io_read8(ast, AST_IO_SEQ_PORT);
- ast_io_write8(ast, AST_IO_DAC_DATA, blue);
- ast_io_read8(ast, AST_IO_SEQ_PORT);
-}
-
static void ast_crtc_set_gamma_linear(struct ast_device *ast,
const struct drm_format_info *format)
{
--
2.39.2

View File

@ -0,0 +1,26 @@
From 33cb4510b70e7625636a4280e29081ce7cef69e9 Mon Sep 17 00:00:00 2001
From: Raptor Engineering Development Team <support@raptorengineering.com>
Date: Fri, 2 Feb 2018 07:37:41 -0600
Subject: [PATCH] Force ASpeed RAMDAC palette reset
---
drivers/gpu/drm/ast/ast_drv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
index 8124eaa92ed3..c44797598760 100644
--- a/drivers/gpu/drm/ast/ast_drv.c
+++ b/drivers/gpu/drm/ast/ast_drv.c
@@ -35,7 +35,7 @@
#include "ast_drv.h"
static int ast_modeset = -1;
-int ast_resetpalette = -1;
+int ast_resetpalette = 1;
MODULE_PARM_DESC(modeset, "Disable/Enable modesetting");
MODULE_PARM_DESC(resetpalette, "Disable/Enable palette reset on load");
--
2.15.1

View File

@ -0,0 +1,329 @@
From f14d20a4aed3b87277557d1ba9ad589dbbdc0900 Mon Sep 17 00:00:00 2001
From: Timothy Pearson <tpearson@raptorengineering.com>
Date: Mon, 12 Feb 2024 10:26:49 -0600
Subject: [PATCH] powerpc: Add gpr1 and fpu save/restore functions
When building the kernel in size optimized mode with the amdgpu module enabled,
gcc will begin referencing external gpr1 and fpu save/restore functions. This
will then cause a linker failure as we do not link against libgcc which
normally contains those builtin functions.
Implement gpr1 and fpu save/restore functions per the ABI v2 documentation.
Tested on a Talos II with a WX7100 installed and running in DisplayCore mode.
Reported-by: kernel test robot <lkp@intel.com>
Tested-by: Timothy Pearson <tpearson@raptorengineering.com>
Signed-off-by: Timothy Pearson <tpearson@raptorengineering.com>
---
arch/powerpc/kernel/prom_init_check.sh | 4 +-
arch/powerpc/lib/crtsavres.S | 244 +++++++++++++++++++++++++
scripts/mod/modpost.c | 4 +
3 files changed, 250 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/kernel/prom_init_check.sh b/arch/powerpc/kernel/prom_init_check.sh
index 69623b9045d5..76c5651e29d3 100644
--- a/arch/powerpc/kernel/prom_init_check.sh
+++ b/arch/powerpc/kernel/prom_init_check.sh
@@ -72,10 +72,10 @@ do
# ignore register save/restore funcitons
case $UNDEF in
- _restgpr_*|_restgpr0_*|_rest32gpr_*)
+ _restgpr_*|_restgpr0_*|_restgpr1_*|_rest32gpr_*)
OK=1
;;
- _savegpr_*|_savegpr0_*|_save32gpr_*)
+ _savegpr_*|_savegpr0_*|_restgpr0_*|_save32gpr_*)
OK=1
;;
esac
diff --git a/arch/powerpc/lib/crtsavres.S b/arch/powerpc/lib/crtsavres.S
index 7e5e1c28e56a..6cd870aacd7f 100644
--- a/arch/powerpc/lib/crtsavres.S
+++ b/arch/powerpc/lib/crtsavres.S
@@ -3,6 +3,7 @@
*
* Copyright (C) 1995, 1996, 1998, 2000, 2001 Free Software Foundation, Inc.
* Copyright 2008 Freescale Semiconductor, Inc.
+ * Copyright 2024 Raptor Engineering, LLC
* Written By Michael Meissner
*
* Based on gcc/config/rs6000/crtsavres.asm from gcc
@@ -435,6 +436,127 @@ _restgpr0_31:
mtlr r0
blr
+.globl _savegpr1_14
+_savegpr1_14:
+ std r14,-144(r12)
+.globl _savegpr1_15
+_savegpr1_15:
+ std r15,-136(r12)
+.globl _savegpr1_16
+_savegpr1_16:
+ std r16,-128(r12)
+.globl _savegpr1_17
+_savegpr1_17:
+ std r17,-120(r12)
+.globl _savegpr1_18
+_savegpr1_18:
+ std r18,-112(r12)
+.globl _savegpr1_19
+_savegpr1_19:
+ std r19,-104(r12)
+.globl _savegpr1_20
+_savegpr1_20:
+ std r20,-96(r12)
+.globl _savegpr1_21
+_savegpr1_21:
+ std r21,-88(r12)
+.globl _savegpr1_22
+_savegpr1_22:
+ std r22,-80(r12)
+.globl _savegpr1_23
+_savegpr1_23:
+ std r23,-72(r12)
+.globl _savegpr1_24
+_savegpr1_24:
+ std r24,-64(r12)
+.globl _savegpr1_25
+_savegpr1_25:
+ std r25,-56(r12)
+.globl _savegpr1_26
+_savegpr1_26:
+ std r26,-48(r12)
+.globl _savegpr1_27
+_savegpr1_27:
+ std r27,-40(r12)
+.globl _savegpr1_28
+_savegpr1_28:
+ std r28,-32(r12)
+.globl _savegpr1_29
+_savegpr1_29:
+ std r29,-24(r12)
+.globl _savegpr1_30
+_savegpr1_30:
+ std r30,-16(r12)
+.globl _savegpr1_31
+_savegpr1_31:
+ std r31,-8(r12)
+ std r0,16(r12)
+ blr
+
+.globl _restgpr1_14
+_restgpr1_14:
+ ld r14,-144(r12)
+.globl _restgpr1_15
+_restgpr1_15:
+ ld r15,-136(r12)
+.globl _restgpr1_16
+_restgpr1_16:
+ ld r16,-128(r12)
+.globl _restgpr1_17
+_restgpr1_17:
+ ld r17,-120(r12)
+.globl _restgpr1_18
+_restgpr1_18:
+ ld r18,-112(r12)
+.globl _restgpr1_19
+_restgpr1_19:
+ ld r19,-104(r12)
+.globl _restgpr1_20
+_restgpr1_20:
+ ld r20,-96(r12)
+.globl _restgpr1_21
+_restgpr1_21:
+ ld r21,-88(r12)
+.globl _restgpr1_22
+_restgpr1_22:
+ ld r22,-80(r12)
+.globl _restgpr1_23
+_restgpr1_23:
+ ld r23,-72(r12)
+.globl _restgpr1_24
+_restgpr1_24:
+ ld r24,-64(r12)
+.globl _restgpr1_25
+_restgpr1_25:
+ ld r25,-56(r12)
+.globl _restgpr1_26
+_restgpr1_26:
+ ld r26,-48(r12)
+.globl _restgpr1_27
+_restgpr1_27:
+ ld r27,-40(r12)
+.globl _restgpr1_28
+_restgpr1_28:
+ ld r28,-32(r12)
+.globl _restgpr1_29
+_restgpr1_29:
+ ld r0,16(r12)
+ ld r29,-24(r12)
+ mtlr r0
+ ld r30,-16(r12)
+ ld r31,-8(r12)
+ blr
+
+.globl _restgpr1_30
+_restgpr1_30:
+ ld r30,-16(r12)
+.globl _restgpr1_31
+_restgpr1_31:
+ ld r0,16(r12)
+ ld r31,-8(r12)
+ mtlr r0
+ blr
+
#ifdef CONFIG_ALTIVEC
/* Called with r0 pointing just beyond the end of the vector save area. */
@@ -540,6 +662,128 @@ _restvr_31:
#endif /* CONFIG_ALTIVEC */
+#ifdef CONFIG_PPC_FPU
+
+.globl _savefpr_14
+_savefpr_14:
+ stfd f14,-144(r1)
+.globl _savefpr_15
+_savefpr_15:
+ stfd f15,-136(r1)
+.globl _savefpr_16
+_savefpr_16:
+ stfd f16,-128(r1)
+.globl _savefpr_17
+_savefpr_17:
+ stfd f17,-120(r1)
+.globl _savefpr_18
+_savefpr_18:
+ stfd f18,-112(r1)
+.globl _savefpr_19
+_savefpr_19:
+ stfd f19,-104(r1)
+.globl _savefpr_20
+_savefpr_20:
+ stfd f20,-96(r1)
+.globl _savefpr_21
+_savefpr_21:
+ stfd f21,-88(r1)
+.globl _savefpr_22
+_savefpr_22:
+ stfd f22,-80(r1)
+.globl _savefpr_23
+_savefpr_23:
+ stfd f23,-72(r1)
+.globl _savefpr_24
+_savefpr_24:
+ stfd f24,-64(r1)
+.globl _savefpr_25
+_savefpr_25:
+ stfd f25,-56(r1)
+.globl _savefpr_26
+_savefpr_26:
+ stfd f26,-48(r1)
+.globl _savefpr_27
+_savefpr_27:
+ stfd f27,-40(r1)
+.globl _savefpr_28
+_savefpr_28:
+ stfd f28,-32(r1)
+.globl _savefpr_29
+_savefpr_29:
+ stfd f29,-24(r1)
+.globl _savefpr_30
+_savefpr_30:
+ stfd f30,-16(r1)
+.globl _savefpr_31
+_savefpr_31:
+ stfd f31,-8(r1)
+ std r0, 16(r1)
+ blr
+
+.globl _restfpr_14
+_restfpr_14:
+ lfd f14,-144(r1)
+.globl _restfpr_15
+_restfpr_15:
+ lfd f15,-136(r1)
+.globl _restfpr_16
+_restfpr_16:
+ lfd f16,-128(r1)
+.globl _restfpr_17
+_restfpr_17:
+ lfd f17,-120(r1)
+.globl _restfpr_18
+_restfpr_18:
+ lfd f18,-112(r1)
+.globl _restfpr_19
+_restfpr_19:
+ lfd f19,-104(r1)
+.globl _restfpr_20
+_restfpr_20:
+ lfd f20,-96(r1)
+.globl _restfpr_21
+_restfpr_21:
+ lfd f21,-88(r1)
+.globl _restfpr_22
+_restfpr_22:
+ lfd f22,-80(r1)
+.globl _restfpr_23
+_restfpr_23:
+ lfd f23,-72(r1)
+.globl _restfpr_24
+_restfpr_24:
+ lfd f24,-64(r1)
+.globl _restfpr_25
+_restfpr_25:
+ lfd f25,-56(r1)
+.globl _restfpr_26
+_restfpr_26:
+ lfd f26,-48(r1)
+.globl _restfpr_27
+_restfpr_27:
+ lfd f27,-40(r1)
+.globl _restfpr_28
+_restfpr_28:
+ lfd f28,-32(r1)
+.globl _restfpr_29
+_restfpr_29:
+ ld r0, 16(r1)
+ lfd f29,-24(r1)
+ mtlr r0
+ lfd f30,-16(r1)
+ lfd f31,-8(r1)
+ blr
+.globl _restfpr_30
+_restfpr_30:
+ lfd f30,-16(r1)
+.globl _restfpr_31
+_restfpr_31:
+ ld r0, 16(r1)
+ lfd f31,-8(r1)
+
+#endif /* CONFIG_PPC_FPU */
+
#endif /* CONFIG_PPC64 */
#endif
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 267b9a0a3abc..153a163ba3f7 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -597,8 +597,12 @@ static int ignore_undef_symbol(struct elf_info *info, const char *symname)
/* Special register function linked on all modules during final link of .ko */
if (strstarts(symname, "_restgpr0_") ||
strstarts(symname, "_savegpr0_") ||
+ strstarts(symname, "_restgpr1_") ||
+ strstarts(symname, "_savegpr1_") ||
strstarts(symname, "_restvr_") ||
strstarts(symname, "_savevr_") ||
+ strstarts(symname, "_restfpr_") ||
+ strstarts(symname, "_savefpr_") ||
strcmp(symname, ".TOC.") == 0)
return 1;
--
2.39.2

View File

@ -0,0 +1,24 @@
From 6fca185285b3c355511885cdb4344a758550c9ba Mon Sep 17 00:00:00 2001
From: Krystian Hebel <krystian.hebel@3mdeb.com>
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 <krystian.hebel@3mdeb.com>
---
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

View File

@ -0,0 +1,91 @@
From 9cdaa84d65888ea288860426a70f36737a6640c6 Mon Sep 17 00:00:00 2001
From: Krystian Hebel <krystian.hebel@3mdeb.com>
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 <krystian.hebel@3mdeb.com>
---
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