From nobody Sat May 4 00:09:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1508165271765213.93759979700735; Mon, 16 Oct 2017 07:47:51 -0700 (PDT) Received: from localhost ([::1]:33318 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e46gB-0008Uy-Sz for importer@patchew.org; Mon, 16 Oct 2017 10:47:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50942) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e46bs-0004xp-Us for qemu-devel@nongnu.org; Mon, 16 Oct 2017 10:43:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e46bo-0005PH-GQ for qemu-devel@nongnu.org; Mon, 16 Oct 2017 10:43:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54650) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e46bo-0005NY-AE for qemu-devel@nongnu.org; Mon, 16 Oct 2017 10:43:12 -0400 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 mx1.redhat.com (Postfix) with ESMTPS id 5285F5F7BE; Mon, 16 Oct 2017 14:43:11 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-221.ams2.redhat.com [10.36.116.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6B0505E1A1; Mon, 16 Oct 2017 14:43:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5285F5F7BE Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=david@redhat.com From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 16:42:56 +0200 Message-Id: <20171016144302.24284-2-david@redhat.com> In-Reply-To: <20171016144302.24284-1-david@redhat.com> References: <20171016144302.24284-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 16 Oct 2017 14:43:11 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 1/7] memory: call log_start after region_add X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Thomas Huth , David Hildenbrand , Joe Clifford Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" It might be confusing for some listener implementations that implement both, region_add and log_start (e.g. KVM) if we call log_start before an actual region was added using region_add. This makes current KVM code trigger an assertion ("kvm_section_update_flags: error finding slot"). So let's just reverse the order instead of tolerating log_start on yet unknown regions. Reported-by: Thomas Huth Signed-off-by: David Hildenbrand --- memory.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/memory.c b/memory.c index 5e6351a6c1..f39b8592bf 100644 --- a/memory.c +++ b/memory.c @@ -2607,12 +2607,12 @@ static void listener_add_address_space(MemoryListen= er *listener, .offset_within_address_space =3D int128_get64(fr->addr.start), .readonly =3D fr->readonly, }; - if (fr->dirty_log_mask && listener->log_start) { - listener->log_start(listener, §ion, 0, fr->dirty_log_mask); - } if (listener->region_add) { listener->region_add(listener, §ion); } + if (fr->dirty_log_mask && listener->log_start) { + listener->log_start(listener, §ion, 0, fr->dirty_log_mask); + } } if (listener->commit) { listener->commit(listener); --=20 2.13.5 From nobody Sat May 4 00:09:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1508165108720749.5943774734513; Mon, 16 Oct 2017 07:45:08 -0700 (PDT) Received: from localhost ([::1]:33303 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e46dU-0005xE-UX for importer@patchew.org; Mon, 16 Oct 2017 10:44:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50925) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e46bq-0004xB-Vd for qemu-devel@nongnu.org; Mon, 16 Oct 2017 10:43:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e46bq-0005St-6A for qemu-devel@nongnu.org; Mon, 16 Oct 2017 10:43:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58466) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e46bp-0005R9-Vv for qemu-devel@nongnu.org; Mon, 16 Oct 2017 10:43:14 -0400 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 mx1.redhat.com (Postfix) with ESMTPS id F26D04ACA7; Mon, 16 Oct 2017 14:43:12 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-221.ams2.redhat.com [10.36.116.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id A397A5E1C8; Mon, 16 Oct 2017 14:43:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com F26D04ACA7 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=david@redhat.com From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 16:42:57 +0200 Message-Id: <20171016144302.24284-3-david@redhat.com> In-Reply-To: <20171016144302.24284-1-david@redhat.com> References: <20171016144302.24284-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 16 Oct 2017 14:43:13 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 2/7] kvm: fix alignment of ram address X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Thomas Huth , David Hildenbrand , Joe Clifford Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Fix the wrong calculation of the delta, used to align the ram address. This only strikes if alignment has to be done. Reported-by: Joe Clifford Fixes: 5ea69c2e3614 ("kvm: factor out alignment of memory section") Signed-off-by: David Hildenbrand --- accel/kvm/kvm-all.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 90c88b517d..fae1eca983 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -717,8 +717,9 @@ static void kvm_set_phys_mem(KVMMemoryListener *kml, return; } =20 + /* use aligned delta to align the ram address */ ram =3D memory_region_get_ram_ptr(mr) + section->offset_within_region + - (section->offset_within_address_space - start_addr); + (start_addr - section->offset_within_address_space); =20 mem =3D kvm_lookup_matching_slot(kml, start_addr, size); if (!add) { --=20 2.13.5 From nobody Sat May 4 00:09:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1508165273054825.4871580375707; Mon, 16 Oct 2017 07:47:53 -0700 (PDT) Received: from localhost ([::1]:33317 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e46gB-0008UX-S3 for importer@patchew.org; Mon, 16 Oct 2017 10:47:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50940) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e46bs-0004xc-KY for qemu-devel@nongnu.org; Mon, 16 Oct 2017 10:43:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e46br-0005W0-QL for qemu-devel@nongnu.org; Mon, 16 Oct 2017 10:43:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60586) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e46br-0005VO-LS for qemu-devel@nongnu.org; Mon, 16 Oct 2017 10:43:15 -0400 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 mx1.redhat.com (Postfix) with ESMTPS id AD966C04AC62; Mon, 16 Oct 2017 14:43:14 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-221.ams2.redhat.com [10.36.116.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4EAEE5E1A1; Mon, 16 Oct 2017 14:43:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AD966C04AC62 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=david@redhat.com From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 16:42:58 +0200 Message-Id: <20171016144302.24284-4-david@redhat.com> In-Reply-To: <20171016144302.24284-1-david@redhat.com> References: <20171016144302.24284-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 16 Oct 2017 14:43:14 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 3/7] kvm: tolerate non-existing slot for log_start/log_stop/log_sync X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Thomas Huth , David Hildenbrand , Joe Clifford Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If we want to trap every access to a section, we might not have a slot. So let's just tolerate if we don't have one. Signed-off-by: David Hildenbrand --- accel/kvm/kvm-all.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index fae1eca983..f5fa3e24bd 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -394,8 +394,8 @@ static int kvm_section_update_flags(KVMMemoryListener *= kml, =20 mem =3D kvm_lookup_matching_slot(kml, start_addr, size); if (!mem) { - fprintf(stderr, "%s: error finding slot\n", __func__); - abort(); + /* We don't have a slot if we want to trap every access. */ + return 0; } =20 return kvm_slot_update_flags(kml, mem, section->mr); @@ -470,8 +470,8 @@ static int kvm_physical_sync_dirty_bitmap(KVMMemoryList= ener *kml, if (size) { mem =3D kvm_lookup_matching_slot(kml, start_addr, size); if (!mem) { - fprintf(stderr, "%s: error finding slot\n", __func__); - abort(); + /* We don't have a slot if we want to trap every access. */ + return 0; } =20 /* XXX bad kernel interface alert --=20 2.13.5 From nobody Sat May 4 00:09:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1508165125335922.7769338095709; Mon, 16 Oct 2017 07:45:25 -0700 (PDT) Received: from localhost ([::1]:33305 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e46dk-0006L5-GK for importer@patchew.org; Mon, 16 Oct 2017 10:45:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50973) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e46bx-00051a-UI for qemu-devel@nongnu.org; Mon, 16 Oct 2017 10:43:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e46bt-0005a2-Gu for qemu-devel@nongnu.org; Mon, 16 Oct 2017 10:43:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60656) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e46bt-0005Xv-Ae for qemu-devel@nongnu.org; Mon, 16 Oct 2017 10:43:17 -0400 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 mx1.redhat.com (Postfix) with ESMTPS id 54D16C04AC65; Mon, 16 Oct 2017 14:43:16 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-221.ams2.redhat.com [10.36.116.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A01E5E1A1; Mon, 16 Oct 2017 14:43:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 54D16C04AC65 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=david@redhat.com From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 16:42:59 +0200 Message-Id: <20171016144302.24284-5-david@redhat.com> In-Reply-To: <20171016144302.24284-1-david@redhat.com> References: <20171016144302.24284-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 16 Oct 2017 14:43:16 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 4/7] kvm: fix error message when failing to unregister slot X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Thomas Huth , David Hildenbrand , Joe Clifford Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" "overlapping" is a leftover, let's drop it. Signed-off-by: David Hildenbrand --- accel/kvm/kvm-all.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index f5fa3e24bd..559c544501 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -734,7 +734,7 @@ static void kvm_set_phys_mem(KVMMemoryListener *kml, mem->memory_size =3D 0; err =3D kvm_set_user_memory_region(kml, mem); if (err) { - fprintf(stderr, "%s: error unregistering overlapping slot: %s\= n", + fprintf(stderr, "%s: error unregistering slot: %s\n", __func__, strerror(-err)); abort(); } --=20 2.13.5 From nobody Sat May 4 00:09:48 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1508165125236501.6276738714239; Mon, 16 Oct 2017 07:45:25 -0700 (PDT) Received: from localhost ([::1]:33306 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e46dl-0006M4-21 for importer@patchew.org; Mon, 16 Oct 2017 10:45:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51001) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e46c1-00053B-Ac for qemu-devel@nongnu.org; Mon, 16 Oct 2017 10:43:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e46c0-0005li-H8 for qemu-devel@nongnu.org; Mon, 16 Oct 2017 10:43:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:13288) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e46c0-0005jb-Bv for qemu-devel@nongnu.org; Mon, 16 Oct 2017 10:43:24 -0400 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 mx1.redhat.com (Postfix) with ESMTPS id 6390CC0587EB; Mon, 16 Oct 2017 14:43:23 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-221.ams2.redhat.com [10.36.116.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id A07A35E1CF; Mon, 16 Oct 2017 14:43:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6390CC0587EB Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=david@redhat.com From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 16:43:00 +0200 Message-Id: <20171016144302.24284-6-david@redhat.com> In-Reply-To: <20171016144302.24284-1-david@redhat.com> References: <20171016144302.24284-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 16 Oct 2017 14:43:23 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 5/7] kvm: region_add and region_del is not called on updates X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Thomas Huth , David Hildenbrand , Joe Clifford Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Attributes are not updated via region_add()/region_del(). Attribute changes lead to a delete first, followed by a new add. If this would ever not be the case, we would get an error when trying to register the new slot. Signed-off-by: David Hildenbrand --- accel/kvm/kvm-all.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 559c544501..2835bb3801 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -721,8 +721,8 @@ static void kvm_set_phys_mem(KVMMemoryListener *kml, ram =3D memory_region_get_ram_ptr(mr) + section->offset_within_region + (start_addr - section->offset_within_address_space); =20 - mem =3D kvm_lookup_matching_slot(kml, start_addr, size); if (!add) { + mem =3D kvm_lookup_matching_slot(kml, start_addr, size); if (!mem) { return; } @@ -741,12 +741,6 @@ static void kvm_set_phys_mem(KVMMemoryListener *kml, return; } =20 - if (mem) { - /* update the slot */ - kvm_slot_update_flags(kml, mem, mr); - return; - } - /* register the new slot */ mem =3D kvm_alloc_slot(kml); mem->memory_size =3D size; --=20 2.13.5 From nobody Sat May 4 00:09:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 150816528074953.210100460487524; Mon, 16 Oct 2017 07:48:00 -0700 (PDT) Received: from localhost ([::1]:33319 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e46gP-0000FZ-TH for importer@patchew.org; Mon, 16 Oct 2017 10:47:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51019) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e46c3-00054b-1F for qemu-devel@nongnu.org; Mon, 16 Oct 2017 10:43:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e46c2-0005o5-8A for qemu-devel@nongnu.org; Mon, 16 Oct 2017 10:43:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36450) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e46c2-0005mO-1s for qemu-devel@nongnu.org; Mon, 16 Oct 2017 10:43:26 -0400 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 mx1.redhat.com (Postfix) with ESMTPS id 1252D7E431; Mon, 16 Oct 2017 14:43:25 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-221.ams2.redhat.com [10.36.116.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id B4D585E1A1; Mon, 16 Oct 2017 14:43:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1252D7E431 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=david@redhat.com From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 16:43:01 +0200 Message-Id: <20171016144302.24284-7-david@redhat.com> In-Reply-To: <20171016144302.24284-1-david@redhat.com> References: <20171016144302.24284-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 16 Oct 2017 14:43:25 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 6/7] kvm: simplify kvm_align_section() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Thomas Huth , David Hildenbrand , Joe Clifford Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Use ROUND_UP and simplify the code a bit. Signed-off-by: David Hildenbrand --- accel/kvm/kvm-all.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 2835bb3801..f290f487a5 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -197,26 +197,20 @@ static hwaddr kvm_align_section(MemoryRegionSection *= section, hwaddr *start) { hwaddr size =3D int128_get64(section->size); - hwaddr delta; - - *start =3D section->offset_within_address_space; + hwaddr delta, aligned; =20 /* kvm works in page size chunks, but the function may be called with sub-page size and unaligned start address. Pad the start address to next and truncate size to previous page boundary. */ - delta =3D qemu_real_host_page_size - (*start & ~qemu_real_host_page_ma= sk); - delta &=3D ~qemu_real_host_page_mask; - *start +=3D delta; + aligned =3D ROUND_UP(section->offset_within_address_space, + qemu_real_host_page_size); + delta =3D aligned - section->offset_within_address_space; + *start =3D aligned; if (delta > size) { return 0; } - size -=3D delta; - size &=3D qemu_real_host_page_mask; - if (*start & ~qemu_real_host_page_mask) { - return 0; - } =20 - return size; + return (size - delta) & qemu_real_host_page_mask; } =20 int kvm_physical_memory_addr_from_host(KVMState *s, void *ram, --=20 2.13.5 From nobody Sat May 4 00:09:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1508165280744404.90673901417404; Mon, 16 Oct 2017 07:48:00 -0700 (PDT) Received: from localhost ([::1]:33320 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e46gQ-0000Gr-Jq for importer@patchew.org; Mon, 16 Oct 2017 10:47:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51038) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e46c8-00059G-2N for qemu-devel@nongnu.org; Mon, 16 Oct 2017 10:43:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e46c6-0005uE-Rv for qemu-devel@nongnu.org; Mon, 16 Oct 2017 10:43:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55528) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e46c6-0005tr-LD for qemu-devel@nongnu.org; Mon, 16 Oct 2017 10:43:30 -0400 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 mx1.redhat.com (Postfix) with ESMTPS id A26712579B; Mon, 16 Oct 2017 14:43:29 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-221.ams2.redhat.com [10.36.116.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 631625E1A1; Mon, 16 Oct 2017 14:43:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A26712579B Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=david@redhat.com From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 16:43:02 +0200 Message-Id: <20171016144302.24284-8-david@redhat.com> In-Reply-To: <20171016144302.24284-1-david@redhat.com> References: <20171016144302.24284-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 16 Oct 2017 14:43:29 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 7/7] memory: reuse section_from_flat_range() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Thomas Huth , David Hildenbrand , Joe Clifford Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We can use section_from_flat_range() instead of manually initializing. Signed-off-by: David Hildenbrand --- memory.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/memory.c b/memory.c index f39b8592bf..7c8e5878d6 100644 --- a/memory.c +++ b/memory.c @@ -2599,14 +2599,8 @@ static void listener_add_address_space(MemoryListene= r *listener, =20 view =3D address_space_get_flatview(as); FOR_EACH_FLAT_RANGE(fr, view) { - MemoryRegionSection section =3D { - .mr =3D fr->mr, - .fv =3D view, - .offset_within_region =3D fr->offset_in_region, - .size =3D fr->addr.size, - .offset_within_address_space =3D int128_get64(fr->addr.start), - .readonly =3D fr->readonly, - }; + MemoryRegionSection section =3D section_from_flat_range(fr, view); + if (listener->region_add) { listener->region_add(listener, §ion); } --=20 2.13.5