From: David Gibson <david@gibson.dropbear.id.au>
To: Nicholas Piggin <npiggin@gmail.com>
Cc: "Alexey Kardashevskiy" <aik@ozlabs.ru>,
"Cédric Le Goater" <clg@fr.ibm.com>,
qemu-ppc@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [PATCH v3 1/4] target/ppc: Fix masked PVR matching
Date: Sat, 12 Mar 2022 19:45:58 +1100 [thread overview]
Message-ID: <YixdxnawYgQi9b1H@yekko> (raw)
In-Reply-To: <20220307065527.156132-2-npiggin@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 4071 bytes --]
On Mon, Mar 07, 2022 at 04:55:24PM +1000, Nicholas Piggin wrote:
> The pvr_match for a CPU class is not supposed to just match for any
> CPU in the family, but rather whether this particular CPU class is the
> best match in the family.
Ok... but I don't see how that question can possibly be answered
without reference to all the available options.
> Prior to this fix, e.g., a POWER9 DD2.3 KVM host matches to the
> power9_v1.0 class (because that's first in the list). After the patch,
> it matches the power9_v2.0 class.
.. so, doesn't this indicate a problem in the check order, rather than
a problem with the matching function?
>
> Fixes: 03ae4133ab8 ("target-ppc: Add pvr_match() callback")
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
> target/ppc/cpu_init.c | 51 ++++++++++++++++++++++++++++---------------
> 1 file changed, 34 insertions(+), 17 deletions(-)
>
> diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
> index 073fd10168..83ca741bea 100644
> --- a/target/ppc/cpu_init.c
> +++ b/target/ppc/cpu_init.c
> @@ -5910,13 +5910,14 @@ static void init_proc_POWER7(CPUPPCState *env)
>
> static bool ppc_pvr_match_power7(PowerPCCPUClass *pcc, uint32_t pvr)
> {
> - if ((pvr & CPU_POWERPC_POWER_SERVER_MASK) == CPU_POWERPC_POWER7P_BASE) {
> - return true;
> - }
> - if ((pvr & CPU_POWERPC_POWER_SERVER_MASK) == CPU_POWERPC_POWER7_BASE) {
> - return true;
> + uint32_t base = pvr & CPU_POWERPC_POWER_SERVER_MASK;
> + uint32_t pcc_base = pcc->pvr & CPU_POWERPC_POWER_SERVER_MASK;
> +
> + if (base != pcc_base) {
> + return false;
> }
> - return false;
> +
> + return true;
> }
>
> static bool cpu_has_work_POWER7(CPUState *cs)
> @@ -6070,16 +6071,14 @@ static void init_proc_POWER8(CPUPPCState *env)
>
> static bool ppc_pvr_match_power8(PowerPCCPUClass *pcc, uint32_t pvr)
> {
> - if ((pvr & CPU_POWERPC_POWER_SERVER_MASK) == CPU_POWERPC_POWER8NVL_BASE) {
> - return true;
> - }
> - if ((pvr & CPU_POWERPC_POWER_SERVER_MASK) == CPU_POWERPC_POWER8E_BASE) {
> - return true;
> - }
> - if ((pvr & CPU_POWERPC_POWER_SERVER_MASK) == CPU_POWERPC_POWER8_BASE) {
> - return true;
> + uint32_t base = pvr & CPU_POWERPC_POWER_SERVER_MASK;
> + uint32_t pcc_base = pcc->pvr & CPU_POWERPC_POWER_SERVER_MASK;
> +
> + if (base != pcc_base) {
> + return false;
> }
> - return false;
> +
> + return true;
> }
>
> static bool cpu_has_work_POWER8(CPUState *cs)
> @@ -6277,9 +6276,18 @@ static void init_proc_POWER9(CPUPPCState *env)
>
> static bool ppc_pvr_match_power9(PowerPCCPUClass *pcc, uint32_t pvr)
> {
> - if ((pvr & CPU_POWERPC_POWER_SERVER_MASK) == CPU_POWERPC_POWER9_BASE) {
> + uint32_t base = pvr & CPU_POWERPC_POWER_SERVER_MASK;
> + uint32_t pcc_base = pcc->pvr & CPU_POWERPC_POWER_SERVER_MASK;
> +
> + if (base != pcc_base) {
> + return false;
> + }
> +
> + if ((pvr & 0x0f00) == (pcc->pvr & 0x0f00)) {
> + /* Major DD version matches to power9_v1.0 and power9_v2.0 */
> return true;
> }
> +
> return false;
> }
>
> @@ -6489,9 +6497,18 @@ static void init_proc_POWER10(CPUPPCState *env)
>
> static bool ppc_pvr_match_power10(PowerPCCPUClass *pcc, uint32_t pvr)
> {
> - if ((pvr & CPU_POWERPC_POWER_SERVER_MASK) == CPU_POWERPC_POWER10_BASE) {
> + uint32_t base = pvr & CPU_POWERPC_POWER_SERVER_MASK;
> + uint32_t pcc_base = pcc->pvr & CPU_POWERPC_POWER_SERVER_MASK;
> +
> + if (base != pcc_base) {
> + return false;
> + }
> +
> + if ((pvr & 0x0f00) == (pcc->pvr & 0x0f00)) {
> + /* Major DD version matches to power10_v1.0 and power10_v2.0 */
> return true;
> }
> +
> return false;
> }
>
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2022-03-12 9:34 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-07 6:55 [PATCH v3 0/4] Fix PVR matching, add AIL cap compatibility Nicholas Piggin
2022-03-07 6:55 ` [PATCH v3 1/4] target/ppc: Fix masked PVR matching Nicholas Piggin
2022-03-10 17:46 ` Cédric Le Goater
2022-03-11 3:03 ` Alexey Kardashevskiy
2022-03-12 8:45 ` David Gibson [this message]
2022-03-07 6:55 ` [PATCH v3 2/4] target/ppc: Remove chip type field from POWER9 DD2.0 PVR Nicholas Piggin
2022-03-12 8:50 ` David Gibson
2022-03-07 6:55 ` [PATCH v3 3/4] target/ppc: Add POWER9 DD2.2 model Nicholas Piggin
2022-03-07 6:55 ` [PATCH v3 4/4] spapr: Add SPAPR_CAP_AIL_MODE_3 for AIL mode 3 support for H_SET_MODE hcall Nicholas Piggin
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=YixdxnawYgQi9b1H@yekko \
--to=david@gibson.dropbear.id.au \
--cc=aik@ozlabs.ru \
--cc=clg@fr.ibm.com \
--cc=npiggin@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).