From nobody Mon Nov 23 04:34:28 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1793019470; cv=none; d=zohomail.com; s=zohoarc; b=bADo3Dhi47MmSYBQWizkJecW6GsHZ1Rxod97nyh1x/4pwp6JpXyxqgOn0Ewqe3K7vveVkm4DVS/OobVbyDVfToxZ/QGAP4ASoI/+rJhab7ywtvdPUwnbO2HNzIAqrnmgueGR50V5/bS6ACwvLZBvPaiBOIqtZN3vSF/XiDvlR3I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793019470; h=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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Go2SlSxJgFJMJitrfP75bb+tTb1pQf8ohmULLsU/JQE=; b=f+jbEkMG9wyY4N3MsNc/93qIeUZW6+iRJcb1pQY7raBoOomKvWbJo6m4qgRoGBK7tH9aMXOr9ncD6K/3GfPh3B2Tjo5ZpLxCBiqJcHrX5E6xMCLCiJa5++fEIWtAtN6EzZ40NPYxHcdtFzIlCFhB0K1OXFdMrcL+R7NRuV5BoQQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793019469941741.0411117128837; Mon, 26 Oct 2026 05:57:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xLKGB-0004Xd-Lj; Mon, 26 Oct 2026 08:57:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xLKG4-0004Wa-RR for qemu-devel@nongnu.org; Mon, 26 Oct 2026 08:57:02 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xLKG2-0002ZQ-Uy for qemu-devel@nongnu.org; Mon, 26 Oct 2026 08:57:00 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4a60f9474c4so10242895e9.0 for ; Mon, 26 Oct 2026 05:56:58 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e3ecd8c05sm20740192f8f.49.2026.10.26.05.56.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2026 05:56:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1793019417; x=1793624217; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Go2SlSxJgFJMJitrfP75bb+tTb1pQf8ohmULLsU/JQE=; b=luGXzujGuRk3sZk93nf2Cb2fGg400LJBimy0DLg6DPP1AcqTI71816aJ1E0jWB/rLq 2u0OYHRDOjdni9F/9WOy9/mVbLQ5O9W/Nx1RmxYal4PhK1lN0Hcwlw/i6F8iOcm+yguY 3Zyn/fbnxyVLLBd/YmW3ioI+/3WttoyAA5FfJDAGuxOAdOEykairgw3GoTjoRCNPc0aX PJW8C9JF1JFBo5122XySUXWCrrxtUTPHCJI+lMI0riTq/o80HxpZqY/O4v+oEdwcx6yA XrvTvWQiwY3fCgdvo8grzHLKT679fsDhjHBXeRj6GM714WkPTaJxS0xWwdd2WRKe3Qp8 g04w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793019417; x=1793624217; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=Go2SlSxJgFJMJitrfP75bb+tTb1pQf8ohmULLsU/JQE=; b=MjdH8hVozFiX9sxojxc9q0a51P0uLk3ENmI8Dbm7YqJ3gq5h0QYs8r9oLaPcGZAZxn SGaTe7jnFKccugFcZ2ZjiAuCRnK3CjWN+XypPEf6hY7jLGfJTWxEMxcpQ7MGvuuTJN4V gJh+Q7H/N7ZrzqEhZxXF7bhrA9UdRMzYbu/EuGpXxSECcoVVn4as+t05XHeFKQtQbDUV y98HeXUGThwcHX7VlxEciOU3nmhYliqs/5vFf3/fjoXEDNd6wtJC4BULIKRESXdtv2LI grQ7Ot34HjMQ9+t7NJzeurPgxSeGJAayjQCJvk81Fdxp8/Qj04rCs3QWAZqFkC4L6xiu WMoA== X-Gm-Message-State: AFq9FYIX3oybx0104lPQG71HIvkF1FNT6qhXmgfROoDc+po4cpRFCu7j 5elyDrx5BABCTUUuBbNeuRLXOQtueD+AD9vcEKX2q84CqvaV7ThKMospcjOsco5g6D8Q1D/tOJy 4xgFWzOo= X-Gm-Gg: AYBFou3oO4UDJdqgQAZ3q3NgYLaN+Ej3bj+4bJqQYVgz8ifiufIAMqYShnPtCYiAetM 4OyasJ0RKivwS1NfKGaH4a5Oj7uLoIpR0bpZcIe41UgyyaSNZ9whANsTEUCQQng2wIQ3iWmdIIa x2dBnQldpQnrNYKFrO71wjfdeta7m52FG2DCRTCI/yeVzRIfZJ+IV7VmMVd2cdM0eOHzgiTho6Y Db3WnRTvtv4jy+kS2E37C12PBnH0u551HB+np+1DKtPAVxIJ2Aj09IjkRZScqscTGrR5gnI4pgf XinPbH+bjs4sKH1dYtTgI7KtTmL/7z3G3XaN/wl8Lw5Eozintn0KvUK/GxE0kLZjsmEC3tEEPdr oVeyucpQ8wJ9GS0vFXN2YOB+kwr2HsIs47IXEuZWhy2WGoVbM1fbvaf9mDzQ1QpIFR31Op81rAp oX2guQkpMPc3fyJsPDvgU+2iZu/1+R9dZlHdqvnA9n4qbuzA2q7OJo5RafaDEmazX3wGZu0h4UG NVHGFIolFY7KOxb2YTG3L7KdAcSdIHDk0/uPS6KEqow/Zfj1CmwDB8FpgRWWVZwmsOTCq++i+dU +BTwTNgZ7oogMffAbyHrs+b+10+ke+hd+McP1LRtgba+qVJOfZR8m40xljyq X-Received: by 2002:a05:600c:a318:b0:4a3:5aee:2c25 with SMTP id 5b1f17b1804b1-4a35aee2cfdmr91609605e9.31.1793019417365; Mon, 26 Oct 2026 05:56:57 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: Fabiano Rosas , Laurent Vivier , Paolo Bonzini Subject: [PATCH 1/3] system/qtest: Avoid fixed-size irq_levels array for IRQ intercept Date: Mon, 26 Oct 2026 12:56:53 +0000 Message-ID: <20261026125655.2668658-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261026125655.2668658-1-peter.maydell@linaro.org> References: <20261026125655.2668658-1-peter.maydell@linaro.org> 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32b.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 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1793019471082158500 Content-Type: text/plain; charset="utf-8" The current implementation of the irq_intercept_out and irq_intercept_in commands uses a fixed-size static irq_levels[] array to track the state of the intercepted IRQ lines. This is sized at MAX_IRQ =3D=3D 256, which is smaller than some real device models use (for instance the GICv2 on the virt board has 384 inputs). A test that tried to intercept the inputs to such a device and then assert an interrupt over 255 would overrun the array. Reimplement the IRQ interception so that it allocates an array of the required size rather than using a static one. Signed-off-by: Peter Maydell Reviewed-by: Fabiano Rosas --- system/qtest.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/system/qtest.c b/system/qtest.c index 47c954838dd..a3de815ce65 100644 --- a/system/qtest.c +++ b/system/qtest.c @@ -57,12 +57,18 @@ static DeviceState *irq_intercept_dev; static FILE *qtest_log_fp; static QTest *qtest; static GString *inbuf; -static int irq_levels[MAX_IRQ]; static GTimer *timer; static bool qtest_opened; static void (*qtest_server_send)(void*, const char*); static void *qtest_server_send_opaque; =20 +typedef struct IrqInterceptState { + int *irq_levels; + int num_irqs; +} IrqInterceptState; + +IrqInterceptState irq_intercept_state; + #define FMT_timeval "%.06f" =20 /** @@ -327,9 +333,10 @@ void qtest_sendf(CharFrontend *chr, const char *fmt, .= ..) =20 static void qtest_irq_handler(void *opaque, int n, int level) { - if (irq_levels[n] !=3D level) { + assert(n >=3D 0 && n < irq_intercept_state.num_irqs); + if (irq_intercept_state.irq_levels[n] !=3D level) { CharFrontend *chr =3D &qtest->qtest_chr; - irq_levels[n] =3D level; + irq_intercept_state.irq_levels[n] =3D level; qtest_sendf(chr, "IRQ %s %d\n", level ? "raise" : "lower", n); } @@ -353,6 +360,13 @@ static void qtest_install_gpio_out_intercept(DeviceSta= te *dev, const char *name, *disconnected =3D qdev_intercept_gpio_out(dev, icpt, name, n); } =20 +static void qtest_init_irq_intercept(int num_irqs) +{ + g_free(irq_intercept_state.irq_levels); + irq_intercept_state.irq_levels =3D g_new0(int, num_irqs); + irq_intercept_state.num_irqs =3D num_irqs; +} + static void qtest_process_command(CharFrontend *chr, gchar **words) { const gchar *command; @@ -413,12 +427,14 @@ static void qtest_process_command(CharFrontend *chr, = gchar **words) /* NULL is valid and matchable, for "unnamed GPIO" */ if (g_strcmp0(ngl->name, words[2]) =3D=3D 0) { int i; + qtest_init_irq_intercept(ngl->num_out); for (i =3D 0; i < ngl->num_out; ++i) { qtest_install_gpio_out_intercept(dev, ngl->name, i= ); } interception_succeeded =3D true; } } else { + qtest_init_irq_intercept(ngl->num_in); qemu_irq_set_observer(ngl->in, qtest_irq_handler, ngl->num_in); interception_succeeded =3D true; @@ -861,8 +877,10 @@ static void qtest_event(void *opaque, QEMUChrEvent eve= nt) * used. Injects an extra reset even when it's not used, and * that can mess up tests, e.g. -boot once. */ - for (i =3D 0; i < ARRAY_SIZE(irq_levels); i++) { - irq_levels[i] =3D 0; + if (irq_intercept_state.irq_levels) { + for (i =3D 0; i < irq_intercept_state.num_irqs; i++) { + irq_intercept_state.irq_levels[i] =3D 0; + } } =20 g_clear_pointer(&timer, g_timer_destroy); --=20 2.43.0 From nobody Mon Nov 23 04:34:28 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1793019485; cv=none; d=zohomail.com; s=zohoarc; b=DP04jeLrBsd5b2KrMdnF3vrYNlfwidLWcV+vKbNa79+8g0Ua85cS3NHbi0jhyQboreyQNWDqQUga+Y5IIydORkaT1q0269bhbFuCl5Djawnlh9xE/GNgoNhJxH+dPEsJUuGHARi1YHN66hjk3gu1WVc+nPlIhaWJxqc1+CE5iJk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793019485; h=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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=YqC37BnXWYn0wl68fxd9YvdQoJH72rEKgw5+PMMfz1Y=; b=VHj3GugJRjZGs4lVkMnwMppHr7b255FtPqJolJhzYekx9weBMAArwLKIKjpdttcHjS0hyKePnwqHzopIezKmSGazvCGEY1lSkV9s3RYoVt1ZM55Id39PuSL/wyiAU0ILvIt6hinCS8IvEHBJMg6YibP+RxG1Hjv2L05h7FeMRWA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793019485058155.99131457884528; Mon, 26 Oct 2026 05:58:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xLKGE-0004Xm-43; Mon, 26 Oct 2026 08:57:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xLKG5-0004Wb-QY for qemu-devel@nongnu.org; Mon, 26 Oct 2026 08:57:02 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xLKG3-0002Zh-M6 for qemu-devel@nongnu.org; Mon, 26 Oct 2026 08:57:01 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4a140e7405dso30064755e9.3 for ; Mon, 26 Oct 2026 05:56:59 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e3ecd8c05sm20740192f8f.49.2026.10.26.05.56.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2026 05:56:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1793019418; x=1793624218; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=YqC37BnXWYn0wl68fxd9YvdQoJH72rEKgw5+PMMfz1Y=; b=R1Jmai4FQwkEI4DIZuVKiUAqtlPGgs3Tb8ErehQu1wPR01bnUt5anH3QRRqS1777xw B2WumFlMfB00zZR08AlNFrtnnBAsjA+FJrjE9GMVff4LjenLzbMIxT+fiFc/KY1yiQbI vqQM9/8JEptw4W+v0XR6LIPMp52pVQCuop+oEhfqcoj9afPCdh0gzls3ltBFmE0Fkdwr nAnoyVTBiRv0ADtiD6BUdzaTR1A2F7RAiCqbp6j5zMl3nlztv5nwvN4rXNhrfu+3Aoir 02XgQppd6FAskemLKrQHxeSM5VQZ0NKAE66yHoIdY8Tkgwu0W26aYNo61wSlPac1ir3J kx5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793019418; x=1793624218; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=YqC37BnXWYn0wl68fxd9YvdQoJH72rEKgw5+PMMfz1Y=; b=X6J6K8Pu+EkCH/6w6ifNJqqoUSoQkZIZTxLXSLKE/8+Ro8DDZ3T773OLH7qRUvo5QL RN6plojen7PJoyh7Brtdd84QgvZm0b6gsOt5rVrO1pz9vmTaFb1bWd9IMcmidT9Ku35g Ys1LOHK/vIakvoNWvTfCFsya7aZNc9xXYbStiKSe7aDjPEXuuqkz5iZMSc3WfjJ+0obk hcBtJB+6Z/m94LEmG9SXdum1F60rh5fX39aOuo8UpKLa3dmXkjRZZO9W8EuPBz7HG2+R VPaMuh/Z7wtZQGZ2Lfp5z+C2At8ykdr9PgVzl3wht6qM80TCLOqRHQ/1YTFfcmAzoY/j PL4A== X-Gm-Message-State: AFq9FYKsRf6xT47NtL0GryvHjR+cpJT45Qu1DDjmIkI2HMilFg/G5gdV 0KN2i/ZdzZ4iHscUGwFeZHHhBFONnyeef3NCumth1UEdic9XGtoDhQDfJxw5ZN0ZqoL7siZPhGe kKDH1EL4= X-Gm-Gg: AYBFou3Ub4z/tq/LUcb0bMVL2f0/GnQGvV/MEy+kJBcYk9/KfECf+il7kXJuehuQ0Zc S28oibfpf6F2pLI1LhYdBZzPjNR2VouZJEEYd7hfnWNYE7bF4NV+KH8Kg8Ot6CrgybIZWa2oCCr CgFDUy37yGAJv47MHlFUqRDfEtauuVCqh7bp6RQ6V28JK2RnNDOZIvkx0WDH/20Ro5reRa2qg6r uUNRHXcZtcxPoGfhDbje0KPmYyJDvLOo2/sSqSCMV8JmemohyUu/F8hUu9p6/tU+dLOieNOg9Ku p0TNMYrvylYQtjQKOqSMPrtD3Qn2uhmuty0C2WCbXvcj13zr0Q6688hJfLCE0nfX2BjBnFqp/FR 93dzhAC181IyUgxDs+P55AP0/53pruKshXGIR2RpSmcLvs/Mx7fzZJthD+h+P6EENzrS6DDL/1S 0TWBoG2QmHq1no8kC0aViQVfndM5QRo3U5dHf4q1old8PQe5pzcfY+iVs9bCng3/dWZ39snhiZs ja65fdGxD13EZVQJgLTqUIjHkMUypLm+7Kucv98ZeBq2fxMA2YUjHNXmnQdoWJM0xadQCoKaa6Q ez9IecRAdOZ/sw0JaeHxoGdKeA3HdN3fAztqm+NUT9HnavTkuXyRg4y24K2r X-Received: by 2002:a05:600c:5246:b0:4a0:eae0:769a with SMTP id 5b1f17b1804b1-4a35ace0486mr128569835e9.28.1793019418259; Mon, 26 Oct 2026 05:56:58 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: Fabiano Rosas , Laurent Vivier , Paolo Bonzini Subject: [PATCH 2/3] system/qtest: Check ngl->name for irq_intercept_in Date: Mon, 26 Oct 2026 12:56:54 +0000 Message-ID: <20261026125655.2668658-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261026125655.2668658-1-peter.maydell@linaro.org> References: <20261026125655.2668658-1-peter.maydell@linaro.org> 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32b.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 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1793019487348158500 Content-Type: text/plain; charset="utf-8" Currently we check the name of the NamedGPIOList when doing irq_intercept_out, but not for irq_intercept_in. Even though we don't currently support irq_intercept_in on named GPIO lines, we still need to check the name, because otherwise we will install the observer on every set of GPIO inputs the device has, rather than only for the unnamed GPIO inputs. This doesn't currently affect any test cases, because of all the tests which use irq_intercept_in only tests/qtest-l2vic-test.c uses it on a device that creates named GPIO inputs. That device has both unnamed GPIO inputs and a named GPIO input "reset". The effect is that a change in the "reset" line state looks like a change in interrupt input line 0; but since the test doesn't cause "reset" to change this doesn't happen and there are no observable effects of the bug. Check the ngl->name against the specified one for both input and output interception. (Currently this will be equivalent to a check against NULL for input intercepts.) As we're now checking for an exact name match unconditionally, we can break out of the loop as soon as we've found it. Signed-off-by: Peter Maydell Reviewed-by: Fabiano Rosas --- The forbidding of intercept_in for named GPIOs is done before the loop. I think the only reason we forbid it is that we don't have a mechanism for the "IRQ raise"/"IRQ lower" messages to say what GPIO they're for. Similarly I don't think supporting intercepts of multiple devices simultaneously would be too hard; but I'd rather wait til we have a test that actually wants that functionality. --- system/qtest.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/system/qtest.c b/system/qtest.c index a3de815ce65..5ff3f9f27d8 100644 --- a/system/qtest.c +++ b/system/qtest.c @@ -422,23 +422,24 @@ static void qtest_process_command(CharFrontend *chr, = gchar **words) } =20 QLIST_FOREACH(ngl, &dev->gpios, node) { - /* We don't support inbound interception of named GPIOs yet */ + /* NULL is valid and matchable, for "unnamed GPIO" */ + if (g_strcmp0(ngl->name, words[2]) !=3D 0) { + continue; + } + if (is_outbound) { - /* NULL is valid and matchable, for "unnamed GPIO" */ - if (g_strcmp0(ngl->name, words[2]) =3D=3D 0) { - int i; - qtest_init_irq_intercept(ngl->num_out); - for (i =3D 0; i < ngl->num_out; ++i) { - qtest_install_gpio_out_intercept(dev, ngl->name, i= ); - } - interception_succeeded =3D true; + int i; + qtest_init_irq_intercept(ngl->num_out); + for (i =3D 0; i < ngl->num_out; ++i) { + qtest_install_gpio_out_intercept(dev, ngl->name, i); } } else { qtest_init_irq_intercept(ngl->num_in); qemu_irq_set_observer(ngl->in, qtest_irq_handler, ngl->num_in); - interception_succeeded =3D true; } + interception_succeeded =3D true; + break; } =20 if (interception_succeeded) { --=20 2.43.0 From nobody Mon Nov 23 04:34:28 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1793019470; cv=none; d=zohomail.com; s=zohoarc; b=IbCRHmJx7lKjD7+p2sgKRy4ALC9/OBiynnjmYHk9bf4LWyOOKI3ShVl9orUtqJaMDEPWe8lY1UgkWA5htlrYLG6+Ly/dO8JH8vI1RnNc+LKrDyszQ0cstl6pVYwIZC+MkTNmlcH19KmFvje5qKNw916zBArYv5U9aH75d3wFTe4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793019470; h=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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=aY84rM7uVtYYZDOMjGD+JkxdYBM6fj9mhrGf4jTcgBE=; b=anyCdSk7NUxWD/f6oLFtS53hpcvYklpYvI5yEzVLXpPsuu2sx/WUC3K8w+p8TBnxlzq9OT5reeHyKwLYPNLuEcdG/QgHYSkGRDVXumXOHhEBkekHrUvi96IN/Oc+hpWxddazbUqF2ULM2RornC8ZHK4iz+ab8w+3c/8O/gT3nMo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793019470067507.8830313390779; Mon, 26 Oct 2026 05:57:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xLKGE-0004Y2-OF; Mon, 26 Oct 2026 08:57:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xLKG6-0004Wq-E9 for qemu-devel@nongnu.org; Mon, 26 Oct 2026 08:57:04 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xLKG4-0002Zs-RB for qemu-devel@nongnu.org; Mon, 26 Oct 2026 08:57:02 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4a20bde60a0so24822065e9.3 for ; Mon, 26 Oct 2026 05:57:00 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e3ecd8c05sm20740192f8f.49.2026.10.26.05.56.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2026 05:56:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1793019419; x=1793624219; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=aY84rM7uVtYYZDOMjGD+JkxdYBM6fj9mhrGf4jTcgBE=; b=L3d6gvUmKoNrrfIKdgkiTc0k/Nhmi5ehd2ybwiE7bEmjp+GLOtaA/c2Ev6Z7Fqc6bk jpC2igG3uqRQ5mV8NJGaGQjWoPh5mEx4RyrVq6HszRmUcgfJJTpdOnaosYb8aEAWVI/j 8XU4xPwiNUjlK+76cYRfb9issTxkqk1JcnjnsYqqTFc8pbXgE6Ox+6jgfTvujEmzb1ai lrZpQ9GyiGbslcLZCnVImuln18UIM9Ovj1ktzA67hi3XP7Jtuk/MvlSSRCRHb+CJF+RN t6gcIUh/SbH2HJeEyXhQCo64gRtKWijTuByG1Izlcto6HqywyVAqfyfJiJoA4rcRlfsA D6HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793019419; x=1793624219; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=aY84rM7uVtYYZDOMjGD+JkxdYBM6fj9mhrGf4jTcgBE=; b=mjYA05JO+CL/bSuQSVWGC5CkwGZUrNhY2MurPc+fJgAlvIU6mIwgNGaW+YuxdhCvOJ jzZHqAuLcG/OlDx4WHFqmQwKLGuq+iDKviP3M2eO0hF7tHz/aYJgkfzQ86Z1p70JBwxy 3mfjxNj8IuS6nj9yDSuly47vFVUrt/OM4g54ueJ45WtVwNNc/W+Ggom7tbpzEJRSKg/O 64V1kwqtr8pTnazte9Dg0xSazRvQTo+AU0yFgnnXcE46xRpeuUUf2SSG3CKRR6mlaj7b ZnqXIlGeoyfMG7DohNTxmOW3ukt6k4hiQS8UBPzLr8KaG+6UjByI8ee1QTBRBnLcajBU HtIQ== X-Gm-Message-State: AFq9FYJM4+7fXK29KqavGCgD1qr0vH7v4jHCUvbfZij6Q34Q1fDKxMNT abIUkHqdpreeny9D85IbTTLNgeFWqfllyw92SMr/D9YS5y2o6qb/QQksGDVIgycKaBCa8iO3NQT 23hKw9VE= X-Gm-Gg: AYBFou3gbBr7AS9E70JZOwgqcb2teWgsCAKOEAjIqZ1Lxq5Yp4u3nFgyw4aaZ90Rxwn JY+eCvygywFaNejYTALRmvSdtvCYoaBTXV1z+C72Im0X/YbkMQoxtFoQZCBV2ppKf9cW5jsl7cp 9Mrg0r2bKkckq+jKUuV3VcJxijpR2iOhXuTYcsKNaxYGnWVygtRsugRgIcdQ6girjc+Ol7mYcek 2DILeBnNPN1lMOJBK0kJElqg3+PwmKQ1IGQAarAiHUoAoxFCZcTDn6ID3GrrDmpRdJjY6JrDGg/ eNr8kg475XTye4W3zenIsQtDGbgIaPiJgKThK+y/LwJQXlIN/+MvMTi/f0z2qRlkX35GmWdVKPc oFhDEHVNsBFnlP5gwWPVvhsulj9pvWZ6cykkAwHtcY4tGLS3ZYo3HZK2k2f/sRdpM0cRvetFKZK jZzE3xqkPpNd/hQsK+7XTGBJVK5P5/GsysjLrg/CNpHP/OR8DYWY0lKhVAxgWcKuiHSWs4e6GRF 2zO4TTdwaHEiW2KVabO9fQD1DqmXKu5eefe0Fy7fnyQvKk3Y3dAlkv9ZiYy4x9AbShRqWlWpYL+ DS4eQatklaCoJxxS0UCIeZH9JfSJ8mn9hoClZ7cjVECdc7sjV+OD0v/7ri21 X-Received: by 2002:a05:600c:c101:b0:4a5:87a:50ba with SMTP id 5b1f17b1804b1-4a5087a51c5mr59882215e9.33.1793019419270; Mon, 26 Oct 2026 05:56:59 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: Fabiano Rosas , Laurent Vivier , Paolo Bonzini Subject: [PATCH 3/3] tests/qtest/libqtest: Use a GArray for QTestState::irq_level[] Date: Mon, 26 Oct 2026 12:56:55 +0000 Message-ID: <20261026125655.2668658-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261026125655.2668658-1-peter.maydell@linaro.org> References: <20261026125655.2668658-1-peter.maydell@linaro.org> 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x332.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 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1793019472978158500 Content-Type: text/plain; charset="utf-8" Currently we use a fixed irq_level[] array of 256 elements in QTestState to implement capturing the IRQ level reported by the QEMU under test so we can return it in qtest_get_irq(). This is smaller than is actually used by some devices, and if a test tries to intercept more IRQs than this and one is reported to libqtest then we'll fail an assertion in qtest_rsp_args(). Switch to a GArray, which automatically resizes as required. Signed-off-by: Peter Maydell Reviewed-by: Fabiano Rosas --- tests/qtest/libqtest.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index 9e7a2d43a18..22b0dc193c9 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -42,8 +42,6 @@ #include "qobject/qstring.h" #include "qobject/qbool.h" =20 -#define MAX_IRQ 256 - #define ACCEPT_TIMEOUT_MS 250 #define ACCEPT_RETRIES (4 * 50) =20 @@ -88,7 +86,7 @@ struct QTestState #endif int expected_status; bool big_endian; - bool irq_level[MAX_IRQ]; + GArray *irq_level; GString *rx; QTestTransportOps ops; GList *pending_events; @@ -501,7 +499,7 @@ static QTestState *qtest_init_internal(const char *qemu= _bin, void *opaque) { QTestState *s; - int sock, qmpsock, i; + int sock, qmpsock; g_autofree gchar *socket_path =3D qtest_socket_path("sock"); g_autofree gchar *qmp_socket_path =3D qtest_socket_path("qmp"); g_autofree gchar *args =3D qtest_qemu_args(extra_args); @@ -525,9 +523,7 @@ static QTestState *qtest_init_internal(const char *qemu= _bin, qtest_client_set_tx_handler(s, qtest_client_socket_send); =20 s->rx =3D g_string_new(""); - for (i =3D 0; i < MAX_IRQ; i++) { - s->irq_level[i] =3D false; - } + s->irq_level =3D g_array_new(false, true, sizeof(bool)); =20 s->fd =3D -1; s->qmp_fd =3D -1; @@ -693,6 +689,7 @@ void qtest_quit(QTestState *s) close(s->fd); close(s->qmp_fd); g_string_free(s->rx, true); + g_array_unref(s->irq_level); =20 for (GList *it =3D s->pending_events; it !=3D NULL; it =3D it->next) { qobject_unref((QDict *)it->data); @@ -778,12 +775,14 @@ redo: ret =3D qemu_strtol(words[2], NULL, 0, &irq); g_assert(!ret); g_assert_cmpint(irq, >=3D, 0); - g_assert_cmpint(irq, <, MAX_IRQ); =20 + if (s->irq_level->len <=3D irq) { + g_array_set_size(s->irq_level, irq + 1); + } if (strcmp(words[1], "raise") =3D=3D 0) { - s->irq_level[irq] =3D true; + g_array_index(s->irq_level, bool, irq) =3D true; } else { - s->irq_level[irq] =3D false; + g_array_index(s->irq_level, bool, irq) =3D false; } =20 g_strfreev(words); @@ -1192,7 +1191,10 @@ bool qtest_get_irq(QTestState *s, int num) /* dummy operation in order to make sure irq is up to date */ qtest_inb(s, 0); =20 - return s->irq_level[num]; + if (s->irq_level->len <=3D num) { + return false; + } + return g_array_index(s->irq_level, bool, num); } =20 void qtest_module_load(QTestState *s, const char *prefix, const char *libn= ame) @@ -2100,9 +2102,7 @@ QTestState *qtest_inproc_init(QTestState **s, bool lo= g, const char* arch, qts->pending_events =3D NULL; *s =3D qts; /* Expose qts early on, since the query endianness relies = on it */ qts->wstatus =3D 0; - for (int i =3D 0; i < MAX_IRQ; i++) { - qts->irq_level[i] =3D false; - } + qts->irq_level =3D g_array_new(false, true, sizeof(bool)); =20 qtest_client_set_rx_handler(qts, qtest_client_inproc_recv_line); =20 --=20 2.43.0