debuggers.hg

annotate stubdom/Makefile @ 17909:c8d9ade45781

Add PV-GRUB

This fetches GRUB1 sources, applies the {graphical, print function,
save default, and ext3_256byte} patches from debian, and applies a
patch to make it work on x86_64 and port it to Mini-OS. By using
libxc, PV-GRUB can then "kexec" the loaded kernel from inside the
domain itself, hence permitting to avoid the security-concerned
pygrub.

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Jun 18 09:36:47 2008 +0100 (2008-06-18)
parents 7e00ebe2b7fd
children b3d827e63a09
rev   line source
keir@17066 1 XEN_ROOT = ..
keir@17905 2 MINI_OS = $(XEN_ROOT)/extras/mini-os
keir@17066 3
keir@17070 4 export XEN_OS=MiniOS
keir@17070 5
keir@17066 6 include $(XEN_ROOT)/Config.mk
keir@17066 7 export stubdom=y
keir@17066 8 export debug=y
keir@17066 9
keir@17066 10 IOEMU_OPTIONS=--disable-vnc-tls
keir@17066 11 BINUTILS_VERSION=2.18
keir@17066 12 GCC_VERSION=4.2.2
keir@17066 13 ZLIB_VERSION=1.2.3
keir@17066 14 LIBPCI_VERSION=2.2.9
keir@17066 15 NEWLIB_DATE=2008-01-01
keir@17823 16 LWIP_DATE=2008-06-01
keir@17909 17 GRUB_DATE=2008-06-01
keir@17066 18
keir@17066 19 WGET=wget -c
keir@17066 20
keir@17066 21 GNU_TARGET_ARCH:=$(XEN_TARGET_ARCH)
keir@17066 22 ifeq ($(XEN_TARGET_ARCH),x86_32)
keir@17066 23 GNU_TARGET_ARCH:=i686
keir@17066 24 endif
keir@17066 25
keir@17066 26 ifeq ($(GNU_TARGET_ARCH), i686)
keir@17066 27 TARGET_CFLAGS=
keir@17830 28 NEWLIB_CFLAGS+=-D_I386MACH_ALLOW_HW_INTERRUPTS
keir@17066 29 endif
keir@17066 30 ifeq ($(GNU_TARGET_ARCH), x86_64)
keir@17066 31 TARGET_CFLAGS=-mno-red-zone
keir@17830 32 NEWLIB_CFLAGS+=-D_I386MACH_ALLOW_HW_INTERRUPTS
keir@17066 33 endif
keir@17066 34 ifeq ($(GNU_TARGET_ARCH), ia64)
keir@17066 35 TARGET_CFLAGS=-mconstant-gp
keir@17066 36 endif
keir@17066 37
keir@17066 38 CROSS_ROOT=cross-root-$(GNU_TARGET_ARCH)
keir@17066 39 CROSS_PREFIX=$(CURDIR)/$(CROSS_ROOT)
keir@17066 40 export CROSS_COMPILE=$(GNU_TARGET_ARCH)-xen-elf-
keir@17066 41 export PATH:=$(CROSS_PREFIX)/bin:$(PATH)
keir@17066 42
keir@17909 43 TARGETS=ioemu c caml grub
keir@17905 44
keir@17066 45 .PHONY: all
keir@17909 46 all: ioemu-stubdom c-stubdom pv-grub
keir@17066 47
keir@17066 48 ################
keir@17066 49 # Cross-binutils
keir@17066 50 ################
keir@17066 51
keir@17066 52 binutils-$(BINUTILS_VERSION).tar.bz2:
keir@17066 53 $(WGET) http://ftp.gnu.org/gnu/binutils/$@
keir@17066 54 binutils-$(BINUTILS_VERSION): binutils-$(BINUTILS_VERSION).tar.bz2
keir@17905 55 tar xjf $<
keir@17905 56 patch -d $@ -p1 < binutils.patch
keir@17066 57 touch $@
keir@17066 58
keir@17066 59 BINUTILS_STAMPFILE=$(CROSS_ROOT)/bin/$(GNU_TARGET_ARCH)-xen-elf-ar
keir@17066 60 .PHONY: cross-binutils
keir@17066 61 cross-binutils: $(BINUTILS_STAMPFILE)
keir@17066 62 $(BINUTILS_STAMPFILE): binutils-$(BINUTILS_VERSION)
keir@17071 63 mkdir -p binutils-build
keir@17071 64 ( cd binutils-build && \
keir@17066 65 ../binutils-$(BINUTILS_VERSION)/configure --prefix=$(CROSS_PREFIX) --verbose --target=$(GNU_TARGET_ARCH)-xen-elf && \
keir@17066 66 $(MAKE) && \
keir@17066 67 $(MAKE) check && \
keir@17066 68 $(MAKE) install )
keir@17066 69
keir@17066 70 ###########
keir@17066 71 # Cross-gcc
keir@17066 72 ###########
keir@17066 73
keir@17066 74 gcc-$(GCC_VERSION).tar.bz2:
keir@17066 75 $(WGET) http://ftp.gnu.org/gnu/gcc/gcc-$(GCC_VERSION)/gcc-$(GCC_VERSION).tar.bz2
keir@17066 76 gcc-$(GCC_VERSION): gcc-$(GCC_VERSION).tar.bz2
keir@17905 77 tar xjf $<
keir@17905 78 patch -d $@ -p1 < gcc.patch
keir@17066 79 touch $@
keir@17830 80
keir@17066 81 GCC_STAMPFILE=$(CROSS_ROOT)/bin/$(GNU_TARGET_ARCH)-xen-elf-gcc-$(GCC_VERSION)
keir@17066 82 .PHONY: cross-gcc
keir@17066 83 cross-gcc: $(GCC_STAMPFILE)
keir@17066 84 $(GCC_STAMPFILE): gcc-$(GCC_VERSION) $(BINUTILS_STAMPFILE)
keir@17071 85 mkdir -p gcc-build
keir@17071 86 ( cd gcc-build && \
keir@17066 87 ../gcc-$(GCC_VERSION)/configure --prefix=$(CROSS_PREFIX) --verbose --target=$(GNU_TARGET_ARCH)-xen-elf --enable-languages=c --disable-libssp --with-gnu-as --with-gnu-ld && \
keir@17066 88 $(MAKE) GCC_FOR_TARGET='$$$$r/gcc/xgcc -B$$$$r/gcc/ '"$(TARGET_CFLAGS)"' $$(FLAGS_FOR_TARGET)' && \
keir@17066 89 $(MAKE) install )
keir@17066 90
keir@17066 91 ##############
keir@17066 92 # Cross-newlib
keir@17066 93 ##############
keir@17066 94
keir@17072 95 newlib-cvs:
keir@17066 96 cvs -z 9 -d :pserver:anoncvs@sources.redhat.com:/cvs/src co -D $(NEWLIB_DATE) newlib
keir@17071 97 mv src newlib-cvs
keir@17905 98 patch -d $@ -p0 < newlib.patch
keir@17066 99
keir@17066 100 NEWLIB_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libc.a
keir@17066 101 .PHONY: cross-newlib
keir@17066 102 cross-newlib: $(NEWLIB_STAMPFILE)
keir@17072 103 $(NEWLIB_STAMPFILE): newlib-cvs $(GCC_STAMPFILE)
keir@17071 104 mkdir -p newlib-build
keir@17071 105 ( cd newlib-build && \
keir@17830 106 CC_FOR_TARGET="$(GNU_TARGET_ARCH)-xen-elf-gcc $(TARGET_CFLAGS) $(NEWLIB_CFLAGS)" ../newlib-cvs/configure --prefix=$(CROSS_PREFIX) --verbose --target=$(GNU_TARGET_ARCH)-xen-elf --enable-newlib-io-long-long && \
keir@17066 107 $(MAKE) && \
keir@17066 108 $(MAKE) install )
keir@17066 109
keir@17066 110 ############
keir@17066 111 # Cross-zlib
keir@17066 112 ############
keir@17066 113
keir@17066 114 zlib-$(ZLIB_VERSION).tar.gz:
keir@17066 115 $(WGET) http://www.zlib.net/zlib-$(ZLIB_VERSION).tar.gz
keir@17066 116
keir@17066 117 ZLIB_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libz.a
keir@17066 118 .PHONY: cross-zlib
keir@17066 119 cross-zlib: $(ZLIB_STAMPFILE)
keir@17066 120 $(ZLIB_STAMPFILE): zlib-$(ZLIB_VERSION).tar.gz $(NEWLIB_STAMPFILE)
keir@17066 121 tar xzf $<
keir@17066 122 ( cd zlib-$(ZLIB_VERSION) && \
keir@17066 123 CFLAGS="$(TARGET_CFLAGS)" CC=$(GNU_TARGET_ARCH)-xen-elf-gcc ./configure --prefix=$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf && \
keir@17066 124 $(MAKE) libz.a && \
keir@17066 125 $(MAKE) install )
keir@17066 126
keir@17066 127 ##############
keir@17066 128 # Cross-libpci
keir@17066 129 ##############
keir@17066 130
keir@17066 131 pciutils-$(LIBPCI_VERSION).tar.bz2:
keir@17066 132 $(WGET) http://www.kernel.org/pub/software/utils/pciutils/pciutils-$(LIBPCI_VERSION).tar.bz2
keir@17066 133
keir@17066 134 LIBPCI_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libpci.a
keir@17066 135 .PHONY: cross-libpci
keir@17066 136 cross-libpci: $(LIBPCI_STAMPFILE)
keir@17066 137 $(LIBPCI_STAMPFILE): pciutils-$(LIBPCI_VERSION).tar.bz2 $(NEWLIB_STAMPFILE) $(ZLIB_STAMPFILE)
keir@17066 138 tar xjf $<
keir@17066 139 ( cd pciutils-$(LIBPCI_VERSION) && \
keir@17066 140 cp ../libpci.config.h lib/config.h && \
keir@17066 141 echo '#define PCILIB_VERSION "$(LIBPCI_VERSION)"' >> lib/config.h && \
keir@17066 142 cp ../libpci.config.mak lib/config.mk && \
keir@17066 143 $(MAKE) CC="$(GNU_TARGET_ARCH)-xen-elf-gcc $(TARGET_CFLAGS)" lib/libpci.a && \
keir@17066 144 $(INSTALL_DATA) lib/libpci.a $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/lib/ && \
keir@17066 145 $(INSTALL_DIR) $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include/pci && \
keir@17066 146 $(INSTALL_DATA) lib/{config,header,pci,types}.h $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include/pci/ \
keir@17066 147 )
keir@17066 148
keir@17066 149 ######
keir@17066 150 # lwIP
keir@17066 151 ######
keir@17066 152
keir@17071 153 lwip-cvs:
keir@17905 154 cvs -z 9 -d :pserver:anonymous@cvs.savannah.nongnu.org:/sources/lwip co -D $(LWIP_DATE) -d $@ lwip
keir@17066 155
keir@17066 156 #######
keir@17066 157 # Links
keir@17066 158 #######
keir@17066 159
keir@17066 160 .PHONY: $(CROSS_ROOT)
keir@17066 161 $(CROSS_ROOT): cross-newlib cross-zlib cross-libpci
keir@17066 162
keir@17066 163 .PHONY: mk-symlinks
keir@17066 164 mk-symlinks:
keir@17066 165 [ -h include ] || ln -sf ../tools/include .
keir@17066 166 mkdir -p libxc
keir@17066 167 [ -h libxc/Makefile ] || ( cd libxc && \
keir@17905 168 ln -sf ../$(XEN_ROOT)/tools/libxc/*.h . && \
keir@17905 169 ln -sf ../$(XEN_ROOT)/tools/libxc/*.c . && \
keir@17905 170 ln -sf ../$(XEN_ROOT)/tools/libxc/Makefile . )
keir@17066 171 mkdir -p libxc/$(XEN_TARGET_ARCH)
keir@17066 172 [ -h libxc/$(XEN_TARGET_ARCH) ] || ( cd libxc/$(XEN_TARGET_ARCH) && \
keir@17905 173 ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/*.c . && \
keir@17905 174 ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/*.h . && \
keir@17905 175 ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/Makefile . )
keir@17066 176 mkdir -p ioemu
keir@17066 177 [ -h ioemu/Makefile ] || ( cd ioemu && \
keir@17905 178 ln -sf ../$(XEN_ROOT)/tools/ioemu/* . && \
keir@17066 179 ([ ! -h config-host.h ] || rm -f config-host.h) && \
keir@17066 180 ([ ! -h config-host.mak ] || rm -f config-host.mak) )
keir@17905 181 $(MAKE) -C $(MINI_OS) links
keir@17905 182
keir@17905 183 TARGETS_MINIOS=$(addprefix mini-os-,$(TARGETS))
keir@17905 184 $(TARGETS_MINIOS): mini-os-%:
keir@17905 185 [ -d $@ ] || \
keir@17905 186 for i in $$(cd $(MINI_OS) ; find . -type d) ; do \
keir@17905 187 mkdir -p $@/$$i ; \
keir@17905 188 done
keir@17066 189
keir@17066 190 #######
keir@17066 191 # libxc
keir@17066 192 #######
keir@17066 193
keir@17066 194 .PHONY: libxc
keir@17905 195 libxc: libxc/libxenctrl.a libxc/libxenguest.a
keir@17905 196 libxc/libxenctrl.a libxc/libxenguest.a: cross-zlib mk-symlinks
keir@17905 197 $(MAKE) -C libxc
keir@17066 198
keir@17066 199 #######
keir@17066 200 # ioemu
keir@17066 201 #######
keir@17066 202
keir@17066 203 .PHONY: ioemu
keir@17066 204 ioemu: cross-zlib cross-libpci mk-symlinks libxc
keir@17066 205 [ -f ioemu/config-host.mak ] || \
keir@17066 206 ( cd ioemu ; XEN_TARGET_ARCH=$(XEN_TARGET_ARCH) sh configure --prefix=/usr --enable-stubdom $(IOEMU_OPTIONS))
keir@17071 207 $(MAKE) -C ioemu LWIPDIR=$(CURDIR)/lwip-cvs
keir@17066 208
keir@17066 209 ######
keir@17066 210 # caml
keir@17066 211 ######
keir@17066 212
keir@17066 213 .PHONY: caml
keir@17830 214 caml: cross-newlib mk-symlinks
keir@17778 215 $(MAKE) -C $@ LWIPDIR=$(CURDIR)/lwip-cvs
keir@17066 216
keir@17299 217 ###
keir@17299 218 # C
keir@17299 219 ###
keir@17299 220
keir@17299 221 .PHONY: c
keir@17830 222 c: cross-newlib mk-symlinks
keir@17778 223 $(MAKE) -C $@ LWIPDIR=$(CURDIR)/lwip-cvs
keir@17299 224
keir@17909 225 ######
keir@17909 226 # Grub
keir@17909 227 ######
keir@17909 228
keir@17909 229 grub-cvs:
keir@17909 230 cvs -z 9 -d :pserver:anonymous@cvs.sv.gnu.org:/sources/grub co -D $(GRUB_DATE) -d $@ grub
keir@17909 231 for i in grub.patches/* ; do \
keir@17909 232 patch -d $@ -p1 < $$i ; \
keir@17909 233 done
keir@17909 234
keir@17909 235 .PHONY: grub
keir@17909 236 grub: grub-cvs cross-newlib mk-symlinks
keir@17909 237 $(MAKE) -C $@
keir@17909 238
keir@17066 239 ########
keir@17066 240 # minios
keir@17066 241 ########
keir@17066 242
keir@17778 243 .PHONY: ioemu-stubdom
keir@17905 244 ioemu-stubdom: mini-os-ioemu lwip-cvs libxc ioemu
keir@17909 245 DEF_CFLAGS=-DCONFIG_QEMU $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< LWIPDIR=$(CURDIR)/lwip-cvs APP_OBJS="$(CURDIR)/ioemu/i386-dm-stubdom/qemu.a $(CURDIR)/ioemu/i386-dm-stubdom/libqemu.a"
keir@17066 246
keir@17778 247 CAMLLIB = $(shell ocamlc -where)
keir@17066 248 .PHONY: caml-stubdom
keir@17905 249 caml-stubdom: mini-os-caml lwip-cvs libxc caml
keir@17909 250 DEF_CFLAGS=-DCONFIG_CAML $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< LWIPDIR=$(CURDIR)/lwip-cvs APP_OBJS="$(CURDIR)/caml/main-caml.o $(CURDIR)/caml/caml.o $(CAMLLIB)/libasmrun.a"
keir@17299 251
keir@17299 252 .PHONY: c-stubdom
keir@17905 253 c-stubdom: mini-os-c lwip-cvs libxc c
keir@17909 254 DEF_CFLAGS=-DCONFIG_C $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< LWIPDIR=$(CURDIR)/lwip-cvs APP_OBJS=$(CURDIR)/c/main.a
keir@17909 255
keir@17909 256 .PHONY: pv-grub
keir@17909 257 pv-grub: mini-os-grub libxc grub
keir@17909 258 DEF_CFLAGS=-DCONFIG_GRUB $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< APP_OBJS=$(CURDIR)/grub/main.a
keir@17066 259
keir@17066 260 #########
keir@17066 261 # install
keir@17066 262 #########
keir@17066 263
keir@17909 264 install: install-ioemu install-grub
keir@17909 265
keir@17909 266 install-ioemu: mini-os-ioemu/mini-os.gz
keir@17066 267 $(INSTALL_PROG) stubdom-dm "$(DESTDIR)/usr/lib/xen/bin"
keir@17909 268 $(INSTALL_PROG) $< "$(DESTDIR)/usr/lib/xen/boot/ioemu-stubdom.gz"
keir@17909 269
keir@17909 270 install-grub: mini-os-grub/mini-os.gz
keir@17909 271 $(INSTALL_PROG) $< "$(DESTDIR)/usr/lib/xen/boot/pv-grub.gz"
keir@17066 272
keir@17066 273 #######
keir@17066 274 # clean
keir@17066 275 #######
keir@17066 276
keir@17066 277 # Only clean the libxc/ioemu/mini-os part
keir@17066 278 .PHONY: clean
keir@17066 279 clean:
keir@17905 280 rm -fr mini-os-ioemu
keir@17905 281 rm -fr mini-os-c
keir@17905 282 rm -fr mini-os-caml
keir@17909 283 rm -fr mini-os-grub
keir@17066 284 $(MAKE) -C caml clean
keir@17778 285 $(MAKE) -C c clean
keir@17909 286 $(MAKE) -C grub clean
keir@17066 287 rm -fr libxc ioemu mini-os include
keir@17066 288
keir@17066 289 # clean the cross-compilation result
keir@17066 290 .PHONY: crossclean
keir@17066 291 crossclean: clean
keir@17066 292 rm -fr $(CROSS_ROOT)
keir@17071 293 rm -fr binutils-build gcc-build newlib-build
keir@17066 294 rm -fr zlib-$(ZLIB_VERSION) pciutils-$(LIBPCI_VERSION)
keir@17066 295
keir@17066 296 # clean patched sources
keir@17066 297 .PHONY: patchclean
keir@17066 298 patchclean: crossclean
keir@17066 299 rm -fr binutils-$(BINUTILS_VERSION)
keir@17066 300 rm -fr gcc-$(GCC_VERSION)
keir@17071 301 rm -fr newlib-cvs
keir@17071 302 rm -fr lwip-cvs
keir@17909 303 rm -fr grub-cvs
keir@17066 304
keir@17066 305 # clean downloads
keir@17066 306 .PHONY: downloadclean
keir@17066 307 downloadclean: patchclean
keir@17066 308 rm -f binutils-$(BINUTILS_VERSION).tar.bz2
keir@17066 309 rm -f gcc-$(GCC_VERSION).tar.bz2
keir@17066 310 rm -f zlib-$(ZLIB_VERSION).tar.gz
keir@17066 311 rm -f pciutils-$(LIBPCI_VERSION).tar.bz2
keir@17066 312
keir@17066 313 .PHONY: distclean
keir@17066 314 distclean: downloadclean