xen: arm: Only lookup kernel/initrd bootmodule once while building dom0.
PATCH v4 1/1 xen: arm: Only lookup kernel/initrd bootmodule once while building dom0.
---
v4: Call the new field kernel_bootmodule for clarity
Use the new field throughout kernel.c as well as in domain_build.c Add and use initrd_bootmodule too.
Const up the uses
v3: New patch
--- xen/arch/arm/domain_build.c | 6 +++--- xen/arch/arm/kernel.c | 2 ++ xen/arch/arm/kernel.h | 1 + 3 files changed, 6 insertions(+), 3 deletions(-)
xen/arch/arm/domain_build.c +3 -3
@@ -405,7 +405,7 @@ static int write_properties(struct domain *d, struct kernel_info *kinfo,int res =0 ;int had_dom0_bootargs =0 ; -struct bootmodule *mod =boot_module_find_by_kind (BOOTMOD_KERNEL ); +const struct bootmodule *mod = kinfo->kernel_bootmodule;if ( mod && mod->cmdline[0 ] ) bootargs = &mod->cmdline[0 ];
@@ -455,7 +455,7 @@ static int write_properties(struct domain *d, struct kernel_info *kinfo,if (dt_node_path_is_equal (node,"/chosen" ) ) { -struct bootmodule *mod =boot_module_find_by_kind (BOOTMOD_RAMDISK ); +const struct bootmodule *mod = kinfo->initrd_bootmodule;if ( bootargs ) {
@@ -1224,7 +1224,7 @@ static void dtb_load(struct kernel_info *kinfo)static void initrd_load (struct kernel_info *kinfo) { -struct bootmodule *mod =boot_module_find_by_kind (BOOTMOD_RAMDISK ); +const struct bootmodule *mod = kinfo->initrd_bootmodule;paddr_t load_addr = kinfo->initrd_paddr;paddr_t paddr, len;unsigned long offs;
xen/arch/arm/kernel.c +2 -0
@@ -116,6 +116,7 @@ static void place_modules(struct kernel_info *info, info->dtb_paddr = modbase; info->initrd_paddr = info->dtb_paddr + dtb_len; + info->initrd_bootmodule = mod; }static paddr_t kernel_zimage_place (struct kernel_info *info)
@@ -383,6 +384,7 @@ int kernel_probe(struct kernel_info *info)return -ENOENT ; } + info->kernel_bootmodule = mod; start = mod->start; size = mod->size;
xen/arch/arm/kernel.h +1 -0
@@ -23,6 +23,7 @@ struct kernel_info {paddr_t entry;/* boot blob load addresses */ +const struct bootmodule *kernel_bootmodule, *initrd_bootmodule;paddr_t dtb_paddr;paddr_t initrd_paddr;
Signature · 1 line
1.7.10.4
Quoted 27 lines · Ian Campbell
Signed-off-by Ian Campbell <[email protected]>---
v4: Call the new fieldkernel_bootmodulefor clarity
Use the new field throughoutkernel.cas well as indomain_build.cAdd and useinitrd_bootmoduletoo.
Const up the uses
v3: New patch--- xen/arch/arm/domain_build.c | 6 +++--- xen/arch/arm/kernel.c | 2 ++ xen/arch/arm/kernel.h | 1 + 3 files changed, 6 insertions(+), 3 deletions(-)xen/arch/arm/domain_build.c +1
-1@@ -405,7 +405,7 @@ static int write_properties(struct domain *d, struct kernel_info *kinfo,int res =0 ;int had_dom0_bootargs =0 ; -struct bootmodule *mod =boot_module_find_by_kind (BOOTMOD_KERNEL ); +const struct bootmodule *mod = kinfo->kernel_bootmodule;if ( mod && mod->cmdline[0 ] ) bootargs = &mod->cmdline[0 ];
xen/arch/arm/domain_build.c static int write_properties(struct domain *d, struct kernel_info *kinfo, · line 458
Quoted 5 lines
xen/arch/arm/domain_build.c +1
-1@@ -455,7 +455,7 @@ static int write_properties(struct domain *d, struct kernel_info *kinfo,if (dt_node_path_is_equal (node,"/chosen" ) ) { -struct bootmodule *mod =boot_module_find_by_kind (BOOTMOD_RAMDISK ); +const struct bootmodule *mod = kinfo->initrd_bootmodule;
Technically speaking, we only execute once this part of the code. So having a new field in kernel_info doesn't seem useful.
BTW, the function already have a variable "mod" defined at the begining. I would rename this variable to modinitrd or smth different to shadow the previous variable.
Regards,
Signature · 1 line
Julien Grall
Quoted 29 lines · Julien Grall
Quoted 28 lines · Ian Campbell
Signed-off-by Ian Campbell <[email protected]>---
v4: Call the new fieldkernel_bootmodulefor clarity
Use the new field throughoutkernel.cas well as indomain_build.cAdd and useinitrd_bootmoduletoo.
Const up the uses
v3: New patch--- xen/arch/arm/domain_build.c | 6 +++--- xen/arch/arm/kernel.c | 2 ++ xen/arch/arm/kernel.h | 1 + 3 files changed, 6 insertions(+), 3 deletions(-)xen/arch/arm/domain_build.c +1
-1@@ -405,7 +405,7 @@ static int write_properties(struct domain *d, struct kernel_info *kinfo,int res =0 ;int had_dom0_bootargs =0 ; -struct bootmodule *mod =boot_module_find_by_kind (BOOTMOD_KERNEL ); +const struct bootmodule *mod = kinfo->kernel_bootmodule;if ( mod && mod->cmdline[0 ] ) bootargs = &mod->cmdline[0 ];@@ -455,7 +455,7 @@ static int write_properties(struct domain *d, struct kernel_info *kinfo,
Quoted 7 lines
xen/arch/arm/domain_build.c static int write_properties(struct domain *d, struct kernel_info *kinfo, · line 458
Quoted 4 lines
xen/arch/arm/domain_build.c +1
-1if (dt_node_path_is_equal (node,"/chosen" ) ) { -struct bootmodule *mod =boot_module_find_by_kind (BOOTMOD_RAMDISK ); +const struct bootmodule *mod = kinfo->initrd_bootmodule;Technically speaking, we only execute once this part of the code. So having a new field in
kernel_infodoesn't seem useful.
It seemed to me to be consistent to only lookup the ramdisk once too, instead of here and in initrd_load().
Quoted 3 lines
BTW, the function already have a variable "mod" defined at the begining. I would rename this variable to modinitrd or smth different to shadow the previous variable.
I noticed that too. Please do.
Julien Grall
Acked-byQuoted 38 lines · Ian Campbell
Quoted 29 lines · Julien Grall
Quoted 28 lines · Ian Campbell
Signed-off-by Ian Campbell <[email protected]>---
v4: Call the new fieldkernel_bootmodulefor clarity
Use the new field throughoutkernel.cas well as indomain_build.cAdd and useinitrd_bootmoduletoo.
Const up the uses
v3: New patch--- xen/arch/arm/domain_build.c | 6 +++--- xen/arch/arm/kernel.c | 2 ++ xen/arch/arm/kernel.h | 1 + 3 files changed, 6 insertions(+), 3 deletions(-)xen/arch/arm/domain_build.c +1
-1@@ -405,7 +405,7 @@ static int write_properties(struct domain *d, struct kernel_info *kinfo,int res =0 ;int had_dom0_bootargs =0 ; -struct bootmodule *mod =boot_module_find_by_kind (BOOTMOD_KERNEL ); +const struct bootmodule *mod = kinfo->kernel_bootmodule;if ( mod && mod->cmdline[0 ] ) bootargs = &mod->cmdline[0 ];@@ -455,7 +455,7 @@ static int write_properties(struct domain *d, struct kernel_info *kinfo,Quoted 7 lines
xen/arch/arm/domain_build.c static int write_properties(struct domain *d, struct kernel_info *kinfo, · line 458
Quoted 4 lines
xen/arch/arm/domain_build.c +1
-1if (dt_node_path_is_equal (node,"/chosen" ) ) { -struct bootmodule *mod =boot_module_find_by_kind (BOOTMOD_RAMDISK ); +const struct bootmodule *mod = kinfo->initrd_bootmodule;Technically speaking, we only execute once this part of the code. So having a new field in
kernel_infodoesn't seem useful.
Quoted 8 lines
It seemed to me to be consistent to only lookup the ramdisk once too, instead of here and in
initrd_load().Quoted 3 lines
BTW, the function already have a variable "mod" defined at the begining. I would rename this variable to modinitrd or smth different to shadow the previous variable.
I noticed that too. Please do.
Ok. I will send a follow-up to fix it.
Regards,
Signature · 1 line
Julien Grall
Ian Campbell
AppliedQuoted 10 lines · Julien Grall
Quoted 10 lines
Quoted 9 lines
xen/arch/arm/domain_build.c static int write_properties(struct domain *d, struct kernel_info *kinfo, · line 458
Quoted 6 lines
xen/arch/arm/domain_build.c +1
-1@@ -455,7 +455,7 @@ static int write_properties(struct domain *d, struct kernel_info *kinfo,if (dt_node_path_is_equal (node,"/chosen" ) ) { -struct bootmodule *mod =boot_module_find_by_kind (BOOTMOD_RAMDISK ); +const struct bootmodule *mod = kinfo->initrd_bootmodule;Technically speaking, we only execute once this part of the code. So having a new field in
kernel_infodoesn't seem useful.
Quoted 4 lines
Quoted 2 lines
It seemed to me to be consistent to only lookup the ramdisk once too, instead of here and in
initrd_load().Acked-by Julien Grall <[email protected]>
Thanks, applied.