From nobody Mon Nov 23 04:34:31 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=1794233178; cv=none; d=zohomail.com; s=zohoarc; b=OQAJNIP0YjXe4keXv0Kz7IPY71g8miK6EBmTYx4XhvRWrKo5MIUM1MVfOsq1L2NgdrVeE+fK/QJ3AXvbd/bTXpg42r/eM6cyp6PuTS9yGabgBZ5sWM4WJs2Po2VNjKIk/PmoXuhPHyLIJhJ6JTOI50jpUnf/HyRvoJp9FVayAPY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794233178; h=Content-Transfer-Encoding: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:Cc; bh=7yNu8ef/LhlDmPJ3xfJh3ZEtZik4Tro2+mKWpoGfMeU=; b=OtShQtboM9KNPX46AqfqLB2u7z0HgdrbnXBfKcIlELpn09CJVRpwVELf/N8izOymdW+fr+jxn4CLx+sVToECX5VjsP246t4VIzHnruBTeqj/D7LBEkqLmVJt/ViVOIy/N1r8V2Rr/tnvgU2XGZNMYke+5oZTb+zm+t2RQEzNoLM= 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 1794233178898879.6989165424529; Mon, 9 Nov 2026 06:06:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQQ0F-0007DY-W0; Mon, 09 Nov 2026 09:05:44 -0500 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 1xQQ01-00078u-Fx for qemu-devel@nongnu.org; Mon, 09 Nov 2026 09:05:31 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xQPzz-00088e-Pv for qemu-devel@nongnu.org; Mon, 09 Nov 2026 09:05:29 -0500 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4b467581b98so8574295e9.0 for ; Mon, 09 Nov 2026 06:05:27 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-49596ea51cbsm11184750f8f.27.2026.11.09.06.05.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2026 06:05:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1794233126; x=1794837926; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=7yNu8ef/LhlDmPJ3xfJh3ZEtZik4Tro2+mKWpoGfMeU=; b=JzUT9sgnSEEBPPIWEolTCRLmEBf3cv0kxomk7H5MMrbgOIPyuwHX9YBYrCU1rBUYKA CcZFQT6My/LmBCKGR+OS2Ap7FdQDHPEkcx9p6ha0F94/re0u1uGhsZU/e5zEg3VUOTz3 Mlue5VFNrYoK31JDciOKVSXXFvNzzsIkb/jX4vpwJKbfXIPyR5vXnh67tWuyz7Mu36ZS XKYTIKEW1u1aTooP7eniRlAXFsRzhxMHfQj1/dHy/JaME/fVlkAbwFOWihuiEoVBXE0V srhT2f6qMfehhg0//l7oXahtK6DUxmKIosO7QcmCvj/DEgVljcC98j1n+8qE0GSyxJ0L fuTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794233126; x=1794837926; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=7yNu8ef/LhlDmPJ3xfJh3ZEtZik4Tro2+mKWpoGfMeU=; b=sA9A89d74j8LncDC6vFAE+hWxIAXpEwEM6JVvpDmZ3VObY0e/i/4hPp4VA/tH/4P/A KVYK/qi3iKQoySfjFIuet8cA2WmLU/YpddjN/aVuPKwC6R7quNZXtaV5+2fp3EqHcVYG qOGODKVEc8NwRaqpzmJm0KvZ9OGvrygU0gsVkcH3/DP+EVapluiWOptROpG6ntK9EaLC g7AoCr1Lbd7SYFG62tokaqpMxyJJbCWVmrzHiNZ161yk0kcGVDxxWX9oCokBFzXtRFzI /T1/c8s9NLjPutLNqRlpP2ZwSZZYwgEK5r5eTRlNUNjpfor1uPx2Af8hxi7+pHCnr4vj 5t0A== X-Gm-Message-State: APuU4Z+hyb83FUvh4r3yHcgkuR/2nuZiskqMDo2GtGrIx4ypHrV9Y/mZ AptsRJH2awW3n5HZo7L7mPzH01os3/YslcfjP3+94YXDwSGpfkN6Auqs6V8x/IxgpkzvzKgTpPm WS0S+WmI= X-Gm-Gg: AYBFou3H8HT2E0wcDdhPrVb1B2SnZJfpI9F67vxrVLgm0q7q037LYTm1gfTKm8A/BIL 8xpAn5Zrp2RoV919AjYdGthr9NWM2N5EwFjUiWeKmiJdp29O+nDeJmH5Lg3VPddfMrS7A6Ne87+ zBK+YLiupFs7HTrHcXDP532LfgD8JqP4LuV9f+jSjtMOWl84qM7DALfxSqOEGFC66CvezZRo4lF lXryYKCyiK5cEjFmzdy2e64XSkozEerA0D8xAyxWBUIzUpyX43vzEdqyAYReKsu6romNN1/AIhb VlvGO1K2cQZsZwdrYfh1GPJonQVFHR3c23W4yAX5d2DFByYjyLxsNI6NJ7lIvRrAO3bowO+XKLi QMNpB4d9Thaw1yH9jBlg09HiRJa0JtP5pigpqtMYbDdRwYl2YSoSISnkKufq3t3WT9urgStWY+1 Q5D1uCrjDNJw6wlpgfsqHIizL2iAWt8l/paS7bfnmrekE4H9iHjOiia67R4GalKLKJRWSHW5FAi tlZRRjI+ksRCVwdA031hV9qh0uV5J/6AVej539+U3LJWElp3JmsR2S1PrvoSIhkZJDh5wxUpG3I AkPQxcd7GuW+3SjUySUO7sQ786SNtqrFDHiLn5DS7m3anMm4n59jbgfSk4RTw4Csa0fjJi5OFxD C3GO8QpEhzZMmKWsiWOuTcUjXPcmxQTFbh69CheEQeyKmFHqLlAUgle4= X-Received: by 2002:a05:600c:3494:b0:4b2:3c81:d1 with SMTP id 5b1f17b1804b1-4b960d9bbc6mr81259745e9.5.1794233126303; Mon, 09 Nov 2026 06:05:26 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 1/9] target/arm/ptw: check XN for ARMv6 in get_S1prot() Date: Mon, 9 Nov 2026 14:05:15 +0000 Message-ID: <20261109140523.240161-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261109140523.240161-1-peter.maydell@linaro.org> References: <20261109140523.240161-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::333; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x333.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: 1794233180342158500 Content-Type: text/plain; charset="utf-8" From: Manos Pitsidianakis The XN bits are supported in all ARMv6 and onward VMSA translation tables, but we were ignoring them unless the CPU was at least v7. For the ARM_FEATURE_V6 case, we retrieve the AP and XN bits in get_phys_addr_v6() but we don't check the XN bit in get_S1prot(). Since you can't validly get to get_S1prot() except via get_phys_addr_v6() or get_phys_addr_lpae(), we can remove the version check entirely and need not explicitly check for "v6 or better".. Change the `else if (arm_feature(env, ARM_FEATURE_V7))` check in get_S1prot() to plain `else`. Cc: qemu-stable@nongnu.org Fixes: d8e052b3876356 ("target-arm: get_phys_addr_lpae: more xn control") Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4367 Signed-off-by: Manos Pitsidianakis Message-id: 20261106-armv6-xn-check-v2-1-1291bb77a6c2@linaro.org Reviewed-by: Peter Maydell [PMM: tweaked commit message] Signed-off-by: Peter Maydell --- target/arm/ptw.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 2e67d02493b..e36d2ff9383 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -1595,7 +1595,7 @@ static int get_S1prot(CPUARMState *env, ARMMMUIdx mmu= _idx, bool is_aa64, if (regime_has_2_ranges(mmu_idx) && !is_user) { xn =3D pxn || (user_rw & PAGE_WRITE); } - } else if (arm_feature(env, ARM_FEATURE_V7)) { + } else { switch (regime_el(mmu_idx)) { case 1: case 3: @@ -1613,8 +1613,6 @@ static int get_S1prot(CPUARMState *env, ARMMMUIdx mmu= _idx, bool is_aa64, case 2: break; } - } else { - xn =3D wxn =3D 0; } =20 if (xn || (wxn && (prot_rw & PAGE_WRITE))) { --=20 2.43.0 From nobody Mon Nov 23 04:34:31 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=1794233178; cv=none; d=zohomail.com; s=zohoarc; b=PhOO8u8rcnwgJ1wQ4IIu/cWSUNBmSnLVOmLj562ZYG73fP9tKSWFPavRQY3A49HQSR3mk5KqIPuMCslznXVlOpNQ6XZLN7bEcO2X+aTaqV4IBg8ebZhvEYRE/53g/2nJvtpf8lfHLhUHuDgiHeOj2OJUEflLtTwxFTtEgp4P5Ao= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794233178; h=Content-Transfer-Encoding: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:Cc; bh=fvqo4j1st1siqJM53V2sV9pY5mo1jyQ0U3Yna1N4QZg=; b=j0T77HI+Y5X7fagzRAXHtMsahem61uUm/34YZd8U2cD1HQz92Yh1cniJSwG/FBf/nmJTtpMnnwJxNbC+aw0Vm0hIvbA17ETV6XT5ect45D+DEPOaNLzQC6tdVDrIuBh9qKUvNbsh3ZMwhdizjaj3AG1W7q6oYueaA1GmewJXmw4= 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 1794233178792755.5866721879562; Mon, 9 Nov 2026 06:06:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQQ0J-0007Ea-5N; Mon, 09 Nov 2026 09:05:48 -0500 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 1xQQ03-000797-D5 for qemu-devel@nongnu.org; Mon, 09 Nov 2026 09:05:31 -0500 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xQQ01-00088v-73 for qemu-devel@nongnu.org; Mon, 09 Nov 2026 09:05:31 -0500 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-490585eddfcso753556f8f.0 for ; Mon, 09 Nov 2026 06:05:28 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-49596ea51cbsm11184750f8f.27.2026.11.09.06.05.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2026 06:05:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1794233127; x=1794837927; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=fvqo4j1st1siqJM53V2sV9pY5mo1jyQ0U3Yna1N4QZg=; b=wZ7stuPZR72+56e/qBmwuMDsPz/UMoTm4x38/6QuJJ6M8TwQ9PvPDi1aRUjo2ZI/Ue ejQ8hy14tGgl6UYwyGKGJe3M2s5r98MmQFCBCmt99HHVK5DRbeHgvj0vJw3IoIFvnbzb EWHb5cUDNJQpplN9kjWFOt8DGb+vEMvZ2tnMEUe4fXvx6m8w+AZlVnAPWwNjPo4mN8Fo BKXuTXqfaH36Qk5QrN9vXBwQKfH4H3KwSiOBDkq90ZcJvx/OiFvJNO6q/o3XZF8IlIqg 23gflQscWutL906uy3cWGxj4KnGVJQUW3lmwJF99+vPfI2X8isni68hpRJdcEaWUqjqG yUQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794233127; x=1794837927; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=fvqo4j1st1siqJM53V2sV9pY5mo1jyQ0U3Yna1N4QZg=; b=u2dCOoxa6wzTlnTi64uynJbF9l/6OybscdpZheZ37Y9+G5qZL0G1E20pyNbCU9/TP/ piIFtMxQRCr/ycF6NjfYYRLeWo5geo8btihUHKD6zrX0zCD3gTa+DBBUDhkv5q7xPo90 B8G98FhBos3Wb81oJXOdnrDxNlOjbAsImG7zLCbCto22x1vTn1HK84pxJYvupWgE3ADA GQFvxozolpTdF5M5/MjscxspphjS0RUAmq9vJyOBzECJ2t4ERUdrwQL3xGuzXyiI73Bc I/kSe3Q9qj7Om+S15dFVYgvUm09hLZcod2NYqIJiRs0usg3J/ZByj1r8O5kHWHtKS9Ro brlQ== X-Gm-Message-State: APuU4Z8yS+fwFDGUbHucvBSoBVi9ToAQZvmXhfGgMdgzBvh8X2JoPCr2 8U0WBRlGDd6PCnigWzU2v95yuZcj8Z2p0qtoOZx0SfJUe2DNdCqvlFKFCkrh02uINr1ZQKTtRnP l/qanCdk= X-Gm-Gg: AYBFou1RNPOGsEYhUsbevLKhlUxrxbxlvgHMeVrDZwra/yf6FAdho8Qrpfr7H8jcFGA GJ8zweDUEssyfWc5mWzrCeVbT7Y1TndcIaslA7hT94WHstTOMjM6C5fbc3XseDbpdnBexecMbeg OLwYfVu0lCK8BR97cwfoXU1kfMo8r597gJeBhNfcO560u3ImWuVK+Af4EDL23xmQjJmie4kiLlS Oe3qDjbuDCleakeO80zd0C86k89MYbkbyM+h1V0qybJDcSHiaSzOidAKxG06rzEjx1BP7T0C5dG b+JuOkqIP2mb+PnlvQJEuhfIZ+vUbIstPl3kpJ5Onxn5pt+ZrN3Iu+z3kBVRbO8SZ66XcnhdKe8 C31RM/IqdyI67I8sfUxu2J18gSLWWhcRbgsyzV/bl0omjs9PkC1T1t/rDkYbOmjej3rtR2PrR+X sSpP38aFCZfqnjrAX4HZlmbmssZ12QbkKrMgormO/PhgNs985KyqLsAX5PL+Hi0NeDfFfsd4+bY ClJ8/2GIpiwVjtDTuLy+V5oeYasPp6r4ilpqIKbv0pNimJZ5xkOptbzDa9rrZ8xVVtXS3WAzTWC 3JD+9ioOINqvK9J9Ei9/V3SlpF3du0x05G2dMTe0XxKNvRmkuUNtMwzQKWNqmBsRHtlZXAyxI2E t/QoBKXQBgvIk7VUUjC69lBkkW+7BwzTnlA== X-Received: by 2002:a5d:5d06:0:b0:48e:d88:55e2 with SMTP id ffacd0b85a97d-4958c779a6dmr7686452f8f.42.1794233127447; Mon, 09 Nov 2026 06:05:27 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 2/9] hw/net/bcm2838_genet: wrap the TX consumer index at 16 bits Date: Mon, 9 Nov 2026 14:05:16 +0000 Message-ID: <20261109140523.240161-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261109140523.240161-1-peter.maydell@linaro.org> References: <20261109140523.240161-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::42a; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42a.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: 1794233180446158500 Content-Type: text/plain; charset="utf-8" From: Lorand Marton The producer and consumer indexes of a GENET DMA ring are 16-bit counters (Linux bcmgenet masks them with DMA_P_INDEX_MASK and DMA_C_INDEX_MASK). bcm2838_genet_tx() counted the consumer index up in a uint32_t and compared it with the 16-bit producer index, so the first transmit that crossed the wrap (consumer 0xfffe, producer 0x0001) never ended the loop: the device sent the ring's descriptors forever with the BQL held, and the guest and the monitor hung. A guest sending a sustained stream hung after about 65k descriptors on one ring. Wrap the index, and test a transmit across the wrap. Signed-off-by: Lorand Marton Reviewed-by: Marcelo Manzo Tested-by: Marcelo Manzo Message-id: 0bd9bd85fd70c12f7e9ad77ad92a0ac1a778a29e.1793613972.git.lorandm= arton.dev@gmail.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/net/bcm2838_genet.c | 4 +- tests/qtest/bcm2838-genet-test.c | 101 +++++++++++++++++++++++++++++++ tests/qtest/meson.build | 2 + 3 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 tests/qtest/bcm2838-genet-test.c diff --git a/hw/net/bcm2838_genet.c b/hw/net/bcm2838_genet.c index 53bba99b38a..557a8a96365 100644 --- a/hw/net/bcm2838_genet.c +++ b/hw/net/bcm2838_genet.c @@ -521,7 +521,9 @@ static uint64_t bcm2838_genet_tx(BCM2838GenetState *s, = unsigned int ring_index, } =20 num_descs++; - cons_index_fld++; + /* The indexes count modulo 2^16 */ + cons_index_fld =3D (cons_index_fld + 1) + & R_GENET_DMA_CONS_INDEX_INDEX_MASK; s->regs.tdma.descs[desc_index].length_status =3D FIELD_DP32(s->regs.tdma.descs[desc_index].length_status, GENET_RDMA_LENGTH_STATUS, OWN, 1); diff --git a/tests/qtest/bcm2838-genet-test.c b/tests/qtest/bcm2838-genet-t= est.c new file mode 100644 index 00000000000..393abd7da28 --- /dev/null +++ b/tests/qtest/bcm2838-genet-test.c @@ -0,0 +1,101 @@ +/* + * QTest testcase for the BCM2838 GENET DMA rings + * + * Frames go out over a socket netdev. The producer and consumer indexes + * of a ring count modulo 2^16. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qemu/bitops.h" +#include "qemu/bswap.h" +#include "libqtest.h" + +#define GENET_BASE 0xfd580000 + +#define RING_START_ADDR 0x14 +#define RING_END_ADDR 0x1c + +#define TDMA_DESC(i) (0x4000 + (i) * 12) +#define TDMA_RING(r) (0x4c00 + (r) * 0x40) +#define TRING_READ_PTR 0x00 +#define TRING_CONS_INDEX 0x08 +#define TRING_PROD_INDEX 0x0c +#define TDMA_RING_CFG 0x5040 +#define TDMA_CTRL 0x5044 +#define TSB_LEN 64 /* transmit status block */ + +#define DESCS_PER_RING 4 +#define BUF_SIZE 2048 +#define BUF_BASE 0x100000 +#define FRAME_LEN 60 + +static void genet_writel(QTestState *qts, uint32_t off, uint32_t val) +{ + qtest_writel(qts, GENET_BASE + off, val); +} + +static uint32_t genet_readl(QTestState *qts, uint32_t off) +{ + return qtest_readl(qts, GENET_BASE + off); +} + +/* Transmit across the wrap of the 16-bit consumer index */ +static void test_tx_index_wrap(void) +{ + const unsigned r =3D 0, n =3D 3; + const uint16_t first =3D 0xfffe; + uint8_t frame[FRAME_LEN] =3D { 0 }; + uint8_t pkt[4 + FRAME_LEN]; + int sv[2]; + QTestState *qts; + + g_assert_cmpint(socketpair(PF_UNIX, SOCK_STREAM, 0, sv), =3D=3D, 0); + qts =3D qtest_initf("-M raspi4b -nic socket,fd=3D%d,model=3Dbcm2838-ge= net", + sv[1]); + close(sv[1]); + + memset(frame, 0xff, 6); + stw_be_p(frame + 12, 0x88b5); + for (unsigned i =3D 0; i < n; i++) { + frame[14] =3D i; + qtest_memset(qts, BUF_BASE + i * BUF_SIZE, 0, TSB_LEN); + qtest_memwrite(qts, BUF_BASE + i * BUF_SIZE + TSB_LEN, frame, + sizeof(frame)); + /* SOP, EOP, buffer length */ + genet_writel(qts, TDMA_DESC(i), BIT(13) | BIT(14) | + (TSB_LEN + FRAME_LEN) << 16); + genet_writel(qts, TDMA_DESC(i) + 4, BUF_BASE + i * BUF_SIZE); + genet_writel(qts, TDMA_DESC(i) + 8, 0); + } + genet_writel(qts, TDMA_RING(r) + RING_START_ADDR, 0); + genet_writel(qts, TDMA_RING(r) + RING_END_ADDR, DESCS_PER_RING * 3 - 1= ); + genet_writel(qts, TDMA_RING(r) + TRING_READ_PTR, 0); + genet_writel(qts, TDMA_RING(r) + TRING_CONS_INDEX, first); + genet_writel(qts, TDMA_RING(r) + TRING_PROD_INDEX, first); + genet_writel(qts, TDMA_RING_CFG, BIT(r)); + genet_writel(qts, TDMA_CTRL, 1 | BIT(1 + r)); + + genet_writel(qts, TDMA_RING(r) + TRING_PROD_INDEX, + (uint16_t)(first + n)); + g_assert_cmphex(genet_readl(qts, TDMA_RING(r) + TRING_CONS_INDEX) & + 0xffff, =3D=3D, (uint16_t)(first + n)); + + for (unsigned i =3D 0; i < n; i++) { + g_assert_cmpint(recv(sv[0], pkt, sizeof(pkt), MSG_WAITALL), =3D=3D, + sizeof(pkt)); + g_assert_cmpuint(ldl_be_p(pkt), =3D=3D, FRAME_LEN); + g_assert_cmpuint(pkt[4 + 14], =3D=3D, i); + } + + qtest_quit(qts); + close(sv[0]); +} + +int main(int argc, char **argv) +{ + g_test_init(&argc, &argv, NULL); + qtest_add_func("/bcm2838-genet/tx-index-wrap", test_tx_index_wrap); + return g_test_run(); +} diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index ff4bf9528a7..79946960869 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -287,6 +287,8 @@ qtests_aarch64 =3D \ (config_all_devices.has_key('CONFIG_XLNX_ZYNQMP_ARM') ? ['xlnx-can-test'= , 'fuzz-xlnx-dp-test'] : []) + \ (config_all_devices.has_key('CONFIG_XLNX_VERSAL') ? ['xlnx-canfd-test', = 'xlnx-versal-trng-test'] : []) + \ (config_all_devices.has_key('CONFIG_RASPI') ? ['bcm2835-dma-test', 'bcm2= 835-i2c-test', 'bcm2835-ic-test'] : []) + \ + (config_all_devices.has_key('CONFIG_RASPI') and host_os !=3D 'windows' ? + ['bcm2838-genet-test'] : []) + \ (config_all_accel.has_key('CONFIG_TCG') and = \ config_all_devices.has_key('CONFIG_TPM_TIS_I2C') ? ['tpm-tis-i2c-test',= 'tpm-tis-i2c-swtpm-test'] : []) + \ (config_all_devices.has_key('CONFIG_ASPEED_SOC') ? qtests_aspeed64 : [])= + \ --=20 2.43.0 From nobody Mon Nov 23 04:34:31 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=1794233179; cv=none; d=zohomail.com; s=zohoarc; b=QrhrJaYTO9e5Gq9lIjnVP4P0i4+K0ZIN30S7oGWSFjk8Zrm8d8DUpNXQq0oPX7mwg0TKOpcojYzNbzVYNUAdYxjBd7SPF7JAJWf1ow5iprcFsOjQa4wMu7ak7PApM+N9UEQT8WKyk94uF8CNisyru07pDxcIfkh8tlfYqPiy2ps= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794233179; h=Content-Transfer-Encoding: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:Cc; bh=K1VpXi1GkQ+jQzC1G7NQ4jEaPlGXNS1VrziwNUDP5bw=; b=O5l8FJ/Wq/iOClhMZbqdTXNcMSGBaSsOMLw0ytCYble6nwcDVwKe4imGGPHDs01AmzDV/b+9AgGAwvTcSI0Rh7won34rWvn4pWHal0sIxBf6p0/GemHZurdOn+pVSAxzwx0F+4RSradQGkxhRjTvHIS2wrl/Q9QaKXyZ5HMCHaE= 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 1794233178956884.2526904939027; Mon, 9 Nov 2026 06:06:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQQ0O-0007K5-Vo; Mon, 09 Nov 2026 09:05:53 -0500 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 1xQQ04-00079k-Ny for qemu-devel@nongnu.org; Mon, 09 Nov 2026 09:05:34 -0500 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xQQ02-00089F-Dg for qemu-devel@nongnu.org; Mon, 09 Nov 2026 09:05:32 -0500 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4b7252a32c8so9540045e9.0 for ; Mon, 09 Nov 2026 06:05:30 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-49596ea51cbsm11184750f8f.27.2026.11.09.06.05.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2026 06:05:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1794233129; x=1794837929; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=K1VpXi1GkQ+jQzC1G7NQ4jEaPlGXNS1VrziwNUDP5bw=; b=cGlY1ctrOPTWz/xw7Rgqk7d4VJvM3JpwWrZCndeWStK9r8M35Jwv0mjbtpHgp6Keeq i7q/XYNgOL6bYCEOZAGJAsNdtpEefQbonDRUDIgi73jHNLWLkhxnIvOi0Usu9W668qRl +XfsOzw80sGFFf/NraNNuwSUKahahTq1wUcim0EPXZnGHcnHC+sk+OAgOT05ToeDFVRK dvCaJMHVwT6VkCWyUGhOiB+oB4+YTlHi7S9o7Yf7MQmS74HDRS/FiV4lduGtCD53ARby Ii80DOsg3Pqz2vR0GafMmjGZyCa/dfyFAKu7zC2QgaHwzXseRfyRiMsQ6pq3lnOou2f8 eSZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794233129; x=1794837929; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=K1VpXi1GkQ+jQzC1G7NQ4jEaPlGXNS1VrziwNUDP5bw=; b=p82fjLkXL2pCSJqbolOy58AoiDYuLCeeW5sqKoQPwRVyhgGQDcFwmrRxuy0v/uPvrK e0gmPX2y73TWMubhnQY6f1ZvoPoc+KpVyf9L+9le4lHNP3m28FCSa3KywslOxoYs2Qgu KMgDWcWp2NY71DJZCGY08rIXMOCqJexfMJbqk85gCM8osj7dHRd7ylsvYqzpPhhYmMMv jX1ZdEq7bT1MYSSq8qeT2PxmqdUYcqY1vM4hfhsWoha8ny55KS+tsihu9p+1duLyJq7c 0ZlkHGUACADWDkHJKZAzh+xUHOEjN8cYOq73pHrLkBqJTn1kOhaD2bbwn7pPXPPzk6Rf i01A== X-Gm-Message-State: APuU4Z9UNqV0nJrqWg0HQABpbqMbStpQYBFKmFAA+IB8Wc/C5Lug7l2n 4vfD/KP1bHJVupM36Lviqst9z516D5I+H222xBDSJhsHap6kYUaV5ARa3kdTXYaKS5JDN0fT3Ad KTS+fQ54= X-Gm-Gg: AYBFou2YsNdFAN2Fw4ac+52qQ3SEn4J6l95cHe/8bb31blaxmoP5FBznOFI66v20qGE E38ft77NP+lUxgUUl0JAlnViAJkOnHew5CmoDQA8TTWQSo8R2JztTdIvYKPnoqTolXAgsJlkC1X j/seTQ79qX8kVMe7zdsU0jUSUftNbf1ron0cJaLEXnYDpXjEGqVNWi4bQrdqZhGql9TqaXQJ+Kf 36JR6k4+2fC8k8t9HNo4wixdN8M9A2YnyYEJqaNwDnrEdLfTJPnikLMaCsECV9PaJ8a+TqNm4gp vyDrb05FQQChK1mck7mVrS5PS2VH7ny+yon+cy8HPihn2Pr5+arE8wvociYwI8aOSuiOxGP6cYm 65qrTKjPBB3CxgT/MXiZOQIZ1zRpO5ZplC2fe0Vzspj7VIrj1aUnXeAoMWUM4TS7Xx6lQMKaAfX 5aeWaKUGmBiyW4k3l94l3r3fQ/uxPOKOht/eX3uKJWap3cpu7FnIwMm3DsjgF6K0gjDYOnmOvaz v/aIteSnnjM41IHvfLclDEleO9dqEO6bsHE/mX5sR327Ep05m3wsda9LbKoNqCKAdPxojJg1TKU iK8bI4+aFKIdINLIzSijdpSdQryfP6SFwsrCVI/iugUvJRIia7AJj+dh3btLD87ORwmijXfePBA Z3LFmrgUPsvzSotjWbZ/UNl757IbHcNdIqA== X-Received: by 2002:a05:600c:4e87:b0:4a1:e69d:90e8 with SMTP id 5b1f17b1804b1-4b963c8e6e7mr72985425e9.22.1794233128608; Mon, 09 Nov 2026 06:05:28 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 3/9] hw/net/bcm2838_genet: hold RX frames while the ring is full Date: Mon, 9 Nov 2026 14:05:17 +0000 Message-ID: <20261109140523.240161-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261109140523.240161-1-peter.maydell@linaro.org> References: <20261109140523.240161-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::331; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x331.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: 1794233180456158500 Content-Type: text/plain; charset="utf-8" From: Lorand Marton bcm2838_genet_rdma() never looked at the consumer index of the RX ring: it wrote each frame to the next descriptor whatever the guest had read, so a burst longer than the ring (Linux bcmgenet gives the default ring 256 descriptors) overwrote frames the guest had not taken yet, and the producer index ran more than a ring ahead of the consumer index, which bcmgenet_desc_rx() does not expect. Count the free descriptors of the ring from its start and end addresses and the two indexes. When there are none, return 0 so that the net layer keeps the frame queued, and flush the queue when the guest writes the consumer index of an RX ring, as e1000 does on a write of RDT. If the ring fills inside a frame that takes several descriptors, stop there instead of writing past the consumer index. Real GENET drops such frames and counts them in the DISCARD_CNT field of the producer index; holding them costs no frame on a slow host and matches the other QEMU NICs. Test that a ring of 4 descriptors keeps 6 frames apart until the guest moves its consumer index. Signed-off-by: Lorand Marton Tested-by: Marcelo Manzo Message-id: fdaf96319d81b2b6602822fd5881a5b5a72e5daa.1793613972.git.lorandm= arton.dev@gmail.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/net/bcm2838_genet.c | 38 +++++++++++ tests/qtest/bcm2838-genet-test.c | 107 ++++++++++++++++++++++++++++++- 2 files changed, 143 insertions(+), 2 deletions(-) diff --git a/hw/net/bcm2838_genet.c b/hw/net/bcm2838_genet.c index 557a8a96365..92d550cb630 100644 --- a/hw/net/bcm2838_genet.c +++ b/hw/net/bcm2838_genet.c @@ -779,6 +779,13 @@ static void bcm2838_genet_write(void *opaque, hwaddr o= ffset, uint64_t value, FIELD_EX32(value, GENET_DMA_CTRL, EN)) { qemu_flush_queued_packets(ncs); } + /* The guest gave descriptors back to an RX ring */ + if (offset >=3D BCM2838_GENET_RDMA_RINGS && + offset < BCM2838_GENET_RDMA_RINGS + sizeof(s->regs.rdma.rings) && + (offset - BCM2838_GENET_RDMA_RINGS) % sizeof(BCM2838GenetRdmaRing) + =3D=3D BCM2838_GENET_RRING_CONS_INDEX) { + qemu_flush_queued_packets(ncs); + } bcm2838_genet_set_irq_default(s); bcm2838_genet_set_irq_prio(s); } @@ -823,6 +830,23 @@ static bool is_packet_multicast(const uint8_t *buf, si= ze_t size) return !!(buf[0] & 0x01); } =20 +/* + * Descriptors of an RX ring that the guest has handed back: the ring + * holds END - START + 1 of them, and PROD - CONS (modulo 2^16) are full. + */ +static unsigned bcm2838_genet_rdma_free_descs(BCM2838GenetRdmaRing *ring, + hwaddr start_index, + hwaddr end_index) +{ + uint16_t used =3D FIELD_EX32(ring->prod_index, GENET_DMA_PROD_INDEX, I= NDEX) + - FIELD_EX32(ring->cons_index, GENET_DMA_CONS_INDEX, I= NDEX); + + if (end_index < start_index || used > end_index - start_index) { + return 0; + } + return end_index - start_index + 1 - used; +} + static ssize_t bcm2838_genet_rdma(BCM2838GenetState *s, uint32_t ring_idx, const void *buf, size_t size) { @@ -855,6 +879,12 @@ static ssize_t bcm2838_genet_rdma(BCM2838GenetState *s= , uint32_t ring_idx, BCM2838_GENET_DMA_DESC_CNT - 1); return -1; } + + /* A full ring: keep the frame queued until the guest frees some */ + if (!bcm2838_genet_rdma_free_descs(ring, start_index, end_index)) { + return 0; + } + desc =3D &rdma->descs[write_index]; =20 desc->length_status =3D FIELD_DP32(desc->length_status, @@ -948,6 +978,14 @@ static ssize_t bcm2838_genet_rdma(BCM2838GenetState *s= , uint32_t ring_idx, desc =3D &rdma->descs[write_index]; ring->write_ptr =3D write_index * desc_word_size; ring->write_ptr_hi =3D ((hwaddr)write_index * desc_word_size) >> 3= 2; + + if (len < size && + !bcm2838_genet_rdma_free_descs(ring, start_index, end_index)) { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: RX ring %u full inside a frame\n", + __func__, ring_idx); + break; + } } =20 if (ring_idx =3D=3D BCM2838_GENET_DMA_RING_DEFAULT) { diff --git a/tests/qtest/bcm2838-genet-test.c b/tests/qtest/bcm2838-genet-t= est.c index 393abd7da28..35653773d1f 100644 --- a/tests/qtest/bcm2838-genet-test.c +++ b/tests/qtest/bcm2838-genet-test.c @@ -1,8 +1,8 @@ /* * QTest testcase for the BCM2838 GENET DMA rings * - * Frames go out over a socket netdev. The producer and consumer indexes - * of a ring count modulo 2^16. + * Frames come in and go out over a socket netdev. The producer and + * consumer indexes of a ring count modulo 2^16. * * SPDX-License-Identifier: GPL-2.0-or-later */ @@ -14,8 +14,16 @@ =20 #define GENET_BASE 0xfd580000 =20 +#define RDMA_DESC(i) (0x2000 + (i) * 12) +#define RDMA_RING(r) (0x2c00 + (r) * 0x40) +#define RING_WRITE_PTR 0x00 +#define RING_PROD_INDEX 0x08 +#define RING_CONS_INDEX 0x0c +#define RING_BUF_SIZE 0x10 #define RING_START_ADDR 0x14 #define RING_END_ADDR 0x1c +#define RDMA_RING_CFG 0x3040 +#define RDMA_CTRL 0x3044 =20 #define TDMA_DESC(i) (0x4000 + (i) * 12) #define TDMA_RING(r) (0x4c00 + (r) * 0x40) @@ -26,9 +34,11 @@ #define TDMA_CTRL 0x5044 #define TSB_LEN 64 /* transmit status block */ =20 +#define DEFAULT_RING 16 #define DESCS_PER_RING 4 #define BUF_SIZE 2048 #define BUF_BASE 0x100000 +#define STATUS_LEN 64 /* receive status block, then 2 bytes = */ #define FRAME_LEN 60 =20 static void genet_writel(QTestState *qts, uint32_t off, uint32_t val) @@ -41,6 +51,98 @@ static uint32_t genet_readl(QTestState *qts, uint32_t of= f) return qtest_readl(qts, GENET_BASE + off); } =20 +/* The default ring uses the first DESCS_PER_RING descriptors */ +static QTestState *genet_rx_init(int *fd) +{ + const unsigned r =3D DEFAULT_RING; + int sv[2]; + QTestState *qts; + + g_assert_cmpint(socketpair(PF_UNIX, SOCK_STREAM, 0, sv), =3D=3D, 0); + qts =3D qtest_initf("-M raspi4b -nic socket,fd=3D%d,model=3Dbcm2838-ge= net", + sv[1]); + close(sv[1]); + *fd =3D sv[0]; + + for (unsigned i =3D 0; i < DESCS_PER_RING; i++) { + genet_writel(qts, RDMA_DESC(i) + 4, BUF_BASE + i * BUF_SIZE); + genet_writel(qts, RDMA_DESC(i) + 8, 0); + } + genet_writel(qts, RDMA_RING(r) + RING_START_ADDR, 0); + genet_writel(qts, RDMA_RING(r) + RING_END_ADDR, (DESCS_PER_RING - 1) *= 3); + genet_writel(qts, RDMA_RING(r) + RING_WRITE_PTR, 0); + genet_writel(qts, RDMA_RING(r) + RING_BUF_SIZE, BUF_SIZE); + genet_writel(qts, RDMA_RING_CFG, BIT(r)); + genet_writel(qts, RDMA_CTRL, 1 | BIT(1 + r)); + return qts; +} + +static uint32_t prod_index(QTestState *qts, unsigned r) +{ + return genet_readl(qts, RDMA_RING(r) + RING_PROD_INDEX) & 0xffff; +} + +/* Send a broadcast frame into the socket netdev */ +static void send_frame(int fd, uint16_t ethertype, uint8_t byte14) +{ + uint8_t pkt[4 + FRAME_LEN] =3D { 0 }; + + stl_be_p(pkt, FRAME_LEN); + memset(pkt + 4, 0xff, 6); + stw_be_p(pkt + 4 + 12, ethertype); + pkt[4 + 14] =3D byte14; + g_assert_cmpint(send(fd, pkt, sizeof(pkt), 0), =3D=3D, sizeof(pkt)); +} + +/* The byte at 14 of the frame that descriptor I holds */ +static uint8_t rx_byte14(QTestState *qts, unsigned i) +{ + return qtest_readb(qts, BUF_BASE + i * BUF_SIZE + STATUS_LEN + 2 + 14); +} + +/* Wait up to MS milliseconds for the producer index of ring R to be N */ +static bool wait_prod_index(QTestState *qts, unsigned r, uint32_t n, + unsigned ms) +{ + gint64 end =3D g_get_monotonic_time() + ms * G_TIME_SPAN_MILLISECOND; + + do { + qtest_clock_step(qts, 100); + if (prod_index(qts, r) =3D=3D n) { + return true; + } + } while (g_get_monotonic_time() < end); + return false; +} + +/* A full RX ring keeps the next frames until the guest frees descriptors = */ +static void test_rx_ring_full(void) +{ + const unsigned n =3D DESCS_PER_RING + 2; + int fd; + QTestState *qts =3D genet_rx_init(&fd); + + for (unsigned i =3D 0; i < n; i++) { + send_frame(fd, 0x0800, i); + } + g_assert(wait_prod_index(qts, DEFAULT_RING, DESCS_PER_RING, 5000)); + /* the rest must not overwrite descriptors the guest has not read */ + g_assert(!wait_prod_index(qts, DEFAULT_RING, DESCS_PER_RING + 1, 500)); + for (unsigned i =3D 0; i < DESCS_PER_RING; i++) { + g_assert_cmpuint(rx_byte14(qts, i), =3D=3D, i); + } + + genet_writel(qts, RDMA_RING(DEFAULT_RING) + RING_CONS_INDEX, 2); + g_assert(wait_prod_index(qts, DEFAULT_RING, n, 5000)); + for (unsigned i =3D 0; i < n; i++) { + g_assert_cmpuint(rx_byte14(qts, i % DESCS_PER_RING), =3D=3D, + i < 2 ? i + DESCS_PER_RING : i); + } + + qtest_quit(qts); + close(fd); +} + /* Transmit across the wrap of the 16-bit consumer index */ static void test_tx_index_wrap(void) { @@ -96,6 +198,7 @@ static void test_tx_index_wrap(void) int main(int argc, char **argv) { g_test_init(&argc, &argv, NULL); + qtest_add_func("/bcm2838-genet/rx-ring-full", test_rx_ring_full); qtest_add_func("/bcm2838-genet/tx-index-wrap", test_tx_index_wrap); return g_test_run(); } --=20 2.43.0 From nobody Mon Nov 23 04:34:31 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=1794233319; cv=none; d=zohomail.com; s=zohoarc; b=dpqnsJ/byzt+q6VPPfpLFdfYW3egpdD/0xNvoO3e8woVNN3Q0/1iG4Koiqq+LOGw5YlLpocpqYZbU7tt8xhYIEmk20/VB0YnW5zJFWvwNoInd1tBydVczw/LvRLofB6LJNL/b5rhPOSlE7qAAw0Cds3dS/JSdvRb6vFPNvyNb2g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794233319; h=Content-Transfer-Encoding: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:Cc; bh=sE8yVpqQAzfmCUET0N5Sgrduw4EonoQvrMHIyBYOkRM=; b=MwAlINe+Xquw8pn9MBpeIKoevzpSAg3ZpnfSyvKY48+uiXa04IY5/a9it+UYN6M+88cFEdV6BHF47gxkYHbxxY/ACPvE9MMex2pFbBi0/i5AcslVMRSkBHcZfqB6NmpOf1roip/RcOSATo9s3Lfmlp+8mu6lDN9+rKpElxpsXZI= 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 1794233319427677.3471646737463; Mon, 9 Nov 2026 06:08:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQQ0Y-0007Q8-BJ; Mon, 09 Nov 2026 09:06:02 -0500 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 1xQQ06-0007A5-0U for qemu-devel@nongnu.org; Mon, 09 Nov 2026 09:05:37 -0500 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xQQ04-0008A4-8T for qemu-devel@nongnu.org; Mon, 09 Nov 2026 09:05:33 -0500 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-491aaed7565so560677f8f.2 for ; Mon, 09 Nov 2026 06:05:31 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-49596ea51cbsm11184750f8f.27.2026.11.09.06.05.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2026 06:05:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1794233130; x=1794837930; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=sE8yVpqQAzfmCUET0N5Sgrduw4EonoQvrMHIyBYOkRM=; b=j/MqKl/f3nwltTNoCAtcl2W9fnTcTWxBwPeazgK34PBBcTlwo4BEFEZr5BEWs2aGpA Fyv4PhnAVvJtIxEl93Xxxt7dHz/vfdNkxm0cdkSZhkNWFpyDTfK+7KIC4Voe56/8atRL Exkuq6mM++53r1g37pIP9WAmt33F4+SclPOXSjDzVoLi4s2UFFIfTknTI1rttPFj5Vas udMyrvkBzENaorVNUogKcK7+xDyV7b1QfVYwS9xyZiFQyL4n4yamwRWZ+juhItKO3ZLG rFFX9f9xp9E+wxBqoscGHOjs/l9gPAqb+uZN3+UPeWblrU+tOyRrCam+fs+dZL3QGo9p nS1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794233130; x=1794837930; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=sE8yVpqQAzfmCUET0N5Sgrduw4EonoQvrMHIyBYOkRM=; b=kx6EUNpXs42kTkG7roWt3tRf49755Kqkk0rRVyfqjQfIx4N84TeDuEgyplss/8faPe Hxl+T5fEhVtbztrGRTGCwNPdx4l+qvQsLQmO8CCi0xNDzGQOj+YCn1GVGtNA2WJEyH/S 1o5XUGPoWS4FgF8L+xdnCXLpX0rbsJZD4VjDR4zlv4lmUQfT6sDIsjcGINbrvnOGMQ5Y Ks5ZC7fi7HjCNfo2qSxpmsBr1e5lazBdfqfRToaO/uk5YL+JHUyTqSUkNxe7Qn8WFGPB 5RJ3hiJjZUvlgWYgJ/KIdf/3JZlAVaNkD4k5BpBWFjdlEii4FC9HinkZHYgOEpGwJ2be btMA== X-Gm-Message-State: APuU4Z9B53g85u1grOQDW3AmUZUVb0QvnaZj/a7qVdvvoKJ2Ys/aE1LB 6YvX/Hjesuq3H8j4RYoaWZt4lmIvxYunS02qOpPa+zhiMAA5ACp3ID+hbF2NniF6kPKPHPI3MJ6 cF2n/BQY= X-Gm-Gg: AYBFou3uM8JSqoKunodSr94IVBzWZCcYVS6zlpml4Afz3xeq0jn9yOKAA8POUh28thC 3iU+hDSiz9TBSvtko1gXzd13Tf8yJ3xhVSNl4fGWplBsrjQeDF0Tf7S8YT3Jl75YOlSFbBXNbKu wsAx992osut4IFjLiAULZ/jvEsCuhQIJLDncynogGLawi4ab2TWMnr0bQ4VcPz/YfC7K/ktTAwG DfYasuf8cyBC7Iyfc4pOqfq05uoMCCm0izlDVXCyDieaAAnJwh2IR0I6Wlly0HTuTr4Xe+hq7A3 Z0P11NuhsgvCixlHO4g0WywZXkOvJyfZJBbSsj0BZAHwwTe6zenj9qQwD9loHDlZEf3ceVf3Vfw yvi3ZKc8dejl1PAqtbJ6ppRacM6S7UwDED1cMhSx2IZpmstb8+sx6RPfn4SmtAV6fUoDri64GY6 iuTQA2oLtD/71MDr0R4uGlpMXqz8TM/FhBGdnGhttkISWDChegLWn72AxcNBxTBEN367npC9uiH kTYEnqfAFEGmiG+pumpB7rkgxJFNu3D0cnHaU1FOBVkJNkc7dIeT24gusPxeHP4QK9xewE57LmF SCm9VSrcFsck/P2GseqVQB+M0t54ryNG4bBOp9QrdsudzCxtb59Ih9jb7OcP2JsySQYFPbt54Oo jEEm4AoJVz2y7RSxwJdYUYNwNNYmXmCZx1vLLI2nZNPqjRPcMlzbI9Ec= X-Received: by 2002:a05:6000:2211:b0:493:d5f0:4e4c with SMTP id ffacd0b85a97d-49582e90293mr7688652f8f.23.1794233130170; Mon, 09 Nov 2026 06:05:30 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 4/9] hw/net/bcm2838_genet: fit the RX frame within the guest's buffer Date: Mon, 9 Nov 2026 14:05:18 +0000 Message-ID: <20261109140523.240161-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261109140523.240161-1-peter.maydell@linaro.org> References: <20261109140523.240161-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::42e; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42e.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: 1794233320603158500 Content-Type: text/plain; charset="utf-8" From: Marcelo Manzo The RX path clamped the payload copied into each descriptor only against the whole RING_BUF_SIZE register (whose upper half is the ring size, not a buffer length) and against the size of the rx_packet staging buffer. It did not account for the status block and 2 byte pad that precede the payload, nor for the 4 byte CRC that is added to the reported BUFLENGTH when CRC forwarding is enabled. The BUFLENGTH written to the descriptor could therefore exceed the buffer the guest supplied. Clamp the payload to the guest's buffer size minus the status block, pad and CRC. BUFLENGTH is then at most the buffer size, which is at most MAX_FRAME_SIZE, so it fits its 12 bit field by construction. (It cannot overflow today, because receive() drops frames larger than MAX_PACKET_SIZE, but nothing in the descriptor code made that obvious.) This also fixes a hang: with a buffer size of 0 the old code copied zero bytes per iteration and never made progress through the frame. Treat a buffer too small to hold any payload as a guest error and drop the frame. Resolves: Coverity CID 1690161 Signed-off-by: Marcelo Manzo Message-id: 20261104140058.24068-1-marcelomanzo@gmail.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/net/bcm2838_genet.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/hw/net/bcm2838_genet.c b/hw/net/bcm2838_genet.c index 92d550cb630..0d61980a0cf 100644 --- a/hw/net/bcm2838_genet.c +++ b/hw/net/bcm2838_genet.c @@ -902,15 +902,24 @@ static ssize_t bcm2838_genet_rdma(BCM2838GenetState *= s, uint32_t ring_idx, uint8_t *frame_buf =3D dma_buf + frame_off; =20 bool crc_fwd =3D FIELD_EX32(s->regs.umac.cmd, GENET_UMAC_CMD, CRC_= FWD); + const size_t crc_len =3D crc_fwd ? 4 : 0; size_t buflength; uint32_t prod_index; =20 - if (l > ring->ring_buf_size) { - l =3D ring->ring_buf_size; + /* + * The buffer holds the status block, the 2 byte pad, the payload + * and (with CRC forwarding) the CRC. buf_size is at most + * MAX_FRAME_SIZE, so the BUFLENGTH computed below always fits + * its 12 bit field. + */ + if (buf_size <=3D frame_off + crc_len) { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: RX buffer size %zu too small\n", + __func__, buf_size); + return -1; } - /* Never copy more than fits in rx_packet after the status block */ - if (l > sizeof(s->rx_packet) - frame_off) { - l =3D sizeof(s->rx_packet) - frame_off; + if (l > buf_size - frame_off - crc_len) { + l =3D buf_size - frame_off - crc_len; } =20 memcpy(frame_buf, buf + len, l); @@ -921,10 +930,7 @@ static ssize_t bcm2838_genet_rdma(BCM2838GenetState *s= , uint32_t ring_idx, GENET_RDMA_LENGTH_STATUS, EOP, !!(len >=3D size)); =20 - buflength =3D l + sizeof(BCM2838GenetXmitStatus) + 2; - if (crc_fwd) { - buflength +=3D 4; - } + buflength =3D frame_off + l + crc_len; =20 desc->length_status =3D FIELD_DP32(desc->length_status, GENET_RDMA_LENGTH_STATUS, --=20 2.43.0 From nobody Mon Nov 23 04:34:31 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=1794233320; cv=none; d=zohomail.com; s=zohoarc; b=ZVjk3Ext1xr7tx6mo9cQj2naXaLY/LpfqZfMqrZkqn+sB097Dnbel+MZWgA9iwvJnX/RLYa7PkV+gdGe/EPN/1LunTMtspU4HC5prH9dFIJBl/UMesh4AoCpyV3qwJDx1WS61+TMk8+Q8EbdNta0T0NCDSHbaPaBeSJ1fTASstw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794233320; h=Content-Transfer-Encoding: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:Cc; bh=u1p3xLhUQaiHmwfqrKKk2BE2A9rmOTSYS3imI80QnJo=; b=hImksmeeXmjFvdAaLAW/DqI/MTLIjUw7Vc+KVByJIHIr8bM9TCx7n4Q1OH0aO9oNYPEya+CHDclo3TUfgDCO55g1XUs0ZikPRIaEDvPjvObNZB72FWm+eXkm9ifOBc3uS8RNF68MWwghs6E3HUhruDncIDCHtZdoNu3lz0ihyXU= 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 1794233320599882.0619505146686; Mon, 9 Nov 2026 06:08:40 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQQ0M-0007Gq-8q; Mon, 09 Nov 2026 09:05:50 -0500 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 1xQQ07-0007AJ-Lx for qemu-devel@nongnu.org; Mon, 09 Nov 2026 09:05:38 -0500 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xQQ05-0008AI-FC for qemu-devel@nongnu.org; Mon, 09 Nov 2026 09:05:34 -0500 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-4919a880834so544886f8f.0 for ; Mon, 09 Nov 2026 06:05:32 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-49596ea51cbsm11184750f8f.27.2026.11.09.06.05.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2026 06:05:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1794233131; x=1794837931; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=u1p3xLhUQaiHmwfqrKKk2BE2A9rmOTSYS3imI80QnJo=; b=QD0pdU+20hNwJMw4Hjs0UNedNpEAqQQ9C7VseX95rgZ/oRBax1As3CV78Cmffn5Xdt wlYJGOSx9QyyV6e/Z8cy5GgaL8RpvsbkXEKZrcBHtwp3vLaFtq0pMwAuPhEIDEtAlLGJ C2fdqux4bSYtEBC4D+CXOw7bHT9yaxRimrZ9uzRy1CLQx+9uQW67veTJ1Zu0UC+IrHI0 +KRQ5awC0XpS6cpNCyHoIyuTZWWYGy3G8XDJVoTK456QB22lOydvQUEu/AkGYeV9PZwI q2uu1myYVucr/YI68kYq1ahklkk7ZkoOQZbExOCG1dJ7l2dlgFFTEaThr6OjvkYUObxL daqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794233131; x=1794837931; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=u1p3xLhUQaiHmwfqrKKk2BE2A9rmOTSYS3imI80QnJo=; b=209M0hxW69wVCwDLAg7XOD36yqyT7gEimxy6e88y0bEgvFl3CDGR7nDY1E8a1S5t35 SHlaOq82bKg9I+mcUE9fFuPvwkESBFciUHYrgn8x1EjAtx7EGb02DCUBoyUykDqBMlA/ bTMbo0WPNpDf4/Q6XG8G5Sqn2BX18eClXl6my+5+HIIj+cp2nf3MtrI1YTx/ZSL9QwY2 nsQJn+3ArVsnPf8oq0jnqPBt4eLvS8e0F76IXUW3ziftJp+VbsJ4lfgNlwHw8zd6Mldb 6t6jzMNhu1N81yieZs4Vy20vo5OzONEOzx9PFpagw4BJUxK1T0yQ7mqWdjGrLJZrQfwS CKNw== X-Gm-Message-State: APuU4Z/hurH0VsRZngV3o2LraKna5mYmsR1mGXPYMA1oJDQzLkoLsC+L 2XJm9IWHpVFQV9i+H9zhtM59wFUVpI+7UDnZmXxDte8fhub+U65XPdYrFU3u6P8coxEOeOT/Cfs yG2YlfRY= X-Gm-Gg: AYBFou32zy8u+74AaPBGmTtCEMmLcltIf8zxngjkDThTpWAgtSs69tfY/hKQC1RHyQQ QGn71RwfIFvsFPMdRyGXq9cy8j9piYdVqtkFTxfZORUcVRHqUkE0I0vbT5BjQpaFccomF0F6g8B LbWpY3xLJ8sU5WBgTab1D8zckEN0DCK4OVT734NmqxS02whvmQTz0o6dD6VZbjIsEQtjD+c6arZ vLvKJaRjilfs36e+5B32IoGBUeNmy4slEKF6gC1wTi5mEAIshq3969JrW+zxaYE0MQe1ztbut43 SInL6C2Tt1I99dYrGoDTvSNn7kC/vaSGMd2k99rrRe2tz2jbGQrULGbDiyv8qgvyfT4PzeBdhl1 +eA6sVnhNltvqaTRfhkk1ufE9BtN/txkc6Sz9KdLveMfqIcgJZHw4bCCc+yjbYl/0PYd6p/uDeD KPWam2t+/nznMTcIqAu5IgOrp+BVy9ZH+b+TyCn2iKHs9AD0rZC/HiVwVgI+C/OXx3Nldgsz2F0 z3NCBhszCJEvM6ZPRTj3p+gm66iN3x/sygf9lVXmhdxCXeK8MDuhciKswz+riC7mdujEj4knR/W VpYJqcjTduWQaNkChzz3q9tRia8sA8MC+ZejSOUgFauOvVQQS9uZynPG2BvSnC9cxfxnQBfSaAL UExHU15Jshgv6nEHHK1Rn14ZHd2zExdEzEDU= X-Received: by 2002:a5d:64c5:0:b0:48e:20ed:d5e7 with SMTP id ffacd0b85a97d-495897722d1mr8870381f8f.34.1794233131416; Mon, 09 Nov 2026 06:05:31 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 5/9] arm/cpu: fix GIC v3 flag for a64fx Date: Mon, 9 Nov 2026 14:05:19 +0000 Message-ID: <20261109140523.240161-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261109140523.240161-1-peter.maydell@linaro.org> References: <20261109140523.240161-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::42b; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42b.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: 1794233322598158500 Content-Type: text/plain; charset="utf-8" From: Ferdinand Schober The a64fx CPU model wrongfully set GIC bits in the processor feature register (ID_AA64PFR0). I traced this back to e31c70ac04001df5e540b79843834277e283fa71, where A64FX got added. This bit is supposed to get set conditionally in id_aa64pfr0_read, depending on whether or not a gicv3 is present, from what I can tell. Qemu picks gic-version=3D2 by default, while v3 gets advertised due to this= flag. Recent EDK2 firmware accesses ICC_SRE_EL2 in this case and crashes. Clear the GIC field, as the other CPU models do. Cc: qemu-stable@nongnu.org Fixes: e31c70ac0400 ("target-arm: Add support for Fujitsu A64FX") Signed-off-by: Ferdinand Schober Message-id: 20261103145254.1543907-1-schober@cs.fau.de Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/tcg/cpu64.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c index a6352e6307e..e46cdd31676 100644 --- a/target/arm/tcg/cpu64.c +++ b/target/arm/tcg/cpu64.c @@ -505,7 +505,8 @@ static void aarch64_a64fx_initfn(Object *obj) SET_IDREG(isar, REVIDR, 0); cpu->ctr =3D 0x86668006; cpu->reset_sctlr =3D 0x30000180; - SET_IDREG(isar, ID_AA64PFR0, 0x0000000101111111); /* No RAS Extensions= */ + /* No RAS Extensions, GIC filled in later */ + SET_IDREG(isar, ID_AA64PFR0, 0x0000000100111111); SET_IDREG(isar, ID_AA64PFR1, 0x0000000000000000); SET_IDREG(isar, ID_AA64DFR0, 0x0000000010305408); SET_IDREG(isar, ID_AA64DFR1, 0x0000000000000000); --=20 2.43.0 From nobody Mon Nov 23 04:34:31 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=1794233288; cv=none; d=zohomail.com; s=zohoarc; b=SDSTNdN2ikRnvX5jWN+nMVnhWiBz4zYkDNb07TiNMzXPWh5DHOeXDC5J5dP5acxIjYnSnujVv7fUutkEwOSTYq6ABzvskzAX5SuKxEQ9A7VgUOz0YUEPZg6RA7TGwO+OFk6lJ/+ntZ4HepaR34J7kh9c36IOy5cwSpMjTGqCvrE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794233288; h=Content-Transfer-Encoding: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:Cc; bh=FZAwqCiEl1W88wep/IFipCYSS4NkriudY1WvKjdITM0=; b=fi09UNUfCotpmAQwo7G38t7aEQ8CX3SReCdwpNnTRRyHTqrzIr6vr4POBwkCG8vThefKmknvM7kncX6LZJu+Kq9yfydWBPSA4P1OPPDN7J7n/qpdnQ61gkWQiaES1tZBHKtylBLDL9Aq+qy6Q7+b30gYYBSeFzxwGbR2ZvKe5p0= 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 1794233288470905.4080422700329; Mon, 9 Nov 2026 06:08:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQQ0N-0007J7-Oc; Mon, 09 Nov 2026 09:05:51 -0500 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 1xQQ09-0007AL-3p for qemu-devel@nongnu.org; Mon, 09 Nov 2026 09:05:39 -0500 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xQQ07-0008Ai-F1 for qemu-devel@nongnu.org; Mon, 09 Nov 2026 09:05:36 -0500 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-4a215e64962so10629575e9.1 for ; Mon, 09 Nov 2026 06:05:34 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-49596ea51cbsm11184750f8f.27.2026.11.09.06.05.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2026 06:05:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1794233133; x=1794837933; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=FZAwqCiEl1W88wep/IFipCYSS4NkriudY1WvKjdITM0=; b=P3oOnhd+JOcQCO79GO0zeHDdWOXMQSdFYkI/0P49SOQb9bdLDGXidWoROoKcdiNJaB Mk23J4/wUMLN8tly5XhEKjZ1I3q6x8QR9sWs7vILSs3XkOFm6JcbrOD8KuTjNRqdqEfO 892qrdMqA/bMexqa0VaHnHICP18A8higyZGeY7YmX9DbR5PvWlvA3A/LiZgS34ZAJC9e NuNXCuHJauXXbAm61RVzGvcnmW1HsLGUpkYhwu1iScqfd3kR3BOdlwK5NoHq9JQztaEk MxFv68O3k98x7vtjTkkWML37sjin90ofzx142UsaZHIzOOKNS866brRE8Pia072Y/0Of /d9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794233133; x=1794837933; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=FZAwqCiEl1W88wep/IFipCYSS4NkriudY1WvKjdITM0=; b=uTyCiuRB60DkjaqxnQjz2MrLAAekObx2TGHxzbntGSC8ierzOxdI3lAnEOFWsOb3Zx wM2ifQy4YZSQNp+d++0ppHd62qh/E7nh8XLDQWzLr9i6+oM9z00nj+5zfKynPxS6A1j0 60jCZ+ZXKUhgqYni01/yArGBd+uEy2mJ5OtAZGoiuc5M+VDkn2Z35qN4vxfOqnD95tvy fccLGpjVCtxmP94SUAlFD2LWhZmb4ApOq+0C1HHtsMPz7URcKh4fF5VyDXmp+npjYctm Cgpv3kvNmpKs4wuQCg652tAFl3K0I0EcEPx+5zh1fRV2in9aWxhEB5qn5Mu0iRWUX0LK Xo2g== X-Gm-Message-State: APuU4Z9YNd9qYLA/rgj0wi0deT+Qun30WrVz4OSCHkzGa3rLo5otGEL7 z32rqBis9v3xCqQZPdKHKyAM4xhin+FnqgjZBZVeu4Pqqm8JsjE2BGIfEETgk4g9+cRhiNE/jgE AokMXgEg= X-Gm-Gg: AYBFou1LIZCayohpPSZZHsZv6+XcwqVv4VZ3UUq/AnPX7VhiYvs5ewboCS+zXShz8vw JALERKqNrgEY5cUmjTLdqAg8rNKWA6Oski/PWOFoQ2qa5IG8Z7xXmEuNmMIaGK2CEj6TCLfFWMW RVQK15cqvMfEzWEniSKslk5SemJW+31PuNdovqOIO11pz4BVYDze4OAioDGad+7xuZditONgTqM v/FVOOdTXbG+0OsOnqHsP0NfzGNyd+qcgZkonwYWXTvpC6qQR1yuqfjJzZ2Z5nr6/mGkPjH3+VA zE5CwgjvkUBcdxpKcalUlYzCIMg6ZOgDEznwvZR+8kEWceAcsIpA+zuwK4GZfSMyJYWQPiC2IYA 4dh0QENA8UE/BHwLsx4OaLlNVNBHuTcT2bOJOihkGxYJIT8LHTwj7sExKQA0PBg0k/Qkw9ooOKe SQbNBNB0u06y38ufDoeXA7L8bx1WIy8R2LYO2nZ0nUMBYuQgXNYPaw6Q8pKJ/LZlGcvMvhILPtk EEkjhvswY3wM5xIBdDSGUEPw0DDp0J3C/gIKEQos5AZ3iH9PaxmEWb0Xcnlp2IG4O+JRlxU/mxj 8KcUG72V2jtoc2RmwpZGJk2XQ/MpXU6Fc6O1UHgGnCuUTfe4eN1lA9BJeveaMiZ5M2t14mpwu4k Tecx28B3wI99UplnNj/oEDCOkQTYKMGv80uhMjLisgrhHhgdH8dCaQkM= X-Received: by 2002:a05:600c:4e45:b0:4a1:e00b:a10b with SMTP id 5b1f17b1804b1-4b963c75f1bmr78416325e9.7.1794233132718; Mon, 09 Nov 2026 06:05:32 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 6/9] hw/intc/arm_gic: move num-priority-bits check Date: Mon, 9 Nov 2026 14:05:20 +0000 Message-ID: <20261109140523.240161-7-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261109140523.240161-1-peter.maydell@linaro.org> References: <20261109140523.240161-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::32a; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32a.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: 1794233290084158501 Content-Type: text/plain; charset="utf-8" From: Manos Pitsidianakis We check the num-priority-bits property for sane values in arm_gic_realize(), but the property is defined on the "common" superclass, so it is present also for TYPE_KVM_ARM_GIC. Currently this misplaced check is harmless, beacuse the KVM subclass never looks at the property value. However, we are about to make a change that will want to use the property value in code called from the common class's reset method. Move num-priority-bits property value check to the common class realize method, where it belongs. Suggested-by: Peter Maydell Signed-off-by: Manos Pitsidianakis Message-id: 20261106-gic_read_bpr_from_property-v2-2-9f096cce4814@linaro.org [PMM: rewrote commit message, moved patch before the change that it is a prerequisite for] Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/intc/arm_gic.c | 10 ---------- hw/intc/arm_gic_common.c | 10 ++++++++++ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c index 4d4b79e6f34..b60f1f630b0 100644 --- a/hw/intc/arm_gic.c +++ b/hw/intc/arm_gic.c @@ -2117,16 +2117,6 @@ static void arm_gic_realize(DeviceState *dev, Error = **errp) return; } =20 - if (s->n_prio_bits > GIC_MAX_PRIORITY_BITS || - (s->virt_extn ? s->n_prio_bits < GIC_VIRT_MAX_GROUP_PRIO_BITS : - s->n_prio_bits < GIC_MIN_PRIORITY_BITS)) { - error_setg(errp, "num-priority-bits cannot be greater than %d" - " or less than %d", GIC_MAX_PRIORITY_BITS, - s->virt_extn ? GIC_VIRT_MAX_GROUP_PRIO_BITS : - GIC_MIN_PRIORITY_BITS); - return; - } - /* This creates distributor, main CPU interface (s->cpuiomem[0]) and if * enabled, virtualization extensions related interfaces (main virtual * interface (s->vifaceiomem[0]) and virtual CPU interface). diff --git a/hw/intc/arm_gic_common.c b/hw/intc/arm_gic_common.c index 304d89cf562..a7c0763ab6a 100644 --- a/hw/intc/arm_gic_common.c +++ b/hw/intc/arm_gic_common.c @@ -233,6 +233,16 @@ static void arm_gic_common_realize(DeviceState *dev, E= rror **errp) */ s->num_lrs =3D 4; } + + if (s->n_prio_bits > GIC_MAX_PRIORITY_BITS || + (s->virt_extn ? s->n_prio_bits < GIC_VIRT_MAX_GROUP_PRIO_BITS : + s->n_prio_bits < GIC_MIN_PRIORITY_BITS)) { + error_setg(errp, "num-priority-bits cannot be greater than %d" + " or less than %d", GIC_MAX_PRIORITY_BITS, + s->virt_extn ? GIC_VIRT_MAX_GROUP_PRIO_BITS : + GIC_MIN_PRIORITY_BITS); + return; + } } =20 static inline void arm_gic_common_reset_irq_state(GICState *s, int cidx, --=20 2.43.0 From nobody Mon Nov 23 04:34:31 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=1794233179; cv=none; d=zohomail.com; s=zohoarc; b=DY5wuiEo4iCaIwiVdw4s8g0Ik/Y1O1X/6mDhtligdaYaeWUE5KHqAWrYWKkQg6lwLnKHcVCuj1eJQT8XyRC2a0YtNQJX/CevEEw6/R2V4MogI1AKEGwHowkXEYdhepXJ3TBV3pVU5hk85KYRm9VX63WuBw54D55loPwwhZjizPw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794233179; h=Content-Transfer-Encoding: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:Cc; bh=K0N5mXlXkvLuRoO3ciD/U4zuNV7Lwc6MUcZnwB0Wneo=; b=PiTgi36KJeZoYAT8WizdmLRKWOGi8FlGwEEJTWMjLuNaV5D2H5LuKfZTG++B7TbN+6ssqlURHjOpHO7vGUsfDsSqSaALhk2Bqz/HqBxF7aqPxpCgtCzmiRTzdNN9/n2SDovUaBZ1O9L1W0e/uvknY6Qv7zXdDeEyUL0OzfO+W0Q= 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 1794233178963815.6315767326995; Mon, 9 Nov 2026 06:06:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQQ0Q-0007Lq-On; Mon, 09 Nov 2026 09:05:56 -0500 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 1xQQ09-0007AX-9u for qemu-devel@nongnu.org; Mon, 09 Nov 2026 09:05:39 -0500 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xQQ07-0008B4-F8 for qemu-devel@nongnu.org; Mon, 09 Nov 2026 09:05:37 -0500 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-490f38e9688so742997f8f.0 for ; Mon, 09 Nov 2026 06:05:35 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-49596ea51cbsm11184750f8f.27.2026.11.09.06.05.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2026 06:05:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1794233134; x=1794837934; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=K0N5mXlXkvLuRoO3ciD/U4zuNV7Lwc6MUcZnwB0Wneo=; b=Iyc3XG+zgEKZav5Y+BfeENeybQVBjCOI2LNTo0+knvohO2b/iWWvfdXvR/avFKx1xP ryESoxaJ7fx3z/AuTyXTWjoY9QjhoFTddINNFSjOjYjFKE7jSUtUgfFdb2hb0bG8awZo tBMuQhlSLlNdVVH5hpEBYGAYWJiSk/8xNCelwTq1/1ssFKs1NLCZBrdqz3GuM/cD0fct YtxJFzjDtd/7ShIuOBDlI436PhBoajdfqo6+UNG+B2f7hsUhylTRrdvOyH+k0ADq8TKA NNSJNaCoUdqUFotBFT2d2/GSpOX74J7YndypB1hoBlA4+fFKAcobf+1pSS/AzE9y4+Mu 5RBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794233134; x=1794837934; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=K0N5mXlXkvLuRoO3ciD/U4zuNV7Lwc6MUcZnwB0Wneo=; b=CVkX9mfN1A7/pHEXewM+Y2TNE6zsB12/dgXgmA8F+hLgCUjilNvKrwZB5tXBl64pI7 s5vcCFJVyhAcyYejLxYjoNC/H0cWpC/7HuKF5WycX3dGcQAq+QMIC40kUmuKFH07BzJC iDu9PtX0RV0tA92Bz7Nzscc816zVg1PtctyyJ1LCbbFGqLIxV4eqiOvFoItmWWfvvC9A KAC3frUA0YSPkxdMUUWOTmKDZhDUF5MfOwen8WpKV7E6mVmva8ltFyMZ5h+W7vLIvtV7 u7aMkXiNHdi5i1dYU5yvtBuvsntP1kKsb/5YN3168evnFs1B93qUWQ8lqc8YOnpk47Cy sQ/A== X-Gm-Message-State: APuU4Z90d+zmLpeVbBK4HTzT1ReJv/tpOZJuQ0eDK/4LYkIBat3HKA+O YGvrptnNXWvAaqHs4sSjidUi7hJHEvqHB7N7cOSqvRsL/t2nUmcdgq3r3OKFHvwzb0ZuElJm3bh SdsEADmY= X-Gm-Gg: AYBFou1iaJG+WqIji7B1DlBOBCjlNMkoqOksJcJjPAwRkGF4aoQtNjz+Ahcn7FYVSUw pb0cjzgYUuIDSURvxy2SlC/r3Ip9u288nSpZflN+wH+RKQcmO5z92MNhUC6lQseLW7a8Q88e+fi Xui0KLmedVVKLpHTpSAlny00kStZv8P/9M4H7p9bdZninuHH8t96jIeiE1lTTOyijDQ+fvElBGv YSGtE+IM2UKZhnBle9ZYau79Rdpa0/Hk2zbx9IZAah/PFf4u4osngA6LveuhvD1qBTHtVYaVfuB aBvjsAA9ly8CDYYZlJtkUsFOOmMbF1qztmS8wifx7xZ6EAx9SuQODajxgzVZLgotM9YFtvZVhwJ xWZCrUDWz9chFxqijn4gKABpT15nnOrNvAqaBXHISAW9mHsKNb3DOifudO42yMl9peE8hyJNV6b 0o9/ukAu2HbNcA8xnuSkkcSHBoXRo7/ZUXox6BfA3TM1NQWfcg7+q8PFfWmtIE1CsSH0Mag6ze3 2WqtxrKtKMguQCxC6mBevpP7xbwzjBIu5T+cGKc5LcMct+VuRC1OnvmW4iz/mWNen6y8ATAaC1C U7vcjkTNrhin8Tm96rjAhAm1ArYn+KufSs/5+puK3NMHfISRec9R27FU4mKEb1a2oKOPOvyzIa5 97EesImfvMw5LFxE0PViCKM6K0Y6Tm3ONN0lnLEe6vVxYILaaZPGUlbc= X-Received: by 2002:a05:6000:4b14:b0:487:13a9:80d with SMTP id ffacd0b85a97d-49588af4845mr9332196f8f.10.1794233133824; Mon, 09 Nov 2026 06:05:33 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 7/9] hw/intc/arm_gic: do not hardcode GICv2 minimum binary point Date: Mon, 9 Nov 2026 14:05:21 +0000 Message-ID: <20261109140523.240161-8-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261109140523.240161-1-peter.maydell@linaro.org> References: <20261109140523.240161-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::429; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x429.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: 1794233180400158500 Content-Type: text/plain; charset="utf-8" From: Manos Pitsidianakis The number of priority bits is implementation defined, and indeed machines such as a9mpcore and arm11mpcore define it in the num-priority-bits property. However we still hardcoded GIC_MIN_BPR. This commit replaces the GIC_MIN_BPR and GIC_MIN_ABPR defs with macros that read the property. The calculation is based on "Table 4-47 Active Priorities register implementation" in the GICv2 spec (page 4-150 of ARM IHI 0048B.b ID072613): +---------------+---------------+---------------+ | | | Maximum | | Minimum value | Minimum value | number of | | of Secure | of Non-secure | group | | GICC_BPR | GICC_BPR | priority bits | +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+ | 3 | 4 | 4 | | 2 | 3 | 5 | | 1 | 2 | 6 | | 0 | 1 | 7 | +---------------+---------------+---------------+ Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4375 Signed-off-by: Manos Pitsidianakis Message-id: 20261106-gic_read_bpr_from_property-v2-1-9f096cce4814@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- include/hw/intc/arm_gic.h | 2 -- include/hw/intc/arm_gic_common.h | 18 ++++++++++++++++-- hw/intc/arm_gic.c | 14 +++++++------- hw/intc/arm_gic_common.c | 4 ++-- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/include/hw/intc/arm_gic.h b/include/hw/intc/arm_gic.h index be923f7ed88..a1f4a2eebab 100644 --- a/include/hw/intc/arm_gic.h +++ b/include/hw/intc/arm_gic.h @@ -72,8 +72,6 @@ =20 /* Number of SGI target-list bits */ #define GIC_TARGETLIST_BITS 8 -#define GIC_MAX_PRIORITY_BITS 8 -#define GIC_MIN_PRIORITY_BITS 4 =20 #define TYPE_ARM_GIC "arm_gic" typedef struct ARMGICClass ARMGICClass; diff --git a/include/hw/intc/arm_gic_common.h b/include/hw/intc/arm_gic_com= mon.h index b169394e6ca..db7370a80ab 100644 --- a/include/hw/intc/arm_gic_common.h +++ b/include/hw/intc/arm_gic_common.h @@ -37,8 +37,8 @@ #define MAX_NR_GROUP_PRIO 128 #define GIC_NR_APRS (MAX_NR_GROUP_PRIO / 32) =20 -#define GIC_MIN_BPR 0 -#define GIC_MIN_ABPR (GIC_MIN_BPR + 1) +#define GIC_MAX_PRIORITY_BITS 8 +#define GIC_MIN_PRIORITY_BITS 4 =20 /* Architectural maximum number of list registers in the virtual interface= */ #define GIC_MAX_LR 64 @@ -151,6 +151,20 @@ struct GICState { }; typedef struct GICState GICState; =20 + +static inline uint32_t gic_min_bpr(GICState *s) +{ + uint32_t num_preemption_bits =3D s->n_prio_bits =3D=3D 8 ? 7 : s->n_pr= io_bits; + assert(!(s->n_prio_bits > GIC_MAX_PRIORITY_BITS + || s->n_prio_bits < GIC_MIN_PRIORITY_BITS)); + return 7 - num_preemption_bits; +} + +static inline uint32_t gic_min_abpr(GICState *s) +{ + return gic_min_bpr(s) + 1; +} + #define TYPE_ARM_GIC_COMMON "arm_gic_common" typedef struct ARMGICCommonClass ARMGICCommonClass; DECLARE_OBJ_CHECKERS(GICState, ARMGICCommonClass, diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c index b60f1f630b0..0236f45c3d1 100644 --- a/hw/intc/arm_gic.c +++ b/hw/intc/arm_gic.c @@ -479,7 +479,7 @@ static void gic_activate_irq(GICState *s, int cpu, int = irq) * and update the running priority. */ int prio =3D gic_get_group_priority(s, cpu, irq); - int min_bpr =3D gic_is_vcpu(cpu) ? GIC_VIRT_MIN_BPR : GIC_MIN_BPR; + int min_bpr =3D gic_is_vcpu(cpu) ? GIC_VIRT_MIN_BPR : gic_min_bpr(s); int preemption_level =3D prio >> (min_bpr + 1); int regno =3D preemption_level / 32; int bitno =3D preemption_level % 32; @@ -521,7 +521,7 @@ static int gic_get_prio_from_apr_bits(GICState *s, int = cpu) if (!apr) { continue; } - return (i * 32 + ctz32(apr)) << (GIC_MIN_BPR + 1); + return (i * 32 + ctz32(apr)) << (gic_min_bpr(s) + 1); } return 0x100; } @@ -1561,7 +1561,7 @@ static inline uint32_t gic_apr_ns_view(GICState *s, i= nt cpu, int regno) /* Return the Nonsecure view of GICC_APR. This is the * second half of GICC_NSAPR. */ - switch (GIC_MIN_BPR) { + switch (gic_min_bpr(s)) { case 0: if (regno < 2) { return s->nsapr[regno + 2][cpu]; @@ -1592,7 +1592,7 @@ static inline void gic_apr_write_ns_view(GICState *s,= int cpu, int regno, uint32_t value) { /* Write the Nonsecure view of GICC_APR. */ - switch (GIC_MIN_BPR) { + switch (gic_min_bpr(s)) { case 0: if (regno < 2) { s->nsapr[regno + 2][cpu] =3D value; @@ -1731,10 +1731,10 @@ static MemTxResult gic_cpu_write(GICState *s, int c= pu, int offset, /* WI when CBPR is 1 */ return MEMTX_OK; } else { - s->abpr[cpu] =3D MAX(value & 0x7, GIC_MIN_ABPR); + s->abpr[cpu] =3D MAX(value & 0x7, gic_min_abpr(s)); } } else { - int min_bpr =3D gic_is_vcpu(cpu) ? GIC_VIRT_MIN_BPR : GIC_MIN_= BPR; + int min_bpr =3D gic_is_vcpu(cpu) ? GIC_VIRT_MIN_BPR : gic_min_= bpr(s); s->bpr[cpu] =3D MAX(value & 0x7, min_bpr); } break; @@ -1746,7 +1746,7 @@ static MemTxResult gic_cpu_write(GICState *s, int cpu= , int offset, /* unimplemented, or NS access: RAZ/WI */ return MEMTX_OK; } else { - s->abpr[cpu] =3D MAX(value & 0x7, GIC_MIN_ABPR); + s->abpr[cpu] =3D MAX(value & 0x7, gic_min_abpr(s)); } break; case 0xd0: case 0xd4: case 0xd8: case 0xdc: diff --git a/hw/intc/arm_gic_common.c b/hw/intc/arm_gic_common.c index a7c0763ab6a..fec5662d695 100644 --- a/hw/intc/arm_gic_common.c +++ b/hw/intc/arm_gic_common.c @@ -259,8 +259,8 @@ static inline void arm_gic_common_reset_irq_state(GICSt= ate *s, int cidx, s->current_pending[i] =3D 1023; s->running_priority[i] =3D 0x100; s->cpu_ctlr[i] =3D 0; - s->bpr[i] =3D gic_is_vcpu(i) ? GIC_VIRT_MIN_BPR : GIC_MIN_BPR; - s->abpr[i] =3D gic_is_vcpu(i) ? GIC_VIRT_MIN_ABPR : GIC_MIN_ABPR; + s->bpr[i] =3D gic_is_vcpu(i) ? GIC_VIRT_MIN_BPR : gic_min_bpr(s); + s->abpr[i] =3D gic_is_vcpu(i) ? GIC_VIRT_MIN_ABPR : gic_min_abpr(s= ); =20 if (!gic_is_vcpu(i)) { for (j =3D 0; j < GIC_INTERNAL; j++) { --=20 2.43.0 From nobody Mon Nov 23 04:34:31 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=1794233264; cv=none; d=zohomail.com; s=zohoarc; b=eDSmxm8gf9HjJFdgOLzXha+9bdp8gcu8hJk1l4UB8syxn9CnuwrUdQONaN+u/4PtFnTalvI8UNfCxyaEc5sB9F4X8PP9IfmKlHzd71Sw5bjlN8HLEv4433q9wZhMqBpF1vxueqsvISEsk5Il5eNZkHFiPfeT6CHQiUUlDfEtxS0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794233264; h=Content-Type:Content-Transfer-Encoding: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:Cc; bh=ufvtlh2otS2NmCc+UOXX75RiNO7l/xL1MQiDIKuY8Ic=; b=Z4Bm752KrufQNekpkBy5LQ/rDOB0/NPmah9r9K6+JoYWUsaJ2phbiySzhVPxPIs8drFu/fWPnaT3scBGjPQBvUCIlJ8O9lujT+FcvulL9erX+8rDV42IDGUVClAIkdQM18lSpJfyT5Df/AWnQDI0ZjBaV4rNBd7X50VeMBb1HZU= 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 1794233264951678.7297940713328; Mon, 9 Nov 2026 06:07:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQQ0Y-0007QM-By; Mon, 09 Nov 2026 09:06:02 -0500 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 1xQQ0G-0007F6-Vd for qemu-devel@nongnu.org; Mon, 09 Nov 2026 09:05:46 -0500 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xQQ08-0008B8-7a for qemu-devel@nongnu.org; Mon, 09 Nov 2026 09:05:38 -0500 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-4a4d7ae1ae9so8123455e9.1 for ; Mon, 09 Nov 2026 06:05:35 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-49596ea51cbsm11184750f8f.27.2026.11.09.06.05.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2026 06:05:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1794233135; x=1794837935; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=ufvtlh2otS2NmCc+UOXX75RiNO7l/xL1MQiDIKuY8Ic=; b=vJkY3bVB1sP9U8Kuq1bAIgg0Rl361wm95louGmAdw6wKdgIhyk6Tcr5zaEo7E6A58k HIdn1aVMeAgC7zYc0wjq1FdoYkC5DKKS8prVxPtQpQX5pNrJKtvasRrZ/wf+MJTo2hfc QM2vuPhHR/kl/04Ud9R9UezaPLWaefsfl1JHnV6DYviUZ373gEpmL3AEBB/uRF2Dcxzb 71ZZJIoy26cAl5qwKoVfzXbvJ9hv+8U7T7rqgTocyDvotbmupx/l+rKgg/X2pbk95XjH hDjlL8eiZCQcb8a1B4iROg8k7ezZyLbeAfSIM64MBhGU0lPCxXmy8YKiKNZfYDr1Jt/e 7P3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794233135; x=1794837935; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=ufvtlh2otS2NmCc+UOXX75RiNO7l/xL1MQiDIKuY8Ic=; b=VbRBFEPJ5GKkLsaGmLP6lBvn9Kuxl3B4RgH1EBLwYOVBGmLhR6Rl+P9HDWR0IvgSWe ts7Sxb5UUfXfSms936axU9g91EzYK4bFEwyOvTiPCDSQqVWXnZDWemH8Vob0siM+Fxu+ gb1VAnp8sr8iPx+4e8iudtQ6OMlhAwRpllFcMYU+8EAoIrDJf/EHU+ZLUUD/JKZD1kPp nHanRPZSosdVpT25IQy+L+D1KirCfG8Fs9gNqWMhIvqSyDPk7Pvb+3Ps0l9gXSrggJVA 0QtEFcx3hoiZZAmUaR+nAHoKqHYGPqXPTs+tkIL74TTRYB+IVPxMICnMm1iujfnJ1IaG bOJg== X-Gm-Message-State: APuU4Z+mI0FY28tIizIXIFWjYNvcLXswFFOfnEyHFKoHWymgakg6wikE YmmdPJu4Fm1vUc83ogFJmFeoHGk1gry/+M5knd6tasGaa0U57HzxjsHjR9uvwa80kG/QvZCwKP1 FVJ4SBJw= X-Gm-Gg: AYBFou187oBjI6ZPrXQU0V4eBVQ7z9Q1ea6oXID/lABhTHaCON89a/fcUzmkbkE/bLO ugdzS1bb5ap4HrpC1aQovBnXrLfOVzOoEGYOhS2IRfsQ1tI5PZDcmzGHbdBPMMHEGL9BJKC1hz6 y7+GH7uGoQFbcckl0IOoRdSNIUqprBc56m8ZoJqmdPfEB7HqT34jUV4ZMBj+/XIGbvtqwYdd21c m1kCft+xYOCGAlcFwFIlhlC6pldvyRZyGnF4jLAkRN2I03+kS175ADg0fqfzCnSbzNMP6VsIJxr GgflGumWomhmN2fcHFeCVph690wbm4iN8Q6L3J3QcoV1wen7BZKcG2Yy0Xv0GEOMyOXmVgn5NG/ Ra9plJGRhHg7BKd1Vn2qKtiDwoz6p1/oIU0vGSoisOmkqSADyqQmI4oncEg6z0sat3SRfgAISPs JLzjCBqahqwqWogdJYHiuX1B86/dvFw/v4hYeP50+Hd8l8w3wimaGvS5c2hAgPiPBrhJ754J8qF 8w5/n7gEh/kV7Y60mDcpv8yW1be0SOJ3wnsku/wd7T43IIWlCHIMCidqa0XV+vuRqRwppl67nGy RL5emY9OmKUcmZYIyaFmPVJETzfHUcW5QrfSJz6scX5ENCflKn5xB21n0jCiSBi2zrKV4lIkrbz wwcYoEUs7LXLGubykXt4JXAr+tcvn5Heliw== X-Received: by 2002:a05:600c:8b6b:b0:4a1:f90d:6f4c with SMTP id 5b1f17b1804b1-4b960da49c6mr75786085e9.7.1794233134700; Mon, 09 Nov 2026 06:05:34 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 8/9] target/arm: Clear the local monitor on AArch32 (v8) exception returns Date: Mon, 9 Nov 2026 14:05:22 +0000 Message-ID: <20261109140523.240161-9-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261109140523.240161-1-peter.maydell@linaro.org> References: <20261109140523.240161-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::336; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x336.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: 1794233265899158500 From: Chris Copeland A/R-profile exception returns prior to Armv8 do not clear the local exclusive monitor, but in Armv8-A/R it is cleared. From the Arm Architecture Reference Manual for A-profile architecture (DDI0487 M.d) =C2=A7E2.10.4 "Context switch support": "An exception return clears the local monitor." The same language appears in the R-profile manual (DDI111353 A.a) =C2=A7B2.11.4 "Context switch support". We correctly clear the monitor for an A64 exception return, but in adding v8 support we missed that the A32 exception return path needed updating. Cc: qemu-stable@nongnu.org Signed-off-by: Chris Copeland Message-id: 20261108-armv8-exception-return-clrex-v1-1-ec11079bf695@chrisnc= .net Reviewed-by: Peter Maydell [PMM: commit message tweak] Signed-off-by: Peter Maydell --- target/arm/tcg/op_helper.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/target/arm/tcg/op_helper.c b/target/arm/tcg/op_helper.c index 4a31ce979c6..22f47f7450a 100644 --- a/target/arm/tcg/op_helper.c +++ b/target/arm/tcg/op_helper.c @@ -803,6 +803,10 @@ void HELPER(cpsr_write_eret)(CPUARMState *env, uint32_= t val) mask =3D aarch32_cpsr_valid_mask(env->features, &env_archcpu(env)->isa= r); cpsr_write(env, val, mask, CPSRWriteExceptionReturn); =20 + if (arm_feature(env, ARM_FEATURE_V8)) { + arm_clear_exclusive(env); + } + /* Generated code has already stored the new PC value, but * without masking out its low bits, because which bits need * masking depends on whether we're returning to Thumb or ARM --=20 2.43.0 From nobody Mon Nov 23 04:34:31 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=1794233189; cv=none; d=zohomail.com; s=zohoarc; b=WZGVOrq7hIzuvwl+HCyEJ8Ne7DsXRdgLO+V7xqh+i2LuiNXi7peZ4rwVPpyI9lMGRXQARbyaSm1w3RZfmyTna6YtIB3LgOZpLYKKQ4iMYlh1p+e85ibcRzjFI+b3FjKezVvXmBO9xIIQr6qKn/ZohK7oKHsEmKqtMfm+7+ZAjJM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794233189; h=Content-Transfer-Encoding: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:Cc; bh=eLMzCKJK010QwiI+TdClrcXBscIJkeSZJom2hWupRi4=; b=Q985trChkfBnUeQENh96JyQvLIzecuR+X3gQfITLbpnvoly5l2Mskd46w9MOrw4uU1uG9CxdlA+UE5AwUA3U1v53/9zjht/C3wlSkSBYJfrBT4NcC7g3z/XBOBIB4UJSIVsrfgDa6I35MdwB32zaETUbqmC2oUOaGKpBOzDy5Ag= 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 17942331890921000.0000660843183; Mon, 9 Nov 2026 06:06:29 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQQ0P-0007Ky-QX; Mon, 09 Nov 2026 09:05:54 -0500 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 1xQQ0H-0007FF-II for qemu-devel@nongnu.org; Mon, 09 Nov 2026 09:05:47 -0500 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xQQ0B-0008BK-LD for qemu-devel@nongnu.org; Mon, 09 Nov 2026 09:05:45 -0500 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-4a3517554f7so9743495e9.2 for ; Mon, 09 Nov 2026 06:05:37 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-49596ea51cbsm11184750f8f.27.2026.11.09.06.05.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2026 06:05:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1794233136; x=1794837936; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=eLMzCKJK010QwiI+TdClrcXBscIJkeSZJom2hWupRi4=; b=PfwwcFOo/KT6yJOwKzfg3fHNhyHpdiDevwfl3mzPmjevqQgQs8YJNa0WJklXwjOvXq pNHdwu52aG6wzrKFjIl46jFZH/3KY35xa29tRdv5ZZCIeX013F5rwf3h0XpUh3Mp1r4i 5GY1smQI22UfOqQlQBKJyYmlZyKZNOBetmxJ8LTGaX0xAg+3rBPdRqUTS54KxRz7l9ic H2pMjq8YYDiyo1ar5+hKKC1PmDXfDYIM3J0CKfr8wo3lpmFe+wWKdGSIN2XG2uKWAoYr qZ23iQ+oBd2SH/dcSLELh1L9UXEyDjZLaVDvREwG+ernLFGc/jmB7YTvMpicKimNXWUX 1X0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794233136; x=1794837936; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=eLMzCKJK010QwiI+TdClrcXBscIJkeSZJom2hWupRi4=; b=xmxrEj6VWF0UXHRw6VYFaAdplcoSjDrA7O41B6gTOKbfQfOgTfEI+QEBflO69ZLWbF fa8F0jKkCd3QbQM2C8bgbcfOrgk0IgxlxmKQmgiDZfVAce3tJ8VWFmrZ72ff0gtCBjb2 CuaPo+XV8pMyJAkauICvfR6KZCnnY79IMC71rCYAH9E3o8nKUPc+jkHObaXdwuflCAtX HvRZvUzGEXNEuhn4JDq3w2Y7skJympBrlkh7PfHzjZ4ZihML3cAHClSwcEv4FjbO6obA rVJ5NJpOhBgaihEWdtueXNAHIj+7L+FXrGOdeFjrqgWSVjvOGajRuZWZYRRsmS9aQSs8 Wp/A== X-Gm-Message-State: APuU4Z9NBRdjabhYLB3wlSw7Thew5tD9JljhhwEWFi/wtiOoCrkOP9+s EgO2bKNbciIqOUospoPGnJ6LoAOVskM4arMRDV9CmMV/qDMfu8TZGW+CtuDg+rooYaM8WChqNOJ kQF0cqGk= X-Gm-Gg: AYBFou3eVW1r3fN+fRYXYGgb0Vuq/SgZk9sYCJyBoOw0hdok/yg2zcbqcjpo4QBBcIE rbTCFRnxjmtbH3Dt5K9ZSKsI3s/IYS9ySSUSdurCQZnqkLOWOA6Aj4fybMzGIEyhhuBtKFcN5As TR6g3s+kTnPZPtYNyCoFsteHGZth5aUDjubIddJSM30sTqX0rE/k/ykXP9FJ1r8RYMHDfV2kqL5 3B9F45eJFzON1l7vTnNAtRzlGZkCIB9LoEU6kbyYPCx1oQrSf8JQ5334K5udjHWXEx/agxUwNvO yTHhnS3wnLCT0TxiXIzjG+mFjtS3sFfBGV4el89ayA5ie2VING2j40nPGSJgBw+WCm3jRB5utnL O0msa08PFzM28NVLJ2eVEmELgZC/sh2WzMjiowHgKX/v2QglfQmMvwwemte96UwXxvCqdGq4dCS GYO7Txq1b4FCEb79tqe5ABzcEifXJin0pvOXgHS6MfLeBHj1q8Bhnk/Q39SQUdHhsERE4cNn9TJ TnaCw2AO7ZyvhQmh1SqRu1L3QYGoAyIlm8B8N3ljgO5+9NewYR+TvSdig5VZxfwh7rtGuWQK/Nb h+pOcaBlXCNXo/f1eiBwILrtKad/RZ7bIMiXyGSOWzm2Gyr1TErsHUQ8qOeoa4/g6eFAD+0MMgk XpvCiCrpXT2mkALLllsHhY0mcP71bz/uSAw== X-Received: by 2002:a05:600c:4eca:b0:4a2:5267:3cd4 with SMTP id 5b1f17b1804b1-4b94d762f4dmr73297255e9.3.1794233136032; Mon, 09 Nov 2026 06:05:36 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 9/9] hw/intc/hex-l2vic: avoid shift into sign bit Date: Mon, 9 Nov 2026 14:05:23 +0000 Message-ID: <20261109140523.240161-10-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261109140523.240161-1-peter.maydell@linaro.org> References: <20261109140523.240161-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::336; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x336.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: 1794233190427158500 Content-Type: text/plain; charset="utf-8" In fastl2vic_write() we do: val =3D 1 << (irq % 32); Because '1' is a signed integer, this can shift into the sign bit of 'int'; the cast to uint64_t to assign to 'val' then results in all the high bits being set. This happens to cause no visible problems because l2vic_write never looks at those bits, but it's obviously not intended. Use 1ULL so that we do the shift as 64 bits unsigned. Resolves: Coverity CID 1685261 Signed-off-by: Peter Maydell Reviewed-by: Tommaso Califano Reviewed-by: Brian Cain Message-id: 20261023084624.1063258-1-peter.maydell@linaro.org --- hw/intc/hex-l2vic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/intc/hex-l2vic.c b/hw/intc/hex-l2vic.c index 2335236f837..93fbb7449e8 100644 --- a/hw/intc/hex-l2vic.c +++ b/hw/intc/hex-l2vic.c @@ -392,7 +392,7 @@ static void fastl2vic_write(void *opaque, hwaddr offset= , uint64_t val, uint32_t cmd =3D (val >> 16) & 0x3; uint32_t irq =3D val & 0x3ff; uint32_t slice =3D (irq / 32) * 4; - val =3D 1 << (irq % 32); + val =3D 1ULL << (irq % 32); =20 if (cmd =3D=3D FASTL2VIC_ENABLE) { l2vic_write(opaque, L2VIC_INT_ENABLE_SETn + slice, val, size); --=20 2.43.0