diff options
| -rw-r--r-- | Documentation/core-api/printk-formats.rst | 3 | ||||
| -rw-r--r-- | drivers/clk/renesas/renesas-cpg-mssr.c | 9 | ||||
| -rw-r--r-- | drivers/thermal/broadcom/bcm2835_thermal.c | 4 | ||||
| -rw-r--r-- | drivers/tty/serial/sh-sci.c | 4 | ||||
| -rw-r--r-- | kernel/printk/printk.c | 14 | ||||
| -rw-r--r-- | kernel/printk/printk_safe.c | 7 | ||||
| -rw-r--r-- | lib/test_printf.c | 2 | ||||
| -rw-r--r-- | lib/vsprintf.c | 133 |
8 files changed, 71 insertions, 105 deletions
diff --git a/Documentation/core-api/printk-formats.rst b/Documentation/core-api/printk-formats.rst index eb30efdd2e78..25dc591cb110 100644 --- a/Documentation/core-api/printk-formats.rst +++ b/Documentation/core-api/printk-formats.rst | |||
| @@ -419,11 +419,10 @@ struct clk | |||
| 419 | 419 | ||
| 420 | %pC pll1 | 420 | %pC pll1 |
| 421 | %pCn pll1 | 421 | %pCn pll1 |
| 422 | %pCr 1560000000 | ||
| 423 | 422 | ||
| 424 | For printing struct clk structures. %pC and %pCn print the name | 423 | For printing struct clk structures. %pC and %pCn print the name |
| 425 | (Common Clock Framework) or address (legacy clock framework) of the | 424 | (Common Clock Framework) or address (legacy clock framework) of the |
| 426 | structure; %pCr prints the current clock rate. | 425 | structure. |
| 427 | 426 | ||
| 428 | Passed by reference. | 427 | Passed by reference. |
| 429 | 428 | ||
diff --git a/drivers/clk/renesas/renesas-cpg-mssr.c b/drivers/clk/renesas/renesas-cpg-mssr.c index 4e88e980fb76..69a7c756658b 100644 --- a/drivers/clk/renesas/renesas-cpg-mssr.c +++ b/drivers/clk/renesas/renesas-cpg-mssr.c | |||
| @@ -258,8 +258,9 @@ struct clk *cpg_mssr_clk_src_twocell_get(struct of_phandle_args *clkspec, | |||
| 258 | dev_err(dev, "Cannot get %s clock %u: %ld", type, clkidx, | 258 | dev_err(dev, "Cannot get %s clock %u: %ld", type, clkidx, |
| 259 | PTR_ERR(clk)); | 259 | PTR_ERR(clk)); |
| 260 | else | 260 | else |
| 261 | dev_dbg(dev, "clock (%u, %u) is %pC at %pCr Hz\n", | 261 | dev_dbg(dev, "clock (%u, %u) is %pC at %lu Hz\n", |
| 262 | clkspec->args[0], clkspec->args[1], clk, clk); | 262 | clkspec->args[0], clkspec->args[1], clk, |
| 263 | clk_get_rate(clk)); | ||
| 263 | return clk; | 264 | return clk; |
| 264 | } | 265 | } |
| 265 | 266 | ||
| @@ -326,7 +327,7 @@ static void __init cpg_mssr_register_core_clk(const struct cpg_core_clk *core, | |||
| 326 | if (IS_ERR_OR_NULL(clk)) | 327 | if (IS_ERR_OR_NULL(clk)) |
| 327 | goto fail; | 328 | goto fail; |
| 328 | 329 | ||
| 329 | dev_dbg(dev, "Core clock %pC at %pCr Hz\n", clk, clk); | 330 | dev_dbg(dev, "Core clock %pC at %lu Hz\n", clk, clk_get_rate(clk)); |
| 330 | priv->clks[id] = clk; | 331 | priv->clks[id] = clk; |
| 331 | return; | 332 | return; |
| 332 | 333 | ||
| @@ -392,7 +393,7 @@ static void __init cpg_mssr_register_mod_clk(const struct mssr_mod_clk *mod, | |||
| 392 | if (IS_ERR(clk)) | 393 | if (IS_ERR(clk)) |
| 393 | goto fail; | 394 | goto fail; |
| 394 | 395 | ||
| 395 | dev_dbg(dev, "Module clock %pC at %pCr Hz\n", clk, clk); | 396 | dev_dbg(dev, "Module clock %pC at %lu Hz\n", clk, clk_get_rate(clk)); |
| 396 | priv->clks[id] = clk; | 397 | priv->clks[id] = clk; |
| 397 | priv->smstpcr_saved[clock->index / 32].mask |= BIT(clock->index % 32); | 398 | priv->smstpcr_saved[clock->index / 32].mask |= BIT(clock->index % 32); |
| 398 | return; | 399 | return; |
diff --git a/drivers/thermal/broadcom/bcm2835_thermal.c b/drivers/thermal/broadcom/bcm2835_thermal.c index a4d6a0e2e993..23ad4f9f2143 100644 --- a/drivers/thermal/broadcom/bcm2835_thermal.c +++ b/drivers/thermal/broadcom/bcm2835_thermal.c | |||
| @@ -213,8 +213,8 @@ static int bcm2835_thermal_probe(struct platform_device *pdev) | |||
| 213 | rate = clk_get_rate(data->clk); | 213 | rate = clk_get_rate(data->clk); |
| 214 | if ((rate < 1920000) || (rate > 5000000)) | 214 | if ((rate < 1920000) || (rate > 5000000)) |
| 215 | dev_warn(&pdev->dev, | 215 | dev_warn(&pdev->dev, |
| 216 | "Clock %pCn running at %pCr Hz is outside of the recommended range: 1.92 to 5MHz\n", | 216 | "Clock %pCn running at %lu Hz is outside of the recommended range: 1.92 to 5MHz\n", |
| 217 | data->clk, data->clk); | 217 | data->clk, rate); |
| 218 | 218 | ||
| 219 | /* register of thermal sensor and get info from DT */ | 219 | /* register of thermal sensor and get info from DT */ |
| 220 | tz = thermal_zone_of_sensor_register(&pdev->dev, 0, data, | 220 | tz = thermal_zone_of_sensor_register(&pdev->dev, 0, data, |
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index b46b146524ce..c181eb37f985 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c | |||
| @@ -2724,8 +2724,8 @@ found: | |||
| 2724 | dev_dbg(dev, "failed to get %s (%ld)\n", clk_names[i], | 2724 | dev_dbg(dev, "failed to get %s (%ld)\n", clk_names[i], |
| 2725 | PTR_ERR(clk)); | 2725 | PTR_ERR(clk)); |
| 2726 | else | 2726 | else |
| 2727 | dev_dbg(dev, "clk %s is %pC rate %pCr\n", clk_names[i], | 2727 | dev_dbg(dev, "clk %s is %pC rate %lu\n", clk_names[i], |
| 2728 | clk, clk); | 2728 | clk, clk_get_rate(clk)); |
| 2729 | sci_port->clks[i] = IS_ERR(clk) ? NULL : clk; | 2729 | sci_port->clks[i] = IS_ERR(clk) ? NULL : clk; |
| 2730 | } | 2730 | } |
| 2731 | return 0; | 2731 | return 0; |
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 2f4af216bd6e..247808333ba4 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c | |||
| @@ -1908,6 +1908,7 @@ asmlinkage int vprintk_emit(int facility, int level, | |||
| 1908 | preempt_enable(); | 1908 | preempt_enable(); |
| 1909 | } | 1909 | } |
| 1910 | 1910 | ||
| 1911 | wake_up_klogd(); | ||
| 1911 | return printed_len; | 1912 | return printed_len; |
| 1912 | } | 1913 | } |
| 1913 | EXPORT_SYMBOL(vprintk_emit); | 1914 | EXPORT_SYMBOL(vprintk_emit); |
| @@ -2289,9 +2290,7 @@ void console_unlock(void) | |||
| 2289 | { | 2290 | { |
| 2290 | static char ext_text[CONSOLE_EXT_LOG_MAX]; | 2291 | static char ext_text[CONSOLE_EXT_LOG_MAX]; |
| 2291 | static char text[LOG_LINE_MAX + PREFIX_MAX]; | 2292 | static char text[LOG_LINE_MAX + PREFIX_MAX]; |
| 2292 | static u64 seen_seq; | ||
| 2293 | unsigned long flags; | 2293 | unsigned long flags; |
| 2294 | bool wake_klogd = false; | ||
| 2295 | bool do_cond_resched, retry; | 2294 | bool do_cond_resched, retry; |
| 2296 | 2295 | ||
| 2297 | if (console_suspended) { | 2296 | if (console_suspended) { |
| @@ -2335,11 +2334,6 @@ again: | |||
| 2335 | 2334 | ||
| 2336 | printk_safe_enter_irqsave(flags); | 2335 | printk_safe_enter_irqsave(flags); |
| 2337 | raw_spin_lock(&logbuf_lock); | 2336 | raw_spin_lock(&logbuf_lock); |
| 2338 | if (seen_seq != log_next_seq) { | ||
| 2339 | wake_klogd = true; | ||
| 2340 | seen_seq = log_next_seq; | ||
| 2341 | } | ||
| 2342 | |||
| 2343 | if (console_seq < log_first_seq) { | 2337 | if (console_seq < log_first_seq) { |
| 2344 | len = sprintf(text, "** %u printk messages dropped **\n", | 2338 | len = sprintf(text, "** %u printk messages dropped **\n", |
| 2345 | (unsigned)(log_first_seq - console_seq)); | 2339 | (unsigned)(log_first_seq - console_seq)); |
| @@ -2397,7 +2391,7 @@ skip: | |||
| 2397 | 2391 | ||
| 2398 | if (console_lock_spinning_disable_and_check()) { | 2392 | if (console_lock_spinning_disable_and_check()) { |
| 2399 | printk_safe_exit_irqrestore(flags); | 2393 | printk_safe_exit_irqrestore(flags); |
| 2400 | goto out; | 2394 | return; |
| 2401 | } | 2395 | } |
| 2402 | 2396 | ||
| 2403 | printk_safe_exit_irqrestore(flags); | 2397 | printk_safe_exit_irqrestore(flags); |
| @@ -2429,10 +2423,6 @@ skip: | |||
| 2429 | 2423 | ||
| 2430 | if (retry && console_trylock()) | 2424 | if (retry && console_trylock()) |
| 2431 | goto again; | 2425 | goto again; |
| 2432 | |||
| 2433 | out: | ||
| 2434 | if (wake_klogd) | ||
| 2435 | wake_up_klogd(); | ||
| 2436 | } | 2426 | } |
| 2437 | EXPORT_SYMBOL(console_unlock); | 2427 | EXPORT_SYMBOL(console_unlock); |
| 2438 | 2428 | ||
diff --git a/kernel/printk/printk_safe.c b/kernel/printk/printk_safe.c index 3e3c2004bb23..d7d091309054 100644 --- a/kernel/printk/printk_safe.c +++ b/kernel/printk/printk_safe.c | |||
| @@ -82,6 +82,7 @@ static __printf(2, 0) int printk_safe_log_store(struct printk_safe_seq_buf *s, | |||
| 82 | { | 82 | { |
| 83 | int add; | 83 | int add; |
| 84 | size_t len; | 84 | size_t len; |
| 85 | va_list ap; | ||
| 85 | 86 | ||
| 86 | again: | 87 | again: |
| 87 | len = atomic_read(&s->len); | 88 | len = atomic_read(&s->len); |
| @@ -100,7 +101,9 @@ again: | |||
| 100 | if (!len) | 101 | if (!len) |
| 101 | smp_rmb(); | 102 | smp_rmb(); |
| 102 | 103 | ||
| 103 | add = vscnprintf(s->buffer + len, sizeof(s->buffer) - len, fmt, args); | 104 | va_copy(ap, args); |
| 105 | add = vscnprintf(s->buffer + len, sizeof(s->buffer) - len, fmt, ap); | ||
| 106 | va_end(ap); | ||
| 104 | if (!add) | 107 | if (!add) |
| 105 | return 0; | 108 | return 0; |
| 106 | 109 | ||
| @@ -278,7 +281,7 @@ void printk_safe_flush_on_panic(void) | |||
| 278 | * Make sure that we could access the main ring buffer. | 281 | * Make sure that we could access the main ring buffer. |
| 279 | * Do not risk a double release when more CPUs are up. | 282 | * Do not risk a double release when more CPUs are up. |
| 280 | */ | 283 | */ |
| 281 | if (in_nmi() && raw_spin_is_locked(&logbuf_lock)) { | 284 | if (raw_spin_is_locked(&logbuf_lock)) { |
| 282 | if (num_online_cpus() > 1) | 285 | if (num_online_cpus() > 1) |
| 283 | return; | 286 | return; |
| 284 | 287 | ||
diff --git a/lib/test_printf.c b/lib/test_printf.c index 71ebfa43ad05..cea592f402ed 100644 --- a/lib/test_printf.c +++ b/lib/test_printf.c | |||
| @@ -204,7 +204,7 @@ test_string(void) | |||
| 204 | #if BITS_PER_LONG == 64 | 204 | #if BITS_PER_LONG == 64 |
| 205 | 205 | ||
| 206 | #define PTR_WIDTH 16 | 206 | #define PTR_WIDTH 16 |
| 207 | #define PTR ((void *)0xffff0123456789ab) | 207 | #define PTR ((void *)0xffff0123456789abUL) |
| 208 | #define PTR_STR "ffff0123456789ab" | 208 | #define PTR_STR "ffff0123456789ab" |
| 209 | #define ZEROS "00000000" /* hex 32 zero bits */ | 209 | #define ZEROS "00000000" /* hex 32 zero bits */ |
| 210 | 210 | ||
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 23920c5ff728..a48aaa79d352 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c | |||
| @@ -703,6 +703,22 @@ char *symbol_string(char *buf, char *end, void *ptr, | |||
| 703 | #endif | 703 | #endif |
| 704 | } | 704 | } |
| 705 | 705 | ||
| 706 | static const struct printf_spec default_str_spec = { | ||
| 707 | .field_width = -1, | ||
| 708 | .precision = -1, | ||
| 709 | }; | ||
| 710 | |||
| 711 | static const struct printf_spec default_flag_spec = { | ||
| 712 | .base = 16, | ||
| 713 | .precision = -1, | ||
| 714 | .flags = SPECIAL | SMALL, | ||
| 715 | }; | ||
| 716 | |||
| 717 | static const struct printf_spec default_dec_spec = { | ||
| 718 | .base = 10, | ||
| 719 | .precision = -1, | ||
| 720 | }; | ||
| 721 | |||
| 706 | static noinline_for_stack | 722 | static noinline_for_stack |
| 707 | char *resource_string(char *buf, char *end, struct resource *res, | 723 | char *resource_string(char *buf, char *end, struct resource *res, |
| 708 | struct printf_spec spec, const char *fmt) | 724 | struct printf_spec spec, const char *fmt) |
| @@ -732,21 +748,11 @@ char *resource_string(char *buf, char *end, struct resource *res, | |||
| 732 | .precision = -1, | 748 | .precision = -1, |
| 733 | .flags = SMALL | ZEROPAD, | 749 | .flags = SMALL | ZEROPAD, |
| 734 | }; | 750 | }; |
| 735 | static const struct printf_spec dec_spec = { | ||
| 736 | .base = 10, | ||
| 737 | .precision = -1, | ||
| 738 | .flags = 0, | ||
| 739 | }; | ||
| 740 | static const struct printf_spec str_spec = { | 751 | static const struct printf_spec str_spec = { |
| 741 | .field_width = -1, | 752 | .field_width = -1, |
| 742 | .precision = 10, | 753 | .precision = 10, |
| 743 | .flags = LEFT, | 754 | .flags = LEFT, |
| 744 | }; | 755 | }; |
| 745 | static const struct printf_spec flag_spec = { | ||
| 746 | .base = 16, | ||
| 747 | .precision = -1, | ||
| 748 | .flags = SPECIAL | SMALL, | ||
| 749 | }; | ||
| 750 | 756 | ||
| 751 | /* 32-bit res (sizeof==4): 10 chars in dec, 10 in hex ("0x" + 8) | 757 | /* 32-bit res (sizeof==4): 10 chars in dec, 10 in hex ("0x" + 8) |
| 752 | * 64-bit res (sizeof==8): 20 chars in dec, 18 in hex ("0x" + 16) */ | 758 | * 64-bit res (sizeof==8): 20 chars in dec, 18 in hex ("0x" + 16) */ |
| @@ -770,10 +776,10 @@ char *resource_string(char *buf, char *end, struct resource *res, | |||
| 770 | specp = &mem_spec; | 776 | specp = &mem_spec; |
| 771 | } else if (res->flags & IORESOURCE_IRQ) { | 777 | } else if (res->flags & IORESOURCE_IRQ) { |
| 772 | p = string(p, pend, "irq ", str_spec); | 778 | p = string(p, pend, "irq ", str_spec); |
| 773 | specp = &dec_spec; | 779 | specp = &default_dec_spec; |
| 774 | } else if (res->flags & IORESOURCE_DMA) { | 780 | } else if (res->flags & IORESOURCE_DMA) { |
| 775 | p = string(p, pend, "dma ", str_spec); | 781 | p = string(p, pend, "dma ", str_spec); |
| 776 | specp = &dec_spec; | 782 | specp = &default_dec_spec; |
| 777 | } else if (res->flags & IORESOURCE_BUS) { | 783 | } else if (res->flags & IORESOURCE_BUS) { |
| 778 | p = string(p, pend, "bus ", str_spec); | 784 | p = string(p, pend, "bus ", str_spec); |
| 779 | specp = &bus_spec; | 785 | specp = &bus_spec; |
| @@ -803,7 +809,7 @@ char *resource_string(char *buf, char *end, struct resource *res, | |||
| 803 | p = string(p, pend, " disabled", str_spec); | 809 | p = string(p, pend, " disabled", str_spec); |
| 804 | } else { | 810 | } else { |
| 805 | p = string(p, pend, " flags ", str_spec); | 811 | p = string(p, pend, " flags ", str_spec); |
| 806 | p = number(p, pend, res->flags, flag_spec); | 812 | p = number(p, pend, res->flags, default_flag_spec); |
| 807 | } | 813 | } |
| 808 | *p++ = ']'; | 814 | *p++ = ']'; |
| 809 | *p = '\0'; | 815 | *p = '\0'; |
| @@ -913,9 +919,6 @@ char *bitmap_list_string(char *buf, char *end, unsigned long *bitmap, | |||
| 913 | int cur, rbot, rtop; | 919 | int cur, rbot, rtop; |
| 914 | bool first = true; | 920 | bool first = true; |
| 915 | 921 | ||
| 916 | /* reused to print numbers */ | ||
| 917 | spec = (struct printf_spec){ .base = 10 }; | ||
| 918 | |||
| 919 | rbot = cur = find_first_bit(bitmap, nr_bits); | 922 | rbot = cur = find_first_bit(bitmap, nr_bits); |
| 920 | while (cur < nr_bits) { | 923 | while (cur < nr_bits) { |
| 921 | rtop = cur; | 924 | rtop = cur; |
| @@ -930,13 +933,13 @@ char *bitmap_list_string(char *buf, char *end, unsigned long *bitmap, | |||
| 930 | } | 933 | } |
| 931 | first = false; | 934 | first = false; |
| 932 | 935 | ||
| 933 | buf = number(buf, end, rbot, spec); | 936 | buf = number(buf, end, rbot, default_dec_spec); |
| 934 | if (rbot < rtop) { | 937 | if (rbot < rtop) { |
| 935 | if (buf < end) | 938 | if (buf < end) |
| 936 | *buf = '-'; | 939 | *buf = '-'; |
| 937 | buf++; | 940 | buf++; |
| 938 | 941 | ||
| 939 | buf = number(buf, end, rtop, spec); | 942 | buf = number(buf, end, rtop, default_dec_spec); |
| 940 | } | 943 | } |
| 941 | 944 | ||
| 942 | rbot = cur; | 945 | rbot = cur; |
| @@ -1354,11 +1357,9 @@ char *uuid_string(char *buf, char *end, const u8 *addr, | |||
| 1354 | return string(buf, end, uuid, spec); | 1357 | return string(buf, end, uuid, spec); |
| 1355 | } | 1358 | } |
| 1356 | 1359 | ||
| 1357 | int kptr_restrict __read_mostly; | ||
| 1358 | |||
| 1359 | static noinline_for_stack | 1360 | static noinline_for_stack |
| 1360 | char *restricted_pointer(char *buf, char *end, const void *ptr, | 1361 | char *pointer_string(char *buf, char *end, const void *ptr, |
| 1361 | struct printf_spec spec) | 1362 | struct printf_spec spec) |
| 1362 | { | 1363 | { |
| 1363 | spec.base = 16; | 1364 | spec.base = 16; |
| 1364 | spec.flags |= SMALL; | 1365 | spec.flags |= SMALL; |
| @@ -1367,6 +1368,15 @@ char *restricted_pointer(char *buf, char *end, const void *ptr, | |||
| 1367 | spec.flags |= ZEROPAD; | 1368 | spec.flags |= ZEROPAD; |
| 1368 | } | 1369 | } |
| 1369 | 1370 | ||
| 1371 | return number(buf, end, (unsigned long int)ptr, spec); | ||
| 1372 | } | ||
| 1373 | |||
| 1374 | int kptr_restrict __read_mostly; | ||
| 1375 | |||
| 1376 | static noinline_for_stack | ||
| 1377 | char *restricted_pointer(char *buf, char *end, const void *ptr, | ||
| 1378 | struct printf_spec spec) | ||
| 1379 | { | ||
| 1370 | switch (kptr_restrict) { | 1380 | switch (kptr_restrict) { |
| 1371 | case 0: | 1381 | case 0: |
| 1372 | /* Always print %pK values */ | 1382 | /* Always print %pK values */ |
| @@ -1378,8 +1388,11 @@ char *restricted_pointer(char *buf, char *end, const void *ptr, | |||
| 1378 | * kptr_restrict==1 cannot be used in IRQ context | 1388 | * kptr_restrict==1 cannot be used in IRQ context |
| 1379 | * because its test for CAP_SYSLOG would be meaningless. | 1389 | * because its test for CAP_SYSLOG would be meaningless. |
| 1380 | */ | 1390 | */ |
| 1381 | if (in_irq() || in_serving_softirq() || in_nmi()) | 1391 | if (in_irq() || in_serving_softirq() || in_nmi()) { |
| 1392 | if (spec.field_width == -1) | ||
| 1393 | spec.field_width = 2 * sizeof(ptr); | ||
| 1382 | return string(buf, end, "pK-error", spec); | 1394 | return string(buf, end, "pK-error", spec); |
| 1395 | } | ||
| 1383 | 1396 | ||
| 1384 | /* | 1397 | /* |
| 1385 | * Only print the real pointer value if the current | 1398 | * Only print the real pointer value if the current |
| @@ -1404,7 +1417,7 @@ char *restricted_pointer(char *buf, char *end, const void *ptr, | |||
| 1404 | break; | 1417 | break; |
| 1405 | } | 1418 | } |
| 1406 | 1419 | ||
| 1407 | return number(buf, end, (unsigned long)ptr, spec); | 1420 | return pointer_string(buf, end, ptr, spec); |
| 1408 | } | 1421 | } |
| 1409 | 1422 | ||
| 1410 | static noinline_for_stack | 1423 | static noinline_for_stack |
| @@ -1456,9 +1469,6 @@ char *clock(char *buf, char *end, struct clk *clk, struct printf_spec spec, | |||
| 1456 | return string(buf, end, NULL, spec); | 1469 | return string(buf, end, NULL, spec); |
| 1457 | 1470 | ||
| 1458 | switch (fmt[1]) { | 1471 | switch (fmt[1]) { |
| 1459 | case 'r': | ||
| 1460 | return number(buf, end, clk_get_rate(clk), spec); | ||
| 1461 | |||
| 1462 | case 'n': | 1472 | case 'n': |
| 1463 | default: | 1473 | default: |
| 1464 | #ifdef CONFIG_COMMON_CLK | 1474 | #ifdef CONFIG_COMMON_CLK |
| @@ -1474,23 +1484,13 @@ char *format_flags(char *buf, char *end, unsigned long flags, | |||
| 1474 | const struct trace_print_flags *names) | 1484 | const struct trace_print_flags *names) |
| 1475 | { | 1485 | { |
| 1476 | unsigned long mask; | 1486 | unsigned long mask; |
| 1477 | const struct printf_spec strspec = { | ||
| 1478 | .field_width = -1, | ||
| 1479 | .precision = -1, | ||
| 1480 | }; | ||
| 1481 | const struct printf_spec numspec = { | ||
| 1482 | .flags = SPECIAL|SMALL, | ||
| 1483 | .field_width = -1, | ||
| 1484 | .precision = -1, | ||
| 1485 | .base = 16, | ||
| 1486 | }; | ||
| 1487 | 1487 | ||
| 1488 | for ( ; flags && names->name; names++) { | 1488 | for ( ; flags && names->name; names++) { |
| 1489 | mask = names->mask; | 1489 | mask = names->mask; |
| 1490 | if ((flags & mask) != mask) | 1490 | if ((flags & mask) != mask) |
| 1491 | continue; | 1491 | continue; |
| 1492 | 1492 | ||
| 1493 | buf = string(buf, end, names->name, strspec); | 1493 | buf = string(buf, end, names->name, default_str_spec); |
| 1494 | 1494 | ||
| 1495 | flags &= ~mask; | 1495 | flags &= ~mask; |
| 1496 | if (flags) { | 1496 | if (flags) { |
| @@ -1501,7 +1501,7 @@ char *format_flags(char *buf, char *end, unsigned long flags, | |||
| 1501 | } | 1501 | } |
| 1502 | 1502 | ||
| 1503 | if (flags) | 1503 | if (flags) |
| 1504 | buf = number(buf, end, flags, numspec); | 1504 | buf = number(buf, end, flags, default_flag_spec); |
| 1505 | 1505 | ||
| 1506 | return buf; | 1506 | return buf; |
| 1507 | } | 1507 | } |
| @@ -1548,22 +1548,18 @@ char *device_node_gen_full_name(const struct device_node *np, char *buf, char *e | |||
| 1548 | { | 1548 | { |
| 1549 | int depth; | 1549 | int depth; |
| 1550 | const struct device_node *parent = np->parent; | 1550 | const struct device_node *parent = np->parent; |
| 1551 | static const struct printf_spec strspec = { | ||
| 1552 | .field_width = -1, | ||
| 1553 | .precision = -1, | ||
| 1554 | }; | ||
| 1555 | 1551 | ||
| 1556 | /* special case for root node */ | 1552 | /* special case for root node */ |
| 1557 | if (!parent) | 1553 | if (!parent) |
| 1558 | return string(buf, end, "/", strspec); | 1554 | return string(buf, end, "/", default_str_spec); |
| 1559 | 1555 | ||
| 1560 | for (depth = 0; parent->parent; depth++) | 1556 | for (depth = 0; parent->parent; depth++) |
| 1561 | parent = parent->parent; | 1557 | parent = parent->parent; |
| 1562 | 1558 | ||
| 1563 | for ( ; depth >= 0; depth--) { | 1559 | for ( ; depth >= 0; depth--) { |
| 1564 | buf = string(buf, end, "/", strspec); | 1560 | buf = string(buf, end, "/", default_str_spec); |
| 1565 | buf = string(buf, end, device_node_name_for_depth(np, depth), | 1561 | buf = string(buf, end, device_node_name_for_depth(np, depth), |
| 1566 | strspec); | 1562 | default_str_spec); |
| 1567 | } | 1563 | } |
| 1568 | return buf; | 1564 | return buf; |
| 1569 | } | 1565 | } |
| @@ -1655,20 +1651,6 @@ char *device_node_string(char *buf, char *end, struct device_node *dn, | |||
| 1655 | return widen_string(buf, buf - buf_start, end, spec); | 1651 | return widen_string(buf, buf - buf_start, end, spec); |
| 1656 | } | 1652 | } |
| 1657 | 1653 | ||
| 1658 | static noinline_for_stack | ||
| 1659 | char *pointer_string(char *buf, char *end, const void *ptr, | ||
| 1660 | struct printf_spec spec) | ||
| 1661 | { | ||
| 1662 | spec.base = 16; | ||
| 1663 | spec.flags |= SMALL; | ||
| 1664 | if (spec.field_width == -1) { | ||
| 1665 | spec.field_width = 2 * sizeof(ptr); | ||
| 1666 | spec.flags |= ZEROPAD; | ||
| 1667 | } | ||
| 1668 | |||
| 1669 | return number(buf, end, (unsigned long int)ptr, spec); | ||
| 1670 | } | ||
| 1671 | |||
| 1672 | static DEFINE_STATIC_KEY_TRUE(not_filled_random_ptr_key); | 1654 | static DEFINE_STATIC_KEY_TRUE(not_filled_random_ptr_key); |
| 1673 | static siphash_key_t ptr_key __read_mostly; | 1655 | static siphash_key_t ptr_key __read_mostly; |
| 1674 | 1656 | ||
| @@ -1710,13 +1692,13 @@ early_initcall(initialize_ptr_random); | |||
| 1710 | /* Maps a pointer to a 32 bit unique identifier. */ | 1692 | /* Maps a pointer to a 32 bit unique identifier. */ |
| 1711 | static char *ptr_to_id(char *buf, char *end, void *ptr, struct printf_spec spec) | 1693 | static char *ptr_to_id(char *buf, char *end, void *ptr, struct printf_spec spec) |
| 1712 | { | 1694 | { |
| 1695 | const char *str = sizeof(ptr) == 8 ? "(____ptrval____)" : "(ptrval)"; | ||
| 1713 | unsigned long hashval; | 1696 | unsigned long hashval; |
| 1714 | const int default_width = 2 * sizeof(ptr); | ||
| 1715 | 1697 | ||
| 1716 | if (static_branch_unlikely(¬_filled_random_ptr_key)) { | 1698 | if (static_branch_unlikely(¬_filled_random_ptr_key)) { |
| 1717 | spec.field_width = default_width; | 1699 | spec.field_width = 2 * sizeof(ptr); |
| 1718 | /* string length must be less than default_width */ | 1700 | /* string length must be less than default_width */ |
| 1719 | return string(buf, end, "(ptrval)", spec); | 1701 | return string(buf, end, str, spec); |
| 1720 | } | 1702 | } |
| 1721 | 1703 | ||
| 1722 | #ifdef CONFIG_64BIT | 1704 | #ifdef CONFIG_64BIT |
| @@ -1729,15 +1711,7 @@ static char *ptr_to_id(char *buf, char *end, void *ptr, struct printf_spec spec) | |||
| 1729 | #else | 1711 | #else |
| 1730 | hashval = (unsigned long)siphash_1u32((u32)ptr, &ptr_key); | 1712 | hashval = (unsigned long)siphash_1u32((u32)ptr, &ptr_key); |
| 1731 | #endif | 1713 | #endif |
| 1732 | 1714 | return pointer_string(buf, end, (const void *)hashval, spec); | |
| 1733 | spec.flags |= SMALL; | ||
| 1734 | if (spec.field_width == -1) { | ||
| 1735 | spec.field_width = default_width; | ||
| 1736 | spec.flags |= ZEROPAD; | ||
| 1737 | } | ||
| 1738 | spec.base = 16; | ||
| 1739 | |||
| 1740 | return number(buf, end, hashval, spec); | ||
| 1741 | } | 1715 | } |
| 1742 | 1716 | ||
| 1743 | /* | 1717 | /* |
| @@ -1750,10 +1724,10 @@ static char *ptr_to_id(char *buf, char *end, void *ptr, struct printf_spec spec) | |||
| 1750 | * | 1724 | * |
| 1751 | * Right now we handle: | 1725 | * Right now we handle: |
| 1752 | * | 1726 | * |
| 1753 | * - 'F' For symbolic function descriptor pointers with offset | 1727 | * - 'S' For symbolic direct pointers (or function descriptors) with offset |
| 1754 | * - 'f' For simple symbolic function names without offset | 1728 | * - 's' For symbolic direct pointers (or function descriptors) without offset |
| 1755 | * - 'S' For symbolic direct pointers with offset | 1729 | * - 'F' Same as 'S' |
| 1756 | * - 's' For symbolic direct pointers without offset | 1730 | * - 'f' Same as 's' |
| 1757 | * - '[FfSs]R' as above with __builtin_extract_return_addr() translation | 1731 | * - '[FfSs]R' as above with __builtin_extract_return_addr() translation |
| 1758 | * - 'B' For backtraced symbolic direct pointers with offset | 1732 | * - 'B' For backtraced symbolic direct pointers with offset |
| 1759 | * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref] | 1733 | * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref] |
| @@ -1850,10 +1824,6 @@ static char *ptr_to_id(char *buf, char *end, void *ptr, struct printf_spec spec) | |||
| 1850 | * ** When making changes please also update: | 1824 | * ** When making changes please also update: |
| 1851 | * Documentation/core-api/printk-formats.rst | 1825 | * Documentation/core-api/printk-formats.rst |
| 1852 | * | 1826 | * |
| 1853 | * Note: The difference between 'S' and 'F' is that on ia64 and ppc64 | ||
| 1854 | * function pointers are really function descriptors, which contain a | ||
| 1855 | * pointer to the real address. | ||
| 1856 | * | ||
| 1857 | * Note: The default behaviour (unadorned %p) is to hash the address, | 1827 | * Note: The default behaviour (unadorned %p) is to hash the address, |
| 1858 | * rendering it useful as a unique identifier. | 1828 | * rendering it useful as a unique identifier. |
| 1859 | */ | 1829 | */ |
| @@ -2129,6 +2099,7 @@ qualifier: | |||
| 2129 | 2099 | ||
| 2130 | case 'x': | 2100 | case 'x': |
| 2131 | spec->flags |= SMALL; | 2101 | spec->flags |= SMALL; |
| 2102 | /* fall through */ | ||
| 2132 | 2103 | ||
| 2133 | case 'X': | 2104 | case 'X': |
| 2134 | spec->base = 16; | 2105 | spec->base = 16; |
| @@ -3087,8 +3058,10 @@ int vsscanf(const char *buf, const char *fmt, va_list args) | |||
| 3087 | break; | 3058 | break; |
| 3088 | case 'i': | 3059 | case 'i': |
| 3089 | base = 0; | 3060 | base = 0; |
| 3061 | /* fall through */ | ||
| 3090 | case 'd': | 3062 | case 'd': |
| 3091 | is_sign = true; | 3063 | is_sign = true; |
| 3064 | /* fall through */ | ||
| 3092 | case 'u': | 3065 | case 'u': |
| 3093 | break; | 3066 | break; |
| 3094 | case '%': | 3067 | case '%': |
