summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Clark <christopher.w.clark@gmail.com>2018-08-18 18:37:13 -0700
committerBruce Ashfield <bruce.ashfield@windriver.com>2018-08-20 11:35:53 -0400
commitd8173ad1c0dde5add365e8d79596747123809a58 (patch)
treed9cebeb4cd0470d35e9b09cee6b8c914958f3c67
parent2c8e62d5b446d9bb167df317bc47111fdee0df33 (diff)
downloadmeta-virtualization-d8173ad1c0dde5add365e8d79596747123809a58.tar.gz
xen: fix build on aarch64 w/ gcc 8.2
Adds patch for compatibility with gcc 8.2, to fix string lengths for copied values to prevent array-bounds warnings. Signed-off-by: Christopher Clark <christopher.clark6@baesystems.com> Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
-rw-r--r--recipes-extended/xen/files/xen-4.11-arm-acpi-fix-string-lengths.patch101
-rw-r--r--recipes-extended/xen/xen_4.11.0.bb1
2 files changed, 102 insertions, 0 deletions
diff --git a/recipes-extended/xen/files/xen-4.11-arm-acpi-fix-string-lengths.patch b/recipes-extended/xen/files/xen-4.11-arm-acpi-fix-string-lengths.patch
new file mode 100644
index 00000000..ece64071
--- /dev/null
+++ b/recipes-extended/xen/files/xen-4.11-arm-acpi-fix-string-lengths.patch
@@ -0,0 +1,101 @@
1From 5e1a00969afe98a713bf14d1ba1902403b60e287 Mon Sep 17 00:00:00 2001
2From: Christopher Clark <christopher.w.clark@gmail.com>
3Date: Thu, 16 Aug 2018 13:04:52 -0700
4Subject: [PATCH v2] libxl/arm: Fix build on arm64 + acpi w/ gcc 8.2
5To: xen-devel@lists.xenproject.org
6Cc: wei.liu2@citrix.com,
7 ian.jackson@eu.citrix.com,
8 julien.grall@arm.com,
9 sstabellini@kernel.org
10
11[modified for Xen 4.11 to add required: #include <xen-tools/libs.h>]
12
13Add zero-padding to #defined ACPI table strings that are copied.
14Provides sufficient characters to satisfy the length required to
15fully populate the destination and prevent array-bounds warnings.
16Add BUILD_BUG_ON sizeof checks for compile-time length checking.
17
18Signed-off-by: Christopher Clark <christopher.clark6@baesystems.com>
19Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
20Acked-by: Wei Liu <wei.liu2@citrix.com>
21---
22v2: add BUILD_BUG_ON length checks, requested by Wei.
23
24v1: Please add this patch to the backport list for the next minor
25 4.11 release.
26
27Prior to this: gcc 8.2 objects to memcpy past bounds:
28
29| libxl_arm_acpi.c: In function 'make_acpi_header':
30| libxl_arm_acpi.c:208:5: error: 'memcpy' forming offset [5, 6] is out
31of the bounds [0, 4] [-Werror=array-bounds]
32| memcpy(h->oem_id, ACPI_OEM_ID, sizeof(h->oem_id));
33| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
34| libxl_arm_acpi.c:209:5: error: 'memcpy' forming offset [5, 8] is out
35of the bounds [0, 4] [-Werror=array-bounds]
36| memcpy(h->oem_table_id, ACPI_OEM_TABLE_ID,
37sizeof(h->oem_table_id));
38|
39^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
40| libxl_arm_acpi.c:211:5: error: 'memcpy' forming offset 4 is out of the
41bounds [0, 3] [-Werror=array-bounds]
42| memcpy(h->asl_compiler_id, ACPI_ASL_COMPILER_ID,
43| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
44| sizeof(h->asl_compiler_id));
45| ~~~~~~~~~~~~~~~~~~~~~~~~~~~
46| In function 'make_acpi_rsdp.isra.4',
47| inlined from 'libxl__prepare_acpi' at libxl_arm_acpi.c:389:5:
48| libxl_arm_acpi.c:193:5: error: 'memcpy' forming offset [5, 6] is out
49of the bounds [0, 4] [-Werror=array-bounds]
50| memcpy(rsdp->oem_id, ACPI_OEM_ID, sizeof(rsdp->oem_id));
51| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
52
53 tools/libxl/libxl_arm_acpi.c | 10 +++++++---
54 1 file changed, 7 insertions(+), 3 deletions(-)
55
56diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c
57index 636f724..8924396 100644
58--- a/tools/libxl/libxl_arm_acpi.c
59+++ b/tools/libxl/libxl_arm_acpi.c
60@@ -29,6 +29,7 @@ typedef int64_t s64;
61
62 #include <acpi/acconfig.h>
63 #include <acpi/actbl.h>
64+#include <xen-tools/libs.h>
65
66 #ifndef BITS_PER_LONG
67 #ifdef _LP64
68@@ -48,9 +49,9 @@ extern const unsigned char dsdt_anycpu_arm[];
69 _hidden
70 extern const int dsdt_anycpu_arm_len;
71
72-#define ACPI_OEM_ID "Xen"
73-#define ACPI_OEM_TABLE_ID "ARM"
74-#define ACPI_ASL_COMPILER_ID "XL"
75+#define ACPI_OEM_ID "Xen\0\0"
76+#define ACPI_OEM_TABLE_ID "ARM\0\0\0\0"
77+#define ACPI_ASL_COMPILER_ID "XL\0"
78
79 enum {
80 RSDP,
81@@ -190,6 +191,7 @@ static void make_acpi_rsdp(libxl__gc *gc, struct xc_dom_image *dom,
82 struct acpi_table_rsdp *rsdp = (void *)dom->acpi_modules[0].data + offset;
83
84 memcpy(rsdp->signature, "RSD PTR ", sizeof(rsdp->signature));
85+ BUILD_BUG_ON(sizeof(ACPI_OEM_ID) != sizeof(rsdp->oem_id));
86 memcpy(rsdp->oem_id, ACPI_OEM_ID, sizeof(rsdp->oem_id));
87 rsdp->length = acpitables[RSDP].size;
88 rsdp->revision = 0x02;
89@@ -205,9 +207,12 @@ static void make_acpi_header(struct acpi_table_header *h, const char *sig,
90 memcpy(h->signature, sig, 4);
91 h->length = len;
92 h->revision = rev;
93+ BUILD_BUG_ON(sizeof(ACPI_OEM_ID) != sizeof(h->oem_id));
94 memcpy(h->oem_id, ACPI_OEM_ID, sizeof(h->oem_id));
95+ BUILD_BUG_ON(sizeof(ACPI_OEM_TABLE_ID) != sizeof(h->oem_table_id));
96 memcpy(h->oem_table_id, ACPI_OEM_TABLE_ID, sizeof(h->oem_table_id));
97 h->oem_revision = 0;
98+ BUILD_BUG_ON(sizeof(ACPI_ASL_COMPILER_ID) != sizeof(h->asl_compiler_id));
99 memcpy(h->asl_compiler_id, ACPI_ASL_COMPILER_ID,
100 sizeof(h->asl_compiler_id));
101 h->asl_compiler_revision = 0;
diff --git a/recipes-extended/xen/xen_4.11.0.bb b/recipes-extended/xen/xen_4.11.0.bb
index 78841942..d7cff324 100644
--- a/recipes-extended/xen/xen_4.11.0.bb
+++ b/recipes-extended/xen/xen_4.11.0.bb
@@ -4,6 +4,7 @@ require xen.inc
4SRC_URI = " \ 4SRC_URI = " \
5 https://downloads.xenproject.org/release/xen/${PV}/xen-${PV}.tar.gz \ 5 https://downloads.xenproject.org/release/xen/${PV}/xen-${PV}.tar.gz \
6 file://tools-xentop-vwprintw.patch \ 6 file://tools-xentop-vwprintw.patch \
7 file://xen-4.11-arm-acpi-fix-string-lengths.patch \
7 " 8 "
8 9
9SRC_URI[md5sum] = "cbec0600284921744bc14119f4ed3fff" 10SRC_URI[md5sum] = "cbec0600284921744bc14119f4ed3fff"