qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: Peter Crosthwaite <crosthwaitepeter@gmail.com>
Cc: "Edgar Iglesias" <edgari@xilinx.com>,
	sorenb@xilinx.com, "QEMU Developers" <qemu-devel@nongnu.org>,
	"Andreas Färber" <afaerber@suse.de>,
	"Richard Henderson" <rth@twiddle.net>
Subject: Re: [Qemu-devel] [RFC PATCH 00/34] Multi Architecture System Emulation
Date: Mon, 11 May 2015 08:13:01 +0100	[thread overview]
Message-ID: <CAFEAcA8wDD4OjmkxmoueaTu-sg6CR415qPFsgh9Mu8W1XWN1Bw@mail.gmail.com> (raw)
In-Reply-To: <cover.1431322749.git.crosthwaite.peter@gmail.com>

On 11 May 2015 at 07:29, Peter Crosthwaite <crosthwaitepeter@gmail.com> wrote:
> This is target-multi, a system-mode build that can support multiple
> cpu-types. Patches 1-3 are the main infrastructure. The hard part
> is the per-target changes needed to get each arch into an includable
> state.

Interesting. This is something I'd thought we were still some way
from being able to do :-)

> The hardest part is what to do about bootloading. Currently each arch
> has it's own architecture specific bootloading which may assume a
> single architecture. I have applied some hacks to at least get this
> RFC testable using a -kernel -firmware split but going forward being
> able to associate an elf/image with a cpu explictitly needs to be
> solved.

My first thought would be to leave the -kernel/-firmware stuff as
legacy (or at least with semantics defined by the board model in use)
and have per-CPU QOM properties for setting up images for genuinely
multi-CPU configs.

> For the implementation of this series, the trickiest part is cpu.h
> inclusion management. There are now more than one cpu.h's and different
> parts of the tree need a different include scheme. target-multi defines
> it's own cpu.h which is bare minimum defs as needed by core code only.
> target-foo/cpu.h are mostly the same but refactored to reuse common
> code (with target-multi/cpu-head.h). Inclusion scheme goes something like
> this (for the multi-arch build):
>
> 1: All obj-y modules include target-multi/cpu.h
> 2: Core code includes no other cpu.h's
> 3: target-foo/ implementation code includes target-foo/cpu.h
> 4: System level code (e.g. mach models) can use multiple target-foo/cpu.h's
>
> Point 4 means that cpu.h's needs to be refactored to be able to include one
> after the other. The interrupts for ARM and MB needed to be renamed to avoid
> namespace collision. A few other defs needed multiple include guards, and
> a few defs which where only for user mode are compiled out or relocated. No
> attempt at support for multi-arch linux-user mode (if that even makes sense?).

I don't think it does make much sense -- our linux-user code hardwires
a lot of ABI details like size of 'long' and struct layouts. In any
case we should probably leave it for later.

> The env as handle by common code now needs to architecture-agnostic. The
> MB and ARM envs are refactored to have CPU_COMMON as the first field(s)
> allowing QOM-style pointer casts to/from a generic env which contains only
> CPU_COMMON. Might need to lock down some struct packing for that but it
> works for me so far.

Have you managed to retain the "generated code passes around a pointer
to an env which starts with the CPU specific fields"? We have the env
structs the layout we do because it's a performance hit if the registers
aren't a short distance away from the pointer...

> The helper function namespace is going to be tricky. I haven't tackled the
> problem just yet, but looking for ideas on how we can avoid prefacing all
> helpers with arch prefixes to avoid link-time collisions because multiple
> arches use the same helper names.
>
> A lowest common denomintor approach is taken on architecture specifics. E.g.
> TARGET_LONG is 64-bit, and the address space sizes and NUM_MMU_MODES is set
> to the maximum of all the supported arches.

...speaking of performance hits.

I'm not sure you can do lowest-common-denominator for TARGET_PAGE_SIZE,
incidentally. At minimum it will result in a perf hit for the CPUs with
larger pages (because we end up taking the hugepage support paths in the
cputlb.c code), and at worst TLB flushing in the target's helper routines
might not take out the right pages. (I think ARM has some theoretical
bugs here which we don't hit in practice; ARM already has to cope with
a TARGET_PAGE_SIZE smaller than its usual pagesize, though.)

> The remaining globally defined interfaces between core code and CPUs are
> QOMified per-cpu (P2)
>
> Microblaze translation needs a change pattern to allow conversion to 64-bit
> TARGET_LONG. Uses of TCGv need to be removed and explicited to 32-bit.

