* linux-next: manual merge of the arm64 tree with the mm tree
@ 2024-10-23 23:37 Stephen Rothwell
2024-10-24 8:14 ` Catalin Marinas
2024-11-20 0:58 ` Stephen Rothwell
0 siblings, 2 replies; 11+ messages in thread
From: Stephen Rothwell @ 2024-10-23 23:37 UTC (permalink / raw)
To: Catalin Marinas, Will Deacon, Andrew Morton
Cc: Linux Kernel Mailing List, Linux Next Mailing List,
Mike Rapoport (Microsoft), Steven Price, Suzuki K Poulose
[-- Attachment #1: Type: text/plain, Size: 3432 bytes --]
Hi all,
Today's linux-next merge of the arm64 tree got a conflict in:
arch/arm64/mm/pageattr.c
between commit:
040ee4186d6c ("arch: introduce set_direct_map_valid_noflush()")
from the mm-unstable branch of the mm tree and commit:
42be24a4178f ("arm64: Enable memory encrypt for Realms")
from the arm64 tree.
I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging. You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.
--
Cheers,
Stephen Rothwell
diff --cc arch/arm64/mm/pageattr.c
index 01225900293a,6ae6ae806454..000000000000
--- a/arch/arm64/mm/pageattr.c
+++ b/arch/arm64/mm/pageattr.c
@@@ -192,16 -202,86 +202,96 @@@ int set_direct_map_default_noflush(stru
PAGE_SIZE, change_page_range, &data);
}
+int set_direct_map_valid_noflush(struct page *page, unsigned nr, bool valid)
+{
+ unsigned long addr = (unsigned long)page_address(page);
+
+ if (!can_set_direct_map())
+ return 0;
+
+ return set_memory_valid(addr, nr, valid);
+}
+
+ static int __set_memory_enc_dec(unsigned long addr,
+ int numpages,
+ bool encrypt)
+ {
+ unsigned long set_prot = 0, clear_prot = 0;
+ phys_addr_t start, end;
+ int ret;
+
+ if (!is_realm_world())
+ return 0;
+
+ if (!__is_lm_address(addr))
+ return -EINVAL;
+
+ start = __virt_to_phys(addr);
+ end = start + numpages * PAGE_SIZE;
+
+ if (encrypt)
+ clear_prot = PROT_NS_SHARED;
+ else
+ set_prot = PROT_NS_SHARED;
+
+ /*
+ * Break the mapping before we make any changes to avoid stale TLB
+ * entries or Synchronous External Aborts caused by RIPAS_EMPTY
+ */
+ ret = __change_memory_common(addr, PAGE_SIZE * numpages,
+ __pgprot(set_prot),
+ __pgprot(clear_prot | PTE_VALID));
+
+ if (ret)
+ return ret;
+
+ if (encrypt)
+ ret = rsi_set_memory_range_protected(start, end);
+ else
+ ret = rsi_set_memory_range_shared(start, end);
+
+ if (ret)
+ return ret;
+
+ return __change_memory_common(addr, PAGE_SIZE * numpages,
+ __pgprot(PTE_VALID),
+ __pgprot(0));
+ }
+
+ static int realm_set_memory_encrypted(unsigned long addr, int numpages)
+ {
+ int ret = __set_memory_enc_dec(addr, numpages, true);
+
+ /*
+ * If the request to change state fails, then the only sensible cause
+ * of action for the caller is to leak the memory
+ */
+ WARN(ret, "Failed to encrypt memory, %d pages will be leaked",
+ numpages);
+
+ return ret;
+ }
+
+ static int realm_set_memory_decrypted(unsigned long addr, int numpages)
+ {
+ int ret = __set_memory_enc_dec(addr, numpages, false);
+
+ WARN(ret, "Failed to decrypt memory, %d pages will be leaked",
+ numpages);
+
+ return ret;
+ }
+
+ static const struct arm64_mem_crypt_ops realm_crypt_ops = {
+ .encrypt = realm_set_memory_encrypted,
+ .decrypt = realm_set_memory_decrypted,
+ };
+
+ int realm_register_memory_enc_ops(void)
+ {
+ return arm64_mem_crypt_ops_register(&realm_crypt_ops);
+ }
+
#ifdef CONFIG_DEBUG_PAGEALLOC
void __kernel_map_pages(struct page *page, int numpages, int enable)
{
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: linux-next: manual merge of the arm64 tree with the mm tree
2024-10-23 23:37 Stephen Rothwell
@ 2024-10-24 8:14 ` Catalin Marinas
2024-11-20 0:58 ` Stephen Rothwell
1 sibling, 0 replies; 11+ messages in thread
From: Catalin Marinas @ 2024-10-24 8:14 UTC (permalink / raw)
To: Stephen Rothwell
Cc: Will Deacon, Andrew Morton, Linux Kernel Mailing List,
Linux Next Mailing List, Mike Rapoport (Microsoft), Steven Price,
Suzuki K Poulose
On Thu, Oct 24, 2024 at 10:37:09AM +1100, Stephen Rothwell wrote:
> Hi all,
>
> Today's linux-next merge of the arm64 tree got a conflict in:
>
> arch/arm64/mm/pageattr.c
>
> between commit:
>
> 040ee4186d6c ("arch: introduce set_direct_map_valid_noflush()")
>
> from the mm-unstable branch of the mm tree and commit:
>
> 42be24a4178f ("arm64: Enable memory encrypt for Realms")
>
> from the arm64 tree.
>
> I fixed it up (see below) and can carry the fix as necessary. This
> is now fixed as far as linux-next is concerned, but any non trivial
> conflicts should be mentioned to your upstream maintainer when your tree
> is submitted for merging. You may also want to consider cooperating
> with the maintainer of the conflicting tree to minimise any particularly
> complex conflicts.
The resolution looks fine. Thanks Stephen.
--
Catalin
^ permalink raw reply [flat|nested] 11+ messages in thread
* linux-next: manual merge of the arm64 tree with the mm tree
@ 2024-10-28 0:10 Stephen Rothwell
2024-10-28 17:25 ` Catalin Marinas
2024-11-20 1:01 ` Stephen Rothwell
0 siblings, 2 replies; 11+ messages in thread
From: Stephen Rothwell @ 2024-10-28 0:10 UTC (permalink / raw)
To: Catalin Marinas, Will Deacon, Andrew Morton
Cc: Linux Kernel Mailing List, Linux Next Mailing List, Mark Brown,
Suren Baghdasaryan
[-- Attachment #1: Type: text/plain, Size: 2765 bytes --]
Hi all,
Today's linux-next merge of the arm64 tree got a conflict in:
include/linux/mm.h
between commit:
e87ec503cf2e ("mm/codetag: uninline and move pgalloc_tag_copy and pgalloc_tag_split")
from the mm-unstable branch of the mm tree and commit:
91e102e79740 ("prctl: arch-agnostic prctl for shadow stack")
from the arm64 tree.
I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging. You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.
--
Cheers,
Stephen Rothwell
diff --cc include/linux/mm.h
index 086ba524d3ba,8852c39c7695..000000000000
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@@ -4166,4 -4174,65 +4178,8 @@@ static inline int do_mseal(unsigned lon
}
#endif
-#ifdef CONFIG_MEM_ALLOC_PROFILING
-static inline void pgalloc_tag_split(struct folio *folio, int old_order, int new_order)
-{
- int i;
- struct alloc_tag *tag;
- unsigned int nr_pages = 1 << new_order;
-
- if (!mem_alloc_profiling_enabled())
- return;
-
- tag = pgalloc_tag_get(&folio->page);
- if (!tag)
- return;
-
- for (i = nr_pages; i < (1 << old_order); i += nr_pages) {
- union codetag_ref *ref = get_page_tag_ref(folio_page(folio, i));
-
- if (ref) {
- /* Set new reference to point to the original tag */
- alloc_tag_ref_set(ref, tag);
- put_page_tag_ref(ref);
- }
- }
-}
-
-static inline void pgalloc_tag_copy(struct folio *new, struct folio *old)
-{
- struct alloc_tag *tag;
- union codetag_ref *ref;
-
- tag = pgalloc_tag_get(&old->page);
- if (!tag)
- return;
-
- ref = get_page_tag_ref(&new->page);
- if (!ref)
- return;
-
- /* Clear the old ref to the original allocation tag. */
- clear_page_tag_ref(&old->page);
- /* Decrement the counters of the tag on get_new_folio. */
- alloc_tag_sub(ref, folio_nr_pages(new));
-
- __alloc_tag_ref_set(ref, tag);
-
- put_page_tag_ref(ref);
-}
-#else /* !CONFIG_MEM_ALLOC_PROFILING */
-static inline void pgalloc_tag_split(struct folio *folio, int old_order, int new_order)
-{
-}
-
-static inline void pgalloc_tag_copy(struct folio *new, struct folio *old)
-{
-}
-#endif /* CONFIG_MEM_ALLOC_PROFILING */
-
+ int arch_get_shadow_stack_status(struct task_struct *t, unsigned long __user *status);
+ int arch_set_shadow_stack_status(struct task_struct *t, unsigned long status);
+ int arch_lock_shadow_stack_status(struct task_struct *t, unsigned long status);
+
#endif /* _LINUX_MM_H */
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: linux-next: manual merge of the arm64 tree with the mm tree
2024-10-28 0:10 linux-next: manual merge of the arm64 tree with the mm tree Stephen Rothwell
@ 2024-10-28 17:25 ` Catalin Marinas
2024-10-28 17:47 ` Suren Baghdasaryan
2024-11-20 1:01 ` Stephen Rothwell
1 sibling, 1 reply; 11+ messages in thread
From: Catalin Marinas @ 2024-10-28 17:25 UTC (permalink / raw)
To: Stephen Rothwell
Cc: Will Deacon, Andrew Morton, Linux Kernel Mailing List,
Linux Next Mailing List, Mark Brown, Suren Baghdasaryan
On Mon, Oct 28, 2024 at 11:10:58AM +1100, Stephen Rothwell wrote:
> Hi all,
>
> Today's linux-next merge of the arm64 tree got a conflict in:
>
> include/linux/mm.h
>
> between commit:
>
> e87ec503cf2e ("mm/codetag: uninline and move pgalloc_tag_copy and pgalloc_tag_split")
>
> from the mm-unstable branch of the mm tree and commit:
>
> 91e102e79740 ("prctl: arch-agnostic prctl for shadow stack")
>
> from the arm64 tree.
>
> I fixed it up (see below) and can carry the fix as necessary. This
> is now fixed as far as linux-next is concerned, but any non trivial
> conflicts should be mentioned to your upstream maintainer when your tree
> is submitted for merging. You may also want to consider cooperating
> with the maintainer of the conflicting tree to minimise any particularly
> complex conflicts.
This looks fine. Thanks.
--
Catalin
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: linux-next: manual merge of the arm64 tree with the mm tree
2024-10-28 17:25 ` Catalin Marinas
@ 2024-10-28 17:47 ` Suren Baghdasaryan
0 siblings, 0 replies; 11+ messages in thread
From: Suren Baghdasaryan @ 2024-10-28 17:47 UTC (permalink / raw)
To: Catalin Marinas
Cc: Stephen Rothwell, Will Deacon, Andrew Morton,
Linux Kernel Mailing List, Linux Next Mailing List, Mark Brown
On Mon, Oct 28, 2024 at 10:25 AM Catalin Marinas
<catalin.marinas@arm.com> wrote:
>
> On Mon, Oct 28, 2024 at 11:10:58AM +1100, Stephen Rothwell wrote:
> > Hi all,
> >
> > Today's linux-next merge of the arm64 tree got a conflict in:
> >
> > include/linux/mm.h
> >
> > between commit:
> >
> > e87ec503cf2e ("mm/codetag: uninline and move pgalloc_tag_copy and pgalloc_tag_split")
> >
> > from the mm-unstable branch of the mm tree and commit:
> >
> > 91e102e79740 ("prctl: arch-agnostic prctl for shadow stack")
> >
> > from the arm64 tree.
> >
> > I fixed it up (see below) and can carry the fix as necessary. This
> > is now fixed as far as linux-next is concerned, but any non trivial
> > conflicts should be mentioned to your upstream maintainer when your tree
> > is submitted for merging. You may also want to consider cooperating
> > with the maintainer of the conflicting tree to minimise any particularly
> > complex conflicts.
>
> This looks fine. Thanks.
Looks valid to me too. Thanks!
>
> --
> Catalin
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: linux-next: manual merge of the arm64 tree with the mm tree
2024-10-23 23:37 Stephen Rothwell
2024-10-24 8:14 ` Catalin Marinas
@ 2024-11-20 0:58 ` Stephen Rothwell
1 sibling, 0 replies; 11+ messages in thread
From: Stephen Rothwell @ 2024-11-20 0:58 UTC (permalink / raw)
To: Andrew Morton
Cc: Catalin Marinas, Will Deacon, Linux Kernel Mailing List,
Linux Next Mailing List, Mike Rapoport (Microsoft), Steven Price,
Suzuki K Poulose
[-- Attachment #1: Type: text/plain, Size: 3874 bytes --]
Hi all,
On Thu, 24 Oct 2024 10:37:09 +1100 Stephen Rothwell <sfr@canb.auug.org.au> wrote:
>
> Today's linux-next merge of the arm64 tree got a conflict in:
>
> arch/arm64/mm/pageattr.c
>
> between commit:
>
> 040ee4186d6c ("arch: introduce set_direct_map_valid_noflush()")
>
> from the mm-unstable branch of the mm tree and commit:
>
> 42be24a4178f ("arm64: Enable memory encrypt for Realms")
>
> from the arm64 tree.
>
> I fixed it up (see below) and can carry the fix as necessary. This
> is now fixed as far as linux-next is concerned, but any non trivial
> conflicts should be mentioned to your upstream maintainer when your tree
> is submitted for merging. You may also want to consider cooperating
> with the maintainer of the conflicting tree to minimise any particularly
> complex conflicts.
>
> --
> Cheers,
> Stephen Rothwell
>
> diff --cc arch/arm64/mm/pageattr.c
> index 01225900293a,6ae6ae806454..000000000000
> --- a/arch/arm64/mm/pageattr.c
> +++ b/arch/arm64/mm/pageattr.c
> @@@ -192,16 -202,86 +202,96 @@@ int set_direct_map_default_noflush(stru
> PAGE_SIZE, change_page_range, &data);
> }
>
> +int set_direct_map_valid_noflush(struct page *page, unsigned nr, bool valid)
> +{
> + unsigned long addr = (unsigned long)page_address(page);
> +
> + if (!can_set_direct_map())
> + return 0;
> +
> + return set_memory_valid(addr, nr, valid);
> +}
> +
> + static int __set_memory_enc_dec(unsigned long addr,
> + int numpages,
> + bool encrypt)
> + {
> + unsigned long set_prot = 0, clear_prot = 0;
> + phys_addr_t start, end;
> + int ret;
> +
> + if (!is_realm_world())
> + return 0;
> +
> + if (!__is_lm_address(addr))
> + return -EINVAL;
> +
> + start = __virt_to_phys(addr);
> + end = start + numpages * PAGE_SIZE;
> +
> + if (encrypt)
> + clear_prot = PROT_NS_SHARED;
> + else
> + set_prot = PROT_NS_SHARED;
> +
> + /*
> + * Break the mapping before we make any changes to avoid stale TLB
> + * entries or Synchronous External Aborts caused by RIPAS_EMPTY
> + */
> + ret = __change_memory_common(addr, PAGE_SIZE * numpages,
> + __pgprot(set_prot),
> + __pgprot(clear_prot | PTE_VALID));
> +
> + if (ret)
> + return ret;
> +
> + if (encrypt)
> + ret = rsi_set_memory_range_protected(start, end);
> + else
> + ret = rsi_set_memory_range_shared(start, end);
> +
> + if (ret)
> + return ret;
> +
> + return __change_memory_common(addr, PAGE_SIZE * numpages,
> + __pgprot(PTE_VALID),
> + __pgprot(0));
> + }
> +
> + static int realm_set_memory_encrypted(unsigned long addr, int numpages)
> + {
> + int ret = __set_memory_enc_dec(addr, numpages, true);
> +
> + /*
> + * If the request to change state fails, then the only sensible cause
> + * of action for the caller is to leak the memory
> + */
> + WARN(ret, "Failed to encrypt memory, %d pages will be leaked",
> + numpages);
> +
> + return ret;
> + }
> +
> + static int realm_set_memory_decrypted(unsigned long addr, int numpages)
> + {
> + int ret = __set_memory_enc_dec(addr, numpages, false);
> +
> + WARN(ret, "Failed to decrypt memory, %d pages will be leaked",
> + numpages);
> +
> + return ret;
> + }
> +
> + static const struct arm64_mem_crypt_ops realm_crypt_ops = {
> + .encrypt = realm_set_memory_encrypted,
> + .decrypt = realm_set_memory_decrypted,
> + };
> +
> + int realm_register_memory_enc_ops(void)
> + {
> + return arm64_mem_crypt_ops_register(&realm_crypt_ops);
> + }
> +
> #ifdef CONFIG_DEBUG_PAGEALLOC
> void __kernel_map_pages(struct page *page, int numpages, int enable)
> {
This is now a conflict between the mm-stable tree and Linus' tree.
--
Cheers,
Stephen Rothwell
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: linux-next: manual merge of the arm64 tree with the mm tree
2024-10-28 0:10 linux-next: manual merge of the arm64 tree with the mm tree Stephen Rothwell
2024-10-28 17:25 ` Catalin Marinas
@ 2024-11-20 1:01 ` Stephen Rothwell
2024-11-20 1:09 ` Suren Baghdasaryan
1 sibling, 1 reply; 11+ messages in thread
From: Stephen Rothwell @ 2024-11-20 1:01 UTC (permalink / raw)
To: Andrew Morton
Cc: Catalin Marinas, Will Deacon, Linux Kernel Mailing List,
Linux Next Mailing List, Mark Brown, Suren Baghdasaryan
[-- Attachment #1: Type: text/plain, Size: 3146 bytes --]
Hi all,
On Mon, 28 Oct 2024 11:10:58 +1100 Stephen Rothwell <sfr@canb.auug.org.au> wrote:
>
> Today's linux-next merge of the arm64 tree got a conflict in:
>
> include/linux/mm.h
>
> between commit:
>
> e87ec503cf2e ("mm/codetag: uninline and move pgalloc_tag_copy and pgalloc_tag_split")
>
> from the mm-unstable branch of the mm tree and commit:
>
> 91e102e79740 ("prctl: arch-agnostic prctl for shadow stack")
>
> from the arm64 tree.
>
> I fixed it up (see below) and can carry the fix as necessary. This
> is now fixed as far as linux-next is concerned, but any non trivial
> conflicts should be mentioned to your upstream maintainer when your tree
> is submitted for merging. You may also want to consider cooperating
> with the maintainer of the conflicting tree to minimise any particularly
> complex conflicts.
>
> --
> Cheers,
> Stephen Rothwell
>
> diff --cc include/linux/mm.h
> index 086ba524d3ba,8852c39c7695..000000000000
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@@ -4166,4 -4174,65 +4178,8 @@@ static inline int do_mseal(unsigned lon
> }
> #endif
>
> -#ifdef CONFIG_MEM_ALLOC_PROFILING
> -static inline void pgalloc_tag_split(struct folio *folio, int old_order, int new_order)
> -{
> - int i;
> - struct alloc_tag *tag;
> - unsigned int nr_pages = 1 << new_order;
> -
> - if (!mem_alloc_profiling_enabled())
> - return;
> -
> - tag = pgalloc_tag_get(&folio->page);
> - if (!tag)
> - return;
> -
> - for (i = nr_pages; i < (1 << old_order); i += nr_pages) {
> - union codetag_ref *ref = get_page_tag_ref(folio_page(folio, i));
> -
> - if (ref) {
> - /* Set new reference to point to the original tag */
> - alloc_tag_ref_set(ref, tag);
> - put_page_tag_ref(ref);
> - }
> - }
> -}
> -
> -static inline void pgalloc_tag_copy(struct folio *new, struct folio *old)
> -{
> - struct alloc_tag *tag;
> - union codetag_ref *ref;
> -
> - tag = pgalloc_tag_get(&old->page);
> - if (!tag)
> - return;
> -
> - ref = get_page_tag_ref(&new->page);
> - if (!ref)
> - return;
> -
> - /* Clear the old ref to the original allocation tag. */
> - clear_page_tag_ref(&old->page);
> - /* Decrement the counters of the tag on get_new_folio. */
> - alloc_tag_sub(ref, folio_nr_pages(new));
> -
> - __alloc_tag_ref_set(ref, tag);
> -
> - put_page_tag_ref(ref);
> -}
> -#else /* !CONFIG_MEM_ALLOC_PROFILING */
> -static inline void pgalloc_tag_split(struct folio *folio, int old_order, int new_order)
> -{
> -}
> -
> -static inline void pgalloc_tag_copy(struct folio *new, struct folio *old)
> -{
> -}
> -#endif /* CONFIG_MEM_ALLOC_PROFILING */
> -
> + int arch_get_shadow_stack_status(struct task_struct *t, unsigned long __user *status);
> + int arch_set_shadow_stack_status(struct task_struct *t, unsigned long status);
> + int arch_lock_shadow_stack_status(struct task_struct *t, unsigned long status);
> +
> #endif /* _LINUX_MM_H */
This is now a conflict between the mm-stable tree and Linus' tree.
--
Cheers,
Stephen Rothwell
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: linux-next: manual merge of the arm64 tree with the mm tree
2024-11-20 1:01 ` Stephen Rothwell
@ 2024-11-20 1:09 ` Suren Baghdasaryan
2024-11-20 1:43 ` Suren Baghdasaryan
2024-11-20 2:57 ` Stephen Rothwell
0 siblings, 2 replies; 11+ messages in thread
From: Suren Baghdasaryan @ 2024-11-20 1:09 UTC (permalink / raw)
To: Stephen Rothwell
Cc: Andrew Morton, Catalin Marinas, Will Deacon,
Linux Kernel Mailing List, Linux Next Mailing List, Mark Brown
On Tue, Nov 19, 2024 at 5:01 PM Stephen Rothwell <sfr@canb.auug.org.au> wrote:
>
> Hi all,
>
> On Mon, 28 Oct 2024 11:10:58 +1100 Stephen Rothwell <sfr@canb.auug.org.au> wrote:
> >
> > Today's linux-next merge of the arm64 tree got a conflict in:
> >
> > include/linux/mm.h
> >
> > between commit:
> >
> > e87ec503cf2e ("mm/codetag: uninline and move pgalloc_tag_copy and pgalloc_tag_split")
> >
> > from the mm-unstable branch of the mm tree and commit:
> >
> > 91e102e79740 ("prctl: arch-agnostic prctl for shadow stack")
> >
> > from the arm64 tree.
> >
> > I fixed it up (see below) and can carry the fix as necessary. This
> > is now fixed as far as linux-next is concerned, but any non trivial
> > conflicts should be mentioned to your upstream maintainer when your tree
> > is submitted for merging. You may also want to consider cooperating
> > with the maintainer of the conflicting tree to minimise any particularly
> > complex conflicts.
> >
> > --
> > Cheers,
> > Stephen Rothwell
> >
> > diff --cc include/linux/mm.h
> > index 086ba524d3ba,8852c39c7695..000000000000
> > --- a/include/linux/mm.h
> > +++ b/include/linux/mm.h
> > @@@ -4166,4 -4174,65 +4178,8 @@@ static inline int do_mseal(unsigned lon
> > }
> > #endif
> >
> > -#ifdef CONFIG_MEM_ALLOC_PROFILING
> > -static inline void pgalloc_tag_split(struct folio *folio, int old_order, int new_order)
> > -{
> > - int i;
> > - struct alloc_tag *tag;
> > - unsigned int nr_pages = 1 << new_order;
> > -
> > - if (!mem_alloc_profiling_enabled())
> > - return;
> > -
> > - tag = pgalloc_tag_get(&folio->page);
> > - if (!tag)
> > - return;
> > -
> > - for (i = nr_pages; i < (1 << old_order); i += nr_pages) {
> > - union codetag_ref *ref = get_page_tag_ref(folio_page(folio, i));
> > -
> > - if (ref) {
> > - /* Set new reference to point to the original tag */
> > - alloc_tag_ref_set(ref, tag);
> > - put_page_tag_ref(ref);
> > - }
> > - }
> > -}
> > -
> > -static inline void pgalloc_tag_copy(struct folio *new, struct folio *old)
> > -{
> > - struct alloc_tag *tag;
> > - union codetag_ref *ref;
> > -
> > - tag = pgalloc_tag_get(&old->page);
> > - if (!tag)
> > - return;
> > -
> > - ref = get_page_tag_ref(&new->page);
> > - if (!ref)
> > - return;
> > -
> > - /* Clear the old ref to the original allocation tag. */
> > - clear_page_tag_ref(&old->page);
> > - /* Decrement the counters of the tag on get_new_folio. */
> > - alloc_tag_sub(ref, folio_nr_pages(new));
> > -
> > - __alloc_tag_ref_set(ref, tag);
> > -
> > - put_page_tag_ref(ref);
> > -}
> > -#else /* !CONFIG_MEM_ALLOC_PROFILING */
> > -static inline void pgalloc_tag_split(struct folio *folio, int old_order, int new_order)
> > -{
> > -}
> > -
> > -static inline void pgalloc_tag_copy(struct folio *new, struct folio *old)
> > -{
> > -}
> > -#endif /* CONFIG_MEM_ALLOC_PROFILING */
> > -
> > + int arch_get_shadow_stack_status(struct task_struct *t, unsigned long __user *status);
> > + int arch_set_shadow_stack_status(struct task_struct *t, unsigned long status);
> > + int arch_lock_shadow_stack_status(struct task_struct *t, unsigned long status);
> > +
> > #endif /* _LINUX_MM_H */
>
> This is now a conflict between the mm-stable tree and Linus' tree.
Let me try to manually apply it to Linus' ToT and will send a replacement patch.
>
> --
> Cheers,
> Stephen Rothwell
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: linux-next: manual merge of the arm64 tree with the mm tree
2024-11-20 1:09 ` Suren Baghdasaryan
@ 2024-11-20 1:43 ` Suren Baghdasaryan
2024-11-20 2:57 ` Stephen Rothwell
1 sibling, 0 replies; 11+ messages in thread
From: Suren Baghdasaryan @ 2024-11-20 1:43 UTC (permalink / raw)
To: Stephen Rothwell
Cc: Andrew Morton, Catalin Marinas, Will Deacon,
Linux Kernel Mailing List, Linux Next Mailing List, Mark Brown
[-- Attachment #1: Type: text/plain, Size: 4330 bytes --]
On Tue, Nov 19, 2024 at 5:09 PM Suren Baghdasaryan <surenb@google.com> wrote:
>
> On Tue, Nov 19, 2024 at 5:01 PM Stephen Rothwell <sfr@canb.auug.org.au> wrote:
> >
> > Hi all,
> >
> > On Mon, 28 Oct 2024 11:10:58 +1100 Stephen Rothwell <sfr@canb.auug.org.au> wrote:
> > >
> > > Today's linux-next merge of the arm64 tree got a conflict in:
> > >
> > > include/linux/mm.h
> > >
> > > between commit:
> > >
> > > e87ec503cf2e ("mm/codetag: uninline and move pgalloc_tag_copy and pgalloc_tag_split")
> > >
> > > from the mm-unstable branch of the mm tree and commit:
> > >
> > > 91e102e79740 ("prctl: arch-agnostic prctl for shadow stack")
> > >
> > > from the arm64 tree.
> > >
> > > I fixed it up (see below) and can carry the fix as necessary. This
> > > is now fixed as far as linux-next is concerned, but any non trivial
> > > conflicts should be mentioned to your upstream maintainer when your tree
> > > is submitted for merging. You may also want to consider cooperating
> > > with the maintainer of the conflicting tree to minimise any particularly
> > > complex conflicts.
> > >
> > > --
> > > Cheers,
> > > Stephen Rothwell
> > >
> > > diff --cc include/linux/mm.h
> > > index 086ba524d3ba,8852c39c7695..000000000000
> > > --- a/include/linux/mm.h
> > > +++ b/include/linux/mm.h
> > > @@@ -4166,4 -4174,65 +4178,8 @@@ static inline int do_mseal(unsigned lon
> > > }
> > > #endif
> > >
> > > -#ifdef CONFIG_MEM_ALLOC_PROFILING
> > > -static inline void pgalloc_tag_split(struct folio *folio, int old_order, int new_order)
> > > -{
> > > - int i;
> > > - struct alloc_tag *tag;
> > > - unsigned int nr_pages = 1 << new_order;
> > > -
> > > - if (!mem_alloc_profiling_enabled())
> > > - return;
> > > -
> > > - tag = pgalloc_tag_get(&folio->page);
> > > - if (!tag)
> > > - return;
> > > -
> > > - for (i = nr_pages; i < (1 << old_order); i += nr_pages) {
> > > - union codetag_ref *ref = get_page_tag_ref(folio_page(folio, i));
> > > -
> > > - if (ref) {
> > > - /* Set new reference to point to the original tag */
> > > - alloc_tag_ref_set(ref, tag);
> > > - put_page_tag_ref(ref);
> > > - }
> > > - }
> > > -}
> > > -
> > > -static inline void pgalloc_tag_copy(struct folio *new, struct folio *old)
> > > -{
> > > - struct alloc_tag *tag;
> > > - union codetag_ref *ref;
> > > -
> > > - tag = pgalloc_tag_get(&old->page);
> > > - if (!tag)
> > > - return;
> > > -
> > > - ref = get_page_tag_ref(&new->page);
> > > - if (!ref)
> > > - return;
> > > -
> > > - /* Clear the old ref to the original allocation tag. */
> > > - clear_page_tag_ref(&old->page);
> > > - /* Decrement the counters of the tag on get_new_folio. */
> > > - alloc_tag_sub(ref, folio_nr_pages(new));
> > > -
> > > - __alloc_tag_ref_set(ref, tag);
> > > -
> > > - put_page_tag_ref(ref);
> > > -}
> > > -#else /* !CONFIG_MEM_ALLOC_PROFILING */
> > > -static inline void pgalloc_tag_split(struct folio *folio, int old_order, int new_order)
> > > -{
> > > -}
> > > -
> > > -static inline void pgalloc_tag_copy(struct folio *new, struct folio *old)
> > > -{
> > > -}
> > > -#endif /* CONFIG_MEM_ALLOC_PROFILING */
> > > -
> > > + int arch_get_shadow_stack_status(struct task_struct *t, unsigned long __user *status);
> > > + int arch_set_shadow_stack_status(struct task_struct *t, unsigned long status);
> > > + int arch_lock_shadow_stack_status(struct task_struct *t, unsigned long status);
> > > +
> > > #endif /* _LINUX_MM_H */
> >
> > This is now a conflict between the mm-stable tree and Linus' tree.
>
> Let me try to manually apply it to Linus' ToT and will send a replacement patch.
Attached patch should apply to Linus' tree but please make sure the
following two patches from mm-stable are merged before this one
because there are dependencies between them:
ed265529d39a mm/codetag: fix arg in pgalloc_tag_copy alloc_tag_sub
42895a861244 alloc_tag: introduce pgtag_ref_handle to abstract page
tag references
>
> >
> > --
> > Cheers,
> > Stephen Rothwell
[-- Attachment #2: 0001-mm-codetag-uninline-and-move-pgalloc_tag_copy-and-pg.patch --]
[-- Type: text/x-patch, Size: 5954 bytes --]
From a9df77cdc42c06b068f782b4733855413d2ff926 Mon Sep 17 00:00:00 2001
From: Suren Baghdasaryan <surenb@google.com>
Date: Thu, 24 Oct 2024 09:23:18 -0700
Subject: [PATCH 1/1] mm/codetag: uninline and move pgalloc_tag_copy and
pgalloc_tag_split
pgalloc_tag_copy() and pgalloc_tag_split() are sizable and outside of any
performance-critical paths, so it should be fine to uninline them. Also
move their declarations into pgalloc_tag.h which seems like a more
appropriate place for them. No functional changes other than uninlining.
Link: https://lkml.kernel.org/r/20241024162318.1640781-1-surenb@google.com
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Suggested-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Yu Zhao <yuzhao@google.com>
Cc: Kent Overstreet <kent.overstreet@linux.dev>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Sourav Panda <souravpanda@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
include/linux/mm.h | 58 -------------------------------------
include/linux/pgalloc_tag.h | 5 ++++
lib/alloc_tag.c | 48 ++++++++++++++++++++++++++++++
3 files changed, 53 insertions(+), 58 deletions(-)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index c36dc44ab91f..8bad7918f5d9 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -4175,64 +4175,6 @@ static inline int do_mseal(unsigned long start, size_t len_in, unsigned long fla
}
#endif
-#ifdef CONFIG_MEM_ALLOC_PROFILING
-static inline void pgalloc_tag_split(struct folio *folio, int old_order, int new_order)
-{
- int i;
- struct alloc_tag *tag;
- unsigned int nr_pages = 1 << new_order;
-
- if (!mem_alloc_profiling_enabled())
- return;
-
- tag = pgalloc_tag_get(&folio->page);
- if (!tag)
- return;
-
- for (i = nr_pages; i < (1 << old_order); i += nr_pages) {
- union pgtag_ref_handle handle;
- union codetag_ref ref;
-
- if (get_page_tag_ref(folio_page(folio, i), &ref, &handle)) {
- /* Set new reference to point to the original tag */
- alloc_tag_ref_set(&ref, tag);
- update_page_tag_ref(handle, &ref);
- put_page_tag_ref(handle);
- }
- }
-}
-
-static inline void pgalloc_tag_copy(struct folio *new, struct folio *old)
-{
- union pgtag_ref_handle handle;
- union codetag_ref ref;
- struct alloc_tag *tag;
-
- tag = pgalloc_tag_get(&old->page);
- if (!tag)
- return;
-
- if (!get_page_tag_ref(&new->page, &ref, &handle))
- return;
-
- /* Clear the old ref to the original allocation tag. */
- clear_page_tag_ref(&old->page);
- /* Decrement the counters of the tag on get_new_folio. */
- alloc_tag_sub(&ref, folio_size(new));
- __alloc_tag_ref_set(&ref, tag);
- update_page_tag_ref(handle, &ref);
- put_page_tag_ref(handle);
-}
-#else /* !CONFIG_MEM_ALLOC_PROFILING */
-static inline void pgalloc_tag_split(struct folio *folio, int old_order, int new_order)
-{
-}
-
-static inline void pgalloc_tag_copy(struct folio *new, struct folio *old)
-{
-}
-#endif /* CONFIG_MEM_ALLOC_PROFILING */
-
int arch_get_shadow_stack_status(struct task_struct *t, unsigned long __user *status);
int arch_set_shadow_stack_status(struct task_struct *t, unsigned long status);
int arch_lock_shadow_stack_status(struct task_struct *t, unsigned long status);
diff --git a/include/linux/pgalloc_tag.h b/include/linux/pgalloc_tag.h
index b13cd3313a88..a942b5a03ebf 100644
--- a/include/linux/pgalloc_tag.h
+++ b/include/linux/pgalloc_tag.h
@@ -122,6 +122,9 @@ static inline void pgalloc_tag_sub_pages(struct alloc_tag *tag, unsigned int nr)
this_cpu_sub(tag->counters->bytes, PAGE_SIZE * nr);
}
+void pgalloc_tag_split(struct folio *folio, int old_order, int new_order);
+void pgalloc_tag_copy(struct folio *new, struct folio *old);
+
#else /* CONFIG_MEM_ALLOC_PROFILING */
static inline void clear_page_tag_ref(struct page *page) {}
@@ -130,6 +133,8 @@ static inline void pgalloc_tag_add(struct page *page, struct task_struct *task,
static inline void pgalloc_tag_sub(struct page *page, unsigned int nr) {}
static inline struct alloc_tag *pgalloc_tag_get(struct page *page) { return NULL; }
static inline void pgalloc_tag_sub_pages(struct alloc_tag *tag, unsigned int nr) {}
+static inline void pgalloc_tag_split(struct folio *folio, int old_order, int new_order) {}
+static inline void pgalloc_tag_copy(struct folio *new, struct folio *old) {}
#endif /* CONFIG_MEM_ALLOC_PROFILING */
diff --git a/lib/alloc_tag.c b/lib/alloc_tag.c
index 81e5f9a70f22..f2790272a603 100644
--- a/lib/alloc_tag.c
+++ b/lib/alloc_tag.c
@@ -144,6 +144,54 @@ size_t alloc_tag_top_users(struct codetag_bytes *tags, size_t count, bool can_sl
return nr;
}
+void pgalloc_tag_split(struct folio *folio, int old_order, int new_order)
+{
+ int i;
+ struct alloc_tag *tag;
+ unsigned int nr_pages = 1 << new_order;
+
+ if (!mem_alloc_profiling_enabled())
+ return;
+
+ tag = pgalloc_tag_get(&folio->page);
+ if (!tag)
+ return;
+
+ for (i = nr_pages; i < (1 << old_order); i += nr_pages) {
+ union pgtag_ref_handle handle;
+ union codetag_ref ref;
+
+ if (get_page_tag_ref(folio_page(folio, i), &ref, &handle)) {
+ /* Set new reference to point to the original tag */
+ alloc_tag_ref_set(&ref, tag);
+ update_page_tag_ref(handle, &ref);
+ put_page_tag_ref(handle);
+ }
+ }
+}
+
+void pgalloc_tag_copy(struct folio *new, struct folio *old)
+{
+ union pgtag_ref_handle handle;
+ union codetag_ref ref;
+ struct alloc_tag *tag;
+
+ tag = pgalloc_tag_get(&old->page);
+ if (!tag)
+ return;
+
+ if (!get_page_tag_ref(&new->page, &ref, &handle))
+ return;
+
+ /* Clear the old ref to the original allocation tag. */
+ clear_page_tag_ref(&old->page);
+ /* Decrement the counters of the tag on get_new_folio. */
+ alloc_tag_sub(&ref, folio_size(new));
+ __alloc_tag_ref_set(&ref, tag);
+ update_page_tag_ref(handle, &ref);
+ put_page_tag_ref(handle);
+}
+
static void __init procfs_init(void)
{
proc_create_seq("allocinfo", 0400, NULL, &allocinfo_seq_op);
--
2.47.0.338.g60cca15819-goog
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: linux-next: manual merge of the arm64 tree with the mm tree
2024-11-20 1:09 ` Suren Baghdasaryan
2024-11-20 1:43 ` Suren Baghdasaryan
@ 2024-11-20 2:57 ` Stephen Rothwell
2024-11-20 3:18 ` Suren Baghdasaryan
1 sibling, 1 reply; 11+ messages in thread
From: Stephen Rothwell @ 2024-11-20 2:57 UTC (permalink / raw)
To: Suren Baghdasaryan
Cc: Andrew Morton, Catalin Marinas, Will Deacon,
Linux Kernel Mailing List, Linux Next Mailing List, Mark Brown
[-- Attachment #1: Type: text/plain, Size: 366 bytes --]
Hi Suren,
On Tue, 19 Nov 2024 17:09:46 -0800 Suren Baghdasaryan <surenb@google.com> wrote:
>
> Let me try to manually apply it to Linus' ToT and will send a replacement patch.
Please don't. Andrew will tell Linus about the conflict (he has done,
I think) and Linus will just fix it up when he merges the mm-stable
tree.
--
Cheers,
Stephen Rothwell
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: linux-next: manual merge of the arm64 tree with the mm tree
2024-11-20 2:57 ` Stephen Rothwell
@ 2024-11-20 3:18 ` Suren Baghdasaryan
0 siblings, 0 replies; 11+ messages in thread
From: Suren Baghdasaryan @ 2024-11-20 3:18 UTC (permalink / raw)
To: Stephen Rothwell
Cc: Andrew Morton, Catalin Marinas, Will Deacon,
Linux Kernel Mailing List, Linux Next Mailing List, Mark Brown
On Tue, Nov 19, 2024 at 6:57 PM Stephen Rothwell <sfr@canb.auug.org.au> wrote:
>
> Hi Suren,
>
> On Tue, 19 Nov 2024 17:09:46 -0800 Suren Baghdasaryan <surenb@google.com> wrote:
> >
> > Let me try to manually apply it to Linus' ToT and will send a replacement patch.
>
> Please don't. Andrew will tell Linus about the conflict (he has done,
> I think) and Linus will just fix it up when he merges the mm-stable
> tree.
Sounds good.
I attached the promised patch in my previous reply but I guess it
won't be needed.
>
> --
> Cheers,
> Stephen Rothwell
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2024-11-20 3:18 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-28 0:10 linux-next: manual merge of the arm64 tree with the mm tree Stephen Rothwell
2024-10-28 17:25 ` Catalin Marinas
2024-10-28 17:47 ` Suren Baghdasaryan
2024-11-20 1:01 ` Stephen Rothwell
2024-11-20 1:09 ` Suren Baghdasaryan
2024-11-20 1:43 ` Suren Baghdasaryan
2024-11-20 2:57 ` Stephen Rothwell
2024-11-20 3:18 ` Suren Baghdasaryan
-- strict thread matches above, loose matches on Subject: below --
2024-10-23 23:37 Stephen Rothwell
2024-10-24 8:14 ` Catalin Marinas
2024-11-20 0:58 ` Stephen Rothwell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox