From nobody Sat Nov 15 12:14:50 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1751510937; cv=none; d=zohomail.com; s=zohoarc; b=MEVWRfZkWyDhcAzSB9VzTzZD+fQ/OMhzmu5dbEQoVwfPGW0Dn5t3xIaP7HhdeEZQ8crWLCT8pGUtUl7jezLCyMRDIhKnSvckJY2H/8jIdLcLadwjN7SwnWnS7mX4+GsZfIpoRdx4FYWfMriExgPGjbTX5ppPZD6TaBkPHcV8u4o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751510937; 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=NH/448gyRvjA38EyasK7VLuGkQyqHZ2NGxL1QFN5xoM=; b=fxON/lixZe1b6IG6gdAi1dATTyvVi2POAXKEv1nVe5fx4dFDv+PnaxCHriQ1l7QVHOW4bLr1N8NiS2ymdv/Tat2LYJ8vJ0lA2XTwj8zfJAPx3Ts7OWa6rVkk1yUXo3W7RLcrL1gqhLQIpJYii40VADVZ5rqGRIF/5+d00gJr1Vs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 175151093741677.28291495379312; Wed, 2 Jul 2025 19:48:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uX9zV-0002T1-NA; Wed, 02 Jul 2025 22:48:01 -0400 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 1uX9zS-0002P0-RM for qemu-devel@nongnu.org; Wed, 02 Jul 2025 22:47:58 -0400 Received: from mgamail.intel.com ([198.175.65.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uX9zR-0007uj-3S for qemu-devel@nongnu.org; Wed, 02 Jul 2025 22:47:58 -0400 Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jul 2025 19:47:54 -0700 Received: from lxy-clx-4s.sh.intel.com ([10.239.48.52]) by fmviesa007.fm.intel.com with ESMTP; 02 Jul 2025 19:47:53 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1751510876; x=1783046876; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aggi/VVoEsa3JDXqyqBaYdGUcSP9MkQM0hUW7deY3Vo=; b=Q+CSYR9wXb1yw7V2SdjMKaejXj0GGK444v1Do9DI4+MPSL8TDDXAswXW 9zb1EBtJTgtoJ9SqHrdFVeyzkxA/05Vrbp5PmmhQ6ffhhFQy8bO8vU3J7 Z6JY+MtQtwgUyNriLCthNZ6WNybrW2W/+UV0c4KoOuIuMyZs+wt2QioeO AsPBEebtv79/CKAurJQan73qmIgsu7ZzpOtba3lVEnf41asQmviE/pBmt Wz86ohM6Mlw/ANe06iIFX+2yR5eYdUnsYojrBmUg20QIwyQbSRv43k57I zVdxzwcHbxy7I4dEoANc9spdmm43fjZ9pOSC1BiEH4SNAXgLuzH4K6lq3 g==; X-CSE-ConnectionGUID: PipyiUgpQDCsjHkFSpNEqw== X-CSE-MsgGUID: n3An80AWS3ydR4gZtxOHjw== X-IronPort-AV: E=McAfee;i="6800,10657,11482"; a="57499450" X-IronPort-AV: E=Sophos;i="6.16,283,1744095600"; d="scan'208";a="57499450" X-CSE-ConnectionGUID: TVVSVLO8T1C99mG6z91B4A== X-CSE-MsgGUID: wFNQ01H+RPa0RYwA0bEPUA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,283,1744095600"; d="scan'208";a="153880358" From: Xiaoyao Li To: Paolo Bonzini Cc: Marcelo Tosatti , qemu-devel@nongnu.org, xiaoyao.li@intel.com Subject: [PATCH 1/4] i386/tdx: Remove enumeration of GetQuote in tdx_handle_get_tdvmcall_info() Date: Thu, 3 Jul 2025 10:40:17 +0800 Message-ID: <20250703024021.3559286-2-xiaoyao.li@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250703024021.3559286-1-xiaoyao.li@intel.com> References: <20250703024021.3559286-1-xiaoyao.li@intel.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=198.175.65.15; envelope-from=xiaoyao.li@intel.com; helo=mgamail.intel.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 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, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.999, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.237, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=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: 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 @intel.com) X-ZM-MESSAGEID: 1751510938633116600 Content-Type: text/plain; charset="utf-8" GHCI is finalized with the being one of the base VMCALLs, and not enuemrated via . Adjust tdx_handle_get_tdvmcall_info() to match with GHCI. Opportunistically fix the wrong indentation and explicitly set the ret to TDG_VP_VMCALL_SUCCESS (in case KVM leaves unexpected value). Signed-off-by: Xiaoyao Li --- target/i386/kvm/tdx.c | 6 ++++-- target/i386/kvm/tdx.h | 2 -- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c index e809e4b2dfa2..8c661c3ecfdb 100644 --- a/target/i386/kvm/tdx.c +++ b/target/i386/kvm/tdx.c @@ -1259,13 +1259,15 @@ out_free: void tdx_handle_get_tdvmcall_info(X86CPU *cpu, struct kvm_run *run) { if (run->tdx.get_tdvmcall_info.leaf !=3D 1) { - return; + return; } =20 - run->tdx.get_tdvmcall_info.r11 =3D TDG_VP_VMCALL_SUBFUNC_GET_QUOTE; + run->tdx.get_tdvmcall_info.r11 =3D 0; run->tdx.get_tdvmcall_info.r12 =3D 0; run->tdx.get_tdvmcall_info.r13 =3D 0; run->tdx.get_tdvmcall_info.r14 =3D 0; + + run->tdx.get_tdvmcall_info.ret =3D TDG_VP_VMCALL_SUCCESS; } =20 static void tdx_panicked_on_fatal_error(X86CPU *cpu, uint64_t error_code, diff --git a/target/i386/kvm/tdx.h b/target/i386/kvm/tdx.h index 35a09c19c521..d439078a8761 100644 --- a/target/i386/kvm/tdx.h +++ b/target/i386/kvm/tdx.h @@ -32,8 +32,6 @@ typedef struct TdxGuestClass { #define TDG_VP_VMCALL_GPA_INUSE 0x8000000000000001ULL #define TDG_VP_VMCALL_ALIGN_ERROR 0x8000000000000002ULL =20 -#define TDG_VP_VMCALL_SUBFUNC_GET_QUOTE 0x0000000000000001ULL - enum TdxRamType { TDX_RAM_UNACCEPTED, TDX_RAM_ADDED, --=20 2.43.0 From nobody Sat Nov 15 12:14:50 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1751510918; cv=none; d=zohomail.com; s=zohoarc; b=k6gpiBCobClN5zV5/V1TvxKhKmSxTx5KuJS+GB1GwocJQW3PQoKeZVHBW1Ta7sFmgJcGxsSgBnPZdrjbzwwpCd79yn9lnOWJVoClhi/FxutT6XXLJKis2nCslmyCUqvbsYHCV36nOEYoGedOP8dLondTSlpFPswEWTSnTs98fIw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751510918; 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=POvpmBfPGDA0FdOyCGV93JIKgNoDb/TOBBY97ny8yBY=; b=CLw7z3CsOOlgQbHJVFHdLARDPiweV6jkGCpZMmjWHIoGGXpqBhDf5X9L6YlX/xsn6u9fIExjBSIH6MMWvK7VKqC9bfX+XVz77vJi92FKlB/tODGOW0urNBfs19ZCdipev6ZNAgnSxl607hJqj5R/NYBGhUTTJ8Da+eNljCrM4RE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17515109182041000.7165188359387; Wed, 2 Jul 2025 19:48:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uX9zb-0002a1-J4; Wed, 02 Jul 2025 22:48:08 -0400 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 1uX9zY-0002Y4-K8 for qemu-devel@nongnu.org; Wed, 02 Jul 2025 22:48:05 -0400 Received: from mgamail.intel.com ([198.175.65.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uX9zR-0007ux-R2 for qemu-devel@nongnu.org; Wed, 02 Jul 2025 22:48:04 -0400 Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jul 2025 19:47:55 -0700 Received: from lxy-clx-4s.sh.intel.com ([10.239.48.52]) by fmviesa007.fm.intel.com with ESMTP; 02 Jul 2025 19:47:55 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1751510877; x=1783046877; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GM3oITmKPvCB1mMVAy/DbcAc4/N7/dTkZo/RHHoELIw=; b=e/vFWTabTxIubWvW7DCVo+emW2ttrfkuX/shq0xcMn3u+NesjojqV0PS xcl2Xe4UlErqKv/C+1XVQ4btJ8TQpg2golunOaYjGYTZDO0xSfQCjhHkb lyz1hGdR9IBn6QUfrASdWsU5KshnjGwyDmubnW7dN2pRsPT52Pn8sonRv JJFOojqdrvQvGRk+a0iMufbsPrHjtKxs57xn49ZMoWNT5PKx580Y4tIMT n1Msz2neGpYugALYAJ2cz1YJmsGMXHYPP3t7PkSZvrwq/sHpPE7k9s4nv f/L/rU/BTnGtp59iwiTRRsMP2qk7UcP3+2zExxLdLSY1YIhl7fTBTGngN g==; X-CSE-ConnectionGUID: FT0RlAuySrqwTev9S3wsBQ== X-CSE-MsgGUID: jopSIopNT/aTRNfBxQ2uIw== X-IronPort-AV: E=McAfee;i="6800,10657,11482"; a="57499453" X-IronPort-AV: E=Sophos;i="6.16,283,1744095600"; d="scan'208";a="57499453" X-CSE-ConnectionGUID: PYpaIqCpTtSlbPj+gY7qzA== X-CSE-MsgGUID: mrJM3aVjRUyU1KyROBiHBA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,283,1744095600"; d="scan'208";a="153880365" From: Xiaoyao Li To: Paolo Bonzini Cc: Marcelo Tosatti , qemu-devel@nongnu.org, xiaoyao.li@intel.com Subject: [PATCH 2/4] update Linux headers to KVM tree master Date: Thu, 3 Jul 2025 10:40:18 +0800 Message-ID: <20250703024021.3559286-3-xiaoyao.li@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250703024021.3559286-1-xiaoyao.li@intel.com> References: <20250703024021.3559286-1-xiaoyao.li@intel.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=198.175.65.15; envelope-from=xiaoyao.li@intel.com; helo=mgamail.intel.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 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, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.999, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.237, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=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: 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 @intel.com) X-ZM-MESSAGEID: 1751510920243116600 Content-Type: text/plain; charset="utf-8" To fetch the update of TDX Signed-off-by: Xiaoyao Li --- linux-headers/asm-x86/kvm.h | 8 +++++++- linux-headers/linux/kvm.h | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/linux-headers/asm-x86/kvm.h b/linux-headers/asm-x86/kvm.h index cd275ae76d25..f0c1a730d9c3 100644 --- a/linux-headers/asm-x86/kvm.h +++ b/linux-headers/asm-x86/kvm.h @@ -963,7 +963,13 @@ struct kvm_tdx_cmd { struct kvm_tdx_capabilities { __u64 supported_attrs; __u64 supported_xfam; - __u64 reserved[254]; + + __u64 kernel_tdvmcallinfo_1_r11; + __u64 user_tdvmcallinfo_1_r11; + __u64 kernel_tdvmcallinfo_1_r12; + __u64 user_tdvmcallinfo_1_r12; + + __u64 reserved[250]; =20 /* Configurable CPUID bits for userspace */ struct kvm_cpuid2 cpuid; diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h index 0690743944bd..32c5885a3c20 100644 --- a/linux-headers/linux/kvm.h +++ b/linux-headers/linux/kvm.h @@ -459,6 +459,10 @@ struct kvm_run { __u64 leaf; __u64 r11, r12, r13, r14; } get_tdvmcall_info; + struct { + __u64 ret; + __u64 vector; + } setup_event_notify; }; } tdx; /* Fix the size of the union. */ --=20 2.43.0 From nobody Sat Nov 15 12:14:50 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1751510953; cv=none; d=zohomail.com; s=zohoarc; b=HCZE2Q30/VSd5z1cCa1WcG9GOSPaD4r1N6D3L5fEllCAMMgBVO9AK18s8qeGmnxN1S8+CB/6WsaW2as7DNNG+5Nyw8zLBinwXw0OMrXZak6hRyVCtsBv40+Fkqd+h9RK63LwQZHQ7D8IxdbX6ZOeprQXgLkD7SwEMDGU25ES0BY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751510953; 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=ltinhlwaNtO+bT1QS0wSsO70d/+lJ44ZWFrJ3PVFgWk=; b=fAWg7rFeZd/tk1tOOAHhzrMwRX0wLqanox/T6PEdIizlnUpg6tDXP1ksVjPIXt/DGOU3fE66FYOVGN1JLdDVDOUkIqVBnXPThQ+ySZo7NlxY+wsTFOg4QuoY53/qWUBGAZpzdZ32e8CfOITGWC3q+3576gfXGltv6dH9ne6QwoM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1751510953451709.6710615689163; Wed, 2 Jul 2025 19:49:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uX9zi-0002c0-8O; Wed, 02 Jul 2025 22:48:14 -0400 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 1uX9zg-0002bf-PA for qemu-devel@nongnu.org; Wed, 02 Jul 2025 22:48:12 -0400 Received: from mgamail.intel.com ([198.175.65.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uX9zW-0007uj-Bm for qemu-devel@nongnu.org; Wed, 02 Jul 2025 22:48:12 -0400 Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jul 2025 19:47:56 -0700 Received: from lxy-clx-4s.sh.intel.com ([10.239.48.52]) by fmviesa007.fm.intel.com with ESMTP; 02 Jul 2025 19:47:56 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1751510881; x=1783046881; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jGc1SEhOx3aErmclLmDyukz5nk+L1TqYMmTJmPp+//I=; b=KxqFXme3y9mNUn37ySE+oJR9UlbOKwtXWGOf4vvWUGXGzBW2gYqi/gpo R4bCpnxDSzxp6/XfMCYaScLD25BcTKsOnid/OeufSfScdkm+Lo5JdnOH5 sswNgxBPyy7ryRXyV916Dh5UT44WJ0X0zmBm2yFgREuqcLO1AKxWyj3uL /c8m/N2VrK4gOrY9QDzLrf2GZfgDnlZYz3r+aR0wV5QT2dD3FR48xmjbg OdyvrpjGpLZp+ZZsR29IJy1VcXn1l58RHlIgUHpeE1gZNZfHiB3o7wOiV 48AphlwmBj/ZJp1L6+/5Rx3iqhPtlFFxxkZm2Rk6g81v+0MJc1FIt4QIB A==; X-CSE-ConnectionGUID: 9L6hRRtsTmGQkqtYsMtYng== X-CSE-MsgGUID: RxIMz+LgRSOse/coqXfmVA== X-IronPort-AV: E=McAfee;i="6800,10657,11482"; a="57499455" X-IronPort-AV: E=Sophos;i="6.16,283,1744095600"; d="scan'208";a="57499455" X-CSE-ConnectionGUID: 2oX2/fo4TPyaeaY7InC+rA== X-CSE-MsgGUID: 6uCgOZjYSi2Vkp4IFjFmlg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,283,1744095600"; d="scan'208";a="153880369" From: Xiaoyao Li To: Paolo Bonzini Cc: Marcelo Tosatti , qemu-devel@nongnu.org, xiaoyao.li@intel.com Subject: [PATCH 3/4] i386/tdx: Set value of based on capabilities of both KVM and QEMU Date: Thu, 3 Jul 2025 10:40:19 +0800 Message-ID: <20250703024021.3559286-4-xiaoyao.li@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250703024021.3559286-1-xiaoyao.li@intel.com> References: <20250703024021.3559286-1-xiaoyao.li@intel.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=198.175.65.15; envelope-from=xiaoyao.li@intel.com; helo=mgamail.intel.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 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, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.999, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.237, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=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: 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 @intel.com) X-ZM-MESSAGEID: 1751510954723116600 Content-Type: text/plain; charset="utf-8" KVM reports the supported TDVMCALL sub leafs in TDX capabilities. one for kernel-supported TDVMCALLs (userspace can set those blindly) and one for user-supported TDVMCALLs (userspace can set those if it knows how to handle them) Signed-off-by: Xiaoyao Li --- target/i386/kvm/tdx.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c index 8c661c3ecfdb..10dfb80d22e2 100644 --- a/target/i386/kvm/tdx.c +++ b/target/i386/kvm/tdx.c @@ -1256,14 +1256,21 @@ out_free: g_free(task); } =20 +#define SUPPORTED_TDVMCALLINFO_1_R11 (0) +#define SUPPORTED_TDVMCALLINFO_1_R12 (0) + void tdx_handle_get_tdvmcall_info(X86CPU *cpu, struct kvm_run *run) { if (run->tdx.get_tdvmcall_info.leaf !=3D 1) { return; } =20 - run->tdx.get_tdvmcall_info.r11 =3D 0; - run->tdx.get_tdvmcall_info.r12 =3D 0; + run->tdx.get_tdvmcall_info.r11 =3D (tdx_caps->user_tdvmcallinfo_1_r11 & + SUPPORTED_TDVMCALLINFO_1_R11) | + tdx_caps->kernel_tdvmcallinfo_1_r11; + run->tdx.get_tdvmcall_info.r12 =3D (tdx_caps->user_tdvmcallinfo_1_r12 & + SUPPORTED_TDVMCALLINFO_1_R12) | + tdx_caps->kernel_tdvmcallinfo_1_r12; run->tdx.get_tdvmcall_info.r13 =3D 0; run->tdx.get_tdvmcall_info.r14 =3D 0; =20 --=20 2.43.0 From nobody Sat Nov 15 12:14:50 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1751510918; cv=none; d=zohomail.com; s=zohoarc; b=EUDNZum6RtCpJYtCK/NT0MZRWav9wDDkt5CZKn9QkVJtbDcW1Xt34vy8+l9e7hSCbQNQwGXrEjEEqrF0k/v+D257d5x3PRD0hzUhs6GDunfDAx5zMKETbtfcLV3UrdjZgUBUkF4gZiSmYtk6m5jeSDUcO+NO1s8HK7FHHfCvq6M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751510918; 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=4GWEIT90cP0I5BlrWyOQjDIeQbO4hUsi2DU5SwfVK40=; b=RU6DpNrbbZ5lazTylx9zCe/z3DiiweOBsg0bttDjBOZvCcCpldjSKu5V6TmIxwiCHDjXDqAmD7pgDI7gJBEBogg/REh7e2a6XH3znZ/nNVD6+NC2mwX/wpDTP9TJ7p0T3dD4vYHegzK1Tt53IC3p0RRqxldhCrT3krjC6+pLUZw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1751510918086830.6274102780853; Wed, 2 Jul 2025 19:48:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uX9zd-0002bF-9A; Wed, 02 Jul 2025 22:48:09 -0400 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 1uX9za-0002ZH-0d for qemu-devel@nongnu.org; Wed, 02 Jul 2025 22:48:06 -0400 Received: from mgamail.intel.com ([198.175.65.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uX9zV-0007sP-9q for qemu-devel@nongnu.org; Wed, 02 Jul 2025 22:48:05 -0400 Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jul 2025 19:47:58 -0700 Received: from lxy-clx-4s.sh.intel.com ([10.239.48.52]) by fmviesa007.fm.intel.com with ESMTP; 02 Jul 2025 19:47:57 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1751510880; x=1783046880; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3JEtPLNDpteWO0MXdkQc36eFxvc/61TwA72slbgFSTI=; b=F0bp9aClU0ZZdz8Od7DicQ2W8RtmwPEPtyKUxvU3dFFoY6nBfREay0BB CyTKEbZTmYiCa0kk5wg5g8Bd3v10FwxItHXrYEnthvNtCRC8kBRqDjLNC 7UuMLgO78Iay3pDfB3SEoJt+9AkX+oI2C9tls3HjPH/v18RiBg/9+CAAe nQ5i5MWZcOnI5vSsn7F3T1seee3iw33Kkz/hnXnpvaFQCTF55Pes43vu1 Z83oBF7SlV3uTdXUiyaZKNICqFMjy8WTuXug/oT74UZP0rSoCNJW9ok2+ yksNJ6YxpTlf2xVs4cRLOVXAyuUe0pzoSSzdqlfrbjR4+Wk8W3RLsv6aJ Q==; X-CSE-ConnectionGUID: o18W3OHnTueLIHjHBHplww== X-CSE-MsgGUID: xvyncF8mQYGkFzKRsYIdnA== X-IronPort-AV: E=McAfee;i="6800,10657,11482"; a="57499457" X-IronPort-AV: E=Sophos;i="6.16,283,1744095600"; d="scan'208";a="57499457" X-CSE-ConnectionGUID: JAco4SqMTCGkM18rW4QavA== X-CSE-MsgGUID: qaInI2rxSMuZN/CwjrilYQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,283,1744095600"; d="scan'208";a="153880373" From: Xiaoyao Li To: Paolo Bonzini Cc: Marcelo Tosatti , qemu-devel@nongnu.org, xiaoyao.li@intel.com Subject: [PATCH 4/4] i386/tdx: handle TDVMCALL_SETUP_EVENT_NOTIFY_INTERRUPT Date: Thu, 3 Jul 2025 10:40:20 +0800 Message-ID: <20250703024021.3559286-5-xiaoyao.li@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250703024021.3559286-1-xiaoyao.li@intel.com> References: <20250703024021.3559286-1-xiaoyao.li@intel.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=198.175.65.15; envelope-from=xiaoyao.li@intel.com; helo=mgamail.intel.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 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, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.999, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.237, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=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: 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 @intel.com) X-ZM-MESSAGEID: 1751510920384116600 Content-Type: text/plain; charset="utf-8" Record the interrupt vector and the apic id of the vcpu that calls TDVMCALL_SETUP_EVENT_NOTIFY_INTERRUPT. Inject the interrupt to TD guest to notify the completion of when notify interrupt vector is valid. Signed-off-by: Xiaoyao Li --- target/i386/kvm/kvm.c | 3 +++ target/i386/kvm/tdx-stub.c | 4 ++++ target/i386/kvm/tdx.c | 48 +++++++++++++++++++++++++++++++++++++- target/i386/kvm/tdx.h | 7 ++++++ 4 files changed, 61 insertions(+), 1 deletion(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 234878c613f6..fc58a23b30dd 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -6182,6 +6182,9 @@ int kvm_arch_handle_exit(CPUState *cs, struct kvm_run= *run) case TDVMCALL_GET_TD_VM_CALL_INFO: tdx_handle_get_tdvmcall_info(cpu, run); break; + case TDVMCALL_SETUP_EVENT_NOTIFY_INTERRUPT: + tdx_handle_setup_event_notify_interrupt(cpu, run); + break; } ret =3D 0; break; diff --git a/target/i386/kvm/tdx-stub.c b/target/i386/kvm/tdx-stub.c index 76fee49eff05..1f0e108a69ea 100644 --- a/target/i386/kvm/tdx-stub.c +++ b/target/i386/kvm/tdx-stub.c @@ -26,3 +26,7 @@ void tdx_handle_get_quote(X86CPU *cpu, struct kvm_run *ru= n) void tdx_handle_get_tdvmcall_info(X86CPU *cpu, struct kvm_run *run) { } + +void tdx_handle_setup_event_notify_interrupt(X86CPU *cpu, struct kvm_run *= run) +{ +} diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c index 10dfb80d22e2..fb31071dd81b 100644 --- a/target/i386/kvm/tdx.c +++ b/target/i386/kvm/tdx.c @@ -28,10 +28,13 @@ #include "cpu.h" #include "cpu-internal.h" #include "host-cpu.h" +#include "hw/i386/apic_internal.h" +#include "hw/i386/apic-msidef.h" #include "hw/i386/e820_memory_layout.h" #include "hw/i386/tdvf.h" #include "hw/i386/x86.h" #include "hw/i386/tdvf-hob.h" +#include "hw/pci/msi.h" #include "kvm_i386.h" #include "tdx.h" #include "tdx-quote-generator.h" @@ -1123,6 +1126,28 @@ int tdx_parse_tdvf(void *flash_ptr, int size) return tdvf_parse_metadata(&tdx_guest->tdvf, flash_ptr, size); } =20 +static void tdx_inject_interrupt(uint32_t apicid, uint32_t vector) +{ + int ret; + + if (vector < 32 || vector > 255) { + return; + } + + MSIMessage msg =3D { + .address =3D ((apicid & 0xff) << MSI_ADDR_DEST_ID_SHIFT) | + (((uint64_t)apicid & 0xffffff00) << 32), + .data =3D vector | (APIC_DM_FIXED << MSI_DATA_DELIVERY_MODE_SHIFT), + }; + + ret =3D kvm_irqchip_send_msi(kvm_state, msg); + if (ret < 0) { + /* In this case, no better way to tell it to guest. Log it. */ + error_report("TDX: injection interrupt %d failed, interrupt lost (= %s).", + vector, strerror(-ret)); + } +} + static void tdx_get_quote_completion(TdxGenerateQuoteTask *task) { TdxGuest *tdx =3D task->opaque; @@ -1154,6 +1179,9 @@ static void tdx_get_quote_completion(TdxGenerateQuote= Task *task) error_report("TDX: get-quote: failed to update GetQuote header."); } =20 + tdx_inject_interrupt(tdx_guest->event_notify_apicid, + tdx_guest->event_notify_vector); + g_free(task->send_data); g_free(task->receive_buf); g_free(task); @@ -1256,7 +1284,7 @@ out_free: g_free(task); } =20 -#define SUPPORTED_TDVMCALLINFO_1_R11 (0) +#define SUPPORTED_TDVMCALLINFO_1_R11 (TDG_VP_VMCALL_SUBFUNC_SET_EVENT_N= OTIFY_INTERRUPT) #define SUPPORTED_TDVMCALLINFO_1_R12 (0) =20 void tdx_handle_get_tdvmcall_info(X86CPU *cpu, struct kvm_run *run) @@ -1277,6 +1305,21 @@ void tdx_handle_get_tdvmcall_info(X86CPU *cpu, struc= t kvm_run *run) run->tdx.get_tdvmcall_info.ret =3D TDG_VP_VMCALL_SUCCESS; } =20 +void tdx_handle_setup_event_notify_interrupt(X86CPU *cpu, struct kvm_run *= run) +{ + uint64_t vector =3D run->tdx.setup_event_notify.vector; + + if (vector >=3D 32 && vector < 256) { + qemu_mutex_lock(&tdx_guest->lock); + tdx_guest->event_notify_vector =3D vector; + tdx_guest->event_notify_apicid =3D cpu->apic_id; + qemu_mutex_unlock(&tdx_guest->lock); + run->tdx.setup_event_notify.ret =3D TDG_VP_VMCALL_SUCCESS; + } else { + run->tdx.setup_event_notify.ret =3D TDG_VP_VMCALL_INVALID_OPERAND; + } +} + static void tdx_panicked_on_fatal_error(X86CPU *cpu, uint64_t error_code, char *message, uint64_t gpa) { @@ -1477,6 +1520,9 @@ static void tdx_guest_init(Object *obj) NULL, NULL); =20 qemu_mutex_init(&tdx->lock); + + tdx->event_notify_vector =3D -1; + tdx->event_notify_apicid =3D -1; } =20 static void tdx_guest_finalize(Object *obj) diff --git a/target/i386/kvm/tdx.h b/target/i386/kvm/tdx.h index d439078a8761..1c38faf9834c 100644 --- a/target/i386/kvm/tdx.h +++ b/target/i386/kvm/tdx.h @@ -25,6 +25,7 @@ typedef struct TdxGuestClass { =20 #define TDVMCALL_GET_TD_VM_CALL_INFO 0x10000 #define TDVMCALL_GET_QUOTE 0x10002 +#define TDVMCALL_SETUP_EVENT_NOTIFY_INTERRUPT 0x10004 =20 #define TDG_VP_VMCALL_SUCCESS 0x0000000000000000ULL #define TDG_VP_VMCALL_RETRY 0x0000000000000001ULL @@ -32,6 +33,8 @@ typedef struct TdxGuestClass { #define TDG_VP_VMCALL_GPA_INUSE 0x8000000000000001ULL #define TDG_VP_VMCALL_ALIGN_ERROR 0x8000000000000002ULL =20 +#define TDG_VP_VMCALL_SUBFUNC_SET_EVENT_NOTIFY_INTERRUPT BIT_ULL(1) + enum TdxRamType { TDX_RAM_UNACCEPTED, TDX_RAM_ADDED, @@ -64,6 +67,9 @@ typedef struct TdxGuest { /* GetQuote */ SocketAddress *qg_sock_addr; int num; + + uint32_t event_notify_vector; + uint32_t event_notify_apicid; } TdxGuest; =20 #ifdef CONFIG_TDX @@ -78,5 +84,6 @@ int tdx_parse_tdvf(void *flash_ptr, int size); int tdx_handle_report_fatal_error(X86CPU *cpu, struct kvm_run *run); void tdx_handle_get_quote(X86CPU *cpu, struct kvm_run *run); void tdx_handle_get_tdvmcall_info(X86CPU *cpu, struct kvm_run *run); +void tdx_handle_setup_event_notify_interrupt(X86CPU *cpu, struct kvm_run *= run); =20 #endif /* QEMU_I386_TDX_H */ --=20 2.43.0