All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] arm64: Improve error reporting on set_pte_at() checks
  2015-12-09 17:26 [PATCH 0/2] arm64: Non-racy PTE setting in the presence of HW AF/DBM Catalin Marinas
@ 2015-12-09 17:26 ` Catalin Marinas
  0 siblings, 0 replies; 4+ messages in thread
From: Catalin Marinas @ 2015-12-09 17:26 UTC (permalink / raw)
  To: linux-arm-kernel

Currently the BUG_ON() checks do not give enough information about the
PTEs being set. This patch changes BUG_ON to WARN_ONCE and dumps the
values of the old and new PTEs.

Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
---
 arch/arm64/include/asm/pgtable.h | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index 7e074f93f383..002dc61a4dff 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -276,10 +276,13 @@ static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
 	 * hardware updates of the pte (ptep_set_access_flags safely changes
 	 * valid ptes without going through an invalid entry).
 	 */
-	if (IS_ENABLED(CONFIG_DEBUG_VM) && IS_ENABLED(CONFIG_ARM64_HW_AFDBM) &&
-	    pte_valid(*ptep)) {
-		BUG_ON(!pte_young(pte));
-		BUG_ON(pte_write(*ptep) && !pte_dirty(pte));
+	if (IS_ENABLED(CONFIG_ARM64_HW_AFDBM) && pte_valid(*ptep)) {
+		VM_WARN_ONCE(!pte_young(pte),
+			     "%s: racy access flag clearing: %016llx -> %016llx",
+			     __func__, pte_val(*ptep), pte_val(pte));
+		VM_WARN_ONCE(pte_write(*ptep) && !pte_dirty(pte),
+			     "%s: racy dirty state clearing: %016llx -> %016llx",
+			     __func__, pte_val(*ptep), pte_val(pte));
 	}
 
 	set_pte(ptep, pte);

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

* Re: [PATCH 1/2] arm64: Improve error reporting on set_pte_at() checks
@ 2015-12-16  3:01 Andrew Pinski
  2015-12-16 11:15   ` James Morse
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Pinski @ 2015-12-16  3:01 UTC (permalink / raw)
  To: Catalin Marinas, LKML
  Cc: linux-arm-kernel@lists.infradead.org, Andrew Pinski, Ming Lei,
	Will Deacon, David Daney

On Tue, Dec 9, 2015 at 17:26:56, Catalin Marinas
<catalin.marinas@arm.com> wrote:
>
> Currently the BUG_ON() checks do not give enough information about the PTEs being set. This patch changes BUG_ON to WARN_ONCE and dumps the values of the old and new PTEs.


This change broke building the mantis driver:

In file included from ./arch/arm64/include/asm/io.h:30:0,
                 from drivers/media/pci/mantis/mantis_i2c.c:21:
