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 04AC2C4829B for ; Mon, 12 Feb 2024 13:06:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5331D6B007B; Mon, 12 Feb 2024 08:06:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4BC4E6B007E; Mon, 12 Feb 2024 08:06:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 35D8B6B0080; Mon, 12 Feb 2024 08:06:44 -0500 (EST) 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 23A4C6B007B for ; Mon, 12 Feb 2024 08:06:44 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id E4C911C11C5 for ; Mon, 12 Feb 2024 13:06:43 +0000 (UTC) X-FDA: 81783176286.05.D815C6B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf07.hostedemail.com (Postfix) with ESMTP id 9D9804000A for ; Mon, 12 Feb 2024 13:06:41 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AFVMOKx2; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf07.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707743201; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=WDWwBBM+E91ZU6bnMPP22WeGEpsgO4NhaElCMSoXp58=; b=DL7pHwdgpkwpEC2gBU0SN58MvpDOGPe7Q/R4+X31rXeyUIScrWOKjK3Xdj8E2MLH5N278Z cCTXoQcbdUA3JF+YYsKbKY90xTK33OBvHm8dzf3GGg7C66EkucS8REbCibAmoNZxfCStAK udOkZz6brIq5KxFtd3O9Of7R8conzZM= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AFVMOKx2; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf07.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707743201; a=rsa-sha256; cv=none; b=6LJ/n8H/15mba7MNPtz415UN4Q0IM0SfxOoh9FZSrEAUOkz3+EdM/AqNV0rcO9WcuLfu8X TZp9UeU+EenrbAwofN3RBkJh0SpTtPZRfgWhqZEthlK8UUj8Mi/fIw1aMtauVGy3dYUqbP 2W41WcSE3zBZul+Q9EAiI2nnQ10azuk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707743200; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=WDWwBBM+E91ZU6bnMPP22WeGEpsgO4NhaElCMSoXp58=; b=AFVMOKx2e5I1R5KAwkvvv4hlBumf7R9tMocHQltNf3EkTvIPOC/ga7RWK5YuhLFOIRURmB s2fVbF8v5H6XN/kEYbTkbWtuyKGuOl7sW415e+i4DiUTo2Bp3cyv7P3ggUuAGFctfcDS2O yFcozKbQ5rR2f8GSakI0cVnDgm3Hs1c= Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com [209.85.167.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-80-dIfkz5bQP0-Pr7budOjbyQ-1; Mon, 12 Feb 2024 08:06:39 -0500 X-MC-Unique: dIfkz5bQP0-Pr7budOjbyQ-1 Received: by mail-lf1-f70.google.com with SMTP id 2adb3069b0e04-51173037e87so2251148e87.3 for ; Mon, 12 Feb 2024 05:06:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707743198; x=1708347998; h=content-transfer-encoding:in-reply-to:organization:autocrypt:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=WDWwBBM+E91ZU6bnMPP22WeGEpsgO4NhaElCMSoXp58=; b=thNEm0IfwI8z8Uo6mUZCZoJt88MFmKcIofyjz72dePIRNN0UHYd5xM/Lnd72cdV83/ 6VC+DSKAP6dfR13Rx82ByxnoTQFpP5mcPtPhW5WTNa6BIUoSYnoTRnE4YSlZXmo5YV1W Bb1dYX4uX+x7swxiYmiVQGVq6uAdwzpXWpX0zlkFO/J7Sx3Mx69lfrIfIsUSK4BNWBWj o0jCaPVfpF4DuQxD6ZM/X4GsWN3TSe04zTbeY68z1wR+WwiSPO/MwZsRSZvDFu8Qnn45 3BVIcw4uu/TuOXT/rTHGQQus9i2D7rcMb1sRe8SzhBmdFXeIxF9OtSYKpEJiJilbp+Te 2KyA== X-Gm-Message-State: AOJu0YwoWt75Wi3TyPvB2wXo2dsz+seiqLaP8vQBAa1gg4XZS9B+BMSj 8noymm4IgmJWQas5j+2x58DydmTZ46d+z/A2I/kpbr4OzR43UGn3Tmpa6nMX2/zzb+gdrEmv0G3 6hFcKCc0OaNtoViVWbrFZx9N+uzE5pGYaOFvHFisjLKzNbEOk X-Received: by 2002:ac2:484e:0:b0:511:82b5:b484 with SMTP id 14-20020ac2484e000000b0051182b5b484mr3671298lfy.64.1707743198002; Mon, 12 Feb 2024 05:06:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IEAi+y4C0q8Pj8RrJ7Auc1O4J3dTFjnTSp79xOJnXlMZlLNC1sCSpKdTZmKkS2ODIqClDBGHg== X-Received: by 2002:ac2:484e:0:b0:511:82b5:b484 with SMTP id 14-20020ac2484e000000b0051182b5b484mr3671254lfy.64.1707743197527; Mon, 12 Feb 2024 05:06:37 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVXC8dM/g488xbOderXCs0dcp21CcwsLFJHR6YjVOxLWNicm8D/FidrCQhXbQYYPXxP52FQn6GG6VS87CK34RcDM5er9ZOju/TaFSRP5Vpmzu6TqjOW2LMQnF3BbnYMLVP1uHrFHPG0v8N5KFXtd09uerHdjz+fhgi+uLxz7BoPg08zwBh1doJbrsgvvrmypqtOfc4y/zmqECoVg6kbZMoFr1VLc1Uhx9+j903DvZR3LMFGsefY+vF2dw+omnf6cDEOkJL/EEYByXjlD3Bi3MnhLsQnf91b07gLGtSs3VJeKLMdKOY//OjJsCnUva0YKI6swT0sg5VplGAwiG8TiipWfkP4Dkuo+CJy6ZdLfdyPrY/uWjQRQPQ5JLXCq8/B4P6wsn4QEpLeM/OzTu1HD2+I92rn6S/dlq0FbWlwlDV7M3SZLPn72BkiZSW2KrQNpYej7sCjrZxy5j6Ar9j6oS5jhbq2Q9ebBuZ81uny5MKkl0vQMNDUoaEfyNOk2Sv/eofaXbkNVypvTg6d299CrApmhqZ//8eVLqWSYV124AAQLp/ezhBtmhkgLN5cbYX9GZAKGwqEVGrkBDvluzSOJECKk765SluUSMDGuBXIa3ueBGkl4Ds7Elh+eSp6LYL1++VFijkYYUu1o6I02DPsqLKsVAZQx4OV5PILjXyGqx48Na+Ep/o+TOHK5TPg9cyO+CDQGD7fwO3mLgVWpn6Yb4BPDPYs2eanp7zukA0iIqseJiOx/CD8z84YqyHqV+78e0WjMdIcw6BUp/JoMtOVURx6X5ADMonU1DZ+F2UqFSdiCU/C+3r1QKmSwSiaW9J3QpiwZUoHqnaK/SIurVbzLe9w4mFoqc3d/AuD8zZ7xc9SetcFkQ99ywYqdtP5T2CxgTRe2LwsDcmxg4A5QfnmdeAfZ1CteF7hcwmX0qnkJwDd1O7u7G+nMAMphnaovd vLYk1sVt Md5KQ94VW9wGUPPwNPZJdsinJnIcn9kBO2w/U5jPqBpfdDTnAswC0qn1g5umFVUiqHB7gH/w04Ns6+L+Hw64YEAKguyQnn/LW8NySO0AhQ2oqgT5AVK2VnmPAeTcgm15OdeIheJPcqNj4x3yAtrIXcwl46Vd/Aqxy+tOLzx02FdOiPiqrALlh8gN7c0CuQBdNU9MMrQMTMC8BDjUbgK+3Q+HIdsVgFFmYhvzdlFUrv7NaWu0yT4hafOLsnnEQoZonKGeQjZsZsvCT457uNFhuE8WfZD0/rKQwSKH6k9FVEUxWmVNC3Zzuz+PpwBigCJCDwsn+yD2q1eiAmUgSmfQ== Received: from ?IPV6:2003:cb:c730:2200:7229:83b1:524e:283a? (p200300cbc7302200722983b1524e283a.dip0.t-ipconnect.de. [2003:cb:c730:2200:7229:83b1:524e:283a]) by smtp.gmail.com with ESMTPSA id k14-20020a056000004e00b0033afc81fc00sm6714883wrx.41.2024.02.12.05.06.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Feb 2024 05:06:37 -0800 (PST) Message-ID: <30493284-53f6-4172-a9e1-cb9052acced4@redhat.com> Date: Mon, 12 Feb 2024 14:06:35 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v7 0/4] kvm: arm64: allow the VM to select DEVICE_* and NORMAL_NC for IO memory To: Jason Gunthorpe Cc: ankita@nvidia.com, maz@kernel.org, oliver.upton@linux.dev, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, reinette.chatre@intel.com, surenb@google.com, stefanha@redhat.com, brauner@kernel.org, catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, alex.williamson@redhat.com, kevin.tian@intel.com, yi.l.liu@intel.com, ardb@kernel.org, akpm@linux-foundation.org, andreyknvl@gmail.com, wangjinchao@xfusion.com, gshan@redhat.com, shahuang@redhat.com, ricarkol@google.com, linux-mm@kvack.org, lpieralisi@kernel.org, rananta@google.com, ryan.roberts@arm.com, linus.walleij@linaro.org, bhe@redhat.com, aniketa@nvidia.com, cjia@nvidia.com, kwankhede@nvidia.com, targupta@nvidia.com, vsethi@nvidia.com, acurrid@nvidia.com, apopple@nvidia.com, jhubbard@nvidia.com, danw@nvidia.com, kvmarm@lists.linux.dev, mochs@nvidia.com, zhiw@nvidia.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org References: <20240211174705.31992-1-ankita@nvidia.com> <20240212125654.GV10476@nvidia.com> From: David Hildenbrand Autocrypt: addr=david@redhat.com; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+GDK0wnacPQFpcG1AE9RMq3aeErY5tujekBS32jfC/7AnH7I0v1v1TbbK3Gp XNeiN4QroO+5qaSr0ID2sz5jtBLRb15RMre27E1ImpaIv2Jw8NJgW0k/D1RyKCwaTsgRdwuK Kx/Y91XuSBdz0uOyU/S8kM1+ag0wvsGlpBVxRR/xw/E8M7TEwuCZQArqqTCmkG6HGcXFT0V9 PXFNNgV5jXMQRwU0O/ztJIQqsE5LsUomE//bLwzj9IVsaQpKDqW6TAPjcdBDPLHvriq7kGjt WhVhdl0qEYB8lkBEU7V2Yb+SYhmhpDrti9Fq1EsmhiHSkxJcGREoMK/63r9WLZYI3+4W2rAc UucZa4OT27U5ZISjNg3Ev0rxU5UH2/pT4wJCfxwocmqaRr6UYmrtZmND89X0KigoF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ntJkNMmQpR4MCBaV/J9gIOPGodDKnjdng+mXliF3Ptu6 3oxc2RCyGzTlxyMwuc2U5Q7KtUNTdDe8T0uE+9b8BLMVQDDfJjqY0VVqSUwImzTDLX9S4g/8 kC4HRcclk8hpyhY2jKGluZO0awwTIMgVEzmTyBphDg/Gx7dZU1Xf8HFuE+UZ5UDHDTnwgv7E th6RC9+WrhDNspZ9fJjKWRbveQgUFCpe1sa77LAw+XFrKmBHXp9ZVIe90RMe2tRL06BGiRZr jPrnvUsUUsjRoRNJjKKA/REq+sAnhkNPPZ/NNMjaZ5b8Tovi8C0tmxiCHaQYqj7G2rgnT0kt WNyWQQ== Organization: Red Hat In-Reply-To: <20240212125654.GV10476@nvidia.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 9D9804000A X-Stat-Signature: oi757bcobd9rb1mbg71fk6c7kiagy1jx X-Rspam-User: X-HE-Tag: 1707743201-87551 X-HE-Meta: U2FsdGVkX1+yMU/JauSUtOS3jk/pNGLCvRJmyi1d6Ah/mLkd67J9K7oQlkzaZ2MEeY6+mncib/UBTEbi47YcSLbNgl/UEWYuueFAjRzriMaapxAjiBDZ4qUbOfyx8AedZR6Y2zmZFPGzF/8VNp7xc5QuTGonbgFepCpW6imGYLRMtacZxq/gmkkbR0eSot+229MQ4ByRu/bI/aGl60oUJ10Vx8bkKQibOkmjY8YHMIwvfUXQEkG84NHuAOHJP7q4Ggy+xTkElgV06uTj9LGaupW6Dc5bnARC2rxaEc0Gw/syKAIfJrogqCg5r4BZFrjlXbHZ9udZ2mQORDkTzJzQgVgWGi+3N5BGRWwOAJ7fRNOa6C11GhiePZZiTEjOXIWvhQduiKIh77ppGd29tECpux7HvwG7/q4xJM476N4wfPaZFvXFYGmLu6a7Vdt1SbwnGTBYdnDTBb9oMThuJrn5lhDT3oF30oLA1lO8iu1k3S+U1z8C/Go9010bF+zimD+5LCWA9kBM1aFAeCl0CY2HUhGlqzTFETDjYmPdvKRh7aiJSMumhty+5HT5ZoMn3M5BeMWd4ClvTuRKoprMjgdIt4ztg/H/kts7SbinDrFyoCHGwlRZFlmz76IHG2STsGF+zNmnmplOU6ApvD/Fjq9sD8Bes8r+QgQr2zgagSEWP2ET/cUABNxBwOq6O3QI/uCNnrt255+N3G0a8aHa4a8dRn+FETAgtYGXUavCSWVheYENPZiLAXt6E2WS/Rpt+XT8yEARIpI3lm2HbDVuIEl4GtsQQRVci3T4MS0rzddwAUMKTx4L1tZ20mReBIGfoc3miQWdPnNTcjThRhtd0j9P2Fhko7gAI50hmEInf7rWO+mufuao/Ft15gkf5Cwc4CpIo8Fz1GnBTVmTioV30p9TyEa885E257IXjCxKKZ36egmReUhhEo1SVmoqTrMYU+RpJdNU20wFx3k4Qy74lmA XFy376IU TC2UGtIXIRYxyOloWN2smsF8V+I++PNy0x3zvzFUQrhSwU7rjw8AtPhh9PRA4iIQr9ay2AUHwFdOvz8i993+r/IkAUmZmVuyug0Mp8znFTGT+4wV/xerd6BiNHo+KeCIqtSqqfh3sI13Qqlgtvn1kFpvVS3VP3QHey54+MgoWEBP8kIberf6RiBtPFkgtADUY9YKSIP7p0vmUB+MC7nS+MxAzbA== 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: Hi Jason, Thanks for all the details (some might be valuable to document in more detail, but I'm not that experienced with all of the mapping types on arm64, so it might "just be me"). > It is worse that some hand wavey "side effect". If you map memory with > NORMAL_NC (ie for write combining) then writel() doesn't work > correctly at all. > > The memory must be mapped according to which kernel APIs the actual > driver in the VM will use. writel() vs __iowrite64_copy(). > >> We can trigger both cases right now inside VMs, where we want the device >> driver to actually make the decision. > > Yes > >> (2) For a VM, that device driver lives inside the VM, for DPDK and friends, >> it lives in user space. They have this information. > > Yes > >> We only focus here on optimizing (fixing?) the mapping for VMs, DPDK is out >> of the picture. > > DPDK will be solved through some VFIO ioctl, we know how to do it, > just nobody has cared enough to do it. Good! > >> So we want to allow the VM to achieve a WC/NC mapping by using a >> relaxed (NC) mapping in stage-1. Whatever is set in stage-2 wins. > > Yes > >> >> (3) vfio knows whether using WC (and NC?) could be problematic, and must >> forbid it, if that is the case. There are cases where we could otherwise >> cause harm (bring down the host?). We must keep mapping the memory as >> DEVICE_nGnRE when in doubt. > > Yes, there is an unspecific fear that on ARM platforms using NORMAL_NC > in the wrong way can trigger a catastrophic error and kill the > host. There is no way to know if the platform has this bug, so the > agreement was to be conservative and only allow it for vfio-pci, based > on some specific details of how PCI has to be implemented and ARM > guidance on PCI integration.. > >> Now, what the new mmap() flag does is tell the world "using the wrong >> mapping type cannot bring down the host", and KVM uses that to use a >> different mapping type (NC) in stage-1 as setup by vfio in the user space >> page tables. > > The inverse meaning, we assume VMAs with the flag can bring down the > host, but yes. Got it, will have a closer look at the patch soon. > >> I was trying to find ways of avoiding a mmap() flag and was hoping that we >> could just use a PTE bit that does not have semantics in VM_PFNMAP mappings. >> Unfortunately, arm64 does not support uffd-wp, which I had in mind, so it's >> not that easy. > > Seems like a waste of a valuable PTE bit to me. It would rather have been "it's already unused there, so let's reuse it". But there was no such low-hanging gruit. > >> Further, I was wondering if there would be a way to let DPDK similarly >> benefit, because it looks like we are happily ignoring that (I was told they >> apply some hacks to work around that). > > dpdk doesn't need the VMA bit, we know how to solve it with vfio > ioctls, it is very straightforward. dpdk just does a ioctl & mmap and > VFIO will create a vma with pgprote_writecombine(). Completely > trivial, the only nasty bit is fitting this into the VFIO uAPI. That's what I thought. > >> (a) User space tells VFIO which parts of a BAR it would like to have mapped >> differently. For QEMU, this would mean, requesting a NC mapping for the >> whole BAR. For DPDK, it could mean requesting different types for parts of a >> BAR. > > We don't want to have have the memory mapped as NC in qemu. As I said > above if it is mapped NC then writel() doesn't work. We can't have > conflicting mappings that go toward NC when the right answer is > DEVICE. I was wondering who would trigger that, but as I read below it could be MMIO emulation. > > writel() on NC will malfunction. > > __iowrite64_copy() on DEVICE will be functionally correct but slower. > > The S2 mapping that KVM creates is special because it doesn't actually > map it once the VM kernel gets started. The VM kernel always supplies > a S1 table that sets the correct type. > > So if qemu has DEVICE, the S2 has NC and the VM's S1 has DEVICE then > the mapping is realiably made to be DEVICE. The hidden S2 doesn't > cause a problem. > >> That would mean, that we would map NC already in QEMU. I wonder if that >> could be a problem with read speculation, even if QEMU never really accesses >> that mmap'ed region. > > Also correct. > > Further, qemu may need to do emulation for MMIO in various cases and > the qemu logic for this requires a DEVICE mapping or the emulation > will malfunction. > > Using NC in qemu is off the table. Good, thanks for the details, all makes sense to me. -- Cheers, David / dhildenb