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: 13778451 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 79587C5321D for ; Mon, 26 Aug 2024 20:56:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=d0kI5he4gLOJUpsF87CpEeiS1FOCa69CaYI81su9df0=; b=nf45MNTlBbWJt6TRzfjfErGky+ U56J67jHikL5JaKGyOnSaXPt8J784uWdMFyTpmDc5RnBOz+3gpa2xCLvnVLe5c0n0bBofR5sqS5fx lFbvtRQJXOAkK4wgCzs5b3VrJcaO2utd7QW1VtdtcNigISTzsuu/3HL3T33IdQ8I/8EaCpordpaZs D/MY22pns2r7NbXZP0UfiCSTM1ApG2WH4MZazY/Mzau3NYaDptXZAmbIQRzfCngRmRJhZeCIarhkZ pBHmYCp/RDwxQt+QgycrpZLAx0fWCGlTf0Q1Z/TMKo+y35GbHOs8p/C2f0U/kfru77ukyeJ8/y7wA BNFY4b8g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sigkz-00000008i2x-3OAi; Mon, 26 Aug 2024 20:56:09 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sigZf-00000008eaI-0DTf for linux-arm-kernel@lists.infradead.org; Mon, 26 Aug 2024 20:44:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724705066; 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=TlIhbTc1ZhoKtSipLHoNMaY3r6WAyvfQrLyXrWCZMyjW0PuyK76PazUM0aXMsUUNgUt/aV Vwfew9Y/My5oOmRSoXxa4ksZp7QN1OQzmPovdvWOemzLE2upwV8v2SNke4ZWaIwxOQMWxP 5xDmbeWlYxfuOH4PGnj54jGqTAzVkvY= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-331-IQvGC-OoOZehu6XeuruFUw-1; Mon, 26 Aug 2024 16:44:25 -0400 X-MC-Unique: IQvGC-OoOZehu6XeuruFUw-1 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-7a1de8a2adbso643993385a.1 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=QhRCbHvwyrf7TZiWh+BECytsT9Y0kjv4T/yiDafZp9RE7JyDWMXt8tcFIec9poS82C xMK9RtGD9IHZMnEXI7RLcSAKJot5m9I4RqizDepI1V2QoUvRfIPjehb1wLTJ9TwXlf96 TwqI77SQUET0kvhRNq2bPj107NHZ1FYfwp6DdMPcPy+9xNUy6mi5Qb7n1jNsbmi5HlaB VAO5YSDzGTl/x15erk1r9LCNQans7v4DZuuPalXdJc7DGSJzdqXBeHEeQmtroYtvr8Yv mjEP/RO4U3Wey+sD5F9LTkEK5RTMasj9xJUuOYLSrUelgBLoZCyZC+c4OPgTG2vLcH8a kGwQ== X-Forwarded-Encrypted: i=1; AJvYcCWCGfxv8j9ZXG6b1NBx4Ls5Cf9wgTO5vy9oDLKlFlzVxQTuzJUzaUvjjARwjDs+zIfu2cEedKvu4B3Xyovd8vYu@lists.infradead.org X-Gm-Message-State: AOJu0Yx+H+lSKcdM4dd60vjuGITsam9jcAUEaTWeWTyIkGT5N5kQ1wZ3 /oOtq82tgAefv6tDq9Ijyzq+QYp+JigMAWICdUwdpXlwth9/b3kD2r8iisjzcglB5DFslhh4mqX 4cafRMhZAelYVxr+ns7YR7uI/vuAQLlce+K7cknzSo7ot36IcgPGxlIGNIK28vrY8ReQYf/OP X-Received: by 2002:a05:620a:2484:b0:79e:ff41:fd47 with SMTP id af79cd13be357-7a7e4dc9528mr93288485a.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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240826_134427_188292_D24E82A6 X-CRM114-Status: GOOD ( 14.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 &&