From: Zhenzhong Duan <zhenzhong.duan@oracle.com>
To: <yinghai@kernel.org>
Cc: <mingo@redhat.com>, <x86@kernel.org>, <tglx@linutronix.de>,
<joe.jin@oracle.com>, <linux-kernel@vger.kernel.org>,
<ethan.zhao@oracle.com>, <hpa@zytor.com>
Subject: 答复: Re: [PATCH] Fix an overflow in range_to_mtrr func
Date: Tue, 29 May 2012 18:26:25 -0700 (PDT) [thread overview]
Message-ID: <a1750a63-2af0-43d9-8d7c-307e1693b5da@default> (raw)
----- yinghai@kernel.org 写道:
> On Mon, May 28, 2012 at 5:29 AM, Zhenzhong Duan
> <zhenzhong.duan@oracle.com> wrote:
> > When boot x86_64 kernel 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 explicit type conversion to force a 64bit constant to fix it.
> > Useful for mem larger than or equal to 4T.
> >
> > Signed-off-by: Zhenzhong Duan <zhenzhong.duan@oracle.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..853a4c6 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 = (unsigned long)1 << align;
>
> how about
>
> sizek = 1UL << align;
>
>
> > if (debug_print) {
> > char start_factor = 'K', size_factor = 'K';
> > unsigned long start_base, size_base;
> > --
> > 1.7.3
> >
Yes, this looks more clean although same compiling result. Should i resend it?
reply other threads:[~2012-05-30 1:26 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=a1750a63-2af0-43d9-8d7c-307e1693b5da@default \
--to=zhenzhong.duan@oracle.com \
--cc=ethan.zhao@oracle.com \
--cc=hpa@zytor.com \
--cc=joe.jin@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
--cc=yinghai@kernel.org \
/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
all inboxes | Powered by JetHome®