Skip to contentSkip to conversation

xen: arm: traps: correct cond

PATCH In review Peng Fan 4 participants 5 messages Sep 21, 2015 – Sep 22, 2015

lore
Share & tools
lore

Peng Fan

author
#0 lore raw

PATCH 2/2 xen: arm: traps: correct cond

Quoted 1 line

From "G6.2.29 CPSR, Current Program Status Register" of Aarch64 ARM

and "B1.3.3 Program Status Registers (PSRs)" of ARMv7-A ARM:
"
IT[7:5] holds the base condition for the IT block. The base condition is
the top 3 bits of the condition code specified by the first condition field of the IT instruction.
IT[4:0] encodes the size of the IT block, which is the number of
instructions that are to be conditionally executed, by the position of the least significant 1 in this field. It also encodes the value of the least significant bit of the condition code for each instruction in the block.
"

So should be "cond = ( it >> 5 );" but not "cond = ( it >> 4 );"

Cc Ian Campbell <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Julien Grall <[email protected]>
---
 xen/arch/arm/traps.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
xen/arch/arm/traps.c +2 -2
index 2e2b1f2..b2879b7 100644
@@ -1561,8 +1561,8 @@ static int check_conditional_instr(struct cpu_user_regs *regs,
         if ( it == 0 )
             return 1;
 
-        /* The cond for this instruction works out as the top 4 bits. */
-        cond = ( it >> 4 );
+        /* The cond for this instruction works out as the top 3 bits. */
+        cond = ( it >> 5 );
     }
 
     cpsr_cond = cpsr >> 28;
Signature · 1 line
1.8.4
#1 lore raw

Hi Peng,

Quoted 3 lines · Peng Fan

From "G6.2.29 CPSR, Current Program Status Register" of Aarch64 ARM and "B1.3.3 Program Status Registers (PSRs)" of ARMv7-A ARM:
"

The section number may change between the different version of the spec. Can you also precise the spec version?

For instance on my ARM64 spec (ARM DDI 0497A.d) the section G6.2.29 points to "CSSELR" and not "CPSR".

Quoted 10 lines

IT[7:5] holds the base condition for the IT block. The base condition is
the top 3 bits of the condition code specified by the first condition field of the IT instruction.
IT[4:0] encodes the size of the IT block, which is the number of
instructions that are to be conditionally executed, by the position of the least significant 1 in this field. It also encodes the value of the least significant bit of the condition code for each instruction in the block.
"
So should be "cond = ( it >> 5 );" but not "cond = ( it >> 4 );"

IT[7:5] encodes the top 3 bits of the condition code and one bit of IT[4:0] will contain the least significant bit of the condition code.

In order to get the full condition code you have to use IT[7:4] which the current code does (see A2.5.2 ARM DDI 0406C.b).

So the current code looks valid to me. Did I miss something?

Regards,

Quoted 24 lines
Cc Ian Campbell <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Julien Grall <[email protected]>
---
 xen/arch/arm/traps.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
xen/arch/arm/traps.c +2 -2
index 2e2b1f2..b2879b7 100644
@@ -1561,8 +1561,8 @@ static int check_conditional_instr(struct cpu_user_regs *regs,
         if ( it == 0 )
             return 1;
 
-        /* The cond for this instruction works out as the top 4 bits. */
-        cond = ( it >> 4 );
+        /* The cond for this instruction works out as the top 3 bits. */
+        cond = ( it >> 5 );
     }
 
     cpsr_cond = cpsr >> 28;
Signature · 1 line
Julien Grall
#2 lore raw
Quoted 24 lines · Julien Grall

Hi Peng,

Quoted 3 lines · Peng Fan

From "G6.2.29 CPSR, Current Program Status Register" of Aarch64 ARM and "B1.3.3 Program Status Registers (PSRs)" of ARMv7-A ARM:
"

The section number may change between the different version of the spec. Can you also precise the spec version?

For instance on my ARM64 spec (ARM DDI 0497A.d) the section G6.2.29 points to "CSSELR" and not "CPSR".

Quoted 10 lines

IT[7:5] holds the base condition for the IT block. The base condition is
the top 3 bits of the condition code specified by the first condition field of the IT instruction.
IT[4:0] encodes the size of the IT block, which is the number of
instructions that are to be conditionally executed, by the position of the least significant 1 in this field. It also encodes the value of the least significant bit of the condition code for each instruction in the block.
"
So should be "cond = ( it >> 5 );" but not "cond = ( it >> 4 );"

