grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] grub-core/kern/arm/misc.S: fix unaligned grub_uint64_t local variable
@ 2014-11-20 20:53 David Kozub
  2014-11-25 11:43 ` Leif Lindholm
  0 siblings, 1 reply; 6+ messages in thread
From: David Kozub @ 2014-11-20 20:53 UTC (permalink / raw)
  To: grub-devel

The unaligned local in __aeabi_uidivmod leads to a store to a 64bit
value at an address that is not divisible by 8 (in grub_divmod64).
The compiler most likely generates a STRD instruction to store it and
this causes an exception.

Fixes Savannah bug #43632.

This includes improvements done by Leif Lindholm.
---
 ChangeLog                 |  6 ++++++
 grub-core/kern/arm/misc.S | 14 +++++++-------
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 6fbec06..8728c04 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2014-11-21  David Kozub  <zub.272@gmail.com>
+
+	* grub-core/kern/arm/misc.S: fix unaligned 64bit local variable
+	in __aeabi_uidivmod
+	Fixes Savannah bug #43632.
+
 2014-11-20  Andrei Borzenkov  <arvidjaar@gmail.com>
 
 	* tests/util/grub-fs-tester.in: Consistently print output
diff --git a/grub-core/kern/arm/misc.S b/grub-core/kern/arm/misc.S
index 8943cc3..16b6f8e 100644
--- a/grub-core/kern/arm/misc.S
+++ b/grub-core/kern/arm/misc.S
@@ -60,17 +60,17 @@ FUNCTION(__aeabi_lmul)
 
 	.macro division parent
 
-        stmfd   sp!, {lr}
-        sub     sp, sp, #12
+        sub     sp, sp, #8      @ Allocate naturally aligned 64-bit space
+        stmfd   sp!, {r3,lr}    @ Dummy r3 to maintain stack alignment
+        add     r3, sp, #8      @ Set r3 to address of 64-bit space
+        str     r3, [sp]        @ Stack parameter, pointer to 64-bit space
         mov     r2, r1
-        add     r1, sp, #4
-        str     r1, [sp, #0]
         mov     r1, #0
         mov     r3, #0
         bl      \parent
-	ldr     r1, [sp, #4]
-        add     sp, sp, #12
-        ldmfd   sp!, {lr}
+        ldr     r1, [sp, #8]    @ Extract remainder
+        ldmfd   sp!, {r3,lr}    @ Pop into an unused arg/scratch register
+        add     sp, sp, #8
         bx      lr
 	.endm
 
-- 
2.1.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] grub-core/kern/arm/misc.S: fix unaligned grub_uint64_t local variable
  2014-11-20 20:53 [PATCH] grub-core/kern/arm/misc.S: fix unaligned grub_uint64_t local variable David Kozub
@ 2014-11-25 11:43 ` Leif Lindholm
  2014-11-27 14:25   ` Andrei Borzenkov
  2014-11-28 19:15   ` Vladimir 'φ-coder/phcoder' Serbinenko
  0 siblings, 2 replies; 6+ messages in thread
From: Leif Lindholm @ 2014-11-25 11:43 UTC (permalink / raw)
  To: The development of GNU GRUB

On Thu, Nov 20, 2014 at 09:53:14PM +0100, David Kozub wrote:
> The unaligned local in __aeabi_uidivmod leads to a store to a 64bit
> value at an address that is not divisible by 8 (in grub_divmod64).
> The compiler most likely generates a STRD instruction to store it and
> this causes an exception.
> 
> Fixes Savannah bug #43632.

I agree with this patch - am I OK to push?

/
    Leif
 
