linux-sgx.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] mm: cleanup with VM_ACCESS_FLAGS
@ 2022-10-19  3:49 Kefeng Wang
  2022-10-19  3:49 ` [PATCH 1/5] nios2: remove unused INIT_MMAP Kefeng Wang
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Kefeng Wang @ 2022-10-19  3:49 UTC (permalink / raw)
  To: linux-kernel, Andrew Morton
  Cc: Dinh Nguyen, Jarkko Sakkinen, Dave Hansen, linux-sgx, amd-gfx,
	linux-mm, Kefeng Wang

Kefeng Wang (5):
  nios2: remove unused INIT_MMAP
  x86/sgx: use VM_ACCESS_FLAGS
  mm: mprotect: use VM_ACCESS_FLAGS
  mm: debug_vm_pgtable: use VM_ACCESS_FLAGS
  amdgpu: use VM_ACCESS_FLAGS

 arch/nios2/include/asm/processor.h      | 3 ---
 arch/x86/kernel/cpu/sgx/encl.c          | 4 ++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 2 +-
 mm/debug_vm_pgtable.c                   | 8 ++------
 mm/mprotect.c                           | 3 +--
 5 files changed, 6 insertions(+), 14 deletions(-)

-- 
2.35.3


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

* [PATCH 1/5] nios2: remove unused INIT_MMAP
  2022-10-19  3:49 [PATCH 0/5] mm: cleanup with VM_ACCESS_FLAGS Kefeng Wang
@ 2022-10-19  3:49 ` Kefeng Wang
  2022-10-19  3:49 ` [PATCH 2/5] x86/sgx: use VM_ACCESS_FLAGS Kefeng Wang
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Kefeng Wang @ 2022-10-19  3:49 UTC (permalink / raw)
  To: linux-kernel, Andrew Morton
  Cc: Dinh Nguyen, Jarkko Sakkinen, Dave Hansen, linux-sgx, amd-gfx,
	linux-mm, Kefeng Wang

It seems that INIT_MMAP is gone in 2.4.10, not sure,
anyways, it is useless now, kill it.

Cc: Dinh Nguyen <dinguyen@kernel.org>
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 arch/nios2/include/asm/processor.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/arch/nios2/include/asm/processor.h b/arch/nios2/include/asm/processor.h
index 8916d93d5c2d..eb44130364a9 100644
--- a/arch/nios2/include/asm/processor.h
+++ b/arch/nios2/include/asm/processor.h
@@ -50,9 +50,6 @@ struct thread_struct {
 	unsigned long kpsr;
 };
 
-#define INIT_MMAP \
-	{ &init_mm, (0), (0), __pgprot(0x0), VM_READ | VM_WRITE | VM_EXEC }
-
 # define INIT_THREAD {			\
 	.kregs	= NULL,			\
 	.ksp	= 0,			\
-- 
2.35.3


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

* [PATCH 2/5] x86/sgx: use VM_ACCESS_FLAGS
  2022-10-19  3:49 [PATCH 0/5] mm: cleanup with VM_ACCESS_FLAGS Kefeng Wang
  2022-10-19  3:49 ` [PATCH 1/5] nios2: remove unused INIT_MMAP Kefeng Wang
