Skip to content

target/loongarch/kvm: cpucfg and device attr fixes

Tao Cui qemu-devel 2 versions – Applied

Status from this message: Applied to loongarch-next.

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest4 patches 4 repliesApplied
  2. v14 patches 6 repliesSuperseded

Changes in v2 from the cover letter

- 1/4: on KVM_GET_DEVICE_ATTR failure, warn and skip the cpucfg2 mask instead of failing the register sync; the &= mask is best-effort, and a GET failure after a successful HAS is most likely a copy_{from,to}_user issue. Switched the report from error_report() to warn_report().

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/4target/loongarch/kvm: fix uninitialized val and unchecked GET in cpucfg2 checktarget/loongarch/kvm/kvm.c+12 -31 reply
2/4target/loongarch/kvm: pass device attr by reference to kvm_vcpu_ioctltarget/loongarch/kvm/kvm.c+6 -60 replies
3/4target/loongarch/kvm: remove redundant cpucfg failure tracestarget/loongarch/kvm/kvm.c target/loongarch/trace-events+0 -81 reply
4/4target/loongarch/kvm: fix cpucfg sync error handlingtarget/loongarch/kvm/kvm.c+9 -61 reply

Reviews trailers per patch

All 4 patches have a Reviewed-by or Acked-by.

PatchBibo Mao
1/4R-b
2/4R-b
3/4R-b
4/4R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/4] target/loongarch/kvm: cpucfg and device attr fixes

From: Tao Cui <[email protected]>

A few small robustness fixes around cpucfg register sync and kvm device attribute handling in the LoongArch KVM target.

1/4: kvm_check_cpucfg2() discarded the return value of
KVM_GET_DEVICE_ATTR and used an uninitialized val to mask cpucfg[2]; check the return value, warn and skip the mask on a GET failure (best-effort negotiation), and initialize val.

2/4: kvm_get_stealtime(), kvm_set_stealtime() and kvm_set_pv_features()
pass a struct kvm_device_attr by value to the variadic kvm_vcpu_ioctl(), which expects a pointer. Pass &attr.

3/4: drop the redundant trace_kvm_failed_get/put_cpucfg() calls and
their now-unused trace events; kvm_get/set_one_reg() already trace on failure.

4/4: kvm_loongarch_get/put_cpucfg() overwrite ret on each iteration, so
only the last register's result is returned and earlier failures are lost; on a failed read, get_cpucfg() also stores a stale val. Accumulate errors with ret |= and only store on a successful read.

Compiled and boot-tested on a loongarch64 KVM host.

Tao Cui (4):
target/loongarch/kvm: fix uninitialized val and unchecked GET in
cpucfg2 check
target/loongarch/kvm: pass device attr by reference to kvm_vcpu_ioctl target/loongarch/kvm: remove redundant cpucfg failure traces target/loongarch/kvm: fix cpucfg sync error handling

 target/loongarch/kvm/kvm.c    | 46 ++++++++++++++++++++---------------
 target/loongarch/trace-events |  2 --
 2 files changed, 26 insertions(+), 22 deletions(-)

---
Changes in v2:
- 1/4: on KVM_GET_DEVICE_ATTR failure, warn and skip the cpucfg2 mask instead of failing the register sync; the &= mask is best-effort, and a GET failure after a successful HAS is most likely a copy_{from,to}_user issue. Switched the report from error_report() to warn_report().

Signature · 1 line
2.43.0