./arch/arm64/include/asm/pgtable.h: In function ‘set_pte_at’:
./arch/arm64/include/asm/pgtable.h:281:3: error: implicit declaration
of function ‘BUILD_BUG_ON_INVALID’
[-Werror=implicit-function-declaration]
   VM_WARN_ONCE(!pte_young(pte),
   ^

Thanks,
Andrew Pinski

>
> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> ---
>   arch/arm64/include/asm/pgtable.h | 11 +++++++----
>   1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/arch/arm64/include/asm/pgtable.h
> b/arch/arm64/include/asm/pgtable.h
> index 7e074f93f383..002dc61a4dff 100644
> --- a/arch/arm64/include/asm/pgtable.h
> +++ b/arch/arm64/include/asm/pgtable.h
> @@ -276,10 +276,13 @@ static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
>          * hardware updates of the pte (ptep_set_access_flags safely changes
>          * valid ptes without going through an invalid entry).
>          */
> -       if (IS_ENABLED(CONFIG_DEBUG_VM) && IS_ENABLED(CONFIG_ARM64_HW_AFDBM) &&
> -           pte_valid(*ptep)) {
> -               BUG_ON(!pte_young(pte));
> -               BUG_ON(pte_write(*ptep) && !pte_dirty(pte));
> +       if (IS_ENABLED(CONFIG_ARM64_HW_AFDBM) && pte_valid(*ptep)) {
> +               VM_WARN_ONCE(!pte_young(pte),
> +                            "%s: racy access flag clearing: %016llx -> %016llx",
> +                            __func__, pte_val(*ptep), pte_val(pte));
> +               VM_WARN_ONCE(pte_write(*ptep) && !pte_dirty(pte),
> +                            "%s: racy dirty state clearing: %016llx -> %016llx",
> +                            __func__, pte_val(*ptep), pte_val(pte));
>         }
>
>         set_pte(ptep, pte);
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
>
>
>

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

* [PATCH 1/2] arm64: Improve error reporting on set_pte_at() checks
  2015-12-16  3:01 [PATCH 1/2] arm64: Improve error reporting on set_pte_at() checks Andrew Pinski
@ 2015-12-16 11:15   ` James Morse
  0 siblings, 0 replies; 4+ messages in thread
From: James Morse @ 2015-12-16 11:15 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Andrew,

On 16/12/15 03:01, Andrew Pinski wrote:
> On Tue, Dec 9, 2015 at 17:26:56, Catalin Marinas
> <catalin.marinas@arm.com> wrote:
>>
>> Currently the BUG_ON() checks do not give enough information about the PTEs being set. This patch changes BUG_ON to WARN_ONCE and dumps the values of the old and new PTEs.
> 
> 
> This change broke building the mantis driver:
> 
> In file included from ./arch/arm64/include/asm/io.h:30:0,
>                  from drivers/media/pci/mantis/mantis_i2c.c:21:
> ./arch/arm64/include/asm/pgtable.h: In function ?set_pte_at?:
> ./arch/arm64/include/asm/pgtable.h:281:3: error: implicit declaration
> of function ?BUILD_BUG_ON_INVALID?
> [-Werror=implicit-function-declaration]
>    VM_WARN_ONCE(!pte_young(pte),
>    ^

This is due to a missing include in include/linux/mmdebug.h, which
Julien Grall saw with CONFIG_XEN & !CONFIG_DEBUG_VM. There was some
discussion at [0], and a patch at [1].

The quick-and-dirty workaround is to toggle CONFIG_DEBUG_VM. It should
be fixed in the next rc.


Thanks,

James

[0] https://lkml.org/lkml/2015/12/14/489
[1] http://www.spinics.net/lists/linux-mm/msg98868.html

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

* Re: [PATCH 1/2] arm64: Improve error reporting on set_pte_at() checks
@ 2015-12-16 11:15   ` James Morse
  0 siblings, 0 replies; 4+ messages in thread
From: James Morse @ 2015-12-16 11:15 UTC (permalink / raw)
  To: Andrew Pinski
  Cc: Catalin Marinas, LKML, linux-arm-kernel@lists.infradead.org,
	Andrew Pinski, Ming Lei, Will Deacon, David Daney

Hi Andrew,

On 16/12/15 03:01, Andrew Pinski wrote:
> On Tue, Dec 9, 2015 at 17:26:56, Catalin Marinas
> <catalin.marinas@arm.com> wrote:
>>
>> Currently the BUG_ON() checks do not give enough information about the PTEs being set. This patch changes BUG_ON to WARN_ONCE and dumps the values of the old and new PTEs.
> 
> 
> This change broke building the mantis driver:
> 
> In file included from ./arch/arm64/include/asm/io.h:30:0,
>                  from drivers/media/pci/mantis/mantis_i2c.c:21:
> ./arch/arm64/include/asm/pgtable.h: In function ‘set_pte_at’:
> ./arch/arm64/include/asm/pgtable.h:281:3: error: implicit declaration
> of function ‘BUILD_BUG_ON_INVALID’
> [-Werror=implicit-function-declaration]
>    VM_WARN_ONCE(!pte_young(pte),
>    ^

This is due to a missing include in include/linux/mmdebug.h, which
Julien Grall saw with CONFIG_XEN & !CONFIG_DEBUG_VM. There was some
discussion at [0], and a patch at [1].

The quick-and-dirty workaround is to toggle CONFIG_DEBUG_VM. It should
be fixed in the next rc.


Thanks,

James

[0] https://lkml.org/lkml/2015/12/14/489
[1] http://www.spinics.net/lists/linux-mm/msg98868.html

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

end of thread, other threads:[~2015-12-16 11:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-16  3:01 [PATCH 1/2] arm64: Improve error reporting on set_pte_at() checks Andrew Pinski
2015-12-16 11:15 ` James Morse
2015-12-16 11:15   ` James Morse
  -- strict thread matches above, loose matches on Subject: below --
2015-12-09 17:26 [PATCH 0/2] arm64: Non-racy PTE setting in the presence of HW AF/DBM Catalin Marinas
2015-12-09 17:26 ` [PATCH 1/2] arm64: Improve error reporting on set_pte_at() checks 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.