Gentoo Archives: gentoo-commits

From: Yixun Lan <dlan@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: app-emulation/xen-pvgrub/files/, app-emulation/xen-pvgrub/
Date: Tue, 11 Oct 2016 07:44:04
Message-Id: 1476171836.732369cdddba45a22cc9cb6a124bd523f12aa05c.dlan@gentoo
1 commit: 732369cdddba45a22cc9cb6a124bd523f12aa05c
2 Author: Yixun Lan <dlan <AT> gentoo <DOT> org>
3 AuthorDate: Tue Oct 11 07:42:53 2016 +0000
4 Commit: Yixun Lan <dlan <AT> gentoo <DOT> org>
5 CommitDate: Tue Oct 11 07:43:56 2016 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=732369cd
7
8 app-emulation/xen-pvgrub: fix boot certain guest kernel
9
10 pvgrub: fix crash when booting kernel with p2m list outside kernel mapping
11 https://xenbits.xen.org/gitweb/?p=xen.git;a=commit;h=9714f6b87e19b32d3a6663a20df6610265c4bfe5
12
13 Gentoo-Bug: 595354
14
15 Package-Manager: portage-2.3.1
16
17 .../files/xen-pvgrub-4.7.0-fix-boot-p2m.patch | 36 +++++
18 .../xen-pvgrub/xen-pvgrub-4.7.0-r1.ebuild | 164 +++++++++++++++++++++
19 2 files changed, 200 insertions(+)
20
21 diff --git a/app-emulation/xen-pvgrub/files/xen-pvgrub-4.7.0-fix-boot-p2m.patch b/app-emulation/xen-pvgrub/files/xen-pvgrub-4.7.0-fix-boot-p2m.patch
22 new file mode 100644
23 index 00000000..e9c8040
24 --- /dev/null
25 +++ b/app-emulation/xen-pvgrub/files/xen-pvgrub-4.7.0-fix-boot-p2m.patch
26 @@ -0,0 +1,36 @@
27 +From 9714f6b87e19b32d3a6663a20df6610265c4bfe5 Mon Sep 17 00:00:00 2001
28 +From: Juergen Gross <jgross@××××.com>
29 +Date: Wed, 28 Sep 2016 06:02:44 +0200
30 +Subject: [PATCH] pvgrub: fix crash when booting kernel with p2m list outside
31 + kernel mapping
32 +
33 +When trying to boot a kernel with the p2m list not mapped by the
34 +initial kernel mapping it can happen that pvgrub is failing as it is
35 +keeping some page tables mapped.
36 +
37 +Unmap the additional page tables created for the special p2m mapping
38 +will avoid this failure.
39 +
40 +Reported-by: Sven Koehler <sven.koehler@×××××.com>
41 +Signed-off-by: Juergen Gross <jgross@××××.com>
42 +Acked-by: Wei Liu <wei.liu2@××××××.com>
43 +---
44 + stubdom/grub/kexec.c | 2 ++
45 + 1 file changed, 2 insertions(+)
46 +
47 +diff --git a/stubdom/grub/kexec.c b/stubdom/grub/kexec.c
48 +index 8fd9ff9..71c2f3f 100644
49 +--- a/stubdom/grub/kexec.c
50 ++++ b/stubdom/grub/kexec.c
51 +@@ -347,6 +347,8 @@ void kexec(void *kernel, long kernel_size, void *module, long module_size, char
52 + /* Unmap libxc's projection of the boot page table */
53 + seg = xc_dom_seg_to_ptr(dom, &dom->pgtables_seg);
54 + munmap(seg, dom->pgtables_seg.vend - dom->pgtables_seg.vstart);
55 ++ seg = xc_dom_seg_to_ptr(dom, &dom->p2m_seg);
56 ++ munmap(seg, dom->p2m_seg.vend - dom->p2m_seg.vstart);
57 +
58 + /* Unmap day0 pages to avoid having a r/w mapping of the future page table */
59 + for (pfn = 0; pfn < allocated; pfn++)
60 +--
61 +2.10.0
62 +
63
64 diff --git a/app-emulation/xen-pvgrub/xen-pvgrub-4.7.0-r1.ebuild b/app-emulation/xen-pvgrub/xen-pvgrub-4.7.0-r1.ebuild
65 new file mode 100644
66 index 00000000..0f9ab30
67 --- /dev/null
68 +++ b/app-emulation/xen-pvgrub/xen-pvgrub-4.7.0-r1.ebuild
69 @@ -0,0 +1,164 @@
70 +# Copyright 1999-2016 Gentoo Foundation
71 +# Distributed under the terms of the GNU General Public License v2
72 +# $Id$
73 +
74 +EAPI=5
75 +
76 +PYTHON_COMPAT=( python2_7 )
77 +PYTHON_REQ_USE='xml,threads'
78 +
79 +inherit flag-o-matic eutils multilib python-single-r1 toolchain-funcs
80 +
81 +XEN_EXTFILES_URL="http://xenbits.xensource.com/xen-extfiles"
82 +LIBPCI_URL=ftp://atrey.karlin.mff.cuni.cz/pub/linux/pci
83 +GRUB_URL=mirror://gnu-alpha/grub
84 +
85 +UPSTREAM_VER=
86 +[[ -n ${UPSTREAM_VER} ]] && \
87 + UPSTREAM_PATCHSET_URI="https://dev.gentoo.org/~dlan/distfiles/${P/-tools/}-upstream-patches-${UPSTREAM_VER}.tar.xz"
88 +
89 +SRC_URI="
90 + http://bits.xensource.com/oss-xen/release/${PV}/xen-${PV}.tar.gz
91 + $GRUB_URL/grub-0.97.tar.gz
92 + $XEN_EXTFILES_URL/zlib-1.2.3.tar.gz
93 + $LIBPCI_URL/pciutils-2.2.9.tar.bz2
94 + $XEN_EXTFILES_URL/lwip-1.3.0.tar.gz
95 + $XEN_EXTFILES_URL/newlib/newlib-1.16.0.tar.gz
96 + $XEN_EXTFILES_URL/polarssl-1.1.4-gpl.tgz
97 + ${UPSTREAM_PATCHSET_URI}"
98 +
99 +S="${WORKDIR}/xen-${PV}"
100 +
101 +DESCRIPTION="allows to boot Xen domU kernels from a menu.lst laying inside guest filesystem"
102 +HOMEPAGE="http://xen.org/"
103 +LICENSE="GPL-2"
104 +SLOT="0"
105 +KEYWORDS="~amd64 ~x86"
106 +IUSE="custom-cflags"
107 +
108 +REQUIRED_USE="${PYTHON_REQUIRED_USE}"
109 +
110 +DEPEND="sys-devel/gettext
111 + sys-devel/bin86
112 + sys-apps/texinfo
113 + x11-libs/pixman"
114 +
115 +RDEPEND=">=app-emulation/xen-tools-${PV}"
116 +
117 +pkg_setup() {
118 + python-single-r1_pkg_setup
119 +}
120 +
121 +retar-externals() {
122 + # Purely to unclutter src_prepare
123 + local set="grub-0.97.tar.gz lwip-1.3.0.tar.gz newlib-1.16.0.tar.gz polarssl-1.1.4-gpl.tgz zlib-1.2.3.tar.gz"
124 +
125 + # epatch can't patch in $WORKDIR, requires a sed; Bug #455194. Patchable, but sed informative
126 + sed -e s':AR=${AR-"ar rc"}:AR=${AR-"ar"}:' \
127 + -i "${WORKDIR}"/zlib-1.2.3/configure
128 + sed -e 's:^AR=ar rc:AR=ar:' \
129 + -e s':$(AR) $@:$(AR) rc $@:' \
130 + -i "${WORKDIR}"/zlib-1.2.3/{Makefile,Makefile.in}
131 + einfo "zlib Makefile edited"
132 +
133 + cd "${WORKDIR}"
134 + tar czp zlib-1.2.3 -f zlib-1.2.3.tar.gz
135 + tar czp grub-0.97 -f grub-0.97.tar.gz
136 + tar czp lwip -f lwip-1.3.0.tar.gz
137 + tar czp newlib-1.16.0 -f newlib-1.16.0.tar.gz
138 + tar czp polarssl-1.1.4 -f polarssl-1.1.4-gpl.tgz
139 + mv $set "${S}"/stubdom/
140 + einfo "tarballs moved to source"
141 +}
142 +
143 +src_prepare() {
144 + # Upstream's patchset
145 + if [[ -n ${UPSTREAM_VER} ]]; then
146 + einfo "Try to apply Xen Upstream patch set"
147 + EPATCH_SUFFIX="patch" \
148 + EPATCH_FORCE="yes" \
149 + EPATCH_OPTS="-p1" \
150 + epatch "${WORKDIR}"/patches-upstream
151 + fi
152 +
153 + # if the user *really* wants to use their own custom-cflags, let them
154 + if use custom-cflags; then
155 + einfo "User wants their own CFLAGS - removing defaults"
156 + # try and remove all the default custom-cflags
157 + find "${S}" -name Makefile -o -name Rules.mk -o -name Config.mk -exec sed \
158 + -e 's/CFLAGS\(.*\)=\(.*\)-O3\(.*\)/CFLAGS\1=\2\3/' \
159 + -e 's/CFLAGS\(.*\)=\(.*\)-march=i686\(.*\)/CFLAGS\1=\2\3/' \
160 + -e 's/CFLAGS\(.*\)=\(.*\)-fomit-frame-pointer\(.*\)/CFLAGS\1=\2\3/' \
161 + -e 's/CFLAGS\(.*\)=\(.*\)-g3*\s\(.*\)/CFLAGS\1=\2 \3/' \
162 + -e 's/CFLAGS\(.*\)=\(.*\)-O2\(.*\)/CFLAGS\1=\2\3/' \
163 + -i {} \;
164 + fi
165 +
166 + # Patch the unmergeable newlib, fix most of the leftover gcc QA issues
167 + cp "${FILESDIR}"/newlib-implicits.patch stubdom || die
168 +
169 + # Patch stubdom/Makefile to patch insource newlib & prevent internal downloading
170 + epatch "${FILESDIR}"/${PN/-pvgrub/}-4.3-externals.patch
171 +
172 + # fix jobserver in Makefile
173 + epatch "${FILESDIR}"/${PN}-4.2-jserver.patch
174 +
175 + # bug 595354
176 + epatch "${FILESDIR}"/${P}-fix-boot-p2m.patch
177 +
178 + #Substitute for internal downloading. pciutils copied only due to the only .bz2
179 + cp "${DISTDIR}"/pciutils-2.2.9.tar.bz2 ./stubdom/ || die "pciutils not copied to stubdom"
180 + retar-externals || die "re-tar procedure failed"
181 +
182 + epatch_user
183 +}
184 +
185 +src_configure() {
186 + local myconf="--prefix=${PREFIX}/usr \
187 + --libdir=${PREFIX}/usr/$(get_libdir) \
188 + --libexecdir=${PREFIX}/usr/libexec \
189 + --disable-werror \
190 + --disable-xen"
191 +
192 + econf ${myconf}
193 +}
194 +
195 +src_compile() {
196 + use custom-cflags || unset CFLAGS
197 + if test-flag-CC -fno-strict-overflow; then
198 + append-flags -fno-strict-overflow
199 + fi
200 +
201 + emake CC="$(tc-getCC)" LD="$(tc-getLD)" AR="$(tc-getAR)" -C tools/include
202 +
203 + if use x86; then
204 + emake CC="$(tc-getCC)" LD="$(tc-getLD)" AR="$(tc-getAR)" \
205 + XEN_TARGET_ARCH="x86_32" -C stubdom pv-grub
206 + elif use amd64; then
207 + emake CC="$(tc-getCC)" LD="$(tc-getLD)" AR="$(tc-getAR)" \
208 + XEN_TARGET_ARCH="x86_64" -C stubdom pv-grub
209 + if has_multilib_profile; then
210 + multilib_toolchain_setup x86
211 + emake CC="$(tc-getCC)" AR="$(tc-getAR)" \
212 + XEN_TARGET_ARCH="x86_32" -C stubdom pv-grub
213 + fi
214 + fi
215 +}
216 +
217 +src_install() {
218 + if use x86; then
219 + emake XEN_TARGET_ARCH="x86_32" DESTDIR="${D}" -C stubdom install-grub
220 + fi
221 + if use amd64; then
222 + emake XEN_TARGET_ARCH="x86_64" DESTDIR="${D}" -C stubdom install-grub
223 + if has_multilib_profile; then
224 + emake XEN_TARGET_ARCH="x86_32" DESTDIR="${D}" -C stubdom install-grub
225 + fi
226 + fi
227 +}
228 +
229 +pkg_postinst() {
230 + elog "Official Xen Guide and the offical wiki page:"
231 + elog "https://wiki.gentoo.org/wiki/Xen"
232 + elog "http://wiki.xen.org/wiki/Main_Page"
233 +}