lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 16 Mar 2015 21:24:12 +0000
From:	"Kani, Toshimitsu" <toshi.kani@...com>
To:	Ingo Molnar <mingo@...nel.org>
CC:	"akpm@...ux-foundation.org" <akpm@...ux-foundation.org>,
	"hpa@...or.com" <hpa@...or.com>,
	"tglx@...utronix.de" <tglx@...utronix.de>,
	"mingo@...hat.com" <mingo@...hat.com>,
	"linux-mm@...ck.org" <linux-mm@...ck.org>,
	"x86@...nel.org" <x86@...nel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"dave.hansen@...el.com" <dave.hansen@...el.com>,
	"Elliott, Robert (Server Storage)" <Elliott@...com>,
	"pebolle@...cali.nl" <pebolle@...cali.nl>
Subject: Re: [PATCH v3 4/5] mtrr, x86: Clean up mtrr_type_lookup()

> On Mar 16, 2015, at 3:58 AM, Ingo Molnar <mingo@...nel.org> wrote:
> 
> 
> * Toshi Kani <toshi.kani@...com> wrote:
> 
>> MTRRs contain fixed and variable entries.  mtrr_type_lookup()
>> may repeatedly call __mtrr_type_lookup() to handle a request
>> that overlaps with variable entries.  However,
>> __mtrr_type_lookup() also handles the fixed entries, which
>> do not have to be repeated.  Therefore, this patch creates
>> separate functions, mtrr_type_lookup_fixed() and
>> mtrr_type_lookup_variable(), to handle the fixed and variable
>> ranges respectively.
>> 
>> The patch also updates the function headers to clarify the
>> return values and output argument.  It updates comments to
>> clarify that the repeating is necessary to handle overlaps
>> with the default type, since overlaps with multiple entries
>> alone can be handled without such repeating.
>> 
>> There is no functional change in this patch.
> 
> Nice cleanup!
> 
> I also suggest adding a small table to the comments before the 
> function, that lists the fixed purpose MTRRs and their address ranges 
> - to make it more obvious what the magic hexadecimal constants within 
> the code are doing.

Yes, I will add a table to describe the fixed entries.

>> +static u8 mtrr_type_lookup_fixed(u64 start, u64 end)
>> +{
>> +    int idx;
>> +
>> +    if (start >= 0x100000)
>> +        return 0xFF;
> 
> Btw., as a separate cleanup patch, we should probably also change 
> '0xFF' (which is sometimes written as 0xff) to be some sufficiently 
> named constant, and explain its usage somewhere?

Sounds good.  I will add a separate patch to do so.

>> +    if (!(mtrr_state.have_fixed) ||
>> +        !(mtrr_state.enabled & MTRR_STATE_MTRR_FIXED_ENABLED))
> 
> Btw., can MTRR_STATE_MTRR_FIXED_ENABLED ever be set in 
> mtrr_state.enabled, without mtrr_state.have_fixed being set?

Yes, I believe the arch allows the fixed entries disabled
while MTRRs are enabled.  I expect the most of systems 
implement the fixed entries, though.

> AFAICS get_mtrr_state() will only ever fill in mtrr_state with fixed 
> MTRRs if mtrr_state.have_fixed != 0 - but I might be mis-reading the 
> (rather convoluted) flow of code ...

I will check the code next week.

Thanks,
-Toshi
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