lkml.org 
[lkml]   [2013]   [Jun]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] x86: Fix /proc/mtrr with base/size more than 44bits
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




\
 
 \ /
  Last update: 2013-06-13 23:01    [W:0.051 / U:2.040 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site