qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Alexey Kardashevskiy <aik@ozlabs.ru>,
	QEMU Developers <qemu-devel@nongnu.org>,
	Paul Brook <paul@codesourcery.com>
Subject: Re: [Qemu-devel] [PATCH v3 11/24] cpu/a15mpcore: Embed GICState
Date: Thu, 22 Aug 2013 12:56:17 +0200	[thread overview]
Message-ID: <5215EE51.8070409@suse.de> (raw)
In-Reply-To: <CAFEAcA8h15KPj+56PecaPG1OK404cgR4YprZyFuQZwDFXBCFig@mail.gmail.com>

Am 21.08.2013 23:05, schrieb Peter Maydell:
> On 20 August 2013 16:21, Andreas Färber <afaerber@suse.de> wrote:
>> From: Andreas Färber <andreas.faerber@web.de>
>>
>> This covers both emulated and KVM GIC.
> 
>> @@ -35,40 +36,48 @@ typedef struct A15MPPrivState {
>>      uint32_t num_cpu;
>>      uint32_t num_irq;
>>      MemoryRegion container;
>> -    DeviceState *gic;
>> +
>> +    GICState gic;
>>  } A15MPPrivState;
> 
>>  static void a15mp_priv_initfn(Object *obj)
>>  {
>>      SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
>>      A15MPPrivState *s = A15MPCORE_PRIV(obj);
>> +    DeviceState *gicdev;
>> +    const char *gictype = "arm_gic";
>> +
>> +    if (kvm_irqchip_in_kernel()) {
>> +        gictype = "kvm-arm-gic";
>> +    }
>>
>>      memory_region_init(&s->container, obj, "a15mp-priv-container", 0x8000);
>>      sysbus_init_mmio(sbd, &s->container);
>> +
>> +    object_initialize(&s->gic, gictype);
>> +    gicdev = DEVICE(&s->gic);
>> +    qdev_set_parent_bus(gicdev, sysbus_get_default());
>> +    qdev_prop_set_uint32(gicdev, "revision", 2);
> 
> So this is basically assuming that kvm-arm-gic and arm-gic
> both have an instance struct of exactly the same size,
> even though they're different classes (they happen to be
> so at the moment, because neither adds extra state beyond
> that needed by common base class). Is that really a good
> idea? (If it ever becomes not true we get silent memory
> corruption here...)

Not sure if a union of only one member is permitted? We're not actually
accessing the GICState, only void* and DEVICE()/SYS_BUS_DEVICE(), so it
just needs to block the memory, hopefully without needing to distinguish
between ->gic.emulated and ->gic.kvm pointers.
The decision doesn't depend on any user-settable property, just on the
at this point global kvm_enabled() state, so I see nowhere else to
allocate it dynamically.

If you change the .instance_size struct one of the GICs uses, then a
number of places will need to be reviewed, including
ARM_GIC_COMMON()[*], ARM_GIC() and KVM_ARM_GIC() all returning the same
type.

[*] When we're through with the functional changes, we should
s/ARM_GIC_COMMON/COMMON_ARM_GIC/g to match the general pattern.

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

  reply	other threads:[~2013-08-22 10:56 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-20 15:20 [Qemu-devel] [PATCH v3 00/24] arm: ARM11MPCore+A9MPCore+A15MPCore QOM'ification Andreas Färber
2013-08-20 15:20 ` [Qemu-devel] [PATCH v3 01/24] cpu/a9mpcore: Split off instance_init Andreas Färber
2013-08-20 15:20 ` [Qemu-devel] [PATCH v3 02/24] intc/arm_gic: Extract headers hw/intc/arm_gic{, _common}.h Andreas Färber
2013-08-20 15:20 ` [Qemu-devel] [PATCH v3 03/24] cpu/a9mpcore: Embed GICState Andreas Färber
2013-08-20 15:20 ` [Qemu-devel] [PATCH v3 04/24] misc/a9scu: QOM cleanups Andreas Färber
2013-08-20 15:20 ` [Qemu-devel] [PATCH v3 05/24] cpu/a9mpcore: Embed A9SCUState Andreas Färber
2013-08-20 15:20 ` [Qemu-devel] [PATCH v3 06/24] timer/arm_mptimer: Convert to QOM realize Andreas Färber
2013-08-20 15:20 ` [Qemu-devel] [PATCH v3 07/24] cpu/a9mpcore: Embed ARMMPTimerState Andreas Färber
2013-08-20 15:21 ` [Qemu-devel] [PATCH v3 08/24] cpu/a9mpcore: Convert to QOM realize Andreas Färber
2013-08-20 15:21 ` [Qemu-devel] [PATCH v3 09/24] cpu/a9mpcore: Prepare for QOM embedding Andreas Färber
2013-08-20 15:21 ` [Qemu-devel] [PATCH v3 10/24] cpu/a15mpcore: Split off instance_init Andreas Färber
2013-08-20 15:21 ` [Qemu-devel] [PATCH v3 11/24] cpu/a15mpcore: Embed GICState Andreas Färber
2013-08-21 21:05   ` Peter Maydell
2013-08-22 10:56     ` Andreas Färber [this message]
2013-08-22 11:41       ` Peter Maydell
2013-08-20 15:21 ` [Qemu-devel] [PATCH v3 12/24] cpu/a15mpcore: Convert to QOM realize Andreas Färber
2013-08-20 15:21 ` [Qemu-devel] [PATCH v3 13/24] cpu/a15mpcore: Prepare for QOM embedding Andreas Färber
2013-08-20 15:21 ` [Qemu-devel] [PATCH v3 14/24] a9scu: Build only once Andreas Färber
2013-08-20 15:21 ` [Qemu-devel] [PATCH v3 15/24] arm11mpcore: Fix typo in MemoryRegion name Andreas Färber
2013-08-20 15:21 ` [Qemu-devel] [PATCH v3 16/24] arm11mpcore: Drop unused fields Andreas Färber
2013-08-20 15:21 ` [Qemu-devel] [PATCH v3 17/24] arm11mpcore: Create container MemoryRegion in instance_init Andreas Färber
2013-08-20 15:21 ` [Qemu-devel] [PATCH v3 18/24] arm11mpcore: Split off SCU device Andreas Färber
2013-08-20 15:21 ` [Qemu-devel] [PATCH v3 19/24] arm11mpcore: Convert ARM11MPCorePriveState to QOM realize Andreas Färber
2013-08-20 15:21 ` [Qemu-devel] [PATCH v3 20/24] realview_gic: Convert " Andreas Färber
2013-08-20 15:21 ` [Qemu-devel] [PATCH v3 21/24] realview_gic: Prepare for QOM embedding Andreas Färber
2013-08-20 15:21 ` [Qemu-devel] [PATCH v3 22/24] arm11mpcore: Convert mpcore_rirq_state to QOM realize Andreas Färber
2013-08-20 15:21 ` [Qemu-devel] [PATCH v3 23/24] arm11mpcore: Prepare for QOM embedding Andreas Färber
2013-08-20 15:21 ` [Qemu-devel] [PATCH v3 24/24] arm11mpcore: Split off RealView MPCore Andreas Färber
2013-08-21 21:01 ` [Qemu-devel] [PATCH v3 00/24] arm: ARM11MPCore+A9MPCore+A15MPCore QOM'ification Peter Maydell
2013-08-22 10:34   ` 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=5215EE51.8070409@suse.de \
    --to=afaerber@suse.de \
    --cc=aik@ozlabs.ru \
    --cc=paul@codesourcery.com \
    --cc=peter.maydell@linaro.org \
    --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).