EDAC/amd64: Limit error injection functionality to supported hw
authorBorislav Petkov <bp@suse.de>
Tue, 22 Dec 2020 17:55:06 +0000 (18:55 +0100)
committerBorislav Petkov <bp@suse.de>
Mon, 28 Dec 2020 18:36:37 +0000 (19:36 +0100)
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.

Suggested-by: Yazen Ghannam <yazen.ghannam@amd.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20201222180013.GD13463@zn.tnic
drivers/edac/Kconfig
drivers/edac/amd64_edac.c

index 47953b06d6c8504718b48bfb325951e9f91d2703..27d0c4cdc58d5204361044127965d5762c6c8f1b 100644 (file)
@@ -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:
index d55f8ef2240c8207267d8f519f0fcdf67218360c..9868f95a56228ad464ea6bebb28442c51a43c7cf 100644 (file)
@@ -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 = {