Yeah, this will be a tedious job for the other targets (I had to do it
for ARM when I added the AArch64 support).

> This RFC will serve as a reference as I send bits and piece to the respective
> maintainers (many major subsystems are patched).
>
> No support for KVM, im not sure if a mix of TCG and KVM is supported even for
> a single arch? (which would be prerequisite to MA KVM).

You can build a single binary which supports both TCG and KVM for a
particular architecture. You just can't swap back and forth between
TCG and KVM at runtime. We should probably start by supporting KVM
only on boards with a single CPU architecture. I don't think it's
in-principle impossible to get a setup with 4 KVM CPUs and one
TCG emulated CPUs to work, but it probably needs to wait til we've
got multi-threaded TCG working before we even think about it.

> Depends (not heavily) on my on-list disas QOMification. Test instructions
> available on request. I have tested ARM & MB elfs handshaking through shared
> memory and both printfing to the same UART (verifying system level
> connectivity). -d in_asm works with the mix of disas arches comming out.

Did you do any benchmarking to see whether the performance hits are
noticeable in practice?

Do you give each CPU its own codegen buffer? (I'm thinking that some
of this might also be more easily done once multithreadded-TCG is
complete, since that will properly split the datastructures.)

thanks
-- PMM

  parent reply	other threads:[~2015-05-11  7:13 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-11  6:29 [Qemu-devel] [RFC PATCH 00/34] Multi Architecture System Emulation Peter Crosthwaite
2015-05-11  6:29 ` [Qemu-devel] [RFC PATCH 01/34] cpu-all: Prototype cpu_exec and cpu_signal_handler Peter Crosthwaite
2015-05-11  6:29 ` [Qemu-devel] [RFC PATCH 02/34] tcg+qom: QOMify core CPU defintions Peter Crosthwaite
2015-05-11 10:18   ` Andreas Färber
2015-05-11 10:24     ` Paolo Bonzini
2015-05-11 10:36       ` Andreas Färber
2015-05-11 10:39         ` Paolo Bonzini
2015-05-12  7:25           ` Peter Crosthwaite
2015-05-11 20:18       ` Richard Henderson
2015-05-12  7:23         ` Peter Crosthwaite
2015-05-12 15:24           ` Richard Henderson
2015-05-11 10:43   ` Peter Maydell
2015-05-11  6:29 ` [Qemu-devel] [RFC PATCH 03/34] target-multi: Add Peter Crosthwaite
2015-05-11  6:29 ` [Qemu-devel] [RFC PATCH 04/34] mb: Change target long to 64b Peter Crosthwaite
2015-05-15  5:37   ` Peter Crosthwaite
2015-05-11  6:29 ` [Qemu-devel] [RFC PATCH 05/34] mb: cpu: Delete MMAP_SHIFT definition Peter Crosthwaite
2015-05-11  6:29 ` [Qemu-devel] [RFC PATCH 06/34] mb: rename EXCP macros Peter Crosthwaite
2015-05-11  6:29 ` [Qemu-devel] [RFC PATCH 07/34] mb: Remove ELF_MACHINE from cpu.h Peter Crosthwaite
2015-05-11  6:29 ` [Qemu-devel] [RFC PATCH 08/34] mb: cpu.h: Move cpu-all include Peter Crosthwaite
2015-05-11  6:29 ` [Qemu-devel] [RFC PATCH 09/34] mb: delete dummy prototypes Peter Crosthwaite
2015-05-11  6:29 ` [Qemu-devel] [RFC PATCH 10/34] HACK: microblaze: rename clz helper Peter Crosthwaite
2015-05-11  6:29 ` [Qemu-devel] [RFC PATCH 11/34] mb: cpu: Remove MMUx macros Peter Crosthwaite
2015-05-11  6:29 ` [Qemu-devel] [RFC PATCH 12/34] mb: cpu: Move CPU_COMMON to front of env Peter Crosthwaite
2015-05-11  6:29 ` [Qemu-devel] [RFC PATCH 13/34] mb: cpu: Change phys and virt address ranges Peter Crosthwaite
2015-05-11  6:29 ` [Qemu-devel] [RFC PATCH 14/34] mb: Use qomified tcg defintions Peter Crosthwaite
2015-05-11  6:29 ` [Qemu-devel] [RFC PATCH 15/34] hw: mb: Explicitly include cpu.h for consumers Peter Crosthwaite
2015-05-11  6:29 ` [Qemu-devel] [RFC PATCH 16/34] mb: cpu: Guard cpu_init definition for user mode Peter Crosthwaite
2015-05-11  6:29 ` [Qemu-devel] [RFC PATCH 17/34] mb: cpu: Multi-define guard deep CPU specifics Peter Crosthwaite
2015-05-11  6:29 ` [Qemu-devel] [RFC PATCH 18/34] mb: cpu-qom: Put the ENV first Peter Crosthwaite
2015-05-11  6:29 ` [Qemu-devel] [RFC PATCH 19/34] mb: Enable multi-arch Peter Crosthwaite
2015-05-11  6:29 ` [Qemu-devel] [RFC PATCH 20/34] configure: Unify arm and aarch64 disas configury Peter Crosthwaite
2015-05-11  6:29 ` [Qemu-devel] [RFC PATCH 21/34] arm: Rename all exceptions Peter Crosthwaite
2015-05-15  5:43   ` Peter Crosthwaite
2015-05-15 10:59     ` Andreas Färber
2015-05-15 13:36       ` Richard Henderson
2015-05-15 17:01         ` Peter Crosthwaite
2015-05-11  6:29 ` [Qemu-devel] [RFC PATCH 22/34] arm: Remove ELF_MACHINE from cpu.h Peter Crosthwaite
2015-05-11  6:29 ` [Qemu-devel] [RFC PATCH 23/34] arm: cpu.h: Move cpu-all include Peter Crosthwaite
2015-05-11  6:29 ` [Qemu-devel] [RFC PATCH 24/34] arm: delete dummy prototypes Peter Crosthwaite
2015-05-11  6:29 ` [Qemu-devel] [RFC PATCH 25/34] arm: cpu: Move CPU_COMMON to front of env Peter Crosthwaite
2015-05-11  8:36   ` Paolo Bonzini
2015-05-11 10:20     ` Andreas Färber
2015-05-11  6:29 ` [Qemu-devel] [RFC PATCH 26/34] arm: Use qomified tcg defintions Peter Crosthwaite
2015-05-11  6:29 ` [Qemu-devel] [RFC PATCH 27/34] hw: arm: Explicitly include cpu.h for consumers Peter Crosthwaite
2015-05-11  6:29 ` [Qemu-devel] [RFC PATCH 28/34] arm: cpu: Guard cpu_init definition for user mode Peter Crosthwaite
2015-05-11  6:29 ` [Qemu-devel] [RFC PATCH 29/34] arm: cpu: Multi-define guard deep CPU specifics Peter Crosthwaite
2015-05-11  6:29 ` [Qemu-devel] [RFC PATCH 30/34] arm: Enable multi-arch Peter Crosthwaite
2015-05-11  6:29 ` [Qemu-devel] [RFC PATCH 31/34] arm: boot: Don't assume all CPUs are ARM Peter Crosthwaite
2015-05-11  6:29 ` [Qemu-devel] [RFC PATCH 32/34] arm: xilinx_zynq: Add a microblaze Peter Crosthwaite
2015-05-11  6:29 ` [Qemu-devel] [RFC PATCH 33/34] HACK: mb: boot: Assume using -firmware for mb software Peter Crosthwaite
2015-05-11  6:29 ` [Qemu-devel] [RFC PATCH 34/34] HACK: mb: boot: Disable dtb load in multi-arch Peter Crosthwaite
2015-05-11  7:13 ` Peter Maydell [this message]
2015-05-11  8:21   ` [Qemu-devel] [RFC PATCH 00/34] Multi Architecture System Emulation Peter Crosthwaite
2015-05-11  8:52     ` Peter Maydell
2015-05-11 10:44     ` Andreas Färber
2015-05-11 10:27 ` Andreas Färber
2015-05-15  6:47   ` Peter Crosthwaite
2015-05-15 11:04     ` Andreas Färber
2015-05-15  6:59 ` Peter Crosthwaite
2015-05-15 11:30   ` Andreas Färber

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=CAFEAcA8wDD4OjmkxmoueaTu-sg6CR415qPFsgh9Mu8W1XWN1Bw@mail.gmail.com \
    --to=peter.maydell@linaro.org \
    --cc=afaerber@suse.de \
    --cc=crosthwaitepeter@gmail.com \
    --cc=edgari@xilinx.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=sorenb@xilinx.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 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).