All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] riscv/mm/fault: add show_pte() before die()
@ 2024-07-23  2:18 ` Yunhui Cui
  0 siblings, 0 replies; 8+ messages in thread
From: Yunhui Cui @ 2024-07-23  2:18 UTC (permalink / raw)
  To: conor, punit.agrawal, paul.walmsley, palmer, aou, akpm, surenb,
	peterx, alexghiti, willy, linux-riscv, linux-kernel
  Cc: Yunhui Cui, Andrew Jones

When the kernel displays "Unable to handle kernel paging request at
virtual address", we would like to confirm the status of the virtual
address in the page table. So add show_pte() before die().

Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com>
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
---
 arch/riscv/mm/fault.c | 52 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c
index 5224f3733802..c72e6c7c09ef 100644
--- a/arch/riscv/mm/fault.c
+++ b/arch/riscv/mm/fault.c
@@ -22,6 +22,57 @@
 
 #include "../kernel/head.h"
 
+static void show_pte(unsigned long addr)
+{
+	pgd_t *pgdp, pgd;
+	p4d_t *p4dp, p4d;
+	pud_t *pudp, pud;
+	pmd_t *pmdp, pmd;
+	pte_t *ptep, pte;
+	struct mm_struct *mm = current->mm;
+
+	if (!mm)
+		mm = &init_mm;
+
+	pr_alert("Current %s pgtable: %luK pagesize, %d-bit VAs, pgdp=0x%016llx\n",
+		 current->comm, PAGE_SIZE / SZ_1K, VA_BITS,
+		 mm == &init_mm ? (u64)__pa_symbol(mm->pgd) : virt_to_phys(mm->pgd));
+
+	pgdp = pgd_offset(mm, addr);
+	pgd = pgdp_get(pgdp);
+	pr_alert("[%016lx] pgd=%016lx", addr, pgd_val(pgd));
+	if (pgd_none(pgd) || pgd_bad(pgd) || pgd_leaf(pgd))
+		goto out;
+
+	p4dp = p4d_offset(pgdp, addr);
+	p4d = p4dp_get(p4dp);
+	pr_cont(", p4d=%016lx", p4d_val(p4d));
+	if (p4d_none(p4d) || p4d_bad(p4d) || p4d_leaf(p4d))
+		goto out;
+
+	pudp = pud_offset(p4dp, addr);
+	pud = pudp_get(pudp);
+	pr_cont(", pud=%016lx", pud_val(pud));
+	if (pud_none(pud) || pud_bad(pud) || pud_leaf(pud))
+		goto out;
+
+	pmdp = pmd_offset(pudp, addr);
+	pmd = pmdp_get(pmdp);
+	pr_cont(", pmd=%016lx", pmd_val(pmd));
+	if (pmd_none(pmd) || pmd_bad(pmd) || pmd_leaf(pmd))
+		goto out;
+
+	ptep = pte_offset_map(pmdp, addr);
+	if (!ptep)
+		goto out;
+
+	pte = ptep_get(ptep);
+	pr_cont(", pte=%016lx", pte_val(pte));
+	pte_unmap(ptep);
+out:
+	pr_cont("\n");
+}
+
 static void die_kernel_fault(const char *msg, unsigned long addr,
 		struct pt_regs *regs)
 {
@@ -31,6 +82,7 @@ static void die_kernel_fault(const char *msg, unsigned long addr,
 		addr);
 
 	bust_spinlocks(0);
+	show_pte(addr);
 	die(regs, "Oops");
 	make_task_dead(SIGKILL);
 }
-- 
2.39.2


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* [PATCH v3] riscv/mm/fault: add show_pte() before die()
@ 2024-07-23  2:18 ` Yunhui Cui
  0 siblings, 0 replies; 8+ messages in thread
From: Yunhui Cui @ 2024-07-23  2:18 UTC (permalink / raw)
  To: conor, punit.agrawal, paul.walmsley, palmer, aou, akpm, surenb,
	peterx, alexghiti, willy, linux-riscv, linux-kernel
  Cc: Yunhui Cui, Andrew Jones

When the kernel displays "Unable to handle kernel paging request at
virtual address", we would like to confirm the status of the virtual
address in the page table. So add show_pte() before die().

Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com>
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
---
 arch/riscv/mm/fault.c | 52 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c
