diff mbox series

[2/7] x86/mm: Drop page table entry address output from pxd_ERROR()

Message ID 20240913084433.1016256-3-anshuman.khandual@arm.com (mailing list archive)
State New
Headers show
Series mm: Use pxdp_get() for accessing page table entries | expand

Commit Message

Anshuman Khandual Sept. 13, 2024, 8:44 a.m. UTC
This drops page table entry address output from all pxd_ERROR() definitions
which now matches with other architectures. This also prevents build issues
while transitioning into pxdp_get() based page table entry accesses.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: x86@kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
 arch/x86/include/asm/pgtable-3level.h | 12 ++++++------
 arch/x86/include/asm/pgtable_64.h     | 20 ++++++++++----------
 2 files changed, 16 insertions(+), 16 deletions(-)

Comments

Dave Hansen Sept. 13, 2024, 5:21 p.m. UTC | #1
On 9/13/24 01:44, Anshuman Khandual wrote:
> This drops page table entry address output from all pxd_ERROR() definitions
> which now matches with other architectures. This also prevents build issues
> while transitioning into pxdp_get() based page table entry accesses.

Could you be a _little_ more specific than "build issues"?  Is it that
you want to do:

 void pmd_clear_bad(pmd_t *pmd)
 {
-        pmd_ERROR(*pmd);
+        pmd_ERROR(pmdp_get(pmd));
         pmd_clear(pmd);
 }

But the pmd_ERROR() macro would expand that to:

	&pmdp_get(pmd)

which is nonsense?

Having the PTEs' kernel addresses _is_ handy, but I guess they're
scrambled on most end users' systems now and anybody that's actively
debugging can just use a kprobe or something to dump the pmd_clear_bad()
argument directly.
Anshuman Khandual Sept. 16, 2024, 2:54 a.m. UTC | #2
On 9/13/24 22:51, Dave Hansen wrote:
> On 9/13/24 01:44, Anshuman Khandual wrote:
>> This drops page table entry address output from all pxd_ERROR() definitions
>> which now matches with other architectures. This also prevents build issues
>> while transitioning into pxdp_get() based page table entry accesses.
> 
> Could you be a _little_ more specific than "build issues"?  Is it that
> you want to do:
> 
>  void pmd_clear_bad(pmd_t *pmd)
>  {
> -        pmd_ERROR(*pmd);
> +        pmd_ERROR(pmdp_get(pmd));
>          pmd_clear(pmd);
>  }
> 
> But the pmd_ERROR() macro would expand that to:
> 
> 	&pmdp_get(pmd)
> 
> which is nonsense?

Yes, that's the one which fails the build with the following warning.

error: lvalue required as unary '&' operand

Will update the commit message with these details about the build problem.

> 
> Having the PTEs' kernel addresses _is_ handy, but I guess they're
> scrambled on most end users' systems now and anybody that's actively
> debugging can just use a kprobe or something to dump the pmd_clear_bad()
> argument directly.

Right.
diff mbox series

Patch

diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
index dabafba957ea..e1fa4dd87753 100644
--- a/arch/x86/include/asm/pgtable-3level.h
+++ b/arch/x86/include/asm/pgtable-3level.h
@@ -10,14 +10,14 @@ 
  */
 
 #define pte_ERROR(e)							\
-	pr_err("%s:%d: bad pte %p(%08lx%08lx)\n",			\
-	       __FILE__, __LINE__, &(e), (e).pte_high, (e).pte_low)
+	pr_err("%s:%d: bad pte (%08lx%08lx)\n",			\
+	       __FILE__, __LINE__, (e).pte_high, (e).pte_low)
 #define pmd_ERROR(e)							\
-	pr_err("%s:%d: bad pmd %p(%016Lx)\n",				\
-	       __FILE__, __LINE__, &(e), pmd_val(e))
+	pr_err("%s:%d: bad pmd (%016Lx)\n",				\
+	       __FILE__, __LINE__, pmd_val(e))
 #define pgd_ERROR(e)							\
-	pr_err("%s:%d: bad pgd %p(%016Lx)\n",				\
-	       __FILE__, __LINE__, &(e), pgd_val(e))
+	pr_err("%s:%d: bad pgd (%016Lx)\n",				\
+	       __FILE__, __LINE__, pgd_val(e))
 
 #define pxx_xchg64(_pxx, _ptr, _val) ({					\
 	_pxx##val_t *_p = (_pxx##val_t *)_ptr;				\
diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
index 3c4407271d08..4e462c825cab 100644
--- a/arch/x86/include/asm/pgtable_64.h
+++ b/arch/x86/include/asm/pgtable_64.h
@@ -32,24 +32,24 @@  extern void paging_init(void);
 static inline void sync_initial_page_table(void) { }
 
 #define pte_ERROR(e)					\
-	pr_err("%s:%d: bad pte %p(%016lx)\n",		\
-	       __FILE__, __LINE__, &(e), pte_val(e))
+	pr_err("%s:%d: bad pte (%016lx)\n",		\
+	       __FILE__, __LINE__, pte_val(e))
 #define pmd_ERROR(e)					\
-	pr_err("%s:%d: bad pmd %p(%016lx)\n",		\
-	       __FILE__, __LINE__, &(e), pmd_val(e))
+	pr_err("%s:%d: bad pmd (%016lx)\n",		\
+	       __FILE__, __LINE__, pmd_val(e))
 #define pud_ERROR(e)					\
-	pr_err("%s:%d: bad pud %p(%016lx)\n",		\
-	       __FILE__, __LINE__, &(e), pud_val(e))
+	pr_err("%s:%d: bad pud (%016lx)\n",		\
+	       __FILE__, __LINE__, pud_val(e))
 
 #if CONFIG_PGTABLE_LEVELS >= 5
 #define p4d_ERROR(e)					\
-	pr_err("%s:%d: bad p4d %p(%016lx)\n",		\
-	       __FILE__, __LINE__, &(e), p4d_val(e))
+	pr_err("%s:%d: bad p4d (%016lx)\n",		\
+	       __FILE__, __LINE__, p4d_val(e))
 #endif
 
 #define pgd_ERROR(e)					\
-	pr_err("%s:%d: bad pgd %p(%016lx)\n",		\
-	       __FILE__, __LINE__, &(e), pgd_val(e))
+	pr_err("%s:%d: bad pgd (%016lx)\n",		\
+	       __FILE__, __LINE__, pgd_val(e))
 
 struct mm_struct;