From patchwork Thu Dec 21 14:55:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 122575 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp997057qgn; Thu, 21 Dec 2017 06:58:22 -0800 (PST) X-Google-Smtp-Source: ACJfBos7SYeX27NHb6BcPSMWQAMuv6o1inHlEH8nGjdMA2Z/ZmyfCIphjuGwUUaxuhtk7PBel4FI X-Received: by 10.107.184.3 with SMTP id i3mr11907831iof.266.1513868302531; Thu, 21 Dec 2017 06:58:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513868302; cv=none; d=google.com; s=arc-20160816; b=Mui1lIO/N6y1MFga/6Ko+jFs5D+i0SrWNxDGNX+HZkPUAx1bPSFXVgqHGUNIauflPl PWZ8/xAQyMrCrP+c0LQk0kabCbnhKgBNzxvhiBuGqEPDNyDif5d6pAyoWPt7y2TmCBR0 k3r4XnB/arJCT9IrchqvS7utf7OAiDjUqeLbgSBCpj3eWY24kbdLtT+Z9Y2NnoJvYnLL 0ra5spIQkORpat5PJpKvrjxz1kI0tM/TNEEVzLa46PPeUZmNcx9fxa3Wyl2TJea3/wlU cK+9r0xwdTaYTefYwNvK8aHBwbL4ZV2fSOYpBebf28khN8TLupM6cac8IiXeici9S+Kv XJBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:message-id:date:to:from:dkim-signature :arc-authentication-results; bh=HvAzFzJtobZJIy+Wvg/5OIeL8pKcRvqodGtJ2BSk384=; b=cimKWt67PMWmRraeRH59klzSfjffT3khgdcJuDPNaU9Da2kBy9xJJVJV4rFYSwL1j7 X+qRx8fEKnYkrjeH0wz+vGDGkS/+UNS7JOE+E11TZ8RJ9i+Nm+3Y5lCm0j0FDqBl3Gub +T+BMTCXuICtp9ek+SVXBDtMZRCM9vXF6DmWjzlEuchqkdLQogdzmcev6aKtYqr7JH06 BbrRADGx8Buof3h/cWj8ujagc/6MeStvvI6ZQShIHd3t62kmTWrNxQ1p0Ibgm1667xvk +BRw7CyLRTtFTUPp/egVeJGChLiGPgLme+adXMmaKsn6smuxBNHDsWp+veeMpg3+wCjK vY3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=RmIrlb84; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id x22si5570274ioe.46.2017.12.21.06.58.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Dec 2017 06:58:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=RmIrlb84; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eS2Fv-0002PL-MT; Thu, 21 Dec 2017 14:55:31 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eS2Fv-0002PE-0A for xen-devel@lists.xen.org; Thu, 21 Dec 2017 14:55:31 +0000 X-Inumbo-ID: df6c4528-e65e-11e7-b4a6-bc764e045a96 Received: from mail-wr0-x244.google.com (unknown [2a00:1450:400c:c0c::244]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id df6c4528-e65e-11e7-b4a6-bc764e045a96; Thu, 21 Dec 2017 15:54:41 +0100 (CET) Received: by mail-wr0-x244.google.com with SMTP id v21so14684711wrc.0 for ; Thu, 21 Dec 2017 06:55:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=WZkcA4Nonz1rzZN9Hgu9an9TrgOqA9GGXMq0VgHo1cY=; b=RmIrlb84lc3Kkl5sH8HxhXPKHrW6Y6DOGWahtYBVWsJdVaVVlzUan/rijN/Nqh6ZIG wbtGVvxJbQ8SHVL5/qSyQRDrQbHcoT9NNUWBK2pgoc2ECdMKLQBuJziXv6G6mPwBJ4my CWR7ov764qHGVjIbntFwScNIWniW4XjjmvJWg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=WZkcA4Nonz1rzZN9Hgu9an9TrgOqA9GGXMq0VgHo1cY=; b=Ui3joVCv49nKOxGQLoR1Ei3F9KDQChVsC+upiZMrZyex/zIMIB0tW/SFi8iXxd2AFl dz+UJiQcygckMpvFhs4nSCOFh4IAWodE/duRNXIosmNTHpRbykToip/jReAZjw9PtHqp x+i1z9wOFZm7W/IWTm9Jt0EzZfnIbzO0YMigOU1zT2fxQs0lV0MR5KOigGEUDytYoCcd RX/cF+uFPhEh/5SB2wsYyDuUGroyxzl1Tne2wPiwHNsJdPEe6Tjb9jEydtTv3BnXkrq2 neJ1WNmSjBqP+UTODfk7LiS5jS8cZ9+1cdfv3tIHY4mUVkXcIiIl/5SwcCgR0ozp54JB fq/A== X-Gm-Message-State: AKGB3mL1dQoiSowCuPDXhDmlvfwoQqqcvbbudQbqoLdiBvZWbtI3Y11T osEULvvmzE1UIm4uQIZcKyheLJhIGrc= X-Received: by 10.223.184.171 with SMTP id i40mr12317080wrf.124.1513868126520; Thu, 21 Dec 2017 06:55:26 -0800 (PST) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id 137sm12657433wmp.34.2017.12.21.06.55.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Dec 2017 06:55:25 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 21 Dec 2017 14:55:21 +0000 Message-Id: <20171221145521.29526-1-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 Cc: sstabellini@kernel.org, wei.liu2@citrix.com, George.Dunlap@eu.citrix.com, andrew.cooper3@citrix.com, Julien Grall , ian.jackson@eu.citrix.com, andre.przywara@linaro.org, tim@xen.org, jbeulich@suse.com Subject: [Xen-devel] [PATCH] xen/efi: Avoid EFI stub using absolute symbols X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The EFI image should be relocatable. At the moment, all the stub is relocatable but one place. On both Arm64 and x86-64 (from a quick glance) , the compiler will generate absolute pointer in the ErrCodeToStr array. Those values are based on Xen view of the virtual memory and may not be the same as EFI. For instance, at least on Arm64, EFI will do a 1:1 mappings of the Stub. Arguably this is either a compiler bug or a problem with the flags passed. I narrow down the problem to the following snippet: const char * const ErrCodeToStr[] = { "Not found", "The device has no media", }; const char * foo(unsigned int i) { return ErrCodeToStr[i]; } To prevent the compiler using absolute pointer, specify the maximum size of the string. Signed-off-by: Julien Grall --- I am not entirely convinced this is the right way. But I though I would start a conversation to get feedback. --- xen/common/efi/boot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index 469bf980cc..87d46f2a56 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -342,7 +342,7 @@ static void __init noreturn blexit(const CHAR16 *str) /* generic routine for printing error messages */ static void __init PrintErrMesg(const CHAR16 *mesg, EFI_STATUS ErrCode) { - static const CHAR16* const ErrCodeToStr[] __initconstrel = { + static const CHAR16 ErrCodeToStr[][25] __initconst = { [~EFI_ERROR_MASK & EFI_NOT_FOUND] = L"Not found", [~EFI_ERROR_MASK & EFI_NO_MEDIA] = L"The device has no media", [~EFI_ERROR_MASK & EFI_MEDIA_CHANGED] = L"Media changed",