sparc64: OBP available region contains grub. Start at grub_phys_end
PATCH 1/1 sparc64: OBP available region contains grub. Start at grub_phys_end
OBP available region contains grub. Start at grub_phys_end.
This prevents a problem where grub was being overwritten since grub_phys_start does not start at a zero offset within the memory map.
--- grub-core/loader/sparc64/ieee1275/linux.c | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-)
grub-core/loader/sparc64/ieee1275/linux.c +8 -8
@@ -203,20 +203,20 @@ alloc_phys_choose (grub_uint64_t addr, grub_uint64_t len,if (addr + ctx->size >= end)return 0 ; -if (addr >= grub_phys_start && addr < grub_phys_end) - { - addr =ALIGN_UP (grub_phys_end,FOUR_MB ); -if (addr + ctx->size >= end) -return 0 ; - } -if ((addr + ctx->size) >= grub_phys_start - && (addr + ctx->size) < grub_phys_end) +/* OBP available region contains grub. Start at grub_phys_end. */ +/* grub_phys_start does not start at the beginning of the memory region */ +if ((grub_phys_start >= addr && grub_phys_end < end) || + (addr > grub_phys_start && addr < grub_phys_end)) { addr =ALIGN_UP (grub_phys_end,FOUR_MB );if (addr + ctx->size >= end)return 0 ; } +grub_dprintf ("loader" , +"addr = 0x%lx grub_phys_start = 0x%lx grub_phys_end = 0x%lx\n" , + addr, grub_phys_start, grub_phys_end); +if (loaded) {grub_addr_t linux_end =ALIGN_UP (linux_paddr + linux_size,FOUR_MB );
Signature · 1 line
1.7.1
Committed, thanks
Quoted 45 lines · Eric Snowberg
OBP available region contains grub. Start at
grub_phys_end.This prevents a problem where grub was being overwritten since
grub_phys_startdoes not start at a zero offset within the memory map.Signed-off-by Eric Snowberg <[email protected]>--- grub-core/loader/sparc64/ieee1275/linux.c | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-)grub-core/loader/sparc64/ieee1275/linux.c +8
-8@@ -203,20 +203,20 @@ alloc_phys_choose (grub_uint64_t addr, grub_uint64_t len,if (addr + ctx->size >= end)return 0 ; -if (addr >= grub_phys_start && addr < grub_phys_end) - { - addr =ALIGN_UP (grub_phys_end,FOUR_MB ); -if (addr + ctx->size >= end) -return 0 ; - } -if ((addr + ctx->size) >= grub_phys_start - && (addr + ctx->size) < grub_phys_end) +/* OBP available region contains grub. Start at grub_phys_end. */ +/* grub_phys_start does not start at the beginning of the memory region */ +if ((grub_phys_start >= addr && grub_phys_end < end) || + (addr > grub_phys_start && addr < grub_phys_end)) { addr =ALIGN_UP (grub_phys_end,FOUR_MB );if (addr + ctx->size >= end)return 0 ; } +grub_dprintf ("loader" , +"addr = 0x%lx grub_phys_start = 0x%lx grub_phys_end = 0x%lx\n" , + addr, grub_phys_start, grub_phys_end); +if (loaded) {grub_addr_t linux_end =ALIGN_UP (linux_paddr + linux_size,FOUR_MB );
13.02.2016 00:35, Eric Snowberg пишет:
Quoted 21 lines
OBP available region contains grub. Start at
grub_phys_end.This prevents a problem where grub was being overwritten since
grub_phys_startdoes not start at a zero offset within the memory map.Signed-off-by Eric Snowberg <[email protected]>--- grub-core/loader/sparc64/ieee1275/linux.c | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-)grub-core/loader/sparc64/ieee1275/linux.c +0
-2@@ -203,20 +203,20 @@ alloc_phys_choose (grub_uint64_t addr, grub_uint64_t len,if (addr + ctx->size >= end)return 0 ; -if (addr >= grub_phys_start && addr < grub_phys_end) - {
grub-core/loader/sparc64/ieee1275/linux.c alloc_phys_choose (grub_uint64_t addr, grub_uint64_t len, · line 209
Quoted 10 lines
grub-core/loader/sparc64/ieee1275/linux.c +4
-6- addr =ALIGN_UP (grub_phys_end,FOUR_MB ); -if (addr + ctx->size >= end) -return 0 ; - } -if ((addr + ctx->size) >= grub_phys_start - && (addr + ctx->size) < grub_phys_end) +/* OBP available region contains grub. Start at grub_phys_end. */ +/* grub_phys_start does not start at the beginning of the memory region */ +if ((grub_phys_start >= addr && grub_phys_end < end) || + (addr > grub_phys_start && addr < grub_phys_end))
What about
a) overlapping regions?
addr < grub_phys_start < end < grub_phys_end
b) is is possible for requested region to fit before grub?
addr < end < grub_phys_start
Quoted 14 lines
grub-core/loader/sparc64/ieee1275/linux.c +4
-0{ addr =ALIGN_UP (grub_phys_end,FOUR_MB );if (addr + ctx->size >= end)return 0 ; } +grub_dprintf ("loader" , +"addr = 0x%lx grub_phys_start = 0x%lx grub_phys_end = 0x%lx\n" , + addr, grub_phys_start, grub_phys_end); +if (loaded) {grub_addr_t linux_end =ALIGN_UP (linux_paddr + linux_size,FOUR_MB );
Le sam. 13 févr. 2016 06:30, Andrei Borzenkov <[email protected]> a écrit :
Quoted 36 lines
13.02.2016 00:35, Eric Snowberg пишет:
Quoted 6 lines
OBP available region contains grub. Start at
grub_phys_end.This prevents a problem where grub was being overwritten since
grub_phys_startdoes not start at a zero offset within the memory map.Review
Quoted 6 lines
Signed-off-by Eric Snowberg <[email protected]>--- grub-core/loader/sparc64/ieee1275/linux.c | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-)(quoted diff) +0
-0
b/grub-core/loader/sparc64/ieee1275/linux.cgrub-core/loader/sparc64/ieee1275/linux.c alloc_phys_choose (grub_uint64_t addr,
Quoted 4 lines
index d44d7a1..67ef048 100644
grub-core/loader/sparc64/ieee1275/linux.c +0
-0@@ -203,20 +203,20 @@ alloc_phys_choose (grub_uint64_t addr,
grub_uint64_tlen,grub-core/loader/sparc64/ieee1275/linux.c alloc_phys_choose (grub_uint64_t addr, grub_uint64_t len,
Quoted 13 lines
grub-core/loader/sparc64/ieee1275/linux.c +2
-8if (addr + ctx->size >= end)return 0 ; -if (addr >= grub_phys_start && addr < grub_phys_end) - { - addr =ALIGN_UP (grub_phys_end,FOUR_MB ); -if (addr + ctx->size >= end) -return 0 ; - } -if ((addr + ctx->size) >= grub_phys_start - && (addr + ctx->size) < grub_phys_end) +/* OBP available region contains grub. Start at grub_phys_end. */ +/* grub_phys_start does not start at the beginning of the memory region */
grub-core/loader/sparc64/ieee1275/linux.c alloc_phys_choose (grub_uint64_t addr, grub_uint64_t len, · line 209
Quoted 2 lines
grub-core/loader/sparc64/ieee1275/linux.c +2
-0+if ((grub_phys_start >= addr && grub_phys_end < end) || + (addr > grub_phys_start && addr < grub_phys_end))
Quoted 7 lines
What about
a) overlapping regions?
addr <
grub_phys_start< end <grub_phys_endGood catch. Condition should have been
grub_phys_start >= addr && grub_phys_start < end) || (addr > grub_phys_start && addr < grub_phys_end))
My pattern matching algorithm failed and I thought it was standard check for segment intersection but it wasn't. I'll fix this
Quoted 3 lines
b) is is possible for requested region to fit before grub?
There is only 16KiB of memory before GRUB but thinking about it again, it's 16 KiB of virtual memory, not physical. What about attached patch?
Quoted 26 lines
addr < end <
grub_phys_startgrub-core/loader/sparc64/ieee1275/linux.c alloc_phys_choose (grub_uint64_t addr, grub_uint64_t len,
Quoted 13 lines
grub-core/loader/sparc64/ieee1275/linux.c +4
-0{ addr =ALIGN_UP (grub_phys_end,FOUR_MB );if (addr + ctx->size >= end)return 0 ; } +grub_dprintf ("loader" , +"addr = 0x%lx grub_phys_start = 0x%lx grub_phys_end = 0x%lx\n" , + addr, grub_phys_start, grub_phys_end); +if (loaded) { grub_addr_t linux_end = ALIGN_UP (linux_paddr + linux_size,
FOUR_MB);Quoted 1 line
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
13.02.2016 16:56, Vladimir 'phcoder' Serbinenko пишет:
Quoted 53 lines
Le sam. 13 févr. 2016 06:30, Andrei Borzenkov <[email protected]> a écrit :
Quoted 36 lines
13.02.2016 00:35, Eric Snowberg пишет:
Quoted 6 lines
OBP available region contains grub. Start at
grub_phys_end.This prevents a problem where grub was being overwritten since
grub_phys_startdoes not start at a zero offset within the memory map.Review
Quoted 6 lines
Signed-off-by Eric Snowberg <[email protected]>--- grub-core/loader/sparc64/ieee1275/linux.c | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-)(quoted diff) +0
-0
b/grub-core/loader/sparc64/ieee1275/linux.cgrub-core/loader/sparc64/ieee1275/linux.c alloc_phys_choose (grub_uint64_t addr,
Quoted 4 lines
index d44d7a1..67ef048 100644
grub-core/loader/sparc64/ieee1275/linux.c +0
-0@@ -203,20 +203,20 @@ alloc_phys_choose (grub_uint64_t addr,
grub_uint64_tlen,grub-core/loader/sparc64/ieee1275/linux.c alloc_phys_choose (grub_uint64_t addr, grub_uint64_t len,
Quoted 13 lines
grub-core/loader/sparc64/ieee1275/linux.c +2
-8if (addr + ctx->size >= end)return 0 ; -if (addr >= grub_phys_start && addr < grub_phys_end) - { - addr =ALIGN_UP (grub_phys_end,FOUR_MB ); -if (addr + ctx->size >= end) -return 0 ; - } -if ((addr + ctx->size) >= grub_phys_start - && (addr + ctx->size) < grub_phys_end) +/* OBP available region contains grub. Start at grub_phys_end. */ +/* grub_phys_start does not start at the beginning of the memory region */
grub-core/loader/sparc64/ieee1275/linux.c alloc_phys_choose (grub_uint64_t addr, grub_uint64_t len, · line 209
Quoted 2 lines
grub-core/loader/sparc64/ieee1275/linux.c +2
-0+if ((grub_phys_start >= addr && grub_phys_end < end) || + (addr > grub_phys_start && addr < grub_phys_end))Quoted 7 lines
What about
a) overlapping regions?
addr <
grub_phys_start< end <grub_phys_endGood catch. Condition should have been
grub_phys_start>= addr &&grub_phys_start< end) || (addr >grub_phys_start&& addr <grub_phys_end))
My pattern matching algorithm failed and I thought it was standard check for segment intersection but it wasn't. I'll fix thisQuoted 1 line
Quoted 5 lines
Quoted 2 lines
b) is is possible for requested region to fit before grub?
There is only 16KiB of memory before GRUB but thinking about it again, it's 16 KiB of virtual memory, not physical. What about attached patch?
As far as I understand what it does looks OK.
Quoted 38 lines · Andrei Borzenkov
13.02.2016 00:35, Eric Snowberg пишет:
Quoted 21 lines
OBP available region contains grub. Start at
grub_phys_end.This prevents a problem where grub was being overwritten since
grub_phys_startdoes not start at a zero offset within the memory map.Signed-off-by Eric Snowberg <[email protected]>---
grub-core/loader/sparc64/ieee1275/linux.c| 16 ++++++++--------1 files changed, 8 insertions(+), 8 deletions(-)grub-core/loader/sparc64/ieee1275/linux.c +0
-2@@ -203,20 +203,20 @@ alloc_phys_choose (grub_uint64_t addr, grub_uint64_t len,if (addr + ctx->size >= end)return 0 ; -if (addr >= grub_phys_start && addr < grub_phys_end) - {grub-core/loader/sparc64/ieee1275/linux.c alloc_phys_choose (grub_uint64_t addr, grub_uint64_t len, · line 209
Quoted 10 lines
grub-core/loader/sparc64/ieee1275/linux.c +4
-6- addr =ALIGN_UP (grub_phys_end,FOUR_MB ); -if (addr + ctx->size >= end) -return 0 ; - } -if ((addr + ctx->size) >= grub_phys_start - && (addr + ctx->size) < grub_phys_end) +/* OBP available region contains grub. Start at grub_phys_end. */ +/* grub_phys_start does not start at the beginning of the memory region */ +if ((grub_phys_start >= addr && grub_phys_end < end) || + (addr > grub_phys_start && addr < grub_phys_end))What about
Quoted 8 lines
a) overlapping regions?
addr <
grub_phys_start< end <grub_phys_endb) is is possible for requested region to fit before grub?
addr < end <
grub_phys_start
On SPARC, there is always an 8k offset from the beginning of memory to grub_phys_start. I had intentionally skipped this memory for the 2 cases above.
Quoted 13 lines
Quoted 13 lines
grub-core/loader/sparc64/ieee1275/linux.c +4
-0{ addr =ALIGN_UP (grub_phys_end,FOUR_MB );if (addr + ctx->size >= end)return 0 ; } +grub_dprintf ("loader" , +"addr = 0x%lx grub_phys_start = 0x%lx grub_phys_end = 0x%lx\n" , + addr, grub_phys_start, grub_phys_end); +if (loaded) {grub_addr_t linux_end =ALIGN_UP (linux_paddr + linux_size,FOUR_MB );
Le Sat, Feb 13, 2016 à 5:03 PM, Eric Snowberg <[email protected]> a écrit :
Quoted 48 lines
Quoted 2 lines
On Feb 12, 2016, at 10:30 PM, Andrei Borzenkov <[email protected]>
Quoted 8 lines · wrote:
13.02.2016 00:35, Eric Snowberg пишет:
Quoted 6 lines
OBP available region contains grub. Start at
grub_phys_end.This prevents a problem where grub was being overwritten since
grub_phys_startdoes not start at a zero offset within the memory map.Quoted 6 lines
Review
Quoted 6 lines
Signed-off-by Eric Snowberg <[email protected]>---
grub-core/loader/sparc64/ieee1275/linux.c| 16 ++++++++--------1 files changed, 8 insertions(+), 8 deletions(-)(quoted diff) +0
-0
b/grub-core/loader/sparc64/ieee1275/linux.cQuoted 4 lines
grub-core/loader/sparc64/ieee1275/linux.c alloc_phys_choose (grub_uint64_t addr,
Quoted 4 lines
index d44d7a1..67ef048 100644
grub-core/loader/sparc64/ieee1275/linux.c +0
-0@@ -203,20 +203,20 @@ alloc_phys_choose (grub_uint64_t addr,
grub_uint64_tlen,Quoted 13 lines
grub-core/loader/sparc64/ieee1275/linux.c alloc_phys_choose (grub_uint64_t addr, grub_uint64_t len,
Quoted 13 lines
grub-core/loader/sparc64/ieee1275/linux.c +2
-8if (addr + ctx->size >= end)return 0 ; -if (addr >= grub_phys_start && addr < grub_phys_end) - { - addr =ALIGN_UP (grub_phys_end,FOUR_MB ); -if (addr + ctx->size >= end) -return 0 ; - } -if ((addr + ctx->size) >= grub_phys_start - && (addr + ctx->size) < grub_phys_end) +/* OBP available region contains grub. Start at grub_phys_end. */ +/* grub_phys_start does not start at the beginning of the memory region */
Quoted 11 lines
grub-core/loader/sparc64/ieee1275/linux.c alloc_phys_choose (grub_uint64_t addr, grub_uint64_t len, · line 209
Quoted 2 lines
grub-core/loader/sparc64/ieee1275/linux.c +2
-0+if ((grub_phys_start >= addr && grub_phys_end < end) || + (addr > grub_phys_start && addr < grub_phys_end))What about
a) overlapping regions?
addr <
grub_phys_start< end <grub_phys_endb) is is possible for requested region to fit before grub?
Quoted 8 lines
Quoted 2 lines
addr < end <
grub_phys_startOn SPARC, there is always an 8k offset from the beginning of memory to
grub_phys_start. I had intentionally skipped this memory for the 2 cases above.Isn't this an internal implementation detail of OBP? It has to be 8k in
virtual memory but why does it have to be in physical memory?
Quoted 22 lines
Quoted 7 lines
Quoted 7 lines
grub-core/loader/sparc64/ieee1275/linux.c +0
-0{ addr =ALIGN_UP (grub_phys_end,FOUR_MB );if (addr + ctx->size >= end)return 0 ; }Quoted 7 lines
grub-core/loader/sparc64/ieee1275/linux.c alloc_phys_choose (grub_uint64_t addr, grub_uint64_t len,
Quoted 7 lines
grub-core/loader/sparc64/ieee1275/linux.c +4
-0+grub_dprintf ("loader" , +"addr = 0x%lx grub_phys_start = 0x%lx grub_phys_end = 0x%lx\n" , + addr, grub_phys_start, grub_phys_end); +if (loaded) { grub_addr_t linux_end = ALIGN_UP (linux_paddr + linux_size,
FOUR_MB);_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 48 lines · Vladimir 'phcoder' Serbinenko
Quoted 41 lines · Eric Snowberg
On Feb 12, 2016, at 10:30 PM, Andrei Borzenkov <[email protected]> wrote:
13.02.2016 00:35, Eric Snowberg пишет:
Quoted 21 lines
OBP available region contains grub. Start at
grub_phys_end.This prevents a problem where grub was being overwritten since
grub_phys_startdoes not start at a zero offset within the memory map.Signed-off-by Eric Snowberg <[email protected]>---
grub-core/loader/sparc64/ieee1275/linux.c| 16 ++++++++--------1 files changed, 8 insertions(+), 8 deletions(-)grub-core/loader/sparc64/ieee1275/linux.c +0
-2@@ -203,20 +203,20 @@ alloc_phys_choose (grub_uint64_t addr, grub_uint64_t len,if (addr + ctx->size >= end)return 0 ; -if (addr >= grub_phys_start && addr < grub_phys_end) - {grub-core/loader/sparc64/ieee1275/linux.c alloc_phys_choose (grub_uint64_t addr, grub_uint64_t len, · line 209
Quoted 10 lines
grub-core/loader/sparc64/ieee1275/linux.c +4
-6- addr =ALIGN_UP (grub_phys_end,FOUR_MB ); -if (addr + ctx->size >= end) -return 0 ; - } -if ((addr + ctx->size) >= grub_phys_start - && (addr + ctx->size) < grub_phys_end) +/* OBP available region contains grub. Start at grub_phys_end. */ +/* grub_phys_start does not start at the beginning of the memory region */ +if ((grub_phys_start >= addr && grub_phys_end < end) || + (addr > grub_phys_start && addr < grub_phys_end))What about
a) overlapping regions?
addr <
grub_phys_start< end <grub_phys_end
Quoted 9 lines
Quoted 4 lines
b) is is possible for requested region to fit before grub?
addr < end <
grub_phys_startOn SPARC, there is always an 8k offset from the beginning of memory to
grub_phys_start. I had intentionally skipped this memory for the 2 cases above.Isn't this an internal implementation detail of OBP? It has to be 8k in virtual memory but why does it have to be in physical memory?
My understanding is this is OBP’s internal implementation, I’m not sure the history behind it. I’ve verified this is the same on 10 year old hardware as it is on current generation hardware. This bug (that this patch fixes) will only show up on older machines though, since there is typically only one large memory map. The newer machines don’t see this do to the way grub_machine_mmap_iterate finds available memory. The newer machines hit the other memory bug for which I submitted a patch.
Quoted 23 lines
Quoted 6 lines
Quoted 6 lines
grub-core/loader/sparc64/ieee1275/linux.c +0
-0{ addr =ALIGN_UP (grub_phys_end,FOUR_MB );if (addr + ctx->size >= end)return 0 ; }Quoted 7 lines
grub-core/loader/sparc64/ieee1275/linux.c alloc_phys_choose (grub_uint64_t addr, grub_uint64_t len, · line 222
Quoted 7 lines
grub-core/loader/sparc64/ieee1275/linux.c +4
-0+grub_dprintf ("loader" , +"addr = 0x%lx grub_phys_start = 0x%lx grub_phys_end = 0x%lx\n" , + addr, grub_phys_start, grub_phys_end); +if (loaded) {grub_addr_t linux_end =ALIGN_UP (linux_paddr + linux_size,FOUR_MB );_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel