lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 28 Oct 2009 17:37:06 +0100
From:	Borislav Petkov <borislav.petkov@....com>
To:	Ingo Molnar <mingo@...e.hu>, Thomas Gleixner <tglx@...utronix.de>,
	"H. Peter Anvin" <hpa@...or.com>, x86 <x86@...nel.org>
CC:	Doug Thompson <norsk5@...oo.com>,
	LKML <linux-kernel@...r.kernel.org>
Subject: [PATCH 1/2] amd64_edac: load syndrome table through firmware API

>From 8fd92e05c26d5d086990e356297c8e69c2325cc6 Mon Sep 17 00:00:00 2001
From: Borislav Petkov <borislav.petkov@....com>
Date: Wed, 28 Oct 2009 13:24:34 +0100
Subject: [PATCH 1/2] amd64_edac: load syndrome table through firmware API

Add a facility for loading binary syndrome tables using the
request_firmware API instead of carrying static tables with the driver
code (esp. the x8 monster).

Not-Signed-off-by: Borislav Petkov <borislav.petkov@....com>
---
 drivers/edac/amd64_edac.c |   32 ++++++++++++++++++++++++++++++++
 drivers/edac/amd64_edac.h |   14 ++++++++++++++
 2 files changed, 46 insertions(+), 0 deletions(-)

diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
index c492721..6222a2c 100644
--- a/drivers/edac/amd64_edac.c
+++ b/drivers/edac/amd64_edac.c
@@ -1,4 +1,5 @@
 #include "amd64_edac.h"
+#include <linux/firmware.h>
 #include <asm/k8.h>
 
 static struct edac_pci_ctl_info *amd64_ctl_pci;
@@ -1982,6 +1983,37 @@ static const unsigned short ecc_chipkill_syndromes[NUMBER_ECC_ROWS][16] = {
 	   0x6f88, 0x19a9, 0xf4ba, 0x829b, 0xb5cc, 0xc3ed, 0x2efe, 0x58df }
 };
 
+static int amd64_load_syndrome_binary(char *fw_name, struct syndrome_table *s,
+				      struct device *dev)
+{
+	const struct firmware *fw;
+	struct syndrome_table tmp_s;
+
+	if (request_firmware(&fw, fw_name, dev)) {
+		amd64_printk(KERN_ERR, "Failure loading %s syndromes\n",
+			     fw_name);
+		return -EINVAL;
+	}
+
+	/* copy only the header */
+	memcpy(&tmp_s, fw->data, sizeof(*s) - sizeof(s->data));
+
+	if (tmp_s.magic != 0x00414d44 ||
+	    tmp_s.type  != s->type ||
+	    tmp_s.rows  != s->rows ||
+	    tmp_s.cols  != s->cols) {
+		amd64_printk(KERN_ERR, "Invalid syndromes binary!\n");
+		return -EINVAL;
+	}
+
+	memcpy(s->data,
+	       fw->data + offsetof(struct syndrome_table, data),
+	       s->rows * s->cols * sizeof(u16));
+
+	release_firmware(fw);
+	return 0;
+}
+
 /*
  * Given the syndrome argument, scan each of the channel tables for a syndrome
  * match. Depending on which table it is found, return the channel number.
diff --git a/drivers/edac/amd64_edac.h b/drivers/edac/amd64_edac.h
index db6c0a1..94f58d7 100644
--- a/drivers/edac/amd64_edac.h
+++ b/drivers/edac/amd64_edac.h
@@ -409,6 +409,20 @@ struct error_injection {
 	u32	bit_map;
 };
 
+enum syndrome_type {
+	SYNDROME_ECC			= (1 << 0),
+	SYNDROME_X4			= (1 << 1),
+	SYNDROME_X8			= (1 << 2),
+};
+
+struct syndrome_table {
+	 u32 magic;			/* should be 0x00414d44 */
+	 enum syndrome_type type;	/* ECC, X4, X8, etc */
+	 u32 rows;			/* dimensions of the syndromes table */
+	 u32 cols;
+	 u16 *data;			/* the actual syndrome table */
+} __attribute__((packed));
+
 struct amd64_pvt {
 	/* pci_device handles which we utilize */
 	struct pci_dev *addr_f1_ctl;
-- 
1.6.4.3

-- 
Regards/Gruss,
Boris.

Operating | Advanced Micro Devices GmbH
  System  | Karl-Hammerschmidt-Str. 34, 85609 Dornach b. München, Germany
 Research | Geschäftsführer: Andrew Bowd, Thomas M. McCoy, Giuliano Meroni
  Center  | Sitz: Dornach, Gemeinde Aschheim, Landkreis München
  (OSRC)  | Registergericht München, HRB Nr. 43632

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