From patchwork Tue Nov 19 06:18:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 21604 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qe0-f70.google.com (mail-qe0-f70.google.com [209.85.128.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id BA23620972 for ; Tue, 19 Nov 2013 06:17:20 +0000 (UTC) Received: by mail-qe0-f70.google.com with SMTP id 9sf11240053qea.1 for ; Mon, 18 Nov 2013 22:17:20 -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=4m9/PL9+o9EdhFlDMYqSoeHuDkZ2liWYlxWihFdssaA=; b=Cmd4z5pgj9I1X+CgJ2JWB1pkZLdO4IN4QkizsuKMNLTmiE6Ncn8r/9+t6ujHjOvZue XUZFLymS+hjArCeVg5F1lWqirnpzZBV9OFeegWYirX3i5dmr9u2+oSq5XmHr2iALjkCu 00n7Vqr6202w3ytO+v96hVXmHCxt2S7bURawF07W6z5G3IKLgHT0VaVoxkcR/6A9alwz j5KLH28LkvJxtd03I6sWrbis2HpqhXytvf1wT6RsBA1jYULnqIJxrrad7yMHiBfN2uvm 1/13jCyKAc+KdXhvTNrCQLe2n5kpvq5kDw+vmRC0N/aXupQ8/xMBF/L3mvJSUwJo+C5m tq+g== X-Gm-Message-State: ALoCoQnivovtyKY0SYMoqNHejMO9CDUhlWQRktnzyCqQE1bFqmtqY6YKaXOB6+qjmbHLBEpVhEwu X-Received: by 10.236.82.115 with SMTP id n79mr13010572yhe.35.1384841840606; Mon, 18 Nov 2013 22:17:20 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.105.34 with SMTP id gj2ls3003188qeb.52.gmail; Mon, 18 Nov 2013 22:17:20 -0800 (PST) X-Received: by 10.221.44.136 with SMTP id ug8mr19446657vcb.13.1384841840514; Mon, 18 Nov 2013 22:17:20 -0800 (PST) Received: from mail-vb0-f46.google.com (mail-vb0-f46.google.com [209.85.212.46]) by mx.google.com with ESMTPS id d19si7418808vcm.106.2013.11.18.22.17.20 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 18 Nov 2013 22:17:20 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.46 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.46; Received: by mail-vb0-f46.google.com with SMTP id i3so3373944vbh.5 for ; Mon, 18 Nov 2013 22:17:20 -0800 (PST) X-Received: by 10.220.159.4 with SMTP id h4mr19079778vcx.1.1384841840438; Mon, 18 Nov 2013 22:17:20 -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.220.174.196 with SMTP id u4csp255374vcz; Mon, 18 Nov 2013 22:17:19 -0800 (PST) X-Received: by 10.68.106.98 with SMTP id gt2mr17163791pbb.61.1384841839453; Mon, 18 Nov 2013 22:17:19 -0800 (PST) Received: from mail-pa0-f54.google.com (mail-pa0-f54.google.com [209.85.220.54]) by mx.google.com with ESMTPS id ei3si11204757pbc.290.2013.11.18.22.17.19 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 18 Nov 2013 22:17:19 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.54 is neither permitted nor denied by best guess record for domain of christoffer.dall@linaro.org) client-ip=209.85.220.54; Received: by mail-pa0-f54.google.com with SMTP id rd3so2094129pab.41 for ; Mon, 18 Nov 2013 22:17:19 -0800 (PST) X-Received: by 10.68.190.136 with SMTP id gq8mr17137529pbc.68.1384841839035; Mon, 18 Nov 2013 22:17:19 -0800 (PST) Received: from localhost.localdomain (c-67-169-181-221.hsd1.ca.comcast.net. [67.169.181.221]) by mx.google.com with ESMTPSA id rz6sm19165159pab.22.2013.11.18.22.17.17 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 18 Nov 2013 22:17:18 -0800 (PST) From: Christoffer Dall To: qemu-devel@nongnu.org Cc: kvmarm@lists.cs.columbia.edu, patches@linaro.org, Christoffer Dall Subject: [RFC PATCH v3 09/10] arm_gic: Add GICC_APRn state to the GICState Date: Mon, 18 Nov 2013 22:18:15 -0800 Message-Id: <1384841896-19566-10-git-send-email-christoffer.dall@linaro.org> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1384841896-19566-1-git-send-email-christoffer.dall@linaro.org> References: <1384841896-19566-1-git-send-email-christoffer.dall@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: christoffer.dall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.46 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) 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: , The GICC_APRn registers are not currently supported by the ARM GIC v2.0 emulation. This patch adds the missing state. The state was previously added in the main vgic save/restore patch, but moved to a separate patch as suggested under review. Note that we also change the number of APRs to use a define GIC_NR_APRS based on the maximum number of preemption levels. This patch also adds RAZ/WI accessors for the four registers on the emulated CPU interface. Signed-off-by: Christoffer Dall --- hw/intc/arm_gic.c | 5 +++++ hw/intc/arm_gic_common.c | 5 +++-- include/hw/intc/arm_gic_common.h | 11 +++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c index 20e926c..09f03e6 100644 --- a/hw/intc/arm_gic.c +++ b/hw/intc/arm_gic.c @@ -616,6 +616,8 @@ static uint32_t gic_cpu_read(GICState *s, int cpu, int offset) return s->current_pending[cpu]; case 0x1c: /* Aliased Binary Point */ return s->abpr[cpu]; + case 0xd0: case 0xd4: case 0xd8: case 0xdc: + return s->apr[(offset - 0xd0) / 4][cpu]; default: qemu_log_mask(LOG_GUEST_ERROR, "gic_cpu_read: Bad offset %x\n", (int)offset); @@ -643,6 +645,9 @@ static void gic_cpu_write(GICState *s, int cpu, int offset, uint32_t value) s->abpr[cpu] = (value & 0x7); } break; + case 0xd0: case 0xd4: case 0xd8: case 0xdc: + DPRINTF("Writing APR not yet supported\n"); + break; default: qemu_log_mask(LOG_GUEST_ERROR, "gic_cpu_write: Bad offset %x\n", (int)offset); diff --git a/hw/intc/arm_gic_common.c b/hw/intc/arm_gic_common.c index 65e3dc8..8dcb4fb 100644 --- a/hw/intc/arm_gic_common.c +++ b/hw/intc/arm_gic_common.c @@ -59,8 +59,8 @@ static const VMStateDescription vmstate_gic_irq_state = { static const VMStateDescription vmstate_gic = { .name = "arm_gic", - .version_id = 6, - .minimum_version_id = 6, + .version_id = 7, + .minimum_version_id = 7, .pre_save = gic_pre_save, .post_load = gic_post_load, .fields = (VMStateField[]) { @@ -79,6 +79,7 @@ static const VMStateDescription vmstate_gic = { VMSTATE_UINT16_ARRAY(current_pending, GICState, GIC_NCPU), VMSTATE_UINT8_ARRAY(bpr, GICState, GIC_NCPU), VMSTATE_UINT8_ARRAY(abpr, GICState, GIC_NCPU), + VMSTATE_UINT32_2DARRAY(apr, GICState, GIC_NR_APRS, GIC_NCPU), VMSTATE_END_OF_LIST() } }; diff --git a/include/hw/intc/arm_gic_common.h b/include/hw/intc/arm_gic_common.h index 2d6c23f..e815593 100644 --- a/include/hw/intc/arm_gic_common.h +++ b/include/hw/intc/arm_gic_common.h @@ -31,6 +31,9 @@ /* Maximum number of possible CPU interfaces, determined by GIC architecture */ #define GIC_NCPU 8 +#define MAX_NR_GROUP_PRIO 128 +#define GIC_NR_APRS (MAX_NR_GROUP_PRIO / 32) + typedef struct gic_irq_state { /* The enable bits are only banked for per-cpu interrupts. */ uint8_t enabled; @@ -70,6 +73,14 @@ typedef struct GICState { uint8_t bpr[GIC_NCPU]; uint8_t abpr[GIC_NCPU]; + /* The APR is implementation defined, so we choose a layout identical to + * the KVM ABI layout for QEMU's implementation of the gic: + * If an interrupt for preemption level X are active, then + * APRn[X mod 32] == 0b1, where n = X / 32 + * otherwise the bit is clear. + */ + uint32_t apr[GIC_NR_APRS][GIC_NCPU]; + uint32_t num_cpu; MemoryRegion iomem; /* Distributor */