From patchwork Mon Aug 26 20:43:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13778409 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 8A737C5321D for ; Mon, 26 Aug 2024 20:44:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5C49F6B00A7; Mon, 26 Aug 2024 16:44:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 549636B00A8; Mon, 26 Aug 2024 16:44:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3C4D36B00A9; Mon, 26 Aug 2024 16:44:32 -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 1B4026B00A7 for ; Mon, 26 Aug 2024 16:44:32 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id C9055C1358 for ; Mon, 26 Aug 2024 20:44:31 +0000 (UTC) X-FDA: 82495574742.17.19DF950 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf26.hostedemail.com (Postfix) with ESMTP id B2EE714000B for ; Mon, 26 Aug 2024 20:44:29 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hXCemyk1; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf26.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724705006; a=rsa-sha256; cv=none; b=FiXVwkVsulABrJe9PlgcB1MpEZw0iLDCtfJyIdCJuKYuML8r0pzy7GShVSHNUAvskmpLgx QBmizZJ68d/PKoe+3rN1tiJE6FRnYnsYrHxargTBOv7hl2rSFI1M+95rzFySi8NG8EzxBB huE/sXpS/+WhlI2+nzokZfBLq4ktl5o= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hXCemyk1; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf26.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724705006; 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=d0kI5he4gLOJUpsF87CpEeiS1FOCa69CaYI81su9df0=; b=rCH+TOmWjwVpZypnkhwuBUdq/dRh92DUalWR8DWpssZy0jcAWe3B4GD/b918lLVTxT0cG8 VAGvtywPM0JTYfBlY3Ciws3eK2v9hfOSFlLhBhBELCGY+1EDHCx3kH9i7gdldn4pIHyF3b bSgMmtOQXOiw1R4VzJeZaKdCXB6k2RU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724705069; 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=d0kI5he4gLOJUpsF87CpEeiS1FOCa69CaYI81su9df0=; b=hXCemyk1jGznDibqf6fEE5WhXyLIPBzuQamm+d+2ykB5JBeYWgIzTcqDb3btvIJ1pHbUSZ glzqM8n/lPORLYONupETHtQdYEZsoQbly4/wGB+e5NkbvFrQiSwH8ddIDHRtrQd0AbaCGF daz4+Qj1i3AGYcmkc4qpjLJ7MVKwPis= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-343-LU42H9xCMjKfUaqc1KxNAg-1; Mon, 26 Aug 2024 16:44:26 -0400 X-MC-Unique: LU42H9xCMjKfUaqc1KxNAg-1 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-7a66c19d33fso676638685a.0 for ; Mon, 26 Aug 2024 13:44:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724705064; x=1725309864; 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=d0kI5he4gLOJUpsF87CpEeiS1FOCa69CaYI81su9df0=; b=JAazJMgIQb8VuEE3AshEAKQYYMWZDgufWsrBrl1lOkblP1CWBsV32/E5WRvfkjqp8v uSjLD7poFSMuJ8y+JQL6iXMmCuT/n6i6MnjlmotgtAxLez9zKX0uDfQXLoyUb89q/cuD thR8zEVNJ0aWx/UlKkJLzNlCFAnIH4bT5oX6eSMkTY7N9XrtGqn2vwdV/t6BzI2e1LdB Tzi7x6zZdUyrm/lRf2eSaFy6WAQMKV9WzJCZ01w24Jt9phzXFHf5gr/3mgPYRtO+PnjS n9bJ9LNNmT9cNPTXKCBYUVaFXELd+S9PC/5/BkU8NMa055/7FhAAEw53WaDQC7edGVIx ocug== X-Forwarded-Encrypted: i=1; AJvYcCXJL+IxFKwXRRfAOJUWTGKgJm+i9bklzomzwu/jTRmUu2CCFVe3HOjBBs+R+ht8Xa9y+JYsWWIykw==@kvack.org X-Gm-Message-State: AOJu0YyjHw8onzctyydg1GFEYhlsw/QBFbhM9w3D+Yg9El84c6UfT5HR BnClCvPQ4lAFiLZC1E+gYEin0JYG7foGZDi2Kyig2hFM9qjCcN1LdrabblabbpBoJQc4KAkxCiI Abpo/9A8bdLgozmTN1fis+ZLD6qJw3q1MS36d7nKsYEbjwkvYPWwye0cG X-Received: by 2002:a05:620a:2484:b0:79e:ff41:fd47 with SMTP id af79cd13be357-7a7e4dc9528mr93288585a.28.1724705064650; Mon, 26 Aug 2024 13:44:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEloa5qz2QVMofE8PCWJJ6gTfdMgC7cjn+h2anZ9qsldjcOaIzzaCXqVOAeeqkMcyU6B13FuA== X-Received: by 2002:a05:620a:2484:b0:79e:ff41:fd47 with SMTP id af79cd13be357-7a7e4dc9528mr93286485a.28.1724705064315; Mon, 26 Aug 2024 13:44:24 -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.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2024 13:44:23 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Gavin Shan , Catalin Marinas , x86@kernel.org, Ingo Molnar , Andrew Morton , Paolo Bonzini , Dave Hansen , Thomas Gleixner , Alistair Popple , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Sean Christopherson , peterx@redhat.com, Oscar Salvador , Jason Gunthorpe , Borislav Petkov , Zi Yan , Axel Rasmussen , David Hildenbrand , Yan Zhao , Will Deacon , Kefeng Wang , Alex Williamson Subject: [PATCH v2 14/19] acrn: Use the new follow_pfnmap API Date: Mon, 26 Aug 2024 16:43:48 -0400 Message-ID: <20240826204353.2228736-15-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 X-Rspamd-Queue-Id: B2EE714000B X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: xjjfe84sqoqkt8d5zgmuwgrsbc58y1h6 X-HE-Tag: 1724705069-842489 X-HE-Meta: U2FsdGVkX19BWuR8m/xxxzM+00UrP0GGDizAoK0+3BwYyHukyl+DtckAr//+wGWuwyHtQHl6zWYE46diE9aFFebYYCIQvFGUPJCG5V+aaGP0QYxzg3Lklv8YHw4S2cOB3Ebk+ogIDbE8kcEDWGYIzriVHcKhDFYUmKSgce5nrNZ7E3k1pJEonTUEkE1p6mqQ+XfMSHZ4UGQtSLrKHCCs6dSns9DRmoFjstuHefPaHnBWdcCPnOCbzP/qI2IgVDU9eyue2H7xZsDbAGTf6SUHaLCIMQxV3s0PxbCM0jqgj5lS98CcAEalp6cXlT6aeruOSQWeh16veW350PoxIrxiN/cBu6zIwY5lqgNo7GJxMYhlZdZ420LRwVZpWCfTptX8NkphfIkQwFWqN2MsA8cNZQKusL39CVrXfiXectbDUDhw34DDbT+0c9lfRHH/kH7FRjGvFw/2fG1KKaWKHt/Fv1arXeaeSrGEEzzd10lTcgGSiQv1rTQ1lqu/YcfNz1AVF/jn8OEt86dSKPK0HUzfd370AYLXzjzdvC8pEj+yEKje2Qcp8D7A4ketmYMLJszfmj5XDRS6WoU0VGHfXJzRX1OIhFbLZKI14/CYSTevJ1m1b5fpL6zppWDAsiqCO63miWD43KSiibXm6OFF4INCEDiqeyJycMmu1A4Dpraen6rh5bOrZWjD5dMgMw00O2+/jV0hRMVXPliLjSkR4pBvcjPGF9rIIsvcQtZfPGbicZntnGN+K6OUH+b+uCHPPzPR8jPpHR9piYv538bAJCJLIWSFwsXryFOQmDQKZY3M0Gwkacqcty/9DPinTUgqQRanT/D36y8F27OYQxhRUozE1ifpeHsfHYzIbzmEQveCjIkTD+zI04IrbAe3l2ERZThv6H65OKLqgMNl2rSUFKZV9kC4QfAdghtUHx+IxRKEI5JhuMKik6jiOfpS1PWq9gfPkLi1e9xecleOE2P2qoD DdICrl5N 9j/uYxivykq856fyCO1qxHabcsShfjBfcRNVNVpA1WB+nINAWWAK+PsfM8ukbPYU5+i9LLKagOeBrWkNLWghL3MABg2eaoHe1xIM9mMnhvocpTq/5Mt4rO79ujFaoNwd0L7VhvgnhapCreEn2sEgjptDENrmrB5n53mWOycZ9t0BiG340WkZ2DCUIWDf3JY6HFd9KzW3xviWIJ1xfwPfA10+0P3x0HO7rnzbeKGlw0diPXuZiyJ5GNvmhAooFpZu2mc1WAQCukWoH2VfWmKuv0/MOhcOzsFpFvhRS0GgqrRzr9AeCcjlwbWNLoCeU2j5uIC5o5IGWgg2aQA71j3CMhsWD+g== 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: Use the new API that can understand huge pfn mappings. Signed-off-by: Peter Xu --- drivers/virt/acrn/mm.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/virt/acrn/mm.c b/drivers/virt/acrn/mm.c index db8ff1d0ac23..4c2f28715b70 100644 --- a/drivers/virt/acrn/mm.c +++ b/drivers/virt/acrn/mm.c @@ -177,9 +177,7 @@ int acrn_vm_ram_map(struct acrn_vm *vm, struct acrn_vm_memmap *memmap) vma = vma_lookup(current->mm, memmap->vma_base); if (vma && ((vma->vm_flags & VM_PFNMAP) != 0)) { unsigned long start_pfn, cur_pfn; - spinlock_t *ptl; bool writable; - pte_t *ptep; if ((memmap->vma_base + memmap->len) > vma->vm_end) { mmap_read_unlock(current->mm); @@ -187,16 +185,20 @@ int acrn_vm_ram_map(struct acrn_vm *vm, struct acrn_vm_memmap *memmap) } for (i = 0; i < nr_pages; i++) { - ret = follow_pte(vma, memmap->vma_base + i * PAGE_SIZE, - &ptep, &ptl); + struct follow_pfnmap_args args = { + .vma = vma, + .address = memmap->vma_base + i * PAGE_SIZE, + }; + + ret = follow_pfnmap_start(&args); if (ret) break; - cur_pfn = pte_pfn(ptep_get(ptep)); + cur_pfn = args.pfn; if (i == 0) start_pfn = cur_pfn; - writable = !!pte_write(ptep_get(ptep)); - pte_unmap_unlock(ptep, ptl); + writable = args.writable; + follow_pfnmap_end(&args); /* Disallow write access if the PTE is not writable. */ if (!writable &&