From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qv1-f46.google.com (mail-qv1-f46.google.com [209.85.219.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 289F83B3BF5 for ; Sat, 28 Feb 2026 18:29:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772303348; cv=none; b=CIeW5fZLFHIUIU8/U8LIW5jBHeJLdp72B0PUBtaqVSANO2eGzplh0FbDMsPsEIRXwo95C8qz8g6woUIDh+KLGCF4lJn07BmmqujURuxB7DM5R/YGt17W6eeyPmccTO5SjtHHpcYn10S8Q8dmByTGs2jtXRsk/9LLK7jeF+ooOFg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772303348; c=relaxed/simple; bh=rkzmltbCB7oYdQAHuLM1PEc4LQu8jhDMt38DwB5M/W8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Rgu+z5OMp8WSQC387CfYbrwyJ3uLXoYkWY6watTJiLF++8oVxn9oaReDD2U2i5H4XloZG7IkwK6/bVo9lPS5MpORVIoHASYixGa1sgPZRHN4VqiRxo1xo42IgOPiol946eV2SVP5fOtVlxk85U3aTXPzfRDrYW9uDXIvD1g4zkM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca; spf=pass smtp.mailfrom=ziepe.ca; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b=K00HouUK; arc=none smtp.client-ip=209.85.219.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="K00HouUK" Received: by mail-qv1-f46.google.com with SMTP id 6a1803df08f44-899ee491af3so1994646d6.1 for ; Sat, 28 Feb 2026 10:29:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1772303346; x=1772908146; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=htHav7RfCL20FBhzRA0W1wS3HhKQenwSmiA0/DmxMnY=; b=K00HouUKZsJ6yofhTGJ0y/OJayrg2Rsbz/GeTxPCJWzmcZsFElp0hZ7EKb+Rn/Qvv4 wR+PylfQBXK+AxGiU3Z59C80ZvmbSqGS6YsTSwanJhY78/jhBPUdb/mUAGl0cMpD+cxD WegdScwcg4S/V0UJDNFYNF1oVir02y0RqUHhurykjNSgjrQNTYyGgGcPJahJibb7BoIh hKqYM6jmiKxNBaCKkiE+uwgFGb9wll501tkQmwTIlaBNtCIgkQgAz79/nXfOV0T6Na2W eO2WBVU+ql4+Iqbib8RKBVi4jsEWODNOaZCMxdyuV4ed9G/yOduHEtrOXqjCMDPDa7R7 NuQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772303346; x=1772908146; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=htHav7RfCL20FBhzRA0W1wS3HhKQenwSmiA0/DmxMnY=; b=jo7UShJOYjmkHj2fqo7UFEkX8KWqxbIja3LL+p3gMKBJ6tuDDmTuy6GQUOig4gxCYF H/hEc3CCc/YUEqi3Zufo8qvf/f/nEIUg7kegHl26bRSQPknUNM1Zat1wGurcqxaC2iyA vpenH6QZ0CuB/HhMHz2MIYcObvQRMvXyyDCBG3p8EAxJElD4A9hLVkj5okmP4y34EKrE LyfiQZwONm9ImPFw+o0uJVcgt5+INmcC6+TFCOEYUshaXU0K9oHnqbTdu87rPxF3sApO l5cpP+PN3V+Xs6uvQO2DvkItcJwXzMEls/jlPCyGl9544XdopwvMi1AttJnq9IDPc/d9 SWFw== X-Forwarded-Encrypted: i=1; AJvYcCVVqFoVEmxXs0BNGqct5q3ryvPfJ41YBu8ZIlmK9LLhPp/XWrkQ2AJov33W8x5HpnslN+Znk9V6K4C9dHk=@vger.kernel.org X-Gm-Message-State: AOJu0YwubK77iqL+TGva1ZApewDS6322zhH3LqA5fPugeemf2bbdErI4 gy5SPBmzrA45undy9lNS8yktFo7OvRiTIijL1sTmazz6s7SaY++XzaqojIzhNj3gd5U= X-Gm-Gg: ATEYQzwA5q+yQSVphVxNfPj4xwBEk7m91KhAoOLA2XqPq39JTkVhQ+7mjm6n+XUqnbT KuclaGxESPCScFyRutoXaJ5zuinuLGA0Z/2LR+V1lHr9jlHAxz+yw3cYQMHX/oO+qqYuxuW4liw oQmYA+UPweJODqQTOGQcZ8+32uRyc/ZQVUxRyCvwSwXr3jT3inXO/TJTjug5CbBk6UtmG3QIkmW Pb8wpoE7ec8CHsozXaWY6BcLfw+rAPBSzyOR06dbHTQsApI78EmIm+c17K7/HhAkfJTvKNEUFqV iOVSb32oNQn7+bMh1Plljpmm78qNpj9M33Q+yt5jqJDoyf5mervQ3ukI6G87lWxuKw/ql85Y1r2 qlpDQvEnYBqN/awInNb7f3NGdwSBvSAV7+J24q5nJ/z+8AS0QIbk20aF76AAjPtob+smyhqrZu4 T8wZI6h2y0tT9HLC5E92ZWRZ+eaormG+Zx3JPMXEhB2zemVhdw1XKV8+uafFwi23dgOYGF0TVe8 6A3OSQP X-Received: by 2002:a05:6214:1943:b0:896:fe42:e8a0 with SMTP id 6a1803df08f44-899d1e8b1camr101368936d6.63.1772303346029; Sat, 28 Feb 2026 10:29:06 -0800 (PST) Received: from ziepe.ca (hlfxns017vw-142-162-112-119.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.162.112.119]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-899c7376847sm71654726d6.28.2026.02.28.10.29.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Feb 2026 10:29:05 -0800 (PST) Received: from jgg by wakko with local (Exim 4.97) (envelope-from ) id 1vwP3o-0000000250x-2vIE; Sat, 28 Feb 2026 14:29:04 -0400 Date: Sat, 28 Feb 2026 14:29:04 -0400 From: Jason Gunthorpe To: Xu Yilun Cc: Sean Christopherson , Ackerley Tng , Alexey Kardashevskiy , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Kevin Tian , Joerg Roedel , Will Deacon , Robin Murphy , Paolo Bonzini , Steve Sistare , Nicolin Chen , iommu@lists.linux.dev, linux-coco@lists.linux.dev, Dan Williams , Santosh Shukla , "Pratik R . Sampat" , Fuad Tabba , "Aneesh Kumar K . V" , michael.roth@amd.com, vannapurve@google.com Subject: Re: [RFC PATCH kernel] iommufd: Allow mapping from KVM's guest_memfd Message-ID: <20260228182904.GR44359@ziepe.ca> References: <20260226190757.GA44359@ziepe.ca> <20260227002105.GC44359@ziepe.ca> <20260227010902.GE44359@ziepe.ca> <20260227131815.GG44359@ziepe.ca> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Sat, Feb 28, 2026 at 12:14:25PM +0800, Xu Yilun wrote: > On Fri, Feb 27, 2026 at 09:18:15AM -0400, Jason Gunthorpe wrote: > > On Fri, Feb 27, 2026 at 06:35:44PM +0800, Xu Yilun wrote: > > > > > Will cause host machine check and host restart, same as host CPU > > > accessing encrypted memory. Intel TDX has no lower level privilege > > > protection table so the wrong accessing will actually impact the > > > memory encryption engine. > > > > Blah, of course it does. > > > > So Intel needs a two step synchronization to wipe the IOPTEs before > > any shared private conversions and restore the right ones after. > > Mainly about shared IOPTE (for both T=0 table & T=1 table): "unmap > before conversion to private" & "map after conversion to shared" > > I see there are already some consideration in QEMU to support in-place > conversion + shared passthrough [*], using uptr, but seems that's > exactly what you are objecting to There is some ugly stuff in qemu trying to make this work with VFIO.. > Further more, I think "unmap shared IOPTE before conversion to private" > may be the only concern to ensure kernel safety, other steps could be > fully left to userspace. Hope the downgrading from "remap" to > "invalidate" simplifies the notification. Maybe, but there is still the large issue of how to deal with fragmenting the mapping and breaking/re-consolidating huge pages, which is not trivial.. To really make this work well we may need iommufd to actively mirror the guestmemfd into IOPTEs and dynamically track changes. I will think about it.. Jason