@ 2022-10-19  3:49 ` Kefeng Wang
  2022-10-23 20:07   ` Jarkko Sakkinen
  2022-10-19  3:49 ` [PATCH 3/5] mm: mprotect: " Kefeng Wang
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 8+ messages in thread
From: Kefeng Wang @ 2022-10-19  3:49 UTC (permalink / raw)
  To: linux-kernel, Andrew Morton
  Cc: Dinh Nguyen, Jarkko Sakkinen, Dave Hansen, linux-sgx, amd-gfx,
	linux-mm, Kefeng Wang

Simplify VM_READ|VM_WRITE|VM_EXEC with VM_ACCESS_FLAGS.

Cc: Jarkko Sakkinen <jarkko@kernel.org>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 arch/x86/kernel/cpu/sgx/encl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/cpu/sgx/encl.c b/arch/x86/kernel/cpu/sgx/encl.c
index 1ec20807de1e..6225c525372d 100644
--- a/arch/x86/kernel/cpu/sgx/encl.c
+++ b/arch/x86/kernel/cpu/sgx/encl.c
@@ -268,7 +268,7 @@ static struct sgx_encl_page *sgx_encl_load_page_in_vma(struct sgx_encl *encl,
 						       unsigned long addr,
 						       unsigned long vm_flags)
 {
-	unsigned long vm_prot_bits = vm_flags & (VM_READ | VM_WRITE | VM_EXEC);
+	unsigned long vm_prot_bits = vm_flags & VM_ACCESS_FLAGS;
 	struct sgx_encl_page *entry;
 
 	entry = xa_load(&encl->page_array, PFN_DOWN(addr));
@@ -502,7 +502,7 @@ static void sgx_vma_open(struct vm_area_struct *vma)
 int sgx_encl_may_map(struct sgx_encl *encl, unsigned long start,
 		     unsigned long end, unsigned long vm_flags)
 {
-	unsigned long vm_prot_bits = vm_flags & (VM_READ | VM_WRITE | VM_EXEC);
+	unsigned long vm_prot_bits = vm_flags & VM_ACCESS_FLAGS;
 	struct sgx_encl_page *page;
 	unsigned long count = 0;
 	int ret = 0;
-- 
2.35.3


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

* [PATCH 3/5] mm: mprotect: use VM_ACCESS_FLAGS
  2022-10-19  3:49 [PATCH 0/5] mm: cleanup with VM_ACCESS_FLAGS Kefeng Wang
  2022-10-19  3:49 ` [PATCH 1/5] nios2: remove unused INIT_MMAP Kefeng Wang
  2022-10-19  3:49 ` [PATCH 2/5] x86/sgx: use VM_ACCESS_FLAGS Kefeng Wang
@ 2022-10-19  3:49 ` Kefeng Wang
  2022-10-19  3:49 ` [PATCH 4/5] mm: debug_vm_pgtable: " Kefeng Wang
  2022-10-19  3:49 ` [PATCH 5/5] amdgpu: " Kefeng Wang
  4 siblings, 0 replies; 8+ messages in thread
From: Kefeng Wang @ 2022-10-19  3:49 UTC (permalink / raw)
  To: linux-kernel, Andrew Morton
  Cc: Dinh Nguyen, Jarkko Sakkinen, Dave Hansen, linux-sgx, amd-gfx,
	linux-mm, Kefeng Wang

Simplify VM_READ|VM_WRITE|VM_EXEC with VM_ACCESS_FLAGS.

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 mm/mprotect.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/mm/mprotect.c b/mm/mprotect.c
index 668bfaa6ed2a..99762403cc8f 100644
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -756,8 +756,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len,
 		 * If a permission is not passed to mprotect(), it must be
 		 * cleared from the VMA.
 		 */
-		mask_off_old_flags = VM_READ | VM_WRITE | VM_EXEC |
-					VM_FLAGS_CLEAR;
+		mask_off_old_flags = VM_ACCESS_FLAGS | VM_FLAGS_CLEAR;
 
 		new_vma_pkey = arch_override_mprotect_pkey(vma, prot, pkey);
 		newflags = calc_vm_prot_bits(prot, new_vma_pkey);
-- 
2.35.3


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

* [PATCH 4/5] mm: debug_vm_pgtable: use VM_ACCESS_FLAGS
  2022-10-19  3:49 [PATCH 0/5] mm: cleanup with VM_ACCESS_FLAGS Kefeng Wang
                   ` (2 preceding siblings ...)
  2022-10-19  3:49 ` [PATCH 3/5] mm: mprotect: " Kefeng Wang
@ 2022-10-19  3:49 ` Kefeng Wang
  2022-10-19  3:49 ` [PATCH 5/5] amdgpu: " Kefeng Wang
  4 siblings, 0 replies; 8+ messages in thread
From: Kefeng Wang @ 2022-10-19  3:49 UTC (permalink / raw)
  To: linux-kernel, Andrew Morton
  Cc: Dinh Nguyen, Jarkko Sakkinen, Dave Hansen, linux-sgx, amd-gfx,
	linux-mm, Kefeng Wang

Directly use VM_ACCESS_FLAGS instead VMFLAGS.

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 mm/debug_vm_pgtable.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/mm/debug_vm_pgtable.c b/mm/debug_vm_pgtable.c
index dc7df1254f0a..2b61fde8c38c 100644
--- a/mm/debug_vm_pgtable.c
+++ b/mm/debug_vm_pgtable.c
@@ -38,11 +38,7 @@
  * Please refer Documentation/mm/arch_pgtable_helpers.rst for the semantics
  * expectations that are being validated here. All future changes in here
  * or the documentation need to be in sync.
