From: "H. Peter Anvin" <hpa@zytor.com>
To: Yinghai Lu <yinghai@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@elte.hu>,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] x86: Fix /proc/mtrr with base/size more than 44bits
Date: Thu, 13 Jun 2013 13:47:48 -0700 [thread overview]
Message-ID: <51BA2FF4.6000604@zytor.com> (raw)
In-Reply-To: <1371149617-17880-1-git-send-email-yinghai@kernel.org>
On 06/13/2013 11:53 AM, Yinghai Lu wrote:
>
> - if (base & size_or_mask || size & size_or_mask) {
> + if (base >> (boot_cpu_data.x86_phys_bits - PAGE_SHIFT) ||
> + base > (base + size) ||
> + (base + size - 1) >> (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) {
> pr_warning("mtrr: base or size exceeds the MTRR width\n");
> return -EINVAL;
> }
Most of this patch looks good as far as being a minimal patch, but I'm
really confused about this bit. Could you explain the reason for why
the original doesn't work? (To be fair: I am not even sure the original
does anything useful so it could just be a "this is just too broken to
live" kind of thing.)
The first and third clause of the test can be simplified, however:
(base | (base + size - 1)) >> (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)
... although it would be cleaner to put boot_cpu_data.x86_phys_bits -
PAGE_SHIFT into a variable.
A lot of the mask_hi/mask_lo stuff should just get removed by using
rdmsrl/wrmsrl, but that is not stable material obviously.
-hpa
next prev parent reply other threads:[~2013-06-13 20:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-13 18:53 [PATCH] x86: Fix /proc/mtrr with base/size more than 44bits Yinghai Lu
2013-06-13 20:47 ` H. Peter Anvin [this message]
2013-06-13 22:11 ` Yinghai Lu
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=51BA2FF4.6000604@zytor.com \
--to=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=stable@vger.kernel.org \
--cc=tglx@linutronix.de \
--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 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.