index 5224f3733802..c72e6c7c09ef 100644
--- a/arch/riscv/mm/fault.c
+++ b/arch/riscv/mm/fault.c
@@ -22,6 +22,57 @@
 
 #include "../kernel/head.h"
 
+static void show_pte(unsigned long addr)
+{
+	pgd_t *pgdp, pgd;
+	p4d_t *p4dp, p4d;
+	pud_t *pudp, pud;
+	pmd_t *pmdp, pmd;
+	pte_t *ptep, pte;
+	struct mm_struct *mm = current->mm;
+
+	if (!mm)
+		mm = &init_mm;
+
+	pr_alert("Current %s pgtable: %luK pagesize, %d-bit VAs, pgdp=0x%016llx\n",
+		 current->comm, PAGE_SIZE / SZ_1K, VA_BITS,
+		 mm == &init_mm ? (u64)__pa_symbol(mm->pgd) : virt_to_phys(mm->pgd));
+
+	pgdp = pgd_offset(mm, addr);
+	pgd = pgdp_get(pgdp);
+	pr_alert("[%016lx] pgd=%016lx", addr, pgd_val(pgd));
+	if (pgd_none(pgd) || pgd_bad(pgd) || pgd_leaf(pgd))
+		goto out;
+
+	p4dp = p4d_offset(pgdp, addr);
+	p4d = p4dp_get(p4dp);
+	pr_cont(", p4d=%016lx", p4d_val(p4d));
+	if (p4d_none(p4d) || p4d_bad(p4d) || p4d_leaf(p4d))
+		goto out;
+
+	pudp = pud_offset(p4dp, addr);
+	pud = pudp_get(pudp);
+	pr_cont(", pud=%016lx", pud_val(pud));
+	if (pud_none(pud) || pud_bad(pud) || pud_leaf(pud))
+		goto out;
+
+	pmdp = pmd_offset(pudp, addr);
+	pmd = pmdp_get(pmdp);
+	pr_cont(", pmd=%016lx", pmd_val(pmd));
+	if (pmd_none(pmd) || pmd_bad(pmd) || pmd_leaf(pmd))
+		goto out;
+
+	ptep = pte_offset_map(pmdp, addr);
+	if (!ptep)
+		goto out;
+
+	pte = ptep_get(ptep);
+	pr_cont(", pte=%016lx", pte_val(pte));
+	pte_unmap(ptep);
+out:
+	pr_cont("\n");
+}
+
 static void die_kernel_fault(const char *msg, unsigned long addr,
 		struct pt_regs *regs)
 {
@@ -31,6 +82,7 @@ static void die_kernel_fault(const char *msg, unsigned long addr,
 		addr);
 
 	bust_spinlocks(0);
+	show_pte(addr);
 	die(regs, "Oops");
 	make_task_dead(SIGKILL);
 }
-- 
2.39.2


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

* Re: [PATCH v3] riscv/mm/fault: add show_pte() before die()
  2024-07-23  2:18 ` Yunhui Cui
@ 2024-08-15  2:05   ` yunhui cui
  -1 siblings, 0 replies; 8+ messages in thread
From: yunhui cui @ 2024-08-15  2:05 UTC (permalink / raw)
  To: conor, punit.agrawal, paul.walmsley, palmer, aou, akpm, surenb,
	peterx, alexghiti, willy, linux-riscv, linux-kernel
  Cc: Andrew Jones

Hi All,

A gentle ping, Any more comments on this patch?

