From mboxrd@z Thu Jan 1 00:00:00 1970 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 D063CC54FC6 for ; Sun, 1 Sep 2024 13:40:47 +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-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=vyGDIwF2j/q+RxX/6PvhOnfgGDLJV1PumKrXufZMqJk=; b=HdVfFWyJakOvvEAVGV3ufY9cnH 2rYhQhTZLoV/AkxMQmydeGwYc7ZrQJ2mAZqA2oJ3Fq1O7apzJ8QCbwenixgzPMnTfIh6tX1uMLX0a pUznKaIjUtHMRG0Vgz7E/3ukhSkankumgvRfwaFl/VrvpDcp/Y2uwKYZD+G6bV7UEMj62VCRlmo9H a5yqW7YoL0pDN4xrVT7Bd60sFRAVwFWQtYRWfvOqUScbDOkKVQuOAeSlnrJFLafsha/W9x1FBRrAq irv9mANVJE07PJjJzP07J4oAzvdmn8RJO6h5/lSSf7/tiVu4P5dZlPMM/yYz9+Lst5LHhJem1kqwW 7dskH6Jg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1skkok-0000000Bj3Y-18SB; Sun, 01 Sep 2024 13:40:34 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1skknp-0000000BirL-2ZFp for linux-arm-kernel@lists.infradead.org; Sun, 01 Sep 2024 13:39:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725197973; 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=vyGDIwF2j/q+RxX/6PvhOnfgGDLJV1PumKrXufZMqJk=; b=bCCFAGgJEonHNydSWRaQ5ta6GfzE0gTgSc3+sjdoN6GssWFgIO9iDYuWM/EbNmla79l4qx RlXW/mwAhruWM97KmFQlM+p8uG14iSVmikroKNYEVMd7D4oIJAISUdIsYYoRcDjD7sKSbN bh1aXyiILNPbQPFnq9RwdMZXVJeU78M= Received: from mail-oo1-f72.google.com (mail-oo1-f72.google.com [209.85.161.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-150-1_mnB7LgOgizOOJrSGaX6Q-1; Sun, 01 Sep 2024 09:39:32 -0400 X-MC-Unique: 1_mnB7LgOgizOOJrSGaX6Q-1 Received: by mail-oo1-f72.google.com with SMTP id 006d021491bc7-5dc96240f1dso3501305eaf.0 for ; Sun, 01 Sep 2024 06:39:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725197972; x=1725802772; h=content-transfer-encoding:in-reply-to:content-language:from :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vyGDIwF2j/q+RxX/6PvhOnfgGDLJV1PumKrXufZMqJk=; b=Tiq67T7INSfnaKJt6fA6jtZ4pwYdoOW1fUaNkHIA4g04Mu9yrGOhmzFq1v940u2L0e t5+TJUgh6Ejm4BZTCsK7eqqSkhRP2qe6FGSM5iVW0MdIcUFkge19ciaXs3U4z8nrowrW 7M5+Q6n81T5JWGX9K54SHkxXlYs27a1GGMxak/mjnfj/89sE7Bwlzl77u92TWquBqU1+ NnyP0W/5PamCPI2C4cyboiW9I8cLadtpPUIMVynal7vD+rilLzpKcExuaDQ86Mm5YWfO oAdnJgzd9PYN2Y00UmT9VZaiwx+f3Twckb0Rhyuq9REucF53UQadroRz/AbXKAQ/Jqwn OTkg== X-Forwarded-Encrypted: i=1; AJvYcCUzAPmIyHJjksR0cBMvLZ7Ty8NTQqLRsWFhdwc7/aJ6PQ9bth0Twi6O4VQxTUZprQloIC0JdbV6pLpCFqdTYsad@lists.infradead.org X-Gm-Message-State: AOJu0YxrFwEGZcKM7E3TGyWoc+pMZHaz+1Fsb1e7SZZoRqmMWk6WkA0k pje/FcuqZY1+C1/NVOqdhGqAC0UQf3JZeHyTRFBzfeje12AeiCgNVImUbV2yaYArrSk/qOp+rTV 4rI9/d566ui2xpKea4bjm/d728ZmpWTytXfud8tHDMsiV1L6KJL2Y4ZlVJeSUgUGniQi8TPzv X-Received: by 2002:a05:6358:9385:b0:1b5:a043:8f43 with SMTP id e5c5f4694b2df-1b603a26699mr1468280655d.0.1725197971953; Sun, 01 Sep 2024 06:39:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEDmQzg0ZPiJwjrC5T+Ay+drE71+FKdZDRY3ijuZM6RzcnlHFemGD4aRZKF9+h5bY5YpETJsQ== X-Received: by 2002:a05:6358:9385:b0:1b5:a043:8f43 with SMTP id e5c5f4694b2df-1b603a26699mr1468276255d.0.1725197971407; Sun, 01 Sep 2024 06:39:31 -0700 (PDT) Received: from ?IPV6:2003:cb:c720:6600:be4f:7c7a:2bbd:4720? (p200300cbc7206600be4f7c7a2bbd4720.dip0.t-ipconnect.de. [2003:cb:c720:6600:be4f:7c7a:2bbd:4720]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6c353173c45sm20426886d6.92.2024.09.01.06.39.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 01 Sep 2024 06:39:31 -0700 (PDT) Message-ID: <8c70fc0d-901c-4a57-8bbd-0a7f8d895f7e@redhat.com> Date: Sun, 1 Sep 2024 15:39:21 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 16/19] mm: Remove follow_pte() To: Yu Zhao , Peter Xu Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, 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 , Oscar Salvador , Jason Gunthorpe , Borislav Petkov , Zi Yan , Axel Rasmussen , Yan Zhao , Will Deacon , Kefeng Wang , Alex Williamson References: <20240826204353.2228736-1-peterx@redhat.com> <20240826204353.2228736-17-peterx@redhat.com> From: David Hildenbrand In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240901_063937_770476_F129DC7F X-CRM114-Status: GOOD ( 24.03 ) 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 Am 01.09.24 um 06:33 schrieb Yu Zhao: > On Mon, Aug 26, 2024 at 2:44 PM Peter Xu wrote: >> >> follow_pte() users have been converted to follow_pfnmap*(). Remove the >> API. >> >> Signed-off-by: Peter Xu >> --- >> include/linux/mm.h | 2 -- >> mm/memory.c | 73 ---------------------------------------------- >> 2 files changed, 75 deletions(-) >> >> diff --git a/include/linux/mm.h b/include/linux/mm.h >> index 161d496bfd18..b31d4bdd65ad 100644 >> --- a/include/linux/mm.h >> +++ b/include/linux/mm.h >> @@ -2368,8 +2368,6 @@ void free_pgd_range(struct mmu_gather *tlb, unsigned long addr, >> unsigned long end, unsigned long floor, unsigned long ceiling); >> int >> copy_page_range(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma); >> -int follow_pte(struct vm_area_struct *vma, unsigned long address, >> - pte_t **ptepp, spinlock_t **ptlp); >> int generic_access_phys(struct vm_area_struct *vma, unsigned long addr, >> void *buf, int len, int write); >> >> diff --git a/mm/memory.c b/mm/memory.c >> index b5d07f493d5d..288f81a8698e 100644 >> --- a/mm/memory.c >> +++ b/mm/memory.c >> @@ -6100,79 +6100,6 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address) >> } >> #endif /* __PAGETABLE_PMD_FOLDED */ >> >> -/** >> - * follow_pte - look up PTE at a user virtual address >> - * @vma: the memory mapping >> - * @address: user virtual address >> - * @ptepp: location to store found PTE >> - * @ptlp: location to store the lock for the PTE >> - * >> - * On a successful return, the pointer to the PTE is stored in @ptepp; >> - * the corresponding lock is taken and its location is stored in @ptlp. >> - * >> - * The contents of the PTE are only stable until @ptlp is released using >> - * pte_unmap_unlock(). This function will fail if the PTE is non-present. >> - * Present PTEs may include PTEs that map refcounted pages, such as >> - * anonymous folios in COW mappings. >> - * >> - * Callers must be careful when relying on PTE content after >> - * pte_unmap_unlock(). Especially if the PTE maps a refcounted page, >> - * callers must protect against invalidation with MMU notifiers; otherwise >> - * access to the PFN at a later point in time can trigger use-after-free. >> - * >> - * Only IO mappings and raw PFN mappings are allowed. The mmap semaphore >> - * should be taken for read. >> - * >> - * This function must not be used to modify PTE content. >> - * >> - * Return: zero on success, -ve otherwise. >> - */ >> -int follow_pte(struct vm_area_struct *vma, unsigned long address, >> - pte_t **ptepp, spinlock_t **ptlp) >> -{ >> - struct mm_struct *mm = vma->vm_mm; >> - pgd_t *pgd; >> - p4d_t *p4d; >> - pud_t *pud; >> - pmd_t *pmd; >> - pte_t *ptep; >> - >> - mmap_assert_locked(mm); >> - if (unlikely(address < vma->vm_start || address >= vma->vm_end)) >> - goto out; >> - >> - if (!(vma->vm_flags & (VM_IO | VM_PFNMAP))) >> - goto out; >> - >> - pgd = pgd_offset(mm, address); >> - if (pgd_none(*pgd) || unlikely(pgd_bad(*pgd))) >> - goto out; >> - >> - p4d = p4d_offset(pgd, address); >> - if (p4d_none(*p4d) || unlikely(p4d_bad(*p4d))) >> - goto out; >> - >> - pud = pud_offset(p4d, address); >> - if (pud_none(*pud) || unlikely(pud_bad(*pud))) >> - goto out; >> - >> - pmd = pmd_offset(pud, address); >> - VM_BUG_ON(pmd_trans_huge(*pmd)); >> - >> - ptep = pte_offset_map_lock(mm, pmd, address, ptlp); >> - if (!ptep) >> - goto out; >> - if (!pte_present(ptep_get(ptep))) >> - goto unlock; >> - *ptepp = ptep; >> - return 0; >> -unlock: >> - pte_unmap_unlock(ptep, *ptlp); >> -out: >> - return -EINVAL; >> -} >> -EXPORT_SYMBOL_GPL(follow_pte); > > I ran into build errors with this -- removing exported symbols breaks > ABI, so I think we should make follow_pte() as a wrapper of its new > equivalent, if that's possible? Build error with OOT modules or in-tree modules? If you are talking about OOT modules, it is their responsibility to fix this up in their implementation. There are no real kabi stability guarantees provided by the kernel. If you are talking about in-tree modules, did Peter miss some (probably in -next?)? -- Thanks, David / dhildenb