All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 6.1.y] LoongArch: Fix build errors due to backported TIMENS
@ 2024-11-02  3:36 Huacai Chen
  2024-11-06  7:27 ` Patch "LoongArch: Fix build errors due to backported TIMENS" has been added to the 6.1-stable tree gregkh
  2024-11-06  7:27 ` [PATCH 6.1.y] LoongArch: Fix build errors due to backported TIMENS Greg Kroah-Hartman
  0 siblings, 2 replies; 3+ messages in thread
From: Huacai Chen @ 2024-11-02  3:36 UTC (permalink / raw)
  To: Huacai Chen
  Cc: Xuerui Wang, loongarch, Greg Kroah-Hartman, Sasha Levin, stable,
	Jiaxun Yang, linux-kernel, Huacai Chen

Commit eb3710efffce1dcff83761db4615f91d93aabfcb ("LoongArch: Add support
to clone a time namespace") backports the TIMENS support for LoongArch
(corresponding upstream commit aa5e65dc0818bbf676bf06927368ec46867778fd)
but causes build errors:

  CC      arch/loongarch/kernel/vdso.o
arch/loongarch/kernel/vdso.c: In function ‘vvar_fault’:
arch/loongarch/kernel/vdso.c:54:36: error: implicit declaration of
function ‘find_timens_vvar_page’ [-Werror=implicit-function-declaration]
   54 |         struct page *timens_page = find_timens_vvar_page(vma);
      |                                    ^~~~~~~~~~~~~~~~~~~~~
arch/loongarch/kernel/vdso.c:54:36: warning: initialization of ‘struct
page *’ from ‘int’ makes pointer from integer without a cast
[-Wint-conversion]
arch/loongarch/kernel/vdso.c: In function ‘vdso_join_timens’:
arch/loongarch/kernel/vdso.c:143:25: error: implicit declaration of
function ‘zap_vma_pages’; did you mean ‘zap_vma_ptes’?
[-Werror=implicit-function-declaration]
  143 |                         zap_vma_pages(vma);
      |                         ^~~~~~~~~~~~~
      |                         zap_vma_ptes
cc1: some warnings being treated as errors

Because in 6.1.y we should define find_timens_vvar_page() by ourselves
and use zap_page_range() instead of zap_vma_pages(), so fix it.

Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
---
 arch/loongarch/kernel/vdso.c | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/arch/loongarch/kernel/vdso.c b/arch/loongarch/kernel/vdso.c
index 59aa9dd466e8..64eb5386e7b2 100644
--- a/arch/loongarch/kernel/vdso.c
+++ b/arch/loongarch/kernel/vdso.c
@@ -40,6 +40,8 @@ static struct page *vdso_pages[] = { NULL };
 struct vdso_data *vdso_data = generic_vdso_data.data;
 struct vdso_pcpu_data *vdso_pdata = loongarch_vdso_data.vdata.pdata;
 
+static struct page *find_timens_vvar_page(struct vm_area_struct *vma);
+
 static int vdso_mremap(const struct vm_special_mapping *sm, struct vm_area_struct *new_vma)
 {
 	current->mm->context.vdso = (void *)(new_vma->vm_start);
@@ -139,13 +141,37 @@ int vdso_join_timens(struct task_struct *task, struct time_namespace *ns)
 
 	mmap_read_lock(mm);
 	for_each_vma(vmi, vma) {
+		unsigned long size = vma->vm_end - vma->vm_start;
+
 		if (vma_is_special_mapping(vma, &vdso_info.data_mapping))
-			zap_vma_pages(vma);
+			zap_page_range(vma, vma->vm_start, size);
 	}
 	mmap_read_unlock(mm);
 
 	return 0;
 }
+
+static struct page *find_timens_vvar_page(struct vm_area_struct *vma)
+{
+	if (likely(vma->vm_mm == current->mm))
+		return current->nsproxy->time_ns->vvar_page;
+
+	/*
+	 * VM_PFNMAP | VM_IO protect .fault() handler from being called
+	 * through interfaces like /proc/$pid/mem or
+	 * process_vm_{readv,writev}() as long as there's no .access()
+	 * in special_mapping_vmops.
+	 * For more details check_vma_flags() and __access_remote_vm()
+	 */
+	WARN(1, "vvar_page accessed remotely");
+
+	return NULL;
+}
+#else
+static struct page *find_timens_vvar_page(struct vm_area_struct *vma)
+{
+	return NULL;
+}
 #endif
 
 static unsigned long vdso_base(void)
-- 
2.43.5


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Patch "LoongArch: Fix build errors due to backported TIMENS" has been added to the 6.1-stable tree
  2024-11-02  3:36 [PATCH 6.1.y] LoongArch: Fix build errors due to backported TIMENS Huacai Chen
@ 2024-11-06  7:27 ` gregkh
  2024-11-06  7:27 ` [PATCH 6.1.y] LoongArch: Fix build errors due to backported TIMENS Greg Kroah-Hartman
  1 sibling, 0 replies; 3+ messages in thread
From: gregkh @ 2024-11-06  7:27 UTC (permalink / raw)
  To: chenhuacai, chenhuacai, gregkh, jiaxun.yang, kernel, loongarch,
	sashal
  Cc: stable-commits


This is a note to let you know that I've just added the patch titled

    LoongArch: Fix build errors due to backported TIMENS

to the 6.1-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     loongarch-fix-build-errors-due-to-backported-timens.patch
and it can be found in the queue-6.1 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.


From chenhuacai@loongson.cn  Wed Nov  6 08:26:52 2024
From: Huacai Chen <chenhuacai@loongson.cn>
Date: Sat,  2 Nov 2024 11:36:16 +0800
Subject: LoongArch: Fix build errors due to backported TIMENS
To: Huacai Chen <chenhuacai@kernel.org>
Cc: Xuerui Wang <kernel@xen0n.name>, loongarch@lists.linux.dev, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Sasha Levin <sashal@kernel.org>, stable@vger.kernel.org, Jiaxun Yang <jiaxun.yang@flygoat.com>, linux-kernel@vger.kernel.org, Huacai Chen <chenhuacai@loongson.cn>
Message-ID: <20241102033616.3517188-1-chenhuacai@loongson.cn>

From: Huacai Chen <chenhuacai@loongson.cn>

Commit eb3710efffce1dcff83761db4615f91d93aabfcb ("LoongArch: Add support
to clone a time namespace") backports the TIMENS support for LoongArch
(corresponding upstream commit aa5e65dc0818bbf676bf06927368ec46867778fd)
but causes build errors:

  CC      arch/loongarch/kernel/vdso.o
arch/loongarch/kernel/vdso.c: In function ‘vvar_fault’:
arch/loongarch/kernel/vdso.c:54:36: error: implicit declaration of
function ‘find_timens_vvar_page’ [-Werror=implicit-function-declaration]
   54 |         struct page *timens_page = find_timens_vvar_page(vma);
      |                                    ^~~~~~~~~~~~~~~~~~~~~
arch/loongarch/kernel/vdso.c:54:36: warning: initialization of ‘struct
page *’ from ‘int’ makes pointer from integer without a cast
[-Wint-conversion]
arch/loongarch/kernel/vdso.c: In function ‘vdso_join_timens’:
arch/loongarch/kernel/vdso.c:143:25: error: implicit declaration of
function ‘zap_vma_pages’; did you mean ‘zap_vma_ptes’?
[-Werror=implicit-function-declaration]
  143 |                         zap_vma_pages(vma);
      |                         ^~~~~~~~~~~~~
      |                         zap_vma_ptes
cc1: some warnings being treated as errors

Because in 6.1.y we should define find_timens_vvar_page() by ourselves
and use zap_page_range() instead of zap_vma_pages(), so fix it.

Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
---
 arch/loongarch/kernel/vdso.c |   28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

--- a/arch/loongarch/kernel/vdso.c
+++ b/arch/loongarch/kernel/vdso.c
@@ -40,6 +40,8 @@ static struct page *vdso_pages[] = { NUL
 struct vdso_data *vdso_data = generic_vdso_data.data;
 struct vdso_pcpu_data *vdso_pdata = loongarch_vdso_data.vdata.pdata;
 
+static struct page *find_timens_vvar_page(struct vm_area_struct *vma);
+
 static int vdso_mremap(const struct vm_special_mapping *sm, struct vm_area_struct *new_vma)
 {
 	current->mm->context.vdso = (void *)(new_vma->vm_start);
@@ -139,13 +141,37 @@ int vdso_join_timens(struct task_struct
 
 	mmap_read_lock(mm);
 	for_each_vma(vmi, vma) {
+		unsigned long size = vma->vm_end - vma->vm_start;
+
 		if (vma_is_special_mapping(vma, &vdso_info.data_mapping))
-			zap_vma_pages(vma);
+			zap_page_range(vma, vma->vm_start, size);
 	}
 	mmap_read_unlock(mm);
 
 	return 0;
 }
+
+static struct page *find_timens_vvar_page(struct vm_area_struct *vma)
+{
+	if (likely(vma->vm_mm == current->mm))
+		return current->nsproxy->time_ns->vvar_page;
+
+	/*
+	 * VM_PFNMAP | VM_IO protect .fault() handler from being called
+	 * through interfaces like /proc/$pid/mem or
+	 * process_vm_{readv,writev}() as long as there's no .access()
+	 * in special_mapping_vmops.
+	 * For more details check_vma_flags() and __access_remote_vm()
+	 */
+	WARN(1, "vvar_page accessed remotely");
+
+	return NULL;
+}
+#else
+static struct page *find_timens_vvar_page(struct vm_area_struct *vma)
+{
+	return NULL;
+}
 #endif
 
 static unsigned long vdso_base(void)


Patches currently in stable-queue which might be from chenhuacai@loongson.cn are

queue-6.1/loongarch-fix-build-errors-due-to-backported-timens.patch

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 6.1.y] LoongArch: Fix build errors due to backported TIMENS
  2024-11-02  3:36 [PATCH 6.1.y] LoongArch: Fix build errors due to backported TIMENS Huacai Chen
  2024-11-06  7:27 ` Patch "LoongArch: Fix build errors due to backported TIMENS" has been added to the 6.1-stable tree gregkh
@ 2024-11-06  7:27 ` Greg Kroah-Hartman
  1 sibling, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2024-11-06  7:27 UTC (permalink / raw)
  To: Huacai Chen
  Cc: Huacai Chen, Xuerui Wang, loongarch, Sasha Levin, stable,
	Jiaxun Yang, linux-kernel

On Sat, Nov 02, 2024 at 11:36:16AM +0800, Huacai Chen wrote:
> Commit eb3710efffce1dcff83761db4615f91d93aabfcb ("LoongArch: Add support
> to clone a time namespace") backports the TIMENS support for LoongArch
> (corresponding upstream commit aa5e65dc0818bbf676bf06927368ec46867778fd)
> but causes build errors:
> 
>   CC      arch/loongarch/kernel/vdso.o
> arch/loongarch/kernel/vdso.c: In function ‘vvar_fault’:
> arch/loongarch/kernel/vdso.c:54:36: error: implicit declaration of
> function ‘find_timens_vvar_page’ [-Werror=implicit-function-declaration]
>    54 |         struct page *timens_page = find_timens_vvar_page(vma);
>       |                                    ^~~~~~~~~~~~~~~~~~~~~
> arch/loongarch/kernel/vdso.c:54:36: warning: initialization of ‘struct
> page *’ from ‘int’ makes pointer from integer without a cast
> [-Wint-conversion]
> arch/loongarch/kernel/vdso.c: In function ‘vdso_join_timens’:
> arch/loongarch/kernel/vdso.c:143:25: error: implicit declaration of
> function ‘zap_vma_pages’; did you mean ‘zap_vma_ptes’?
> [-Werror=implicit-function-declaration]
>   143 |                         zap_vma_pages(vma);
>       |                         ^~~~~~~~~~~~~
>       |                         zap_vma_ptes
> cc1: some warnings being treated as errors
> 
> Because in 6.1.y we should define find_timens_vvar_page() by ourselves
> and use zap_page_range() instead of zap_vma_pages(), so fix it.
> 
> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
> ---
>  arch/loongarch/kernel/vdso.c | 28 +++++++++++++++++++++++++++-
>  1 file changed, 27 insertions(+), 1 deletion(-)

Now queued up, thanks!

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-11-06  7:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-02  3:36 [PATCH 6.1.y] LoongArch: Fix build errors due to backported TIMENS Huacai Chen
2024-11-06  7:27 ` Patch "LoongArch: Fix build errors due to backported TIMENS" has been added to the 6.1-stable tree gregkh
2024-11-06  7:27 ` [PATCH 6.1.y] LoongArch: Fix build errors due to backported TIMENS Greg Kroah-Hartman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.