linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] arm64: move the PTE_VALID to pgtable-hwdef.h
@ 2016-05-30  2:14 Huang Shijie
  2016-05-30  2:14 ` [PATCH 2/3] arm64: fix the wrong type Huang Shijie
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Huang Shijie @ 2016-05-30  2:14 UTC (permalink / raw)
  To: linux-arm-kernel

The PTE_VALID is used to check whether the page descriptor is valid.
It's not a software defined PTE bits, such as PTE_WRITE/PTE_DIRTY.

So move it to the proper header file: pgtable-hwdef.h.

Signed-off-by: Huang Shijie <shijie.huang@arm.com>
---
 arch/arm64/include/asm/pgtable-hwdef.h | 1 +
 arch/arm64/include/asm/pgtable-prot.h  | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/include/asm/pgtable-hwdef.h b/arch/arm64/include/asm/pgtable-hwdef.h
index 2813748..eeb3269 100644
--- a/arch/arm64/include/asm/pgtable-hwdef.h
+++ b/arch/arm64/include/asm/pgtable-hwdef.h
@@ -154,6 +154,7 @@
 #define PTE_TYPE_MASK		(_AT(pteval_t, 3) << 0)
 #define PTE_TYPE_FAULT		(_AT(pteval_t, 0) << 0)
 #define PTE_TYPE_PAGE		(_AT(pteval_t, 3) << 0)
+#define PTE_VALID		(_AT(pteval_t, 1) << 0)
 #define PTE_TABLE_BIT		(_AT(pteval_t, 1) << 1)
 #define PTE_USER		(_AT(pteval_t, 1) << 6)		/* AP[1] */
 #define PTE_RDONLY		(_AT(pteval_t, 1) << 7)		/* AP[2] */
diff --git a/arch/arm64/include/asm/pgtable-prot.h b/arch/arm64/include/asm/pgtable-prot.h
index 29fcb33..5ac71f4 100644
--- a/arch/arm64/include/asm/pgtable-prot.h
+++ b/arch/arm64/include/asm/pgtable-prot.h
@@ -24,7 +24,6 @@
 /*
  * Software defined PTE bits definition.
  */
-#define PTE_VALID		(_AT(pteval_t, 1) << 0)
 #define PTE_WRITE		(PTE_DBM)		 /* same as DBM (51) */
 #define PTE_DIRTY		(_AT(pteval_t, 1) << 55)
 #define PTE_SPECIAL		(_AT(pteval_t, 1) << 56)
-- 
2.5.5

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

* [PATCH 2/3] arm64: fix the wrong type
  2016-05-30  2:14 [PATCH 1/3] arm64: move the PTE_VALID to pgtable-hwdef.h Huang Shijie
@ 2016-05-30  2:14 ` Huang Shijie
  2016-05-30  2:14 ` [PATCH 3/3] arm64: add a new macro for the pgd table descriptor Huang Shijie
  2016-06-02 18:16 ` [PATCH 1/3] arm64: move the PTE_VALID to pgtable-hwdef.h Will Deacon
  2 siblings, 0 replies; 5+ messages in thread
From: Huang Shijie @ 2016-05-30  2:14 UTC (permalink / raw)
  To: linux-arm-kernel

We should use the pudval_t for the PUD_* macros, not the pgdval_t.
This patch fixes them.

Signed-off-by: Huang Shijie <shijie.huang@arm.com>
---
 arch/arm64/include/asm/pgtable-hwdef.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm64/include/asm/pgtable-hwdef.h b/arch/arm64/include/asm/pgtable-hwdef.h
index eeb3269..54e2fbf 100644
--- a/arch/arm64/include/asm/pgtable-hwdef.h
+++ b/arch/arm64/include/asm/pgtable-hwdef.h
@@ -116,9 +116,9 @@
  * Level 1 descriptor (PUD).
  */
 #define PUD_TYPE_TABLE		(_AT(pudval_t, 3) << 0)
