From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 06/32] target-arm: Make page size a runtime setting
Date: Mon, 24 Oct 2016 18:25:02 +0100 [thread overview]
Message-ID: <1477329928-26414-7-git-send-email-peter.maydell@linaro.org> (raw)
In-Reply-To: <1477329928-26414-1-git-send-email-peter.maydell@linaro.org>
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 <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
---
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 1b9540e..c94a324 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 2218c00..6695390 100644
--- a/target-arm/cpu.h
+++ b/target-arm/cpu.h
@@ -1766,10 +1766,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)
--
2.7.4
next prev parent reply other threads:[~2016-10-24 17:25 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-24 17:24 [Qemu-devel] [PULL 00/32] target-arm queue Peter Maydell
2016-10-24 17:24 ` [Qemu-devel] [PULL 01/32] migration: Remove static allocation of xzblre cache buffer Peter Maydell
2016-10-24 17:24 ` [Qemu-devel] [PULL 02/32] exec.c: Remove static allocation of sub_section of sub_page Peter Maydell
2016-10-24 17:24 ` [Qemu-devel] [PULL 03/32] translate-all.c: Compute L1 page table properties at runtime Peter Maydell
2016-10-24 17:25 ` [Qemu-devel] [PULL 04/32] cpu: Support a target CPU having a variable page size Peter Maydell
2016-10-24 17:25 ` [Qemu-devel] [PULL 05/32] migration/savevm.c: migrate non-default " Peter Maydell
2016-10-24 17:25 ` Peter Maydell [this message]
2016-10-24 17:25 ` [Qemu-devel] [PULL 07/32] hw/arm/virt: Set minimum_page_bits to 12 Peter Maydell
2016-10-24 17:25 ` [Qemu-devel] [PULL 08/32] hw/ptimer: Add "wraparound after one period" policy Peter Maydell
2016-10-24 17:25 ` [Qemu-devel] [PULL 09/32] tests: ptimer: Add tests for " Peter Maydell
2016-10-24 17:25 ` [Qemu-devel] [PULL 10/32] hw/ptimer: Add "continuous trigger" policy Peter Maydell
2016-10-24 17:25 ` [Qemu-devel] [PULL 11/32] tests: ptimer: Add tests for " Peter Maydell
2016-10-24 17:25 ` [Qemu-devel] [PULL 12/32] hw/ptimer: Add "no immediate " Peter Maydell
2016-10-24 17:25 ` [Qemu-devel] [PULL 13/32] tests: ptimer: Add tests for " Peter Maydell
2016-10-24 17:25 ` [Qemu-devel] [PULL 14/32] hw/ptimer: Add "no immediate reload" policy Peter Maydell
2016-10-24 17:25 ` [Qemu-devel] [PULL 15/32] tests: ptimer: Add tests for " Peter Maydell
2016-10-24 17:25 ` [Qemu-devel] [PULL 16/32] hw/ptimer: Add "no counter round down" policy Peter Maydell
2016-10-24 17:25 ` [Qemu-devel] [PULL 17/32] tests: ptimer: Add tests for " Peter Maydell
2016-10-24 17:25 ` [Qemu-devel] [PULL 18/32] tests: ptimer: Change the copyright comment Peter Maydell
2016-10-24 17:25 ` [Qemu-devel] [PULL 19/32] tests: ptimer: Replace 10000 with 1 Peter Maydell
2016-10-24 17:25 ` [Qemu-devel] [PULL 20/32] arm_mptimer: Convert to use ptimer Peter Maydell
2016-10-24 17:25 ` [Qemu-devel] [PULL 21/32] tests: Add tests for the ARM MPTimer Peter Maydell
2016-10-24 17:25 ` [Qemu-devel] [PULL 22/32] ACPI: Add IORT Structure definition Peter Maydell
2016-10-24 17:25 ` [Qemu-devel] [PULL 23/32] ARM: Virt: ACPI: Build an IORT table with RC and ITS nodes Peter Maydell
2016-10-24 17:25 ` [Qemu-devel] [PULL 24/32] timer: a9gtimer: remove loop to auto-increment comparator Peter Maydell
2016-10-24 17:25 ` [Qemu-devel] [PULL 25/32] i2c: Fix SMBus read transactions to avoid double events Peter Maydell
2016-10-24 17:25 ` [Qemu-devel] [PULL 26/32] timer: stm32f2xx_timer: add check for prescaler value Peter Maydell
2016-10-24 17:25 ` [Qemu-devel] [PULL 27/32] hw/arm: QOM'ify musicpal.c Peter Maydell
2016-10-24 17:25 ` [Qemu-devel] [PULL 28/32] hw/arm: QOM'ify pxa2xx_gpio.c Peter Maydell
2016-10-24 17:25 ` [Qemu-devel] [PULL 29/32] hw/arm: QOM'ify strongarm.c Peter Maydell
2016-10-24 17:25 ` [Qemu-devel] [PULL 30/32] hw/display: QOM'ify pl110.c Peter Maydell
2016-10-24 17:25 ` [Qemu-devel] [PULL 31/32] target-arm: Implement new HLT trap for semihosting Peter Maydell
2016-10-24 17:25 ` [Qemu-devel] [PULL 32/32] i2c: Add asserts for second smbus i2c_start_transfer() Peter Maydell
2016-10-24 19:11 ` [Qemu-devel] [PULL 00/32] target-arm queue no-reply
2016-10-25 9:17 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1477329928-26414-7-git-send-email-peter.maydell@linaro.org \
--to=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).