From: Aravind Gopalakrishnan <Aravind.Gopalakrishnan@amd.com>
To: <tglx@linutronix.de>, <mingo@redhat.com>, <hpa@zytor.com>,
<dougthompson@xmission.com>, <bp@alien8.de>,
<bhelgaas@google.com>, <jbeulich@suse.com>,
<linux-kernel@vger.kernel.org>, <linux-edac@vger.kernel.org>,
<linux-pci@vger.kernel.org>
Cc: Aravind Gopalakrishnan <Aravind.Gopalakrishnan@amd.com>
Subject: [PATCH 1/1] AMD64_EDAC: Fix incorrect wrap arounds due to left shift beyond 32 bits.
Date: Mon, 19 Aug 2013 19:27:52 -0500 [thread overview]
Message-ID: <1376958472-2150-2-git-send-email-Aravind.Gopalakrishnan@amd.com> (raw)
In-Reply-To: <1376958472-2150-1-git-send-email-Aravind.Gopalakrishnan@amd.com>
Link to the bug report:
http://marc.info/?l=linux-edac&m=137692201732220&w=2
dct_base and dct_limit obtain 32 bit register values when they read their
respective pci config space registers. A left shift beyond 32 bits will
cause them to wrap around. Similar case for chan_addr as can be seen from
the bug report. In the patch, we rectify this by casting chan_addr to u64
and by comparing dct_base and dct_limit against (sys_addr >> 27)
Tested on F15h, M30h with ECC turned on and works fine.
Signed-off-by: Aravind Gopalakrishnan <Aravind.Gopalakrishnan@amd.com>
diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
index b86228c..eb4793e 100644
--- a/drivers/edac/amd64_edac.c
+++ b/drivers/edac/amd64_edac.c
@@ -1558,11 +1558,12 @@ static int f15_m30h_match_to_this_node(struct amd64_pvt *pvt, unsigned range,
}
/* Verify sys_addr is within DCT Range. */
- dct_base = (dct_sel_baseaddr(pvt) << 27);
- dct_limit = (((dct_cont_limit_reg >> 11) & 0x1FFF) << 27) | 0x7FFFFFF;
+ dct_base = dct_sel_baseaddr(pvt);
+ dct_limit = (dct_cont_limit_reg >> 11) & 0x1FFF;
if (!(dct_cont_base_reg & BIT(0)) &&
- !(dct_base <= sys_addr && dct_limit >= sys_addr))
+ !(dct_base <= (sys_addr >> 27) &&
+ dct_limit >= (sys_addr >> 27)))
return -EINVAL;
/* Verify number of dct's that participate in channel interleaving. */
@@ -1614,7 +1615,7 @@ static int f15_m30h_match_to_this_node(struct amd64_pvt *pvt, unsigned range,
amd64_read_pci_cfg(pvt->F1,
DRAM_CONT_HIGH_OFF + (int) channel * 4,
&tmp);
- chan_addr += ((tmp >> 11) & 0xfff) << 27;
+ chan_addr += (u64) ((tmp >> 11) & 0xfff) << 27;
}
f15h_select_dct(pvt, channel);
--
1.7.10.4
next prev parent reply other threads:[~2013-08-20 0:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-20 0:27 [PATCH 0/1] " Aravind Gopalakrishnan
2013-08-20 0:27 ` Aravind Gopalakrishnan [this message]
2013-08-23 21:37 ` [PATCH 1/1] " Borislav Petkov
2013-08-23 23:07 ` Aravind Gopalakrishnan
2013-08-20 6:53 ` [PATCH 0/1] " Borislav Petkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1376958472-2150-2-git-send-email-Aravind.Gopalakrishnan@amd.com \
--to=aravind.gopalakrishnan@amd.com \
--cc=bhelgaas@google.com \
--cc=bp@alien8.de \
--cc=dougthompson@xmission.com \
--cc=hpa@zytor.com \
--cc=jbeulich@suse.com \
--cc=linux-edac@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome