All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Oscar Alejandro Sánchez Lucero" <aleszlucero@gmail.com>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	qemu-arm@nongnu.org, "Jonathan Cameron" <jic23@kernel.org>,
	"Bin Meng" <bin.meng@processmission.com>,
	"Oscar Alejandro Sánchez Lucero" <aleszlucero@gmail.com>
Subject: [PATCH v2] hw/arm/virt: Use g_assert_not_reached() in virt_get_caches()
Date: Wed, 02 Dec 2026 02:01:56 +0000	[thread overview]
Message-ID: <20261202-virt-assert-not-reached-v2-1-d58f4b4ce276@gmail.com> (raw)

Replace error_setg(&error_abort, ...) on an unreachable branch with
g_assert_not_reached(), as documented in include/qapi/error.h.

In virt_get_caches(), clidr is never populated from a host CPU by any
accelerator (and is explicitly forced to 0 under KVM). All non-zero
CLIDR values come from static TCG CPU model definitions in target/arm/,
which only encode valid CTYPE values 0-4, making the fallback branch for
reserved encodings 5-7 unreachable.

Reviewed-by: Bin Meng <bin.meng@processmission.com>
Signed-off-by: Oscar Alejandro Sánchez Lucero <aleszlucero@gmail.com>
---
Changes in v2;
- Explain in the commit message why CTYPE values 5-7 cannot occur in
  virt_get_caches() (Jonathan Cameron).
- Link to v1: https://lore.kernel.org/qemu-devel/20261130-virt-assert-not-reached-v1-1-af81f07853a2@gmail.com
---
 hw/arm/virt.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 0b11f7e..278882e 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -383,8 +383,7 @@ unsigned int virt_get_caches(const VirtMachineState *vms, CPUCoreCaches *caches)
             set_cpu_cache(&caches[num_cache++], INSTRUCTION_CACHE, cache_level,
                           true);
         } else {
-            error_setg(&error_abort, "Unrecognized cache type");
-            return 0;
+            g_assert_not_reached();
         }
     }
 

---
base-commit: 9751c62358073580cbf330a4df22077a7c6a407c
change-id: 20261130-virt-assert-not-reached-84c6a3157ac5

Best regards,
--  
Oscar Alejandro Sánchez Lucero <aleszlucero@gmail.com>



                 reply	other threads:[~2026-12-02  2:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261202-virt-assert-not-reached-v2-1-d58f4b4ce276@gmail.com \
    --to=aleszlucero@gmail.com \
    --cc=bin.meng@processmission.com \
    --cc=jic23@kernel.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.