diff mbox series

[1/2] arm64/mm: Export contpte symbols only to GPL users

Message ID 20240226120321.1055731-2-ryan.roberts@arm.com (mailing list archive)
State New, archived
Headers show
Series Address some contpte nits | expand

Commit Message

Ryan Roberts Feb. 26, 2024, 12:03 p.m. UTC
The contpte symbols must be exported since some of the public inline
ptep_* APIs are called from modules and these inlines now call the
contpte functions. Originally they were exported as EXPORT_SYMBOL() for
fear of breaking out-of-tree modules. But we subsequently concluded that
EXPORT_SYMBOL_GPL() should be safe since these functions are deeply core
mm routines, and any module operating at this level is not going to be
able to survive on EXPORT_SYMBOL alone.

Link: https://lore.kernel.org/linux-mm/f9fc2b31-11cb-4969-8961-9c89fea41b74@nvidia.com/
Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
---
 arch/arm64/mm/contpte.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

Comments

David Hildenbrand Feb. 26, 2024, 12:25 p.m. UTC | #1
On 26.02.24 13:03, Ryan Roberts wrote:
> The contpte symbols must be exported since some of the public inline
> ptep_* APIs are called from modules and these inlines now call the
> contpte functions. Originally they were exported as EXPORT_SYMBOL() for
> fear of breaking out-of-tree modules. But we subsequently concluded that
> EXPORT_SYMBOL_GPL() should be safe since these functions are deeply core
> mm routines, and any module operating at this level is not going to be
> able to survive on EXPORT_SYMBOL alone.
> 

I only looked at __set_ptes() to get a feeling what would currently work.

__set_ptes() might already call __sync_icache_dcache() via 
__sync_cache_and_tags(), that is EXPORT_SYMBOL_GPL.

[mte_sync_tags() is not exported at all, so maybe it's safe to assume 
that some out-of-tree module could not make good use of set_pte_at() in 
general]

Acked-by: David Hildenbrand <david@redhat.com>
Ryan Roberts Feb. 26, 2024, 12:40 p.m. UTC | #2
On 26/02/2024 12:25, David Hildenbrand wrote:
> On 26.02.24 13:03, Ryan Roberts wrote:
>> The contpte symbols must be exported since some of the public inline
>> ptep_* APIs are called from modules and these inlines now call the
>> contpte functions. Originally they were exported as EXPORT_SYMBOL() for
>> fear of breaking out-of-tree modules. But we subsequently concluded that
>> EXPORT_SYMBOL_GPL() should be safe since these functions are deeply core
>> mm routines, and any module operating at this level is not going to be
>> able to survive on EXPORT_SYMBOL alone.
>>
> 
> I only looked at __set_ptes() to get a feeling what would currently work.
> 
> __set_ptes() might already call __sync_icache_dcache() via
> __sync_cache_and_tags(), that is EXPORT_SYMBOL_GPL.
> 
> [mte_sync_tags() is not exported at all, so maybe it's safe to assume that some
> out-of-tree module could not make good use of set_pte_at() in general]

That's interesting, some grepping I previously did showed that ptep_get() and
set_pte_at() are used by in-tree drivers (which I assume can be built as modules):

https://lore.kernel.org/linux-arm-kernel/b994ff89-1a1f-26ca-9479-b08c77f94be8@arm.com/

> 
> Acked-by: David Hildenbrand <david@redhat.com>
> 

Thanks!
John Hubbard Feb. 27, 2024, 2:49 a.m. UTC | #3
On 2/26/24 04:03, Ryan Roberts wrote:
> The contpte symbols must be exported since some of the public inline
> ptep_* APIs are called from modules and these inlines now call the
> contpte functions. Originally they were exported as EXPORT_SYMBOL() for
> fear of breaking out-of-tree modules. But we subsequently concluded that
> EXPORT_SYMBOL_GPL() should be safe since these functions are deeply core
> mm routines, and any module operating at this level is not going to be
> able to survive on EXPORT_SYMBOL alone.
> 
> Link: https://lore.kernel.org/linux-mm/f9fc2b31-11cb-4969-8961-9c89fea41b74@nvidia.com/
> Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
> ---
>   arch/arm64/mm/contpte.c | 22 +++++++++++-----------
>   1 file changed, 11 insertions(+), 11 deletions(-)
> 

Yes, looks good.

Reviewed-by:  John Hubbard <jhubbard@nvidia.com>


thanks,
Catalin Marinas March 4, 2024, 5:38 p.m. UTC | #4
On Mon, Feb 26, 2024 at 12:03:20PM +0000, Ryan Roberts wrote:
> The contpte symbols must be exported since some of the public inline
> ptep_* APIs are called from modules and these inlines now call the
> contpte functions. Originally they were exported as EXPORT_SYMBOL() for
> fear of breaking out-of-tree modules. But we subsequently concluded that
> EXPORT_SYMBOL_GPL() should be safe since these functions are deeply core
> mm routines, and any module operating at this level is not going to be
> able to survive on EXPORT_SYMBOL alone.
> 
> Link: https://lore.kernel.org/linux-mm/f9fc2b31-11cb-4969-8961-9c89fea41b74@nvidia.com/
> Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>

Acked-by: Catalin Marinas <catalin.marinas@arm.com>
diff mbox series

Patch

