EDAC/amd64: Merge sysfs debugging attributes setup code
Subsystems (2)
Borislav Petkov
maintainerPATCH 1/2 EDAC/amd64: Merge sysfs debugging attributes setup code
From: Borislav Petkov <[email protected]>
There's no need for them to be in a separate file so merge them into the main driver compilation unit like the other EDAC drivers do.
Drop now-unneeded function export, make the function static and shorten static function names.
No functional changes.
--- drivers/edac/Makefile | 1 - drivers/edac/amd64_edac.c | 65 +++++++++++++++++++++++++++++++---- drivers/edac/amd64_edac.h | 3 -- drivers/edac/amd64_edac_dbg.c | 55 ----------------------------- 4 files changed, 59 insertions(+), 65 deletions(-) delete mode 100644 drivers/edac/amd64_edac_dbg.c
drivers/edac/Makefile +0 -1
@@ -45,7 +45,6 @@ obj-$(CONFIG_EDAC_I82860) += i82860_edac.o obj-$(CONFIG_EDAC_R82600) += r82600_edac.o amd64_edac_mod-y := amd64_edac.o -amd64_edac_mod-$(CONFIG_EDAC_DEBUG) += amd64_edac_dbg.o amd64_edac_mod-$(CONFIG_EDAC_AMD64_ERROR_INJECTION) += amd64_edac_inj.o obj-$(CONFIG_EDAC_AMD64) += amd64_edac_mod.o
drivers/edac/amd64_edac.c +59 -6
89 lines not on this page · raw message
drivers/edac/amd64_edac.h +0 -3
@@ -501,9 +501,6 @@ int __amd64_write_pci_cfg_dword(struct pci_dev *pdev, int offset,#define amd64_write_pci_cfg (pdev, offset, val) \ __amd64_write_pci_cfg_dword(pdev, offset, val, __func__) -int amd64_get_dram_hole_info (struct mem_ctl_info *mci,u64 *hole_base, -u64 *hole_offset,u64 *hole_size); -#define to_mci (k) container_of(k, struct mem_ctl_info, dev)/* Injection helpers */
drivers/edac/amd64_edac_dbg.c deleted +0 -55
55 lines not on this page · raw message
Signature · 1 line
2.29.2
Borislav Petkov
maintainerPATCH 2/2 EDAC/amd64: Merge error injection sysfs facilities
From: Borislav Petkov <[email protected]>
Merge them into the main driver and put them inside an EDAC_DEBUG ifdeffery to simplify the driver and have all debugging/injection stuff behind a debug build-time switch.
No functional changes.
--- drivers/edac/Kconfig | 7 +- drivers/edac/Makefile | 6 +- drivers/edac/amd64_edac.c | 237 +++++++++++++++++++++++++++++++++- drivers/edac/amd64_edac.h | 8 -- drivers/edac/amd64_edac_inj.c | 235 --------------------------------- 5 files changed, 236 insertions(+), 257 deletions(-) delete mode 100644 drivers/edac/amd64_edac_inj.c
drivers/edac/Kconfig +3 -4
@@ -81,10 +81,9 @@ config EDAC_AMD64 Support for error detection and correction of DRAM ECC errors on the AMD64 families (>= K8) of memory controllers. -config EDAC_AMD64_ERROR_INJECTION - bool "Sysfs HW Error injection facilities" - depends on EDAC_AMD64 - help + When EDAC_DEBUG is enabled, hardware error injection facilities + through sysfs are available: + Recent Opterons (Family 10h and later) provide for Memory Error Injection into the ECC detection circuits. The amd64_edac module allows the operator/user to inject Uncorrectable and Correctable
drivers/edac/Makefile +1 -5
@@ -43,11 +43,7 @@ obj-$(CONFIG_EDAC_IE31200) += ie31200_edac.o obj-$(CONFIG_EDAC_X38) += x38_edac.o obj-$(CONFIG_EDAC_I82860) += i82860_edac.o obj-$(CONFIG_EDAC_R82600) += r82600_edac.o - -amd64_edac_mod-y := amd64_edac.o -amd64_edac_mod-$(CONFIG_EDAC_AMD64_ERROR_INJECTION) += amd64_edac_inj.o - -obj-$(CONFIG_EDAC_AMD64) += amd64_edac_mod.o +obj-$(CONFIG_EDAC_AMD64) += amd64_edac.o obj-$(CONFIG_EDAC_PASEMI) += pasemi_edac.o
drivers/edac/amd64_edac.c +232 -5
252 lines not on this page · raw message
drivers/edac/amd64_edac.h +0 -8
@@ -462,14 +462,6 @@ struct ecc_settings { } flags; }; -#ifdef CONFIG_EDAC_DEBUG -extern const struct attribute_group amd64_edac_dbg_group; -#endif - -#ifdef CONFIG_EDAC_AMD64_ERROR_INJECTION -extern const struct attribute_group amd64_edac_inj_group; -#endif -/* * Each of the PCI Device IDs types have their own set of hardware accessor * functions and per device encoding/decoding logic.
drivers/edac/amd64_edac_inj.c deleted +0 -235
235 lines not on this page · raw message
Signature · 1 line
2.29.2
Quoted 11 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
There's no need for them to be in a separate file so merge them into the main driver compilation unit like the other EDAC drivers do.
Drop now-unneeded function export, make the function static and shorten static function names.
No functional changes.
Signed-off-by Borislav Petkov <[email protected]>
Thanks,
Yazen
Re: [PATCH 2/2] EDAC/amd64: Merge error injection sysfs facilities
In reply to Borislav PetkovQuoted 24 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
Merge them into the main driver and put them inside an
EDAC_DEBUGifdeffery to simplify the driver and have all debugging/injection stuff behind a debug build-time switch.No functional changes.
Signed-off-by Borislav Petkov <[email protected]>--- drivers/edac/Kconfig | 7 +- drivers/edac/Makefile | 6 +- drivers/edac/amd64_edac.c | 237 +++++++++++++++++++++++++++++++++- drivers/edac/amd64_edac.h | 8 -- drivers/edac/amd64_edac_inj.c | 235 --------------------------------- 5 files changed, 236 insertions(+), 257 deletions(-) delete mode 100644 drivers/edac/amd64_edac_inj.cdrivers/edac/Kconfig +0
-0@@ -81,10 +81,9 @@ config EDAC_AMD64 Support for error detection and correction of DRAM ECC errors on
drivers/edac/Kconfig config EDAC_AMD64 · line 87
Quoted 10 lines
drivers/edac/Kconfig +3
-4the AMD64 families (>= K8) of memory controllers. -config EDAC_AMD64_ERROR_INJECTION - bool "Sysfs HW Error injection facilities" - depends on EDAC_AMD64 - help + When EDAC_DEBUG is enabled, hardware error injection facilities + through sysfs are available: + Recent Opterons (Family 10h and later) provide for Memory Error
Can we say "Opterons (Family 10h to Family 15h)"? It may also apply to Family 16h, but I don't know if they were branded as Opterons.
The injection code in this module doesn't apply to Family 17h and later.
Also, Family 17h and later doesn't allow the OS direct access to the error injection registers. They're locked down by security policy, etc.
Quoted 2 lines
drivers/edac/Kconfig +0
-0Injection into the ECC detection circuits. The amd64_edac module allows the operator/user to inject Uncorrectable and Correctable
...
drivers/edac/Kconfig
Quoted 8 lines
drivers/edac/Kconfig +8
-0+ +static umode_t inj_is_visible(struct kobject *kobj, struct attribute *attr, int idx) +{ + struct device *dev = kobj_to_dev(kobj); + struct mem_ctl_info *mci = container_of(dev, struct mem_ctl_info, dev); + struct amd64_pvt *pvt = mci->pvt_info; + + if (pvt->fam < 0x10)
Related to the comment above, can this be changed to the following?
if (pvt->fam < 0x10 || pvt->fam >= 0x17)
drivers/edac/Kconfig
Quoted 4 lines
drivers/edac/Kconfig +4
-0+ return 0; + return attr->mode; +} +
Everything else looks good to me.
Thanks,
Yazen
Borislav Petkov
maintainerRe: [PATCH 2/2] EDAC/amd64: Merge error injection sysfs facilities
Quoted 7 lines · Yazen Ghannam
Can we say "Opterons (Family 10h to Family 15h)"? It may also apply to Family 16h, but I don't know if they were branded as Opterons.
The injection code in this module doesn't apply to Family 17h and later.
Also, Family 17h and later doesn't allow the OS direct access to the error injection registers. They're locked down by security policy, etc.
Yeah, figured as much after I started getting all 0s while poking at them with setpci...
Ok, I'll fix that ontop - this patch should be only code movement and trivial cleanups, functionality changes ontop.
Quoted 3 lines
Related to the comment above, can this be changed to the following?
if (pvt->fam < 0x10 || pvt->fam >= 0x17)
Right.
Quoted 3 lines
Everything else looks good to me.
Reviewed-by Yazen Ghannam <[email protected]>
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteBorislav Petkov
maintainerRe: [PATCH 2/2] EDAC/amd64: Merge error injection sysfs facilities
In reply to Yazen GhannamQuoted 3 lines · Yazen Ghannam
Related to the comment above, can this be changed to the following?
if (pvt->fam < 0x10 || pvt->fam >= 0x17)
I made that a "positive" list so that it is explicit which do support it out of the box:
---
From: Borislav Petkov <[email protected]>
Date: Tue, 22 Dec 2020 18:55:06 +0100
Subject: [PATCH] EDAC/amd64: Limit error injection functionality to supported hw
Families up to and including 0x16 allow access to the injection hardware. Starting with family 0x17, access to those registers is blocked by security policy.
Limit that only on the families which support it.
--- drivers/edac/Kconfig | 8 ++++---- drivers/edac/amd64_edac.c | 8 +++++--- 2 files changed, 9 insertions(+), 7 deletions(-)
drivers/edac/Kconfig +4 -4
@@ -84,10 +84,10 @@ config EDAC_AMD64 When EDAC_DEBUG is enabled, hardware error injection facilities through sysfs are available: - Recent Opterons (Family 10h and later) provide for Memory Error - Injection into the ECC detection circuits. The amd64_edac module - allows the operator/user to inject Uncorrectable and Correctable - errors into DRAM. + AMD CPUs up to and excluding family 0x17 provide for Memory + Error Injection into the ECC detection circuits. The amd64_edac + module allows the operator/user to inject Uncorrectable and + Correctable errors into DRAM. When enabled, in each of the respective memory controller directories (/sys/devices/system/edac/mc/mcX), there are 3 input files:
drivers/edac/amd64_edac.c +5 -3
@@ -828,9 +828,11 @@ static umode_t inj_is_visible(struct kobject *kobj, struct attribute *attr, int struct mem_ctl_info *mci = container_of(dev, struct mem_ctl_info, dev);struct amd64_pvt *pvt = mci->pvt_info; -if (pvt->fam <0x10 ) -return 0 ; -return attr->mode; +/* Families which have that injection hw */ +if (pvt->fam >=0x10 && pvt->fam <=0x16 ) +return attr->mode; + +return 0 ; }static const struct attribute_group inj_group = {
Signature · 7 lines
2.29.2
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette