All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] ARM: mm: report both sections from PMD
@ 2014-02-12 22:46 ` Kees Cook
  0 siblings, 0 replies; 8+ messages in thread
From: Kees Cook @ 2014-02-12 22:46 UTC (permalink / raw)
  To: Russell King
  Cc: Catalin Marinas, Will Deacon, Steven Capper, Christoffer Dall,
	Kees Cook, Marc Zyngier, Laura Abbott, linux-arm-kernel,
	linux-kernel

On 2-level page table systems, the PMD has 2 section entries. Report
these, otherwise ARM_PTDUMP will miss reporting permission changes on
odd section boundaries.

Signed-off-by: Kees Cook <keescook@chromium.org>
---
v2:
 - reorganize, suggested by Catalin Marinas.
---
 arch/arm/include/asm/pgtable-3level.h |    4 ----
 arch/arm/include/asm/pgtable.h        |    4 ++++
 arch/arm/mm/dump.c                    |    8 +++++++-
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
index 03243f7eeddf..fb3de59ee811 100644
--- a/arch/arm/include/asm/pgtable-3level.h
+++ b/arch/arm/include/asm/pgtable-3level.h
@@ -138,10 +138,6 @@
 #define pud_none(pud)		(!pud_val(pud))
 #define pud_bad(pud)		(!(pud_val(pud) & 2))
 #define pud_present(pud)	(pud_val(pud))
-#define pmd_table(pmd)		((pmd_val(pmd) & PMD_TYPE_MASK) == \
-						 PMD_TYPE_TABLE)
-#define pmd_sect(pmd)		((pmd_val(pmd) & PMD_TYPE_MASK) == \
-						 PMD_TYPE_SECT)
 #define pmd_large(pmd)		pmd_sect(pmd)
 
 #define pud_clear(pudp)			\
diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
index 7d59b524f2af..934aa5b60c7c 100644
--- a/arch/arm/include/asm/pgtable.h
+++ b/arch/arm/include/asm/pgtable.h
@@ -183,6 +183,10 @@ extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
 
 #define pmd_none(pmd)		(!pmd_val(pmd))
 #define pmd_present(pmd)	(pmd_val(pmd))
+#define pmd_table(pmd)		((pmd_val(pmd) & PMD_TYPE_MASK) == \
+						 PMD_TYPE_TABLE)
+#define pmd_sect(pmd)		((pmd_val(pmd) & PMD_TYPE_MASK) == \
+						 PMD_TYPE_SECT)
 
 static inline pte_t *pmd_page_vaddr(pmd_t pmd)
 {
diff --git a/arch/arm/mm/dump.c b/arch/arm/mm/dump.c
index 2b342177f5de..32635b474832 100644
--- a/arch/arm/mm/dump.c
+++ b/arch/arm/mm/dump.c
@@ -260,8 +260,14 @@ static void walk_pmd(struct pg_state *st, pud_t *pud, unsigned long start)
 
 	for (i = 0; i < PTRS_PER_PMD; i++, pmd++) {
 		addr = start + i * PMD_SIZE;
-		if (pmd_none(*pmd) || pmd_large(*pmd) || !pmd_present(*pmd))
+		if (pmd_none(*pmd) || pmd_large(*pmd) || !pmd_present(*pmd)) {
 			note_page(st, addr, 3, pmd_val(*pmd));
+			if (SECTION_SIZE < PMD_SIZE &&
+			    pmd_sect(*pmd) && pmd_sect(pmd[1])) {
+				note_page(st, addr + SECTION_SIZE, 3,
+					  pmd_val(pmd[1]));
+			}
+		}
 		else
 			walk_pte(st, pmd, addr);
 	}
-- 
1.7.9.5


-- 
Kees Cook
Chrome OS Security

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

* [PATCH v2] ARM: mm: report both sections from PMD
@ 2014-02-12 22:46 ` Kees Cook
  0 siblings, 0 replies; 8+ messages in thread
From: Kees Cook @ 2014-02-12 22:46 UTC (permalink / raw)
  To: linux-arm-kernel

On 2-level page table systems, the PMD has 2 section entries. Report
these, otherwise ARM_PTDUMP will miss reporting permission changes on
odd section boundaries.