Quoted 7 lines

IT[7:5] encodes the top 3 bits of the condition code and one bit of IT[4:0] will contain the least significant bit of the condition code.

In order to get the full condition code you have to use IT[7:4] which the current code does (see A2.5.2 ARM DDI 0406C.b).

So the current code looks valid to me. Did I miss something?

No, you are correct.

Thanks,
Peng.

Quoted 30 lines

Regards,

Quoted 24 lines
Cc Ian Campbell <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Julien Grall <[email protected]>
---
 xen/arch/arm/traps.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
xen/arch/arm/traps.c +2 -2
index 2e2b1f2..b2879b7 100644
@@ -1561,8 +1561,8 @@ static int check_conditional_instr(struct cpu_user_regs *regs,
         if ( it == 0 )
             return 1;
 
-        /* The cond for this instruction works out as the top 4 bits. */
-        cond = ( it >> 4 );
+        /* The cond for this instruction works out as the top 3 bits. */
+        cond = ( it >> 5 );
     }
 
     cpsr_cond = cpsr >> 28;
Signature · 1 line
Julien Grall
#3 lore raw
Quoted 30 lines · Peng Fan
Quoted 29 lines · Julien Grall

Hi Peng,

Quoted 3 lines · Peng Fan

From "G6.2.29 CPSR, Current Program Status Register" of Aarch64 ARM and "B1.3.3 Program Status Registers (PSRs)" of ARMv7-A ARM:
"

The section number may change between the different version of the spec.
Can you also precise the spec version?

For instance on my ARM64 spec (ARM DDI 0497A.d) the section G6.2.29 points to "CSSELR" and not "CPSR".

Quoted 11 lines

IT[7:5] holds the base condition for the IT block. The base condition is
the top 3 bits of the condition code specified by the first condition field of the IT instruction.
IT[4:0] encodes the size of the IT block, which is the number of
instructions that are to be conditionally executed, by the position of the least significant 1 in this field. It also encodes the value of the least significant bit of the condition code for each instruction in the block.
"
So should be "cond = ( it >> 5 );" but not "cond = ( it >> 4 );"

IT[7:5] encodes the top 3 bits of the condition code and one bit of IT[4:0] will contain the least significant bit of the condition code.

Quoted 6 lines
Quoted 4 lines

In order to get the full condition code you have to use IT[7:4] which the current code does (see A2.5.2 ARM DDI 0406C.b).

So the current code looks valid to me. Did I miss something?

No, you are correct.

Were these two patches motivated by an actual issue you were seeing? Or just from code inspection?

#4 lore raw
Quoted 34 lines · Ian Campbell
Quoted 33 lines · Peng Fan
Quoted 32 lines · Julien Grall

Hi Peng,

Quoted 3 lines · Peng Fan

From "G6.2.29 CPSR, Current Program Status Register" of Aarch64 ARM and "B1.3.3 Program Status Registers (PSRs)" of ARMv7-A ARM:
"

The section number may change between the different version of the spec.
Can you also precise the spec version?

For instance on my ARM64 spec (ARM DDI 0497A.d) the section G6.2.29 points to "CSSELR" and not "CPSR".

Quoted 11 lines

IT[7:5] holds the base condition for the IT block. The base condition is
the top 3 bits of the condition code specified by the first condition field of the IT instruction.
IT[4:0] encodes the size of the IT block, which is the number of
instructions that are to be conditionally executed, by the position of the least significant 1 in this field. It also encodes the value of the least significant bit of the condition code for each instruction in the block.
"
So should be "cond = ( it >> 5 );" but not "cond = ( it >> 4 );"

IT[7:5] encodes the top 3 bits of the condition code and one bit of IT[4:0] will contain the least significant bit of the condition code.

In order to get the full condition code you have to use IT[7:4] which the current code does (see A2.5.2 ARM DDI 0406C.b).

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

So the current code looks valid to me. Did I miss something?

No, you are correct.

Were these two patches motivated by an actual issue you were seeing? Or just from code inspection?

Just code inspection, not an actual issue.

Regards,
Peng.

Quoted 1 line