Message ID | 20240606121657.254308-6-adityag@linux.ibm.com |
---|---|
State | New |
Headers | show |
Series | Power11 support for QEMU [PSeries] | expand |
On Thu Jun 6, 2024 at 10:16 PM AEST, Aditya Gupta wrote: > Power11 has the same PCR (Processor Compatibility Register) value, as > Power10. > > Due to this, QEMU considers Power11 as a valid compat-mode for Power10, > ie. earlier it was possible to run QEMU with '-M pseries,max-compat-mode=power11 --cpu power10' Isn't this expected to work, or no? > > Same PCR also introduced a regression where `-M pseries --cpu power10` > boots as Power11 (ie. logical PVR is of Power11, even though PVR is Power10). > The regression was due to 'do_client_architecture_support' checking for > valid compat modes and finding Power11 to be a valid compat mode for > Power10 (it happens even without passing 'max-compat-mode' explicitly). > > Fix compat-mode issue and regression, by ensuring a future Power > processor (with a higher logical_pvr value, eg. P11) cannot be valid > compat-mode for an older Power processor (eg. P10) This should be done before introducing the Power11 CPU so there's no regression inside the series. > > Cc: Cédric Le Goater <clg@kaod.org> > Cc: Daniel Henrique Barboza <danielhb413@gmail.com> > Cc: Harsh Prateek Bora <harshpb@linux.ibm.com> > Cc: Mahesh J Salgaonkar <mahesh@linux.ibm.com> > Cc: Madhavan Srinivasan <maddy@linux.ibm.com> > Cc: Nicholas Piggin <npiggin@gmail.com> > Signed-off-by: Aditya Gupta <adityag@linux.ibm.com> > --- > target/ppc/compat.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/target/ppc/compat.c b/target/ppc/compat.c > index 12dd8ae290ca..168a3c06316f 100644 > --- a/target/ppc/compat.c > +++ b/target/ppc/compat.c > @@ -139,6 +139,10 @@ static bool pcc_compat(PowerPCCPUClass *pcc, uint32_t compat_pvr, > /* Outside specified range */ > return false; > } > + if (compat->pvr > pcc->logical_pvr) { > + /* Older CPU cannot support a newer processor's compat mode */ > + return false; > + } Hmm. I suppose this is the right way to fix it. Reviewed-by: Nicholas Piggin <npiggin@gmail.com> > if (!(pcc->pcr_supported & compat->pcr_level)) { > /* Not supported by this CPU */ > return false;
On 23/07/24 10:28, Nicholas Piggin wrote: > On Thu Jun 6, 2024 at 10:16 PM AEST, Aditya Gupta wrote: >> Power11 has the same PCR (Processor Compatibility Register) value, as >> Power10. >> >> Due to this, QEMU considers Power11 as a valid compat-mode for Power10, >> ie. earlier it was possible to run QEMU with '-M pseries,max-compat-mode=power11 --cpu power10' > Isn't this expected to work, or no? It works, but it didn't feel logical to be able to boot an older CPU in a compat mode of a newer CPU. Major reason though, it caused regression where `-M pseries --cpu power10` was booting as Power11, since Power11 was the highest PCR it found as compatible. The only issue I see in this patch is the assumption that a newer processor must always have a higher PVR value, which is true as of now. > >> Same PCR also introduced a regression where `-M pseries --cpu power10` >> boots as Power11 (ie. logical PVR is of Power11, even though PVR is Power10). >> The regression was due to 'do_client_architecture_support' checking for >> valid compat modes and finding Power11 to be a valid compat mode for >> Power10 (it happens even without passing 'max-compat-mode' explicitly). >> >> Fix compat-mode issue and regression, by ensuring a future Power >> processor (with a higher logical_pvr value, eg. P11) cannot be valid >> compat-mode for an older Power processor (eg. P10) > This should be done before introducing the Power11 CPU so there's no > regression inside the series. Sure, I will move it before the 'Add Power11 DD2.0 processor' patch. >> Cc: Cédric Le Goater <clg@kaod.org> >> Cc: Daniel Henrique Barboza <danielhb413@gmail.com> >> Cc: Harsh Prateek Bora <harshpb@linux.ibm.com> >> Cc: Mahesh J Salgaonkar <mahesh@linux.ibm.com> >> Cc: Madhavan Srinivasan <maddy@linux.ibm.com> >> Cc: Nicholas Piggin <npiggin@gmail.com> >> Signed-off-by: Aditya Gupta <adityag@linux.ibm.com> >> --- >> target/ppc/compat.c | 4 ++++ >> 1 file changed, 4 insertions(+) >> >> diff --git a/target/ppc/compat.c b/target/ppc/compat.c >> index 12dd8ae290ca..168a3c06316f 100644 >> --- a/target/ppc/compat.c >> +++ b/target/ppc/compat.c >> @@ -139,6 +139,10 @@ static bool pcc_compat(PowerPCCPUClass *pcc, uint32_t compat_pvr, >> /* Outside specified range */ >> return false; >> } >> + if (compat->pvr > pcc->logical_pvr) { >> + /* Older CPU cannot support a newer processor's compat mode */ >> + return false; >> + } > Hmm. I suppose this is the right way to fix it. > > Reviewed-by: Nicholas Piggin <npiggin@gmail.com> Thank you for the tag, Nick ! - Aditya Gupta >> if (!(pcc->pcr_supported & compat->pcr_level)) { >> /* Not supported by this CPU */ >> return false;
diff --git a/target/ppc/compat.c b/target/ppc/compat.c index 12dd8ae290ca..168a3c06316f 100644 --- a/target/ppc/compat.c +++ b/target/ppc/compat.c @@ -139,6 +139,10 @@ static bool pcc_compat(PowerPCCPUClass *pcc, uint32_t compat_pvr, /* Outside specified range */ return false; } + if (compat->pvr > pcc->logical_pvr) { + /* Older CPU cannot support a newer processor's compat mode */ + return false; + } if (!(pcc->pcr_supported & compat->pcr_level)) { /* Not supported by this CPU */ return false;
Power11 has the same PCR (Processor Compatibility Register) value, as Power10. Due to this, QEMU considers Power11 as a valid compat-mode for Power10, ie. earlier it was possible to run QEMU with '-M pseries,max-compat-mode=power11 --cpu power10' Same PCR also introduced a regression where `-M pseries --cpu power10` boots as Power11 (ie. logical PVR is of Power11, even though PVR is Power10). The regression was due to 'do_client_architecture_support' checking for valid compat modes and finding Power11 to be a valid compat mode for Power10 (it happens even without passing 'max-compat-mode' explicitly). Fix compat-mode issue and regression, by ensuring a future Power processor (with a higher logical_pvr value, eg. P11) cannot be valid compat-mode for an older Power processor (eg. P10) Cc: Cédric Le Goater <clg@kaod.org> Cc: Daniel Henrique Barboza <danielhb413@gmail.com> Cc: Harsh Prateek Bora <harshpb@linux.ibm.com> Cc: Mahesh J Salgaonkar <mahesh@linux.ibm.com> Cc: Madhavan Srinivasan <maddy@linux.ibm.com> Cc: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Aditya Gupta <adityag@linux.ibm.com> --- target/ppc/compat.c | 4 ++++ 1 file changed, 4 insertions(+)