From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AEA3EC35FFA for ; Wed, 19 Mar 2025 18:04:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9B2D3280002; Wed, 19 Mar 2025 14:04:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9621D280001; Wed, 19 Mar 2025 14:04:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 85236280002; Wed, 19 Mar 2025 14:04:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 684CB280001 for ; Wed, 19 Mar 2025 14:04:08 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 60CD6806F0 for ; Wed, 19 Mar 2025 18:04:09 +0000 (UTC) X-FDA: 83239074618.09.598E2FD Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf15.hostedemail.com (Postfix) with ESMTP id BDA36A0030 for ; Wed, 19 Mar 2025 18:04:07 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=none; spf=pass (imf15.hostedemail.com: domain of cmarinas@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=cmarinas@kernel.org; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1742407447; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BEvgrf1KyRaFRDiLcbW6T4Orhgn3+tVGRqSE8Ca+PVo=; b=7+KhkxkysJLslzfE21+Bsns79lIh4bNG3XrYC+09anx7Yu6HfiDQzS1VTj83Rz/pPHFDpB GUQw9qhWXj/vioKx/S4oGL0yRTKphbDIFp+OREmFHzypV57U+m6wJUlIPmSrd7DeI00imL LerD2IZuHaOXwsWNtDPXJ04bxkuJIeM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1742407447; a=rsa-sha256; cv=none; b=7+7JA5Fd/BxKq4sR5ZpI65nmjIgNWJ/FsZps9n29ZXkQCO9k1s0KQaqNB1jkHvfR6xdIUb p8dyijI23StK4CBousTQZiE2aKphP/5IV2PtnK0kPk9fyqE3T1O1vX2lQblbxtYEr1TIU5 pbYePZtXCU49dimZ5L/VesvDE9o887Y= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=none; spf=pass (imf15.hostedemail.com: domain of cmarinas@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=cmarinas@kernel.org; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 66622A446FB; Wed, 19 Mar 2025 17:58:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EBB44C4CEE4; Wed, 19 Mar 2025 18:03:59 +0000 (UTC) Date: Wed, 19 Mar 2025 18:03:57 +0000 From: Catalin Marinas To: Jason Gunthorpe Cc: Marc Zyngier , Ankit Agrawal , "oliver.upton@linux.dev" , "joey.gouly@arm.com" , "suzuki.poulose@arm.com" , "yuzenghui@huawei.com" , "will@kernel.org" , "ryan.roberts@arm.com" , "shahuang@redhat.com" , "lpieralisi@kernel.org" , "david@redhat.com" , Aniket Agashe , Neo Jia , Kirti Wankhede , "Tarun Gupta (SW-GPU)" , Vikram Sethi , Andy Currid , Alistair Popple , John Hubbard , Dan Williams , Zhi Wang , Matt Ochs , Uday Dhoke , Dheeraj Nigam , Krishnakant Jaju , "alex.williamson@redhat.com" , "sebastianene@google.com" , "coltonlewis@google.com" , "kevin.tian@intel.com" , "yi.l.liu@intel.com" , "ardb@kernel.org" , "akpm@linux-foundation.org" , "gshan@redhat.com" , "linux-mm@kvack.org" , "ddutile@redhat.com" , "tabba@google.com" , "qperret@google.com" , "seanjc@google.com" , "kvmarm@lists.linux.dev" , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" Subject: Re: [PATCH v3 1/1] KVM: arm64: Allow cacheable stage 2 mapping using VMA flags Message-ID: References: <86r033olwv.wl-maz@kernel.org> <87tt7y7j6r.wl-maz@kernel.org> <8634fcnh0n.wl-maz@kernel.org> <86wmcmn0dp.wl-maz@kernel.org> <20250318125527.GP9311@nvidia.com> <20250318231736.GE9311@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250318231736.GE9311@nvidia.com> X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: BDA36A0030 X-Stat-Signature: c1f6zopom3gcwzg448bjdejact8isuix X-HE-Tag: 1742407447-862714 X-HE-Meta: U2FsdGVkX1+5jdRmq9I9EjaPAuV7JAXvfElSBFoQZHpeRTedorH8EwKD/mjOoYA1Wq6dub/ox/FbA3giTqhImrGoUV7LOSLPoIX9BP2rKvLTB3oDvmw4jaqmN2T/y9fAdTrV8W2E7iO2y0by4AL5C4AmirEijVw/jK9ELf5CcVKSC+0OcuUbPI0Nj8maC6zAynBKx10Kw1UAyQ7oZra1LNE46EiV9eJraWQgBwPq6IHCsmmJrHU1vYMPjdRcCFqIYqjB2iIQuYTKmUHWHefbgsGFTqWInyTIRkBbfi5cu8WMrEQdk3p5T8Qbgmpn1VP6XEkmLrOGAonTGE7qZhVM/3BpXn6KSJI+nah5PPd9zQDEd8bzgR7LR1rl529Z8vdO5ojZJrvb6u3SH/WAt9nXHxBmsMOlsR1/iR3FU2iKB/IbO/Je23kt5d0CBsSd3S/tUcJmxfCvQajiYC2712Ax5ZVSZ3DbElQ44heTWrQkvzKvScyTldhL7M/yxl7bploGTL0IbubsT9zzAkOd1Y/yVPtxCbgglAEfAiKwTtUF+Fi1xl2ae2nd/g/Rwp8YHLfSP89RPRmA47i9UazQ41Vvn+EvrvnX0HNQpvKu8QCV2CpTFh+hep03G2T+QlJFvsXMGzgeE2A6RvpI8TksRt461Za42fWFU+yldIr0DqHknHTWeyTFZ92xR92zaXbUpHspuH9rQUVN7jEDKuYmmALN/azAkarfRz2Zm94eE799CpkMKCj3NToTpjf62aBusk1crplrN/wTmCNid5FiSAZE5KbSMIEbqmRLG9oPApplkL8xQ/mkec2lMFEUd7oHfhvX+4SAyTmHG15lxIqTG+aJ3wk0jqAXj5Nbst0uXT0VKMBSY7UmpSf9y2uJHl9sx8YwcpUJAjsigj3eS6rPxUgFHcHhMS6RAY4lTb0dwHyir4M8EjeCTePLa/nMAPnUEV3v0FrJfEbgbRBMtIfRf3d tOyBxx6j j/oBVpXMfsnAfGyq5GI6IddSJ6LPJq1nfKuogun887TKVXnzCNHeUieEavqhehSPCciuw0BNEEeARlZc0nyo8puz5pcAkWHAeX1088ogViZuEEzO5MLLoSHEK31fzCRXHdT62fz+amkpax14VE4DjyPmedfYQ7xIoPhpAgr5vLc/3F/dkQjZr4uco4qKwk8J3ndEDMJy7VsgEb3Uq0aJU3BHMG9GkotO40zUH/s7CcrxZ8TJV9Xr9vAAW0UybQUTWNAXspkMWRgVuYgA7kBeUYpwaK73jsR05kqjlybDzw5L4xbDjrcwBkxVLMOmnmHzKspDBQPpp5WkQ6hgJpixlndj9P3FAAY6eZuQyCc6kZ7tQ067XFzxwbs8Rk7EclguuYRmmKr866OZG97o= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Tue, Mar 18, 2025 at 08:17:36PM -0300, Jason Gunthorpe wrote: > On Tue, Mar 18, 2025 at 07:27:27PM +0000, Catalin Marinas wrote: > > Thinking some more about a KVM capability that the VMM can check, I'm > > not sure what it can do with this. The VMM simply maps something from a > > device and cannot probe the cacheability > > KVM is mirroring the MM's PTEs to the S2's PTEs. > > You can think about this differently - KVM currently has a little bug > where the MM's PTE's can say cachable but KVM will mirror it to a S2 > PTE that is forced non-cachable. KVM will not do any cache flushing to > make this safe. > > Fundamentally that discrepancy is what is being addressed > here. Cachable PTEs in the MM should be mirrored to cachable PTEs in > the S2. If we treat this as a bug (and I agree it's a potential problem if we assign devices to the guest that have cacheable VMM mappings), the first step would be to reject such memory slots, report some error to the VMM. I don't think it's worth attempting to do any cache maintenance to sync the aliases. Subsequently, this can be allowed with on FWB-capable hardware. Whether we want to expose such capability to the VMM, I guess it's harmless but I doubt the VMM would do anything with it since it doesn't know the device mapping attributes anyway. -- Catalin