On Tue, Jul 23, 2024 at 10:18 AM Yunhui Cui <cuiyunhui@bytedance.com> wrote:
>
> When the kernel displays "Unable to handle kernel paging request at
> virtual address", we would like to confirm the status of the virtual
> address in the page table. So add show_pte() before die().
>
> Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com>
> Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
> Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
> ---
>  arch/riscv/mm/fault.c | 52 +++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 52 insertions(+)
>
> diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c
> index 5224f3733802..c72e6c7c09ef 100644
> --- a/arch/riscv/mm/fault.c
> +++ b/arch/riscv/mm/fault.c
> @@ -22,6 +22,57 @@
>
>  #include "../kernel/head.h"
>
> +static void show_pte(unsigned long addr)
> +{
> +       pgd_t *pgdp, pgd;
> +       p4d_t *p4dp, p4d;
> +       pud_t *pudp, pud;
> +       pmd_t *pmdp, pmd;
> +       pte_t *ptep, pte;
> +       struct mm_struct *mm = current->mm;
> +
> +       if (!mm)
> +               mm = &init_mm;
> +
> +       pr_alert("Current %s pgtable: %luK pagesize, %d-bit VAs, pgdp=0x%016llx\n",
> +                current->comm, PAGE_SIZE / SZ_1K, VA_BITS,
> +                mm == &init_mm ? (u64)__pa_symbol(mm->pgd) : virt_to_phys(mm->pgd));
> +
> +       pgdp = pgd_offset(mm, addr);
> +       pgd = pgdp_get(pgdp);
> +       pr_alert("[%016lx] pgd=%016lx", addr, pgd_val(pgd));
> +       if (pgd_none(pgd) || pgd_bad(pgd) || pgd_leaf(pgd))
> +               goto out;
> +
> +       p4dp = p4d_offset(pgdp, addr);
> +       p4d = p4dp_get(p4dp);
> +       pr_cont(", p4d=%016lx", p4d_val(p4d));
> +       if (p4d_none(p4d) || p4d_bad(p4d) || p4d_leaf(p4d))
> +               goto out;
> +
> +       pudp = pud_offset(p4dp, addr);
> +       pud = pudp_get(pudp);
> +       pr_cont(", pud=%016lx", pud_val(pud));
> +       if (pud_none(pud) || pud_bad(pud) || pud_leaf(pud))
> +               goto out;
> +
> +       pmdp = pmd_offset(pudp, addr);
> +       pmd = pmdp_get(pmdp);
> +       pr_cont(", pmd=%016lx", pmd_val(pmd));
> +       if (pmd_none(pmd) || pmd_bad(pmd) || pmd_leaf(pmd))
> +               goto out;
> +
> +       ptep = pte_offset_map(pmdp, addr);
> +       if (!ptep)
> +               goto out;
> +
> +       pte = ptep_get(ptep);
> +       pr_cont(", pte=%016lx", pte_val(pte));
> +       pte_unmap(ptep);
> +out:
> +       pr_cont("\n");
> +}
> +
>  static void die_kernel_fault(const char *msg, unsigned long addr,
>                 struct pt_regs *regs)
>  {
> @@ -31,6 +82,7 @@ static void die_kernel_fault(const char *msg, unsigned long addr,
>                 addr);
>
>         bust_spinlocks(0);
> +       show_pte(addr);
>         die(regs, "Oops");
>         make_task_dead(SIGKILL);
>  }
> --
> 2.39.2
>

Thanks,
Yunhui

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH v3] riscv/mm/fault: add show_pte() before die()
@ 2024-08-15  2:05   ` yunhui cui
  0 siblings, 0 replies; 8+ messages in thread
From: yunhui cui @ 2024-08-15  2:05 UTC (permalink / raw)
  To: conor, punit.agrawal, paul.walmsley, palmer, aou, akpm, surenb,
	peterx, alexghiti, willy, linux-riscv, linux-kernel
  Cc: Andrew Jones

Hi All,

A gentle ping, Any more comments on this patch?

On Tue, Jul 23, 2024 at 10:18 AM Yunhui Cui <cuiyunhui@bytedance.com> wrote:
>
> When the kernel displays "Unable to handle kernel paging request at
> virtual address", we would like to confirm the status of the virtual
> address in the page table. So add show_pte() before die().
>
> Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com>
> Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
> Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
> ---
>  arch/riscv/mm/fault.c | 52 +++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 52 insertions(+)
>
> diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c
> index 5224f3733802..c72e6c7c09ef 100644
> --- a/arch/riscv/mm/fault.c
> +++ b/arch/riscv/mm/fault.c
> @@ -22,6 +22,57 @@
>
>  #include "../kernel/head.h"
>
> +static void show_pte(unsigned long addr)
> +{
> +       pgd_t *pgdp, pgd;
> +       p4d_t *p4dp, p4d;
> +       pud_t *pudp, pud;
> +       pmd_t *pmdp, pmd;
> +       pte_t *ptep, pte;
> +       struct mm_struct *mm = current->mm;
> +
> +       if (!mm)
> +               mm = &init_mm;
> +
> +       pr_alert("Current %s pgtable: %luK pagesize, %d-bit VAs, pgdp=0x%016llx\n",
> +                current->comm, PAGE_SIZE / SZ_1K, VA_BITS,
> +                mm == &init_mm ? (u64)__pa_symbol(mm->pgd) : virt_to_phys(mm->pgd));
> +
> +       pgdp = pgd_offset(mm, addr);
> +       pgd = pgdp_get(pgdp);
> +       pr_alert("[%016lx] pgd=%016lx", addr, pgd_val(pgd));
> +       if (pgd_none(pgd) || pgd_bad(pgd) || pgd_leaf(pgd))
> +               goto out;
> +
> +       p4dp = p4d_offset(pgdp, addr);
> +       p4d = p4dp_get(p4dp);
> +       pr_cont(", p4d=%016lx", p4d_val(p4d));
> +       if (p4d_none(p4d) || p4d_bad(p4d) || p4d_leaf(p4d))
> +               goto out;
> +
> +       pudp = pud_offset(p4dp, addr);
> +       pud = pudp_get(pudp);
> +       pr_cont(", pud=%016lx", pud_val(pud));
> +       if (pud_none(pud) || pud_bad(pud) || pud_leaf(pud))
> +               goto out;
> +
> +       pmdp = pmd_offset(pudp, addr);
> +       pmd = pmdp_get(pmdp);
> +       pr_cont(", pmd=%016lx", pmd_val(pmd));
> +       if (pmd_none(pmd) || pmd_bad(pmd) || pmd_leaf(pmd))
> +               goto out;
> +
> +       ptep = pte_offset_map(pmdp, addr);
> +       if (!ptep)
> +               goto out;
> +
> +       pte = ptep_get(ptep);
> +       pr_cont(", pte=%016lx", pte_val(pte));
> +       pte_unmap(ptep);
> +out:
> +       pr_cont("\n");
> +}
> +
>  static void die_kernel_fault(const char *msg, unsigned long addr,
>                 struct pt_regs *regs)
>  {
> @@ -31,6 +82,7 @@ static void die_kernel_fault(const char *msg, unsigned long addr,
>                 addr);
>
>         bust_spinlocks(0);
> +       show_pte(addr);
>         die(regs, "Oops");
>         make_task_dead(SIGKILL);
>  }
> --
> 2.39.2
>

Thanks,
Yunhui

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

* Re: [PATCH v3] riscv/mm/fault: add show_pte() before die()
  2024-08-15  2:05   ` yunhui cui