> This includes improvements done by Leif Lindholm.
> ---
>  ChangeLog                 |  6 ++++++
>  grub-core/kern/arm/misc.S | 14 +++++++-------
>  2 files changed, 13 insertions(+), 7 deletions(-)
> 
> diff --git a/ChangeLog b/ChangeLog
> index 6fbec06..8728c04 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,3 +1,9 @@
> +2014-11-21  David Kozub  <zub.272@gmail.com>
> +
> +	* grub-core/kern/arm/misc.S: fix unaligned 64bit local variable
> +	in __aeabi_uidivmod
> +	Fixes Savannah bug #43632.
> +
>  2014-11-20  Andrei Borzenkov  <arvidjaar@gmail.com>
>  
>  	* tests/util/grub-fs-tester.in: Consistently print output
> diff --git a/grub-core/kern/arm/misc.S b/grub-core/kern/arm/misc.S
> index 8943cc3..16b6f8e 100644
> --- a/grub-core/kern/arm/misc.S
> +++ b/grub-core/kern/arm/misc.S
> @@ -60,17 +60,17 @@ FUNCTION(__aeabi_lmul)
>  
>  	.macro division parent
>  
> -        stmfd   sp!, {lr}
> -        sub     sp, sp, #12
> +        sub     sp, sp, #8      @ Allocate naturally aligned 64-bit space
> +        stmfd   sp!, {r3,lr}    @ Dummy r3 to maintain stack alignment
> +        add     r3, sp, #8      @ Set r3 to address of 64-bit space
> +        str     r3, [sp]        @ Stack parameter, pointer to 64-bit space
>          mov     r2, r1
> -        add     r1, sp, #4
> -        str     r1, [sp, #0]
>          mov     r1, #0
>          mov     r3, #0
>          bl      \parent
> -	ldr     r1, [sp, #4]
> -        add     sp, sp, #12
> -        ldmfd   sp!, {lr}
> +        ldr     r1, [sp, #8]    @ Extract remainder
> +        ldmfd   sp!, {r3,lr}    @ Pop into an unused arg/scratch register
> +        add     sp, sp, #8
>          bx      lr
>  	.endm
>  
> -- 
> 2.1.1
> 
> 
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] grub-core/kern/arm/misc.S: fix unaligned grub_uint64_t local variable
  2014-11-25 11:43 ` Leif Lindholm
@ 2014-11-27 14:25   ` Andrei Borzenkov
  2014-12-07 17:05     ` Vladimir 'φ-coder/phcoder' Serbinenko
  2014-11-28 19:15   ` Vladimir 'φ-coder/phcoder' Serbinenko
  1 sibling, 1 reply; 6+ messages in thread
From: Andrei Borzenkov @ 2014-11-27 14:25 UTC (permalink / raw)
  To: Leif Lindholm; +Cc: The development of GNU GRUB

В Tue, 25 Nov 2014 11:43:57 +0000
Leif Lindholm <leif.lindholm@linaro.org> пишет:

> On Thu, Nov 20, 2014 at 09:53:14PM +0100, David Kozub wrote:
> > The unaligned local in __aeabi_uidivmod leads to a store to a 64bit
> > value at an address that is not divisible by 8 (in grub_divmod64).
> > The compiler most likely generates a STRD instruction to store it and
> > this causes an exception.
> > 
> > Fixes Savannah bug #43632.
> 
> I agree with this patch - am I OK to push?

Yes, you are the best expert here.

> 
> /
>     Leif
>  
> > This includes improvements done by Leif Lindholm.
> > ---
> >  ChangeLog                 |  6 ++++++
> >  grub-core/kern/arm/misc.S | 14 +++++++-------
> >  2 files changed, 13 insertions(+), 7 deletions(-)
> > 
> > diff --git a/ChangeLog b/ChangeLog
> > index 6fbec06..8728c04 100644
> > --- a/ChangeLog
> > +++ b/ChangeLog
> > @@ -1,3 +1,9 @@
> > +2014-11-21  David Kozub  <zub.272@gmail.com>
> > +
> > +	* grub-core/kern/arm/misc.S: fix unaligned 64bit local variable
> > +	in __aeabi_uidivmod
> > +	Fixes Savannah bug #43632.
> > +
> >  2014-11-20  Andrei Borzenkov  <arvidjaar@gmail.com>
> >  
> >  	* tests/util/grub-fs-tester.in: Consistently print output
> > diff --git a/grub-core/kern/arm/misc.S b/grub-core/kern/arm/misc.S
> > index 8943cc3..16b6f8e 100644
> > --- a/grub-core/kern/arm/misc.S
> > +++ b/grub-core/kern/arm/misc.S
> > @@ -60,17 +60,17 @@ FUNCTION(__aeabi_lmul)
> >  
> >  	.macro division parent
> >  
> > -        stmfd   sp!, {lr}
> > -        sub     sp, sp, #12
> > +        sub     sp, sp, #8      @ Allocate naturally aligned 64-bit space
> > +        stmfd   sp!, {r3,lr}    @ Dummy r3 to maintain stack alignment
> > +        add     r3, sp, #8      @ Set r3 to address of 64-bit space
> > +        str     r3, [sp]        @ Stack parameter, pointer to 64-bit space
> >          mov     r2, r1
> > -        add     r1, sp, #4
> > -        str     r1, [sp, #0]
> >          mov     r1, #0
> >          mov     r3, #0
> >          bl      \parent
> > -	ldr     r1, [sp, #4]
> > -        add     sp, sp, #12
> > -        ldmfd   sp!, {lr}
> > +        ldr     r1, [sp, #8]    @ Extract remainder
> > +        ldmfd   sp!, {r3,lr}    @ Pop into an unused arg/scratch register
> > +        add     sp, sp, #8
> >          bx      lr
> >  	.endm
> >  
> > -- 
> > 2.1.1
> > 
> > 
> > _______________________________________________
> > Grub-devel mailing list
> > Grub-devel@gnu.org
> > https://lists.gnu.org/mailman/listinfo/grub-devel
> 
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] grub-core/kern/arm/misc.S: fix unaligned grub_uint64_t local variable
  2014-11-25 11:43 ` Leif Lindholm
  2014-11-27 14:25   ` Andrei Borzenkov
@ 2014-11-28 19:15   ` Vladimir 'φ-coder/phcoder' Serbinenko
  1 sibling, 0 replies; 6+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2014-11-28 19:15 UTC (permalink / raw)
  To: The development of GNU GRUB

[-- Attachment #1: Type: text/plain, Size: 2607 bytes --]

On 25.11.2014 13:43, Leif Lindholm wrote:
> On Thu, Nov 20, 2014 at 09:53:14PM +0100, David Kozub wrote:
>> The unaligned local in __aeabi_uidivmod leads to a store to a 64bit
>> value at an address that is not divisible by 8 (in grub_divmod64).
>> The compiler most likely generates a STRD instruction to store it and
>> this causes an exception.
>>
>> Fixes Savannah bug #43632.
> 
> I agree with this patch - am I OK to push?
> 
Go ahead.
> /
>     Leif
>  
>> This includes improvements done by Leif Lindholm.
>> ---
>>  ChangeLog                 |  6 ++++++
>>  grub-core/kern/arm/misc.S | 14 +++++++-------
>>  2 files changed, 13 insertions(+), 7 deletions(-)
>>
>> diff --git a/ChangeLog b/ChangeLog
>> index 6fbec06..8728c04 100644
>> --- a/ChangeLog
>> +++ b/ChangeLog
>> @@ -1,3 +1,9 @@
>> +2014-11-21  David Kozub  <zub.272@gmail.com>
>> +
>> +	* grub-core/kern/arm/misc.S: fix unaligned 64bit local variable
>> +	in __aeabi_uidivmod
>> +	Fixes Savannah bug #43632.
>> +
>>  2014-11-20  Andrei Borzenkov  <arvidjaar@gmail.com>
>>  
>>  	* tests/util/grub-fs-tester.in: Consistently print output
>> diff --git a/grub-core/kern/arm/misc.S b/grub-core/kern/arm/misc.S
>> index 8943cc3..16b6f8e 100644
>> --- a/grub-core/kern/arm/misc.S
>> +++ b/grub-core/kern/arm/misc.S
>> @@ -60,17 +60,17 @@ FUNCTION(__aeabi_lmul)
>>  
>>  	.macro division parent
>>  
>> -        stmfd   sp!, {lr}
>> -        sub     sp, sp, #12
>> +        sub     sp, sp, #8      @ Allocate naturally aligned 64-bit space
>> +        stmfd   sp!, {r3,lr}    @ Dummy r3 to maintain stack alignment
>> +        add     r3, sp, #8      @ Set r3 to address of 64-bit space
>> +        str     r3, [sp]        @ Stack parameter, pointer to 64-bit space
>>          mov     r2, r1
>> -        add     r1, sp, #4
>> -        str     r1, [sp, #0]
>>          mov     r1, #0
>>          mov     r3, #0
>>          bl      \parent
>> -	ldr     r1, [sp, #4]
>> -        add     sp, sp, #12
>> -        ldmfd   sp!, {lr}
>> +        ldr     r1, [sp, #8]    @ Extract remainder
>> +        ldmfd   sp!, {r3,lr}    @ Pop into an unused arg/scratch register
>> +        add     sp, sp, #8
>>          bx      lr
>>  	.endm
>>  
>> -- 
>> 2.1.1
>>
>>
>> _______________________________________________
>> Grub-devel mailing list
>> Grub-devel@gnu.org
>> https://lists.gnu.org/mailman/listinfo/grub-devel
> 
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 213 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] grub-core/kern/arm/misc.S: fix unaligned grub_uint64_t local variable
  2014-11-27 14:25   ` Andrei Borzenkov
@ 2014-12-07 17:05     ` Vladimir 'φ-coder/phcoder' Serbinenko
  2014-12-11 15:51       ` Leif Lindholm
  0 siblings, 1 reply; 6+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2014-12-07 17:05 UTC (permalink / raw)
  To: The development of GNU GRUB

[-- Attachment #1: Type: text/plain, Size: 3001 bytes --]

Please commit and push.
On 27.11.2014 15:25, Andrei Borzenkov wrote:
> В Tue, 25 Nov 2014 11:43:57 +0000
> Leif Lindholm <leif.lindholm@linaro.org> пишет:
> 
>> On Thu, Nov 20, 2014 at 09:53:14PM +0100, David Kozub wrote:
>>> The unaligned local in __aeabi_uidivmod leads to a store to a 64bit
>>> value at an address that is not divisible by 8 (in grub_divmod64).
>>> The compiler most likely generates a STRD instruction to store it and
>>> this causes an exception.
>>>
>>> Fixes Savannah bug #43632.
>>
>> I agree with this patch - am I OK to push?
> 
> Yes, you are the best expert here.
> 
>>
>> /
>>     Leif
>>  
>>> This includes improvements done by Leif Lindholm.
>>> ---
>>>  ChangeLog                 |  6 ++++++
>>>  grub-core/kern/arm/misc.S | 14 +++++++-------
>>>  2 files changed, 13 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/ChangeLog b/ChangeLog
>>> index 6fbec06..8728c04 100644
>>> --- a/ChangeLog
>>> +++ b/ChangeLog
>>> @@ -1,3 +1,9 @@
>>> +2014-11-21  David Kozub  <zub.272@gmail.com>
>>> +
>>> +	* grub-core/kern/arm/misc.S: fix unaligned 64bit local variable
>>> +	in __aeabi_uidivmod
>>> +	Fixes Savannah bug #43632.
>>> +
>>>  2014-11-20  Andrei Borzenkov  <arvidjaar@gmail.com>
>>>  
>>>  	* tests/util/grub-fs-tester.in: Consistently print output
>>> diff --git a/grub-core/kern/arm/misc.S b/grub-core/kern/arm/misc.S
>>> index 8943cc3..16b6f8e 100644
>>> --- a/grub-core/kern/arm/misc.S
>>> +++ b/grub-core/kern/arm/misc.S
>>> @@ -60,17 +60,17 @@ FUNCTION(__aeabi_lmul)
>>>  
>>>  	.macro division parent
>>>  
>>> -        stmfd   sp!, {lr}
>>> -        sub     sp, sp, #12
>>> +        sub     sp, sp, #8      @ Allocate naturally aligned 64-bit space
>>> +        stmfd   sp!, {r3,lr}    @ Dummy r3 to maintain stack alignment
>>> +        add     r3, sp, #8      @ Set r3 to address of 64-bit space
>>> +        str     r3, [sp]        @ Stack parameter, pointer to 64-bit space
>>>          mov     r2, r1
>>> -        add     r1, sp, #4
>>> -        str     r1, [sp, #0]
>>>          mov     r1, #0
>>>          mov     r3, #0
>>>          bl      \parent
>>> -	ldr     r1, [sp, #4]
>>> -        add     sp, sp, #12
>>> -        ldmfd   sp!, {lr}
>>> +        ldr     r1, [sp, #8]    @ Extract remainder
>>> +        ldmfd   sp!, {r3,lr}    @ Pop into an unused arg/scratch register
>>> +        add     sp, sp, #8
>>>          bx      lr
>>>  	.endm
>>>  
>>> -- 
>>> 2.1.1
>>>
>>>
>>> _______________________________________________
>>> Grub-devel mailing list
>>> Grub-devel@gnu.org
>>> https://lists.gnu.org/mailman/listinfo/grub-devel
>>
>> _______________________________________________
>> Grub-devel mailing list
>> Grub-devel@gnu.org
>> https://lists.gnu.org/mailman/listinfo/grub-devel
> 
> 
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 213 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] grub-core/kern/arm/misc.S: fix unaligned grub_uint64_t local variable
  2014-12-07 17:05     ` Vladimir 'φ-coder/phcoder' Serbinenko
@ 2014-12-11 15:51       ` Leif Lindholm
  0 siblings, 0 replies; 6+ messages in thread
From: Leif Lindholm @ 2014-12-11 15:51 UTC (permalink / raw)
  To: The development of GNU GRUB

On 7 December 2014 at 17:05, Vladimir 'φ-coder/phcoder' Serbinenko
<phcoder@gmail.com> wrote:
> Please commit and push.

Apologies, I've been on holiday and then knocked down with a bad cold,
but I notice Andrei has now committed this - thanks!

/
    Leif


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-12-11 15:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-20 20:53 [PATCH] grub-core/kern/arm/misc.S: fix unaligned grub_uint64_t local variable David Kozub
2014-11-25 11:43 ` Leif Lindholm
2014-11-27 14:25   ` Andrei Borzenkov
2014-12-07 17:05     ` Vladimir 'φ-coder/phcoder' Serbinenko
2014-12-11 15:51       ` Leif Lindholm
2014-11-28 19:15   ` Vladimir 'φ-coder/phcoder' Serbinenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).