tcg: Unassorted patch set
cover tcg: Unassorted patch set
Few TCG-related patches I have queued, not sure is posting them appart would help review.
Philippe Mathieu-Daudé (5):
tcg: Include missing 'qemu/bitops.h' header in tcg-gvec-desc.h target/arm/ptw: Restrict PMSAv8 code to TCG
target/ppc: Restrict TCGTBCPUState to TCG
target/or1k: Have exception_helper.c absorb exception.c accel/tcg: Remove pre-vCPU ignore_memory_transaction_failures flag
include/hw/core/cpu.h | 2 -- include/system/tcg.h | 2 ++ include/tcg/tcg-gvec-desc.h | 2 ++ target/or1k/exception.h | 2 +- target/ppc/internal.h | 5 ++++- accel/stubs/tcg-stub.c | 1 + accel/tcg/cputlb.c | 9 +++++++-- hw/core/cpu-common.c | 15 --------------- hw/core/machine.c | 5 +++++ target/arm/ptw.c | 20 +++++++++++++++++++- target/or1k/exception.c | 30 ------------------------------ target/or1k/exception_helper.c | 13 +++++++++++-- target/ppc/helper_regs.c | 3 ++- target/or1k/meson.build | 1 - 14 files changed, 54 insertions(+), 56 deletions(-) delete mode 100644 target/or1k/exception.c
Signature · 1 line
2.53.0
PATCH 1/5 tcg: Include missing 'qemu/bitops.h' header in tcg-gvec-desc.h
Include the missing 'qemu/bitops.h' header to avoid when refactoring unrelated headers:
In file included from target/arm/internals.h:34:
include/tcg/tcg-gvec-desc.h:48:12: error: call to undeclared function 'extract32'
48 | return extract32(desc, SIMD_MAXSZ_SHIFT, SIMD_MAXSZ_BITS) * 8 + 8;
| ^--- include/tcg/tcg-gvec-desc.h | 2 ++ 1 file changed, 2 insertions(+)
include/tcg/tcg-gvec-desc.h +2 -0
@@ -20,6 +20,8 @@#ifndef TCG_TCG_GVEC_DESC_H #define TCG_TCG_GVEC_DESC_H +#include "qemu/bitops.h" +/* * This configuration allows MAXSZ to represent 2048 bytes, and * OPRSZ to match MAXSZ, or represent the smaller values 8, 16, or 32.
Signature · 1 line
2.53.0
Re: [PATCH 1/5] tcg: Include missing 'qemu/bitops.h' header in tcg-gvec-desc.h
Quoted 18 lines · Philippe Mathieu-Daudé
Include the missing '
qemu/bitops.h' header to avoid when refactoring unrelated headers:In file included from
target/arm/internals.h:34:
include/tcg/tcg-gvec-desc.h:48:12: error: call to undeclared function 'extract32'48 | return extract32(desc, SIMD_MAXSZ_SHIFT, SIMD_MAXSZ_BITS) * 8 + 8; | ^Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/tcg/tcg-gvec-desc.h | 2 ++ 1 file changed, 2 insertions(+)include/tcg/tcg-gvec-desc.h +0
-0
include/tcg/tcg-gvec-desc.h line 27
Quoted 8 lines
include/tcg/tcg-gvec-desc.h +2
-0@@ -20,6 +20,8 @@#ifndef TCG_TCG_GVEC_DESC_H #define TCG_TCG_GVEC_DESC_H +#include "qemu/bitops.h" +/* * This configuration allows MAXSZ to represent 2048 bytes, and * OPRSZ to match MAXSZ, or represent the smaller values 8, 16, or 32.
r~
PATCH 2/5 target/arm/ptw: Restrict PMSAv8 code to TCG
In reply to Philippe Mathieu-DaudéArmv8-M Protected Memory System Architecture can only be emulated, therefore restrict it to TCG to avoid compiling it on hardware accelerators.
--- target/arm/ptw.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
target/arm/ptw.c +19 -1
@@ -13,11 +13,13 @@#include "exec/page-protection.h" #include "exec/target_page.h" #include "exec/tlb-flags.h" +#ifdef CONFIG_TCG #include "accel/tcg/probe.h" +#include "target/arm/tcg/idau.h" +#endif #include "cpu.h" #include "internals.h" #include "cpu-features.h" -#include "target/arm/tcg/idau.h" typedef struct S1Translate { /*
@@ -2818,6 +2820,8 @@ static bool get_phys_addr_pmsav7(CPUARMState *env,return (ptw->in_prot_check & ~result->f.prot) ==0 ; } +#ifdef CONFIG_TCG +static uint32_t *regime_rbar (CPUARMState *env,ARMMMUIdx mmu_idx,uint32_t secure) {
@@ -3247,6 +3251,20 @@ static bool get_phys_addr_pmsav8(CPUARMState *env, return ret; } +#else /* !CONFIG_TCG */ + +static bool get_phys_addr_pmsav8 (CPUARMState *env, +S1Translate *ptw, +uint32_t address, +MMUAccessType access_type, +GetPhysAddrResult *result, +ARMMMUFaultInfo *fi) +{ +g_assert_not_reached (); +} + +#endif /* !CONFIG_TCG */ +/* * Translate from the 4-bit stage 2 representation of * memory attributes (without cache-allocation hints) to
Signature · 1 line
2.53.0
Re: [PATCH 2/5] target/arm/ptw: Restrict PMSAv8 code to TCG
Quoted 4 lines · Philippe Mathieu-Daudé
Armv8-M Protected Memory System Architecture can only be emulated, therefore restrict it to TCG to avoid compiling it on hardware accelerators.
True, but this is also true for pmsav5 and pmsav7. Could we move the ifdef up to cover those as well, or does it get too awkward ?
Quoted 1 line
Signed-off-by Philippe Mathieu-Daudé <[email protected]>
thanks
-- PMM
PATCH 3/5 target/ppc: Restrict TCGTBCPUState to TCG
In reply to Philippe Mathieu-DaudéTCGTBCPUState is a structure used during TCG translation, therefore not needed when TCG is not available.
--- target/ppc/internal.h | 5 ++++- target/ppc/helper_regs.c | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-)
target/ppc/internal.h +4 -1
@@ -22,7 +22,6 @@#include "exec/memop.h" #include "hw/core/registerfields.h" #include "exec/page-protection.h" -#include "accel/tcg/tb-cpu-state.h" static inline bool ppc_env_is_little_endian (const CPUPPCState *env) {
@@ -326,6 +325,10 @@ static inline int ger_pack_masks(int pmsk, int ymsk, int xmsk) return msk; } +#ifdef CONFIG_TCG +#include "accel/tcg/tb-cpu-state.h" +TCGTBCPUState ppc_get_tb_cpu_state (CPUState *cs); +#endif #endif /* PPC_INTERNAL_H */
target/ppc/helper_regs.c +2 -1
@@ -27,7 +27,6 @@#include "power8-pmu.h" #include "cpu-models.h" #include "spr_common.h" -#include "accel/tcg/cpu-ops.h" #include "internal.h" /* Swap temporary saved registers with GPRs */
@@ -261,6 +260,7 @@ void hreg_update_pmu_hflags(CPUPPCState *env) env->hflags |=hreg_compute_pmu_hflags_value (env); } +#ifdef CONFIG_TCG TCGTBCPUState ppc_get_tb_cpu_state (CPUState *cs) {CPUPPCState *env =cpu_env (cs);
@@ -277,6 +277,7 @@ TCGTBCPUState ppc_get_tb_cpu_state(CPUState *cs) return (TCGTBCPUState){ .pc = env->nip, .flags = hflags_current }; } +#endif /* CONFIG_TCG */ #ifndef CONFIG_USER_ONLY void cpu_interrupt_exittb (CPUState *cs)
Signature · 1 line
2.53.0
Re: [PATCH 3/5] target/ppc: Restrict TCGTBCPUState to TCG
Quoted 8 lines · Philippe Mathieu-Daudé
TCGTBCPUState is a structure used during TCG translation, therefore not needed when TCG is not available.
Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- target/ppc/internal.h | 5 ++++- target/ppc/helper_regs.c | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-)
r~
PATCH 4/5 target/or1k: Have exception_helper.c absorb exception.c
In reply to Philippe Mathieu-DaudéOpenRISC is only available with TCG. No need to keep raise_exception() in a distinct file unit, merge it with exception_helper.c.
--- target/or1k/exception.h | 2 +- target/or1k/exception.c | 30 ------------------------------ target/or1k/exception_helper.c | 13 +++++++++++-- target/or1k/meson.build | 1 - 4 files changed, 12 insertions(+), 34 deletions(-) delete mode 100644 target/or1k/exception.c
target/or1k/exception.h +1 -1
@@ -20,7 +20,7 @@#ifndef TARGET_OPENRISC_EXCEPTION_H #define TARGET_OPENRISC_EXCEPTION_H -#include "cpu.h" +#include "target/or1k/cpu-qom.h" G_NORETURN void raise_exception(OpenRISCCPU *cpu, uint32_t excp);
target/or1k/exception.c deleted +0 -30
@@ -1,30 +0,0 @@ -/* -* OpenRISC exception. -* -* Copyright (c) 2011-2012 Jia Liu <[email protected]> -* -* 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/>. -*/ - -#include "qemu/osdep.h" -#include "cpu.h" -#include "exception.h" - -G_NORETURN void raise_exception(OpenRISCCPU *cpu, uint32_t excp) -{ -CPUState *cs =CPU (cpu); - - cs->exception_index = excp; -cpu_loop_exit (cs); -}
target/or1k/exception_helper.c +11 -2
@@ -18,9 +18,18 @@*/ #include "qemu/osdep.h" -#include "cpu.h" #include "exec/helper-proto.h" -#include "exception.h" + +#include "target/or1k/cpu.h" +#include "target/or1k/exception.h" + +G_NORETURN void raise_exception(OpenRISCCPU *cpu, uint32_t excp) +{ +CPUState *cs =CPU (cpu); + + cs->exception_index = excp; +cpu_loop_exit (cs); +}void HELPER (exception )(CPUOpenRISCState *env,uint32_t excp) {
target/or1k/meson.build +0 -1
@@ -5,7 +5,6 @@ or1k_ss.add(gen) or1k_ss.add(files( 'cpu.c', 'disas.c', - 'exception.c', 'exception_helper.c', 'fpu_helper.c', 'interrupt_helper.c',
Signature · 1 line
2.53.0
Re: [PATCH 4/5] target/or1k: Have exception_helper.c absorb exception.c
Quoted 18 lines · Philippe Mathieu-Daudé
OpenRISC is only available with TCG. No need to keep
raise_exception()in a distinct file unit, merge it withexception_helper.c.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/or1k/exception.h | 2 +- target/or1k/exception.c | 30 ------------------------------ target/or1k/exception_helper.c | 13 +++++++++++-- target/or1k/meson.build | 1 - 4 files changed, 12 insertions(+), 34 deletions(-)delete mode 100644
target/or1k/exception.ctarget/or1k/exception.h +0
-0
target/or1k/exception.h line 23
Quoted 5 lines
target/or1k/exception.h +1
-1@@ -20,7 +20,7 @@#ifndef TARGET_OPENRISC_EXCEPTION_H #define TARGET_OPENRISC_EXCEPTION_H -#include "cpu.h" +#include "target/or1k/cpu-qom.h"
Why are you adding full paths here?
target/or1k/exception.h line 24
Quoted 11 lines
target/or1k/exception.h +4
-2+++ b/target/or1k/exception_helper.c@@ -18,9 +18,18 @@*/ #include "qemu/osdep.h" -#include "cpu.h" #include "exec/helper-proto.h" -#include "exception.h" + +#include "target/or1k/cpu.h" +#include "target/or1k/exception.h"
And here there seems to be no need of adjusting the includes at all.
r~
PATCH 5/5 accel/tcg: Remove pre-vCPU ignore_memory_transaction_failures flag
In reply to Philippe Mathieu-DaudéThe %ignore_memory_transaction_failures flag is meant for legacy machines, and is defined once per machine, then applied to all vCPUs such machine creates, to be eventually only used by the TCG soft MMU layer.
We can decouple it of the vCPU layer by making it a global, setting it once when the machine is initialized, allowing to remove machine code in the common vCPU Realize() handler.
---
Even better is to make it an accelerator property.
--- include/hw/core/cpu.h | 2 -- include/system/tcg.h | 2 ++ accel/stubs/tcg-stub.c | 1 + accel/tcg/cputlb.c | 9 +++++++-- hw/core/cpu-common.c | 15 --------------- hw/core/machine.c | 5 +++++ 6 files changed, 15 insertions(+), 19 deletions(-)
include/hw/core/cpu.h +0 -2
@@ -575,8 +575,6 @@ struct CPUState {*/ int64_t throttle_us_per_full; -bool ignore_memory_transaction_failures; -/* Used for user-only emulation of prctl(PR_SET_UNALIGN). */ bool prctl_unalign_sigbus;
include/system/tcg.h +2 -0
@@ -25,4 +25,6 @@ extern bool tcg_allowed;*/ bool qemu_tcg_mttcg_enabled (void ); +extern bool tcg_ignore_memory_transaction_failures; +#endif
accel/stubs/tcg-stub.c +1 -0
@@ -11,6 +11,7 @@*/ #include "qemu/osdep.h" +#include "system/tcg.h" #include "exec/cpu-common.h" G_NORETURN void cpu_loop_exit(CPUState *cpu)
accel/tcg/cputlb.c +7 -2
@@ -26,6 +26,7 @@#include "exec/page-protection.h" #include "system/memory.h" #include "system/physmem.h" +#include "system/tcg.h" #include "accel/tcg/cpu-ldst-common.h" #include "accel/tcg/cpu-mmu-index.h" #include "exec/cputlb.h"
@@ -90,6 +91,8 @@*/ QEMU_BUILD_BUG_ON (sizeof (vaddr) >sizeof (run_on_cpu_data)); +bool tcg_ignore_memory_transaction_failures; +#define ALL_MMUIDX_BITS ((1 << NB_MMU_MODES) - 1)static inline size_t tlb_n_entries (CPUTLBDescFast *fast)
@@ -1291,8 +1294,10 @@ static void io_failed(CPUState *cpu, CPUTLBEntryFull *full, vaddr addr, unsigned size, MMUAccessType access_type, int mmu_idx, MemTxResult response, uintptr_t retaddr) { - if (!cpu->ignore_memory_transaction_failures - && cpu->cc->tcg_ops->do_transaction_failed) { + if (unlikely(tcg_ignore_memory_transaction_failures)) { + return; + } +if (cpu->cc->tcg_ops->do_transaction_failed) {hwaddr physaddr = full->phys_addr | (addr & ~TARGET_PAGE_MASK ); cpu->cc->tcg_ops->do_transaction_failed(cpu, physaddr, addr, size,
hw/core/cpu-common.c +0 -15
@@ -32,7 +32,6 @@#include "exec/log.h" #include "exec/gdbstub.h" #include "system/tcg.h" -#include "hw/core/boards.h" #include "hw/core/qdev-properties.h" #include "trace.h" #ifdef CONFIG_PLUGIN
@@ -247,20 +246,6 @@ bool cpu_exec_realizefn(CPUState *cpu, Error **errp)static void cpu_common_realizefn (DeviceState *dev,Error **errp) {CPUState *cpu =CPU (dev); -Object *machine =qdev_get_machine (); - -/* qdev_get_machine() can return something that's not TYPE_MACHINE -* if this is one of the user-only emulators; in that case there's -* no need to check the ignore_memory_transaction_failures board flag. -*/ -if (object_dynamic_cast (machine,TYPE_MACHINE )) { -MachineClass *mc =MACHINE_GET_CLASS (machine); - -if (mc) { - cpu->ignore_memory_transaction_failures = - mc->ignore_memory_transaction_failures; - } - }if (dev->hotplugged) {cpu_synchronize_post_init (cpu);
hw/core/machine.c +5 -0
@@ -29,6 +29,7 @@#include "system/runstate.h" #include "system/xen.h" #include "system/qtest.h" +#include "system/tcg.h" #include "hw/pci/pci_bridge.h" #include "hw/mem/nvdimm.h" #include "migration/global_state.h"
@@ -1213,6 +1214,10 @@ static void machine_class_base_init(ObjectClass *oc, const void *data) strlen(cname) - strlen(TYPE_MACHINE_SUFFIX)); mc->compat_props =g_ptr_array_new (); } +if (tcg_enabled ()) { + tcg_ignore_memory_transaction_failures + = mc->ignore_memory_transaction_failures; + } }static void machine_initfn (Object *obj)
Signature · 1 line
2.53.0
Re: [PATCH 5/5] accel/tcg: Remove pre-vCPU ignore_memory_transaction_failures flag
accel/tcg/cputlb.c static void io_failed(CPUState *cpu, CPUTLBEntryFull *full, vaddr addr, · line 1299
Quoted 9 lines · Philippe Mathieu-Daudé
accel/tcg/cputlb.c +3
-2@@ -1291,8 +1294,10 @@ static void io_failed(CPUState *cpu, CPUTLBEntryFull *full, vaddr addr, unsigned size, MMUAccessType access_type, int mmu_idx, MemTxResult response, uintptr_t retaddr) { - if (!cpu->ignore_memory_transaction_failures - && cpu->cc->tcg_ops->do_transaction_failed) { + if (unlikely(tcg_ignore_memory_transaction_failures)) { + return; + }
Any reason not to pull this from MACHINE_CLASS(current_machine) instead of a global?
r~
Re: [PATCH 5/5] accel/tcg: Remove pre-vCPU ignore_memory_transaction_failures flag
Quoted 13 lines · Richard Henderson
accel/tcg/cputlb.c static void io_failed(CPUState *cpu, · line 1300
Quoted 10 lines · Philippe Mathieu-Daudé
accel/tcg/cputlb.c +3
-2@@ -1291,8 +1294,10 @@ static void io_failed(CPUState *cpu, CPUTLBEntryFull *full, vaddr addr, unsigned size, MMUAccessType access_type, int mmu_idx, MemTxResult response, uintptr_t retaddr) { - if (!cpu->ignore_memory_transaction_failures - && cpu->cc->tcg_ops->do_transaction_failed) { + if (unlikely(tcg_ignore_memory_transaction_failures)) { + return; + }Any reason not to pull this from
MACHINE_CLASS(current_machine)instead of a global?
Restrict this TCG specific handling out of CPU common. I'll see as an alternative to defer the check to late TCG TLB init, allowing to make the boolean non-global.