target/ppc: Fix host PVR matching for KVM
commit21d3a78ed9cf470f87180db62f7aa1296b7b0ee5
authorNicholas Piggin <npiggin@gmail.com>
Sun, 31 Jul 2022 01:33:58 +0000 (31 11:33 +1000)
committerDaniel Henrique Barboza <danielhb413@gmail.com>
Tue, 30 Aug 2022 19:20:29 +0000 (30 16:20 -0300)
tree67a9e26c0411f9c7edaef82a2f97423500ad4abd
parentc49b67f72b1a875ca355a170759303b0faa959ca
target/ppc: Fix host PVR matching for KVM

ppc_cpu_compare_class_pvr_mask() should match the best CPU class in the
family, because it is used by the KVM subsystem to find the host CPU
class. Since commit 03ae4133ab8 ("target-ppc: Add pvr_match()
callback"), it matches any class in the family (the first one in the
comparison list).

Since commit f30c843ced5 ("ppc/pnv: Introduce PowerNV machines with
fixed CPU models"), pnv has relied on pnv_match having these new
semantics to check machine compatibility with a CPU family.

Resolve this by adding a parameter to the pvr_match function to select
the best or any match, and restore the old behaviour for the KVM case.

Prior to this fix, e.g., a POWER9 DD2.3 KVM host matches to the
power9_v1.0 class (because that happens to be the first POWER9 family
CPU compared). After the patch, it matches the power9_v2.0 class.

This approach requires pnv_match contain knowledge of the CPU classes
implemented in the same family, which feels ugly. But pushing the 'best'
match down to the class would still require they know about one another
which is not obviously much better. For now this gets things working.

Fixes: 03ae4133ab8 ("target-ppc: Add pvr_match() callback")
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <20220731013358.170187-1-npiggin@gmail.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
hw/ppc/pnv.c
target/ppc/cpu-qom.h
target/ppc/cpu_init.c
target/ppc/machine.c