From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.21 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796201142; b=NeXNrPKmQ4gYsRwxNlww51aQN5N/r/1qOspwDAR3C8MveQGWqEADCNjgMSFhzAeQepSw wyEVFJejoccxV3jmCZ5+ShCkbbsswgyupdubNutDLX3gc1B1wRMjo457mH8U7iNrq5/V4 IZe8A8UGd8F6rKLqUgGxnu7eq/Fa10rSwEcnNgihxvCMFxITz/d9zik5N8O6ccSaXgkiE KZOrvK8dzYxx470pEjLmwGHQjOpL6D+fGU26Mw95HwLFbPMPfvRzK7z7wKX1ZbZaqvkXE JbtX8iy9SNxyrUFwmtoz1kLUriFLM/c0UaoUt9us5TTQdttcMTaz0IO7gwnaFC7db/g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796201142; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:Message-ID:Date: MIME-Version:User-Agent:Cc:Subject:To:References:Content-Language: From:In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=t3Quc+P/tYk9jUQ9dBT0vvi+Dl55sTlVLOQ5y8gDZj8=; b=oWW1cPlHX8r+Cq9d+iCEsA+fcgy34wnHE+EqMcKLCeK9T0NLdAo3vsRdTEY6SsDIWP0V rSMh8v+LAJVXXZtUtzel3VZSat9PTPEqa92m6Yc/IcjeyrkRcYu4MsbbXO6FtpYDxewEs Y0fK6FCb76YdcLqxRp+dmL8uhMzq+jFKf9d1S7OzrUM2oZAFIqE3FzXiu4dw+IAdpQfbu YnHY3Lzp/vK9nwQ+o1+G+s2Z30PCia5wtyUIEJSfm+5rT39BWnx90WnDRqDhH5Us8Vyoy wp9qkXwc/y0CAlCHpdXmBdLuzBcyORkXD4J/IJpn8gdNoEdkGF+dmPU5C6NvlD+VjgQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Dl9hWxvE; arc=none smtp.remote-ip=198.175.65.21 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8B64C606A322; Wed, 2 Dec 2026 08:45:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8B64C606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Dl9hWxvE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796201141; x=1827737141; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=t3Quc+P/tYk9jUQ9dBT0vvi+Dl55sTlVLOQ5y8gDZj8=; b=Dl9hWxvENch+npAS+iPItWZG3OGUbNSx3Ic+0fSoyaejShAmzXw+baxj XpoLJwuWCM2bB9DO53USAgI/YKNvqNpxcd5jKTU2ACkrgBblZceOPUGTc xTz31uL7IUqWaw0mfWVlBnTSREGQFNKLfkXxM++yA8ggX+deOg89RLK2h q5LheFEuXwHe7qOeZNKkSpzfpxazfDQ0Vl+/4xiQiZmtuYfGzezbtMKPx NwGfSjZVQEIwu9WJH6GpphwpnsTxTPgFtkvaxP1BwZDVMJjaQvnniZHJb JatDLkXkJZVltozvawq62/jB5OEuRT1GQtSX6q87iStunmNfttbuKT8gl Q==; X-CSE-ConnectionGUID: Wyy6QjHySJ+jd4Pg8ddmxQ== X-CSE-MsgGUID: AWzUm++PTcOXazYqhBsJVg== X-IronPort-AV: E=McAfee;i="6800,10657,11983"; a="5217635" X-IronPort-AV: E=Sophos;i="6.27,246,1787036400"; d="scan'208";a="5217635" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 00:45:40 -0800 X-CSE-ConnectionGUID: Fy5j48Y0RW66NFmi4AYRXA== X-CSE-MsgGUID: WxuP0u5GTQiTZW1X646PXQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,246,1787036400"; d="scan'208";a="13306943" Received: from blu2-mobl.ccr.corp.intel.com (HELO [10.124.249.52]) ([10.124.249.52]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 00:45:37 -0800 Message-ID: <12ee9032-e885-482f-ba58-b6899c5147e3@linux.intel.com> Date: Wed, 2 Dec 2026 16:45:34 +0800 X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: baolu.lu@linux.intel.com, iommu@lists.linux.dev, x86@kernel.org, linux-coco@lists.linux.dev, kvm@vger.kernel.org, Jason Gunthorpe , Kevin Tian , Kiryl Shutsemau , Rick Edgecombe , Chao Gao , Binbin Wu , linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 1/9] x86/virt/tdx: Add SEAMCALL wrappers for IOMMU setup/clear To: Xiaoyao Li , Xu Yilun References: <20261112043054.2664857-1-baolu.lu@linux.intel.com> <20261112043054.2664857-2-baolu.lu@linux.intel.com> <4ca101ca-90e2-4245-8b13-c56846c3f081@intel.com> Content-Language: en-US From: Baolu Lu In-Reply-To: <4ca101ca-90e2-4245-8b13-c56846c3f081@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 12/2/2026 3:26 PM, Xiaoyao Li wrote: > On 11/24/2026 1:46 PM, Baolu Lu wrote: >>>> +            u64 *tdx_iommu_id) >>>> +{ >>>> +    struct tdx_module_args args = { >>>> +        .rcx = reg_base, >>>> +        .rdx = __pa(param), >>>> +    }; >>>> +    u64 ret; >>>> + >>>> +    /* >>>> +     * Retry only on TDX_INTERRUPTED_RESUMABLE: >>>> +     * >>>> +     *  - TDX_INTERRUPTED_RESUMABLE guarantees forward progress between >>>> +     *    calls. >>>> +     *  - On TDX_INTERRUPTED_RESUMABLE, all registers except RAX remain >>>> +     *    unchanged. >>>> +     * >>>> +     * The ABI spec also allows retrying on TDX_OPERAND_BUSY, but that >>>> +     * status doesn't guarantee forward progress, so retrying could spin >>>> +     * forever. The host serializes all TDH.IOMMU.SETUP and >>>> +     * TDH.IOMMU.CLEAR calls for an IOMMU, so the TDX module should never >>>> +     * report the operand as busy. >>> >>> Many SEAMCALLs return TDX_OPERAND_BUSY, and this is the generally expected >>> handling. I don't think we don't need the comment if nothing special. >> >> I'd like to keep a shorter note. It's the usual handling for TDX folks, >> but people outside TDX may read this path too. > > Can we check in what cases it returns TDX_OPERAND_BUSY? Can some SEAMCALLs other > than TDH.IOMMU.SETUP/CLEAR contend resources with TDH.IOMMU.SETUP/CLEAR and can > lead to TDX_OPERAND_BUSY? If so, the statement of "the host serializes all > TDH.IOMMU.SETUP and TDH.IOMMU.CLEAR calls for an IOMMU, so the TDX module should > never report the operand as busy" is not true. You're right. Host-side serialization only covers SETUP/CLEAR against each other. It says nothing about other SEAMCALLs that may contend for the same TDX module resources, so the "should never report busy" is not true. The handling stays the same: retry only on TDX_INTERRUPTED_RESUMABLE, which guarantees forward progress. TDX_OPERAND_BUSY makes no such guarantee, so it is returned to the caller as a failure rather than retried. tdx-host then fails the SETUP and releases the IOMMU, or logs the CLEAR failure and leaves the IOMMU in TDX mode. I'll drop the serialization statement and reduce the comment to: /* * Retry only on TDX_INTERRUPTED_RESUMABLE, which guarantees forward * progress and leaves all registers but RAX unchanged. Other errors, * including TDX_OPERAND_BUSY, are returned to the caller. */ Thanks, baolu