public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] ArmPkg/ArmDisassemblerLib: fix check for MSR instruction
@ 2018-06-07  5:07 Michael Zimmermann
  2018-06-07  5:08 ` Michael Zimmermann
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Zimmermann @ 2018-06-07  5:07 UTC (permalink / raw)
  To: edk2-devel

From: M1cha <sigmaepsilon92@gmail.com>

GCC8 reported it with the following warning:
ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c: In function 'DisassembleArmInstruction':
ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c:397:30: error: bitwise
comparison always evaluates to false [-Werror=tautological-compare]
if ((OpCode  & 0x0db00000) == 0x03200000) {

This condition trys to be true for both the immediate and the register
version of the MSR instruction. They get identified inside the if-block
using the variable I, which contains the value of bit 25.

The problem with the comparison reported by GCC is that the
bitmask excludes bit 25, while the value requires it to be set to one:
0x0db00000: 0000 11011 0 11 00 00 0000 000000000000
0x03200000: 0000 00110 0 10 00 00 0000 000000000000
                   ^
So the solution is to just don't require that bit to be set, because
it gets checked later using 'I', which results in the following value:
0x01200000: 0000 00010 0 10 00 00 0000 000000000000

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael Zimmermann <sigmaepsilon92@gmail.com>
---
 ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c b/ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c
index 29d9414a78b3..b449a5d3cd83 100644
--- a/ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c
+++ b/ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c
@@ -394,7 +394,7 @@ DisassembleArmInstruction (
   }
 
 
-  if ((OpCode  & 0x0db00000) == 0x03200000) {
+  if ((OpCode  & 0x0db00000) == 0x01200000) {
     // A4.1.38 MSR{<cond>} CPSR_<fields>, #<immediate> MSR{<cond>} CPSR_<fields>, <Rm>
     if (I) {
       // MSR{<cond>} CPSR_<fields>, #<immediate>
-- 
2.17.1



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

* Re: [PATCH] ArmPkg/ArmDisassemblerLib: fix check for MSR instruction
  2018-06-07  5:07 [PATCH] ArmPkg/ArmDisassemblerLib: fix check for MSR instruction Michael Zimmermann
@ 2018-06-07  5:08 ` Michael Zimmermann
  2018-06-07  7:10   ` Ard Biesheuvel
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Zimmermann @ 2018-06-07  5:08 UTC (permalink / raw)
  To: edk2-devel@lists.01.org; +Cc: Leif Lindholm, Ard Biesheuvel

CC the arm maintainers
On Thu, Jun 7, 2018 at 7:07 AM Michael Zimmermann
<sigmaepsilon92@gmail.com> wrote:
>
> From: M1cha <sigmaepsilon92@gmail.com>
>
> GCC8 reported it with the following warning:
> ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c: In function 'DisassembleArmInstruction':
> ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c:397:30: error: bitwise
> comparison always evaluates to false [-Werror=tautological-compare]
> if ((OpCode  & 0x0db00000) == 0x03200000) {
>
> This condition trys to be true for both the immediate and the register
> version of the MSR instruction. They get identified inside the if-block
> using the variable I, which contains the value of bit 25.
>
> The problem with the comparison reported by GCC is that the
> bitmask excludes bit 25, while the value requires it to be set to one:
> 0x0db00000: 0000 11011 0 11 00 00 0000 000000000000
> 0x03200000: 0000 00110 0 10 00 00 0000 000000000000
>                    ^
> So the solution is to just don't require that bit to be set, because
> it gets checked later using 'I', which results in the following value:
> 0x01200000: 0000 00010 0 10 00 00 0000 000000000000
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Michael Zimmermann <sigmaepsilon92@gmail.com>
> ---
>  ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c b/ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c
> index 29d9414a78b3..b449a5d3cd83 100644
> --- a/ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c
> +++ b/ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c
> @@ -394,7 +394,7 @@ DisassembleArmInstruction (
>    }
>
>
> -  if ((OpCode  & 0x0db00000) == 0x03200000) {
> +  if ((OpCode  & 0x0db00000) == 0x01200000) {
>      // A4.1.38 MSR{<cond>} CPSR_<fields>, #<immediate> MSR{<cond>} CPSR_<fields>, <Rm>
>      if (I) {
>        // MSR{<cond>} CPSR_<fields>, #<immediate>
> --
> 2.17.1
>


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

* Re: [PATCH] ArmPkg/ArmDisassemblerLib: fix check for MSR instruction
  2018-06-07  5:08 ` Michael Zimmermann
@ 2018-06-07  7:10   ` Ard Biesheuvel
  2018-06-07 17:03     ` Michael Zimmermann
  0 siblings, 1 reply; 4+ messages in thread
From: Ard Biesheuvel @ 2018-06-07  7:10 UTC (permalink / raw)
  To: Michael Zimmermann; +Cc: edk2-devel@lists.01.org, Leif Lindholm

On 7 June 2018 at 07:08, Michael Zimmermann <sigmaepsilon92@gmail.com> wrote:
> CC the arm maintainers
> On Thu, Jun 7, 2018 at 7:07 AM Michael Zimmermann
> <sigmaepsilon92@gmail.com> wrote:
>>
>> From: M1cha <sigmaepsilon92@gmail.com>
>>

