target-arm: Make page size a runtime setting
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>
This commit is contained in:
parent
59811a320d
commit
e97da98f11
@ -576,6 +576,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
|
|||||||
ARMCPU *cpu = ARM_CPU(dev);
|
ARMCPU *cpu = ARM_CPU(dev);
|
||||||
ARMCPUClass *acc = ARM_CPU_GET_CLASS(dev);
|
ARMCPUClass *acc = ARM_CPU_GET_CLASS(dev);
|
||||||
CPUARMState *env = &cpu->env;
|
CPUARMState *env = &cpu->env;
|
||||||
|
int pagebits;
|
||||||
|
|
||||||
/* Some features automatically imply others: */
|
/* Some features automatically imply others: */
|
||||||
if (arm_feature(env, ARM_FEATURE_V8)) {
|
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);
|
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) {
|
if (cpu->reset_hivecs) {
|
||||||
cpu->reset_sctlr |= (1 << 13);
|
cpu->reset_sctlr |= (1 << 13);
|
||||||
}
|
}
|
||||||
|
@ -1766,10 +1766,11 @@ bool write_cpustate_to_list(ARMCPU *cpu);
|
|||||||
#if defined(CONFIG_USER_ONLY)
|
#if defined(CONFIG_USER_ONLY)
|
||||||
#define TARGET_PAGE_BITS 12
|
#define TARGET_PAGE_BITS 12
|
||||||
#else
|
#else
|
||||||
/* The ARM MMU allows 1k pages. */
|
/* ARMv7 and later CPUs have 4K pages minimum, but ARMv5 and v6
|
||||||
/* ??? Linux doesn't actually use these, and they're deprecated in recent
|
* have to support 1K tiny pages.
|
||||||
architecture revisions. Maybe a configure option to disable them. */
|
*/
|
||||||
#define TARGET_PAGE_BITS 10
|
#define TARGET_PAGE_BITS_VARY
|
||||||
|
#define TARGET_PAGE_BITS_MIN 10
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(TARGET_AARCH64)
|
#if defined(TARGET_AARCH64)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user