From nobody Mon May 6 23:41:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1579206334; cv=none; d=zohomail.com; s=zohoarc; b=GRDZlEFG5xDeBjYO6UA+j1UwHxRMQvJimSegelYtW2to4VwWWQV3YbXAz0MDgKQwIM7nPEUvr5uKAHuWjmlH1oRpVLbfLGJ5KKIcdTYKnzH1f665CqHfG5bX6OhipJ6bzQ24/FeRI8qBx33b8HsPFrWxNG2mQ8tE8SSkl0X9AQo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579206334; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WNez6IxU3/7Q9hEtGYz6qTWwUPHKrvmn+EW+Tm1OE9s=; b=CWGZBCsEhN0+SACj4Fw0VkTqUgbCbmT6Zz6/ugJldz9rfwmCCTix9BpcYZeFI/PGtrVRtsvRxP65Ks1FfSg9nNs+HRPcZEf/tgGA1YOGVjTZzdx64L7+Pb19OdcTlNRyIVp5q77ELej6RMn9CaXq4m/NQJLa+guNd0Spjd5m+ZM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579206334679132.2053329846409; Thu, 16 Jan 2020 12:25:34 -0800 (PST) Received: from localhost ([::1]:47990 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1isBht-0008Bw-4J for importer@patchew.org; Thu, 16 Jan 2020 15:25:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55792) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1isBgp-00073w-2C for qemu-devel@nongnu.org; Thu, 16 Jan 2020 15:24:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1isBgn-0006bF-67 for qemu-devel@nongnu.org; Thu, 16 Jan 2020 15:24:26 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:47083 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1isBgn-0006aW-2G for qemu-devel@nongnu.org; Thu, 16 Jan 2020 15:24:25 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-330-tcw-HadSNRmVyVeC7BsegQ-1; Thu, 16 Jan 2020 15:24:22 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BCD7C800D4E for ; Thu, 16 Jan 2020 20:24:21 +0000 (UTC) Received: from dgilbert-t580.localhost (unknown [10.36.118.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 97FBA5C1D8; Thu, 16 Jan 2020 20:24:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579206264; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WNez6IxU3/7Q9hEtGYz6qTWwUPHKrvmn+EW+Tm1OE9s=; b=c4vjEyjgSUHCC8hVvGunBDZbSOl2Z2GdtwtVb1vql2EuMnQzuyH5LIcIp0Vx5wDnhzO/MB +eiA9nbBtJAfUuTmu5fUsgs5mREgF4Yof2sRllAYKQMrsA7rY+gkgIyyy4lFJseU7bq//d jolDH+v760950RuHkdlhKYmiV76jSkk= From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, vkuznets@redhat.com, mst@redhat.com, jasowang@redhat.com, pbonzini@redhat.com Subject: [PATCH v3 1/2] vhost: Add names to section rounded warning Date: Thu, 16 Jan 2020 20:24:13 +0000 Message-Id: <20200116202414.157959-2-dgilbert@redhat.com> In-Reply-To: <20200116202414.157959-1-dgilbert@redhat.com> References: <20200116202414.157959-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: tcw-HadSNRmVyVeC7BsegQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: "Dr. David Alan Gilbert" Add the memory region names to section rounding/alignment warnings. Signed-off-by: Dr. David Alan Gilbert --- hw/virtio/vhost.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 4da0d5a6c5..774d87d98e 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -590,9 +590,10 @@ static void vhost_region_add_section(struct vhost_dev = *dev, * match up in the same RAMBlock if they do. */ if (mrs_gpa < prev_gpa_start) { - error_report("%s:Section rounded to %"PRIx64 - " prior to previous %"PRIx64, - __func__, mrs_gpa, prev_gpa_start); + error_report("%s:Section '%s' rounded to %"PRIx64 + " prior to previous '%s' %"PRIx64, + __func__, section->mr->name, mrs_gpa, + prev_sec->mr->name, prev_gpa_start); /* A way to cleanly fail here would be better */ return; } --=20 2.24.1 From nobody Mon May 6 23:41:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1579206398; cv=none; d=zohomail.com; s=zohoarc; b=j4B07SRP7ygMUB2MLV3fQNTtk0FovJ9cvLt91U7Yr/HrpR6TQ5gWVYathOUk8Mo7bMFZcTLmSxqny2f0N0G+5TjqF/WqCGmazo9qMgG/eoD6IHhn8oVS/qxYJoTiZJCEfvv3n7gN6oJe38LETd2aEM1Ztw9zupqvB8Gba9CdiJk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579206398; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1Gj+wL32s3lB/zSvJEimeOw3jv9y4l33FtW0ORfO8Fk=; b=N41oZ/VcVNnFwahcPJxRzO2ZzdQf/mz2DXMR0wuszzPMhZmtoJzLX3sIREAQ28f/O+GjWL06pUKUDsnhXdRc1gigF0qNTivaTjkj87Vh/HCh74ixXj+P4y++i2NOaDInLUzdv+rA/qrBoFSToHZIQUxAQxENBfYwHfaaqsdF290= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579206398449653.4006044634626; Thu, 16 Jan 2020 12:26:38 -0800 (PST) Received: from localhost ([::1]:48018 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1isBiu-0001Pu-TE for importer@patchew.org; Thu, 16 Jan 2020 15:26:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55807) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1isBgp-00074L-Ju for qemu-devel@nongnu.org; Thu, 16 Jan 2020 15:24:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1isBgo-0006cl-GZ for qemu-devel@nongnu.org; Thu, 16 Jan 2020 15:24:27 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:34756 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1isBgo-0006cJ-DM for qemu-devel@nongnu.org; Thu, 16 Jan 2020 15:24:26 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-249-BqmyV8SyM1urA18hBYKxpw-1; Thu, 16 Jan 2020 15:24:24 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3D984DB20 for ; Thu, 16 Jan 2020 20:24:23 +0000 (UTC) Received: from dgilbert-t580.localhost (unknown [10.36.118.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 13C345C1D8; Thu, 16 Jan 2020 20:24:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579206266; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1Gj+wL32s3lB/zSvJEimeOw3jv9y4l33FtW0ORfO8Fk=; b=BKYF5Gu+CiU09NjP+LmIva4GF7cHP/MBDT0k9t7XTTOEQJVljyYbYGZO/RUQpnmBLQou5H eaggaICJRnkn0hC4kjCF0FxfuhnPILNZbSsgISVTwO6yD8XwaXntAOKgb3DTHpxMW/JJqc W5iLDrLMYsUC1Kw5TRmVj4ROr4LW0Ag= From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, vkuznets@redhat.com, mst@redhat.com, jasowang@redhat.com, pbonzini@redhat.com Subject: [PATCH v3 2/2] vhost: Only align sections for vhost-user Date: Thu, 16 Jan 2020 20:24:14 +0000 Message-Id: <20200116202414.157959-3-dgilbert@redhat.com> In-Reply-To: <20200116202414.157959-1-dgilbert@redhat.com> References: <20200116202414.157959-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: BqmyV8SyM1urA18hBYKxpw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: "Dr. David Alan Gilbert" I added hugepage alignment code in c1ece84e7c9 to deal with vhost-user + postcopy which needs aligned pages when using userfault. However, on x86 the lower 2MB of address space tends to be shotgun'd with small fragments around the 512-640k range - e.g. video RAM, and with HyperV synic pages tend to sit around there - again splitting it up. The alignment code complains with a 'Section rounded to ...' error and gives up. Since vhost-user already filters out devices without an fd (see vhost-user.c vhost_user_mem_section_filter) it shouldn't be affected by those overlaps. Turn the alignment off on vhost-kernel so that it doesn't try and align, and thus won't hit the rounding issues. Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Paolo Bonzini --- hw/virtio/vhost.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 774d87d98e..25fd469179 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -547,26 +547,28 @@ static void vhost_region_add_section(struct vhost_dev= *dev, uintptr_t mrs_host =3D (uintptr_t)memory_region_get_ram_ptr(section->m= r) + section->offset_within_region; RAMBlock *mrs_rb =3D section->mr->ram_block; - size_t mrs_page =3D qemu_ram_pagesize(mrs_rb); =20 trace_vhost_region_add_section(section->mr->name, mrs_gpa, mrs_size, mrs_host); =20 - /* Round the section to it's page size */ - /* First align the start down to a page boundary */ - uint64_t alignage =3D mrs_host & (mrs_page - 1); - if (alignage) { - mrs_host -=3D alignage; - mrs_size +=3D alignage; - mrs_gpa -=3D alignage; - } - /* Now align the size up to a page boundary */ - alignage =3D mrs_size & (mrs_page - 1); - if (alignage) { - mrs_size +=3D mrs_page - alignage; - } - trace_vhost_region_add_section_aligned(section->mr->name, mrs_gpa, mrs= _size, - mrs_host); + if (dev->vhost_ops->backend_type =3D=3D VHOST_BACKEND_TYPE_USER) { =20 + /* Round the section to it's page size */ + /* First align the start down to a page boundary */ + size_t mrs_page =3D qemu_ram_pagesize(mrs_rb); + uint64_t alignage =3D mrs_host & (mrs_page - 1); + if (alignage) { + mrs_host -=3D alignage; + mrs_size +=3D alignage; + mrs_gpa -=3D alignage; + } + /* Now align the size up to a page boundary */ + alignage =3D mrs_size & (mrs_page - 1); + if (alignage) { + mrs_size +=3D mrs_page - alignage; + } + trace_vhost_region_add_section_aligned(section->mr->name, mrs_gpa,= mrs_size, + mrs_host); + } =20 if (dev->n_tmp_sections) { /* Since we already have at least one section, lets see if --=20 2.24.1