Parse and handle command line from dtb
PATCH v2 2/2 xen/riscv: parse and handle fdt command line
In reply to Oleksii KurochkoReceive Xen's command line passed by DTB using boot_fdt_cmdline() and passed it to cmdline_parse() for further procesinng and setup of Xen-specific parameters.
---
Changes in V2:
- add Acked-by: Jan Beulich <[email protected]>
--- xen/arch/riscv/setup.c | 6 ++++++ 1 file changed, 6 insertions(+)
xen/arch/riscv/setup.c +6 -0
@@ -27,6 +27,8 @@ unsigned char __initdata cpu0_boot_stack[STACK_SIZE]void __init noreturnstart_xen (unsigned long bootcpu_id,paddr_t dtb_addr) { +const char *cmdline; +remove_identity_mapping ();set_processor_id (0 );
@@ -52,6 +54,10 @@ void __init noreturn start_xen(unsigned long bootcpu_id,BUG_ON (!boot_fdt_info (device_tree_flattened, dtb_addr)); + cmdline =boot_fdt_cmdline (device_tree_flattened); +printk ("Command line: %s\n" , cmdline); +cmdline_parse (cmdline); +printk ("All set up\n" );machine_halt ();
Signature · 1 line
2.46.2
v2 cover Parse and handle command line from dtb
This patch series initializes bootinfo from dtb and then parse and handle command line from dtb.
---
Changes in v2:
- Update the cover letter message: drop information about patch series dependency.
- Add Acked-by for the patch 2 ( xen/riscv: parse and handle fdt command line )
- Minor changes for patch 1 ( xen/riscv: initialize bootinfo from dtb ):
- Drop local variable fdt_size as it is going to be used only once.
---
Oleksii Kurochko (2):
xen/riscv: initialize bootinfo from dtb
xen/riscv: parse and handle fdt command line
xen/arch/riscv/setup.c | 8 ++++++++ 1 file changed, 8 insertions(+)
Signature · 1 line
2.46.2
PATCH v2 1/2 xen/riscv: initialize bootinfo from dtb
Parse DTB during startup, allowing memory banks and reserved memory regions to be set up, along with early device tree node ( chosen, "xen,domain", "reserved-memory", etc ) handling.
---
Changes in V2:
- Drop local variable fdt_size as it is going to be used only once.
--- xen/arch/riscv/setup.c | 2 ++ 1 file changed, 2 insertions(+)
xen/arch/riscv/setup.c +2 -0
@@ -50,6 +50,8 @@ void __init noreturn start_xen(unsigned long bootcpu_id, _end - _start, false) )panic ("Failed to add BOOTMOD_XEN\n" ); +BUG_ON (!boot_fdt_info (device_tree_flattened, dtb_addr)); +printk ("All set up\n" );machine_halt ();
Signature · 1 line
2.46.2
Re: [PATCH v2 1/2] xen/riscv: initialize bootinfo from dtb
xen/arch/riscv/setup.c void __init noreturn start_xen(unsigned long bootcpu_id, · line 53
Quoted 7 lines · Oleksii Kurochko
xen/arch/riscv/setup.c +1
-0@@ -50,6 +50,8 @@ void __init noreturn start_xen(unsigned long bootcpu_id, _end - _start, false) )panic ("Failed to add BOOTMOD_XEN\n" ); +BUG_ON (!boot_fdt_info (device_tree_flattened, dtb_addr));
We generally aim at avoiding side effects in BUG_ON() (or ASSERT()). With
if (!boot_fdt_info(device_tree_flattened, dtb_addr))
BUG();
I can make the adjustment while committing, if desired.
Jan
Re: [PATCH v2 1/2] xen/riscv: initialize bootinfo from dtb
Quoted 13 lines · Jan Beulich
Quoted 8 lines · Oleksii Kurochko
xen/arch/riscv/setup.c +0
-0@@ -50,6 +50,8 @@ void __init noreturn start_xen(unsigned long bootcpu_id, _end - _start, false) ) panic("Failed to add BOOTMOD_XEN\n");
+BUG_ON(!boot_fdt_info(device_tree_flattened, dtb_addr));We generally aim at avoiding side effects in
BUG_ON()(orASSERT()). With
Quoted 6 lines
if (!boot_fdt_info(device_tree_flattened,
dtb_addr))BUG();Acked-by Jan Beulich <[email protected]>I can make the adjustment while committing, if desired.
It would be great if these changes could be made during the commit.
Thanks.
~ Oleksii
Re: [PATCH v2 1/2] xen/riscv: initialize bootinfo from dtb
Quoted 14 lines · On 15.10.2024 11:11, [email protected] wrote:
Quoted 13 lines · Jan Beulich
Quoted 8 lines · Oleksii Kurochko
xen/arch/riscv/setup.c +0
-0@@ -50,6 +50,8 @@ void __init noreturn start_xen(unsigned long bootcpu_id, _end - _start, false) ) panic("Failed to add BOOTMOD_XEN\n");
+BUG_ON(!boot_fdt_info(device_tree_flattened, dtb_addr));We generally aim at avoiding side effects in
BUG_ON()(orASSERT()). With
Quoted 7 lines
Quoted 6 lines
if (!boot_fdt_info(device_tree_flattened,
dtb_addr))BUG();Acked-by Jan Beulich <[email protected]>I can make the adjustment while committing, if desired.
It would be great if these changes could be made during the commit.
I've committed it with the adjustment, yet once again I wondered: Why not panic()?
Jan
Re: [PATCH v2 1/2] xen/riscv: initialize bootinfo from dtb
Quoted 19 lines · Jan Beulich
Quoted 18 lines · On 15.10.2024 11:11, [email protected] wrote:
Quoted 17 lines · Jan Beulich
Quoted 8 lines · Oleksii Kurochko
xen/arch/riscv/setup.c +0
-0@@ -50,6 +50,8 @@ void __init noreturn start_xen(unsigned long bootcpu_id, _end - _start, false) ) panic("Failed to add BOOTMOD_XEN\n");
+BUG_ON(!boot_fdt_info(device_tree_flattened, dtb_addr));We generally aim at avoiding side effects in
BUG_ON()(orASSERT()).
Withif (!boot_fdt_info(device_tree_flattened,
dtb_addr))BUG();
Quoted 6 lines
Quoted 4 lines
Quoted 3 lines
Acked-by Jan Beulich <[email protected]>I can make the adjustment while committing, if desired.
It would be great if these changes could be made during the commit.
I've committed it with the adjustment,
Thanks!
Quoted 2 lines
yet once again I wondered: Why not
panic()?
It could be panic() here; there's no specific reason. I agree that using BUG() here isn't logically correct, as technically, a size of zero for the FDT isn't a bug but rather indicates that someone provided an incorrect FDT to Xen.
I will use panic() in the future for such cases.
It’s not always clear what should be used and where. Perhaps it would be helpful to add some explanation somewhere.
~ Oleksii
Re: [PATCH v2 1/2] xen/riscv: initialize bootinfo from dtb
Quoted 35 lines · On 16.10.2024 09:50, [email protected] wrote:
Quoted 19 lines · Jan Beulich
Quoted 18 lines · On 15.10.2024 11:11, [email protected] wrote:
Quoted 17 lines · Jan Beulich
Quoted 8 lines · Oleksii Kurochko
xen/arch/riscv/setup.c +0
-0@@ -50,6 +50,8 @@ void __init noreturn start_xen(unsigned long bootcpu_id, _end - _start, false) ) panic("Failed to add BOOTMOD_XEN\n");
+BUG_ON(!boot_fdt_info(device_tree_flattened, dtb_addr));We generally aim at avoiding side effects in
BUG_ON()(orASSERT()).
Withif (!boot_fdt_info(device_tree_flattened,
dtb_addr))BUG();Quoted 6 lines
Quoted 4 lines
Quoted 3 lines
Acked-by Jan Beulich <[email protected]>I can make the adjustment while committing, if desired.
It would be great if these changes could be made during the commit.
I've committed it with the adjustment,
Thanks!
Quoted 2 lines
yet once again I wondered: Why not
panic()?It could be
panic()here; there's no specific reason. I agree that usingBUG()here isn't logically correct, as technically, a size of zero for the FDT isn't a bug but rather indicates that someone provided an incorrect FDT to Xen.
Quoted 4 lines
I will use
panic()in the future for such cases.It’s not always clear what should be used and where. Perhaps it would be helpful to add some explanation somewhere.
My rule of thumb: During init and when the call stack / register state aren't relevant to understand the details of the issue, use panic().
Jan
Re: [PATCH v2 1/2] xen/riscv: initialize bootinfo from dtb
In reply to [email protected]Quoted 33 lines · On 16/10/2024 8:50 am, [email protected] wrote:
Quoted 15 lines · Jan Beulich
Quoted 14 lines · On 15.10.2024 11:11, [email protected] wrote:
Quoted 13 lines · Jan Beulich
Quoted 8 lines · Oleksii Kurochko
xen/arch/riscv/setup.c +0
-0@@ -50,6 +50,8 @@ void __init noreturn start_xen(unsigned long bootcpu_id, _end - _start, false) ) panic("Failed to add BOOTMOD_XEN\n");
+BUG_ON(!boot_fdt_info(device_tree_flattened, dtb_addr));We generally aim at avoiding side effects in
BUG_ON()(orASSERT()).
WithQuoted 8 lines
Quoted 7 lines
Quoted 6 lines
if (!boot_fdt_info(device_tree_flattened,
dtb_addr))BUG();Acked-by Jan Beulich <[email protected]>I can make the adjustment while committing, if desired.
It would be great if these changes could be made during the commit.
I've committed it with the adjustment,
Thanks!
Quoted 2 lines
yet once again I wondered: Why not
panic()?It could be
panic()here; there's no specific reason. I agree that usingBUG()here isn't logically correct, as technically, a size of zero for the FDT isn't a bug but rather indicates that someone provided an incorrect FDT to Xen.
Quoted 4 lines
I will use
panic()in the future for such cases.It’s not always clear what should be used and where. Perhaps it would be helpful to add some explanation somewhere.
panic() gets you a single line diagnostic. BUG() gets you a backtrace, but no diagnostic information at all.
BUG() should be a last resort, because it requires someone to go digging in the source code to even figure out what went wrong. panic() (with a good diagnostic message, e.g. "unexpected $foo in device tree") is far more meaningful.
There are ways of getting a backtrace in combination with a panic(), if the situation warrants it.
~Andrew