Do basic initialization things
v3 cover Do basic initialization things
The patch series groups and updates the following patches:
1. xen/riscv: disable fpu
2. xen/riscv: initialize .bss section
3. xen/riscv: read/save hart_id and dtb_base passed by bootloader
---
Changes since v2:
* Patch [xen/riscv: disable fpu] was moved to the start of start() function to detect illegal usage of floating point earlier.
* Add dummy_bss variable to make .bss initialization code more simple.
* Change comparison of addresses from signed to unsigned.
* Add the comment for start() function with the explanation what and how OpenSBI pass to start() function.
* Clean up start() code related to read&save hart_id & dtb_base.
---
Changes since v1:
* initialization of .bss was moved to head.S
* read/save/pass of hart_id and dtb_base passed by a bootloader were moved to head.S. Also, it was updated start_xen() arguments to recieve hard_id & dtb_base
---
Oleksii Kurochko (3):
xen/riscv: disable fpu
xen/riscv: read/save hart_id and dtb_base passed by bootloader xen/riscv: initialize .bss section
xen/arch/riscv/riscv64/head.S | 21 +++++++++++++++++++++ xen/arch/riscv/setup.c | 11 ++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-)
Signature · 1 line
2.39.0
PATCH v3 1/3 xen/riscv: disable fpu
Disable FPU to detect illegal usage of floating point in kernel space.
--- xen/arch/riscv/riscv64/head.S | 7 +++++++ 1 file changed, 7 insertions(+)
xen/arch/riscv/riscv64/head.S +7 -0
@@ -6,6 +6,13 @@ ENTRY(start) /* Mask all interrupts */ csrw CSR_SIE, zero + /* + * Disable FPU to detect illegal usage of + * floating point in kernel space + */ + li t0, SSTATUS_FS + csrc CSR_SSTATUS, t0 + la sp, cpu0_boot_stack li t0, STACK_SIZE add sp, sp, t0
Signature · 1 line
2.39.0
PATCH v3 2/3 xen/riscv: read/save hart_id and dtb_base passed by bootloader
In reply to Oleksii Kurochko---
Changes since v2:
* Add the comment for start() function with the explanation what and how OpenSBI pass to start() function.
* Clean up start() code related to read&save hart_id & dtb_base.
---
Changes since v1:
* read/save/pass of hart_id and dtb_base passed by a bootloader were moved to head.S.
* Update start_xen() to recieve hard_id & dtb_base
--- xen/arch/riscv/riscv64/head.S | 5 +++++ xen/arch/riscv/setup.c | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-)
xen/arch/riscv/riscv64/head.S +5 -0
@@ -2,6 +2,11 @@ .section .text.header, "ax", %progbits + /* + * OpenSBI pass to start(): + * a0 -> hart_id ( bootcpu_id ) + * a1 -> dtb_base + */ ENTRY(start) /* Mask all interrupts */ csrw CSR_SIE, zero
xen/arch/riscv/setup.c +2 -1
@@ -7,7 +7,8 @@unsigned char __initdata cpu0_boot_stack[STACK_SIZE ]__aligned(STACK_SIZE) ; -void __init noreturnstart_xen (void ) +void __init noreturnstart_xen (unsigned long bootcpu_id, +unsigned long dtb_base) {early_printk ("Hello from C env\n" );
Signature · 1 line
2.39.0
PATCH v3 3/3 xen/riscv: initialize .bss section
In reply to Oleksii Kurochko--- xen/arch/riscv/riscv64/head.S | 9 +++++++++ xen/arch/riscv/setup.c | 8 ++++++++ 2 files changed, 17 insertions(+)
xen/arch/riscv/riscv64/head.S +9 -0
@@ -1,3 +1,4 @@ +#include <asm/asm.h> #include <asm/riscv_encoding.h> .section .text.header, "ax", %progbits
@@ -18,6 +19,14 @@ ENTRY(start) li t0, SSTATUS_FS csrc CSR_SSTATUS, t0 + /* Clear the BSS */ + la t3, __bss_start + la t4, __bss_end +.L_clear_bss: + REG_S zero, (t3) + add t3, t3, __SIZEOF_POINTER__ + bltu t3, t4, .L_clear_bss + la sp, cpu0_boot_stack li t0, STACK_SIZE add sp, sp, t0
xen/arch/riscv/setup.c +8 -0
@@ -7,6 +7,14 @@unsigned char __initdata cpu0_boot_stack[STACK_SIZE ]__aligned(STACK_SIZE) ; +/* +* To be sure that .bss isn't zero. It will simplify code of +* .bss initialization. +* TODO: +* To be deleted when the first real .bss user appears +*/ +int dummy_bss __attribute__((unused)); +void __init noreturnstart_xen (unsigned long bootcpu_id,unsigned long dtb_base) {
Signature · 1 line
2.39.0
Re: [PATCH v3 1/3] xen/riscv: disable fpu
In reply to Oleksii KurochkoQuoted 4 lines · Oleksii Kurochko
Disable FPU to detect illegal usage of floating point in kernel space.
Signed-off-by Oleksii Kurochko <[email protected]>
Re: [PATCH v3 2/3] xen/riscv: read/save hart_id and dtb_base passed by bootloader
In reply to Oleksii KurochkoQuoted 1 line · Oleksii Kurochko
Signed-off-by Oleksii Kurochko <[email protected]>
occurs to me...
xen/arch/riscv/setup.c line 11
Quoted 11 lines
xen/arch/riscv/setup.c +2
-1@@ -7,7 +7,8 @@unsigned char __initdata cpu0_boot_stack[STACK_SIZE ]__aligned(STACK_SIZE) ; -void __init noreturnstart_xen (void ) +void __init noreturnstart_xen (unsigned long bootcpu_id, +unsigned long dtb_base)
dtb_base probably wants renaming to dtb_paddr as the pagetable series is just about to make it a non-identity mapping between the two address spaces.
Can fix on commit if you're happy with the suggestion?
~Andrew
Re: [PATCH v3 3/3] xen/riscv: initialize .bss section
In reply to Oleksii KurochkoQuoted 1 line · Oleksii Kurochko
Signed-off-by Oleksii Kurochko <[email protected]>
Quoted 5 lines
xen/arch/riscv/riscv64/head.S +0
-0
xen/arch/riscv/riscv64/head.S ENTRY(start) · line 28
Quoted 10 lines
xen/arch/riscv/riscv64/head.S +7
-0@@ -18,6 +19,14 @@ ENTRY(start) li t0, SSTATUS_FS csrc CSR_SSTATUS, t0 + /* Clear the BSS */ + la t3, __bss_start + la t4, __bss_end +.L_clear_bss: + REG_S zero, (t3) + add t3, t3, __SIZEOF_POINTER__ + bltu t3, t4, .L_clear_bss
Using t3/t4 is fine, but it would also have been fine to use t0/t1.
~Andrew
Re: [PATCH v3 3/3] xen/riscv: initialize .bss section
Quoted 15 lines · Andrew Cooper
Quoted 1 line · Oleksii Kurochko
Signed-off-by Oleksii Kurochko <[email protected]>Reviewed-by Andrew Cooper <[email protected]>Quoted 10 lines
xen/arch/riscv/riscv64/head.S +0
-0@@ -18,6 +19,14 @@ ENTRY(start)li t0,
SSTATUS_FS
csrcCSR_SSTATUS, t0
+ /* Clear the BSS */
Quoted 8 lines
Quoted 6 lines
+ la t3,
__bss_start
+ la t4,__bss_end
+.L_clear_bss:
+ REG_S zero, (t3)
+ add t3, t3,__SIZEOF_POINTER__
+ bltu t3, t4, .L_clear_bssUsing t3/t4 is fine, but it would also have been fine to use t0/t1.
Yeah, I understand that. It was easier to rename and not confuse something.
Could you please rename them during commit?
Have I to send new patch version?
~ Oleksii
Re: [PATCH v3 2/3] xen/riscv: read/save hart_id and dtb_base passed by bootloader
In reply to Andrew CooperQuoted 23 lines · Andrew Cooper
Quoted 1 line · Oleksii Kurochko
Signed-off-by Oleksii Kurochko <[email protected]>Reviewed-by Andrew Cooper <[email protected]>, although itoccurs to me...
xen/arch/riscv/setup.c line 11
Quoted 11 lines
xen/arch/riscv/setup.c +0
-0@@ -7,7 +7,8 @@unsigned char
__initdatacpu0_boot_stack[STACK_SIZE]__aligned(STACK_SIZE);xen/arch/riscv/setup.c +2
-1-void __init noreturnstart_xen (void ) +void __init noreturnstart_xen (unsigned long bootcpu_id, + unsigned long dtb_base)
dtb_baseprobably wants renaming todtb_paddras the pagetable series is
just about to make it a non-identity mapping between the two address spaces.
Quoted 1 line
Can fix on commit if you're happy with the suggestion?
I will be happy with that.
Thanks.
~ Oleksii
Re: [PATCH v3 3/3] xen/riscv: initialize .bss section
In reply to OleksiiQuoted 22 lines · Oleksii
Quoted 13 lines · Andrew Cooper
Quoted 1 line · Oleksii Kurochko
Signed-off-by Oleksii Kurochko <[email protected]>Reviewed-by Andrew Cooper <[email protected]>Quoted 9 lines
xen/arch/riscv/riscv64/head.S +0
-0@@ -18,6 +19,14 @@ ENTRY(start)li t0,
SSTATUS_FS
csrcCSR_SSTATUS, t0Quoted 8 lines
Quoted 7 lines
+ /* Clear the BSS */
+ la t3,__bss_start
+ la t4,__bss_end
+.L_clear_bss:
+ REG_S zero, (t3)
+ add t3, t3,__SIZEOF_POINTER__
+ bltu t3, t4, .L_clear_bssUsing t3/t4 is fine, but it would also have been fine to use t0/t1.
Quoted 5 lines
Yeah, I understand that. It was easier to rename and not confuse something.
Could you please rename them during commit?
Have I to send new patch version?
No need to send another patch. TBH, I wasn't intending to change it at all - this was just supposed to be a note - but I can if you'd prefer.
~Andrew
Re: [PATCH v3 3/3] xen/riscv: initialize .bss section
Quoted 27 lines · Andrew Cooper
Quoted 26 lines · Oleksii
Quoted 14 lines · Andrew Cooper
Quoted 1 line · Oleksii Kurochko
Signed-off-by Oleksii Kurochko <[email protected]>Reviewed-by Andrew Cooper <[email protected]>Quoted 10 lines
xen/arch/riscv/riscv64/head.S +0
-0@@ -18,6 +19,14 @@ ENTRY(start)li t0,
SSTATUS_FS
csrcCSR_SSTATUS, t0
+ /* Clear the BSS */Quoted 8 lines
Quoted 6 lines
+ la t3,
__bss_start
+ la t4,__bss_end
+.L_clear_bss:
+ REG_S zero, (t3)
+ add t3, t3,__SIZEOF_POINTER__
+ bltu t3, t4, .L_clear_bssUsing t3/t4 is fine, but it would also have been fine to use t0/t1.
Yeah, I understand that. It was easier to rename and not confuse something.
Quoted 7 lines
Quoted 2 lines
Could you please rename them during commit?
Have I to send new patch version?No need to send another patch. TBH, I wasn't intending to change it at
all - this was just supposed to be a note - but I can if you'd prefer.
Feel free to do that.
Thanks.
~ Oleksii
I just wanted to let you know I have this queued up to review, I’ve just been very overloaded. I’ll give these a review in the coming week.
Best,
Bobby
Quoted 36 lines · Oleksii Kurochko
The patch series groups and updates the following patches:
1. xen/riscv: disable fpu
2. xen/riscv: initialize .bss section
3. xen/riscv: read/savehart_idanddtb_basepassed by bootloader---
Changes since v2:
* Patch [xen/riscv: disable fpu] was moved to the start ofstart()function to detect illegal usage of floating point earlier.
* Adddummy_bssvariable to make .bss initialization code more simple.
* Change comparison of addresses from signed to unsigned.
* Add the comment forstart()function with the explanation what and how OpenSBI pass tostart()function.
* Clean upstart()code related to read&savehart_id&dtb_base.
---
Changes since v1:
* initialization of .bss was moved tohead.S
* read/save/pass ofhart_idanddtb_basepassed by a bootloader were moved tohead.S. Also, it was updatedstart_xen()arguments to recievehard_id&dtb_base
---Oleksii Kurochko (3):
xen/riscv: disable fpu
xen/riscv: read/savehart_idanddtb_basepassed by bootloader xen/riscv: initialize .bss sectionxen/arch/riscv/riscv64/head.S | 21 +++++++++++++++++++++ xen/arch/riscv/setup.c | 11 ++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-)--
2.39.0
Quoted 2 lines · Bobby Eshleman
I just wanted to let you know I have this queued up to review, I’ve just been very overloaded. I’ll give these a review in the coming week.
Any update on this?
FWIW, all 3 look ready to go in to me, so hopefully its very easy.
~Andrew
Re: [PATCH v3 1/3] xen/riscv: disable fpu
In reply to Oleksii KurochkoQuoted 30 lines · Oleksii Kurochko
Disable FPU to detect illegal usage of floating point in kernel space.
Signed-off-by Oleksii Kurochko <[email protected]>--- xen/arch/riscv/riscv64/head.S | 7 +++++++ 1 file changed, 7 insertions(+)xen/arch/riscv/riscv64/head.S +7
-0@@ -6,6 +6,13 @@ ENTRY(start) /* Mask all interrupts */ csrw CSR_SIE, zero + /* + * Disable FPU to detect illegal usage of + * floating point in kernel space + */ + li t0, SSTATUS_FS + csrc CSR_SSTATUS, t0 + la sp, cpu0_boot_stack li t0, STACK_SIZE add sp, sp, t0Signature · 1 line
2.39.0
Re: [PATCH v3 1/3] xen/riscv: disable fpu
In reply to Oleksii KurochkoQuoted 30 lines · Oleksii Kurochko
Disable FPU to detect illegal usage of floating point in kernel space.
Signed-off-by Oleksii Kurochko <[email protected]>--- xen/arch/riscv/riscv64/head.S | 7 +++++++ 1 file changed, 7 insertions(+)xen/arch/riscv/riscv64/head.S +7
-0@@ -6,6 +6,13 @@ ENTRY(start) /* Mask all interrupts */ csrw CSR_SIE, zero + /* + * Disable FPU to detect illegal usage of + * floating point in kernel space + */ + li t0, SSTATUS_FS + csrc CSR_SSTATUS, t0 + la sp, cpu0_boot_stack li t0, STACK_SIZE add sp, sp, t0Signature · 1 line
2.39.0
My last email had the wrong trailer:
Re: [PATCH v3 2/3] xen/riscv: read/save hart_id and dtb_base passed by bootloader
In reply to Oleksii KurochkoQuoted 50 lines · Oleksii Kurochko
Signed-off-by Oleksii Kurochko <[email protected]>---
Changes since v2:
* Add the comment forstart()function with the explanation what and how OpenSBI pass tostart()function.
* Clean upstart()code related to read&savehart_id&dtb_base.
---
Changes since v1:
* read/save/pass ofhart_idanddtb_basepassed by a bootloader were moved tohead.S.
* Updatestart_xen()to recievehard_id&dtb_base--- xen/arch/riscv/riscv64/head.S | 5 +++++ xen/arch/riscv/setup.c | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-)xen/arch/riscv/riscv64/head.S +5
-0@@ -2,6 +2,11 @@ .section .text.header, "ax", %progbits + /* + * OpenSBI pass to start(): + * a0 -> hart_id ( bootcpu_id ) + * a1 -> dtb_base + */ ENTRY(start) /* Mask all interrupts */ csrw CSR_SIE, zeroxen/arch/riscv/setup.c +2
-1@@ -7,7 +7,8 @@unsigned char __initdata cpu0_boot_stack[STACK_SIZE ]__aligned(STACK_SIZE) ; -void __init noreturnstart_xen (void ) +void __init noreturnstart_xen (unsigned long bootcpu_id, +unsigned long dtb_base) {early_printk ("Hello from C env\n" );Signature · 1 line
2.39.0
Re: [PATCH v3 3/3] xen/riscv: initialize .bss section
In reply to Oleksii KurochkoQuoted 53 lines · Oleksii Kurochko
Signed-off-by Oleksii Kurochko <[email protected]>--- xen/arch/riscv/riscv64/head.S | 9 +++++++++ xen/arch/riscv/setup.c | 8 ++++++++ 2 files changed, 17 insertions(+)xen/arch/riscv/riscv64/head.S +9
-0@@ -1,3 +1,4 @@ +#include <asm/asm.h> #include <asm/riscv_encoding.h> .section .text.header, "ax", %progbits@@ -18,6 +19,14 @@ ENTRY(start) li t0, SSTATUS_FS csrc CSR_SSTATUS, t0 + /* Clear the BSS */ + la t3, __bss_start + la t4, __bss_end +.L_clear_bss: + REG_S zero, (t3) + add t3, t3, __SIZEOF_POINTER__ + bltu t3, t4, .L_clear_bss + la sp, cpu0_boot_stack li t0, STACK_SIZE add sp, sp, t0xen/arch/riscv/setup.c +8
-0@@ -7,6 +7,14 @@unsigned char __initdata cpu0_boot_stack[STACK_SIZE ]__aligned(STACK_SIZE) ; +/* +* To be sure that .bss isn't zero. It will simplify code of +* .bss initialization. +* TODO: +* To be deleted when the first real .bss user appears +*/ +int dummy_bss __attribute__((unused)); +void __init noreturnstart_xen (unsigned long bootcpu_id,unsigned long dtb_base) {Signature · 1 line
2.39.0