diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/Kconfig.debug | 34 | ||||
| -rw-r--r-- | lib/Kconfig.kmemcheck | 3 | ||||
| -rw-r--r-- | lib/debugobjects.c | 1 | ||||
| -rw-r--r-- | lib/decompress_inflate.c | 8 | ||||
| -rw-r--r-- | lib/decompress_unlzma.c | 10 | ||||
| -rw-r--r-- | lib/dma-debug.c | 6 | ||||
| -rw-r--r-- | lib/fault-inject.c | 1 | ||||
| -rw-r--r-- | lib/flex_array.c | 121 | ||||
| -rw-r--r-- | lib/inflate.c | 2 | ||||
| -rw-r--r-- | lib/kernel_lock.c | 20 | ||||
| -rw-r--r-- | lib/radix-tree.c | 5 | ||||
| -rw-r--r-- | lib/ratelimit.c | 45 | ||||
| -rw-r--r-- | lib/string.c | 20 | ||||
| -rw-r--r-- | lib/swiotlb.c | 46 | ||||
| -rw-r--r-- | lib/vsprintf.c | 236 | ||||
| -rw-r--r-- | lib/zlib_deflate/deflate.c | 4 |
16 files changed, 411 insertions, 151 deletions
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 7dbd5d9c29a4..a79c4d0407ab 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug | |||
| @@ -50,6 +50,14 @@ config MAGIC_SYSRQ | |||
| 50 | keys are documented in <file:Documentation/sysrq.txt>. Don't say Y | 50 | keys are documented in <file:Documentation/sysrq.txt>. Don't say Y |
| 51 | unless you really know what this hack does. | 51 | unless you really know what this hack does. |
| 52 | 52 | ||
| 53 | config STRIP_ASM_SYMS | ||
| 54 | bool "Strip assembler-generated symbols during link" | ||
| 55 | default n | ||
| 56 | help | ||
| 57 | Strip internal assembler-generated symbols during a link (symbols | ||
| 58 | that look like '.Lxxx') so they don't pollute the output of | ||
| 59 | get_wchan() and suchlike. | ||
| 60 | |||
| 53 | config UNUSED_SYMBOLS | 61 | config UNUSED_SYMBOLS |
| 54 | bool "Enable unused/obsolete exported symbols" | 62 | bool "Enable unused/obsolete exported symbols" |
| 55 | default y if X86 | 63 | default y if X86 |
| @@ -338,8 +346,9 @@ config SLUB_STATS | |||
| 338 | 346 | ||
| 339 | config DEBUG_KMEMLEAK | 347 | config DEBUG_KMEMLEAK |
| 340 | bool "Kernel memory leak detector" | 348 | bool "Kernel memory leak detector" |
| 341 | depends on DEBUG_KERNEL && EXPERIMENTAL && (X86 || ARM) && \ | 349 | depends on DEBUG_KERNEL && EXPERIMENTAL && !MEMORY_HOTPLUG && \ |
| 342 | !MEMORY_HOTPLUG | 350 | (X86 || ARM || PPC || S390) |
| 351 | |||
| 343 | select DEBUG_FS if SYSFS | 352 | select DEBUG_FS if SYSFS |
| 344 | select STACKTRACE if STACKTRACE_SUPPORT | 353 | select STACKTRACE if STACKTRACE_SUPPORT |
| 345 | select KALLSYMS | 354 | select KALLSYMS |
| @@ -362,7 +371,7 @@ config DEBUG_KMEMLEAK | |||
| 362 | config DEBUG_KMEMLEAK_EARLY_LOG_SIZE | 371 | config DEBUG_KMEMLEAK_EARLY_LOG_SIZE |
| 363 | int "Maximum kmemleak early log entries" | 372 | int "Maximum kmemleak early log entries" |
| 364 | depends on DEBUG_KMEMLEAK | 373 | depends on DEBUG_KMEMLEAK |
| 365 | range 200 2000 | 374 | range 200 40000 |
| 366 | default 400 | 375 | default 400 |
| 367 | help | 376 | help |
| 368 | Kmemleak must track all the memory allocations to avoid | 377 | Kmemleak must track all the memory allocations to avoid |
| @@ -383,7 +392,7 @@ config DEBUG_KMEMLEAK_TEST | |||
| 383 | 392 | ||
| 384 | config DEBUG_PREEMPT | 393 | config DEBUG_PREEMPT |
| 385 | bool "Debug preemptible kernel" | 394 | bool "Debug preemptible kernel" |
| 386 | depends on DEBUG_KERNEL && PREEMPT && (TRACE_IRQFLAGS_SUPPORT || PPC64) | 395 | depends on DEBUG_KERNEL && PREEMPT && TRACE_IRQFLAGS_SUPPORT |
| 387 | default y | 396 | default y |
| 388 | help | 397 | help |
| 389 | If you say Y here then the kernel will use a debug variant of the | 398 | If you say Y here then the kernel will use a debug variant of the |
| @@ -741,7 +750,7 @@ config RCU_TORTURE_TEST_RUNNABLE | |||
| 741 | config RCU_CPU_STALL_DETECTOR | 750 | config RCU_CPU_STALL_DETECTOR |
| 742 | bool "Check for stalled CPUs delaying RCU grace periods" | 751 | bool "Check for stalled CPUs delaying RCU grace periods" |
| 743 | depends on TREE_RCU || TREE_PREEMPT_RCU | 752 | depends on TREE_RCU || TREE_PREEMPT_RCU |
| 744 | default n | 753 | default y |
| 745 | help | 754 | help |
| 746 | This option causes RCU to printk information on which | 755 | This option causes RCU to printk information on which |
| 747 | CPUs are delaying the current grace period, but only when | 756 | CPUs are delaying the current grace period, but only when |
| @@ -805,6 +814,21 @@ config DEBUG_BLOCK_EXT_DEVT | |||
| 805 | 814 | ||
| 806 | Say N if you are unsure. | 815 | Say N if you are unsure. |
| 807 | 816 | ||
| 817 | config DEBUG_FORCE_WEAK_PER_CPU | ||
| 818 | bool "Force weak per-cpu definitions" | ||
| 819 | depends on DEBUG_KERNEL | ||
| 820 | help | ||
| 821 | s390 and alpha require percpu variables in modules to be | ||
| 822 | defined weak to work around addressing range issue which | ||
| 823 | puts the following two restrictions on percpu variable | ||
| 824 | definitions. | ||
| 825 | |||
| 826 | 1. percpu symbols must be unique whether static or not | ||
| 827 | 2. percpu variables can't be defined inside a function | ||
| 828 | |||
| 829 | To ensure that generic code follows the above rules, this | ||
| 830 | option forces all percpu variables to be defined as weak. | ||
| 831 | |||
| 808 | config LKDTM | 832 | config LKDTM |
| 809 | tristate "Linux Kernel Dump Test Tool Module" | 833 | tristate "Linux Kernel Dump Test Tool Module" |
| 810 | depends on DEBUG_KERNEL | 834 | depends on DEBUG_KERNEL |
diff --git a/lib/Kconfig.kmemcheck b/lib/Kconfig.kmemcheck index 603c81b66549..846e039a86b4 100644 --- a/lib/Kconfig.kmemcheck +++ b/lib/Kconfig.kmemcheck | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | config HAVE_ARCH_KMEMCHECK | 1 | config HAVE_ARCH_KMEMCHECK |
| 2 | bool | 2 | bool |
| 3 | 3 | ||
| 4 | if HAVE_ARCH_KMEMCHECK | ||
| 5 | |||
| 4 | menuconfig KMEMCHECK | 6 | menuconfig KMEMCHECK |
| 5 | bool "kmemcheck: trap use of uninitialized memory" | 7 | bool "kmemcheck: trap use of uninitialized memory" |
| 6 | depends on DEBUG_KERNEL | 8 | depends on DEBUG_KERNEL |
| @@ -89,3 +91,4 @@ config KMEMCHECK_BITOPS_OK | |||
| 89 | accesses where not all the bits are initialized at the same time. | 91 | accesses where not all the bits are initialized at the same time. |
| 90 | This may also hide some real bugs. | 92 | This may also hide some real bugs. |
| 91 | 93 | ||
| 94 | endif | ||
diff --git a/lib/debugobjects.c b/lib/debugobjects.c index 2755a3bd16a1..eae56fddfa3b 100644 --- a/lib/debugobjects.c +++ b/lib/debugobjects.c | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | */ | 9 | */ |
| 10 | #include <linux/debugobjects.h> | 10 | #include <linux/debugobjects.h> |
| 11 | #include <linux/interrupt.h> | 11 | #include <linux/interrupt.h> |
| 12 | #include <linux/sched.h> | ||
| 12 | #include <linux/seq_file.h> | 13 | #include <linux/seq_file.h> |
| 13 | #include <linux/debugfs.h> | 14 | #include <linux/debugfs.h> |
| 14 | #include <linux/hash.h> | 15 | #include <linux/hash.h> |
diff --git a/lib/decompress_inflate.c b/lib/decompress_inflate.c index 68dfce59c1b8..fc686c7a0a0d 100644 --- a/lib/decompress_inflate.c +++ b/lib/decompress_inflate.c | |||
| @@ -27,6 +27,11 @@ | |||
| 27 | 27 | ||
| 28 | #define GZIP_IOBUF_SIZE (16*1024) | 28 | #define GZIP_IOBUF_SIZE (16*1024) |
| 29 | 29 | ||
| 30 | static int nofill(void *buffer, unsigned int len) | ||
| 31 | { | ||
| 32 | return -1; | ||
| 33 | } | ||
| 34 | |||
| 30 | /* Included from initramfs et al code */ | 35 | /* Included from initramfs et al code */ |
| 31 | STATIC int INIT gunzip(unsigned char *buf, int len, | 36 | STATIC int INIT gunzip(unsigned char *buf, int len, |
| 32 | int(*fill)(void*, unsigned int), | 37 | int(*fill)(void*, unsigned int), |
| @@ -76,6 +81,9 @@ STATIC int INIT gunzip(unsigned char *buf, int len, | |||
| 76 | goto gunzip_nomem4; | 81 | goto gunzip_nomem4; |
| 77 | } | 82 | } |
| 78 | 83 | ||
| 84 | if (!fill) | ||
| 85 | fill = nofill; | ||
| 86 | |||
| 79 | if (len == 0) | 87 | if (len == 0) |
| 80 | len = fill(zbuf, GZIP_IOBUF_SIZE); | 88 | len = fill(zbuf, GZIP_IOBUF_SIZE); |
| 81 | 89 | ||
diff --git a/lib/decompress_unlzma.c b/lib/decompress_unlzma.c index 0b954e04bd30..ca82fde81c8f 100644 --- a/lib/decompress_unlzma.c +++ b/lib/decompress_unlzma.c | |||
| @@ -82,6 +82,11 @@ struct rc { | |||
| 82 | #define RC_MODEL_TOTAL_BITS 11 | 82 | #define RC_MODEL_TOTAL_BITS 11 |
| 83 | 83 | ||
| 84 | 84 | ||
| 85 | static int nofill(void *buffer, unsigned int len) | ||
| 86 | { | ||
| 87 | return -1; | ||
| 88 | } | ||
| 89 | |||
| 85 | /* Called twice: once at startup and once in rc_normalize() */ | 90 | /* Called twice: once at startup and once in rc_normalize() */ |
| 86 | static void INIT rc_read(struct rc *rc) | 91 | static void INIT rc_read(struct rc *rc) |
| 87 | { | 92 | { |
| @@ -97,7 +102,10 @@ static inline void INIT rc_init(struct rc *rc, | |||
| 97 | int (*fill)(void*, unsigned int), | 102 | int (*fill)(void*, unsigned int), |
| 98 | char *buffer, int buffer_size) | 103 | char *buffer, int buffer_size) |
| 99 | { | 104 | { |
| 100 | rc->fill = fill; | 105 | if (fill) |
| 106 | rc->fill = fill; | ||
| 107 | else | ||
| 108 | rc->fill = nofill; | ||
| 101 | rc->buffer = (uint8_t *)buffer; | 109 | rc->buffer = (uint8_t *)buffer; |
| 102 | rc->buffer_size = buffer_size; | 110 | rc->buffer_size = buffer_size; |
| 103 | rc->buffer_end = rc->buffer + rc->buffer_size; | 111 | rc->buffer_end = rc->buffer + rc->buffer_size; |
diff --git a/lib/dma-debug.c b/lib/dma-debug.c index 58a9f9fc609a..ce6b7eabf674 100644 --- a/lib/dma-debug.c +++ b/lib/dma-debug.c | |||
| @@ -819,9 +819,11 @@ static void check_unmap(struct dma_debug_entry *ref) | |||
| 819 | err_printk(ref->dev, entry, "DMA-API: device driver frees " | 819 | err_printk(ref->dev, entry, "DMA-API: device driver frees " |
| 820 | "DMA memory with different CPU address " | 820 | "DMA memory with different CPU address " |
| 821 | "[device address=0x%016llx] [size=%llu bytes] " | 821 | "[device address=0x%016llx] [size=%llu bytes] " |
| 822 | "[cpu alloc address=%p] [cpu free address=%p]", | 822 | "[cpu alloc address=0x%016llx] " |
| 823 | "[cpu free address=0x%016llx]", | ||
| 823 | ref->dev_addr, ref->size, | 824 | ref->dev_addr, ref->size, |
| 824 | (void *)entry->paddr, (void *)ref->paddr); | 825 | (unsigned long long)entry->paddr, |
| 826 | (unsigned long long)ref->paddr); | ||
| 825 | } | 827 | } |
| 826 | 828 | ||
| 827 | if (ref->sg_call_ents && ref->type == dma_debug_sg && | 829 | if (ref->sg_call_ents && ref->type == dma_debug_sg && |
diff --git a/lib/fault-inject.c b/lib/fault-inject.c index f97af55bdd96..7e65af70635e 100644 --- a/lib/fault-inject.c +++ b/lib/fault-inject.c | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | #include <linux/kernel.h> | 1 | #include <linux/kernel.h> |
| 2 | #include <linux/init.h> | 2 | #include <linux/init.h> |
| 3 | #include <linux/random.h> | 3 | #include <linux/random.h> |
| 4 | #include <linux/sched.h> | ||
| 4 | #include <linux/stat.h> | 5 | #include <linux/stat.h> |
| 5 | #include <linux/types.h> | 6 | #include <linux/types.h> |
| 6 | #include <linux/fs.h> | 7 | #include <linux/fs.h> |
diff --git a/lib/flex_array.c b/lib/flex_array.c index 7baed2fc3bc8..66eef2e4483e 100644 --- a/lib/flex_array.c +++ b/lib/flex_array.c | |||
| @@ -28,23 +28,6 @@ struct flex_array_part { | |||
| 28 | char elements[FLEX_ARRAY_PART_SIZE]; | 28 | char elements[FLEX_ARRAY_PART_SIZE]; |
| 29 | }; | 29 | }; |
| 30 | 30 | ||
| 31 | static inline int __elements_per_part(int element_size) | ||
| 32 | { | ||
| 33 | return FLEX_ARRAY_PART_SIZE / element_size; | ||
| 34 | } | ||
| 35 | |||
| 36 | static inline int bytes_left_in_base(void) | ||
| 37 | { | ||
| 38 | int element_offset = offsetof(struct flex_array, parts); | ||
| 39 | int bytes_left = FLEX_ARRAY_BASE_SIZE - element_offset; | ||
| 40 | return bytes_left; | ||
| 41 | } | ||
| 42 | |||
| 43 | static inline int nr_base_part_ptrs(void) | ||
| 44 | { | ||
| 45 | return bytes_left_in_base() / sizeof(struct flex_array_part *); | ||
| 46 | } | ||
| 47 | |||
| 48 | /* | 31 | /* |
| 49 | * If a user requests an allocation which is small | 32 | * If a user requests an allocation which is small |
| 50 | * enough, we may simply use the space in the | 33 | * enough, we may simply use the space in the |
| @@ -54,7 +37,7 @@ static inline int nr_base_part_ptrs(void) | |||
| 54 | static inline int elements_fit_in_base(struct flex_array *fa) | 37 | static inline int elements_fit_in_base(struct flex_array *fa) |
| 55 | { | 38 | { |
| 56 | int data_size = fa->element_size * fa->total_nr_elements; | 39 | int data_size = fa->element_size * fa->total_nr_elements; |
| 57 | if (data_size <= bytes_left_in_base()) | 40 | if (data_size <= FLEX_ARRAY_BASE_BYTES_LEFT) |
| 58 | return 1; | 41 | return 1; |
| 59 | return 0; | 42 | return 0; |
| 60 | } | 43 | } |
| @@ -63,6 +46,7 @@ static inline int elements_fit_in_base(struct flex_array *fa) | |||
| 63 | * flex_array_alloc - allocate a new flexible array | 46 | * flex_array_alloc - allocate a new flexible array |
| 64 | * @element_size: the size of individual elements in the array | 47 | * @element_size: the size of individual elements in the array |
| 65 | * @total: total number of elements that this should hold | 48 | * @total: total number of elements that this should hold |
| 49 | * @flags: page allocation flags to use for base array | ||
| 66 | * | 50 | * |
| 67 | * Note: all locking must be provided by the caller. | 51 | * Note: all locking must be provided by the caller. |
| 68 | * | 52 | * |
| @@ -103,7 +87,8 @@ struct flex_array *flex_array_alloc(int element_size, unsigned int total, | |||
| 103 | gfp_t flags) | 87 | gfp_t flags) |
| 104 | { | 88 | { |
| 105 | struct flex_array *ret; | 89 | struct flex_array *ret; |
| 106 | int max_size = nr_base_part_ptrs() * __elements_per_part(element_size); | 90 | int max_size = FLEX_ARRAY_NR_BASE_PTRS * |
| 91 | FLEX_ARRAY_ELEMENTS_PER_PART(element_size); | ||
| 107 | 92 | ||
| 108 | /* max_size will end up 0 if element_size > PAGE_SIZE */ | 93 | /* max_size will end up 0 if element_size > PAGE_SIZE */ |
| 109 | if (total > max_size) | 94 | if (total > max_size) |
| @@ -113,17 +98,21 @@ struct flex_array *flex_array_alloc(int element_size, unsigned int total, | |||
| 113 | return NULL; | 98 | return NULL; |
| 114 | ret->element_size = element_size; | 99 | ret->element_size = element_size; |
| 115 | ret->total_nr_elements = total; | 100 | ret->total_nr_elements = total; |
| 101 | if (elements_fit_in_base(ret) && !(flags & __GFP_ZERO)) | ||
| 102 | memset(ret->parts[0], FLEX_ARRAY_FREE, | ||
| 103 | FLEX_ARRAY_BASE_BYTES_LEFT); | ||
| 116 | return ret; | 104 | return ret; |
| 117 | } | 105 | } |
| 118 | 106 | ||
| 119 | static int fa_element_to_part_nr(struct flex_array *fa, | 107 | static int fa_element_to_part_nr(struct flex_array *fa, |
| 120 | unsigned int element_nr) | 108 | unsigned int element_nr) |
| 121 | { | 109 | { |
| 122 | return element_nr / __elements_per_part(fa->element_size); | 110 | return element_nr / FLEX_ARRAY_ELEMENTS_PER_PART(fa->element_size); |
| 123 | } | 111 | } |
| 124 | 112 | ||
| 125 | /** | 113 | /** |
| 126 | * flex_array_free_parts - just free the second-level pages | 114 | * flex_array_free_parts - just free the second-level pages |
| 115 | * @fa: the flex array from which to free parts | ||
| 127 | * | 116 | * |
| 128 | * This is to be used in cases where the base 'struct flex_array' | 117 | * This is to be used in cases where the base 'struct flex_array' |
| 129 | * has been statically allocated and should not be free. | 118 | * has been statically allocated and should not be free. |
| @@ -131,11 +120,10 @@ static int fa_element_to_part_nr(struct flex_array *fa, | |||
| 131 | void flex_array_free_parts(struct flex_array *fa) | 120 | void flex_array_free_parts(struct flex_array *fa) |
| 132 | { | 121 | { |
| 133 | int part_nr; | 122 | int part_nr; |
| 134 | int max_part = nr_base_part_ptrs(); | ||
| 135 | 123 | ||
| 136 | if (elements_fit_in_base(fa)) | 124 | if (elements_fit_in_base(fa)) |
| 137 | return; | 125 | return; |
| 138 | for (part_nr = 0; part_nr < max_part; part_nr++) | 126 | for (part_nr = 0; part_nr < FLEX_ARRAY_NR_BASE_PTRS; part_nr++) |
| 139 | kfree(fa->parts[part_nr]); | 127 | kfree(fa->parts[part_nr]); |
| 140 | } | 128 | } |
| 141 | 129 | ||
| @@ -150,7 +138,8 @@ static unsigned int index_inside_part(struct flex_array *fa, | |||
| 150 | { | 138 | { |
| 151 | unsigned int part_offset; | 139 | unsigned int part_offset; |
| 152 | 140 | ||
| 153 | part_offset = element_nr % __elements_per_part(fa->element_size); | 141 | part_offset = element_nr % |
| 142 | FLEX_ARRAY_ELEMENTS_PER_PART(fa->element_size); | ||
| 154 | return part_offset * fa->element_size; | 143 | return part_offset * fa->element_size; |
| 155 | } | 144 | } |
| 156 | 145 | ||
| @@ -159,15 +148,12 @@ __fa_get_part(struct flex_array *fa, int part_nr, gfp_t flags) | |||
| 159 | { | 148 | { |
| 160 | struct flex_array_part *part = fa->parts[part_nr]; | 149 | struct flex_array_part *part = fa->parts[part_nr]; |
| 161 | if (!part) { | 150 | if (!part) { |
| 162 | /* | 151 | part = kmalloc(sizeof(struct flex_array_part), flags); |
| 163 | * This leaves the part pages uninitialized | ||
| 164 | * and with potentially random data, just | ||
| 165 | * as if the user had kmalloc()'d the whole. | ||
| 166 | * __GFP_ZERO can be used to zero it. | ||
| 167 | */ | ||
| 168 | part = kmalloc(FLEX_ARRAY_PART_SIZE, flags); | ||
| 169 | if (!part) | 152 | if (!part) |
| 170 | return NULL; | 153 | return NULL; |
| 154 | if (!(flags & __GFP_ZERO)) | ||
| 155 | memset(part, FLEX_ARRAY_FREE, | ||
| 156 | sizeof(struct flex_array_part)); | ||
| 171 | fa->parts[part_nr] = part; | 157 | fa->parts[part_nr] = part; |
| 172 | } | 158 | } |
| 173 | return part; | 159 | return part; |
| @@ -175,9 +161,12 @@ __fa_get_part(struct flex_array *fa, int part_nr, gfp_t flags) | |||
| 175 | 161 | ||
| 176 | /** | 162 | /** |
| 177 | * flex_array_put - copy data into the array at @element_nr | 163 | * flex_array_put - copy data into the array at @element_nr |
| 178 | * @src: address of data to copy into the array | 164 | * @fa: the flex array to copy data into |
| 179 | * @element_nr: index of the position in which to insert | 165 | * @element_nr: index of the position in which to insert |
| 180 | * the new element. | 166 | * the new element. |
| 167 | * @src: address of data to copy into the array | ||
| 168 | * @flags: page allocation flags to use for array expansion | ||
| 169 | * | ||
| 181 | * | 170 | * |
| 182 | * Note that this *copies* the contents of @src into | 171 | * Note that this *copies* the contents of @src into |
| 183 | * the array. If you are trying to store an array of | 172 | * the array. If you are trying to store an array of |
| @@ -207,9 +196,38 @@ int flex_array_put(struct flex_array *fa, unsigned int element_nr, void *src, | |||
| 207 | } | 196 | } |
| 208 | 197 | ||
| 209 | /** | 198 | /** |
| 199 | * flex_array_clear - clear element in array at @element_nr | ||
| 200 | * @fa: the flex array of the element. | ||
| 201 | * @element_nr: index of the position to clear. | ||
| 202 | * | ||
| 203 | * Locking must be provided by the caller. | ||
| 204 | */ | ||
| 205 | int flex_array_clear(struct flex_array *fa, unsigned int element_nr) | ||
| 206 | { | ||
| 207 | int part_nr = fa_element_to_part_nr(fa, element_nr); | ||
| 208 | struct flex_array_part *part; | ||
| 209 | void *dst; | ||
| 210 | |||
| 211 | if (element_nr >= fa->total_nr_elements) | ||
| 212 | return -ENOSPC; | ||
| 213 | if (elements_fit_in_base(fa)) | ||
| 214 | part = (struct flex_array_part *)&fa->parts[0]; | ||
| 215 | else { | ||
| 216 | part = fa->parts[part_nr]; | ||
| 217 | if (!part) | ||
| 218 | return -EINVAL; | ||
| 219 | } | ||
| 220 | dst = &part->elements[index_inside_part(fa, element_nr)]; | ||
| 221 | memset(dst, FLEX_ARRAY_FREE, fa->element_size); | ||
| 222 | return 0; | ||
| 223 | } | ||
| 224 | |||
| 225 | /** | ||
| 210 | * flex_array_prealloc - guarantee that array space exists | 226 | * flex_array_prealloc - guarantee that array space exists |
| 227 | * @fa: the flex array for which to preallocate parts | ||
| 211 | * @start: index of first array element for which space is allocated | 228 | * @start: index of first array element for which space is allocated |
| 212 | * @end: index of last (inclusive) element for which space is allocated | 229 | * @end: index of last (inclusive) element for which space is allocated |
| 230 | * @flags: page allocation flags | ||
| 213 | * | 231 | * |
| 214 | * This will guarantee that no future calls to flex_array_put() | 232 | * This will guarantee that no future calls to flex_array_put() |
| 215 | * will allocate memory. It can be used if you are expecting to | 233 | * will allocate memory. It can be used if you are expecting to |
| @@ -242,6 +260,7 @@ int flex_array_prealloc(struct flex_array *fa, unsigned int start, | |||
| 242 | 260 | ||
| 243 | /** | 261 | /** |
| 244 | * flex_array_get - pull data back out of the array | 262 | * flex_array_get - pull data back out of the array |
| 263 | * @fa: the flex array from which to extract data | ||
| 245 | * @element_nr: index of the element to fetch from the array | 264 | * @element_nr: index of the element to fetch from the array |
| 246 | * | 265 | * |
| 247 | * Returns a pointer to the data at index @element_nr. Note | 266 | * Returns a pointer to the data at index @element_nr. Note |
| @@ -266,3 +285,43 @@ void *flex_array_get(struct flex_array *fa, unsigned int element_nr) | |||
| 266 | } | 285 | } |
| 267 | return &part->elements[index_inside_part(fa, element_nr)]; | 286 | return &part->elements[index_inside_part(fa, element_nr)]; |
| 268 | } | 287 | } |
| 288 | |||
| 289 | static int part_is_free(struct flex_array_part *part) | ||
| 290 | { | ||
| 291 | int i; | ||
| 292 | |||
| 293 | for (i = 0; i < sizeof(struct flex_array_part); i++) | ||
| 294 | if (part->elements[i] != FLEX_ARRAY_FREE) | ||
| 295 | return 0; | ||
| 296 | return 1; | ||
| 297 | } | ||
| 298 | |||
| 299 | /** | ||
| 300 | * flex_array_shrink - free unused second-level pages | ||
| 301 | * @fa: the flex array to shrink | ||
| 302 | * | ||
| 303 | * Frees all second-level pages that consist solely of unused | ||
| 304 | * elements. Returns the number of pages freed. | ||
| 305 | * | ||
| 306 | * Locking must be provided by the caller. | ||
| 307 | */ | ||
| 308 | int flex_array_shrink(struct flex_array *fa) | ||
| 309 | { | ||
| 310 | struct flex_array_part *part; | ||
| 311 | int part_nr; | ||
| 312 | int ret = 0; | ||
| 313 | |||
| 314 | if (elements_fit_in_base(fa)) | ||
| 315 | return ret; | ||
| 316 | for (part_nr = 0; part_nr < FLEX_ARRAY_NR_BASE_PTRS; part_nr++) { | ||
| 317 | part = fa->parts[part_nr]; | ||
| 318 | if (!part) | ||
| 319 | continue; | ||
| 320 | if (part_is_free(part)) { | ||
| 321 | fa->parts[part_nr] = NULL; | ||
| 322 | kfree(part); | ||
| 323 | ret++; | ||
| 324 | } | ||
| 325 | } | ||
| 326 | return ret; | ||
| 327 | } | ||
diff --git a/lib/inflate.c b/lib/inflate.c index 1a8e8a978128..d10255973a9f 100644 --- a/lib/inflate.c +++ b/lib/inflate.c | |||
| @@ -7,7 +7,7 @@ | |||
| 7 | * Adapted for booting Linux by Hannu Savolainen 1993 | 7 | * Adapted for booting Linux by Hannu Savolainen 1993 |
| 8 | * based on gzip-1.0.3 | 8 | * based on gzip-1.0.3 |
| 9 | * | 9 | * |
| 10 | * Nicolas Pitre <nico@cam.org>, 1999/04/14 : | 10 | * Nicolas Pitre <nico@fluxnic.net>, 1999/04/14 : |
| 11 | * Little mods for all variable to reside either into rodata or bss segments | 11 | * Little mods for all variable to reside either into rodata or bss segments |
| 12 | * by marking constant variables with 'const' and initializing all the others | 12 | * by marking constant variables with 'const' and initializing all the others |
| 13 | * at run-time only. This allows for the kernel uncompressor to run | 13 | * at run-time only. This allows for the kernel uncompressor to run |
diff --git a/lib/kernel_lock.c b/lib/kernel_lock.c index 39f1029e3525..4ebfa5a164d7 100644 --- a/lib/kernel_lock.c +++ b/lib/kernel_lock.c | |||
| @@ -5,10 +5,13 @@ | |||
| 5 | * relegated to obsolescence, but used by various less | 5 | * relegated to obsolescence, but used by various less |
| 6 | * important (or lazy) subsystems. | 6 | * important (or lazy) subsystems. |
| 7 | */ | 7 | */ |
| 8 | #include <linux/smp_lock.h> | ||
| 9 | #include <linux/module.h> | 8 | #include <linux/module.h> |
| 10 | #include <linux/kallsyms.h> | 9 | #include <linux/kallsyms.h> |
| 11 | #include <linux/semaphore.h> | 10 | #include <linux/semaphore.h> |
| 11 | #include <linux/smp_lock.h> | ||
| 12 | |||
| 13 | #define CREATE_TRACE_POINTS | ||
| 14 | #include <trace/events/bkl.h> | ||
| 12 | 15 | ||
| 13 | /* | 16 | /* |
| 14 | * The 'big kernel lock' | 17 | * The 'big kernel lock' |
| @@ -113,21 +116,26 @@ static inline void __unlock_kernel(void) | |||
| 113 | * This cannot happen asynchronously, so we only need to | 116 | * This cannot happen asynchronously, so we only need to |
| 114 | * worry about other CPU's. | 117 | * worry about other CPU's. |
| 115 | */ | 118 | */ |
| 116 | void __lockfunc lock_kernel(void) | 119 | void __lockfunc _lock_kernel(const char *func, const char *file, int line) |
| 117 | { | 120 | { |
| 118 | int depth = current->lock_depth+1; | 121 | int depth = current->lock_depth + 1; |
| 122 | |||
| 123 | trace_lock_kernel(func, file, line); | ||
| 124 | |||
| 119 | if (likely(!depth)) | 125 | if (likely(!depth)) |
| 120 | __lock_kernel(); | 126 | __lock_kernel(); |
| 121 | current->lock_depth = depth; | 127 | current->lock_depth = depth; |
| 122 | } | 128 | } |
| 123 | 129 | ||
| 124 | void __lockfunc unlock_kernel(void) | 130 | void __lockfunc _unlock_kernel(const char *func, const char *file, int line) |
| 125 | { | 131 | { |
| 126 | BUG_ON(current->lock_depth < 0); | 132 | BUG_ON(current->lock_depth < 0); |
| 127 | if (likely(--current->lock_depth < 0)) | 133 | if (likely(--current->lock_depth < 0)) |
| 128 | __unlock_kernel(); | 134 | __unlock_kernel(); |
| 135 | |||
| 136 | trace_unlock_kernel(func, file, line); | ||
| 129 | } | 137 | } |
| 130 | 138 | ||
| 131 | EXPORT_SYMBOL(lock_kernel); | 139 | EXPORT_SYMBOL(_lock_kernel); |
| 132 | EXPORT_SYMBOL(unlock_kernel); | 140 | EXPORT_SYMBOL(_unlock_kernel); |
| 133 | 141 | ||
diff --git a/lib/radix-tree.c b/lib/radix-tree.c index 23abbd93cae1..92cdd9936e3d 100644 --- a/lib/radix-tree.c +++ b/lib/radix-tree.c | |||
| @@ -200,6 +200,9 @@ radix_tree_node_free(struct radix_tree_node *node) | |||
| 200 | * ensure that the addition of a single element in the tree cannot fail. On | 200 | * ensure that the addition of a single element in the tree cannot fail. On |
| 201 | * success, return zero, with preemption disabled. On error, return -ENOMEM | 201 | * success, return zero, with preemption disabled. On error, return -ENOMEM |
| 202 | * with preemption not disabled. | 202 | * with preemption not disabled. |
| 203 | * | ||
| 204 | * To make use of this facility, the radix tree must be initialised without | ||
| 205 | * __GFP_WAIT being passed to INIT_RADIX_TREE(). | ||
| 203 | */ | 206 | */ |
| 204 | int radix_tree_preload(gfp_t gfp_mask) | 207 | int radix_tree_preload(gfp_t gfp_mask) |
| 205 | { | 208 | { |
| @@ -543,7 +546,6 @@ out: | |||
| 543 | } | 546 | } |
| 544 | EXPORT_SYMBOL(radix_tree_tag_clear); | 547 | EXPORT_SYMBOL(radix_tree_tag_clear); |
| 545 | 548 | ||
| 546 | #ifndef __KERNEL__ /* Only the test harness uses this at present */ | ||
| 547 | /** | 549 | /** |
| 548 | * radix_tree_tag_get - get a tag on a radix tree node | 550 | * radix_tree_tag_get - get a tag on a radix tree node |
| 549 | * @root: radix tree root | 551 | * @root: radix tree root |
| @@ -606,7 +608,6 @@ int radix_tree_tag_get(struct radix_tree_root *root, | |||
| 606 | } | 608 | } |
| 607 | } | 609 | } |
| 608 | EXPORT_SYMBOL(radix_tree_tag_get); | 610 | EXPORT_SYMBOL(radix_tree_tag_get); |
| 609 | #endif | ||
| 610 | 611 | ||
| 611 | /** | 612 | /** |
| 612 | * radix_tree_next_hole - find the next hole (not-present entry) | 613 | * radix_tree_next_hole - find the next hole (not-present entry) |
diff --git a/lib/ratelimit.c b/lib/ratelimit.c index 26187edcc7ea..09f5ce1810dc 100644 --- a/lib/ratelimit.c +++ b/lib/ratelimit.c | |||
| @@ -7,15 +7,12 @@ | |||
| 7 | * parameter. Now every user can use their own standalone ratelimit_state. | 7 | * parameter. Now every user can use their own standalone ratelimit_state. |
| 8 | * | 8 | * |
| 9 | * This file is released under the GPLv2. | 9 | * This file is released under the GPLv2. |
| 10 | * | ||
| 11 | */ | 10 | */ |
| 12 | 11 | ||
| 13 | #include <linux/kernel.h> | 12 | #include <linux/ratelimit.h> |
| 14 | #include <linux/jiffies.h> | 13 | #include <linux/jiffies.h> |
| 15 | #include <linux/module.h> | 14 | #include <linux/module.h> |
| 16 | 15 | ||
| 17 | static DEFINE_SPINLOCK(ratelimit_lock); | ||
| 18 | |||
| 19 | /* | 16 | /* |
| 20 | * __ratelimit - rate limiting | 17 | * __ratelimit - rate limiting |
| 21 | * @rs: ratelimit_state data | 18 | * @rs: ratelimit_state data |
| @@ -23,35 +20,43 @@ static DEFINE_SPINLOCK(ratelimit_lock); | |||
| 23 | * This enforces a rate limit: not more than @rs->ratelimit_burst callbacks | 20 | * This enforces a rate limit: not more than @rs->ratelimit_burst callbacks |
| 24 | * in every @rs->ratelimit_jiffies | 21 | * in every @rs->ratelimit_jiffies |
| 25 | */ | 22 | */ |
| 26 | int __ratelimit(struct ratelimit_state *rs) | 23 | int ___ratelimit(struct ratelimit_state *rs, const char *func) |
| 27 | { | 24 | { |
| 28 | unsigned long flags; | 25 | unsigned long flags; |
| 26 | int ret; | ||
| 29 | 27 | ||
| 30 | if (!rs->interval) | 28 | if (!rs->interval) |
| 31 | return 1; | 29 | return 1; |
| 32 | 30 | ||
| 33 | spin_lock_irqsave(&ratelimit_lock, flags); | 31 | /* |
| 32 | * If we contend on this state's lock then almost | ||
| 33 | * by definition we are too busy to print a message, | ||
| 34 | * in addition to the one that will be printed by | ||
| 35 | * the entity that is holding the lock already: | ||
| 36 | */ | ||
| 37 | if (!spin_trylock_irqsave(&rs->lock, flags)) | ||
| 38 | return 1; | ||
| 39 | |||
| 34 | if (!rs->begin) | 40 | if (!rs->begin) |
| 35 | rs->begin = jiffies; | 41 | rs->begin = jiffies; |
| 36 | 42 | ||
| 37 | if (time_is_before_jiffies(rs->begin + rs->interval)) { | 43 | if (time_is_before_jiffies(rs->begin + rs->interval)) { |
| 38 | if (rs->missed) | 44 | if (rs->missed) |
| 39 | printk(KERN_WARNING "%s: %d callbacks suppressed\n", | 45 | printk(KERN_WARNING "%s: %d callbacks suppressed\n", |
| 40 | __func__, rs->missed); | 46 | func, rs->missed); |
| 41 | rs->begin = 0; | 47 | rs->begin = 0; |
| 42 | rs->printed = 0; | 48 | rs->printed = 0; |
| 43 | rs->missed = 0; | 49 | rs->missed = 0; |
| 44 | } | 50 | } |
| 45 | if (rs->burst && rs->burst > rs->printed) | 51 | if (rs->burst && rs->burst > rs->printed) { |
| 46 | goto print; | 52 | rs->printed++; |
| 47 | 53 | ret = 1; | |
| 48 | rs->missed++; | 54 | } else { |
| 49 | spin_unlock_irqrestore(&ratelimit_lock, flags); | 55 | rs->missed++; |
| 50 | return 0; | 56 | ret = 0; |
| 57 | } | ||
| 58 | spin_unlock_irqrestore(&rs->lock, flags); | ||
| 51 | 59 | ||
| 52 | print: | 60 | return ret; |
| 53 | rs->printed++; | ||
| 54 | spin_unlock_irqrestore(&ratelimit_lock, flags); | ||
| 55 | return 1; | ||
| 56 | } | 61 | } |
| 57 | EXPORT_SYMBOL(__ratelimit); | 62 | EXPORT_SYMBOL(___ratelimit); |
diff --git a/lib/string.c b/lib/string.c index b19b87af65a3..e96421ab9a9a 100644 --- a/lib/string.c +++ b/lib/string.c | |||
| @@ -246,13 +246,17 @@ EXPORT_SYMBOL(strlcat); | |||
| 246 | #undef strcmp | 246 | #undef strcmp |
| 247 | int strcmp(const char *cs, const char *ct) | 247 | int strcmp(const char *cs, const char *ct) |
| 248 | { | 248 | { |
| 249 | signed char __res; | 249 | unsigned char c1, c2; |
| 250 | 250 | ||
| 251 | while (1) { | 251 | while (1) { |
| 252 | if ((__res = *cs - *ct++) != 0 || !*cs++) | 252 | c1 = *cs++; |
| 253 | c2 = *ct++; | ||
| 254 | if (c1 != c2) | ||
| 255 | return c1 < c2 ? -1 : 1; | ||
| 256 | if (!c1) | ||
| 253 | break; | 257 | break; |
| 254 | } | 258 | } |
| 255 | return __res; | 259 | return 0; |
| 256 | } | 260 | } |
| 257 | EXPORT_SYMBOL(strcmp); | 261 | EXPORT_SYMBOL(strcmp); |
| 258 | #endif | 262 | #endif |
| @@ -266,14 +270,18 @@ EXPORT_SYMBOL(strcmp); | |||
| 266 | */ | 270 | */ |
| 267 | int strncmp(const char *cs, const char *ct, size_t count) | 271 | int strncmp(const char *cs, const char *ct, size_t count) |
| 268 | { | 272 | { |
| 269 | signed char __res = 0; | 273 | unsigned char c1, c2; |
| 270 | 274 | ||
| 271 | while (count) { | 275 | while (count) { |
| 272 | if ((__res = *cs - *ct++) != 0 || !*cs++) | 276 | c1 = *cs++; |
| 277 | c2 = *ct++; | ||
| 278 | if (c1 != c2) | ||
| 279 | return c1 < c2 ? -1 : 1; | ||
| 280 | if (!c1) | ||
| 273 | break; | 281 | break; |
| 274 | count--; | 282 | count--; |
| 275 | } | 283 | } |
| 276 | return __res; | 284 | return 0; |
| 277 | } | 285 | } |
| 278 | EXPORT_SYMBOL(strncmp); | 286 | EXPORT_SYMBOL(strncmp); |
| 279 | #endif | 287 | #endif |
diff --git a/lib/swiotlb.c b/lib/swiotlb.c index ac25cd28e807..795472d8ae24 100644 --- a/lib/swiotlb.c +++ b/lib/swiotlb.c | |||
| @@ -97,6 +97,8 @@ static phys_addr_t *io_tlb_orig_addr; | |||
| 97 | */ | 97 | */ |
| 98 | static DEFINE_SPINLOCK(io_tlb_lock); | 98 | static DEFINE_SPINLOCK(io_tlb_lock); |
| 99 | 99 | ||
| 100 | static int late_alloc; | ||
| 101 | |||
| 100 | static int __init | 102 | static int __init |
| 101 | setup_io_tlb_npages(char *str) | 103 | setup_io_tlb_npages(char *str) |
| 102 | { | 104 | { |
| @@ -109,6 +111,7 @@ setup_io_tlb_npages(char *str) | |||
| 109 | ++str; | 111 | ++str; |
| 110 | if (!strcmp(str, "force")) | 112 | if (!strcmp(str, "force")) |
| 111 | swiotlb_force = 1; | 113 | swiotlb_force = 1; |
| 114 | |||
| 112 | return 1; | 115 | return 1; |
| 113 | } | 116 | } |
| 114 | __setup("swiotlb=", setup_io_tlb_npages); | 117 | __setup("swiotlb=", setup_io_tlb_npages); |
| @@ -121,8 +124,9 @@ static dma_addr_t swiotlb_virt_to_bus(struct device *hwdev, | |||
| 121 | return phys_to_dma(hwdev, virt_to_phys(address)); | 124 | return phys_to_dma(hwdev, virt_to_phys(address)); |
| 122 | } | 125 | } |
| 123 | 126 | ||
| 124 | static void swiotlb_print_info(unsigned long bytes) | 127 | void swiotlb_print_info(void) |
| 125 | { | 128 | { |
| 129 | unsigned long bytes = io_tlb_nslabs << IO_TLB_SHIFT; | ||
| 126 | phys_addr_t pstart, pend; | 130 | phys_addr_t pstart, pend; |
| 127 | 131 | ||
| 128 | pstart = virt_to_phys(io_tlb_start); | 132 | pstart = virt_to_phys(io_tlb_start); |
| @@ -140,7 +144,7 @@ static void swiotlb_print_info(unsigned long bytes) | |||
| 140 | * structures for the software IO TLB used to implement the DMA API. | 144 | * structures for the software IO TLB used to implement the DMA API. |
| 141 | */ | 145 | */ |
| 142 | void __init | 146 | void __init |
| 143 | swiotlb_init_with_default_size(size_t default_size) | 147 | swiotlb_init_with_default_size(size_t default_size, int verbose) |
| 144 | { | 148 | { |
| 145 | unsigned long i, bytes; | 149 | unsigned long i, bytes; |
| 146 | 150 | ||
| @@ -176,14 +180,14 @@ swiotlb_init_with_default_size(size_t default_size) | |||
| 176 | io_tlb_overflow_buffer = alloc_bootmem_low(io_tlb_overflow); | 180 | io_tlb_overflow_buffer = alloc_bootmem_low(io_tlb_overflow); |
| 177 | if (!io_tlb_overflow_buffer) | 181 | if (!io_tlb_overflow_buffer) |
| 178 | panic("Cannot allocate SWIOTLB overflow buffer!\n"); | 182 | panic("Cannot allocate SWIOTLB overflow buffer!\n"); |
| 179 | 183 | if (verbose) | |
| 180 | swiotlb_print_info(bytes); | 184 | swiotlb_print_info(); |
| 181 | } | 185 | } |
| 182 | 186 | ||
| 183 | void __init | 187 | void __init |
| 184 | swiotlb_init(void) | 188 | swiotlb_init(int verbose) |
| 185 | { | 189 | { |
| 186 | swiotlb_init_with_default_size(64 * (1<<20)); /* default to 64MB */ | 190 | swiotlb_init_with_default_size(64 * (1<<20), verbose); /* default to 64MB */ |
| 187 | } | 191 | } |
| 188 | 192 | ||
| 189 | /* | 193 | /* |
| @@ -260,7 +264,9 @@ swiotlb_late_init_with_default_size(size_t default_size) | |||
| 260 | if (!io_tlb_overflow_buffer) | 264 | if (!io_tlb_overflow_buffer) |
| 261 | goto cleanup4; | 265 | goto cleanup4; |
| 262 | 266 | ||
| 263 | swiotlb_print_info(bytes); | 267 | swiotlb_print_info(); |
| 268 | |||
| 269 | late_alloc = 1; | ||
| 264 | 270 | ||
| 265 | return 0; | 271 | return 0; |
| 266 | 272 | ||
| @@ -281,6 +287,32 @@ cleanup1: | |||
| 281 | return -ENOMEM; | 287 | return -ENOMEM; |
| 282 | } | 288 | } |
| 283 | 289 | ||
| 290 | void __init swiotlb_free(void) | ||
| 291 | { | ||
| 292 | if (!io_tlb_overflow_buffer) | ||
| 293 | return; | ||
| 294 | |||
| 295 | if (late_alloc) { | ||
| 296 | free_pages((unsigned long)io_tlb_overflow_buffer, | ||
| 297 | get_order(io_tlb_overflow)); | ||
| 298 | free_pages((unsigned long)io_tlb_orig_addr, | ||
| 299 | get_order(io_tlb_nslabs * sizeof(phys_addr_t))); | ||
| 300 | free_pages((unsigned long)io_tlb_list, get_order(io_tlb_nslabs * | ||
| 301 | sizeof(int))); | ||
| 302 | free_pages((unsigned long)io_tlb_start, | ||
| 303 | get_order(io_tlb_nslabs << IO_TLB_SHIFT)); | ||
| 304 | } else { | ||
| 305 | free_bootmem_late(__pa(io_tlb_overflow_buffer), | ||
| 306 | io_tlb_overflow); | ||
| 307 | free_bootmem_late(__pa(io_tlb_orig_addr), | ||
| 308 | io_tlb_nslabs * sizeof(phys_addr_t)); | ||
| 309 | free_bootmem_late(__pa(io_tlb_list), | ||
| 310 | io_tlb_nslabs * sizeof(int)); | ||
| 311 | free_bootmem_late(__pa(io_tlb_start), | ||
| 312 | io_tlb_nslabs << IO_TLB_SHIFT); | ||
| 313 | } | ||
| 314 | } | ||
| 315 | |||
| 284 | static int is_swiotlb_buffer(phys_addr_t paddr) | 316 | static int is_swiotlb_buffer(phys_addr_t paddr) |
| 285 | { | 317 | { |
| 286 | return paddr >= virt_to_phys(io_tlb_start) && | 318 | return paddr >= virt_to_phys(io_tlb_start) && |
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 756ccafa9cec..33bed5e67a21 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c | |||
| @@ -25,6 +25,7 @@ | |||
| 25 | #include <linux/kallsyms.h> | 25 | #include <linux/kallsyms.h> |
| 26 | #include <linux/uaccess.h> | 26 | #include <linux/uaccess.h> |
| 27 | #include <linux/ioport.h> | 27 | #include <linux/ioport.h> |
| 28 | #include <net/addrconf.h> | ||
| 28 | 29 | ||
| 29 | #include <asm/page.h> /* for PAGE_SIZE */ | 30 | #include <asm/page.h> /* for PAGE_SIZE */ |
| 30 | #include <asm/div64.h> | 31 | #include <asm/div64.h> |
| @@ -580,7 +581,7 @@ static char *symbol_string(char *buf, char *end, void *ptr, | |||
| 580 | unsigned long value = (unsigned long) ptr; | 581 | unsigned long value = (unsigned long) ptr; |
| 581 | #ifdef CONFIG_KALLSYMS | 582 | #ifdef CONFIG_KALLSYMS |
| 582 | char sym[KSYM_SYMBOL_LEN]; | 583 | char sym[KSYM_SYMBOL_LEN]; |
| 583 | if (ext != 'f') | 584 | if (ext != 'f' && ext != 's') |
| 584 | sprint_symbol(sym, value); | 585 | sprint_symbol(sym, value); |
| 585 | else | 586 | else |
| 586 | kallsyms_lookup(value, NULL, NULL, NULL, sym); | 587 | kallsyms_lookup(value, NULL, NULL, NULL, sym); |
| @@ -630,60 +631,161 @@ static char *resource_string(char *buf, char *end, struct resource *res, | |||
| 630 | } | 631 | } |
| 631 | 632 | ||
| 632 | static char *mac_address_string(char *buf, char *end, u8 *addr, | 633 | static char *mac_address_string(char *buf, char *end, u8 *addr, |
| 633 | struct printf_spec spec) | 634 | struct printf_spec spec, const char *fmt) |
| 634 | { | 635 | { |
| 635 | char mac_addr[6 * 3]; /* (6 * 2 hex digits), 5 colons and trailing zero */ | 636 | char mac_addr[sizeof("xx:xx:xx:xx:xx:xx")]; |
| 636 | char *p = mac_addr; | 637 | char *p = mac_addr; |
| 637 | int i; | 638 | int i; |
| 638 | 639 | ||
| 639 | for (i = 0; i < 6; i++) { | 640 | for (i = 0; i < 6; i++) { |
| 640 | p = pack_hex_byte(p, addr[i]); | 641 | p = pack_hex_byte(p, addr[i]); |
| 641 | if (!(spec.flags & SPECIAL) && i != 5) | 642 | if (fmt[0] == 'M' && i != 5) |
| 642 | *p++ = ':'; | 643 | *p++ = ':'; |
| 643 | } | 644 | } |
| 644 | *p = '\0'; | 645 | *p = '\0'; |
| 645 | spec.flags &= ~SPECIAL; | ||
| 646 | 646 | ||
| 647 | return string(buf, end, mac_addr, spec); | 647 | return string(buf, end, mac_addr, spec); |
| 648 | } | 648 | } |
| 649 | 649 | ||
| 650 | static char *ip6_addr_string(char *buf, char *end, u8 *addr, | 650 | static char *ip4_string(char *p, const u8 *addr, bool leading_zeros) |
| 651 | struct printf_spec spec) | ||
| 652 | { | 651 | { |
| 653 | char ip6_addr[8 * 5]; /* (8 * 4 hex digits), 7 colons and trailing zero */ | ||
| 654 | char *p = ip6_addr; | ||
| 655 | int i; | 652 | int i; |
| 656 | 653 | ||
| 654 | for (i = 0; i < 4; i++) { | ||
| 655 | char temp[3]; /* hold each IP quad in reverse order */ | ||
| 656 | int digits = put_dec_trunc(temp, addr[i]) - temp; | ||
| 657 | if (leading_zeros) { | ||
| 658 | if (digits < 3) | ||
| 659 | *p++ = '0'; | ||
| 660 | if (digits < 2) | ||
| 661 | *p++ = '0'; | ||
| 662 | } | ||
| 663 | /* reverse the digits in the quad */ | ||
| 664 | while (digits--) | ||
| 665 | *p++ = temp[digits]; | ||
| 666 | if (i < 3) | ||
| 667 | *p++ = '.'; | ||
| 668 | } | ||
| 669 | |||
| 670 | *p = '\0'; | ||
| 671 | return p; | ||
| 672 | } | ||
| 673 | |||
| 674 | static char *ip6_compressed_string(char *p, const char *addr) | ||
| 675 | { | ||
| 676 | int i; | ||
| 677 | int j; | ||
| 678 | int range; | ||
| 679 | unsigned char zerolength[8]; | ||
| 680 | int longest = 1; | ||
| 681 | int colonpos = -1; | ||
| 682 | u16 word; | ||
| 683 | u8 hi; | ||
| 684 | u8 lo; | ||
| 685 | bool needcolon = false; | ||
| 686 | bool useIPv4; | ||
| 687 | struct in6_addr in6; | ||
| 688 | |||
| 689 | memcpy(&in6, addr, sizeof(struct in6_addr)); | ||
| 690 | |||
| 691 | useIPv4 = ipv6_addr_v4mapped(&in6) || ipv6_addr_is_isatap(&in6); | ||
| 692 | |||
| 693 | memset(zerolength, 0, sizeof(zerolength)); | ||
| 694 | |||
| 695 | if (useIPv4) | ||
| 696 | range = 6; | ||
| 697 | else | ||
| 698 | range = 8; | ||
| 699 | |||
| 700 | /* find position of longest 0 run */ | ||
| 701 | for (i = 0; i < range; i++) { | ||
| 702 | for (j = i; j < range; j++) { | ||
| 703 | if (in6.s6_addr16[j] != 0) | ||
| 704 | break; | ||
| 705 | zerolength[i]++; | ||
| 706 | } | ||
| 707 | } | ||
| 708 | for (i = 0; i < range; i++) { | ||
| 709 | if (zerolength[i] > longest) { | ||
| 710 | longest = zerolength[i]; | ||
| 711 | colonpos = i; | ||
| 712 | } | ||
| 713 | } | ||
| 714 | |||
| 715 | /* emit address */ | ||
| 716 | for (i = 0; i < range; i++) { | ||
| 717 | if (i == colonpos) { | ||
| 718 | if (needcolon || i == 0) | ||
| 719 | *p++ = ':'; | ||
| 720 | *p++ = ':'; | ||
| 721 | needcolon = false; | ||
| 722 | i += longest - 1; | ||
| 723 | continue; | ||
| 724 | } | ||
| 725 | if (needcolon) { | ||
| 726 | *p++ = ':'; | ||
| 727 | needcolon = false; | ||
| 728 | } | ||
| 729 | /* hex u16 without leading 0s */ | ||
| 730 | word = ntohs(in6.s6_addr16[i]); | ||
| 731 | hi = word >> 8; | ||
| 732 | lo = word & 0xff; | ||
| 733 | if (hi) { | ||
| 734 | if (hi > 0x0f) | ||
| 735 | p = pack_hex_byte(p, hi); | ||
| 736 | else | ||
| 737 | *p++ = hex_asc_lo(hi); | ||
| 738 | } | ||
| 739 | if (hi || lo > 0x0f) | ||
| 740 | p = pack_hex_byte(p, lo); | ||
| 741 | else | ||
| 742 | *p++ = hex_asc_lo(lo); | ||
| 743 | needcolon = true; | ||
| 744 | } | ||
| 745 | |||
| 746 | if (useIPv4) { | ||
| 747 | if (needcolon) | ||
| 748 | *p++ = ':'; | ||
| 749 | p = ip4_string(p, &in6.s6_addr[12], false); | ||
| 750 | } | ||
| 751 | |||
| 752 | *p = '\0'; | ||
| 753 | return p; | ||
| 754 | } | ||
| 755 | |||
| 756 | static char *ip6_string(char *p, const char *addr, const char *fmt) | ||
| 757 | { | ||
| 758 | int i; | ||
| 657 | for (i = 0; i < 8; i++) { | 759 | for (i = 0; i < 8; i++) { |
| 658 | p = pack_hex_byte(p, addr[2 * i]); | 760 | p = pack_hex_byte(p, *addr++); |
| 659 | p = pack_hex_byte(p, addr[2 * i + 1]); | 761 | p = pack_hex_byte(p, *addr++); |
| 660 | if (!(spec.flags & SPECIAL) && i != 7) | 762 | if (fmt[0] == 'I' && i != 7) |
| 661 | *p++ = ':'; | 763 | *p++ = ':'; |
| 662 | } | 764 | } |
| 765 | |||
| 663 | *p = '\0'; | 766 | *p = '\0'; |
| 664 | spec.flags &= ~SPECIAL; | 767 | return p; |
| 768 | } | ||
| 769 | |||
| 770 | static char *ip6_addr_string(char *buf, char *end, const u8 *addr, | ||
| 771 | struct printf_spec spec, const char *fmt) | ||
| 772 | { | ||
| 773 | char ip6_addr[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255")]; | ||
| 774 | |||
| 775 | if (fmt[0] == 'I' && fmt[2] == 'c') | ||
| 776 | ip6_compressed_string(ip6_addr, addr); | ||
| 777 | else | ||
| 778 | ip6_string(ip6_addr, addr, fmt); | ||
| 665 | 779 | ||
| 666 | return string(buf, end, ip6_addr, spec); | 780 | return string(buf, end, ip6_addr, spec); |
| 667 | } | 781 | } |
| 668 | 782 | ||
| 669 | static char *ip4_addr_string(char *buf, char *end, u8 *addr, | 783 | static char *ip4_addr_string(char *buf, char *end, const u8 *addr, |
| 670 | struct printf_spec spec) | 784 | struct printf_spec spec, const char *fmt) |
| 671 | { | 785 | { |
| 672 | char ip4_addr[4 * 4]; /* (4 * 3 decimal digits), 3 dots and trailing zero */ | 786 | char ip4_addr[sizeof("255.255.255.255")]; |
| 673 | char temp[3]; /* hold each IP quad in reverse order */ | ||
| 674 | char *p = ip4_addr; | ||
| 675 | int i, digits; | ||
| 676 | 787 | ||
| 677 | for (i = 0; i < 4; i++) { | 788 | ip4_string(ip4_addr, addr, fmt[0] == 'i'); |
| 678 | digits = put_dec_trunc(temp, addr[i]) - temp; | ||
| 679 | /* reverse the digits in the quad */ | ||
| 680 | while (digits--) | ||
| 681 | *p++ = temp[digits]; | ||
| 682 | if (i != 3) | ||
| 683 | *p++ = '.'; | ||
| 684 | } | ||
| 685 | *p = '\0'; | ||
| 686 | spec.flags &= ~SPECIAL; | ||
| 687 | 789 | ||
| 688 | return string(buf, end, ip4_addr, spec); | 790 | return string(buf, end, ip4_addr, spec); |
| 689 | } | 791 | } |
| @@ -697,16 +799,21 @@ static char *ip4_addr_string(char *buf, char *end, u8 *addr, | |||
| 697 | * | 799 | * |
| 698 | * - 'F' For symbolic function descriptor pointers with offset | 800 | * - 'F' For symbolic function descriptor pointers with offset |
| 699 | * - 'f' For simple symbolic function names without offset | 801 | * - 'f' For simple symbolic function names without offset |
| 700 | * - 'S' For symbolic direct pointers | 802 | * - 'S' For symbolic direct pointers with offset |
| 803 | * - 's' For symbolic direct pointers without offset | ||
| 701 | * - 'R' For a struct resource pointer, it prints the range of | 804 | * - 'R' For a struct resource pointer, it prints the range of |
| 702 | * addresses (not the name nor the flags) | 805 | * addresses (not the name nor the flags) |
| 703 | * - 'M' For a 6-byte MAC address, it prints the address in the | 806 | * - 'M' For a 6-byte MAC address, it prints the address in the |
| 704 | * usual colon-separated hex notation | 807 | * usual colon-separated hex notation |
| 705 | * - 'I' [46] for IPv4/IPv6 addresses printed in the usual way (dot-separated | 808 | * - 'm' For a 6-byte MAC address, it prints the hex address without colons |
| 706 | * decimal for v4 and colon separated network-order 16 bit hex for v6) | 809 | * - 'I' [46] for IPv4/IPv6 addresses printed in the usual way |
| 707 | * - 'i' [46] for 'raw' IPv4/IPv6 addresses, IPv6 omits the colons, IPv4 is | 810 | * IPv4 uses dot-separated decimal without leading 0's (1.2.3.4) |
| 708 | * currently the same | 811 | * IPv6 uses colon separated network-order 16 bit hex with leading 0's |
| 709 | * | 812 | * - 'i' [46] for 'raw' IPv4/IPv6 addresses |
| 813 | * IPv6 omits the colons (01020304...0f) | ||
| 814 | * IPv4 uses dot-separated decimal with leading 0's (010.123.045.006) | ||
| 815 | * - 'I6c' for IPv6 addresses printed as specified by | ||
| 816 | * http://www.ietf.org/id/draft-kawamura-ipv6-text-representation-03.txt | ||
| 710 | * Note: The difference between 'S' and 'F' is that on ia64 and ppc64 | 817 | * Note: The difference between 'S' and 'F' is that on ia64 and ppc64 |
| 711 | * function pointers are really function descriptors, which contain a | 818 | * function pointers are really function descriptors, which contain a |
| 712 | * pointer to the real address. | 819 | * pointer to the real address. |
| @@ -721,25 +828,30 @@ static char *pointer(const char *fmt, char *buf, char *end, void *ptr, | |||
| 721 | case 'F': | 828 | case 'F': |
| 722 | case 'f': | 829 | case 'f': |
| 723 | ptr = dereference_function_descriptor(ptr); | 830 | ptr = dereference_function_descriptor(ptr); |
| 831 | case 's': | ||
| 724 | /* Fallthrough */ | 832 | /* Fallthrough */ |
| 725 | case 'S': | 833 | case 'S': |
| 726 | return symbol_string(buf, end, ptr, spec, *fmt); | 834 | return symbol_string(buf, end, ptr, spec, *fmt); |
| 727 | case 'R': | 835 | case 'R': |
| 728 | return resource_string(buf, end, ptr, spec); | 836 | return resource_string(buf, end, ptr, spec); |
| 729 | case 'm': | 837 | case 'M': /* Colon separated: 00:01:02:03:04:05 */ |
| 730 | spec.flags |= SPECIAL; | 838 | case 'm': /* Contiguous: 000102030405 */ |
| 731 | /* Fallthrough */ | 839 | return mac_address_string(buf, end, ptr, spec, fmt); |
| 732 | case 'M': | 840 | case 'I': /* Formatted IP supported |
| 733 | return mac_address_string(buf, end, ptr, spec); | 841 | * 4: 1.2.3.4 |
| 734 | case 'i': | 842 | * 6: 0001:0203:...:0708 |
| 735 | spec.flags |= SPECIAL; | 843 | * 6c: 1::708 or 1::1.2.3.4 |
| 736 | /* Fallthrough */ | 844 | */ |
| 737 | case 'I': | 845 | case 'i': /* Contiguous: |
| 738 | if (fmt[1] == '6') | 846 | * 4: 001.002.003.004 |
| 739 | return ip6_addr_string(buf, end, ptr, spec); | 847 | * 6: 000102...0f |
| 740 | if (fmt[1] == '4') | 848 | */ |
| 741 | return ip4_addr_string(buf, end, ptr, spec); | 849 | switch (fmt[1]) { |
| 742 | spec.flags &= ~SPECIAL; | 850 | case '6': |
| 851 | return ip6_addr_string(buf, end, ptr, spec, fmt); | ||
| 852 | case '4': | ||
| 853 | return ip4_addr_string(buf, end, ptr, spec, fmt); | ||
| 854 | } | ||
| 743 | break; | 855 | break; |
| 744 | } | 856 | } |
| 745 | spec.flags |= SMALL; | 857 | spec.flags |= SMALL; |
| @@ -958,10 +1070,12 @@ qualifier: | |||
| 958 | * @args: Arguments for the format string | 1070 | * @args: Arguments for the format string |
| 959 | * | 1071 | * |
| 960 | * This function follows C99 vsnprintf, but has some extensions: | 1072 | * This function follows C99 vsnprintf, but has some extensions: |
| 961 | * %pS output the name of a text symbol | 1073 | * %pS output the name of a text symbol with offset |
| 1074 | * %ps output the name of a text symbol without offset | ||
| 962 | * %pF output the name of a function pointer with its offset | 1075 | * %pF output the name of a function pointer with its offset |
| 963 | * %pf output the name of a function pointer without its offset | 1076 | * %pf output the name of a function pointer without its offset |
| 964 | * %pR output the address range in a struct resource | 1077 | * %pR output the address range in a struct resource |
| 1078 | * %n is ignored | ||
| 965 | * | 1079 | * |
| 966 | * The return value is the number of characters which would | 1080 | * The return value is the number of characters which would |
| 967 | * be generated for the given input, excluding the trailing | 1081 | * be generated for the given input, excluding the trailing |
| @@ -983,13 +1097,8 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args) | |||
| 983 | 1097 | ||
| 984 | /* Reject out-of-range values early. Large positive sizes are | 1098 | /* Reject out-of-range values early. Large positive sizes are |
| 985 | used for unknown buffer sizes. */ | 1099 | used for unknown buffer sizes. */ |
| 986 | if (unlikely((int) size < 0)) { | 1100 | if (WARN_ON_ONCE((int) size < 0)) |
| 987 | /* There can be only one.. */ | ||
| 988 | static char warn = 1; | ||
| 989 | WARN_ON(warn); | ||
| 990 | warn = 0; | ||
| 991 | return 0; | 1101 | return 0; |
| 992 | } | ||
| 993 | 1102 | ||
| 994 | str = buf; | 1103 | str = buf; |
| 995 | end = buf + size; | 1104 | end = buf + size; |
| @@ -1417,11 +1526,7 @@ EXPORT_SYMBOL_GPL(vbin_printf); | |||
| 1417 | * a binary buffer that generated by vbin_printf. | 1526 | * a binary buffer that generated by vbin_printf. |
| 1418 | * | 1527 | * |
| 1419 | * The format follows C99 vsnprintf, but has some extensions: | 1528 | * The format follows C99 vsnprintf, but has some extensions: |
| 1420 | * %pS output the name of a text symbol | 1529 | * see vsnprintf comment for details. |
| 1421 | * %pF output the name of a function pointer with its offset | ||
| 1422 | * %pf output the name of a function pointer without its offset | ||
| 1423 | * %pR output the address range in a struct resource | ||
| 1424 | * %n is ignored | ||
| 1425 | * | 1530 | * |
| 1426 | * The return value is the number of characters which would | 1531 | * The return value is the number of characters which would |
| 1427 | * be generated for the given input, excluding the trailing | 1532 | * be generated for the given input, excluding the trailing |
| @@ -1439,13 +1544,8 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf) | |||
| 1439 | 1544 | ||
| 1440 | struct printf_spec spec = {0}; | 1545 | struct printf_spec spec = {0}; |
| 1441 | 1546 | ||
| 1442 | if (unlikely((int) size < 0)) { | 1547 | if (WARN_ON_ONCE((int) size < 0)) |
| 1443 | /* There can be only one.. */ | ||
| 1444 | static char warn = 1; | ||
| 1445 | WARN_ON(warn); | ||
| 1446 | warn = 0; | ||
| 1447 | return 0; | 1548 | return 0; |
| 1448 | } | ||
| 1449 | 1549 | ||
| 1450 | str = buf; | 1550 | str = buf; |
| 1451 | end = buf + size; | 1551 | end = buf + size; |
| @@ -1671,7 +1771,7 @@ int vsscanf(const char * buf, const char * fmt, va_list args) | |||
| 1671 | * advance both strings to next white space | 1771 | * advance both strings to next white space |
| 1672 | */ | 1772 | */ |
| 1673 | if (*fmt == '*') { | 1773 | if (*fmt == '*') { |
| 1674 | while (!isspace(*fmt) && *fmt) | 1774 | while (!isspace(*fmt) && *fmt != '%' && *fmt) |
| 1675 | fmt++; | 1775 | fmt++; |
| 1676 | while (!isspace(*str) && *str) | 1776 | while (!isspace(*str) && *str) |
| 1677 | str++; | 1777 | str++; |
diff --git a/lib/zlib_deflate/deflate.c b/lib/zlib_deflate/deflate.c index c3e4a2baf835..46a31e5f49c3 100644 --- a/lib/zlib_deflate/deflate.c +++ b/lib/zlib_deflate/deflate.c | |||
| @@ -135,7 +135,7 @@ static const config configuration_table[10] = { | |||
| 135 | 135 | ||
| 136 | /* =========================================================================== | 136 | /* =========================================================================== |
| 137 | * Update a hash value with the given input byte | 137 | * Update a hash value with the given input byte |
| 138 | * IN assertion: all calls to to UPDATE_HASH are made with consecutive | 138 | * IN assertion: all calls to UPDATE_HASH are made with consecutive |
| 139 | * input characters, so that a running hash key can be computed from the | 139 | * input characters, so that a running hash key can be computed from the |
| 140 | * previous key instead of complete recalculation each time. | 140 | * previous key instead of complete recalculation each time. |
| 141 | */ | 141 | */ |
| @@ -146,7 +146,7 @@ static const config configuration_table[10] = { | |||
| 146 | * Insert string str in the dictionary and set match_head to the previous head | 146 | * Insert string str in the dictionary and set match_head to the previous head |
| 147 | * of the hash chain (the most recent string with same hash key). Return | 147 | * of the hash chain (the most recent string with same hash key). Return |
| 148 | * the previous length of the hash chain. | 148 | * the previous length of the hash chain. |
| 149 | * IN assertion: all calls to to INSERT_STRING are made with consecutive | 149 | * IN assertion: all calls to INSERT_STRING are made with consecutive |
| 150 | * input characters and the first MIN_MATCH bytes of str are valid | 150 | * input characters and the first MIN_MATCH bytes of str are valid |
| 151 | * (except for the last MIN_MATCH-1 bytes of the input file). | 151 | * (except for the last MIN_MATCH-1 bytes of the input file). |
| 152 | */ | 152 | */ |
