From nobody Sun Apr 12 07:20:05 2026 Delivered-To: importer@patchew.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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1771991643; cv=none; d=zohomail.com; s=zohoarc; b=cJmXBdnhIIx3dYzybVj9mQHmCH1BaQ5ls9Q8kPcc5rLmeqfSOm0fs9oGR2V2JsaGFjmhVaGs9AJMMnQUOgTLtLV1hBoHpX/8aZdVHFjmbycAMDtucvqHEPFdrFazycGyLvFzcUC87lc82JTYxAme5BWfxmx8d8PV/AXDlIPwEmw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771991643; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=M5fiyO5toFV4jV0KLoqJkMTJePRwiukufXlV5ZgaA7k=; b=DOWF3lEPMteNXpYla6oErISwhxSiMdGzuLGGGzWYjWdG3xvRucsg2dlrtN7rseKvenwNL1rmrMoXxK1YqdXw8PGvI4XCEFdJcz6L/smJ8AxwOlqlGVyO49UTiKvlYqJua0dvKdFfaoityUKu3xEH9wzLvs4jssjYG6b78pYihus= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771991643209116.00510396871312; Tue, 24 Feb 2026 19:54:03 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vv5wI-0003N9-B1; Tue, 24 Feb 2026 22:51:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vv5wE-0003C3-Ju for qemu-devel@nongnu.org; Tue, 24 Feb 2026 22:51:50 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vv5wC-0008DR-St for qemu-devel@nongnu.org; Tue, 24 Feb 2026 22:51:50 -0500 Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-319-EA_gmIPfMWKRSf4lCysq_A-1; Tue, 24 Feb 2026 22:51:44 -0500 Received: by mail-pj1-f70.google.com with SMTP id 98e67ed59e1d1-358e79b4ca6so1140829a91.1 for ; Tue, 24 Feb 2026 19:51:44 -0800 (PST) Received: from rhel9-box.lan ([122.176.129.56]) by smtp.googlemail.com with ESMTPSA id 98e67ed59e1d1-359018838b2sm1186006a91.5.2026.02.24.19.51.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Feb 2026 19:51:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771991508; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=M5fiyO5toFV4jV0KLoqJkMTJePRwiukufXlV5ZgaA7k=; b=PCKNnNpuinNn0tyFtF56jhmWMgsNgFkn52S0JNcMlDYw/jZuAM7s3W+RNC75roJ2BpVoHs Dmvp6ov5UTc092OWJ1Ax+fGOTq6NuRibD85Wj/n5QCveicLhNYAkwSUMR1V4XgfADJdesj f+/L31eknYZ7ZldpPGc5Lra0w0aj2Tc= X-MC-Unique: EA_gmIPfMWKRSf4lCysq_A-1 X-Mimecast-MFC-AGG-ID: EA_gmIPfMWKRSf4lCysq_A_1771991504 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1771991503; x=1772596303; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=M5fiyO5toFV4jV0KLoqJkMTJePRwiukufXlV5ZgaA7k=; b=dDwrxOCf4UYVO1Mx4qjx+OYKFC0OSjhnlsVM4+uj9HAWwmXbpogaSvKCt9yNnKNkTi Zu9EqU97/JL7HRVU/+BPC07Dn+VRhm1gjLmemy2RcpoE/JnxcdQ62S+H09q9aV33LoL6 iMjbV49+7ctt9qPOoqZoGOV0mwcQOCDwVrqFyI13l9S3a5PZsa//ePZmmROfFyxLOsBu SlJhX3jtsiw9gM5axm3VVwg2YihQDeArXL1YafsJLwMr/9bEtMATuawoS3auSOgf8mF1 n1ndlmKERSjjyS+rP7iIp8jhBSW/+4LrDipJwrprvoLzpcet0j/v48VMlzwu33Wea/kd 0YQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771991503; x=1772596303; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=M5fiyO5toFV4jV0KLoqJkMTJePRwiukufXlV5ZgaA7k=; b=AhqSpCuPQ/HNI1BI3OdGggUHWNPRafn8ZKXbeXOllV/ySUe/Pvofzy9Kc43dZmFqG2 rNHRfbVUp+uWx1JXSKLYMWZoCTjh4smBTtCcnG0mSLT6Fu//Zj2GQJfjw9j7+WMNTS1r 0T+Xkuy1agcOIiYWJaHIAVbs3ey+5wdFhGKg0UdIFspnwuNRdms7nZwO0pbaYTvU8F4b p/YYazNSfGjBKnBK1gbfVSLsFDQH59C736hitofuF24Cu3aKjGf/2VqShFYgXZXzwjRH q32zBOigqLqvHZmE6XkUIz+GlN3taRAFKlEZbdxcd8Lpj+WSZp96tdrDrm+KT/kRN9L8 TrWQ== X-Forwarded-Encrypted: i=1; AJvYcCUvzrtCIt7yTZstBJN7CNv8JFpNVEuzWaWtlRWvZHH/jK4gg/b4HHBprdx+UkyP9n/soo+RVGLkzH4/@nongnu.org X-Gm-Message-State: AOJu0YxZ+yLvHUa+4Ba2C75of199xR2bzaG2tfow7F4fmFlqlxPbm+FY xuixTNInvnDvaQc8XdXJKfXRbICaLFW11/3iwrS6JvD4gNLC/84UFkc6dVOPfJ8Y8uUczI8b3AC T+lTMyowv+4VeU/40Wt2nbXqmfaT5E/Nx2BCPJuqX1kFeCL8oIS+3FaUA X-Gm-Gg: ATEYQzxUwEATQ4cM2HAlyk9c3qDHIj7AZfI5T6ukax3M1xztx5zNGYfaeHkW3GpcHrJ u5TbKvmy9s/L8A6/1cVhbnbxjSW8R5FLWLOeBE1+T8kPNFpBW1OTab0na26sHu5qO96WEnkfna3 Zm04gzCUfYjXvvusCu34WT5KwM2g4c1DCb92hmnAsY96gbquYtC1Wp1cjGHj3PsZar3wxbZ3KaY 9/Q589RovpVF2lWFvwqHo1DqgJggauJfWZ4Pq/VQ0ADIwMn13iZ84/5guNyCAFs+U8kFKDkZ7px qt8E1jRUuSRohLYmTz2sBDwyuxHdG+zB8HXoax56WDKhOpD1O1r1vG0R6IScNYoOIXCu444P7yX lmOJSCg4FKp2da2hMBuPZ1774DD+GbBobnd2iYcDtbckCZCM+gu756Yw= X-Received: by 2002:a17:90b:5185:b0:340:b912:536 with SMTP id 98e67ed59e1d1-3590f1f3c09mr822866a91.31.1771991503579; Tue, 24 Feb 2026 19:51:43 -0800 (PST) X-Received: by 2002:a17:90b:5185:b0:340:b912:536 with SMTP id 98e67ed59e1d1-3590f1f3c09mr822856a91.31.1771991503196; Tue, 24 Feb 2026 19:51:43 -0800 (PST) From: Ani Sinha To: David Woodhouse , Paul Durrant , Paolo Bonzini , Marcelo Tosatti Cc: Ani Sinha , kraxel@redhat.com, ani@anisinha.ca, kvm@vger.kernel.org, qemu-devel@nongnu.org Subject: [PATCH v6 28/35] kvm/xen-emu: re-initialize capabilities during confidential guest reset Date: Wed, 25 Feb 2026 09:19:33 +0530 Message-ID: <20260225035000.385950-29-anisinha@redhat.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20260225035000.385950-1-anisinha@redhat.com> References: <20260225035000.385950-1-anisinha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=170.10.129.124; envelope-from=anisinha@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.358, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.659, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771991644964158500 Content-Type: text/plain; charset="utf-8" On confidential guests KVM virtual machine file descriptor changes as a part of the guest reset process. Xen capabilities needs to be re-initialize= d in KVM against the new file descriptor. Signed-off-by: Ani Sinha --- target/i386/kvm/xen-emu.c | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/target/i386/kvm/xen-emu.c b/target/i386/kvm/xen-emu.c index 52de019834..29364a9279 100644 --- a/target/i386/kvm/xen-emu.c +++ b/target/i386/kvm/xen-emu.c @@ -44,9 +44,12 @@ =20 #include "xen-compat.h" =20 +NotifierWithReturn xen_vmfd_change_notifier; +static uint32_t xen_msr; static void xen_vcpu_singleshot_timer_event(void *opaque); static void xen_vcpu_periodic_timer_event(void *opaque); static int vcpuop_stop_singleshot_timer(CPUState *cs); +static int do_initialize_xen_caps(KVMState *s, uint32_t hypercall_msr); =20 #ifdef TARGET_X86_64 #define hypercall_compat32(longmode) (!(longmode)) @@ -54,6 +57,23 @@ static int vcpuop_stop_singleshot_timer(CPUState *cs); #define hypercall_compat32(longmode) (false) #endif =20 +static int xen_handle_vmfd_change(NotifierWithReturn *n, + void *data, Error** errp) +{ + int ret; + + /* we are not interested in pre vmfd change notification */ + if (((VmfdChangeNotifier *)data)->pre) { + return 0; + } + + ret =3D do_initialize_xen_caps(kvm_state, xen_msr); + if (ret < 0) { + return ret; + } + return 0; +} + static bool kvm_gva_to_gpa(CPUState *cs, uint64_t gva, uint64_t *gpa, size_t *len, bool is_write) { @@ -111,7 +131,7 @@ static inline int kvm_copy_to_gva(CPUState *cs, uint64_= t gva, void *buf, return kvm_gva_rw(cs, gva, buf, sz, true); } =20 -int kvm_xen_init(KVMState *s, uint32_t hypercall_msr) +static int do_initialize_xen_caps(KVMState *s, uint32_t hypercall_msr) { const int required_caps =3D KVM_XEN_HVM_CONFIG_HYPERCALL_MSR | KVM_XEN_HVM_CONFIG_INTERCEPT_HCALL | KVM_XEN_HVM_CONFIG_SHARED_INF= O; @@ -143,6 +163,19 @@ int kvm_xen_init(KVMState *s, uint32_t hypercall_msr) strerror(-ret)); return ret; } + return xen_caps; +} + +int kvm_xen_init(KVMState *s, uint32_t hypercall_msr) +{ + int xen_caps; + + xen_caps =3D do_initialize_xen_caps(s, hypercall_msr); + if (xen_caps < 0) { + return xen_caps; + } + + xen_msr =3D hypercall_msr; =20 /* If called a second time, don't repeat the rest of the setup. */ if (s->xen_caps) { @@ -185,6 +218,9 @@ int kvm_xen_init(KVMState *s, uint32_t hypercall_msr) xen_primary_console_reset(); xen_xenstore_reset(); =20 + xen_vmfd_change_notifier.notify =3D xen_handle_vmfd_change; + kvm_vmfd_add_change_notifier(&xen_vmfd_change_notifier); + return 0; } =20 --=20 2.42.0