repair stubdoms
Subsystems (3)
cover repair stubdoms
Adding support for HVMlite Mini-OS broke some stubdom functionality as various parts of the stubdom code was built without specifying any Mini-OS configuration defines. This led to inconsistencies when those parts included Mini-OS headers now depending on the config of Mini9-OS. Some of those cases did work just by pure luck.
Juergen Gross (3):
mini-os: support newer xen interface
mini-os: provide irq on/off/save/restore functions for Mini-OS apps
mini-os: support "make config" for out-of-tree users
.gitignore | 1 + Config.mk | 4 +++- Makefile | 5 +++++ arch/arm/mm.c | 2 +- arch/x86/mm.c | 2 +- arch/x86/sched.c | 28 ++++++++++++++++++++++++++++ balloon.c | 2 -- gnttab.c | 4 ++-- include/gnttab.h | 2 +- include/x86/os.h | 13 +++++++++++++ minios.mk | 1 - 11 files changed, 55 insertions(+), 9 deletions(-)
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 1/3 mini-os: support newer xen interface
Mini-OS is currently setting __XEN_INTERFACE_VERSION__ to a rather ancient version.
To be able to use a more recent variant garnt_entry_t must be changed to grant_entry_v1_t. In balloon.c we omit initializing elements of struct xen_memory_reservation with 0 to avoid problems with different named structure elements in different Xen interface versions.
--- arch/arm/mm.c | 2 +- arch/x86/mm.c | 2 +- balloon.c | 2 -- gnttab.c | 4 ++-- include/gnttab.h | 2 +- 5 files changed, 5 insertions(+), 7 deletions(-)
arch/arm/mm.c +1 -1
@@ -116,7 +116,7 @@ static paddr_t get_gnttab_base(void)return gnttab_base; } -grant_entry_t *arch_init_gnttab (int nr_grant_frames) +grant_entry_v1_t *arch_init_gnttab (int nr_grant_frames) {struct xen_add_to_physmap xatp;struct gnttab_setup_table setup;
arch/x86/mm.c +1 -1
@@ -890,7 +890,7 @@ void arch_init_mm(unsigned long* start_pfn_p, unsigned long* max_pfn_p)#endif } -grant_entry_t *arch_init_gnttab (int nr_grant_frames) +grant_entry_v1_t *arch_init_gnttab (int nr_grant_frames) {struct gnttab_setup_table setup;unsigned long frames[nr_grant_frames];
balloon.c +0 -2
@@ -73,8 +73,6 @@ int balloon_up(unsigned long n_pages)unsigned long page, pfn;int rc;struct xen_memory_reservation reservation = { - .address_bits =0 , - .extent_order =0 , .domid =DOMID_SELF };
gnttab.c +2 -2
@@ -24,9 +24,9 @@/* NR_GRANT_FRAMES must be less than or equal to that configured in Xen */ #define NR_GRANT_FRAMES 4 -#define NR_GRANT_ENTRIES (NR_GRANT_FRAMES * PAGE_SIZE / sizeof(grant_entry_t)) +#define NR_GRANT_ENTRIES (NR_GRANT_FRAMES * PAGE_SIZE / sizeof(grant_entry_v1_t)) -static grant_entry_t *gnttab_table; +static grant_entry_v1_t *gnttab_table;static grant_ref_t gnttab_list[NR_GRANT_ENTRIES ];#ifdef GNT_DEBUG static char inuse[NR_GRANT_ENTRIES ];
include/gnttab.h +1 -1
@@ -12,6 +12,6 @@ unsigned long gnttab_end_transfer(grant_ref_t gref);int gnttab_end_access (grant_ref_t ref);const char *gnttabop_error (int16_t status);void fini_gnttab (void ); -grant_entry_t *arch_init_gnttab (int nr_grant_frames); +grant_entry_v1_t *arch_init_gnttab (int nr_grant_frames);#endif /* !__GNTTAB_H__ */
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 2/3 mini-os: provide irq on/off/save/restore functions for Mini-OS apps
In reply to Juergen GrossProvide non-inline variants of the local_irq_*() functions for Mini-OS apps which should not depend on Mini-OS configuration.
--- arch/x86/sched.c | 28 ++++++++++++++++++++++++++++ include/x86/os.h | 13 +++++++++++++ 2 files changed, 41 insertions(+)
arch/x86/sched.c +28 -0
@@ -135,5 +135,33 @@ void run_idle_thread(void)#endif } +unsigned long __local_irq_save (void ) +{ +unsigned long flags; +local_irq_save (flags); +return flags; +} +void __local_irq_restore (unsigned long flags) +{ +local_irq_restore (flags); +} + +unsigned long __local_save_flags (void ) +{ +unsigned long flags; + +local_save_flags (flags); +return flags; +} + +void __local_irq_disable (void ) +{ +local_irq_disable (); +} + +void __local_irq_enable (void ) +{ +local_irq_enable (); +}
include/x86/os.h +13 -0
@@ -176,11 +176,24 @@ static inline int irqs_disabled(void)#endif +#ifdef __INSIDE_MINIOS__#define local_irq_save (x) __save_and_cli(x)#define local_irq_restore (x) __restore_flags(x)#define local_save_flags (x) __save_flags(x)#define local_irq_disable () __cli()#define local_irq_enable () __sti() +#else +unsigned long __local_irq_save (void ); +void __local_irq_restore (unsigned long flags); +unsigned long __local_save_flags (void ); +void __local_irq_disable (void ); +void __local_irq_enable (void ); +#define local_irq_save (x) x = __local_irq_save() +#define local_irq_restore (x) __local_irq_restore(x) +#define local_save_flags (x) x = __local_save_flags() +#define local_irq_disable () __local_irq_disable() +#define local_irq_enable () __local_irq_enable() +#endif /* This is a barrier for the compiler only, NOT the processor! */ #define barrier () __asm__ __volatile__("": : :"memory")
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 3/3 mini-os: support "make config" for out-of-tree users
In reply to Juergen GrossMini-OS applications being compiled using Mini-OS headers without being integrated in the make environment of Mini-OS need a way to set CONFIG_* defines according to their Mini-OS configuration.
Add a new make target "config" for that purpose creating a Makefile snipplet $(CONFIG_FILE) (defaults to ./minios-config.mk) containing the needed information.
--- .gitignore | 1 + Config.mk | 4 +++- Makefile | 5 +++++ minios.mk | 1 - 4 files changed, 9 insertions(+), 2 deletions(-)
.gitignore +1 -0
@@ -13,3 +13,4 @@ arch/x86/minios-x86*.lds include/list.h mini-os mini-os.gz +minios-config.mk
Config.mk +3 -1
@@ -51,7 +51,7 @@ endif libc = $(stubdom) -XEN_INTERFACE_VERSION := 0x00030205 +XEN_INTERFACE_VERSION ?= 0x00030205 export XEN_INTERFACE_VERSION # Try to find out the architecture family TARGET_ARCH_FAM.
@@ -193,6 +193,8 @@ DEFINES-$(CONFIG_CONSFRONT) += -DCONFIG_CONSFRONT DEFINES-$(CONFIG_XENBUS) += -DCONFIG_XENBUS DEFINES-$(CONFIG_BALLOON) += -DCONFIG_BALLOON +DEFINES-y += -D__XEN_INTERFACE_VERSION__=$(XEN_INTERFACE_VERSION) + # Override settings for this OS PTHREAD_LIBS = nosharedlibs=y
Makefile +5 -0
@@ -158,6 +158,11 @@ $(OBJ_DIR)/$(TARGET): $(OBJS) $(APP_O) arch_lib $(TARGET_ARCH_DIR)/minios-$(MINI $(LD) $(LDFLAGS) $(LDFLAGS_FINAL) [email protected] $(EXTRA_OBJS) -o $@ gzip -f -9 -c $@ >[email protected] +.PHONY: config +CONFIG_FILE ?= $(CURDIR)/minios-config.mk +config: + echo "$(DEFINES-y)" >$(CONFIG_FILE) + .PHONY: clean arch_clean arch_clean:
minios.mk +0 -1
@@ -10,7 +10,6 @@ DEF_CFLAGS += -fno-builtin -Wall -Werror -Wredundant-decls -Wno-format -Wno-redu DEF_CFLAGS += $(call cc-option,$(CC),-fno-stack-protector,) DEF_CFLAGS += $(call cc-option,$(CC),-fgnu89-inline) DEF_CFLAGS += -Wstrict-prototypes -Wnested-externs -Wpointer-arith -Winline -DEF_CPPFLAGS += -D__XEN_INTERFACE_VERSION__=$(XEN_INTERFACE_VERSION) DEF_ASFLAGS += -D__ASSEMBLY__ DEF_LDFLAGS +=
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 1/3] mini-os: support newer xen interface
In reply to Juergen GrossQuoted 9 lines · Juergen Gross
Mini-OS is currently setting
__XEN_INTERFACE_VERSION__to a rather ancient version.To be able to use a more recent variant
garnt_entry_tmust be changed togrant_entry_v1_t. Inballoon.cwe omit initializing elements of structxen_memory_reservationwith 0 to avoid problems with different named structure elements in different Xen interface versions.Signed-off-by Juergen Gross <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [Minios-devel] [PATCH 2/3] mini-os: provide irq on/off/save/restore functions for Mini-OS apps
In reply to Juergen GrossQuoted 3 lines · Juergen Gross
Provide non-inline variants of the local_irq_*() functions for Mini-OS apps which should not depend on Mini-OS configuration.
I think it would be worth pointing out which apps need to access such low level functionalities in commit message.
Quoted 1 line
Signed-off-by Juergen Gross <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [Minios-devel] [PATCH 3/3] mini-os: support "make config" for out-of-tree users
In reply to Juergen GrossQuoted 9 lines · Juergen Gross
Mini-OS applications being compiled using Mini-OS headers without being integrated in the make environment of Mini-OS need a way to set CONFIG_* defines according to their Mini-OS configuration.
Add a new make target "config" for that purpose creating a
Makefilesnipplet $(CONFIG_FILE) (defaults to ./minios-config.mk) containing the needed information.Signed-off-by Juergen Gross <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [Minios-devel] [PATCH 2/3] mini-os: provide irq on/off/save/restore functions for Mini-OS apps
In reply to Wei LiuQuoted 7 lines · Wei Liu
Quoted 3 lines · Juergen Gross
Provide non-inline variants of the local_irq_*() functions for Mini-OS apps which should not depend on Mini-OS configuration.
I think it would be worth pointing out which apps need to access such low level functionalities in commit message.
I stumbled over it with ioemu-stubdom. Basically it could be any app using e.g. wake_up() or wait_event() as those are macros fiddling with irq on/off. xenevtchn_pending() is another candidate.
Quoted 3 lines
Quoted 1 line
Signed-off-by Juergen Gross <[email protected]>Reviewed-by Wei Liu <[email protected]>
Thanks,
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Samuel Thibault
Acked-byRe: [PATCH 1/3] mini-os: support newer xen interface
In reply to Wei LiuQuoted 4 lines · Wei Liu, on Tue 30 Aug 2016 14:53:10 +0100, wrote:
Quoted 3 lines · Juergen Gross
Mini-OS is currently setting
__XEN_INTERFACE_VERSION__to a rather ancient version.
Quoted 8 lines
Quoted 6 lines
To be able to use a more recent variant
garnt_entry_tmust be changed togrant_entry_v1_t. Inballoon.cwe omit initializing elements of structxen_memory_reservationwith 0 to avoid problems with different named structure elements in different Xen interface versions.Signed-off-by Juergen Gross <[email protected]>Reviewed-by Wei Liu <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Samuel Thibault
Acked-byRe: [Minios-devel] [PATCH 2/3] mini-os: provide irq on/off/save/restore functions for Mini-OS apps
In reply to Juergen GrossQuoted 6 lines · Juergen Gross, on Tue 30 Aug 2016 16:08:45 +0200, wrote:
Quoted 5 lines · Wei Liu
Quoted 3 lines · Juergen Gross
Provide non-inline variants of the local_irq_*() functions for Mini-OS apps which should not depend on Mini-OS configuration.
Quoted 6 lines
Quoted 2 lines
I think it would be worth pointing out which apps need to access such low level functionalities in commit message.
I stumbled over it with ioemu-stubdom. Basically it could be any app using e.g.
wake_up()orwait_event()as those are macros fiddling with irq on/off.xenevtchn_pending()is another candidate.
I was thinking that we should perhaps rather make wake_up/wait_event non-inlined, instead of exposing irq on/off. But then I see that it's typically used in event handlers too (e.g. *front/back.c), and applications may want to implement some such...
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Juergen Gross <[email protected]>Reviewed-by Wei Liu <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 3/3] mini-os: support "make config" for out-of-tree users
In reply to Juergen GrossHello,
Config.mk endif · line 54
Quoted 6 lines · Juergen Gross, on Tue 30 Aug 2016 13:51:23 +0200, wrote:
Config.mk +1
-1@@ -51,7 +51,7 @@ endif libc = $(stubdom) -XEN_INTERFACE_VERSION := 0x00030205 +XEN_INTERFACE_VERSION ?= 0x00030205
Why making it overridable? AIUI changing the version would change the xen headers API, and thus the existing mini-os source would possibly not even compile any more. I also don't see the relation with the commit log :)
Samuel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 3/3] mini-os: support "make config" for out-of-tree users
Quoted 7 lines · Samuel Thibault
Hello,
Quoted 4 lines · Juergen Gross, on Tue 30 Aug 2016 13:51:23 +0200, wrote:
Config.mk +0
-0@@ -51,7 +51,7 @@ endif libc = $(stubdom)
Quoted 7 lines
Config.mk endif · line 54
Quoted 2 lines
Config.mk +1
-1-XEN_INTERFACE_VERSION := 0x00030205 +XEN_INTERFACE_VERSION ?= 0x00030205Why making it overridable? AIUI changing the version would change the xen headers API, and thus the existing mini-os source would possibly not even compile any more. I also don't see the relation with the commit log :)
Hmm, I should have included more reasoning.
I stumbled over the problem with xenstore-stubdom: xenstore is using __XEN_LATEST_INTERFACE_VERSION__ when being compiled. This produced a build error with Mini-OS (console_evtchn in include/console.h was #define'd to console.domU.evtchn by include/xen/xen.h). It was pure luck such a problem didn't occur before my recent changes.
I think it is much more reasonable to compile all parts of a stubdom with the same Xen interface version instead of letting use the core of Mini-OS an ancient version and the App using Mini-OS another one. So I added XEN_INTERFACE_VERSION to be configurable.
This requires some adjustments in Mini-OS, of course. That is the purpose of patch 1 of this series.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 3/3] mini-os: support "make config" for out-of-tree users
Hello,
Quoted 9 lines · Juergen Gross, on Thu 01 Sep 2016 08:21:33 +0200, wrote:
I stumbled over the problem with xenstore-stubdom: xenstore is using
__XEN_LATEST_INTERFACE_VERSION__when being compiled. This produced a build error with Mini-OS (console_evtchnininclude/console.hwas #define'd to console.domU.evtchn byinclude/xen/xen.h). It was pure luck such a problem didn't occur before my recent changes.I think it is much more reasonable to compile all parts of a stubdom with the same Xen interface version instead of letting use the core of Mini-OS an ancient version and the App using Mini-OS another one.
Ok, I agree with that.
Quoted 3 lines
So I added
XEN_INTERFACE_VERSIONto be configurable. This requires some adjustments in Mini-OS, of course. That is the purpose of patch 1 of this series.
Ok, now I better understand the issue, pros and cons, etc. It would be better to clearly document and test it: AIUI,
- interface version compatibility is not so great: some features are e.g. just *not* available when using interface version 0, so if mini-os tries to use newer interfaces while stubdom asks for an older interface version, it will fail to build, so it may need #ifs to check for presence of the interface, and gracefully disable using the feature instead of failing-to-build.
- mini-os happens not to be able to build with interface version 0, basically because the current default is 0x00030205 and so nobody tests with 0. Notably due to the console_evtchn #define, but also the use of set_xen_guest_handle. Ideally we'd fix it, but I guess nobody will want something older than that anyway, so we probably don't want to handle the burden.
- to be able to let the stubdom application decide which interface version it wants to build against, mini-os must be buildable standalone with all versions from 0x00030205 to latest supported (which is what patch 1 fixes). A not too bad approximation of this would be to be able to build it with the minimum supported version and with latest version. Perhaps we can declare that Config.mk's default interface version is the minimum supported, so building standalone mini-os will test that, and since as you say we already build the xenstore-stubdom with latest version, building the xenstore-stubdom will test that.
- that way, stubdom applications can choose the level of compatibility they wish from mini-os' minimum supported to mini-os' latest supported.
- whenever somebody would like to use an interface version which is not supported by mini-os headers yet, we just need to update mini-os' headers, and we have to fix the build with the minimum supported version and with the latest supported version.
So if you agree with my reasoning, I'd say that the patch series should document all that along the definition of XEN_INTERFACE_VERSION in Config.mk: explaining that this default is the minimum supported interface version, which the application can override up to the latest supported by mini-os, and if a yet-newer interface is needed, one should upgrade the headers, and before committing, try to build mini-os both with the same minimum supported version for compatibility, and with the latest version.
Samuel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Samuel Thibault
Acked-byRe: [Minios-devel] [PATCH 3/3] mini-os: support "make config" for out-of-tree users
In reply to Wei LiuQuoted 5 lines · Wei Liu, on Tue 30 Aug 2016 14:57:50 +0100, wrote:
Quoted 4 lines · Juergen Gross
Mini-OS applications being compiled using Mini-OS headers without being integrated in the make environment of Mini-OS need a way to set CONFIG_* defines according to their Mini-OS configuration.
Quoted 7 lines
Quoted 5 lines
Add a new make target "config" for that purpose creating a
Makefilesnipplet $(CONFIG_FILE) (defaults to ./minios-config.mk) containing the needed information.Signed-off-by Juergen Gross <[email protected]>Reviewed-by Wei Liu <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 3/3] mini-os: support "make config" for out-of-tree users
In reply to Samuel ThibaultQuoted 9 lines · Samuel Thibault
Hello,
Quoted 6 lines · Juergen Gross, on Thu 01 Sep 2016 08:21:33 +0200, wrote:
I stumbled over the problem with xenstore-stubdom: xenstore is using
__XEN_LATEST_INTERFACE_VERSION__when being compiled. This produced a build error with Mini-OS (console_evtchnininclude/console.hwas #define'd to console.domU.evtchn byinclude/xen/xen.h). It was pure luck such a problem didn't occur before my recent changes.
Quoted 5 lines
Quoted 3 lines
I think it is much more reasonable to compile all parts of a stubdom with the same Xen interface version instead of letting use the core of Mini-OS an ancient version and the App using Mini-OS another one.
Ok, I agree with that.
Very good.
Quoted 14 lines
Quoted 3 lines
So I added
XEN_INTERFACE_VERSIONto be configurable. This requires some adjustments in Mini-OS, of course. That is the purpose of patch 1 of this series.Ok, now I better understand the issue, pros and cons, etc. It would be better to clearly document and test it: AIUI,
- interface version compatibility is not so great: some features are e.g. just *not* available when using interface version 0, so if mini-os tries to use newer interfaces while stubdom asks for an older interface version, it will fail to build, so it may need #ifs to check for presence of the interface, and gracefully disable using the feature instead of failing-to-build.
Quoted 6 lines
- mini-os happens not to be able to build with interface version 0, basically because the current default is
0x00030205and so nobody tests with 0. Notably due to theconsole_evtchn#define, but also the use ofset_xen_guest_handle. Ideally we'd fix it, but I guess nobody will want something older than that anyway, so we probably don't want to handle the burden.
I think 0x00030205 should be the minimum version Mini-OS has to support.
Quoted 9 lines
- to be able to let the stubdom application decide which interface version it wants to build against, mini-os must be buildable standalone with all versions from
0x00030205to latest supported (which is what patch 1 fixes). A not too bad approximation of this would be to be able to build it with the minimum supported version and with latest version. Perhaps we can declare that Config.mk's default interface version is the minimum supported, so building standalone mini-os will test that, and since as you say we already build the xenstore-stubdom with latest version, building the xenstore-stubdom will test that.
I think I'll add a new make target "test" which will test different build configurations (PARAVIRT y/n, BALLOON y/n, 32/64 bit, Xen interface versions, all/no frontends). This can be easily added to OSStest.
Quoted 7 lines
- that way, stubdom applications can choose the level of compatibility they wish from mini-os' minimum supported to mini-os' latest supported.
- whenever somebody would like to use an interface version which is not supported by mini-os headers yet, we just need to update mini-os' headers, and we have to fix the build with the minimum supported version and with the latest supported version.
Right.
Quoted 8 lines
So if you agree with my reasoning, I'd say that the patch series should document all that along the definition of
XEN_INTERFACE_VERSIONin Config.mk: explaining that this default is the minimum supported interface version, which the application can override up to the latest supported by mini-os, and if a yet-newer interface is needed, one should upgrade the headers, and before committing, try to build mini-os both with the same minimum supported version for compatibility, and with the latest version.
Okay, I'll update the patch description and add some README contents.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 3/3] mini-os: support "make config" for out-of-tree users
Quoted 4 lines · Juergen Gross, on Fri 02 Sep 2016 07:42:36 +0200, wrote:
I think I'll add a new make target "test" which will test different build configurations (PARAVIRT y/n, BALLOON y/n, 32/64 bit, Xen interface versions, all/no frontends). This can be easily added to OSStest.
Good, thanks.
Samuel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 11 lines · Juergen Gross
Adding support for HVMlite Mini-OS broke some stubdom functionality as various parts of the stubdom code was built without specifying any Mini-OS configuration defines. This led to inconsistencies when those parts included Mini-OS headers now depending on the config of Mini9-OS. Some of those cases did work just by pure luck.
Juergen Gross (3):
mini-os: support newer xen interface
mini-os: provide irq on/off/save/restore functions for Mini-OS apps
mini-os: support "make config" for out-of-tree users
Pushed.
I will update Xen's Config.mk soon-ish.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel