From patchwork Fri Apr 8 14:15:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 558831 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp381051map; Fri, 8 Apr 2022 07:38:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVwb+1oTmP8D5YH9AtNGEMYQ4louq5nTdYwoYmTTPxxEVtq/qtXys67ITqKOoTsr32memk X-Received: by 2002:a25:4013:0:b0:63d:b15b:f468 with SMTP id n19-20020a254013000000b0063db15bf468mr14670236yba.636.1649428731347; Fri, 08 Apr 2022 07:38:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649428731; cv=none; d=google.com; s=arc-20160816; b=HbAJ8qPjHLa6YtAT4x3XutS6nfjhaEOpopKCIsg5/pakmZshh5M8XirDP3UB3y9/7p QfNEyF/2K8aX0Zeg//2Qp93x1nJOR/zpSz7zXx+t02AQGNnC/IjnBZ1NLaA277UTS5L3 7nNqFWWV3gVgbmy7NAQ1U5xMiZR8PdwrkB4P0xYdGBhxzqWbQ5hB4RHLHeI/lmvoZaOk ZJm55xllLxErEpm+gwhzzFqk050Pr1iFPO9Y4ejY+vZMk3DyDaSpioZSu9khYVz7mONr Aa2pPn7HbQ41CQVYF3Ny2TYcodlORapdwUSOYmUsY/jedPogt4h5ShRQS5k2/iYVBDnW uITA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=4X5gt1qh1B1TGFcyO7ZbfSY/eEx5BCkyPS7Ts12JMq0=; b=D9S4wO7hHHRAFj8Qb6pCSQgfHxhvKZ6dQTNqgwt9XUisxaZb4CytHm25qDsT54loMV UubkfgoVu7r1dzufRxbce5JYyNMNYY9nCaqZ2CtP7kVk3eybhJvA2bokeOQXfXC5wiAX ZW08YmUM1o2qn5Bi3cRB5ieWgO3npKk5O0ZvPm4lr4y6mLjDfFuuWAzjaVxq8WbVoO+0 ul1vWdvTk6MHo4BdVOr5Jcx3m93t09wRJup7f45O1oke0ykL/zxCvKknSKVvyvqz56hx QVIQ+6j10PcXOSt3BIPASgucosTgDtmGXlZSFKoK9188cJdI+Tc1boAePKU7R0zAdrMC DmiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jOXXMYgP; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 2-20020a250802000000b0063db0e71ef6si590146ybi.222.2022.04.08.07.38.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Apr 2022 07:38:51 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jOXXMYgP; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:43576 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ncplC-0008EF-R7 for patch@linaro.org; Fri, 08 Apr 2022 10:38:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42610) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ncpPN-0006yt-On for qemu-devel@nongnu.org; Fri, 08 Apr 2022 10:16:18 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]:44978) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ncpPL-0002LU-Ke for qemu-devel@nongnu.org; Fri, 08 Apr 2022 10:16:17 -0400 Received: by mail-wm1-x32f.google.com with SMTP id v20-20020a05600c15d400b0038e9a88aee7so2493684wmf.3 for ; Fri, 08 Apr 2022 07:16:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4X5gt1qh1B1TGFcyO7ZbfSY/eEx5BCkyPS7Ts12JMq0=; b=jOXXMYgPL3yhnk1Vp7xvzHHBDDF34JuRGXI4WS2VmoIoyK+qeJqKxfp1oeNSDyOiev oJSn9Wq6jW3etOPvTK/K5x5K3KyLryPaUmjF0UbFzyaJcDEbWeeoItCAvrNJbJJv6797 xeU7eh7Eoek6zESCgxBaa4gV5oNVQDR+VZd6D096YcMnngrOU3le3y1xBOXIZDpmuzRc nS4+LKIaYcp6K5yZJ6DZMFHG+ZH18IjTru+cX5wZA0oRkzQCODFrDT9SelUszlOeVGpT knq71e2GN3wl/xykeY34/6DYOpSeKSmo6GqDIlkzYtgXNWJxGPZTBV3UG16bBro+s0/e 59hQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4X5gt1qh1B1TGFcyO7ZbfSY/eEx5BCkyPS7Ts12JMq0=; b=DqXXQ+DtwaZ+5fgIPOTRFBmFVUiQ4jGKJAloZl8DkT0S3FiYjPpnCRxmtjz6euD1pe A2I7Dn70PPK9q/7GN4PkS+PJs+lHGKbuQBSoVJIwCEcQ0HGOaHTqPT2zrn8dOeoAKRZq hRXV42u00xVL7ESylQIJ4VfRcreicRVBXtKfFN12108iTlK1zWTT+46u89m9d7TH38q0 kTJ77cnLV6xuVs/6aDRKBE4e+olzwy1P0icGjKaEpzPE1yjA7ko/vHfifgHFo1noMvhI 0aPL2TLw6z3KL74633G06f6DlNjuAlHYkGL43TD5d1Zq28+aRjl7lLMiy/+HauBfBr2t 7arQ== X-Gm-Message-State: AOAM533m93vQK3kS0RbuEnrSN4tQxthfDMsW4mMnA6lvG9nGhrCQ98Bz AxphRT0juBXYWETS0iWzsQORqA== X-Received: by 2002:a1c:f413:0:b0:37b:d1de:5762 with SMTP id z19-20020a1cf413000000b0037bd1de5762mr17267965wma.108.1649427374155; Fri, 08 Apr 2022 07:16:14 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id i3-20020adffc03000000b0020616ee90dbsm11498849wrr.42.2022.04.08.07.16.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Apr 2022 07:16:13 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 22/41] hw/intc/arm_gicv3: Implement GICv4's new redistributor frame Date: Fri, 8 Apr 2022 15:15:31 +0100 Message-Id: <20220408141550.1271295-23-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220408141550.1271295-1-peter.maydell@linaro.org> References: <20220408141550.1271295-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marc Zyngier Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The GICv4 extends the redistributor register map -- where GICv3 had two 64KB frames per CPU, GICv4 has four frames. Add support for the extra frame by using a new gicv3_redist_size() function in the places in the GIC implementation which currently use a fixed constant size for the redistributor register block. (Until we implement the extra registers they will RAZ/WI.) Any board that wants to use a GICv4 will need to also adjust to handle the different sized redistributor register block; that will be done separately. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- hw/intc/gicv3_internal.h | 21 +++++++++++++++++++++ include/hw/intc/arm_gicv3_common.h | 5 +++++ hw/intc/arm_gicv3_common.c | 2 +- hw/intc/arm_gicv3_redist.c | 8 ++++---- 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h index 8d58d38836f..9720ccf7507 100644 --- a/hw/intc/gicv3_internal.h +++ b/hw/intc/gicv3_internal.h @@ -489,6 +489,27 @@ FIELD(VTE, RDBASE, 42, RDBASE_PROCNUM_LENGTH) /* Functions internal to the emulated GICv3 */ +/** + * gicv3_redist_size: + * @s: GICv3State + * + * Return the size of the redistributor register frame in bytes + * (which depends on what GIC version this is) + */ +static inline int gicv3_redist_size(GICv3State *s) +{ + /* + * Redistributor size is controlled by the redistributor GICR_TYPER.VLPIS. + * It's the same for every redistributor in the GIC, so arbitrarily + * use the register field in the first one. + */ + if (s->cpu[0].gicr_typer & GICR_TYPER_VLPIS) { + return GICV4_REDIST_SIZE; + } else { + return GICV3_REDIST_SIZE; + } +} + /** * gicv3_intid_is_special: * @intid: interrupt ID diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3_common.h index 08b27789385..40bc404a652 100644 --- a/include/hw/intc/arm_gicv3_common.h +++ b/include/hw/intc/arm_gicv3_common.h @@ -38,7 +38,12 @@ #define GICV3_LPI_INTID_START 8192 +/* + * The redistributor in GICv3 has two 64KB frames per CPU; in + * GICv4 it has four 64KB frames per CPU. + */ #define GICV3_REDIST_SIZE 0x20000 +#define GICV4_REDIST_SIZE 0x40000 /* Number of SGI target-list bits */ #define GICV3_TARGETLIST_BITS 16 diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c index dcc5ce28c6a..18999e3c8bb 100644 --- a/hw/intc/arm_gicv3_common.c +++ b/hw/intc/arm_gicv3_common.c @@ -295,7 +295,7 @@ void gicv3_init_irqs_and_mmio(GICv3State *s, qemu_irq_handler handler, memory_region_init_io(®ion->iomem, OBJECT(s), ops ? &ops[1] : NULL, region, name, - s->redist_region_count[i] * GICV3_REDIST_SIZE); + s->redist_region_count[i] * gicv3_redist_size(s)); sysbus_init_mmio(sbd, ®ion->iomem); g_free(name); } diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c index 7c75dd6f072..9f1fe09a78e 100644 --- a/hw/intc/arm_gicv3_redist.c +++ b/hw/intc/arm_gicv3_redist.c @@ -442,8 +442,8 @@ MemTxResult gicv3_redist_read(void *opaque, hwaddr offset, uint64_t *data, * in the memory map); if so then the GIC has multiple MemoryRegions * for the redistributors. */ - cpuidx = region->cpuidx + offset / GICV3_REDIST_SIZE; - offset %= GICV3_REDIST_SIZE; + cpuidx = region->cpuidx + offset / gicv3_redist_size(s); + offset %= gicv3_redist_size(s); cs = &s->cpu[cpuidx]; @@ -501,8 +501,8 @@ MemTxResult gicv3_redist_write(void *opaque, hwaddr offset, uint64_t data, * in the memory map); if so then the GIC has multiple MemoryRegions * for the redistributors. */ - cpuidx = region->cpuidx + offset / GICV3_REDIST_SIZE; - offset %= GICV3_REDIST_SIZE; + cpuidx = region->cpuidx + offset / gicv3_redist_size(s); + offset %= gicv3_redist_size(s); cs = &s->cpu[cpuidx];