From nobody Mon Feb 9 07:56:33 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1737443306; cv=none; d=zohomail.com; s=zohoarc; b=NvWvixexA1KrwrPNmSBAyHAhuttmwIimSk4l+wyokz1EpxwXOf8NGbPe0oP1zsBgO1QHY+Q2E2tjblzMmVIiQRDjiTpXYnNNwennrr307Onj7yUyiVQUQi5vm5pHfO6SElNIxbdkH6jl4xyyNGTNaeu05SVBDc9bGadycWoc6NI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1737443306; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=PLYT51RZdOdgFNVJk+NhS53LGVij9r+kYrpKRx00+IQ=; b=JBj9oXACLEN3WbHUQKjyEu/RfCkV046wBJFxwl/YTVmmkqfx357AsC4/dmpufYbZdHzGvNtQw1KChT/m/AbST1hYtOVvZGrAQDOhKvKEju6lUIcm5k5dFhj23qiPo/VeWXHAIkYB5Wzji1TdhSR4UyoK+DKd44lCLgWO14SDoWg= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1737443306097611.9588829458847; Mon, 20 Jan 2025 23:08:26 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ta8Ju-0006ki-4c; Tue, 21 Jan 2025 02:05:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ta8Jl-0006gf-C4; Tue, 21 Jan 2025 02:04:58 -0500 Received: from mail.aspeedtech.com ([211.20.114.72] helo=TWMBX01.aspeed.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ta8Jj-0001Q8-RO; Tue, 21 Jan 2025 02:04:57 -0500 Received: from TWMBX01.aspeed.com (192.168.0.62) by TWMBX01.aspeed.com (192.168.0.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Tue, 21 Jan 2025 15:04:26 +0800 Received: from localhost.localdomain (192.168.10.10) by TWMBX01.aspeed.com (192.168.0.62) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Tue, 21 Jan 2025 15:04:26 +0800 To: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Peter Maydell , Steven Lee , Troy Lee , Andrew Jeffery , "Joel Stanley" , "open list:ASPEED BMCs" , "open list:All patches CC here" CC: , , Subject: [PATCH v1 04/18] hw/intc/aspeed: Support setting different memory and register size Date: Tue, 21 Jan 2025 15:04:10 +0800 Message-ID: <20250121070424.2465942-5-jamin_lin@aspeedtech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250121070424.2465942-1-jamin_lin@aspeedtech.com> References: <20250121070424.2465942-1-jamin_lin@aspeedtech.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=211.20.114.72; envelope-from=jamin_lin@aspeedtech.com; helo=TWMBX01.aspeed.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_FAIL=0.001, SPF_PASS=-0.001 autolearn=ham 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: , Reply-to: Jamin Lin From: Jamin Lin via Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1737443307969019000 Content-Type: text/plain; charset="utf-8" According to the AST2700 datasheet, the INTC0 (CPU DIE) controller has 16KB (0x4000) of register space, and the INTC1 (I/O DIE) controller has 1KB (0x4= 00) of register space. Introduced a new class attribute "mem_size" to set different memory sizes f= or the INTC models in AST2700. Introduced a new class attribute "reg_size" to set different register sizes= for the INTC models in AST2700. Signed-off-by: Jamin Lin --- hw/intc/aspeed_intc.c | 17 +++++++++++++---- include/hw/intc/aspeed_intc.h | 4 ++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/hw/intc/aspeed_intc.c b/hw/intc/aspeed_intc.c index 219ca02940..25035c65ca 100644 --- a/hw/intc/aspeed_intc.c +++ b/hw/intc/aspeed_intc.c @@ -118,10 +118,11 @@ static uint64_t aspeed_2700_intc0_read(void *opaque, = hwaddr offset, unsigned int size) { AspeedINTCState *s =3D ASPEED_INTC(opaque); + AspeedINTCClass *aic =3D ASPEED_INTC_GET_CLASS(s); uint32_t addr =3D offset >> 2; uint32_t value =3D 0; =20 - if (addr >=3D ASPEED_INTC_NR_REGS) { + if (offset >=3D aic->reg_size) { qemu_log_mask(LOG_GUEST_ERROR, "%s: Out-of-bounds read at offset 0x%" HWADDR_PRIx "= \n", __func__, offset); @@ -144,7 +145,7 @@ static void aspeed_2700_intc0_write(void *opaque, hwadd= r offset, uint64_t data, uint32_t change; uint32_t irq; =20 - if (addr >=3D ASPEED_INTC_NR_REGS) { + if (offset >=3D aic->reg_size) { qemu_log_mask(LOG_GUEST_ERROR, "%s: Out-of-bounds write at offset 0x%" HWADDR_PRIx = "\n", __func__, offset); @@ -301,10 +302,16 @@ static void aspeed_intc_realize(DeviceState *dev, Err= or **errp) AspeedINTCClass *aic =3D ASPEED_INTC_GET_CLASS(s); int i; =20 + memory_region_init(&s->iomem_container, OBJECT(s), + TYPE_ASPEED_INTC ".container", aic->mem_size); + + sysbus_init_mmio(sbd, &s->iomem_container); + memory_region_init_io(&s->iomem, OBJECT(s), aic->reg_ops, s, - TYPE_ASPEED_INTC ".regs", ASPEED_INTC_NR_REGS <<= 2); + TYPE_ASPEED_INTC ".regs", aic->reg_size); + + memory_region_add_subregion(&s->iomem_container, 0x0, &s->iomem); =20 - sysbus_init_mmio(sbd, &s->iomem); qdev_init_gpio_in(dev, aspeed_intc_set_irq, aic->num_ints); =20 for (i =3D 0; i < aic->num_ints; i++) { @@ -357,6 +364,8 @@ static void aspeed_2700_intc0_class_init(ObjectClass *k= lass, void *data) aic->num_lines =3D 32; aic->num_ints =3D 9; aic->reg_ops =3D &aspeed_2700_intc0_ops; + aic->mem_size =3D 0x4000; + aic->reg_size =3D 0x2000; } =20 static const TypeInfo aspeed_2700_intc0_info =3D { diff --git a/include/hw/intc/aspeed_intc.h b/include/hw/intc/aspeed_intc.h index 9a73661403..d881cb7088 100644 --- a/include/hw/intc/aspeed_intc.h +++ b/include/hw/intc/aspeed_intc.h @@ -25,6 +25,8 @@ struct AspeedINTCState { =20 /*< public >*/ MemoryRegion iomem; + MemoryRegion iomem_container; + uint32_t regs[ASPEED_INTC_NR_REGS]; OrIRQState orgates[ASPEED_INTC_NR_INTS]; qemu_irq output_pins[ASPEED_INTC_NR_INTS]; @@ -40,6 +42,8 @@ struct AspeedINTCClass { uint32_t num_lines; uint32_t num_ints; const MemoryRegionOps *reg_ops; + uint64_t mem_size; + uint64_t reg_size; }; =20 #endif /* ASPEED_INTC_H */ --=20 2.34.1