From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.12 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796038447; b=qzBYiCaNQhn3Tb7kfiJCVwOUByR8dQojZ9FTyzCSKb5t3Rz8sWHhMCtU0LdXA8eAVlQ+ sIqqeM+1QBVTYcw9/iBAcTVoeLczND3WyXrSFvuj88pqTc9nZAUQCxlPGGSvNDgNSiGRe +Eq92gHp3Gogw5hLtxR565n9c/ZJP+X5XVoirh03VZ9Rjo6Mi8b/DxcTz8yQVHIx6WP9Q c7TyMWXdonf5OFqlGM08hIpXMaiOWzYIjW1wcaDOJ9f6sa7c5MhEbNQQwXYG/UmBExcir F1bYjDPbRrsw85ImtNcOGgTFDHY5LHWwhvwWP5G/nlSSzbylz8h/FYLDrE6/22InlXw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796038447; 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=WiY+72Cm8Pwj8kGXKlMnKYcTfJsVo4BFG4i5yJPrK3A=; b=JmQGeT9iZuQFdDWdY7qwU8F9qJADqa+K8bpemyHb6pYSLZ/ijjVDMd8tFA3akkYh35rc JHowKP4kP0G/s9eU/Kx9k4qu7IFfXOuNyhsl5NuVTGUIGyDkOBAOAF2nVjjZepf671+34 l3s5gkLbw1xsJ0GiNINGB+2vvWkD+ZrSrLbwGZvW9Uu1igZKrdG1pjhSNkfpbIYsKSP2Q SRlzUHXFSOY8AM3A1ssqkANmgxHLYX4dAJk9mQ6tn/wIHDeY6H5nlAAe/WHihDKs1csoB OysQGJEUrvTjqdlNB5Moq/P/FaqwmteQrY1PxAMo+TaW/3sYFRlclpzUzLWQ/030eow== 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=T7od9oNT; arc=none smtp.remote-ip=198.175.65.12 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 0DBC9606A320 for ; Mon, 30 Nov 2026 11:34:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0DBC9606A320 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=T7od9oNT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796038447; x=1827574447; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=WiY+72Cm8Pwj8kGXKlMnKYcTfJsVo4BFG4i5yJPrK3A=; b=T7od9oNTntyIKd8rtkrY81c/Wvq8DdMCggi06wvEx7hXi5bt5PAb75Hd ZuWTKmwm9d6fQULGkGoSe0WYZCB0qm3wOINnktdKFQmBTOtd+BU/w0dSj Sbp1XsNiESPI3kAJzk1B5yjAfTdQ97V2J3SN6mJJ1F0JZF/hymLqyNtjO bw3y9CogZd0X9fb94vvTd3P3kzMeh48qdmDDrooT08C+tTR++8E9WU1sT e2iDN1HkwnVki6i8bA0Y5mptSuDb9DyvUZ3uKAtAOBZcr846ZmeatZcvc 1p8eyMCGlnYZDmP1zS0WKtzD56oITvpLsiGHRyUp8UuSHh4g1v6PpJShj w==; X-CSE-ConnectionGUID: L9mDpEemThyQIYdWtapNdw== X-CSE-MsgGUID: MC009i45QXSV4Sw7pvZ3Cw== X-IronPort-AV: E=McAfee;i="6800,10657,11981"; a="4769320" X-IronPort-AV: E=Sophos;i="6.27,242,1787036400"; d="scan'208";a="4769320" Received: from fmviesa013.fm.intel.com ([10.60.135.153]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2026 03:34:06 -0800 X-CSE-ConnectionGUID: NcRN1LMAS3yWAeWSnsMQVQ== X-CSE-MsgGUID: FJ71asWLSTeMN/f2yV4PXg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,242,1787036400"; d="scan'208";a="14919352" 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; 30 Nov 2026 03:34:01 -0800 Message-ID: <0487472f-7c39-4ca2-910e-31ee9dcda7aa@intel.com> Date: Mon, 30 Nov 2026 19:33:57 +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: Xu Yilun Cc: "Edgecombe, Rick P" , "linux-coco@lists.linux.dev" , "linux-kernel@vger.kernel.org" , "Duan, Zhenzhong" , "x86@kernel.org" , "Hansen, Dave" , "dave.hansen@linux.intel.com" , "kas@kernel.org" , "seanjc@google.com" , "mingo@redhat.com" , "Peng, Chao P" , "pbonzini@redhat.com" , "Tian, Kevin" , "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" 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/30/2026 5:49 PM, Xu Yilun wrote: >>>>>> 4. TDX_PAGE_ALREADY_ACCEPTED is listed as the possible return code for >>>>>>    TDG.TDI.MMIO.ACCEPT while the description of TDG.TDI.MMIO.ACCEPT reads: >>>>>> >>>>>>      If the page is already MMIO_MAPPED, skip the page. >>>>>> >>>>>>    They conflict with each other and lead to confusion. >>>>> >>>>> I'd think if the page size is incorrect it should return >>>>> TDX_MMIO_ACCEPT_SIZE_MISMATCH. If it is already accepted it should return >>>>> TDX_PAGE_ALREADY_ACCEPTED. In the case of mismatched size but already >>>>> accepted >>>>> page, ideally it would return TDX_PAGE_ALREADY_ACCEPTED, but it would be ok >>>>> if >>>>> it returns TDX_MMIO_ACCEPT_SIZE_MISMATCH. >>>> >>>> For private memory accept, if the mapping is not accepted by the guest yet: >>>> >>>>  - when accept level > mapped level, SIZE_MISMATCH is returned so that guest >>>> can >>>>    try accepting at a lower level. >>>> >>>>    TDX_MMIO_ACCEPT_SIZE_MISMATCH is also returned for MMIO in such case. They >>>>    are consistent. >>>> >>>>  - when accept level < mapped level, EPT violation happens so that host can >>>>    demote the mapping. >>>> >>>>    There is no behavior defined for such case. But I think the reasonable >>>> option >>>>    is also to EPT violation to the host to request the host maps at lower >>>> level. >>>>    Forcing the guest to a higher level doesn't sound reasonable because the >>>>    guest might not want the whole range of 2M MMIO is accessible by the >>>> driver. >>>> >>>> Regarding ALREADY_ACCEPT, we need it for private memory because a successful >>>> acceptance of private memory will clear the content to 0. TDX module don't >>>> know >>>> the intent of the guest, so it makes sense to return an error code to tell >>>> guest >>>> the page is already accepted without clearing it. If guest wants to clear the >>>> page, it can do it itself. >>>> >>>> But for MMIO, there is no such clearing semantic. Skip on the already-accepted >>>> MMIO page and return success seems to have no problem. Besides, private memory >>>> accept is operating on a single (huge) page but the MMIO accept is operating >>>> on >>>> a range. Return ALREADY_ACCEPT would increase the complexity on the output to >>>> tell the current status but without any real benefit. >>> >>> In the past discussion on private memory accept, someone made the point that re- >>> accepting memory should be fixed in the caller because it could be a weakness >>> used to attack the guest. If the kernel is confused, the host could zero memory >>> for the guest as part of some attack, or the new caller of accept could be >>> surprised by un-zeroed memory. This came up when the memory hot replug bug that >>> was eventually fixed in qemu partly to avoid allowing survival of re-accepting >>> memory in the guest. (and caught by the already accepted error code). We >>> discussed if the guest could handle the error by simply re-zeroing the memory >>> after a double accept. But then the debate was whether this would cover up bugs. >>> >>> I think a similar case could be made for MMIO, which is probably the purpose of >>> this error? >> >> 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. >> >>> 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 > > I would not say "guest doesn't care the mapping ...", guest absolutely > cares whether a GPA is correctly mapped to the expected MMIO... I cannot remember what I wanted convey last week. Yeah, thanks for your correction. >> 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 > > ... and yes TDX module helps guest to make the validation via TDG.TDI.MMIO.ACCEPT > >> converted between shared/private back and forth runtime. During the 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. > > The definition of TDX_PAGE_ALREADY_ACCEPTED is still not 100% clear to > me, does it mean: > > 1. A GPA is already accepted, regardless of where the GPA is mapped to. > > Or > > 2. A GPA is already accepted && the GPA-to-MMIO mapping is also correct. > > If it is the later, seems good to drop the error. > > But AI tells me the module code implements the former, that seems a problem > we can't ignore. Maybe your AI was analysis the TDX_PAGE_ALREADY_ACCEPTED for memory case? For MMIO case, I think the TDX_PAGE_ALREADY_ACCEPTED means for #2 because the "already-accepted" means the TDX module has changed the state the MMIO EPT mapping to mapped, during which TDX module surely validated the GPA-to-MMIO mapping. > Thanks > >> >>> 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.