- */
-
-#define VMFLAGS	(VM_READ|VM_WRITE|VM_EXEC)
-
-/*
+ *
  * On s390 platform, the lower 4 bits are used to identify given page table
  * entry type. But these bits might affect the ability to clear entries with
  * pxx_clear() because of how dynamic page table folding works on s390. So
@@ -1125,7 +1121,7 @@ static int __init init_args(struct pgtable_debug_args *args)
 	 */
 	memset(args, 0, sizeof(*args));
 	args->vaddr              = get_random_vaddr();
-	args->page_prot          = vm_get_page_prot(VMFLAGS);
+	args->page_prot          = vm_get_page_prot(VM_ACCESS_FLAGS);
 	args->page_prot_none     = vm_get_page_prot(VM_NONE);
 	args->is_contiguous_page = false;
 	args->pud_pfn            = ULONG_MAX;
-- 
2.35.3


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

* [PATCH 5/5] amdgpu: use VM_ACCESS_FLAGS
  2022-10-19  3:49 [PATCH 0/5] mm: cleanup with VM_ACCESS_FLAGS Kefeng Wang
                   ` (3 preceding siblings ...)
  2022-10-19  3:49 ` [PATCH 4/5] mm: debug_vm_pgtable: " Kefeng Wang
@ 2022-10-19  3:49 ` Kefeng Wang
  4 siblings, 0 replies; 8+ messages in thread
From: Kefeng Wang @ 2022-10-19  3:49 UTC (permalink / raw)
  To: linux-kernel, Andrew Morton
  Cc: Dinh Nguyen, Jarkko Sakkinen, Dave Hansen, linux-sgx, amd-gfx,
	linux-mm, Kefeng Wang, Alex Deucher, Christian König, Pan,
	Xinhui, David Airlie, Daniel Vetter

Simplify VM_READ|VM_WRITE|VM_EXEC with VM_ACCESS_FLAGS.

Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: "Christian König" <christian.koenig@amd.com>
Cc: "Pan, Xinhui" <Xinhui.Pan@amd.com>
Cc: David Airlie <airlied@gmail.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
index 8ef31d687ef3..4728be161828 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
@@ -255,7 +255,7 @@ static int amdgpu_gem_object_mmap(struct drm_gem_object *obj, struct vm_area_str
 	 * becoming writable and makes is_cow_mapping(vm_flags) false.
 	 */
 	if (is_cow_mapping(vma->vm_flags) &&
-	    !(vma->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)))
+	    !(vma->vm_flags & VM_ACCESS_FLAGS))
 		vma->vm_flags &= ~VM_MAYWRITE;
 
 	return drm_gem_ttm_mmap(obj, vma);
-- 
2.35.3


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

* Re: [PATCH 2/5] x86/sgx: use VM_ACCESS_FLAGS
  2022-10-19  3:49 ` [PATCH 2/5] x86/sgx: use VM_ACCESS_FLAGS Kefeng Wang
@ 2022-10-23 20:07   ` Jarkko Sakkinen
  2022-10-23 20:09     ` Jarkko Sakkinen
  0 siblings, 1 reply; 8+ messages in thread
From: Jarkko Sakkinen @ 2022-10-23 20:07 UTC (permalink / raw)
  To: Kefeng Wang
  Cc: linux-kernel, Andrew Morton, Dinh Nguyen, Dave Hansen, linux-sgx,
	amd-gfx, linux-mm

