Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2195848/?format=api
{ "id": 2195848, "url": "http://patchwork.ozlabs.org/api/patches/2195848/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260212062522.99565-14-anisinha@redhat.com/", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api", "name": "QEMU Development", "link_name": "qemu-devel", "list_id": "qemu-devel.nongnu.org", "list_email": "qemu-devel@nongnu.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260212062522.99565-14-anisinha@redhat.com>", "list_archive_url": null, "date": "2026-02-12T06:24:57", "name": "[v4,13/31] accel/kvm: rebind current VCPUs to the new KVM VM file descriptor upon reset", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "383bf4bddf41272fbad8337ca759513485781598", "submitter": { "id": 86030, "url": "http://patchwork.ozlabs.org/api/people/86030/?format=api", "name": "Ani Sinha", "email": "anisinha@redhat.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260212062522.99565-14-anisinha@redhat.com/mbox/", "series": [ { "id": 491935, "url": "http://patchwork.ozlabs.org/api/series/491935/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=491935", "date": "2026-02-12T06:24:45", "name": "Introduce support for confidential guest reset (x86)", "version": 4, "mbox": "http://patchwork.ozlabs.org/series/491935/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2195848/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2195848/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=el2udbjH;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=google header.b=NBTILwzf;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)" ], "Received": [ "from lists.gnu.org (lists.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fBQPG6ZKDz1xvb\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 12 Feb 2026 17:29:06 +1100 (AEDT)", "from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1vqQ9e-0007ni-Eb; Thu, 12 Feb 2026 01:26:22 -0500", "from eggs.gnu.org ([2001:470:142:3::10])\n by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <anisinha@redhat.com>)\n id 1vqQ9d-0007ms-Kt\n for qemu-devel@nongnu.org; Thu, 12 Feb 2026 01:26:21 -0500", "from us-smtp-delivery-124.mimecast.com ([170.10.133.124])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <anisinha@redhat.com>)\n id 1vqQ9b-0005Fx-QP\n for qemu-devel@nongnu.org; Thu, 12 Feb 2026 01:26:21 -0500", "from mail-pj1-f71.google.com (mail-pj1-f71.google.com\n [209.85.216.71]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n us-mta-330-gN9iWca4MP6kkyL5HZW6hA-1; Thu, 12 Feb 2026 01:26:17 -0500", "by mail-pj1-f71.google.com with SMTP id\n 98e67ed59e1d1-354c7febaefso5791843a91.3\n for <qemu-devel@nongnu.org>; Wed, 11 Feb 2026 22:26:17 -0800 (PST)", "from rhel9-box.lan ([122.164.27.113])\n by smtp.googlemail.com with ESMTPSA id\n 98e67ed59e1d1-3567e7d95d8sm4894122a91.2.2026.02.11.22.26.13\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Wed, 11 Feb 2026 22:26:15 -0800 (PST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1770877579;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=npi3eP36456mUDuK+ax2iLB1NMn8InaMo9diT4vHZh4=;\n b=el2udbjHwBtLw+s7RRymsfKtnzJZm7W2n5J6btcXliF0FFTOszj/yVkFamNtDjzr8PHb+S\n 5/Q8uNxX7GkruSEUHe05jsOEwjxwfv9N+7cRObeZih+PTKwLJzyZMFFWYAtuBGKrA4FLcI\n VsMhbMgi1BWSNa6TIQCoim7bPP6GLXg=", "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=redhat.com; s=google; t=1770877576; x=1771482376; darn=nongnu.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=npi3eP36456mUDuK+ax2iLB1NMn8InaMo9diT4vHZh4=;\n b=NBTILwzf+ouWxbtQZtIcoT80Pw54q7cu76pBqOa73zrOCfrmIy7Mp2qKyHROo3LB40\n c0WHdSpmeVlhOWbp+FC8Grr8VFpTWbnvNq+VTbBwNypQwG7wHOivq6ESUbgQ+GATzMBM\n wccihGTfXjo7U0sRWH/C9p+ZIKBDzaYQbit2+JKH3lvwxt4xoiX5dWyx8wXBdDd+Ax5H\n Djeb3cu6l5UqwkQXDMYwoxSVQNHbXV5AzjtZ7U0+a3e12OxG71UA/XQGF17tzf393SPz\n vJjmdD5aeR9flBfhOxZRSP4+XOYY+VlUHjX+OUPuR2ronTQnr+eYyk2tFC/aybTgy1KN\n Pc8g==" ], "X-MC-Unique": "gN9iWca4MP6kkyL5HZW6hA-1", "X-Mimecast-MFC-AGG-ID": "gN9iWca4MP6kkyL5HZW6hA_1770877576", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1770877576; x=1771482376;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n :to:cc:subject:date:message-id:reply-to;\n bh=npi3eP36456mUDuK+ax2iLB1NMn8InaMo9diT4vHZh4=;\n b=c5pkDf98FMmZwluxdiEpem0eHGpOB6CKapk551YIVVKGoQTVB95NV66AgElmXHIq9F\n JOvk0Q3la2K4j5iFdiKT8zycUlTefutdOXlFPeHchBkfzpuPxQK+ca20689TB5LoY/tu\n jMN7vqvkcsCA1EKktGlKjN3HSGaxdbYzLHGYmwaTnNAJaI4e4xxElIDwlqIA0bQ+cDAG\n NSSJxA7wjMvYr4JhjvSBQaIm7vyFuBk653Clkc5K1pXBo2iR4fU8ljTK613wKMt7kHfE\n pxtvhl9njF7NLJfsUU21x8DGox/N0RfolIXE9d4/2VOyFsc4fSojs8CqJ5e0eCSQFhAC\n ok6Q==", "X-Forwarded-Encrypted": "i=1;\n AJvYcCXHQPd+tiDKpfrc2GC7k4x53Ks4FLg0tD6bBt4Z0i36O+Hc8syf8pVGNG5UjXrslEDMgBH+PRN/M6BU@nongnu.org", "X-Gm-Message-State": "AOJu0Yz84FbipzOaMICe2ZT32xZD0Kd6ALja4wuUP2pjhpuiQlWCp+JK\n lcfekhqHAj8x7rm86rZcc5nAf1xAscNhG2p36uSPRAfirHS1TDIdefHAYbXeHyDS0Lh6+o2dpDY\n p54ZR7//LWZ9sTbpsPJo8QxVU+YLOI65ZgO1aX6j+7Q/X9xIfyvr06n95", "X-Gm-Gg": "AZuq6aIjxwWMXQ2MJG1DruWWIjbQecMR/HY3XPNHHFZdaVqr/jfw67iQQnwOLF3ceam\n KmirIgVAeaSJT4o1OeeiBMIp2ui28GTPbCaFTBIFNKvkF7KG2EnG6DEU3Ihme8U1TaoLB9+SV+j\n qU1nJW7G3jcLaKIUkle+75EtHtoN0VqKvka5pXZWhicjDB+AMOsLrggUhvCo5XzYvNfmAS3HRlN\n 7cI1XzR3joioMDzsqX223IqobpDBFWHysbiMecG6NNXRnphGjusVoBOxhzvqyxcgyTu26WP01Np\n frdo10+PcfWw3yd3dmrbIBSRRJiQUcvlJsGX2PUf6+iPIg8Hvv0RmEleDCFyY5EOP7f8kvB1vNm\n RSs1WvFvIX6s/Z5RCe1Kcl4hivduo9vuifGonJO6b7aNOFNHGeTUTNNI=", "X-Received": [ "by 2002:a17:90b:5403:b0:340:c179:3657 with SMTP id\n 98e67ed59e1d1-35693dd1630mr1151669a91.33.1770877576486;\n Wed, 11 Feb 2026 22:26:16 -0800 (PST)", "by 2002:a17:90b:5403:b0:340:c179:3657 with SMTP id\n 98e67ed59e1d1-35693dd1630mr1151648a91.33.1770877576087;\n Wed, 11 Feb 2026 22:26:16 -0800 (PST)" ], "From": "Ani Sinha <anisinha@redhat.com>", "To": "Paolo Bonzini <pbonzini@redhat.com>", "Cc": "kraxel@redhat.com, Ani Sinha <anisinha@redhat.com>, kvm@vger.kernel.org,\n qemu-devel@nongnu.org", "Subject": "[PATCH v4 13/31] accel/kvm: rebind current VCPUs to the new KVM VM\n file descriptor upon reset", "Date": "Thu, 12 Feb 2026 11:54:57 +0530", "Message-ID": "<20260212062522.99565-14-anisinha@redhat.com>", "X-Mailer": "git-send-email 2.42.0", "In-Reply-To": "<20260212062522.99565-1-anisinha@redhat.com>", "References": "<20260212062522.99565-1-anisinha@redhat.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Received-SPF": "pass client-ip=170.10.133.124;\n envelope-from=anisinha@redhat.com;\n helo=us-smtp-delivery-124.mimecast.com", "X-Spam_score_int": "-20", "X-Spam_score": "-2.1", "X-Spam_bar": "--", "X-Spam_report": "(-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001,\n DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001,\n RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001,\n SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no", "X-Spam_action": "no action", "X-BeenThere": "qemu-devel@nongnu.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "qemu development <qemu-devel.nongnu.org>", "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>", "List-Archive": "<https://lists.nongnu.org/archive/html/qemu-devel>", "List-Post": "<mailto:qemu-devel@nongnu.org>", "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>", "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>", "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org", "Sender": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org" }, "content": "Confidential guests needs to generate a new KVM file descriptor upon virtual\nmachine reset. Existing VCPUs needs to be reattached to this new\nKVM VM file descriptor. As a part of this, new VCPU file descriptors against\nthis new KVM VM file descriptor needs to be created and re-initialized.\nResources allocated against the old VCPU fds needs to be released. This change\nmakes this happen.\n\nSigned-off-by: Ani Sinha <anisinha@redhat.com>\n---\n accel/kvm/kvm-all.c | 215 +++++++++++++++++++++++++++++++++--------\n accel/kvm/trace-events | 1 +\n 2 files changed, 174 insertions(+), 42 deletions(-)", "diff": "diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c\nindex a6ff16a037..5e81bf8ad2 100644\n--- a/accel/kvm/kvm-all.c\n+++ b/accel/kvm/kvm-all.c\n@@ -127,6 +127,10 @@ static NotifierList kvm_irqchip_change_notifiers =\n static NotifierWithReturnList register_vmfd_changed_notifiers =\n NOTIFIER_WITH_RETURN_LIST_INITIALIZER(register_vmfd_changed_notifiers);\n \n+static int map_kvm_run(KVMState *s, CPUState *cpu, Error **errp);\n+static int map_kvm_dirty_gfns(KVMState *s, CPUState *cpu, Error **errp);\n+static int vcpu_unmap_regions(KVMState *s, CPUState *cpu);\n+\n struct KVMResampleFd {\n int gsi;\n EventNotifier *resample_event;\n@@ -420,6 +424,90 @@ err:\n return ret;\n }\n \n+static void kvm_create_vcpu_internal(CPUState *cpu, KVMState *s, int kvm_fd)\n+{\n+ cpu->kvm_fd = kvm_fd;\n+ cpu->kvm_state = s;\n+ if (!s->guest_state_protected) {\n+ cpu->vcpu_dirty = true;\n+ }\n+ cpu->dirty_pages = 0;\n+ cpu->throttle_us_per_full = 0;\n+\n+ return;\n+}\n+\n+static int kvm_rebind_vcpus(Error **errp)\n+{\n+ CPUState *cpu;\n+ unsigned long vcpu_id;\n+ KVMState *s = kvm_state;\n+ int kvm_fd, ret = 0;\n+\n+ CPU_FOREACH(cpu) {\n+ vcpu_id = kvm_arch_vcpu_id(cpu);\n+\n+ if (cpu->kvm_fd) {\n+ close(cpu->kvm_fd);\n+ }\n+\n+ ret = kvm_arch_destroy_vcpu(cpu);\n+ if (ret < 0) {\n+ goto err;\n+ }\n+\n+ if (s->coalesced_mmio_ring == (void *)cpu->kvm_run + PAGE_SIZE) {\n+ s->coalesced_mmio_ring = NULL;\n+ }\n+\n+ ret = vcpu_unmap_regions(s, cpu);\n+ if (ret < 0) {\n+ goto err;\n+ }\n+\n+ ret = kvm_arch_pre_create_vcpu(cpu, errp);\n+ if (ret < 0) {\n+ goto err;\n+ }\n+\n+ kvm_fd = kvm_vm_ioctl(s, KVM_CREATE_VCPU, vcpu_id);\n+ if (kvm_fd < 0) {\n+ error_report(\"KVM_CREATE_VCPU IOCTL failed for vCPU %lu (%s)\",\n+ vcpu_id, strerror(kvm_fd));\n+ return kvm_fd;\n+ }\n+\n+ kvm_create_vcpu_internal(cpu, s, kvm_fd);\n+\n+ ret = map_kvm_run(s, cpu, errp);\n+ if (ret < 0) {\n+ goto err;\n+ }\n+\n+ if (s->kvm_dirty_ring_size) {\n+ ret = map_kvm_dirty_gfns(s, cpu, errp);\n+ if (ret < 0) {\n+ goto err;\n+ }\n+ }\n+\n+ ret = kvm_arch_init_vcpu(cpu);\n+ if (ret < 0) {\n+ error_setg_errno(errp, -ret,\n+ \"kvm_init_vcpu: kvm_arch_init_vcpu failed (%lu)\",\n+ vcpu_id);\n+ }\n+\n+ close(cpu->kvm_vcpu_stats_fd);\n+ cpu->kvm_vcpu_stats_fd = kvm_vcpu_ioctl(cpu, KVM_GET_STATS_FD, NULL);\n+ kvm_init_cpu_signals(cpu);\n+ }\n+ trace_kvm_rebind_vcpus();\n+\n+ err:\n+ return ret;\n+}\n+\n static void kvm_park_vcpu(CPUState *cpu)\n {\n struct KVMParkedVcpu *vcpu;\n@@ -483,13 +571,7 @@ static int kvm_create_vcpu(CPUState *cpu)\n }\n }\n \n- cpu->kvm_fd = kvm_fd;\n- cpu->kvm_state = s;\n- if (!s->guest_state_protected) {\n- cpu->vcpu_dirty = true;\n- }\n- cpu->dirty_pages = 0;\n- cpu->throttle_us_per_full = 0;\n+ kvm_create_vcpu_internal(cpu, s, kvm_fd);\n \n trace_kvm_create_vcpu(cpu->cpu_index, vcpu_id, kvm_fd);\n \n@@ -508,19 +590,11 @@ int kvm_create_and_park_vcpu(CPUState *cpu)\n return ret;\n }\n \n-static int do_kvm_destroy_vcpu(CPUState *cpu)\n+static int vcpu_unmap_regions(KVMState *s, CPUState *cpu)\n {\n- KVMState *s = kvm_state;\n int mmap_size;\n int ret = 0;\n \n- trace_kvm_destroy_vcpu(cpu->cpu_index, kvm_arch_vcpu_id(cpu));\n-\n- ret = kvm_arch_destroy_vcpu(cpu);\n- if (ret < 0) {\n- goto err;\n- }\n-\n mmap_size = kvm_ioctl(s, KVM_GET_VCPU_MMAP_SIZE, 0);\n if (mmap_size < 0) {\n ret = mmap_size;\n@@ -548,39 +622,47 @@ static int do_kvm_destroy_vcpu(CPUState *cpu)\n cpu->kvm_dirty_gfns = NULL;\n }\n \n- kvm_park_vcpu(cpu);\n-err:\n+ err:\n return ret;\n }\n \n-void kvm_destroy_vcpu(CPUState *cpu)\n-{\n- if (do_kvm_destroy_vcpu(cpu) < 0) {\n- error_report(\"kvm_destroy_vcpu failed\");\n- exit(EXIT_FAILURE);\n- }\n-}\n-\n-int kvm_init_vcpu(CPUState *cpu, Error **errp)\n+static int do_kvm_destroy_vcpu(CPUState *cpu)\n {\n KVMState *s = kvm_state;\n- int mmap_size;\n- int ret;\n+ int ret = 0;\n \n- trace_kvm_init_vcpu(cpu->cpu_index, kvm_arch_vcpu_id(cpu));\n+ trace_kvm_destroy_vcpu(cpu->cpu_index, kvm_arch_vcpu_id(cpu));\n \n- ret = kvm_arch_pre_create_vcpu(cpu, errp);\n+ ret = kvm_arch_destroy_vcpu(cpu);\n if (ret < 0) {\n goto err;\n }\n \n- ret = kvm_create_vcpu(cpu);\n+ /* If I am the CPU that created coalesced_mmio_ring, then discard it */\n+ if (s->coalesced_mmio_ring == (void *)cpu->kvm_run + PAGE_SIZE) {\n+ s->coalesced_mmio_ring = NULL;\n+ }\n+\n+ ret = vcpu_unmap_regions(s, cpu);\n if (ret < 0) {\n- error_setg_errno(errp, -ret,\n- \"kvm_init_vcpu: kvm_create_vcpu failed (%lu)\",\n- kvm_arch_vcpu_id(cpu));\n goto err;\n }\n+ kvm_park_vcpu(cpu);\n+err:\n+ return ret;\n+}\n+\n+void kvm_destroy_vcpu(CPUState *cpu)\n+{\n+ if (do_kvm_destroy_vcpu(cpu) < 0) {\n+ error_report(\"kvm_destroy_vcpu failed\");\n+ exit(EXIT_FAILURE);\n+ }\n+}\n+\n+static int map_kvm_run(KVMState *s, CPUState *cpu, Error **errp)\n+{\n+ int mmap_size, ret = 0;\n \n mmap_size = kvm_ioctl(s, KVM_GET_VCPU_MMAP_SIZE, 0);\n if (mmap_size < 0) {\n@@ -605,14 +687,53 @@ int kvm_init_vcpu(CPUState *cpu, Error **errp)\n (void *)cpu->kvm_run + s->coalesced_mmio * PAGE_SIZE;\n }\n \n+ err:\n+ return ret;\n+}\n+\n+static int map_kvm_dirty_gfns(KVMState *s, CPUState *cpu, Error **errp)\n+{\n+ int ret = 0;\n+ /* Use MAP_SHARED to share pages with the kernel */\n+ cpu->kvm_dirty_gfns = mmap(NULL, s->kvm_dirty_ring_bytes,\n+ PROT_READ | PROT_WRITE, MAP_SHARED,\n+ cpu->kvm_fd,\n+ PAGE_SIZE * KVM_DIRTY_LOG_PAGE_OFFSET);\n+ if (cpu->kvm_dirty_gfns == MAP_FAILED) {\n+ ret = -errno;\n+ }\n+\n+ return ret;\n+}\n+\n+int kvm_init_vcpu(CPUState *cpu, Error **errp)\n+{\n+ KVMState *s = kvm_state;\n+ int ret;\n+\n+ trace_kvm_init_vcpu(cpu->cpu_index, kvm_arch_vcpu_id(cpu));\n+\n+ ret = kvm_arch_pre_create_vcpu(cpu, errp);\n+ if (ret < 0) {\n+ goto err;\n+ }\n+\n+ ret = kvm_create_vcpu(cpu);\n+ if (ret < 0) {\n+ error_setg_errno(errp, -ret,\n+ \"kvm_init_vcpu: kvm_create_vcpu failed (%lu)\",\n+ kvm_arch_vcpu_id(cpu));\n+ goto err;\n+ }\n+\n+ ret = map_kvm_run(s, cpu, errp);\n+ if (ret < 0) {\n+ goto err;\n+ }\n+\n if (s->kvm_dirty_ring_size) {\n- /* Use MAP_SHARED to share pages with the kernel */\n- cpu->kvm_dirty_gfns = mmap(NULL, s->kvm_dirty_ring_bytes,\n- PROT_READ | PROT_WRITE, MAP_SHARED,\n- cpu->kvm_fd,\n- PAGE_SIZE * KVM_DIRTY_LOG_PAGE_OFFSET);\n- if (cpu->kvm_dirty_gfns == MAP_FAILED) {\n- ret = -errno;\n+ ret = map_kvm_dirty_gfns(s, cpu, errp);\n+ if (ret < 0) {\n goto err;\n }\n }\n@@ -2707,6 +2828,16 @@ static int kvm_reset_vmfd(MachineState *ms)\n }\n assert(!err);\n \n+ /*\n+ * rebind new vcpu fds with the new kvm fds\n+ * These can only be called after kvm_arch_on_vmfd_change()\n+ */\n+ ret = kvm_rebind_vcpus(&err);\n+ if (ret < 0) {\n+ return ret;\n+ }\n+ assert(!err);\n+\n /* these can be only called after ram_block_rebind() */\n memory_listener_register(&kml->listener, &address_space_memory);\n memory_listener_register(&kvm_io_listener, &address_space_io);\ndiff --git a/accel/kvm/trace-events b/accel/kvm/trace-events\nindex e4beda0148..4a8921c632 100644\n--- a/accel/kvm/trace-events\n+++ b/accel/kvm/trace-events\n@@ -15,6 +15,7 @@ kvm_park_vcpu(int cpu_index, unsigned long arch_cpu_id) \"index: %d id: %lu\"\n kvm_unpark_vcpu(unsigned long arch_cpu_id, const char *msg) \"id: %lu %s\"\n kvm_irqchip_commit_routes(void) \"\"\n kvm_reset_vmfd(void) \"\"\n+kvm_rebind_vcpus(void) \"\"\n kvm_irqchip_add_msi_route(char *name, int vector, int virq) \"dev %s vector %d virq %d\"\n kvm_irqchip_update_msi_route(int virq) \"Updating MSI route virq=%d\"\n kvm_irqchip_release_virq(int virq) \"virq %d\"\n", "prefixes": [ "v4", "13/31" ] }