xen/arm: domain: Fix MISRA C 2012 Rule 8.7 violation
PATCH v3 1/1 xen/arm: domain: Fix MISRA C 2012 Rule 8.7 violation
The function idle_loop() is referenced only in domain.c. Change its linkage from external to internal by adding the storage-class specifier static to its definitions.
Add the function as a 'fake' input operand to the inline assembly statement, to make the compiler aware that the function is used.
Fake means that the function is not actually used as an operand by the asm code. That is because there is not a suitable gcc arm32 asm constraint for labels.
Declare return_to_new_vcpu32() and return_to_new_vcpu64() that are also referenced by this inline asm statement.
Also, this patch resolves indirectly a MISRA C 2012 Rule 8.4 violation warning.
---
Changes in v2:
- remove the 'used' attribute and pass the function as input operand to the inline asm statement
- declare return_to_new_vcpu32() and return_to_new_vcpu64()
Changes in v3:
- remove the declarations of return_to_new_vcpu32() and return_to_new_vcpu64() from asm/current.h because this is not the appropriate header
- place them in arm/domain.c to restrict their visibilty to this particular file
- declare them as noreturn
xen/arch/arm/domain.c | 5 ++++- xen/arch/arm/include/asm/current.h | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-)
xen/arch/arm/domain.c +4 -1
@@ -63,7 +63,7 @@ static void do_idle(void)rcu_idle_exit (cpu); } -void idle_loop (void ) +static void idle_loop (void ) {unsigned int cpu =smp_processor_id ();
@@ -331,6 +331,9 @@ static void schedule_tail(struct vcpu *prev)update_vcpu_system_time (current); } +extern void noreturnreturn_to_new_vcpu32 (void ); +extern void noreturnreturn_to_new_vcpu64 (void ); +static void continue_new_vcpu (struct vcpu *prev) { current->arch.actlr =READ_SYSREG (ACTLR_EL1 );
xen/arch/arm/include/asm/current.h +1 -1
@@ -45,7 +45,7 @@ static inline struct cpu_info *get_cpu_info(void)#define guest_cpu_user_regs () (&get_cpu_info()->guest_cpu_user_regs)#define switch_stack_and_jump (stack, fn) do { \ - asm volatile ("mov sp,%0; b " STR(fn) : : "r" (stack) : "memory" ); \ + asm volatile ("mov sp,%0; b " STR(fn) : : "r" (stack), "X" (fn) : "memory" ); \ unreachable(); \ } while ( false )
Signature · 1 line
2.34.1
xen/arch/arm/domain.c static void do_idle(void) · line 66
Quoted 8 lines · Xenia Ragiadakou
xen/arch/arm/domain.c +1
-1@@ -63,7 +63,7 @@ static void do_idle(void)rcu_idle_exit (cpu); } -void idle_loop (void ) +static void idle_loop (void )
While you're adding "noreturn" below, shouldn't this one be marked so as well? Preferably with the addition:
Jan
Hi Jan,
Quoted 7 lines · Jan Beulich
Quoted 6 lines · Xenia Ragiadakou
xen/arch/arm/domain.c +0
-0@@ -63,7 +63,7 @@ static void do_idle(void)rcu_idle_exit (cpu); }
Quoted 7 lines
xen/arch/arm/domain.c static void do_idle(void) · line 66
Quoted 2 lines
xen/arch/arm/domain.c +1
-1-void idle_loop (void ) +static void idle_loop (void )While you're adding "noreturn" below, shouldn't this one be marked so as well? Preferably with the addition:
Reviewed-by Jan Beulich <[email protected]>
Yes, but I was not sure if this should go in this patch or in a separate one.
Signature · 1 line
Xenia
Bertrand Marquis
Reviewed-byHi Xenia,
Quoted 17 lines · Xenia Ragiadakou
Hi Jan,
Quoted 11 lines · Jan Beulich
xen/arch/arm/domain.c static void do_idle(void) · line 66
Quoted 7 lines · Xenia Ragiadakou
xen/arch/arm/domain.c +1
-0@@ -63,7 +63,7 @@ static void do_idle(void)rcu_idle_exit (cpu); } -void idle_loop(void) +static void idle_loop(void)While you're adding "noreturn" below, shouldn't this one be marked so as well? Preferably with the addition:
Reviewed-by Jan Beulich <[email protected]>
Quoted 1 line
Yes, but I was not sure if this should go in this patch or in a separate one.
As you modify the function to make it static, I think it is ok to also add the noreturn in the same patch.
With that done, you can add my:
Cheers
Bertrand
Quoted 3 lines
Signature · 2 lines
-- Xenia
Quoted 21 lines · Bertrand Marquis
Hi Xenia,
Quoted 17 lines · Xenia Ragiadakou
Hi Jan,
Quoted 11 lines · Jan Beulich
xen/arch/arm/domain.c static void do_idle(void) · line 66
Quoted 7 lines · Xenia Ragiadakou
xen/arch/arm/domain.c +1
-0@@ -63,7 +63,7 @@ static void do_idle(void)rcu_idle_exit (cpu); } -void idle_loop(void) +static void idle_loop(void)While you're adding "noreturn" below, shouldn't this one be marked so as well? Preferably with the addition:
Reviewed-by Jan Beulich <[email protected]>Quoted 1 line
Yes, but I was not sure if this should go in this patch or in a separate one.
Quoted 7 lines
As you modify the function to make it static, I think it is ok to also add the noreturn in the same patch.
With that done, you can add my:
Reviewed-by Bertrand Marquis <[email protected]>Cheers
Bertrand
I consider this change unrelated to the patch. I think it is a bad practice to squash unrelated changes in a single patch. Also, I do not think it is unfair to be obliged to make it in order for the patch to be accepted. I could have taken the opportunity to fix this in the same patch but I decided to not take it.
Signature · 1 line
Xenia
Hi Xenia,
Quoted 25 lines · Xenia Ragiadakou
Quoted 23 lines · Bertrand Marquis
Hi Xenia,
Quoted 17 lines · Xenia Ragiadakou
Hi Jan,
Quoted 11 lines · Jan Beulich
xen/arch/arm/domain.c static void do_idle(void) · line 66
Quoted 7 lines · Xenia Ragiadakou
xen/arch/arm/domain.c +1
-0@@ -63,7 +63,7 @@ static void do_idle(void) rcu_idle_exit(cpu); } -void idle_loop(void) +static void idle_loop(void)While you're adding "noreturn" below, shouldn't this one be marked so as well? Preferably with the addition:
Reviewed-by Jan Beulich <[email protected]>Quoted 1 line
Yes, but I was not sure if this should go in this patch or in a separate one.
As you modify the function to make it static, I think it is ok to also add the noreturn in the same patch.
Quoted 8 lines
Quoted 5 lines
With that done, you can add my:
Reviewed-by Bertrand Marquis <[email protected]>Cheers
BertrandI consider this change unrelated to the patch. I think it is a bad practice to squash unrelated changes in a single patch. Also, I do not think it is unfair to be obliged to make it in order for the patch to be accepted. I could have taken the opportunity to fix this in the same patch but I decided to not take it.
In general, I don't like having multiple changes within a patch. However, here this is a consistency problem. You are modifying the 3 prototypes (well one is technically a declaration) and it reads odd that 2 are using noreturn but not the other one.
I would actually argue that if this patch goes in like that, then the commit message ought to explain why there is a lack of consistency.
Anyway, I agree with Bertrand that it would be preferable to add noreturn to the declaration of idle_loop() in this patch.
To avoid a round trip, I would be OK to handle on commit.
Cheers,
Signature · 1 line
Julien Grall
Hi Julien,
Hi Julien,
Quoted 31 lines · Julien Grall
Hi Xenia,
Quoted 28 lines · Xenia Ragiadakou
Quoted 26 lines · Bertrand Marquis
Hi Xenia,
Quoted 17 lines · Xenia Ragiadakou
Hi Jan,
Quoted 11 lines · Jan Beulich
xen/arch/arm/domain.c static void do_idle(void) · line 66
Quoted 7 lines · Xenia Ragiadakou
xen/arch/arm/domain.c +1
-0@@ -63,7 +63,7 @@ static void do_idle(void) rcu_idle_exit(cpu); } -void idle_loop(void) +static void idle_loop(void)While you're adding "noreturn" below, shouldn't this one be marked so as well? Preferably with the addition:
Reviewed-by Jan Beulich <[email protected]>Quoted 1 line
Yes, but I was not sure if this should go in this patch or in a separate one.
As you modify the function to make it static, I think it is ok to also add the noreturn in the same patch.
With that done, you can add my:
Reviewed-by Bertrand Marquis <[email protected]>
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Cheers
BertrandI consider this change unrelated to the patch. I think it is a bad practice to squash unrelated changes in a single patch. Also, I do not think it is unfair to be obliged to make it in order for the patch to be accepted. I could have taken the opportunity to fix this in the same patch but I decided to not take it.
In general, I don't like having multiple changes within a patch. However, here this is a consistency problem. You are modifying the 3 prototypes (well one is technically a declaration) and it reads odd that 2 are using noreturn but not the other one.
The patch adds the 2 function declarations, it does not modify them. Since they do not return, they are declared noreturn. If the function idle_loop was not declared noreturn, although it should have been, for me is a completely different issue.
Quoted 2 lines
I would actually argue that if this patch goes in like that, then the commit message ought to explain why there is a lack of consistency.
I do not agree with you saying that the patch introduced this inconsistency. The function idle_loop should have been declared noreturn in the first place. If you would like to fix this in the current patch, it is up to you.
Quoted 6 lines
Anyway, I agree with Bertrand that it would be preferable to add noreturn to the declaration of
idle_loop()in this patch.To avoid a round trip, I would be OK to handle on commit.
Cheers,
Signature · 1 line
Xenia
Hi,
Quoted 35 lines · Xenia Ragiadakou
Quoted 34 lines · Julien Grall
Hi Xenia,
Quoted 31 lines · Xenia Ragiadakou
Quoted 28 lines · Bertrand Marquis
Hi Xenia,
Quoted 17 lines · Xenia Ragiadakou
Hi Jan,
Quoted 11 lines · Jan Beulich
xen/arch/arm/domain.c static void do_idle(void) · line 66
Quoted 7 lines · Xenia Ragiadakou
xen/arch/arm/domain.c +1
-0@@ -63,7 +63,7 @@ static void do_idle(void) rcu_idle_exit(cpu); } -void idle_loop(void) +static void idle_loop(void)While you're adding "noreturn" below, shouldn't this one be marked so as well? Preferably with the addition:
Reviewed-by Jan Beulich <[email protected]>Quoted 1 line
Yes, but I was not sure if this should go in this patch or in a separate one.
As you modify the function to make it static, I think it is ok to also add the noreturn in the same patch.
With that done, you can add my:
Reviewed-by Bertrand Marquis <[email protected]>Cheers
Bertrand
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
I consider this change unrelated to the patch. I think it is a bad practice to squash unrelated changes in a single patch. Also, I do not think it is unfair to be obliged to make it in order for the patch to be accepted. I could have taken the opportunity to fix this in the same patch but I decided to not take it.
In general, I don't like having multiple changes within a patch. However, here this is a consistency problem. You are modifying the 3 prototypes (well one is technically a declaration) and it reads odd that 2 are using noreturn but not the other one.
The patch adds the 2 function declarations, it does not modify them.
Fair enough, you are adding 2 declarations and modifying one. This doesn't change the inconsistency problem though.
Quoted 2 lines
Since they do not return, they are declared noreturn.
If the functionidle_loopwas not declared noreturn, although it should have been, for me is a completely different issue.
[...]
Quoted 1 line
I do not agree with you saying that the patch introduced this inconsistency. The function
idle_loopshould have been declared noreturn in the first place.
I think everyone involved in the discussion agrees that idle_loop() should have been marked as noreturn from the start.
And we all agree that this needs to be fixed. So I don't think this is particularly useful to spend time arguing on whether this needs to be handled within or separately. 3 of the reviewers agree that this should be preferably added here. So...
Quoted 1 line
If you would like to fix this in the current patch, it is up to you.
... I will commit it with the change on the next swipe.
Cheers,
Signature · 1 line
Julien Grall