{"id":2197722,"url":"http://patchwork.ozlabs.org/api/1.0/patches/2197722/?format=json","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/1.0/projects/14/?format=json","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":""},"msgid":"<20260218114233.266178-20-anisinha@redhat.com>","date":"2026-02-18T11:42:12","name":"[v5,19/34] i386/sev: add notifiers only once","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"664c561377be43c936f5b869537d11805195678a","submitter":{"id":86030,"url":"http://patchwork.ozlabs.org/api/1.0/people/86030/?format=json","name":"Ani Sinha","email":"anisinha@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260218114233.266178-20-anisinha@redhat.com/mbox/","series":[{"id":492541,"url":"http://patchwork.ozlabs.org/api/1.0/series/492541/?format=json","date":"2026-02-18T11:41:56","name":"Introduce support for confidential guest reset (x86)","version":5,"mbox":"http://patchwork.ozlabs.org/series/492541/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2197722/checks/","tags":{},"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=HDtt0HID;\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=EibTa4uF;\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 4fGF7W0Nl5z1xvq\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 18 Feb 2026 22:45:27 +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 1vsfyd-0004Cs-Rc; Wed, 18 Feb 2026 06:44:20 -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 1vsfy8-0003Uw-WF\n for qemu-devel@nongnu.org; Wed, 18 Feb 2026 06:43:52 -0500","from us-smtp-delivery-124.mimecast.com ([170.10.129.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 1vsfy7-0007uZ-Io\n for qemu-devel@nongnu.org; Wed, 18 Feb 2026 06:43:48 -0500","from mail-pl1-f197.google.com (mail-pl1-f197.google.com\n [209.85.214.197]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n us-mta-125-W5PzG3PiMp-FLCJqcujqmQ-1; Wed, 18 Feb 2026 06:43:45 -0500","by mail-pl1-f197.google.com with SMTP id\n d9443c01a7336-2a944e6336eso304902475ad.0\n for <qemu-devel@nongnu.org>; Wed, 18 Feb 2026 03:43:45 -0800 (PST)","from rhel9-box.lan ([117.99.83.54])\n by smtp.googlemail.com with ESMTPSA id\n d9443c01a7336-2ad1aaeab38sm127803425ad.82.2026.02.18.03.43.41\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Wed, 18 Feb 2026 03:43:44 -0800 (PST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1771415026;\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=N2v6djobNSdTdF+YCpvzDQ17kkQi5jILZoPxzgDYLR8=;\n b=HDtt0HIDHXefXcLNZg8r2hqk9kYp+pNpBnpCJqlvd7NH59gDdIloRFRWt9fSpnLVc//VyO\n Fi3GOTkQMP3oTk2fKYnrFvBQPq+K2lb6Z2n/Qwk8kYPIS7JI8XcWRAmoud5N9OGlkMDAQW\n m4KH/2TAQrgobIdJD1ehB+LVoLdyZrw=","v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=redhat.com; s=google; t=1771415024; x=1772019824; 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=N2v6djobNSdTdF+YCpvzDQ17kkQi5jILZoPxzgDYLR8=;\n b=EibTa4uF4YeWfoxl3kg8hQqvMkR6gDvJygsBBmRRC41XVuGIAm08crIJFj7pOOUz+Q\n gyPC6FPc+PDSrf1Ab7AG2yqK4D+iiOaRR0aViJoXv8JXVi6UkCtoT4wPCKp7KuqeqhDt\n ZZKDruaJufWh2B40oNx7nJz4dAEiI7rVSKjuhJ3bLqLNY0Od+CECnTQoq76aEpSM4l03\n AIDHzgTscgUiuMQ5RjiBw26YvSchT2rB9fcxv/+3P4AhFM7uFeoUTAYCCSVt7MNqQ66r\n oCtWAbVwgAQnZ3ul52xy4teU5ghXKjqIi7R7cpVRAmPTHIbk0Y3aN99+NaS2H5pduBwF\n Dozw=="],"X-MC-Unique":"W5PzG3PiMp-FLCJqcujqmQ-1","X-Mimecast-MFC-AGG-ID":"W5PzG3PiMp-FLCJqcujqmQ_1771415025","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1771415024; x=1772019824;\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=N2v6djobNSdTdF+YCpvzDQ17kkQi5jILZoPxzgDYLR8=;\n b=uZjMxZv9BjJ3XZhrKucj+T/DSVbkqsR2LDxKHOcbmxwiqkvLW7VF/ZANYYCPx2ws/M\n tyS/qhjKbJeK27Cpidbebm91hbzVIBlEWNf1awpMSKAN8mGsb7U4YL+6r3fy/ctjFslC\n KihbO0VjXFx7V5w6BE4xmy1RJ6cJPju6F4w+AYrUO04UYE4Zb2PMRfY/LD84usYmHKkv\n GuEa9huCUXiiQmmRS9qyUUtfito1y5nlmlYDACqtfGwJsaCjHofUV9sQPUO7ewOMxE0S\n K5mMMi4Z+kLTAeax7mkjjV/Oo2B3qHjs8zHSWD/RFFNM3tS45EyeU0wRU+XmGWI0c/IY\n Q3mA==","X-Forwarded-Encrypted":"i=1;\n AJvYcCUmLQPm53rcumAlbCNXq0gAACEQ4PsOGoleVL333SH4kHjQWTdh6tZRTDyeUYtgkTIUJJP+DNBtJhCB@nongnu.org","X-Gm-Message-State":"AOJu0YyGom+oFDED72QiJWbrLwQMMkYkseqG6IuZcVneuuPZMTlivauU\n Pl6euP7PLFpquIV9ragTs4uNHQ+vFGhueTwEV+h7/73ABjhzPbkSp47zivzeKmV58cG+3SkLAfv\n l/eCV+X0ILs68ekSyz8BT4WgbSGOnGbc4/HQkWyX6rJV7RS0Rv3pJ1jc7","X-Gm-Gg":"AZuq6aJBOkozFcJZ3J+6lX+TIDUl4lcltil449qQh8DFgWuCKshNZAziNMS5xcqprau\n mdsyM7k4s5CQfI3DuYpVGqdmcQqE5t08nzTyVwJASnuKpI93OdIDMjup5Skl8Wv3a+At/ceMfpa\n Rf8my12hc6RRPbQL1NB9s2RqaWfNfNMP4+6gfi+xiPciXnKiHJCHUMlWDve7EnPIW1sy+qtvyDw\n 1DRl/8RGSQbiCbq0nkE4bcWRHsFl8tmARo+bUHP+TwMxJhIBwAAzxVKTq9Yee4AvxQhmu3mJLIS\n UkVPUI6gDfxJeIkrjdwonV+F7R4xO7u2PqNnHwOMkLLYTsDXnieMtgMVe3uJR9ZNqutpXfbXz39\n FCjXKPhVxjDyw0fXR8Fmd5HJLkm4Heg/Xi30uXMGXgnIGcoe02lpx","X-Received":["by 2002:a17:902:ccca:b0:295:9b73:b15c with SMTP id\n d9443c01a7336-2ad50f4c562mr14531485ad.42.1771415024598;\n Wed, 18 Feb 2026 03:43:44 -0800 (PST)","by 2002:a17:902:ccca:b0:295:9b73:b15c with SMTP id\n d9443c01a7336-2ad50f4c562mr14531355ad.42.1771415024293;\n Wed, 18 Feb 2026 03:43:44 -0800 (PST)"],"From":"Ani Sinha <anisinha@redhat.com>","To":"Paolo Bonzini <pbonzini@redhat.com>, Zhao Liu <zhao1.liu@intel.com>,\n Marcelo Tosatti <mtosatti@redhat.com>","Cc":"Ani Sinha <anisinha@redhat.com>, kraxel@redhat.com, kvm@vger.kernel.org,\n qemu-devel@nongnu.org","Subject":"[PATCH v5 19/34] i386/sev: add notifiers only once","Date":"Wed, 18 Feb 2026 17:12:12 +0530","Message-ID":"<20260218114233.266178-20-anisinha@redhat.com>","X-Mailer":"git-send-email 2.42.0","In-Reply-To":"<20260218114233.266178-1-anisinha@redhat.com>","References":"<20260218114233.266178-1-anisinha@redhat.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Received-SPF":"pass client-ip=170.10.129.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.043,\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_H4=0.001, RCVD_IN_MSPIKE_WL=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":"The various notifiers that are used needs to be installed only once not on\nevery initialization. This includes the vm state change notifier and others.\nThis change uses 'cgs->ready' flag to install the notifiers only one time,\nthe first time.\n\nSigned-off-by: Ani Sinha <anisinha@redhat.com>\n---\n target/i386/sev.c | 36 +++++++++++++++++++-----------------\n 1 file changed, 19 insertions(+), 17 deletions(-)","diff":"diff --git a/target/i386/sev.c b/target/i386/sev.c\nindex 260d8ef88b..647f4bf63d 100644\n--- a/target/i386/sev.c\n+++ b/target/i386/sev.c\n@@ -1920,8 +1920,9 @@ static int sev_common_kvm_init(ConfidentialGuestSupport *cgs, Error **errp)\n         return -1;\n     }\n \n-    qemu_add_vm_change_state_handler(sev_vm_state_change, sev_common);\n-\n+    if (!cgs->ready) {\n+        qemu_add_vm_change_state_handler(sev_vm_state_change, sev_common);\n+    }\n     cgs->ready = true;\n \n     return 0;\n@@ -1943,22 +1944,23 @@ static int sev_kvm_init(ConfidentialGuestSupport *cgs, Error **errp)\n         return -1;\n     }\n \n-    /*\n-     * SEV uses these notifiers to register/pin pages prior to guest use,\n-     * but SNP relies on guest_memfd for private pages, which has its\n-     * own internal mechanisms for registering/pinning private memory.\n-     */\n-    ram_block_notifier_add(&sev_ram_notifier);\n-\n-    /*\n-     * The machine done notify event is used for SEV guests to get the\n-     * measurement of the encrypted images. When SEV-SNP is enabled, the\n-     * measurement is part of the guest attestation process where it can\n-     * be collected without any reliance on the VMM. So skip registering\n-     * the notifier for SNP in favor of using guest attestation instead.\n-     */\n-    qemu_add_machine_init_done_notifier(&sev_machine_done_notify);\n+    if (!cgs->ready) {\n+        /*\n+         * SEV uses these notifiers to register/pin pages prior to guest use,\n+         * but SNP relies on guest_memfd for private pages, which has its\n+         * own internal mechanisms for registering/pinning private memory.\n+         */\n+        ram_block_notifier_add(&sev_ram_notifier);\n \n+        /*\n+         * The machine done notify event is used for SEV guests to get the\n+         * measurement of the encrypted images. When SEV-SNP is enabled, the\n+         * measurement is part of the guest attestation process where it can\n+         * be collected without any reliance on the VMM. So skip registering\n+         * the notifier for SNP in favor of using guest attestation instead.\n+         */\n+        qemu_add_machine_init_done_notifier(&sev_machine_done_notify);\n+    }\n     return 0;\n }\n \n","prefixes":["v5","19/34"]}