From: Andre Przywara <andre.przywara@arm.com>
To: Michael Ellerman <mpe@ellerman.id.au>
Cc: Will Deacon <Will.Deacon@arm.com>, Matt Evans <matt@ozlabs.org>,
"kvm-ppc@vger.kernel.org" <kvm-ppc@vger.kernel.org>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>
Subject: Re: [PATCH 2/3] powerpc: use default endianness for converting guest/init
Date: Fri, 19 Jun 2015 16:15:43 +0000 [thread overview]
Message-ID: <5584402F.1040208@arm.com> (raw)
In-Reply-To: <1434676121.23771.1.camel@ellerman.id.au>
Hi Michael,
On 19/06/15 02:08, Michael Ellerman wrote:
> On Thu, 2015-06-18 at 15:52 +0100, Andre Przywara wrote:
>> Hi,
>>
>> On 06/17/2015 10:43 AM, Andre Przywara wrote:
>>> For converting the guest/init binary into an object file, we call
>>> the linker binary, setting the endianness to big endian explicitly
>>> when compiling kvmtool for powerpc.
>>> This breaks if the compiler is actually targetting little endian
>>> (which is true for the Debian port, for instance).
>>> Remove the explicit big endianness switch from the linker call to
>>> allow linking on little endian PowerPC builds again.
>>>
>>> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
>>> ---
>>> Hi,
>>>
>>> this fixed the powerpc64le build for me, while still compiling fine
>>> for big endian. Admittedly this whole init->guest_init.o conversion
>>> has its issues (with MIPS, for instance), which deserve proper fixing,
>>> but lets just fix that build for now.
>>
>> Will was concerned about breaking toolchains where the linker does not
>> default to 64-bit. Is that an issue we care about?
>
> Yeah, that would be Debian & Ubuntu BE at least, and maybe Fedora too? I'm not
> sure how you compiled it big endian?
I have my own cross-compiler built from scratch. This is
powerpc64-linux-gnu, which is big endian. I don't have any distribution
behind it, it's just a cross-compiler with glibc.
>> AFAICT LDFLAGS is only used in this dodgy binary-to-object-file
>> conversion of guest/init. For this we rely on the resulting .o file to
>> have the same ELF target as the other object files to be finally linked
>> into the lkvm binary. As we don't compile guest/init with CFLAGS, there
>> is a possible mismatch.
>>
>> I am looking into a proper fix for this now (compiling guest/init with
>> CFLAGS, calling $CC with linker options instead of $LD and allowing CC
>> and LD override). Still struggling with MIPS, though :-(
>
> Yeah that's obviously a better solution medium term.
>
> Can you do something like this? Sorry untested:
>
> diff --git a/Makefile b/Makefile
> index 6110b8e..8663d67 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -149,7 +149,11 @@ ifeq ($(ARCH), powerpc)
> OBJS += powerpc/xics.o
> ARCH_INCLUDE := powerpc/include
> CFLAGS += -m64
> - LDFLAGS += -m elf64ppc
> + ifeq ($(call try-build,$(SOURCE_HELLO),$(CFLAGS),-m elf64ppc),y)
> + LDFLAGS += -m elf64ppc
> + else
> + LDFLAGS += -m elf64leppc
> + endif
>
> ARCH_WANT_LIBFDT := y
> endif
Nah, actually I want to get rid of those LDFLAGS at all. For some
reasons using ld to convert a random binary file into a C object is
causing trouble on MIPS, because ld uses a slightly different ELF target
than CC there.
I think this conversion should be more a job for objcopy than for ld,
but that does not fix the problem in a generic way (though I was able to
hack it with some magic objcopy options).
What works though is using xxd to convert the binary guest/init into a C
array:
$ xxd -i guest/init | $(CC) -x c -c - -o guest/guest_init.o
This has the nice property of using the same compiler that generates the
other object files and thus automatically matches them (which is a
problem under MIPS atm, as ld seems to default to some different ELF type).
The only issue is that xxd is part of the vim package, which would annoy
Emacs users. Not sure we are in a position to mandate vim for compiling
kvmtool ;-)
Cheers,
Andre.
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
WARNING: multiple messages have this Message-ID (diff)
From: Andre Przywara <andre.przywara@arm.com>
To: Michael Ellerman <mpe@ellerman.id.au>
Cc: Will Deacon <Will.Deacon@arm.com>, Matt Evans <matt@ozlabs.org>,
"kvm-ppc@vger.kernel.org" <kvm-ppc@vger.kernel.org>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>
Subject: Re: [PATCH 2/3] powerpc: use default endianness for converting guest/init
Date: Fri, 19 Jun 2015 17:15:43 +0100 [thread overview]
Message-ID: <5584402F.1040208@arm.com> (raw)
In-Reply-To: <1434676121.23771.1.camel@ellerman.id.au>
Hi Michael,
On 19/06/15 02:08, Michael Ellerman wrote:
> On Thu, 2015-06-18 at 15:52 +0100, Andre Przywara wrote:
>> Hi,
>>
>> On 06/17/2015 10:43 AM, Andre Przywara wrote:
>>> For converting the guest/init binary into an object file, we call
>>> the linker binary, setting the endianness to big endian explicitly
>>> when compiling kvmtool for powerpc.
>>> This breaks if the compiler is actually targetting little endian
>>> (which is true for the Debian port, for instance).
>>> Remove the explicit big endianness switch from the linker call to
>>> allow linking on little endian PowerPC builds again.
>>>
>>> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
>>> ---
>>> Hi,
>>>
>>> this fixed the powerpc64le build for me, while still compiling fine
>>> for big endian. Admittedly this whole init->guest_init.o conversion
>>> has its issues (with MIPS, for instance), which deserve proper fixing,
>>> but lets just fix that build for now.
>>
>> Will was concerned about breaking toolchains where the linker does not
>> default to 64-bit. Is that an issue we care about?
>
> Yeah, that would be Debian & Ubuntu BE at least, and maybe Fedora too? I'm not
> sure how you compiled it big endian?
I have my own cross-compiler built from scratch. This is
powerpc64-linux-gnu, which is big endian. I don't have any distribution
behind it, it's just a cross-compiler with glibc.
>> AFAICT LDFLAGS is only used in this dodgy binary-to-object-file
>> conversion of guest/init. For this we rely on the resulting .o file to
>> have the same ELF target as the other object files to be finally linked
>> into the lkvm binary. As we don't compile guest/init with CFLAGS, there
>> is a possible mismatch.
>>
>> I am looking into a proper fix for this now (compiling guest/init with
>> CFLAGS, calling $CC with linker options instead of $LD and allowing CC
>> and LD override). Still struggling with MIPS, though :-(
>
> Yeah that's obviously a better solution medium term.
>
> Can you do something like this? Sorry untested:
>
> diff --git a/Makefile b/Makefile
> index 6110b8e..8663d67 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -149,7 +149,11 @@ ifeq ($(ARCH), powerpc)
> OBJS += powerpc/xics.o
> ARCH_INCLUDE := powerpc/include
> CFLAGS += -m64
> - LDFLAGS += -m elf64ppc
> + ifeq ($(call try-build,$(SOURCE_HELLO),$(CFLAGS),-m elf64ppc),y)
> + LDFLAGS += -m elf64ppc
> + else
> + LDFLAGS += -m elf64leppc
> + endif
>
> ARCH_WANT_LIBFDT := y
> endif
Nah, actually I want to get rid of those LDFLAGS at all. For some
reasons using ld to convert a random binary file into a C object is
causing trouble on MIPS, because ld uses a slightly different ELF target
than CC there.
I think this conversion should be more a job for objcopy than for ld,
but that does not fix the problem in a generic way (though I was able to
hack it with some magic objcopy options).
What works though is using xxd to convert the binary guest/init into a C
array:
$ xxd -i guest/init | $(CC) -x c -c - -o guest/guest_init.o
This has the nice property of using the same compiler that generates the
other object files and thus automatically matches them (which is a
problem under MIPS atm, as ld seems to default to some different ELF type).
The only issue is that xxd is part of the vim package, which would annoy
Emacs users. Not sure we are in a position to mandate vim for compiling
kvmtool ;-)
Cheers,
Andre.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
next prev parent reply other threads:[~2015-06-19 16:15 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-17 9:43 [PATCH 0/3] kvmtool: fixes for PowerPC Andre Przywara
2015-06-17 9:43 ` Andre Przywara
2015-06-17 9:43 ` [PATCH 1/3] powerpc: implement barrier primitives Andre Przywara
2015-06-17 9:43 ` Andre Przywara
2015-06-17 10:15 ` Will Deacon
2015-06-17 10:15 ` Will Deacon
2015-06-17 10:46 ` Alexander Graf
2015-06-17 10:46 ` Alexander Graf
2015-06-18 9:11 ` Michael Ellerman
2015-06-18 9:11 ` Michael Ellerman
2015-06-18 9:38 ` Will Deacon
2015-06-18 9:38 ` Will Deacon
2015-06-17 9:43 ` [PATCH 2/3] powerpc: use default endianness for converting guest/init Andre Przywara
2015-06-17 9:43 ` Andre Przywara
2015-06-18 14:52 ` Andre Przywara
2015-06-18 14:52 ` Andre Przywara
2015-06-19 1:08 ` Michael Ellerman
2015-06-19 1:08 ` Michael Ellerman
2015-06-19 16:15 ` Andre Przywara [this message]
2015-06-19 16:15 ` Andre Przywara
2015-06-21 20:01 ` Michael Ellerman
2015-06-21 20:01 ` Michael Ellerman
2015-06-17 9:43 ` [PATCH 3/3] powerpc: add hvcall.h header from Linux Andre Przywara
2015-06-17 9:43 ` Andre Przywara
2015-06-17 10:13 ` Will Deacon
2015-06-17 10:13 ` Will Deacon
2015-06-18 9:15 ` Michael Ellerman
2015-06-18 9:15 ` Michael Ellerman
2015-06-18 10:10 ` [PATCH v2] " Andre Przywara
2015-06-18 10:10 ` Andre Przywara
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=5584402F.1040208@arm.com \
--to=andre.przywara@arm.com \
--cc=Will.Deacon@arm.com \
--cc=kvm-ppc@vger.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=matt@ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=svaidy@linux.vnet.ibm.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.