Signed-off-by: Kees Cook <keescook@chromium.org>
---
v2:
 - reorganize, suggested by Catalin Marinas.
---
 arch/arm/include/asm/pgtable-3level.h |    4 ----
 arch/arm/include/asm/pgtable.h        |    4 ++++
 arch/arm/mm/dump.c                    |    8 +++++++-
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
index 03243f7eeddf..fb3de59ee811 100644
--- a/arch/arm/include/asm/pgtable-3level.h
+++ b/arch/arm/include/asm/pgtable-3level.h
@@ -138,10 +138,6 @@
 #define pud_none(pud)		(!pud_val(pud))
 #define pud_bad(pud)		(!(pud_val(pud) & 2))
 #define pud_present(pud)	(pud_val(pud))
-#define pmd_table(pmd)		((pmd_val(pmd) & PMD_TYPE_MASK) == \
-						 PMD_TYPE_TABLE)
-#define pmd_sect(pmd)		((pmd_val(pmd) & PMD_TYPE_MASK) == \
-						 PMD_TYPE_SECT)
 #define pmd_large(pmd)		pmd_sect(pmd)
 
 #define pud_clear(pudp)			\
diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
index 7d59b524f2af..934aa5b60c7c 100644
--- a/arch/arm/include/asm/pgtable.h
+++ b/arch/arm/include/asm/pgtable.h
@@ -183,6 +183,10 @@ extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
 
 #define pmd_none(pmd)		(!pmd_val(pmd))
 #define pmd_present(pmd)	(pmd_val(pmd))
+#define pmd_table(pmd)		((pmd_val(pmd) & PMD_TYPE_MASK) == \
+						 PMD_TYPE_TABLE)
+#define pmd_sect(pmd)		((pmd_val(pmd) & PMD_TYPE_MASK) == \
+						 PMD_TYPE_SECT)
 
 static inline pte_t *pmd_page_vaddr(pmd_t pmd)
 {
diff --git a/arch/arm/mm/dump.c b/arch/arm/mm/dump.c
index 2b342177f5de..32635b474832 100644
--- a/arch/arm/mm/dump.c
+++ b/arch/arm/mm/dump.c
@@ -260,8 +260,14 @@ static void walk_pmd(struct pg_state *st, pud_t *pud, unsigned long start)
 
 	for (i = 0; i < PTRS_PER_PMD; i++, pmd++) {
 		addr = start + i * PMD_SIZE;
-		if (pmd_none(*pmd) || pmd_large(*pmd) || !pmd_present(*pmd))
+		if (pmd_none(*pmd) || pmd_large(*pmd) || !pmd_present(*pmd)) {
 			note_page(st, addr, 3, pmd_val(*pmd));
+			if (SECTION_SIZE < PMD_SIZE &&
+			    pmd_sect(*pmd) && pmd_sect(pmd[1])) {
+				note_page(st, addr + SECTION_SIZE, 3,
+					  pmd_val(pmd[1]));
+			}
+		}
 		else
 			walk_pte(st, pmd, addr);
 	}
-- 
1.7.9.5


-- 
Kees Cook
Chrome OS Security

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

* Re: [PATCH v2] ARM: mm: report both sections from PMD
  2014-02-12 22:46 ` Kees Cook
@ 2014-02-13 17:12   ` Catalin Marinas
  -1 siblings, 0 replies; 8+ messages in thread
From: Catalin Marinas @ 2014-02-13 17:12 UTC (permalink / raw)
  To: Kees Cook
  Cc: Russell King, Will Deacon, Steven Capper, Christoffer Dall,
	Marc Zyngier, Laura Abbott, linux-arm-kernel, linux-kernel

On Wed, Feb 12, 2014 at 10:46:38PM +0000, Kees Cook wrote:
> diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
> index 03243f7eeddf..fb3de59ee811 100644
> --- a/arch/arm/include/asm/pgtable-3level.h
> +++ b/arch/arm/include/asm/pgtable-3level.h
> @@ -138,10 +138,6 @@
>  #define pud_none(pud)		(!pud_val(pud))
>  #define pud_bad(pud)		(!(pud_val(pud) & 2))
>  #define pud_present(pud)	(pud_val(pud))
> -#define pmd_table(pmd)		((pmd_val(pmd) & PMD_TYPE_MASK) == \
> -						 PMD_TYPE_TABLE)
> -#define pmd_sect(pmd)		((pmd_val(pmd) & PMD_TYPE_MASK) == \
> -						 PMD_TYPE_SECT)
>  #define pmd_large(pmd)		pmd_sect(pmd)
>  
>  #define pud_clear(pudp)			\
> diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
> index 7d59b524f2af..934aa5b60c7c 100644
> --- a/arch/arm/include/asm/pgtable.h
> +++ b/arch/arm/include/asm/pgtable.h
> @@ -183,6 +183,10 @@ extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
>  
>  #define pmd_none(pmd)		(!pmd_val(pmd))
>  #define pmd_present(pmd)	(pmd_val(pmd))
> +#define pmd_table(pmd)		((pmd_val(pmd) & PMD_TYPE_MASK) == \
> +						 PMD_TYPE_TABLE)
> +#define pmd_sect(pmd)		((pmd_val(pmd) & PMD_TYPE_MASK) == \
> +						 PMD_TYPE_SECT)

