bugGNU GRUB - Bugs: bug #43632, GRUB crashes on the Raspberry Pi

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #43632: GRUB crashes on the Raspberry Pi

Submitted by:  David Kozub <zub>
Submitted on:  Tue 18 Nov 2014 07:56:57 PM UTC  
 
Category: BootingSeverity: Major
Priority: 5 - NormalItem Group: Software Error
Status: FixedPrivacy: Public
Assigned to: NoneOriginator Name: 
Open/Closed: ClosedRelease: 
Release: Git masterReproducibility: Every Time
Planned Release: None

(Jump to the original submission Jump to the original submission)

Sun 07 Dec 2014 05:18:20 PM UTC, comment #7:

Fixed in 17328db3b33d67f2e5365fcb123d41aacc7ab16b. Thank you!

Andrei Borzenkov <arvidjaar>
Project Member
Fri 21 Nov 2014 08:16:00 PM UTC, comment #6:

That r4 was actually deliberete. I thought using one and the same register would make it seem, at first sight, like a push-pop while it's not. But after some sleep I'm not convinced the r4-r3 combo is any better (at first sight it makes one wonder: why move r4 to r3?). As there's plenty of comments, other than cursory look should make it clear.

So I will turn that into {r3,lr}, {r3, lr}. And I will send it to grub-devel.

Thank you!

David Kozub <zub>
Thu 20 Nov 2014 10:18:30 PM UTC, comment #5:

Doh!

Right, so I might swap the first {r4, lr} for {r3, lr} as well, for consistency. Either way, you've put as much work into this as I have - do you want to send the patch to grub-devel@gnu.org?

Leif Lindholm <leiflindholm>
Project Member
Thu 20 Nov 2014 09:08:56 PM UTC, comment #4:

Still "data abort". I think the trouble is that your patch clobbers r4.

I adapted your patch to preserve r4. This version works for me.

David Kozub <zub>
Thu 20 Nov 2014 02:48:23 PM UTC, comment #3:

Note to self - don't try write clever code when you really are too tired. Right, so in my defence, the image produced by my patch does superficially appear to work on my platform, but I clearly didn't test it sufficiently. It does not crash, but command line handling goes crazy.

The attached (final?) patch would be my preferred solution, and it resolves the command line handling with my setup. Can you give that a go as well please?

(file #32489)

Leif Lindholm <leiflindholm>
Project Member
Wed 19 Nov 2014 10:07:39 PM UTC, comment #2:

Hi. I tested the patch but it results in a hang.

I adapted your version so that it works again. And I have added some perhaps superflous comments, so feel free to edit it.

There could be more variations on the theme, like using r8 for the address calculation, and then restoring r8 together with lr but in the end it probably would not improve readability.

(file #32479)

David Kozub <zub>
Tue 18 Nov 2014 11:16:57 PM UTC, comment #1:

Thank you for your clear and detailed bug report.

Could you test the attached simplified (also compared to the original) version?

(file #32472)

Leif Lindholm <leiflindholm>
Project Member
Tue 18 Nov 2014 07:56:57 PM UTC, original submission:

My environment:

  • Raspbbery Pi B 2.0
  • U-boot master (commit bdf1638)
  • GRUB master (commit 004a2b1)
  • toolchain gcc-linaro-arm-linux-gnueabihf-raspbian-x64 from git://github.com/raspberrypi/tools.git (commit b0c3db7)
  • I compiled grub with ./configure --target=arm-linux-gnueabihf but I've also tested native build (with toolchain that comes with raspbian) with the same result
  • I'm loading GRUB like this: usb start;fatload mmc 0:1 0x20000 ${fdtfile};tftp 0x40000 core.img;bootm 0x40000 - 0x20000

What I see on the serial is:

---
## Booting kernel from Legacy Image at 00040000 ...
Image Name:
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 269020 Bytes = 262.7 KiB
Load Address: 08000000
Entry Point: 08000000
Verifying Checksum ... OK
## Flattened Device Tree blob at 00020000
Booting using the fdt blob at 0x020000
Loading Kernel Image ... OK
Loading Device Tree to 1eb47000, end 1eb4af7a ... OK

Starting kernel ...

  1. crossers

MMU tables generated
enabling MMU
MMU enabled
data abort
pc : [<080092dc>] lr : [<08054d54>]
sp : 08054d38 ip : 00000000 fp : 00000000
r10: 1eb4d644 r9 : 1eb4cef8 r8 : 80000000
r7 : 00000000 r6 : 00000000 r5 : 00000000 r4 : 00000008
r3 : 00000000 r2 : 0000000d r1 : 00000000 r0 : 000000c7
Flags: nzCv IRQs off FIQs off Mode SVC_32
Resetting CPU ...

resetting ...
---

I think the issue is an unaligned 64bit local variable in __aeabi_uidivmod() (in grub-core/kern/arm/misc.S).

__aeabi_uidivmod() calls grub_divmod64(), passing it a pointer to grub_uint64_t as the last argument. At least with my toolchain grub_divmod64() uses the STRD instruction to store a value into the 64bit variable. But as the value is not aligned at 8 bytes, an exception occurrs.

Attached is a patch that solves this for me.

David Kozub <zub>

 

Attached Files
file #32489:  0001-grub-core-kern-arm-misc.S-fix-unaligned-grub_uint64_.patch added by leiflindholm (1KiB - text/x-patch - Yet another simplified version.)
file #32479:  0001-grub-core-kern-arm-misc.S-fix-unaligned-grub_uint64_.patch added by zub (2KiB - text/x-patch - Yet another version.)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by arvidjaar (Posted a comment)
  • -unavailable- added by leiflindholm (Updated the item)
  • -unavailable- added by zub (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 7 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sun 07 Dec 2014 05:18:20 PM UTCarvidjaarStatusNone=>Fixed
      Open/ClosedOpen=>Closed
    Thu 20 Nov 2014 09:10:03 PM UTCzubAttached File-=>Added 0001-grub-core-kern-arm-misc.S-fix-unaligned-grub_uint64_.patch, #32491
    Thu 20 Nov 2014 02:48:23 PM UTCleiflindholmAttached File-=>Added 0001-grub-core-kern-arm-misc.S-fix-unaligned-grub_uint64_.patch, #32489
    Wed 19 Nov 2014 10:07:39 PM UTCzubAttached File-=>Added 0001-grub-core-kern-arm-misc.S-fix-unaligned-grub_uint64_.patch, #32479
    Tue 18 Nov 2014 11:16:57 PM UTCleiflindholmAttached File-=>Added 0001-grub-core-kern-arm-misc.S-fix-unaligned-grub_uint64_.patch, #32472
    Tue 18 Nov 2014 07:56:57 PM UTCzubAttached File-=>Added 0001-grub-core-kern-arm-misc.S-fix-unaligned-grub_uint64_.patch, #32466

    Back to the top


    Powered by Savane 3.1-cleanup1