-#define PUD_TABLE_BIT		(_AT(pgdval_t, 1) << 1)
-#define PUD_TYPE_MASK		(_AT(pgdval_t, 3) << 0)
-#define PUD_TYPE_SECT		(_AT(pgdval_t, 1) << 0)
+#define PUD_TABLE_BIT		(_AT(pudval_t, 1) << 1)
+#define PUD_TYPE_MASK		(_AT(pudval_t, 3) << 0)
+#define PUD_TYPE_SECT		(_AT(pudval_t, 1) << 0)
 
 /*
  * Level 2 descriptor (PMD).
-- 
2.5.5

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

* [PATCH 3/3] arm64: add a new macro for the pgd table descriptor
  2016-05-30  2:14 [PATCH 1/3] arm64: move the PTE_VALID to pgtable-hwdef.h Huang Shijie
  2016-05-30  2:14 ` [PATCH 2/3] arm64: fix the wrong type Huang Shijie
@ 2016-05-30  2:14 ` Huang Shijie
  2016-06-02 18:16 ` [PATCH 1/3] arm64: move the PTE_VALID to pgtable-hwdef.h Will Deacon
  2 siblings, 0 replies; 5+ messages in thread
From: Huang Shijie @ 2016-05-30  2:14 UTC (permalink / raw)
  To: linux-arm-kernel

Add a new macro for the pgd table descriptor to define the "Table"
type, and use it to replace the numerical constant in the pgd_bad().

This patch makes the code more legible.

Signed-off-by: Huang Shijie <shijie.huang@arm.com>
---
 arch/arm64/include/asm/pgtable-hwdef.h | 5 +++++
 arch/arm64/include/asm/pgtable.h       | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/include/asm/pgtable-hwdef.h b/arch/arm64/include/asm/pgtable-hwdef.h
index 54e2fbf..f648c28 100644
--- a/arch/arm64/include/asm/pgtable-hwdef.h
+++ b/arch/arm64/include/asm/pgtable-hwdef.h
@@ -113,6 +113,11 @@
 /*
  * Hardware page table definitions.
  *
+ * Level 0 descriptor (PGD).
+ */
+#define PGD_TABLE_BIT		(_AT(pgdval_t, 1) << 1)
+
+/*
  * Level 1 descriptor (PUD).
  */
 #define PUD_TYPE_TABLE		(_AT(pudval_t, 3) << 0)
diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index 46472a9..bfa0092 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -453,7 +453,7 @@ static inline phys_addr_t pud_page_paddr(pud_t pud)
 #define pud_ERROR(pud)		__pud_error(__FILE__, __LINE__, pud_val(pud))
 
 #define pgd_none(pgd)		(!pgd_val(pgd))
-#define pgd_bad(pgd)		(!(pgd_val(pgd) & 2))
+#define pgd_bad(pgd)		(!(pgd_val(pgd) & PGD_TABLE_BIT))
 #define pgd_present(pgd)	(pgd_val(pgd))
 
 static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
-- 
2.5.5

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

* [PATCH 1/3] arm64: move the PTE_VALID to pgtable-hwdef.h
  2016-05-30  2:14 [PATCH 1/3] arm64: move the PTE_VALID to pgtable-hwdef.h Huang Shijie
  2016-05-30  2:14 ` [PATCH 2/3] arm64: fix the wrong type Huang Shijie
  2016-05-30  2:14 ` [PATCH 3/3] arm64: add a new macro for the pgd table descriptor Huang Shijie
@ 2016-06-02 18:16 ` Will Deacon
  2016-06-03  2:32   ` Huang Shijie
  2 siblings, 1 reply; 5+ messages in thread
From: Will Deacon @ 2016-06-02 18:16 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, May 30, 2016 at 10:14:26AM +0800, Huang Shijie wrote:
> The PTE_VALID is used to check whether the page descriptor is valid.
> It's not a software defined PTE bits, such as PTE_WRITE/PTE_DIRTY.
> 
> So move it to the proper header file: pgtable-hwdef.h.
> 
> Signed-off-by: Huang Shijie <shijie.huang@arm.com>
> ---
>  arch/arm64/include/asm/pgtable-hwdef.h | 1 +
>  arch/arm64/include/asm/pgtable-prot.h  | 1 -
>  2 files changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/include/asm/pgtable-hwdef.h b/arch/arm64/include/asm/pgtable-hwdef.h
> index 2813748..eeb3269 100644
> --- a/arch/arm64/include/asm/pgtable-hwdef.h
> +++ b/arch/arm64/include/asm/pgtable-hwdef.h
> @@ -154,6 +154,7 @@
>  #define PTE_TYPE_MASK		(_AT(pteval_t, 3) << 0)
>  #define PTE_TYPE_FAULT		(_AT(pteval_t, 0) << 0)
>  #define PTE_TYPE_PAGE		(_AT(pteval_t, 3) << 0)
> +#define PTE_VALID		(_AT(pteval_t, 1) << 0)
>  #define PTE_TABLE_BIT		(_AT(pteval_t, 1) << 1)
>  #define PTE_USER		(_AT(pteval_t, 1) << 6)		/* AP[1] */
>  #define PTE_RDONLY		(_AT(pteval_t, 1) << 7)		/* AP[2] */
> diff --git a/arch/arm64/include/asm/pgtable-prot.h b/arch/arm64/include/asm/pgtable-prot.h
> index 29fcb33..5ac71f4 100644
> --- a/arch/arm64/include/asm/pgtable-prot.h
> +++ b/arch/arm64/include/asm/pgtable-prot.h
> @@ -24,7 +24,6 @@
>  /*
>   * Software defined PTE bits definition.
>   */
> -#define PTE_VALID		(_AT(pteval_t, 1) << 0)
>  #define PTE_WRITE		(PTE_DBM)		 /* same as DBM (51) */

