[PATCH 2/3] target/ppc: Fix embedded memory barriers

2024-05-01 Thread Nicholas Piggin
Memory barriers are supposed to do something on BookE systems, these were probably just missed during MTTCG enablement, maybe no targets support SMP. Either way, add proper BookE implementations. Signed-off-by: Nicholas Piggin --- target/ppc/translate/misc-impl.c.inc | 4 ++-- 1 file changed, 2

[PATCH 1/3] target/ppc: Move sync instructions to decodetree

2024-05-01 Thread Nicholas Piggin
instruction exceptions when using new POWER10 sync variants that add new fields, after this the instructions are accepted and are implemented as supersets of the new behaviour, as intended. Signed-off-by: Nicholas Piggin --- target/ppc/insn32.decode | 7 ++ target/ppc/translate.c

Re: [PATCH 2/2] ppc/pnv: Implement ADU access to LPC space

2024-05-02 Thread Nicholas Piggin
On Thu May 2, 2024 at 6:32 PM AEST, Cédric Le Goater wrote: > Hello Nick, > > > >>> diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c > >>> index 5869aac89a..eb9dbc62dd 100644 > >>> --- a/hw/ppc/pnv.c > >>> +++ b/hw/ppc/pnv.c > >>> @@ -1642,6 +1642,8 @@ static void pnv_chip_power9_realize(DeviceState > >>>

Re: [PATCH] ppc/pnv: Introduce pnv_chip_foreach_cpu()

2024-05-02 Thread Nicholas Piggin
On Wed Apr 24, 2024 at 7:30 PM AEST, Cédric Le Goater wrote: > This helper routine uses the machine definition, sockets, cores and > threads, to loop on all CPUs of the machine. Replace CPU_FOREACH() > with it. > > Signed-off-by: Cédric Le Goater Reviewed-by: Nicholas Piggin

Re: [PATCH 1/2] ppc/pnv: Begin a more complete ADU LPC model for POWER9/10

2024-05-02 Thread Nicholas Piggin
On Thu May 2, 2024 at 6:47 PM AEST, Cédric Le Goater wrote: > On 5/1/24 14:39, Nicholas Piggin wrote: > > On Wed Apr 17, 2024 at 9:25 PM AEST, Cédric Le Goater wrote: > >> Hello Nick, > >> > >> On 4/17/24 13:02, Nicholas Piggin wrote: > >>> T

Re: [PATCH v2 09/10] ppc: Make Power11 as default cpu type for 'pseries' and 'powernv'

2024-05-02 Thread Nicholas Piggin
On Sat Apr 27, 2024 at 12:32 AM AEST, Cédric Le Goater wrote: > On 4/26/24 13:00, Aditya Gupta wrote: > > Make Power11 as default cpu type for 'pseries' and 'powernv' machine type, > > with Power11 being the newest supported Power processor in QEMU. > > This is too early. We should merge Power11 su

[PATCH] spapr: Migrate ail-mode-3 spapr cap

2024-05-06 Thread Nicholas Piggin
ned-off-by: Nicholas Piggin --- include/hw/ppc/spapr.h | 1 + hw/ppc/spapr.c | 1 + hw/ppc/spapr_caps.c| 1 + 3 files changed, 3 insertions(+) diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 4aaf23d28f..f6de3e9972 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/p

Re: [PATCH 1/2] ppc/pnv: Begin a more complete ADU LPC model for POWER9/10

2024-05-06 Thread Nicholas Piggin
On Fri May 3, 2024 at 3:44 PM AEST, Cédric Le Goater wrote: > On 5/3/24 06:51, Nicholas Piggin wrote: > > On Thu May 2, 2024 at 6:47 PM AEST, Cédric Le Goater wrote: > >> On 5/1/24 14:39, Nicholas Piggin wrote: > >>> On Wed Apr 17, 2024 at 9:25 PM AEST, Cédric Le G

Re: [PATCH v2 04/28] target/ppc: Remove unused helper

2024-05-07 Thread Nicholas Piggin
On Thu May 2, 2024 at 9:43 AM AEST, BALATON Zoltan wrote: > The helper_rac function is defined but not used, remove it. > > Fixes: 005b69fdcc (target/ppc: Remove PowerPC 601 CPUs) > Signed-off-by: BALATON Zoltan Reviwed-by: Nicholas Piggin > --- > target/ppc/helper.h |

Re: [PATCH v2 05/28] target/ppc/mmu_common.c: Move calculation of a value closer to its usage

2024-05-07 Thread Nicholas Piggin
er and avoid computing it when not needed. > > Signed-off-by: BALATON Zoltan Reviwed-by: Nicholas Piggin > --- > target/ppc/mmu_common.c | 11 +-- > 1 file changed, 5 insertions(+), 6 deletions(-) > > diff --git a/target/ppc/mmu_common.c b/target/ppc/mmu_common.c >

Re: [PATCH v2 06/28] target/ppc/mmu_common.c: Move calculation of a value closer to its usage

2024-05-07 Thread Nicholas Piggin
er and avoid computing it when not needed. > > Signed-off-by: BALATON Zoltan Reviwed-by: Nicholas Piggin > --- > target/ppc/mmu_common.c | 25 - > 1 file changed, 12 insertions(+), 13 deletions(-) > > diff --git a/target/ppc/mmu_common.c b/target/pp

Re: [PATCH v2 07/28] target/ppc/mmu_common.c: Remove unneeded local variable

2024-05-07 Thread Nicholas Piggin
te ctx->prot even if the lookup failed, but it already does that in some cases so... no issue. If this was more widely used API we'd rather change it to never update *prot on failure, but okay we can do this. Reviewed-by: Nicholas Piggin > Signed-off-by: BALATON Zoltan > --- >

Re: [PATCH v2 08/28] target/ppc/mmu_common.c: Simplify checking for real mode

2024-05-07 Thread Nicholas Piggin
. Hopefully the compiler should be able to work it out, but IMO it reads better with your change. Reviewed-by: Nicholas Piggin > > Signed-off-by: BALATON Zoltan > --- > target/ppc/mmu_common.c | 6 -- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a

Re: [PATCH v2 09/28] target/ppc/mmu_common.c: Drop cases for unimplemented MPC8xx MMU

2024-05-07 Thread Nicholas Piggin
On Thu May 2, 2024 at 9:43 AM AEST, BALATON Zoltan wrote: > The default case will catch this and abort the same way and there is > still a warning about it in ppc_tlb_invalidate_all() so drop these > from mmu_common.c to simplify this code. Reviewed-by: Nicholas Piggin > >

Re: [PATCH v2 10/28] target/ppc/mmu_common.c: Introduce mmu6xx_get_physical_address()

2024-05-07 Thread Nicholas Piggin
y */ if (env->nb_BATs != 0) { int ret = get_bat_6xx_tlb(env, ctx, eaddr, access_type); if (ret >= 0) { return ret; } } Otherwise, Reviewed-by: Nicholas Piggin > +/* Perform segment based translation when no BATs matched */ > pr =

Re: [PATCH v2 11/28] target/ppc/mmu_common.c: Rename get_bat_6xx_tlb()

2024-05-07 Thread Nicholas Piggin
On Thu May 2, 2024 at 9:43 AM AEST, BALATON Zoltan wrote: > Rename to ppc6xx_tlb_get_bat() to match other similar names in the > same file. > > Signed-off-by: BALATON Zoltan Acked-by: Nicholas Piggin > --- > target/ppc/mmu_common.c | 6 +++--- > 1 file changed, 3 inser

Re: [PATCH v2 12/28] target/ppc/mmu_common.c: Split out BookE cases before checking real mode

2024-05-07 Thread Nicholas Piggin
On Thu May 2, 2024 at 9:43 AM AEST, BALATON Zoltan wrote: > BookE does not have real mode so split off and handle it first in > get_physical_address_wtlb() before checking for real mode for other > MMU models. Reviewed-by: Nicholas Piggin > > Signed-off-by: BALATON Zoltan >

Re: [PATCH v2 13/28] target/ppc/mmu_common.c: Split off real mode cases in get_physical_address_wtlb()

2024-05-07 Thread Nicholas Piggin
On Thu May 2, 2024 at 9:43 AM AEST, BALATON Zoltan wrote: > The real mode handling is identical in the remaining switch cases. > Split off these common real mode cases into a separate conditional to > leave only the else branches in the switch that are different. > Reviewed-by: Nic

Re: [PATCH v2 14/28] target/ppc/mmu_common.c: Inline and remove check_physical()

2024-05-07 Thread Nicholas Piggin
On Thu May 2, 2024 at 9:43 AM AEST, BALATON Zoltan wrote: > This function just does two assignments and and unnecessary check that > is always true so inline it in the only caller left and remove it. Reviewed-by: Nicholas Piggin > > Signed-off-by: BALATON Zoltan > --

Re: [PATCH v2 15/28] target/ppc/mmu_common.c: Simplify mmubooke_get_physical_address()

2024-05-07 Thread Nicholas Piggin
On Thu May 2, 2024 at 9:43 AM AEST, BALATON Zoltan wrote: > Signed-off-by: BALATON Zoltan Reviewed-by: Nicholas Piggin > --- > target/ppc/mmu_common.c | 25 + > 1 file changed, 9 insertions(+), 16 deletions(-) > > diff --git a/target/ppc/mmu_com

Re: [PATCH v2 17/28] target/ppc/mmu_common.c: Fix misindented qemu_log_mask() calls

2024-05-07 Thread Nicholas Piggin
On Thu May 2, 2024 at 9:43 AM AEST, BALATON Zoltan wrote: > Fix several qemu_log_mask() calls that are misindented. Acked-by: Nicholas Piggin > > Signed-off-by: BALATON Zoltan > --- > target/ppc/mmu_common.c | 42 - > 1 file chan

Re: [PATCH v2 16/28] target/ppc/mmu_common.c: Simplify mmubooke206_get_physical_address()

2024-05-07 Thread Nicholas Piggin
nt i, j, ways, ret = -1; > > for (i = 0; i < BOOKE206_MAX_TLBN; i++) { > -int ways = booke206_tlb_ways(env, i); Don't need to bring the ways variable into a larger scope I think? Otherwise, Reviewed-by: Nicholas Piggin > - > +ways = booke206_tlb_ways(env, i);

Re: [PATCH v2 18/28] target/ppc/mmu_common.c: Deindent ppc_jumbo_xlate()

2024-05-07 Thread Nicholas Piggin
static bool ppc_jumbo_xlate(PowerPCCPU *cpu, vaddr > eaddr, > *protp = ctx.prot; > *psizep = TARGET_PAGE_BITS; > return true; > +} else if (!guest_visible) { > +return false; > } Acked-by: Nicholas Piggin > > -if

Re: [PATCH v2 19/28] target/ppc/mmu_common.c: Replace hard coded constants in ppc_jumbo_xlate()

2024-05-07 Thread Nicholas Piggin
cess so using MMU_DATA_LOAD here seems wrong so replace it with > access_type here as well that yields the same result. This also makes > these calls the same as the data access branch further down. Looks right. Reviewed-by: Nicholas Piggin > > Signed-off-by: BALATON Zoltan > --

Re: [PATCH v2 20/28] target/ppc/mmu_common.c: Make get_physical_address_wtlb() static

2024-05-07 Thread Nicholas Piggin
On Thu May 2, 2024 at 9:43 AM AEST, BALATON Zoltan wrote: > This function is not used from any other files so make it static and > fix the maybe used uninitialised warnings this has uncovered. > > Signed-off-by: BALATON Zoltan > --- > target/ppc/internal.h | 5 + > target/ppc/mmu_common.c |

Re: [PATCH v2 21/28] target/ppc: Move mmu_ctx_t definition to mmu_common.c

2024-05-07 Thread Nicholas Piggin
On Thu May 2, 2024 at 9:43 AM AEST, BALATON Zoltan wrote: > This type is only used within mmu_common.c. Move its definition from > internal.h to there. This can be squashed with the previous patch unexport the remaining user. Reviewed-by: Nicholas Piggin > > Signed-off-by: BA

Re: [PATCH v2 22/28] target/ppc: Remove ppc_hash32_pp_prot() and reuse common function

2024-05-07 Thread Nicholas Piggin
On Thu May 2, 2024 at 9:43 AM AEST, BALATON Zoltan wrote: > The ppc_hash32_pp_prot() function in mmu-hash32.c is the same as > pp_check() in mmu_common.c. Rename the latter to ppc_pte_prot() and > merge with ppc_hash32_pp_prot() to remove duplicated code. > > Signed-off-by: BALATON Zoltan > --- >

Re: [PATCH v2 23/28] target/ppc/mmu_common.c: Split off BookE handling from ppc_jumbo_xlate()

2024-05-07 Thread Nicholas Piggin
On Thu May 2, 2024 at 9:43 AM AEST, BALATON Zoltan wrote: > Introduce ppc_booke_xlate() to handle BookE and BookE 2.06 cases to > reduce ppc_jumbo_xlate() further. Nice. > > Signed-off-by: BALATON Zoltan > --- > target/ppc/mmu_common.c | 180 ++-- > 1 file ch

Re: [PATCH v2 24/28] target/ppc/mmu_common.c: Remove BookE handling from get_physical_address_wtlb()

2024-05-07 Thread Nicholas Piggin
On Thu May 2, 2024 at 9:43 AM AEST, BALATON Zoltan wrote: > This function is no longer called for BookE MMU model so remove parts > related to it. This has uncovered a few may be used uninitialised > warnings that are also fixed. > > Signed-off-by: BALATON Zoltan > --- > target/ppc/mmu_common.c |

Re: [PATCH v2 25/28] target/ppc/mmu_common.c: Simplify ppc_booke_xlate()

2024-05-07 Thread Nicholas Piggin
Will review this if we can get -4 case removed... Don't know if I'm too keen on doing the fetch branch first and asymmetric (if vs switch) checking of ret in the fetch vs data cases. I think with -4 case removed things will look much nicer. Thanks, Nick On Thu May 2, 2024 at 9:43 AM AEST, BALATO

Re: [PATCH v2 26/28] target/ppc/mmu_common.c: Move BookE MMU functions together

2024-05-07 Thread Nicholas Piggin
What do you think about adding mmu-book3e.c instead? Thanks, Nick On Thu May 2, 2024 at 9:43 AM AEST, BALATON Zoltan wrote: > Signed-off-by: BALATON Zoltan > --- > target/ppc/mmu_common.c | 300 > 1 file changed, 150 insertions(+), 150 deletions(-) > > d

Re: [PATCH v2 27/28] target/ppc: Remove id_tlbs flag from CPU env

2024-05-07 Thread Nicholas Piggin
he_line_size); > qemu_fdt_setprop_cell(fdt, cp, "i-cache-line-size", >cpu->env.icache_line_size); > -if (cpu->env.id_tlbs) { > +if (cpu->env.tlb_type == TLB_6XX) { Want to just add the standard comment here? /* 6xx h

Re: [PATCH v2 28/28] target/ppc: Split off common 4xx TLB init

2024-05-07 Thread Nicholas Piggin
_74xx(CPUPPCState *env) > return 0; > } > > +static void init_tlbs_4xx(CPUPPCState *env) > +{ > +#ifndef CONFIG_USER_ONLY > +env->nb_tlb = 64; > +env->nb_ways = 1; > +env->tlb_type = TLB_EMB; > +#endif > +} e200 isn't 4xx though is it? Call it i

Re: [PATCH v2 00/28] Misc PPC exception and BookE MMU clean ups

2024-05-07 Thread Nicholas Piggin
On Thu May 2, 2024 at 9:43 AM AEST, BALATON Zoltan wrote: > This series does some further clean up mostly around BookE MMU to > untangle it from other MMU models. It also contains some other changes > that I've come up with while working on this. The first 3 patches are > from the last exception ha

Re: [PATCH v2 26/28] target/ppc/mmu_common.c: Move BookE MMU functions together

2024-05-08 Thread Nicholas Piggin
On Tue May 7, 2024 at 10:31 PM AEST, BALATON Zoltan wrote: > On Tue, 7 May 2024, Nicholas Piggin wrote: > > What do you think about adding mmu-book3e.c instead? > > I have considered that but found that some functions have to be in the > same file and declared static for the

Re: [PATCH v2] ppc: Deprecate 'ref405ep' machine and 405 CPUs

2024-05-08 Thread Nicholas Piggin
this ancient hardware and focus on newer CPUs and platforms. > > Signed-off-by: Cédric Le Goater Acked-by: Nicholas Piggin > --- > v2: fixed header line > > docs/about/deprecated.rst | 8 > hw/ppc/ppc405_boards.c| 1 + > 2 files changed, 9 insertions(+

Re: [PATCH v2 27/28] target/ppc: Remove id_tlbs flag from CPU env

2024-05-08 Thread Nicholas Piggin
On Wed May 8, 2024 at 2:02 AM AEST, BALATON Zoltan wrote: > On Tue, 7 May 2024, Nicholas Piggin wrote: > > On Thu May 2, 2024 at 9:43 AM AEST, BALATON Zoltan wrote: > >> This flag for split instruction/data TLBs is only set for 6xx soft TLB > >> MMU model and not used o

Re: [PATCH v3 09/33] target/ppc/mmu_common.c: Introduce mmu6xx_get_physical_address()

2024-05-08 Thread Nicholas Piggin
r so no need to keep these separate functions and > combining them simplifies the caller allowing further restructuring. > Reviewed-by: Nicholas Piggin > Signed-off-by: BALATON Zoltan > --- > target/ppc/mmu_common.c | 26 -- > 1 file changed, 12 insertion

Re: [PATCH v3 10/33] target/ppc/mmu_common.c: Move else branch to avoid large if block

2024-05-08 Thread Nicholas Piggin
return -3; > +} Function is already inconsistent with assigning ret and falling through to the return ret at the end vs returning immediately, so okay since you're tidying it up. Reviewed-by: Nicholas Piggin > +/* Page address translation */ > +

Re: [PATCH v3 11/33] target/ppc/mmu_common.c: Move some debug logging

2024-05-08 Thread Nicholas Piggin
>prot, ret); > /* Update page flags */ > pte_update_flags(ctx, &env->tlb.tlb6[best].pte1, ret, access_type); > } > +#if defined(DUMP_PAGE_TABLES) > +if (qemu_loglevel_mask(CPU_LOG_MMU)) { > +CPUState *cs = env_cpu(env); > +

Re: [PATCH v3 12/33] target/ppc/mmu_common.c: Eliminate ret from mmu6xx_get_physical_address()

2024-05-08 Thread Nicholas Piggin
On Wed May 8, 2024 at 10:15 AM AEST, BALATON Zoltan wrote: > Return directly, which is simpler than dragging a return value through > multpile if and else blocks. Reviewed-by: Nicholas Piggin > > Signed-off-by: BALATON Zoltan > --- > target/ppc

Re: [PATCH v2 24/28] target/ppc/mmu_common.c: Remove BookE handling from get_physical_address_wtlb()

2024-05-08 Thread Nicholas Piggin
On Wed May 8, 2024 at 9:40 AM AEST, BALATON Zoltan wrote: > On Tue, 7 May 2024, Nicholas Piggin wrote: > > On Thu May 2, 2024 at 9:43 AM AEST, BALATON Zoltan wrote: > >> This function is no longer called for BookE MMU model so remove parts > >> related to it. This has

Re: [PATCH v3 21/33] target/ppc/mmu_common.c: Make get_physical_address_wtlb() static

2024-05-08 Thread Nicholas Piggin
ile. If you add a /* quiet used uninitialized warning */ or similar comment on the memset then. Reviewed-by: Nicholas Piggin If you respin you could, put the prot fixes as their own patch but pretty minor thing if you can't be bothered. > > Signed-off-by: BALATON Zoltan > --

Re: [PATCH v3 23/33] target/ppc/mmu_common.c: Remove BookE from direct store handling

2024-05-08 Thread Nicholas Piggin
On Wed May 8, 2024 at 10:15 AM AEST, BALATON Zoltan wrote: > As BookE never returns -4 we can drop BookE from the direct store case > in ppc_jumbo_xlate(). > > Signed-off-by: BALATON Zoltan Reviewed-by: Nicholas Piggin > --- > target/ppc/mmu_common.c | 7 +-- > 1 file

Re: [PATCH v3 22/33] target/ppc: Remove pp_check() and reuse ppc_hash32_pp_prot()

2024-05-08 Thread Nicholas Piggin
ion from mmu-hash32.c would stop the compiler > inlining it which results in slightly lower performance. Reviewed-by: Nicholas Piggin > > Signed-off-by: BALATON Zoltan > --- > target/ppc/internal.h | 35 >

Re: [PATCH v3 24/33] target/ppc/mmu_common.c: Split off BookE handling from ppc_jumbo_xlate()

2024-05-08 Thread Nicholas Piggin
On Wed May 8, 2024 at 10:15 AM AEST, BALATON Zoltan wrote: > Introduce ppc_booke_xlate() to handle BookE and BookE 2.06 cases to > reduce ppc_jumbo_xlate() further. > Reviewed-by: Nicholas Piggin > Signed-off-by: BALATON Zoltan > --- > target/ppc/

Re: [PATCH v3 25/33] target/ppc/mmu_common.c: Remove BookE handling from get_physical_address_wtlb()

2024-05-08 Thread Nicholas Piggin
On Wed May 8, 2024 at 10:15 AM AEST, BALATON Zoltan wrote: > This function is no longer called for BookE MMU model so remove parts > related to it. This has uncovered a few may be used uninitialised > warnings that are also fixed. > > Signed-off-by: BALATON Zoltan > --- > target/ppc/mmu_common.c

Re: [PATCH v3 26/33] target/ppc/mmu_common.c: Simplify ppc_booke_xlate() part 1

2024-05-08 Thread Nicholas Piggin
On Wed May 8, 2024 at 10:15 AM AEST, BALATON Zoltan wrote: > Move setting error_code that appears in every case out in front and > hoist the common fall through case for BOOKE206 as well which allows > removing the nested switches. > Reviewed-by: Nicholas Piggin > Signed-off-by:

Re: [PATCH v3 27/33] target/ppc/mmu_common.c: Simplify ppc_booke_xlate() part 2

2024-05-08 Thread Nicholas Piggin
On Wed May 8, 2024 at 10:15 AM AEST, BALATON Zoltan wrote: > Merge the code fetch and data access cases in a common switch. > > Signed-off-by: BALATON Zoltan > --- > target/ppc/mmu_common.c | 50 + > 1 file changed, 20 insertions(+), 30 deletions(-) > > dif

Re: [PATCH v3 28/33] target/ppc/mmu_common.c: Move BookE MMU functions together

2024-05-08 Thread Nicholas Piggin
On Wed May 8, 2024 at 10:15 AM AEST, BALATON Zoltan wrote: > Signed-off-by: BALATON Zoltan Okay for now but we should split into a new file soon. Acked-by: Nicholas Piggin > --- > target/ppc/mmu_common.c | 226 > 1 file changed, 113 insert

Re: [PATCH v3 32/33] target/ppc/mmu-radix64.c: Drop a local variable

2024-05-08 Thread Nicholas Piggin
On Wed May 8, 2024 at 10:15 AM AEST, BALATON Zoltan wrote: > The value is only used once so no need to introduce a local variable > for it. Reviewed-by: Nicholas Piggin > > Signed-off-by: BALATON Zoltan > --- > target/ppc/mmu-radix64.c | 5 ++--- > 1 file changed, 2 inser

Re: [PATCH v3 31/33] target/ppc/mmu-hash32.c: Drop a local variable

2024-05-08 Thread Nicholas Piggin
sed once. We can drop the local variable and calculate > it when needed, which makes these checks using it similar to other > places with such checks. Sure, why not. Reviewed-by: Nicholas Piggin > > Signed-off-by: BALATON Zoltan > --- > target/ppc/mmu-hash32.c | 7 ++- &

Re: [PATCH v3 33/33] target/ppc: Add a macro to check for page protection bit

2024-05-08 Thread Nicholas Piggin
On Wed May 8, 2024 at 10:15 AM AEST, BALATON Zoltan wrote: > Checking if a page protection bit is set for a given access type is a > common operation. Add a macro to avoid repeating the same check at > multiple places and also avoid a function call. As this relies on > access type and page protecti

Re: [PATCH v3 01/33] target/ppc: Fix gen_sc to use correct nip

2024-05-08 Thread Nicholas Piggin
On Wed May 8, 2024 at 10:14 AM AEST, BALATON Zoltan wrote: > Most exceptions are raised with nip pointing to the faulting > instruction but the sc instruction generating a syscall exception > leaves nip pointing to next instruction. Fix gen_sc to not use > gen_exception_err() which sets nip back bu

Re: [PATCH v3 01/33] target/ppc: Fix gen_sc to use correct nip

2024-05-08 Thread Nicholas Piggin
On Thu May 9, 2024 at 1:17 AM AEST, BALATON Zoltan wrote: > On Wed, 8 May 2024, Nicholas Piggin wrote: > > On Wed May 8, 2024 at 10:14 AM AEST, BALATON Zoltan wrote: > >> Most exceptions are raised with nip pointing to the faulting > >> instruction but the sc instr

Re: [PATCH v3 33/33] target/ppc: Add a macro to check for page protection bit

2024-05-08 Thread Nicholas Piggin
On Thu May 9, 2024 at 1:23 AM AEST, BALATON Zoltan wrote: > On Wed, 8 May 2024, Nicholas Piggin wrote: > > On Wed May 8, 2024 at 10:15 AM AEST, BALATON Zoltan wrote: > >> Checking if a page protection bit is set for a given access type is a > >> common operation. Add a m

Re: [PATCH v3 26/33] target/ppc/mmu_common.c: Simplify ppc_booke_xlate() part 1

2024-05-08 Thread Nicholas Piggin
On Thu May 9, 2024 at 1:25 AM AEST, BALATON Zoltan wrote: > On Wed, 8 May 2024, Nicholas Piggin wrote: > > On Wed May 8, 2024 at 10:15 AM AEST, BALATON Zoltan wrote: > >> Move setting error_code that appears in every case out in front and > >> hoist the common fall t

Re: [PATCH v2 26/28] target/ppc/mmu_common.c: Move BookE MMU functions together

2024-05-08 Thread Nicholas Piggin
On Thu May 9, 2024 at 9:33 AM AEST, BALATON Zoltan wrote: > On Wed, 8 May 2024, Nicholas Piggin wrote: > > On Tue May 7, 2024 at 10:31 PM AEST, BALATON Zoltan wrote: > >> On Tue, 7 May 2024, Nicholas Piggin wrote: > >>> What do you think about adding mmu-book

Re: [PATCH v3 33/33] target/ppc: Add a macro to check for page protection bit

2024-05-08 Thread Nicholas Piggin
On Thu May 9, 2024 at 9:35 AM AEST, BALATON Zoltan wrote: > On Wed, 8 May 2024, Nicholas Piggin wrote: > > On Wed May 8, 2024 at 10:15 AM AEST, BALATON Zoltan wrote: > >> Checking if a page protection bit is set for a given access type is a > >> common operation. Add a m

Re: [PATCH v4 08/33] target/ppc/mmu_common.c: Drop cases for unimplemented MPC8xx MMU

2024-05-08 Thread Nicholas Piggin
t; called in ppc_cpu_reset_hold() so likely we never get here but to make > sure add a case to ppc_xlate() to the same effect. > > Signed-off-by: BALATON Zoltan Reviewed-by: Nicholas Piggin > --- > target/ppc/mmu_common.c | 12 ++-- > 1 file changed, 2 insertions(+), 10 deleti

Re: [PATCH v4 11/33] target/ppc/mmu_common.c: Move some debug logging

2024-05-08 Thread Nicholas Piggin
On Thu May 9, 2024 at 9:36 AM AEST, BALATON Zoltan wrote: > Move the debug logging within ppc6xx_tlb_check() from after its only > call to simplify the caller. > > Signed-off-by: BALATON Zoltan Reviewed-by: Nicholas Piggin > --- > target/ppc

Re: [PATCH v4 19/33] target/ppc/mmu_common.c: Don't use mmu_ctx_t for mmu40x_get_physical_address()

2024-05-08 Thread Nicholas Piggin
ret = -1; > -raddr = (hwaddr)-1ULL; > +*prot = 0; This is still doing some sneaky used-uninit things which I would rather not without a comment, but okay we can try untangle things more after this series. Reviewed-by: Nicholas Piggin > pr = FIELD_EX64(env->msr, MSR, P

Re: [PATCH v4 20/33] target/ppc/mmu_common.c: Don't use mmu_ctx_t in mmubooke_get_physical_address()

2024-05-08 Thread Nicholas Piggin
On Thu May 9, 2024 at 9:36 AM AEST, BALATON Zoltan wrote: > mmubooke_get_physical_address() only uses the raddr and prot fields > from mmu_ctx_t. Pass these directly instead of using a ctx struct. Reviewed-by: Nicholas Piggin > > Signed-off-by: BALATON Zoltan > --- > targe

Re: [PATCH v4 21/33] target/ppc/mmu_common.c: Don't use mmu_ctx_t in mmubooke206_get_physical_address()

2024-05-08 Thread Nicholas Piggin
On Thu May 9, 2024 at 9:36 AM AEST, BALATON Zoltan wrote: > mmubooke206_get_physical_address() only uses the raddr and prot fields > from mmu_ctx_t. Pass these directly instead of using a ctx struct. > Reviewed-by: Nicholas Piggin > Signed-off-by: BALATON Zoltan > --

Re: [PATCH v4 22/33] target/ppc/mmu_common.c: Make get_physical_address_wtlb() static

2024-05-08 Thread Nicholas Piggin
in this file. get_physical_address_wtlb and mmu_ctx_t is becoming basically 6xx specific after this. Nice. Reviewed-by: Nicholas Piggin > > Signed-off-by: BALATON Zoltan > --- > target/ppc/internal.h | 17 + > target/ppc/mmu_common.c | 17 ++--- > 2 files

Re: [PATCH v4 25/33] target/ppc/mmu_common.c: Split off BookE handling from ppc_jumbo_xlate()

2024-05-08 Thread Nicholas Piggin
On Thu May 9, 2024 at 9:36 AM AEST, BALATON Zoltan wrote: > Introduce ppc_booke_xlate() to handle BookE and BookE 2.06 cases to > reduce ppc_jumbo_xlate() further. > Reviewed-by: Nicholas Piggin > Signed-off-by: BALATON Zoltan > --- > target/ppc/

Re: [PATCH v4 27/33] target/ppc/mmu_common.c: Simplify ppc_booke_xlate() part 2

2024-05-08 Thread Nicholas Piggin
On Thu May 9, 2024 at 9:36 AM AEST, BALATON Zoltan wrote: > Merge the code fetch and data access cases in a common switch. > > Signed-off-by: BALATON Zoltan Reviewed-by: Nicholas Piggin > --- > target/ppc/mmu_common.c | 52 - >

Re: [PATCH v4 33/33] target/ppc: Move out BookE and related MMU functions from mmu_common.c

2024-05-08 Thread Nicholas Piggin
On Thu May 9, 2024 at 9:36 AM AEST, BALATON Zoltan wrote: > Add a new mmu-booke.c file for BookE and related MMU bits from > mmu_common.c. > Nice work. Acked-by: Nicholas Piggin > Signed-off-by: BALATON Zoltan > --- > target/ppc/cpu.h| 4 - > target/p

[PATCH v2 2/2] ppc/pnv: Implement ADU access to LPC space

2024-05-10 Thread Nicholas Piggin
. This requires a linkage between adu and lpc, which allows adu to perform memory access in the lpc space. Signed-off-by: Nicholas Piggin --- include/hw/ppc/pnv_adu.h | 7 +++ include/hw/ppc/pnv_lpc.h | 5 +++ hw/ppc/pnv.c | 4 ++ hw/ppc/pnv_adu.c | 95

[PATCH v2 1/2] ppc/pnv: Begin a more complete ADU LPC model for POWER9/10

2024-05-10 Thread Nicholas Piggin
XSCOM bridge implementation, and pnv_adu.c implements the ADU registers and other functions. So far, just the ADU no-op registers in the pnv_xscom.c default handler are moved over to the adu model. Signed-off-by: Nicholas Piggin --- include/hw/ppc/pnv_adu.h | 25 + include/hw/ppc

[PATCH v2 0/2] ppc/pnv: ADU model for POWER9/10

2024-05-10 Thread Nicholas Piggin
u-lpc link - Renamed funcions to pnv_lpc_opb_ prefix rather than pnv_opb_lpc_ - Removed the unnecessary ADU class Thanks, Nick Nicholas Piggin (2): ppc/pnv: Begin a more complete ADU LPC model for POWER9/10 ppc/pnv: Implement ADU access to LPC space include/hw/ppc/pnv_adu.h | 32 ++ incl

[PATCH] ppc/pnv: Implement POWER9 LPC PSI serirq outputs and auto-clear function

2024-05-10 Thread Nicholas Piggin
psi#0:lpc_serirq_mux1 Whereas they previously turn up on lpchc. Signed-off-by: Nicholas Piggin --- include/hw/ppc/pnv_lpc.h | 12 - hw/ppc/pnv.c | 38 +-- hw/ppc/pnv_lpc.c | 100 +++ 3 files changed, 136 insertions(+), 14 deletions(-)

Re: [PATCH 3/6] target/ppc: Fix instruction loading endianness in alignment interrupt

2023-03-26 Thread Nicholas Piggin
ing, and actually I did catch some of these (the SPR size one) when running kvm-unit-tests with TCG. I ported it to powernv too. I wonder if we should merge pnv-test into kvm-unit-tests. > > Signed-off-by: Nicholas Piggin > > --- > > target/ppc/excp_helper.c | 27 +++

Re: [PATCH 4/6] target/ppc: Alignment faults do not set DSISR in ISA v3.0 onward

2023-03-26 Thread Nicholas Piggin
On Fri Mar 24, 2023 at 11:39 PM AEST, Fabiano Rosas wrote: > Nicholas Piggin writes: > > > This optional behavior was removed from the ISA in v3.0, see > > Summary of Changes preface: > > > > Data Storage Interrupt Status Register for Alignment Interrupt:

[PATCH v2 1/6] target/ppc: Fix width of some 32-bit SPRs

2023-03-27 Thread Nicholas Piggin
implement finer details of SPR implementation (e.g., not all bits implemented as simple read/write storage). Signed-off-by: Nicholas Piggin --- target/ppc/cpu_init.c| 18 +- target/ppc/helper_regs.c | 2 +- target/ppc/misc_helper.c | 4 ++-- target/ppc/power8-pmu.c | 2

[PATCH v2 6/6] target/ppc: Implement HEIR SPR

2023-03-27 Thread Nicholas Piggin
The hypervisor emulation assistance interrupt modifies HEIR to contain the value of the instruction which caused the exception. Signed-off-by: Nicholas Piggin --- target/ppc/cpu.h | 1 + target/ppc/cpu_init.c| 23 +++ target/ppc/excp_helper.c | 12

[PATCH v2 2/6] target/ppc: Better CTRL SPR implementation

2023-03-27 Thread Nicholas Piggin
The CTRL register is able to write bit zero, and that is reflected in a bit field in the register that reflects the state of all threads in the core. TCG does not implement SMT, so this just requires mirroring that bit into the first bit of the thread state field. Signed-off-by: Nicholas Piggin

[PATCH v2 4/6] target/ppc: Alignment faults do not set DSISR in ISA v3.0 onward

2023-03-27 Thread Nicholas Piggin
by the Alignment interrupt. Signed-off-by: Nicholas Piggin --- Since v1: - Use insns_flags instead of excp_model [Fabiano review] target/ppc/excp_helper.c | 17 ++--- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c

[PATCH v2 5/6] target/ppc: Add SRR1 prefix indication to interrupt handlers

2023-03-27 Thread Nicholas Piggin
ISA v3.1 introduced prefix instructions. Among the changes, various synchronous interrupts report whether they were caused by a prefix instruction in (H)SRR1. Signed-off-by: Nicholas Piggin --- Since v1: - Use insns_flags instead of excp_model [Fabiano review] target/ppc/excp_helper.c | 32

[PATCH v2 3/6] target/ppc: Fix instruction loading endianness in alignment interrupt

2023-03-27 Thread Nicholas Piggin
powerpc ifetch endianness depends on MSR[LE] so it has to byteswap after cpu_ldl_code(). This corrects DSISR bits in alignment interrupts when running in little endian mode. Signed-off-by: Nicholas Piggin --- Since v1: - Removed big endian ifdef [Fabiano review] - Acaually use need_byswap helper

Re: [PATCH v2 6/6] target/ppc: Implement HEIR SPR

2023-04-01 Thread Nicholas Piggin
On Wed Mar 29, 2023 at 3:51 PM AEST, Michael Neuling wrote: > Nick, > > > +case POWERPC_EXCP_HV_EMU: > > +env->spr[SPR_HEIR] = insn; > > +if (is_prefix_excp(env, insn)) { > > +uint32_t insn2 = ppc_ldl_code(env, env->nip + 4); > > +env->spr[SPR_HEIR] |= (u

assert !temp_readonly(ts) in tcg_reg_alloc_op

2023-04-07 Thread Nicholas Piggin
I get a crash running a powerpc64 TCG machine on x86. It can be triggered by booting a custom vmlinux patched to use powerpc prefix instructions and pcrel addressing, I don't know if that's related or coincidence. I can give Linux patches or a vmlinux file to reproduce if needed, or I can test pat

Re: assert !temp_readonly(ts) in tcg_reg_alloc_op

2023-04-07 Thread Nicholas Piggin
On Fri Apr 7, 2023 at 7:02 PM AEST, Nicholas Piggin wrote: > I get a crash running a powerpc64 TCG machine on x86. > > It can be triggered by booting a custom vmlinux patched to use powerpc > prefix instructions and pcrel addressing, I don't know if that's related > o

Re: [PATCH for-8.0 v2] target/ppc: Fix temp usage in gen_op_arith_modw

2023-04-08 Thread Nicholas Piggin
("target/ppc: Avoid tcg_const_* in translate.c") > > Reported-by: Nicholas Piggin > > Reviewed-by: Anton Johansson > > Signed-off-by: Richard Henderson > > Looks good: > >https://gitlab.com/legoater/qemu/-/pipelines/831847446 > > I have a PR ready for

Re: [RFC PATCH 2/4] spapr: Add a nested state struct

2023-05-12 Thread Nicholas Piggin
On Fri May 5, 2023 at 8:54 PM AEST, Harsh Prateek Bora wrote: > > > On 5/3/23 06:09, Nicholas Piggin wrote: > > @@ -1593,12 +1713,14 @@ static target_ulong h_enter_nested(PowerPCCPU *cpu, > > return H_PARAMETER; > > } > > > > -s

Re: [RFC PATCH 3/4] spapr: load and store l2 state with helper functions

2023-05-12 Thread Nicholas Piggin
On Fri May 5, 2023 at 9:03 PM AEST, Harsh Prateek Bora wrote: > > > On 5/3/23 06:09, Nicholas Piggin wrote: > > Arguably this is just shuffling around register accesses, but one nice > > thing it does is allow the exit to save away the L2 state then switch > > the e

Re: [RFC PATCH 4/4] spapr: Move spapr nested HV to a new file

2023-05-12 Thread Nicholas Piggin
On Fri May 5, 2023 at 9:09 PM AEST, Harsh Prateek Bora wrote: > > > On 5/3/23 06:09, Nicholas Piggin wrote: > > Create spapr_nested.c for the nested HV implementation (modulo small > > pieces in MMU and exception handling). > > > This separation of nested code in it

Re: [PATCH] target: ppc: Correctly initialize HILE in HID-0 for book3s processors

2023-05-14 Thread Nicholas Piggin
On Sat Apr 29, 2023 at 12:30 AM AEST, Fabiano Rosas wrote: > Vaibhav Jain writes: > > > Hi Fabiano, > > > > Thanks for looking into this patch and apologies for the delayed reponse. > > Fabiano Rosas writes: > > > >> Narayana Murty N writes: > >> > >>> On PPC64 the HILE(Hypervisor Interrupt Litt

Re: [PATCH 6/6] target/ppc: Implement HEIR SPR

2023-05-15 Thread Nicholas Piggin
On Tue May 9, 2023 at 7:51 PM AEST, Harsh Prateek Bora wrote: > On Thu, Mar 23, 2023 at 12:22:37PM +1000, Nicholas Piggin wrote: > > The hypervisor emulation assistance interrupt modifies HEIR to > > contain the value of the instruction which caused the exception. > > > &

[PATCH v3 1/9] target/ppc: Fix width of some 32-bit SPRs

2023-05-15 Thread Nicholas Piggin
implement finer details of SPR implementation (e.g., not all bits implemented as simple read/write storage). Signed-off-by: Nicholas Piggin --- Since v2: no change. target/ppc/cpu_init.c| 18 +- target/ppc/helper_regs.c | 2 +- target/ppc/misc_helper.c | 4 ++-- target/ppc

[PATCH v3 7/9] target/ppc: Implement HEIR SPR

2023-05-15 Thread Nicholas Piggin
The hypervisor emulation assistance interrupt modifies HEIR to contain the value of the instruction which caused the exception. Signed-off-by: Nicholas Piggin --- Since v2: - Fix ordering of prefix/suffix words in the register, as pointed out by Mikey. target/ppc/cpu.h | 1 + target

[PATCH v3 3/9] target/ppc: Fix instruction loading endianness in alignment interrupt

2023-05-15 Thread Nicholas Piggin
powerpc ifetch endianness depends on MSR[LE] so it has to byteswap after cpu_ldl_code(). This corrects DSISR bits in alignment interrupts when running in little endian mode. Reviewed-by: Fabiano Rosas Signed-off-by: Nicholas Piggin --- Since v2: no change. target/ppc/excp_helper.c | 20

[PATCH v3 0/9] target/ppc: Assorted ppc target fixes

2023-05-15 Thread Nicholas Piggin
Hopefully these are getting close to ready now. There is still the question about doing better with adding test cases for all this, I haven't exactly got a good answer yet but I do have kvm-unit-tests for most at least. Thanks, Nick Nicholas Piggin (9): target/ppc: Fix width of some 3

[PATCH v3 9/9] target/ppc: Better CTRL SPR implementation

2023-05-15 Thread Nicholas Piggin
The CTRL register is able to write bit zero, and that is reflected in a bit field in the register that reflects the state of all threads in the core. TCG does not implement SMT, so this just requires mirroring that bit into the first bit of the thread state field. Signed-off-by: Nicholas Piggin

[PATCH v3 4/9] target/ppc: Alignment faults do not set DSISR in ISA v3.0 onward

2023-05-15 Thread Nicholas Piggin
by the Alignment interrupt. Reviewed-by: Fabiano Rosas Signed-off-by: Nicholas Piggin --- Since v2: no change. target/ppc/excp_helper.c | 17 ++--- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c index bc2be4a726

[PATCH v3 5/9] target/ppc: Change partition-scope translate interface

2023-05-15 Thread Nicholas Piggin
will allow more information to be passed to the exception handler in the next patch. Signed-off-by: Nicholas Piggin --- Since v2: new patch to deal with bug in patch 6. target/ppc/mmu-radix64.c | 24 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/target

[PATCH v3 2/9] target/ppc: Fix PMU MMCR0[PMCjCE] bit in hflags calculation

2023-05-15 Thread Nicholas Piggin
A store to MMCR0 with PMCjCE=1 fails to update hflags correctly and results in hflags mismatch: qemu: fatal: TCG hflags mismatch (current:0x2408003d rebuilt:0x240a003d) This can be reproduced by running perf on a recent machine. Signed-off-by: Nicholas Piggin --- Since v2: new patch

[PATCH v3 6/9] target/ppc: Add SRR1 prefix indication to interrupt handlers

2023-05-15 Thread Nicholas Piggin
from a load or store instruction (in that case the prefix bit should be provided). Reviewed-by: Fabiano Rosas Signed-off-by: Nicholas Piggin --- Since v2: - Fix a bug where ifetch access causing HDSI due to process scoped table access failing on partition scope translation would go into infinite

[PATCH v3 8/9] target/ppc: Add ISA v3.1 LEV indication in SRR1 for system call interrupts

2023-05-15 Thread Nicholas Piggin
System call interrupts in ISA v3.1 CPUs add a LEV indication in SRR1 that corresponds with the LEV field of the instruction that caused the interrupt. Signed-off-by: Nicholas Piggin --- Since v2: new patch. target/ppc/excp_helper.c | 4 1 file changed, 4 insertions(+) diff --git a/target

Re: [PATCH 6/6] target/ppc: Implement HEIR SPR

2023-05-15 Thread Nicholas Piggin
On Mon May 15, 2023 at 7:32 PM AEST, Harsh Prateek Bora wrote: > > > On 5/15/23 14:02, Harsh Prateek Bora wrote: > >> > >> That would be wrong for the other HSRR fallthroughs above it. > >> > > Oh yeh, in that case, may be move it to top of the EXCP_HISI, it would > > need duplicating one line of

<    1   2   3   4   5   6   7   8   9   10   >