ppc-for-10.0-1 queue
Subsystems (2)
Nicholas Piggin
reviewer[PULL 57/72] hw/ppc/spapr: Convert CLEAN_HPTE() macro as hpte_set_clean() method
In reply to Nicholas PigginFrom: Philippe Mathieu-Daudé <[email protected]>
Convert CLEAN_HPTE() macro as hpte_set_clean() method.
sPAPR data structures including the hash page table are big-endian regardless of current CPU endian mode, so use the big-endian LD/ST API to access the hash PTEs.
Message-ID: <[email protected]>
--- hw/ppc/spapr.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
hw/ppc/spapr.c +10 -5
@@ -1419,7 +1419,12 @@ static bool hpte_is_dirty(SpaprMachineState *s, unsigned index)return ldq_be_p (hpte_get_ptr (s, index)) &HPTE64_V_HPTE_DIRTY ; } -#define CLEAN_HPTE (_hpte) ((*(uint64_t *)(_hpte)) &= tswap64(~HPTE64_V_HPTE_DIRTY)) +static void hpte_set_clean (SpaprMachineState *s,unsigned index) +{ +stq_be_p (hpte_get_ptr (s, index), +ldq_be_p (hpte_get_ptr (s, index)) & ~HPTE64_V_HPTE_DIRTY ); +} +#define DIRTY_HPTE (_hpte) ((*(uint64_t *)(_hpte)) |= tswap64(HPTE64_V_HPTE_DIRTY))/*
@@ -2215,7 +2220,7 @@ static void htab_save_first_pass(QEMUFile *f, SpaprMachineState *spapr,/* Consume invalid HPTEs */ while ((index < htabslots) && !hpte_is_valid (spapr, index)) { -CLEAN_HPTE (hpte_get_ptr (spapr, index)); +hpte_set_clean (spapr, index); index++; }
@@ -2223,7 +2228,7 @@ static void htab_save_first_pass(QEMUFile *f, SpaprMachineState *spapr, chunkstart = index;while ((index < htabslots) && (index - chunkstart <USHRT_MAX ) &&hpte_is_valid (spapr, index)) { -CLEAN_HPTE (hpte_get_ptr (spapr, index)); +hpte_set_clean (spapr, index); index++; }
@@ -2273,7 +2278,7 @@ static int htab_save_later_pass(QEMUFile *f, SpaprMachineState *spapr,while ((index < htabslots) && (index - chunkstart <USHRT_MAX ) &&hpte_is_dirty (spapr, index) &&hpte_is_valid (spapr, index)) { -CLEAN_HPTE (hpte_get_ptr (spapr, index)); +hpte_set_clean (spapr, index); index++; examined++; }
@@ -2283,7 +2288,7 @@ static int htab_save_later_pass(QEMUFile *f, SpaprMachineState *spapr,while ((index < htabslots) && (index - invalidstart <USHRT_MAX ) &&hpte_is_dirty (spapr, index) && !hpte_is_valid (spapr, index)) { -CLEAN_HPTE (hpte_get_ptr (spapr, index)); +hpte_set_clean (spapr, index); index++; examined++; }
Signature · 1 line
2.47.1
Nicholas Piggin
reviewer[PULL 47/72] target/ppc: Restrict powerpc_checkstop() to TCG
In reply to Nicholas PigginFrom: Philippe Mathieu-Daudé <[email protected]>
Expose powerpc_checkstop() prototype, and move it to tcg-excp_helper.c, only built when TCG is available.
Message-ID: <[email protected]>
--- target/ppc/excp_helper.c | 26 -------------------------- target/ppc/internal.h | 4 +++- target/ppc/tcg-excp_helper.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 27 deletions(-)
target/ppc/excp_helper.c +0 -26
@@ -400,32 +400,6 @@ static void powerpc_set_excp_state(PowerPCCPU *cpu, target_ulong vector, } #ifdef CONFIG_TCG -/* - * This stops the machine and logs CPU state without killing QEMU (like - * cpu_abort()) because it is often a guest error as opposed to a QEMU error, - * so the machine can still be debugged. - */ -static G_NORETURN void powerpc_checkstop(CPUPPCState *env, const char *reason) -{ - CPUState *cs = env_cpu(env); - FILE *f; - - f = qemu_log_trylock(); - if (f) { - fprintf(f, "Entering checkstop state: %s\n", reason); - cpu_dump_state(cs, f, CPU_DUMP_FPU | CPU_DUMP_CCOP); - qemu_log_unlock(f); - } - - /* - * This stops the machine and logs CPU state without killing QEMU - * (like cpu_abort()) so the machine can still be debugged (because - * it is often a guest error). - */ - qemu_system_guest_panicked(NULL); - cpu_loop_exit_noexc(cs); -} - #if defined(TARGET_PPC64) && !defined(CONFIG_USER_ONLY) void helper_attn(CPUPPCState *env) {
target/ppc/internal.h +3 -1
@@ -289,7 +289,9 @@ void ppc_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,void ppc_cpu_debug_excp_handler (CPUState *cs);bool ppc_cpu_debug_check_breakpoint (CPUState *cs);bool ppc_cpu_debug_check_watchpoint (CPUState *cs,CPUWatchpoint *wp); -#endif + +G_NORETURN void powerpc_checkstop(CPUPPCState *env, const char *reason); +#endif /* !CONFIG_USER_ONLY */ FIELD(GER_MSK, XMSK, 0, 4)FIELD (GER_MSK ,YMSK ,4 ,4 )
target/ppc/tcg-excp_helper.c +28 -0
@@ -17,7 +17,9 @@* License along with this library; if not, see <http://www.gnu.org/licenses/>. */ #include "qemu/osdep.h" +#include "qemu/log.h" #include "exec/cpu_ldst.h" +#include "system/runstate.h" #include "hw/ppc/ppc.h" #include "internal.h"
@@ -199,6 +201,32 @@ bool ppc_cpu_debug_check_watchpoint(CPUState *cs, CPUWatchpoint *wp)return false; } +/* +* This stops the machine and logs CPU state without killing QEMU (like +* cpu_abort()) because it is often a guest error as opposed to a QEMU error, +* so the machine can still be debugged. +*/ +G_NORETURN void powerpc_checkstop(CPUPPCState *env, const char *reason) +{ +CPUState *cs =env_cpu (env); +FILE *f; + + f =qemu_log_trylock (); +if (f) { +fprintf (f,"Entering checkstop state: %s\n" , reason); +cpu_dump_state (cs, f,CPU_DUMP_FPU |CPU_DUMP_CCOP ); +qemu_log_unlock (f); + } + +/* +* This stops the machine and logs CPU state without killing QEMU +* (like cpu_abort()) so the machine can still be debugged (because +* it is often a guest error). +*/ +qemu_system_guest_panicked (NULL ); +cpu_loop_exit_noexc (cs); +} +/* Return true iff byteswap is needed to load instruction */ static inline bool insn_need_byteswap (CPUArchState *env) {
Signature · 1 line
2.47.1
Nicholas Piggin
reviewer[PULL 64/72] target/ppc: Wire up BookE ATB registers for e500 family
In reply to Nicholas PigginFrom the Freescale PowerPC Architecture Primer:
Alternate time base APU. This APU, implemented on the e500v2, defines a 64-bit time base counter that differs from the PowerPC defined time base in that it is not writable and counts at a different, and typically much higher, frequency. The alternate time base always counts up, wrapping when the 64-bit count overflows.
This implementation of ATB uses the same frequency as the TB. The existing spr_read_atbu/l functions are unused without this patch to wire them into the SPR.
RTEMS uses this SPR on the e6500, though this hasn't been tested.
Message-ID: <[email protected]>
--- target/ppc/cpu_init.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
target/ppc/cpu_init.c +17 -0
@@ -922,6 +922,18 @@ static void register_BookE206_sprs(CPUPPCState *env, uint32_t mas_mask,#endif } +static void register_atb_sprs (CPUPPCState *env) +{ +spr_register (env,SPR_ATBL ,"ATBL" , + &spr_read_atbl,SPR_NOACCESS , + &spr_read_atbl,SPR_NOACCESS , +0x00000000 ); +spr_register (env,SPR_ATBU ,"ATBU" , + &spr_read_atbu,SPR_NOACCESS , + &spr_read_atbu,SPR_NOACCESS , +0x00000000 ); +} +/* SPR specific to PowerPC 440 implementation */ static void register_440_sprs (CPUPPCState *env) {
@@ -2911,6 +2923,11 @@ static void init_proc_e500(CPUPPCState *env, int version)register_BookE206_sprs (env,0x000000DF , tlbncfg, mmucfg);register_usprgh_sprs (env); +if (version != fsl_e500v1) { +/* e500v1 has no support for alternate timebase */ +register_atb_sprs (env); + } + spr_register(env, SPR_HID0, "HID0", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic,
Signature · 1 line
2.47.1
Nicholas Piggin
reviewer[PULL 60/72] ppc: Enable 2nd DAWR support on Power10 PowerNV machine
In reply to Nicholas PigginFrom: Shivaprasad G Bhat <[email protected]>
Extend the existing watchpoint facility from TCG DAWR0 emulation to DAWR1 on POWER10.
Message-ID: <[email protected]>
--- target/ppc/cpu.c | 45 +++++++++++++++++++-------- target/ppc/cpu.h | 6 ++-- target/ppc/cpu_init.c | 15 +++++++++ target/ppc/helper.h | 2 ++ target/ppc/machine.c | 3 +- target/ppc/misc_helper.c | 10 ++++++ target/ppc/spr_common.h | 2 ++ target/ppc/tcg-excp_helper.c | 59 +++++++++++++++++++----------------- target/ppc/translate.c | 12 ++++++++ 9 files changed, 110 insertions(+), 44 deletions(-)
target/ppc/cpu.c +32 -13
@@ -130,11 +130,13 @@ void ppc_store_ciabr(CPUPPCState *env, target_ulong val)ppc_update_ciabr (env); } -void ppc_update_daw0 (CPUPPCState *env) +void ppc_update_daw (CPUPPCState *env,int rid) {CPUState *cs =env_cpu (env); -target_ulong deaw = env->spr[SPR_DAWR0 ] &PPC_BITMASK (0 ,60 ); -uint32_t dawrx = env->spr[SPR_DAWRX0 ]; +int spr_dawr = rid ?SPR_DAWR1 :SPR_DAWR0 ; +int spr_dawrx = rid ?SPR_DAWRX1 :SPR_DAWRX0 ; +target_ulong deaw = env->spr[spr_dawr] &PPC_BITMASK (0 ,60 ); +uint32_t dawrx = env->spr[spr_dawrx];int mrd =extract32 (dawrx,PPC_BIT_NR (48 ),54 -48 );bool dw =extract32 (dawrx,PPC_BIT_NR (57 ),1 );bool dr =extract32 (dawrx,PPC_BIT_NR (58 ),1 );
@@ -144,9 +146,9 @@ void ppc_update_daw0(CPUPPCState *env)vaddr len;int flags; -if (env->dawr0_watchpoint) { -cpu_watchpoint_remove_by_ref (cs, env->dawr0_watchpoint); - env->dawr0_watchpoint =NULL ; +if (env->dawr_watchpoint[rid]) { +cpu_watchpoint_remove_by_ref (cs, env->dawr_watchpoint[rid]); + env->dawr_watchpoint[rid] =NULL ; }if (!dr && !dw) {
@@ -166,28 +168,45 @@ void ppc_update_daw0(CPUPPCState *env) flags |=BP_MEM_WRITE ; } -cpu_watchpoint_insert (cs, deaw, len, flags, &env->dawr0_watchpoint); +cpu_watchpoint_insert (cs, deaw, len, flags, &env->dawr_watchpoint[rid]); }void ppc_store_dawr0 (CPUPPCState *env,target_ulong val) { env->spr[SPR_DAWR0 ] = val; -ppc_update_daw0 (env); +ppc_update_daw (env,0 ); } -void ppc_store_dawrx0 (CPUPPCState *env,uint32_t val) +static void ppc_store_dawrx (CPUPPCState *env,uint32_t val,int rid) {int hrammc =extract32 (val,PPC_BIT_NR (56 ),1 );if (hrammc) {/* This might be done with a second watchpoint at the xor of DEAW[0] */ -qemu_log_mask (LOG_UNIMP ,"%s: DAWRX0[HRAMMC] is unimplemented\n" , - __func__); +qemu_log_mask (LOG_UNIMP ,"%s: DAWRX%d[HRAMMC] is unimplemented\n" , + __func__, rid); } - env->spr[SPR_DAWRX0 ] = val; -ppc_update_daw0 (env); + env->spr[rid ?SPR_DAWRX1 :SPR_DAWRX0 ] = val; +ppc_update_daw (env, rid); +} + +void ppc_store_dawrx0 (CPUPPCState *env,uint32_t val) +{ +ppc_store_dawrx (env, val,0 ); +} + +void ppc_store_dawr1 (CPUPPCState *env,target_ulong val) +{ + env->spr[SPR_DAWR1 ] = val; +ppc_update_daw (env,1 ); +} + +void ppc_store_dawrx1 (CPUPPCState *env,uint32_t val) +{ +ppc_store_dawrx (env, val,1 ); } +#endif #endif
target/ppc/cpu.h +4 -2
@@ -1260,7 +1260,7 @@ struct CPUArchState {#if defined(TARGET_PPC64 )ppc_slb_t slb[MAX_SLB_ENTRIES ];/* PowerPC 64 SLB area */ struct CPUBreakpoint *ciabr_breakpoint; -struct CPUWatchpoint *dawr0_watchpoint; +struct CPUWatchpoint *dawr_watchpoint[2 ];#endif target_ulong sr[32 ];/* segment registers */ uint32_t nb_BATs;/* number of BATs */
@@ -1589,9 +1589,11 @@ void ppc_store_sdr1(CPUPPCState *env, target_ulong value);void ppc_store_lpcr (PowerPCCPU *cpu,target_ulong val);void ppc_update_ciabr (CPUPPCState *env);void ppc_store_ciabr (CPUPPCState *env,target_ulong value); -void ppc_update_daw0 (CPUPPCState *env); +void ppc_update_daw (CPUPPCState *env,int rid);void ppc_store_dawr0 (CPUPPCState *env,target_ulong value);void ppc_store_dawrx0 (CPUPPCState *env,uint32_t value); +void ppc_store_dawr1 (CPUPPCState *env,target_ulong value); +void ppc_store_dawrx1 (CPUPPCState *env,uint32_t value);#endif /* !defined(CONFIG_USER_ONLY) */ void ppc_store_msr (CPUPPCState *env,target_ulong value);
target/ppc/cpu_init.c +15 -0
@@ -5172,6 +5172,20 @@ static void register_book3s_207_dbg_sprs(CPUPPCState *env) KVM_REG_PPC_CIABR, 0x00000000); } +static void register_book3s_310_dbg_sprs (CPUPPCState *env) +{ +spr_register_kvm_hv (env,SPR_DAWR1 ,"DAWR1" , +SPR_NOACCESS ,SPR_NOACCESS , +SPR_NOACCESS ,SPR_NOACCESS , + &spr_read_generic, &spr_write_dawr1, +KVM_REG_PPC_DAWR1 ,0x00000000 ); +spr_register_kvm_hv (env,SPR_DAWRX1 ,"DAWRX1" , +SPR_NOACCESS ,SPR_NOACCESS , +SPR_NOACCESS ,SPR_NOACCESS , + &spr_read_generic, &spr_write_dawrx1, +KVM_REG_PPC_DAWRX1 ,0x00000000 ); +} +static void register_970_dbg_sprs (CPUPPCState *env) {/* Breakpoints */
@@ -6584,6 +6598,7 @@ static void init_proc_POWER10(CPUPPCState *env) {register_power9_common_sprs (env);register_HEIR64_spr (env); +register_book3s_310_dbg_sprs (env);register_power10_hash_sprs (env);register_power10_dexcr_sprs (env);register_power10_pmu_sup_sprs (env);
target/ppc/helper.h +2 -0
@@ -28,6 +28,8 @@ DEF_HELPER_2(store_pcr, void, env, tl) DEF_HELPER_2(store_ciabr, void, env, tl) DEF_HELPER_2(store_dawr0, void, env, tl) DEF_HELPER_2(store_dawrx0, void, env, tl) +DEF_HELPER_2(store_dawr1, void, env, tl) +DEF_HELPER_2(store_dawrx1, void, env, tl) DEF_HELPER_2(store_mmcr0, void, env, tl) DEF_HELPER_2(store_mmcr1, void, env, tl)DEF_HELPER_2 (store_mmcrA, void, env, tl)
target/ppc/machine.c +2 -1
@@ -264,7 +264,8 @@ static int cpu_post_load(void *opaque, int version_id)/* Re-set breaks based on regs */ #if defined(TARGET_PPC64 )ppc_update_ciabr (env); -ppc_update_daw0 (env); +ppc_update_daw (env,0 ); +ppc_update_daw (env,1 );#endif /* * TCG needs to re-start the decrementer timer and/or raise the
target/ppc/misc_helper.c +10 -0
@@ -234,6 +234,16 @@ void helper_store_dawrx0(CPUPPCState *env, target_ulong value)ppc_store_dawrx0 (env, value); } +void helper_store_dawr1 (CPUPPCState *env,target_ulong value) +{ +ppc_store_dawr1 (env, value); +} + +void helper_store_dawrx1 (CPUPPCState *env,target_ulong value) +{ +ppc_store_dawrx1 (env, value); +} +/* * DPDES register is shared. Each bit reflects the state of the * doorbell interrupt of a thread of the same core.
target/ppc/spr_common.h +2 -0
@@ -165,6 +165,8 @@ void spr_write_cfar(DisasContext *ctx, int sprn, int gprn);void spr_write_ciabr (DisasContext *ctx,int sprn,int gprn);void spr_write_dawr0 (DisasContext *ctx,int sprn,int gprn);void spr_write_dawrx0 (DisasContext *ctx,int sprn,int gprn); +void spr_write_dawr1 (DisasContext *ctx,int sprn,int gprn); +void spr_write_dawrx1 (DisasContext *ctx,int sprn,int gprn);void spr_write_ureg (DisasContext *ctx,int sprn,int gprn);void spr_read_purr (DisasContext *ctx,int gprn,int sprn);void spr_write_purr (DisasContext *ctx,int sprn,int gprn);
target/ppc/tcg-excp_helper.c +31 -28
70 lines not on this page · raw message
target/ppc/translate.c +12 -0
@@ -637,6 +637,18 @@ void spr_write_dawrx0(DisasContext *ctx, int sprn, int gprn)translator_io_start (&ctx->base); gen_helper_store_dawrx0(tcg_env, cpu_gpr[gprn]); } + +void spr_write_dawr1 (DisasContext *ctx,int sprn,int gprn) +{ +translator_io_start (&ctx->base); +gen_helper_store_dawr1 (tcg_env, cpu_gpr[gprn]); +} + +void spr_write_dawrx1 (DisasContext *ctx,int sprn,int gprn) +{ +translator_io_start (&ctx->base); +gen_helper_store_dawrx1 (tcg_env, cpu_gpr[gprn]); +}#endif /* defined(TARGET_PPC64) && !defined(CONFIG_USER_ONLY) */ /* CTR */
Signature · 1 line
2.47.1
Nicholas Piggin
reviewer[PULL 69/72] ppc/amigaone: Add default environment
In reply to Nicholas PigginFrom: BALATON Zoltan <[email protected]>
Initialise empty NVRAM with default values. This also enables IDE UDMA mode in AmigaOS that is faster but has to be enabled in environment due to problems with real hardware but that does not affect emulation so we can use faster defaults here.
Message-ID: <4d63f88191612329e0ca8102c7c0d4fc626dc372.1740673173.git.balaton@eik.bme.hu>
--- hw/ppc/amigaone.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-)
hw/ppc/amigaone.c +36 -1
@@ -52,6 +52,28 @@ static const char dummy_fw[] = {#define NVRAM_ADDR 0xfd0e0000#define NVRAM_SIZE (4 * KiB) +static char default_env[] = +"baudrate=115200\0" +"stdout=vga\0" +"stdin=ps2kbd\0" +"bootcmd=boota; menu; run menuboot_cmd\0" +"boot1=ide\0" +"boot2=cdrom\0" +"boota_timeout=3\0" +"ide_doreset=on\0" +"pci_irqa=9\0" +"pci_irqa_select=level\0" +"pci_irqb=10\0" +"pci_irqb_select=level\0" +"pci_irqc=11\0" +"pci_irqc_select=level\0" +"pci_irqd=7\0" +"pci_irqd_select=level\0" +"a1ide_irq=1111\0" +"a1ide_xfer=FFFF\0" ; +#define CRC32_DEFAULT_ENV 0xb5548481 +#define CRC32_ALL_ZEROS 0x603b0489 +#define TYPE_A1_NVRAM "a1-nvram"OBJECT_DECLARE_SIMPLE_TYPE (A1NVRAMState,A1_NVRAM )
@@ -94,7 +116,7 @@ static void nvram_realize(DeviceState *dev, Error **errp) {A1NVRAMState *s =A1_NVRAM (dev);void *p; -uint32_t *c; +uint32_t crc, *c;memory_region_init_rom_device (&s->mr,NULL , &nvram_ops, s,"nvram" ,NVRAM_SIZE , &error_fatal);
@@ -113,12 +135,25 @@ static void nvram_realize(DeviceState *dev, Error **errp)return ; } } + crc =crc32 (0 , p +4 ,NVRAM_SIZE -4 ); +if (crc ==CRC32_ALL_ZEROS ) {/* If env is uninitialized set default */ + *c =cpu_to_be32 (CRC32_DEFAULT_ENV ); +/* Also copies terminating \0 as env is terminated by \0\0 */ +memcpy (p +4 , default_env,sizeof (default_env)); +if (s->blk) { +blk_pwrite (s->blk,0 ,sizeof (crc) +sizeof (default_env), p,0 ); + } +return ; + }if (*c ==0 ) { *c =cpu_to_be32 (crc32 (0 , p +4 ,NVRAM_SIZE -4 ));if (s->blk) {blk_pwrite (s->blk,0 ,4 , p,0 ); } } +if (be32_to_cpu (*c) != crc) { +warn_report ("NVRAM checksum mismatch" ); + } }static const Property nvram_properties[] = {
Signature · 1 line
2.47.1
Nicholas Piggin
reviewer[PULL 62/72] spapr: nested: Add support for reporting Hostwide state counter
In reply to Nicholas PigginFrom: Vaibhav Jain <[email protected]>
Add support for reporting Hostwide state counters for nested KVM pseries guests running with 'cap-nested-papr' on Qemu-TCG acting as L0-hypervisor. The Hostwide state counters are statistics about state that L0-hypervisor maintains for the L2-guests and represent the state of all L2-guests, not just a specific one.
These stats counters are exposed to L1-Hypervisor by the L0-Hypervisor via a new bit-flag named 'getHostWideState' for the H_GUEST_GET_STATE hcall which is documented at [1]. Once this flag is set the hcall should populate the Guest-State-Elements in the requested GSB with the stat counter values. Currently following five counters are supported:
* l0_guest_heap_size_inuse
* l0_guest_heap_size_max
* l0_guest_pagetable_size_inuse
* l0_guest_pagetable_size_max
* l0_guest_pagetable_reclaimed
At the moment '0' is being reported for all these counters as these counters doesn't align with how L0-Qemu manages Guest memory.
The patch implements support for these counters by adding new members to the 'struct SpaprMachineStateNested'. These new members are then plugged into the existing 'guest_state_element_types[]' with the help of a new macro 'GSBE_NESTED_MACHINE_DW' together with a new helper 'get_machine_ptr()'. guest_state_request_check() is updated to ensure correctness of the requested GSB and finally h_guest_getset_state() is updated to handle the newly introduced flag 'GUEST_STATE_REQUEST_HOST_WIDE'.
This patch is tested with the proposed linux-kernel implementation to expose these stat-counter as perf-events at [2].
[1]
https://lore.kernel.org/all/[email protected]
[2]
https://lore.kernel.org/all/[email protected]
Message-ID: <[email protected]>
--- hw/ppc/spapr_nested.c | 119 ++++++++++++++++++++++++---------- include/hw/ppc/spapr_nested.h | 67 +++++++++++++++++-- 2 files changed, 147 insertions(+), 39 deletions(-)
hw/ppc/spapr_nested.c +86 -33
@@ -65,10 +65,9 @@ staticSpaprMachineStateNestedGuest *spapr_get_nested_guest (SpaprMachineState *spapr,target_ulong guestid) { -SpaprMachineStateNestedGuest *guest; - - guest =g_hash_table_lookup (spapr->nested.guests,GINT_TO_POINTER (guestid)); -return guest; +return spapr->nested.guests ? +g_hash_table_lookup (spapr->nested.guests, +GINT_TO_POINTER (guestid)) :NULL ; } bool spapr_get_pate_nested_papr(SpaprMachineState *spapr, PowerPCCPU *cpu,
@@ -594,26 +593,37 @@ static bool spapr_nested_vcpu_check(SpaprMachineStateNestedGuest *guest,return false; } -static void *get_vcpu_state_ptr (SpaprMachineStateNestedGuest *guest, -target_ulong vcpuid) +static void *get_vcpu_state_ptr (SpaprMachineState *spapr, +SpaprMachineStateNestedGuest *guest, +target_ulong vcpuid) {assert (spapr_nested_vcpu_check (guest, vcpuid, false));return &guest->vcpus[vcpuid].state; } -static void *get_vcpu_ptr (SpaprMachineStateNestedGuest *guest, -target_ulong vcpuid) +static void *get_vcpu_ptr (SpaprMachineState *spapr, +SpaprMachineStateNestedGuest *guest, +target_ulong vcpuid) {assert (spapr_nested_vcpu_check (guest, vcpuid, false));return &guest->vcpus[vcpuid]; } -static void *get_guest_ptr (SpaprMachineStateNestedGuest *guest, +static void *get_guest_ptr (SpaprMachineState *spapr, +SpaprMachineStateNestedGuest *guest,target_ulong vcpuid) {return guest;/* for GSBE_NESTED */ } +static void *get_machine_ptr (SpaprMachineState *spapr, +SpaprMachineStateNestedGuest *guest, +target_ulong vcpuid) +{ +/* ignore guest and vcpuid for this */ +return &spapr->nested; +} +/* * set=1 means the L1 is trying to set some state * set=0 means the L1 is trying to get some state
@@ -1013,7 +1023,15 @@ struct guest_state_element_type guest_state_element_types[] = {GSBE_NESTED_VCPU (GSB_VCPU_OUT_BUFFER ,0x10 , runbufout, copy_state_runbuf),GSBE_NESTED_VCPU (GSB_VCPU_OUT_BUF_MIN_SZ ,0x8 , runbufout, out_buf_min_size),GSBE_NESTED_VCPU (GSB_VCPU_HDEC_EXPIRY_TB ,0x8 , hdecr_expiry_tb, - copy_state_hdecr) + copy_state_hdecr), +GSBE_NESTED_MACHINE_DW (GSB_L0_GUEST_HEAP_INUSE , l0_guest_heap_inuse), +GSBE_NESTED_MACHINE_DW (GSB_L0_GUEST_HEAP_MAX , l0_guest_heap_max), +GSBE_NESTED_MACHINE_DW (GSB_L0_GUEST_PGTABLE_SIZE_INUSE , + l0_guest_pgtable_size_inuse), +GSBE_NESTED_MACHINE_DW (GSB_L0_GUEST_PGTABLE_SIZE_MAX , + l0_guest_pgtable_size_max), +GSBE_NESTED_MACHINE_DW (GSB_L0_GUEST_PGTABLE_RECLAIMED , + l0_guest_pgtable_reclaimed), };void spapr_nested_gsb_init (void )
@@ -1031,8 +1049,13 @@ void spapr_nested_gsb_init(void)else if (type->id >=GSB_VCPU_IN_BUFFER )/* 0x0c00 - 0xf000 Thread + RW */ type->flags =0 ; +else if (type->id >=GSB_L0_GUEST_HEAP_INUSE ) + +/*0x0800 - 0x0804 Hostwide Counters + RO */ + type->flags =GUEST_STATE_ELEMENT_TYPE_FLAG_HOST_WIDE | +GUEST_STATE_ELEMENT_TYPE_FLAG_READ_ONLY ;else if (type->id >=GSB_VCPU_LPVR ) -/* 0x0003 - 0x0bff Guest + RW */ +/* 0x0003 - 0x07ff Guest + RW */ type->flags =GUEST_STATE_ELEMENT_TYPE_FLAG_GUEST_WIDE ;else if (type->id >=GSB_HV_VCPU_STATE_SIZE )/* 0x0001 - 0x0002 Guest + RO */
@@ -1139,18 +1162,26 @@ static bool guest_state_request_check(struct guest_state_request *gsr)return false; } -if (type->flags &GUEST_STATE_ELEMENT_TYPE_FLAG_GUEST_WIDE ) { +if (type->flags &GUEST_STATE_ELEMENT_TYPE_FLAG_HOST_WIDE ) { +/* Hostwide elements cant be clubbed with other types */ +if (!(gsr->flags &GUEST_STATE_REQUEST_HOST_WIDE )) { +qemu_log_mask (LOG_GUEST_ERROR ,"trying to get/set a host wide " +"Element ID:%04x.\n" , id); +return false; + } + }else if (type->flags &GUEST_STATE_ELEMENT_TYPE_FLAG_GUEST_WIDE ) {/* guest wide element type */ if (!(gsr->flags &GUEST_STATE_REQUEST_GUEST_WIDE )) { -qemu_log_mask (LOG_GUEST_ERROR ,"trying to set a guest wide " +qemu_log_mask (LOG_GUEST_ERROR ,"trying to get/set a guest wide " "Element ID:%04x.\n" , id);return false; } }else {/* thread wide element type */ -if (gsr->flags &GUEST_STATE_REQUEST_GUEST_WIDE ) { -qemu_log_mask (LOG_GUEST_ERROR ,"trying to set a thread wide " -"Element ID:%04x.\n" , id); +if (gsr->flags & (GUEST_STATE_REQUEST_GUEST_WIDE | +GUEST_STATE_REQUEST_HOST_WIDE )) { +qemu_log_mask (LOG_GUEST_ERROR ,"trying to get/set a thread wide" +" Element ID:%04x.\n" , id);return false; } }
@@ -1419,7 +1450,8 @@ static target_ulong h_guest_create_vcpu(PowerPCCPU *cpu,return H_SUCCESS ; } -static target_ulong getset_state (SpaprMachineStateNestedGuest *guest, +static target_ulong getset_state (SpaprMachineState *spapr, +SpaprMachineStateNestedGuest *guest,uint64_t vcpuid,struct guest_state_request *gsr) {
@@ -1452,7 +1484,7 @@ static target_ulong getset_state(SpaprMachineStateNestedGuest *guest,/* Get pointer to guest data to get/set */ if (type->location && type->copy) { - ptr = type->location (guest, vcpuid); + ptr = type->location (spapr, guest, vcpuid);assert (ptr);if (!~(type->mask) &&is_gsr_invalid (gsr, element, type)) {return H_INVALID_ELEMENT_VALUE ;
@@ -1469,6 +1501,7 @@ next_element: }static target_ulong map_and_getset_state (PowerPCCPU *cpu, +SpaprMachineState *spapr,SpaprMachineStateNestedGuest *guest,uint64_t vcpuid,struct guest_state_request *gsr)
@@ -1492,7 +1525,7 @@ static target_ulong map_and_getset_state(PowerPCCPU *cpu, goto out1; } - rc =getset_state (guest, vcpuid, gsr); + rc =getset_state (spapr, guest, vcpuid, gsr); out1:address_space_unmap (CPU (cpu)->as, gsr->gsb, len, is_write, len);
@@ -1510,27 +1543,46 @@ static target_ulong h_guest_getset_state(PowerPCCPU *cpu,target_ulong buf = args[3 ];target_ulong buflen = args[4 ];struct guest_state_request gsr; -SpaprMachineStateNestedGuest *guest; +SpaprMachineStateNestedGuest *guest =NULL ; - guest =spapr_get_nested_guest (spapr, lpid); -if (!guest) { -return H_P2 ; - } gsr.buf = buf;assert (buflen <=GSB_MAX_BUF_SIZE ); gsr.len = buflen; gsr.flags =0 ; -if (flags &H_GUEST_GETSET_STATE_FLAG_GUEST_WIDE ) { + +/* Works for both get/set state */ +if ((flags &H_GUEST_GET_STATE_FLAGS_GUEST_WIDE ) || + (flags &H_GUEST_SET_STATE_FLAGS_GUEST_WIDE )) { gsr.flags |=GUEST_STATE_REQUEST_GUEST_WIDE ; } -if (flags & ~H_GUEST_GETSET_STATE_FLAG_GUEST_WIDE ) { -return H_PARAMETER ;/* flag not supported yet */ - }if (set) { +if (flags & ~H_GUEST_SET_STATE_FLAGS_MASK ) { +return H_PARAMETER ; + } gsr.flags |=GUEST_STATE_REQUEST_SET ; + }else { +/* +* No reserved fields to be set in flags nor both +* GUEST/HOST wide bits +*/ +if ((flags & ~H_GUEST_GET_STATE_FLAGS_MASK ) || + (flags ==H_GUEST_GET_STATE_FLAGS_MASK )) { +return H_PARAMETER ; + } + +if (flags &H_GUEST_GET_STATE_FLAGS_HOST_WIDE ) { + gsr.flags |=GUEST_STATE_REQUEST_HOST_WIDE ; + } + } + +if (!(gsr.flags &GUEST_STATE_REQUEST_HOST_WIDE )) { + guest =spapr_get_nested_guest (spapr, lpid); +if (!guest) { +return H_P2 ; + } } -return map_and_getset_state (cpu, guest, vcpuid, &gsr); +return map_and_getset_state (cpu, spapr, guest, vcpuid, &gsr); } static target_ulong h_guest_set_state(PowerPCCPU *cpu,
@@ -1641,7 +1693,8 @@ static int get_exit_ids(uint64_t srr0, uint16_t ids[16])return nr; } -static void exit_process_output_buffer (PowerPCCPU *cpu, +static void exit_process_output_buffer (SpaprMachineState *spapr, +PowerPCCPU *cpu,SpaprMachineStateNestedGuest *guest,target_ulong vcpuid,target_ulong *r3)
@@ -1679,7 +1732,7 @@ static void exit_process_output_buffer(PowerPCCPU *cpu, gsr.gsb = gsb; gsr.len =VCPU_OUT_BUF_MIN_SZ ; gsr.flags =0 ;/* get + never guest wide */ -getset_state (guest, vcpuid, &gsr); +getset_state (spapr, guest, vcpuid, &gsr);address_space_unmap (CPU (cpu)->as, gsb, len, true, len);return ;
@@ -1705,7 +1758,7 @@ void spapr_exit_nested_papr(SpaprMachineState *spapr, PowerPCCPU *cpu, int excp)exit_nested_store_l2 (cpu, excp, vcpu);/* do the output buffer for run_vcpu*/ -exit_process_output_buffer (cpu, guest, vcpuid, &r3_return); +exit_process_output_buffer (spapr, cpu, guest, vcpuid, &r3_return);assert (env->spr[SPR_LPIDR ] !=0 );nested_load_state (cpu, spapr_cpu->nested_host_state);
@@ -1820,7 +1873,7 @@ static target_ulong h_guest_run_vcpu(PowerPCCPU *cpu, gsr.buf = vcpu->runbufin.addr; gsr.len = vcpu->runbufin.size; gsr.flags =GUEST_STATE_REQUEST_SET ;/* Thread wide + writing */ - rc =map_and_getset_state (cpu, guest, vcpuid, &gsr); + rc =map_and_getset_state (cpu, spapr, guest, vcpuid, &gsr);if (rc ==H_SUCCESS ) {nested_papr_run_vcpu (cpu, lpid, vcpu); }else {
include/hw/ppc/spapr_nested.h +61 -6
98 lines not on this page · raw message
Signature · 1 line
2.47.1
Nicholas Piggin
reviewer[PULL 13/72] ppc/pnv/occ: Update pstate frequency tables
In reply to Nicholas PigginOCC pstate frequencies are in kHz, so the OCC data was 3-4MHz. Upgrade to GHz. Make each pstate have a different frequency.
--- hw/ppc/pnv_occ.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
hw/ppc/pnv_occ.c +6 -6
@@ -682,11 +682,11 @@ static bool occ_init_homer_memory(PnvOCC *occ, Error **errp) static_data.v2.pstate_turbo =-1 ; static_data.v2.pstate_ultra_turbo =0 ; static_data.v2.pstates[0 ].id =0 ; - static_data.v2.pstates[1 ].freq_khz =cpu_to_be32 (3000 ); + static_data.v2.pstates[1 ].freq_khz =cpu_to_be32 (4000000 ); static_data.v2.pstates[1 ].id =-1 ; - static_data.v2.pstates[1 ].freq_khz =cpu_to_be32 (3000 ); + static_data.v2.pstates[1 ].freq_khz =cpu_to_be32 (3000000 ); static_data.v2.pstates[2 ].id =-2 ; - static_data.v2.pstates[2 ].freq_khz =cpu_to_be32 (3000 ); + static_data.v2.pstates[2 ].freq_khz =cpu_to_be32 (2000000 );for (i =0 ; i < chip->nr_cores; i++) { static_data.v2.core_max[i] =1 ; }
@@ -702,11 +702,11 @@ static bool occ_init_homer_memory(PnvOCC *occ, Error **errp) static_data.v9.pstate_turbo =1 ; static_data.v9.pstate_ultra_turbo =0 ; static_data.v9.pstates[0 ].id =0 ; - static_data.v9.pstates[0 ].freq_khz =cpu_to_be32 (3000 ); + static_data.v9.pstates[0 ].freq_khz =cpu_to_be32 (4000000 ); static_data.v9.pstates[1 ].id =1 ; - static_data.v9.pstates[1 ].freq_khz =cpu_to_be32 (3000 ); + static_data.v9.pstates[1 ].freq_khz =cpu_to_be32 (3000000 ); static_data.v9.pstates[2 ].id =2 ; - static_data.v9.pstates[2 ].freq_khz =cpu_to_be32 (3000 ); + static_data.v9.pstates[2 ].freq_khz =cpu_to_be32 (2000000 );for (i =0 ; i < chip->nr_cores; i++) { static_data.v9.core_max[i] =1 ; }
Signature · 1 line
2.47.1
Nicholas Piggin
reviewer[PULL 50/72] target/ppc: Restrict various common helpers to TCG
In reply to Nicholas PigginFrom: Philippe Mathieu-Daudé <[email protected]>
Move helpers common to system/user emulation to tcg-excp_helper.c.
Message-ID: <[email protected]>
--- target/ppc/excp_helper.c | 141 ---------------------------------- target/ppc/tcg-excp_helper.c | 143 +++++++++++++++++++++++++++++++++++ 2 files changed, 143 insertions(+), 141 deletions(-)
target/ppc/excp_helper.c +0 -141
@@ -2711,148 +2711,7 @@ void helper_rfmci(CPUPPCState *env)/* FIXME: choose CSRR1 or MCSRR1 based on cpu type */ do_rfi (env, env->spr[SPR_BOOKE_MCSRR0 ], env->spr[SPR_BOOKE_MCSRR1 ]); } -#endif /* !CONFIG_USER_ONLY */ - -void helper_TW (CPUPPCState *env,target_ulong arg1,target_ulong arg2, -uint32_t flags) -{ -if (!likely (!(((int32_t )arg1 < (int32_t )arg2 && (flags &0x10 )) || - ((int32_t )arg1 > (int32_t )arg2 && (flags &0x08 )) || - ((int32_t )arg1 == (int32_t )arg2 && (flags &0x04 )) || - ((uint32_t )arg1 < (uint32_t )arg2 && (flags &0x02 )) || - ((uint32_t )arg1 > (uint32_t )arg2 && (flags &0x01 ))))) { -raise_exception_err_ra (env,POWERPC_EXCP_PROGRAM , -POWERPC_EXCP_TRAP ,GETPC ()); - } -} - -#ifdef TARGET_PPC64 -void helper_TD (CPUPPCState *env,target_ulong arg1,target_ulong arg2, -uint32_t flags) -{ -if (!likely (!(((int64_t )arg1 < (int64_t )arg2 && (flags &0x10 )) || - ((int64_t )arg1 > (int64_t )arg2 && (flags &0x08 )) || - ((int64_t )arg1 == (int64_t )arg2 && (flags &0x04 )) || - ((uint64_t )arg1 < (uint64_t )arg2 && (flags &0x02 )) || - ((uint64_t )arg1 > (uint64_t )arg2 && (flags &0x01 ))))) { -raise_exception_err_ra (env,POWERPC_EXCP_PROGRAM , -POWERPC_EXCP_TRAP ,GETPC ()); - } -} -#endif /* TARGET_PPC64 */ - -static uint32_t helper_SIMON_LIKE_32_64 (uint32_t x,uint64_t key,uint32_t lane) -{ -const uint16_t c =0xfffc ; -const uint64_t z0 =0xfa2561cdf44ac398ULL ; -uint16_t z =0 , temp; -uint16_t k[32 ], eff_k[32 ], xleft[33 ], xright[33 ], fxleft[32 ]; - -for (int i =3 ; i >=0 ; i--) { - k[i] = key &0xffff ; - key >>=16 ; - } - xleft[0 ] = x &0xffff ; - xright[0 ] = (x >>16 ) &0xffff ; - -for (int i =0 ; i <28 ; i++) { - z = (z0 >> (63 - i)) &1 ; - temp =ror16 (k[i +3 ],3 ) ^ k[i +1 ]; - k[i +4 ] = c ^ z ^ k[i] ^ temp ^ror16 (temp,1 ); - } - -for (int i =0 ; i <8 ; i++) { - eff_k[4 * i +0 ] = k[4 * i + ((0 + lane) %4 )]; - eff_k[4 * i +1 ] = k[4 * i + ((1 + lane) %4 )]; - eff_k[4 * i +2 ] = k[4 * i + ((2 + lane) %4 )]; - eff_k[4 * i +3 ] = k[4 * i + ((3 + lane) %4 )]; - } - -for (int i =0 ; i <32 ; i++) { - fxleft[i] = (rol16 (xleft[i],1 ) & -rol16 (xleft[i],8 )) ^rol16 (xleft[i],2 ); - xleft[i +1 ] = xright[i] ^ fxleft[i] ^ eff_k[i]; - xright[i +1 ] = xleft[i]; - } - -return (((uint32_t )xright[32 ]) <<16 ) | xleft[32 ]; -} -static uint64_t hash_digest (uint64_t ra,uint64_t rb,uint64_t key) -{ -uint64_t stage0_h =0ULL , stage0_l =0ULL ; -uint64_t stage1_h, stage1_l; - -for (int i =0 ; i <4 ; i++) { - stage0_h |=ror64 (rb &0xff ,8 * (2 * i +1 )); - stage0_h |= ((ra >>32 ) &0xff ) << (8 *2 * i); - stage0_l |=ror64 ((rb >>32 ) &0xff ,8 * (2 * i +1 )); - stage0_l |= (ra &0xff ) << (8 *2 * i); - rb >>=8 ; - ra >>=8 ; - } - - stage1_h = (uint64_t )helper_SIMON_LIKE_32_64 (stage0_h >>32 , key,0 ) <<32 ; - stage1_h |=helper_SIMON_LIKE_32_64 (stage0_h, key,1 ); - stage1_l = (uint64_t )helper_SIMON_LIKE_32_64 (stage0_l >>32 , key,2 ) <<32 ; - stage1_l |=helper_SIMON_LIKE_32_64 (stage0_l, key,3 ); - -return stage1_h ^ stage1_l; -} - -static void do_hash (CPUPPCState *env,target_ulong ea,target_ulong ra, -target_ulong rb,uint64_t key,bool store) -{ -uint64_t calculated_hash =hash_digest (ra, rb, key), loaded_hash; - -if (store) { -cpu_stq_data_ra (env, ea, calculated_hash,GETPC ()); - }else { - loaded_hash =cpu_ldq_data_ra (env, ea,GETPC ()); -if (loaded_hash != calculated_hash) { -raise_exception_err_ra (env,POWERPC_EXCP_PROGRAM , -POWERPC_EXCP_TRAP ,GETPC ()); - } - } -} - -#include "qemu/guest-random.h" - -#ifdef TARGET_PPC64 -#define HELPER_HASH (op, key, store, dexcr_aspect) \ -void helper_##op(CPUPPCState *env, target_ulong ea, target_ulong ra, \ - target_ulong rb) \ -{ \ - if (env->msr & R_MSR_PR_MASK) { \ - if (!(env->spr[SPR_DEXCR] & R_DEXCR_PRO_##dexcr_aspect##_MASK || \ - env->spr[SPR_HDEXCR] & R_HDEXCR_ENF_##dexcr_aspect##_MASK)) \ - return; \ - } else if (!(env->msr & R_MSR_HV_MASK)) { \ - if (!(env->spr[SPR_DEXCR] & R_DEXCR_PNH_##dexcr_aspect##_MASK || \ - env->spr[SPR_HDEXCR] & R_HDEXCR_ENF_##dexcr_aspect##_MASK)) \ - return; \ - } else if (!(env->msr & R_MSR_S_MASK)) { \ - if (!(env->spr[SPR_HDEXCR] & R_HDEXCR_HNU_##dexcr_aspect##_MASK)) \ - return; \ - } \ - \ - do_hash(env, ea, ra, rb, key, store); \ -} -#else -#define HELPER_HASH (op, key, store, dexcr_aspect) \ -void helper_##op(CPUPPCState *env, target_ulong ea, target_ulong ra, \ - target_ulong rb) \ -{ \ - do_hash(env, ea, ra, rb, key, store); \ -} -#endif /* TARGET_PPC64 */ - -HELPER_HASH(HASHST, env->spr[SPR_HASHKEYR], true, NPHIE) -HELPER_HASH(HASHCHK, env->spr[SPR_HASHKEYR], false, NPHIE) -HELPER_HASH(HASHSTP, env->spr[SPR_HASHPKEYR], true, PHIE) -HELPER_HASH(HASHCHKP, env->spr[SPR_HASHPKEYR], false, PHIE) - -#ifndef CONFIG_USER_ONLY /* Embedded.Processor Control */ static int dbell2irq (target_ulong rb) {
target/ppc/tcg-excp_helper.c +143 -0
149 lines not on this page · raw message
Signature · 1 line
2.47.1
Nicholas Piggin
reviewer[PULL 66/72] spapr: Generate random HASHPKEYR for spapr machines
In reply to Nicholas PigginThe hypervisor is expected to create a value for the HASHPKEY SPR for each partition. Currently it uses zero for all partitions, use a random number instead, which in theory might make kernel ROP protection more secure.
Message-ID: <[email protected]>
--- hw/ppc/spapr.c | 3 +++ hw/ppc/spapr_cpu_core.c | 2 ++ include/hw/ppc/spapr.h | 1 + 3 files changed, 6 insertions(+)
hw/ppc/spapr.c +3 -0
@@ -2917,6 +2917,9 @@ static void spapr_machine_init(MachineState *machine)spapr_ovec_set (spapr->ov5,OV5_XIVE_EXPLOIT ); } +qemu_guest_getrandom_nofail (&spapr->hashpkey_val, +sizeof (spapr->hashpkey_val)); +/* init CPUs */ spapr_init_cpus (spapr);
hw/ppc/spapr_cpu_core.c +2 -0
@@ -273,6 +273,8 @@ static bool spapr_realize_vcpu(PowerPCCPU *cpu, SpaprMachineState *spapr, env->spr_cb[SPR_PIR ].default_value = cs->cpu_index; env->spr_cb[SPR_TIR ].default_value = thread_index; + env->spr_cb[SPR_HASHPKEYR ].default_value = spapr->hashpkey_val; +cpu_ppc_set_1lpar (cpu);/* Set time-base frequency to 512 MHz. vhyp must be set first. */
include/hw/ppc/spapr.h +1 -0
@@ -203,6 +203,7 @@ struct SpaprMachineState {uint32_t fdt_initial_size;void *fdt_blob;uint8_t fdt_rng_seed[32 ]; +uint64_t hashpkey_val;long kernel_size;bool kernel_le;uint64_t kernel_addr;
Signature · 1 line
2.47.1
Nicholas Piggin
reviewer[PULL 25/72] ppc/xive2: Add grouping level to notification
In reply to Nicholas PigginFrom: Frederic Barrat <[email protected]>
The NSR has a (so far unused) grouping level field. When a interrupt is presented, that field tells the hypervisor or OS if the interrupt is for an individual VP or for a VP-group/crowd. This patch reworks the presentation API to allow to set/unset the level when raising/accepting an interrupt.
It also renames xive_tctx_ipb_update() to xive_tctx_pipr_update() as the IPB is only used for VP-specific target, whereas the PIPR always needs to be updated.
--- hw/intc/trace-events | 2 +- hw/intc/xive.c | 88 ++++++++++++++++++++++---------------- hw/intc/xive2.c | 19 ++++---- include/hw/ppc/xive.h | 9 +++- include/hw/ppc/xive_regs.h | 25 ++++++++--- 5 files changed, 90 insertions(+), 53 deletions(-)
hw/intc/trace-events +1 -1
@@ -283,7 +283,7 @@ xive_router_end_notify(uint8_t end_blk, uint32_t end_idx, uint32_t end_data) "EN xive_router_end_escalate(uint8_t end_blk, uint32_t end_idx, uint8_t esc_blk, uint32_t esc_idx, uint32_t end_data) "END 0x%02x/0x%04x -> escalate END 0x%02x/0x%04x data 0x%08x" xive_tctx_tm_write(uint32_t index, uint64_t offset, unsigned int size, uint64_t value) "target=%d @0x%"PRIx64" sz=%d val=0x%" PRIx64 xive_tctx_tm_read(uint32_t index, uint64_t offset, unsigned int size, uint64_t value) "target=%d @0x%"PRIx64" sz=%d val=0x%" PRIx64 -xive_presenter_notify(uint8_t nvt_blk, uint32_t nvt_idx, uint8_t ring) "found NVT 0x%x/0x%x ring=0x%x" +xive_presenter_notify(uint8_t nvt_blk, uint32_t nvt_idx, uint8_t ring, uint8_t group_level) "found NVT 0x%x/0x%x ring=0x%x group_level=%d" xive_end_source_read(uint8_t end_blk, uint32_t end_idx, uint64_t addr) "END 0x%x/0x%x @0x%"PRIx64 # pnv_xive.c
hw/intc/xive.c +51 -37
179 lines not on this page · raw message
hw/intc/xive2.c +11 -8
@@ -563,8 +563,11 @@ static void xive2_tctx_need_resend(Xive2Router *xrtr, XiveTCTX *tctx, uint8_t nvp_blk, uint32_t nvp_idx, bool do_restore) { - Xive2Nvp nvp; uint8_t ipb; +uint8_t backlog_level; +uint8_t backlog_prio; +uint8_t *regs = &tctx->regs[TM_QW1_OS ]; +Xive2Nvp nvp;/* * Grab the associated thread interrupt context registers in the
@@ -593,15 +596,15 @@ static void xive2_tctx_need_resend(Xive2Router *xrtr, XiveTCTX *tctx, nvp.w2 =xive_set_field32 (NVP2_W2_IPB , nvp.w2,0 );xive2_router_write_nvp (xrtr, nvp_blk, nvp_idx, &nvp,2 ); } + regs[TM_IPB ] |= ipb; + backlog_prio =xive_ipb_to_pipr (ipb); + backlog_level =0 ; +/* -* Always call xive_tctx_ipb_update(). Even if there were no -* escalation triggered, there could be a pending interrupt which -* was saved when the context was pulled and that we need to take -* into account by recalculating the PIPR (which is not -* saved/restored). -* It will also raise the External interrupt signal if needed. +* Compute the PIPR based on the restored state. +* It will raise the External interrupt signal if needed. */ -xive_tctx_ipb_update (tctx,TM_QW1_OS , ipb); +xive_tctx_pipr_update (tctx,TM_QW1_OS , backlog_prio, backlog_level); }/*
include/hw/ppc/xive.h +8 -1
@@ -508,6 +508,11 @@ static inline uint8_t xive_priority_to_ipb(uint8_t priority) 0 : 1 << (XIVE_PRIORITY_MAX - priority); } +static inline uint8_t xive_priority_to_pipr (uint8_t priority) +{ +return priority >XIVE_PRIORITY_MAX ?0xFF : priority; +} +/* * Convert an Interrupt Pending Buffer (IPB) register to a Pending * Interrupt Priority Register (PIPR), which contains the priority of
@@ -540,8 +545,10 @@ void xive_tctx_pic_print_info(XiveTCTX *tctx, GString *buf);Object *xive_tctx_create (Object *cpu,XivePresenter *xptr,Error **errp);void xive_tctx_reset (XiveTCTX *tctx);void xive_tctx_destroy (XiveTCTX *tctx); -void xive_tctx_ipb_update (XiveTCTX *tctx,uint8_t ring,uint8_t ipb); +void xive_tctx_pipr_update (XiveTCTX *tctx,uint8_t ring,uint8_t priority, +uint8_t group_level);void xive_tctx_reset_signal (XiveTCTX *tctx,uint8_t ring); +void xive_tctx_notify (XiveTCTX *tctx,uint8_t ring,uint8_t group_level);/* * KVM XIVE device helpers
include/hw/ppc/xive_regs.h +19 -6
@@ -7,10 +7,9 @@* access to the different fields. * * -* Copyright (c) 2016-2018, IBM Corporation. +* Copyright (c) 2016-2024, IBM Corporation. * -* This code is licensed under the GPL version 2 or later. See the -* COPYING file in the top-level directory. +* SPDX-License-Identifier: GPL-2.0-or-later */ #ifndef PPC_XIVE_REGS_H
@@ -146,7 +145,14 @@#define TM_SPC_PULL_PHYS_CTX_OL 0xc38/* Pull phys ctx to odd cache line */ /* XXX more... */ -/* NSR fields for the various QW ack types */ +/* +* NSR fields for the various QW ack types +* +* P10 has an extra bit in QW3 for the group level instead of the +* reserved 'i' bit. Since it is not used and we don't support group +* interrupts on P9, we use the P10 definition for the group level so +* that we can have common macros for the NSR +*/ #define TM_QW0_NSR_EB PPC_BIT8(0)#define TM_QW1_NSR_EO PPC_BIT8(0)#define TM_QW3_NSR_HE PPC_BITMASK8(0, 1)
@@ -154,8 +160,15 @@#define TM_QW3_NSR_HE_POOL 1#define TM_QW3_NSR_HE_PHYS 2#define TM_QW3_NSR_HE_LSI 3 -#define TM_QW3_NSR_I PPC_BIT8(2) -#define TM_QW3_NSR_GRP_LVL PPC_BIT8(3, 7) +#define TM_NSR_GRP_LVL PPC_BITMASK8(2, 7) +/* +* On P10, the format of the 6-bit group level is: 2 bits for the +* crowd size and 4 bits for the group size. Since group/crowd size is +* always a power of 2, we encode the log. For example, group_level=4 +* means crowd size = 0 and group size = 16 (2^4) +* Same encoding is used in the NVP and NVGC structures for +* PGoFirst and PGoNext fields +*/ /* * EAS (Event Assignment Structure)
Signature · 1 line
2.47.1
Nicholas Piggin
reviewer[PULL 67/72] ppc/amigaone: Simplify replacement dummy_fw
In reply to Nicholas PigginFrom: BALATON Zoltan <[email protected]>
There's no need to do shift in a loop, doing it in one instruction works just as well, only the result is used.
Message-ID: <446bf740cbb99422be2cc5a31e51a1034eddded7.1740673173.git.balaton@eik.bme.hu>
--- hw/ppc/amigaone.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
hw/ppc/amigaone.c +1 -4
@@ -41,10 +41,7 @@/* AmigaOS calls this routine from ROM, use this if no firmware loaded */ static const char dummy_fw[] = { -0x38 ,0x00 ,0x00 ,0x08 ,/* li r0,8 */ -0x7c ,0x09 ,0x03 ,0xa6 ,/* mtctr r0 */ -0x54 ,0x63 ,0xf8 ,0x7e ,/* srwi r3,r3,1 */ -0x42 ,0x00 ,0xff ,0xfc ,/* bdnz 0x8 */ +0x54 ,0x63 ,0xc2 ,0x3e ,/* srwi r3,r3,8 */ 0x7c ,0x63 ,0x18 ,0xf8 ,/* not r3,r3 */ 0x4e ,0x80 ,0x00 ,0x20 ,/* blr */ };
Signature · 1 line
2.47.1
Nicholas Piggin
reviewer[PULL 49/72] target/ppc: Restrict exception helpers to TCG
In reply to Nicholas PigginFrom: Philippe Mathieu-Daudé <[email protected]>
Move exception helpers to tcg-excp_helper.c so they are only built when TCG is selected. Preprocessor guards are added for some helpers unused when CONFIG_USER_ONLY.
Message-ID: <[email protected]>
--- target/ppc/excp_helper.c | 34 -------------------------------- target/ppc/tcg-excp_helper.c | 38 ++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 34 deletions(-)
target/ppc/excp_helper.c +0 -34
@@ -2504,41 +2504,7 @@ bool ppc_cpu_exec_interrupt(CPUState *cs, int interrupt_request)#endif /* !CONFIG_USER_ONLY */ -/*****************************************************************************/ -/* Exceptions processing helpers */ - -void raise_exception_err_ra (CPUPPCState *env,uint32_t exception, -uint32_t error_code,uintptr_t raddr) -{ -CPUState *cs =env_cpu (env); - - cs->exception_index = exception; - env->error_code = error_code; -cpu_loop_exit_restore (cs, raddr); -} - -void raise_exception_err (CPUPPCState *env,uint32_t exception, -uint32_t error_code) -{ -raise_exception_err_ra (env, exception, error_code,0 ); -} - -void raise_exception (CPUPPCState *env,uint32_t exception) -{ -raise_exception_err_ra (env, exception,0 ,0 ); -} -#ifdef CONFIG_TCG -void helper_raise_exception_err (CPUPPCState *env,uint32_t exception, -uint32_t error_code) -{ -raise_exception_err_ra (env, exception, error_code,0 ); -} - -void helper_raise_exception (CPUPPCState *env,uint32_t exception) -{ -raise_exception_err_ra (env, exception,0 ,0 ); -}#ifndef CONFIG_USER_ONLY void helper_store_msr (CPUPPCState *env,target_ulong val)
target/ppc/tcg-excp_helper.c +38 -0
@@ -19,15 +19,53 @@#include "qemu/osdep.h" #include "qemu/log.h" #include "exec/cpu_ldst.h" +#include "exec/exec-all.h" +#include "exec/helper-proto.h" #include "system/runstate.h" +#include "helper_regs.h" #include "hw/ppc/ppc.h" #include "internal.h" #include "cpu.h" #include "trace.h" +/*****************************************************************************/ +/* Exceptions processing helpers */ + +void raise_exception_err_ra (CPUPPCState *env,uint32_t exception, +uint32_t error_code,uintptr_t raddr) +{ +CPUState *cs =env_cpu (env); + + cs->exception_index = exception; + env->error_code = error_code; +cpu_loop_exit_restore (cs, raddr); +} + +void helper_raise_exception_err (CPUPPCState *env,uint32_t exception, +uint32_t error_code) +{ +raise_exception_err_ra (env, exception, error_code,0 ); +} + +void helper_raise_exception (CPUPPCState *env,uint32_t exception) +{ +raise_exception_err_ra (env, exception,0 ,0 ); +} +#ifndef CONFIG_USER_ONLY +void raise_exception_err (CPUPPCState *env,uint32_t exception, +uint32_t error_code) +{ +raise_exception_err_ra (env, exception, error_code,0 ); +} + +void raise_exception (CPUPPCState *env,uint32_t exception) +{ +raise_exception_err_ra (env, exception,0 ,0 ); +} +void ppc_cpu_do_unaligned_access (CPUState *cs,vaddr vaddr,MMUAccessType access_type,int mmu_idx,uintptr_t retaddr)
Signature · 1 line
2.47.1
Nicholas Piggin
reviewer[PULL 71/72] ppc/amigaone: Add #defines for memory map constants
In reply to Nicholas PigginFrom: BALATON Zoltan <[email protected]>
Message-ID: <3b8e54ad9220d57e7b0a33f3570e880f26677ce8.1740673173.git.balaton@eik.bme.hu>
--- hw/ppc/amigaone.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-)
hw/ppc/amigaone.c +14 -6
@@ -32,6 +32,14 @@#define BUS_FREQ_HZ 100000000#define INITRD_MIN_ADDR 0x600000 +#define INIT_RAM_ADDR 0x40000000 + +#define PCI_HIGH_ADDR 0x80000000 +#define PCI_HIGH_SIZE 0x7d000000 +#define PCI_LOW_ADDR 0xfd000000 +#define PCI_LOW_SIZE 0xe0000 + +#define ARTICIA_ADDR 0xfe000000/* * Firmware binary available at
@@ -287,7 +295,7 @@ static void amigaone_init(MachineState *machine)/* Firmware uses this area for startup */ mr =g_new (MemoryRegion,1 );memory_region_init_ram (mr,NULL ,"init-cache" ,32 * KiB, &error_fatal); -memory_region_add_subregion (get_system_memory (),0x40000000 , mr); +memory_region_add_subregion (get_system_memory (),INIT_RAM_ADDR , mr); }/* nvram */
@@ -322,7 +330,7 @@ static void amigaone_init(MachineState *machine) }/* Articia S */ - dev =sysbus_create_simple (TYPE_ARTICIA ,0xfe000000 ,NULL ); + dev =sysbus_create_simple (TYPE_ARTICIA ,ARTICIA_ADDR ,NULL ); i2c_bus =I2C_BUS (qdev_get_child_bus (dev,"smbus" ));if (machine->ram_size >512 * MiB) {
@@ -339,12 +347,12 @@ static void amigaone_init(MachineState *machine) pci_mem =sysbus_mmio_get_region (SYS_BUS_DEVICE (dev),1 ); mr =g_new (MemoryRegion,1 );memory_region_init_alias (mr,OBJECT (dev),"pci-mem-low" , pci_mem, -0 ,0xe0000 ); -memory_region_add_subregion (get_system_memory (),0xfd000000 , mr); +0 ,PCI_LOW_SIZE ); +memory_region_add_subregion (get_system_memory (),PCI_LOW_ADDR , mr); mr =g_new (MemoryRegion,1 );memory_region_init_alias (mr,OBJECT (dev),"pci-mem-high" , pci_mem, -0x80000000 ,0x7d000000 ); -memory_region_add_subregion (get_system_memory (),0x80000000 , mr); +PCI_HIGH_ADDR ,PCI_HIGH_SIZE ); +memory_region_add_subregion (get_system_memory (),PCI_HIGH_ADDR , mr); pci_bus =PCI_BUS (qdev_get_child_bus (dev,"pci.0" ));/* VIA VT82c686B South Bridge (multifunction PCI device) */
Signature · 1 line
2.47.1
Nicholas Piggin
reviewer[PULL 36/72] qtest/xive: Add test of pool interrupts
In reply to Nicholas PigginFrom: Glenn Miles <[email protected]>
Added new test for pool interrupts. Removed all printfs from pnv-xive2-* qtests.
--- tests/qtest/pnv-xive2-test.c | 76 ++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+)
tests/qtest/pnv-xive2-test.c +76 -0
@@ -267,6 +267,79 @@ static void test_hw_irq(QTestState *qts) g_assert_cmphex(cppr, ==, 0xFF); } +static void test_pool_irq (QTestState *qts) +{ +uint32_t irq =2 ; +uint32_t irq_data =0x600d0d06 ; +uint32_t end_index =5 ; +uint32_t target_pir =1 ; +uint32_t target_nvp =0x100 + target_pir; +uint8_t priority =5 ; +uint32_t reg32; +uint16_t reg16; +uint8_t pq, nsr, cppr, ipb; + +g_test_message ("=========================================================" ); +g_test_message ("Testing irq %d to pool thread %d" , irq, target_pir); + +/* irq config */ +set_eas (qts, irq, end_index, irq_data); +set_end (qts, end_index, target_nvp, priority, false/* group */ ); + +/* enable and trigger irq */ +get_esb (qts, irq,XIVE_EOI_PAGE ,XIVE_ESB_SET_PQ_00 ); +set_esb (qts, irq,XIVE_TRIGGER_PAGE ,0 ,0 ); + +/* check irq is raised on cpu */ + pq =get_esb (qts, irq,XIVE_EOI_PAGE ,XIVE_ESB_GET ); + g_assert_cmpuint(pq, ==, XIVE_ESB_PENDING); + +/* check TIMA values in the PHYS ring (shared by POOL ring) */ + reg32 =get_tima32 (qts, target_pir,TM_QW3_HV_PHYS +TM_WORD0 ); + nsr = reg32 >>24 ; + cppr = (reg32 >>16 ) &0xFF ; + g_assert_cmphex(nsr, ==, 0x40); + g_assert_cmphex(cppr, ==, 0xFF); + +/* check TIMA values in the POOL ring */ + reg32 =get_tima32 (qts, target_pir,TM_QW2_HV_POOL +TM_WORD0 ); + nsr = reg32 >>24 ; + cppr = (reg32 >>16 ) &0xFF ; + ipb = (reg32 >>8 ) &0xFF ; + g_assert_cmphex(nsr, ==, 0); + g_assert_cmphex(cppr, ==, 0); + g_assert_cmphex(ipb, ==, 0x80 >> priority); + +/* ack the irq */ + reg16 =get_tima16 (qts, target_pir,TM_SPC_ACK_HV_REG ); + nsr = reg16 >>8 ; + cppr = reg16 &0xFF ; + g_assert_cmphex(nsr, ==, 0x40); + g_assert_cmphex(cppr, ==, priority); + +/* check irq data is what was configured */ + reg32 =qtest_readl (qts,xive_get_queue_addr (end_index)); + g_assert_cmphex((reg32 & 0x7fffffff), ==, (irq_data & 0x7fffffff)); + +/* check IPB is cleared in the POOL ring */ + reg32 =get_tima32 (qts, target_pir,TM_QW2_HV_POOL +TM_WORD0 ); + ipb = (reg32 >>8 ) &0xFF ; + g_assert_cmphex(ipb, ==, 0); + +/* End Of Interrupt */ +set_esb (qts, irq,XIVE_EOI_PAGE ,XIVE_ESB_STORE_EOI ,0 ); + pq =get_esb (qts, irq,XIVE_EOI_PAGE ,XIVE_ESB_GET ); + g_assert_cmpuint(pq, ==, XIVE_ESB_RESET); + +/* reset CPPR */ +set_tima8 (qts, target_pir,TM_QW3_HV_PHYS +TM_CPPR ,0xFF ); + reg32 =get_tima32 (qts, target_pir,TM_QW3_HV_PHYS +TM_WORD0 ); + nsr = reg32 >>24 ; + cppr = (reg32 >>16 ) &0xFF ; + g_assert_cmphex(nsr, ==, 0x00); + g_assert_cmphex(cppr, ==, 0xFF); +} +#define XIVE_ODD_CL 0x80static void test_pull_thread_ctx_to_odd_thread_cl (QTestState *qts) {
@@ -486,6 +559,9 @@ static void test_xive(void)/* omit reset_state here and use settings from test_hw_irq */ test_pull_thread_ctx_to_odd_thread_cl (qts); +reset_state (qts); +test_pool_irq (qts); +reset_state (qts);test_hw_group_irq (qts);
Signature · 1 line
2.47.1
Nicholas Piggin
reviewer[PULL 43/72] target/ppc: Make ppc_ldl_code() declaration public
In reply to Nicholas PigginFrom: Philippe Mathieu-Daudé <[email protected]>
We are going to move code calling ppc_ldl_code() out of excp_helper.c where it is defined. Expose its declaration for few commits, until eventually making it static again once everything is moved.
Message-ID: <[email protected]>
--- target/ppc/excp_helper.c | 2 +- target/ppc/internal.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)
target/ppc/excp_helper.c +1 -1
@@ -144,7 +144,7 @@ static inline bool insn_need_byteswap(CPUArchState *env)return !!(env->msr & ((target_ulong )1 <<MSR_LE )); } -static uint32_t ppc_ldl_code (CPUArchState *env,target_ulong addr) +uint32_t ppc_ldl_code (CPUArchState *env,target_ulong addr) {uint32_t insn =cpu_ldl_code (env, addr);
target/ppc/internal.h +2 -0
@@ -268,6 +268,8 @@ static inline void pte_invalidate(target_ulong *pte0)#define PTE_PTEM_MASK 0x7FFFFFBF#define PTE_CHECK_MASK (TARGET_PAGE_MASK | 0x7B) +uint32_t ppc_ldl_code (CPUArchState *env,target_ulong addr); +#ifdef CONFIG_USER_ONLY void ppc_cpu_record_sigsegv(CPUState *cs, vaddr addr, MMUAccessType access_type,
Signature · 1 line
2.47.1
Nicholas Piggin
reviewer[PULL 40/72] hw/ssi/pnv_spi: Put a limit to RDR match failures
In reply to Nicholas PigginFrom: Chalapathi V <[email protected]>
There is a possibility that SPI controller can get into loop due to indefinite RDR match failures. Hence put a limit to failures and stop the sequencer.
Message-ID: <[email protected]>
--- hw/ssi/pnv_spi.c | 10 ++++++++++ include/hw/ssi/pnv_spi.h | 1 + 2 files changed, 11 insertions(+)
hw/ssi/pnv_spi.c +10 -0
@@ -20,6 +20,7 @@#define PNV_SPI_OPCODE_LO_NIBBLE (x) (x & 0x0F)#define PNV_SPI_MASKED_OPCODE (x) (x & 0xF0)#define PNV_SPI_FIFO_SIZE 16 +#define RDR_MATCH_FAILURE_LIMIT 16/* * Macro from include/hw/ppc/fdt.h
@@ -872,18 +873,27 @@ static void operation_sequencer(PnvSpi *s) rdr_matched =does_rdr_match (s);if (rdr_matched) {trace_pnv_spi_RDR_match ("success" ); + s->fail_count =0 ;/* A match occurred, increment the sequencer index. */ seq_index++; s->status =SETFIELD (SPI_STS_SEQ_FSM , s->status,SEQ_STATE_INDEX_INCREMENT ); }else {trace_pnv_spi_RDR_match ("failed" ); + s->fail_count++;/* * Branch the sequencer to the index coded into the op * code. */ seq_index =PNV_SPI_OPCODE_LO_NIBBLE (opcode); } +if (s->fail_count >=RDR_MATCH_FAILURE_LIMIT ) { +qemu_log_mask (LOG_GUEST_ERROR ,"pnv_spi: RDR match failure" +" limit crossed %d times hence requesting " +"sequencer to stop.\n" , +RDR_MATCH_FAILURE_LIMIT ); + stop = true; + }/* * Regardless of where the branch ended up we want the * sequencer to continue shifting so we have to clear
include/hw/ssi/pnv_spi.h +1 -0
@@ -40,6 +40,7 @@ typedef struct PnvSpi {MemoryRegion xscom_spic_regs;Fifo8 tx_fifo;Fifo8 rx_fifo; +uint8_t fail_count;/* RDR Match failure counter */ /* SPI object number */ uint32_t spic_num;uint32_t chip_id;
Signature · 1 line
2.47.1
Nicholas Piggin
reviewer[PULL 59/72] hw/ppc/epapr: Do not swap ePAPR magic value
In reply to Nicholas PigginFrom: Philippe Mathieu-Daudé <[email protected]>
The ePAPR magic value in $r6 doesn't need to be byte swapped.
See ePAPR-v1.1.pdf chapter 5.4.1 "Boot CPU Initial Register State" and the following mailing-list threads:
https://lore.kernel.org/qemu-devel/CAFEAcA_NR4XW5DNL4nq7vnH4XRH5UWbhQCxuLyKqYk6_FCBrAA@mail.gmail.com/
https://lore.kernel.org/qemu-devel/[email protected]/
Message-ID: <[email protected]>
--- hw/ppc/sam460ex.c | 2 +- hw/ppc/virtex_ml507.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
hw/ppc/sam460ex.c +1 -1
@@ -234,7 +234,7 @@ static void main_cpu_reset(void *opaque)/* Create a mapping for the kernel. */ booke_set_tlb (&env->tlb.tlbe[0 ],0 ,0 ,1 <<31 ); - env->gpr[6 ] =tswap32 (EPAPR_MAGIC ); + env->gpr[6 ] =EPAPR_MAGIC ; env->gpr[7 ] = (16 * MiB) -8 ;/* bi->ima_size; */ }else {
hw/ppc/virtex_ml507.c +1 -1
@@ -119,7 +119,7 @@ static void main_cpu_reset(void *opaque)/* Create a mapping spanning the 32bit addr space. */ booke_set_tlb (&env->tlb.tlbe[0 ],0 ,0 ,1U <<31 );booke_set_tlb (&env->tlb.tlbe[1 ],0x80000000 ,0x80000000 ,1U <<31 ); - env->gpr[6 ] =tswap32 (EPAPR_MAGIC ); + env->gpr[6 ] =EPAPR_MAGIC ; env->gpr[7 ] = bi->ima_size; }
Signature · 1 line
2.47.1
Nicholas Piggin
reviewer[PULL 70/72] ppc/amigaone: Add kernel and initrd support
In reply to Nicholas PigginFrom: BALATON Zoltan <[email protected]>
Add support for -kernel, -initrd and -append command line options.
Message-ID: <489b1be5d95d5153e924c95b0691b8b53f9ffb9e.1740673173.git.balaton@eik.bme.hu>
--- hw/ppc/amigaone.c | 113 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 112 insertions(+), 1 deletion(-)
hw/ppc/amigaone.c +112 -1
@@ -25,11 +25,14 @@#include "system/qtest.h" #include "system/reset.h" #include "kvm_ppc.h" +#include "elf.h" #include <zlib.h> /* for crc32 */ #define BUS_FREQ_HZ 100000000 +#define INITRD_MIN_ADDR 0x600000 +/* * Firmware binary available at * https://www.hyperion-entertainment.com/index.php/downloads?view=files&parent=28
@@ -178,12 +181,68 @@ static const TypeInfo nvram_types[] = { };DEFINE_TYPES (nvram_types) +struct boot_info { +hwaddr entry; +hwaddr stack; +hwaddr bd_info; +hwaddr initrd_start; +hwaddr initrd_end; +hwaddr cmdline_start; +hwaddr cmdline_end; +}; + +/* Board info struct from U-Boot */ +struct bd_info { +uint32_t bi_memstart; +uint32_t bi_memsize; +uint32_t bi_flashstart; +uint32_t bi_flashsize; +uint32_t bi_flashoffset; +uint32_t bi_sramstart; +uint32_t bi_sramsize; +uint32_t bi_bootflags; +uint32_t bi_ip_addr; +uint8_t bi_enetaddr[6 ]; +uint16_t bi_ethspeed; +uint32_t bi_intfreq; +uint32_t bi_busfreq; +uint32_t bi_baudrate; +}QEMU_PACKED ; + +static void create_bd_info (hwaddr addr,ram_addr_t ram_size) +{ + struct bd_info *bd = g_new0(struct bd_info, 1); + + bd->bi_memsize =cpu_to_be32 (ram_size); + bd->bi_flashstart =cpu_to_be32 (PROM_ADDR ); + bd->bi_flashsize =cpu_to_be32 (1 );/* match what U-Boot detects */ + bd->bi_bootflags =cpu_to_be32 (1 ); + bd->bi_intfreq =cpu_to_be32 (11.5 *BUS_FREQ_HZ ); + bd->bi_busfreq =cpu_to_be32 (BUS_FREQ_HZ ); + bd->bi_baudrate =cpu_to_be32 (115200 ); + +cpu_physical_memory_write (addr, bd,sizeof (*bd)); +} +static void amigaone_cpu_reset (void *opaque) {PowerPCCPU *cpu = opaque; +CPUPPCState *env = &cpu->env;cpu_reset (CPU (cpu)); -cpu_ppc_tb_reset (&cpu->env); +if (env->load_info) { +struct boot_info *bi = env->load_info; + + env->gpr[1 ] = bi->stack; + env->gpr[2 ] =1024 ; + env->gpr[3 ] = bi->bd_info; + env->gpr[4 ] = bi->initrd_start; + env->gpr[5 ] = bi->initrd_end; + env->gpr[6 ] = bi->cmdline_start; + env->gpr[7 ] = bi->cmdline_end; + env->nip = bi->entry; + } +cpu_ppc_tb_reset (env); }static void fix_spd_data (uint8_t *spd)
@@ -205,6 +264,8 @@ static void amigaone_init(MachineState *machine)I2CBus *i2c_bus;uint8_t *spd_data;DriveInfo *di; +hwaddr loadaddr; +struct boot_info *bi =NULL ;/* init CPU */ cpu =POWERPC_CPU (cpu_create (machine->cpu_type));
@@ -301,6 +362,56 @@ static void amigaone_init(MachineState *machine) }pci_ide_create_devs (PCI_DEVICE (object_resolve_path_component (via,"ide" )));pci_vga_init (pci_bus); + +if (!machine->kernel_filename) { +return ; + } + +/* handle -kernel, -initrd, -append options and emulate U-Boot */ + bi = g_new0(struct boot_info, 1); + cpu->env.load_info = bi; + + loadaddr =MIN (machine->ram_size,256 * MiB); + bi->bd_info = loadaddr -8 * MiB; +create_bd_info (bi->bd_info, machine->ram_size); + bi->stack = bi->bd_info -64 * KiB -8 ; + +if (machine->kernel_cmdline && machine->kernel_cmdline[0 ]) { +size_t len =strlen (machine->kernel_cmdline); + + loadaddr = bi->bd_info +1 * MiB; +cpu_physical_memory_write (loadaddr, machine->kernel_cmdline, len +1 ); + bi->cmdline_start = loadaddr; + bi->cmdline_end = loadaddr + len +1 ;/* including terminating '\0' */ + } + + sz =load_elf (machine->kernel_filename,NULL ,NULL ,NULL , + &bi->entry, &loadaddr,NULL ,NULL , +ELFDATA2MSB ,PPC_ELF_MACHINE ,0 ,0 ); +if (sz <=0 ) { + sz =load_uimage (machine->kernel_filename, &bi->entry, &loadaddr, +NULL ,NULL ,NULL ); + } +if (sz <=0 ) { +error_report ("Could not load kernel '%s'" , + machine->kernel_filename); +exit (1 ); + } + loadaddr += sz; + +if (machine->initrd_filename) { + loadaddr =ROUND_UP (loadaddr +4 * MiB,4 * KiB); + loadaddr =MAX (loadaddr,INITRD_MIN_ADDR ); + sz =load_image_targphys (machine->initrd_filename, loadaddr, + bi->bd_info - loadaddr); +if (sz <=0 ) { +error_report ("Could not load initrd '%s'" , + machine->initrd_filename); +exit (1 ); + } + bi->initrd_start = loadaddr; + bi->initrd_end = loadaddr + sz; + } }static void amigaone_machine_init (MachineClass *mc)
Signature · 1 line
2.47.1
Re: [PULL 70/72] ppc/amigaone: Add kernel and initrd support
Hi,
Quoted 31 lines · Nicholas Piggin
From: BALATON Zoltan <[email protected]>
Add support for -kernel, -initrd and -append command line options.
Signed-off-by BALATON Zoltan <[email protected]>Reviewed-by Nicholas Piggin <[email protected]>Message-ID: <489b1be5d95d5153e924c95b0691b8b53f9ffb9e.1740673173.git.balaton@eik.bme.hu>
Signed-off-by Nicholas Piggin <[email protected]>--- hw/ppc/amigaone.c | 113 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 112 insertions(+), 1 deletion(-)hw/ppc/amigaone.c +9
-0@@ -301,6 +362,56 @@ static void amigaone_init(MachineState *machine) }pci_ide_create_devs (PCI_DEVICE (object_resolve_path_component (via,"ide" )));pci_vga_init (pci_bus); + +if (!machine->kernel_filename) { +return ; + } + +/* handle -kernel, -initrd, -append options and emulate U-Boot */ + bi = g_new0(struct boot_info, 1); + cpu->env.load_info = bi; +
hw/ppc/amigaone.c static void amigaone_init(MachineState *machine) · line 383
Quoted 10 lines
hw/ppc/amigaone.c +10
-0+ loadaddr =MIN (machine->ram_size,256 * MiB); + bi->bd_info = loadaddr -8 * MiB; +create_bd_info (bi->bd_info, machine->ram_size); + bi->stack = bi->bd_info -64 * KiB -8 ; + +if (machine->kernel_cmdline && machine->kernel_cmdline[0 ]) { +size_t len =strlen (machine->kernel_cmdline); + + loadaddr = bi->bd_info +1 * MiB; +cpu_physical_memory_write (loadaddr, machine->kernel_cmdline, len +1 );
This patch introduces a call to a legacy API (documented since at least 2017 in commit b7ecba0f6f6: "docs/devel/loads-stores.rst: Document our various load and store APIs"). Can we load via &address_space_memory instead?
Quoted 34 lines
hw/ppc/amigaone.c +31
-0+ bi->cmdline_start = loadaddr; + bi->cmdline_end = loadaddr + len +1 ;/* including terminating '\0' */ + } + + sz =load_elf (machine->kernel_filename,NULL ,NULL ,NULL , + &bi->entry, &loadaddr,NULL ,NULL , +ELFDATA2MSB ,PPC_ELF_MACHINE ,0 ,0 ); +if (sz <=0 ) { + sz =load_uimage (machine->kernel_filename, &bi->entry, &loadaddr, +NULL ,NULL ,NULL ); + } +if (sz <=0 ) { +error_report ("Could not load kernel '%s'" , + machine->kernel_filename); +exit (1 ); + } + loadaddr += sz; + +if (machine->initrd_filename) { + loadaddr =ROUND_UP (loadaddr +4 * MiB,4 * KiB); + loadaddr =MAX (loadaddr,INITRD_MIN_ADDR ); + sz =load_image_targphys (machine->initrd_filename, loadaddr, + bi->bd_info - loadaddr); +if (sz <=0 ) { +error_report ("Could not load initrd '%s'" , + machine->initrd_filename); +exit (1 ); + } + bi->initrd_start = loadaddr; + bi->initrd_end = loadaddr + sz; + } }static void amigaone_machine_init (MachineClass *mc)
Re: [PULL 70/72] ppc/amigaone: Add kernel and initrd support
Quoted 40 lines · Philippe Mathieu-Daudé
Quoted 39 lines · Nicholas Piggin
From: BALATON Zoltan <[email protected]>
Add support for -kernel, -initrd and -append command line options.
Signed-off-by BALATON Zoltan <[email protected]>Reviewed-by Nicholas Piggin <[email protected]>Message-ID: <489b1be5d95d5153e924c95b0691b8b53f9ffb9e.1740673173.git.balaton@eik.bme.hu>
Signed-off-by Nicholas Piggin <[email protected]>--- hw/ppc/amigaone.c | 113 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 112 insertions(+), 1 deletion(-)hw/ppc/amigaone.c +16
-0@@ -301,6 +362,56 @@ static void amigaone_init(MachineState *machine) }pci_ide_create_devs (PCI_DEVICE (object_resolve_path_component (via,"ide" )));pci_vga_init (pci_bus); + +if (!machine->kernel_filename) { +return ; + } + +/* handle -kernel, -initrd, -append options and emulate U-Boot */ + bi = g_new0(struct boot_info, 1); + cpu->env.load_info = bi; + + loadaddr =MIN (machine->ram_size,256 * MiB); + bi->bd_info = loadaddr -8 * MiB; +create_bd_info (bi->bd_info, machine->ram_size); + bi->stack = bi->bd_info -64 * KiB -8 ; + +if (machine->kernel_cmdline && machine->kernel_cmdline[0 ]) { +size_t len =strlen (machine->kernel_cmdline);
Quoted 8 lines
hw/ppc/amigaone.c static void amigaone_init(MachineState *machine)
Quoted 4 lines
hw/ppc/amigaone.c +3
-0+ + loadaddr = bi->bd_info +1 * MiB; +cpu_physical_memory_write (loadaddr, machine->kernel_cmdline, len +1 );This patch introduces a call to a legacy API (documented since at least 2017 in commit
b7ecba0f6f6: "docs/devel/loads-stores.rst: Document our various load and store APIs").
It does not say deprecated but only if you're in a device you probably need something else as this implicitly operates on system address space and does not report errors. But we're in a machine here and there's nothing to be done for a failure which is not expected at this point.
Quoted 1 line
Can we load via
&address_space_memoryinstead?
I guess we could but that would just make this line much longer and less readable. There are plenty of places using this still so unless it's about to be removed I'd leave it as it is. Get back to this when it's the last instance.
Regards,
BALATON Zoltan
Re: [PULL 70/72] ppc/amigaone: Add kernel and initrd support
In reply to Nicholas PigginQuoted 10 lines · Nicholas Piggin
From: BALATON Zoltan <[email protected]>
Add support for -kernel, -initrd and -append command line options.
Signed-off-by BALATON Zoltan <[email protected]>Reviewed-by Nicholas Piggin <[email protected]>Message-ID: <489b1be5d95d5153e924c95b0691b8b53f9ffb9e.1740673173.git.balaton@eik.bme.hu>
Signed-off-by Nicholas Piggin <[email protected]>---
Hi; Coverity reports a memory leak in this function (CID 1641398):
hw/ppc/amigaone.c static const TypeInfo nvram_types[] = { · line 214
Quoted 3 lines
hw/ppc/amigaone.c +3
-0+static void create_bd_info (hwaddr addr,ram_addr_t ram_size) +{ + struct bd_info *bd = g_new0(struct bd_info, 1);
We allocate the bd_info struct here...
hw/ppc/amigaone.c static const TypeInfo nvram_types[] = { · line 224
Quoted 10 lines
hw/ppc/amigaone.c +10
-0+ + bd->bi_memsize =cpu_to_be32 (ram_size); + bd->bi_flashstart =cpu_to_be32 (PROM_ADDR ); + bd->bi_flashsize =cpu_to_be32 (1 );/* match what U-Boot detects */ + bd->bi_bootflags =cpu_to_be32 (1 ); + bd->bi_intfreq =cpu_to_be32 (11.5 *BUS_FREQ_HZ ); + bd->bi_busfreq =cpu_to_be32 (BUS_FREQ_HZ ); + bd->bi_baudrate =cpu_to_be32 (115200 ); + +cpu_physical_memory_write (addr, bd,sizeof (*bd));
...but we never free it or keep a pointer to it.
I guess we can mark it g_autofree ?
Quoted 1 line
+}
thanks
-- PMM
Nicholas Piggin
reviewer[PULL 44/72] target/ppc: Move TCG specific exception handlers to tcg-excp_helper.c
In reply to Nicholas PigginFrom: Philippe Mathieu-Daudé <[email protected]>
Move the TCGCPUOps handlers to a new unit: tcg-excp_helper.c, only built when TCG is selected.
See in target/ppc/cpu_init.c:
#ifdef CONFIG_TCG
static const TCGCPUOps ppc_tcg_ops = {
...
.do_unaligned_access = ppc_cpu_do_unaligned_access, .do_transaction_failed = ppc_cpu_do_transaction_failed, .debug_excp_handler = ppc_cpu_debug_excp_handler, .debug_check_breakpoint = ppc_cpu_debug_check_breakpoint, .debug_check_watchpoint = ppc_cpu_debug_check_watchpoint,
};
#endif /* CONFIG_TCG */
Message-ID: <[email protected]>
--- target/ppc/excp_helper.c | 173 ------------------------------ target/ppc/meson.build | 1 + target/ppc/tcg-excp_helper.c | 202 +++++++++++++++++++++++++++++++++++ 3 files changed, 203 insertions(+), 173 deletions(-) create mode 100644 target/ppc/tcg-excp_helper.c
target/ppc/excp_helper.c +0 -173
@@ -3144,178 +3144,5 @@ void helper_book3s_trace(CPUPPCState *env, target_ulong prev_ip)raise_exception_err (env,POWERPC_EXCP_TRACE , error_code); } -void ppc_cpu_do_unaligned_access (CPUState *cs,vaddr vaddr, -MMUAccessType access_type, -int mmu_idx,uintptr_t retaddr) -{ -CPUPPCState *env =cpu_env (cs); -uint32_t insn; - -/* Restore state and reload the insn we executed, for filling in DSISR. */ -cpu_restore_state (cs, retaddr); - insn =ppc_ldl_code (env, env->nip); - -switch (env->mmu_model) { -case POWERPC_MMU_SOFT_4xx: - env->spr[SPR_40x_DEAR] = vaddr; -break ; -case POWERPC_MMU_BOOKE : -case POWERPC_MMU_BOOKE206 : - env->spr[SPR_BOOKE_DEAR ] = vaddr; -break ; -default : - env->spr[SPR_DAR ] = vaddr; -break ; - } - - cs->exception_index =POWERPC_EXCP_ALIGN ; - env->error_code = insn &0x03FF0000 ; -cpu_loop_exit (cs); -} - -void ppc_cpu_do_transaction_failed (CPUState *cs,hwaddr physaddr, -vaddr vaddr,unsigned size, -MMUAccessType access_type, -int mmu_idx,MemTxAttrs attrs, -MemTxResult response,uintptr_t retaddr) -{ -CPUPPCState *env =cpu_env (cs); - -switch (env->excp_model) { -#if defined(TARGET_PPC64 ) -case POWERPC_EXCP_POWER8 : -case POWERPC_EXCP_POWER9 : -case POWERPC_EXCP_POWER10 : -case POWERPC_EXCP_POWER11 : -/* -* Machine check codes can be found in processor User Manual or -* Linux or skiboot source. -*/ -if (access_type ==MMU_DATA_LOAD ) { - env->spr[SPR_DAR ] = vaddr; - env->spr[SPR_DSISR ] =PPC_BIT (57 ); - env->error_code =PPC_BIT (42 ); - - }else if (access_type ==MMU_DATA_STORE ) { -/* -* MCE for stores in POWER is asynchronous so hardware does -* not set DAR, but QEMU can do better. -*/ - env->spr[SPR_DAR ] = vaddr; - env->error_code =PPC_BIT (36 ) |PPC_BIT (43 ) |PPC_BIT (45 ); - env->error_code |=PPC_BIT (42 ); - - }else {/* Fetch */ -/* -* is_prefix_insn_excp() tests !PPC_BIT(42) to avoid fetching -* the instruction, so that must always be clear for fetches. -*/ - env->error_code =PPC_BIT (36 ) |PPC_BIT (44 ) |PPC_BIT (45 ); - } -break ; -#endif -default : -/* -* TODO: Check behaviour for other CPUs, for now do nothing. -* Could add a basic MCE even if real hardware ignores. -*/ -return ; - } - - cs->exception_index =POWERPC_EXCP_MCHECK ; -cpu_loop_exit_restore (cs, retaddr); -} - -void ppc_cpu_debug_excp_handler (CPUState *cs) -{ -#if defined(TARGET_PPC64 ) -CPUPPCState *env =cpu_env (cs); - -if (env->insns_flags2 &PPC2_ISA207S ) { -if (cs->watchpoint_hit) { -if (cs->watchpoint_hit->flags &BP_CPU ) { - env->spr[SPR_DAR ] = cs->watchpoint_hit->hitaddr; - env->spr[SPR_DSISR ] =PPC_BIT (41 ); - cs->watchpoint_hit =NULL ; -raise_exception (env,POWERPC_EXCP_DSI ); - } - cs->watchpoint_hit =NULL ; - }else if (cpu_breakpoint_test (cs, env->nip,BP_CPU )) { -raise_exception_err (env,POWERPC_EXCP_TRACE , -PPC_BIT (33 ) |PPC_BIT (43 )); - } - } -#endif -} - -bool ppc_cpu_debug_check_breakpoint (CPUState *cs) -{ -#if defined(TARGET_PPC64 ) -CPUPPCState *env =cpu_env (cs); - -if (env->insns_flags2 &PPC2_ISA207S ) { -target_ulong priv; - - priv = env->spr[SPR_CIABR ] &PPC_BITMASK (62 ,63 ); -switch (priv) { -case 0x1 :/* problem */ -return env->msr & ((target_ulong )1 <<MSR_PR ); -case 0x2 :/* supervisor */ -return (!(env->msr & ((target_ulong )1 <<MSR_PR )) && - !(env->msr & ((target_ulong )1 <<MSR_HV ))); -case 0x3 :/* hypervisor */ -return (!(env->msr & ((target_ulong )1 <<MSR_PR )) && - (env->msr & ((target_ulong )1 <<MSR_HV ))); -default : -g_assert_not_reached (); - } - } -#endif - -return false; -} - -bool ppc_cpu_debug_check_watchpoint (CPUState *cs,CPUWatchpoint *wp) -{ -#if defined(TARGET_PPC64 ) -CPUPPCState *env =cpu_env (cs); - -if (env->insns_flags2 &PPC2_ISA207S ) { -if (wp == env->dawr0_watchpoint) { -uint32_t dawrx = env->spr[SPR_DAWRX0 ]; -bool wt =extract32 (dawrx,PPC_BIT_NR (59 ),1 ); -bool wti =extract32 (dawrx,PPC_BIT_NR (60 ),1 ); -bool hv =extract32 (dawrx,PPC_BIT_NR (61 ),1 ); -bool sv =extract32 (dawrx,PPC_BIT_NR (62 ),1 ); -bool pr =extract32 (dawrx,PPC_BIT_NR (62 ),1 ); - -if ((env->msr & ((target_ulong )1 <<MSR_PR )) && !pr) { -return false; - }else if ((env->msr & ((target_ulong )1 <<MSR_HV )) && !hv) { -return false; - }else if (!sv) { -return false; - } - -if (!wti) { -if (env->msr & ((target_ulong )1 <<MSR_DR )) { -if (!wt) { -return false; - } - }else { -if (wt) { -return false; - } - } - } - -return true; - } - } -#endif - -return false; -} -#endif /* !CONFIG_USER_ONLY */ #endif /* CONFIG_TCG */
target/ppc/meson.build +1 -0
@@ -14,6 +14,7 @@ ppc_ss.add(when: 'CONFIG_TCG', if_true: files( 'int_helper.c', 'mem_helper.c', 'misc_helper.c', + 'tcg-excp_helper.c', 'timebase_helper.c', 'translate.c', 'power8-pmu.c',
target/ppc/tcg-excp_helper.c new file +202 -0
202 lines not on this page · raw message
Signature · 1 line
2.47.1
Nicholas Piggin
reviewer[PULL 41/72] hw/ppc/spapr: Restrict CONFER hypercall to TCG
In reply to Nicholas PigginFrom: Philippe Mathieu-Daudé <[email protected]>
KVM handles H_CONFER and does not pass it along to QEMU, so only vhyp (as used by TCG spapr) needs to handle it.
Message-ID: <[email protected]>
--- hw/ppc/spapr_hcall.c | 2 ++ 1 file changed, 2 insertions(+)
hw/ppc/spapr_hcall.c +2 -0
@@ -580,6 +580,8 @@ static target_ulong h_confer(PowerPCCPU *cpu, SpaprMachineState *spapr,CPUState *cs =CPU (cpu);SpaprCpuState *spapr_cpu; +assert (tcg_enabled ());/* KVM will have handled this */ +/* * -1 means confer to all other CPUs without dispatch counter check, * otherwise it's a targeted confer.
Signature · 1 line
2.47.1
Nicholas Piggin
reviewer[PULL 72/72] docs/system/ppc/amigang.rst: Update for NVRAM emulation
In reply to Nicholas PigginFrom: BALATON Zoltan <[email protected]>
Add NVRAM and hint on how to make it persistent. Also update Linux boot section which should now boot automatically with the new NVRAM defaults so manual settings in menu may not be needed normally.
Message-ID: <[email protected]>
--- docs/system/ppc/amigang.rst | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
docs/system/ppc/amigang.rst +9 -8
@@ -21,6 +21,7 @@ Emulated devices * VIA VT82C686B south bridge * PCI VGA compatible card (guests may need other card instead) * PS/2 keyboard and mouse + * 4 KiB NVRAM (use ``-drive if=mtd,format=raw,file=nvram.bin`` to keep contents persistent) Firmware --------
@@ -54,14 +55,14 @@ To boot the system run: -cdrom "A1 Linux Net Installer.iso" \ -device ati-vga,model=rv100,romfile=VGABIOS-lgpl-latest.bin -From the firmware menu that appears select ``Boot sequence`` → -``Amiga Multiboot Options`` and set ``Boot device 1`` to -``Onboard VIA IDE CDROM``. Then hit escape until the main screen appears again, -hit escape once more and from the exit menu that appears select either -``Save settings and exit`` or ``Use settings for this session only``. It may -take a long time loading the kernel into memory but eventually it boots and the -installer becomes visible. The ``ati-vga`` RV100 emulation is not -complete yet so only frame buffer works, DRM and 3D is not available. +If a firmware menu appears, select ``Boot sequence`` → ``Amiga Multiboot Options`` +and set ``Boot device 1`` to ``Onboard VIA IDE CDROM``. Then hit escape until +the main screen appears again, hit escape once more and from the exit menu that +appears select either ``Save settings and exit`` or ``Use settings for this +session only``. It may take a long time loading the kernel into memory but +eventually it boots and the installer becomes visible. The ``ati-vga`` RV100 +emulation is not complete yet so only frame buffer works, DRM and 3D is not +available. Genesi/bPlan Pegasos II (``pegasos2``) ======================================
Signature · 1 line
2.47.1
Nicholas Piggin
reviewer[PULL 45/72] target/ppc: Move ppc_ldl_code() to tcg-excp_helper.c
In reply to Nicholas PigginFrom: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
--- target/ppc/excp_helper.c | 21 --------------------- target/ppc/tcg-excp_helper.c | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 21 deletions(-)
target/ppc/excp_helper.c +0 -21
@@ -136,27 +136,6 @@ static void dump_hcall(CPUPPCState *env) env->nip); } -#ifdef CONFIG_TCG -/* Return true iff byteswap is needed to load instruction */ -static inline bool insn_need_byteswap (CPUArchState *env) -{ -/* SYSTEM builds TARGET_BIG_ENDIAN. Need to swap when MSR[LE] is set */ -return !!(env->msr & ((target_ulong )1 <<MSR_LE )); -} - -uint32_t ppc_ldl_code (CPUArchState *env,target_ulong addr) -{ -uint32_t insn =cpu_ldl_code (env, addr); - -if (insn_need_byteswap (env)) { - insn =bswap32 (insn); - } - -return insn; -} - -#endif -static void ppc_excp_debug_sw_tlb (CPUPPCState *env,int excp) {const char *es;
target/ppc/tcg-excp_helper.c +18 -0
@@ -199,4 +199,22 @@ bool ppc_cpu_debug_check_watchpoint(CPUState *cs, CPUWatchpoint *wp) return false; } +/* Return true iff byteswap is needed to load instruction */ +static inline bool insn_need_byteswap (CPUArchState *env) +{ +/* SYSTEM builds TARGET_BIG_ENDIAN. Need to swap when MSR[LE] is set */ +return !!(env->msr & ((target_ulong )1 <<MSR_LE )); +} + +uint32_t ppc_ldl_code (CPUArchState *env,target_ulong addr) +{ +uint32_t insn =cpu_ldl_code (env, addr); + +if (insn_need_byteswap (env)) { + insn =bswap32 (insn); + } + +return insn; +} +#endif /* !CONFIG_USER_ONLY */
Signature · 1 line
2.47.1
Nicholas Piggin
reviewer[PULL 63/72] target/ppc: fix timebase register reset state
In reply to Nicholas Piggin(H)DEC and PURR get reset before icount does, which causes them to be skewed and not match the init state. This can cause replay to not match the recorded trace exactly. For DEC and HDEC this is usually not noticable since they tend to get programmed before affecting the target machine. PURR has been observed to cause replay bugs when running Linux.
Fix this by resetting using a time of 0.
Message-ID: <[email protected]>
--- hw/ppc/ppc.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
hw/ppc/ppc.c +8 -3
@@ -1123,16 +1123,21 @@ void cpu_ppc_tb_reset(CPUPPCState *env)timer_del (tb_env->hdecr_timer);ppc_set_irq (cpu,PPC_INTERRUPT_HDECR ,0 ); tb_env->hdecr_next =0 ; +_cpu_ppc_store_hdecr (cpu,0 ,0 ,0 ,64 ); }/* * There is a bug in Linux 2.4 kernels: * if a decrementer exception is pending when it enables msr_ee at startup, * it's not ready to handle it... +* +* On machine reset, this is called before icount is reset, so for +* icount-mode, setting TB registers using now == qemu_clock_get_ns() +* results in them being garbage after icount is reset. Use an +* explicit now == 0 to get a consistent reset state. */ -cpu_ppc_store_decr (env,-1 ); -cpu_ppc_store_hdecr (env,-1 ); -cpu_ppc_store_purr (env,0x0000000000000000ULL ); +_cpu_ppc_store_decr (cpu,0 ,0 ,-1 ,64 ); +_cpu_ppc_store_purr (env,0 ,0 ); }void cpu_ppc_tb_free (CPUPPCState *env)
Signature · 1 line
2.47.1
Nicholas Piggin
reviewer[PULL 23/72] ppc/xive2: Update NVP save/restore for group attributes
In reply to Nicholas PigginFrom: Frederic Barrat <[email protected]>
If the 'H' attribute is set on the NVP structure, the hardware automatically saves and restores some attributes from the TIMA in the NVP structure.
The group-specific attributes LSMFB, LGS and T have an extra flag to individually control what is saved/restored.
--- hw/intc/xive2.c | 23 ++++++++++++++++++----- include/hw/ppc/xive2_regs.h | 10 +++++++--- 2 files changed, 25 insertions(+), 8 deletions(-)
hw/intc/xive2.c +18 -5
@@ -1,10 +1,9 @@/* * QEMU PowerPC XIVE2 interrupt controller model (POWER10) * -* Copyright (c) 2019-2022, IBM Corporation.. +* Copyright (c) 2019-2024, IBM Corporation.. * -* This code is licensed under the GPL version 2 or later. See the -* COPYING file in the top-level directory. +* SPDX-License-Identifier: GPL-2.0-or-later */ #include "qemu/osdep.h"
@@ -313,7 +312,19 @@ static void xive2_tctx_save_ctx(Xive2Router *xrtr, XiveTCTX *tctx, nvp.w2 =xive_set_field32 (NVP2_W2_IPB , nvp.w2, regs[TM_IPB ]); nvp.w2 =xive_set_field32 (NVP2_W2_CPPR , nvp.w2, regs[TM_CPPR ]); - nvp.w2 =xive_set_field32 (NVP2_W2_LSMFB , nvp.w2, regs[TM_LSMFB ]); +if (nvp.w0 &NVP2_W0_L ) { +/* +* Typically not used. If LSMFB is restored with 0, it will +* force a backlog rescan +*/ + nvp.w2 =xive_set_field32 (NVP2_W2_LSMFB , nvp.w2, regs[TM_LSMFB ]); + } +if (nvp.w0 &NVP2_W0_G ) { + nvp.w2 =xive_set_field32 (NVP2_W2_LGS , nvp.w2, regs[TM_LGS ]); + } +if (nvp.w0 &NVP2_W0_T ) { + nvp.w2 =xive_set_field32 (NVP2_W2_T , nvp.w2, regs[TM_T ]); + }xive2_router_write_nvp (xrtr, nvp_blk, nvp_idx, &nvp,2 ); nvp.w1 =xive_set_field32 (NVP2_W1_CO , nvp.w1,0 );
@@ -527,7 +538,9 @@ static uint8_t xive2_tctx_restore_os_ctx(Xive2Router *xrtr, XiveTCTX *tctx,xive2_router_write_nvp (xrtr, nvp_blk, nvp_idx, nvp,2 ); tctx->regs[TM_QW1_OS +TM_CPPR ] = cppr; -/* we don't model LSMFB */ + tctx->regs[TM_QW1_OS +TM_LSMFB ] =xive_get_field32 (NVP2_W2_LSMFB , nvp->w2); + tctx->regs[TM_QW1_OS +TM_LGS ] =xive_get_field32 (NVP2_W2_LGS , nvp->w2); + tctx->regs[TM_QW1_OS +TM_T ] =xive_get_field32 (NVP2_W2_T , nvp->w2); nvp->w1 =xive_set_field32 (NVP2_W1_CO , nvp->w1,1 ); nvp->w1 =xive_set_field32 (NVP2_W1_CO_THRID_VALID , nvp->w1,1 );
include/hw/ppc/xive2_regs.h +7 -3
@@ -1,10 +1,9 @@/* * QEMU PowerPC XIVE2 internal structure definitions (POWER10) * -* Copyright (c) 2019-2022, IBM Corporation. +* Copyright (c) 2019-2024, IBM Corporation. * -* This code is licensed under the GPL version 2 or later. See the -* COPYING file in the top-level directory. +* SPDX-License-Identifier: GPL-2.0-or-later */ #ifndef PPC_XIVE2_REGS_H
@@ -152,6 +151,9 @@ typedef struct Xive2Nvp {uint32_t w0;#define NVP2_W0_VALID PPC_BIT32(0)#define NVP2_W0_HW PPC_BIT32(7) +#define NVP2_W0_L PPC_BIT32(8) +#define NVP2_W0_G PPC_BIT32(9) +#define NVP2_W0_T PPC_BIT32(10)#define NVP2_W0_ESC_END PPC_BIT32(25)/* 'N' bit 0:ESB 1:END */ #define NVP2_W0_PGOFIRST PPC_BITMASK32(26, 31)uint32_t w1;
@@ -163,6 +165,8 @@ typedef struct Xive2Nvp {#define NVP2_W2_CPPR PPC_BITMASK32(0, 7)#define NVP2_W2_IPB PPC_BITMASK32(8, 15)#define NVP2_W2_LSMFB PPC_BITMASK32(16, 23) +#define NVP2_W2_T PPC_BIT32(27) +#define NVP2_W2_LGS PPC_BITMASK32(28, 31)uint32_t w3;uint32_t w4;#define NVP2_W4_ESC_ESB_BLOCK PPC_BITMASK32(0, 3)/* N:0 */
Signature · 1 line
2.47.1
Nicholas Piggin
reviewer[PULL 61/72] ppc: spapr: Enable 2nd DAWR on Power10 pSeries machine
In reply to Nicholas PigginFrom: Shivaprasad G Bhat <[email protected]>
As per the PAPR, bit 0 of byte 64 in pa-features property indicates availability of 2nd DAWR registers. i.e. If this bit is set, 2nd DAWR is present, otherwise not. Use KVM_CAP_PPC_DAWR1 capability to find whether kvm supports 2nd DAWR or not. If it's supported, allow user to set the pa-feature bit in guest DT using cap-dawr1 machine capability.
Message-ID: <[email protected]>
--- hw/ppc/spapr.c | 7 ++++++- hw/ppc/spapr_caps.c | 43 ++++++++++++++++++++++++++++++++++++++++++ hw/ppc/spapr_hcall.c | 27 +++++++++++++++++--------- include/hw/ppc/spapr.h | 6 +++++- target/ppc/kvm.c | 12 ++++++++++++ target/ppc/kvm_ppc.h | 12 ++++++++++++ 6 files changed, 96 insertions(+), 11 deletions(-)
hw/ppc/spapr.c +6 -1
@@ -246,7 +246,7 @@ static void spapr_dt_pa_features(SpaprMachineState *spapr,0x80 ,0x00 ,0x80 ,0x00 ,0x80 ,0x00 ,/* 48 - 53 */ /* 54: DecFP, 56: DecI, 58: SHA */ 0x80 ,0x00 ,0x80 ,0x00 ,0x80 ,0x00 ,/* 54 - 59 */ -/* 60: NM atomic, 62: RNG */ +/* 60: NM atomic, 62: RNG, 64: DAWR1 (ISA 3.1) */ 0x80 ,0x00 ,0x80 ,0x00 ,0x00 ,0x00 ,/* 60 - 65 */ /* 68: DEXCR[SBHE|IBRTPDUS|SRAPD|NPHIE|PHIE] */ 0x00, 0x00, 0xce, 0x00, 0x00, 0x00, /* 66 - 71 */
@@ -295,6 +295,9 @@ static void spapr_dt_pa_features(SpaprMachineState *spapr,* in pa-features. So hide it from them. */ pa_features[40 +2 ] &= ~0x80 ;/* Radix MMU */ } +if (spapr_get_cap (spapr,SPAPR_CAP_DAWR1 )) { + pa_features[66 ] |=0x80 ; + }_FDT ((fdt_setprop (fdt, offset,"ibm,pa-features" , pa_features, pa_size))); }
@@ -2163,6 +2166,7 @@ static const VMStateDescription vmstate_spapr = { &vmstate_spapr_cap_rpt_invalidate, &vmstate_spapr_cap_ail_mode_3, &vmstate_spapr_cap_nested_papr, + &vmstate_spapr_cap_dawr1, NULL } };
@@ -4680,6 +4684,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) smc->default_caps.caps[SPAPR_CAP_CCF_ASSIST ] =SPAPR_CAP_ON ; smc->default_caps.caps[SPAPR_CAP_FWNMI ] =SPAPR_CAP_ON ; smc->default_caps.caps[SPAPR_CAP_RPT_INVALIDATE ] =SPAPR_CAP_OFF ; + smc->default_caps.caps[SPAPR_CAP_DAWR1 ] =SPAPR_CAP_ON ;/* * This cap specifies whether the AIL 3 mode for
hw/ppc/spapr_caps.c +43 -0
67 lines not on this page · raw message
hw/ppc/spapr_hcall.c +18 -9
@@ -822,11 +822,12 @@ static target_ulong h_set_mode_resource_set_ciabr(PowerPCCPU *cpu,return H_SUCCESS ; } -static target_ulong h_set_mode_resource_set_dawr0 (PowerPCCPU *cpu, -SpaprMachineState *spapr, -target_ulong mflags, -target_ulong value1, -target_ulong value2) +static target_ulong h_set_mode_resource_set_dawr (PowerPCCPU *cpu, +SpaprMachineState *spapr, +target_ulong mflags, +target_ulong resource, +target_ulong value1, +target_ulong value2) {CPUPPCState *env = &cpu->env;
@@ -839,8 +840,15 @@ static target_ulong h_set_mode_resource_set_dawr0(PowerPCCPU *cpu,return H_P4 ; } -ppc_store_dawr0 (env, value1); -ppc_store_dawrx0 (env, value2); +if (resource ==H_SET_MODE_RESOURCE_SET_DAWR0 ) { +ppc_store_dawr0 (env, value1); +ppc_store_dawrx0 (env, value2); + }else if (resource ==H_SET_MODE_RESOURCE_SET_DAWR1 ) { +ppc_store_dawr1 (env, value1); +ppc_store_dawrx1 (env, value2); + }else { +g_assert_not_reached (); + }return H_SUCCESS ; }
@@ -919,8 +927,9 @@ static target_ulong h_set_mode(PowerPCCPU *cpu, SpaprMachineState *spapr, args[3]);break ;case H_SET_MODE_RESOURCE_SET_DAWR0 : - ret =h_set_mode_resource_set_dawr0 (cpu, spapr, args[0 ], args[2 ], - args[3 ]); +case H_SET_MODE_RESOURCE_SET_DAWR1 : + ret =h_set_mode_resource_set_dawr (cpu, spapr, args[0 ], args[1 ], + args[2 ], args[3 ]);break ;case H_SET_MODE_RESOURCE_LE : ret =h_set_mode_resource_le (cpu, spapr, args[0 ], args[2 ], args[3 ]);
include/hw/ppc/spapr.h +5 -1
@@ -83,8 +83,10 @@ typedef enum {#define SPAPR_CAP_AIL_MODE_3 0x0C/* Nested PAPR */ #define SPAPR_CAP_NESTED_PAPR 0x0D +/* DAWR1 */ +#define SPAPR_CAP_DAWR1 0x0E/* Num Caps */ -#define SPAPR_CAP_NUM (SPAPR_CAP_NESTED_PAPR + 1) +#define SPAPR_CAP_NUM (SPAPR_CAP_DAWR1 + 1)/* * Capability Values
@@ -406,6 +408,7 @@ struct SpaprMachineState {#define H_SET_MODE_RESOURCE_SET_DAWR0 2#define H_SET_MODE_RESOURCE_ADDR_TRANS_MODE 3#define H_SET_MODE_RESOURCE_LE 4 +#define H_SET_MODE_RESOURCE_SET_DAWR1 5/* Flags for H_SET_MODE_RESOURCE_LE */ #define H_SET_MODE_ENDIAN_BIG 0
@@ -1003,6 +1006,7 @@ extern const VMStateDescription vmstate_spapr_cap_fwnmi;extern const VMStateDescription vmstate_spapr_cap_rpt_invalidate;extern const VMStateDescription vmstate_spapr_cap_ail_mode_3;extern const VMStateDescription vmstate_spapr_wdt; +extern const VMStateDescription vmstate_spapr_cap_dawr1;static inline uint8_t spapr_get_cap (SpaprMachineState *spapr,int cap) {
target/ppc/kvm.c +12 -0
@@ -92,6 +92,7 @@ static int cap_large_decr;static int cap_fwnmi;static int cap_rpt_invalidate;static int cap_ail_mode_3; +static int cap_dawr1;#ifdef CONFIG_PSERIES static int cap_papr;
@@ -152,6 +153,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s) cap_ppc_nested_kvm_hv =kvm_vm_check_extension (s,KVM_CAP_PPC_NESTED_HV ); cap_large_decr =kvmppc_get_dec_bits (); cap_fwnmi =kvm_vm_check_extension (s,KVM_CAP_PPC_FWNMI ); + cap_dawr1 =kvm_vm_check_extension (s,KVM_CAP_PPC_DAWR1 );/* * Note: setting it to false because there is not such capability * in KVM at this moment.
@@ -2114,6 +2116,16 @@ int kvmppc_set_fwnmi(PowerPCCPU *cpu)return kvm_vcpu_enable_cap (cs,KVM_CAP_PPC_FWNMI ,0 ); } +bool kvmppc_has_cap_dawr1 (void ) +{ +return !!cap_dawr1; +} + +int kvmppc_set_cap_dawr1 (int enable) +{ +return kvm_vm_enable_cap (kvm_state,KVM_CAP_PPC_DAWR1 ,0 , enable); +} +int kvmppc_smt_threads (void ) {return cap_ppc_smt ? cap_ppc_smt :1 ;
target/ppc/kvm_ppc.h +12 -0
@@ -68,6 +68,8 @@ bool kvmppc_has_cap_htm(void);bool kvmppc_has_cap_mmu_radix (void );bool kvmppc_has_cap_mmu_hash_v3 (void );bool kvmppc_has_cap_xive (void ); +bool kvmppc_has_cap_dawr1 (void ); +int kvmppc_set_cap_dawr1 (int enable);int kvmppc_get_cap_safe_cache (void );int kvmppc_get_cap_safe_bounds_check (void );int kvmppc_get_cap_safe_indirect_branch (void );
@@ -377,6 +379,16 @@ static inline bool kvmppc_has_cap_xive(void)return false; } +static inline bool kvmppc_has_cap_dawr1 (void ) +{ +return false; +} + +static inline int kvmppc_set_cap_dawr1 (int enable) +{ +abort (); +} +static inline int kvmppc_get_cap_safe_cache (void ) {return 0 ;
Signature · 1 line
2.47.1
Nicholas Piggin
reviewer[PULL 55/72] hw/ppc/spapr: Convert HPTE_VALID() macro as hpte_is_valid() method
In reply to Nicholas PigginFrom: Philippe Mathieu-Daudé <[email protected]>
Convert HPTE_VALID() macro as hpte_is_valid() method.
sPAPR data structures including the hash page table are big-endian regardless of current CPU endian mode, so use the big-endian LD/ST API to access the hash PTEs.
Message-ID: <[email protected]>
--- hw/ppc/spapr.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
hw/ppc/spapr.c +9 -5
@@ -1409,7 +1409,11 @@ static uint64_t *hpte_get_ptr(SpaprMachineState *s, unsigned index)return &table[2 * index]; } -#define HPTE_VALID (_hpte) (tswap64(*((uint64_t *)(_hpte))) & HPTE64_V_VALID) +static bool hpte_is_valid (SpaprMachineState *s,unsigned index) +{ +return ldq_be_p (hpte_get_ptr (s, index)) &HPTE64_V_VALID ; +} +#define HPTE_DIRTY (_hpte) (tswap64(*((uint64_t *)(_hpte))) & HPTE64_V_HPTE_DIRTY)#define CLEAN_HPTE (_hpte) ((*(uint64_t *)(_hpte)) &= tswap64(~HPTE64_V_HPTE_DIRTY))#define DIRTY_HPTE (_hpte) ((*(uint64_t *)(_hpte)) |= tswap64(HPTE64_V_HPTE_DIRTY))
@@ -2206,7 +2210,7 @@ static void htab_save_first_pass(QEMUFile *f, SpaprMachineState *spapr,/* Consume invalid HPTEs */ while ((index < htabslots) - && !HPTE_VALID (hpte_get_ptr (spapr, index))) { + && !hpte_is_valid (spapr, index)) {CLEAN_HPTE (hpte_get_ptr (spapr, index)); index++; }
@@ -2214,7 +2218,7 @@ static void htab_save_first_pass(QEMUFile *f, SpaprMachineState *spapr,/* Consume valid HPTEs */ chunkstart = index;while ((index < htabslots) && (index - chunkstart <USHRT_MAX ) - &&HPTE_VALID (hpte_get_ptr (spapr, index))) { + &&hpte_is_valid (spapr, index)) {CLEAN_HPTE (hpte_get_ptr (spapr, index)); index++; }
@@ -2264,7 +2268,7 @@ static int htab_save_later_pass(QEMUFile *f, SpaprMachineState *spapr,/* Consume valid dirty HPTEs */ while ((index < htabslots) && (index - chunkstart <USHRT_MAX ) &&HPTE_DIRTY (hpte_get_ptr (spapr, index)) - &&HPTE_VALID (hpte_get_ptr (spapr, index))) { + &&hpte_is_valid (spapr, index)) {CLEAN_HPTE (hpte_get_ptr (spapr, index)); index++; examined++;
@@ -2274,7 +2278,7 @@ static int htab_save_later_pass(QEMUFile *f, SpaprMachineState *spapr,/* Consume invalid dirty HPTEs */ while ((index < htabslots) && (index - invalidstart <USHRT_MAX ) &&HPTE_DIRTY (hpte_get_ptr (spapr, index)) - && !HPTE_VALID (hpte_get_ptr (spapr, index))) { + && !hpte_is_valid (spapr, index)) {CLEAN_HPTE (hpte_get_ptr (spapr, index)); index++; examined++;
Signature · 1 line
2.47.1
Nicholas Piggin
reviewer[PULL 46/72] target/ppc: Ensure powerpc_mcheck_checkstop() is only called under TCG
In reply to Nicholas PigginFrom: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
--- target/ppc/excp_helper.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
target/ppc/excp_helper.c +2 -4
@@ -19,6 +19,7 @@#include "qemu/osdep.h" #include "qemu/main-loop.h" #include "qemu/log.h" +#include "system/tcg.h" #include "system/system.h" #include "system/runstate.h" #include "cpu.h"
@@ -30,7 +31,6 @@#include "trace.h" #ifdef CONFIG_TCG -#include "system/tcg.h" #include "exec/helper-proto.h" #include "exec/cpu_ldst.h" #endif
@@ -443,13 +443,11 @@ void helper_attn(CPUPPCState *env)static void powerpc_mcheck_checkstop (CPUPPCState *env) {/* KVM guests always have MSR[ME] enabled */ -#ifdef CONFIG_TCG if (FIELD_EX64 (env->msr,MSR ,ME )) {return ; } - +assert (tcg_enabled ());powerpc_checkstop (env,"machine check with MSR[ME]=0" ); -#endif }static void powerpc_excp_40x (PowerPCCPU *cpu,int excp)
Signature · 1 line
2.47.1
Nicholas Piggin
reviewer[PULL 20/72] ppc/pnv: Move PNOR to offset 0 in the ISA FW space
In reply to Nicholas Pigginskiboot has a bug that does not handle ISA FW access correctly for IDSEL devices > 0, and the current PNOR default address and size puts 64MB in device 0 and 64MB in device 1, which causes skiboot to hit this bug and breaks PNOR accesses.
Move the PNOR address down to 0 for now, so a 256MB PNOR can be accessed via device 0.
--- include/hw/ppc/pnv_pnor.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
include/hw/ppc/pnv_pnor.h +4 -2
@@ -13,9 +13,11 @@#include "hw/sysbus.h" /* -* PNOR offset on the LPC FW address space +* PNOR offset on the LPC FW address space. For now this should be 0 because +* skiboot 7.1 has a bug where IDSEL > 0 (LPC FW address > 256MB) access is +* not performed correctly. */ -#define PNOR_SPI_OFFSET 0x0c000000UL +#define PNOR_SPI_OFFSET 0x00000000UL#define TYPE_PNV_PNOR "pnv-pnor"OBJECT_DECLARE_SIMPLE_TYPE (PnvPnor,PNV_PNOR )
Signature · 1 line
2.47.1
Nicholas Piggin
reviewer[PULL 56/72] hw/ppc/spapr: Convert HPTE_DIRTY() macro as hpte_is_dirty() method
In reply to Nicholas PigginFrom: Philippe Mathieu-Daudé <[email protected]>
Convert HPTE_DIRTY() macro as hpte_is_dirty() method.
sPAPR data structures including the hash page table are big-endian regardless of current CPU endian mode, so use the big-endian LD/ST API to access the hash PTEs.
Message-ID: <[email protected]>
--- hw/ppc/spapr.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
hw/ppc/spapr.c +8 -4
@@ -1414,7 +1414,11 @@ static bool hpte_is_valid(SpaprMachineState *s, unsigned index)return ldq_be_p (hpte_get_ptr (s, index)) &HPTE64_V_VALID ; } -#define HPTE_DIRTY (_hpte) (tswap64(*((uint64_t *)(_hpte))) & HPTE64_V_HPTE_DIRTY) +static bool hpte_is_dirty (SpaprMachineState *s,unsigned index) +{ +return ldq_be_p (hpte_get_ptr (s, index)) &HPTE64_V_HPTE_DIRTY ; +} +#define CLEAN_HPTE (_hpte) ((*(uint64_t *)(_hpte)) &= tswap64(~HPTE64_V_HPTE_DIRTY))#define DIRTY_HPTE (_hpte) ((*(uint64_t *)(_hpte)) |= tswap64(HPTE64_V_HPTE_DIRTY))
@@ -2259,7 +2263,7 @@ static int htab_save_later_pass(QEMUFile *f, SpaprMachineState *spapr,/* Consume non-dirty HPTEs */ while ((index < htabslots) - && !HPTE_DIRTY (hpte_get_ptr (spapr, index))) { + && !hpte_is_dirty (spapr, index)) { index++; examined++; }
@@ -2267,7 +2271,7 @@ static int htab_save_later_pass(QEMUFile *f, SpaprMachineState *spapr, chunkstart = index;/* Consume valid dirty HPTEs */ while ((index < htabslots) && (index - chunkstart <USHRT_MAX ) - &&HPTE_DIRTY (hpte_get_ptr (spapr, index)) + &&hpte_is_dirty (spapr, index) &&hpte_is_valid (spapr, index)) {CLEAN_HPTE (hpte_get_ptr (spapr, index)); index++;
@@ -2277,7 +2281,7 @@ static int htab_save_later_pass(QEMUFile *f, SpaprMachineState *spapr, invalidstart = index;/* Consume invalid dirty HPTEs */ while ((index < htabslots) && (index - invalidstart <USHRT_MAX ) - &&HPTE_DIRTY (hpte_get_ptr (spapr, index)) + &&hpte_is_dirty (spapr, index) && !hpte_is_valid (spapr, index)) {CLEAN_HPTE (hpte_get_ptr (spapr, index)); index++;
Signature · 1 line
2.47.1
Nicholas Piggin
reviewer[PULL 27/72] ppc/xive2: Add undelivered group interrupt to backlog
In reply to Nicholas PigginFrom: Frederic Barrat <[email protected]>
When a group interrupt cannot be delivered, we need to:
- increment the backlog counter for the group in the NVG table (if the END is configured to keep a backlog).
- start a broadcast operation to set the LSMFB field on matching CPUs which can't take the interrupt now because they're running at too high a priority.
[npiggin: squash in fixes from milesg]
[milesg: only load the NVP if the END is !ignore]
[milesg: always broadcast backlog, not only when there are precluded VPs]
--- hw/intc/pnv_xive2.c | 42 +++++++++++++ hw/intc/xive2.c | 136 ++++++++++++++++++++++++++++++++--------- hw/ppc/pnv.c | 22 ++++++- include/hw/ppc/xive.h | 5 ++ include/hw/ppc/xive2.h | 1 + 5 files changed, 175 insertions(+), 31 deletions(-)
hw/intc/pnv_xive2.c +42 -0
@@ -705,6 +705,47 @@ static uint32_t pnv_xive2_presenter_get_config(XivePresenter *xptr)return cfg; } +static int pnv_xive2_broadcast (XivePresenter *xptr, +uint8_t nvt_blk,uint32_t nvt_idx, +uint8_t priority) +{ +PnvXive2 *xive =PNV_XIVE2 (xptr); +PnvChip *chip = xive->chip; +int i, j; +bool gen1_tima_os = + xive->cq_regs[CQ_XIVE_CFG >>3 ] &CQ_XIVE_CFG_GEN1_TIMA_OS ; + +for (i =0 ; i < chip->nr_cores; i++) { +PnvCore *pc = chip->cores[i]; +CPUCore *cc =CPU_CORE (pc); + +for (j =0 ; j < cc->nr_threads; j++) { +PowerPCCPU *cpu = pc->threads[j]; +XiveTCTX *tctx; +int ring; + +if (!pnv_xive2_is_cpu_enabled (xive, cpu)) { +continue ; + } + + tctx =XIVE_TCTX (pnv_cpu_state (cpu)->intc); + +if (gen1_tima_os) { + ring =xive_presenter_tctx_match (xptr, tctx,0 , nvt_blk, + nvt_idx, true,0 ); + }else { + ring =xive2_presenter_tctx_match (xptr, tctx,0 , nvt_blk, + nvt_idx, true,0 ); + } + +if (ring !=-1 ) { +xive2_tm_set_lsmfb (tctx, ring, priority); + } + } + } +return 0 ; +} +static uint8_t pnv_xive2_get_block_id (Xive2Router *xrtr) {return pnv_xive2_block_id (PNV_XIVE2 (xrtr));
@@ -2444,6 +2485,7 @@ static void pnv_xive2_class_init(ObjectClass *klass, void *data) xpc->match_nvt = pnv_xive2_match_nvt; xpc->get_config = pnv_xive2_presenter_get_config; + xpc->broadcast = pnv_xive2_broadcast; };static const TypeInfo pnv_xive2_info = {
hw/intc/xive2.c +106 -30
180 lines not on this page · raw message
hw/ppc/pnv.c +21 -1
@@ -1,7 +1,9 @@/* * QEMU PowerPC PowerNV machine model * -* Copyright (c) 2016, IBM Corporation. +* Copyright (c) 2016-2024, IBM Corporation. +* +* SPDX-License-Identifier: GPL-2.0-or-later * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public
@@ -2662,6 +2664,23 @@ static int pnv10_xive_match_nvt(XiveFabric *xfb, uint8_t format,return total_count; } +static int pnv10_xive_broadcast (XiveFabric *xfb, +uint8_t nvt_blk,uint32_t nvt_idx, +uint8_t priority) +{ +PnvMachineState *pnv =PNV_MACHINE (xfb); +int i; + +for (i =0 ; i < pnv->num_chips; i++) { +Pnv10Chip *chip10 =PNV10_CHIP (pnv->chips[i]); +XivePresenter *xptr =XIVE_PRESENTER (&chip10->xive); +XivePresenterClass *xpc =XIVE_PRESENTER_GET_CLASS (xptr); + + xpc->broadcast (xptr, nvt_blk, nvt_idx, priority); + } +return 0 ; +} +static bool pnv_machine_get_big_core (Object *obj,Error **errp) {PnvMachineState *pnv =PNV_MACHINE (obj);
@@ -2795,6 +2814,7 @@ static void pnv_machine_p10_common_class_init(ObjectClass *oc, void *data) pmc->dt_power_mgt = pnv_dt_power_mgt; xfc->match_nvt = pnv10_xive_match_nvt; + xfc->broadcast = pnv10_xive_broadcast;machine_class_allow_dynamic_sysbus_dev (mc,TYPE_PNV_PHB ); }
include/hw/ppc/xive.h +5 -0
@@ -442,6 +442,9 @@ struct XivePresenterClass { uint32_t logic_serv, XiveTCTXMatch *match);bool (*in_kernel)(const XivePresenter *xptr);uint32_t (*get_config)(XivePresenter *xptr); +int (*broadcast)(XivePresenter *xptr, +uint8_t nvt_blk,uint32_t nvt_idx, +uint8_t priority); }; int xive_presenter_tctx_match(XivePresenter *xptr, XiveTCTX *tctx,
@@ -472,6 +475,8 @@ struct XiveFabricClass { uint8_t nvt_blk, uint32_t nvt_idx, bool cam_ignore, uint8_t priority, uint32_t logic_serv, XiveTCTXMatch *match); +int (*broadcast)(XiveFabric *xfb,uint8_t nvt_blk,uint32_t nvt_idx, +uint8_t priority); };/*
include/hw/ppc/xive2.h +1 -0
@@ -120,6 +120,7 @@ uint64_t xive2_tm_pull_os_ctx(XivePresenter *xptr, XiveTCTX *tctx,void xive2_tm_pull_os_ctx_ol (XivePresenter *xptr,XiveTCTX *tctx,hwaddr offset,uint64_t value,unsigned size);bool xive2_tm_irq_precluded (XiveTCTX *tctx,int ring,uint8_t priority); +void xive2_tm_set_lsmfb (XiveTCTX *tctx,int ring,uint8_t priority);void xive2_tm_set_hv_target (XivePresenter *xptr,XiveTCTX *tctx,hwaddr offset,uint64_t value,unsigned size); void xive2_tm_pull_phys_ctx_ol(XivePresenter *xptr, XiveTCTX *tctx,
Signature · 1 line
2.47.1
Quoted 13 lines · Nicholas Piggin
The following changes since commit
825b96dbcee23d134b691fc75618b59c5f53da32:Merge tag 'migration-20250310-pull-request' of https://gitlab.com/farosas/qemu into staging (2025-03-11 09:32:07 +0800)
are available in the Git repository at:
https://gitlab.com/npiggin/qemu.git tags/pull-ppc-for-10.0-1-20250311
for you to fetch changes up to
0f17ae24b53eaab4bbe9cfab267c536e2f7fdbd7:
docs/system/ppc/amigang.rst: Update for NVRAM emulation (2025-03-11 22:43:32 +1000)
Quoted 11 lines
----------------------------------------------------------------
* amigaone enhancements, NVRAM and kernel/initrd support
* Next round of XIVE group/crowd changes
* SPI updates for powernv
* Power10 2nd DAWR support for powernv and spapr
* powernv HOMER/OCC fixes and improvements for power management
* powernv PNOR support
* Big cleanup to move TCG code under ifdef or into its own file
* Update SLOF and skiboot ROMs
* Remove 405 boards and deprecate 405 CPU
* Add support for nested KVM "hostwide state" data.
I fixed a CI failure on FreeBSD 14 hosts because of the __packed macro redefinition in hw/ppc/pnv_occ.c:
https://gitlab.com/qemu-project/qemu/-/jobs/9388495246#L5857
Here is my fix in the merge commit, if you prefer a different fix, please send a follow-up commit:
hw/ppc/pnv_occ.c +2 -0
@@ -394,7 +394,9 @@ type_init(pnv_occ_register_types);#define s64 int64_t#define __be16 uint16_t#define __be32 uint32_t +#ifndef __packed#define __packed QEMU_PACKED +#endif /* !__packed */ /** * OCC-OPAL Shared Memory Region
Stefan
Quoted 183 lines
----------------------------------------------------------------
Alexey Kardashevskiy (1):
pseries: Update SLOF firmware imageBALATON Zoltan (6):
ppc/amigaone: Simplify replacementdummy_fwppc/amigaone: Implement NVRAM emulation ppc/amigaone: Add default environment ppc/amigaone: Add kernel and initrd support ppc/amigaone: Add #defines for memory map constantsdocs/system/ppc/amigang.rst: Update for NVRAM emulationChalapathi V (4):
hw/ssi/pnv_spi: Replace PnvXferBuffer with Fifo8 structure hw/ssi/pnv_spi: Use local varseq_indexinstead ofget_seq_index(). hw/ssi/pnv_spi: Make bus names distinct for each controllers of a socket hw/ssi/pnv_spi: Put a limit to RDR match failuresCédric Le Goater (3):
ppc/ppc405: Remove tests
ppc/ppc405: Remove boards
hw/ppc: Deprecate 405 CPUsFrederic Barrat (10):
ppc/xive2: Update NVP save/restore for group attributes ppc/xive2: Add grouping level to notification ppc/xive2: Support group-matching when looking for target ppc/xive2: Add undelivered group interrupt to backlog ppc/xive2: Process group backlog when pushing an OS context ppc/xive2: Process group backlog when updating the CPPR qtest/xive: Add group-interrupt test
ppc/xive2: Add support for MMIO operations on the NVPG/NVC BAR ppc/xive2: Support crowd-matching when looking for target ppc/xive2: Check crowd backlog when scanning group backlogGlenn Miles (3):
pnv/xive2: Renamenvp_tonvx_if they can refer to NVP or NVGC qtest/xive: Change printf tog_test_messageqtest/xive: Add test of pool interruptsMichael Kowal (1):
ppc/xive: Renameipb_to_pipr()toxive_ipb_to_pipr()Nicholas Piggin (22):
ppc/pnv: Update skiboot to 7.1-106
ppc/pnv/phb4: Add pervasive chiplet support to PHB4/5 ppc/pnv/homer: Fix OCC registers
ppc/pnv/homer: Make dummy reads return 0
ppc/pnv/occ: Fix common area sensor offsets ppc/pnv/homer: class-based base and size
ppc/pnv/occ: Better document OCCMISC bits
ppc/pnv: Make HOMER memory a RAM region
ppc/pnv/occ: Update pstate frequency tables ppc/pnv/occ: Add POWER10 OCC-OPAL data format ppc/pnv/occ: Implement a basic dynamic OCC model target/ppc: Add Power9/10 power management SPRs ppc/pnv: Support LPC host controller irqs other than serirqs ppc/pnv: raise no-response errors if an LPC transaction fails ppc/pnv: Implement LPC FW address space IDSEL ppc/pnv: Move PNOR to offset 0 in the ISA FW space ppc/pnv: Add a PNOR address and size sanity checks ppc/pnv: Add a default formatted PNOR image target/ppc: fix timebase register reset state target/ppc: Wire up BookE ATB registers for e500 family target/ppc: Avoid warning message for zero process table entries
spapr: Generate random HASHPKEYR for spapr machinesPhilippe Mathieu-Daudé (18):
hw/ppc/spapr: Restrict CONFER hypercall to TCG
target/ppc: Makeppc_ldl_code()declaration public target/ppc: Move TCG specific exception handlers totcg-excp_helper.ctarget/ppc: Moveppc_ldl_code()totcg-excp_helper.ctarget/ppc: Ensurepowerpc_mcheck_checkstop()is only called under TCG target/ppc: Restrictpowerpc_checkstop()to TCG target/ppc: Removeraise_exception_ra()
target/ppc: Restrict exception helpers to TCG
target/ppc: Restrict various common helpers to TCG target/ppc: Fix style inexcp_helper.c
target/ppc: Makepowerpc_excp()prototype public target/ppc: Restrict ATTN / SCV / PMINSN helpers to TCG hw/ppc/spapr: ConvertHPTE()macro ashpte_get_ptr()method hw/ppc/spapr: ConvertHPTE_VALID()macro ashpte_is_valid()method hw/ppc/spapr: ConvertHPTE_DIRTY()macro ashpte_is_dirty()method hw/ppc/spapr: ConvertCLEAN_HPTE()macro ashpte_set_clean()method hw/ppc/spapr: ConvertDIRTY_HPTE()macro ashpte_set_dirty()method hw/ppc/epapr: Do not swap ePAPR magic valueShivaprasad G Bhat (2):
ppc: Enable 2nd DAWR support on Power10 PowerNV machine
ppc: spapr: Enable 2nd DAWR on Power10 pSeries machineVaibhav Jain (1):
spapr: nested: Add support for reporting Hostwide state counterdan tan (1):
ppc/pnv: Add new PowerPC Special Purpose Registers (RWMR)MAINTAINERS | 7 +- docs/about/deprecated.rst | 17 +- docs/about/removed-features.rst | 7 + docs/system/ppc/amigang.rst | 17 +- docs/system/ppc/embedded.rst | 1 - docs/system/ppc/powernv.rst | 7 + hw/intc/pnv_xive.c | 10 +- hw/intc/pnv_xive2.c | 166 ++++- hw/intc/spapr_xive.c | 8 +- hw/intc/trace-events | 6 +- hw/intc/xive.c | 205 +++--- hw/intc/xive2.c | 690 +++++++++++++++++--- hw/pci-host/pnv_phb4_pec.c | 55 +- hw/ppc/Kconfig | 9 - hw/ppc/amigaone.c | 284 ++++++++- hw/ppc/meson.build | 3 - hw/ppc/pnv.c | 150 +++-- hw/ppc/pnv_bmc.c | 28 + hw/ppc/pnv_homer.c | 230 ++----- hw/ppc/pnv_lpc.c | 89 +-- hw/ppc/pnv_occ.c | 670 +++++++++++++++++++- hw/ppc/ppc.c | 11 +- hw/ppc/ppc405.h | 186 ------ hw/ppc/ppc405_boards.c | 520 --------------- hw/ppc/ppc405_uc.c | 1216 ------------------------------------ hw/ppc/sam460ex.c | 2 +- hw/ppc/spapr.c | 80 ++- hw/ppc/spapr_caps.c | 43 ++ hw/ppc/spapr_cpu_core.c | 2 + hw/ppc/spapr_hcall.c | 29 +- hw/ppc/spapr_nested.c | 119 +++- hw/ppc/virtex_ml507.c | 2 +- hw/ssi/pnv_spi.c | 366 +++++------ include/hw/pci-host/pnv_phb4.h | 5 + include/hw/ppc/pnv.h | 6 +- include/hw/ppc/pnv_homer.h | 12 +- include/hw/ppc/pnv_occ.h | 9 + include/hw/ppc/pnv_pnor.h | 6 +- include/hw/ppc/pnv_xscom.h | 4 + include/hw/ppc/spapr.h | 7 +- include/hw/ppc/spapr_nested.h | 67 +- include/hw/ppc/xive.h | 41 +- include/hw/ppc/xive2.h | 24 +- include/hw/ppc/xive2_regs.h | 17 +- include/hw/ppc/xive_regs.h | 25 +- include/hw/ssi/pnv_spi.h | 7 +- pc-bios/README | 17 +- pc-bios/meson.build | 1 + pc-bios/pnv-pnor.bin | Bin 0 -> 139264 bytes pc-bios/skiboot.lid | Bin 2527328 -> 2592960 bytes pc-bios/slof.bin | Bin 995000 -> 996184 bytes roms/skiboot | 2 +- target/ppc/cpu.c | 45 +- target/ppc/cpu.h | 14 +- target/ppc/cpu_init.c | 48 ++ target/ppc/excp_helper.c | 842 +------------------------ target/ppc/helper.h | 4 + target/ppc/internal.h | 8 +- target/ppc/kvm.c | 12 + target/ppc/kvm_ppc.h | 12 + target/ppc/machine.c | 3 +- target/ppc/meson.build | 1 + target/ppc/misc_helper.c | 63 ++ target/ppc/mmu-radix64.c | 14 + target/ppc/spr_common.h | 4 + target/ppc/tcg-excp_helper.c | 851 +++++++++++++++++++++++++ target/ppc/translate.c | 28 + tests/functional/meson.build | 1 - tests/functional/test_ppc_405.py | 37 -- tests/qtest/m48t59-test.c | 5 - tests/qtest/meson.build | 4 +- tests/qtest/pnv-spi-seeprom-test.c | 2 +- tests/qtest/pnv-xive2-common.h | 1 + tests/qtest/pnv-xive2-flush-sync.c | 6 +- tests/qtest/pnv-xive2-nvpg_bar.c | 152 +++++ tests/qtest/pnv-xive2-test.c | 249 +++++++- 76 files changed, 4201 insertions(+), 3690 deletions(-) delete mode 100644 hw/ppc/ppc405.h delete mode 100644 hw/ppc/ppc405_boards.c delete mode 100644 hw/ppc/ppc405_uc.c create mode 100644 pc-bios/pnv-pnor.bin create mode 100644 target/ppc/tcg-excp_helper.c delete mode 100755 tests/functional/test_ppc_405.py create mode 100644 tests/qtest/pnv-xive2-nvpg_bar.c
Quoted 37 lines · Stefan Hajnoczi
Quoted 13 lines · Nicholas Piggin
The following changes since commit
825b96dbcee23d134b691fc75618b59c5f53da32:Merge tag 'migration-20250310-pull-request' of https://gitlab.com/farosas/qemu into staging (2025-03-11 09:32:07 +0800)are available in the Git repository at:
https://gitlab.com/npiggin/qemu.git tags/pull-ppc-for-10.0-1-20250311for you to fetch changes up to
0f17ae24b53eaab4bbe9cfab267c536e2f7fdbd7:docs/system/ppc/amigang.rst: Update for NVRAM emulation (2025-03-11 22:43:32 +1000)Quoted 11 lines
----------------------------------------------------------------
* amigaone enhancements, NVRAM and kernel/initrd support
* Next round of XIVE group/crowd changes
* SPI updates for powernv
* Power10 2nd DAWR support for powernv and spapr
* powernv HOMER/OCC fixes and improvements for power management
* powernv PNOR support
* Big cleanup to move TCG code under ifdef or into its own file
* Update SLOF and skiboot ROMs
* Remove 405 boards and deprecate 405 CPU
* Add support for nested KVM "hostwide state" data.I fixed a CI failure on FreeBSD 14 hosts because of the
__packedmacro redefinition inhw/ppc/pnv_occ.c:
https://gitlab.com/qemu-project/qemu/-/jobs/9388495246#L5857Here is my fix in the merge commit, if you prefer a different fix, please send a follow-up commit:
hw/ppc/pnv_occ.c +0
-0
hw/ppc/pnv_occ.c type_init(pnv_occ_register_types); · line 399
Quoted 6 lines
hw/ppc/pnv_occ.c +2
-0@@ -394,7 +394,9 @@ type_init(pnv_occ_register_types);#define s64 int64_t#define __be16 uint16_t#define __be32 uint32_t +#ifndef __packed#define __packed QEMU_PACKED +#endif /* !__packed */
We should never define such macros in userspace - everything with two underscores at the beginning is reserved for the system and the compiler and must not be created by the userspace code. Why doesn't this code use QEMU_PACKED directly instead?
Thomas
Quoted 31 lines · Thomas Huth
Quoted 30 lines · Stefan Hajnoczi
Quoted 13 lines · Nicholas Piggin
The following changes since commit
825b96dbcee23d134b691fc75618b59c5f53da32:Merge tag 'migration-20250310-pull-request' of https://gitlab.com/ farosas/qemu into staging (2025-03-11 09:32:07 +0800)
are available in the Git repository at:
https://gitlab.com/npiggin/qemu.git tags/pull-ppc-for-10.0-1-20250311
for you to fetch changes up to
0f17ae24b53eaab4bbe9cfab267c536e2f7fdbd7:
docs/system/ppc/amigang.rst: Update for NVRAM emulation (2025-03-11 22:43:32 +1000)Quoted 11 lines
----------------------------------------------------------------
* amigaone enhancements, NVRAM and kernel/initrd support
* Next round of XIVE group/crowd changes
* SPI updates for powernv
* Power10 2nd DAWR support for powernv and spapr
* powernv HOMER/OCC fixes and improvements for power management
* powernv PNOR support
* Big cleanup to move TCG code under ifdef or into its own file
* Update SLOF and skiboot ROMs
* Remove 405 boards and deprecate 405 CPU
* Add support for nested KVM "hostwide state" data.I fixed a CI failure on FreeBSD 14 hosts because of the
__packedmacro redefinition inhw/ppc/pnv_occ.c:
https://gitlab.com/qemu-project/qemu/-/jobs/9388495246#L5857
Quoted 16 lines
hw/ppc/pnv_occ.c type_init(pnv_occ_register_types); · line 399
Quoted 13 lines
Here is my fix in the merge commit, if you prefer a different fix, please send a follow-up commit:
hw/ppc/pnv_occ.c +2
-0@@ -394,7 +394,9 @@ type_init(pnv_occ_register_types); #define s64 int64_t #define __be16 uint16_t #define __be32 uint32_t +#ifndef __packed #define __packed QEMU_PACKED +#endif /* !__packed */ We should never define such macros in userspace - everything with two underscores at the beginning is reserved for the system and the compiler and must not be created by the userspace code. Why doesn't this code use
QEMU_PACKEDdirectly instead?
Similar question with __be16 / __be32.
Nicholas Piggin
reviewerQuoted 55 lines · Philippe Mathieu-Daudé
Quoted 45 lines · Thomas Huth
Quoted 44 lines · Stefan Hajnoczi
Quoted 16 lines · Nicholas Piggin
The following changes since commit
825b96dbcee23d134b691fc75618b59c5f53da32:Merge tag 'migration-20250310-pull-request' of https://gitlab.com/
farosas/qemu into staging (2025-03-11 09:32:07 +0800)are available in the Git repository at:
https://gitlab.com/npiggin/qemu.git tags/pull-ppc-for-10.0-1-20250311
for you to fetch changes up to
0f17ae24b53eaab4bbe9cfab267c536e2f7fdbd7:
docs/system/ppc/amigang.rst: Update for NVRAM emulation (2025-03-11 22:43:32 +1000)Quoted 11 lines
----------------------------------------------------------------
* amigaone enhancements, NVRAM and kernel/initrd support
* Next round of XIVE group/crowd changes
* SPI updates for powernv
* Power10 2nd DAWR support for powernv and spapr
* powernv HOMER/OCC fixes and improvements for power management
* powernv PNOR support
* Big cleanup to move TCG code under ifdef or into its own file
* Update SLOF and skiboot ROMs
* Remove 405 boards and deprecate 405 CPU
* Add support for nested KVM "hostwide state" data.I fixed a CI failure on FreeBSD 14 hosts because of the
__packedmacro redefinition inhw/ppc/pnv_occ.c:
https://gitlab.com/qemu-project/qemu/-/jobs/9388495246#L5857Here is my fix in the merge commit, if you prefer a different fix, please send a follow-up commit:
hw/ppc/pnv_occ.c +0
-0@@ -394,7 +394,9 @@ type_init(pnv_occ_register_types); #define s64 int64_t #define __be16 uint16_t #define __be32 uint32_tQuoted 8 lines
hw/ppc/pnv_occ.c type_init(pnv_occ_register_types); · line 399
Quoted 3 lines
hw/ppc/pnv_occ.c +2
-0+#ifndef __packed #define __packed QEMU_PACKED +#endif /* !__packed */ We should never define such macros in userspace - everything with two underscores at the beginning is reserved for the system and the compiler and must not be created by the userspace code.
Why doesn't this code useQEMU_PACKEDdirectly instead?
Quoted 1 line
Similar question with
__be16/__be32.
Okay these were just because the type definition is taken from skiboot firmware, so I added those defs just in the .c file to make it a bit less change. It's not too much to change if that is preferred.
Thanks,
Nick
Quoted 56 lines · Nicholas Piggin
Quoted 55 lines · Philippe Mathieu-Daudé
Quoted 53 lines · Thomas Huth
Quoted 41 lines · Stefan Hajnoczi
Quoted 16 lines · Nicholas Piggin
The following changes since commit
825b96dbcee23d134b691fc75618b59c5f53da32:Merge tag 'migration-20250310-pull-request' of https://gitlab.com/
farosas/qemu into staging (2025-03-11 09:32:07 +0800)are available in the Git repository at:
https://gitlab.com/npiggin/qemu.git tags/pull-ppc-for-10.0-1-20250311
for you to fetch changes up to
0f17ae24b53eaab4bbe9cfab267c536e2f7fdbd7:
docs/system/ppc/amigang.rst: Update for NVRAM emulation
(2025-03-11 22:43:32 +1000)Quoted 11 lines
----------------------------------------------------------------
* amigaone enhancements, NVRAM and kernel/initrd support
* Next round of XIVE group/crowd changes
* SPI updates for powernv
* Power10 2nd DAWR support for powernv and spapr
* powernv HOMER/OCC fixes and improvements for power management
* powernv PNOR support
* Big cleanup to move TCG code under ifdef or into its own file
* Update SLOF and skiboot ROMs
* Remove 405 boards and deprecate 405 CPU
* Add support for nested KVM "hostwide state" data.I fixed a CI failure on FreeBSD 14 hosts because of the
__packedmacro redefinition inhw/ppc/pnv_occ.c:
https://gitlab.com/qemu-project/qemu/-/jobs/9388495246#L5857Here is my fix in the merge commit, if you prefer a different fix, please send a follow-up commit:
hw/ppc/pnv_occ.c +0
-0hw/ppc/pnv_occ.c type_init(pnv_occ_register_types); · line 399
Quoted 6 lines
hw/ppc/pnv_occ.c +2
-0@@ -394,7 +394,9 @@ type_init(pnv_occ_register_types); #define s64 int64_t #define __be16 uint16_t #define __be32 uint32_t +#ifndef __packed #define __packed QEMU_PACKED +#endif /* !__packed */ We should never define such macros in userspace - everything with two underscores at the beginning is reserved for the system and the compiler and must not be created by the userspace code.
Why doesn't this code useQEMU_PACKEDdirectly instead?
Quoted 6 lines
Quoted 1 line
Similar question with
__be16/__be32.Okay these were just because the type definition is taken from skiboot firmware, so I added those defs just in the .c file to make it a bit less change. It's not too much to change if that is preferred.
Yes, I think that would be more solid. Otherwise, there is theoretically a chance that a system header defines __packed to something different (e.g. "#define __packed __attribute__((ms_struct, packed))"), and then we might run into problems here.
Thomas
Nicholas Piggin
reviewerQuoted 55 lines · Philippe Mathieu-Daudé
Quoted 45 lines · Thomas Huth
Quoted 44 lines · Stefan Hajnoczi
Quoted 16 lines · Nicholas Piggin
The following changes since commit
825b96dbcee23d134b691fc75618b59c5f53da32:Merge tag 'migration-20250310-pull-request' of https://gitlab.com/
farosas/qemu into staging (2025-03-11 09:32:07 +0800)are available in the Git repository at:
https://gitlab.com/npiggin/qemu.git tags/pull-ppc-for-10.0-1-20250311
for you to fetch changes up to
0f17ae24b53eaab4bbe9cfab267c536e2f7fdbd7:
docs/system/ppc/amigang.rst: Update for NVRAM emulation (2025-03-11 22:43:32 +1000)Quoted 11 lines
----------------------------------------------------------------
* amigaone enhancements, NVRAM and kernel/initrd support
* Next round of XIVE group/crowd changes
* SPI updates for powernv
* Power10 2nd DAWR support for powernv and spapr
* powernv HOMER/OCC fixes and improvements for power management
* powernv PNOR support
* Big cleanup to move TCG code under ifdef or into its own file
* Update SLOF and skiboot ROMs
* Remove 405 boards and deprecate 405 CPU
* Add support for nested KVM "hostwide state" data.I fixed a CI failure on FreeBSD 14 hosts because of the
__packedmacro redefinition inhw/ppc/pnv_occ.c:
https://gitlab.com/qemu-project/qemu/-/jobs/9388495246#L5857Here is my fix in the merge commit, if you prefer a different fix, please send a follow-up commit:
hw/ppc/pnv_occ.c +0
-0@@ -394,7 +394,9 @@ type_init(pnv_occ_register_types); #define s64 int64_t #define __be16 uint16_t #define __be32 uint32_tQuoted 8 lines
hw/ppc/pnv_occ.c type_init(pnv_occ_register_types); · line 399
Quoted 3 lines
hw/ppc/pnv_occ.c +2
-0+#ifndef __packed #define __packed QEMU_PACKED +#endif /* !__packed */ We should never define such macros in userspace - everything with two underscores at the beginning is reserved for the system and the compiler and must not be created by the userspace code.
Why doesn't this code useQEMU_PACKEDdirectly instead?
Quoted 1 line
Similar question with
__be16/__be32.
Okay these were just because the type definition is taken from skiboot firmware, so I added those defs just in the .c file to make it a bit less change. It's not too much to change if that is preferred.
Thanks,
Nick
Stefan Hajnoczi
AppliedApplied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/10.0 for any user-visible changes.