[PATCH] tools: Fix CPSR/SPSR print size

Bertrand Marquis posted 1 patch 2 years, 9 months ago
Test gitlab-ci failed
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/f28690afd8c4f36351fcdb1e95704cc5240b193a.1625583993.git.bertrand.marquis@arm.com
There is a newer version of this series
tools/libs/guest/xg_dom_arm.c | 4 ++--
tools/xentrace/xenctx.c       | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)
[PATCH] tools: Fix CPSR/SPSR print size
Posted by Bertrand Marquis 2 years, 9 months ago
With the changes of register size introduced in
918b8842a852e0e7446286f546724b1c63c56c66, CPSR and SPSR are now stored
as 64bit values.

Fix the print size to use 64bit type.

Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com>
---
 tools/libs/guest/xg_dom_arm.c | 4 ++--
 tools/xentrace/xenctx.c       | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/libs/guest/xg_dom_arm.c b/tools/libs/guest/xg_dom_arm.c
index 01e85e0ea9..5e3b76355e 100644
--- a/tools/libs/guest/xg_dom_arm.c
+++ b/tools/libs/guest/xg_dom_arm.c
@@ -140,7 +140,7 @@ static int vcpu_arm32(struct xc_dom_image *dom)
 
     ctxt->flags = VGCF_online;
 
