[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 25/30] target/ppc: Restrict KVM-specific fields from ArchCPU
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 25/30] target/ppc: Restrict KVM-specific fields from ArchCPU |
Date: |
Wed, 28 Jun 2023 17:53:08 +0200 |
The 'kvm_sw_tlb' and 'tlb_dirty' fields introduced in commit
93dd5e852c ("kvm: ppc: booke206: use MMU API") are specific
to KVM and shouldn't be accessed when it is not available.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Message-Id: <20230624192645.13680-1-philmd@linaro.org>
---
target/ppc/cpu.h | 2 ++
hw/ppc/e500.c | 2 ++
hw/ppc/ppce500_spin.c | 2 ++
target/ppc/mmu_common.c | 4 ++++
4 files changed, 10 insertions(+)
diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
index 94497aa115..af12c93ebc 100644
--- a/target/ppc/cpu.h
+++ b/target/ppc/cpu.h
@@ -1149,8 +1149,10 @@ struct CPUArchState {
int nb_pids; /* Number of available PID registers */
int tlb_type; /* Type of TLB we're dealing with */
ppc_tlb_t tlb; /* TLB is optional. Allocate them only if needed */
+#ifdef CONFIG_KVM
bool tlb_dirty; /* Set to non-zero when modifying TLB */
bool kvm_sw_tlb; /* non-zero if KVM SW TLB API is active */
+#endif /* CONFIG_KVM */
uint32_t tlb_need_flush; /* Delayed flush needed */
#define TLB_NEED_LOCAL_FLUSH 0x1
#define TLB_NEED_GLOBAL_FLUSH 0x2
diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
index b6eb599751..67793a86f1 100644
--- a/hw/ppc/e500.c
+++ b/hw/ppc/e500.c
@@ -765,7 +765,9 @@ static void mmubooke_create_initial_mapping(CPUPPCState
*env)
tlb->mas7_3 = 0;
tlb->mas7_3 |= MAS3_UR | MAS3_UW | MAS3_UX | MAS3_SR | MAS3_SW | MAS3_SX;
+#ifdef CONFIG_KVM
env->tlb_dirty = true;
+#endif
}
static void ppce500_cpu_reset_sec(void *opaque)
diff --git a/hw/ppc/ppce500_spin.c b/hw/ppc/ppce500_spin.c
index d57b199797..bbce63e8a4 100644
--- a/hw/ppc/ppce500_spin.c
+++ b/hw/ppc/ppce500_spin.c
@@ -83,7 +83,9 @@ static void mmubooke_create_initial_mapping(CPUPPCState *env,
tlb->mas2 = (va & TARGET_PAGE_MASK) | MAS2_M;
tlb->mas7_3 = pa & TARGET_PAGE_MASK;
tlb->mas7_3 |= MAS3_UR | MAS3_UW | MAS3_UX | MAS3_SR | MAS3_SW | MAS3_SX;
+#ifdef CONFIG_KVM
env->tlb_dirty = true;
+#endif
}
static void spin_kick(CPUState *cs, run_on_cpu_data data)
diff --git a/target/ppc/mmu_common.c b/target/ppc/mmu_common.c
index ae1db6e348..8c000e250d 100644
--- a/target/ppc/mmu_common.c
+++ b/target/ppc/mmu_common.c
@@ -930,10 +930,12 @@ static void mmubooke_dump_mmu(CPUPPCState *env)
ppcemb_tlb_t *entry;
int i;
+#ifdef CONFIG_KVM
if (kvm_enabled() && !env->kvm_sw_tlb) {
qemu_printf("Cannot access KVM TLB\n");
return;
}
+#endif
qemu_printf("\nTLB:\n");
qemu_printf("Effective Physical Size PID Prot "
@@ -1021,10 +1023,12 @@ static void mmubooke206_dump_mmu(CPUPPCState *env)
int offset = 0;
int i;
+#ifdef CONFIG_KVM
if (kvm_enabled() && !env->kvm_sw_tlb) {
qemu_printf("Cannot access KVM TLB\n");
return;
}
+#endif
for (i = 0; i < BOOKE206_MAX_TLBN; i++) {
int size = booke206_tlb_size(env, i);
--
2.38.1
- [PULL 14/30] accel: Remove WHPX unreachable error path, (continued)
- [PULL 14/30] accel: Remove WHPX unreachable error path, Philippe Mathieu-Daudé, 2023/06/28
- [PULL 15/30] accel: Rename WHPX 'struct whpx_vcpu' -> AccelCPUState, Philippe Mathieu-Daudé, 2023/06/28
- [PULL 17/30] accel: Rename 'cpu_state' -> 'cs', Philippe Mathieu-Daudé, 2023/06/28
- [PULL 16/30] accel: Inline WHPX get_whpx_vcpu(), Philippe Mathieu-Daudé, 2023/06/28
- [PULL 19/30] accel/kvm: Re-include "exec/memattrs.h" header, Philippe Mathieu-Daudé, 2023/06/28
- [PULL 18/30] accel: Rename HVF 'struct hvf_vcpu_state' -> AccelCPUState, Philippe Mathieu-Daudé, 2023/06/28
- [PULL 21/30] hw/intc/arm_gic: Un-inline GIC*/ITS class_name() helpers, Philippe Mathieu-Daudé, 2023/06/28
- [PULL 28/30] exec/memory: Add symbolic value for memory listener priority for accel, Philippe Mathieu-Daudé, 2023/06/28
- [PULL 20/30] accel/kvm: Declare kvm_direct_msi_allowed in stubs, Philippe Mathieu-Daudé, 2023/06/28
- [PULL 24/30] target/arm: Restrict KVM-specific fields from ArchCPU, Philippe Mathieu-Daudé, 2023/06/28
- [PULL 25/30] target/ppc: Restrict KVM-specific fields from ArchCPU,
Philippe Mathieu-Daudé <=
- [PULL 23/30] hw/arm/sbsa-ref: Include missing 'sysemu/kvm.h' header, Philippe Mathieu-Daudé, 2023/06/28
- [PULL 26/30] target/riscv: Restrict KVM-specific fields from ArchCPU, Philippe Mathieu-Daudé, 2023/06/28
- [PULL 29/30] exec/memory: Add symbol for memory listener priority for device backend, Philippe Mathieu-Daudé, 2023/06/28
- [PULL 22/30] hw/intc/arm_gic: Rename 'first_cpu' argument, Philippe Mathieu-Daudé, 2023/06/28
- [PULL 30/30] exec/memory: Add symbol for the min value of memory listener priority, Philippe Mathieu-Daudé, 2023/06/28
- [PULL 27/30] target/i386/WHPX: Fix error message when fail to set ProcessorCount, Philippe Mathieu-Daudé, 2023/06/28
- Re: [PULL 00/30] Accelerator patches for 2023-06-28, Richard Henderson, 2023/06/29