From: David Woodhouse <dwmw2@infradead.org>
To: Anatol Pomozov <anatol.pomozov@gmail.com>,
qemu-devel@nongnu.org,
Adam Lackorzynski <adam@os.inf.tu-dresden.de>
Cc: Goswin von Brederlow <goswin-v-b@web.de>
Subject: Re: [Qemu-devel] [PATCH] Remove restriction that prevents bootimg elf64 images
Date: Tue, 20 Dec 2022 23:45:20 +0000 [thread overview]
Message-ID: <b2fd6676446f5bb19f08ae26b8c4fbbd5ebd1c10.camel@infradead.org> (raw)
In-Reply-To: <CAOMFOmXQDUd0m0uFxVOWQP35dfkvurbj7YRuDT_=0Xubib0PBw@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3261 bytes --]
On Wed, 2017-06-21 at 13:45 -0700, Anatol Pomozov wrote:
> Hi Adam, thank you for your reply.
>
> On Mon, Jun 19, 2017 at 2:08 PM, Adam Lackorzynski
> <adam@os.inf.tu-dresden.de> wrote:
> > Hi,
> >
> > On Tue Jun 13, 2017 at 17:05:41 -0700, Anatol Pomozov wrote:
> > > Do these arguments sound reasonable to apply the patch?
> >
> > I'm not really convinced.
> >
> > > On Thu, Jun 8, 2017 at 2:07 PM, Anatol Pomozov <anatol.pomozov@gmail.com> wrote:
> > > > +reply-all
> > > >
> > > > On Thu, Jun 8, 2017 at 1:41 PM, Adam Lackorzynski
> > > > <adam@os.inf.tu-dresden.de> wrote:
> > > > >
> > > > > On Tue Jun 06, 2017 at 21:41:48 -0700, Anatol Pomozov wrote:
> > > > > > It is possible to create a 64 bit elf image that has valid multiboot header.
> > > > > > qemu should be able to boot such images.
> > > > >
> > > > > But this 64bit image actually starts with 32bit code, right?
> > > >
> > > > Correct. The very first part of the startup code has to be 32bit.
> > > > After it sets "long mode" it can use 64bit instructions. To make sure
> > > > that the preamble has only 32bit instructions one have to use asm
> > > > directive such as ".code32".
> > > >
> > > > Here is an example from LitleKernel sturtup code:
> > > >
> > > > https://github.com/littlekernel/lk/blob/master/arch/x86/64/start.S#L50
> > > >
> > > > .code32 tells assembler to treat following text as 32 bit code. And
> > > > later when it jumps into "long mode"
> > > >
> > > > https://github.com/littlekernel/lk/blob/master/arch/x86/64/start.S#L214
> > > > one can use 64bit code.
> > > >
> > > > > So it's a 32bit program and the check verifies that this is the case.
> > > >
> > > > While preamble have to contain 32 only instructions the rest of the
> > > > image can perfectly contain 64bit code. Right now 64bit binary cannot
> > > > be run with "qemu-system-x86_64 -kernel". But the same binary runs
> > > > fine if packed with GRUB as iso.
> > > >
> > > > I tried to hack around this restriction by adding
> > > > "OUTPUT_FORMAT(elf32-i386)" to the linker file and compiling project
> > > > with 64bit support. But GNU ld program crashed at Ubuntu 14.04. It
> > > > means not that many people use this code path. GNU ld compiled from
> > > > HEAD does not have this problem but now GDB is confused by the fact
> > > > that ELF contains 64bit code while header reports i386.
> >
> > That's unfortunate.
> >
> > > > Practically there is no reason for this check as it prevents running
> > > > 64bit binaries with "qemu-system-x86_64 -kernel".
> >
> > One reason for the check is that it prevents that one loads a 64bit ELF
> > binary that then fails strangely because it does not have the magic
> > 32bit code to set up things.
>
> I would not call the 32bit preamble a magic - it is fairly well
> documented; it is just a result of backward compatibility that
> AMD/Intel carry for a long time. Every single 64-bit operation system
> (Linux, Windows, FreeBSD, ...) has such 32bit init sequence.
FWIW, Anatol's patch also makes it possible for qemu to load the 64-bit
Xen XTF tests.
It would be a useful to at least have a way to override the check, even
if it's still present by default.
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5965 bytes --]
prev parent reply other threads:[~2022-12-20 23:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-07 4:41 [Qemu-devel] [PATCH] Remove restriction that prevents bootimg elf64 images Anatol Pomozov
2017-06-07 17:19 ` Anatol Pomozov
2017-06-08 20:41 ` Adam Lackorzynski
2017-06-08 21:07 ` Anatol Pomozov
2017-06-14 0:05 ` Anatol Pomozov
2017-06-19 21:08 ` Adam Lackorzynski
2017-06-21 20:45 ` Anatol Pomozov
2022-12-20 23:45 ` David Woodhouse [this message]
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=b2fd6676446f5bb19f08ae26b8c4fbbd5ebd1c10.camel@infradead.org \
--to=dwmw2@infradead.org \
--cc=adam@os.inf.tu-dresden.de \
--cc=anatol.pomozov@gmail.com \
--cc=goswin-v-b@web.de \
--cc=qemu-devel@nongnu.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).