On Wed, Oct 19, 2022 at 11:49:42AM +0800, Kefeng Wang wrote:
> Simplify VM_READ|VM_WRITE|VM_EXEC with VM_ACCESS_FLAGS.
> 
> Cc: Jarkko Sakkinen <jarkko@kernel.org>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
>  arch/x86/kernel/cpu/sgx/encl.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/kernel/cpu/sgx/encl.c b/arch/x86/kernel/cpu/sgx/encl.c
> index 1ec20807de1e..6225c525372d 100644
> --- a/arch/x86/kernel/cpu/sgx/encl.c
> +++ b/arch/x86/kernel/cpu/sgx/encl.c
> @@ -268,7 +268,7 @@ static struct sgx_encl_page *sgx_encl_load_page_in_vma(struct sgx_encl *encl,
>  						       unsigned long addr,
>  						       unsigned long vm_flags)
>  {
> -	unsigned long vm_prot_bits = vm_flags & (VM_READ | VM_WRITE | VM_EXEC);
> +	unsigned long vm_prot_bits = vm_flags & VM_ACCESS_FLAGS;
>  	struct sgx_encl_page *entry;
>  
>  	entry = xa_load(&encl->page_array, PFN_DOWN(addr));
> @@ -502,7 +502,7 @@ static void sgx_vma_open(struct vm_area_struct *vma)
>  int sgx_encl_may_map(struct sgx_encl *encl, unsigned long start,
>  		     unsigned long end, unsigned long vm_flags)
>  {
> -	unsigned long vm_prot_bits = vm_flags & (VM_READ | VM_WRITE | VM_EXEC);
> +	unsigned long vm_prot_bits = vm_flags & VM_ACCESS_FLAGS;
>  	struct sgx_encl_page *page;
>  	unsigned long count = 0;
>  	int ret = 0;
> -- 
> 2.35.3
> 

Why?

BR, Jarkko

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

* Re: [PATCH 2/5] x86/sgx: use VM_ACCESS_FLAGS
  2022-10-23 20:07   ` Jarkko Sakkinen
@ 2022-10-23 20:09     ` Jarkko Sakkinen
  0 siblings, 0 replies; 8+ messages in thread
From: Jarkko Sakkinen @ 2022-10-23 20:09 UTC (permalink / raw)
  To: Kefeng Wang
  Cc: linux-kernel, Andrew Morton, Dinh Nguyen, Dave Hansen, linux-sgx,
	amd-gfx, linux-mm

On Sun, Oct 23, 2022 at 11:07:47PM +0300, Jarkko Sakkinen wrote:
> On Wed, Oct 19, 2022 at 11:49:42AM +0800, Kefeng Wang wrote:
> > Simplify VM_READ|VM_WRITE|VM_EXEC with VM_ACCESS_FLAGS.
> > 
> > Cc: Jarkko Sakkinen <jarkko@kernel.org>
> > Cc: Dave Hansen <dave.hansen@linux.intel.com>
> > Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> > ---
> >  arch/x86/kernel/cpu/sgx/encl.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/arch/x86/kernel/cpu/sgx/encl.c b/arch/x86/kernel/cpu/sgx/encl.c
> > index 1ec20807de1e..6225c525372d 100644
> > --- a/arch/x86/kernel/cpu/sgx/encl.c
> > +++ b/arch/x86/kernel/cpu/sgx/encl.c
> > @@ -268,7 +268,7 @@ static struct sgx_encl_page *sgx_encl_load_page_in_vma(struct sgx_encl *encl,
> >  						       unsigned long addr,
> >  						       unsigned long vm_flags)
> >  {
> > -	unsigned long vm_prot_bits = vm_flags & (VM_READ | VM_WRITE | VM_EXEC);
> > +	unsigned long vm_prot_bits = vm_flags & VM_ACCESS_FLAGS;
> >  	struct sgx_encl_page *entry;
> >  
> >  	entry = xa_load(&encl->page_array, PFN_DOWN(addr));
> > @@ -502,7 +502,7 @@ static void sgx_vma_open(struct vm_area_struct *vma)
> >  int sgx_encl_may_map(struct sgx_encl *encl, unsigned long start,
> >  		     unsigned long end, unsigned long vm_flags)
> >  {
> > -	unsigned long vm_prot_bits = vm_flags & (VM_READ | VM_WRITE | VM_EXEC);
> > +	unsigned long vm_prot_bits = vm_flags & VM_ACCESS_FLAGS;
> >  	struct sgx_encl_page *page;
> >  	unsigned long count = 0;
> >  	int ret = 0;
> > -- 
> > 2.35.3
> > 
> 
> Why?

Only benefit I see is a downside: you have xref VM_ACCESS_FLAGS, which
is counter-productive. Zero gain.

BR, Jarkko

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

end of thread, other threads:[~2022-10-23 20:09 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-19  3:49 [PATCH 0/5] mm: cleanup with VM_ACCESS_FLAGS Kefeng Wang
2022-10-19  3:49 ` [PATCH 1/5] nios2: remove unused INIT_MMAP Kefeng Wang
2022-10-19  3:49 ` [PATCH 2/5] x86/sgx: use VM_ACCESS_FLAGS Kefeng Wang
2022-10-23 20:07   ` Jarkko Sakkinen
2022-10-23 20:09     ` Jarkko Sakkinen
2022-10-19  3:49 ` [PATCH 3/5] mm: mprotect: " Kefeng Wang
2022-10-19  3:49 ` [PATCH 4/5] mm: debug_vm_pgtable: " Kefeng Wang
2022-10-19  3:49 ` [PATCH 5/5] amdgpu: " Kefeng Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).