On Wed, Aug 12, 2026 at 01:33:14PM +0200, David Hildenbrand (Arm) wrote:
On 8/11/26 06:21, Anshuman Khandual wrote:
quoted
pxd_ERROR() has been used in generic mm just to print the page table entry
in pxd_clear_bad() before clearing those out with pxd_clear() later. These
pxd_ERROR() macros have been provided by all platforms which basically did
the same thing.
Make pxd_clear_bad() use recently added ptval_to_str() instead for printing
page table entries thus completely dropping dependency on platform provided
pxd_ERROR() macros which can then be dropped off. First move all required
helpers in core MM into a header file which could then be used else where.
It might make sense to split this patch further up to ease review:
Patch 1) provide ptval_to_str() a header.
Patch 2) Stop using pxd_ERROR() and friends in common code, converting to
pteval_to_str()
Patch 3) Remove now unused pxd_ERROR() and friends from arch code.
Sure but the intiial platform changes which now use ptval_to_str() as well
will probably come after the Patch (2) but before the Patch (3).
...
quoted
+static inline void
+ptval_bytes_to_hex_str(char *buf, size_t buf_size, const void *entry, size_t entry_size)
+{
+ if (WARN_ON_ONCE(buf_size < entry_size * 2 + 1)) {
+ snprintf(buf, buf_size, "overflow");
+ return;
+ }
+
+ switch (entry_size) {
+ case sizeof(u32):
+ snprintf(buf, buf_size, "%08x", *(const u32 *)entry);
+ break;
+ case sizeof(u64):
+ snprintf(buf, buf_size, "%016llx", *(const u64 *)entry);
+ break;
+#if defined(__SIZEOF_INT128__)
+ case sizeof(u128):
+ snprintf(buf, buf_size, "%016llx%016llx",
+ (unsigned long long)(*(const u128 *)entry >> 64),
+ (unsigned long long)*(const u128 *)entry);
+ break;
+#endif
+ default:
+ snprintf(buf, buf_size, "unsupported");
+ break;
+ }
+}
Why not leave ptval_bytes_to_hex_str() in the C file for less churn for now?
Agreed - will change.
--
Cheers,
David
Thanks for the review.