[PATCH v2 0/3] target/loongarch: advertise pv features per vCPU

Tao Cui posted 3 patches 1 day, 23 hours ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260710005029.345378-1-cui.tao@linux.dev
Maintainers: Song Gao <17746591750@163.com>, Bibo Mao <maobibo@loongson.cn>, Xianglai Li <lixianglai@loongson.cn>, Jiaxun Yang <jiaxun.yang@flygoat.com>
hw/loongarch/virt.c         | 14 +++++++++++++-
include/hw/loongarch/virt.h |  9 ++++++++-
target/loongarch/cpu.h      |  1 +
target/loongarch/kvm/kvm.c  | 20 +++++++++++---------
target/loongarch/machine.c  | 19 +++++++++++++++++++
5 files changed, 52 insertions(+), 11 deletions(-)
[PATCH v2 0/3] target/loongarch: advertise pv features per vCPU
Posted by Tao Cui 1 day, 23 hours ago
From: Tao Cui <cuitao@kylinos.cn>

kvm_set_pv_features() programs the KVM_FEATURE cpucfg attribute, which is a
per-vCPU setting, but it was called from kvm_arch_put_registers() under a
function-local static guard and so ran only once for the whole VM: only the
first vCPU got its pv features pushed to KVM, and on SMP guests the others
never saw KVM_FEATURE_IPI / KVM_FEATURE_STEAL_TIME.

  1/3: drop the static guard and push pv features per vCPU under
       KVM_PUT_FULL_STATE, like kvm_set_stealtime(); host detection stays in
       kvm_arch_init_vcpu().
  2/3: add pv_features (the value of pseudo-register CPUCFG_KVM_FEATURE) to
       the vCPU VMState as a subsection so it travels across migration.
  3/3: add a no_pv_feature compat flag (LoongArchCPU + virt machine class)
       so the new behavior is gated per machine version: 11.1 keeps pv
       advertisement off, the new 11.2 enables it.

Compiled and boot-tested on a loongarch64 KVM host; migration verified
virt-11.2->virt-11.2 and virt-11.1->virt-11.1.

Changes in v2 (per Bibo Mao's review):
- Revert v1's move to kvm_arch_init_vcpu(); keep kvm_set_pv_features() in
  kvm_arch_put_registers(), drop the static guard, push per vCPU under
  KVM_PUT_FULL_STATE.
- Migrate pv_features (CPUCFG_KVM_FEATURE) via a VMState subsection.
- Add no_pv_feature compat flag: 11.1 off, 11.2 on.
- Split into three patches (fix / migrate / compat).

Tao Cui (3):
  target/loongarch/kvm: advertise pv features per vCPU
  target/loongarch: migrate pv_features in the vCPU VMState
  target/loongarch: add no_pv_feature compat flag

 hw/loongarch/virt.c         | 14 +++++++++++++-
 include/hw/loongarch/virt.h |  9 ++++++++-
 target/loongarch/cpu.h      |  1 +
 target/loongarch/kvm/kvm.c  | 20 +++++++++++---------
 target/loongarch/machine.c  | 19 +++++++++++++++++++
 5 files changed, 52 insertions(+), 11 deletions(-)

-- 
2.43.0