aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2022-01-28 11:24:39 +0100
committerNatanael Copa <ncopa@alpinelinux.org>2022-01-28 11:26:27 +0100
commitde650f84b869534b65356e97d4d469cea6fa6117 (patch)
tree266dea5ef44b97c23096d660197b173859d12fa2
parent2454e1427e06fa5a774474fae62b9f77ee469d44 (diff)
downloadaports-de650f84b869534b65356e97d4d469cea6fa6117.tar.gz
aports-de650f84b869534b65356e97d4d469cea6fa6117.tar.bz2
aports-de650f84b869534b65356e97d4d469cea6fa6117.tar.xz
community/qemu: backport kvm support for m1
backport patches from upstram that should make kvm work on m1 machines
-rw-r--r--community/qemu/0001-hw-arm-virt-Add-a-control-for-the-the-highmem-PCIe-M.patch112
-rw-r--r--community/qemu/0002-hw-arm-virt-Add-a-control-for-the-the-highmem-redist.patch82
-rw-r--r--community/qemu/0003-hw-arm-virt-Honor-highmem-setting-when-computing-the.patch66
-rw-r--r--community/qemu/0004-hw-arm-virt-Use-the-PA-range-to-compute-the-memory-m.patch151
-rw-r--r--community/qemu/0005-hw-arm-virt-Disable-highmem-devices-that-don-t-fit-i.patch75
-rw-r--r--community/qemu/0006-hw-arm-virt-Drop-superfluous-checks-against-highmem.patch58
-rw-r--r--community/qemu/APKBUILD14
7 files changed, 557 insertions, 1 deletions
diff --git a/community/qemu/0001-hw-arm-virt-Add-a-control-for-the-the-highmem-PCIe-M.patch b/community/qemu/0001-hw-arm-virt-Add-a-control-for-the-the-highmem-PCIe-M.patch
new file mode 100644
index 0000000000..1ebbf062ea
--- /dev/null
+++ b/community/qemu/0001-hw-arm-virt-Add-a-control-for-the-the-highmem-PCIe-M.patch
@@ -0,0 +1,112 @@
+From c8f008c40fb9dc35bc0fdcd52d747c920d614725 Mon Sep 17 00:00:00 2001
+From: Marc Zyngier <maz@kernel.org>
+Date: Fri, 14 Jan 2022 14:07:36 +0000
+Subject: [PATCH 1/6] hw/arm/virt: Add a control for the the highmem PCIe MMIO
+
+Just like we can control the enablement of the highmem PCIe ECAM
+region using highmem_ecam, let's add a control for the highmem
+PCIe MMIO region.
+
+Similarily to highmem_ecam, this region is disabled when highmem
+is off.
+
+Signed-off-by: Marc Zyngier <maz@kernel.org>
+Reviewed-by: Eric Auger <eric.auger@redhat.com>
+Message-id: 20220114140741.1358263-2-maz@kernel.org
+Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
+---
+ hw/arm/virt-acpi-build.c | 10 ++++------
+ hw/arm/virt.c | 7 +++++--
+ include/hw/arm/virt.h | 1 +
+ 3 files changed, 10 insertions(+), 8 deletions(-)
+
+diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
+index f2514ce77c..449fab0080 100644
+--- a/hw/arm/virt-acpi-build.c
++++ b/hw/arm/virt-acpi-build.c
+@@ -158,10 +158,9 @@ static void acpi_dsdt_add_virtio(Aml *scope,
+ }
+
+ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap,
+- uint32_t irq, bool use_highmem, bool highmem_ecam,
+- VirtMachineState *vms)
++ uint32_t irq, VirtMachineState *vms)
+ {
+- int ecam_id = VIRT_ECAM_ID(highmem_ecam);
++ int ecam_id = VIRT_ECAM_ID(vms->highmem_ecam);
+ struct GPEXConfig cfg = {
+ .mmio32 = memmap[VIRT_PCIE_MMIO],
+ .pio = memmap[VIRT_PCIE_PIO],
+@@ -170,7 +169,7 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap,
+ .bus = vms->bus,
+ };
+
+- if (use_highmem) {
++ if (vms->highmem_mmio) {
+ cfg.mmio64 = memmap[VIRT_HIGH_PCIE_MMIO];
+ }
+
+@@ -869,8 +868,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
+ acpi_dsdt_add_fw_cfg(scope, &memmap[VIRT_FW_CFG]);
+ acpi_dsdt_add_virtio(scope, &memmap[VIRT_MMIO],
+ (irqmap[VIRT_MMIO] + ARM_SPI_BASE), NUM_VIRTIO_TRANSPORTS);
+- acpi_dsdt_add_pci(scope, memmap, (irqmap[VIRT_PCIE] + ARM_SPI_BASE),
+- vms->highmem, vms->highmem_ecam, vms);
++ acpi_dsdt_add_pci(scope, memmap, irqmap[VIRT_PCIE] + ARM_SPI_BASE, vms);
+ if (vms->acpi_dev) {
+ build_ged_aml(scope, "\\_SB."GED_DEVICE,
+ HOTPLUG_HANDLER(vms->acpi_dev),
+diff --git a/hw/arm/virt.c b/hw/arm/virt.c
+index a76d86b592..16369ce10e 100644
+--- a/hw/arm/virt.c
++++ b/hw/arm/virt.c
+@@ -1419,7 +1419,7 @@ static void create_pcie(VirtMachineState *vms)
+ mmio_reg, base_mmio, size_mmio);
+ memory_region_add_subregion(get_system_memory(), base_mmio, mmio_alias);
+
+- if (vms->highmem) {
++ if (vms->highmem_mmio) {
+ /* Map high MMIO space */
+ MemoryRegion *high_mmio_alias = g_new0(MemoryRegion, 1);
+
+@@ -1473,7 +1473,7 @@ static void create_pcie(VirtMachineState *vms)
+ qemu_fdt_setprop_sized_cells(ms->fdt, nodename, "reg",
+ 2, base_ecam, 2, size_ecam);
+
+- if (vms->highmem) {
++ if (vms->highmem_mmio) {
+ qemu_fdt_setprop_sized_cells(ms->fdt, nodename, "ranges",
+ 1, FDT_PCI_RANGE_IOPORT, 2, 0,
+ 2, base_pio, 2, size_pio,
+@@ -2112,6 +2112,8 @@ static void machvirt_init(MachineState *machine)
+
+ virt_flash_fdt(vms, sysmem, secure_sysmem ?: sysmem);
+
++ vms->highmem_mmio &= vms->highmem;
++
+ create_gic(vms, sysmem);
+
+ virt_cpu_post_init(vms, sysmem);
+@@ -2899,6 +2901,7 @@ static void virt_instance_init(Object *obj)
+ vms->gic_version = VIRT_GIC_VERSION_NOSEL;
+
+ vms->highmem_ecam = !vmc->no_highmem_ecam;
++ vms->highmem_mmio = true;
+
+ if (vmc->no_its) {
+ vms->its = false;
+diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
+index be0534608f..cf5d8b83de 100644
+--- a/include/hw/arm/virt.h
++++ b/include/hw/arm/virt.h
+@@ -143,6 +143,7 @@ struct VirtMachineState {
+ bool secure;
+ bool highmem;
+ bool highmem_ecam;
++ bool highmem_mmio;
+ bool its;
+ bool tcg_its;
+ bool virt;
+--
+2.35.0
+
diff --git a/community/qemu/0002-hw-arm-virt-Add-a-control-for-the-the-highmem-redist.patch b/community/qemu/0002-hw-arm-virt-Add-a-control-for-the-the-highmem-redist.patch
new file mode 100644
index 0000000000..94e7df0637
--- /dev/null
+++ b/community/qemu/0002-hw-arm-virt-Add-a-control-for-the-the-highmem-redist.patch
@@ -0,0 +1,82 @@
+From a63618b147443de2485fb93705e21879b25c64c2 Mon Sep 17 00:00:00 2001
+From: Marc Zyngier <maz@kernel.org>
+Date: Fri, 14 Jan 2022 14:07:37 +0000
+Subject: [PATCH 2/6] hw/arm/virt: Add a control for the the highmem
+ redistributors
+
+Just like we can control the enablement of the highmem PCIe region
+using highmem_ecam, let's add a control for the highmem GICv3
+redistributor region.
+
+Similarily to highmem_ecam, these redistributors are disabled when
+highmem is off.
+
+Reviewed-by: Andrew Jones <drjones@redhat.com>
+Signed-off-by: Marc Zyngier <maz@kernel.org>
+Reviewed-by: Eric Auger <eric.auger@redhat.com>
+Message-id: 20220114140741.1358263-3-maz@kernel.org
+Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
+---
+ hw/arm/virt-acpi-build.c | 2 ++
+ hw/arm/virt.c | 2 ++
+ include/hw/arm/virt.h | 4 +++-
+ 3 files changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
+index 449fab0080..0757c28f69 100644
+--- a/hw/arm/virt-acpi-build.c
++++ b/hw/arm/virt-acpi-build.c
+@@ -947,6 +947,8 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables)
+ acpi_add_table(table_offsets, tables_blob);
+ build_fadt_rev5(tables_blob, tables->linker, vms, dsdt);
+
++ vms->highmem_redists &= vms->highmem;
++
+ acpi_add_table(table_offsets, tables_blob);
+ build_madt(tables_blob, tables->linker, vms);
+
+diff --git a/hw/arm/virt.c b/hw/arm/virt.c
+index 16369ce10e..62bdce1eb4 100644
+--- a/hw/arm/virt.c
++++ b/hw/arm/virt.c
+@@ -2113,6 +2113,7 @@ static void machvirt_init(MachineState *machine)
+ virt_flash_fdt(vms, sysmem, secure_sysmem ?: sysmem);
+
+ vms->highmem_mmio &= vms->highmem;
++ vms->highmem_redists &= vms->highmem;
+
+ create_gic(vms, sysmem);
+
+@@ -2902,6 +2903,7 @@ static void virt_instance_init(Object *obj)
+
+ vms->highmem_ecam = !vmc->no_highmem_ecam;
+ vms->highmem_mmio = true;
++ vms->highmem_redists = true;
+
+ if (vmc->no_its) {
+ vms->its = false;
+diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
+index cf5d8b83de..c1ea17d0de 100644
+--- a/include/hw/arm/virt.h
++++ b/include/hw/arm/virt.h
+@@ -144,6 +144,7 @@ struct VirtMachineState {
+ bool highmem;
+ bool highmem_ecam;
+ bool highmem_mmio;
++ bool highmem_redists;
+ bool its;
+ bool tcg_its;
+ bool virt;
+@@ -191,7 +192,8 @@ static inline int virt_gicv3_redist_region_count(VirtMachineState *vms)
+
+ assert(vms->gic_version == VIRT_GIC_VERSION_3);
+
+- return MACHINE(vms)->smp.cpus > redist0_capacity ? 2 : 1;
++ return (MACHINE(vms)->smp.cpus > redist0_capacity &&
++ vms->highmem_redists) ? 2 : 1;
+ }
+
+ #endif /* QEMU_ARM_VIRT_H */
+--
+2.35.0
+
diff --git a/community/qemu/0003-hw-arm-virt-Honor-highmem-setting-when-computing-the.patch b/community/qemu/0003-hw-arm-virt-Honor-highmem-setting-when-computing-the.patch
new file mode 100644
index 0000000000..675adf9437
--- /dev/null
+++ b/community/qemu/0003-hw-arm-virt-Honor-highmem-setting-when-computing-the.patch
@@ -0,0 +1,66 @@
+From 0152b169ce163b99660b80a8ed6664707e889052 Mon Sep 17 00:00:00 2001
+From: Marc Zyngier <maz@kernel.org>
+Date: Fri, 14 Jan 2022 14:07:38 +0000
+Subject: [PATCH 3/6] hw/arm/virt: Honor highmem setting when computing the
+ memory map
+
+Even when the VM is configured with highmem=off, the highest_gpa
+field includes devices that are above the 4GiB limit.
+Similarily, nothing seem to check that the memory is within
+the limit set by the highmem=off option.
+
+This leads to failures in virt_kvm_type() on systems that have
+a crippled IPA range, as the reported IPA space is larger than
+what it should be.
+
+Instead, honor the user-specified limit to only use the devices
+at the lowest end of the spectrum, and fail if we have memory
+crossing the 4GiB limit.
+
+Reviewed-by: Andrew Jones <drjones@redhat.com>
+Reviewed-by: Eric Auger <eric.auger@redhat.com>
+Signed-off-by: Marc Zyngier <maz@kernel.org>
+Message-id: 20220114140741.1358263-4-maz@kernel.org
+Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
+---
+ hw/arm/virt.c | 10 +++++++---
+ 1 file changed, 7 insertions(+), 3 deletions(-)
+
+diff --git a/hw/arm/virt.c b/hw/arm/virt.c
+index 62bdce1eb4..3b839ba78b 100644
+--- a/hw/arm/virt.c
++++ b/hw/arm/virt.c
+@@ -1670,7 +1670,7 @@ static uint64_t virt_cpu_mp_affinity(VirtMachineState *vms, int idx)
+ static void virt_set_memmap(VirtMachineState *vms)
+ {
+ MachineState *ms = MACHINE(vms);
+- hwaddr base, device_memory_base, device_memory_size;
++ hwaddr base, device_memory_base, device_memory_size, memtop;
+ int i;
+
+ vms->memmap = extended_memmap;
+@@ -1697,7 +1697,11 @@ static void virt_set_memmap(VirtMachineState *vms)
+ device_memory_size = ms->maxram_size - ms->ram_size + ms->ram_slots * GiB;
+
+ /* Base address of the high IO region */
+- base = device_memory_base + ROUND_UP(device_memory_size, GiB);
++ memtop = base = device_memory_base + ROUND_UP(device_memory_size, GiB);
++ if (!vms->highmem && memtop > 4 * GiB) {
++ error_report("highmem=off, but memory crosses the 4GiB limit\n");
++ exit(EXIT_FAILURE);
++ }
+ if (base < device_memory_base) {
+ error_report("maxmem/slots too huge");
+ exit(EXIT_FAILURE);
+@@ -1714,7 +1718,7 @@ static void virt_set_memmap(VirtMachineState *vms)
+ vms->memmap[i].size = size;
+ base += size;
+ }
+- vms->highest_gpa = base - 1;
++ vms->highest_gpa = (vms->highmem ? base : memtop) - 1;
+ if (device_memory_size > 0) {
+ ms->device_memory = g_malloc0(sizeof(*ms->device_memory));
+ ms->device_memory->base = device_memory_base;
+--
+2.35.0
+
diff --git a/community/qemu/0004-hw-arm-virt-Use-the-PA-range-to-compute-the-memory-m.patch b/community/qemu/0004-hw-arm-virt-Use-the-PA-range-to-compute-the-memory-m.patch
new file mode 100644
index 0000000000..c7c1ae6ef2
--- /dev/null
+++ b/community/qemu/0004-hw-arm-virt-Use-the-PA-range-to-compute-the-memory-m.patch
@@ -0,0 +1,151 @@
+From 3715c251cc781b263fbd7f7c535fde7a4da401c3 Mon Sep 17 00:00:00 2001
+From: Marc Zyngier <maz@kernel.org>
+Date: Fri, 14 Jan 2022 14:07:39 +0000
+Subject: [PATCH 4/6] hw/arm/virt: Use the PA range to compute the memory map
+
+The highmem attribute is nothing but another way to express the
+PA range of a VM. To support HW that has a smaller PA range then
+what QEMU assumes, pass this PA range to the virt_set_memmap()
+function, allowing it to correctly exclude highmem devices
+if they are outside of the PA range.
+
+Signed-off-by: Marc Zyngier <maz@kernel.org>
+Reviewed-by: Eric Auger <eric.auger@redhat.com>
+Message-id: 20220114140741.1358263-5-maz@kernel.org
+Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
+---
+ hw/arm/virt.c | 64 +++++++++++++++++++++++++++++++++++++++++----------
+ 1 file changed, 52 insertions(+), 12 deletions(-)
+
+diff --git a/hw/arm/virt.c b/hw/arm/virt.c
+index 3b839ba78b..8627f5ab95 100644
+--- a/hw/arm/virt.c
++++ b/hw/arm/virt.c
+@@ -1667,7 +1667,7 @@ static uint64_t virt_cpu_mp_affinity(VirtMachineState *vms, int idx)
+ return arm_cpu_mp_affinity(idx, clustersz);
+ }
+
+-static void virt_set_memmap(VirtMachineState *vms)
++static void virt_set_memmap(VirtMachineState *vms, int pa_bits)
+ {
+ MachineState *ms = MACHINE(vms);
+ hwaddr base, device_memory_base, device_memory_size, memtop;
+@@ -1685,6 +1685,14 @@ static void virt_set_memmap(VirtMachineState *vms)
+ exit(EXIT_FAILURE);
+ }
+
++ /*
++ * !highmem is exactly the same as limiting the PA space to 32bit,
++ * irrespective of the underlying capabilities of the HW.
++ */
++ if (!vms->highmem) {
++ pa_bits = 32;
++ }
++
+ /*
+ * We compute the base of the high IO region depending on the
+ * amount of initial and device memory. The device memory start/size
+@@ -1698,8 +1706,9 @@ static void virt_set_memmap(VirtMachineState *vms)
+
+ /* Base address of the high IO region */
+ memtop = base = device_memory_base + ROUND_UP(device_memory_size, GiB);
+- if (!vms->highmem && memtop > 4 * GiB) {
+- error_report("highmem=off, but memory crosses the 4GiB limit\n");
++ if (memtop > BIT_ULL(pa_bits)) {
++ error_report("Addressing limited to %d bits, but memory exceeds it by %llu bytes\n",
++ pa_bits, memtop - BIT_ULL(pa_bits));
+ exit(EXIT_FAILURE);
+ }
+ if (base < device_memory_base) {
+@@ -1718,7 +1727,13 @@ static void virt_set_memmap(VirtMachineState *vms)
+ vms->memmap[i].size = size;
+ base += size;
+ }
+- vms->highest_gpa = (vms->highmem ? base : memtop) - 1;
++
++ /*
++ * If base fits within pa_bits, all good. If it doesn't, limit it
++ * to the end of RAM, which is guaranteed to fit within pa_bits.
++ */
++ vms->highest_gpa = (base <= BIT_ULL(pa_bits) ? base : memtop) - 1;
++
+ if (device_memory_size > 0) {
+ ms->device_memory = g_malloc0(sizeof(*ms->device_memory));
+ ms->device_memory->base = device_memory_base;
+@@ -1909,12 +1924,43 @@ static void machvirt_init(MachineState *machine)
+ unsigned int smp_cpus = machine->smp.cpus;
+ unsigned int max_cpus = machine->smp.max_cpus;
+
++ if (!cpu_type_valid(machine->cpu_type)) {
++ error_report("mach-virt: CPU type %s not supported", machine->cpu_type);
++ exit(1);
++ }
++
++ possible_cpus = mc->possible_cpu_arch_ids(machine);
++
+ /*
+ * In accelerated mode, the memory map is computed earlier in kvm_type()
+ * to create a VM with the right number of IPA bits.
+ */
+ if (!vms->memmap) {
+- virt_set_memmap(vms);
++ Object *cpuobj;
++ ARMCPU *armcpu;
++ int pa_bits;
++
++ /*
++ * Instanciate a temporary CPU object to find out about what
++ * we are about to deal with. Once this is done, get rid of
++ * the object.
++ */
++ cpuobj = object_new(possible_cpus->cpus[0].type);
++ armcpu = ARM_CPU(cpuobj);
++
++ if (object_property_get_bool(cpuobj, "aarch64", NULL)) {
++ pa_bits = arm_pamax(armcpu);
++ } else if (arm_feature(&armcpu->env, ARM_FEATURE_LPAE)) {
++ /* v7 with LPAE */
++ pa_bits = 40;
++ } else {
++ /* Anything else */
++ pa_bits = 32;
++ }
++
++ object_unref(cpuobj);
++
++ virt_set_memmap(vms, pa_bits);
+ }
+
+ /* We can probe only here because during property set
+@@ -1922,11 +1968,6 @@ static void machvirt_init(MachineState *machine)
+ */
+ finalize_gic_version(vms);
+
+- if (!cpu_type_valid(machine->cpu_type)) {
+- error_report("mach-virt: CPU type %s not supported", machine->cpu_type);
+- exit(1);
+- }
+-
+ if (vms->secure) {
+ /*
+ * The Secure view of the world is the same as the NonSecure,
+@@ -1996,7 +2037,6 @@ static void machvirt_init(MachineState *machine)
+
+ create_fdt(vms);
+
+- possible_cpus = mc->possible_cpu_arch_ids(machine);
+ assert(possible_cpus->len == max_cpus);
+ for (n = 0; n < possible_cpus->len; n++) {
+ Object *cpuobj;
+@@ -2735,7 +2775,7 @@ static int virt_kvm_type(MachineState *ms, const char *type_str)
+ max_vm_pa_size = kvm_arm_get_max_vm_ipa_size(ms, &fixed_ipa);
+
+ /* we freeze the memory map to compute the highest gpa */
+- virt_set_memmap(vms);
++ virt_set_memmap(vms, max_vm_pa_size);
+
+ requested_pa_size = 64 - clz64(vms->highest_gpa);
+
+--
+2.35.0
+
diff --git a/community/qemu/0005-hw-arm-virt-Disable-highmem-devices-that-don-t-fit-i.patch b/community/qemu/0005-hw-arm-virt-Disable-highmem-devices-that-don-t-fit-i.patch
new file mode 100644
index 0000000000..7b4b2a728b
--- /dev/null
+++ b/community/qemu/0005-hw-arm-virt-Disable-highmem-devices-that-don-t-fit-i.patch
@@ -0,0 +1,75 @@
+From d9afe24c29a0985b29d7535b2f1615affbd1a888 Mon Sep 17 00:00:00 2001
+From: Marc Zyngier <maz@kernel.org>
+Date: Fri, 14 Jan 2022 14:07:40 +0000
+Subject: [PATCH 5/6] hw/arm/virt: Disable highmem devices that don't fit in
+ the PA range
+
+In order to only keep the highmem devices that actually fit in
+the PA range, check their location against the range and update
+highest_gpa if they fit. If they don't, mark them as disabled.
+
+Signed-off-by: Marc Zyngier <maz@kernel.org>
+Reviewed-by: Eric Auger <eric.auger@redhat.com>
+Message-id: 20220114140741.1358263-6-maz@kernel.org
+Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
+---
+ hw/arm/virt.c | 34 ++++++++++++++++++++++++++++------
+ 1 file changed, 28 insertions(+), 6 deletions(-)
+
+diff --git a/hw/arm/virt.c b/hw/arm/virt.c
+index 8627f5ab95..8d02c2267d 100644
+--- a/hw/arm/virt.c
++++ b/hw/arm/virt.c
+@@ -1719,21 +1719,43 @@ static void virt_set_memmap(VirtMachineState *vms, int pa_bits)
+ base = vms->memmap[VIRT_MEM].base + LEGACY_RAMLIMIT_BYTES;
+ }
+
++ /* 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;
+ }
+
+- /*
+- * If base fits within pa_bits, all good. If it doesn't, limit it
+- * to the end of RAM, which is guaranteed to fit within pa_bits.
+- */
+- vms->highest_gpa = (base <= BIT_ULL(pa_bits) ? base : memtop) - 1;
+-
+ if (device_memory_size > 0) {
+ ms->device_memory = g_malloc0(sizeof(*ms->device_memory));
+ ms->device_memory->base = device_memory_base;
+--
+2.35.0
+
diff --git a/community/qemu/0006-hw-arm-virt-Drop-superfluous-checks-against-highmem.patch b/community/qemu/0006-hw-arm-virt-Drop-superfluous-checks-against-highmem.patch
new file mode 100644
index 0000000000..d26e130d69
--- /dev/null
+++ b/community/qemu/0006-hw-arm-virt-Drop-superfluous-checks-against-highmem.patch
@@ -0,0 +1,58 @@
+From 2dcb74e5c271b9bb581013b949e4ef3bb3f6969b Mon Sep 17 00:00:00 2001
+From: Marc Zyngier <maz@kernel.org>
+Date: Fri, 14 Jan 2022 14:07:41 +0000
+Subject: [PATCH 6/6] hw/arm/virt: Drop superfluous checks against highmem
+
+Now that the devices present in the extended memory map are checked
+against the available PA space and disabled when they don't fit,
+there is no need to keep the same checks against highmem, as
+highmem really is a shortcut for the PA space being 32bit.
+
+Reviewed-by: Eric Auger <eric.auger@redhat.com>
+Signed-off-by: Marc Zyngier <maz@kernel.org>
+Message-id: 20220114140741.1358263-7-maz@kernel.org
+Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
+---
+ hw/arm/virt-acpi-build.c | 2 --
+ hw/arm/virt.c | 5 +----
+ 2 files changed, 1 insertion(+), 6 deletions(-)
+
+diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
+index 0757c28f69..449fab0080 100644
+--- a/hw/arm/virt-acpi-build.c
++++ b/hw/arm/virt-acpi-build.c
+@@ -947,8 +947,6 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables)
+ acpi_add_table(table_offsets, tables_blob);
+ build_fadt_rev5(tables_blob, tables->linker, vms, dsdt);
+
+- vms->highmem_redists &= vms->highmem;
+-
+ acpi_add_table(table_offsets, tables_blob);
+ build_madt(tables_blob, tables->linker, vms);
+
+diff --git a/hw/arm/virt.c b/hw/arm/virt.c
+index 8d02c2267d..141350bf21 100644
+--- a/hw/arm/virt.c
++++ b/hw/arm/virt.c
+@@ -2178,9 +2178,6 @@ static void machvirt_init(MachineState *machine)
+
+ virt_flash_fdt(vms, sysmem, secure_sysmem ?: sysmem);
+
+- vms->highmem_mmio &= vms->highmem;
+- vms->highmem_redists &= vms->highmem;
+-
+ create_gic(vms, sysmem);
+
+ virt_cpu_post_init(vms, sysmem);
+@@ -2199,7 +2196,7 @@ static void machvirt_init(MachineState *machine)
+ machine->ram_size, "mach-virt.tag");
+ }
+
+- vms->highmem_ecam &= vms->highmem && (!firmware_loaded || aarch64);
++ vms->highmem_ecam &= (!firmware_loaded || aarch64);
+
+ create_rtc(vms);
+
+--
+2.35.0
+
diff --git a/community/qemu/APKBUILD b/community/qemu/APKBUILD
index 66e6b332d1..08b439f601 100644
--- a/community/qemu/APKBUILD
+++ b/community/qemu/APKBUILD
@@ -4,7 +4,7 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=qemu
pkgver=6.2.0
-pkgrel=1
+pkgrel=2
pkgdesc="QEMU is a generic machine emulator and virtualizer"
url="https://qemu.org/"
arch="all"
@@ -190,6 +190,12 @@ source="https://wiki.qemu-project.org/download/qemu-$pkgver.tar.xz
mips-softfloat.patch
CVE-2021-20255.patch
+ 0001-hw-arm-virt-Add-a-control-for-the-the-highmem-PCIe-M.patch
+ 0002-hw-arm-virt-Add-a-control-for-the-the-highmem-redist.patch
+ 0003-hw-arm-virt-Honor-highmem-setting-when-computing-the.patch
+ 0004-hw-arm-virt-Use-the-PA-range-to-compute-the-memory-m.patch
+ 0005-hw-arm-virt-Disable-highmem-devices-that-don-t-fit-i.patch
+ 0006-hw-arm-virt-Drop-superfluous-checks-against-highmem.patch
$pkgname-guest-agent.confd
$pkgname-guest-agent.initd
@@ -483,6 +489,12 @@ d7de79ea74e36702cac4a59e472564a55f0a663be7e63c3755e32b4b5dfbc04b390ee79f09f43f6a
d6b81846cefd46b8fd1fb04450d4898f97dc77d11e049fb1bc8e2553bbb88c8325151d0e4bec70cc6820a5863c1d1749b99100b4747d91182856c3ca1946cb28 guest-agent-shutdown.patch
e3acdab38c17eccb87bce1dfec22ce9474dae281474b886860848ae206006b071378882b855023916bb00a86cfbe55216c3fa4336b4e402399df2a9937b8c21c mips-softfloat.patch
e9389a6e3b2c3b59f66ea13eb7a3515e87341a68ca14afeb1ddd0084717bf4a13f5f58dc41dadbf0f2faf8fe1ae94ba7d1469c41539c79e45fa1624c6081e904 CVE-2021-20255.patch
+88d2599275f64b67ee56b110241c4ad3e74aaf8a18d031e9c9323c8d887adeb4171b4b53c5d4991567dfac995c17a309fd10f3a70e72c2d26e4aec3eb526ad63 0001-hw-arm-virt-Add-a-control-for-the-the-highmem-PCIe-M.patch
+0dbc4e0f2cc880886ce1f16587b2dec8f04e478fdcc6378bedc50a6c4dacafec04bf7882db3522e4ee70f26e6d84557d27cd827e8982db31620f2973d4ba4a28 0002-hw-arm-virt-Add-a-control-for-the-the-highmem-redist.patch
+bdc51c430987322af007f966d8c03f7c7ee844e8a8d3bebef4d26a8f163f4b85751bcc6f704b4b5c29f33d02c81b6bc660b5e798e97ab5c3da1fd05eb991548f 0003-hw-arm-virt-Honor-highmem-setting-when-computing-the.patch
+cfb9ffd164284b9822ccd213e368e917e159717a12221c548df7e91382189b56e7e98565fb6c2f4633be163079fe3130b7593cc7aeffc091d117b07fe30edc08 0004-hw-arm-virt-Use-the-PA-range-to-compute-the-memory-m.patch
+198966993e94247067bf2125aa30eb90f83178ec1cd090380b2ecc925d7509d4d22b9c9880c500cc092e84c9ee25cdc25b1f0b17a3b40b3f3fca682f3d0aae5e 0005-hw-arm-virt-Disable-highmem-devices-that-don-t-fit-i.patch
+719f0fd6d985db2b1f7dd95138dfa3a09a5241de6358267d5cdc5a309ab268526cfefe24a04b6ab718d26e65a69f0dbf39154006bdf16a24fe149a6bec732580 0006-hw-arm-virt-Drop-superfluous-checks-against-highmem.patch
d90c034cae3f9097466854ed1a9f32ab4b02089fcdf7320e8f4da13b2b1ff65067233f48809911485e4431d7ec1a22448b934121bc9522a2dc489009e87e2b1f qemu-guest-agent.confd
1cd24c2444c5935a763c501af2b0da31635aad9cf62e55416d6477fcec153cddbe7de205d99616def11b085e0dd366ba22463d2270f831d884edbc307c7864a6 qemu-guest-agent.initd
9b7a89b20fcf737832cb7b4d5dc7d8301dd88169cbe5339eda69fbb51c2e537d8cb9ec7cf37600899e734209e63410d50d0821bce97e401421db39c294d97be2 80-kvm.rules