From patchwork Tue Dec 2 18:28:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 41828 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E717E25E3D for ; Tue, 2 Dec 2014 18:28:35 +0000 (UTC) Received: by mail-la0-f70.google.com with SMTP id hs14sf5116063lab.9 for ; Tue, 02 Dec 2014 10:28:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=Pe6GyA14rvMp3pWAxBu5A4TRo3e2LiJG4hzwaX9ZLX4=; b=Uywklz707gAHnMmemA8kredLlVh+ZhX8rxUXbu5rRYM9sdZekYkfXhZM2SQcxl/5fi /p1h5tF1kOXxbi6L1TcfAs+t5mn6qECJ37I5PCeeSITrZffLzrigYT/3xYVWb7c+SFdO RHjJGcbHqS3dS9DO4wwBbB45HLTOQM6govUSTIkFGLi2tarPWyoXKBcBSwGDTertXqHG HYKLBbl+maF1LCobjTHaOv/r/fv4erAZKpEG7ukfVy91BXverzzSnzyq76CqhdmtL/iV /wSkFuDxObsgJKGV8c3FEMxC9IgYu9kFhpURzSXtRqoZItLMx3gU2Xv9Y3ot5lmXokFs 1DGg== X-Gm-Message-State: ALoCoQkxeQJeiy2aBhbeD91Vibb1qRgeB0RyZNak6zUykv0q2LCNrTuiD4e9cDNIWBU++xh20mK2 X-Received: by 10.180.24.131 with SMTP id u3mr1181184wif.4.1417544914636; Tue, 02 Dec 2014 10:28:34 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.206.102 with SMTP id ln6ls63058lac.95.gmail; Tue, 02 Dec 2014 10:28:34 -0800 (PST) X-Received: by 10.112.201.72 with SMTP id jy8mr524250lbc.65.1417544914386; Tue, 02 Dec 2014 10:28:34 -0800 (PST) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id wz10si21040346lbb.109.2014.12.02.10.28.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 02 Dec 2014 10:28:34 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by mail-la0-f49.google.com with SMTP id hs14so11218844lab.36 for ; Tue, 02 Dec 2014 10:28:34 -0800 (PST) X-Received: by 10.112.189.10 with SMTP id ge10mr560957lbc.23.1417544911566; Tue, 02 Dec 2014 10:28:31 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp536961lbc; Tue, 2 Dec 2014 10:28:31 -0800 (PST) X-Received: by 10.180.99.1 with SMTP id em1mr7376684wib.29.1417544910918; Tue, 02 Dec 2014 10:28:30 -0800 (PST) Received: from mail-wi0-f178.google.com (mail-wi0-f178.google.com. [209.85.212.178]) by mx.google.com with ESMTPS id bt4si58324834wib.2.2014.12.02.10.28.30 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 02 Dec 2014 10:28:30 -0800 (PST) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 209.85.212.178 as permitted sender) client-ip=209.85.212.178; Received: by mail-wi0-f178.google.com with SMTP id em10so2388286wid.11 for ; Tue, 02 Dec 2014 10:28:30 -0800 (PST) X-Received: by 10.180.97.195 with SMTP id ec3mr97098463wib.79.1417544910676; Tue, 02 Dec 2014 10:28:30 -0800 (PST) Received: from midway01-04-00.lavalab ([81.128.185.50]) by mx.google.com with ESMTPSA id dm10sm47446829wib.18.2014.12.02.10.28.29 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 02 Dec 2014 10:28:30 -0800 (PST) From: Eric Auger To: eric.auger@st.com, christoffer.dall@linaro.org, qemu-devel@nongnu.org, a.rigo@virtualopensystems.com, marc.zyngier@arm.com, ard.biesheuvel@linaro.org, agraf@suse.de, peter.maydell@linaro.org, pbonzini@redhat.com, afaerber@suse.de Cc: eric.auger@linaro.org, kvmarm@lists.cs.columbia.edu, patches@linaro.org, a.motakis@virtualopensystems.com, alex.williamson@redhat.com Subject: [PATCH 2/2] hw/intc/arm_gic: Initialize the vgic on machine init done Date: Tue, 2 Dec 2014 18:28:14 +0000 Message-Id: <1417544894-2000-3-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1417544894-2000-1-git-send-email-eric.auger@linaro.org> References: <1417544894-2000-1-git-send-email-eric.auger@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: eric.auger@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , With current implementation the vgic is instantiated very late, when the VM is started, on the first VCPU run execution. This patch forces its initialization in a machine init done notifier. This latter is registered in the vgic realize function. The notifier uses a new group/attribute that allows such operation. In practice, vgic initialization can be done as soon as those dimensioning parameters are known: - the number of IRQs, - the number of vcpus - start address of dist and CPU interface (set in a memory listener). This earlier initialization allows, for example, to setup VFIO signaling after vgic initialization, on a reset notifier. Signed-off-by: Eric Auger --- hw/intc/arm_gic_kvm.c | 21 +++++++++++++++++++++ include/hw/intc/arm_gic_common.h | 1 + 2 files changed, 22 insertions(+) diff --git a/hw/intc/arm_gic_kvm.c b/hw/intc/arm_gic_kvm.c index 5038885..24fdf98 100644 --- a/hw/intc/arm_gic_kvm.c +++ b/hw/intc/arm_gic_kvm.c @@ -23,6 +23,7 @@ #include "sysemu/kvm.h" #include "kvm_arm.h" #include "gic_internal.h" +#include "sysemu/sysemu.h" //#define DEBUG_GIC_KVM @@ -511,6 +512,17 @@ static void kvm_arm_gic_reset(DeviceState *dev) kvm_arm_gic_put(s); } +static void kvm_arm_vgic_init_notify(Notifier *notifier, void *data) +{ + GICState *s = container_of(notifier, GICState, init_notifier); + struct kvm_device_attr attr = { + .group = KVM_DEV_ARM_VGIC_GRP_CTRL, + .attr = KVM_DEV_ARM_VGIC_CTRL_INIT}; + if (s->dev_fd >= 0) { + kvm_device_ioctl(s->dev_fd, KVM_SET_DEVICE_ATTR, &attr); + } +} + static void kvm_arm_gic_realize(DeviceState *dev, Error **errp) { int i; @@ -553,6 +565,15 @@ static void kvm_arm_gic_realize(DeviceState *dev, Error **errp) return; } + /* + * Register a notifier that will request the VGIC initialization. + * It will be executed after the notifier registered by + * kvm_arm_register_device whose role is to set dist and cpu interface + * base address. Also IRQ and VCPU number is known. + */ + s->init_notifier.notify = kvm_arm_vgic_init_notify; + qemu_add_machine_init_done_notifier(&s->init_notifier); + /* Distributor */ memory_region_init_reservation(&s->iomem, OBJECT(s), "kvm-gic_dist", 0x1000); diff --git a/include/hw/intc/arm_gic_common.h b/include/hw/intc/arm_gic_common.h index f6887ed..98653c9 100644 --- a/include/hw/intc/arm_gic_common.h +++ b/include/hw/intc/arm_gic_common.h @@ -105,6 +105,7 @@ typedef struct GICState { uint32_t num_irq; uint32_t revision; int dev_fd; /* kvm device fd if backed by kvm vgic support */ + Notifier init_notifier; /* notifier used to init the vgic */ } GICState; #define TYPE_ARM_GIC_COMMON "arm_gic_common"