From: Marc Zyngier <maz@kernel.org>
To: qemu-devel@nongnu.org
Cc: kvm@vger.kernel.org, kernel-team@android.com,
kvmarm@lists.cs.columbia.edu
Subject: [PATCH 2/3] hw/arm/virt: Honor highmem setting when computing highest_gpa
Date: Sun, 22 Aug 2021 15:44:40 +0100 [thread overview]
Message-ID: <20210822144441.1290891-3-maz@kernel.org> (raw)
In-Reply-To: <20210822144441.1290891-1-maz@kernel.org>
Even when the VM is configured with highmem=off, the highest_gpa
field includes devices that are above the 4GiB limit, which is
what highmem=off is supposed to enforce. 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.
Note that this doesn't affect memory, which is still allowed to
go beyond 4GiB with highmem=on configurations.
Cc: Andrew Jones <drjones@redhat.com>
Cc: Eric Auger <eric.auger@redhat.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Marc Zyngier <maz@kernel.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 81eda46b0b..bc189e30b8 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -1598,7 +1598,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, ceiling;
int i;
vms->memmap = extended_memmap;
@@ -1625,7 +1625,7 @@ 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);
+ ceiling = base = device_memory_base + ROUND_UP(device_memory_size, GiB);
if (base < device_memory_base) {
error_report("maxmem/slots too huge");
exit(EXIT_FAILURE);
@@ -1642,7 +1642,11 @@ static void virt_set_memmap(VirtMachineState *vms)
vms->memmap[i].size = size;
base += size;
}
- vms->highest_gpa = base - 1;
+ if (vms->highmem) {
+ /* If we have highmem, move the IPA limit to the top */
+ ceiling = base;
+ }
+ vms->highest_gpa = ceiling - 1;
if (device_memory_size > 0) {
ms->device_memory = g_malloc0(sizeof(*ms->device_memory));
ms->device_memory->base = device_memory_base;
--
2.30.2
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <maz@kernel.org>
To: qemu-devel@nongnu.org
Cc: Andrew Jones <drjones@redhat.com>,
Eric Auger <eric.auger@redhat.com>,
Peter Maydell <peter.maydell@linaro.org>,
kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org,
kernel-team@android.com
Subject: [PATCH 2/3] hw/arm/virt: Honor highmem setting when computing highest_gpa
Date: Sun, 22 Aug 2021 15:44:40 +0100 [thread overview]
Message-ID: <20210822144441.1290891-3-maz@kernel.org> (raw)
In-Reply-To: <20210822144441.1290891-1-maz@kernel.org>
Even when the VM is configured with highmem=off, the highest_gpa
field includes devices that are above the 4GiB limit, which is
what highmem=off is supposed to enforce. 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.
Note that this doesn't affect memory, which is still allowed to
go beyond 4GiB with highmem=on configurations.
Cc: Andrew Jones <drjones@redhat.com>
Cc: Eric Auger <eric.auger@redhat.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Marc Zyngier <maz@kernel.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 81eda46b0b..bc189e30b8 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -1598,7 +1598,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, ceiling;
int i;
vms->memmap = extended_memmap;
@@ -1625,7 +1625,7 @@ 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);
+ ceiling = base = device_memory_base + ROUND_UP(device_memory_size, GiB);
if (base < device_memory_base) {
error_report("maxmem/slots too huge");
exit(EXIT_FAILURE);
@@ -1642,7 +1642,11 @@ static void virt_set_memmap(VirtMachineState *vms)
vms->memmap[i].size = size;
base += size;
}
- vms->highest_gpa = base - 1;
+ if (vms->highmem) {
+ /* If we have highmem, move the IPA limit to the top */
+ ceiling = base;
+ }
+ vms->highest_gpa = ceiling - 1;
if (device_memory_size > 0) {
ms->device_memory = g_malloc0(sizeof(*ms->device_memory));
ms->device_memory->base = device_memory_base;
--
2.30.2
WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <maz@kernel.org>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Andrew Jones <drjones@redhat.com>,
kvm@vger.kernel.org, Eric Auger <eric.auger@redhat.com>,
kernel-team@android.com, kvmarm@lists.cs.columbia.edu
Subject: [PATCH 2/3] hw/arm/virt: Honor highmem setting when computing highest_gpa
Date: Sun, 22 Aug 2021 15:44:40 +0100 [thread overview]
Message-ID: <20210822144441.1290891-3-maz@kernel.org> (raw)
In-Reply-To: <20210822144441.1290891-1-maz@kernel.org>
Even when the VM is configured with highmem=off, the highest_gpa
field includes devices that are above the 4GiB limit, which is
what highmem=off is supposed to enforce. 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.
Note that this doesn't affect memory, which is still allowed to
go beyond 4GiB with highmem=on configurations.
Cc: Andrew Jones <drjones@redhat.com>
Cc: Eric Auger <eric.auger@redhat.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Marc Zyngier <maz@kernel.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 81eda46b0b..bc189e30b8 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -1598,7 +1598,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, ceiling;
int i;
vms->memmap = extended_memmap;
@@ -1625,7 +1625,7 @@ 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);
+ ceiling = base = device_memory_base + ROUND_UP(device_memory_size, GiB);
if (base < device_memory_base) {
error_report("maxmem/slots too huge");
exit(EXIT_FAILURE);
@@ -1642,7 +1642,11 @@ static void virt_set_memmap(VirtMachineState *vms)
vms->memmap[i].size = size;
base += size;
}
- vms->highest_gpa = base - 1;
+ if (vms->highmem) {
+ /* If we have highmem, move the IPA limit to the top */
+ ceiling = base;
+ }
+ vms->highest_gpa = ceiling - 1;
if (device_memory_size > 0) {
ms->device_memory = g_malloc0(sizeof(*ms->device_memory));
ms->device_memory->base = device_memory_base;
--
2.30.2
next prev parent reply other threads:[~2021-08-22 14:45 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-22 14:44 [PATCH 0/3] target/arm: Reduced-IPA space and highmem=off fixes Marc Zyngier
2021-08-22 14:44 ` Marc Zyngier
2021-08-22 14:44 ` Marc Zyngier
2021-08-22 14:44 ` [PATCH 1/3] hw/arm/virt: KVM: Probe for KVM_CAP_ARM_VM_IPA_SIZE when creating scratch VM Marc Zyngier
2021-08-22 14:44 ` Marc Zyngier
2021-08-22 14:44 ` Marc Zyngier
2021-08-23 9:07 ` Andrew Jones
2021-08-23 9:07 ` Andrew Jones
2021-08-23 9:07 ` Andrew Jones
2021-09-08 7:16 ` Eric Auger
2021-09-08 7:16 ` Eric Auger
2021-09-08 7:16 ` Eric Auger
2021-08-22 14:44 ` Marc Zyngier [this message]
2021-08-22 14:44 ` [PATCH 2/3] hw/arm/virt: Honor highmem setting when computing highest_gpa Marc Zyngier
2021-08-22 14:44 ` Marc Zyngier
2021-09-07 12:58 ` Peter Maydell
2021-09-07 12:58 ` Peter Maydell
2021-09-07 12:58 ` Peter Maydell
2021-09-08 7:16 ` Eric Auger
2021-09-08 7:16 ` Eric Auger
2021-09-08 7:16 ` Eric Auger
2021-08-22 14:44 ` [PATCH 3/3] docs/system/arm/virt: Fix documentation for the 'highmem' option Marc Zyngier
2021-08-22 14:44 ` Marc Zyngier
2021-08-22 14:44 ` Marc Zyngier
2021-09-07 12:51 ` Peter Maydell
2021-09-07 12:51 ` Peter Maydell
2021-09-07 12:51 ` Peter Maydell
2021-09-07 17:09 ` Marc Zyngier
2021-09-07 17:09 ` Marc Zyngier
2021-09-07 17:09 ` Marc Zyngier
2021-09-07 18:25 ` Peter Maydell
2021-09-07 18:25 ` Peter Maydell
2021-09-07 18:25 ` Peter Maydell
2021-09-08 9:16 ` Marc Zyngier
2021-09-08 9:16 ` Marc Zyngier
2021-09-08 9:16 ` Marc Zyngier
2021-09-08 8:53 ` Eric Auger
2021-09-08 8:53 ` Eric Auger
2021-09-08 8:53 ` Eric Auger
2021-08-22 14:48 ` [PATCH 0/3] target/arm: Reduced-IPA space and highmem=off fixes Marc Zyngier
2021-08-22 14:48 ` Marc Zyngier
2021-08-22 14:48 ` Marc Zyngier
2021-09-07 12:52 ` Peter Maydell
2021-09-07 12:52 ` Peter Maydell
2021-09-07 12:52 ` Peter Maydell
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=20210822144441.1290891-3-maz@kernel.org \
--to=maz@kernel.org \
--cc=kernel-team@android.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=qemu-devel@nongnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.