2013-10-16 07:03:33

by Dave Young

[permalink] [raw]
Subject: [PATCH] x86 efi: efi reverve boot service fix


Current code check boot service region with kernel text region by:
start+size >= __pa_symbol(_text)
The end of the above region should be start + size - 1 instead.

I see this problem in ovmf + Fedora 19 grub boot:
text start: 1000000 md start: 800000 md size: 800000

Signed-off-by: Dave Young <[email protected]>
---
arch/x86/platform/efi/efi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

--- linux-2.6.orig/arch/x86/platform/efi/efi.c
+++ linux-2.6/arch/x86/platform/efi/efi.c
@@ -440,7 +440,7 @@ void __init efi_reserve_boot_services(vo
* - Not within any part of the kernel
* - Not the bios reserved area
*/
- if ((start+size >= __pa_symbol(_text)
+ if ((start + size - 1 >= __pa_symbol(_text)
&& start <= __pa_symbol(_end)) ||
!e820_all_mapped(start, start+size, E820_RAM) ||
memblock_is_region_reserved(start, size)) {


2013-10-16 07:11:56

by Dave Young

[permalink] [raw]
Subject: Re: [PATCH] x86 efi: efi reverve boot service fix

typo, fix hpa's mail address..

On 10/16/13 at 03:03pm, Dave Young wrote:
>
> Current code check boot service region with kernel text region by:
> start+size >= __pa_symbol(_text)
> The end of the above region should be start + size - 1 instead.
>
> I see this problem in ovmf + Fedora 19 grub boot:
> text start: 1000000 md start: 800000 md size: 800000
>
> Signed-off-by: Dave Young <[email protected]>
> ---
> arch/x86/platform/efi/efi.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> --- linux-2.6.orig/arch/x86/platform/efi/efi.c
> +++ linux-2.6/arch/x86/platform/efi/efi.c
> @@ -440,7 +440,7 @@ void __init efi_reserve_boot_services(vo
> * - Not within any part of the kernel
> * - Not the bios reserved area
> */
> - if ((start+size >= __pa_symbol(_text)
> + if ((start + size - 1 >= __pa_symbol(_text)
> && start <= __pa_symbol(_end)) ||
> !e820_all_mapped(start, start+size, E820_RAM) ||
> memblock_is_region_reserved(start, size)) {

2013-10-16 07:31:06

by H. Peter Anvin

[permalink] [raw]
Subject: Re: [PATCH] x86 efi: efi reverve boot service fix

On 10/16/2013 12:11 AM, Dave Young wrote:
>>
>> --- linux-2.6.orig/arch/x86/platform/efi/efi.c
>> +++ linux-2.6/arch/x86/platform/efi/efi.c
>> @@ -440,7 +440,7 @@ void __init efi_reserve_boot_services(vo
>> * - Not within any part of the kernel
>> * - Not the bios reserved area
>> */
>> - if ((start+size >= __pa_symbol(_text)
>> + if ((start + size - 1 >= __pa_symbol(_text)
>> && start <= __pa_symbol(_end)) ||
>> !e820_all_mapped(start, start+size, E820_RAM) ||
>> memblock_is_region_reserved(start, size)) {

It would be better to change >= to >.

-hpa

2013-10-16 08:07:26

by Matt Fleming

[permalink] [raw]
Subject: Re: [PATCH] x86 efi: efi reverve boot service fix

Also better include Maarten on Cc as the author of the code.

On Wed, 16 Oct, at 03:11:22PM, Dave Young wrote:
> typo, fix hpa's mail address..
>
> On 10/16/13 at 03:03pm, Dave Young wrote:
> >
> > Current code check boot service region with kernel text region by:
> > start+size >= __pa_symbol(_text)
> > The end of the above region should be start + size - 1 instead.
> >
> > I see this problem in ovmf + Fedora 19 grub boot:
> > text start: 1000000 md start: 800000 md size: 800000
> >
> > Signed-off-by: Dave Young <[email protected]>
> > ---
> > arch/x86/platform/efi/efi.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > --- linux-2.6.orig/arch/x86/platform/efi/efi.c
> > +++ linux-2.6/arch/x86/platform/efi/efi.c
> > @@ -440,7 +440,7 @@ void __init efi_reserve_boot_services(vo
> > * - Not within any part of the kernel
> > * - Not the bios reserved area
> > */
> > - if ((start+size >= __pa_symbol(_text)
> > + if ((start + size - 1 >= __pa_symbol(_text)
> > && start <= __pa_symbol(_end)) ||
> > !e820_all_mapped(start, start+size, E820_RAM) ||
> > memblock_is_region_reserved(start, size)) {

--
Matt Fleming, Intel Open Source Technology Center

2013-10-16 08:24:28

by Dave Young

[permalink] [raw]
Subject: Re: [PATCH] x86 efi: efi reverve boot service fix

On 10/16/13 at 12:29am, H. Peter Anvin wrote:
> On 10/16/2013 12:11 AM, Dave Young wrote:
> >>
> >> --- linux-2.6.orig/arch/x86/platform/efi/efi.c
> >> +++ linux-2.6/arch/x86/platform/efi/efi.c
> >> @@ -440,7 +440,7 @@ void __init efi_reserve_boot_services(vo
> >> * - Not within any part of the kernel
> >> * - Not the bios reserved area
> >> */
> >> - if ((start+size >= __pa_symbol(_text)
> >> + if ((start + size - 1 >= __pa_symbol(_text)
> >> && start <= __pa_symbol(_end)) ||
> >> !e820_all_mapped(start, start+size, E820_RAM) ||
> >> memblock_is_region_reserved(start, size)) {
>
> It would be better to change >= to >.

Both are fine to me, will resend with '>'

2013-10-16 08:35:48

by Dave Young

[permalink] [raw]
Subject: [PATCH v2] x86 efi: efi reverve boot service fix

Current code check boot service region with kernel text region by:
start+size >= __pa_symbol(_text)
The end of the above region should be start + size - 1 instead.

I see this problem in ovmf + Fedora 19 grub boot:
text start: 1000000 md start: 800000 md size: 800000

Signed-off-by: Dave Young <[email protected]>
---
v2: use > instead of >= per hpa

arch/x86/platform/efi/efi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

--- linux-2.6.orig/arch/x86/platform/efi/efi.c
+++ linux-2.6/arch/x86/platform/efi/efi.c
@@ -440,7 +440,7 @@ void __init efi_reserve_boot_services(vo
* - Not within any part of the kernel
* - Not the bios reserved area
*/
- if ((start+size >= __pa_symbol(_text)
+ if ((start + size > __pa_symbol(_text)
&& start <= __pa_symbol(_end)) ||
!e820_all_mapped(start, start+size, E820_RAM) ||
memblock_is_region_reserved(start, size)) {

2013-10-16 08:36:19

by Maarten Lankhorst

[permalink] [raw]
Subject: Re: [PATCH] x86 efi: efi reverve boot service fix

op 16-10-13 10:07, Matt Fleming schreef:
> Also better include Maarten on Cc as the author of the code.
>
> On Wed, 16 Oct, at 03:11:22PM, Dave Young wrote:
>> typo, fix hpa's mail address..
>>
>> On 10/16/13 at 03:03pm, Dave Young wrote:
>>> Current code check boot service region with kernel text region by:
>>> start+size >= __pa_symbol(_text)
>>> The end of the above region should be start + size - 1 instead.

Acked-by: Maarten Lankhorst <[email protected]>

>>> I see this problem in ovmf + Fedora 19 grub boot:
>>> text start: 1000000 md start: 800000 md size: 800000
>>>
>>> Signed-off-by: Dave Young <[email protected]>
>>> ---
>>> arch/x86/platform/efi/efi.c | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> --- linux-2.6.orig/arch/x86/platform/efi/efi.c
>>> +++ linux-2.6/arch/x86/platform/efi/efi.c
>>> @@ -440,7 +440,7 @@ void __init efi_reserve_boot_services(vo
>>> * - Not within any part of the kernel
>>> * - Not the bios reserved area
>>> */
>>> - if ((start+size >= __pa_symbol(_text)
>>> + if ((start + size - 1 >= __pa_symbol(_text)
>>> && start <= __pa_symbol(_end)) ||
>>> !e820_all_mapped(start, start+size, E820_RAM) ||
>>> memblock_is_region_reserved(start, size)) {

2013-10-16 08:36:26

by Dave Young

[permalink] [raw]
Subject: Re: [PATCH] x86 efi: efi reverve boot service fix

On 10/16/13 at 09:07am, Matt Fleming wrote:
> Also better include Maarten on Cc as the author of the code.

Will do in next version