@@ -119,26 +119,37 @@ For printing struct resources. The ``R`` and ``r`` specifiers result in a
printed resource with (``R``) or without (``r``) a decoded flags member.
Passed by reference.
+Physical addresses types
+========================
+
+::
+
+ %pa[P] 0x01234567 or 0x0123456789abcdef
+
+Synonymous with ``%pap[P]`` (for printing ``phys_addr_t``). See below.
+
Physical addresses types ``phys_addr_t``
========================================
::
- %pa[p] 0x01234567 or 0x0123456789abcdef
+ %pap[P] 0x01234567 or 0x0123456789abcdef
For printing a ``phys_addr_t`` type (and its derivatives, such as
``resource_size_t``) which can vary based on build options, regardless of
-the width of the CPU data path. Passed by reference.
+the width of the CPU data path. Passed by reference. Use the trailing 'P'
+if it needs to be always shown.
DMA addresses types ``dma_addr_t``
==================================
::
- %pad 0x01234567 or 0x0123456789abcdef
+ %pad[P] 0x01234567 or 0x0123456789abcdef
For printing a ``dma_addr_t`` type which can vary based on build options,
-regardless of the width of the CPU data path. Passed by reference.
+regardless of the width of the CPU data path. Passed by reference. Use the
+trailing 'P' if it needs to be always shown.
Raw buffer as an escaped string
===============================
@@ -400,8 +400,8 @@ however kernel pointers printed using %pP will continue to be printed.
When kptr_restrict is set to (4), kernel pointers printed with
%p, %pK, %pa, and %p[rR] will be replaced with 0's regardless of
-privileges. Kernel pointers printed using %pP will continue to be
-printed.
+privileges. Kernel pointers printed using %pP, %paP, %papP, %padP will
+continue to be printed.
==============================================================
@@ -1395,21 +1395,26 @@ static noinline_for_stack
char *address_val(char *buf, char *end, const void *addr, const char *fmt)
{
unsigned long long num;
+ int cleanse = kptr_restrict_cleanse_addresses();
+ int decleanse_idx = 1;
int size;
switch (fmt[1]) {
case 'd':
num = *(const dma_addr_t *)addr;
size = sizeof(dma_addr_t);
+ decleanse_idx = 2;
break;
case 'p':
+ decleanse_idx = 2;
+ /* fall through */
default:
num = *(const phys_addr_t *)addr;
size = sizeof(phys_addr_t);
break;
}
-
- if (kptr_restrict_cleanse_addresses())
+ /* 'P' on the tail means don't restrict the pointer. */
+ if (cleanse && (fmt[decleanse_idx] != 'P'))
num = 0UL;
return special_hex_number(buf, end, num, size);
Add %papP and %padP for address types that need to always be shown regardless of kptr restrictions. Add %paP is a synonym for %papP, this is inline with current implementation (%pa is a synonym for %pap). Signed-off-by: Tobin C. Harding <me@tobin.cc> --- Documentation/printk-formats.txt | 19 +++++++++++++++---- Documentation/sysctl/kernel.txt | 4 ++-- lib/vsprintf.c | 9 +++++++-- 3 files changed, 24 insertions(+), 8 deletions(-)