So how would you define PTE_WRITE? It's a software bit in v8.0 and a
hardware bit in v8.1 ;)

I don't mind shuffling the #defines about, I just think the boundaries
are somewhat blurred and maybe it's a mistake to put software bits and
hardware bits in separate headers.

Will

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

* [PATCH 1/3] arm64: move the PTE_VALID to pgtable-hwdef.h
  2016-06-02 18:16 ` [PATCH 1/3] arm64: move the PTE_VALID to pgtable-hwdef.h Will Deacon
@ 2016-06-03  2:32   ` Huang Shijie
  0 siblings, 0 replies; 5+ messages in thread
From: Huang Shijie @ 2016-06-03  2:32 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Jun 02, 2016 at 07:16:09PM +0100, Will Deacon wrote:
> On Mon, May 30, 2016 at 10:14:26AM +0800, Huang Shijie wrote:
> > The PTE_VALID is used to check whether the page descriptor is valid.
> > It's not a software defined PTE bits, such as PTE_WRITE/PTE_DIRTY.
> > 
> > So move it to the proper header file: pgtable-hwdef.h.
> > 
> > Signed-off-by: Huang Shijie <shijie.huang@arm.com>
> > ---
> >  arch/arm64/include/asm/pgtable-hwdef.h | 1 +
> >  arch/arm64/include/asm/pgtable-prot.h  | 1 -
> >  2 files changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/arch/arm64/include/asm/pgtable-hwdef.h b/arch/arm64/include/asm/pgtable-hwdef.h
> > index 2813748..eeb3269 100644
> > --- a/arch/arm64/include/asm/pgtable-hwdef.h
> > +++ b/arch/arm64/include/asm/pgtable-hwdef.h
> > @@ -154,6 +154,7 @@
> >  #define PTE_TYPE_MASK		(_AT(pteval_t, 3) << 0)
> >  #define PTE_TYPE_FAULT		(_AT(pteval_t, 0) << 0)
> >  #define PTE_TYPE_PAGE		(_AT(pteval_t, 3) << 0)
> > +#define PTE_VALID		(_AT(pteval_t, 1) << 0)
> >  #define PTE_TABLE_BIT		(_AT(pteval_t, 1) << 1)
> >  #define PTE_USER		(_AT(pteval_t, 1) << 6)		/* AP[1] */
> >  #define PTE_RDONLY		(_AT(pteval_t, 1) << 7)		/* AP[2] */
> > diff --git a/arch/arm64/include/asm/pgtable-prot.h b/arch/arm64/include/asm/pgtable-prot.h
> > index 29fcb33..5ac71f4 100644
> > --- a/arch/arm64/include/asm/pgtable-prot.h
> > +++ b/arch/arm64/include/asm/pgtable-prot.h
> > @@ -24,7 +24,6 @@
> >  /*
> >   * Software defined PTE bits definition.
> >   */
> > -#define PTE_VALID		(_AT(pteval_t, 1) << 0)
> >  #define PTE_WRITE		(PTE_DBM)		 /* same as DBM (51) */
> 
> So how would you define PTE_WRITE? It's a software bit in v8.0 and a
> hardware bit in v8.1 ;)
> 
> I don't mind shuffling the #defines about, I just think the boundaries
> are somewhat blurred and maybe it's a mistake to put software bits and
> hardware bits in separate headers.
Do you mind I move all the software bits(PTE_VALID/PTE_WRITE/PTE_DIRTY...)
to the pgtable-hwdef.h?

thanks
Huang Shijie

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

end of thread, other threads:[~2016-06-03  2:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-30  2:14 [PATCH 1/3] arm64: move the PTE_VALID to pgtable-hwdef.h Huang Shijie
2016-05-30  2:14 ` [PATCH 2/3] arm64: fix the wrong type Huang Shijie
2016-05-30  2:14 ` [PATCH 3/3] arm64: add a new macro for the pgd table descriptor Huang Shijie
2016-06-02 18:16 ` [PATCH 1/3] arm64: move the PTE_VALID to pgtable-hwdef.h Will Deacon
2016-06-03  2:32   ` Huang Shijie

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).