Message ID | 20240826204353.2228736-11-peterx@redhat.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 C1AECC5321D for <linux-mm@archiver.kernel.org>; Mon, 26 Aug 2024 20:44:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ACC696B009F; Mon, 26 Aug 2024 16:44:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A60336B00A1; Mon, 26 Aug 2024 16:44:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7E0EE6B00A0; Mon, 26 Aug 2024 16:44:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 58F006B009E for <linux-mm@kvack.org>; Mon, 26 Aug 2024 16:44:21 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 09041121396 for <linux-mm@kvack.org>; Mon, 26 Aug 2024 20:44:21 +0000 (UTC) X-FDA: 82495574322.21.E2D831C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf23.hostedemail.com (Postfix) with ESMTP id E4AC0140008 for <linux-mm@kvack.org>; Mon, 26 Aug 2024 20:44:18 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=I8EyohvP; spf=pass (imf23.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@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=1724704972; 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=RcTv8PG6WUMces5zPq/dQ8qXZuImd+6bX+nNmvbIpbY=; b=O7UlkbYOy2rcHisnn+6+dOHCHPXQKvnOvtkFuADH8WL6Gz2uVvaF6THtFa+ucQMBClNIdU m29gz/b/Z60Cetkx8nQhMiUHavXoi9FIytOcv3muaTO/gNp/nM2UtNlL2kHumarBDAa7Ty Hu4BSFsaL9Sy7Pa1Ww3oD2gujw8SREg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724704972; a=rsa-sha256; cv=none; b=Rgtfi8QVwzm+oJI+Npr44xhbSYDeMfDaUhnVWyarHXhLLlgw4jLA0QR+X/ehXFsW2LawhO yySZKGqyvLDHmRUDAaCNdIK7RQ27woYafe/x4waBVjrJNFCrKdoKXlzEaE0MYF+TBOhTLv ktHbhhCbRof9My6DVjTzIWW9abZznQk= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=I8EyohvP; spf=pass (imf23.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@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=1724705058; 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=RcTv8PG6WUMces5zPq/dQ8qXZuImd+6bX+nNmvbIpbY=; b=I8EyohvPdwcIg3kArl1LTRYt9zwIvuGxiAQJP+1J0tgK5vMuVxP4bpdqVL8va3o2o/ybJr uVSc2joH5AWRJRW/AKI6SbWnIUxWE3K1m4W7N5TMW4QVCBLi7/bGthYrzVd598iQdt38KB pX3PDZzAhNdgf35Cvnhvlag7IGnnfBI= Received: from mail-yw1-f199.google.com (mail-yw1-f199.google.com [209.85.128.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-54-gM-UhamaMICb4kv_IvaKQA-1; Mon, 26 Aug 2024 16:44:17 -0400 X-MC-Unique: gM-UhamaMICb4kv_IvaKQA-1 Received: by mail-yw1-f199.google.com with SMTP id 00721157ae682-6b41e02c293so94041157b3.0 for <linux-mm@kvack.org>; Mon, 26 Aug 2024 13:44:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724705056; x=1725309856; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RcTv8PG6WUMces5zPq/dQ8qXZuImd+6bX+nNmvbIpbY=; b=k7mQc59uUjNuYUhVHjUid35gkQng1YaMq3u0+LdNO4gZeH5c9pU6rNvyoNCDwoYmOr E1MrJ7N1cfldpkZiGaakBPU7Zk4Th8urLe10Kij+ll45qnMKXB/CaiAYI3GuotJlgs8W yMx9K/2ilh5NCopo0Ym633g9bvEc0+Sz3ZaMOVniFZeo3Zoc5pibZVE8EYSJUvVr/tk1 FjDnPAx1iYlJcOMQKnmG/Obmbe9tgo78ZVAu0NEBNBYLnyOGQMpt4tEE5sOO7KYzGgBl pBVNy3LSGV7hIugYWWRkOJpeOAsMqqotYwUrcz+tgkXzUy7OOXDHGXz/OhpIv48lGDtv 80og== X-Forwarded-Encrypted: i=1; AJvYcCUKIV/s0S/VMywJcSIJ1BmMCk379zUY17Ng2LNiTgiHe8hY+EJMyN60LpCgl7suvR+s1LbFDknzqQ==@kvack.org X-Gm-Message-State: AOJu0YxbdwvE0NYeachgx1pEhL429PudXGYbbLt9FccEzeb2+/BE6gM7 7rQvHb3tiniCm6aq2eWEYwt9jcAMPtuPeoIgd06kRrsiSZRBzJxynC9JhSmcmidg1u7JqT+eL1H OkRINaukr9petJXGMdtOmz7CUeo+ioKq9p/64YB5U3M7t4iad X-Received: by 2002:a05:690c:4246:b0:6b2:4154:e598 with SMTP id 00721157ae682-6c6262f43e4mr113946257b3.26.1724705056533; Mon, 26 Aug 2024 13:44:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGCZvjuJnmUbtCZKJF68AHOtk4V9xJHAv9nFBXLLIOg3bv7tZNlMwBWnRJYIMuW8OX1o2s1rQ== X-Received: by 2002:a05:690c:4246:b0:6b2:4154:e598 with SMTP id 00721157ae682-6c6262f43e4mr113946177b3.26.1724705056224; Mon, 26 Aug 2024 13:44:16 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a67f3fd6c1sm491055185a.121.2024.08.26.13.44.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2024 13:44:15 -0700 (PDT) From: Peter Xu <peterx@redhat.com> To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Gavin Shan <gshan@redhat.com>, Catalin Marinas <catalin.marinas@arm.com>, x86@kernel.org, Ingo Molnar <mingo@redhat.com>, Andrew Morton <akpm@linux-foundation.org>, Paolo Bonzini <pbonzini@redhat.com>, Dave Hansen <dave.hansen@linux.intel.com>, Thomas Gleixner <tglx@linutronix.de>, Alistair Popple <apopple@nvidia.com>, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Sean Christopherson <seanjc@google.com>, peterx@redhat.com, Oscar Salvador <osalvador@suse.de>, Jason Gunthorpe <jgg@nvidia.com>, Borislav Petkov <bp@alien8.de>, Zi Yan <ziy@nvidia.com>, Axel Rasmussen <axelrasmussen@google.com>, David Hildenbrand <david@redhat.com>, Yan Zhao <yan.y.zhao@intel.com>, Will Deacon <will@kernel.org>, Kefeng Wang <wangkefeng.wang@huawei.com>, Alex Williamson <alex.williamson@redhat.com> Subject: [PATCH v2 10/19] KVM: Use follow_pfnmap API Date: Mon, 26 Aug 2024 16:43:44 -0400 Message-ID: <20240826204353.2228736-11-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240826204353.2228736-1-peterx@redhat.com> References: <20240826204353.2228736-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Stat-Signature: r7i4qitkutw78q1bpbikja9uyc3g8yfm X-Rspamd-Queue-Id: E4AC0140008 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1724705058-975170 X-HE-Meta: U2FsdGVkX1/rdOKzr2iiVSOWneSbLZzyIELAuqndDNBWQrQFKIN2gq/g+lcdE8F3UjZuJdDUowLGoaUr1g09qut+Rv5Jdng+c3AFQpmqax7CcgN0BTWMQzZ1XXjr1E448lkq6q7vMyIT0RrKJNIudwaWJFqyGqsH0TUNPmrkc3LfUCGYJCU3/CyJVo9dCfMMp6tH6WrwWxWQm/ypmj/ywWVZ0quIghVnTYxLNARO6K8JHCnA9Jz0411u5++S9rXkqDEHVmqGf5sUoKs3EusMl1KRbtBR0kb06Sc2LuVwShudSK9rdyrtLX5S554zxSRosl6QfwUKa0oJOSJ9TpPLdBMTDqIWpP6vwjH35SAka5ZOhLosduN1Srp2YlTPDQWtDpKdnmM7T+cyd1NckzxIgRP4MH6FwSirDf/xSy/v/dd9N7YCddkAYWyd2Ix8uP2yZfgruuJDX1uYwccpYMFV/dJoV8c2pKy4kLdAjn+xAlg2UoeA6VTmsm5WAuCC6jfi0xNuVZ0LHoRoc6kj1p8IvXsj3NczOnvbHWtaiPZDGS+bEnps0MSyU66g7T+1M4Ia9+cu5x2bFL0np1qUOCQJ/XNf6VwawcCoeKwXJ5Ak6k6guWt0Lp7YMG/Wmpc6SlJrG5RJlba+mr/7sLjvJtPVk0AsHOAInlYm4j5f9z5zRCofoT3Vv0OYfGGKW0z40rmxr3JZaVGJxbl6gK4rHKAhwEpOUw8d/PN9pYuiA8XzUcdKoeYZUjCx2GBZeRhToNjUTJU27g766j/LgLdLEUdJoReNcUssXhDtVBPN0Pmetqk5BCTpGMjBbZuH+hOvvJWNvYT9vm83qV0OjMlr+miMkmnKhZgQ6xy+wMgWMba9e363kfIFnKUK54fowXiHbH5Tmbsjf+J1gAs1yVX5gONG/tHica5fEXK83l43HpaEj6LQ/RdsHcyucaF7FOjABy/fmyIjqPf0Xfg9JV0lkUC H4Hrl9ad 4Jkf8Rb+8gaOdsA8I/IQdbTPv4IrhlocVexxYVcLwOSu0xMfpWR7+6U9YnkWNQ0hX5YLrOO54PWA2lW1A1lPnFwclYyHTf+PnQoXNfQl8BqTHeM3u9WhZZYC1hFnpzSbQnY7PWtZXztPM2EUeJgOCEOxJhtgNcEKoVZOQ2PCWJQCaGaRx7HDc9eYfM9CuPhF4wRVJVNoP5/tVSjebxBggRMmPUsczrZnYGHl8GmhNeOMmecKiHVSE/vdKtFrH7HXu6x4eRw3n5mYqtylqbU7fHFVO8gI3BWb2JF9xBGShALZ7jKeaf6JaZt5qhh1mrXhB2y8wOBfHSP/YTUgYZPsiFOT9PpQ1wz6avBAbwAcrsMh1YmmUhSP+aSDSBj3ZDXW1NDhyaw9xZpTN9Hq8nNurTII0O1MsghkD9Ngu 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: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
mm: Support huge pfnmaps
|
expand
|
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index cb2b78e92910..f416d5e3f9c0 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2860,13 +2860,11 @@ static int hva_to_pfn_remapped(struct vm_area_struct *vma, unsigned long addr, bool write_fault, bool *writable, kvm_pfn_t *p_pfn) { + struct follow_pfnmap_args args = { .vma = vma, .address = addr }; kvm_pfn_t pfn; - pte_t *ptep; - pte_t pte; - spinlock_t *ptl; int r; - r = follow_pte(vma, addr, &ptep, &ptl); + r = follow_pfnmap_start(&args); if (r) { /* * get_user_pages fails for VM_IO and VM_PFNMAP vmas and does @@ -2881,21 +2879,19 @@ static int hva_to_pfn_remapped(struct vm_area_struct *vma, if (r) return r; - r = follow_pte(vma, addr, &ptep, &ptl); + r = follow_pfnmap_start(&args); if (r) return r; } - pte = ptep_get(ptep); - - if (write_fault && !pte_write(pte)) { + if (write_fault && !args.writable) { pfn = KVM_PFN_ERR_RO_FAULT; goto out; } if (writable) - *writable = pte_write(pte); - pfn = pte_pfn(pte); + *writable = args.writable; + pfn = args.pfn; /* * Get a reference here because callers of *hva_to_pfn* and @@ -2916,9 +2912,8 @@ static int hva_to_pfn_remapped(struct vm_area_struct *vma, */ if (!kvm_try_get_pfn(pfn)) r = -EFAULT; - out: - pte_unmap_unlock(ptep, ptl); + follow_pfnmap_end(&args); *p_pfn = pfn; return r;
Use the new pfnmap API to allow huge MMIO mappings for VMs. The rest work is done perfectly on the other side (host_pfn_mapping_level()). Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Sean Christopherson <seanjc@google.com> Signed-off-by: Peter Xu <peterx@redhat.com> --- virt/kvm/kvm_main.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-)