From nobody Mon Nov 23 04:38:02 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793008704680183.09521228317976; Mon, 26 Oct 2026 02:58:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xLHSz-0003TV-Qm; Mon, 26 Oct 2026 05:58:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xLHSx-0003TM-IQ for qemu-devel@nongnu.org; Mon, 26 Oct 2026 05:58:07 -0400 Received: from mail.loongson.cn ([114.242.206.163]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xLHSt-00008d-Oo for qemu-devel@nongnu.org; Mon, 26 Oct 2026 05:58:07 -0400 Received: from loongson.cn (unknown [10.40.46.54]) by gateway (Coremail) with SMTP id _____8BxLtMiJN9qHXAZAA--.8153S3; Mon, 26 Oct 2026 17:57:55 +0800 (CST) Received: from fedora.loongson.cn (unknown [127.0.0.1]) by front1 (Coremail) with SMTP id qMiowJCxNs0hJN9qFk4wAA--.21773S2; Mon, 26 Oct 2026 17:57:54 +0800 (CST) From: Bibo Mao To: Song Gao <17746591750@163.com> Cc: Xianglai Li , qemu-devel@nongnu.org Subject: [PATCH] target/loongarch: Replace sys_state with vm_level Date: Mon, 26 Oct 2026 17:59:22 +0800 Message-ID: <20261026095922.241092-1-maobibo@loongson.cn> X-Mailer: git-send-email 2.54.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: qMiowJCxNs0hJN9qFk4wAA--.21773S2 X-CM-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x kF7I0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x07UWHqcUUUUU= 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=114.242.206.163; envelope-from=maobibo@loongson.cn; helo=mail.loongson.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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-ZM-MESSAGEID: 1793008707033158500 Content-Type: text/plain; charset="utf-8" Int type vm_level is more meaningful than pointer type sys_state, and it is easy to get current mode from value of vm_level. Here replace sys_state with vm_level, and use vm_level directly. Signed-off-by: Bibo Mao Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/loongarch/cpu.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/target/loongarch/cpu.h b/target/loongarch/cpu.h index 5cc2370da2..57cb893d95 100644 --- a/target/loongarch/cpu.h +++ b/target/loongarch/cpu.h @@ -429,7 +429,7 @@ typedef struct CPUArchState { /* Fields up to this point are cleared by a CPU reset */ struct {} end_reset_fields; =20 - CPUSysState sys_states[1]; + CPUSysState sys_states[VM_LEVELS]; uint32_t cpucfg[21]; uint32_t pv_features; uint64_t vendor_id; @@ -440,7 +440,7 @@ typedef struct CPUArchState { AddressSpace *address_space_iocsr; uint32_t mp_state; #endif - CPUSysState *sys_state; + int vm_level; unsigned int irq_nr; } CPULoongArchState; =20 @@ -510,12 +510,14 @@ struct LoongArchCPUClass { =20 static inline CPUSysState *env_sys(CPULoongArchState *env) { - return env->sys_state; + return env->sys_states + env->vm_level; } =20 static inline void set_sys(CPULoongArchState *env, int vm_level) { - env->sys_state =3D &env->sys_states[vm_level]; + if (vm_level >=3D 0 && vm_level < VM_LEVELS) { + env->vm_level =3D vm_level; + } } =20 static inline CPUTimerState *env_timer(CPULoongArchState *env) base-commit: d73149283205645625bfa9fe029cfb68e4c4a9ae --=20 2.54.0