Do you still need to move these two if you only use pmd_large()? AFAICT,
it is equivalent to pmd_sect().

>  static inline pte_t *pmd_page_vaddr(pmd_t pmd)
>  {
> diff --git a/arch/arm/mm/dump.c b/arch/arm/mm/dump.c
> index 2b342177f5de..32635b474832 100644
> --- a/arch/arm/mm/dump.c
> +++ b/arch/arm/mm/dump.c
> @@ -260,8 +260,14 @@ static void walk_pmd(struct pg_state *st, pud_t *pud, unsigned long start)
>  
>  	for (i = 0; i < PTRS_PER_PMD; i++, pmd++) {
>  		addr = start + i * PMD_SIZE;
> -		if (pmd_none(*pmd) || pmd_large(*pmd) || !pmd_present(*pmd))
> +		if (pmd_none(*pmd) || pmd_large(*pmd) || !pmd_present(*pmd)) {
>  			note_page(st, addr, 3, pmd_val(*pmd));
> +			if (SECTION_SIZE < PMD_SIZE &&
> +			    pmd_sect(*pmd) && pmd_sect(pmd[1])) {

I think the first patch was better with pmd[0] and pmd[1] treated
independently if SECTION_SIZE < PMD_SIZE, only that it should have
checked for pmd_sect(pmd[1]). I don't see anything in
__map_init_section() that would prevent populating only the second pmd
leaving the first one empty.

-- 
Catalin

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

* [PATCH v2] ARM: mm: report both sections from PMD
@ 2014-02-13 17:12   ` Catalin Marinas
  0 siblings, 0 replies; 8+ messages in thread
From: Catalin Marinas @ 2014-02-13 17:12 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Feb 12, 2014 at 10:46:38PM +0000, Kees Cook wrote:
> diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
> index 03243f7eeddf..fb3de59ee811 100644
> --- a/arch/arm/include/asm/pgtable-3level.h
> +++ b/arch/arm/include/asm/pgtable-3level.h
> @@ -138,10 +138,6 @@
>  #define pud_none(pud)		(!pud_val(pud))
>  #define pud_bad(pud)		(!(pud_val(pud) & 2))
>  #define pud_present(pud)	(pud_val(pud))
> -#define pmd_table(pmd)		((pmd_val(pmd) & PMD_TYPE_MASK) == \
> -						 PMD_TYPE_TABLE)
> -#define pmd_sect(pmd)		((pmd_val(pmd) & PMD_TYPE_MASK) == \
> -						 PMD_TYPE_SECT)
>  #define pmd_large(pmd)		pmd_sect(pmd)
>  
>  #define pud_clear(pudp)			\
> diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
> index 7d59b524f2af..934aa5b60c7c 100644
> --- a/arch/arm/include/asm/pgtable.h
> +++ b/arch/arm/include/asm/pgtable.h
> @@ -183,6 +183,10 @@ extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
>  
>  #define pmd_none(pmd)		(!pmd_val(pmd))
>  #define pmd_present(pmd)	(pmd_val(pmd))
> +#define pmd_table(pmd)		((pmd_val(pmd) & PMD_TYPE_MASK) == \
> +						 PMD_TYPE_TABLE)
> +#define pmd_sect(pmd)		((pmd_val(pmd) & PMD_TYPE_MASK) == \
> +						 PMD_TYPE_SECT)

Do you still need to move these two if you only use pmd_large()? AFAICT,
it is equivalent to pmd_sect().

>  static inline pte_t *pmd_page_vaddr(pmd_t pmd)
>  {
> diff --git a/arch/arm/mm/dump.c b/arch/arm/mm/dump.c
> index 2b342177f5de..32635b474832 100644
> --- a/arch/arm/mm/dump.c
> +++ b/arch/arm/mm/dump.c
> @@ -260,8 +260,14 @@ static void walk_pmd(struct pg_state *st, pud_t *pud, unsigned long start)
>  
>  	for (i = 0; i < PTRS_PER_PMD; i++, pmd++) {
>  		addr = start + i * PMD_SIZE;
> -		if (pmd_none(*pmd) || pmd_large(*pmd) || !pmd_present(*pmd))
> +		if (pmd_none(*pmd) || pmd_large(*pmd) || !pmd_present(*pmd)) {
>  			note_page(st, addr, 3, pmd_val(*pmd));
> +			if (SECTION_SIZE < PMD_SIZE &&
> +			    pmd_sect(*pmd) && pmd_sect(pmd[1])) {

I think the first patch was better with pmd[0] and pmd[1] treated
independently if SECTION_SIZE < PMD_SIZE, only that it should have
checked for pmd_sect(pmd[1]). I don't see anything in
__map_init_section() that would prevent populating only the second pmd
leaving the first one empty.

-- 
Catalin

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

* Re: [PATCH v2] ARM: mm: report both sections from PMD
  2014-02-13 17:12   ` Catalin Marinas
@ 2014-02-13 19:52     ` Kees Cook
  -1 siblings, 0 replies; 8+ messages in thread
From: Kees Cook @ 2014-02-13 19:52 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: Russell King, Will Deacon, Steven Capper, Christoffer Dall,
	Marc Zyngier, Laura Abbott, linux-arm-kernel, linux-kernel

On Thu, Feb 13, 2014 at 9:12 AM, Catalin Marinas
<catalin.marinas@arm.com> wrote:
> On Wed, Feb 12, 2014 at 10:46:38PM +0000, Kees Cook wrote:
>> diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
>> index 03243f7eeddf..fb3de59ee811 100644
>> --- a/arch/arm/include/asm/pgtable-3level.h
>> +++ b/arch/arm/include/asm/pgtable-3level.h
>> @@ -138,10 +138,6 @@
>>  #define pud_none(pud)                (!pud_val(pud))
>>  #define pud_bad(pud)         (!(pud_val(pud) & 2))
>>  #define pud_present(pud)     (pud_val(pud))
>> -#define pmd_table(pmd)               ((pmd_val(pmd) & PMD_TYPE_MASK) == \
>> -                                              PMD_TYPE_TABLE)
>> -#define pmd_sect(pmd)                ((pmd_val(pmd) & PMD_TYPE_MASK) == \
>> -                                              PMD_TYPE_SECT)
>>  #define pmd_large(pmd)               pmd_sect(pmd)
>>
>>  #define pud_clear(pudp)                      \
>> diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
>> index 7d59b524f2af..934aa5b60c7c 100644
>> --- a/arch/arm/include/asm/pgtable.h
>> +++ b/arch/arm/include/asm/pgtable.h
>> @@ -183,6 +183,10 @@ extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
>>
>>  #define pmd_none(pmd)                (!pmd_val(pmd))
>>  #define pmd_present(pmd)     (pmd_val(pmd))
>> +#define pmd_table(pmd)               ((pmd_val(pmd) & PMD_TYPE_MASK) == \
>> +                                              PMD_TYPE_TABLE)
>> +#define pmd_sect(pmd)                ((pmd_val(pmd) & PMD_TYPE_MASK) == \
>> +                                              PMD_TYPE_SECT)
>
> Do you still need to move these two if you only use pmd_large()? AFAICT,
> it is equivalent to pmd_sect().

Why does pmd_sect exist? I can reduce it to just using pmd_large.

>
>>  static inline pte_t *pmd_page_vaddr(pmd_t pmd)
>>  {
>> diff --git a/arch/arm/mm/dump.c b/arch/arm/mm/dump.c
>> index 2b342177f5de..32635b474832 100644
>> --- a/arch/arm/mm/dump.c
>> +++ b/arch/arm/mm/dump.c
>> @@ -260,8 +260,14 @@ static void walk_pmd(struct pg_state *st, pud_t *pud, unsigned long start)
>>
>>       for (i = 0; i < PTRS_PER_PMD; i++, pmd++) {
>>               addr = start + i * PMD_SIZE;
>> -             if (pmd_none(*pmd) || pmd_large(*pmd) || !pmd_present(*pmd))
>> +             if (pmd_none(*pmd) || pmd_large(*pmd) || !pmd_present(*pmd)) {
>>                       note_page(st, addr, 3, pmd_val(*pmd));
>> +                     if (SECTION_SIZE < PMD_SIZE &&
>> +                         pmd_sect(*pmd) && pmd_sect(pmd[1])) {
>
> I think the first patch was better with pmd[0] and pmd[1] treated
> independently if SECTION_SIZE < PMD_SIZE, only that it should have
> checked for pmd_sect(pmd[1]). I don't see anything in
> __map_init_section() that would prevent populating only the second pmd
> leaving the first one empty.

Ah, gotcha. Okay, I will send a new version. Thanks!

-Kees

-- 
Kees Cook
Chrome OS Security

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

* [PATCH v2] ARM: mm: report both sections from PMD
@ 2014-02-13 19:52     ` Kees Cook
  0 siblings, 0 replies; 8+ messages in thread
From: Kees Cook @ 2014-02-13 19:52 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Feb 13, 2014 at 9:12 AM, Catalin Marinas
<catalin.marinas@arm.com> wrote:
> On Wed, Feb 12, 2014 at 10:46:38PM +0000, Kees Cook wrote:
>> diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
>> index 03243f7eeddf..fb3de59ee811 100644
>> --- a/arch/arm/include/asm/pgtable-3level.h
>> +++ b/arch/arm/include/asm/pgtable-3level.h
>> @@ -138,10 +138,6 @@
>>  #define pud_none(pud)                (!pud_val(pud))
>>  #define pud_bad(pud)         (!(pud_val(pud) & 2))
>>  #define pud_present(pud)     (pud_val(pud))
>> -#define pmd_table(pmd)               ((pmd_val(pmd) & PMD_TYPE_MASK) == \
>> -                                              PMD_TYPE_TABLE)
>> -#define pmd_sect(pmd)                ((pmd_val(pmd) & PMD_TYPE_MASK) == \
>> -                                              PMD_TYPE_SECT)
>>  #define pmd_large(pmd)               pmd_sect(pmd)
>>
>>  #define pud_clear(pudp)                      \
>> diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
>> index 7d59b524f2af..934aa5b60c7c 100644
>> --- a/arch/arm/include/asm/pgtable.h
>> +++ b/arch/arm/include/asm/pgtable.h
>> @@ -183,6 +183,10 @@ extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
>>
>>  #define pmd_none(pmd)                (!pmd_val(pmd))
>>  #define pmd_present(pmd)     (pmd_val(pmd))
>> +#define pmd_table(pmd)               ((pmd_val(pmd) & PMD_TYPE_MASK) == \
>> +                                              PMD_TYPE_TABLE)
>> +#define pmd_sect(pmd)                ((pmd_val(pmd) & PMD_TYPE_MASK) == \
>> +                                              PMD_TYPE_SECT)
>
> Do you still need to move these two if you only use pmd_large()? AFAICT,
> it is equivalent to pmd_sect().

