All of lore.kernel.org
 help / color / mirror / Atom feed
From: "tip-bot for zhenzhong.duan" <zhenzhong.duan@oracle.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@kernel.org,
	zhenzhong.duan@oracle.com, tglx@linutronix.de
Subject: [tip:x86/urgent] x86, mtrr: Fix a type overflow in range_to_mtrr func
Date: Wed, 30 May 2012 16:22:50 -0700	[thread overview]
Message-ID: <tip-2da06af8106f8f35318bb084baf8448797ef058a@git.kernel.org> (raw)
In-Reply-To: <4FC5A77F.6060505@oracle.com>

Commit-ID:  2da06af8106f8f35318bb084baf8448797ef058a
Gitweb:     http://git.kernel.org/tip/2da06af8106f8f35318bb084baf8448797ef058a
Author:     zhenzhong.duan <zhenzhong.duan@oracle.com>
AuthorDate: Wed, 30 May 2012 12:52:15 +0800
Committer:  H. Peter Anvin <hpa@zytor.com>
CommitDate: Wed, 30 May 2012 14:37:00 -0700

x86, mtrr: Fix a type overflow in range_to_mtrr func

When boot on sun G5+ with 4T mem, see an overflow in mtrr cleanup as below.

*BAD*gran_size: 2G      chunk_size: 2G  num_reg: 10     lose cover RAM:
-18014398505283592M

This is because 1<<31 sign extended. Use an unsigned long constant to
fix it.  Useful for mem larger than or equal to 4T.

-v2: Use 64bit constant instead of explicit type conversion as suggested
by Yinghai. Description updated too.

Signed-off-by: Zhenzhong Duan <zhenzhong.duan@oracle.com>
Link: http://lkml.kernel.org/r/4FC5A77F.6060505@oracle.com
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
---
 arch/x86/kernel/cpu/mtrr/cleanup.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/cpu/mtrr/cleanup.c b/arch/x86/kernel/cpu/mtrr/cleanup.c
index ac140c7..bdda2e6 100644
--- a/arch/x86/kernel/cpu/mtrr/cleanup.c
+++ b/arch/x86/kernel/cpu/mtrr/cleanup.c
@@ -266,7 +266,7 @@ range_to_mtrr(unsigned int reg, unsigned long range_startk,
 		if (align > max_align)
 			align = max_align;
 
-		sizek = 1 << align;
+		sizek = 1UL << align;
 		if (debug_print) {
 			char start_factor = 'K', size_factor = 'K';
 			unsigned long start_base, size_base;

      reply	other threads:[~2012-05-30 23:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-28 12:29 [PATCH] Fix an overflow in range_to_mtrr func Zhenzhong Duan
2012-05-29 17:18 ` Yinghai Lu
2012-05-30  4:52   ` [PATCH v2] " zhenzhong.duan
2012-05-30 23:22     ` tip-bot for zhenzhong.duan [this message]

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=tip-2da06af8106f8f35318bb084baf8448797ef058a@git.kernel.org \
    --to=zhenzhong.duan@oracle.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.