diff options
3 files changed, 263 insertions, 0 deletions
diff --git a/recipes-extended/xen/files/0001-firmware-provide-a-stand-alone-set-of-headers-Xen-4.14.patch b/recipes-extended/xen/files/0001-firmware-provide-a-stand-alone-set-of-headers-Xen-4.14.patch new file mode 100644 index 00000000..7b062b7b --- /dev/null +++ b/recipes-extended/xen/files/0001-firmware-provide-a-stand-alone-set-of-headers-Xen-4.14.patch | |||
@@ -0,0 +1,178 @@ | |||
1 | From 73b13705af7c3bb8fdf11932eb68788d090a443f Mon Sep 17 00:00:00 2001 | ||
2 | From: =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= <roger.pau@citrix.com> | ||
3 | Date: Thu, 4 Mar 2021 16:49:00 +0100 | ||
4 | Subject: [PATCH] firmware: provide a stand alone set of headers | ||
5 | MIME-Version: 1.0 | ||
6 | Content-Type: text/plain; charset=UTF-8 | ||
7 | Content-Transfer-Encoding: 8bit | ||
8 | |||
9 | The current build of the firmware relies on having 32bit compatible | ||
10 | headers installed in order to build some of the 32bit firmware. | ||
11 | Usually this can be solved by using the -ffreestanding compiler option | ||
12 | which drops the usage of the system headers in favor of a private set | ||
13 | of freestanding headers provided by the compiler itself that are not | ||
14 | tied to libc. | ||
15 | |||
16 | However such option is broken at least in the gcc compiler provided in | ||
17 | Alpine Linux, as the system include path (ie: /usr/include) takes | ||
18 | precedence over the gcc private include path: | ||
19 | |||
20 | #include <...> search starts here: | ||
21 | /usr/include | ||
22 | /usr/lib/gcc/x86_64-alpine-linux-musl/10.2.1/include | ||
23 | |||
24 | And the headers in /usr/include are exclusively 64bit. | ||
25 | |||
26 | Since -ffreestanding is currently broken on at least that distro, and | ||
27 | for resilience against future compilers also having the option broken | ||
28 | provide a set of stand alone 32bit headers required for the firmware | ||
29 | build. | ||
30 | |||
31 | Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> | ||
32 | Reviewed-by: Jan Beulich <jbeulich@suse.com> | ||
33 | Release-Acked-by: Ian Jackson <iwj@xenproject.org> | ||
34 | Applied to Xen 4.14 by: Christopher Clark <christopher.w.clark@gmail.com> | ||
35 | --- | ||
36 | tools/firmware/Rules.mk | 13 +++++++ | ||
37 | tools/firmware/include/stdarg.h | 10 +++++ | ||
38 | tools/firmware/include/stdbool.h | 9 +++++ | ||
39 | tools/firmware/include/stddef.h | 10 +++++ | ||
40 | tools/firmware/include/stdint.h | 39 +++++++++++++++++++ | ||
41 | tools/firmware/rombios/32bit/rombios_compat.h | 4 +- | ||
42 | 6 files changed, 82 insertions(+), 3 deletions(-) | ||
43 | create mode 100644 tools/firmware/include/stdarg.h | ||
44 | create mode 100644 tools/firmware/include/stdbool.h | ||
45 | create mode 100644 tools/firmware/include/stddef.h | ||
46 | create mode 100644 tools/firmware/include/stdint.h | ||
47 | |||
48 | diff --git a/tools/firmware/include/stdarg.h b/tools/firmware/include/stdarg.h | ||
49 | new file mode 100644 | ||
50 | index 0000000000..c5e3761cd2 | ||
51 | --- /dev/null | ||
52 | +++ b/tools/firmware/include/stdarg.h | ||
53 | @@ -0,0 +1,10 @@ | ||
54 | +#ifndef _STDARG_H_ | ||
55 | +#define _STDARG_H_ | ||
56 | + | ||
57 | +typedef __builtin_va_list va_list; | ||
58 | +#define va_copy(dest, src) __builtin_va_copy(dest, src) | ||
59 | +#define va_start(ap, last) __builtin_va_start(ap, last) | ||
60 | +#define va_end(ap) __builtin_va_end(ap) | ||
61 | +#define va_arg __builtin_va_arg | ||
62 | + | ||
63 | +#endif | ||
64 | diff --git a/tools/firmware/include/stdbool.h b/tools/firmware/include/stdbool.h | ||
65 | new file mode 100644 | ||
66 | index 0000000000..0cf76b106c | ||
67 | --- /dev/null | ||
68 | +++ b/tools/firmware/include/stdbool.h | ||
69 | @@ -0,0 +1,9 @@ | ||
70 | +#ifndef _STDBOOL_H_ | ||
71 | +#define _STDBOOL_H_ | ||
72 | + | ||
73 | +#define bool _Bool | ||
74 | +#define true 1 | ||
75 | +#define false 0 | ||
76 | +#define __bool_true_false_are_defined 1 | ||
77 | + | ||
78 | +#endif | ||
79 | diff --git a/tools/firmware/include/stddef.h b/tools/firmware/include/stddef.h | ||
80 | new file mode 100644 | ||
81 | index 0000000000..c7f974608a | ||
82 | --- /dev/null | ||
83 | +++ b/tools/firmware/include/stddef.h | ||
84 | @@ -0,0 +1,10 @@ | ||
85 | +#ifndef _STDDEF_H_ | ||
86 | +#define _STDDEF_H_ | ||
87 | + | ||
88 | +typedef __SIZE_TYPE__ size_t; | ||
89 | + | ||
90 | +#define NULL ((void*)0) | ||
91 | + | ||
92 | +#define offsetof(t, m) __builtin_offsetof(t, m) | ||
93 | + | ||
94 | +#endif | ||
95 | diff --git a/tools/firmware/include/stdint.h b/tools/firmware/include/stdint.h | ||
96 | new file mode 100644 | ||
97 | index 0000000000..16a0b6de19 | ||
98 | --- /dev/null | ||
99 | +++ b/tools/firmware/include/stdint.h | ||
100 | @@ -0,0 +1,39 @@ | ||
101 | +#ifndef _STDINT_H_ | ||
102 | +#define _STDINT_H_ | ||
103 | + | ||
104 | +#if defined(__LP64__) || defined(__P64__) | ||
105 | +#error "32bit only header" | ||
106 | +#endif | ||
107 | + | ||
108 | +typedef unsigned char uint8_t; | ||
109 | +typedef signed char int8_t; | ||
110 | + | ||
111 | +typedef unsigned short uint16_t; | ||
112 | +typedef signed short int16_t; | ||
113 | + | ||
114 | +typedef unsigned int uint32_t; | ||
115 | +typedef signed int int32_t; | ||
116 | + | ||
117 | +typedef unsigned long long uint64_t; | ||
118 | +typedef signed long long int64_t; | ||
119 | + | ||
120 | +#define INT8_MIN (-0x7f-1) | ||
121 | +#define INT16_MIN (-0x7fff-1) | ||
122 | +#define INT32_MIN (-0x7fffffff-1) | ||
123 | +#define INT64_MIN (-0x7fffffffffffffffll-1) | ||
124 | + | ||
125 | +#define INT8_MAX 0x7f | ||
126 | +#define INT16_MAX 0x7fff | ||
127 | +#define INT32_MAX 0x7fffffff | ||
128 | +#define INT64_MAX 0x7fffffffffffffffll | ||
129 | + | ||
130 | +#define UINT8_MAX 0xff | ||
131 | +#define UINT16_MAX 0xffff | ||
132 | +#define UINT32_MAX 0xffffffffu | ||
133 | +#define UINT64_MAX 0xffffffffffffffffull | ||
134 | + | ||
135 | +typedef uint32_t uintptr_t; | ||
136 | + | ||
137 | +#define UINTPTR_MAX UINT32_MAX | ||
138 | + | ||
139 | +#endif | ||
140 | diff --git a/tools/firmware/rombios/32bit/rombios_compat.h b/tools/firmware/rombios/32bit/rombios_compat.h | ||
141 | index 3fe7d67721..8ba4c17ffd 100644 | ||
142 | --- a/tools/firmware/rombios/32bit/rombios_compat.h | ||
143 | +++ b/tools/firmware/rombios/32bit/rombios_compat.h | ||
144 | @@ -8,9 +8,7 @@ | ||
145 | |||
146 | #define ADDR_FROM_SEG_OFF(seg, off) (void *)((((uint32_t)(seg)) << 4) + (off)) | ||
147 | |||
148 | -typedef unsigned char uint8_t; | ||
149 | -typedef unsigned short int uint16_t; | ||
150 | -typedef unsigned int uint32_t; | ||
151 | +#include <stdint.h> | ||
152 | |||
153 | typedef uint8_t Bit8u; | ||
154 | typedef uint16_t Bit16u; | ||
155 | diff --git a/tools/firmware/Rules.mk b/tools/firmware/Rules.mk | ||
156 | index 26bbddccd4..cb388b7011 100644 | ||
157 | --- a/tools/firmware/Rules.mk | ||
158 | +++ b/tools/firmware/Rules.mk | ||
159 | @@ -17,3 +17,16 @@ $(call cc-options-add,CFLAGS,CC,$(EMBEDDED_EXTRA_CFLAGS)) | ||
160 | |||
161 | # Extra CFLAGS suitable for an embedded type of environment. | ||
162 | CFLAGS += -fno-builtin -msoft-float | ||
163 | + | ||
164 | +# Use our own set of stand alone headers to build firmware. | ||
165 | +# | ||
166 | +# Ideally using -ffreestanding should be enough, but that relies on the | ||
167 | +# compiler having the right order for include paths (ie: compiler private | ||
168 | +# headers before system ones) or the libc headers having proper arch-agnostic | ||
169 | +# freestanding support. This is not the case in Alpine at least which searches | ||
170 | +# system headers before compiler ones and has arch-specific libc headers. This | ||
171 | +# has been reported upstream: | ||
172 | +# https://gitlab.alpinelinux.org/alpine/aports/-/issues/12477 | ||
173 | +# In the meantime (and for resilience against broken systems) use our own set | ||
174 | +# of headers that provide what's needed for the firmware build. | ||
175 | +CFLAGS += -nostdinc -I$(XEN_ROOT)/tools/firmware/include | ||
176 | -- | ||
177 | 2.25.1 | ||
178 | |||
diff --git a/recipes-extended/xen/files/0001-tools-firmware-Build-firmware-as-ffreestanding-Xen-4.14.patch b/recipes-extended/xen/files/0001-tools-firmware-Build-firmware-as-ffreestanding-Xen-4.14.patch new file mode 100644 index 00000000..001b196d --- /dev/null +++ b/recipes-extended/xen/files/0001-tools-firmware-Build-firmware-as-ffreestanding-Xen-4.14.patch | |||
@@ -0,0 +1,83 @@ | |||
1 | From 0eae016b6e3dce69e3fb86aca5c4f221591a2f12 Mon Sep 17 00:00:00 2001 | ||
2 | From: Andrew Cooper <andrew.cooper3@citrix.com> | ||
3 | Date: Thu, 25 Feb 2021 19:15:08 +0000 | ||
4 | Subject: [PATCH] tools/firmware: Build firmware as -ffreestanding | ||
5 | |||
6 | firmware should always have been -ffreestanding, as it doesn't execute in the | ||
7 | host environment. -ffreestanding implies -fno-builtin, so replace the option. | ||
8 | |||
9 | inttypes.h isn't a freestanding header, but the 32bitbios_support.c only wants | ||
10 | the stdint.h types so switch to the more appropriate include. | ||
11 | |||
12 | This removes the build time dependency on a 32bit libc just to compile the | ||
13 | hvmloader and friends. | ||
14 | |||
15 | Update README and the TravisCI configuration. | ||
16 | |||
17 | Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> | ||
18 | Reviewed-by: Jan Beulich <jbeulich@suse.com> | ||
19 | Reviewed-by: Ian Jackson <iwj@xenproject.org> | ||
20 | Release-Acked-by: Ian Jackson <iwj@xenproject.org> | ||
21 | Applied to m-v Xen 4.14 series: Christopher Clark <christopher.w.clark@gmail.com> | ||
22 | --- | ||
23 | .travis.yml | 1 - | ||
24 | README | 3 --- | ||
25 | tools/firmware/Rules.mk | 2 +- | ||
26 | tools/firmware/hvmloader/32bitbios_support.c | 2 +- | ||
27 | 4 files changed, 2 insertions(+), 6 deletions(-) | ||
28 | |||
29 | diff --git a/.travis.yml b/.travis.yml | ||
30 | index 15ca9e9047..2362475f7a 100644 | ||
31 | --- a/.travis.yml | ||
32 | +++ b/.travis.yml | ||
33 | @@ -58,7 +58,6 @@ addons: | ||
34 | - acpica-tools | ||
35 | - bin86 | ||
36 | - bcc | ||
37 | - - libc6-dev-i386 | ||
38 | - libnl-3-dev | ||
39 | - ocaml-nox | ||
40 | - libfindlib-ocaml-dev | ||
41 | diff --git a/README b/README | ||
42 | index 6e15242ae1..8c99c30986 100644 | ||
43 | --- a/README | ||
44 | +++ b/README | ||
45 | @@ -62,9 +62,6 @@ provided by your OS distributor: | ||
46 | * GNU bison and GNU flex | ||
47 | * GNU gettext | ||
48 | * ACPI ASL compiler (iasl) | ||
49 | - * Libc multiarch package (e.g. libc6-dev-i386 / glibc-devel.i686). | ||
50 | - Required when building on a 64-bit platform to build | ||
51 | - 32-bit components which are enabled on a default build. | ||
52 | |||
53 | In addition to the above there are a number of optional build | ||
54 | prerequisites. Omitting these will cause the related features to be | ||
55 | diff --git a/tools/firmware/Rules.mk b/tools/firmware/Rules.mk | ||
56 | index cb388b7011..9f78a7dec9 100644 | ||
57 | --- a/tools/firmware/Rules.mk | ||
58 | +++ b/tools/firmware/Rules.mk | ||
59 | @@ -16,7 +16,7 @@ CFLAGS += -Werror | ||
60 | $(call cc-options-add,CFLAGS,CC,$(EMBEDDED_EXTRA_CFLAGS)) | ||
61 | |||
62 | # Extra CFLAGS suitable for an embedded type of environment. | ||
63 | -CFLAGS += -fno-builtin -msoft-float | ||
64 | +CFLAGS += -ffreestanding -msoft-float | ||
65 | |||
66 | # Use our own set of stand alone headers to build firmware. | ||
67 | # | ||
68 | diff --git a/tools/firmware/hvmloader/32bitbios_support.c b/tools/firmware/hvmloader/32bitbios_support.c | ||
69 | index 114135022e..ef681d4f57 100644 | ||
70 | --- a/tools/firmware/hvmloader/32bitbios_support.c | ||
71 | +++ b/tools/firmware/hvmloader/32bitbios_support.c | ||
72 | @@ -20,7 +20,7 @@ | ||
73 | * this program; If not, see <http://www.gnu.org/licenses/>. | ||
74 | */ | ||
75 | |||
76 | -#include <inttypes.h> | ||
77 | +#include <stdint.h> | ||
78 | #include <elf.h> | ||
79 | #ifdef __sun__ | ||
80 | #include <sys/machelf.h> | ||
81 | -- | ||
82 | 2.25.1 | ||
83 | |||
diff --git a/recipes-extended/xen/xen-tools_4.14.bb b/recipes-extended/xen/xen-tools_4.14.bb index a79b41d9..10982a2c 100644 --- a/recipes-extended/xen/xen-tools_4.14.bb +++ b/recipes-extended/xen/xen-tools_4.14.bb | |||
@@ -6,6 +6,8 @@ XEN_BRANCH ?= "stable-${XEN_REL}" | |||
6 | SRC_URI = " \ | 6 | SRC_URI = " \ |
7 | git://xenbits.xen.org/xen.git;branch=${XEN_BRANCH} \ | 7 | git://xenbits.xen.org/xen.git;branch=${XEN_BRANCH} \ |
8 | file://0001-python-pygrub-pass-DISTUTILS-xen-4.14.patch \ | 8 | file://0001-python-pygrub-pass-DISTUTILS-xen-4.14.patch \ |
9 | file://0001-firmware-provide-a-stand-alone-set-of-headers-Xen-4.14.patch \ | ||
10 | file://0001-tools-firmware-Build-firmware-as-ffreestanding-Xen-4.14.patch \ | ||
9 | " | 11 | " |
10 | 12 | ||
11 | LIC_FILES_CHKSUM ?= "file://COPYING;md5=419739e325a50f3d7b4501338e44a4e5" | 13 | LIC_FILES_CHKSUM ?= "file://COPYING;md5=419739e325a50f3d7b4501338e44a4e5" |