Skip to contentSkip to conversation

xen: Drop the (almost) unused extern start[]

PATCH In review Andrew Cooper 3 participants 3 messages Jul 25, 2023 – Jul 26, 2023 RISC-V

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen: Drop the (almost) unused extern start[]

This global variable is shadowed by plenty local variables, violating MISRA rule 5.3. Some architectures happen to have a symbol by the name of start in their head.S's, but it's not a useful symbol to reference from C.

In fact, the single use of the global start[] in RISC-V is wrong and means to use _start[] as the linker symbol at the beginning of the .text section, not the function which happens to be in the same location.

Fix RISC-V to use the right symbol for it's calculation, and drop the extern.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Bob Eshleman <[email protected]>
CC: Alistair Francis <[email protected]>
CC: Connor Davis <[email protected]>
CC: Oleksii Kurochko <[email protected]>
CC: Roberto Bagnara <[email protected]>

I'm expecting:

https://gitlab.com/xen-project/people/andyhhp/xen/-/pipelines/945105609

to come back and show green, but Gitlab is very backed up right now. I've compiled each architecture locally.

---
 xen/arch/riscv/mm.c      | 2 +-
 xen/include/xen/kernel.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
xen/arch/riscv/mm.c +1 -1
index fddb3cd0bdeb..99ed5e9623cc 100644
@@ -148,7 +148,7 @@ static bool __init check_pgtbl_mode_support(struct mmu_desc *mmu_desc,
 
     unsigned long aligned_load_start = load_start & level_map_mask;
     unsigned long aligned_page_size = XEN_PT_LEVEL_SIZE(page_table_level);
-    unsigned long xen_size = (unsigned long)(_end - start);
+    unsigned long xen_size = (unsigned long)(_end - _start);
 
     if ( (load_start + xen_size) > (aligned_load_start + aligned_page_size) )
     {
xen/include/xen/kernel.h +1 -1
index 9ac2694dc7b1..46b3c9c02625 100644
@@ -66,7 +66,7 @@
 })
 
 /* SAF-0-safe */
-extern char _start[], _end[], start[];
+extern char _start[], _end[];
 #define is_kernel(p) ({                         \
     char *__p = (char *)(unsigned long)(p);     \
     (__p >= _start) && (__p < _end);            \

base-commit: 0b1171be87698bc7d14760383c0770aeb6e41dd4

Signature · 1 line
2.30.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Andrew Cooper

This global variable is shadowed by plenty local variables, violating MISRA rule 5.3. Some architectures happen to have a symbol by the name of start in their head.S's, but it's not a useful symbol to reference from C.

In fact, the single use of the global start[] in RISC-V is wrong and means to use _start[] as the linker symbol at the beginning of the .text section, not the function which happens to be in the same location.

Fix RISC-V to use the right symbol for it's calculation, and drop the extern.

Quoted 56 lines

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Bob Eshleman <[email protected]>
CC: Alistair Francis <[email protected]>
CC: Connor Davis <[email protected]>
CC: Oleksii Kurochko <[email protected]>
CC: Roberto Bagnara <[email protected]>

I'm expecting:

https://gitlab.com/xen-project/people/andyhhp/xen/-/pipelines/945105609

to come back and show green, but Gitlab is very backed up right now. I've compiled each architecture locally.

---
 xen/arch/riscv/mm.c      | 2 +-
 xen/include/xen/kernel.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
xen/arch/riscv/mm.c +1 -1
index fddb3cd0bdeb..99ed5e9623cc 100644
@@ -148,7 +148,7 @@ static bool __init check_pgtbl_mode_support(struct mmu_desc *mmu_desc,
 
     unsigned long aligned_load_start = load_start & level_map_mask;
     unsigned long aligned_page_size = XEN_PT_LEVEL_SIZE(page_table_level);
-    unsigned long xen_size = (unsigned long)(_end - start);
+    unsigned long xen_size = (unsigned long)(_end - _start);
 
     if ( (load_start + xen_size) > (aligned_load_start + aligned_page_size) )
     {
xen/include/xen/kernel.h +1 -1
index 9ac2694dc7b1..46b3c9c02625 100644
@@ -66,7 +66,7 @@
 })
 
 /* SAF-0-safe */
-extern char _start[], _end[], start[];
+extern char _start[], _end[];
 #define is_kernel(p) ({                         \
     char *__p = (char *)(unsigned long)(p);     \
     (__p >= _start) && (__p < _end);            \

base-commit: 0b1171be87698bc7d14760383c0770aeb6e41dd4

Signature · 1 line
2.30.2
Reviewed-by on v1 1/1
#2 lore raw
In reply to Andrew Cooper
Quoted 12 lines · Andrew Cooper

This global variable is shadowed by plenty local variables, violating MISRA
rule 5.3.  Some architectures happen to have a symbol by the name of start in
their head.S's, but it's not a useful symbol to reference from C.

In fact, the single use of the global start[] in RISC-V is wrong and means to
use _start[] as the linker symbol at the beginning of the .text section, not
the function which happens to be in the same location.

Quoted 4 lines

Fix RISC-V to use the right symbol for it's calculation, and drop the extern.

Really missed '_start'.

Quoted 58 lines

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Bob Eshleman <[email protected]>
CC: Alistair Francis <[email protected]>
CC: Connor Davis <[email protected]>
CC: Oleksii Kurochko <[email protected]>
CC: Roberto Bagnara <[email protected]>

I'm expecting:


https://gitlab.com/xen-project/people/andyhhp/xen/-/pipelines/945105609

to come back and show green, but Gitlab is very backed up right now. I've
compiled each architecture locally.
---
 xen/arch/riscv/mm.c      | 2 +-
 xen/include/xen/kernel.h | 2 +-

 2 files changed, 2 insertions(+), 2 deletions(-)
xen/arch/riscv/mm.c +0 -0
index fddb3cd0bdeb..99ed5e9623cc 100644
@@ -148,7 +148,7 @@ static bool __init
 check_pgtbl_mode_support(struct mmu_desc *mmu_desc,


     unsigned long aligned_load_start = load_start & level_map_mask; unsigned long aligned_page_size = XEN_PT_LEVEL_SIZE(page_table_level);
-    unsigned long xen_size = (unsigned long)(_end - start); +    unsigned long xen_size = (unsigned long)(_end - _start);
     if ( (load_start + xen_size) > (aligned_load_start + aligned_page_size) )
     {

xen/include/xen/kernel.h +0 -0
index 9ac2694dc7b1..46b3c9c02625 100644
@@ -66,7 +66,7 @@
  })


 /* SAF-0-safe */

xen/include/xen/kernel.h +1 -1
-extern char _start[], _end[], start[];
+extern char _start[], _end[];

 #define is_kernel(p) ({                         \
     char *__p = (char *)(unsigned long)(p);     \
     (__p >= _start) && (__p < _end);            \

base-commit: 0b1171be87698bc7d14760383c0770aeb6e41dd4