From: Julien Grall <julien.grall@linaro.org>
To: xen-devel@lists.xen.org
Cc: sstabellini@kernel.org, wei.liu2@citrix.com,
George.Dunlap@eu.citrix.com, andrew.cooper3@citrix.com,
Julien Grall <julien.grall@linaro.org>,
ian.jackson@eu.citrix.com, andre.przywara@linaro.org,
tim@xen.org, jbeulich@suse.com
Subject: [PATCH] xen/efi: Avoid EFI stub using absolute symbols
Date: Thu, 21 Dec 2017 14:55:21 +0000 [thread overview]
Message-ID: <20171221145521.29526-1-julien.grall@linaro.org> (raw)
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 <julien.grall@linaro.org>
---
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",
--
2.11.0
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next reply other threads:[~2017-12-21 14:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-21 14:55 Julien Grall [this message]
2018-01-02 16:35 ` [PATCH] xen/efi: Avoid EFI stub using absolute symbols Jan Beulich
2018-01-09 19:43 ` Julien Grall
2018-01-12 13:13 ` Jan Beulich
2018-01-16 17:43 ` Julien Grall
2018-01-17 8:30 ` Jan Beulich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171221145521.29526-1-julien.grall@linaro.org \
--to=julien.grall@linaro.org \
--cc=George.Dunlap@eu.citrix.com \
--cc=andre.przywara@linaro.org \
--cc=andrew.cooper3@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=jbeulich@suse.com \
--cc=sstabellini@kernel.org \
--cc=tim@xen.org \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).