@ 2024-09-18  3:44     ` yunhui cui
  -1 siblings, 0 replies; 8+ messages in thread
From: yunhui cui @ 2024-09-18  3:44 UTC (permalink / raw)
  To: conor, punit.agrawal, paul.walmsley, palmer, aou, akpm, surenb,
	peterx, alexghiti, willy, linux-riscv, linux-kernel
  Cc: Andrew Jones

Hi Palmer,

A gentle ping for this patch.

On Thu, Aug 15, 2024 at 10:05 AM yunhui cui <cuiyunhui@bytedance.com> wrote:
>
> Hi All,
>
> A gentle ping, Any more comments on this patch?
>
> On Tue, Jul 23, 2024 at 10:18 AM Yunhui Cui <cuiyunhui@bytedance.com> wrote:
> >
> > When the kernel displays "Unable to handle kernel paging request at
> > virtual address", we would like to confirm the status of the virtual
> > address in the page table. So add show_pte() before die().
> >
> > Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com>
> > Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
> > Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
> > ---
> >  arch/riscv/mm/fault.c | 52 +++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 52 insertions(+)
> >
> > diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c
> > index 5224f3733802..c72e6c7c09ef 100644
> > --- a/arch/riscv/mm/fault.c
> > +++ b/arch/riscv/mm/fault.c
> > @@ -22,6 +22,57 @@
> >
> >  #include "../kernel/head.h"
> >
> > +static void show_pte(unsigned long addr)
> > +{
> > +       pgd_t *pgdp, pgd;
> > +       p4d_t *p4dp, p4d;
> > +       pud_t *pudp, pud;
> > +       pmd_t *pmdp, pmd;
> > +       pte_t *ptep, pte;
> > +       struct mm_struct *mm = current->mm;
> > +
> > +       if (!mm)
> > +               mm = &init_mm;
> > +
> > +       pr_alert("Current %s pgtable: %luK pagesize, %d-bit VAs, pgdp=0x%016llx\n",
> > +                current->comm, PAGE_SIZE / SZ_1K, VA_BITS,
> > +                mm == &init_mm ? (u64)__pa_symbol(mm->pgd) : virt_to_phys(mm->pgd));
> > +
> > +       pgdp = pgd_offset(mm, addr);
> > +       pgd = pgdp_get(pgdp);
> > +       pr_alert("[%016lx] pgd=%016lx", addr, pgd_val(pgd));
> > +       if (pgd_none(pgd) || pgd_bad(pgd) || pgd_leaf(pgd))
> > +               goto out;
> > +
> > +       p4dp = p4d_offset(pgdp, addr);
> > +       p4d = p4dp_get(p4dp);
> > +       pr_cont(", p4d=%016lx", p4d_val(p4d));
> > +       if (p4d_none(p4d) || p4d_bad(p4d) || p4d_leaf(p4d))
> > +               goto out;
> > +
> > +       pudp = pud_offset(p4dp, addr);
> > +       pud = pudp_get(pudp);
> > +       pr_cont(", pud=%016lx", pud_val(pud));
> > +       if (pud_none(pud) || pud_bad(pud) || pud_leaf(pud))
> > +               goto out;
> > +
> > +       pmdp = pmd_offset(pudp, addr);
> > +       pmd = pmdp_get(pmdp);
> > +       pr_cont(", pmd=%016lx", pmd_val(pmd));
> > +       if (pmd_none(pmd) || pmd_bad(pmd) || pmd_leaf(pmd))
> > +               goto out;
> > +
> > +       ptep = pte_offset_map(pmdp, addr);
> > +       if (!ptep)
> > +               goto out;
> > +
> > +       pte = ptep_get(ptep);
> > +       pr_cont(", pte=%016lx", pte_val(pte));
> > +       pte_unmap(ptep);
> > +out:
> > +       pr_cont("\n");
> > +}
> > +
> >  static void die_kernel_fault(const char *msg, unsigned long addr,
> >                 struct pt_regs *regs)
> >  {
> > @@ -31,6 +82,7 @@ static void die_kernel_fault(const char *msg, unsigned long addr,
> >                 addr);
> >
> >         bust_spinlocks(0);
> > +       show_pte(addr);
> >         die(regs, "Oops");
> >         make_task_dead(SIGKILL);
> >  }
> > --
> > 2.39.2
> >
>
> Thanks,
> Yunhui


Thanks,
Yunhui

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH v3] riscv/mm/fault: add show_pte() before die()
@ 2024-09-18  3:44     ` yunhui cui
  0 siblings, 0 replies; 8+ messages in thread
From: yunhui cui @ 2024-09-18  3:44 UTC (permalink / raw)
  To: conor, punit.agrawal, paul.walmsley, palmer, aou, akpm, surenb,
	peterx, alexghiti, willy, linux-riscv, linux-kernel
  Cc: Andrew Jones

Hi Palmer,

A gentle ping for this patch.

