* [PATCH] x86: adjust generic_get_mtrr() for 64-bit
@ 2012-07-06 14:14 Jan Beulich
2012-07-06 21:38 ` Yinghai Lu
0 siblings, 1 reply; 4+ messages in thread
From: Jan Beulich @ 2012-07-06 14:14 UTC (permalink / raw)
To: mingo, tglx, hpa; +Cc: linux-kernel
Needing to deal with potentially large memory configurations, the
variables here should be "unsigned long" instead of "unsigned int".
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
arch/x86/kernel/cpu/mtrr/generic.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
--- 3.5-rc5/arch/x86/kernel/cpu/mtrr/generic.c
+++ 3.5-rc5-x86-mtrr-generic-types/arch/x86/kernel/cpu/mtrr/generic.c
@@ -514,8 +514,8 @@ generic_get_free_region(unsigned long ba
static void generic_get_mtrr(unsigned int reg, unsigned long *base,
unsigned long *size, mtrr_type *type)
{
- unsigned int mask_lo, mask_hi, base_lo, base_hi;
- unsigned int tmp, hi;
+ unsigned long mask_lo, mask_hi, base_lo, base_hi, tmp;
+ unsigned int hi;
/*
* get_mtrr doesn't need to update mtrr_state, also it could be called
@@ -540,9 +540,9 @@ static void generic_get_mtrr(unsigned in
mask_lo = size_or_mask | tmp;
/* Expand tmp with high bits to all 1s: */
- hi = fls(tmp);
+ hi = fls_long(tmp);
if (hi > 0) {
- tmp |= ~((1<<(hi - 1)) - 1);
+ tmp |= ~((1UL<<(hi - 1)) - 1);
if (tmp != mask_lo) {
printk(KERN_WARNING "mtrr: your BIOS has configured an incorrect mask, fixing it.\n");
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] x86: adjust generic_get_mtrr() for 64-bit
2012-07-06 14:14 [PATCH] x86: adjust generic_get_mtrr() for 64-bit Jan Beulich
@ 2012-07-06 21:38 ` Yinghai Lu
2012-07-23 7:02 ` Jan Beulich
2012-07-25 7:51 ` Jan Beulich
0 siblings, 2 replies; 4+ messages in thread
From: Yinghai Lu @ 2012-07-06 21:38 UTC (permalink / raw)
To: Jan Beulich; +Cc: mingo, tglx, hpa, linux-kernel
On Fri, Jul 6, 2012 at 7:14 AM, Jan Beulich <JBeulich@suse.com> wrote:
> Needing to deal with potentially large memory configurations, the
> variables here should be "unsigned long" instead of "unsigned int".
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>
> ---
> arch/x86/kernel/cpu/mtrr/generic.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> --- 3.5-rc5/arch/x86/kernel/cpu/mtrr/generic.c
> +++ 3.5-rc5-x86-mtrr-generic-types/arch/x86/kernel/cpu/mtrr/generic.c
> @@ -514,8 +514,8 @@ generic_get_free_region(unsigned long ba
> static void generic_get_mtrr(unsigned int reg, unsigned long *base,
> unsigned long *size, mtrr_type *type)
> {
> - unsigned int mask_lo, mask_hi, base_lo, base_hi;
> - unsigned int tmp, hi;
> + unsigned long mask_lo, mask_hi, base_lo, base_hi, tmp;
> + unsigned int hi;
_lo, _hi means we want it as 32bit.
or we just change them to u32 to make it more clear ?
Thanks
Yinghai
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] x86: adjust generic_get_mtrr() for 64-bit
2012-07-06 21:38 ` Yinghai Lu
@ 2012-07-23 7:02 ` Jan Beulich
2012-07-25 7:51 ` Jan Beulich
1 sibling, 0 replies; 4+ messages in thread
From: Jan Beulich @ 2012-07-23 7:02 UTC (permalink / raw)
To: Yinghai Lu; +Cc: mingo, tglx, linux-kernel, hpa
>>> On 06.07.12 at 23:38, Yinghai Lu <yinghai@kernel.org> wrote:
> On Fri, Jul 6, 2012 at 7:14 AM, Jan Beulich <JBeulich@suse.com> wrote:
>> Needing to deal with potentially large memory configurations, the
>> variables here should be "unsigned long" instead of "unsigned int".
>>
>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>>
>> ---
>> arch/x86/kernel/cpu/mtrr/generic.c | 8 ++++----
>> 1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> --- 3.5-rc5/arch/x86/kernel/cpu/mtrr/generic.c
>> +++ 3.5-rc5-x86-mtrr-generic-types/arch/x86/kernel/cpu/mtrr/generic.c
>> @@ -514,8 +514,8 @@ generic_get_free_region(unsigned long ba
>> static void generic_get_mtrr(unsigned int reg, unsigned long *base,
>> unsigned long *size, mtrr_type *type)
>> {
>> - unsigned int mask_lo, mask_hi, base_lo, base_hi;
>> - unsigned int tmp, hi;
>> + unsigned long mask_lo, mask_hi, base_lo, base_hi, tmp;
>> + unsigned int hi;
>
> _lo, _hi means we want it as 32bit.
>
> or we just change them to u32 to make it more clear ?
Agreed, it's really only "tmp" that needs to be "unsigned long".
I'll send out a v2 soon, at once converting lo/hi to u32.
Jan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] x86: adjust generic_get_mtrr() for 64-bit
2012-07-06 21:38 ` Yinghai Lu
2012-07-23 7:02 ` Jan Beulich
@ 2012-07-25 7:51 ` Jan Beulich
1 sibling, 0 replies; 4+ messages in thread
From: Jan Beulich @ 2012-07-25 7:51 UTC (permalink / raw)
To: Yinghai Lu; +Cc: mingo, tglx, linux-kernel, hpa
>>> On 06.07.12 at 23:38, Yinghai Lu <yinghai@kernel.org> wrote:
> On Fri, Jul 6, 2012 at 7:14 AM, Jan Beulich <JBeulich@suse.com> wrote:
>> Needing to deal with potentially large memory configurations, the
>> variables here should be "unsigned long" instead of "unsigned int".
>>
>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>>
>> ---
>> arch/x86/kernel/cpu/mtrr/generic.c | 8 ++++----
>> 1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> --- 3.5-rc5/arch/x86/kernel/cpu/mtrr/generic.c
>> +++ 3.5-rc5-x86-mtrr-generic-types/arch/x86/kernel/cpu/mtrr/generic.c
>> @@ -514,8 +514,8 @@ generic_get_free_region(unsigned long ba
>> static void generic_get_mtrr(unsigned int reg, unsigned long *base,
>> unsigned long *size, mtrr_type *type)
>> {
>> - unsigned int mask_lo, mask_hi, base_lo, base_hi;
>> - unsigned int tmp, hi;
>> + unsigned long mask_lo, mask_hi, base_lo, base_hi, tmp;
>> + unsigned int hi;
>
> _lo, _hi means we want it as 32bit.
>
> or we just change them to u32 to make it more clear ?
Actually, as I was about to do the adjustment, this isn't correct:
Both mask_hi and base_hi get shifted left in some calculations
there, and hence they would require up-casts to unsigned long
if their type would remain a 32-bit one. Further, mask_lo gets
or-ed with size_or_mask, which is u64, the result compared
with tmp (now unsigned long), and the same result also negated
so the *size (also unsigned long), so needs to be unsigned long
itself unless we want to introduce another variable.
That leaves only base_lo as a candidate for remaining 32-bit,
but for consistency I think it would be better to have them all
have the same type.
Consequently I think the patch should remain as is.
Jan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-07-25 7:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-06 14:14 [PATCH] x86: adjust generic_get_mtrr() for 64-bit Jan Beulich
2012-07-06 21:38 ` Yinghai Lu
2012-07-23 7:02 ` Jan Beulich
2012-07-25 7:51 ` Jan Beulich
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.