From: cuitao <cuitao@kylinos.cn>
To: zhaotianrui@loongson.cn, maobibo@loongson.cn,
chenhuacai@kernel.org, loongarch@lists.linux.dev
Cc: kernel@xen0n.name, cuitao <cuitao@kylinos.cn>
Subject: [PATCH] LoongArch/KVM: Fix missing EMULATE_FAIL in ldptr default case of kvm_emu_mmio_read
Date: Tue, 14 Apr 2026 09:31:14 +0800 [thread overview]
Message-ID: <20260414013114.306033-1-cuitao@kylinos.cn> (raw)
In the ldptr (0x24...0x27) opcode decoding path, the default case
only breaks out without setting ret to EMULATE_FAIL. This leaves
run->mmio.len uninitialized (stale from a previous MMIO operation)
while ret remains EMULATE_DO_MMIO, causing the code to proceed with
an incorrect MMIO length.
Add ret = EMULATE_FAIL to match the other default branches in the
same function (e.g. the 0x28...0x2e and 0x38 cases).
Signed-off-by: cuitao <cuitao@kylinos.cn>
---
arch/loongarch/kvm/exit.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/loongarch/kvm/exit.c b/arch/loongarch/kvm/exit.c
index da0ad89f2eb7..3b95cd0f989b 100644
--- a/arch/loongarch/kvm/exit.c
+++ b/arch/loongarch/kvm/exit.c
@@ -390,6 +390,7 @@ int kvm_emu_mmio_read(struct kvm_vcpu *vcpu, larch_inst inst)
run->mmio.len = 8;
break;
default:
+ ret = EMULATE_FAIL;
break;
}
break;
--
2.43.0
next reply other threads:[~2026-04-14 1:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-14 1:31 cuitao [this message]
2026-04-14 1:39 ` [PATCH] LoongArch/KVM: Fix missing EMULATE_FAIL in ldptr default case of kvm_emu_mmio_read Bibo Mao
2026-04-27 7:57 ` Huacai Chen
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=20260414013114.306033-1-cuitao@kylinos.cn \
--to=cuitao@kylinos.cn \
--cc=chenhuacai@kernel.org \
--cc=kernel@xen0n.name \
--cc=loongarch@lists.linux.dev \
--cc=maobibo@loongson.cn \
--cc=zhaotianrui@loongson.cn \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).