diff options
| -rw-r--r-- | recipes-extended/xen/files/xen-4.11-arm-acpi-fix-string-lengths.patch | 101 | ||||
| -rw-r--r-- | recipes-extended/xen/xen_4.11.0.bb | 1 |
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 @@ | |||
| 1 | From 5e1a00969afe98a713bf14d1ba1902403b60e287 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Christopher Clark <christopher.w.clark@gmail.com> | ||
| 3 | Date: Thu, 16 Aug 2018 13:04:52 -0700 | ||
| 4 | Subject: [PATCH v2] libxl/arm: Fix build on arm64 + acpi w/ gcc 8.2 | ||
| 5 | To: xen-devel@lists.xenproject.org | ||
| 6 | Cc: 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 | |||
| 13 | Add zero-padding to #defined ACPI table strings that are copied. | ||
| 14 | Provides sufficient characters to satisfy the length required to | ||
| 15 | fully populate the destination and prevent array-bounds warnings. | ||
| 16 | Add BUILD_BUG_ON sizeof checks for compile-time length checking. | ||
| 17 | |||
| 18 | Signed-off-by: Christopher Clark <christopher.clark6@baesystems.com> | ||
| 19 | Reviewed-by: Stefano Stabellini <sstabellini@kernel.org> | ||
| 20 | Acked-by: Wei Liu <wei.liu2@citrix.com> | ||
| 21 | --- | ||
| 22 | v2: add BUILD_BUG_ON length checks, requested by Wei. | ||
| 23 | |||
| 24 | v1: Please add this patch to the backport list for the next minor | ||
| 25 | 4.11 release. | ||
| 26 | |||
| 27 | Prior 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 | ||
| 31 | of 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 | ||
| 35 | of the bounds [0, 4] [-Werror=array-bounds] | ||
| 36 | | memcpy(h->oem_table_id, ACPI_OEM_TABLE_ID, | ||
| 37 | sizeof(h->oem_table_id)); | ||
| 38 | | | ||
| 39 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 40 | | libxl_arm_acpi.c:211:5: error: 'memcpy' forming offset 4 is out of the | ||
| 41 | bounds [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 | ||
| 49 | of 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 | |||
| 56 | diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c | ||
| 57 | index 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 | |||
| 4 | SRC_URI = " \ | 4 | SRC_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 | ||
| 9 | SRC_URI[md5sum] = "cbec0600284921744bc14119f4ed3fff" | 10 | SRC_URI[md5sum] = "cbec0600284921744bc14119f4ed3fff" |