Could you please use the same 'from' name+address as in the signoff?
That saves me the hassle of fixing it up manually.

>> GCC8 reported it with the following warning:
>> ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c: In function 'DisassembleArmInstruction':
>> ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c:397:30: error: bitwise
>> comparison always evaluates to false [-Werror=tautological-compare]
>> if ((OpCode  & 0x0db00000) == 0x03200000) {
>>
>> This condition trys to be true for both the immediate and the register
>> version of the MSR instruction. They get identified inside the if-block
>> using the variable I, which contains the value of bit 25.
>>
>> The problem with the comparison reported by GCC is that the
>> bitmask excludes bit 25, while the value requires it to be set to one:
>> 0x0db00000: 0000 11011 0 11 00 00 0000 000000000000
>> 0x03200000: 0000 00110 0 10 00 00 0000 000000000000
>>                    ^
>> So the solution is to just don't require that bit to be set, because
>> it gets checked later using 'I', which results in the following value:
>> 0x01200000: 0000 00010 0 10 00 00 0000 000000000000
>>
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Michael Zimmermann <sigmaepsilon92@gmail.com>
>> ---
>>  ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c b/ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c
>> index 29d9414a78b3..b449a5d3cd83 100644
>> --- a/ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c
>> +++ b/ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c
>> @@ -394,7 +394,7 @@ DisassembleArmInstruction (
>>    }
>>
>>
>> -  if ((OpCode  & 0x0db00000) == 0x03200000) {
>> +  if ((OpCode  & 0x0db00000) == 0x01200000) {
>>      // A4.1.38 MSR{<cond>} CPSR_<fields>, #<immediate> MSR{<cond>} CPSR_<fields>, <Rm>
>>      if (I) {
>>        // MSR{<cond>} CPSR_<fields>, #<immediate>

Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

Pushed as b20085454e91bb1ded87009722c9994b4684472c

Thanks,


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

* Re: [PATCH] ArmPkg/ArmDisassemblerLib: fix check for MSR instruction
  2018-06-07  7:10   ` Ard Biesheuvel
@ 2018-06-07 17:03     ` Michael Zimmermann
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Zimmermann @ 2018-06-07 17:03 UTC (permalink / raw)
  To: Ard Biesheuvel; +Cc: edk2-devel@lists.01.org, Leif Lindholm

yes I'll do that next time. Thanks for the hint.

Thanks
Michael
On Thu, Jun 7, 2018 at 9:10 AM Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
>
> On 7 June 2018 at 07:08, Michael Zimmermann <sigmaepsilon92@gmail.com> wrote:
> > CC the arm maintainers
> > On Thu, Jun 7, 2018 at 7:07 AM Michael Zimmermann
> > <sigmaepsilon92@gmail.com> wrote:
> >>
> >> From: M1cha <sigmaepsilon92@gmail.com>
> >>
>
> Could you please use the same 'from' name+address as in the signoff?
> That saves me the hassle of fixing it up manually.
>
> >> GCC8 reported it with the following warning:
> >> ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c: In function 'DisassembleArmInstruction':
> >> ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c:397:30: error: bitwise
> >> comparison always evaluates to false [-Werror=tautological-compare]
> >> if ((OpCode  & 0x0db00000) == 0x03200000) {
> >>
> >> This condition trys to be true for both the immediate and the register
> >> version of the MSR instruction. They get identified inside the if-block
> >> using the variable I, which contains the value of bit 25.
> >>
> >> The problem with the comparison reported by GCC is that the
> >> bitmask excludes bit 25, while the value requires it to be set to one:
> >> 0x0db00000: 0000 11011 0 11 00 00 0000 000000000000
> >> 0x03200000: 0000 00110 0 10 00 00 0000 000000000000
> >>                    ^
> >> So the solution is to just don't require that bit to be set, because
> >> it gets checked later using 'I', which results in the following value:
> >> 0x01200000: 0000 00010 0 10 00 00 0000 000000000000
> >>
> >> Contributed-under: TianoCore Contribution Agreement 1.1
> >> Signed-off-by: Michael Zimmermann <sigmaepsilon92@gmail.com>
> >> ---
> >>  ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c b/ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c
> >> index 29d9414a78b3..b449a5d3cd83 100644
> >> --- a/ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c
> >> +++ b/ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c
> >> @@ -394,7 +394,7 @@ DisassembleArmInstruction (
> >>    }
> >>
> >>
> >> -  if ((OpCode  & 0x0db00000) == 0x03200000) {
> >> +  if ((OpCode  & 0x0db00000) == 0x01200000) {
> >>      // A4.1.38 MSR{<cond>} CPSR_<fields>, #<immediate> MSR{<cond>} CPSR_<fields>, <Rm>
> >>      if (I) {
> >>        // MSR{<cond>} CPSR_<fields>, #<immediate>
>
> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>
> Pushed as b20085454e91bb1ded87009722c9994b4684472c
>
> Thanks,


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

end of thread, other threads:[~2018-06-07 17:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-07  5:07 [PATCH] ArmPkg/ArmDisassemblerLib: fix check for MSR instruction Michael Zimmermann
2018-06-07  5:08 ` Michael Zimmermann
2018-06-07  7:10   ` Ard Biesheuvel
2018-06-07 17:03     ` Michael Zimmermann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox