From patchwork Mon Aug 26 20:43:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13778405 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 7D5CAC5321D for ; Mon, 26 Aug 2024 20:44:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 809D86B00A0; Mon, 26 Aug 2024 16:44:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7BB9D6B00A1; Mon, 26 Aug 2024 16:44:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5BE996B00A2; Mon, 26 Aug 2024 16:44:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 3E0076B00A0 for ; Mon, 26 Aug 2024 16:44:24 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 04405413CB for ; Mon, 26 Aug 2024 20:44:23 +0000 (UTC) X-FDA: 82495574448.03.CF9705C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf21.hostedemail.com (Postfix) with ESMTP id E2CCA1C0010 for ; Mon, 26 Aug 2024 20:44:21 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=J8eqF3l5; spf=pass (imf21.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=1724704977; 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=kaY3EfeA+k09YWgS+MfGM8qkjlv58srLyvVau/9jXnU=; b=kdtWdaIbZ20IQKqFWJmr1XtWhvr99W64NEq5SN8fJDDUsJZM4w5I7vugHH4aXgf2T+WNDv jLMJl9qYQqXI+a8oGtCsB1MUSYzEn0Ub2x9PsgILok/KsmMs2QRb+5sYqe8xQzKoBYhjEu G5bZcYwvX5Wk4r2vB7tm4RZv6Thg5ZQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724704977; a=rsa-sha256; cv=none; b=mUIMhYEFA36TcFCXs3X+ooGm7MensiwhGTdNAEqtDSvmz/Ud8YSp2DSIjcsVx8+Dc9k0Zy LmkxTE7vE/9H1t3k+u7NAMYIagMxWJSZVDB9hcjK9OaECVdTOBM30RePlEKDT4SOJQXMX6 xOKljABX1C4Rb13KYuL4XliQ896eX60= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=J8eqF3l5; spf=pass (imf21.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=1724705061; 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=kaY3EfeA+k09YWgS+MfGM8qkjlv58srLyvVau/9jXnU=; b=J8eqF3l5TjJLjwTcZd/Ijl+hgiFskRSTSPxTeafDfoRjyRPTXsvUVxl+mkbsgRCnwTAR57 mOLdcYe3xHhChX/b6Jwv/wU8KEmwnmv1zrAuMEVG06m24BYvoBMZaNOc/dZfbuJ6UBX1Sb YBXUUqstBndX9WmK5YTpOC7tkbWfqXA= Received: from mail-oa1-f70.google.com (mail-oa1-f70.google.com [209.85.160.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-633-z1SjHFiYPkGTUQUinnhufQ-1; Mon, 26 Aug 2024 16:44:20 -0400 X-MC-Unique: z1SjHFiYPkGTUQUinnhufQ-1 Received: by mail-oa1-f70.google.com with SMTP id 586e51a60fabf-26823e7e16eso10890276fac.3 for ; Mon, 26 Aug 2024 13:44:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724705059; x=1725309859; 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=kaY3EfeA+k09YWgS+MfGM8qkjlv58srLyvVau/9jXnU=; b=Qn4SFV+ilkm2VGftTiUECIiaNS8FXmjjbWNf/ldqJxemb9+xmUROWn6b3yAjf+96yX txqbRMtSbE5xszCqjXWwdt+C5X6OAy6W729ujyE+k7jDeYSqsCAs0qL2GWWWoqFouTF5 cFSpfQdZuYPNuzwEHx+ctMn/NI2QDc3Pxvl+JPTVxeWlPVeXGTs3aDeTyc5eQy3oZSGq cu/Mahya2joBENtQD04TS8pYV+iUXu4k61Cctko4XPJuR1sTMfVTbd2SVpnvHvv090MI Gy76RS/VEtStLpxAiReHzgPcius6JV23GaK2BLN3TMmsYhWHd65DuxEToe3kZowyApVa 9uZA== X-Forwarded-Encrypted: i=1; AJvYcCVRIoADMcrisT+MuanTwYwhIjevE68Wqo0rcUXGEjZ8a8UvWL/aJ3I7MzZ6gE3ArJRhnShj54gnEg==@kvack.org X-Gm-Message-State: AOJu0YyM2ZY/NOcE+DGgxtV6y0Zfl6fhpn+fCoMXp+X3Ds/47uiAjCI1 Uh9NEZvs8ITT4Dim99ZA1OmLucbRWUwCOl+dNGlKTKPp3mK/SX4YrH3tJNzheBmGF6xyZOTT0aB QvwPNdeevNVpYAWtV/I9oXNw59EnyJp+zFjgqJhsKgvzHYoNtVeGXZ9+Z X-Received: by 2002:a05:6358:7201:b0:1ac:f3df:3bde with SMTP id e5c5f4694b2df-1b5ebf3abdcmr117740055d.5.1724705058981; Mon, 26 Aug 2024 13:44:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHztBftH8jfc2wrFWJQjc0BC5uJ0IwQWlV9Rpv0YGeitSfcFoHRh3KGrU0k5GaslF87BwNh3Q== X-Received: by 2002:a05:6358:7201:b0:1ac:f3df:3bde with SMTP id e5c5f4694b2df-1b5ebf3abdcmr117734755d.5.1724705058531; Mon, 26 Aug 2024 13:44:18 -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.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2024 13:44:18 -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 , Niklas Schnelle , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , linux-s390@vger.kernel.org Subject: [PATCH v2 11/19] s390/pci_mmio: Use follow_pfnmap API Date: Mon, 26 Aug 2024 16:43:45 -0400 Message-ID: <20240826204353.2228736-12-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: E2CCA1C0010 X-Stat-Signature: 3ith431i1cngwiuecnwk9j8j9k4eaqfa X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1724705061-998465 X-HE-Meta: U2FsdGVkX18qr14F77ogpSIsHPpYGWztnf/mySsD8rMixQucY5btDmxa/BKEJM0I6hhirTizNoxdcno1Hch67wCNLrfocudm8W+RmX5mjDhsdDl3qZD+/NWdGC0DDszaN5kmnABT//pzzt7dFzTWm8dY9YeAXXQQqHeeYj8/Qr1zZHdIQ40beQ9j/GldpUgNeV8FEK6zbVJzRU2A6F5Zm4NYS1XdKIo2/wvnhx9vnrySunJYqTMTtwpRA2D2fMDpqZ4euXNMWsxtKB3ZWy2I6D8aVWDyqQ66btm+IJyWwh3c5MFFCx3222Ymit+D0GkiWTk+q5qX4+arPliHI7YiqZ/MJtIP1/gUkkSq0iIjALMjYmVVWBjYvy+1n4kp2Qx2LeJZRm7gf7vbr6SqaTep3oiVeLeT+r0suPWsunFC2mp93YdbD1oGqhR0GOejX3xesXrzJ0suo97T4VwaJW5eyHzmUsefMTlJagPxfb2V9/5QWEgHuWEqvbfxRxxsj3w4TQGbHN8Y9auSsLBo/O2o8y8EDgh2vegoaR67IlW9H7gfAaxryOzatXWdildZbnIAEGcl9TYN4pP4UH5D3xrv0gEvF6iKoxjcXjRrg2HCv8ulbKpOurNJkPI1N9Eh6SrbZUtJPYsgRuZKo4e9uGHia2yw1QZZ6oVct+fMhi94OopOPkLy5BqJHmHiklXAoIprJ9y0eLGzIOhnMbsJPb+o5Y6zJD3h+k+HGir2hxOrJpVOCslDlhIC3iD8/orMUCW6Ngo5GO/oP8VZKsjCwc3A67RqUHS+v0fDZP/Ts6TuxkeatdYWJZiZwpcN86y5N4prdnQcBvjZEaHD5BVAEL7WEcN59Vsx/XB5+m3sO3YbT1HBQAKHYsz8HHRatSr4Emwh2Ad1nMAXgyEvUxGf6ERACHBOc6SLMT3hVHl5AgbTebF01K0vV++eK4RjhS7T79rG7E3EnnzCrvltpwoleiy jTHQOeFW Y3UEYgKAhFKPHeL0wRljzPpHhe0uNTBU+wYYdpV8BCRF1LejMtJkag28mlUE77f4sKA6KCg84nudGJHgWXzrDti3MdybMW6h/4fGW/YyQk43lI2Rl4/rwwgN5CnBSHbQgG/caIS6XCylWzwffRBbBcZuQUE6Y5rVpCPY5p+MVwISQGms7/6Qku1Az6Mwvzx+V8aJ2Sd27o78qzYsJgOfOglnVwLyxqBdhMqeG2huKYrOAMmlpGjnrx9MjwWM4H6SoB/g+BV45HthDXe16etQhnVO+AedPObdT8oGBWxCiZmLJ3WisESGSMkbegFM39p3ILytamDYuaYtp7yQZAg5kEkDq6JiQPmFLy7dvJP4BANpBHw6xKn7ytq9FAQn1HeuItiqUiAbRZOrbFOMSYhNmSALNnbY+0FscQvlXXrddifBEKWp+E3kPfsJxcUXixg9XrJp5qii3/miLMZ+ddFZMKk4/bA== 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: Niklas Schnelle Cc: Gerald Schaefer Cc: Heiko Carstens Cc: Vasily Gorbik Cc: Alexander Gordeev Cc: Christian Borntraeger Cc: Sven Schnelle Cc: linux-s390@vger.kernel.org Signed-off-by: Peter Xu --- arch/s390/pci/pci_mmio.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/arch/s390/pci/pci_mmio.c b/arch/s390/pci/pci_mmio.c index 5398729bfe1b..de5c0b389a3e 100644 --- a/arch/s390/pci/pci_mmio.c +++ b/arch/s390/pci/pci_mmio.c @@ -118,12 +118,11 @@ static inline int __memcpy_toio_inuser(void __iomem *dst, SYSCALL_DEFINE3(s390_pci_mmio_write, unsigned long, mmio_addr, const void __user *, user_buffer, size_t, length) { + struct follow_pfnmap_args args = { }; u8 local_buf[64]; void __iomem *io_addr; void *buf; struct vm_area_struct *vma; - pte_t *ptep; - spinlock_t *ptl; long ret; if (!zpci_is_enabled()) @@ -169,11 +168,13 @@ SYSCALL_DEFINE3(s390_pci_mmio_write, unsigned long, mmio_addr, if (!(vma->vm_flags & VM_WRITE)) goto out_unlock_mmap; - ret = follow_pte(vma, mmio_addr, &ptep, &ptl); + args.address = mmio_addr; + args.vma = vma; + ret = follow_pfnmap_start(&args); if (ret) goto out_unlock_mmap; - io_addr = (void __iomem *)((pte_pfn(*ptep) << PAGE_SHIFT) | + io_addr = (void __iomem *)((args.pfn << PAGE_SHIFT) | (mmio_addr & ~PAGE_MASK)); if ((unsigned long) io_addr < ZPCI_IOMAP_ADDR_BASE) @@ -181,7 +182,7 @@ SYSCALL_DEFINE3(s390_pci_mmio_write, unsigned long, mmio_addr, ret = zpci_memcpy_toio(io_addr, buf, length); out_unlock_pt: - pte_unmap_unlock(ptep, ptl); + follow_pfnmap_end(&args); out_unlock_mmap: mmap_read_unlock(current->mm); out_free: @@ -260,12 +261,11 @@ static inline int __memcpy_fromio_inuser(void __user *dst, SYSCALL_DEFINE3(s390_pci_mmio_read, unsigned long, mmio_addr, void __user *, user_buffer, size_t, length) { + struct follow_pfnmap_args args = { }; u8 local_buf[64]; void __iomem *io_addr; void *buf; struct vm_area_struct *vma; - pte_t *ptep; - spinlock_t *ptl; long ret; if (!zpci_is_enabled()) @@ -308,11 +308,13 @@ SYSCALL_DEFINE3(s390_pci_mmio_read, unsigned long, mmio_addr, if (!(vma->vm_flags & VM_WRITE)) goto out_unlock_mmap; - ret = follow_pte(vma, mmio_addr, &ptep, &ptl); + args.vma = vma; + args.address = mmio_addr; + ret = follow_pfnmap_start(&args); if (ret) goto out_unlock_mmap; - io_addr = (void __iomem *)((pte_pfn(*ptep) << PAGE_SHIFT) | + io_addr = (void __iomem *)((args.pfn << PAGE_SHIFT) | (mmio_addr & ~PAGE_MASK)); if ((unsigned long) io_addr < ZPCI_IOMAP_ADDR_BASE) { @@ -322,7 +324,7 @@ SYSCALL_DEFINE3(s390_pci_mmio_read, unsigned long, mmio_addr, ret = zpci_memcpy_fromio(buf, io_addr, length); out_unlock_pt: - pte_unmap_unlock(ptep, ptl); + follow_pfnmap_end(&args); out_unlock_mmap: mmap_read_unlock(current->mm);