From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.19 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796020530; b=XUmft7a/Xf0arwludHV06GmUuFrJo/Wpk2J1FTdoHOkk5BqLiUWRjt2Nd0OEKahXVfLP wg83whKRhgFF5hz9ND9Ht+OeHM8d+qK6e9ZcG10Gp/mRfkbawZDnBhMNagzv2KlNGl0Sq Ud0on7szIbwZBA+zZ8Ba7oeD/i2Jpo68i1oCakF8foOlfpCX5+ABtNx5HDq8WbmTsOPyx D+HpMWNroKucQrfh2G3BSiXjLcAdohzoS9zZF3aPPv6xSrkMDZ5k6aZsS8ex5trVP0YWy J2c+6L49rV7U+RFlhZfqsHumitSP2RNUxJkbBakfImi1V9kTtwkYIbwMJz8Uc/wM3vA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796020530; 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:Subject:To:Cc:References:Content-Language: From:In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=d1h0x4Je6domVQPNe7wGRmdpG1Lm8oOW0gicoMauGl4=; b=H3seZrKbIsMW4myzu44qifcQo7/BIElaTQNeNlM6mvBhtG2OMSZ4nz74UMLaUK+RyeN0 RCSwBS296liQSgU9aXCvqgO5AUIloNxb/B5SF6TXXo2l4DPUO1A5u7PRQURhO3f+9zGnS W+YZDR1Y4Hxpci3JYEbqIb97J9nTrNI0g0QT0CRH/RsA5qpYDwW08rgb0bqDdnUklCiXL T0GwLwWzpUAkKUtJimEfflglnZJuCkkYy2wfAqW25d6UNXcSjbVp3KjisCx9hOYGRvVN3 qW3F16QCwZ8Pg2K+q6yPe4IX6J9IvDAw2x0J04JtOSja1uoKMLwYxilzpR7H891I4Gg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Z23I+c0c; arc=none smtp.remote-ip=198.175.65.19 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (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 8E826606A33C for ; Mon, 30 Nov 2026 06:35:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8E826606A33C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=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=Z23I+c0c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796020529; x=1827556529; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=d1h0x4Je6domVQPNe7wGRmdpG1Lm8oOW0gicoMauGl4=; b=Z23I+c0cQK2sR8Sr3ID6Is3fHaPQmocTZn9OB+uIPTHMg8J0QGn8/+N3 kC4ljG+DJFrxd+prL++OxQYU9gYs34obglVaXvRjuZayJIzqEUZbzVvhw nqYOx84Y8oYLXo2B9wzT+05sDj/JiJb0Hj932kqEEowOU0pb9s6zy04WI 4VIAWfP405Aqgoej+yMRbsF/lKNuLhFPq8O83WT7ikCsYXnCspKOdkeCU MJQ4dMNTTuDNcj3pLVI/QtOTAFctq1megivWeinS0g6sn/AEnxml0fas6 qrSri8++WLjPHJrM8A6mGJN/mbLTEGk7qSNIxcJ/+qEDrXEB320qVVH0F w==; X-CSE-ConnectionGUID: I68APX5zTfSG4paNMEjj1Q== X-CSE-MsgGUID: bob1WtPrT9qS9k8zHTCjYw== X-IronPort-AV: E=McAfee;i="6800,10657,11981"; a="4901193" X-IronPort-AV: E=Sophos;i="6.27,242,1787036400"; d="scan'208";a="4901193" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2026 22:35:29 -0800 X-CSE-ConnectionGUID: KYSYl5DsRL6MApEu1FcBJQ== X-CSE-MsgGUID: Hmc65yTWS/CoWjuCgraN6g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,242,1787036400"; d="scan'208";a="12726436" Received: from xiaoyaol-hp-g830.ccr.corp.intel.com (HELO [10.124.240.106]) ([10.124.240.106]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2026 22:35:23 -0800 Message-ID: Date: Mon, 30 Nov 2026 14:35:21 +0800 X-Mailing-List: linux-kernel@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 Subject: Re: [RFC PATCH 00/15] PCI/TSM: coco/tdx-guest: Implement TDX-Connect PCIe TDISP (phase2) To: "Tian, Kevin" , "Edgecombe, Rick P" , "linux-coco@lists.linux.dev" , "linux-kernel@vger.kernel.org" , "Duan, Zhenzhong" , "x86@kernel.org" Cc: "Hansen, Dave" , "dave.hansen@linux.intel.com" , "kas@kernel.org" , "seanjc@google.com" , "mingo@redhat.com" , "Peng, Chao P" , "pbonzini@redhat.com" , "jgg@nvidia.com" , "aneesh.kumar@kernel.org" , "Verma, Vishal L" , "hpa@zytor.com" , "tglx@kernel.org" , "nicolinc@nvidia.com" , "Gao, Chao" , "bp@alien8.de" , "aik@amd.com" , "yilun.xu@linux.intel.com" References: <20260924041032.1096569-1-zhenzhong.duan@intel.com> <8acf514600526e3a2b0af151b0fa8a7b7a779c81.camel@intel.com> <5b6837a8-f8bc-4e7f-8419-01853eecd531@intel.com> <244d504ddfefd2c2bfc17da62f71685dc8b4205c.camel@intel.com> Content-Language: en-US From: Xiaoyao Li In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 11/27/2026 4:13 PM, Tian, Kevin wrote: >> From: Li, Xiaoyao >> Sent: Thursday, November 26, 2026 4:10 PM >> >> On 11/26/2026 1:47 AM, Edgecombe, Rick P wrote: >>> On Wed, 2026-11-25 at 16:32 +0800, Xiaoyao Li wrote: >>>> On 11/25/2026 3:41 AM, Edgecombe, Rick P wrote: >>>>> On Tue, 2026-11-24 at 14:01 +0800, Xiaoyao Li wrote: >>>>>> 1. The requirement of R8-R15 are reserved to 0 on TDG.DMAR.ACCEPT. >>>>>> >>>>>>    This is the first leaf in TDCALL/SEAMCALL that explicitly requires some >>>>>>    unused  registers to be 0. Without justification of why it must to be >>>>>> such, >>>>>>    we are going to propose to remove this requirement and it helps drop >>>>>> the >>>>>>    PATCH 13. > > TDG.VM.RD/WR and TDG.VP.RD/WR require RCX must be 0, so it's not > the first example. I missed them. Thanks for catching this! I think they are reserved to 0 because their host SEAMCALL counterpart, TDH.MNG.RD/WR and TDH.VP.RD/WR, have R10 defined to identify the TD and VCPU. But for guest TDCALL, no need for such identifier. It is reasonable to reserve the R10 on TDG.VM.RD/WR and TDG.VP.RD/WR to make the API consistent with host side SEAMCALL and reserve the ability for future extension. ... >> >> Re-accept of memory has the effect to reset the memory content 0. But re- >> accept >> of MMIO doesn't do any harm, as I see it. > > dumb question - why would the guest want to re-accept a memory, in > different sizes? is there a concrete example? No. It's not telling that the guest wants to re-accept a memory, but telling that the success of re-accepting a memory has the semantic of "the memory is initialized to zero". This "resetting to 0" behavior sometimes causes problem so we don't want re-accept of memory to return success, but return an error code of TDX_PAGE_ALEARDY_ACCEPTED. But for MMIO, re-accept has no such additional semantic. It looks OK to return success for MMIO re-accept. >> >>> The guest could get confused about which MMIO address is mapped at a >>> particular GPA? >> >> I'm not sure. Guest doesn't care the mapping between MMIO and GPA. The >> TSM and >> secure firmware will help validate that the host VMM has mapped the GPA to >> the >> correct MMIO resource of the corresponding haredware device. And MMIO >> cannot be >> converted between shared/private back and forth runtime. During the > > is it true? when the device transitions from locked to unlocked it then goes > from private to shared? My wording of "runtime" seems not that accurate. Let's say it this way. There are two states of a device, bound and unbound. During the lifetime of each state, whether the MMIO is private and shared is determined and we cannot change part of the MMIO into a different shared/private state. >> lifetime, >> guest kernel only needs to accept the private MMIO once after the device is >> locked and accepted. >> >>> There must be some trusting intended as part of the operation or >>> why even have the MMIO accept in the guest in the first place. >> >> We have two reasons: >> 1. the same for the page accept. Accepting the page/MMIO by the guest >> prevents >> host from mapping a new page/MMIO to the GPA without guest's awareness. >> >> 2. TDX module will validate that the host maps the correct MMIO resource to >> the >> GPA. >> >>> So I think if we don't need the error, why even need the MMIO accept call >> at >>> all? But we probably want both. >> >> The ALREADY_ACCEPT error code and MMIO accept are two things. We care >> if the >> MMIO is accepted or not, but we don't care how many times the MMIO is >> accepted. >> >>> And I also don't see a major simplicity benefit to dropping error. What is >> the >>> savings? >> >> It makes the guest code simpler that the guest doesn't need to implement >> the >> skipping itself. > > simpler compared to treating ALREADY_ACCEPT as success? yes. If re-accept of MMIO will return ALREADY_ACCEPT. Even by treating it as success, guest code still needs something like below: diff --git a/arch/x86/coco/tdx/tdx_connect.c b/arch/x86/coco/tdx/tdx_connect.c index 01c12b459570..da049ea30764 100644 --- a/arch/x86/coco/tdx/tdx_connect.c +++ b/arch/x86/coco/tdx/tdx_connect.c @@ -69,7 +69,10 @@ int tdx_mcall_tdi_mmio_accept(struct pci_dev *dev, .r9 = size >> PAGE_SHIFT, }; - ret = __tdcall(TDG_TDI_MMIO_ACCEPT, &args); + do { + ret = __tdcall_ret(TDG_TDI_MMIO_ACCEPT, &args); + } while (TDCALL_RETURN_CODE(ret) == TDX_PAGE_ALREADY_ACCEPTED); + if (!ret) return 0;