-    DOMPRINTF("Initial state CPSR %#"PRIx32" PC %#"PRIx32,
+    DOMPRINTF("Initial state CPSR %#"PRIx64" PC %#"PRIx32,
            ctxt->user_regs.cpsr, ctxt->user_regs.pc32);
 
     rc = xc_vcpu_setcontext(dom->xch, dom->guest_domid, 0, &any_ctx);
@@ -182,7 +182,7 @@ static int vcpu_arm64(struct xc_dom_image *dom)
 
     ctxt->flags = VGCF_online;
 
-    DOMPRINTF("Initial state CPSR %#"PRIx32" PC %#"PRIx64,
+    DOMPRINTF("Initial state CPSR %#"PRIx64" PC %#"PRIx64,
            ctxt->user_regs.cpsr, ctxt->user_regs.pc64);
 
     rc = xc_vcpu_setcontext(dom->xch, dom->guest_domid, 0, &any_ctx);
diff --git a/tools/xentrace/xenctx.c b/tools/xentrace/xenctx.c
index 972f473dbf..85ba0c0fa6 100644
--- a/tools/xentrace/xenctx.c
+++ b/tools/xentrace/xenctx.c
@@ -556,7 +556,7 @@ static void print_ctx_32(vcpu_guest_context_t *ctx)
     printf("PC:       %08"PRIx32, regs->pc32);
     print_symbol(regs->pc32, KERNEL_TEXT_ADDR);
     printf("\n");
-    printf("CPSR:     %08"PRIx32"\n", regs->cpsr);
+    printf("CPSR:     %08"PRIx64"\n", regs->cpsr);
     printf("USR:               SP:%08"PRIx32" LR:%08"PRIx32"\n",
            regs->sp_usr, regs->lr_usr);
     printf("SVC: SPSR:%08"PRIx32" SP:%08"PRIx32" LR:%08"PRIx32"\n",
@@ -614,8 +614,8 @@ static void print_ctx_64(vcpu_guest_context_t *ctx)
     printf("LR:       %016"PRIx64"\n", regs->x30);
     printf("ELR_EL1:  %016"PRIx64"\n", regs->elr_el1);
 
-    printf("CPSR:     %08"PRIx32"\n", regs->cpsr);
-    printf("SPSR_EL1: %08"PRIx32"\n", regs->spsr_el1);
+    printf("CPSR:     %08"PRIx64"\n", regs->cpsr);
+    printf("SPSR_EL1: %08"PRIx64"\n", regs->spsr_el1);
 
     printf("SP_EL0:   %016"PRIx64"\n", regs->sp_el0);
     printf("SP_EL1:   %016"PRIx64"\n", regs->sp_el1);
-- 
2.17.1


Re: [PATCH] tools: Fix CPSR/SPSR print size
Posted by Julien Grall 2 years, 9 months ago
Hi Bertrand,

Thanks for the fix. I forgot to check the full tools build when sending 
the first fix :(.

On 06/07/2021 16:09, Bertrand Marquis wrote:
> With the changes of register size introduced in
> 918b8842a852e0e7446286f546724b1c63c56c66, CPSR and SPSR are now stored
> as 64bit values.
> 
> Fix the print size to use 64bit type.
> 

Can you add a fixes tag? This makes easier to find bug fix in the tree.

For this patch it would be:

Fixes: 918b8842a852 ("arm64: Change type of hsr, cpsr, spsr_el1 to 
uint64_t")

> Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com>

Just to confirm, with this patch and mine the tools build successfully 
on 32-bit and 64-bit?

Cheers,

-- 
Julien Grall

Re: [PATCH] tools: Fix CPSR/SPSR print size
Posted by Bertrand Marquis 2 years, 9 months ago
Hi Julien,

> On 6 Jul 2021, at 16:15, Julien Grall <julien@xen.org> wrote:
> 
> Hi Bertrand,
> 
> Thanks for the fix. I forgot to check the full tools build when sending the first fix :(.
> 
> On 06/07/2021 16:09, Bertrand Marquis wrote:
>> With the changes of register size introduced in
>> 918b8842a852e0e7446286f546724b1c63c56c66, CPSR and SPSR are now stored
>> as 64bit values.
>> Fix the print size to use 64bit type.
> 
> Can you add a fixes tag? This makes easier to find bug fix in the tree.
> 
> For this patch it would be:
> 
> Fixes: 918b8842a852 ("arm64: Change type of hsr, cpsr, spsr_el1 to uint64_t")

Sure. Patch incoming in the next minutes.

> 
>> Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com>
> 
> Just to confirm, with this patch and mine the tools build successfully on 32-bit and 64-bit?

Yes I have a full build running with both patches added for arm32, arm64 and x86_64.

Cheers
Bertrand

> 
> Cheers,
> 
> -- 
> Julien Grall
> 


Re: [PATCH] tools: Fix CPSR/SPSR print size
Posted by Julien Grall 2 years, 9 months ago

On 06/07/2021 16:23, Bertrand Marquis wrote:
> Hi Julien,

Hi Bertrand,

>> On 6 Jul 2021, at 16:15, Julien Grall <julien@xen.org> wrote:
>>
>> Hi Bertrand,
>>
>> Thanks for the fix. I forgot to check the full tools build when sending the first fix :(.
>>
>> On 06/07/2021 16:09, Bertrand Marquis wrote:
>>> With the changes of register size introduced in
>>> 918b8842a852e0e7446286f546724b1c63c56c66, CPSR and SPSR are now stored
>>> as 64bit values.
>>> Fix the print size to use 64bit type.
>>
>> Can you add a fixes tag? This makes easier to find bug fix in the tree.
>>
>> For this patch it would be:
>>
>> Fixes: 918b8842a852 ("arm64: Change type of hsr, cpsr, spsr_el1 to uint64_t")
> 
> Sure. Patch incoming in the next minutes.

I can fix it on commit.

> 
>>
>>> Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com>
>>
>> Just to confirm, with this patch and mine the tools build successfully on 32-bit and 64-bit?
> 
> Yes I have a full build running with both patches added for arm32, arm64 and x86_64.

Perfect!

Acked-by: Julien Grall <jgrall@amazon.com>

Cheers,

-- 
Julien Grall

Re: [PATCH] tools: Fix CPSR/SPSR print size
Posted by Bertrand Marquis 2 years, 9 months ago

> On 6 Jul 2021, at 16:25, Julien Grall <julien@xen.org> wrote:
> 
> 
> 
> On 06/07/2021 16:23, Bertrand Marquis wrote:
>> Hi Julien,
> 
> Hi Bertrand,
> 
>>> On 6 Jul 2021, at 16:15, Julien Grall <julien@xen.org> wrote:
>>> 
>>> Hi Bertrand,
>>> 
>>> Thanks for the fix. I forgot to check the full tools build when sending the first fix :(.
>>> 
>>> On 06/07/2021 16:09, Bertrand Marquis wrote:
>>>> With the changes of register size introduced in
>>>> 918b8842a852e0e7446286f546724b1c63c56c66, CPSR and SPSR are now stored
>>>> as 64bit values.
>>>> Fix the print size to use 64bit type.
>>> 
>>> Can you add a fixes tag? This makes easier to find bug fix in the tree.
>>> 
>>> For this patch it would be:
>>> 
>>> Fixes: 918b8842a852 ("arm64: Change type of hsr, cpsr, spsr_el1 to uint64_t")
>> Sure. Patch incoming in the next minutes.
> 
> I can fix it on commit.

Up to you, I also just sent a v2 if it is easier :-)

Cheers
Bertrand

> 
>>> 
>>>> Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com>
>>> 
>>> Just to confirm, with this patch and mine the tools build successfully on 32-bit and 64-bit?
>> Yes I have a full build running with both patches added for arm32, arm64 and x86_64.
> 
> Perfect!
> 
> Acked-by: Julien Grall <jgrall@amazon.com>
> 
> Cheers,
> 
> -- 
> Julien Grall