[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-arm] [PATCH v2 5/6] target-arm: Make page size a runtime setting
From: |
Peter Maydell |
Subject: |
[Qemu-arm] [PATCH v2 5/6] target-arm: Make page size a runtime setting |
Date: |
Tue, 21 Jun 2016 18:09:33 +0100 |
Rather than defining TARGET_PAGE_BITS to always be 10,
switch to using a value picked at runtime. This allows us
to use 4K pages for modern ARM CPUs (and in particular all
64-bit CPUs) without having to drop support for the old
ARMv5 CPUs which had 1K pages.
Signed-off-by: Peter Maydell <address@hidden>
---
target-arm/cpu.c | 24 ++++++++++++++++++++++++
target-arm/cpu.h | 9 +++++----
2 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/target-arm/cpu.c b/target-arm/cpu.c
index ce8b8f4..d807b3f 100644
--- a/target-arm/cpu.c
+++ b/target-arm/cpu.c
@@ -576,6 +576,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error
**errp)
ARMCPU *cpu = ARM_CPU(dev);
ARMCPUClass *acc = ARM_CPU_GET_CLASS(dev);
CPUARMState *env = &cpu->env;
+ int pagebits;
/* Some features automatically imply others: */
if (arm_feature(env, ARM_FEATURE_V8)) {
@@ -631,6 +632,29 @@ static void arm_cpu_realizefn(DeviceState *dev, Error
**errp)
set_feature(env, ARM_FEATURE_THUMB_DSP);
}
+ if (arm_feature(env, ARM_FEATURE_V7) &&
+ !arm_feature(env, ARM_FEATURE_M) &&
+ !arm_feature(env, ARM_FEATURE_MPU)) {
+ /* v7VMSA drops support for the old ARMv5 tiny pages, so we
+ * can use 4K pages.
+ */
+ pagebits = 12;
+ } else {
+ /* For CPUs which might have tiny 1K pages, or which have an
+ * MPU and might have small region sizes, stick with 1K pages.
+ */
+ pagebits = 10;
+ }
+ if (!set_preferred_target_page_bits(pagebits)) {
+ /* This can only ever happen for hotplugging a CPU, or if
+ * the board code incorrectly creates a CPU which it has
+ * promised via minimum_page_size that it will not.
+ */
+ error_setg(errp, "This CPU requires a smaller page size than the "
+ "system is using");
+ return;
+ }
+
if (cpu->reset_hivecs) {
cpu->reset_sctlr |= (1 << 13);
}
diff --git a/target-arm/cpu.h b/target-arm/cpu.h
index 7938ddc..073f91f 100644
--- a/target-arm/cpu.h
+++ b/target-arm/cpu.h
@@ -1767,10 +1767,11 @@ bool write_cpustate_to_list(ARMCPU *cpu);
#if defined(CONFIG_USER_ONLY)
#define TARGET_PAGE_BITS 12
#else
-/* The ARM MMU allows 1k pages. */
-/* ??? Linux doesn't actually use these, and they're deprecated in recent
- architecture revisions. Maybe a configure option to disable them. */
-#define TARGET_PAGE_BITS 10
+/* ARMv7 and later CPUs have 4K pages minimum, but ARMv5 and v6
+ * have to support 1K tiny pages.
+ */
+#define TARGET_PAGE_BITS_VARY
+#define TARGET_PAGE_BITS_MIN 10
#endif
#if defined(TARGET_AARCH64)
--
1.9.1
- Re: [Qemu-arm] [Qemu-devel] [PATCH v2 1/6] migration: Remove static allocation of xzblre cache buffer, (continued)
- [Qemu-arm] [PATCH v2 4/6] cpu: Support a target CPU having a variable page size, Peter Maydell, 2016/06/21
- [Qemu-arm] [PATCH v2 3/6] translate-all.c: Compute L1 page table properties at runtime, Peter Maydell, 2016/06/21
- [Qemu-arm] [PATCH v2 5/6] target-arm: Make page size a runtime setting,
Peter Maydell <=
- Re: [Qemu-arm] [Qemu-devel] [PATCH v2 0/6] Runtime pagesize computation, Dr. David Alan Gilbert, 2016/06/22
- Re: [Qemu-arm] [PATCH v2 0/6] Runtime pagesize computation, Peter Maydell, 2016/06/28