Skip to contentSkip to conversation

pv-grub doesn't run on rhel5

bug New Gerd Hoffmann 4 participants 18 messages Aug 14, 2008 – Aug 16, 2008 1 message not in the archive Kbuild

lore
Share & tools
lore
#0 lore raw

Hi,

Trying to boot pv-grub on RHEL-5 makes it fail with

[ ... ]
gnttab_table mapped at 0x10001000.
Initialising scheduler
(XEN) mm.c:694:d6 Bad L3 flags 6
ERROR: mmu_update failed
Do_exit called!

Guess more recent xen versions are less picky here and just silenly fixup this? This is with 32bit pae. 64bit pvgrub runs fine.

Another issue: As 64bit pv-grub can't boot 32bit kernels, the 64bit xen build should create both 32bit and 64bit builds of pv-grub, so you can boot 32-on-64 guests with it?

cheers,
Gerd

Signature · 1 line
http://kraxel.fedorapeople.org/xenner/
#1 lore raw
Quoted 8 lines · Gerd Hoffmann, le Thu 14 Aug 2008 12:38:15 +0200, a écrit :

Trying to boot pv-grub on RHEL-5 makes it fail with

[ ... ]
gnttab_table mapped at 0x10001000.
Initialising scheduler
(XEN) mm.c:694:d6 Bad L3 flags 6
ERROR: mmu_update failed
Do_exit called!

It looks like it's mini-os itself that has troubles very early.

It works in my environment.

Quoted 2 lines

Guess more recent xen versions are less picky here and just silenly fixup this?

No, the check is still there, and I wonder how flags 6 could make it to L3 flags. Could you send me your mini-os.gz image?

Quoted 1 line

This is with 32bit pae.

Is it a 64 bit or 32 bit hypervisor? Which version of the hypervisor?

Quoted 3 lines

Another issue: As 64bit pv-grub can't boot 32bit kernels, the 64bit xen build should create both 32bit and 64bit builds of pv-grub, so you can boot 32-on-64 guests with it?

I'm afraid Keir will consider it is too late in the 3.3 release to make such a change in the build process.

Actually I am currently working on how we could switch a PV domain between 32 and 64. That won't ever go into 3.3 either, however.

Samuel

#3 lore raw
In reply to a message not in the archive
Quoted 8 lines · Gerd Hoffmann, le Thu 14 Aug 2008 14:20:59 +0200, a écrit :
Quoted 5 lines · Samuel Thibault
Quoted 2 lines

Guess more recent xen versions are less picky here and just silenly fixup this?

No, the check is still there, and I wonder how flags 6 could make it to L3 flags. Could you send me your mini-os.gz image?

Attached.

I have no problem running it under xen 3.3 indeed. Are you able to run the 3.3 mini-os itself for instance?

Samuel

#18 lore raw

