qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Auger <eric.auger@redhat.com>
To: Gavin Shan <gshan@redhat.com>, qemu-arm@nongnu.org
Cc: qemu-devel@nongnu.org, maz@kernel.org, cohuck@redhat.com,
	zhenyzha@redhat.com, richard.henderson@linaro.org,
	peter.maydell@linaro.org, shan.gavin@gmail.com
Subject: Re: [PATCH v3 1/5] hw/arm/virt: Introduce virt_set_high_memmap() helper
Date: Wed, 28 Sep 2022 14:09:34 +0200	[thread overview]
Message-ID: <13f19e41-0feb-7cfc-11f8-46d0f3f326db@redhat.com> (raw)
In-Reply-To: <20220921231349.274049-2-gshan@redhat.com>

Hi Gavin,

On 9/22/22 01:13, Gavin Shan wrote:
> This introduces virt_set_high_memmap() helper. The logic of high
> memory region address assignment is moved to the helper. The intention
> is to make the subsequent optimization for high memory region address
> assignment easier.
>
> No functional change intended.
>
> Signed-off-by: Gavin Shan <gshan@redhat.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>

Thanks

Eric
> ---
>  hw/arm/virt.c | 74 ++++++++++++++++++++++++++++-----------------------
>  1 file changed, 41 insertions(+), 33 deletions(-)
>
> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index 0961e053e5..4dab528b82 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -1689,6 +1689,46 @@ static uint64_t virt_cpu_mp_affinity(VirtMachineState *vms, int idx)
>      return arm_cpu_mp_affinity(idx, clustersz);
>  }
>  
> +static void virt_set_high_memmap(VirtMachineState *vms,
> +                                 hwaddr base, int pa_bits)
> +{
> +    int i;
> +
> +    for (i = VIRT_LOWMEMMAP_LAST; i < ARRAY_SIZE(extended_memmap); i++) {
> +        hwaddr size = extended_memmap[i].size;
> +        bool fits;
> +
> +        base = ROUND_UP(base, size);
> +        vms->memmap[i].base = base;
> +        vms->memmap[i].size = size;
> +
> +        /*
> +         * Check each device to see if they fit in the PA space,
> +         * moving highest_gpa as we go.
> +         *
> +         * For each device that doesn't fit, disable it.
> +         */
> +        fits = (base + size) <= BIT_ULL(pa_bits);
> +        if (fits) {
> +            vms->highest_gpa = base + size - 1;
> +        }
> +
> +        switch (i) {
> +        case VIRT_HIGH_GIC_REDIST2:
> +            vms->highmem_redists &= fits;
> +            break;
> +        case VIRT_HIGH_PCIE_ECAM:
> +            vms->highmem_ecam &= fits;
> +            break;
> +        case VIRT_HIGH_PCIE_MMIO:
> +            vms->highmem_mmio &= fits;
> +            break;
> +        }
> +
> +        base += size;
> +    }
> +}
> +
>  static void virt_set_memmap(VirtMachineState *vms, int pa_bits)
>  {
>      MachineState *ms = MACHINE(vms);
> @@ -1744,39 +1784,7 @@ static void virt_set_memmap(VirtMachineState *vms, int pa_bits)
>      /* We know for sure that at least the memory fits in the PA space */
>      vms->highest_gpa = memtop - 1;
>  
> -    for (i = VIRT_LOWMEMMAP_LAST; i < ARRAY_SIZE(extended_memmap); i++) {
> -        hwaddr size = extended_memmap[i].size;
> -        bool fits;
> -
> -        base = ROUND_UP(base, size);
> -        vms->memmap[i].base = base;
> -        vms->memmap[i].size = size;
> -
> -        /*
> -         * Check each device to see if they fit in the PA space,
> -         * moving highest_gpa as we go.
> -         *
> -         * For each device that doesn't fit, disable it.
> -         */
> -        fits = (base + size) <= BIT_ULL(pa_bits);
> -        if (fits) {
> -            vms->highest_gpa = base + size - 1;
> -        }
> -
> -        switch (i) {
> -        case VIRT_HIGH_GIC_REDIST2:
> -            vms->highmem_redists &= fits;
> -            break;
> -        case VIRT_HIGH_PCIE_ECAM:
> -            vms->highmem_ecam &= fits;
> -            break;
> -        case VIRT_HIGH_PCIE_MMIO:
> -            vms->highmem_mmio &= fits;
> -            break;
> -        }
> -
> -        base += size;
> -    }
> +    virt_set_high_memmap(vms, base, pa_bits);
>  
>      if (device_memory_size > 0) {
>          ms->device_memory = g_malloc0(sizeof(*ms->device_memory));



  reply	other threads:[~2022-09-28 13:53 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-21 23:13 [PATCH v3 0/5] hw/arm/virt: Improve address assignment for high memory regions Gavin Shan
2022-09-21 23:13 ` [PATCH v3 1/5] hw/arm/virt: Introduce virt_set_high_memmap() helper Gavin Shan
2022-09-28 12:09   ` Eric Auger [this message]
2022-09-29 13:48   ` Cornelia Huck
2022-09-21 23:13 ` [PATCH v3 2/5] hw/arm/virt: Rename variable size to region_size in virt_set_high_memmap() Gavin Shan
2022-10-03  8:26   ` Eric Auger
2022-09-21 23:13 ` [PATCH v3 3/5] hw/arm/virt: Introduce variable region_base " Gavin Shan
2022-09-28 12:10   ` Eric Auger
2022-09-28 23:15     ` Gavin Shan
2022-10-03  8:26       ` Eric Auger
2022-10-03  8:27   ` Eric Auger
2022-09-21 23:13 ` [PATCH v3 4/5] hw/arm/virt: Improve high memory region address assignment Gavin Shan
2022-09-28 12:51   ` Eric Auger
2022-09-28 23:37     ` Gavin Shan
2022-10-03  8:44       ` Eric Auger
2022-10-03 22:17         ` Gavin Shan
2022-10-04  7:06           ` Eric Auger
2022-09-21 23:13 ` [PATCH v3 5/5] hw/arm/virt: Add 'highmem-compact' property Gavin Shan
2022-09-28 12:22   ` Eric Auger
2022-09-28 23:49     ` Gavin Shan
2022-09-29 10:27       ` Cornelia Huck
2022-09-29 11:21         ` Gavin Shan
2022-10-03  8:49       ` Eric Auger
2022-10-03 23:50         ` Gavin Shan
2022-09-22  1:50 ` [PATCH v3 0/5] hw/arm/virt: Improve address assignment for high memory regions Zhenyu Zhang

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=13f19e41-0feb-7cfc-11f8-46d0f3f326db@redhat.com \
    --to=eric.auger@redhat.com \
    --cc=cohuck@redhat.com \
    --cc=gshan@redhat.com \
    --cc=maz@kernel.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=shan.gavin@gmail.com \
    --cc=zhenyzha@redhat.com \
    /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).