From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Aaron Lewis <aaronlewis@google.com>,
Andrew Jones <drjones@redhat.com>,
Steve Rutherford <srutherford@google.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Sasha Levin <sashal@kernel.org>,
kvm@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: [PATCH AUTOSEL 5.11 04/12] selftests: kvm: Mmap the entire vcpu mmap area
Date: Sun, 7 Mar 2021 08:57:38 -0500 [thread overview]
Message-ID: <20210307135746.967418-4-sashal@kernel.org> (raw)
In-Reply-To: <20210307135746.967418-1-sashal@kernel.org>
From: Aaron Lewis <aaronlewis@google.com>
[ Upstream commit 6528fc0a11de3d16339cf17639e2f69a68fcaf4d ]
The vcpu mmap area may consist of more than just the kvm_run struct.
Allocate enough space for the entire vcpu mmap area. Without this, on
x86, the PIO page, for example, will be missing. This is problematic
when dealing with an unhandled exception from the guest as the exception
vector will be incorrectly reported as 0x0.
Message-Id: <20210210165035.3712489-1-aaronlewis@google.com>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Co-developed-by: Steve Rutherford <srutherford@google.com>
Signed-off-by: Aaron Lewis <aaronlewis@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
tools/testing/selftests/kvm/lib/kvm_util.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c
index fa5a90e6c6f0..859a0b57c683 100644
--- a/tools/testing/selftests/kvm/lib/kvm_util.c
+++ b/tools/testing/selftests/kvm/lib/kvm_util.c
@@ -21,6 +21,8 @@
#define KVM_UTIL_PGS_PER_HUGEPG 512
#define KVM_UTIL_MIN_PFN 2
+static int vcpu_mmap_sz(void);
+
/* Aligns x up to the next multiple of size. Size must be a power of 2. */
static void *align(void *x, size_t size)
{
@@ -509,7 +511,7 @@ static void vm_vcpu_rm(struct kvm_vm *vm, struct vcpu *vcpu)
vcpu->dirty_gfns = NULL;
}
- ret = munmap(vcpu->state, sizeof(*vcpu->state));
+ ret = munmap(vcpu->state, vcpu_mmap_sz());
TEST_ASSERT(ret == 0, "munmap of VCPU fd failed, rc: %i "
"errno: %i", ret, errno);
close(vcpu->fd);
@@ -978,7 +980,7 @@ void vm_vcpu_add(struct kvm_vm *vm, uint32_t vcpuid)
TEST_ASSERT(vcpu_mmap_sz() >= sizeof(*vcpu->state), "vcpu mmap size "
"smaller than expected, vcpu_mmap_sz: %i expected_min: %zi",
vcpu_mmap_sz(), sizeof(*vcpu->state));
- vcpu->state = (struct kvm_run *) mmap(NULL, sizeof(*vcpu->state),
+ vcpu->state = (struct kvm_run *) mmap(NULL, vcpu_mmap_sz(),
PROT_READ | PROT_WRITE, MAP_SHARED, vcpu->fd, 0);
TEST_ASSERT(vcpu->state != MAP_FAILED, "mmap vcpu_state failed, "
"vcpu id: %u errno: %i", vcpuid, errno);
--
2.30.1
next prev parent reply other threads:[~2021-03-07 13:58 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-07 13:57 [PATCH AUTOSEL 5.11 01/12] btrfs: avoid checking for RO block group twice during nocow writeback Sasha Levin
2021-03-07 13:57 ` [PATCH AUTOSEL 5.11 02/12] pstore: Fix warning in pstore_kill_sb() Sasha Levin
2021-03-07 13:57 ` [PATCH AUTOSEL 5.11 03/12] btrfs: subpage: fix the false data csum mismatch error Sasha Levin
2021-03-08 15:43 ` David Sterba
2021-03-07 13:57 ` Sasha Levin [this message]
2021-03-07 13:57 ` [PATCH AUTOSEL 5.11 05/12] pstore/ram: Rate-limit "uncorrectable error in header" message Sasha Levin
2021-03-07 13:57 ` [PATCH AUTOSEL 5.11 06/12] drm/amdgpu: enable BACO runpm by default on sienna cichlid and navy flounder Sasha Levin
2021-03-07 13:57 ` [PATCH AUTOSEL 5.11 07/12] tracing: Skip selftests if tracing is disabled Sasha Levin
2021-03-07 13:57 ` [PATCH AUTOSEL 5.11 08/12] nvme-pci: mark Seagate Nytro XM1440 as QUIRK_NO_NS_DESC_LIST Sasha Levin
2021-03-07 13:57 ` [PATCH AUTOSEL 5.11 09/12] nvme-pci: mark Kingston SKC2000 as not supporting the deepest power state Sasha Levin
2021-03-07 15:00 ` Böszörményi Zoltán
2021-03-07 13:57 ` [PATCH AUTOSEL 5.11 10/12] nvme-pci: add quirks for Lexar 256GB SSD Sasha Levin
2021-03-07 13:57 ` [PATCH AUTOSEL 5.11 11/12] nvme-fabrics: fix kato initialization Sasha Levin
2021-03-07 13:57 ` [PATCH AUTOSEL 5.11 12/12] nvmet: model_number must be immutable once set Sasha Levin
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=20210307135746.967418-4-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=aaronlewis@google.com \
--cc=drjones@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=srutherford@google.com \
--cc=stable@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox