Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3071710775EA for ; Wed, 18 Mar 2026 17:16:46 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w2uVd-0007OP-Rz; Wed, 18 Mar 2026 13:16:43 -0400 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 1w2uVa-0007NT-3k for qemu-arm@nongnu.org; Wed, 18 Mar 2026 13:16:38 -0400 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1w2uVY-0007Oc-7o for qemu-arm@nongnu.org; Wed, 18 Mar 2026 13:16:37 -0400 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-82a124f3a5bso150855b3a.0 for ; Wed, 18 Mar 2026 10:16:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1773854194; x=1774458994; darn=nongnu.org; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :from:references:cc:to:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=/Ru9uZ7RVjHY6f0f/wOmmSCBlhl3W/TsW1sGUtThduk=; b=dEyKaFGQW/LLBOSoCCCAvTNC8M/rGy4utDIUwkk2fpM3SdbU5N15i5bSYatL3IRyH8 7Ki7KhHfTXmN7rsxnaJK+uaH9BIbYJThpsSVBm5xWcp2b09t4VqwlaXo4wGQLqlIpA5m U72MGlhQJ4nOX1x5iIwJ48lV503H163m1/VxpZ4VxL695Jnzq2eENMufVqi4g67tvmBr keNAUuIcRy+ZNBrFEabu9Qzmmevt3WCcYr28CWHgKi4TSmlycVb1Hu5z2jVvZ82Tv3uj D0HcdH6v4i4sqVX3obnlNsRXSJOzrH0n8POVXvO+D+ylSLfchZVQKn1mOaVaTQgRuWgQ cuJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773854194; x=1774458994; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :from:references:cc:to:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=/Ru9uZ7RVjHY6f0f/wOmmSCBlhl3W/TsW1sGUtThduk=; b=WTExIAD2URcDBQctxqbyk3UZ78y3PJLKLi/yRr42y+c46LLUeO4K9nWOrsY4V73mf3 ZI19AZajC2UiRlrxb3SZFG6XSY7nQ7fWvKRjRg85hQRoDw8ixhNqhgYwE+NUQboERT2x jLu9XkfOrnvs6UNUnFDmRMdXFBy3RuSblQV7pLzWVs4zGWtJUVb63K6UtGLWdrdSgwLv 6g9jw/rAJ27QFfWMH/y2Q6TdGQMsB4wagNAKjY2PCcCB54X86tnak7KfECsg0kbDe2+n jRj7dd/1w52Ogtyb/ZRPj0KXTQVlzHmyGe/6gKVzXROjOscqzdI9XahCBBvAjln9YxVW o06g== X-Gm-Message-State: AOJu0YzNcjMSsPVIAU/LJmobk56D+LXeyIRdoEaKA6TzsxnEpgbhpq47 jSfKi9Sz4PnovUVLUzyZZ83mJq6enUtxogrQSJGRxpx0pPve2J/di2E1Sax18wLOpiU= X-Gm-Gg: ATEYQzyyrE4jSVc5SMWGtm0zbxlaIXC1uno2ofpvIhQ/7E0+vH3bWVXxC/DOPwkgVHm P1fclm7dxeUi1skHBCkQOHqdZgpMzNQAysHqrPxAtk9a3LeXyw/kdZdIUeUmAkWJ8aC/7m22IRd BfS624XeIGph4Xo7ExAxtllp/V1CwuqyvNqFyapHzEMbi3qz+sny/JLvlxiE/H8/JmuM2fo/mZC ZRcILc+uVbuqECJzflxlnUhZzMhbNe3sBtP69p0CapkGs5MZ9yXQQ5Y+wg3XZ9SEbqXiKcwffLQ Tzd5gR+xqMOL+/IbKsJfsP+LAMr8mJsY+C2shlvvsxq026/x8JUDS6wO3PIlPldqpNZ+KsMNG39 LbGL6c+v1ApDSkT0vSk32lH53vxAsaieDeEEYjtWWUh3oOICYicRRQZetfRfeEHXBz6EofIy6ZL Ffha1uyNDWkon2BNGwFbMWLf2GCWh+1z5VAtZziNc2t1iyggPc7wuHc1rptRk0I+3ZAxfSSWPnp c4AG3I= X-Received: by 2002:a05:6a00:66d9:b0:82a:6de8:fa4d with SMTP id d2e1a72fcca58-82a6de8fc37mr2928570b3a.14.1773854193976; Wed, 18 Mar 2026 10:16:33 -0700 (PDT) Received: from [192.168.1.87] (216-71-219-44.dyn.novuscom.net. [216.71.219.44]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82a6bbb2f41sm3117178b3a.33.2026.03.18.10.16.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Mar 2026 10:16:33 -0700 (PDT) Message-ID: <4e8f4e6e-e9d2-4457-af3d-755ced6d2a45@linaro.org> Date: Wed, 18 Mar 2026 10:16:32 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH 0/9] plugins: Introduce Fault Injection framework and API extensions To: Ruslan Ruslichenko , qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, artem_mygaiev@epam.com, volodymyr_babchuk@epam.com, alex.bennee@linaro.org, peter.maydell@linaro.org, philmd@linaro.org, Ruslan_Ruslichenko@epam.com References: <20260318104640.239752-1-ruslichenko.r@gmail.com> From: Pierrick Bouvier Content-Language: en-US Autocrypt: addr=pierrick.bouvier@linaro.org; keydata= xsDNBGK9dgwBDACYuRp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i9KzGXJO82O9gW 5SYuJaKzCAgNeAy3gUVUUPrUsul1oe2PeWMFUhWKrqko0/Qo4HkwTZY6S16drTMncoUahSAl X4Z3BbSPXPq0v1JJBYNBL9qmjULEX+NbtRd3v0OfB5L49sSAC2zIO8S9Cufiibqx3mxZTaJ1 ZtfdHNZotF092MIH0IQC3poExQpV/WBYFAI= In-Reply-To: <20260318104640.239752-1-ruslichenko.r@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=2607:f8b0:4864:20::432; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pf1-x432.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-arm@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-arm-bounces+qemu-arm=archiver.kernel.org@nongnu.org Sender: qemu-arm-bounces+qemu-arm=archiver.kernel.org@nongnu.org Hi Ruslan, On 3/18/26 3:46 AM, Ruslan Ruslichenko wrote: > From: Ruslan Ruslichenko > > This patch series is submitted as an RFC to gather early feedback on a Fault Injection (FI) framework built on top of the QEMU TCG plugin subsystem. > > Motivation > > Testing guest operating systems, hypervisors (like Xen), and low-level drivers against unexpected hardware failures can be difficult. > This series provides an interface to inject faults dynamically without altering QEMU's core emulation source code for every test case. > > Architecture & Key Features > > The series introduces the core API extensions and implements a fault injection plugin (contrib/plugins/fault_injection.c) targeting AArch64. > The plugin can be controlled statically via XML configurations on boot, or dynamically at runtime via a UNIX socket (enabling integration with automated testing frameworks via Python or GDB). > > New Plugin API Capabilities: > > MMIO Interception: Allows plugins to hook into memory_region_dispatch_read/write to modify hardware register reads or drop writes. > Asynchronous Timers: Exposes QEMU_CLOCK_VIRTUAL to plugins, allowing callbacks to be scheduled based on guest virtual time. > TB Cache Flushing: Exposes qemu_plugin_flush_tb_cache() so plugins can force re-translation when applying dynamic PC-based hooks. > Interrupt & Exception Injection: Exposes APIs to raise/pulse hardware IRQs on the primary INTC and inject CPU exceptions (e.g., SErrors). > Custom Device Faults: Introduces a registry where device models (e.g., SMMUv3) can expose specific fault handlers (like CMDQ errors) to be triggered externally by plugins. > > Patch Summary > Patch 1 (target/arm): Adds support for asynchronous CPU exception injection. > Patch 2-3 (plugins/api): Exposes virtual clock timers and TB cache flushing to the public plugin API. > Patch 4 (plugins): Introduces the core fault injection subsystem, IRQ/Exception routing, and the Custom Fault registry. > Patch 5 (system/memory): Adds the MMIO override hooks into the memory dispatch path. > Patch 6 (hw/intc): Registers the ARM GIC (v2/v3) with the plugin subsystem to enable direct hardware IRQ injection. > Patch 7 (hw/arm): Registers the SMMUv3 with the custom fault registry to demonstrate how device models can expose specific errors (like CMDQ faults) to plugins. > Patch 8 (contrib/plugins): Implements the actual fault_injection plugin using the new APIs. > Patch 9 (docs): Adds documentation and usage examples for the plugin. > > Request for Comments & Feedback > > Any suggestions on improvements, potential edge cases, or issues with the current design are highly welcome. > > Ruslan Ruslichenko (9): > target/arm: Add API for dynamic exception injection > plugins/api: Expose virtual clock timers to plugins > plugins: Expose Transaction Block cache flush API to plugins > plugins: Introduce fault injection API and core subsystem > system/memory: Add plugin callbacks to intercept MMIO accesses > hw/intc/arm_gic: Register primary GIC for plugin IRQ injection > hw/arm/smmuv3: Add plugin fault handler for CMDQ errors > contrib/plugins: Add fault injection plugin > docs: Add description of fault-injection plugin and subsystem > > contrib/plugins/fault_injection.c | 772 ++++++++++++++++++++++++++++++ > contrib/plugins/meson.build | 1 + > docs/fault-injection.txt | 111 +++++ > hw/arm/smmuv3.c | 54 +++ > hw/intc/arm_gic.c | 28 ++ > hw/intc/arm_gicv3.c | 28 ++ > include/plugins/qemu-plugin.h | 28 ++ > include/qemu/plugin.h | 39 ++ > plugins/api.c | 62 +++ > plugins/core.c | 11 + > plugins/fault.c | 116 +++++ > plugins/meson.build | 1 + > plugins/plugin.h | 2 + > system/memory.c | 8 + > target/arm/cpu.h | 4 + > target/arm/helper.c | 55 +++ > 16 files changed, 1320 insertions(+) > create mode 100644 contrib/plugins/fault_injection.c > create mode 100644 docs/fault-injection.txt > create mode 100644 plugins/fault.c > first, thanks for posting your series! About the general approach. As you noticed, this is exposing a lot of QEMU internals, and it's something we tend to avoid to do. As well, it's very architecture specific, which is another pattern we try to avoid. For some of your needs (especially IRQ injection and timer injection), did you consider writing a custom ad-hoc device and timer generating those? There is nothing preventing you from writing a plugin that can communicate with this specific device (through a socket for instance), to request specific injections. I feel that it would scale better than exposing all this to QEMU plugins API. For SMMU, this is trickier. Tao recently (6ce361b02c82) an iommu test device, associated to qtest to unit test the smmu implementation. We could maybe see to leverage that on a full machine, associated with the communication method mentioned above, to generate specific operations at runtime, all triggered via a plugin. Exposing qemu_plugin_flush_tb_cache is a hint we are missing something on QEMU side. Better to fix it than expose this very internal function. The associated TRIGGER_ON_PC is very similar to existing inline operations. They could be enhanced to support writing to a given register, all the bricks are there. For TRIGGER_ON_SYSREG it's a bit more complex, but we might enhance inline operations also to support hooks on specific register writes. For MMIO override, the current approach you have is good, and it's definitely something we could integrate. What are you toughts about this? (especially the device based approach in case that you maybe tried first). Regards, Pierrick