PATCH 1/1 compiled a 32bit pv-grub on x86_64 xen target [Was: pv-grub doesn't run on rhel5]

In reply to Samuel Thibault
Quoted 7 lines · Samuel Thibault, le Thu 14 Aug 2008 12:15:20 +0100, a écrit :
Quoted 3 lines · Gerd Hoffmann, le Thu 14 Aug 2008 12:38:15 +0200, a écrit :

Another issue: As 64bit pv-grub can't boot 32bit kernels, the 64bit xen build should create both 32bit and 64bit builds of pv-grub, so you can boot 32-on-64 guests with it?

I'm afraid Keir will consider it is too late in the 3.3 release to make such a change in the build process.

Here is a patch anyway, it doesn't touch any code so at least shouldn't break anything.

pv-grub: On x86_64, also build an x86_32 pv-grub

This requires suffixing obj directories and having grub compiled outside sources.

.hgignore +3 -7
diff -r 37f3bdce0394 .hgignore
@@ -90,20 +90,16 @@
 ^stubdom/gcc-.*$
 ^stubdom/include$
 ^stubdom/ioemu$
-^stubdom/libxc$
+^stubdom/libxc-.*$
 ^stubdom/lwip-.*$
 ^stubdom/mini-os-.*$
-^stubdom/mk-headers$
+^stubdom/mk-headers-.*$
 ^stubdom/newlib-.*$
 ^stubdom/pciutils-.*$
 ^stubdom/zlib-.*$
-^stubdom/grub-cvs$
-^stubdom/grub/stage2$
-^stubdom/grub/netboot$
-^stubdom/grub/dirs$
+^stubdom/grub-.*$
 ^stubdom/lwip/
 ^stubdom/ioemu/
-^stubdom/grub-upstream/
 ^tools/.*/build/lib.*/.*\.py$
 ^tools/blktap/Makefile\.smh$
 ^tools/blktap/drivers/blktapctrl$
Makefile +12 -0
diff -r 37f3bdce0394 Makefile
@@ -22,6 +22,9 @@ build: kernels
 	$(MAKE) -C xen build
 	$(MAKE) -C tools build
 	$(MAKE) -C stubdom build
+ifeq (x86_64,$(XEN_TARGET_ARCH))
+	XEN_TARGET_ARCH=x86_32 $(MAKE) -C stubdom pv-grub
+endif
 	$(MAKE) -C docs build
 
 # The test target is for unit tests that can run without an installation.  Of
@@ -71,6 +74,9 @@ install-kernels:
 .PHONY: install-stubdom
 install-stubdom:
 	$(MAKE) -C stubdom install
+ifeq (x86_64,$(XEN_TARGET_ARCH))
+	XEN_TARGET_ARCH=x86_32 $(MAKE) -C stubdom install-grub
+endif
 
 .PHONY: install-docs
 install-docs:
@@ -109,6 +115,9 @@ clean::
 	$(MAKE) -C xen clean
 	$(MAKE) -C tools clean
 	$(MAKE) -C stubdom crossclean
+ifeq (x86_64,$(XEN_TARGET_ARCH))
+	XEN_TARGET_ARCH=x86_32 $(MAKE) -C stubdom crossclean
+endif
 	$(MAKE) -C docs clean
 
 # clean, but blow away kernel build tree plus tarballs
@@ -117,6 +126,9 @@ distclean:
 	$(MAKE) -C xen distclean
 	$(MAKE) -C tools distclean
 	$(MAKE) -C stubdom distclean
+ifeq (x86_64,$(XEN_TARGET_ARCH))
+	XEN_TARGET_ARCH=x86_32 $(MAKE) -C stubdom distclean
+endif
 	$(MAKE) -C docs distclean
 	rm -rf dist patches/tmp
 	for i in $(ALLKERNELS) ; do $(MAKE) $$i-delete ; done
extras/mini-os/Makefile +2 -2
diff -r 37f3bdce0394 extras/mini-os/Makefile
@@ -66,8 +66,8 @@ ifeq ($(lwip),y)
 # lwIP library
 LWC	:= $(shell find $(LWIPDIR)/ -type f -name '*.c')
 LWC	:= $(filter-out %6.c %ip6_addr.c %ethernetif.c, $(LWC))
-LWC	+= lwip-arch.c lwip-net.c
 LWO	:= $(patsubst %.c,%.o,$(LWC))
+LWO	+= $(addprefix $(OBJ_DIR)/,lwip-arch.o lwip-net.o)
 
 $(OBJ_DIR)/lwip.a: $(LWO)
 	$(RM) $@
@@ -79,7 +79,7 @@ OBJS := $(filter-out $(OBJ_DIR)/lwip%.o 
 OBJS := $(filter-out $(OBJ_DIR)/lwip%.o $(LWO), $(OBJS))
 
 ifeq ($(libc),y)
-APP_LDLIBS += -L$(XEN_ROOT)/stubdom/libxc -whole-archive -lxenguest -lxenctrl -no-whole-archive
+APP_LDLIBS += -L$(XEN_ROOT)/stubdom/libxc-$(XEN_TARGET_ARCH) -whole-archive -lxenguest -lxenctrl -no-whole-archive
 APP_LDLIBS += -lpci
 APP_LDLIBS += -lz
 APP_LDLIBS += -lm
stubdom/Makefile +52 -46

230 lines not on this page · raw message

stubdom/grub/Makefile +17 -7
diff -r 37f3bdce0394 stubdom/grub/Makefile
@@ -3,7 +3,7 @@ include $(XEN_ROOT)/Config.mk
 include $(XEN_ROOT)/Config.mk
 vpath %.c ../grub-upstream
 
-BOOT=boot-$(XEN_TARGET_ARCH).o
+BOOT=$(OBJ_DIR)/boot-$(XEN_TARGET_ARCH).o
 
 DEF_CPPFLAGS += -I$(XEN_ROOT)/tools/libxc -I$(XEN_ROOT)/tools/include -I.
 DEF_CPPFLAGS += -I../grub-upstream/stage1
@@ -17,7 +17,7 @@ DEF_CPPFLAGS += -DPRESET_MENU_STRING='""
 DEF_CPPFLAGS += -DPRESET_MENU_STRING='""'
 DEF_CPPFLAGS += -DPACKAGE='"grubdom"' -DVERSION='"0.97"'
 
-all: main.a
+all: $(OBJ_DIR)/main.a
 
 STAGE2_SOURCES=builtins.c char_io.c cmdline.c common.c console.c disk_io.c graphics.c gunzip.c md5.c serial.c stage2.c terminfo.c tparm.c
 
@@ -59,16 +59,26 @@ NETBOOT_SOURCES:=$(addprefix netboot/,$(
 
 $(BOOT): DEF_CPPFLAGS+=-D__ASSEMBLY__
 
-OBJS = $(NETBOOT_SOURCES:.c=.o) $(STAGE2_SOURCES:.c=.o) kexec.o mini-os.o
+PV_GRUB_SOURCES = kexec.c mini-os.c
 
-dirs:
-	mkdir -p netboot stage2
+SOURCES = $(NETBOOT_SOURCES) $(STAGE2_SOURCES) $(PV_GRUB_SOURCES)
+
+OBJS = $(addprefix $(OBJ_DIR)/,$(SOURCES:.c=.o))
+
+$(OBJ_DIR)/dirs:
+	mkdir -p $(OBJ_DIR)/netboot $(OBJ_DIR)/stage2
 	touch $@
 
-$(OBJS): dirs
+$(OBJS): $(OBJ_DIR)/dirs
 
-main.a: $(BOOT) $(OBJS)
+$(OBJ_DIR)/main.a: $(BOOT) $(OBJS)
 	$(AR) cr $@ $^
+
+$(OBJ_DIR)/%.o: %.c
+	$(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
+
+$(OBJ_DIR)/%.o: %.S
+	$(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
 
 clean:
 	rm -fr dirs *.a *.o stage2 netboot
#4 lore raw
In reply to Samuel Thibault
Quoted 10 lines · Samuel Thibault
Quoted 6 lines · Gerd Hoffmann, le Thu 14 Aug 2008 14:20:59 +0200, a écrit :
Quoted 4 lines · Samuel Thibault
Quoted 2 lines

Guess more recent xen versions are less picky here and just silenly fixup this?

No, the check is still there, and I wonder how flags 6 could make it to L3 flags. Could you send me your mini-os.gz image?

Attached.

I have no problem running it under xen 3.3 indeed. Are you able to run the 3.3 mini-os itself for instance?

That runs fine. It doesn't touch address space above 1gb though, thus it has no need to touch the pae pgd.

cheers,
Gerd

Signature · 1 line
http://kraxel.fedorapeople.org/xenner/
#5 lore raw
Quoted 7 lines · Gerd Hoffmann, le Thu 14 Aug 2008 16:18:21 +0200, a écrit :
Quoted 6 lines · Samuel Thibault
Quoted 5 lines · Gerd Hoffmann, le Thu 14 Aug 2008 14:20:59 +0200, a écrit :
Quoted 4 lines · Samuel Thibault
Quoted 2 lines

Guess more recent xen versions are less picky here and just silenly fixup this?

No, the check is still there, and I wonder how flags 6 could make it to L3 flags. Could you send me your mini-os.gz image?

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Attached.

I have no problem running it under xen 3.3 indeed. Are you able to run the 3.3 mini-os itself for instance?

That runs fine. It doesn't touch address space above 1gb though, thus it has no need to touch the pae pgd.

That's possible indeed.

The problem is a bug in the hypervisor's mod_l3_entry which calls adjust_guest_l3e before calling get_page_from_l3e, see c/s 17061. Is it possible for you to backport the patch?

Samuel

#6 lore raw
Quoted 3 lines · Samuel Thibault

The problem is a bug in the hypervisor's mod_l3_entry which calls adjust_guest_l3e before calling get_page_from_l3e, see c/s 17061. Is it possible for you to backport the patch?

So due to the wrong ordering xen first sets the bits, then notices they shouldn't be set, then complains the guest passed invalid bits? Uhm, well, no way to fix minios to run on older xen versions then I guess (which I'd prefer). Except maybe limiting the 32bit version to 1GB address space. Which should be fine at least for pvgrub ...

Another pvgrub issue: Is booting guests with the framebuffer enabled supposed to work? I suspect that needs some work on the qemu side. Right now I see the pvgrub screen just fine, after booting the guest kernel I see funny, scrambled pictures though. I suspect that needs some work on the qemu side, so it remaps the framebuffer correctly.

cheers,
Gerd

Signature · 1 line
http://kraxel.fedorapeople.org/xenner/
#7 lore raw
Quoted 7 lines · Gerd Hoffmann, le Thu 14 Aug 2008 17:04:07 +0200, a écrit :
Quoted 3 lines · Samuel Thibault

The problem is a bug in the hypervisor's mod_l3_entry which calls adjust_guest_l3e before calling get_page_from_l3e, see c/s 17061. Is it possible for you to backport the patch?

So due to the wrong ordering xen first sets the bits, then notices they shouldn't be set, then complains the guest passed invalid bits?

Yes.

Quoted 3 lines

Uhm, well, no way to fix minios to run on older xen versions then I guess (which I'd prefer). Except maybe limiting the 32bit version to 1GB address space. Which should be fine at least for pvgrub ...

That should be feasible indeed.

Quoted 2 lines

Another pvgrub issue: Is booting guests with the framebuffer enabled supposed to work?

Yes, but you have to not enable the framebuffer in the grub configuration, because the framebuffer is currently not able to restart.

Quoted 1 line

I suspect that needs some work on the qemu side.

Exactly.

Samuel

#8 lore raw
Quoted 6 lines · Samuel Thibault, le Thu 14 Aug 2008 16:14:00 +0100, a écrit :
Quoted 3 lines · Gerd Hoffmann, le Thu 14 Aug 2008 17:04:07 +0200, a écrit :

Uhm, well, no way to fix minios to run on older xen versions then I guess (which I'd prefer). Except maybe limiting the 32bit version to 1GB address space. Which should be fine at least for pvgrub ...

That should be feasible indeed.

As seen below. I'm not sure whether we want that into mainline Xen 3.3 however?

BTW, Keir commited the 32on64 pv-grub build, it should appear after the regression tests.

Samuel

pv-grub: limit address space usage to less than a GB so as to be runnable on xen hypervisor revisions earlier than c/s 17061.

extras/mini-os/arch/x86/mm.c +4 -0
diff -r 38783464a671 extras/mini-os/arch/x86/mm.c
@@ -414,18 +414,22 @@ pgentry_t *need_pgt(unsigned long addr)
 }
 
 static unsigned long demand_map_area_start;
+#ifndef DEMAND_MAP_PAGES
 #ifdef __x86_64__
 #define DEMAND_MAP_PAGES ((128ULL << 30) / PAGE_SIZE)
 #else
 #define DEMAND_MAP_PAGES ((2ULL << 30) / PAGE_SIZE)
 #endif
+#endif
 
 #ifdef HAVE_LIBC
 unsigned long heap, brk, heap_mapped, heap_end;
+#ifndef HEAP_PAGES
 #ifdef __x86_64__
 #define HEAP_PAGES ((128ULL << 30) / PAGE_SIZE)
 #else
 #define HEAP_PAGES ((1ULL << 30) / PAGE_SIZE)
+#endif
 #endif
 #endif
 
stubdom/Makefile +2 -1
diff -r 38783464a671 stubdom/Makefile
@@ -33,6 +33,7 @@ TARGET_CFLAGS=
 TARGET_CFLAGS=
 NEWLIB_CFLAGS+=-D_I386MACH_ALLOW_HW_INTERRUPTS
 STUBDOM_SUPPORTED=1
+PVGRUB_CPPFLAGS=-DDEMAND_MAP_PAGES='((256ULL << 20) / PAGE_SIZE)' -DHEAP_PAGES='((256ULL << 20) / PAGE_SIZE)'
 endif
 ifeq ($(GNU_TARGET_ARCH), x86_64)
 TARGET_CFLAGS=-mno-red-zone
@@ -296,7 +297,7 @@ c-stubdom: mini-os-$(XEN_TARGET_ARCH)-c 
 
 .PHONY: pv-grub
 pv-grub: mini-os-$(XEN_TARGET_ARCH)-grub libxc grub
-	DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="-DCONFIG_GRUB $(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< APP_OBJS=$(CURDIR)/grub-$(XEN_TARGET_ARCH)/main.a
+	DEF_CPPFLAGS="$(TARGET_CPPFLAGS) $(PVGRUB_CPPFLAGS)" DEF_CFLAGS="-DCONFIG_GRUB $(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< APP_OBJS=$(CURDIR)/grub-$(XEN_TARGET_ARCH)/main.a
 
 #########
 # install
#16 lore raw
In reply to Samuel Thibault
Quoted 4 lines · Samuel Thibault

The problem is a bug in the hypervisor's mod_l3_entry which calls adjust_guest_l3e before calling get_page_from_l3e, see c/s 17061. Is it possible for you to backport the patch?

Fedora 8 just updated their Xen package because the pvops kernels also trigger this bug.

J

#9 lore raw
In reply to Samuel Thibault

Hi,

Quoted 9 lines
Quoted 2 lines

Another pvgrub issue: Is booting guests with the framebuffer enabled supposed to work?

Yes, but you have to not enable the framebuffer in the grub configuration, because the framebuffer is currently not able to restart.

Quoted 1 line

I suspect that needs some work on the qemu side.

Exactly.

I'll have a look I guess as I'm busy with qemu coding anyway ...

cheers,
Gerd

Signature · 1 line
http://kraxel.fedorapeople.org/xenner/
#17 lore raw
In reply to Jeremy Fitzhardinge
Quoted 8 lines · Jeremy Fitzhardinge
Quoted 4 lines · Samuel Thibault

The problem is a bug in the hypervisor's mod_l3_entry which calls adjust_guest_l3e before calling get_page_from_l3e, see c/s 17061. Is it possible for you to backport the patch?

Fedora 8 just updated their Xen package because the pvops kernels also trigger this bug.

Then rhel-5 will probably fixed too. Not being able to run pvops kernels isn't going to fly. Having the 1GB limit for pvgrub would be nice nevertheless.

cheers,
Gerd

Signature · 1 line
http://kraxel.fedorapeople.org/xenner/
#10 lore raw

PATCH 1/1 xenfb: make restartable [Was: pv-grub doesn't run on rhel5]

In reply to Samuel Thibault
Quoted 5 lines · Samuel Thibault, le Thu 14 Aug 2008 16:14:00 +0100, a écrit :
Quoted 2 lines

Another pvgrub issue: Is booting guests with the framebuffer enabled supposed to work?

Yes, but you have to not enable the framebuffer in the grub configuration, because the framebuffer is currently not able to restart.

Oh actually it was a lot easier than I thought, see patch below (which is actually partly bug fixes).

xenfb: make restartable

- Fix the pixel unmapping, which should happen during the Closing state.
- Fix qemu segfault when a guest shuts its fb down.
- Once connected, if frontend state goes from Closed to Initialized, restart the connection loop.

extras/mini-os/fbfront.c +2 -4
diff -r 38783464a671 extras/mini-os/fbfront.c
@@ -226,8 +226,7 @@ void shutdown_kbdfront(struct kbdfront_d
     xenbus_wait_for_value(path, "6", &dev->events);
 
     err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 1);
-    // does not work yet.
-    //xenbus_wait_for_value(path, "2", &dev->events);
+    xenbus_wait_for_value(path, "2", &dev->events);
 
     xenbus_unwatch_path(XBT_NIL, path);
 
@@ -566,8 +565,7 @@ void shutdown_fbfront(struct fbfront_dev
     xenbus_wait_for_value(path, "6", &dev->events);
 
     err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 1);
-    // does not work yet
-    //xenbus_wait_for_value(path, "2", &dev->events);
+    xenbus_wait_for_value(path, "2", &dev->events);
 
     xenbus_unwatch_path(XBT_NIL, path);
 
stubdom/README +1 -6
diff -r 38783464a671 stubdom/README
@@ -126,9 +126,4 @@ Limitations
 ===========
 
 - You can not boot a 64bit kernel with a 32bit-compiled PV-GRUB and vice-versa.
-To cross-compile a 32bit PV-GRUB,
-
-export XEN_TARGET_ARCH=x86_32
-
-- bootsplash is supported, but the ioemu backend does not yet support restart
-for use by the booted kernel.
+You need to choose between pv-grub-x86_64.gz and pv-grub-x86_32.gz
tools/ioemu/hw/xenfb.c +20 -4
diff -r 38783464a671 tools/ioemu/hw/xenfb.c
@@ -445,6 +445,13 @@ static void xenfb_unbind(struct xenfb_de
 		xc_evtchn_unbind(dev->xenfb->evt_xch, dev->port);
 		dev->port = -1;
 	}
+
+	if (!strcmp(dev->devicetype, "vfb")) {
+	    if (dev->xenfb->pixels) {
+		    munmap(dev->xenfb->pixels, dev->xenfb->fb_len);
+		    dev->xenfb->pixels = NULL;
+	    }
+	}
 }
 
 
@@ -452,10 +459,6 @@ static void xenfb_detach_dom(struct xenf
 {
 	xenfb_unbind(&xenfb->fb);
 	xenfb_unbind(&xenfb->kbd);
-	if (xenfb->pixels) {
-		munmap(xenfb->pixels, xenfb->fb_len);
-		xenfb->pixels = NULL;
-	}
 }
 
 /* Remove the backend area in xenbus since the framebuffer really is
@@ -653,6 +656,16 @@ static int xenfb_on_state_change(struct 
 		   not much point in us continuing. */
 		return -1;
 	case XenbusStateInitialising:
+		if (dev->state != XenbusStateClosed)
+		    /* Do not let a domain make us skip the closing state */
+		    return 0;
+		xenfb_switch_state(dev, XenbusStateInitWait);
+		xs_unwatch(dev->xenfb->xsh, dev->otherend, "");
+		if (!strcmp(dev->devicetype, "vkbd")) {
+		    fprintf(stderr, "FB: Waiting for KBD backend creation\n");
+		    xenfb_wait_for_frontend(&dev->xenfb->kbd, xenfb_frontend_initialized_kbd);
+		}
+		break;
 	case XenbusStateInitWait:
 	case XenbusStateInitialised:
 	case XenbusStateConnected:
@@ -1274,6 +1287,9 @@ static void xenfb_update(void *opaque)
     struct xenfb *xenfb = opaque;
     int period;
 
+    if (!xenfb->fb.page)
+        return;
+
     if (xenfb_queue_full(xenfb))
         return;
 
#11 lore raw

Re: [PATCH] xenfb: make restartable [Was: pv-grub doesn't run on rhel5]

Quoted 8 lines · Samuel Thibault
Quoted 4 lines · Samuel Thibault, le Thu 14 Aug 2008 16:14:00 +0100, a écrit :
Quoted 2 lines

Another pvgrub issue: Is booting guests with the framebuffer enabled supposed to work?

Yes, but you have to not enable the framebuffer in the grub configuration, because the framebuffer is currently not able to restart.

Oh actually it was a lot easier than I thought, see patch below (which is actually partly bug fixes).

Yea, looks reasonable, I've ended up with something quite simliar (against the new framebuffer code).

cheers,
Gerd

Signature · 1 line
http://kraxel.fedorapeople.org/xenner/
#12 lore raw

Re: [PATCH] xenfb: make restartable

In reply to Samuel Thibault

extras/mini-os/fbfront.c

Quoted 24 lines · Samuel Thibault
Quoted 5 lines · Samuel Thibault, le Thu 14 Aug 2008 16:14:00 +0100, a écrit :
Quoted 2 lines

Another pvgrub issue: Is booting guests with the framebuffer enabled supposed to work?

Yes, but you have to not enable the framebuffer in the grub configuration, because the framebuffer is currently not able to restart.

Oh actually it was a lot easier than I thought, see patch below (which is actually partly bug fixes).

xenfb: make restartable

- Fix the pixel unmapping, which should happen during the Closing state.
- Fix qemu segfault when a guest shuts its fb down.
- Once connected, if frontend state goes from Closed to Initialized, restart the connection loop.

diff -r 38783464a671 extras/mini-os/fbfront.c

extras/mini-os/fbfront.c +0 -0

[Not familiar with this code...]

Quoted 7 lines

diff -r 38783464a671 tools/ioemu/hw/xenfb.c

tools/ioemu/hw/xenfb.c +0 -0
@@ -445,6 +445,13 @@ static void xenfb_unbind(struct xenfb_de
 		xc_evtchn_unbind(dev->xenfb->evt_xch, dev->port);
 		dev->port = -1;
 	}

tools/ioemu/hw/xenfb.c static void xenfb_unbind(struct xenfb_de · line 457

Quoted 10 lines
tools/ioemu/hw/xenfb.c +7 -0
+
+	if (!strcmp(dev->devicetype, "vfb")) {
+	    if (dev->xenfb->pixels) {
+		    munmap(dev->xenfb->pixels, dev->xenfb->fb_len);
+		    dev->xenfb->pixels = NULL;
+	    }
+	}
 }
 
 

The check for vfb is ugly. The only alternative I can see is fb == dev->xenfb->fb. Matter of taste.

Also somewhat ugly is the fact that xenfb_unbind() is no longer the exact reverse of xenfb_bind(), but reverses xenfb_map_fb() as well. Could be avoided by creating xenfb_unmap_fb() and calling it after xenfb_unbind() from xenfb_detach_dom() unconditionally, and from xenfb_on_state_change() when dev is fb.

Quoted 12 lines
tools/ioemu/hw/xenfb.c +0 -4
@@ -452,10 +459,6 @@ static void xenfb_detach_dom(struct xenf
 {
 	xenfb_unbind(&xenfb->fb);
 	xenfb_unbind(&xenfb->kbd);
-	if (xenfb->pixels) {
-		munmap(xenfb->pixels, xenfb->fb_len);
-		xenfb->pixels = NULL;
-	}
 }
 
 /* Remove the backend area in xenbus since the framebuffer really is

tools/ioemu/hw/xenfb.c static int xenfb_on_state_change(struct · line 661

Quoted 6 lines
tools/ioemu/hw/xenfb.c +3 -0
@@ -653,6 +656,16 @@ static int xenfb_on_state_change(struct 
 		   not much point in us continuing. */
 		return -1;
 	case XenbusStateInitialising:
+		if (dev->state != XenbusStateClosed)
+		    /* Do not let a domain make us skip the closing state */
+		    return 0;

Why does this work?

tools/ioemu/hw/xenfb.c static int xenfb_on_state_change(struct · line 668

Quoted 7 lines
tools/ioemu/hw/xenfb.c +7 -0
+		xenfb_switch_state(dev, XenbusStateInitWait);
+		xs_unwatch(dev->xenfb->xsh, dev->otherend, "");
+		if (!strcmp(dev->devicetype, "vkbd")) {
+		    fprintf(stderr, "FB: Waiting for KBD backend creation\n");
+		    xenfb_wait_for_frontend(&dev->xenfb->kbd, xenfb_frontend_initialized_kbd);
+		}
+		break;

Man, I hate this state machine... not your fault.

Gerd's new one is much clearer (I asked for that).

Quoted 14 lines
tools/ioemu/hw/xenfb.c +3 -0
 	case XenbusStateInitWait:
 	case XenbusStateInitialised:
 	case XenbusStateConnected:
@@ -1274,6 +1287,9 @@ static void xenfb_update(void *opaque)
     struct xenfb *xenfb = opaque;
     int period;
 
+    if (!xenfb->fb.page)
+        return;
+
     if (xenfb_queue_full(xenfb))
         return;
 
#13 lore raw

Re: [PATCH] xenfb: make restartable

Quoted 4 lines · Markus Armbruster, le Fri 15 Aug 2008 08:39:06 -0400, a écrit :
Quoted 4 lines
tools/ioemu/hw/xenfb.c +4 -0
+	if (!strcmp(dev->devicetype, "vfb")) {
+	    if (dev->xenfb->pixels) {
+		    munmap(dev->xenfb->pixels, dev->xenfb->fb_len);
+		    dev->xenfb->pixels = NULL;
Quoted 8 lines

tools/ioemu/hw/xenfb.c static void xenfb_unbind(struct xenfb_de · line 455

Quoted 5 lines
tools/ioemu/hw/xenfb.c +2 -0
+	    }
+	}
 }

The check for vfb is ugly. The only alternative I can see is fb == dev->xenfb->fb. Matter of taste.

Hum, that was what I had written previously actually. I don't see why it is "ugly", in that pixels is a device resource. It should probably be in xenfb->fb actually.

Quoted 9 lines

tools/ioemu/hw/xenfb.c static int xenfb_on_state_change(struct · line 661

Quoted 7 lines
tools/ioemu/hw/xenfb.c +3 -0
@@ -653,6 +656,16 @@ static int xenfb_on_state_change(struct 
 		   not much point in us continuing. */
 		return -1;
 	case XenbusStateInitialising:
+		if (dev->state != XenbusStateClosed)
+		    /* Do not let a domain make us skip the closing state */
+		    return 0;

Why does this work?

It's meant to not work. If the frontend is not playing well (going through the closing state), then ignore what it's doing until it plays well. An alternative could be to just shut down. In any case, we don't want to let it drive us to remapping something else without unmapping the previous fb.

Quoted 9 lines

tools/ioemu/hw/xenfb.c static int xenfb_on_state_change(struct · line 668

Quoted 7 lines
tools/ioemu/hw/xenfb.c +7 -0
+		xenfb_switch_state(dev, XenbusStateInitWait);
+		xs_unwatch(dev->xenfb->xsh, dev->otherend, "");
+		if (!strcmp(dev->devicetype, "vkbd")) {
+		    fprintf(stderr, "FB: Waiting for KBD backend creation\n");
+		    xenfb_wait_for_frontend(&dev->xenfb->kbd, xenfb_frontend_initialized_kbd);
+		}
+		break;

Man, I hate this state machine...

I agree :)

Quoted 1 line

Gerd's new one is much clearer (I asked for that).

Then since 3.3 is about to be released, we'd probably have this change with it.

Samuel

#14 lore raw

Re: [PATCH] xenfb: make restartable

Quoted 14 lines · Samuel Thibault
Quoted 4 lines · Markus Armbruster, le Fri 15 Aug 2008 08:39:06 -0400, a écrit :
Quoted 4 lines
tools/ioemu/hw/xenfb.c +4 -0
+	if (!strcmp(dev->devicetype, "vfb")) {
+	    if (dev->xenfb->pixels) {
+		    munmap(dev->xenfb->pixels, dev->xenfb->fb_len);
+		    dev->xenfb->pixels = NULL;
Quoted 8 lines

tools/ioemu/hw/xenfb.c static void xenfb_unbind(struct xenfb_de · line 455

Quoted 5 lines
tools/ioemu/hw/xenfb.c +2 -0
+	    }
+	}
 }

The check for vfb is ugly. The only alternative I can see is fb == dev->xenfb->fb. Matter of taste.

Quoted 3 lines

Hum, that was what I had written previously actually. I don't see why it is "ugly", in that pixels is a device resource. It should probably be in xenfb->fb actually.

struct xenfb_device captures stuff that both devices have.

By "is ugly" I meant to say that checking for vfb by testing its devicetype string looks ugly to me. But fb == dev->xenfb->fb isn't exactly the acme of elegance either.

Quoted 10 lines
Quoted 9 lines

tools/ioemu/hw/xenfb.c static int xenfb_on_state_change(struct · line 661

Quoted 7 lines
tools/ioemu/hw/xenfb.c +3 -0
@@ -653,6 +656,16 @@ static int xenfb_on_state_change(struct 
 		   not much point in us continuing. */
 		return -1;
 	case XenbusStateInitialising:
+		if (dev->state != XenbusStateClosed)
+		    /* Do not let a domain make us skip the closing state */
+		    return 0;

Why does this work?

Quoted 5 lines

It's meant to not work. If the frontend is not playing well (going through the closing state), then ignore what it's doing until it plays well. An alternative could be to just shut down. In any case, we don't want to let it drive us to remapping something else without unmapping the previous fb.

We need to make up our mind how to handle invalid state transitions.

Is silently ignoring guest misbehavior smart? I'd rather log it.

[...]

#15 lore raw

Re: [PATCH] xenfb: make restartable

Quoted 3 lines · Markus Armbruster, le Fri 15 Aug 2008 18:53:01 -0400, a écrit :

We need to make up our mind how to handle invalid state transitions.

Is silently ignoring guest misbehavior smart? I'd rather log it.

Why not indeed, but beware of logging too much.

Samuel