[coreboot-gerrit] New patch to review for coreboot: amd/gx2 + amd/lx: Fix shift overflow issue

Stefan Reinauer (stefan.reinauer@coreboot.org) gerrit at coreboot.org
Thu May 5 03:04:26 CEST 2016


Stefan Reinauer (stefan.reinauer at coreboot.org) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/14617

-gerrit

commit ac92cdf1068ddfd71c26dca84b4cb701f048776b
Author: Stefan Reinauer <stefan.reinauer at coreboot.org>
Date:   Wed May 4 16:26:44 2016 -0700

    amd/gx2 + amd/lx: Fix shift overflow issue
    
    gcc 6.1 complains that SMM_OFFSET << 8 is larger than the register
    it is assigned to (rightly so):
    
    src/northbridge/amd/gx2/northbridgeinit.c:196:23: error: result of
        '1077936128 << 8' requires 40 bits to represent, but 'int' only
        has 32 bits [-Werror=shift-overflow=]
      msr.lo = (SMM_OFFSET << 8) & 0xfff00000;
                           ^~
    
    Change-Id: Ib0d669268202d222574abee335a6a65c8a255cc7
    Signed-off-by: Stefan Reinauer <stefan.reinauer at coreboot.org>
---
 src/northbridge/amd/gx2/northbridgeinit.c | 4 ++--
 src/northbridge/amd/lx/northbridgeinit.c  | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/northbridge/amd/gx2/northbridgeinit.c b/src/northbridge/amd/gx2/northbridgeinit.c
index 348cdb9..efbe51e 100644
--- a/src/northbridge/amd/gx2/northbridgeinit.c
+++ b/src/northbridge/amd/gx2/northbridgeinit.c
@@ -177,7 +177,7 @@ static void SMMGL0Init(struct gliutable *gl)
 	msr.hi = offset << 8 | gl->hi;
 	msr.hi |= SMM_OFFSET >> 24;
 
-	msr.lo = SMM_OFFSET << 8;
+	msr.lo = (SMM_OFFSET & 0x00ffffff) << 8;
 	msr.lo |= ((~(SMM_SIZE * 1024) + 1) >> 12) & 0xfffff;
 
 	wrmsr(gl->desc_name, msr);	/* MSR - See table above */
@@ -193,7 +193,7 @@ static void SMMGL1Init(struct gliutable *gl)
 	/* I don't think this is needed */
 	msr.hi &= 0xffffff00;
 	msr.hi |= (SMM_OFFSET >> 24);
-	msr.lo = (SMM_OFFSET << 8) & 0xfff00000;
+	msr.lo = (SMM_OFFSET & 0x00fff000) << 8;
 	msr.lo |= ((~(SMM_SIZE * 1024) + 1) >> 12) & 0xfffff;
 
 	wrmsr(gl->desc_name, msr);	/* MSR - See table above */
diff --git a/src/northbridge/amd/lx/northbridgeinit.c b/src/northbridge/amd/lx/northbridgeinit.c
index f385770..08259f8 100644
--- a/src/northbridge/amd/lx/northbridgeinit.c
+++ b/src/northbridge/amd/lx/northbridgeinit.c
@@ -164,7 +164,7 @@ static void SMMGL0Init(struct gliutable *gl)
 	msr.hi = offset << 8 | gl->hi;
 	msr.hi |= SMM_OFFSET >> 24;
 
-	msr.lo = SMM_OFFSET << 8;
+	msr.lo = (SMM_OFFSET & 0x00ffffff) << 8;
 	msr.lo |= ((~(SMM_SIZE * 1024) + 1) >> 12) & 0xfffff;
 
 	wrmsr(gl->desc_name, msr);	// MSR - See table above
@@ -181,7 +181,7 @@ static void SMMGL1Init(struct gliutable *gl)
 	/* I don't think this is needed */
 	msr.hi &= 0xffffff00;
 	msr.hi |= (SMM_OFFSET >> 24);
-	msr.lo = (SMM_OFFSET << 8) & 0xFFF00000;
+	msr.lo = (SMM_OFFSET & 0x00fff000) << 8;
 	msr.lo |= ((~(SMM_SIZE * 1024) + 1) >> 12) & 0xfffff;
 
 	wrmsr(gl->desc_name, msr);	// MSR - See table above



More information about the coreboot-gerrit mailing list