ppc-for-6.1 queue 20210709
The following changes since commit 9db3065c62a983286d06c207f4981408cf42184d:
Merge remote-tracking branch 'remotes/vivier2/tags/linux-user-for-6.1-pull-request' into staging (2021-07-08 16:30:18 +0100)
are available in the Git repository at:
https://gitlab.com/dgibson/qemu.git tags/ppc-for-6.1-20210709
for you to fetch changes up to 82123b756a1a2f1965350e5794aaa7b5c6a15282:
target/ppc: Support for H_RPT_INVALIDATE hcall (2021-07-09 11:01:06 +1000)
----------------------------------------------------------------
ppc patch queue 2021-07-09
Here's a (probably) final pull request before the qemu-6.1 soft freeze. Includes:
* Implementation of the new H_RPT_INVALIDATE hypercall
* Virtual Open Firmware for pSeries and pegasos2 machine types. This is an experimental minimal Open Firmware implementation which works by delegating nearly everything to qemu itself via a special hypercall.
* A number of cleanups to the ppc soft MMU code
* Fix to handling of two-level radix mode translations for the powernv machine type
* Update the H_GET_CPU_CHARACTERISTICS call with newly defined bits. This will allow more flexible handling of possible future CPU Spectre-like flaws
* Correctly treat mtmsrd as an illegal instruction on BookE cpus
* Firmware update for the ppce500 machine type
----------------------------------------------------------------
Alexey Kardashevskiy (3):
spapr: tune rtas-size
spapr: Implement Open Firmware client interface
spapr: Fix implementation of Open Firmware client interface
BALATON Zoltan (4):
ppc/pegasos2: Introduce Pegasos2MachineState structure target/ppc: Allow virtual hypervisor on CPU without HV ppc/pegasos2: Use Virtual Open Firmware as firmware replacement ppc/pegasos2: Implement some RTAS functions with VOF
Bharata B Rao (2):
linux-headers: Update
target/ppc: Support for H_RPT_INVALIDATE hcall
Bin Meng (2):
roms/u-boot: Bump ppce500 u-boot to v2021.07 to add eTSEC support docs/system: ppc: Update ppce500 documentation with eTSEC support
Bruno Larsen (billionai) (4):
target/ppc: fix address translation bug for radix mmus target/ppc: changed ppc_hash64_xlate to use mmu_idx target/ppc: introduce mmu-books.h target/ppc: change ppc_hash32_xlate to use mmu_idx
David Gibson (1):
ppc/pegasos2: Fix use of && instead of &
Fabiano Rosas (3):
target/ppc: Fix compilation with DUMP_PAGE_TABLES debug option target/ppc: Fix compilation with FLUSH_ALL_TLBS debug option target/ppc: Fix compilation with DEBUG_BATS debug option
Greg Kurz (2):
target/ppc: Introduce ppc_interrupts_little_endian() target/ppc: Drop PowerPCCPUClass::interrupts_big_endian()
Lucas Mateus Castro (alqotel) (1):
target/ppc: Don't compile ppc_tlb_invalid_all without TCG
Nicholas Piggin (2):
target/ppc: mtmsrd is an illegal instruction on BookE target/ppc/spapr: Update H_GET_CPU_CHARACTERISTICS L1D cache flush bits
Richard Henderson (9):
target/ppc: Remove PowerPCCPUClass.handle_mmu_fault target/ppc: Use MMUAccessType with *_handle_mmu_fault target/ppc: Push real-mode handling into ppc_radix64_xlate target/ppc: Use bool success for ppc_radix64_xlate target/ppc: Split out ppc_hash64_xlate target/ppc: Split out ppc_hash32_xlate target/ppc: Split out ppc_jumbo_xlate target/ppc: Introduce ppc_xlate
target/ppc: Restrict ppc_cpu_tlb_fill to TCG
MAINTAINERS | 12 + default-configs/devices/ppc-softmmu.mak | 2 +- docs/system/ppc/ppce500.rst | 10 +- hw/ppc/Kconfig | 5 + hw/ppc/meson.build | 3 + hw/ppc/pegasos2.c | 789 ++++++++++++++- hw/ppc/spapr.c | 77 +- hw/ppc/spapr_caps.c | 41 + hw/ppc/spapr_hcall.c | 24 +- hw/ppc/spapr_vof.c | 167 ++++ hw/ppc/trace-events | 24 + hw/ppc/vof.c | 1053 ++++++++++++++++++++ include/hw/ppc/spapr.h | 31 +- include/hw/ppc/vof.h | 58 ++ include/standard-headers/asm-x86/kvm_para.h | 13 + include/standard-headers/drm/drm_fourcc.h | 7 + include/standard-headers/linux/ethtool.h | 4 +- include/standard-headers/linux/input-event-codes.h | 1 + include/standard-headers/linux/virtio_ids.h | 2 +- include/standard-headers/linux/virtio_vsock.h | 9 + linux-headers/asm-arm64/kvm.h | 11 + linux-headers/asm-generic/mman-common.h | 3 + linux-headers/asm-generic/unistd.h | 4 +- linux-headers/asm-mips/mman.h | 3 + linux-headers/asm-mips/unistd_n32.h | 1 + linux-headers/asm-mips/unistd_n64.h | 1 + linux-headers/asm-mips/unistd_o32.h | 1 + linux-headers/asm-powerpc/unistd_32.h | 1 + linux-headers/asm-powerpc/unistd_64.h | 1 + linux-headers/asm-s390/unistd_32.h | 1 + linux-headers/asm-s390/unistd_64.h | 1 + linux-headers/asm-x86/kvm.h | 13 + linux-headers/asm-x86/unistd_32.h | 7 +- linux-headers/asm-x86/unistd_64.h | 7 +- linux-headers/asm-x86/unistd_x32.h | 7 +- linux-headers/linux/kvm.h | 105 ++ linux-headers/linux/userfaultfd.h | 11 +- pc-bios/README | 4 + pc-bios/u-boot.e500 | Bin 406920 -> 421720 bytes pc-bios/vof-nvram.bin | Bin 0 -> 16384 bytes pc-bios/vof.bin | Bin 0 -> 3456 bytes pc-bios/vof/Makefile | 23 + pc-bios/vof/bootmem.c | 14 + pc-bios/vof/ci.c | 91 ++ pc-bios/vof/entry.S | 49 + pc-bios/vof/libc.c | 66 ++ pc-bios/vof/main.c | 21 + pc-bios/vof/vof.h | 41 + pc-bios/vof/vof.lds | 48 + roms/u-boot | 2 +- target/ppc/arch_dump.c | 8 +- target/ppc/cpu-qom.h | 2 - target/ppc/cpu.c | 2 +- target/ppc/cpu.h | 15 + target/ppc/cpu_init.c | 64 +- target/ppc/excp_helper.c | 3 +- target/ppc/kvm.c | 12 + target/ppc/kvm_ppc.h | 12 + target/ppc/mmu-book3s-v3.c | 19 - target/ppc/mmu-book3s-v3.h | 6 +- target/ppc/mmu-books.h | 30 + target/ppc/mmu-hash32.c | 254 +++-- target/ppc/mmu-hash32.h | 8 +- target/ppc/mmu-hash64.c | 157 ++- target/ppc/mmu-hash64.h | 6 +- target/ppc/mmu-radix64.c | 151 ++- target/ppc/mmu-radix64.h | 6 +- target/ppc/mmu_helper.c | 215 ++-- target/ppc/translate.c | 5 + tests/qtest/rtas-test.c | 15 +- 70 files changed, 3256 insertions(+), 603 deletions(-) create mode 100644 hw/ppc/spapr_vof.c create mode 100644 hw/ppc/vof.c create mode 100644 include/hw/ppc/vof.h create mode 100644 pc-bios/vof-nvram.bin create mode 100755 pc-bios/vof.bin create mode 100644 pc-bios/vof/Makefile create mode 100644 pc-bios/vof/bootmem.c create mode 100644 pc-bios/vof/ci.c create mode 100644 pc-bios/vof/entry.S create mode 100644 pc-bios/vof/libc.c create mode 100644 pc-bios/vof/main.c create mode 100644 pc-bios/vof/vof.h create mode 100644 pc-bios/vof/vof.lds create mode 100644 target/ppc/mmu-books.h
[PULL 01/33] target/ppc: Introduce ppc_interrupts_little_endian()
From: Greg Kurz <[email protected]>
PowerPC CPUs use big endian by default but starting with POWER7, server grade CPUs use the ILE bit of the LPCR special purpose register to decide on the endianness to use when handling interrupts. This gives a clue to QEMU on the endianness the guest kernel is running, which is needed when generating an ELF dump of the guest or when delivering an FWNMI machine check interrupt.
Commit 382d2db62bcb ("target-ppc: Introduce callback for interrupt endianness") added a class method to PowerPCCPUClass to modelize this : default implementation returns a fixed "big endian" value, while POWER7 and newer do the LPCR_ILE check. This is suboptimal as it forces to implement the method for every new CPU family, and it is very unlikely that this will ever be different than what we have today.
We basically only have three cases to consider:
a) CPU doesn't have an LPCR => big endian
b) CPU has an LPCR but doesn't support the ILE bit => big endian
c) CPU has an LPCR and supports the ILE bit => little or big endian
Instead of class methods, introduce an inline helper that checks the ILE bit in the LPCR_MASK to decide on the outcome. The new helper words little endian instead of big endian. This allows to drop a ! operator in ppc_cpu_do_fwnmi_machine_check().
Message-Id: <[email protected]>
--- target/ppc/arch_dump.c | 8 +++----- target/ppc/cpu.h | 15 +++++++++++++++ target/ppc/excp_helper.c | 3 +-- 3 files changed, 19 insertions(+), 7 deletions(-)
target/ppc/arch_dump.c +3 -5
@@ -227,22 +227,20 @@ int cpu_get_dump_info(ArchDumpInfo *info, const struct GuestPhysBlockList *guest_phys_blocks) {PowerPCCPU *cpu; -PowerPCCPUClass *pcc;if (first_cpu ==NULL ) {return -1 ; } cpu =POWERPC_CPU (first_cpu); - pcc =POWERPC_CPU_GET_CLASS (cpu); info->d_machine =PPC_ELF_MACHINE ; info->d_class =ELFCLASS ; -if ((*pcc->interrupts_big_endian)(cpu)) { - info->d_endian =ELFDATA2MSB ; - }else { +if (ppc_interrupts_little_endian (cpu)) { info->d_endian =ELFDATA2LSB ; + }else { + info->d_endian =ELFDATA2MSB ; }/* 64KB is the max page size for pseries kernel */ if (strncmp(object_get_typename(qdev_get_machine()),
target/ppc/cpu.h +15 -0
@@ -2643,6 +2643,21 @@ static inline bool ppc_has_spr(PowerPCCPU *cpu, int spr)return cpu->env.spr_cb[spr].name !=NULL ; } +static inline bool ppc_interrupts_little_endian (PowerPCCPU *cpu) +{ +PowerPCCPUClass *pcc =POWERPC_CPU_GET_CLASS (cpu); + +/* +* Only models that have an LPCR and know about LPCR_ILE can do little +* endian. +*/ +if (pcc->lpcr_mask &LPCR_ILE ) { +return !!(cpu->env.spr[SPR_LPCR ] &LPCR_ILE ); + } + +return false; +} +void dump_mmu (CPUPPCState *env);void ppc_maybe_bswap_register (CPUPPCState *env,uint8_t *mem_buf,int len);
target/ppc/excp_helper.c +1 -2
@@ -1099,7 +1099,6 @@ void ppc_cpu_do_fwnmi_machine_check(CPUState *cs, target_ulong vector) {PowerPCCPU *cpu =POWERPC_CPU (cs);CPUPPCState *env = &cpu->env; -PowerPCCPUClass *pcc =POWERPC_CPU_GET_CLASS (cpu);target_ulong msr =0 ;/*
@@ -1108,7 +1107,7 @@ void ppc_cpu_do_fwnmi_machine_check(CPUState *cs, target_ulong vector)*/ msr = (1ULL <<MSR_ME ); msr |= env->msr & (1ULL <<MSR_SF ); -if (!(*pcc->interrupts_big_endian)(cpu)) { +if (ppc_interrupts_little_endian (cpu)) { msr |= (1ULL <<MSR_LE ); }
Signature · 1 line
2.31.1
[PULL 02/33] target/ppc: Drop PowerPCCPUClass::interrupts_big_endian()
In reply to David GibsonFrom: Greg Kurz <[email protected]>
This isn't used anymore.
Message-Id: <[email protected]>
--- target/ppc/cpu-qom.h | 1 - target/ppc/cpu_init.c | 17 ----------------- 2 files changed, 18 deletions(-)
target/ppc/cpu-qom.h +0 -1
@@ -199,7 +199,6 @@ struct PowerPCCPUClass {void (*init_proc)(CPUPPCState *env);int (*check_pow)(CPUPPCState *env);int (*handle_mmu_fault)(PowerPCCPU *cpu,vaddr eaddr,int rwx,int mmu_idx); -bool (*interrupts_big_endian)(PowerPCCPU *cpu); };#ifndef CONFIG_USER_ONLY
target/ppc/cpu_init.c +0 -17
@@ -2666,18 +2666,6 @@ static int check_pow_hid0_74xx(CPUPPCState *env)return 0 ; } -static bool ppc_cpu_interrupts_big_endian_always (PowerPCCPU *cpu) -{ -return true; -} - -#ifdef TARGET_PPC64 -static bool ppc_cpu_interrupts_big_endian_lpcr (PowerPCCPU *cpu) -{ -return !(cpu->env.spr[SPR_LPCR ] &LPCR_ILE ); -} -#endif -/*****************************************************************************/ /* PowerPC implementations definitions */
@@ -7740,7 +7728,6 @@ POWERPC_FAMILY(POWER7)(ObjectClass *oc, void *data)POWERPC_FLAG_VSX ; pcc->l1_dcache_size =0x8000 ; pcc->l1_icache_size =0x8000 ; - pcc->interrupts_big_endian = ppc_cpu_interrupts_big_endian_lpcr; }static void init_proc_POWER8 (CPUPPCState *env)
@@ -7918,7 +7905,6 @@ POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *data)POWERPC_FLAG_VSX |POWERPC_FLAG_TM ; pcc->l1_dcache_size =0x8000 ; pcc->l1_icache_size =0x8000 ; - pcc->interrupts_big_endian = ppc_cpu_interrupts_big_endian_lpcr; }#ifdef CONFIG_SOFTMMU
@@ -8136,7 +8122,6 @@ POWERPC_FAMILY(POWER9)(ObjectClass *oc, void *data)POWERPC_FLAG_VSX |POWERPC_FLAG_TM |POWERPC_FLAG_SCV ; pcc->l1_dcache_size =0x8000 ; pcc->l1_icache_size =0x8000 ; - pcc->interrupts_big_endian = ppc_cpu_interrupts_big_endian_lpcr; }#ifdef CONFIG_SOFTMMU
@@ -8347,7 +8332,6 @@ POWERPC_FAMILY(POWER10)(ObjectClass *oc, void *data)POWERPC_FLAG_VSX |POWERPC_FLAG_TM |POWERPC_FLAG_SCV ; pcc->l1_dcache_size =0x8000 ; pcc->l1_icache_size =0x8000 ; - pcc->interrupts_big_endian = ppc_cpu_interrupts_big_endian_lpcr; }#if !defined(CONFIG_USER_ONLY )
@@ -9094,7 +9078,6 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data)device_class_set_parent_unrealize (dc, ppc_cpu_unrealize, &pcc->parent_unrealize); pcc->pvr_match = ppc_pvr_match_default; - pcc->interrupts_big_endian = ppc_cpu_interrupts_big_endian_always;device_class_set_props (dc, ppc_cpu_properties);device_class_set_parent_reset (dc, ppc_cpu_reset, &pcc->parent_reset);
Signature · 1 line
2.31.1
[PULL 04/33] target/ppc: Remove PowerPCCPUClass.handle_mmu_fault
In reply to David GibsonFrom: Richard Henderson <[email protected]>
Instead, use a switch on env->mmu_model. This avoids some replicated information in cpu setup.
Message-Id: <[email protected]>
--- target/ppc/cpu-qom.h | 1 - target/ppc/cpu_init.c | 45 ----------------------------------------- target/ppc/mmu_helper.c | 24 ++++++++++++++++++---- 3 files changed, 20 insertions(+), 50 deletions(-)
target/ppc/cpu-qom.h +0 -1
@@ -198,7 +198,6 @@ struct PowerPCCPUClass {int n_host_threads;void (*init_proc)(CPUPPCState *env);int (*check_pow)(CPUPPCState *env); -int (*handle_mmu_fault)(PowerPCCPU *cpu,vaddr eaddr,int rwx,int mmu_idx); };#ifndef CONFIG_USER_ONLY
target/ppc/cpu_init.c +0 -45
159 lines not on this page · raw message
target/ppc/mmu_helper.c +20 -4
@@ -2947,14 +2947,30 @@ bool ppc_cpu_tlb_fill(CPUState *cs, vaddr addr, int size, bool probe, uintptr_t retaddr) {PowerPCCPU *cpu =POWERPC_CPU (cs); -PowerPCCPUClass *pcc =POWERPC_CPU_GET_CLASS (cs);CPUPPCState *env = &cpu->env;int ret; -if (pcc->handle_mmu_fault) { - ret = pcc->handle_mmu_fault (cpu, addr, access_type, mmu_idx); - }else { +switch (env->mmu_model) { +#if defined(TARGET_PPC64 ) +case POWERPC_MMU_64B : +case POWERPC_MMU_2_03 : +case POWERPC_MMU_2_06 : +case POWERPC_MMU_2_07 : + ret =ppc_hash64_handle_mmu_fault (cpu, addr, access_type, mmu_idx); +break ; +case POWERPC_MMU_3_00 : + ret =ppc64_v3_handle_mmu_fault (cpu, addr, access_type, mmu_idx); +break ; +#endif + +case POWERPC_MMU_32B : +case POWERPC_MMU_601 : + ret =ppc_hash32_handle_mmu_fault (cpu, addr, access_type, mmu_idx); +break ; + +default : ret =cpu_ppc_handle_mmu_fault (env, addr, access_type, mmu_idx); +break ; }if (unlikely (ret !=0 )) {if (probe) {
Signature · 1 line
2.31.1
[PULL 03/33] spapr: tune rtas-size
In reply to David GibsonFrom: Alexey Kardashevskiy <[email protected]>
QEMU reserves space for RTAS via /rtas/rtas-size which tells the client how much space the RTAS requires to work which includes the RTAS binary blob implementing RTAS runtime. Because pseries supports FWNMI which requires plenty of space, QEMU reserves more than 2KB which is enough for the RTAS blob as it is just 20 bytes (under QEMU).
Since FWNMI reset delivery was added, RTAS_SIZE macro is not used anymore. This replaces RTAS_SIZE with RTAS_MIN_SIZE and uses it in
the /rtas/rtas-size calculation to account for the RTAS blob.
Message-Id: <[email protected]>
--- hw/ppc/spapr.c | 8 ++++++-- include/hw/ppc/spapr.h | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-)
hw/ppc/spapr.c +6 -2
@@ -919,9 +919,13 @@ static void spapr_dt_rtas(SpaprMachineState *spapr, void *fdt)* * The extra 8 bytes is required because Linux's FWNMI error log check * is off-by-one. +* +* RTAS_MIN_SIZE is required for the RTAS blob itself. */ -_FDT (fdt_setprop_cell (fdt, rtas,"rtas-size" ,RTAS_ERROR_LOG_MAX + - ms->smp.max_cpus *sizeof (uint64_t )*2 +sizeof (uint64_t ))); +_FDT (fdt_setprop_cell (fdt, rtas,"rtas-size" ,RTAS_MIN_SIZE + +RTAS_ERROR_LOG_MAX + + ms->smp.max_cpus *sizeof (uint64_t ) *2 + +sizeof (uint64_t )));_FDT (fdt_setprop_cell (fdt, rtas,"rtas-error-log-max" ,RTAS_ERROR_LOG_MAX )); _FDT(fdt_setprop_cell(fdt, rtas, "rtas-event-scan-rate",
include/hw/ppc/spapr.h +1 -1
@@ -770,7 +770,7 @@ void spapr_load_rtas(SpaprMachineState *spapr, void *fdt, hwaddr addr);#define SPAPR_IS_PCI_LIOBN (liobn) (!!((liobn) & 0x80000000))#define SPAPR_PCI_DMA_WINDOW_NUM (liobn) ((liobn) & 0xff) -#define RTAS_SIZE 2048 +#define RTAS_MIN_SIZE 20/* hv_rtas_size in SLOF */ #define RTAS_ERROR_LOG_MAX 2048/* Offset from rtas-base where error log is placed */
Signature · 1 line
2.31.1
[PULL 10/33] target/ppc: Split out ppc_jumbo_xlate
In reply to David GibsonFrom: Richard Henderson <[email protected]>
Mirror the interface of ppc_radix64_xlate (mostly), putting all of the logic for older mmu translation into a single entry point. For booke, we need to add mmu_idx to the xlate-style interface.
Message-Id: <[email protected]>
--- target/ppc/mmu_helper.c | 179 +++++++++++++++++++++------------------- 1 file changed, 96 insertions(+), 83 deletions(-)
target/ppc/mmu_helper.c +96 -83
@@ -1435,48 +1435,6 @@ static int get_physical_address(CPUPPCState *env, mmu_ctx_t *ctx, }#endif -hwaddr ppc_cpu_get_phys_page_debug (CPUState *cs,vaddr addr) -{ -PowerPCCPU *cpu =POWERPC_CPU (cs); -CPUPPCState *env = &cpu->env; -mmu_ctx_t ctx; - -switch (env->mmu_model) { -#if defined(TARGET_PPC64 ) -case POWERPC_MMU_64B : -case POWERPC_MMU_2_03 : -case POWERPC_MMU_2_06 : -case POWERPC_MMU_2_07 : -return ppc_hash64_get_phys_page_debug (cpu, addr); -case POWERPC_MMU_3_00 : -return ppc64_v3_get_phys_page_debug (cpu, addr); -#endif - -case POWERPC_MMU_32B : -case POWERPC_MMU_601 : -return ppc_hash32_get_phys_page_debug (cpu, addr); - -default : - ; - } - -if (unlikely (get_physical_address (env, &ctx, addr,MMU_DATA_LOAD , -ACCESS_INT ) !=0 )) { - -/* -* Some MMUs have separate TLBs for code and data. If we only -* try an ACCESS_INT, we may not be able to read instructions -* mapped by code TLBs, so we also try a ACCESS_CODE. -*/ -if (unlikely (get_physical_address (env, &ctx, addr,MMU_INST_FETCH , -ACCESS_CODE ) !=0 )) { -return -1 ; - } - } - -return ctx.raddr &TARGET_PAGE_MASK ; -} -static void booke206_update_mas_tlb_miss (CPUPPCState *env,target_ulong address,MMUAccessType access_type,int mmu_idx) {
@@ -1532,30 +1490,38 @@ static void booke206_update_mas_tlb_miss(CPUPPCState *env, target_ulong address, }/* Perform address translation */ -static int cpu_ppc_handle_mmu_fault (CPUPPCState *env,target_ulong address, -MMUAccessType access_type,int mmu_idx) +/* TODO: Split this by mmu_model. */ +static bool ppc_jumbo_xlate (PowerPCCPU *cpu,vaddr eaddr, +MMUAccessType access_type, +hwaddr *raddrp,int *psizep,int *protp, +int mmu_idx,bool guest_visible) { -CPUState *cs =env_cpu (env); -PowerPCCPU *cpu =POWERPC_CPU (cs); +CPUState *cs =CPU (cpu); +CPUPPCState *env = &cpu->env;mmu_ctx_t ctx;int type; -int ret =0 ; +int ret;if (access_type ==MMU_INST_FETCH ) {/* code access */ type =ACCESS_CODE ; - }else { + }else if (guest_visible) {/* data access */ type = env->access_type; + }else { + type =ACCESS_INT ; } - ret =get_physical_address_wtlb (env, &ctx, address, access_type, + + ret =get_physical_address_wtlb (env, &ctx, eaddr, access_type, type, mmu_idx);if (ret ==0 ) { -tlb_set_page (cs, address &TARGET_PAGE_MASK , - ctx.raddr &TARGET_PAGE_MASK , ctx.prot, - mmu_idx,TARGET_PAGE_SIZE ); - ret =0 ; - }else if (ret <0 ) { + *raddrp = ctx.raddr; + *protp = ctx.prot; + *psizep =TARGET_PAGE_BITS ; +return true; + } + +if (guest_visible) {LOG_MMU_STATE (cs);if (type ==ACCESS_CODE ) {switch (ret) {
@@ -1565,7 +1531,7 @@ static int cpu_ppc_handle_mmu_fault(CPUPPCState *env, target_ulong address,case POWERPC_MMU_SOFT_6xx: cs->exception_index =POWERPC_EXCP_IFTLB ; env->error_code =1 <<18 ; - env->spr[SPR_IMISS ] = address; + env->spr[SPR_IMISS ] = eaddr; env->spr[SPR_ICMP ] =0x80000000 | ctx.ptem; goto tlb_miss;case POWERPC_MMU_SOFT_74xx:
@@ -1575,29 +1541,25 @@ static int cpu_ppc_handle_mmu_fault(CPUPPCState *env, target_ulong address,case POWERPC_MMU_SOFT_4xx_Z: cs->exception_index =POWERPC_EXCP_ITLB ; env->error_code =0 ; - env->spr[SPR_40x_DEAR] = address; + env->spr[SPR_40x_DEAR] = eaddr; env->spr[SPR_40x_ESR] =0x00000000 ;break ;case POWERPC_MMU_BOOKE206 : -booke206_update_mas_tlb_miss (env, address,2 , mmu_idx); +booke206_update_mas_tlb_miss (env, eaddr,2 , mmu_idx);/* fall through */ case POWERPC_MMU_BOOKE : cs->exception_index =POWERPC_EXCP_ITLB ; env->error_code =0 ; - env->spr[SPR_BOOKE_DEAR ] = address; + env->spr[SPR_BOOKE_DEAR ] = eaddr; env->spr[SPR_BOOKE_ESR ] =mmubooke206_esr (mmu_idx,MMU_DATA_LOAD ); -return -1 ; +break ;case POWERPC_MMU_MPC8xx: -/* XXX: TODO */ cpu_abort (cs,"MPC8xx MMU model is not implemented\n" ); -break ;case POWERPC_MMU_REAL :cpu_abort (cs,"PowerPC in real mode should never raise " "any MMU exceptions\n" ); -return -1 ;default :cpu_abort (cs,"Unknown or invalid MMU model\n" ); -return -1 ; }break ;case -2 :
@@ -1634,7 +1596,7 @@ static int cpu_ppc_handle_mmu_fault(CPUPPCState *env, target_ulong address, cs->exception_index =POWERPC_EXCP_DLTLB ; env->error_code =0 ; } - env->spr[SPR_DMISS ] = address; + env->spr[SPR_DMISS ] = eaddr; env->spr[SPR_DCMP ] =0x80000000 | ctx.ptem; tlb_miss: env->error_code |= ctx.key <<19 ;
@@ -1652,7 +1614,7 @@ static int cpu_ppc_handle_mmu_fault(CPUPPCState *env, target_ulong address, tlb_miss_74xx:/* Implement LRU algorithm */ env->error_code = ctx.key <<19 ; - env->spr[SPR_TLBMISS ] = (address & ~((target_ulong )0x3 )) | + env->spr[SPR_TLBMISS ] = (eaddr & ~((target_ulong )0x3 )) | ((env->last_way +1 ) & (env->nb_ways -1 )); env->spr[SPR_PTEHI ] =0x80000000 | ctx.ptem;break ;
@@ -1660,7 +1622,7 @@ static int cpu_ppc_handle_mmu_fault(CPUPPCState *env, target_ulong address,case POWERPC_MMU_SOFT_4xx_Z: cs->exception_index =POWERPC_EXCP_DTLB ; env->error_code =0 ; - env->spr[SPR_40x_DEAR] = address; + env->spr[SPR_40x_DEAR] = eaddr;if (access_type ==MMU_DATA_STORE ) { env->spr[SPR_40x_ESR] =0x00800000 ; }else {
@@ -1670,23 +1632,20 @@ static int cpu_ppc_handle_mmu_fault(CPUPPCState *env, target_ulong address,case POWERPC_MMU_MPC8xx:/* XXX: TODO */ cpu_abort (cs,"MPC8xx MMU model is not implemented\n" ); -break ;case POWERPC_MMU_BOOKE206 : -booke206_update_mas_tlb_miss (env, address, access_type, mmu_idx); +booke206_update_mas_tlb_miss (env, eaddr, access_type, mmu_idx);/* fall through */ case POWERPC_MMU_BOOKE : cs->exception_index =POWERPC_EXCP_DTLB ; env->error_code =0 ; - env->spr[SPR_BOOKE_DEAR ] = address; + env->spr[SPR_BOOKE_DEAR ] = eaddr; env->spr[SPR_BOOKE_ESR ] =mmubooke206_esr (mmu_idx, access_type); -return -1 ; +break ;case POWERPC_MMU_REAL :cpu_abort (cs,"PowerPC in real mode should never raise " "any MMU exceptions\n" ); -return -1 ;default :cpu_abort (cs,"Unknown or invalid MMU model\n" ); -return -1 ; }break ;case -2 :
@@ -1695,16 +1654,16 @@ static int cpu_ppc_handle_mmu_fault(CPUPPCState *env, target_ulong address, env->error_code =0 ;if (env->mmu_model == POWERPC_MMU_SOFT_4xx || env->mmu_model == POWERPC_MMU_SOFT_4xx_Z) { - env->spr[SPR_40x_DEAR] = address; + env->spr[SPR_40x_DEAR] = eaddr;if (access_type ==MMU_DATA_STORE ) { env->spr[SPR_40x_ESR] |=0x00800000 ; } }else if ((env->mmu_model ==POWERPC_MMU_BOOKE ) || (env->mmu_model ==POWERPC_MMU_BOOKE206 )) { - env->spr[SPR_BOOKE_DEAR ] = address; + env->spr[SPR_BOOKE_DEAR ] = eaddr; env->spr[SPR_BOOKE_ESR ] =mmubooke206_esr (mmu_idx, access_type); }else { - env->spr[SPR_DAR ] = address; + env->spr[SPR_DAR ] = eaddr;if (access_type ==MMU_DATA_STORE ) { env->spr[SPR_DSISR ] =0x0A000000 ; }else {
@@ -1719,13 +1678,13 @@ static int cpu_ppc_handle_mmu_fault(CPUPPCState *env, target_ulong address,/* Floating point load/store */ cs->exception_index =POWERPC_EXCP_ALIGN ; env->error_code =POWERPC_EXCP_ALIGN_FP ; - env->spr[SPR_DAR ] = address; + env->spr[SPR_DAR ] = eaddr;break ;case ACCESS_RES :/* lwarx, ldarx or stwcx. */ cs->exception_index =POWERPC_EXCP_DSI ; env->error_code =0 ; - env->spr[SPR_DAR ] = address; + env->spr[SPR_DAR ] = eaddr;if (access_type ==MMU_DATA_STORE ) { env->spr[SPR_DSISR ] =0x06000000 ; }else {
@@ -1736,7 +1695,7 @@ static int cpu_ppc_handle_mmu_fault(CPUPPCState *env, target_ulong address,/* eciwx or ecowx */ cs->exception_index =POWERPC_EXCP_DSI ; env->error_code =0 ; - env->spr[SPR_DAR ] = address; + env->spr[SPR_DAR ] = eaddr;if (access_type ==MMU_DATA_STORE ) { env->spr[SPR_DSISR ] =0x06100000 ; }else {
@@ -1748,16 +1707,14 @@ static int cpu_ppc_handle_mmu_fault(CPUPPCState *env, target_ulong address, cs->exception_index =POWERPC_EXCP_PROGRAM ; env->error_code =POWERPC_EXCP_INVAL |POWERPC_EXCP_INVAL_INVAL ; - env->spr[SPR_DAR ] = address; + env->spr[SPR_DAR ] = eaddr;break ; }break ; } } - ret =1 ; } - -return ret; +return false; }#ifdef CONFIG_TCG
@@ -2942,6 +2899,62 @@ void helper_check_tlb_flush_global(CPUPPCState *env)/*****************************************************************************/ +static int cpu_ppc_handle_mmu_fault (PowerPCCPU *cpu,vaddr eaddr, +MMUAccessType access_type,int mmu_idx) +{ +CPUState *cs =CPU (cpu); +int page_size, prot; +hwaddr raddr; + +if (!ppc_jumbo_xlate (cpu, eaddr, access_type, &raddr, + &page_size, &prot, mmu_idx, true)) { +return 1 ; + } + +tlb_set_page (cs, eaddr &TARGET_PAGE_MASK , raddr &TARGET_PAGE_MASK , + prot, mmu_idx,1UL << page_size); +return 0 ; +} + +hwaddr ppc_cpu_get_phys_page_debug (CPUState *cs,vaddr addr) +{ +PowerPCCPU *cpu =POWERPC_CPU (cs); +CPUPPCState *env = &cpu->env; +hwaddr raddr; +int s, p; + +switch (env->mmu_model) { +#if defined(TARGET_PPC64 ) +case POWERPC_MMU_64B : +case POWERPC_MMU_2_03 : +case POWERPC_MMU_2_06 : +case POWERPC_MMU_2_07 : +return ppc_hash64_get_phys_page_debug (cpu, addr); +case POWERPC_MMU_3_00 : +return ppc64_v3_get_phys_page_debug (cpu, addr); +#endif + +case POWERPC_MMU_32B : +case POWERPC_MMU_601 : +return ppc_hash32_get_phys_page_debug (cpu, addr); + +default : + ; + } + +/* +* Some MMUs have separate TLBs for code and data. If we only +* try an MMU_DATA_LOAD, we may not be able to read instructions +* mapped by code TLBs, so we also try a MMU_INST_FETCH. +*/ +if (ppc_jumbo_xlate (cpu, addr,MMU_DATA_LOAD , &raddr, &s, &p,0 , false) || +ppc_jumbo_xlate (cpu, addr,MMU_INST_FETCH , &raddr, &s, &p,0 , false)) { +return raddr &TARGET_PAGE_MASK ; + } +return -1 ; +} + +bool ppc_cpu_tlb_fill (CPUState *cs,vaddr addr,int size,MMUAccessType access_type,int mmu_idx,bool probe,uintptr_t retaddr)
@@ -2969,7 +2982,7 @@ bool ppc_cpu_tlb_fill(CPUState *cs, vaddr addr, int size,break ;default : - ret =cpu_ppc_handle_mmu_fault (env, addr, access_type, mmu_idx); + ret =cpu_ppc_handle_mmu_fault (cpu, addr, access_type, mmu_idx);break ; }if (unlikely (ret !=0 )) {
Signature · 1 line
2.31.1
[PULL 05/33] target/ppc: Use MMUAccessType with *_handle_mmu_fault
In reply to David GibsonFrom: Richard Henderson <[email protected]>
These changes were waiting until we didn't need to match the function type of PowerPCCPUClass.handle_mmu_fault.
Message-Id: <[email protected]>
--- target/ppc/mmu-hash32.c | 7 ++----- target/ppc/mmu-hash32.h | 4 ++-- target/ppc/mmu-hash64.c | 6 +----- target/ppc/mmu-hash64.h | 4 ++-- target/ppc/mmu-radix64.c | 7 ++----- target/ppc/mmu-radix64.h | 4 ++-- 6 files changed, 11 insertions(+), 21 deletions(-)
target/ppc/mmu-hash32.c +2 -5
@@ -415,8 +415,8 @@ static hwaddr ppc_hash32_pte_raddr(target_ulong sr, ppc_hash_pte32_t pte,return (rpn & ~mask) | (eaddr & mask); } -int ppc_hash32_handle_mmu_fault (PowerPCCPU *cpu,vaddr eaddr,int rwx, -int mmu_idx) +int ppc_hash32_handle_mmu_fault (PowerPCCPU *cpu,vaddr eaddr, +MMUAccessType access_type,int mmu_idx) {CPUState *cs =CPU (cpu);CPUPPCState *env = &cpu->env;
@@ -425,11 +425,8 @@ int ppc_hash32_handle_mmu_fault(PowerPCCPU *cpu, vaddr eaddr, int rwx,ppc_hash_pte32_t pte;int prot;int need_prot; -MMUAccessType access_type;hwaddr raddr; -assert ((rwx ==0 ) || (rwx ==1 ) || (rwx ==2 )); - access_type = rwx; need_prot =prot_for_access_type (access_type);/* 1. Handle real mode accesses */
target/ppc/mmu-hash32.h +2 -2
@@ -5,8 +5,8 @@hwaddr get_pteg_offset32 (PowerPCCPU *cpu,hwaddr hash);hwaddr ppc_hash32_get_phys_page_debug (PowerPCCPU *cpu,target_ulong addr); -int ppc_hash32_handle_mmu_fault (PowerPCCPU *cpu,vaddr address,int rw, -int mmu_idx); +int ppc_hash32_handle_mmu_fault (PowerPCCPU *cpu,vaddr address, +MMUAccessType access_type,int mmu_idx);/* * Segment register definitions
target/ppc/mmu-hash64.c +1 -5
@@ -874,7 +874,7 @@ static int build_vrma_slbe(PowerPCCPU *cpu, ppc_slb_t *slb) }int ppc_hash64_handle_mmu_fault (PowerPCCPU *cpu,vaddr eaddr, -int rwx,int mmu_idx) +MMUAccessType access_type,int mmu_idx) {CPUState *cs =CPU (cpu);CPUPPCState *env = &cpu->env;
@@ -884,13 +884,9 @@ int ppc_hash64_handle_mmu_fault(PowerPCCPU *cpu, vaddr eaddr,hwaddr ptex;ppc_hash_pte64_t pte;int exec_prot, pp_prot, amr_prot, prot; -MMUAccessType access_type;int need_prot;hwaddr raddr; -assert ((rwx ==0 ) || (rwx ==1 ) || (rwx ==2 )); - access_type = rwx; -/* * Note on LPCR usage: 970 uses HID4, but our special variant of * store_spr copies relevant fields into env->spr[SPR_LPCR].
target/ppc/mmu-hash64.h +2 -2
@@ -8,8 +8,8 @@ void dump_slb(PowerPCCPU *cpu);int ppc_store_slb (PowerPCCPU *cpu,target_ulong slot,target_ulong esid,target_ulong vsid);hwaddr ppc_hash64_get_phys_page_debug (PowerPCCPU *cpu,target_ulong addr); -int ppc_hash64_handle_mmu_fault (PowerPCCPU *cpu,vaddr address,int rw, -int mmu_idx); +int ppc_hash64_handle_mmu_fault (PowerPCCPU *cpu,vaddr address, +MMUAccessType access_type,int mmu_idx);void ppc_hash64_tlb_flush_hpte (PowerPCCPU *cpu,target_ulong pte_index,target_ulong pte0,target_ulong pte1);
target/ppc/mmu-radix64.c +2 -5
@@ -555,19 +555,16 @@ static int ppc_radix64_xlate(PowerPCCPU *cpu, vaddr eaddr,return 0 ; } -int ppc_radix64_handle_mmu_fault (PowerPCCPU *cpu,vaddr eaddr,int rwx, -int mmu_idx) +int ppc_radix64_handle_mmu_fault (PowerPCCPU *cpu,vaddr eaddr, +MMUAccessType access_type,int mmu_idx) {CPUState *cs =CPU (cpu);CPUPPCState *env = &cpu->env;int page_size, prot;bool relocation; -MMUAccessType access_type;hwaddr raddr;assert (!(msr_hv && cpu->vhyp)); -assert ((rwx ==0 ) || (rwx ==1 ) || (rwx ==2 )); - access_type = rwx; relocation = (access_type ==MMU_INST_FETCH ? msr_ir : msr_dr);/* HV or virtual hypervisor Real Mode Access */
target/ppc/mmu-radix64.h +2 -2
@@ -44,8 +44,8 @@#ifdef TARGET_PPC64 -int ppc_radix64_handle_mmu_fault (PowerPCCPU *cpu,vaddr eaddr,int rwx, -int mmu_idx); +int ppc_radix64_handle_mmu_fault (PowerPCCPU *cpu,vaddr eaddr, +MMUAccessType access_type,int mmu_idx);hwaddr ppc_radix64_get_phys_page_debug (PowerPCCPU *cpu,target_ulong addr);static inline int ppc_radix64_get_prot_eaa (uint64_t pte)
Signature · 1 line
2.31.1
[PULL 06/33] target/ppc: Push real-mode handling into ppc_radix64_xlate
In reply to David GibsonFrom: Richard Henderson <[email protected]>
This removes some incomplete duplication between ppc_radix64_handle_mmu_fault and ppc_radix64_get_phys_page_debug. The former was correct wrt SPR_HRMOR and the latter was not.
Message-Id: <[email protected]>
--- target/ppc/mmu-radix64.c | 77 ++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 43 deletions(-)
target/ppc/mmu-radix64.c +34 -43
@@ -465,7 +465,6 @@ static int ppc_radix64_process_scoped_xlate(PowerPCCPU *cpu,*/ static int ppc_radix64_xlate (PowerPCCPU *cpu,vaddr eaddr,MMUAccessType access_type, -bool relocation,hwaddr *raddr,int *psizep,int *protp,bool guest_visible) {
@@ -474,6 +473,37 @@ static int ppc_radix64_xlate(PowerPCCPU *cpu, vaddr eaddr,ppc_v3_pate_t pate;int psize, prot;hwaddr g_raddr; +bool relocation; + +assert (!(msr_hv && cpu->vhyp)); + + relocation = (access_type ==MMU_INST_FETCH ? msr_ir : msr_dr); + +/* HV or virtual hypervisor Real Mode Access */ +if (!relocation && (msr_hv || cpu->vhyp)) { +/* In real mode top 4 effective addr bits (mostly) ignored */ + *raddr = eaddr &0x0FFFFFFFFFFFFFFFULL ; + +/* In HV mode, add HRMOR if top EA bit is clear */ +if (msr_hv || !env->has_hv_mode) { +if (!(eaddr >>63 )) { + *raddr |= env->spr[SPR_HRMOR ]; + } + } + *protp =PAGE_READ |PAGE_WRITE |PAGE_EXEC ; + *psizep =TARGET_PAGE_BITS ; +return 0 ; + } + +/* +* Check UPRT (we avoid the check in real mode to deal with +* transitional states during kexec. +*/ +if (guest_visible && !ppc64_use_proc_tbl (cpu)) { +qemu_log_mask (LOG_GUEST_ERROR , +"LPCR:UPRT not set in radix mode ! LPCR=" + TARGET_FMT_lx"\n" , env->spr[SPR_LPCR ]); + }/* Virtual Mode Access - get the fully qualified address */ if (!ppc_radix64_get_fully_qualified_addr (&cpu->env, eaddr, &lpid, &pid)) {
@@ -559,43 +589,11 @@ int ppc_radix64_handle_mmu_fault(PowerPCCPU *cpu, vaddr eaddr, MMUAccessType access_type, int mmu_idx) {CPUState *cs =CPU (cpu); -CPUPPCState *env = &cpu->env;int page_size, prot; -bool relocation;hwaddr raddr; -assert (!(msr_hv && cpu->vhyp)); - - relocation = (access_type ==MMU_INST_FETCH ? msr_ir : msr_dr); -/* HV or virtual hypervisor Real Mode Access */ -if (!relocation && (msr_hv || cpu->vhyp)) { -/* In real mode top 4 effective addr bits (mostly) ignored */ - raddr = eaddr &0x0FFFFFFFFFFFFFFFULL ; - -/* In HV mode, add HRMOR if top EA bit is clear */ -if (msr_hv || !env->has_hv_mode) { -if (!(eaddr >>63 )) { - raddr |= env->spr[SPR_HRMOR ]; - } - } -tlb_set_page (cs, eaddr &TARGET_PAGE_MASK , raddr &TARGET_PAGE_MASK , -PAGE_READ |PAGE_WRITE |PAGE_EXEC , mmu_idx, -TARGET_PAGE_SIZE ); -return 0 ; - } - -/* -* Check UPRT (we avoid the check in real mode to deal with -* transitional states during kexec. -*/ -if (!ppc64_use_proc_tbl (cpu)) { -qemu_log_mask (LOG_GUEST_ERROR , -"LPCR:UPRT not set in radix mode ! LPCR=" - TARGET_FMT_lx"\n" , env->spr[SPR_LPCR ]); - } -/* Translate eaddr to raddr (where raddr is addr qemu needs for access) */ -if (ppc_radix64_xlate (cpu, eaddr, access_type, relocation, &raddr, +if (ppc_radix64_xlate (cpu, eaddr, access_type, &raddr, &page_size, &prot, true)) {return 1 ; }
@@ -607,18 +605,11 @@ int ppc_radix64_handle_mmu_fault(PowerPCCPU *cpu, vaddr eaddr,hwaddr ppc_radix64_get_phys_page_debug (PowerPCCPU *cpu,target_ulong eaddr) { -CPUPPCState *env = &cpu->env;int psize, prot;hwaddr raddr; -/* Handle Real Mode */ -if ((msr_dr ==0 ) && (msr_hv || cpu->vhyp)) { -/* In real mode top 4 effective addr bits (mostly) ignored */ -return eaddr &0x0FFFFFFFFFFFFFFFULL ; - } - -if (ppc_radix64_xlate (cpu, eaddr,0 , msr_dr, &raddr, &psize, - &prot, false)) { +if (ppc_radix64_xlate (cpu, eaddr,MMU_DATA_LOAD , &raddr, + &psize, &prot, false)) {return -1 ; }
Signature · 1 line
2.31.1
[PULL 07/33] target/ppc: Use bool success for ppc_radix64_xlate
In reply to David GibsonFrom: Richard Henderson <[email protected]>
Instead of returning non-zero for failure, return true for success.
Message-Id: <[email protected]>
--- target/ppc/mmu-radix64.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)
target/ppc/mmu-radix64.c +15 -15
@@ -463,10 +463,10 @@ static int ppc_radix64_process_scoped_xlate(PowerPCCPU *cpu,* | = On | Process Scoped | Scoped | * +-------------+----------------+---------------+ */ -static int ppc_radix64_xlate (PowerPCCPU *cpu,vaddr eaddr, -MMUAccessType access_type, -hwaddr *raddr,int *psizep,int *protp, -bool guest_visible) +static bool ppc_radix64_xlate (PowerPCCPU *cpu,vaddr eaddr, +MMUAccessType access_type, +hwaddr *raddr,int *psizep,int *protp, +bool guest_visible) {CPUPPCState *env = &cpu->env;uint64_t lpid, pid;
@@ -492,7 +492,7 @@ static int ppc_radix64_xlate(PowerPCCPU *cpu, vaddr eaddr, } *protp =PAGE_READ |PAGE_WRITE |PAGE_EXEC ; *psizep =TARGET_PAGE_BITS ; -return 0 ; +return true; }/*
@@ -510,7 +510,7 @@ static int ppc_radix64_xlate(PowerPCCPU *cpu, vaddr eaddr,if (guest_visible) {ppc_radix64_raise_segi (cpu, access_type, eaddr); } -return 1 ; +return false; }/* Get Process Table */
@@ -523,13 +523,13 @@ static int ppc_radix64_xlate(PowerPCCPU *cpu, vaddr eaddr,if (guest_visible) {ppc_radix64_raise_si (cpu, access_type, eaddr,DSISR_NOPTE ); } -return 1 ; +return false; }if (!validate_pate (cpu, lpid, &pate)) {if (guest_visible) {ppc_radix64_raise_si (cpu, access_type, eaddr,DSISR_R_BADCONFIG ); } -return 1 ; +return false; } }
@@ -549,7 +549,7 @@ static int ppc_radix64_xlate(PowerPCCPU *cpu, vaddr eaddr, pate, &g_raddr, &prot, &psize, guest_visible);if (ret) { -return ret; +return false; } *psizep =MIN (*psizep, psize); *protp &= prot;
@@ -573,7 +573,7 @@ static int ppc_radix64_xlate(PowerPCCPU *cpu, vaddr eaddr, &prot, &psize, false, guest_visible);if (ret) { -return ret; +return false; } *psizep =MIN (*psizep, psize); *protp &= prot;
@@ -582,7 +582,7 @@ static int ppc_radix64_xlate(PowerPCCPU *cpu, vaddr eaddr, } } -return 0 ; +return true; } int ppc_radix64_handle_mmu_fault(PowerPCCPU *cpu, vaddr eaddr,
@@ -593,8 +593,8 @@ int ppc_radix64_handle_mmu_fault(PowerPCCPU *cpu, vaddr eaddr,hwaddr raddr;/* Translate eaddr to raddr (where raddr is addr qemu needs for access) */ -if (ppc_radix64_xlate (cpu, eaddr, access_type, &raddr, - &page_size, &prot, true)) { +if (!ppc_radix64_xlate (cpu, eaddr, access_type, &raddr, + &page_size, &prot, true)) {return 1 ; }
@@ -608,8 +608,8 @@ hwaddr ppc_radix64_get_phys_page_debug(PowerPCCPU *cpu, target_ulong eaddr)int psize, prot;hwaddr raddr; -if (ppc_radix64_xlate (cpu, eaddr,MMU_DATA_LOAD , &raddr, - &psize, &prot, false)) { +if (!ppc_radix64_xlate (cpu, eaddr,MMU_DATA_LOAD , &raddr, + &psize, &prot, false)) {return -1 ; }
Signature · 1 line
2.31.1
[PULL 09/33] target/ppc: Split out ppc_hash32_xlate
In reply to David GibsonFrom: Richard Henderson <[email protected]>
Mirror the interface of ppc_radix64_xlate, putting all of the logic for hash32 translation into a single entry point.
Message-Id: <[email protected]>
--- target/ppc/mmu-hash32.c | 224 ++++++++++++++++++++-------------------- 1 file changed, 113 insertions(+), 111 deletions(-)
target/ppc/mmu-hash32.c +113 -111
@@ -218,10 +218,11 @@ static hwaddr ppc_hash32_bat_lookup(PowerPCCPU *cpu, target_ulong ea,return -1 ; } -static int ppc_hash32_direct_store (PowerPCCPU *cpu,target_ulong sr, -target_ulong eaddr, -MMUAccessType access_type, -hwaddr *raddr,int *prot) +static bool ppc_hash32_direct_store (PowerPCCPU *cpu,target_ulong sr, +target_ulong eaddr, +MMUAccessType access_type, +hwaddr *raddr,int *prot, +bool guest_visible) {CPUState *cs =CPU (cpu);CPUPPCState *env = &cpu->env;
@@ -238,17 +239,23 @@ static int ppc_hash32_direct_store(PowerPCCPU *cpu, target_ulong sr,*/ *raddr = ((sr &0xF ) <<28 ) | (eaddr &0x0FFFFFFF ); *prot =PAGE_READ |PAGE_WRITE |PAGE_EXEC ; -return 0 ; +return true; }if (access_type ==MMU_INST_FETCH ) {/* No code fetch is allowed in direct-store areas */ - cs->exception_index =POWERPC_EXCP_ISI ; - env->error_code =0x10000000 ; -return 1 ; +if (guest_visible) { + cs->exception_index =POWERPC_EXCP_ISI ; + env->error_code =0x10000000 ; + } +return false; } -switch (env->access_type) { +/* +* From ppc_cpu_get_phys_page_debug, env->access_type is not set. +* Assume ACCESS_INT for that case. +*/ +switch (guest_visible ? env->access_type :ACCESS_INT ) {case ACCESS_INT :/* Integer load/store : only access allowed */ break ;
@@ -257,7 +264,7 @@ static int ppc_hash32_direct_store(PowerPCCPU *cpu, target_ulong sr, cs->exception_index =POWERPC_EXCP_ALIGN ; env->error_code =POWERPC_EXCP_ALIGN_FP ; env->spr[SPR_DAR ] = eaddr; -return 1 ; +return false;case ACCESS_RES :/* lwarx, ldarx or srwcx. */ env->error_code =0 ;
@@ -267,7 +274,7 @@ static int ppc_hash32_direct_store(PowerPCCPU *cpu, target_ulong sr, }else { env->spr[SPR_DSISR ] =0x04000000 ; } -return 1 ; +return false;case ACCESS_CACHE :/* * dcba, dcbt, dcbtst, dcbf, dcbi, dcbst, dcbz, or icbi
@@ -276,7 +283,7 @@ static int ppc_hash32_direct_store(PowerPCCPU *cpu, target_ulong sr,* no-op, it's quite easy :-) */ *raddr = eaddr; -return 0 ; +return true;case ACCESS_EXT :/* eciwx or ecowx */ cs->exception_index =POWERPC_EXCP_DSI ;
@@ -287,16 +294,18 @@ static int ppc_hash32_direct_store(PowerPCCPU *cpu, target_ulong sr, }else { env->spr[SPR_DSISR ] =0x04100000 ; } -return 1 ; +return false;default : -cpu_abort (cs,"ERROR: instruction should not need " -"address translation\n" ); +cpu_abort (cs,"ERROR: insn should not need address translation\n" ); } -if ((access_type ==MMU_DATA_STORE || key !=1 ) && - (access_type ==MMU_DATA_LOAD || key !=0 )) { + + *prot = key ?PAGE_READ |PAGE_WRITE :PAGE_READ ; +if (*prot &prot_for_access_type (access_type)) { *raddr = eaddr; -return 0 ; - }else { +return true; + } + +if (guest_visible) { cs->exception_index =POWERPC_EXCP_DSI ; env->error_code =0 ; env->spr[SPR_DAR ] = eaddr;
@@ -305,8 +314,8 @@ static int ppc_hash32_direct_store(PowerPCCPU *cpu, target_ulong sr, }else { env->spr[SPR_DSISR ] =0x08000000 ; } -return 1 ; } +return false; }hwaddr get_pteg_offset32 (PowerPCCPU *cpu,hwaddr hash)
@@ -415,8 +424,10 @@ static hwaddr ppc_hash32_pte_raddr(target_ulong sr, ppc_hash_pte32_t pte,return (rpn & ~mask) | (eaddr & mask); } -int ppc_hash32_handle_mmu_fault (PowerPCCPU *cpu,vaddr eaddr, -MMUAccessType access_type,int mmu_idx) +static bool ppc_hash32_xlate (PowerPCCPU *cpu,vaddr eaddr, +MMUAccessType access_type, +hwaddr *raddrp,int *psizep,int *protp, +bool guest_visible) {CPUState *cs =CPU (cpu);CPUPPCState *env = &cpu->env;
@@ -427,43 +438,43 @@ int ppc_hash32_handle_mmu_fault(PowerPCCPU *cpu, vaddr eaddr,int need_prot;hwaddr raddr; - need_prot =prot_for_access_type (access_type); +/* There are no hash32 large pages. */ + *psizep =TARGET_PAGE_BITS ;/* 1. Handle real mode accesses */ if (access_type ==MMU_INST_FETCH ? !msr_ir : !msr_dr) {/* Translation is off */ - raddr = eaddr; -tlb_set_page (cs, eaddr &TARGET_PAGE_MASK , raddr &TARGET_PAGE_MASK , -PAGE_READ |PAGE_WRITE |PAGE_EXEC , mmu_idx, -TARGET_PAGE_SIZE ); -return 0 ; + *raddrp = eaddr; + *protp =PAGE_READ |PAGE_WRITE |PAGE_EXEC ; +return true; } + need_prot =prot_for_access_type (access_type); +/* 2. Check Block Address Translation entries (BATs) */ if (env->nb_BATs !=0 ) { - raddr =ppc_hash32_bat_lookup (cpu, eaddr, access_type, &prot); + raddr =ppc_hash32_bat_lookup (cpu, eaddr, access_type, protp);if (raddr !=-1 ) { -if (need_prot & ~prot) { -if (access_type ==MMU_INST_FETCH ) { - cs->exception_index =POWERPC_EXCP_ISI ; - env->error_code =0x08000000 ; - }else { - cs->exception_index =POWERPC_EXCP_DSI ; - env->error_code =0 ; - env->spr[SPR_DAR ] = eaddr; -if (access_type ==MMU_DATA_STORE ) { - env->spr[SPR_DSISR ] =0x0a000000 ; +if (need_prot & ~*protp) { +if (guest_visible) { +if (access_type ==MMU_INST_FETCH ) { + cs->exception_index =POWERPC_EXCP_ISI ; + env->error_code =0x08000000 ; }else { - env->spr[SPR_DSISR ] =0x08000000 ; + cs->exception_index =POWERPC_EXCP_DSI ; + env->error_code =0 ; + env->spr[SPR_DAR ] = eaddr; +if (access_type ==MMU_DATA_STORE ) { + env->spr[SPR_DSISR ] =0x0a000000 ; + }else { + env->spr[SPR_DSISR ] =0x08000000 ; + } } } -return 1 ; +return false; } - -tlb_set_page (cs, eaddr &TARGET_PAGE_MASK , - raddr &TARGET_PAGE_MASK , prot, mmu_idx, -TARGET_PAGE_SIZE ); -return 0 ; + *raddrp = raddr; +return true; } }
@@ -472,42 +483,38 @@ int ppc_hash32_handle_mmu_fault(PowerPCCPU *cpu, vaddr eaddr,/* 4. Handle direct store segments */ if (sr &SR32_T ) { -if (ppc_hash32_direct_store (cpu, sr, eaddr, access_type, - &raddr, &prot) ==0 ) { -tlb_set_page (cs, eaddr &TARGET_PAGE_MASK , - raddr &TARGET_PAGE_MASK , prot, mmu_idx, -TARGET_PAGE_SIZE ); -return 0 ; - }else { -return 1 ; - } +return ppc_hash32_direct_store (cpu, sr, eaddr, access_type, + raddrp, protp, guest_visible); }/* 5. Check for segment level no-execute violation */ if (access_type ==MMU_INST_FETCH && (sr &SR32_NX )) { - cs->exception_index =POWERPC_EXCP_ISI ; - env->error_code =0x10000000 ; -return 1 ; +if (guest_visible) { + cs->exception_index =POWERPC_EXCP_ISI ; + env->error_code =0x10000000 ; + } +return false; }/* 6. Locate the PTE in the hash table */ pte_offset =ppc_hash32_htab_lookup (cpu, sr, eaddr, &pte);if (pte_offset ==-1 ) { -if (access_type ==MMU_INST_FETCH ) { - cs->exception_index =POWERPC_EXCP_ISI ; - env->error_code =0x40000000 ; - }else { - cs->exception_index =POWERPC_EXCP_DSI ; - env->error_code =0 ; - env->spr[SPR_DAR ] = eaddr; -if (access_type ==MMU_DATA_STORE ) { - env->spr[SPR_DSISR ] =0x42000000 ; +if (guest_visible) { +if (access_type ==MMU_INST_FETCH ) { + cs->exception_index =POWERPC_EXCP_ISI ; + env->error_code =0x40000000 ; }else { - env->spr[SPR_DSISR ] =0x40000000 ; + cs->exception_index =POWERPC_EXCP_DSI ; + env->error_code =0 ; + env->spr[SPR_DAR ] = eaddr; +if (access_type ==MMU_DATA_STORE ) { + env->spr[SPR_DSISR ] =0x42000000 ; + }else { + env->spr[SPR_DSISR ] =0x40000000 ; + } } } - -return 1 ; +return false; }qemu_log_mask (CPU_LOG_MMU ,"found PTE at offset %08" HWADDR_PRIx"\n" , pte_offset);
@@ -519,20 +526,22 @@ int ppc_hash32_handle_mmu_fault(PowerPCCPU *cpu, vaddr eaddr,if (need_prot & ~prot) {/* Access right violation */ qemu_log_mask (CPU_LOG_MMU ,"PTE access rejected\n" ); -if (access_type ==MMU_INST_FETCH ) { - cs->exception_index =POWERPC_EXCP_ISI ; - env->error_code =0x08000000 ; - }else { - cs->exception_index =POWERPC_EXCP_DSI ; - env->error_code =0 ; - env->spr[SPR_DAR ] = eaddr; -if (access_type ==MMU_DATA_STORE ) { - env->spr[SPR_DSISR ] =0x0a000000 ; +if (guest_visible) { +if (access_type ==MMU_INST_FETCH ) { + cs->exception_index =POWERPC_EXCP_ISI ; + env->error_code =0x08000000 ; }else { - env->spr[SPR_DSISR ] =0x08000000 ; + cs->exception_index =POWERPC_EXCP_DSI ; + env->error_code =0 ; + env->spr[SPR_DAR ] = eaddr; +if (access_type ==MMU_DATA_STORE ) { + env->spr[SPR_DSISR ] =0x0a000000 ; + }else { + env->spr[SPR_DSISR ] =0x08000000 ; + } } } -return 1 ; +return false; }qemu_log_mask (CPU_LOG_MMU ,"PTE access granted !\n" );
@@ -556,45 +565,38 @@ int ppc_hash32_handle_mmu_fault(PowerPCCPU *cpu, vaddr eaddr,/* 9. Determine the real address from the PTE */ - raddr =ppc_hash32_pte_raddr (sr, pte, eaddr); - -tlb_set_page (cs, eaddr &TARGET_PAGE_MASK , raddr &TARGET_PAGE_MASK , - prot, mmu_idx,TARGET_PAGE_SIZE ); - -return 0 ; + *raddrp =ppc_hash32_pte_raddr (sr, pte, eaddr); + *protp = prot; +return true; } -hwaddr ppc_hash32_get_phys_page_debug (PowerPCCPU *cpu,target_ulong eaddr) +int ppc_hash32_handle_mmu_fault (PowerPCCPU *cpu,vaddr eaddr, +MMUAccessType access_type,int mmu_idx) { -CPUPPCState *env = &cpu->env; -target_ulong sr; -hwaddr pte_offset; -ppc_hash_pte32_t pte; -int prot; - -if (msr_dr ==0 ) { -/* Translation is off */ -return eaddr; - } +CPUState *cs =CPU (cpu); +int page_size, prot; +hwaddr raddr; -if (env->nb_BATs !=0 ) { -hwaddr raddr =ppc_hash32_bat_lookup (cpu, eaddr,0 , &prot); -if (raddr !=-1 ) { -return raddr; - } +/* Translate eaddr to raddr (where raddr is addr qemu needs for access) */ +if (!ppc_hash32_xlate (cpu, eaddr, access_type, &raddr, + &page_size, &prot, true)) { +return 1 ; } - sr = env->sr[eaddr >>28 ]; +tlb_set_page (cs, eaddr &TARGET_PAGE_MASK , raddr &TARGET_PAGE_MASK , + prot, mmu_idx,1UL << page_size); +return 0 ; +} -if (sr &SR32_T ) { -/* FIXME: Add suitable debug support for Direct Store segments */ -return -1 ; - } +hwaddr ppc_hash32_get_phys_page_debug (PowerPCCPU *cpu,target_ulong eaddr) +{ +int psize, prot; +hwaddr raddr; - pte_offset =ppc_hash32_htab_lookup (cpu, sr, eaddr, &pte); -if (pte_offset ==-1 ) { +if (!ppc_hash32_xlate (cpu, eaddr,MMU_DATA_LOAD , &raddr, + &psize, &prot, false)) {return -1 ; } -return ppc_hash32_pte_raddr (sr, pte, eaddr) &TARGET_PAGE_MASK ; +return raddr &TARGET_PAGE_MASK ; }
Signature · 1 line
2.31.1
[PULL 15/33] target/ppc: Fix compilation with DEBUG_BATS debug option
In reply to David GibsonFrom: Fabiano Rosas <[email protected]>
../target/ppc/mmu-hash32.c: In function 'ppc_hash32_bat_lookup':../target/ppc/mmu-hash32.c:204:13: error: 'BATu' undeclared (first use in this function);
204 | BATu = &BATut[i];
| ^~~~
| BATut
../target/ppc/mmu-hash32.c:205:13: error: 'BATl' undeclared (first use in this function);
205 | BATl = &BATlt[i];
| ^~~~
| BATlt
../target/ppc/mmu-hash32.c:206:13: error: 'BEPIu' undeclared (first use in this function)
206 | BEPIu = *BATu & BATU32_BEPIU;
| ^~~~~
../target/ppc/mmu-hash32.c:206:29: error: 'BATU32_BEPIU' undeclared (first use in this function);
206 | BEPIu = *BATu & BATU32_BEPIU;
| ^~~~~~~~~~~~
| BATU32_BEPI
../target/ppc/mmu-hash32.c:207:13: error: 'BEPIl' undeclared (first use in this function)
207 | BEPIl = *BATu & BATU32_BEPIL;
| ^~~~~
../target/ppc/mmu-hash32.c:207:29: error: 'BATU32_BEPIL' undeclared (first use in this function);
207 | BEPIl = *BATu & BATU32_BEPIL;
| ^~~~~~~~~~~~
| BATU32_BEPI
../target/ppc/mmu-hash32.c:208:13: error: 'bl' undeclared (first use in this function)
208 | bl = (*BATu & 0x00001FFC) << 15;
| ^~Message-Id: <[email protected]>
--- target/ppc/mmu-hash32.c | 5 ++++- target/ppc/mmu-hash32.h | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-)
target/ppc/mmu-hash32.c +4 -1
@@ -27,7 +27,7 @@#include "mmu-hash32.h" #include "exec/log.h" -/* #define DEBUG_BAT */ +/* #define DEBUG_BATS */ #ifdef DEBUG_BATS # define LOG_BATS (...) qemu_log_mask(CPU_LOG_MMU, __VA_ARGS__)
@@ -199,6 +199,9 @@ static hwaddr ppc_hash32_bat_lookup(PowerPCCPU *cpu, target_ulong ea,/* No hit */ #if defined(DEBUG_BATS )if (qemu_log_enabled ()) { +target_ulong *BATu, *BATl; +target_ulong BEPIl, BEPIu, bl; +LOG_BATS ("no BAT match for " TARGET_FMT_lx":\n" , ea);for (i =0 ; i <4 ; i++) { BATu = &BATut[i];
target/ppc/mmu-hash32.h +2 -0
@@ -22,6 +22,8 @@ bool ppc_hash32_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAccessType access_type,* Block Address Translation (BAT) definitions */ +#define BATU32_BEPIU 0xf0000000 +#define BATU32_BEPIL 0x0ffe0000#define BATU32_BEPI 0xfffe0000#define BATU32_BL 0x00001ffc#define BATU32_VS 0x00000002
Signature · 1 line
2.31.1
[PULL 21/33] docs/system: ppc: Update ppce500 documentation with eTSEC support
In reply to David GibsonFrom: Bin Meng <[email protected]>
This adds eTSEC support to the PowerPC ppce500 machine documentation.
--- docs/system/ppc/ppce500.rst | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
docs/system/ppc/ppce500.rst +9 -1
@@ -19,6 +19,7 @@ The ``ppce500`` machine supports the following devices: * Power-off functionality via one GPIO pin * 1 Freescale MPC8xxx PCI host controller * VirtIO devices via PCI bus +* 1 Freescale Enhanced Triple Speed Ethernet controller (eTSEC) Hardware configuration information ----------------------------------
@@ -121,7 +122,7 @@ To boot the 32-bit Linux kernel: Running U-Boot -------------- -U-Boot mainline v2021.04 release is tested at the time of writing. To build a +U-Boot mainline v2021.07 release is tested at the time of writing. To build a U-Boot mainline bootloader that can be booted by the ``ppce500`` machine, use the qemu-ppce500_defconfig with similar commands as described above for Linux:
@@ -154,3 +155,10 @@ interface at PCI address 0.1.0, but we can switch that to an e1000 NIC by: -display none -serial stdio \ -bios u-boot \ -nic tap,ifname=tap0,script=no,downscript=no,model=e1000 + +The QEMU ``ppce500`` machine can also dynamically instantiate an eTSEC device +if “-device eTSEC” is given to QEMU: + +.. code-block:: bash + + -netdev tap,ifname=tap0,script=no,downscript=no,id=net0 -device eTSEC,netdev=net0
Signature · 1 line
2.31.1
[PULL 08/33] target/ppc: Split out ppc_hash64_xlate
In reply to David GibsonFrom: Richard Henderson <[email protected]>
Mirror the interface of ppc_radix64_xlate, putting all of the logic for hash64 translation into a single function.
Message-Id: <[email protected]>
--- target/ppc/mmu-hash64.c | 125 +++++++++++++++++++--------------------- 1 file changed, 59 insertions(+), 66 deletions(-)
target/ppc/mmu-hash64.c +59 -66
@@ -873,8 +873,10 @@ static int build_vrma_slbe(PowerPCCPU *cpu, ppc_slb_t *slb)return -1 ; } -int ppc_hash64_handle_mmu_fault (PowerPCCPU *cpu,vaddr eaddr, -MMUAccessType access_type,int mmu_idx) +static bool ppc_hash64_xlate (PowerPCCPU *cpu,vaddr eaddr, +MMUAccessType access_type, +hwaddr *raddrp,int *psizep,int *protp, +bool guest_visible) {CPUState *cs =CPU (cpu);CPUPPCState *env = &cpu->env;
@@ -918,9 +920,11 @@ int ppc_hash64_handle_mmu_fault(PowerPCCPU *cpu, vaddr eaddr, slb = &vrma_slbe;if (build_vrma_slbe (cpu, slb) !=0 ) {/* Invalid VRMA setup, machine check */ - cs->exception_index =POWERPC_EXCP_MCHECK ; - env->error_code =0 ; -return 1 ; +if (guest_visible) { + cs->exception_index =POWERPC_EXCP_MCHECK ; + env->error_code =0 ; + } +return false; } goto skip_slb_search;
@@ -929,6 +933,9 @@ int ppc_hash64_handle_mmu_fault(PowerPCCPU *cpu, vaddr eaddr,/* Emulated old-style RMO mode, bounds check against RMLS */ if (raddr >= limit) { +if (!guest_visible) { +return false; + }switch (access_type) {case MMU_INST_FETCH :ppc_hash64_set_isi (cs,SRR1_PROTFAULT );
@@ -943,15 +950,16 @@ int ppc_hash64_handle_mmu_fault(PowerPCCPU *cpu, vaddr eaddr,default :g_assert_not_reached (); } -return 1 ; +return false; } raddr |= env->spr[SPR_RMOR ]; } -tlb_set_page (cs, eaddr &TARGET_PAGE_MASK , raddr &TARGET_PAGE_MASK , -PAGE_READ |PAGE_WRITE |PAGE_EXEC , mmu_idx, -TARGET_PAGE_SIZE ); -return 0 ; + + *raddrp = raddr; + *protp =PAGE_READ |PAGE_WRITE |PAGE_EXEC ; + *psizep =TARGET_PAGE_BITS ; +return true; }/* 2. Translation is on, so look up the SLB */
@@ -964,6 +972,9 @@ int ppc_hash64_handle_mmu_fault(PowerPCCPU *cpu, vaddr eaddr,exit (1 ); }/* Segment still not found, generate the appropriate interrupt */ +if (!guest_visible) { +return false; + }switch (access_type) {case MMU_INST_FETCH : cs->exception_index =POWERPC_EXCP_ISEG ;
@@ -978,20 +989,25 @@ int ppc_hash64_handle_mmu_fault(PowerPCCPU *cpu, vaddr eaddr,default :g_assert_not_reached (); } -return 1 ; +return false; } -skip_slb_search: + skip_slb_search:/* 3. Check for segment level no-execute violation */ if (access_type ==MMU_INST_FETCH && (slb->vsid &SLB_VSID_N )) { -ppc_hash64_set_isi (cs,SRR1_NOEXEC_GUARD ); -return 1 ; +if (guest_visible) { +ppc_hash64_set_isi (cs,SRR1_NOEXEC_GUARD ); + } +return false; }/* 4. Locate the PTE in the hash table */ ptex =ppc_hash64_htab_lookup (cpu, slb, eaddr, &pte, &apshift);if (ptex ==-1 ) { +if (!guest_visible) { +return false; + }switch (access_type) {case MMU_INST_FETCH :ppc_hash64_set_isi (cs,SRR1_NOPTE );
@@ -1005,7 +1021,7 @@ skip_slb_search:default :g_assert_not_reached (); } -return 1 ; +return false; }qemu_log_mask (CPU_LOG_MMU ,"found PTE at index %08" HWADDR_PRIx"\n" , ptex);
@@ -1021,6 +1037,9 @@ skip_slb_search:if (need_prot & ~prot) {/* Access right violation */ qemu_log_mask (CPU_LOG_MMU ,"PTE access rejected\n" ); +if (!guest_visible) { +return false; + }if (access_type ==MMU_INST_FETCH ) {int srr1 =0 ;if (PAGE_EXEC & ~exec_prot) {
@@ -1045,7 +1064,7 @@ skip_slb_search: }ppc_hash64_set_dsi (cs, eaddr, dsisr); } -return 1 ; +return false; }qemu_log_mask (CPU_LOG_MMU ,"PTE access granted !\n" );
@@ -1069,66 +1088,40 @@ skip_slb_search:/* 7. Determine the real address from the PTE */ - raddr =deposit64 (pte.pte1 &HPTE64_R_RPN ,0 , apshift, eaddr); - -tlb_set_page (cs, eaddr &TARGET_PAGE_MASK , raddr &TARGET_PAGE_MASK , - prot, mmu_idx,1ULL << apshift); - -return 0 ; + *raddrp =deposit64 (pte.pte1 &HPTE64_R_RPN ,0 , apshift, eaddr); + *protp = prot; + *psizep = apshift; +return true; } -hwaddr ppc_hash64_get_phys_page_debug (PowerPCCPU *cpu,target_ulong addr) +int ppc_hash64_handle_mmu_fault (PowerPCCPU *cpu,vaddr eaddr, +MMUAccessType access_type,int mmu_idx) { -CPUPPCState *env = &cpu->env; -ppc_slb_t vrma_slbe; -ppc_slb_t *slb; -hwaddr ptex, raddr; -ppc_hash_pte64_t pte; -unsigned apshift; +CPUState *cs =CPU (cpu); +int page_size, prot; +hwaddr raddr; -/* Handle real mode */ -if (msr_dr ==0 ) { -/* In real mode the top 4 effective address bits are ignored */ - raddr = addr &0x0FFFFFFFFFFFFFFFULL ; +if (!ppc_hash64_xlate (cpu, eaddr, access_type, &raddr, + &page_size, &prot, true)) { +return 1 ; + } -if (cpu->vhyp) { -/* -* In virtual hypervisor mode, there's nothing to do: -* EA == GPA == qemu guest address -*/ -return raddr; - }else if ((msr_hv || !env->has_hv_mode) && !(addr >>63 )) { -/* In HV mode, add HRMOR if top EA bit is clear */ -return raddr | env->spr[SPR_HRMOR ]; - }else if (ppc_hash64_use_vrma (env)) { -/* Emulated VRMA mode */ - slb = &vrma_slbe; -if (build_vrma_slbe (cpu, slb) !=0 ) { -return -1 ; - } - }else { -target_ulong limit =rmls_limit (cpu); +tlb_set_page (cs, eaddr &TARGET_PAGE_MASK , raddr &TARGET_PAGE_MASK , + prot, mmu_idx,1UL << page_size); +return 0 ; +} -/* Emulated old-style RMO mode, bounds check against RMLS */ -if (raddr >= limit) { -return -1 ; - } -return raddr | env->spr[SPR_RMOR ]; - } - }else { - slb =slb_lookup (cpu, addr); -if (!slb) { -return -1 ; - } - } +hwaddr ppc_hash64_get_phys_page_debug (PowerPCCPU *cpu,target_ulong eaddr) +{ +int psize, prot; +hwaddr raddr; - ptex =ppc_hash64_htab_lookup (cpu, slb, addr, &pte, &apshift); -if (ptex ==-1 ) { +if (!ppc_hash64_xlate (cpu, eaddr,MMU_DATA_LOAD , &raddr, + &psize, &prot, false)) {return -1 ; } -return deposit64 (pte.pte1 &HPTE64_R_RPN ,0 , apshift, addr) - &TARGET_PAGE_MASK ; +return raddr &TARGET_PAGE_MASK ; } void ppc_hash64_tlb_flush_hpte(PowerPCCPU *cpu, target_ulong ptex,
Signature · 1 line
2.31.1
[PULL 11/33] target/ppc: Introduce ppc_xlate
In reply to David GibsonFrom: Richard Henderson <[email protected]>
Create one common dispatch for all of the ppc_*_xlate functions. Use ppc64_v3_radix to directly dispatch between ppc_radix64_xlate and ppc_hash64_xlate.
Remove the separate *_handle_mmu_fault and *_get_phys_page_debug functions, using common code for ppc_cpu_tlb_fill and ppc_cpu_get_phys_page_debug.
Message-Id: <[email protected]>
--- target/ppc/mmu-book3s-v3.c | 19 ------- target/ppc/mmu-book3s-v3.h | 5 -- target/ppc/mmu-hash32.c | 38 ++------------ target/ppc/mmu-hash32.h | 6 +-- target/ppc/mmu-hash64.c | 37 ++------------ target/ppc/mmu-hash64.h | 6 +-- target/ppc/mmu-radix64.c | 38 ++------------ target/ppc/mmu-radix64.h | 6 +-- target/ppc/mmu_helper.c | 100 ++++++++++++++----------------------- 9 files changed, 55 insertions(+), 200 deletions(-)
target/ppc/mmu-book3s-v3.c +0 -19
@@ -23,25 +23,6 @@#include "mmu-book3s-v3.h" #include "mmu-radix64.h" -int ppc64_v3_handle_mmu_fault (PowerPCCPU *cpu,vaddr eaddr,int rwx, -int mmu_idx) -{ -if (ppc64_v3_radix (cpu)) {/* Guest uses radix */ -return ppc_radix64_handle_mmu_fault (cpu, eaddr, rwx, mmu_idx); - }else {/* Guest uses hash */ -return ppc_hash64_handle_mmu_fault (cpu, eaddr, rwx, mmu_idx); - } -} - -hwaddr ppc64_v3_get_phys_page_debug (PowerPCCPU *cpu,vaddr eaddr) -{ -if (ppc64_v3_radix (cpu)) { -return ppc_radix64_get_phys_page_debug (cpu, eaddr); - }else { -return ppc_hash64_get_phys_page_debug (cpu, eaddr); - } -} -bool ppc64_v3_get_pate (PowerPCCPU *cpu,target_ulong lpid,ppc_v3_pate_t *entry) {uint64_t patb = cpu->env.spr[SPR_PTCR ] &PTCR_PATB ;
target/ppc/mmu-book3s-v3.h +0 -5
@@ -67,11 +67,6 @@ static inline bool ppc64_v3_radix(PowerPCCPU *cpu)return !!(cpu->env.spr[SPR_LPCR ] &LPCR_HR ); } -hwaddr ppc64_v3_get_phys_page_debug (PowerPCCPU *cpu,vaddr eaddr); - -int ppc64_v3_handle_mmu_fault (PowerPCCPU *cpu,vaddr eaddr,int rwx, -int mmu_idx); -static inline hwaddr ppc_hash64_hpt_base (PowerPCCPU *cpu) {uint64_t base;
target/ppc/mmu-hash32.c +3 -35
@@ -424,10 +424,9 @@ static hwaddr ppc_hash32_pte_raddr(target_ulong sr, ppc_hash_pte32_t pte,return (rpn & ~mask) | (eaddr & mask); } -static bool ppc_hash32_xlate (PowerPCCPU *cpu,vaddr eaddr, -MMUAccessType access_type, -hwaddr *raddrp,int *psizep,int *protp, -bool guest_visible) +bool ppc_hash32_xlate (PowerPCCPU *cpu,vaddr eaddr,MMUAccessType access_type, +hwaddr *raddrp,int *psizep,int *protp, +bool guest_visible) {CPUState *cs =CPU (cpu);CPUPPCState *env = &cpu->env;
@@ -569,34 +568,3 @@ static bool ppc_hash32_xlate(PowerPCCPU *cpu, vaddr eaddr, *protp = prot;return true; } - -int ppc_hash32_handle_mmu_fault (PowerPCCPU *cpu,vaddr eaddr, -MMUAccessType access_type,int mmu_idx) -{ -CPUState *cs =CPU (cpu); -int page_size, prot; -hwaddr raddr; - -/* Translate eaddr to raddr (where raddr is addr qemu needs for access) */ -if (!ppc_hash32_xlate (cpu, eaddr, access_type, &raddr, - &page_size, &prot, true)) { -return 1 ; - } - -tlb_set_page (cs, eaddr &TARGET_PAGE_MASK , raddr &TARGET_PAGE_MASK , - prot, mmu_idx,1UL << page_size); -return 0 ; -} - -hwaddr ppc_hash32_get_phys_page_debug (PowerPCCPU *cpu,target_ulong eaddr) -{ -int psize, prot; -hwaddr raddr; - -if (!ppc_hash32_xlate (cpu, eaddr,MMU_DATA_LOAD , &raddr, - &psize, &prot, false)) { -return -1 ; - } - -return raddr &TARGET_PAGE_MASK ; -}
target/ppc/mmu-hash32.h +3 -3
@@ -4,9 +4,9 @@#ifndef CONFIG_USER_ONLY hwaddr get_pteg_offset32 (PowerPCCPU *cpu,hwaddr hash); -hwaddr ppc_hash32_get_phys_page_debug (PowerPCCPU *cpu,target_ulong addr); -int ppc_hash32_handle_mmu_fault (PowerPCCPU *cpu,vaddr address, -MMUAccessType access_type,int mmu_idx); +bool ppc_hash32_xlate (PowerPCCPU *cpu,vaddr eaddr,MMUAccessType access_type, +hwaddr *raddrp,int *psizep,int *protp, +bool guest_visible);/* * Segment register definitions
target/ppc/mmu-hash64.c +3 -34
@@ -873,10 +873,9 @@ static int build_vrma_slbe(PowerPCCPU *cpu, ppc_slb_t *slb)return -1 ; } -static bool ppc_hash64_xlate (PowerPCCPU *cpu,vaddr eaddr, -MMUAccessType access_type, -hwaddr *raddrp,int *psizep,int *protp, -bool guest_visible) +bool ppc_hash64_xlate (PowerPCCPU *cpu,vaddr eaddr,MMUAccessType access_type, +hwaddr *raddrp,int *psizep,int *protp, +bool guest_visible) {CPUState *cs =CPU (cpu);CPUPPCState *env = &cpu->env;
@@ -1094,36 +1093,6 @@ static bool ppc_hash64_xlate(PowerPCCPU *cpu, vaddr eaddr,return true; } -int ppc_hash64_handle_mmu_fault (PowerPCCPU *cpu,vaddr eaddr, -MMUAccessType access_type,int mmu_idx) -{ -CPUState *cs =CPU (cpu); -int page_size, prot; -hwaddr raddr; - -if (!ppc_hash64_xlate (cpu, eaddr, access_type, &raddr, - &page_size, &prot, true)) { -return 1 ; - } - -tlb_set_page (cs, eaddr &TARGET_PAGE_MASK , raddr &TARGET_PAGE_MASK , - prot, mmu_idx,1UL << page_size); -return 0 ; -} - -hwaddr ppc_hash64_get_phys_page_debug (PowerPCCPU *cpu,target_ulong eaddr) -{ -int psize, prot; -hwaddr raddr; - -if (!ppc_hash64_xlate (cpu, eaddr,MMU_DATA_LOAD , &raddr, - &psize, &prot, false)) { -return -1 ; - } - -return raddr &TARGET_PAGE_MASK ; -} -void ppc_hash64_tlb_flush_hpte (PowerPCCPU *cpu,target_ulong ptex,target_ulong pte0,target_ulong pte1) {
target/ppc/mmu-hash64.h +3 -3
@@ -7,9 +7,9 @@void dump_slb (PowerPCCPU *cpu);int ppc_store_slb (PowerPCCPU *cpu,target_ulong slot,target_ulong esid,target_ulong vsid); -hwaddr ppc_hash64_get_phys_page_debug (PowerPCCPU *cpu,target_ulong addr); -int ppc_hash64_handle_mmu_fault (PowerPCCPU *cpu,vaddr address, -MMUAccessType access_type,int mmu_idx); +bool ppc_hash64_xlate (PowerPCCPU *cpu,vaddr eaddr,MMUAccessType access_type, +hwaddr *raddrp,int *psizep,int *protp, +bool guest_visible);void ppc_hash64_tlb_flush_hpte (PowerPCCPU *cpu,target_ulong pte_index,target_ulong pte0,target_ulong pte1);
target/ppc/mmu-radix64.c +3 -35
@@ -463,10 +463,9 @@ static int ppc_radix64_process_scoped_xlate(PowerPCCPU *cpu,* | = On | Process Scoped | Scoped | * +-------------+----------------+---------------+ */ -static bool ppc_radix64_xlate (PowerPCCPU *cpu,vaddr eaddr, -MMUAccessType access_type, -hwaddr *raddr,int *psizep,int *protp, -bool guest_visible) +bool ppc_radix64_xlate (PowerPCCPU *cpu,vaddr eaddr,MMUAccessType access_type, +hwaddr *raddr,int *psizep,int *protp, +bool guest_visible) {CPUPPCState *env = &cpu->env;uint64_t lpid, pid;
@@ -584,34 +583,3 @@ static bool ppc_radix64_xlate(PowerPCCPU *cpu, vaddr eaddr,return true; } - -int ppc_radix64_handle_mmu_fault (PowerPCCPU *cpu,vaddr eaddr, -MMUAccessType access_type,int mmu_idx) -{ -CPUState *cs =CPU (cpu); -int page_size, prot; -hwaddr raddr; - -/* Translate eaddr to raddr (where raddr is addr qemu needs for access) */ -if (!ppc_radix64_xlate (cpu, eaddr, access_type, &raddr, - &page_size, &prot, true)) { -return 1 ; - } - -tlb_set_page (cs, eaddr &TARGET_PAGE_MASK , raddr &TARGET_PAGE_MASK , - prot, mmu_idx,1UL << page_size); -return 0 ; -} - -hwaddr ppc_radix64_get_phys_page_debug (PowerPCCPU *cpu,target_ulong eaddr) -{ -int psize, prot; -hwaddr raddr; - -if (!ppc_radix64_xlate (cpu, eaddr,MMU_DATA_LOAD , &raddr, - &psize, &prot, false)) { -return -1 ; - } - -return raddr &TARGET_PAGE_MASK ; -}
target/ppc/mmu-radix64.h +3 -3
@@ -44,9 +44,9 @@#ifdef TARGET_PPC64 -int ppc_radix64_handle_mmu_fault (PowerPCCPU *cpu,vaddr eaddr, -MMUAccessType access_type,int mmu_idx); -hwaddr ppc_radix64_get_phys_page_debug (PowerPCCPU *cpu,target_ulong addr); +bool ppc_radix64_xlate (PowerPCCPU *cpu,vaddr eaddr,MMUAccessType access_type, +hwaddr *raddr,int *psizep,int *protp, +bool guest_visible);static inline int ppc_radix64_get_prot_eaa (uint64_t pte) {
target/ppc/mmu_helper.c +37 -63
135 lines not on this page · raw message
Signature · 1 line
2.31.1
[PULL 18/33] target/ppc: introduce mmu-books.h
In reply to David GibsonFrom: "Bruno Larsen (billionai)" <[email protected]>
Intrudoce a header common to all BookS MMUs, that can hold code that is common to hash32 and book3s-v3 MMUs.
Message-Id: <[email protected]>
--- target/ppc/mmu-book3s-v3.h | 14 +------------- target/ppc/mmu-books.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 13 deletions(-) create mode 100644 target/ppc/mmu-books.h
target/ppc/mmu-book3s-v3.h +1 -13
@@ -21,6 +21,7 @@#define PPC_MMU_BOOK3S_V3_H #include "mmu-hash64.h" +#include "mmu-books.h" #ifndef CONFIG_USER_ONLY
@@ -47,19 +48,6 @@ struct prtb_entry {uint64_t prtbe0, prtbe1; }; -/* -* These correspond to the mmu_idx values computed in -* hreg_compute_hflags_value. See the tables therein -* -* They are here because some bits are inverted for BookE MMUs -* not necessarily because they only work for BookS. However, -* we only needed to change BookS MMUs, we left the functions -* here to avoid other possible bugs for untested MMUs -*/ -static inline bool mmuidx_pr (int idx) {return !(idx &1 ); } -static inline bool mmuidx_real (int idx) {return idx &2 ; } -static inline bool mmuidx_hv (int idx) {return idx &4 ; } -#ifdef TARGET_PPC64 static inline bool ppc64_use_proc_tbl (PowerPCCPU *cpu)
target/ppc/mmu-books.h new file +30 -0
@@ -0,0 +1,30 @@ +/* +* PowerPC BookS emulation generic mmu definitions for qemu. +* +* Copyright (c) 2021 Instituto de Pesquisas Eldorado (eldorado.org.br) +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef PPC_MMU_BOOKS_H +#define PPC_MMU_BOOKS_H + +/* +* These correspond to the mmu_idx values computed in +* hreg_compute_hflags_value. See the tables therein +*/ +static inline bool mmuidx_pr (int idx) {return !(idx &1 ); } +static inline bool mmuidx_real (int idx) {return idx &2 ; } +static inline bool mmuidx_hv (int idx) {return idx &4 ; } +#endif /* PPC_MMU_BOOKS_H */
Signature · 1 line
2.31.1
[PULL 16/33] target/ppc: fix address translation bug for radix mmus
In reply to David GibsonFrom: "Bruno Larsen (billionai)" <[email protected]>
This commit attempts to fix a technical hiccup first mentioned by Richard Henderson in
https://lists.nongnu.org/archive/html/qemu-devel/2021-05/msg06247.html
To sumarize the hiccup here, when radix-style mmus are translating an address, they might need to call a second level of translation, with hypervisor privileges. However, the way it was being done up until this point meant that the second level translation had the same privileges as the first level. It could lead to a bug in address translation when running KVM inside a TCG guest, but this bug was never experienced by users, so this isn't as much a bug fix as it is a correctness cleanup.
This patch attempts that cleanup by making radix64_*_xlate functions receive the mmu_idx, and passing one with the correct permission for the second level translation.
The mmuidx macros added by this patch are only correct for non-bookE mmus, because BookE style set the IS and DS bits inverted and there might be other subtle differences. However, there doesn't seem to be BookE cpus that have radix-style mmus, so we left a comment there to document the issue, in case a machine does have that and was missed.
As part of this cleanup, we now need to send the correct mmmu_idx when calling get_phys_page_debug, otherwise we might not be able to see the memory that the CPU could
Message-Id: <[email protected]>
--- target/ppc/mmu-book3s-v3.h | 13 +++++++++++++ target/ppc/mmu-radix64.c | 37 +++++++++++++++++++++---------------- target/ppc/mmu-radix64.h | 2 +- target/ppc/mmu_helper.c | 8 +++++--- 4 files changed, 40 insertions(+), 20 deletions(-)
target/ppc/mmu-book3s-v3.h +13 -0
@@ -47,6 +47,19 @@ struct prtb_entry {uint64_t prtbe0, prtbe1; }; +/* +* These correspond to the mmu_idx values computed in +* hreg_compute_hflags_value. See the tables therein +* +* They are here because some bits are inverted for BookE MMUs +* not necessarily because they only work for BookS. However, +* we only needed to change BookS MMUs, we left the functions +* here to avoid other possible bugs for untested MMUs +*/ +static inline bool mmuidx_pr (int idx) {return !(idx &1 ); } +static inline bool mmuidx_real (int idx) {return idx &2 ; } +static inline bool mmuidx_hv (int idx) {return idx &4 ; } +#ifdef TARGET_PPC64 static inline bool ppc64_use_proc_tbl (PowerPCCPU *cpu)
target/ppc/mmu-radix64.c +21 -16
@@ -155,7 +155,7 @@ static void ppc_radix64_raise_hsi(PowerPCCPU *cpu, MMUAccessType access_type,static bool ppc_radix64_check_prot (PowerPCCPU *cpu,MMUAccessType access_type,uint64_t pte,int *fault_cause,int *prot, -bool partition_scoped) +int mmu_idx,bool partition_scoped) {CPUPPCState *env = &cpu->env;int need_prot;
@@ -173,7 +173,8 @@ static bool ppc_radix64_check_prot(PowerPCCPU *cpu, MMUAccessType access_type,/* Determine permissions allowed by Encoded Access Authority */ if (!partition_scoped && (pte &R_PTE_EAA_PRIV ) && msr_pr) { *prot =0 ; - }else if (msr_pr || (pte &R_PTE_EAA_PRIV ) || partition_scoped) { + }else if (mmuidx_pr (mmu_idx) || (pte &R_PTE_EAA_PRIV ) || + partition_scoped) { *prot =ppc_radix64_get_prot_eaa (pte); }else {/* !msr_pr && !(pte & R_PTE_EAA_PRIV) && !partition_scoped */ *prot =ppc_radix64_get_prot_eaa (pte);
@@ -299,7 +300,7 @@ static int ppc_radix64_partition_scoped_xlate(PowerPCCPU *cpu,ppc_v3_pate_t pate, hwaddr *h_raddr, int *h_prot, int *h_page_size, bool pde_addr, - bool guest_visible) + int mmu_idx, bool guest_visible) { int fault_cause = 0;hwaddr pte_addr;
@@ -310,7 +311,8 @@ static int ppc_radix64_partition_scoped_xlate(PowerPCCPU *cpu,if (ppc_radix64_walk_tree (CPU (cpu)->as, g_raddr, pate.dw0 &PRTBE_R_RPDB , pate.dw0 &PRTBE_R_RPDS , h_raddr, h_page_size, &pte, &fault_cause, &pte_addr) || -ppc_radix64_check_prot (cpu, access_type, pte, &fault_cause, h_prot, true)) { +ppc_radix64_check_prot (cpu, access_type, pte, + &fault_cause, h_prot, mmu_idx, true)) {if (pde_addr) {/* address being translated was that of a guest pde */ fault_cause |=DSISR_PRTABLE_FAULT ; }
@@ -332,7 +334,7 @@ static int ppc_radix64_process_scoped_xlate(PowerPCCPU *cpu, vaddr eaddr, uint64_t pid, ppc_v3_pate_t pate, hwaddr *g_raddr, int *g_prot, int *g_page_size, - bool guest_visible) + int mmu_idx, bool guest_visible) { CPUState *cs = CPU(cpu);CPUPPCState *env = &cpu->env;
@@ -367,7 +369,8 @@ static int ppc_radix64_process_scoped_xlate(PowerPCCPU *cpu, ret =ppc_radix64_partition_scoped_xlate (cpu,0 , eaddr, prtbe_addr, pate, &h_raddr, &h_prot, &h_page_size, true, - guest_visible); +/* mmu_idx is 5 because we're translating from hypervisor scope */ +5 , guest_visible);if (ret) {return ret; }
@@ -407,7 +410,8 @@ static int ppc_radix64_process_scoped_xlate(PowerPCCPU *cpu, ret =ppc_radix64_partition_scoped_xlate (cpu,0 , eaddr, pte_addr, pate, &h_raddr, &h_prot, &h_page_size, true, - guest_visible); +/* mmu_idx is 5 because we're translating from hypervisor scope */ +5 , guest_visible);if (ret) {return ret; }
@@ -431,7 +435,8 @@ static int ppc_radix64_process_scoped_xlate(PowerPCCPU *cpu, *g_raddr = (rpn & ~mask) | (eaddr & mask); } -if (ppc_radix64_check_prot (cpu, access_type, pte, &fault_cause, g_prot, false)) { +if (ppc_radix64_check_prot (cpu, access_type, pte, &fault_cause, + g_prot, mmu_idx, false)) {/* Access denied due to protection */ if (guest_visible) {ppc_radix64_raise_si (cpu, access_type, eaddr, fault_cause);
@@ -464,7 +469,7 @@ static int ppc_radix64_process_scoped_xlate(PowerPCCPU *cpu,* +-------------+----------------+---------------+ */ bool ppc_radix64_xlate (PowerPCCPU *cpu,vaddr eaddr,MMUAccessType access_type, -hwaddr *raddr,int *psizep,int *protp, +hwaddr *raddr,int *psizep,int *protp,int mmu_idx,bool guest_visible) {CPUPPCState *env = &cpu->env;
@@ -474,17 +479,17 @@ bool ppc_radix64_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAccessType access_type,hwaddr g_raddr;bool relocation; -assert (!(msr_hv && cpu->vhyp)); +assert (!(mmuidx_hv (mmu_idx) && cpu->vhyp)); - relocation = (access_type ==MMU_INST_FETCH ? msr_ir : msr_dr); + relocation = !mmuidx_real (mmu_idx);/* HV or virtual hypervisor Real Mode Access */ -if (!relocation && (msr_hv || cpu->vhyp)) { +if (!relocation && (mmuidx_hv (mmu_idx) || cpu->vhyp)) {/* In real mode top 4 effective addr bits (mostly) ignored */ *raddr = eaddr &0x0FFFFFFFFFFFFFFFULL ;/* In HV mode, add HRMOR if top EA bit is clear */ -if (msr_hv || !env->has_hv_mode) { +if (mmuidx_hv (mmu_idx) || !env->has_hv_mode) {if (!(eaddr >>63 )) { *raddr |= env->spr[SPR_HRMOR ]; }
@@ -546,7 +551,7 @@ bool ppc_radix64_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAccessType access_type,if (relocation) {int ret =ppc_radix64_process_scoped_xlate (cpu, access_type, eaddr, pid, pate, &g_raddr, &prot, - &psize, guest_visible); + &psize, mmu_idx, guest_visible);if (ret) {return false; }
@@ -564,13 +569,13 @@ bool ppc_radix64_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAccessType access_type,* quadrants 1 or 2. Translates a guest real address to a host * real address. */ -if (lpid || !msr_hv) { +if (lpid || !mmuidx_hv (mmu_idx)) {int ret; ret =ppc_radix64_partition_scoped_xlate (cpu, access_type, eaddr, g_raddr, pate, raddr, &prot, &psize, false, - guest_visible); + mmu_idx, guest_visible);if (ret) {return false; }
target/ppc/mmu-radix64.h +1 -1
@@ -45,7 +45,7 @@#ifdef TARGET_PPC64 bool ppc_radix64_xlate (PowerPCCPU *cpu,vaddr eaddr,MMUAccessType access_type, -hwaddr *raddr,int *psizep,int *protp, +hwaddr *raddr,int *psizep,int *protp,int mmu_idx,bool guest_visible);static inline int ppc_radix64_get_prot_eaa (uint64_t pte)
target/ppc/mmu_helper.c +5 -3
@@ -2900,7 +2900,7 @@ static bool ppc_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAccessType access_type,case POWERPC_MMU_3_00 :if (ppc64_v3_radix (cpu)) {return ppc_radix64_xlate (cpu, eaddr, access_type, - raddrp, psizep, protp, guest_visible); + raddrp, psizep, protp, mmu_idx, guest_visible); }/* fall through */ case POWERPC_MMU_64B :
@@ -2933,8 +2933,10 @@ hwaddr ppc_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)* try an MMU_DATA_LOAD, we may not be able to read instructions * mapped by code TLBs, so we also try a MMU_INST_FETCH. */ -if (ppc_xlate (cpu, addr,MMU_DATA_LOAD , &raddr, &s, &p,0 , false) || -ppc_xlate (cpu, addr,MMU_INST_FETCH , &raddr, &s, &p,0 , false)) { +if (ppc_xlate (cpu, addr,MMU_DATA_LOAD , &raddr, &s, &p, +cpu_mmu_index (&cpu->env, false), false) || +ppc_xlate (cpu, addr,MMU_INST_FETCH , &raddr, &s, &p, +cpu_mmu_index (&cpu->env, true), false)) {return raddr &TARGET_PAGE_MASK ; }return -1 ;
Signature · 1 line
2.31.1
[PULL 12/33] target/ppc: Restrict ppc_cpu_tlb_fill to TCG
In reply to David GibsonFrom: Richard Henderson <[email protected]>
This function is used by TCGCPUOps, and is thus TCG specific.
Message-Id: <[email protected]>
--- target/ppc/mmu_helper.c | 2 ++ 1 file changed, 2 insertions(+)
target/ppc/mmu_helper.c +2 -0
@@ -2948,6 +2948,7 @@ hwaddr ppc_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)return -1 ; } +#ifdef CONFIG_TCG bool ppc_cpu_tlb_fill (CPUState *cs,vaddr eaddr,int size,MMUAccessType access_type,int mmu_idx,bool probe,uintptr_t retaddr)
@@ -2968,3 +2969,4 @@ bool ppc_cpu_tlb_fill(CPUState *cs, vaddr eaddr, int size,raise_exception_err_ra (&cpu->env, cs->exception_index, cpu->env.error_code, retaddr); } +#endif
Signature · 1 line
2.31.1
[PULL 17/33] target/ppc: changed ppc_hash64_xlate to use mmu_idx
In reply to David GibsonFrom: "Bruno Larsen (billionai)" <[email protected]>
Changed hash64 address translation to use the supplied mmu_idx instead of using the one stored in the msr, for parity purposes (other book3s MMUs already use it).
Message-Id: <[email protected]>
--- target/ppc/mmu-hash64.c | 43 ++++++++++++++++++++--------------------- target/ppc/mmu-hash64.h | 2 +- target/ppc/mmu_helper.c | 2 +- 3 files changed, 23 insertions(+), 24 deletions(-)
target/ppc/mmu-hash64.c +21 -22
@@ -366,10 +366,9 @@ static inline int ppc_hash64_pte_noexec_guard(PowerPCCPU *cpu, }/* Check Basic Storage Protection */ -static int ppc_hash64_pte_prot (PowerPCCPU *cpu, +static int ppc_hash64_pte_prot (int mmu_idx,ppc_slb_t *slb,ppc_hash_pte64_t pte) { -CPUPPCState *env = &cpu->env;unsigned pp, key;/* * Some pp bit combinations have undefined behaviour, so default
@@ -377,7 +376,7 @@ static int ppc_hash64_pte_prot(PowerPCCPU *cpu,*/ int prot =0 ; - key = !!(msr_pr ? (slb->vsid &SLB_VSID_KP ) + key = !!(mmuidx_pr (mmu_idx) ? (slb->vsid &SLB_VSID_KP ) : (slb->vsid &SLB_VSID_KS )); pp = (pte.pte1 &HPTE64_R_PP ) | ((pte.pte1 &HPTE64_R_PP0 ) >>61 );
@@ -744,17 +743,17 @@ static bool ppc_hash64_use_vrma(CPUPPCState *env) } } -static void ppc_hash64_set_isi (CPUState *cs,uint64_t error_code) +static void ppc_hash64_set_isi (CPUState *cs,int mmu_idx,uint64_t error_code) {CPUPPCState *env = &POWERPC_CPU (cs)->env;bool vpm; -if (msr_ir) { +if (!mmuidx_real (mmu_idx)) { vpm = !!(env->spr[SPR_LPCR ] &LPCR_VPM1 ); }else { vpm =ppc_hash64_use_vrma (env); } -if (vpm && !msr_hv) { +if (vpm && !mmuidx_hv (mmu_idx)) { cs->exception_index =POWERPC_EXCP_HISI ; }else { cs->exception_index =POWERPC_EXCP_ISI ;
@@ -762,17 +761,17 @@ static void ppc_hash64_set_isi(CPUState *cs, uint64_t error_code) env->error_code = error_code; } -static void ppc_hash64_set_dsi (CPUState *cs,uint64_t dar,uint64_t dsisr) +static void ppc_hash64_set_dsi (CPUState *cs,int mmu_idx,uint64_t dar,uint64_t dsisr) {CPUPPCState *env = &POWERPC_CPU (cs)->env;bool vpm; -if (msr_dr) { +if (!mmuidx_real (mmu_idx)) { vpm = !!(env->spr[SPR_LPCR ] &LPCR_VPM1 ); }else { vpm =ppc_hash64_use_vrma (env); } -if (vpm && !msr_hv) { +if (vpm && !mmuidx_hv (mmu_idx)) { cs->exception_index =POWERPC_EXCP_HDSI ; env->spr[SPR_HDAR ] = dar; env->spr[SPR_HDSISR ] = dsisr;
@@ -874,7 +873,7 @@ static int build_vrma_slbe(PowerPCCPU *cpu, ppc_slb_t *slb) }bool ppc_hash64_xlate (PowerPCCPU *cpu,vaddr eaddr,MMUAccessType access_type, -hwaddr *raddrp,int *psizep,int *protp, +hwaddr *raddrp,int *psizep,int *protp,int mmu_idx,bool guest_visible) {CPUState *cs =CPU (cpu);
@@ -897,7 +896,7 @@ bool ppc_hash64_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAccessType access_type,*/ /* 1. Handle real mode accesses */ -if (access_type ==MMU_INST_FETCH ? !msr_ir : !msr_dr) { +if (mmuidx_real (mmu_idx)) {/* * Translation is supposedly "off", but in real mode the top 4 * effective address bits are (mostly) ignored
@@ -909,7 +908,7 @@ bool ppc_hash64_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAccessType access_type,* In virtual hypervisor mode, there's nothing to do: * EA == GPA == qemu guest address */ - }else if (msr_hv || !env->has_hv_mode) { + }else if (mmuidx_hv (mmu_idx) || !env->has_hv_mode) {/* In HV mode, add HRMOR if top EA bit is clear */ if (!(eaddr >>63 )) { raddr |= env->spr[SPR_HRMOR ];
@@ -937,13 +936,13 @@ bool ppc_hash64_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAccessType access_type, }switch (access_type) {case MMU_INST_FETCH : -ppc_hash64_set_isi (cs,SRR1_PROTFAULT ); +ppc_hash64_set_isi (cs, mmu_idx,SRR1_PROTFAULT );break ;case MMU_DATA_LOAD : -ppc_hash64_set_dsi (cs, eaddr,DSISR_PROTFAULT ); +ppc_hash64_set_dsi (cs, mmu_idx, eaddr,DSISR_PROTFAULT );break ;case MMU_DATA_STORE : -ppc_hash64_set_dsi (cs, eaddr, +ppc_hash64_set_dsi (cs, mmu_idx, eaddr,DSISR_PROTFAULT |DSISR_ISSTORE );break ;default :
@@ -996,7 +995,7 @@ bool ppc_hash64_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAccessType access_type,/* 3. Check for segment level no-execute violation */ if (access_type ==MMU_INST_FETCH && (slb->vsid &SLB_VSID_N )) {if (guest_visible) { -ppc_hash64_set_isi (cs,SRR1_NOEXEC_GUARD ); +ppc_hash64_set_isi (cs, mmu_idx,SRR1_NOEXEC_GUARD ); }return false; }
@@ -1009,13 +1008,13 @@ bool ppc_hash64_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAccessType access_type, }switch (access_type) {case MMU_INST_FETCH : -ppc_hash64_set_isi (cs,SRR1_NOPTE ); +ppc_hash64_set_isi (cs, mmu_idx,SRR1_NOPTE );break ;case MMU_DATA_LOAD : -ppc_hash64_set_dsi (cs, eaddr,DSISR_NOPTE ); +ppc_hash64_set_dsi (cs, mmu_idx, eaddr,DSISR_NOPTE );break ;case MMU_DATA_STORE : -ppc_hash64_set_dsi (cs, eaddr,DSISR_NOPTE |DSISR_ISSTORE ); +ppc_hash64_set_dsi (cs, mmu_idx, eaddr,DSISR_NOPTE |DSISR_ISSTORE );break ;default :g_assert_not_reached ();
@@ -1028,7 +1027,7 @@ bool ppc_hash64_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAccessType access_type,/* 5. Check access permissions */ exec_prot =ppc_hash64_pte_noexec_guard (cpu, pte); - pp_prot =ppc_hash64_pte_prot (cpu, slb, pte); + pp_prot =ppc_hash64_pte_prot (mmu_idx, slb, pte); amr_prot =ppc_hash64_amr_prot (cpu, pte); prot = exec_prot & pp_prot & amr_prot;
@@ -1049,7 +1048,7 @@ bool ppc_hash64_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAccessType access_type,if (PAGE_EXEC & ~amr_prot) { srr1 |=SRR1_IAMR ;/* Access violates virt pg class key prot */ } -ppc_hash64_set_isi (cs, srr1); +ppc_hash64_set_isi (cs, mmu_idx, srr1); }else {int dsisr =0 ;if (need_prot & ~pp_prot) {
@@ -1061,7 +1060,7 @@ bool ppc_hash64_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAccessType access_type,if (need_prot & ~amr_prot) { dsisr |=DSISR_AMR ; } -ppc_hash64_set_dsi (cs, eaddr, dsisr); +ppc_hash64_set_dsi (cs, mmu_idx, eaddr, dsisr); }return false; }
target/ppc/mmu-hash64.h +1 -1
@@ -8,7 +8,7 @@ void dump_slb(PowerPCCPU *cpu);int ppc_store_slb (PowerPCCPU *cpu,target_ulong slot,target_ulong esid,target_ulong vsid);bool ppc_hash64_xlate (PowerPCCPU *cpu,vaddr eaddr,MMUAccessType access_type, -hwaddr *raddrp,int *psizep,int *protp, +hwaddr *raddrp,int *psizep,int *protp,int mmu_idx,bool guest_visible); void ppc_hash64_tlb_flush_hpte(PowerPCCPU *cpu, target_ulong pte_index,
target/ppc/mmu_helper.c +1 -1
@@ -2908,7 +2908,7 @@ static bool ppc_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAccessType access_type,case POWERPC_MMU_2_06 :case POWERPC_MMU_2_07 :return ppc_hash64_xlate (cpu, eaddr, access_type, - raddrp, psizep, protp, guest_visible); + raddrp, psizep, protp, mmu_idx, guest_visible);#endif case POWERPC_MMU_32B :
Signature · 1 line
2.31.1
[PULL 25/33] target/ppc: Allow virtual hypervisor on CPU without HV
In reply to David GibsonFrom: BALATON Zoltan <[email protected]>
Change the assert in ppc_store_sdr1() to allow vhyp to be set on CPUs without HV bit. This allows using the vhyp interface for firmware emulation on pegasos2.
Message-Id: <21c7745aabbb68fcc50bb2ffaf16b939ba21261c.1624811233.git.balaton@eik.bme.hu>
--- target/ppc/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/ppc/cpu.c +1 -1
@@ -72,7 +72,7 @@ void ppc_store_sdr1(CPUPPCState *env, target_ulong value) {PowerPCCPU *cpu =env_archcpu (env);qemu_log_mask (CPU_LOG_MMU ,"%s: " TARGET_FMT_lx"\n" , __func__, value); -assert (!cpu->vhyp); +assert (!cpu->env.has_hv_mode || !cpu->vhyp);#if defined(TARGET_PPC64 )if (mmu_is_64bit (env->mmu_model)) {target_ulong sdr_mask =SDR_64_HTABORG |SDR_64_HTABSIZE ;
Signature · 1 line
2.31.1
[PULL 22/33] spapr: Implement Open Firmware client interface
In reply to David GibsonFrom: Alexey Kardashevskiy <[email protected]>
The PAPR platform describes an OS environment that's presented by a combination of a hypervisor and firmware. The features it specifies require collaboration between the firmware and the hypervisor.
Since the beginning, the runtime component of the firmware (RTAS) has been implemented as a 20 byte shim which simply forwards it to a hypercall implemented in qemu. The boot time firmware component is SLOF - but a build that's specific to qemu, and has always needed to be updated in sync with it. Even though we've managed to limit the amount of runtime communication we need between qemu and SLOF, there's some, and it has become increasingly awkward to handle as we've implemented new features.
This implements a boot time OF client interface (CI) which is enabled by a new "x-vof" pseries machine option (stands for "Virtual Open Firmware). When enabled, QEMU implements the custom H_OF_CLIENT hcall which implements Open Firmware Client Interface (OF CI). This allows using a smaller stateless firmware which does not have to manage the device tree.
The new "vof.bin" firmware image is included with source code under pc-bios/. It also includes RTAS blob.
This implements a handful of CI methods just to get -kernel/-initrd working. In particular, this implements the device tree fetching and simple memory allocator - "claim" (an OF CI memory allocator) and updates "/memory@0/available" to report the client about available memory.
This implements changing some device tree properties which we know how to deal with, the rest is ignored. To allow changes, this skips fdt_pack() when x-vof=on as not packing the blob leaves some room for appending.
In absence of SLOF, this assigns phandles to device tree nodes to make device tree traversing work.
When x-vof=on, this adds "/chosen" every time QEMU (re)builds a tree.
This adds basic instances support which are managed by a hash map ihandle -> [phandle].
Before the guest started, the used memory is:
0..e60 - the initial firmware
8000..10000 - stack
400000.. - kernel
3ea0000.. - initramdisk
This OF CI does not implement "interpret".
Unlike SLOF, this does not format uninitialized nvram. Instead, this includes a disk image with pre-formatted nvram.
With this basic support, this can only boot into kernel directly. However this is just enough for the petitboot kernel and initradmdisk to boot from any possible source. Note this requires reasonably recent guest kernel with:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=df5be5be8735
The immediate benefit is much faster booting time which especially crucial with fully emulated early CPU bring up environments. Also this may come handy when/if GRUB-in-the-userspace sees light of the day.
This separates VOF and sPAPR in a hope that VOF bits may be reused by other POWERPC boards which do not support pSeries.
This assumes potential support for booting from QEMU backends such as blockdev or netdev without devices/drivers used.
Message-Id: <[email protected]>
[dwg: Adjusted some includes which broke compile in some more obscure
compilation setups]
--- MAINTAINERS | 12 + hw/ppc/Kconfig | 4 + hw/ppc/meson.build | 3 + hw/ppc/spapr.c | 67 ++- hw/ppc/spapr_hcall.c | 25 +- hw/ppc/spapr_vof.c | 153 ++++++ hw/ppc/trace-events | 24 + hw/ppc/vof.c | 1049 +++++++++++++++++++++++++++++++++++++++ include/hw/ppc/spapr.h | 19 +- include/hw/ppc/vof.h | 58 +++ pc-bios/README | 4 + pc-bios/vof-nvram.bin | Bin 0 -> 16384 bytes pc-bios/vof.bin | Bin 0 -> 3784 bytes pc-bios/vof/Makefile | 23 + pc-bios/vof/bootmem.c | 14 + pc-bios/vof/ci.c | 91 ++++ pc-bios/vof/entry.S | 49 ++ pc-bios/vof/libc.c | 92 ++++ pc-bios/vof/main.c | 21 + pc-bios/vof/vof.h | 43 ++ pc-bios/vof/vof.lds | 48 ++ tests/qtest/rtas-test.c | 15 +- 22 files changed, 1801 insertions(+), 13 deletions(-) create mode 100644 hw/ppc/spapr_vof.c create mode 100644 hw/ppc/vof.c create mode 100644 include/hw/ppc/vof.h create mode 100644 pc-bios/vof-nvram.bin create mode 100755 pc-bios/vof.bin create mode 100644 pc-bios/vof/Makefile create mode 100644 pc-bios/vof/bootmem.c create mode 100644 pc-bios/vof/ci.c create mode 100644 pc-bios/vof/entry.S create mode 100644 pc-bios/vof/libc.c create mode 100644 pc-bios/vof/main.c create mode 100644 pc-bios/vof/vof.h create mode 100644 pc-bios/vof/vof.lds
MAINTAINERS +12 -0
@@ -1360,6 +1360,18 @@ F: hw/pci-host/mv64361.c F: hw/pci-host/mv643xx.h F: include/hw/pci-host/mv64361.h +Virtual Open Firmware (VOF) +M: Alexey Kardashevskiy <[email protected]> +M: David Gibson <[email protected]> +M: Greg Kurz <[email protected]> +L: [email protected] +S: Maintained +F: hw/ppc/spapr_vof* +F: hw/ppc/vof* +F: include/hw/ppc/vof* +F: pc-bios/vof/* +F: pc-bios/vof* + RISC-V Machines --------------- OpenTitan
hw/ppc/Kconfig +4 -0
@@ -13,6 +13,7 @@ config PSERIES select MSI_NONBROKEN select FDT_PPC select CHRP_NVRAM + select VOF config SPAPR_RNG bool
@@ -144,3 +145,6 @@ config FW_CFG_PPC config FDT_PPC bool + +config VOF + bool
hw/ppc/meson.build +3 -0
@@ -84,4 +84,7 @@ ppc_ss.add(when: 'CONFIG_VIRTEX', if_true: files('virtex_ml507.c')) # Pegasos2 ppc_ss.add(when: 'CONFIG_PEGASOS2', if_true: files('pegasos2.c')) +ppc_ss.add(when: 'CONFIG_VOF', if_true: files('vof.c')) +ppc_ss.add(when: ['CONFIG_VOF', 'CONFIG_PSERIES'], if_true: files('spapr_vof.c')) + hw_arch += {'ppc': ppc_ss}
hw/ppc/spapr.c +60 -7
131 lines not on this page · raw message
hw/ppc/spapr_hcall.c +22 -3
@@ -1080,7 +1080,7 @@ target_ulong do_client_architecture_support(PowerPCCPU *cpu,SpaprOptionVector *ov1_guest, *ov5_guest;bool guest_radix;bool raw_mode_supported = false; -bool guest_xive; +bool guest_xive, reset_fdt = false;CPUState *cs;void *fdt;uint32_t max_compat = spapr->max_compat_pvr;
@@ -1233,8 +1233,8 @@ target_ulong do_client_architecture_support(PowerPCCPU *cpu,spapr_setup_hpt (spapr); } - fdt =spapr_build_fdt (spapr, false, fdt_bufsize); - + reset_fdt = spapr->vof !=NULL ; + fdt =spapr_build_fdt (spapr, reset_fdt, fdt_bufsize);g_free (spapr->fdt_blob); spapr->fdt_size =fdt_totalsize (fdt); spapr->fdt_initial_size = spapr->fdt_size;
@@ -1277,6 +1277,25 @@ static target_ulong h_client_architecture_support(PowerPCCPU *cpu,return ret; } +target_ulong spapr_vof_client_architecture_support (MachineState *ms, +CPUState *cs, +target_ulong ovec_addr) +{ +SpaprMachineState *spapr =SPAPR_MACHINE (ms); + +target_ulong ret =do_client_architecture_support (POWERPC_CPU (cs), spapr, + ovec_addr,FDT_MAX_SIZE ); + +/* +* This adds stdout and generates phandles for boottime and CAS FDTs. +* It is alright to update the FDT here as do_client_architecture_support() +* does not pack it. +*/ +spapr_vof_client_dt_finalize (spapr, spapr->fdt_blob); + +return ret; +} + static target_ulong h_get_cpu_characteristics(PowerPCCPU *cpu, SpaprMachineState *spapr, target_ulong opcode,
hw/ppc/spapr_vof.c new file +153 -0
153 lines not on this page · raw message
hw/ppc/trace-events +24 -0
@@ -71,6 +71,30 @@ spapr_rtas_ibm_configure_connector_invalid(uint32_t index) "DRC index: 0x%"PRIx3 spapr_vio_h_reg_crq(uint64_t reg, uint64_t queue_addr, uint64_t queue_len) "CRQ for dev 0x%" PRIx64 " registered at 0x%" PRIx64 "/0x%" PRIx64 spapr_vio_free_crq(uint32_t reg) "CRQ for dev 0x%" PRIx32 " freed" +# vof.c +vof_error_str_truncated(const char *s, int len) "%s truncated to %d" +vof_error_param(const char *method, int nargscheck, int nretcheck, int nargs, int nret) "%s takes/returns %d/%d, not %d/%d" +vof_error_unknown_service(const char *service, int nargs, int nret) "\"%s\" args=%d rets=%d" +vof_error_unknown_method(const char *method) "\"%s\"" +vof_error_unknown_ihandle_close(uint32_t ih) "ih=0x%x" +vof_error_unknown_path(const char *path) "\"%s\"" +vof_error_write(uint32_t ih) "ih=0x%x" +vof_finddevice(const char *path, uint32_t ph) "\"%s\" => ph=0x%x" +vof_claim(uint32_t virt, uint32_t size, uint32_t align, uint32_t ret) "virt=0x%x size=0x%x align=0x%x => 0x%x" +vof_release(uint32_t virt, uint32_t size, uint32_t ret) "virt=0x%x size=0x%x => 0x%x" +vof_method(uint32_t ihandle, const char *method, uint32_t param, uint32_t ret, uint32_t ret2) "ih=0x%x \"%s\"(0x%x) => 0x%x 0x%x" +vof_getprop(uint32_t ph, const char *prop, uint32_t ret, const char *val) "ph=0x%x \"%s\" => len=%d [%s]" +vof_getproplen(uint32_t ph, const char *prop, uint32_t ret) "ph=0x%x \"%s\" => len=%d" +vof_setprop(uint32_t ph, const char *prop, const char *val, uint32_t vallen, uint32_t ret) "ph=0x%x \"%s\" [%s] len=%d => ret=%d" +vof_open(const char *path, uint32_t ph, uint32_t ih) "%s ph=0x%x => ih=0x%x" +vof_interpret(const char *cmd, uint32_t param1, uint32_t param2, uint32_t ret, uint32_t ret2) "[%s] 0x%x 0x%x => 0x%x 0x%x" +vof_package_to_path(uint32_t ph, const char *tmp, uint32_t ret) "ph=0x%x => %s len=%d" +vof_instance_to_path(uint32_t ih, uint32_t ph, const char *tmp, uint32_t ret) "ih=0x%x ph=0x%x => %s len=%d" +vof_instance_to_package(uint32_t ih, uint32_t ph) "ih=0x%x => ph=0x%x" +vof_write(uint32_t ih, unsigned cb, const char *msg) "ih=0x%x [%u] \"%s\"" +vof_avail(uint64_t start, uint64_t end, uint64_t size) "0x%"PRIx64"..0x%"PRIx64" size=0x%"PRIx64 +vof_claimed(uint64_t start, uint64_t end, uint64_t size) "0x%"PRIx64"..0x%"PRIx64" size=0x%"PRIx64 + # ppc.c ppc_tb_adjust(uint64_t offs1, uint64_t offs2, int64_t diff, int64_t seconds) "adjusted from 0x%"PRIx64" to 0x%"PRIx64", diff %"PRId64" (%"PRId64"s)"
hw/ppc/vof.c new file +1049 -0
1,049 lines not on this page · raw message
include/hw/ppc/spapr.h +18 -1
@@ -12,6 +12,7 @@#include "hw/ppc/spapr_xive.h" /* For SpaprXive */ #include "hw/ppc/xics.h" /* For ICSState */ #include "hw/ppc/spapr_tpm_proxy.h" +#include "hw/ppc/vof.h" struct SpaprVioBus ;struct SpaprPhbState ;
@@ -180,6 +181,7 @@ struct SpaprMachineState {uint64_t kernel_addr;uint32_t initrd_base;long initrd_size; +Vof *vof;uint64_t rtc_offset;/* Now used only during incoming migration */ struct PPCTimebase tb;bool has_graphics;
@@ -558,7 +560,9 @@ struct SpaprMachineState {/* Client Architecture support */ #define KVMPPC_H_CAS (KVMPPC_HCALL_BASE + 0x2)#define KVMPPC_H_UPDATE_DT (KVMPPC_HCALL_BASE + 0x3) -#define KVMPPC_HCALL_MAX KVMPPC_H_UPDATE_DT +/* 0x4 was used for KVMPPC_H_UPDATE_PHANDLE in SLOF */ +#define KVMPPC_H_VOF_CLIENT (KVMPPC_HCALL_BASE + 0x5) +#define KVMPPC_HCALL_MAX KVMPPC_H_VOF_CLIENT/* * The hcall range 0xEF00 to 0xEF80 is reserved for use in facilitating
@@ -956,4 +960,17 @@ bool spapr_check_pagesize(SpaprMachineState *spapr, hwaddr pagesize,void spapr_set_all_lpcrs (target_ulong value,target_ulong mask);hwaddr spapr_get_rtas_addr (void );bool spapr_memory_hot_unplug_supported (SpaprMachineState *spapr); + +void spapr_vof_reset (SpaprMachineState *spapr,void *fdt, +target_ulong *stack_ptr,Error **errp); +void spapr_vof_quiesce (MachineState *ms); +bool spapr_vof_setprop (MachineState *ms,const char *path,const char *propname, +void *val,int vallen); +target_ulong spapr_h_vof_client (PowerPCCPU *cpu,SpaprMachineState *spapr, +target_ulong opcode,target_ulong *args); +target_ulong spapr_vof_client_architecture_support (MachineState *ms, +CPUState *cs, +target_ulong ovec_addr); +void spapr_vof_client_dt_finalize (SpaprMachineState *spapr,void *fdt); +#endif /* HW_SPAPR_H */
include/hw/ppc/vof.h new file +58 -0
58 lines not on this page · raw message
pc-bios/README +4 -0
@@ -16,6 +16,10 @@ https://github.com/aik/SLOF, and the image currently in qemu is built from git tag qemu-slof-20210217. +- VOF (Virtual Open Firmware) is a minimalistic firmware to work with + -machine pseries,x-vof=on. When enabled, the firmware acts as a slim shim and + QEMU implements parts of the IEEE 1275 Open Firmware interface. + - sgabios (the Serial Graphics Adapter option ROM) provides a means for legacy x86 software to communicate with an attached serial console as if a video card were attached. The master sources reside in a subversion
pc-bios/vof-nvram.bin new file binary +0 -0
pc-bios/vof.bin new file binary +0 -0
pc-bios/vof/Makefile new file +23 -0
@@ -0,0 +1,23 @@ +all: build-all + +build-all: vof.bin + +CROSS ?= +CC = $(CROSS)gcc +LD = $(CROSS)ld +OBJCOPY = $(CROSS)objcopy + +%.o: %.S + $(CC) -m32 -mbig-endian -mcpu=power4 -c -o $@ $< + +%.o: %.c + $(CC) -m32 -mbig-endian -mcpu=power4 -c -fno-stack-protector -o $@ $< + +vof.elf: entry.o main.o ci.o bootmem.o libc.o + $(LD) -nostdlib -e_start -Tvof.lds -EB -o $@ $^ + +%.bin: %.elf + $(OBJCOPY) -O binary -j .text -j .data -j .toc -j .got2 $^ $@ + +clean: + rm -f *.o vof.bin vof.elf *~
pc-bios/vof/bootmem.c new file +14 -0
@@ -0,0 +1,14 @@ +#include "vof.h" + +void boot_from_memory (uint64_t initrd,uint64_t initrdsize) +{ +uint64_t kern[2 ]; +phandle chosen =ci_finddevice ("/chosen" ); + +if (ci_getprop (chosen,"qemu,boot-kernel" , kern,sizeof (kern)) != +sizeof (kern)) { +return ; + } + +do_boot (kern[0 ], initrd, initrdsize); +}
pc-bios/vof/ci.c new file +91 -0
91 lines not on this page · raw message
pc-bios/vof/entry.S new file +49 -0
49 lines not on this page · raw message
pc-bios/vof/libc.c new file +92 -0
92 lines not on this page · raw message
pc-bios/vof/main.c new file +21 -0
@@ -0,0 +1,21 @@ +#include "vof.h" + +void do_boot (unsigned long addr,unsigned long _r3,unsigned long _r4) +{ + register unsigned long r3 __asm__("r3") = _r3; + register unsigned long r4 __asm__("r4") = _r4; + register unsigned long r5 __asm__("r5") = (unsigned long) _prom_entry; + + ((client *)(uint32_t )addr)(); +} + +void entry_c (void ) +{ + registerunsigned long r3 __asm__("r3" ); + registerunsigned long r4 __asm__("r4" ); + registerunsigned long r5 __asm__("r5" ); +uint64_t initrd = r3, initrdsize = r4; + +boot_from_memory (initrd, initrdsize); +ci_panic ("*** No boot target ***\n" ); +}
pc-bios/vof/vof.h new file +43 -0
43 lines not on this page · raw message
pc-bios/vof/vof.lds new file +48 -0
48 lines not on this page · raw message
tests/qtest/rtas-test.c +13 -2
@@ -5,7 +5,7 @@#include "libqos/libqos-spapr.h" #include "libqos/rtas.h" -static void test_rtas_get_time_of_day (void ) +static void run_test_rtas_get_time_of_day (const char *machine) {QOSState *qs;struct tm tm;
@@ -13,7 +13,7 @@ static void test_rtas_get_time_of_day(void)uint64_t ret;time_t t1, t2; - qs =qtest_spapr_boot ("-machine pseries" ); + qs =qtest_spapr_boot (machine); t1 =time (NULL ); ret =qrtas_get_time_of_day (qs->qts, &qs->alloc, &tm, &ns);
@@ -24,6 +24,16 @@ static void test_rtas_get_time_of_day(void)qtest_shutdown (qs); } +static void test_rtas_get_time_of_day (void ) +{ +run_test_rtas_get_time_of_day ("-machine pseries" ); +} + +static void test_rtas_get_time_of_day_vof (void ) +{ +run_test_rtas_get_time_of_day ("-machine pseries,x-vof=on" ); +} +int main (int argc,char *argv[]) {const char *arch =qtest_get_arch ();
@@ -35,6 +45,7 @@ int main(int argc, char *argv[])exit (EXIT_FAILURE ); }qtest_add_func ("rtas/get-time-of-day" , test_rtas_get_time_of_day); +qtest_add_func ("rtas/get-time-of-day-vof" , test_rtas_get_time_of_day_vof);return g_test_run (); }
Signature · 1 line
2.31.1
Re: [PULL 22/33] spapr: Implement Open Firmware client interface
Quoted 6 lines · David Gibson
From: Alexey Kardashevskiy <[email protected]>
The PAPR platform describes an OS environment that's presented by a combination of a hypervisor and firmware. The features it specifies require collaboration between the firmware and the hypervisor.
Hi; Coverity reports issues in this code:
hw/ppc/vof.c line 518
Quoted 4 lines
hw/ppc/vof.c new file +4
-0+static uint32_t vof_package_to_path (const void *fdt,uint32_t phandle, +uint32_t buf,uint32_t len) +{ +uint32_t ret =-1 ;
Here we declare 'ret' as an unsigned type...
hw/ppc/vof.c line 522
Quoted 4 lines
hw/ppc/vof.c new file +4
-0+char tmp[VOF_MAX_PATH ] ="" ; + + ret =phandle_to_path (fdt, phandle, tmp,sizeof (tmp)); +if (ret >0 ) {
...so this is doing an unsigned comparison, which means that the negative values returned from phandle_to_path() (whose return type is 'int') will not be detected (viewed as unsigned values they will all be positive and >2GB).
Quoted 1 line
+ if (
VOF_MEM_WRITE(buf, tmp, ret)!=MEMTX_OK) {
This then means that we will attempt to write >2GB of data here...
Quoted 9 lines
hw/ppc/vof.c new file +9
-0+ ret =-1 ; + } + } + +trace_vof_package_to_path (phandle, tmp, ret); + +return ret; +} +
hw/ppc/vof.c line 542
Quoted 10 lines
hw/ppc/vof.c new file +10
-0+static uint32_t vof_instance_to_path (void *fdt,Vof *vof,uint32_t ihandle, +uint32_t buf,uint32_t len) +{ +uint32_t ret =-1 ; +uint32_t phandle =vof_instance_to_package (vof, ihandle); +char tmp[VOF_MAX_PATH ] ="" ; + +if (phandle !=-1 ) { + ret =phandle_to_path (fdt, phandle, tmp,sizeof (tmp)); +if (ret >0 ) {
This function has the same problem.
hw/ppc/vof.c line 551
Quoted 9 lines
hw/ppc/vof.c new file +9
-0+if (VOF_MEM_WRITE (buf, tmp, ret) !=MEMTX_OK ) { + ret =-1 ; + } + } + } +trace_vof_instance_to_path (ihandle, phandle, tmp, ret); + +return ret; +}
thanks
-- PMM
Re: [PULL 22/33] spapr: Implement Open Firmware client interface
In reply to David GibsonQuoted 6 lines · David Gibson
From: Alexey Kardashevskiy <[email protected]>
The PAPR platform describes an OS environment that's presented by a combination of a hypervisor and firmware. The features it specifies require collaboration between the firmware and the hypervisor.
Another Coverity issue unrelated to the others: CID 1458132:
Quoted 4 lines
hw/ppc/vof.c new file +4
-0+int vof_client_call (MachineState *ms,Vof *vof,void *fdt, +target_ulong args_real) +{ +struct prom_args args_be;
hw/ppc/vof.c line 946
Quoted 10 lines
hw/ppc/vof.c new file +10
-0+uint32_t args[ARRAY_SIZE (args_be.args)]; +uint32_t rets[ARRAY_SIZE (args_be.args)] = {0 }, ret; +char service[64 ]; +unsigned nargs, nret, i; + +if (VOF_MEM_READ (args_real, &args_be,sizeof (args_be)) !=MEMTX_OK ) { +return -EINVAL ; + } + nargs =be32_to_cpu (args_be.nargs); +if (nargs >=ARRAY_SIZE (args_be.args)) {
Our only bounds check against overflowing the args arrays is here, on 'nargs'...
Quoted 16 lines
hw/ppc/vof.c new file +16
-0+return -EINVAL ; + } + +if (VOF_MEM_READ (be32_to_cpu (args_be.service), service,sizeof (service)) != +MEMTX_OK ) { +return -EINVAL ; + } +if (strnlen (service,sizeof (service)) ==sizeof (service)) { +/* Too long service name */ +return -EINVAL ; + } + +for (i =0 ; i < nargs; ++i) { + args[i] =be32_to_cpu (args_be.args[i]); + } +
hw/ppc/vof.c line 972
Quoted 10 lines
hw/ppc/vof.c new file +10
-0+ nret =be32_to_cpu (args_be.nret); + ret =vof_client_handle (ms, fdt, vof, service, args, nargs, rets, nret); +if (!nret) { +return 0 ; + } + + args_be.args[nargs] =cpu_to_be32 (ret); +for (i =1 ; i < nret; ++i) { + args_be.args[nargs + i] =cpu_to_be32 (rets[i -1 ]); + }
...but in the code we fill the args_be array with "nargs + 1 + nret - 1" values.
Side note: is the code really intentionally copying only nret-1 values from rets[], or is the loop condition supposed to be "<= nret" ?
hw/ppc/vof.c line 981
Quoted 9 lines
hw/ppc/vof.c new file +9
-0+ + if (VOF_MEM_WRITE(args_real + offsetof(struct prom_args, args[nargs]), + args_be.args + nargs, sizeof(args_be.args[0]) * nret) != + MEMTX_OK) { +return -EINVAL ; + } + +return 0 ; +}
thanks
-- PMM
Re: [PULL 22/33] spapr: Implement Open Firmware client interface
In reply to David GibsonQuoted 6 lines · David Gibson
From: Alexey Kardashevskiy <[email protected]>
The PAPR platform describes an OS environment that's presented by a combination of a hypervisor and firmware. The features it specifies require collaboration between the firmware and the hypervisor.
Hi; the latest version of Coverity has pointed out another bug in this commit (CID 1487241):
hw/ppc/vof.c line 297
Quoted 5 lines
hw/ppc/vof.c new file +5
-0+static uint32_t vof_setprop (MachineState *ms,void *fdt,Vof *vof, +uint32_t nodeph,uint32_t pname, +uint32_t valaddr,uint32_t vallen) +{ +char propname[OF_PROPNAME_LEN_MAX +1 ];
We don't initialize this array...
hw/ppc/vof.c line 306
Quoted 9 lines
hw/ppc/vof.c new file +9
-0+uint32_t ret =-1 ; +int offset; +char trval[64 ] ="" ; +char nodepath[VOF_MAX_PATH ] ="" ; +Object *vmo =object_dynamic_cast (OBJECT (ms),TYPE_VOF_MACHINE_IF ); + g_autofree char *val = NULL; + +if (vallen >VOF_MAX_SETPROPLEN ) { + goto trace_exit;
...and this error-exit check happens before the readstr() that fills in the propname[] array...
hw/ppc/vof.c line 306
Quoted 3 lines
hw/ppc/vof.c new file +3
-0+ } +if (readstr (pname, propname,sizeof (propname))) { + goto trace_exit;
...and if the readstr() fails then propname[] isn't set either...
hw/ppc/vof.c line 346
Quoted 4 lines
hw/ppc/vof.c new file +3
-0+ } +trace_exit: +trace_vof_setprop (nodeph, propname, trval, vallen, ret);
...but on the 'trace_exit' error path we still try to trace propname, which will use the %s format string on it, printing a potentially arbitrary amount of garbage.
We should either initialize the propname array or else not trace it for these error paths.
thanks
-- PMM
[PULL 13/33] target/ppc: Fix compilation with DUMP_PAGE_TABLES debug option
In reply to David GibsonFrom: Fabiano Rosas <[email protected]>
../target/ppc/mmu_helper.c: In function 'get_segment_6xx_tlb':../target/ppc/mmu_helper.c:514:46: error: passing argument 1 of 'ppc_hash32_hpt_mask' from incompatible pointer type [-Werror=incompatible-pointer-types]
514 | ppc_hash32_hpt_mask(env) + 0x80);
| ^~~
| |
| CPUPPCState *Message-Id: <[email protected]>
--- target/ppc/mmu_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/ppc/mmu_helper.c +1 -1
@@ -511,7 +511,7 @@ static int get_segment_6xx_tlb(CPUPPCState *env, mmu_ctx_t *ctx,qemu_log ("Page table: " TARGET_FMT_plx" len " TARGET_FMT_plx"\n" ,ppc_hash32_hpt_base (cpu), -ppc_hash32_hpt_mask (env) +0x80 ); +ppc_hash32_hpt_mask (cpu) +0x80 ); for (curaddr = ppc_hash32_hpt_base(cpu); curaddr < (ppc_hash32_hpt_base(cpu) + ppc_hash32_hpt_mask(cpu) + 0x80);
Signature · 1 line
2.31.1
[PULL 23/33] target/ppc: mtmsrd is an illegal instruction on BookE
In reply to David GibsonFrom: Nicholas Piggin <[email protected]>
MSR is a 32-bit register in BookE and there is no mtmsrd instruction.
Message-Id: <[email protected]>
--- target/ppc/translate.c | 5 +++++ 1 file changed, 5 insertions(+)
target/ppc/translate.c +5 -0
@@ -4940,6 +4940,11 @@ static void gen_mtcrf(DisasContext *ctx)#if defined(TARGET_PPC64 )static void gen_mtmsrd (DisasContext *ctx) { +if (unlikely (!is_book3s_arch2x (ctx))) { +gen_invalid (ctx); +return ; + } +CHK_SV ;#if !defined(CONFIG_USER_ONLY )
Signature · 1 line
2.31.1
[PULL 30/33] target/ppc: Don't compile ppc_tlb_invalid_all without TCG
In reply to David GibsonFrom: "Lucas Mateus Castro (alqotel)" <[email protected]>
The function ppc_tlb_invalid_all is not compiled anymore in a TCG-less environment, and the call to that function has been disabled in this situation
Message-Id: <[email protected]>
--- target/ppc/cpu_init.c | 2 ++ target/ppc/mmu_helper.c | 4 ++++ 2 files changed, 6 insertions(+)
target/ppc/cpu_init.c +2 -0
@@ -8847,9 +8847,11 @@ static void ppc_cpu_reset(DeviceState *dev)#if !defined(CONFIG_USER_ONLY ) env->nip = env->hreset_vector | env->excp_prefix; +#if defined(CONFIG_TCG )if (env->mmu_model !=POWERPC_MMU_REAL ) {ppc_tlb_invalidate_all (env); } +#endif /* CONFIG_TCG */ #endif hreg_compute_hflags (env);
target/ppc/mmu_helper.c +4 -0
@@ -825,6 +825,7 @@ static int mmubooke_get_physical_address(CPUPPCState *env, mmu_ctx_t *ctx,return ret; } +#ifdef CONFIG_TCG static void booke206_flush_tlb (CPUPPCState *env,int flags,const int check_iprot) {
@@ -846,6 +847,7 @@ static void booke206_flush_tlb(CPUPPCState *env, int flags, tlb_flush(env_cpu(env)); } +#endif static hwaddr booke206_tlb_to_page_size (CPUPPCState *env,ppcmas_tlb_t *tlb)
@@ -1901,6 +1903,7 @@ void helper_store_601_batl(CPUPPCState *env, uint32_t nr, target_ulong value) }#endif +#ifdef CONFIG_TCG /*****************************************************************************/ /* TLB management */ void ppc_tlb_invalidate_all (CPUPPCState *env)
@@ -1944,6 +1947,7 @@ void ppc_tlb_invalidate_all(CPUPPCState *env) break; } } +#endif #ifdef CONFIG_TCG void ppc_tlb_invalidate_one (CPUPPCState *env,target_ulong addr)
Signature · 1 line
2.31.1
[PULL 24/33] ppc/pegasos2: Introduce Pegasos2MachineState structure
In reply to David GibsonFrom: BALATON Zoltan <[email protected]>
Add own machine state structure which will be used to store state needed for firmware emulation.
Message-Id: <7f6d5fbf4f70c64dba001483174a2921dd616ecd.1624811233.git.balaton@eik.bme.hu>
--- hw/ppc/pegasos2.c | 50 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 13 deletions(-)
hw/ppc/pegasos2.c +37 -13
@@ -1,7 +1,7 @@/* * QEMU PowerPC CHRP (Genesi/bPlan Pegasos II) hardware System Emulator * -* Copyright (c) 2018-2020 BALATON Zoltan +* Copyright (c) 2018-2021 BALATON Zoltan * * This work is licensed under the GNU GPL license version 2 or later. *
@@ -41,6 +41,15 @@#define BUS_FREQ_HZ 133333333 +#define TYPE_PEGASOS2_MACHINE MACHINE_TYPE_NAME("pegasos2") +OBJECT_DECLARE_TYPE(Pegasos2MachineState, MachineClass, PEGASOS2_MACHINE) + +struct Pegasos2MachineState { +MachineState parent_obj; +PowerPCCPU *cpu; +DeviceState *mv; +}; +static void pegasos2_cpu_reset (void *opaque) {PowerPCCPU *cpu = opaque;
@@ -51,9 +60,9 @@ static void pegasos2_cpu_reset(void *opaque)static void pegasos2_init (MachineState *machine) { -PowerPCCPU *cpu =NULL ; +Pegasos2MachineState *pm =PEGASOS2_MACHINE (machine); +CPUPPCState *env;MemoryRegion *rom =g_new (MemoryRegion,1 ); -DeviceState *mv;PCIBus *pci_bus;PCIDevice *dev;I2CBus *i2c_bus;
@@ -63,15 +72,16 @@ static void pegasos2_init(MachineState *machine)uint8_t *spd_data;/* init CPU */ - cpu =POWERPC_CPU (cpu_create (machine->cpu_type)); -if (PPC_INPUT (&cpu->env) != PPC_FLAGS_INPUT_6xx) { + pm->cpu =POWERPC_CPU (cpu_create (machine->cpu_type)); + env = &pm->cpu->env; +if (PPC_INPUT (env) != PPC_FLAGS_INPUT_6xx) {error_report ("Incompatible CPU, only 6xx bus supported" );exit (1 ); }/* Set time-base frequency */ -cpu_ppc_tb_init (&cpu->env,BUS_FREQ_HZ /4 ); -qemu_register_reset (pegasos2_cpu_reset, cpu); +cpu_ppc_tb_init (env,BUS_FREQ_HZ /4 ); +qemu_register_reset (pegasos2_cpu_reset, pm->cpu);/* RAM */ memory_region_add_subregion (get_system_memory (),0 , machine->ram);
@@ -96,16 +106,16 @@ static void pegasos2_init(MachineState *machine)g_free (filename);/* Marvell Discovery II system controller */ - mv =DEVICE (sysbus_create_simple (TYPE_MV64361 ,-1 , - ((qemu_irq *)cpu->env.irq_inputs)[PPC6xx_INPUT_INT])); - pci_bus =mv64361_get_pci_bus (mv,1 ); + pm->mv =DEVICE (sysbus_create_simple (TYPE_MV64361 ,-1 , + ((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_INT])); + pci_bus =mv64361_get_pci_bus (pm->mv,1 );/* VIA VT8231 South Bridge (multifunction PCI device) */ /* VT8231 function 0: PCI-to-ISA Bridge */ dev =pci_create_simple_multifunction (pci_bus,PCI_DEVFN (12 ,0 ), true,TYPE_VT8231_ISA );qdev_connect_gpio_out (DEVICE (dev),0 , -qdev_get_gpio_in_named (mv,"gpp" ,31 )); +qdev_get_gpio_in_named (pm->mv,"gpp" ,31 ));/* VT8231 function 1: IDE Controller */ dev =pci_create_simple (pci_bus,PCI_DEVFN (12 ,1 ),"via-ide" );
@@ -129,8 +139,10 @@ static void pegasos2_init(MachineState *machine)pci_vga_init (pci_bus); } -static void pegasos2_machine (MachineClass *mc) +static void pegasos2_machine_class_init (ObjectClass *oc,void *data) { +MachineClass *mc =MACHINE_CLASS (oc); + mc->desc ="Genesi/bPlan Pegasos II" ; mc->init = pegasos2_init; mc->block_default_type =IF_IDE ;
@@ -141,4 +153,16 @@ static void pegasos2_machine(MachineClass *mc) mc->default_ram_size =512 * MiB; } -DEFINE_MACHINE ("pegasos2" , pegasos2_machine) +static const TypeInfo pegasos2_machine_info = { + .name =TYPE_PEGASOS2_MACHINE , + .parent =TYPE_MACHINE , + .class_init = pegasos2_machine_class_init, + .instance_size =sizeof (Pegasos2MachineState), +}; + +static void pegasos2_machine_register_types (void ) +{ +type_register_static (&pegasos2_machine_info); +} + +type_init (pegasos2_machine_register_types)
Signature · 1 line
2.31.1
[PULL 14/33] target/ppc: Fix compilation with FLUSH_ALL_TLBS debug option
In reply to David GibsonFrom: Fabiano Rosas <[email protected]>
../target/ppc/mmu_helper.c: In function 'helper_store_ibatu':../target/ppc/mmu_helper.c:1802:17: error: unused variable 'cpu' [-Werror=unused-variable]
1802 | PowerPCCPU *cpu = env_archcpu(env);
| ^~~../target/ppc/mmu_helper.c: In function 'helper_store_dbatu':../target/ppc/mmu_helper.c:1838:17: error: unused variable 'cpu' [-Werror=unused-variable]
1838 | PowerPCCPU *cpu = env_archcpu(env);
| ^~~../target/ppc/mmu_helper.c: In function 'helper_store_601_batu':../target/ppc/mmu_helper.c:1874:17: error: unused variable 'cpu' [-Werror=unused-variable]
1874 | PowerPCCPU *cpu = env_archcpu(env);
| ^~~../target/ppc/mmu_helper.c: In function 'helper_store_601_batl':../target/ppc/mmu_helper.c:1919:17: error: unused variable 'cpu' [-Werror=unused-variable]
1919 | PowerPCCPU *cpu = env_archcpu(env);
Message-Id: <[email protected]>
--- target/ppc/mmu_helper.c | 8 -------- 1 file changed, 8 deletions(-)
target/ppc/mmu_helper.c +0 -8
@@ -1755,9 +1755,6 @@ static inline void dump_store_bat(CPUPPCState *env, char ID, int ul, int nr,void helper_store_ibatu (CPUPPCState *env,uint32_t nr,target_ulong value) {target_ulong mask; -#if defined(FLUSH_ALL_TLBS ) -PowerPCCPU *cpu =env_archcpu (env); -#endif dump_store_bat (env,'I' ,0 , nr, value);if (env->IBAT[0 ][nr] != value) {
@@ -1791,9 +1788,6 @@ void helper_store_ibatl(CPUPPCState *env, uint32_t nr, target_ulong value)void helper_store_dbatu (CPUPPCState *env,uint32_t nr,target_ulong value) {target_ulong mask; -#if defined(FLUSH_ALL_TLBS ) -PowerPCCPU *cpu =env_archcpu (env); -#endif dump_store_bat (env,'D' ,0 , nr, value);if (env->DBAT[0 ][nr] != value) {
@@ -1828,7 +1822,6 @@ void helper_store_601_batu(CPUPPCState *env, uint32_t nr, target_ulong value) {target_ulong mask;#if defined(FLUSH_ALL_TLBS ) -PowerPCCPU *cpu =env_archcpu (env);int do_inval;#endif
@@ -1873,7 +1866,6 @@ void helper_store_601_batl(CPUPPCState *env, uint32_t nr, target_ulong value)#if !defined(FLUSH_ALL_TLBS )target_ulong mask;#else -PowerPCCPU *cpu =env_archcpu (env);int do_inval;#endif
Signature · 1 line
2.31.1
[PULL 33/33] target/ppc: Support for H_RPT_INVALIDATE hcall
In reply to David GibsonFrom: Bharata B Rao <[email protected]>
If KVM_CAP_RPT_INVALIDATE KVM capability is enabled, then
- indicate the availability of H_RPT_INVALIDATE hcall to the guest via ibm,hypertas-functions property.
- Enable the hcall
Both the above are done only if the new sPAPR machine capability cap-rpt-invalidate is set.
Message-Id: <[email protected]>
--- hw/ppc/spapr.c | 6 ++++++ hw/ppc/spapr_caps.c | 41 +++++++++++++++++++++++++++++++++++++++++ include/hw/ppc/spapr.h | 8 ++++++-- target/ppc/kvm.c | 12 ++++++++++++ target/ppc/kvm_ppc.h | 12 ++++++++++++ 5 files changed, 77 insertions(+), 2 deletions(-)
hw/ppc/spapr.c +6 -0
@@ -881,6 +881,10 @@ static void spapr_dt_rtas(SpaprMachineState *spapr, void *fdt)add_str (hypertas,"hcall-copy" );add_str (hypertas,"hcall-debug" );add_str (hypertas,"hcall-vphn" ); +if (spapr_get_cap (spapr,SPAPR_CAP_RPT_INVALIDATE ) ==SPAPR_CAP_ON ) { +add_str (hypertas,"hcall-rpt-invalidate" ); + } +add_str (qemu_hypertas,"hcall-memop1" );if (!kvm_enabled () ||kvmppc_spapr_use_multitce ()) {
@@ -2030,6 +2034,7 @@ static const VMStateDescription vmstate_spapr = { &vmstate_spapr_cap_ccf_assist, &vmstate_spapr_cap_fwnmi, &vmstate_spapr_fwnmi, + &vmstate_spapr_cap_rpt_invalidate, NULL } };
@@ -4618,6 +4623,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) smc->default_caps.caps[SPAPR_CAP_LARGE_DECREMENTER ] =SPAPR_CAP_ON ; 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 ;spapr_caps_add_properties (smc); smc->irq = &spapr_irq_dual; smc->dr_phb_enabled = true;
hw/ppc/spapr_caps.c +41 -0
59 lines not on this page · raw message
include/hw/ppc/spapr.h +6 -2
@@ -75,8 +75,10 @@ typedef enum {#define SPAPR_CAP_CCF_ASSIST 0x09/* Implements PAPR FWNMI option */ #define SPAPR_CAP_FWNMI 0x0A +/* Support H_RPT_INVALIDATE */ +#define SPAPR_CAP_RPT_INVALIDATE 0x0B/* Num Caps */ -#define SPAPR_CAP_NUM (SPAPR_CAP_FWNMI + 1) +#define SPAPR_CAP_NUM (SPAPR_CAP_RPT_INVALIDATE + 1)/* * Capability Values
@@ -547,8 +549,9 @@ struct SpaprMachineState {#define H_SCM_UNBIND_MEM 0x3F0#define H_SCM_UNBIND_ALL 0x3FC#define H_SCM_HEALTH 0x400 +#define H_RPT_INVALIDATE 0x448 -#define MAX_HCALL_OPCODE H_SCM_HEALTH +#define MAX_HCALL_OPCODE H_RPT_INVALIDATE/* The hcalls above are standardized in PAPR and implemented by pHyp * as well.
@@ -939,6 +942,7 @@ extern const VMStateDescription vmstate_spapr_cap_nested_kvm_hv;extern const VMStateDescription vmstate_spapr_cap_large_decr;extern const VMStateDescription vmstate_spapr_cap_ccf_assist;extern const VMStateDescription vmstate_spapr_cap_fwnmi; +extern const VMStateDescription vmstate_spapr_cap_rpt_invalidate;static inline uint8_t spapr_get_cap (SpaprMachineState *spapr,int cap) {
target/ppc/kvm.c +12 -0
@@ -89,6 +89,7 @@ static int cap_ppc_count_cache_flush_assist;static int cap_ppc_nested_kvm_hv;static int cap_large_decr;static int cap_fwnmi; +static int cap_rpt_invalidate;static uint32_t debug_inst_opcode;
@@ -152,6 +153,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s)exit (1 ); } + cap_rpt_invalidate =kvm_vm_check_extension (s,KVM_CAP_PPC_RPT_INVALIDATE );kvm_ppc_register_host_cpu_type ();return 0 ;
@@ -2040,6 +2042,11 @@ void kvmppc_enable_h_page_init(void)kvmppc_enable_hcall (kvm_state,H_PAGE_INIT ); } +void kvmppc_enable_h_rpt_invalidate (void ) +{ +kvmppc_enable_hcall (kvm_state,H_RPT_INVALIDATE ); +} +void kvmppc_set_papr (PowerPCCPU *cpu) {CPUState *cs =CPU (cpu);
@@ -2551,6 +2558,11 @@ int kvmppc_enable_cap_large_decr(PowerPCCPU *cpu, int enable)return 0 ; } +int kvmppc_has_cap_rpt_invalidate (void ) +{ +return cap_rpt_invalidate; +} +PowerPCCPUClass *kvm_ppc_get_host_cpu_class (void ) {uint32_t host_pvr =mfpvr ();
target/ppc/kvm_ppc.h +12 -0
@@ -24,6 +24,7 @@ void kvmppc_enable_logical_ci_hcalls(void);void kvmppc_enable_set_mode_hcall (void );void kvmppc_enable_clear_ref_mod_hcalls (void );void kvmppc_enable_h_page_init (void ); +void kvmppc_enable_h_rpt_invalidate (void );void kvmppc_set_papr (PowerPCCPU *cpu);int kvmppc_set_compat (PowerPCCPU *cpu,uint32_t compat_pvr);void kvmppc_set_mpic_proxy (PowerPCCPU *cpu,int mpic_proxy);
@@ -71,6 +72,7 @@ bool kvmppc_has_cap_nested_kvm_hv(void);int kvmppc_set_cap_nested_kvm_hv (int enable);int kvmppc_get_cap_large_decr (void );int kvmppc_enable_cap_large_decr (PowerPCCPU *cpu,int enable); +int kvmppc_has_cap_rpt_invalidate (void );int kvmppc_enable_hwrng (void );int kvmppc_put_books_sregs (PowerPCCPU *cpu);PowerPCCPUClass *kvm_ppc_get_host_cpu_class (void );
@@ -150,6 +152,11 @@ static inline void kvmppc_enable_h_page_init(void) { } +static inline void kvmppc_enable_h_rpt_invalidate (void ) +{ +g_assert_not_reached (); +} +static inline void kvmppc_set_papr (PowerPCCPU *cpu) { }
@@ -381,6 +388,11 @@ static inline int kvmppc_enable_cap_large_decr(PowerPCCPU *cpu, int enable)return -1 ; } +static inline int kvmppc_has_cap_rpt_invalidate (void ) +{ +return false; +} +static inline int kvmppc_enable_hwrng (void ) {return -1 ;
Signature · 1 line
2.31.1
[PULL 20/33] roms/u-boot: Bump ppce500 u-boot to v2021.07 to add eTSEC support
In reply to David GibsonFrom: Bin Meng <[email protected]>
Update the QEMU shipped u-boot.e500 image built from U-Boot mainline v2021.07 release, which added eTSEC support to the QEMU ppce500 target, via the following U-Boot series:
http://patchwork.ozlabs.org/project/uboot/list/?series=233875&state=*
The cross-compilation toolchain used to build the U-Boot image is:
https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/10.1.0/x86_64-gcc-10.1.0-nolibc-powerpc-linux.tar.xz
--- pc-bios/u-boot.e500 | Bin 406920 -> 421720 bytes roms/u-boot | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-)
pc-bios/u-boot.e500 binary +0 -0
roms/u-boot +1 -1
@@ -1 +1 @@ -Subproject commit b46dd116ce03e235f2a7d4843c6278e1da44b5e1 +Subproject commit 840658b093976390e9537724f802281c9c8439f5
Signature · 1 line
2.31.1
[PULL 28/33] ppc/pegasos2: Fix use of && instead of &
In reply to David GibsonThis is obviously intended to be a mask, not a logical operation.
--- hw/ppc/pegasos2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/ppc/pegasos2.c +1 -1
@@ -584,7 +584,7 @@ static void add_pci_device(PCIBus *bus, PCIDevice *d, void *opaque) pci_get_word(&d->config[PCI_SUBSYSTEM_VENDOR_ID])); cells[0 ] =pci_get_long (&d->config[PCI_CLASS_REVISION ]);qemu_fdt_setprop_cell (fi->fdt, node->str,"class-code" , cells[0 ] >>8 ); -qemu_fdt_setprop_cell (fi->fdt, node->str,"revision-id" , cells[0 ] &&0xff ); +qemu_fdt_setprop_cell (fi->fdt, node->str,"revision-id" , cells[0 ] &0xff );qemu_fdt_setprop_cell (fi->fdt, node->str,"device-id" ,pci_get_word (&d->config[PCI_DEVICE_ID ])); qemu_fdt_setprop_cell(fi->fdt, node->str, "vendor-id",
Signature · 1 line
2.31.1
[PULL 19/33] target/ppc: change ppc_hash32_xlate to use mmu_idx
In reply to David GibsonFrom: "Bruno Larsen (billionai)" <[email protected]>
Changed hash32 address translation to use the supplied mmu_idx, instead of using what was stored in the msr, for parity purposes (radix64 already uses that) and for conceptual correctness, all the relevant functions should always use the supplied mmu_idx, as there are no guarantees that the mmu_idx stored in the CPU variable will not desync.
Message-Id: <[email protected]>
--- target/ppc/mmu-hash32.c | 40 +++++++++++++++++++--------------------- target/ppc/mmu-hash32.h | 2 +- target/ppc/mmu_helper.c | 2 +- 3 files changed, 21 insertions(+), 23 deletions(-)
target/ppc/mmu-hash32.c +19 -21
@@ -25,6 +25,7 @@#include "kvm_ppc.h" #include "internal.h" #include "mmu-hash32.h" +#include "mmu-books.h" #include "exec/log.h" /* #define DEBUG_BATS */
@@ -86,25 +87,22 @@ static int ppc_hash32_pp_prot(int key, int pp, int nx)return prot; } -static int ppc_hash32_pte_prot (PowerPCCPU *cpu, +static int ppc_hash32_pte_prot (int mmu_idx,target_ulong sr,ppc_hash_pte32_t pte) { -CPUPPCState *env = &cpu->env;unsigned pp, key; - key = !!(msr_pr ? (sr &SR32_KP ) : (sr &SR32_KS )); + key = !!(mmuidx_pr (mmu_idx) ? (sr &SR32_KP ) : (sr &SR32_KS )); pp = pte.pte1 &HPTE32_R_PP ;return ppc_hash32_pp_prot (key, pp, !!(sr &SR32_NX )); } -static target_ulong hash32_bat_size (PowerPCCPU *cpu, +static target_ulong hash32_bat_size (int mmu_idx,target_ulong batu,target_ulong batl) { -CPUPPCState *env = &cpu->env; - -if ((msr_pr && !(batu &BATU32_VP )) - || (!msr_pr && !(batu &BATU32_VS ))) { +if ((mmuidx_pr (mmu_idx) && !(batu &BATU32_VP )) + || (!mmuidx_pr (mmu_idx) && !(batu &BATU32_VS ))) {return 0 ; }
@@ -137,14 +135,13 @@ static target_ulong hash32_bat_601_size(PowerPCCPU *cpu,return BATU32_BEPI & ~((batl &BATL32_601_BL ) <<17 ); } -static int hash32_bat_601_prot (PowerPCCPU *cpu, +static int hash32_bat_601_prot (int mmu_idx,target_ulong batu,target_ulong batl) { -CPUPPCState *env = &cpu->env;int key, pp; pp = batu &BATU32_601_PP ; -if (msr_pr ==0 ) { +if (mmuidx_pr (mmu_idx) ==0 ) { key = !!(batu &BATU32_601_KS ); }else { key = !!(batu &BATU32_601_KP );
@@ -153,7 +150,8 @@ static int hash32_bat_601_prot(PowerPCCPU *cpu, }static hwaddr ppc_hash32_bat_lookup (PowerPCCPU *cpu,target_ulong ea, -MMUAccessType access_type,int *prot) +MMUAccessType access_type,int *prot, +int mmu_idx) {CPUPPCState *env = &cpu->env;target_ulong *BATlt, *BATut;
@@ -177,7 +175,7 @@ static hwaddr ppc_hash32_bat_lookup(PowerPCCPU *cpu, target_ulong ea,if (unlikely (env->mmu_model ==POWERPC_MMU_601 )) { mask =hash32_bat_601_size (cpu, batu, batl); }else { - mask =hash32_bat_size (cpu, batu, batl); + mask =hash32_bat_size (mmu_idx, batu, batl); } LOG_BATS("%s: %cBAT%d v " TARGET_FMT_lx " BATu " TARGET_FMT_lx " BATl " TARGET_FMT_lx "\n", __func__,
@@ -187,7 +185,7 @@ static hwaddr ppc_hash32_bat_lookup(PowerPCCPU *cpu, target_ulong ea,hwaddr raddr = (batl & mask) | (ea & ~mask);if (unlikely (env->mmu_model ==POWERPC_MMU_601 )) { - *prot =hash32_bat_601_prot (cpu, batu, batl); + *prot =hash32_bat_601_prot (mmu_idx, batu, batl); }else { *prot =hash32_bat_prot (cpu, batu, batl); }
@@ -224,12 +222,12 @@ static hwaddr ppc_hash32_bat_lookup(PowerPCCPU *cpu, target_ulong ea,static bool ppc_hash32_direct_store (PowerPCCPU *cpu,target_ulong sr,target_ulong eaddr,MMUAccessType access_type, -hwaddr *raddr,int *prot, +hwaddr *raddr,int *prot,int mmu_idx,bool guest_visible) {CPUState *cs =CPU (cpu);CPUPPCState *env = &cpu->env; -int key = !!(msr_pr ? (sr &SR32_KP ) : (sr &SR32_KS )); +int key = !!(mmuidx_pr (mmu_idx) ? (sr &SR32_KP ) : (sr &SR32_KS ));qemu_log_mask (CPU_LOG_MMU ,"direct store...\n" );
@@ -428,7 +426,7 @@ static hwaddr ppc_hash32_pte_raddr(target_ulong sr, ppc_hash_pte32_t pte, }bool ppc_hash32_xlate (PowerPCCPU *cpu,vaddr eaddr,MMUAccessType access_type, -hwaddr *raddrp,int *psizep,int *protp, +hwaddr *raddrp,int *psizep,int *protp,int mmu_idx,bool guest_visible) {CPUState *cs =CPU (cpu);
@@ -444,7 +442,7 @@ bool ppc_hash32_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAccessType access_type, *psizep =TARGET_PAGE_BITS ;/* 1. Handle real mode accesses */ -if (access_type ==MMU_INST_FETCH ? !msr_ir : !msr_dr) { +if (mmuidx_real (mmu_idx)) {/* Translation is off */ *raddrp = eaddr; *protp =PAGE_READ |PAGE_WRITE |PAGE_EXEC ;
@@ -455,7 +453,7 @@ bool ppc_hash32_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAccessType access_type,/* 2. Check Block Address Translation entries (BATs) */ if (env->nb_BATs !=0 ) { - raddr =ppc_hash32_bat_lookup (cpu, eaddr, access_type, protp); + raddr =ppc_hash32_bat_lookup (cpu, eaddr, access_type, protp, mmu_idx);if (raddr !=-1 ) {if (need_prot & ~*protp) {if (guest_visible) {
@@ -486,7 +484,7 @@ bool ppc_hash32_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAccessType access_type,/* 4. Handle direct store segments */ if (sr &SR32_T ) {return ppc_hash32_direct_store (cpu, sr, eaddr, access_type, - raddrp, protp, guest_visible); + raddrp, protp, mmu_idx, guest_visible); }/* 5. Check for segment level no-execute violation */
@@ -523,7 +521,7 @@ bool ppc_hash32_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAccessType access_type,/* 7. Check access permissions */ - prot =ppc_hash32_pte_prot (cpu, sr, pte); + prot =ppc_hash32_pte_prot (mmu_idx, sr, pte);if (need_prot & ~prot) {/* Access right violation */
target/ppc/mmu-hash32.h +1 -1
@@ -5,7 +5,7 @@hwaddr get_pteg_offset32 (PowerPCCPU *cpu,hwaddr hash);bool ppc_hash32_xlate (PowerPCCPU *cpu,vaddr eaddr,MMUAccessType access_type, -hwaddr *raddrp,int *psizep,int *protp, +hwaddr *raddrp,int *psizep,int *protp,int mmu_idx,bool guest_visible);/*
target/ppc/mmu_helper.c +1 -1
@@ -2914,7 +2914,7 @@ static bool ppc_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAccessType access_type,case POWERPC_MMU_32B :case POWERPC_MMU_601 :return ppc_hash32_xlate (cpu, eaddr, access_type, - raddrp, psizep, protp, guest_visible); + raddrp, psizep, protp, mmu_idx, guest_visible);default : return ppc_jumbo_xlate(cpu, eaddr, access_type, raddrp,
Signature · 1 line
2.31.1
[PULL 27/33] ppc/pegasos2: Use Virtual Open Firmware as firmware replacement
In reply to David GibsonFrom: BALATON Zoltan <[email protected]>
The pegasos2 board comes with an Open Firmware compliant ROM based on SmartFirmware but it has some changes that are not open source therefore the ROM binary cannot be included in QEMU. Guests running on the board however depend on services provided by the firmware. The Virtual Open Firmware recently added to QEMU implements a minimal set of these services to allow some guests to boot without the original firmware. This patch adds VOF as the default firmware for pegasos2 which allows booting Linux and MorphOS via -kernel option while a ROM image can still be used with -bios for guests that don't run with VOF.
Message-Id: <1d6ed6f290c5c1f0b5a1e1c51cf1151452d70d9a.1624811233.git.balaton@eik.bme.hu>
--- hw/ppc/Kconfig | 1 + hw/ppc/pegasos2.c | 602 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 601 insertions(+), 2 deletions(-)
hw/ppc/Kconfig +1 -0
@@ -76,6 +76,7 @@ config PEGASOS2 select VT82C686 select IDE_VIA select SMBUS_EEPROM + select VOF # This should come with VT82C686 select ACPI_X86
hw/ppc/pegasos2.c +600 -2
674 lines not on this page · raw message
Signature · 1 line
2.31.1
[PULL 32/33] linux-headers: Update
In reply to David GibsonFrom: Bharata B Rao <[email protected]>
Update to mainline commit: 79160a603bdb ("Merge tag 'usb-5.14-rc1' ofgit://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb"
Message-Id: <[email protected]>
--- include/standard-headers/asm-x86/kvm_para.h | 13 +++ include/standard-headers/drm/drm_fourcc.h | 7 ++ include/standard-headers/linux/ethtool.h | 4 +- .../linux/input-event-codes.h | 1 + include/standard-headers/linux/virtio_ids.h | 2 +- include/standard-headers/linux/virtio_vsock.h | 9 ++ linux-headers/asm-arm64/kvm.h | 11 ++ linux-headers/asm-generic/mman-common.h | 3 + linux-headers/asm-generic/unistd.h | 4 +- linux-headers/asm-mips/mman.h | 3 + linux-headers/asm-mips/unistd_n32.h | 1 + linux-headers/asm-mips/unistd_n64.h | 1 + linux-headers/asm-mips/unistd_o32.h | 1 + linux-headers/asm-powerpc/unistd_32.h | 1 + linux-headers/asm-powerpc/unistd_64.h | 1 + linux-headers/asm-s390/unistd_32.h | 1 + linux-headers/asm-s390/unistd_64.h | 1 + linux-headers/asm-x86/kvm.h | 13 +++ linux-headers/asm-x86/unistd_32.h | 7 +- linux-headers/asm-x86/unistd_64.h | 7 +- linux-headers/asm-x86/unistd_x32.h | 7 +- linux-headers/linux/kvm.h | 105 ++++++++++++++++++ linux-headers/linux/userfaultfd.h | 11 +- 23 files changed, 197 insertions(+), 17 deletions(-)
include/standard-headers/asm-x86/kvm_para.h +13 -0
@@ -33,6 +33,8 @@#define KVM_FEATURE_PV_SCHED_YIELD 13#define KVM_FEATURE_ASYNC_PF_INT 14#define KVM_FEATURE_MSI_EXT_DEST_ID 15 +#define KVM_FEATURE_HC_MAP_GPA_RANGE 16 +#define KVM_FEATURE_MIGRATION_CONTROL 17#define KVM_HINTS_REALTIME 0
@@ -54,6 +56,7 @@#define MSR_KVM_POLL_CONTROL 0x4b564d05#define MSR_KVM_ASYNC_PF_INT 0x4b564d06#define MSR_KVM_ASYNC_PF_ACK 0x4b564d07 +#define MSR_KVM_MIGRATION_CONTROL 0x4b564d08struct kvm_steal_time {uint64_t steal;
@@ -90,6 +93,16 @@ struct kvm_clock_pairing {/* MSR_KVM_ASYNC_PF_INT */ #define KVM_ASYNC_PF_VEC_MASK GENMASK(7, 0) +/* MSR_KVM_MIGRATION_CONTROL */ +#define KVM_MIGRATION_READY (1 << 0) + +/* KVM_HC_MAP_GPA_RANGE */ +#define KVM_MAP_GPA_RANGE_PAGE_SZ_4K 0 +#define KVM_MAP_GPA_RANGE_PAGE_SZ_2M (1 << 0) +#define KVM_MAP_GPA_RANGE_PAGE_SZ_1G (1 << 1) +#define KVM_MAP_GPA_RANGE_ENC_STAT (n) (n << 4) +#define KVM_MAP_GPA_RANGE_ENCRYPTED KVM_MAP_GPA_RANGE_ENC_STAT(1) +#define KVM_MAP_GPA_RANGE_DECRYPTED KVM_MAP_GPA_RANGE_ENC_STAT(0)/* Operations for KVM_HC_MMU_OP */ #define KVM_MMU_OP_WRITE_PTE 1
include/standard-headers/drm/drm_fourcc.h +7 -0
@@ -167,6 +167,13 @@ extern "C" {#define DRM_FORMAT_RGBA1010102 fourcc_code('R', 'A', '3', '0')/* [31:0] R:G:B:A 10:10:10:2 little endian */ #define DRM_FORMAT_BGRA1010102 fourcc_code('B', 'A', '3', '0')/* [31:0] B:G:R:A 10:10:10:2 little endian */ +/* 64 bpp RGB */ +#define DRM_FORMAT_XRGB16161616 fourcc_code('X', 'R', '4', '8')/* [63:0] x:R:G:B 16:16:16:16 little endian */ +#define DRM_FORMAT_XBGR16161616 fourcc_code('X', 'B', '4', '8')/* [63:0] x:B:G:R 16:16:16:16 little endian */ + +#define DRM_FORMAT_ARGB16161616 fourcc_code('A', 'R', '4', '8')/* [63:0] A:R:G:B 16:16:16:16 little endian */ +#define DRM_FORMAT_ABGR16161616 fourcc_code('A', 'B', '4', '8')/* [63:0] A:B:G:R 16:16:16:16 little endian */ +/* * Floating point 64bpp RGB * IEEE 754-2008 binary16 half-precision float
include/standard-headers/linux/ethtool.h +2 -2
@@ -233,7 +233,7 @@ enum tunable_id {ETHTOOL_PFC_PREVENTION_TOUT ,/* timeout in msecs */ /* * Add your fresh new tunable attribute above and remember to update -* tunable_strings[] in net/core/ethtool.c +* tunable_strings[] in net/ethtool/common.c */ __ETHTOOL_TUNABLE_COUNT, };
@@ -297,7 +297,7 @@ enum phy_tunable_id {ETHTOOL_PHY_EDPD ,/* * Add your fresh new phy tunable attribute above and remember to update -* phy_tunable_strings[] in net/core/ethtool.c +* phy_tunable_strings[] in net/ethtool/common.c */ __ETHTOOL_PHY_TUNABLE_COUNT, };
include/standard-headers/linux/input-event-codes.h +1 -0
@@ -611,6 +611,7 @@#define KEY_VOICECOMMAND 0x246/* Listening Voice Command */ #define KEY_ASSISTANT 0x247/* AL Context-aware desktop assistant */ #define KEY_KBD_LAYOUT_NEXT 0x248/* AC Next Keyboard Layout Select */ +#define KEY_EMOJI_PICKER 0x249/* Show/hide emoji picker (HUTRR101) */ #define KEY_BRIGHTNESS_MIN 0x250/* Set Brightness to Minimum */ #define KEY_BRIGHTNESS_MAX 0x251/* Set Brightness to Maximum */
include/standard-headers/linux/virtio_ids.h +1 -1
@@ -54,7 +54,7 @@#define VIRTIO_ID_SOUND 25/* virtio sound */ #define VIRTIO_ID_FS 26/* virtio filesystem */ #define VIRTIO_ID_PMEM 27/* virtio pmem */ -#define VIRTIO_ID_BT 28/* virtio bluetooth */ #define VIRTIO_ID_MAC80211_HWSIM 29/* virtio mac80211-hwsim */ +#define VIRTIO_ID_BT 40/* virtio bluetooth */ #endif /* _LINUX_VIRTIO_IDS_H */
include/standard-headers/linux/virtio_vsock.h +9 -0
@@ -38,6 +38,9 @@#include "standard-headers/linux/virtio_ids.h" #include "standard-headers/linux/virtio_config.h" +/* The feature bitmap for virtio vsock */ +#define VIRTIO_VSOCK_F_SEQPACKET 1/* SOCK_SEQPACKET supported */ +struct virtio_vsock_config {uint64_t guest_cid; }QEMU_PACKED ;
@@ -65,6 +68,7 @@ struct virtio_vsock_hdr {enum virtio_vsock_type {VIRTIO_VSOCK_TYPE_STREAM =1 , +VIRTIO_VSOCK_TYPE_SEQPACKET =2 , };enum virtio_vsock_op {
@@ -91,4 +95,9 @@ enum virtio_vsock_shutdown { VIRTIO_VSOCK_SHUTDOWN_SEND = 2, }; +/* VIRTIO_VSOCK_OP_RW flags values */ +enum virtio_vsock_rw { +VIRTIO_VSOCK_SEQ_EOR =1 , +}; +#endif /* _LINUX_VIRTIO_VSOCK_H */
linux-headers/asm-arm64/kvm.h +11 -0
@@ -184,6 +184,17 @@ struct kvm_vcpu_events {__u32 reserved[12 ]; }; +struct kvm_arm_copy_mte_tags { +__u64 guest_ipa; +__u64 length; +void *addr; +__u64 flags; +__u64 reserved[2 ]; +}; + +#define KVM_ARM_TAGS_TO_GUEST 0 +#define KVM_ARM_TAGS_FROM_GUEST 1 +/* If you need to interpret the index values, here is the key: */ #define KVM_REG_ARM_COPROC_MASK 0x000000000FFF0000#define KVM_REG_ARM_COPROC_SHIFT 16
linux-headers/asm-generic/mman-common.h +3 -0
@@ -72,6 +72,9 @@#define MADV_COLD 20/* deactivate these pages */ #define MADV_PAGEOUT 21/* reclaim these pages */ +#define MADV_POPULATE_READ 22/* populate (prefault) page tables readable */ +#define MADV_POPULATE_WRITE 23/* populate (prefault) page tables writable */ +/* compatibility flags */ #define MAP_FILE 0
linux-headers/asm-generic/unistd.h +2 -2
@@ -863,8 +863,8 @@ __SYSCALL(__NR_process_madvise, sys_process_madvise) __SC_COMP(__NR_epoll_pwait2, sys_epoll_pwait2, compat_sys_epoll_pwait2)#define __NR_mount_setattr 442 __SYSCALL(__NR_mount_setattr, sys_mount_setattr) -#define __NR_quotactl_path 443 -__SYSCALL(__NR_quotactl_path, sys_quotactl_path) +#define __NR_quotactl_fd 443 +__SYSCALL(__NR_quotactl_fd, sys_quotactl_fd)#define __NR_landlock_create_ruleset 444__SYSCALL (__NR_landlock_create_ruleset, sys_landlock_create_ruleset)
linux-headers/asm-mips/mman.h +3 -0
@@ -98,6 +98,9 @@#define MADV_COLD 20/* deactivate these pages */ #define MADV_PAGEOUT 21/* reclaim these pages */ +#define MADV_POPULATE_READ 22/* populate (prefault) page tables readable */ +#define MADV_POPULATE_WRITE 23/* populate (prefault) page tables writable */ +/* compatibility flags */ #define MAP_FILE 0
linux-headers/asm-mips/unistd_n32.h +1 -0
@@ -372,6 +372,7 @@#define __NR_process_madvise (__NR_Linux + 440)#define __NR_epoll_pwait2 (__NR_Linux + 441)#define __NR_mount_setattr (__NR_Linux + 442) +#define __NR_quotactl_fd (__NR_Linux + 443)#define __NR_landlock_create_ruleset (__NR_Linux + 444)#define __NR_landlock_add_rule (__NR_Linux + 445)#define __NR_landlock_restrict_self (__NR_Linux + 446)
linux-headers/asm-mips/unistd_n64.h +1 -0
@@ -348,6 +348,7 @@#define __NR_process_madvise (__NR_Linux + 440)#define __NR_epoll_pwait2 (__NR_Linux + 441)#define __NR_mount_setattr (__NR_Linux + 442) +#define __NR_quotactl_fd (__NR_Linux + 443)#define __NR_landlock_create_ruleset (__NR_Linux + 444)#define __NR_landlock_add_rule (__NR_Linux + 445)#define __NR_landlock_restrict_self (__NR_Linux + 446)
linux-headers/asm-mips/unistd_o32.h +1 -0
@@ -418,6 +418,7 @@#define __NR_process_madvise (__NR_Linux + 440)#define __NR_epoll_pwait2 (__NR_Linux + 441)#define __NR_mount_setattr (__NR_Linux + 442) +#define __NR_quotactl_fd (__NR_Linux + 443)#define __NR_landlock_create_ruleset (__NR_Linux + 444)#define __NR_landlock_add_rule (__NR_Linux + 445)#define __NR_landlock_restrict_self (__NR_Linux + 446)
linux-headers/asm-powerpc/unistd_32.h +1 -0
@@ -425,6 +425,7 @@#define __NR_process_madvise 440#define __NR_epoll_pwait2 441#define __NR_mount_setattr 442 +#define __NR_quotactl_fd 443#define __NR_landlock_create_ruleset 444#define __NR_landlock_add_rule 445#define __NR_landlock_restrict_self 446
linux-headers/asm-powerpc/unistd_64.h +1 -0
@@ -397,6 +397,7 @@#define __NR_process_madvise 440#define __NR_epoll_pwait2 441#define __NR_mount_setattr 442 +#define __NR_quotactl_fd 443#define __NR_landlock_create_ruleset 444#define __NR_landlock_add_rule 445#define __NR_landlock_restrict_self 446
linux-headers/asm-s390/unistd_32.h +1 -0
@@ -415,6 +415,7 @@#define __NR_process_madvise 440#define __NR_epoll_pwait2 441#define __NR_mount_setattr 442 +#define __NR_quotactl_fd 443#define __NR_landlock_create_ruleset 444#define __NR_landlock_add_rule 445#define __NR_landlock_restrict_self 446
linux-headers/asm-s390/unistd_64.h +1 -0
@@ -363,6 +363,7 @@#define __NR_process_madvise 440#define __NR_epoll_pwait2 441#define __NR_mount_setattr 442 +#define __NR_quotactl_fd 443#define __NR_landlock_create_ruleset 444#define __NR_landlock_add_rule 445#define __NR_landlock_restrict_self 446
linux-headers/asm-x86/kvm.h +13 -0
@@ -159,6 +159,19 @@ struct kvm_sregs {__u64 interrupt_bitmap[(KVM_NR_INTERRUPTS +63 ) /64 ]; }; +struct kvm_sregs2 { +/* out (KVM_GET_SREGS2) / in (KVM_SET_SREGS2) */ +struct kvm_segment cs, ds, es, fs, gs, ss; +struct kvm_segment tr, ldt; +struct kvm_dtable gdt, idt; +__u64 cr0, cr2, cr3, cr4, cr8; +__u64 efer; +__u64 apic_base; +__u64 flags; +__u64 pdptrs[4 ]; +}; +#define KVM_SREGS2_FLAGS_PDPTRS_VALID 1 +/* for KVM_GET_FPU and KVM_SET_FPU */ struct kvm_fpu {__u8 fpr[8 ][16 ];
linux-headers/asm-x86/unistd_32.h +4 -3
@@ -1,5 +1,5 @@ -#ifndef _ASM_X86_UNISTD_32_H -#define _ASM_X86_UNISTD_32_H 1 +#ifndef _ASM_UNISTD_32_H +#define _ASM_UNISTD_32_H#define __NR_restart_syscall 0#define __NR_exit 1
@@ -433,9 +433,10 @@#define __NR_process_madvise 440#define __NR_epoll_pwait2 441#define __NR_mount_setattr 442 +#define __NR_quotactl_fd 443#define __NR_landlock_create_ruleset 444#define __NR_landlock_add_rule 445#define __NR_landlock_restrict_self 446 -#endif /* _ASM_X86_UNISTD_32_H */ +#endif /* _ASM_UNISTD_32_H */
linux-headers/asm-x86/unistd_64.h +4 -3
@@ -1,5 +1,5 @@ -#ifndef _ASM_X86_UNISTD_64_H -#define _ASM_X86_UNISTD_64_H 1 +#ifndef _ASM_UNISTD_64_H +#define _ASM_UNISTD_64_H#define __NR_read 0#define __NR_write 1
@@ -355,9 +355,10 @@#define __NR_process_madvise 440#define __NR_epoll_pwait2 441#define __NR_mount_setattr 442 +#define __NR_quotactl_fd 443#define __NR_landlock_create_ruleset 444#define __NR_landlock_add_rule 445#define __NR_landlock_restrict_self 446 -#endif /* _ASM_X86_UNISTD_64_H */ +#endif /* _ASM_UNISTD_64_H */
linux-headers/asm-x86/unistd_x32.h +4 -3
@@ -1,5 +1,5 @@ -#ifndef _ASM_X86_UNISTD_X32_H -#define _ASM_X86_UNISTD_X32_H 1 +#ifndef _ASM_UNISTD_X32_H +#define _ASM_UNISTD_X32_H#define __NR_read (__X32_SYSCALL_BIT + 0)#define __NR_write (__X32_SYSCALL_BIT + 1)
@@ -308,6 +308,7 @@#define __NR_process_madvise (__X32_SYSCALL_BIT + 440)#define __NR_epoll_pwait2 (__X32_SYSCALL_BIT + 441)#define __NR_mount_setattr (__X32_SYSCALL_BIT + 442) +#define __NR_quotactl_fd (__X32_SYSCALL_BIT + 443)#define __NR_landlock_create_ruleset (__X32_SYSCALL_BIT + 444)#define __NR_landlock_add_rule (__X32_SYSCALL_BIT + 445)#define __NR_landlock_restrict_self (__X32_SYSCALL_BIT + 446)
@@ -349,4 +350,4 @@#define __NR_pwritev2 (__X32_SYSCALL_BIT + 547) -#endif /* _ASM_X86_UNISTD_X32_H */ +#endif /* _ASM_UNISTD_X32_H */
linux-headers/linux/kvm.h +105 -0
139 lines not on this page · raw message
linux-headers/linux/userfaultfd.h +8 -3
@@ -31,7 +31,8 @@ UFFD_FEATURE_MISSING_SHMEM | \ UFFD_FEATURE_SIGBUS | \ UFFD_FEATURE_THREAD_ID | \ - UFFD_FEATURE_MINOR_HUGETLBFS) + UFFD_FEATURE_MINOR_HUGETLBFS | \ + UFFD_FEATURE_MINOR_SHMEM)#define UFFD_API_IOCTLS \ ((__u64)1 << _UFFDIO_REGISTER | \ (__u64)1 << _UFFDIO_UNREGISTER | \
@@ -80,8 +81,8 @@ struct uffdio_zeropage)#define UFFDIO_WRITEPROTECT _IOWR(UFFDIO, _UFFDIO_WRITEPROTECT, \ struct uffdio_writeprotect) -#define UFFDIO_CONTINUE _IOR(UFFDIO, _UFFDIO_CONTINUE, \ - struct uffdio_continue) +#define UFFDIO_CONTINUE _IOWR(UFFDIO, _UFFDIO_CONTINUE, \ + struct uffdio_continue)/* read() structure */ struct uffd_msg {
@@ -185,6 +186,9 @@ struct uffdio_api {* UFFD_FEATURE_MINOR_HUGETLBFS indicates that minor faults * can be intercepted (via REGISTER_MODE_MINOR) for * hugetlbfs-backed pages. +* +* UFFD_FEATURE_MINOR_SHMEM indicates the same support as +* UFFD_FEATURE_MINOR_HUGETLBFS, but for shmem-backed pages instead. */ #define UFFD_FEATURE_PAGEFAULT_FLAG_WP (1<<0)#define UFFD_FEATURE_EVENT_FORK (1<<1)
@@ -196,6 +200,7 @@ struct uffdio_api {#define UFFD_FEATURE_SIGBUS (1<<7)#define UFFD_FEATURE_THREAD_ID (1<<8)#define UFFD_FEATURE_MINOR_HUGETLBFS (1<<9) +#define UFFD_FEATURE_MINOR_SHMEM (1<<10)__u64 features;__u64 ioctls;
Signature · 1 line
2.31.1
[PULL 26/33] target/ppc/spapr: Update H_GET_CPU_CHARACTERISTICS L1D cache flush bits
In reply to David GibsonFrom: Nicholas Piggin <[email protected]>
There are several new L1D cache flush bits added to the hcall which reflect hardware security features for speculative cache access issues.
These behaviours are now being specified as negative in order to simplify patched kernel compatibility with older firmware (a new problem found in existing systems would automatically be vulnerable).
[dwg: Technically this changes behaviour for existing machine types.
After discussion with Nick, we've determined this is safe, because the worst that will happen if a guest gets the wrong information due to a migration is that it will perform some unnecessary workarounds, but will remain correct and secure (well, as secure as it was going to be anyway). In addition the change only affects cap-cfpc=safe which is not enabled by default, and in fact is not possible to set on any current hardware (though it's expected it will be possible on POWER10)]
Message-Id: <[email protected]>
--- hw/ppc/spapr_hcall.c | 2 ++ include/hw/ppc/spapr.h | 3 +++ 2 files changed, 5 insertions(+)
hw/ppc/spapr_hcall.c +2 -0
@@ -1318,6 +1318,8 @@ static target_ulong h_get_cpu_characteristics(PowerPCCPU *cpu, behaviour |=H_CPU_BEHAV_L1D_FLUSH_PR ;break ;case SPAPR_CAP_FIXED : + behaviour |=H_CPU_BEHAV_NO_L1D_FLUSH_ENTRY ; + behaviour |=H_CPU_BEHAV_NO_L1D_FLUSH_UACCESS ;break ;default :/* broken */ assert (safe_cache ==SPAPR_CAP_BROKEN );
include/hw/ppc/spapr.h +3 -0
@@ -400,10 +400,13 @@ struct SpaprMachineState {#define H_CPU_CHAR_THR_RECONF_TRIG PPC_BIT(6)#define H_CPU_CHAR_CACHE_COUNT_DIS PPC_BIT(7)#define H_CPU_CHAR_BCCTR_FLUSH_ASSIST PPC_BIT(9) +#define H_CPU_BEHAV_FAVOUR_SECURITY PPC_BIT(0)#define H_CPU_BEHAV_L1D_FLUSH_PR PPC_BIT(1)#define H_CPU_BEHAV_BNDS_CHK_SPEC_BAR PPC_BIT(2)#define H_CPU_BEHAV_FLUSH_COUNT_CACHE PPC_BIT(5) +#define H_CPU_BEHAV_NO_L1D_FLUSH_ENTRY PPC_BIT(7) +#define H_CPU_BEHAV_NO_L1D_FLUSH_UACCESS PPC_BIT(8)/* Each control block has to be on a 4K boundary */ #define H_CB_ALIGNMENT 4096
Signature · 1 line
2.31.1
[PULL 29/33] ppc/pegasos2: Implement some RTAS functions with VOF
In reply to David GibsonFrom: BALATON Zoltan <[email protected]>
Linux uses RTAS functions to access PCI devices so we need to provide these with VOF. Implement some of the most important functions to allow booting Linux with VOF. With this the board is now usable without a binary ROM image and we can enable it by default as other boards.
Message-Id: <[email protected]>
--- default-configs/devices/ppc-softmmu.mak | 2 +- hw/ppc/pegasos2.c | 137 ++++++++++++++++++++++++ 2 files changed, 138 insertions(+), 1 deletion(-)
default-configs/devices/ppc-softmmu.mak +1 -1
@@ -14,7 +14,7 @@ CONFIG_SAM460EX=y CONFIG_MAC_OLDWORLD=y CONFIG_MAC_NEWWORLD=y -CONFIG_PEGASOS2=n +CONFIG_PEGASOS2=y # For PReP CONFIG_PREP=y
hw/ppc/pegasos2.c +137 -0
167 lines not on this page · raw message
Signature · 1 line
2.31.1
[PULL 31/33] spapr: Fix implementation of Open Firmware client interface
In reply to David GibsonFrom: Alexey Kardashevskiy <[email protected]>
This addresses the comments from v22.
The functional changes are (the VOF ones need retesting with Pegasos2):
(VOF) setprop will start failing if the machine class callback did not handle it;
(VOF) unit addresses are lowered in path_offset(); (SPAPR) /chosen/bootargs is initialized from kernel_cmdline if the client did not change it.
Message-Id: <[email protected]>
--- MAINTAINERS | 4 ++-- hw/ppc/spapr.c | 10 +--------- hw/ppc/spapr_hcall.c | 5 ++--- hw/ppc/spapr_vof.c | 32 +++++++++++++++++++++++--------- hw/ppc/vof.c | 30 +++++++++++++++++------------- include/hw/ppc/spapr.h | 3 +-- pc-bios/vof.bin | Bin 3784 -> 3456 bytes pc-bios/vof/ci.c | 2 +- pc-bios/vof/libc.c | 26 -------------------------- pc-bios/vof/main.c | 2 +- pc-bios/vof/vof.h | 2 -- 11 files changed, 48 insertions(+), 68 deletions(-)
MAINTAINERS +2 -2
@@ -1362,8 +1362,8 @@ F: include/hw/pci-host/mv64361.h Virtual Open Firmware (VOF) M: Alexey Kardashevskiy <[email protected]> -M: David Gibson <[email protected]> -M: Greg Kurz <[email protected]> +R: David Gibson <[email protected]> +R: Greg Kurz <[email protected]> L: [email protected] S: Maintained F: hw/ppc/spapr_vof*
hw/ppc/spapr.c +1 -9
@@ -1645,15 +1645,7 @@ static void spapr_machine_reset(MachineState *machine) fdt =spapr_build_fdt (spapr, true,FDT_MAX_SIZE );if (spapr->vof) { -target_ulong stack_ptr =0 ; - -spapr_vof_reset (spapr, fdt, &stack_ptr, &error_fatal); - -spapr_cpu_set_entry_state (first_ppc_cpu,SPAPR_ENTRY_POINT , - stack_ptr, spapr->initrd_base, - spapr->initrd_size); -/* VOF is 32bit BE so enforce MSR here */ - first_ppc_cpu->env.msr &= ~((1ULL <<MSR_SF ) | (1ULL <<MSR_LE )); +spapr_vof_reset (spapr, fdt, &error_fatal);/* * Do not pack the FDT as the client may change properties. * VOF client does not expect the FDT so we do not load it to the VM.
hw/ppc/spapr_hcall.c +2 -3
@@ -1080,7 +1080,7 @@ target_ulong do_client_architecture_support(PowerPCCPU *cpu,SpaprOptionVector *ov1_guest, *ov5_guest;bool guest_radix;bool raw_mode_supported = false; -bool guest_xive, reset_fdt = false; +bool guest_xive;CPUState *cs;void *fdt;uint32_t max_compat = spapr->max_compat_pvr;
@@ -1233,8 +1233,7 @@ target_ulong do_client_architecture_support(PowerPCCPU *cpu,spapr_setup_hpt (spapr); } - reset_fdt = spapr->vof !=NULL ; - fdt =spapr_build_fdt (spapr, reset_fdt, fdt_bufsize); + fdt =spapr_build_fdt (spapr, spapr->vof !=NULL , fdt_bufsize);g_free (spapr->fdt_blob); spapr->fdt_size =fdt_totalsize (fdt); spapr->fdt_initial_size = spapr->fdt_size;
hw/ppc/spapr_vof.c +23 -9
@@ -8,6 +8,7 @@#include "qapi/error.h" #include "hw/ppc/spapr.h" #include "hw/ppc/spapr_vio.h" +#include "hw/ppc/spapr_cpu_core.h" #include "hw/ppc/fdt.h" #include "hw/ppc/vof.h" #include "sysemu/sysemu.h"
@@ -29,13 +30,19 @@ target_ulong spapr_h_vof_client(PowerPCCPU *cpu, SpaprMachineState *spapr,void spapr_vof_client_dt_finalize (SpaprMachineState *spapr,void *fdt) {char *stdout_path =spapr_vio_stdout_path (spapr->vio_bus); -int chosen;vof_build_dt (fdt, spapr->vof); -_FDT (chosen =fdt_path_offset (fdt,"/chosen" )); -_FDT (fdt_setprop_string (fdt, chosen,"bootargs" , - spapr->vof->bootargs ? :"" )); +if (spapr->vof->bootargs) { +int chosen; + +_FDT (chosen =fdt_path_offset (fdt,"/chosen" )); +/* +* If the client did not change "bootargs", spapr_dt_chosen() must have +* stored machine->kernel_cmdline in it before getting here. +*/ +_FDT (fdt_setprop_string (fdt, chosen,"bootargs" , spapr->vof->bootargs)); + }/* * SLOF-less setup requires an open instance of stdout for early
@@ -48,20 +55,21 @@ void spapr_vof_client_dt_finalize(SpaprMachineState *spapr, void *fdt) } } -void spapr_vof_reset (SpaprMachineState *spapr,void *fdt, -target_ulong *stack_ptr,Error **errp) +void spapr_vof_reset (SpaprMachineState *spapr,void *fdt,Error **errp) { +target_ulong stack_ptr;Vof *vof = spapr->vof; +PowerPCCPU *first_ppc_cpu =POWERPC_CPU (first_cpu);vof_init (vof, spapr->rma_size, errp); - *stack_ptr =vof_claim (vof,0 ,VOF_STACK_SIZE ,VOF_STACK_SIZE ); -if (*stack_ptr ==-1 ) { + stack_ptr =vof_claim (vof,0 ,VOF_STACK_SIZE ,VOF_STACK_SIZE ); +if (stack_ptr ==-1 ) {error_setg (errp,"Memory allocation for stack failed" );return ; }/* Stack grows downwards plus reserve space for the minimum stack frame */ - *stack_ptr +=VOF_STACK_SIZE -0x20 ; + stack_ptr +=VOF_STACK_SIZE -0x20 ;if (spapr->kernel_size &&vof_claim (vof, spapr->kernel_addr, spapr->kernel_size,0 ) ==-1 ) {
@@ -77,6 +85,12 @@ void spapr_vof_reset(SpaprMachineState *spapr, void *fdt,spapr_vof_client_dt_finalize (spapr, fdt); +spapr_cpu_set_entry_state (first_ppc_cpu,SPAPR_ENTRY_POINT , + stack_ptr, spapr->initrd_base, + spapr->initrd_size); +/* VOF is 32bit BE so enforce MSR here */ + first_ppc_cpu->env.msr &= ~((1ULL <<MSR_SF ) | (1ULL <<MSR_LE )); +/* * At this point the expected allocation map is: *
hw/ppc/vof.c +17 -13
@@ -144,15 +144,16 @@ static int path_offset(const void *fdt, const char *path)* the lower case forms of the hexadecimal digits in the range a..f, * suppressing leading zeros". */ - at =strchr (path,'@' ); -if (!at) { -return fdt_path_offset (fdt, path); - } - p =g_strdup (path); -for (at = at - path + p +1 ; *at; ++at) { - *at =tolower (*at); +for (at =strchr (p,'@' ); at && *at; ) { +if (*at =='/' ) { + at =strchr (at,'@' ); + }else { + *at =tolower (*at); + ++at; + } } +return fdt_path_offset (fdt, p); }
@@ -300,6 +301,7 @@ static uint32_t vof_setprop(MachineState *ms, void *fdt, Vof *vof,char trval[64 ] ="" ;char nodepath[VOF_MAX_PATH ] ="" ;Object *vmo =object_dynamic_cast (OBJECT (ms),TYPE_VOF_MACHINE_IF ); +VofMachineIfClass *vmc; g_autofree char *val = NULL;if (vallen >VOF_MAX_SETPROPLEN ) {
@@ -322,13 +324,13 @@ static uint32_t vof_setprop(MachineState *ms, void *fdt, Vof *vof, goto trace_exit; } -if (vmo) { -VofMachineIfClass *vmc =VOF_MACHINE_GET_CLASS (vmo); +if (!vmo) { + goto trace_exit; + } -if (vmc->setprop && - !vmc->setprop (ms, nodepath, propname, val, vallen)) { - goto trace_exit; - } + vmc =VOF_MACHINE_GET_CLASS (vmo); +if (!vmc->setprop || !vmc->setprop (ms, nodepath, propname, val, vallen)) { + goto trace_exit; } ret =fdt_setprop (fdt, offset, propname, val, vallen);
@@ -919,6 +921,8 @@ static uint32_t vof_client_handle(MachineState *ms, void *fdt, Vof *vof, ret =-1 ; } +#undef cmpserv +return ret; }
include/hw/ppc/spapr.h +1 -2
@@ -964,8 +964,7 @@ void spapr_set_all_lpcrs(target_ulong value, target_ulong mask);hwaddr spapr_get_rtas_addr (void );bool spapr_memory_hot_unplug_supported (SpaprMachineState *spapr); -void spapr_vof_reset (SpaprMachineState *spapr,void *fdt, -target_ulong *stack_ptr,Error **errp); +void spapr_vof_reset (SpaprMachineState *spapr,void *fdt,Error **errp);void spapr_vof_quiesce (MachineState *ms);bool spapr_vof_setprop (MachineState *ms,const char *path,const char *propname,void *val,int vallen);
pc-bios/vof.bin binary +0 -0
pc-bios/vof/ci.c +1 -1
@@ -69,7 +69,7 @@ static int call_ci(const char *service, int nargs, int nret, ...) }if (ci_entry ((uint32_t )(&args)) <0 ) { -return PROM_ERROR ; +return -1 ; }return (nret >0 ) ? args.args[nargs] :0 ;
pc-bios/vof/libc.c +0 -26
@@ -54,32 +54,6 @@ int memcmp(const void *ptr1, const void *ptr2, size_t n)return 0 ; } -void *memmove (void *dest,const void *src,size_t n) -{ -char *cdest; -const char *csrc; -int i; - -/* Do the buffers overlap in a bad way? */ -if (src < dest && src + n >= dest) { -/* Copy from end to start */ - cdest = dest + n -1 ; - csrc = src + n -1 ; -for (i =0 ; i < n; i++) { - *cdest-- = *csrc--; - } - }else { -/* Normal copy is possible */ - cdest = dest; - csrc = src; -for (i =0 ; i < n; i++) { - *cdest++ = *csrc++; - } - } - -return dest; -} -void *memset (void *dest,int c,size_t size) {unsigned char *d = (unsigned char *)dest;
pc-bios/vof/main.c +1 -1
@@ -6,7 +6,7 @@ void do_boot(unsigned long addr, unsigned long _r3, unsigned long _r4) register unsigned long r4 __asm__("r4") = _r4; register unsigned long r5 __asm__("r5") = (unsigned long) _prom_entry; - ((client *)(uint32_t )addr)(); + ((void (*)(void ))(uint32_t )addr)(); }void entry_c (void )
pc-bios/vof/vof.h +0 -2
@@ -10,11 +10,9 @@ typedef unsigned short uint16_t;typedef unsigned long uint32_t ;typedef unsigned long long uint64_t ;#define NULL (0) -#define PROM_ERROR (-1u)typedef unsigned long ihandle ;typedef unsigned long phandle ;typedef int size_t ; -typedef void client (void );/* globals */ extern void _prom_entry (void );/* OF CI entry point (i.e. this firmware) */
Signature · 1 line
2.31.1
Peter Maydell
AppliedQuoted 16 lines · David Gibson
The following changes since commit
9db3065c62a983286d06c207f4981408cf42184d:Merge remote-tracking branch 'remotes/vivier2/tags/linux-user-for-6.1-pull-request' into staging (2021-07-08 16:30:18 +0100)
are available in the Git repository at:
https://gitlab.com/dgibson/qemu.git tags/ppc-for-6.1-20210709
for you to fetch changes up to
82123b756a1a2f1965350e5794aaa7b5c6a15282:target/ppc: Support for
H_RPT_INVALIDATEhcall (2021-07-09 11:01:06 +1000)----------------------------------------------------------------
ppc patch queue 2021-07-09
Quoted 16 lines
Here's a (probably) final pull request before the qemu-6.1 soft freeze. Includes:
* Implementation of the newH_RPT_INVALIDATEhypercall
* Virtual Open Firmware for pSeries and pegasos2 machine types. This is an experimental minimal Open Firmware implementation which works by delegating nearly everything to qemu itself via a special hypercall.
* A number of cleanups to the ppc soft MMU code
* Fix to handling of two-level radix mode translations for the powernv machine type
* Update theH_GET_CPU_CHARACTERISTICScall with newly defined bits. This will allow more flexible handling of possible future CPU Spectre-like flaws
* Correctly treat mtmsrd as an illegal instruction on BookE cpus
* Firmware update for the ppce500 machine type
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/6.1
for any user-visible changes.
-- PMM