stubdom/grub: avoid relying on start_info definition
v2 cover stubdom/grub: avoid relying on start_info definition
With the related change having been added to Mini-OS, the single V1 patch can now be expanded to a 3 patch series, especially meant to untangle the close dependencies between grub-pv and Mini-OS internals.
Changes in V2:
- add comment to patch 1
- added patches 2+3
Juergen Gross (3):
stubdom/grub: avoid relying on start_info definition
Config: update Mini-OS commit id
stubdom/grub: swap start_info usage with start_info_ptr
Config.mk | 2 +- stubdom/grub/kexec.c | 26 +++++++++++++------------- 2 files changed, 14 insertions(+), 14 deletions(-)
Signature · 1 line
2.43.0
PATCH v2 1/3 stubdom/grub: avoid relying on start_info definition
The kexec() function of grub-pv is relying on the exact definition of start_info from Mini-OS by having an "#undef start_info" and a few lines later a copy of the Mini-OS definition again.
This is bad practice by making all attempts of Mini-OS to change that definition impossible.
Avoid that dependency by moving the code fragment in question to the very end of the source file, allowing to drop the copy of the definition.
---
V2:
- add comment (Jan Beulich)
--- stubdom/grub/kexec.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
stubdom/grub/kexec.c +11 -4
@@ -209,6 +209,8 @@ static void tpm_hash2pcr(struct xc_dom_image *dom, char *cmdline)shutdown_tpmfront (tpm); } +static void call_start_info_hook (struct xc_dom_image *dom); +void kexec (void *kernel,long kernel_size,void *module,long module_size,char *cmdline,unsigned long flags) {struct xc_dom_image *dom;
@@ -330,10 +332,7 @@ void kexec(void *kernel, long kernel_size, void *module, long module_size, char }/* start info page */ -#undef start_info -if ( dom->arch_hooks->start_info ) - dom->arch_hooks->start_info (dom); -#define start_info (start_info_union.start_info) +call_start_info_hook (dom);xc_dom_log_memory_footprint (dom);
@@ -432,3 +431,11 @@ out: allocated =0 ;xc_interface_close (xc_handle ); } + +/* No references to start_info of Mini-OS after this function. */ +static void call_start_info_hook (struct xc_dom_image *dom) +{ +#undef start_info +if ( dom->arch_hooks->start_info ) + dom->arch_hooks->start_info (dom); +}
Signature · 1 line
2.43.0
PATCH v2 2/3 Config: update Mini-OS commit id
In reply to Juergen GrossUse the newest Mini-OS.
---
V2:
- new patch
--- Config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Config.mk +1 -1
@@ -208,7 +208,7 @@ QEMU_UPSTREAM_URL ?= https://xenbits.xen.org/git-http/qemu-xen.git QEMU_UPSTREAM_REVISION ?= master MINIOS_UPSTREAM_URL ?= https://xenbits.xen.org/git-http/mini-os.git -MINIOS_UPSTREAM_REVISION ?= d273a44cec90dad5d3f0bc361a6fea41e0288a56 +MINIOS_UPSTREAM_REVISION ?= 2d3b22f842a969574cf967925b435c5913e8a6e0 SEABIOS_UPSTREAM_URL ?= https://xenbits.xen.org/git-http/seabios.git SEABIOS_UPSTREAM_REVISION ?= rel-1.16.3
Signature · 1 line
2.43.0
Re: [PATCH v2 2/3] Config: update Mini-OS commit id
Quoted 3 lines · Juergen Gross
Use the newest Mini-OS.
Signed-off-by Juergen Gross <[email protected]>
PATCH v2 3/3 stubdom/grub: swap start_info usage with start_info_ptr
In reply to Juergen GrossNow that Mini-OS is exporting start_info_ptr, use that instead of the tedious start_info macro.
Note that the Mini-OS macro still needs to be undefined, but now it can be done right at the top of kexec.c.
Undo the previous move of the "other" start_info into a dedicated function.
---
V2:
- new patch
--- stubdom/grub/kexec.c | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-)
stubdom/grub/kexec.c +15 -22
@@ -34,6 +34,8 @@#include "mini-os.h" +#undef start_info +#if 0 #define DEBUG (fmt, ...) printk(fmt, ## __VA_ARGS__)#else
@@ -86,10 +88,10 @@ static void do_exchange(struct xc_dom_image *dom, xen_pfn_t target_pfn, xen_pfn_xen_pfn_t source_pfn;xen_pfn_t target_mfn; -for (source_pfn =0 ; source_pfn < start_info.nr_pages; source_pfn++) +for (source_pfn =0 ; source_pfn < start_info_ptr->nr_pages; source_pfn++)if (dom->pv_p2m[source_pfn] == source_mfn)break ; -ASSERT (source_pfn < start_info.nr_pages); +ASSERT (source_pfn < start_info_ptr->nr_pages); target_mfn = dom->pv_p2m[target_pfn];
@@ -209,8 +211,6 @@ static void tpm_hash2pcr(struct xc_dom_image *dom, char *cmdline)shutdown_tpmfront (tpm); } -static void call_start_info_hook (struct xc_dom_image *dom); -void kexec (void *kernel,long kernel_size,void *module,long module_size,char *cmdline,unsigned long flags) {struct xc_dom_image *dom;
@@ -242,8 +242,8 @@ void kexec(void *kernel, long kernel_size, void *module, long module_size, charxc_dom_module_mem (dom, module, module_size,NULL ); dom->flags = flags; - dom->console_evtchn = start_info.console.domU.evtchn; - dom->xenstore_evtchn = start_info.store_evtchn; + dom->console_evtchn = start_info_ptr->console.domU.evtchn; + dom->xenstore_evtchn = start_info_ptr->store_evtchn;tpm_hash2pcr (dom, cmdline);
@@ -279,7 +279,7 @@ void kexec(void *kernel, long kernel_size, void *module, long module_size, char errnum =ERR_EXEC_FORMAT ; goto out; } - dom->total_pages = start_info.nr_pages; + dom->total_pages = start_info_ptr->nr_pages;/* equivalent of arch_setup_meminit */ dom->p2m_size = dom->total_pages;
@@ -306,7 +306,7 @@ void kexec(void *kernel, long kernel_size, void *module, long module_size, char }/* Equivalent of xc_dom_boot_image */ - dom->shared_info_mfn =PHYS_PFN (start_info.shared_info); + dom->shared_info_mfn =PHYS_PFN (start_info_ptr->shared_info);if (!xc_dom_compat_check (dom)) {printk ("xc_dom_compat_check failed\n" );
@@ -315,8 +315,8 @@ void kexec(void *kernel, long kernel_size, void *module, long module_size, char }/* Move current console, xenstore and boot MFNs to the allocated place */ -do_exchange (dom, dom->console_pfn, start_info.console.domU.mfn); -do_exchange (dom, dom->xenstore_pfn, start_info.store_mfn); +do_exchange (dom, dom->console_pfn, start_info_ptr->console.domU.mfn); +do_exchange (dom, dom->xenstore_pfn, start_info_ptr->store_mfn);DEBUG ("virt base at %llx\n" , virt_base);DEBUG ("bootstack_pfn %lx\n" , dom->bootstack_pfn); _boot_target = virt_base +PFN_PHYS (dom->bootstack_pfn);
@@ -332,7 +332,8 @@ void kexec(void *kernel, long kernel_size, void *module, long module_size, char }/* start info page */ -call_start_info_hook (dom); +if ( dom->arch_hooks->start_info ) + dom->arch_hooks->start_info (dom);xc_dom_log_memory_footprint (dom);
@@ -371,7 +372,7 @@ void kexec(void *kernel, long kernel_size, void *module, long module_size, charDEBUG ("boot page mfn %lx\n" , boot_page_mfn); _boot_page_entry =PFN_PHYS (boot_page_mfn) |L1_PROT ;DEBUG ("boot page entry %llx\n" , _boot_page_entry); - _boot_oldpdmfn =virt_to_mfn (start_info.pt_base); + _boot_oldpdmfn =virt_to_mfn (start_info_ptr->pt_base);DEBUG ("boot old pd mfn %lx\n" , _boot_oldpdmfn);DEBUG ("boot pd virt %lx\n" , dom->pgtables_seg.vstart); _boot_pdmfn = dom->pv_p2m[PHYS_PFN (dom->pgtables_seg.vstart - virt_base)];
@@ -384,12 +385,12 @@ void kexec(void *kernel, long kernel_size, void *module, long module_size, charDEBUG ("boot start %lx\n" , _boot_start);/* Keep only useful entries */ -for (nr_m2p_updates = pfn =0 ; pfn < start_info.nr_pages; pfn++) +for (nr_m2p_updates = pfn =0 ; pfn < start_info_ptr->nr_pages; pfn++)if (dom->pv_p2m[pfn] !=pfn_to_mfn (pfn)) nr_m2p_updates++; m2p_updates =malloc (sizeof (*m2p_updates) * nr_m2p_updates); -for (i = pfn =0 ; pfn < start_info.nr_pages; pfn++) +for (i = pfn =0 ; pfn < start_info_ptr->nr_pages; pfn++)if (dom->pv_p2m[pfn] !=pfn_to_mfn (pfn)) { m2p_updates[i].ptr =PFN_PHYS (dom->pv_p2m[pfn]) |MMU_MACHPHYS_UPDATE ; m2p_updates[i].val = pfn;
@@ -431,11 +432,3 @@ out: allocated =0 ;xc_interface_close (xc_handle ); } - -/* No references to start_info of Mini-OS after this function. */ -static void call_start_info_hook (struct xc_dom_image *dom) -{ -#undef start_info -if ( dom->arch_hooks->start_info ) - dom->arch_hooks->start_info (dom); -}
Signature · 1 line
2.43.0
Re: [PATCH v2 3/3] stubdom/grub: swap start_info usage with start_info_ptr
Quoted 10 lines · Juergen Gross
Now that Mini-OS is exporting
start_info_ptr, use that instead of the tediousstart_infomacro.Note that the Mini-OS macro still needs to be undefined, but now it can be done right at the top of
kexec.c.Undo the previous move of the "other"
start_infointo a dedicated function.Signed-off-by Juergen Gross <[email protected]>
Quoted 4 lines · Juergen Gross
With the related change having been added to Mini-OS, the single V1 patch can now be expanded to a 3 patch series, especially meant to untangle the close dependencies between grub-pv and Mini-OS internals.
Quoted 8 lines
Changes in V2:
- add comment to patch 1
- added patches 2+3Juergen Gross (3):
stubdom/grub: avoid relying onstart_infodefinition
Config: update Mini-OS commit id
stubdom/grub: swapstart_infousage withstart_info_ptr
As patches 1 and 3 are still waiting for a maintainer ack, is patch 2 okay to put in ahead of patch 1?
Jan
Quoted 9 lines · Jan Beulich
Quoted 8 lines · Juergen Gross
With the related change having been added to Mini-OS, the single V1 patch can now be expanded to a 3 patch series, especially meant to untangle the close dependencies between grub-pv and Mini-OS internals.
Changes in V2:
- add comment to patch 1
- added patches 2+3
Quoted 7 lines
Quoted 4 lines
Juergen Gross (3):
stubdom/grub: avoid relying onstart_infodefinition
Config: update Mini-OS commit id
stubdom/grub: swapstart_infousage withstart_info_ptrAs patches 1 and 3 are still waiting for a maintainer ack, is patch 2 okay to put in ahead of patch 1?
That would break the grub-pv build again.
Juergen
Quoted 8 lines · Juergen Gross
With the related change having been added to Mini-OS, the single V1 patch can now be expanded to a 3 patch series, especially meant to untangle the close dependencies between grub-pv and Mini-OS internals.
Changes in V2:
- add comment to patch 1
- added patches 2+3
Quoted 9 lines
Juergen Gross (3):
stubdom/grub: avoid relying onstart_infodefinition
Config: update Mini-OS commit id
stubdom/grub: swapstart_infousage withstart_info_ptrConfig.mk | 2 +- stubdom/grub/kexec.c | 26 +++++++++++++------------- 2 files changed, 14 insertions(+), 14 deletions(-)
Any chance to get this series in?
Samuel doesn't seem to respond since several months now.
Juergen