From: Tao Cui <cui.tao@linux.dev>
To: qemu-devel@nongnu.org
Cc: "Song Gao" <gaosong@loongson.cn>,
"Bibo Mao" <maobibo@loongson.cn>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@mailo.com>,
"Qiang Ma" <maqianga@uniontech.com>,
"Tao Cui" <cuitao@kylinos.cn>
Subject: [PATCH v2 2/4] target/loongarch/kvm: pass device attr by reference to kvm_vcpu_ioctl
Date: Fri, 26 Jun 2026 13:27:40 +0800 [thread overview]
Message-ID: <20260626052742.810726-3-cui.tao@linux.dev> (raw)
In-Reply-To: <20260626052742.810726-1-cui.tao@linux.dev>
From: Tao Cui <cuitao@kylinos.cn>
kvm_vcpu_ioctl() is variadic and reads its argument as a pointer, but
kvm_get_stealtime(), kvm_set_stealtime() and kvm_set_pv_features() pass
the local struct kvm_device_attr by value. It currently works because of
how the calling convention passes large structs; pass &attr so the
argument is passed as intended.
Reviewed-by: Bibo Mao <maobibo@loongson.cn>
Signed-off-by: Tao Cui <cuitao@kylinos.cn>
---
target/loongarch/kvm/kvm.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/target/loongarch/kvm/kvm.c b/target/loongarch/kvm/kvm.c
index 5bd5e268b9..4bb5be6864 100644
--- a/target/loongarch/kvm/kvm.c
+++ b/target/loongarch/kvm/kvm.c
@@ -46,12 +46,12 @@ static int kvm_get_stealtime(CPUState *cs)
.addr = (uint64_t)&env->stealtime.guest_addr,
};
- err = kvm_vcpu_ioctl(cs, KVM_HAS_DEVICE_ATTR, attr);
+ err = kvm_vcpu_ioctl(cs, KVM_HAS_DEVICE_ATTR, &attr);
if (err) {
return 0;
}
- err = kvm_vcpu_ioctl(cs, KVM_GET_DEVICE_ATTR, attr);
+ err = kvm_vcpu_ioctl(cs, KVM_GET_DEVICE_ATTR, &attr);
if (err) {
error_report("PVTIME: KVM_GET_DEVICE_ATTR: %s", strerror(errno));
return err;
@@ -70,12 +70,12 @@ static int kvm_set_stealtime(CPUState *cs)
.addr = (uint64_t)&env->stealtime.guest_addr,
};
- err = kvm_vcpu_ioctl(cs, KVM_HAS_DEVICE_ATTR, attr);
+ err = kvm_vcpu_ioctl(cs, KVM_HAS_DEVICE_ATTR, &attr);
if (err) {
return 0;
}
- err = kvm_vcpu_ioctl(cs, KVM_SET_DEVICE_ATTR, attr);
+ err = kvm_vcpu_ioctl(cs, KVM_SET_DEVICE_ATTR, &attr);
if (err) {
error_report("PVTIME: KVM_SET_DEVICE_ATTR %s with gpa "TARGET_FMT_lx,
strerror(errno), env->stealtime.guest_addr);
@@ -96,13 +96,13 @@ static int kvm_set_pv_features(CPUState *cs)
.addr = (uint64_t)&val,
};
- err = kvm_vcpu_ioctl(cs, KVM_HAS_DEVICE_ATTR, attr);
+ err = kvm_vcpu_ioctl(cs, KVM_HAS_DEVICE_ATTR, &attr);
if (err) {
return 0;
}
val = env->pv_features;
- err = kvm_vcpu_ioctl(cs, KVM_SET_DEVICE_ATTR, attr);
+ err = kvm_vcpu_ioctl(cs, KVM_SET_DEVICE_ATTR, &attr);
if (err) {
error_report("Fail to set pv feature "TARGET_FMT_lx " with error %s",
val, strerror(errno));
--
2.43.0
next prev parent reply other threads:[~2026-06-26 5:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-26 5:27 [PATCH v2 0/4] target/loongarch/kvm: cpucfg and device attr fixes Tao Cui
2026-06-26 5:27 ` [PATCH v2 1/4] target/loongarch/kvm: fix uninitialized val and unchecked GET in cpucfg2 check Tao Cui
2026-06-26 5:27 ` Tao Cui [this message]
2026-06-26 5:27 ` [PATCH v2 3/4] target/loongarch/kvm: remove redundant cpucfg failure traces Tao Cui
2026-06-26 5:27 ` [PATCH v2 4/4] target/loongarch/kvm: fix cpucfg sync error handling Tao Cui
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=20260626052742.810726-3-cui.tao@linux.dev \
--to=cui.tao@linux.dev \
--cc=cuitao@kylinos.cn \
--cc=gaosong@loongson.cn \
--cc=maobibo@loongson.cn \
--cc=maqianga@uniontech.com \
--cc=pbonzini@redhat.com \
--cc=philmd@mailo.com \
--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.