On Thu, Aug 15, 2024 at 10:05 AM yunhui cui <cuiyunhui@bytedance.com> wrote:
>
> Hi All,
>
> A gentle ping, Any more comments on this patch?
>
> On Tue, Jul 23, 2024 at 10:18 AM Yunhui Cui <cuiyunhui@bytedance.com> wrote:
> >
> > When the kernel displays "Unable to handle kernel paging request at
> > virtual address", we would like to confirm the status of the virtual
> > address in the page table. So add show_pte() before die().
> >
> > Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com>
> > Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
> > Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
> > ---
> >  arch/riscv/mm/fault.c | 52 +++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 52 insertions(+)
> >
> > diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c
> > index 5224f3733802..c72e6c7c09ef 100644
> > --- a/arch/riscv/mm/fault.c
> > +++ b/arch/riscv/mm/fault.c
> > @@ -22,6 +22,57 @@
> >
> >  #include "../kernel/head.h"
> >
> > +static void show_pte(unsigned long addr)
> > +{
> > +       pgd_t *pgdp, pgd;
> > +       p4d_t *p4dp, p4d;
> > +       pud_t *pudp, pud;
> > +       pmd_t *pmdp, pmd;
> > +       pte_t *ptep, pte;
> > +       struct mm_struct *mm = current->mm;
> > +
> > +       if (!mm)
> > +               mm = &init_mm;
> > +
> > +       pr_alert("Current %s pgtable: %luK pagesize, %d-bit VAs, pgdp=0x%016llx\n",
> > +                current->comm, PAGE_SIZE / SZ_1K, VA_BITS,
> > +                mm == &init_mm ? (u64)__pa_symbol(mm->pgd) : virt_to_phys(mm->pgd));
> > +
> > +       pgdp = pgd_offset(mm, addr);
> > +       pgd = pgdp_get(pgdp);
> > +       pr_alert("[%016lx] pgd=%016lx", addr, pgd_val(pgd));
> > +       if (pgd_none(pgd) || pgd_bad(pgd) || pgd_leaf(pgd))
> > +               goto out;
> > +
> > +       p4dp = p4d_offset(pgdp, addr);
> > +       p4d = p4dp_get(p4dp);
> > +       pr_cont(", p4d=%016lx", p4d_val(p4d));
> > +       if (p4d_none(p4d) || p4d_bad(p4d) || p4d_leaf(p4d))
> > +               goto out;
> > +
> > +       pudp = pud_offset(p4dp, addr);
> > +       pud = pudp_get(pudp);
> > +       pr_cont(", pud=%016lx", pud_val(pud));
> > +       if (pud_none(pud) || pud_bad(pud) || pud_leaf(pud))
> > +               goto out;
> > +
> > +       pmdp = pmd_offset(pudp, addr);
> > +       pmd = pmdp_get(pmdp);
> > +       pr_cont(", pmd=%016lx", pmd_val(pmd));
> > +       if (pmd_none(pmd) || pmd_bad(pmd) || pmd_leaf(pmd))
> > +               goto out;
> > +
> > +       ptep = pte_offset_map(pmdp, addr);
> > +       if (!ptep)
> > +               goto out;
> > +
> > +       pte = ptep_get(ptep);
> > +       pr_cont(", pte=%016lx", pte_val(pte));
> > +       pte_unmap(ptep);
> > +out:
> > +       pr_cont("\n");
> > +}
> > +
> >  static void die_kernel_fault(const char *msg, unsigned long addr,
> >                 struct pt_regs *regs)
> >  {
> > @@ -31,6 +82,7 @@ static void die_kernel_fault(const char *msg, unsigned long addr,
> >                 addr);
> >
> >         bust_spinlocks(0);
> > +       show_pte(addr);
> >         die(regs, "Oops");
> >         make_task_dead(SIGKILL);
> >  }
> > --
> > 2.39.2
> >
>
> Thanks,
> Yunhui


Thanks,
Yunhui

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

* Re: [PATCH v3] riscv/mm/fault: add show_pte() before die()
  2024-09-18  3:44     ` yunhui cui
@ 2024-10-23 14:25       ` Punit Agrawal
  -1 siblings, 0 replies; 8+ messages in thread
From: Punit Agrawal @ 2024-10-23 14:25 UTC (permalink / raw)
  To: palmer
  Cc: conor, punit.agrawal, paul.walmsley, aou, akpm, surenb, peterx,
	alexghiti, willy, linux-riscv, linux-kernel, Andrew Jones,
	yunhui cui

yunhui cui <cuiyunhui@bytedance.com> writes:

> Hi Palmer,
>
> A gentle ping for this patch.
>
> On Thu, Aug 15, 2024 at 10:05 AM yunhui cui <cuiyunhui@bytedance.com> wrote:
>>
>> Hi All,
>>
>> A gentle ping, Any more comments on this patch?
>>
>> On Tue, Jul 23, 2024 at 10:18 AM Yunhui Cui <cuiyunhui@bytedance.com> wrote:
>> >
>> > When the kernel displays "Unable to handle kernel paging request at
>> > virtual address", we would like to confirm the status of the virtual
>> > address in the page table. So add show_pte() before die().
>> >
>> > Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com>
>> > Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
>> > Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
>> > ---
>> >  arch/riscv/mm/fault.c | 52 +++++++++++++++++++++++++++++++++++++++++++
>> >  1 file changed, 52 insertions(+)

Another one that seems to have slipped through the cracks. If there are
no further comments, please merge the patch.

Thanks,
Punit

