From patchwork Mon Aug 26 20:43:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13778406 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 27216C5472E for ; Mon, 26 Aug 2024 20:44:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AA5396B00A2; Mon, 26 Aug 2024 16:44:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9DE346B00A3; Mon, 26 Aug 2024 16:44:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 830026B00A4; Mon, 26 Aug 2024 16:44:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 63BAE6B00A2 for ; Mon, 26 Aug 2024 16:44:25 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 2C2C01C5063 for ; Mon, 26 Aug 2024 20:44:25 +0000 (UTC) X-FDA: 82495574490.27.8847D14 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf11.hostedemail.com (Postfix) with ESMTP id 18F184001E for ; Mon, 26 Aug 2024 20:44:22 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=U3Hm2rYD; spf=pass (imf11.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.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=1724704976; 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=moprxbUn5M7+L+63SZwwyqeq4iL0OHeeIJZbsfnkOho=; b=jKOUtB676QmPGwuQnBANOow534L0GStwa73a9J1u9INrz5+jCF11Lj2U7J/YhTRmtnTWxK r1DEFoVPsTdQ1WV38cDyM4H3FcgcZb5f5W08d3p+55Dfs6D/tPuNE8kVhuuG65VDtQlhHl 7Ehoh5yvxrYFbnt4cU+pXuP++EvMGwU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724704976; a=rsa-sha256; cv=none; b=m2UEfHBYax/3wfbkKLRCUg5BFucqmQcRxvz4yzUPBMJyFm5GTmT7a7pP+a9OsIb+GtXsLP IULeLmFpMK7sgE3ZeSbU2LEJu3SOGcRn62aqdb1LtEyK75YaIUufGvZfeFZwjjMVXj4xrH +lwNeelnPi4Z7ZuQRNawIo6DLp35S0A= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=U3Hm2rYD; spf=pass (imf11.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.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=1724705062; 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=moprxbUn5M7+L+63SZwwyqeq4iL0OHeeIJZbsfnkOho=; b=U3Hm2rYD+TDFjedSX/ywSr3TBwLzavI/njXNAx2PRr3kBvrgbXYEsimWA9V8GdFgkvgTqI QHFkl3NbnN/CADQ7NIKFB44/ot9+5/3OCazsr0aRTnROLZGe27rIkiOclJhDj6D96tU5e8 e6H2RLrc9sAJ0WTxvRViRz8JODo/Ed4= 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-597-PfjDT15aMICk5SKflzJl0g-1; Mon, 26 Aug 2024 16:44:21 -0400 X-MC-Unique: PfjDT15aMICk5SKflzJl0g-1 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-7a1d4335cceso884881285a.1 for ; Mon, 26 Aug 2024 13:44:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724705061; x=1725309861; 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=moprxbUn5M7+L+63SZwwyqeq4iL0OHeeIJZbsfnkOho=; b=MAj5iEtT3iTFw1ROSX/i4IG90VkfshCtre5HJZYXHY9HOoHHi/KOTiis2jQnk1CqqG dZE7vx/wDSmDcL2e73lVfJPm/G7hmrBp05XmitZwHEL+hzTv6xut8zUS572SYFnyfE5c 1dCUd2TcPTDEdcyOxP7Mj0OKFdgrCK7o+gJhU9k0VtNVZme+g2W8U46WbzaLIahMN3Co 01WTsRlCiTuMBpVKcfm742xQtzuQFUIGW3BeSv+3DW7R/7PoCtNEfgmkQZoUy2n1u1tO cdMxgEfCs+AnVF+ODfZxFFADmZJDT0/aVVLhZXh6cQtx5IlSDf1khjZsGH7qGaZDMAGf iGpQ== X-Forwarded-Encrypted: i=1; AJvYcCWmsHmWu2hjbDJ1udz72lmX3x4K6hfq14k4ienRUeSjW5ZZkSsxjesw2DTTA35tNNE0gv0JDJBBjw==@kvack.org X-Gm-Message-State: AOJu0YzBdr1KwoEOEEYvdF93lQkPXjuGnVy7qZUyb2OsAvLyFhZMDSiW LeUVN3zq7RcTAO7M2l2mnsVx6DSUvfhvDqQiXzFeCKnK6LirdKTZjOVJ1iQXcJFKcMS1lVr5011 dxdeSk91hJ+RzD3s4RQRnOlS2sLNpzCwdviN2/Uvt8hTI3BI5 X-Received: by 2002:a05:620a:1a92:b0:7a1:e341:d543 with SMTP id af79cd13be357-7a7e4cf3a3fmr158797585a.28.1724705060674; Mon, 26 Aug 2024 13:44:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF8L+Naz3FkxDynSQ3yMse2qHglqFkf4LqBPi/5cD3sQEuFfYs6yWPMbT2Qk9XtpK98A+7trg== X-Received: by 2002:a05:620a:1a92:b0:7a1:e341:d543 with SMTP id af79cd13be357-7a7e4cf3a3fmr158793685a.28.1724705060390; Mon, 26 Aug 2024 13:44:20 -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.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2024 13:44:19 -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 12/19] mm/x86/pat: Use the new follow_pfnmap API Date: Mon, 26 Aug 2024 16:43:46 -0400 Message-ID: <20240826204353.2228736-13-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-Stat-Signature: ehhem9k5d9h5t9yzo63i8b37nrsamimz X-Rspamd-Queue-Id: 18F184001E X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1724705062-887955 X-HE-Meta: U2FsdGVkX1+c0eoaRGKfPKOeV75IY2er5X0tx79cQnUiNeUlB7D4EYa9v3Mx+PSWK1CUaII4X0dCimT4nQ7Tj8kwApseEXM3/iUwv3lmeNjJfQ9snynRD7HcvT6ieEPamrP42c0mcDJAiB09g1n3ygWIHIdhu+GKcJsrXTKKbVkqNJfQg43/8R7Y4Z07daki2VrGwClQYadJ3W1MQbv2tR1Y1ZXfe1d7h8uUmoid57tAEKW16ibab6fFnLoIPoQrmxQtiSjwiTFWCnSemO+yrUQY5HEhtfl7tkfg79oJzyMA+On0S5zZIWp1NYfTg+BecBKo3qNxnaArA33cWt3tIL/I8fJiJucWN2gyz8AL53bRlaPBAwQ2f+GL9Z8fcAG+dtA1d5kMkkXz9TsklC6tPAHwejhfAyhN19d6Vu8s4p85XtYnFVLmKlDjrvFhrhLetWEhS69myR6pNMKsniCNH9J2UjDcrtdEYm3B4+4CeqfupaSvrZJFN2qz4QLTEXb/4xxHX5Ltv9dMb6/tbiVD72L4kPNrhw88X7Co1hmlCyiC+2aqspazdJvLY6WF7mU2cIS0dGmIEoz9Z4AcZ3mFqdnBi/WEIX0gLoYbPznGqicFpUrkbnPlipPHJuyfDuKH2NfHAOySy02mAWrkygTqZa4INCqMlSgzsWP8C8SKDbL/QL2GnTPlTt626rUlmEeHaxQnJrR0zdI7vcaHWDTRH0y/27FoaXekxs6h84whNtjTdK53Q5lxdSVOLPmQCBTtoIHSED7Or6HOzEImHWY7nBuO10MwaVuYjySaToHsyUt6DFbzk5zyUYNeh0ra7p9xs43c4vK1CoDU5neQJhNUqLJOTe7AS/5BMS7v1ZSQdoyv5KgmKAQkM3OrVJXuqSJfwcA5+91p7cXDh9IL1qOMwgZkw3lnLeBaufyHMx2ObJybKlT8jkB5cmiNHmImSpEJpKWShEm99Wb6zx4TVBO +vmNek00 YRIzxwxKjrjQNV1ZlAPfqfiaMKJ5skrKs3wQQ10qR9M+grRbeebVxNFeRdRHmfFLX/stbbD3+H3c51i7rSLaaImd6hAR33X2YqnS/9jS9oKz6x9D6J7JS04wE201Z4WhQPm1qLL5GSppnzp/zBxQ/HaYFpjT/WMYsY00v3YJ+zKnksOrgTcq5OAJfn3tAdTdmINcg8zrMuDItR+949RIjk3HuhwrKKGPXlT+/e0huTHUPGMcpqLWA6YkbKx4XscuzJwIkxiro3Yal6N38xN2Nv6HX9ByH5+aVi96hld4Ergx+q960pRXWT86AYWNhzyE4O6yTwK9Uy078FLG34+U6xWD+EaOel7avbo6eU4g8AbODxrLIiBqPDyLbx98rWrvbu+tSuPlcC33hk5RUV7Y4EDyLa7cdjPKUM5jtr8e0d8P24VRZJ+JupHAbM24JfuJ/ckAjh4io7g01BqFGUaLsaoigbPPWcdMkHmnI3o/lYV/Fa5MJub4jbFB7zkyBXRoMDELn6wesmGumT9vD02an41b6tHhZ97eQyWEjdKTNkajYSG8ecEQzOONGLMmEQ308GLptiiY60PlA4oz0yFHx9HkptA== 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. Cc: x86@kernel.org Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Dave Hansen Signed-off-by: Peter Xu --- arch/x86/mm/pat/memtype.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/arch/x86/mm/pat/memtype.c b/arch/x86/mm/pat/memtype.c index 1fa0bf6ed295..f73b5ce270b3 100644 --- a/arch/x86/mm/pat/memtype.c +++ b/arch/x86/mm/pat/memtype.c @@ -951,23 +951,20 @@ static void free_pfn_range(u64 paddr, unsigned long size) static int follow_phys(struct vm_area_struct *vma, unsigned long *prot, resource_size_t *phys) { - pte_t *ptep, pte; - spinlock_t *ptl; + struct follow_pfnmap_args args = { .vma = vma, .address = vma->vm_start }; - if (follow_pte(vma, vma->vm_start, &ptep, &ptl)) + if (follow_pfnmap_start(&args)) return -EINVAL; - pte = ptep_get(ptep); - /* Never return PFNs of anon folios in COW mappings. */ - if (vm_normal_folio(vma, vma->vm_start, pte)) { - pte_unmap_unlock(ptep, ptl); + if (!args.special) { + follow_pfnmap_end(&args); return -EINVAL; } - *prot = pgprot_val(pte_pgprot(pte)); - *phys = (resource_size_t)pte_pfn(pte) << PAGE_SHIFT; - pte_unmap_unlock(ptep, ptl); + *prot = pgprot_val(args.pgprot); + *phys = (resource_size_t)args.pfn << PAGE_SHIFT; + follow_pfnmap_end(&args); return 0; }