diff --git a/arch/arm64/mm/contpte.c b/arch/arm64/mm/contpte.c
index 16788f07716d..be0a226c4ff9 100644
--- a/arch/arm64/mm/contpte.c
+++ b/arch/arm64/mm/contpte.c
@@ -135,7 +135,7 @@  void __contpte_try_fold(struct mm_struct *mm, unsigned long addr,
 	pte = pte_mkcont(pte);
 	contpte_convert(mm, addr, orig_ptep, pte);
 }
-EXPORT_SYMBOL(__contpte_try_fold);
+EXPORT_SYMBOL_GPL(__contpte_try_fold);
 
 void __contpte_try_unfold(struct mm_struct *mm, unsigned long addr,
 			pte_t *ptep, pte_t pte)
@@ -150,7 +150,7 @@  void __contpte_try_unfold(struct mm_struct *mm, unsigned long addr,
 	pte = pte_mknoncont(pte);
 	contpte_convert(mm, addr, ptep, pte);
 }
-EXPORT_SYMBOL(__contpte_try_unfold);
+EXPORT_SYMBOL_GPL(__contpte_try_unfold);
 
 pte_t contpte_ptep_get(pte_t *ptep, pte_t orig_pte)
 {
@@ -178,7 +178,7 @@  pte_t contpte_ptep_get(pte_t *ptep, pte_t orig_pte)
 
 	return orig_pte;
 }
-EXPORT_SYMBOL(contpte_ptep_get);
+EXPORT_SYMBOL_GPL(contpte_ptep_get);
 
 pte_t contpte_ptep_get_lockless(pte_t *orig_ptep)
 {
@@ -231,7 +231,7 @@  pte_t contpte_ptep_get_lockless(pte_t *orig_ptep)
 
 	return orig_pte;
 }
-EXPORT_SYMBOL(contpte_ptep_get_lockless);
+EXPORT_SYMBOL_GPL(contpte_ptep_get_lockless);
 
 void contpte_set_ptes(struct mm_struct *mm, unsigned long addr,
 					pte_t *ptep, pte_t pte, unsigned int nr)
@@ -274,7 +274,7 @@  void contpte_set_ptes(struct mm_struct *mm, unsigned long addr,
 
 	} while (addr != end);
 }
-EXPORT_SYMBOL(contpte_set_ptes);
+EXPORT_SYMBOL_GPL(contpte_set_ptes);
 
 void contpte_clear_full_ptes(struct mm_struct *mm, unsigned long addr,
 				pte_t *ptep, unsigned int nr, int full)
@@ -282,7 +282,7 @@  void contpte_clear_full_ptes(struct mm_struct *mm, unsigned long addr,
 	contpte_try_unfold_partial(mm, addr, ptep, nr);
 	__clear_full_ptes(mm, addr, ptep, nr, full);
 }
-EXPORT_SYMBOL(contpte_clear_full_ptes);
+EXPORT_SYMBOL_GPL(contpte_clear_full_ptes);
 
 pte_t contpte_get_and_clear_full_ptes(struct mm_struct *mm,
 				unsigned long addr, pte_t *ptep,
@@ -291,7 +291,7 @@  pte_t contpte_get_and_clear_full_ptes(struct mm_struct *mm,
 	contpte_try_unfold_partial(mm, addr, ptep, nr);
 	return __get_and_clear_full_ptes(mm, addr, ptep, nr, full);
 }
-EXPORT_SYMBOL(contpte_get_and_clear_full_ptes);
+EXPORT_SYMBOL_GPL(contpte_get_and_clear_full_ptes);
 
 int contpte_ptep_test_and_clear_young(struct vm_area_struct *vma,
 					unsigned long addr, pte_t *ptep)
@@ -316,7 +316,7 @@  int contpte_ptep_test_and_clear_young(struct vm_area_struct *vma,
 
 	return young;
 }
-EXPORT_SYMBOL(contpte_ptep_test_and_clear_young);
+EXPORT_SYMBOL_GPL(contpte_ptep_test_and_clear_young);
 
 int contpte_ptep_clear_flush_young(struct vm_area_struct *vma,
 					unsigned long addr, pte_t *ptep)
@@ -337,7 +337,7 @@  int contpte_ptep_clear_flush_young(struct vm_area_struct *vma,
 
 	return young;
 }
-EXPORT_SYMBOL(contpte_ptep_clear_flush_young);
+EXPORT_SYMBOL_GPL(contpte_ptep_clear_flush_young);
 
 void contpte_wrprotect_ptes(struct mm_struct *mm, unsigned long addr,
 					pte_t *ptep, unsigned int nr)
@@ -355,7 +355,7 @@  void contpte_wrprotect_ptes(struct mm_struct *mm, unsigned long addr,
 	contpte_try_unfold_partial(mm, addr, ptep, nr);
 	__wrprotect_ptes(mm, addr, ptep, nr);
 }
-EXPORT_SYMBOL(contpte_wrprotect_ptes);
+EXPORT_SYMBOL_GPL(contpte_wrprotect_ptes);
 
 int contpte_ptep_set_access_flags(struct vm_area_struct *vma,
 					unsigned long addr, pte_t *ptep,
@@ -401,4 +401,4 @@  int contpte_ptep_set_access_flags(struct vm_area_struct *vma,
 
 	return 1;
 }
-EXPORT_SYMBOL(contpte_ptep_set_access_flags);
+EXPORT_SYMBOL_GPL(contpte_ptep_set_access_flags);