>> >
>> > diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c
>> > index 5224f3733802..c72e6c7c09ef 100644
>> > --- a/arch/riscv/mm/fault.c
>> > +++ b/arch/riscv/mm/fault.c
>> > @@ -22,6 +22,57 @@
>> >
>> >  #include "../kernel/head.h"
>> >
>> > +static void show_pte(unsigned long addr)
>> > +{
>> > +       pgd_t *pgdp, pgd;
>> > +       p4d_t *p4dp, p4d;
>> > +       pud_t *pudp, pud;
>> > +       pmd_t *pmdp, pmd;
>> > +       pte_t *ptep, pte;
>> > +       struct mm_struct *mm = current->mm;
>> > +
>> > +       if (!mm)
>> > +               mm = &init_mm;
>> > +
>> > +       pr_alert("Current %s pgtable: %luK pagesize, %d-bit VAs, pgdp=0x%016llx\n",
>> > +                current->comm, PAGE_SIZE / SZ_1K, VA_BITS,
>> > +                mm == &init_mm ? (u64)__pa_symbol(mm->pgd) : virt_to_phys(mm->pgd));
>> > +
>> > +       pgdp = pgd_offset(mm, addr);
>> > +       pgd = pgdp_get(pgdp);
>> > +       pr_alert("[%016lx] pgd=%016lx", addr, pgd_val(pgd));
>> > +       if (pgd_none(pgd) || pgd_bad(pgd) || pgd_leaf(pgd))
>> > +               goto out;
>> > +
>> > +       p4dp = p4d_offset(pgdp, addr);
>> > +       p4d = p4dp_get(p4dp);
>> > +       pr_cont(", p4d=%016lx", p4d_val(p4d));
>> > +       if (p4d_none(p4d) || p4d_bad(p4d) || p4d_leaf(p4d))
>> > +               goto out;
>> > +
>> > +       pudp = pud_offset(p4dp, addr);
>> > +       pud = pudp_get(pudp);
>> > +       pr_cont(", pud=%016lx", pud_val(pud));
>> > +       if (pud_none(pud) || pud_bad(pud) || pud_leaf(pud))
>> > +               goto out;
>> > +
>> > +       pmdp = pmd_offset(pudp, addr);
>> > +       pmd = pmdp_get(pmdp);
>> > +       pr_cont(", pmd=%016lx", pmd_val(pmd));
>> > +       if (pmd_none(pmd) || pmd_bad(pmd) || pmd_leaf(pmd))
>> > +               goto out;
>> > +
>> > +       ptep = pte_offset_map(pmdp, addr);
>> > +       if (!ptep)
>> > +               goto out;
>> > +
>> > +       pte = ptep_get(ptep);
>> > +       pr_cont(", pte=%016lx", pte_val(pte));
>> > +       pte_unmap(ptep);
>> > +out:
>> > +       pr_cont("\n");
>> > +}
>> > +
>> >  static void die_kernel_fault(const char *msg, unsigned long addr,
>> >                 struct pt_regs *regs)
>> >  {
>> > @@ -31,6 +82,7 @@ static void die_kernel_fault(const char *msg, unsigned long addr,
>> >                 addr);
>> >
>> >         bust_spinlocks(0);
>> > +       show_pte(addr);
>> >         die(regs, "Oops");
>> >         make_task_dead(SIGKILL);
>> >  }
>> > --
>> > 2.39.2
>> >
>>
>> Thanks,
>> Yunhui
>
>
> Thanks,
> Yunhui

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH v3] riscv/mm/fault: add show_pte() before die()
@ 2024-10-23 14:25       ` Punit Agrawal
  0 siblings, 0 replies; 8+ messages in thread
From: Punit Agrawal @ 2024-10-23 14:25 UTC (permalink / raw)
  To: palmer
  Cc: conor, punit.agrawal, paul.walmsley, aou, akpm, surenb, peterx,
	alexghiti, willy, linux-riscv, linux-kernel, Andrew Jones,
	yunhui cui

yunhui cui <cuiyunhui@bytedance.com> writes:

> Hi Palmer,
>
> A gentle ping for this patch.
>
> On Thu, Aug 15, 2024 at 10:05 AM yunhui cui <cuiyunhui@bytedance.com> wrote:
>>
>> Hi All,
>>
>> A gentle ping, Any more comments on this patch?
>>
>> On Tue, Jul 23, 2024 at 10:18 AM Yunhui Cui <cuiyunhui@bytedance.com> wrote:
>> >
>> > When the kernel displays "Unable to handle kernel paging request at
>> > virtual address", we would like to confirm the status of the virtual
>> > address in the page table. So add show_pte() before die().
>> >
>> > Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com>
>> > Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
>> > Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
>> > ---
>> >  arch/riscv/mm/fault.c | 52 +++++++++++++++++++++++++++++++++++++++++++
>> >  1 file changed, 52 insertions(+)

Another one that seems to have slipped through the cracks. If there are
no further comments, please merge the patch.

Thanks,
Punit

>> >
>> > diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c
>> > index 5224f3733802..c72e6c7c09ef 100644
>> > --- a/arch/riscv/mm/fault.c
>> > +++ b/arch/riscv/mm/fault.c
>> > @@ -22,6 +22,57 @@
>> >
>> >  #include "../kernel/head.h"
>> >
>> > +static void show_pte(unsigned long addr)
>> > +{
>> > +       pgd_t *pgdp, pgd;
>> > +       p4d_t *p4dp, p4d;
>> > +       pud_t *pudp, pud;
>> > +       pmd_t *pmdp, pmd;
>> > +       pte_t *ptep, pte;
>> > +       struct mm_struct *mm = current->mm;
>> > +
>> > +       if (!mm)
>> > +               mm = &init_mm;
>> > +
>> > +       pr_alert("Current %s pgtable: %luK pagesize, %d-bit VAs, pgdp=0x%016llx\n",
>> > +                current->comm, PAGE_SIZE / SZ_1K, VA_BITS,
>> > +                mm == &init_mm ? (u64)__pa_symbol(mm->pgd) : virt_to_phys(mm->pgd));
>> > +
>> > +       pgdp = pgd_offset(mm, addr);
>> > +       pgd = pgdp_get(pgdp);
>> > +       pr_alert("[%016lx] pgd=%016lx", addr, pgd_val(pgd));
>> > +       if (pgd_none(pgd) || pgd_bad(pgd) || pgd_leaf(pgd))
>> > +               goto out;
>> > +
>> > +       p4dp = p4d_offset(pgdp, addr);
>> > +       p4d = p4dp_get(p4dp);
>> > +       pr_cont(", p4d=%016lx", p4d_val(p4d));
>> > +       if (p4d_none(p4d) || p4d_bad(p4d) || p4d_leaf(p4d))
>> > +               goto out;
>> > +
>> > +       pudp = pud_offset(p4dp, addr);
>> > +       pud = pudp_get(pudp);
>> > +       pr_cont(", pud=%016lx", pud_val(pud));
>> > +       if (pud_none(pud) || pud_bad(pud) || pud_leaf(pud))
>> > +               goto out;
>> > +
>> > +       pmdp = pmd_offset(pudp, addr);
>> > +       pmd = pmdp_get(pmdp);
>> > +       pr_cont(", pmd=%016lx", pmd_val(pmd));
>> > +       if (pmd_none(pmd) || pmd_bad(pmd) || pmd_leaf(pmd))
>> > +               goto out;
>> > +
>> > +       ptep = pte_offset_map(pmdp, addr);
>> > +       if (!ptep)
>> > +               goto out;
>> > +
>> > +       pte = ptep_get(ptep);
>> > +       pr_cont(", pte=%016lx", pte_val(pte));
>> > +       pte_unmap(ptep);
>> > +out:
>> > +       pr_cont("\n");
>> > +}
>> > +
>> >  static void die_kernel_fault(const char *msg, unsigned long addr,
>> >                 struct pt_regs *regs)
>> >  {
>> > @@ -31,6 +82,7 @@ static void die_kernel_fault(const char *msg, unsigned long addr,
>> >                 addr);
>> >
>> >         bust_spinlocks(0);
>> > +       show_pte(addr);
>> >         die(regs, "Oops");
>> >         make_task_dead(SIGKILL);
>> >  }
>> > --
>> > 2.39.2
>> >
>>
>> Thanks,
>> Yunhui
>
>
> Thanks,
> Yunhui

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

end of thread, other threads:[~2024-10-23 14:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-23  2:18 [PATCH v3] riscv/mm/fault: add show_pte() before die() Yunhui Cui
2024-07-23  2:18 ` Yunhui Cui
2024-08-15  2:05 ` yunhui cui
2024-08-15  2:05   ` yunhui cui
2024-09-18  3:44   ` yunhui cui
2024-09-18  3:44     ` yunhui cui
2024-10-23 14:25     ` Punit Agrawal
2024-10-23 14:25       ` Punit Agrawal

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.