qemu-arm
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-arm] [RFC PATCH v1 4/4] target-arm: Compute page size based on


From: Peter Maydell
Subject: Re: [Qemu-arm] [RFC PATCH v1 4/4] target-arm: Compute page size based on ARM target cpu type
Date: Mon, 13 Jun 2016 10:43:36 +0100

On 13 June 2016 at 10:08,  <address@hidden> wrote:
> From: Vijaya Kumar K <address@hidden>
>
> Replace TARGET_PAGE_BITS with arm_target_page_size function
> in order to fetch page size at run-time.
>
> Introduced MachineClass callback to compute target page
> size at the early boot before memory initialization.
> This callback is currently implemented for ARM platforms.
> Based on cpu_model, the page size is updated in
> target_page_bits which is defined as TARGET_PAGE_BITS.
>
> Signed-off-by: Vijaya Kumar K <address@hidden>
> ---
>  hw/arm/virt.c       |   48 ++++++++++++++++++++++++++++++++++++++++++++++++
>  include/hw/boards.h |    1 +
>  target-arm/cpu.h    |   12 +++++++-----
>  vl.c                |    7 +++++++
>  4 files changed, 63 insertions(+), 5 deletions(-)
>
> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index 73113cf..37aab33 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -90,6 +90,12 @@ typedef struct {
>      int32_t gic_version;
>  } VirtMachineState;
>
> +/*
> + * Holds TARGET_AARCH_64_PAGE_BITS or TARGET_ARM_PAGE_BITS
> + * based on the the cpu type emulated at runtime.
> + */
> +static uint32_t target_page_bits;

The CPU page size is not specific to the 'virt' board, so this
is the wrong place to do this. You should identify the
page size in arm_cpu_realizefn() based on the set of feature
bits the CPU has: anything with ARM_FEATURE_V7 has a 4K page
table (this includes a lot of 32-bit CPUs).

CPU realize is pretty late in startup so you may need
to rearrange some other stuff to be sure that it will
work OK. If that absolutely can't work then we could do
this in CPU init, but that would be a bit messier.

> --- a/vl.c
> +++ b/vl.c
> @@ -4045,6 +4045,13 @@ int main(int argc, char **argv, char **envp)
>      object_property_add_child(object_get_root(), "machine",
>                                OBJECT(current_machine), &error_abort);
>
> +    /*
> +     * Compute target page size dynamically if arch supports
> +     * multiple page sizes. Ex: ARM
> +     */
> +    if (machine_class->update_target_page_size)
> +        machine_class->update_target_page_size(cpu_model);
> +
>      init_l1_page_table_param();

Page size isn't board specific so you don't need any of these hook
functions in the machine class.

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]