From: Segher Boessenkool <segher@kernel.crashing.org>
To: Michael Ellerman <mpe@ellerman.id.au>
Cc: linuxppc-dev@lists.ozlabs.org, dja@axtens.net
Subject: Re: [PATCH] powerpc/kexec: Don't use .machine ppc64 in trampoline_64.S
Date: Mon, 15 Mar 2021 21:44:34 -0500 [thread overview]
Message-ID: <20210316024434.GE16691@gate.crashing.org> (raw)
In-Reply-To: <20210315034159.315675-1-mpe@ellerman.id.au>
Hi!
On Mon, Mar 15, 2021 at 02:41:59PM +1100, Michael Ellerman wrote:
> The ".machine" directive allows changing the machine for which code is
> being generated. It's equivalent to passing an -mcpu option on the
> command line.
>
> Although it can be useful, it's generally a bad idea because it adds
> another way to influence code generation separate from the flags
> passed via the build system. ie. if we need to build different pieces
> of code with different flags we should do that via our Makefiles, not
> using ".machine".
It does not influence code generation. It says which instructions are
valid, instead. There are a few cases where the same mnemonic will
generate a different binary encoding depending on machine selected,
maybe you mean that?
It is *normal* to use .machine push/pop and a specific .machine around
instructions that require a machine other than what you are building
for. The compiler does this itself, and it is the recommended way to
use "foreign" instructions in inline assembler.
That said...
> However as best as I can tell the ".machine" directive in
> trampoline_64.S is not necessary at all.
>
> It was added in commit 0d97631392c2 ("powerpc: Add purgatory for
> kexec_file_load() implementation."), which created the file based on
> the kexec-tools purgatory. It may be/have-been necessary in the
> kexec-tools version, but we have a completely different build system,
> and we already pass the desired CPU flags, eg:
>
> gcc ... -m64 -Wl,-a64 -mabi=elfv2 -Wa,-maltivec -Wa,-mpower4 -Wa,-many
> ... arch/powerpc/purgatory/trampoline_64.S
>
> So drop the ".machine" directive and rely on the assembler flags.
> - .machine ppc64
Please make sure to test this on a big endian config.
A ppc64le-linux assembler defaults to power8. A ppc64-linux assembler
defaults to power3 (that is the same as .machine ppc64). Or maybe it
makes it power4? I get lost :-)
It certainly *should* work, but, test please :-)
(And with a *default* powerpc64-linux config, not one that defaults to
power7 or power8 or similar! Arnd's toolchains at
<https://mirrors.edge.kernel.org/pub/tools/crosstool/>
are fine for this.)
Reviewed-by: Segher Boessenkool <segher@kernel.crashing.org>
Segher
next prev parent reply other threads:[~2021-03-16 2:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-15 3:41 [PATCH] powerpc/kexec: Don't use .machine ppc64 in trampoline_64.S Michael Ellerman
2021-03-16 2:44 ` Segher Boessenkool [this message]
2021-03-19 6:12 ` Michael Ellerman
2021-04-10 14:28 ` Michael Ellerman
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=20210316024434.GE16691@gate.crashing.org \
--to=segher@kernel.crashing.org \
--cc=dja@axtens.net \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
/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).