[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v5 20/22] target/arm: Create tagged ram when MTE is enabled
From: |
Peter Maydell |
Subject: |
Re: [PATCH v5 20/22] target/arm: Create tagged ram when MTE is enabled |
Date: |
Thu, 5 Dec 2019 18:40:00 +0000 |
On Fri, 11 Oct 2019 at 14:50, Richard Henderson
<address@hidden> wrote:
>
> Signed-off-by: Richard Henderson <address@hidden>
> ---
> v5: Assign cs->num_ases to the final value first.
> Downgrade to ID_AA64PFR1.MTE=1 if tag memory is not available.
> v6: Add secure tag memory for EL3.
> ---
> target/arm/cpu.h | 6 ++++++
> hw/arm/virt.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++
> target/arm/cpu.c | 53 ++++++++++++++++++++++++++++++++++++++++++++---
> 3 files changed, 110 insertions(+), 3 deletions(-)
>
> diff --git a/target/arm/cpu.h b/target/arm/cpu.h
> index 93a362708b..faca43ea78 100644
> --- a/target/arm/cpu.h
> +++ b/target/arm/cpu.h
> @@ -765,6 +765,10 @@ struct ARMCPU {
> /* MemoryRegion to use for secure physical accesses */
> MemoryRegion *secure_memory;
>
> + /* MemoryRegion to use for allocation tag accesses */
> + MemoryRegion *tag_memory;
> + MemoryRegion *secure_tag_memory;
> +
> /* For v8M, pointer to the IDAU interface provided by board/SoC */
> Object *idau;
>
> @@ -2956,6 +2960,8 @@ int cpu_mmu_index(CPUARMState *env, bool ifetch);
> typedef enum ARMASIdx {
> ARMASIdx_NS = 0,
> ARMASIdx_S = 1,
> + ARMASIdx_TagNS = 2,
> + ARMASIdx_TagS = 3,
> } ARMASIdx;
>
> /* Return the Exception Level targeted by debug exceptions. */
> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index d74538b021..573988ba4d 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -1330,6 +1330,18 @@ static void create_secure_ram(VirtMachineState *vms,
> g_free(nodename);
> }
>
> +static void create_tag_ram(MemoryRegion *tag_sysmem,
> + hwaddr base, hwaddr size,
> + const char *name)
> +{
> + MemoryRegion *tagram = g_new(MemoryRegion, 1);
> +
> + memory_region_init_ram(tagram, NULL, name, size / 32, &error_fatal);
> + memory_region_add_subregion(tag_sysmem, base / 32, tagram);
> +
> + /* ??? Do we really need an fdt entry, or is MemTag enabled sufficient.
> */
What's this '???' asking about? I would be surprised if the
kernel expected to have any kind of FDT for tag RAM
(with the exception that an implementation that puts tags
in a special part of normal-ram will want that not
to be described in the fdt as ram usable by the kernel), but
we should ask the kernel folks.
> +}
> +
> static void *machvirt_dtb(const struct arm_boot_info *binfo, int *fdt_size)
> {
> const VirtMachineState *board = container_of(binfo, VirtMachineState,
> @@ -1485,6 +1497,8 @@ static void machvirt_init(MachineState *machine)
> qemu_irq pic[NUM_IRQS];
> MemoryRegion *sysmem = get_system_memory();
> MemoryRegion *secure_sysmem = NULL;
> + MemoryRegion *tag_sysmem = NULL;
> + MemoryRegion *secure_tag_sysmem = NULL;
> int n, virt_max_cpus;
> MemoryRegion *ram = g_new(MemoryRegion, 1);
> bool firmware_loaded;
> @@ -1652,6 +1666,35 @@ static void machvirt_init(MachineState *machine)
> "secure-memory", &error_abort);
> }
>
> + /*
> + * The cpu adds the property iff MemTag is supported.
We've had confusion before from non-native-speakers and
non-maths-geeks about 'iff' in comments; better to expand to
'if and only if'.
> + * If it is, we must allocate the ram to back that up.
> + */
> + if (object_property_find(cpuobj, "tag-memory", NULL)) {
> + if (!tag_sysmem) {
> + tag_sysmem = g_new(MemoryRegion, 1);
> + memory_region_init(tag_sysmem, OBJECT(machine),
> + "tag-memory", UINT64_MAX / 32);
> +
> + if (vms->secure) {
> + secure_tag_sysmem = g_new(MemoryRegion, 1);
> + memory_region_init(secure_tag_sysmem, OBJECT(machine),
> + "secure-tag-memory", UINT64_MAX / 32);
> +
> + /* As with ram, secure-tag takes precedence over tag. */
> + memory_region_add_subregion_overlap(secure_tag_sysmem, 0,
> + tag_sysmem, -1);
> + }
> + }
Are there really separate S and NS tag RAMs?
thanks
-- PMM
- Re: [PATCH v5 20/22] target/arm: Create tagged ram when MTE is enabled,
Peter Maydell <=