|
|
ddf19c |
From c35466c168e5219bf585aa65ac31fc9bdc7cbf36 Mon Sep 17 00:00:00 2001
|
|
|
ddf19c |
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
|
|
|
ddf19c |
Date: Fri, 24 Jan 2020 19:46:12 +0100
|
|
|
ddf19c |
Subject: [PATCH 003/116] vhost: Only align sections for vhost-user
|
|
|
ddf19c |
MIME-Version: 1.0
|
|
|
ddf19c |
Content-Type: text/plain; charset=UTF-8
|
|
|
ddf19c |
Content-Transfer-Encoding: 8bit
|
|
|
ddf19c |
|
|
|
ddf19c |
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
ddf19c |
Message-id: <20200124194613.41119-3-dgilbert@redhat.com>
|
|
|
ddf19c |
Patchwork-id: 93452
|
|
|
ddf19c |
O-Subject: [RHEL-AV-8.2 qemu-kvm PATCH 2/3] vhost: Only align sections for vhost-user
|
|
|
ddf19c |
Bugzilla: 1779041
|
|
|
ddf19c |
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
ddf19c |
RH-Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
|
|
|
ddf19c |
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
|
ddf19c |
|
|
|
ddf19c |
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
|
|
|
ddf19c |
|
|
|
ddf19c |
I added hugepage alignment code in c1ece84e7c9 to deal with
|
|
|
ddf19c |
vhost-user + postcopy which needs aligned pages when using userfault.
|
|
|
ddf19c |
However, on x86 the lower 2MB of address space tends to be shotgun'd
|
|
|
ddf19c |
with small fragments around the 512-640k range - e.g. video RAM, and
|
|
|
ddf19c |
with HyperV synic pages tend to sit around there - again splitting
|
|
|
ddf19c |
it up. The alignment code complains with a 'Section rounded to ...'
|
|
|
ddf19c |
error and gives up.
|
|
|
ddf19c |
|
|
|
ddf19c |
Since vhost-user already filters out devices without an fd
|
|
|
ddf19c |
(see vhost-user.c vhost_user_mem_section_filter) it shouldn't be
|
|
|
ddf19c |
affected by those overlaps.
|
|
|
ddf19c |
|
|
|
ddf19c |
Turn the alignment off on vhost-kernel so that it doesn't try
|
|
|
ddf19c |
and align, and thus won't hit the rounding issues.
|
|
|
ddf19c |
|
|
|
ddf19c |
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
ddf19c |
Message-Id: <20200116202414.157959-3-dgilbert@redhat.com>
|
|
|
ddf19c |
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
ddf19c |
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
ddf19c |
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
ddf19c |
(cherry picked from commit 76525114736e8f669766e69b715fa59ce8648aae)
|
|
|
ddf19c |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
ddf19c |
|
|
|
ddf19c |
hw/virtio/vhost.c | 34 ++++++++++++++++++
|
|
|
ddf19c |
1 file changed, 18 insertions(+), 16 deletions(-)
|
|
|
ddf19c |
|
|
|
ddf19c |
diff
|
|
|
ddf19c |
index 774d87d..25fd469 100644
|
|
|
ddf19c |
|
|
|
ddf19c |
|
|
|
ddf19c |
@@ -547,26 +547,28 @@ static void vhost_region_add_section(struct vhost_dev *dev,
|
|
|
ddf19c |
uintptr_t mrs_host = (uintptr_t)memory_region_get_ram_ptr(section->mr) +
|
|
|
ddf19c |
section->offset_within_region;
|
|
|
ddf19c |
RAMBlock *mrs_rb = section->mr->ram_block;
|
|
|
ddf19c |
- size_t mrs_page = qemu_ram_pagesize(mrs_rb);
|
|
|
ddf19c |
|
|
|
ddf19c |
trace_vhost_region_add_section(section->mr->name, mrs_gpa, mrs_size,
|
|
|
ddf19c |
mrs_host);
|
|
|
ddf19c |
|
|
|
ddf19c |
-
|
|
|
ddf19c |
-
|
|
|
ddf19c |
- uint64_t alignage = mrs_host & (mrs_page - 1);
|
|
|
ddf19c |
- if (alignage) {
|
|
|
ddf19c |
- mrs_host -= alignage;
|
|
|
ddf19c |
- mrs_size += alignage;
|
|
|
ddf19c |
- mrs_gpa -= alignage;
|
|
|
ddf19c |
- }
|
|
|
ddf19c |
-
|
|
|
ddf19c |
- alignage = mrs_size & (mrs_page - 1);
|
|
|
ddf19c |
- if (alignage) {
|
|
|
ddf19c |
- mrs_size += mrs_page - alignage;
|
|
|
ddf19c |
- }
|
|
|
ddf19c |
- trace_vhost_region_add_section_aligned(section->mr->name, mrs_gpa, mrs_size,
|
|
|
ddf19c |
- mrs_host);
|
|
|
ddf19c |
+ if (dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_USER) {
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ size_t mrs_page = qemu_ram_pagesize(mrs_rb);
|
|
|
ddf19c |
+ uint64_t alignage = mrs_host & (mrs_page - 1);
|
|
|
ddf19c |
+ if (alignage) {
|
|
|
ddf19c |
+ mrs_host -= alignage;
|
|
|
ddf19c |
+ mrs_size += alignage;
|
|
|
ddf19c |
+ mrs_gpa -= alignage;
|
|
|
ddf19c |
+ }
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ alignage = mrs_size & (mrs_page - 1);
|
|
|
ddf19c |
+ if (alignage) {
|
|
|
ddf19c |
+ mrs_size += mrs_page - alignage;
|
|
|
ddf19c |
+ }
|
|
|
ddf19c |
+ trace_vhost_region_add_section_aligned(section->mr->name, mrs_gpa, mrs_size,
|
|
|
ddf19c |
+ mrs_host);
|
|
|
ddf19c |
+ }
|
|
|
ddf19c |
|
|
|
ddf19c |
if (dev->n_tmp_sections) {
|
|
|
ddf19c |
/* Since we already have at least one section, lets see if
|
|
|
ddf19c |
--
|
|
|
ddf19c |
1.8.3.1
|
|
|
ddf19c |
|