Thread (5 messages) flat view 5 messages, 2 authors, 2022-03-08

Re: [RFC PATCH 2/2] KVM: PPC: Book3S HV: Provide a more accurate MAX_VCPU_ID in P9

From: Fabiano Rosas <hidden>
Date: 2022-03-08 14:28:37

Christophe Leroy [off-list ref] writes:
Le 13/04/2021 à 00:26, Fabiano Rosas a écrit :
quoted
The KVM_CAP_MAX_VCPU_ID capability was added by commit 0b1b1dfd52a6
("kvm: introduce KVM_MAX_VCPU_ID") to allow for vcpu ids larger than
KVM_MAX_VCPU in powerpc.

For a P9 host we depend on the guest VSMT value to know what is the
maximum number of vcpu id we can support:

kvmppc_core_vcpu_create_hv:
     (...)
     if (cpu_has_feature(CPU_FTR_ARCH_300)) {
-->         if (id >= (KVM_MAX_VCPUS * kvm->arch.emul_smt_mode)) {
                     pr_devel("KVM: VCPU ID too high\n");
                     core = KVM_MAX_VCORES;
             } else {
                     BUG_ON(kvm->arch.smt_mode != 1);
                     core = kvmppc_pack_vcpu_id(kvm, id);
             }
     } else {
             core = id / kvm->arch.smt_mode;
     }

which means that the value being returned by the capability today for
a given guest is potentially way larger than what we actually support:

\#define KVM_MAX_VCPU_ID (MAX_SMT_THREADS * KVM_MAX_VCORES)

If the capability is queried before userspace enables the
KVM_CAP_PPC_SMT ioctl there is not much we can do, but if the emulated
smt mode is already known we could provide a more accurate value.

The only practical effect of this change today is to make the
kvm_create_max_vcpus test pass for powerpc. The QEMU spapr machine has
a lower max vcpu than what KVM allows so even KVM_MAX_VCPU is not
reached.

Signed-off-by: Fabiano Rosas <redacted>
This patch won't apply after commit a1c42ddedf35 ("kvm: rename 
KVM_MAX_VCPU_ID to KVM_MAX_VCPU_IDS")

Feel free to resubmit if still applicable.
Thanks for the reminder, Christophe.

I was focusing on enabling the rest of the kvm-selftests:
https://lore.kernel.org/r/20220120170109.948681-1-farosas@linux.ibm.com (local)

I'm preparing a v2 for that series and will try to include these patches
as well.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help