Why does pmd_sect exist? I can reduce it to just using pmd_large.

>
>>  static inline pte_t *pmd_page_vaddr(pmd_t pmd)
>>  {
>> diff --git a/arch/arm/mm/dump.c b/arch/arm/mm/dump.c
>> index 2b342177f5de..32635b474832 100644
>> --- a/arch/arm/mm/dump.c
>> +++ b/arch/arm/mm/dump.c
>> @@ -260,8 +260,14 @@ static void walk_pmd(struct pg_state *st, pud_t *pud, unsigned long start)
>>
>>       for (i = 0; i < PTRS_PER_PMD; i++, pmd++) {
>>               addr = start + i * PMD_SIZE;
>> -             if (pmd_none(*pmd) || pmd_large(*pmd) || !pmd_present(*pmd))
>> +             if (pmd_none(*pmd) || pmd_large(*pmd) || !pmd_present(*pmd)) {
>>                       note_page(st, addr, 3, pmd_val(*pmd));
>> +                     if (SECTION_SIZE < PMD_SIZE &&
>> +                         pmd_sect(*pmd) && pmd_sect(pmd[1])) {
>
> I think the first patch was better with pmd[0] and pmd[1] treated
> independently if SECTION_SIZE < PMD_SIZE, only that it should have
> checked for pmd_sect(pmd[1]). I don't see anything in
> __map_init_section() that would prevent populating only the second pmd
> leaving the first one empty.

Ah, gotcha. Okay, I will send a new version. Thanks!

-Kees

-- 
Kees Cook
Chrome OS Security

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

* Re: [PATCH v2] ARM: mm: report both sections from PMD
  2014-02-13 19:52     ` Kees Cook
@ 2014-02-14 10:15       ` Catalin Marinas
  -1 siblings, 0 replies; 8+ messages in thread
From: Catalin Marinas @ 2014-02-14 10:15 UTC (permalink / raw)
  To: Kees Cook
  Cc: Russell King, Will Deacon, Steven Capper, Christoffer Dall,
	Marc Zyngier, Laura Abbott, linux-arm-kernel, linux-kernel

On Thu, Feb 13, 2014 at 07:52:03PM +0000, Kees Cook wrote:
> On Thu, Feb 13, 2014 at 9:12 AM, Catalin Marinas
> <catalin.marinas@arm.com> wrote:
> > On Wed, Feb 12, 2014 at 10:46:38PM +0000, Kees Cook wrote:
> >> diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
> >> index 03243f7eeddf..fb3de59ee811 100644
> >> --- a/arch/arm/include/asm/pgtable-3level.h
> >> +++ b/arch/arm/include/asm/pgtable-3level.h
> >> @@ -138,10 +138,6 @@
> >>  #define pud_none(pud)                (!pud_val(pud))
> >>  #define pud_bad(pud)         (!(pud_val(pud) & 2))
> >>  #define pud_present(pud)     (pud_val(pud))
> >> -#define pmd_table(pmd)               ((pmd_val(pmd) & PMD_TYPE_MASK) == \
> >> -                                              PMD_TYPE_TABLE)
> >> -#define pmd_sect(pmd)                ((pmd_val(pmd) & PMD_TYPE_MASK) == \
> >> -                                              PMD_TYPE_SECT)
> >>  #define pmd_large(pmd)               pmd_sect(pmd)
> >>
> >>  #define pud_clear(pudp)                      \
> >> diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
> >> index 7d59b524f2af..934aa5b60c7c 100644
> >> --- a/arch/arm/include/asm/pgtable.h
> >> +++ b/arch/arm/include/asm/pgtable.h
> >> @@ -183,6 +183,10 @@ extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
> >>
> >>  #define pmd_none(pmd)                (!pmd_val(pmd))
> >>  #define pmd_present(pmd)     (pmd_val(pmd))
> >> +#define pmd_table(pmd)               ((pmd_val(pmd) & PMD_TYPE_MASK) == \
> >> +                                              PMD_TYPE_TABLE)
> >> +#define pmd_sect(pmd)                ((pmd_val(pmd) & PMD_TYPE_MASK) == \
> >> +                                              PMD_TYPE_SECT)
> >
> > Do you still need to move these two if you only use pmd_large()? AFAICT,
> > it is equivalent to pmd_sect().
> 
> Why does pmd_sect exist? I can reduce it to just using pmd_large.

