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 1FF5AEB64DC for ; Mon, 17 Jul 2023 18:35:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5E15F8D0001; Mon, 17 Jul 2023 14:35:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 591746B0074; Mon, 17 Jul 2023 14:35:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 431C28D0001; Mon, 17 Jul 2023 14:35:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 33ED96B0072 for ; Mon, 17 Jul 2023 14:35:35 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id E9EFBA04EB for ; Mon, 17 Jul 2023 18:35:34 +0000 (UTC) X-FDA: 81021956988.19.674695E Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf01.hostedemail.com (Postfix) with ESMTP id 099A94000D for ; Mon, 17 Jul 2023 18:35:29 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=EaKmfr+w; spf=pass (imf01.hostedemail.com: domain of alex.williamson@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=alex.williamson@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689618931; 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=X7lLouRsAU88eON8j2CGNjFVozkxl67pRtBcpN+x+9w=; b=aLYyFuz/Npe6o7bmu051xklMNU3+DfiP3gt4GBzWbE362JGyRtu2kSa3o4etFDRq5a7H7G /Tq7psVNAuX2eb+/WOxEjAqY+UUE7lW8Bui81Wu1SHtmVgv3olfi6LtJGYFyQi3pw9B7mc UbmwctsrlFhccaweOrJDaVXWoGzVtb4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689618931; a=rsa-sha256; cv=none; b=Vj0XP416+U3ZKnGMoyWKYjAngusW9o+IGJ/f8mW6AKj9dNXS4Z3y6RGNpIh3Lde5zbqN3K fBxvhGt8bFU1taudelGzsIewyfkRHmXS5ZWkhF7L0E0lb6liHc7z98kf+vB9mj4J4w402X Ifx97HCKWI7u31Mpufpplmo33bTTHTg= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=EaKmfr+w; spf=pass (imf01.hostedemail.com: domain of alex.williamson@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=alex.williamson@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689618929; 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; bh=X7lLouRsAU88eON8j2CGNjFVozkxl67pRtBcpN+x+9w=; b=EaKmfr+wECdfqzT8cI/fW5JnHM/1B2rUEXcUoLGHUJV5pWjacJVbeR1eGu1MK0F4vXTQSi TuBCEPUab5v7g3L82jjKdpefkItmLhv5HjWqdnOXORaIFUThiZSTrCjbEwlyVUX0TtL2xJ ckjtib2mMqMPA67SiC8Kza8ja0bL/ds= Received: from mail-il1-f200.google.com (mail-il1-f200.google.com [209.85.166.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-531-nDam9O5oPRysRq80UnJ5sg-1; Mon, 17 Jul 2023 14:35:27 -0400 X-MC-Unique: nDam9O5oPRysRq80UnJ5sg-1 Received: by mail-il1-f200.google.com with SMTP id e9e14a558f8ab-34670b3089dso15702795ab.1 for ; Mon, 17 Jul 2023 11:35:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689618927; x=1692210927; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=X7lLouRsAU88eON8j2CGNjFVozkxl67pRtBcpN+x+9w=; b=kuNiX+9nrIEBXARQEPJKUIiE9CXCiu4U7aFp71s7uf7yDA8BGcTq3f/IlV70Sf+otj nHD/0dviYla1DE3FEn4ZB3S8SR+bK3l9CcUMiS0ON8zEoLdHNzSEOBT5Wlm6TAPaX4XT f7XrWaGsreuYr9s1alekR1i/xhOhFCRFUdq0rlu0IObcng31RGq7+ldkwtzN7eklvq6e YkmFG+P2Z6jMgBdAzfVUs7c1GXCneXQtar+GQ0T9jbJkCexUYJmgHVBBV1Nr3dP3mvTi xiXgti6U11ijuMF13Ouc60iXRks8SyKZTNb4hMtHo+eYakCnfAN0NzUUW5cl/H0Z4pMj odeQ== X-Gm-Message-State: ABy/qLY5BPBZXt4119Z1llxJsKIUNFVVmN1Vk28oAMtZJqsWDKt+PznX 06ZrAhvcS9+jQfSGlAGKip+NDWRsGoFMlFa/it2keWhHDWOM9A5H1ZG7JTMGGMgxU2oz9mjr6im rsM951SYgvUo= X-Received: by 2002:a05:6e02:156b:b0:345:873d:1102 with SMTP id k11-20020a056e02156b00b00345873d1102mr270372ilu.15.1689618927253; Mon, 17 Jul 2023 11:35:27 -0700 (PDT) X-Google-Smtp-Source: APBJJlGKd0dPxU+CkmAXbq+VKsvbmxGVZ2rrV0eSsjby80iWZntyS3+BBEsMDgTKlmF+oLB55GZOEg== X-Received: by 2002:a05:6e02:156b:b0:345:873d:1102 with SMTP id k11-20020a056e02156b00b00345873d1102mr270353ilu.15.1689618926963; Mon, 17 Jul 2023 11:35:26 -0700 (PDT) Received: from redhat.com ([38.15.36.239]) by smtp.gmail.com with ESMTPSA id j2-20020a02cb02000000b0042acf934cbasm10621jap.72.2023.07.17.11.35.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jul 2023 11:35:26 -0700 (PDT) Date: Mon, 17 Jul 2023 12:35:24 -0600 From: Alex Williamson To: Jason Gunthorpe Cc: Catalin Marinas , Benjamin Herrenschmidt , Marc Zyngier , ankita@nvidia.com, naoya.horiguchi@nec.com, oliver.upton@linux.dev, 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, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, Lorenzo Pieralisi , Clint Sbisa , osamaabb@amazon.com Subject: Re: [PATCH v3 1/6] kvm: determine memory type from VMA Message-ID: <20230717123524.0cefedd0.alex.williamson@redhat.com> In-Reply-To: References: <20230405180134.16932-1-ankita@nvidia.com> <20230405180134.16932-2-ankita@nvidia.com> <86r0spl18x.wl-maz@kernel.org> <67a7374a72053107661ecc2b2f36fdb3ff6cc6ae.camel@kernel.crashing.org> Organization: Red Hat MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Stat-Signature: pxksbbg8zcgmitowkf6rj8yq4psss5wr X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 099A94000D X-Rspam-User: X-HE-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qO2P/MRF29ZEr2c0ESQh5K8EkU1IypZ5bexnU4z2C0Xvkb6EKufH6TUtIZ2xKRfTQ4UUhqqflbZC/qXJ1xXeoYbNAmMm8G6E5DLtnhYJWQbo6R7WnILACiaVn/xXEcyx25IfRxK4Mtw17NwV/iEsibx/3Ov8w7Bl8To2WE45X2mFVpbtv3MKlWePTrKwtNGTG8Syt8KnFk6OZj0YrCXJFHGfCcmvkOMFQjIE0NHuG4g9GUp4bZL7CVhoLU+HI3XWF7xkJhptuBh6/FONMKtzBOwwPkd2vIjkSBJC/z89YAMRE0B2EbgedTiJCf2EEzeEtnVNTEptdUyW0GYbTv4JErYbreYH5owoBVcgRS2eNyEM0= 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: On Sun, 16 Jul 2023 19:30:23 -0300 Jason Gunthorpe wrote: > On Sun, Jul 16, 2023 at 08:09:02AM -0700, Catalin Marinas wrote: > > > In terms of security for arm64 at least, Device vs Normal NC (or nc vs > > wc in Linux terminology) doesn't make much difference with the former > > occasionally being worse. The kernel would probably trust the DPDK code > > if it allows direct device access. > > RDMA and DRM already allow device drivers to map WC to userspace on > demand, we expect the platform to support this. > > > > So the userspace component needs to be responsible for selecting the > > > mapping, the same way using the PCI sysfs resource files today allows > > > to do that by selecting the _wc variant. > > > > I guess the sysfs interface is just trying to work around the VFIO > > limitations. > > I think just nobody has ever asked for VFIO WC support. The main > non-VM user is DPDK and none of the NIC drivers have wanted this (DPDK > applications areis more of throughput than latency focused typically) Yes, QEMU can't know whether the device or driver want a WC BAR mapping, so we've left it for KVM manipulation relative to VM use cases. Nobody has followed through with a complete proposal to enable it otherwise for direct userspace driver access, but I don't think there's opposition to providing such a thing. Thanks, Alex > > > This is particularly suited for the case (which used to exist, I don't > > > know if it still does) where the buffer that wants write combining > > > reside in the same BAR as registers that otherwise don't. > > > > IIUC that's still the case for some devices (I think Jason mentioned > > some Mellanox cards). > > Right, VFIO will have to allow it page-by-page > > > I think this interface would help KVM when we'll need a cacheable > > mapping. For WC, we are ok without any VFIO changes. > > Yes, it may be interesting to map cachable CXL memory as NORMAL_NC > into userspace for similar reasons. > > Jason >