pmd_sect/pmd_table were there first and used by kvm. The pmd_large() was
added by Russell because the dump.c code was derived from x86 which uses
such macro. And we have another close relative, pmd_huge(), though only
defined if CONFIG_HUGETLB_PAGE.

We could drop pmd_large() in favour of pmd_sect() but it's up to
Russell. OTOH, when someone will try to add arm64 support, I'll most
likely ask for part of the x86 code to be turned into a generic library
and we'll need some common naming for such macros (e.g. pmd_large()).

-- 
Catalin

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

* [PATCH v2] ARM: mm: report both sections from PMD
@ 2014-02-14 10:15       ` Catalin Marinas
  0 siblings, 0 replies; 8+ messages in thread
From: Catalin Marinas @ 2014-02-14 10:15 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Feb 13, 2014 at 07:52:03PM +0000, Kees Cook wrote:
> On Thu, Feb 13, 2014 at 9:12 AM, Catalin Marinas
> <catalin.marinas@arm.com> wrote:
> > On Wed, Feb 12, 2014 at 10:46:38PM +0000, Kees Cook wrote:
> >> diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
> >> index 03243f7eeddf..fb3de59ee811 100644
> >> --- a/arch/arm/include/asm/pgtable-3level.h
> >> +++ b/arch/arm/include/asm/pgtable-3level.h
> >> @@ -138,10 +138,6 @@
> >>  #define pud_none(pud)                (!pud_val(pud))
> >>  #define pud_bad(pud)         (!(pud_val(pud) & 2))
> >>  #define pud_present(pud)     (pud_val(pud))
> >> -#define pmd_table(pmd)               ((pmd_val(pmd) & PMD_TYPE_MASK) == \
> >> -                                              PMD_TYPE_TABLE)
> >> -#define pmd_sect(pmd)                ((pmd_val(pmd) & PMD_TYPE_MASK) == \
> >> -                                              PMD_TYPE_SECT)
> >>  #define pmd_large(pmd)               pmd_sect(pmd)
> >>
> >>  #define pud_clear(pudp)                      \
> >> diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
> >> index 7d59b524f2af..934aa5b60c7c 100644
> >> --- a/arch/arm/include/asm/pgtable.h
> >> +++ b/arch/arm/include/asm/pgtable.h
> >> @@ -183,6 +183,10 @@ extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
> >>
> >>  #define pmd_none(pmd)                (!pmd_val(pmd))
> >>  #define pmd_present(pmd)     (pmd_val(pmd))
> >> +#define pmd_table(pmd)               ((pmd_val(pmd) & PMD_TYPE_MASK) == \
> >> +                                              PMD_TYPE_TABLE)
> >> +#define pmd_sect(pmd)                ((pmd_val(pmd) & PMD_TYPE_MASK) == \
> >> +                                              PMD_TYPE_SECT)
> >
> > Do you still need to move these two if you only use pmd_large()? AFAICT,
> > it is equivalent to pmd_sect().
> 
> Why does pmd_sect exist? I can reduce it to just using pmd_large.

pmd_sect/pmd_table were there first and used by kvm. The pmd_large() was
added by Russell because the dump.c code was derived from x86 which uses
such macro. And we have another close relative, pmd_huge(), though only
defined if CONFIG_HUGETLB_PAGE.

We could drop pmd_large() in favour of pmd_sect() but it's up to
Russell. OTOH, when someone will try to add arm64 support, I'll most
likely ask for part of the x86 code to be turned into a generic library
and we'll need some common naming for such macros (e.g. pmd_large()).

-- 
Catalin

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

end of thread, other threads:[~2014-02-14 10:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-12 22:46 [PATCH v2] ARM: mm: report both sections from PMD Kees Cook
2014-02-12 22:46 ` Kees Cook
2014-02-13 17:12 ` Catalin Marinas
2014-02-13 17:12   ` Catalin Marinas
2014-02-13 19:52   ` Kees Cook
2014-02-13 19:52     ` Kees Cook
2014-02-14 10:15     ` Catalin Marinas
2014-02-14 10:15       ` Catalin Marinas

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.