aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Kconfig46
-rw-r--r--lib/Kconfig.debug88
-rw-r--r--lib/Makefile9
-rw-r--r--lib/assoc_array.c6
-rw-r--r--lib/atomic64.c83
-rw-r--r--lib/bitmap.c123
-rw-r--r--lib/cmdline.c44
-rw-r--r--lib/crc32.c153
-rw-r--r--lib/decompress.c2
-rw-r--r--lib/decompress_bunzip2.c26
-rw-r--r--lib/decompress_inflate.c12
-rw-r--r--lib/decompress_unlz4.c83
-rw-r--r--lib/decompress_unlzma.c28
-rw-r--r--lib/decompress_unlzo.c12
-rw-r--r--lib/decompress_unxz.c10
-rw-r--r--lib/devres.c30
-rw-r--r--lib/dma-debug.c2
-rw-r--r--lib/dynamic_debug.c65
-rw-r--r--lib/flex_proportions.c8
-rw-r--r--lib/fonts/Kconfig9
-rw-r--r--lib/fonts/Makefile1
-rw-r--r--lib/fonts/font_6x10.c3086
-rw-r--r--lib/fonts/fonts.c4
-rw-r--r--lib/genalloc.c50
-rw-r--r--lib/glob.c287
-rw-r--r--lib/hexdump.c16
-rw-r--r--lib/hweight.c4
-rw-r--r--lib/idr.c27
-rw-r--r--lib/iovec.c4
-rw-r--r--lib/kfifo.c6
-rw-r--r--lib/klist.c6
-rw-r--r--lib/libcrc32c.c16
-rw-r--r--lib/list_sort.c71
-rw-r--r--lib/lru_cache.c23
-rw-r--r--lib/lzo/lzo1x_decompress_safe.c103
-rw-r--r--lib/net_utils.c10
-rw-r--r--lib/percpu-refcount.c299
-rw-r--r--lib/percpu_counter.c20
-rw-r--r--lib/prio_heap.c70
-rw-r--r--lib/proportions.c10
-rw-r--r--lib/raid6/algos.c12
-rw-r--r--lib/random32.c86
-rw-r--r--lib/rbtree.c2
-rw-r--r--lib/rhashtable.c794
-rw-r--r--lib/scatterlist.c29
-rw-r--r--lib/string.c48
-rw-r--r--lib/string_helpers.c327
-rw-r--r--lib/test-kstrtox.c2
-rw-r--r--lib/test-string_helpers.c277
-rw-r--r--lib/test_bpf.c89
-rw-r--r--lib/test_firmware.c117
-rw-r--r--lib/textsearch.c4
-rw-r--r--lib/vsprintf.c73
-rw-r--r--lib/zlib_deflate/deflate.c143
-rw-r--r--lib/zlib_inflate/inflate.c132
55 files changed, 6050 insertions, 1037 deletions
diff --git a/lib/Kconfig b/lib/Kconfig
index 334f7722a999..54cf309a92a5 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -51,6 +51,9 @@ config PERCPU_RWSEM
51config ARCH_USE_CMPXCHG_LOCKREF 51config ARCH_USE_CMPXCHG_LOCKREF
52 bool 52 bool
53 53
54config ARCH_HAS_FAST_MULTIPLIER
55 bool
56
54config CRC_CCITT 57config CRC_CCITT
55 tristate "CRC-CCITT functions" 58 tristate "CRC-CCITT functions"
56 help 59 help
@@ -396,6 +399,39 @@ config CPU_RMAP
396config DQL 399config DQL
397 bool 400 bool
398 401
402config GLOB
403 bool
404# This actually supports modular compilation, but the module overhead
405# is ridiculous for the amount of code involved. Until an out-of-tree
406# driver asks for it, we'll just link it directly it into the kernel
407# when required. Since we're ignoring out-of-tree users, there's also
408# no need bother prompting for a manual decision:
409# prompt "glob_match() function"
410 help
411 This option provides a glob_match function for performing
412 simple text pattern matching. It originated in the ATA code
413 to blacklist particular drive models, but other device drivers
414 may need similar functionality.
415
416 All drivers in the Linux kernel tree that require this function
417 should automatically select this option. Say N unless you
418 are compiling an out-of tree driver which tells you that it
419 depends on this.
420
421config GLOB_SELFTEST
422 bool "glob self-test on init"
423 default n
424 depends on GLOB
425 help
426 This option enables a simple self-test of the glob_match
427 function on startup. It is primarily useful for people
428 working on the code to ensure they haven't introduced any
429 regressions.
430
431 It only adds a little bit of code and slows kernel boot (or
432 module load) by a small amount, so you're welcome to play with
433 it, but you probably don't need it.
434
399# 435#
400# Netlink attribute parsing support is select'ed if needed 436# Netlink attribute parsing support is select'ed if needed
401# 437#
@@ -451,7 +487,8 @@ config MPILIB
451 487
452config SIGNATURE 488config SIGNATURE
453 tristate 489 tristate
454 depends on KEYS && CRYPTO 490 depends on KEYS
491 select CRYPTO
455 select CRYPTO_SHA1 492 select CRYPTO_SHA1
456 select MPILIB 493 select MPILIB
457 help 494 help
@@ -474,4 +511,11 @@ config UCS2_STRING
474 511
475source "lib/fonts/Kconfig" 512source "lib/fonts/Kconfig"
476 513
514#
515# sg chaining option
516#
517
518config ARCH_HAS_SG_CHAIN
519 def_bool n
520
477endmenu 521endmenu
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 901096d31c66..4e35a5d767ed 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -15,7 +15,7 @@ config PRINTK_TIME
15 The behavior is also controlled by the kernel command line 15 The behavior is also controlled by the kernel command line
16 parameter printk.time=1. See Documentation/kernel-parameters.txt 16 parameter printk.time=1. See Documentation/kernel-parameters.txt
17 17
18config DEFAULT_MESSAGE_LOGLEVEL 18config MESSAGE_LOGLEVEL_DEFAULT
19 int "Default message log level (1-7)" 19 int "Default message log level (1-7)"
20 range 1 7 20 range 1 7
21 default "4" 21 default "4"
@@ -143,6 +143,30 @@ config DEBUG_INFO_REDUCED
143 DEBUG_INFO build and compile times are reduced too. 143 DEBUG_INFO build and compile times are reduced too.
144 Only works with newer gcc versions. 144 Only works with newer gcc versions.
145 145
146config DEBUG_INFO_SPLIT
147 bool "Produce split debuginfo in .dwo files"
148 depends on DEBUG_INFO
149 help
150 Generate debug info into separate .dwo files. This significantly
151 reduces the build directory size for builds with DEBUG_INFO,
152 because it stores the information only once on disk in .dwo
153 files instead of multiple times in object files and executables.
154 In addition the debug information is also compressed.
155
156 Requires recent gcc (4.7+) and recent gdb/binutils.
157 Any tool that packages or reads debug information would need
158 to know about the .dwo files and include them.
159 Incompatible with older versions of ccache.
160
161config DEBUG_INFO_DWARF4
162 bool "Generate dwarf4 debuginfo"
163 depends on DEBUG_INFO
164 help
165 Generate dwarf4 debug info. This requires recent versions
166 of gcc and gdb. It makes the debug information larger.
167 But it significantly improves the success of resolving
168 variables in gdb on optimized code.
169
146config ENABLE_WARN_DEPRECATED 170config ENABLE_WARN_DEPRECATED
147 bool "Enable __deprecated logic" 171 bool "Enable __deprecated logic"
148 default y 172 default y
@@ -800,6 +824,18 @@ config SCHEDSTATS
800 application, you can say N to avoid the very slight overhead 824 application, you can say N to avoid the very slight overhead
801 this adds. 825 this adds.
802 826
827config SCHED_STACK_END_CHECK
828 bool "Detect stack corruption on calls to schedule()"
829 depends on DEBUG_KERNEL
830 default n
831 help
832 This option checks for a stack overrun on calls to schedule().
833 If the stack end location is found to be over written always panic as
834 the content of the corrupted region can no longer be trusted.
835 This is to ensure no erroneous behaviour occurs which could result in
836 data corruption or a sporadic crash at a later stage once the region
837 is examined. The runtime overhead introduced is minimal.
838
803config TIMER_STATS 839config TIMER_STATS
804 bool "Collect kernel timers statistics" 840 bool "Collect kernel timers statistics"
805 depends on DEBUG_KERNEL && PROC_FS 841 depends on DEBUG_KERNEL && PROC_FS
@@ -868,6 +904,10 @@ config DEBUG_WW_MUTEX_SLOWPATH
868 the full mutex checks enabled with (CONFIG_PROVE_LOCKING) this 904 the full mutex checks enabled with (CONFIG_PROVE_LOCKING) this
869 will test all possible w/w mutex interface abuse with the 905 will test all possible w/w mutex interface abuse with the
870 exception of simply not acquiring all the required locks. 906 exception of simply not acquiring all the required locks.
907 Note that this feature can introduce significant overhead, so
908 it really should not be enabled in a production or distro kernel,
909 even a debug kernel. If you are a driver writer, enable it. If
910 you are a distro, do not.
871 911
872config DEBUG_LOCK_ALLOC 912config DEBUG_LOCK_ALLOC
873 bool "Lock debugging: detect incorrect freeing of live locks" 913 bool "Lock debugging: detect incorrect freeing of live locks"
@@ -924,7 +964,7 @@ config PROVE_LOCKING
924 the proof of observed correctness is also maintained for an 964 the proof of observed correctness is also maintained for an
925 arbitrary combination of these separate locking variants. 965 arbitrary combination of these separate locking variants.
926 966
927 For more details, see Documentation/lockdep-design.txt. 967 For more details, see Documentation/locking/lockdep-design.txt.
928 968
929config LOCKDEP 969config LOCKDEP
930 bool 970 bool
@@ -945,7 +985,7 @@ config LOCK_STAT
945 help 985 help
946 This feature enables tracking lock contention points 986 This feature enables tracking lock contention points
947 987
948 For more details, see Documentation/lockstat.txt 988 For more details, see Documentation/locking/lockstat.txt
949 989
950 This also enables lock events required by "perf lock", 990 This also enables lock events required by "perf lock",
951 subcommand of perf. 991 subcommand of perf.
@@ -1008,8 +1048,13 @@ config TRACE_IRQFLAGS
1008 either tracing or lock debugging. 1048 either tracing or lock debugging.
1009 1049
1010config STACKTRACE 1050config STACKTRACE
1011 bool 1051 bool "Stack backtrace support"
1012 depends on STACKTRACE_SUPPORT 1052 depends on STACKTRACE_SUPPORT
1053 help
1054 This option causes the kernel to create a /proc/pid/stack for
1055 every process, showing its current stack trace.
1056 It is also used by various kernel debugging features that require
1057 stack trace generation.
1013 1058
1014config DEBUG_KOBJECT 1059config DEBUG_KOBJECT
1015 bool "kobject debugging" 1060 bool "kobject debugging"
@@ -1536,6 +1581,14 @@ config TEST_STRING_HELPERS
1536config TEST_KSTRTOX 1581config TEST_KSTRTOX
1537 tristate "Test kstrto*() family of functions at runtime" 1582 tristate "Test kstrto*() family of functions at runtime"
1538 1583
1584config TEST_RHASHTABLE
1585 bool "Perform selftest on resizable hash table"
1586 default n
1587 help
1588 Enable this option to test the rhashtable functions at boot.
1589
1590 If unsure, say N.
1591
1539endmenu # runtime tests 1592endmenu # runtime tests
1540 1593
1541config PROVIDE_OHCI1394_DMA_INIT 1594config PROVIDE_OHCI1394_DMA_INIT
@@ -1595,7 +1648,7 @@ config DMA_API_DEBUG
1595 1648
1596 If unsure, say N. 1649 If unsure, say N.
1597 1650
1598config TEST_MODULE 1651config TEST_LKM
1599 tristate "Test module loading with 'hello world' module" 1652 tristate "Test module loading with 'hello world' module"
1600 default n 1653 default n
1601 depends on m 1654 depends on m
@@ -1631,7 +1684,30 @@ config TEST_BPF
1631 against the BPF interpreter or BPF JIT compiler depending on the 1684 against the BPF interpreter or BPF JIT compiler depending on the
1632 current setting. This is in particular useful for BPF JIT compiler 1685 current setting. This is in particular useful for BPF JIT compiler
1633 development, but also to run regression tests against changes in 1686 development, but also to run regression tests against changes in
1634 the interpreter code. 1687 the interpreter code. It also enables test stubs for eBPF maps and
1688 verifier used by user space verifier testsuite.
1689
1690 If unsure, say N.
1691
1692config TEST_FIRMWARE
1693 tristate "Test firmware loading via userspace interface"
1694 default n
1695 depends on FW_LOADER
1696 help
1697 This builds the "test_firmware" module that creates a userspace
1698 interface for testing firmware loading. This can be used to
1699 control the triggering of firmware loading without needing an
1700 actual firmware-using device. The contents can be rechecked by
1701 userspace.
1702
1703 If unsure, say N.
1704
1705config TEST_UDELAY
1706 tristate "udelay test driver"
1707 default n
1708 help
1709 This builds the "udelay_test" module that helps to make sure
1710 that udelay() is working properly.
1635 1711
1636 If unsure, say N. 1712 If unsure, say N.
1637 1713
diff --git a/lib/Makefile b/lib/Makefile
index ba967a19edba..7512dc978f18 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -11,7 +11,7 @@ lib-y := ctype.o string.o vsprintf.o cmdline.o \
11 rbtree.o radix-tree.o dump_stack.o timerqueue.o\ 11 rbtree.o radix-tree.o dump_stack.o timerqueue.o\
12 idr.o int_sqrt.o extable.o \ 12 idr.o int_sqrt.o extable.o \
13 sha1.o md5.o irq_regs.o reciprocal_div.o argv_split.o \ 13 sha1.o md5.o irq_regs.o reciprocal_div.o argv_split.o \
14 proportions.o flex_proportions.o prio_heap.o ratelimit.o show_mem.o \ 14 proportions.o flex_proportions.o ratelimit.o show_mem.o \
15 is_single_threaded.o plist.o decompress.o kobject_uevent.o \ 15 is_single_threaded.o plist.o decompress.o kobject_uevent.o \
16 earlycpio.o 16 earlycpio.o
17 17
@@ -26,14 +26,15 @@ obj-y += bcd.o div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \
26 bust_spinlocks.o hexdump.o kasprintf.o bitmap.o scatterlist.o \ 26 bust_spinlocks.o hexdump.o kasprintf.o bitmap.o scatterlist.o \
27 gcd.o lcm.o list_sort.o uuid.o flex_array.o iovec.o clz_ctz.o \ 27 gcd.o lcm.o list_sort.o uuid.o flex_array.o iovec.o clz_ctz.o \
28 bsearch.o find_last_bit.o find_next_bit.o llist.o memweight.o kfifo.o \ 28 bsearch.o find_last_bit.o find_next_bit.o llist.o memweight.o kfifo.o \
29 percpu-refcount.o percpu_ida.o hash.o 29 percpu-refcount.o percpu_ida.o hash.o rhashtable.o
30obj-y += string_helpers.o 30obj-y += string_helpers.o
31obj-$(CONFIG_TEST_STRING_HELPERS) += test-string_helpers.o 31obj-$(CONFIG_TEST_STRING_HELPERS) += test-string_helpers.o
32obj-y += kstrtox.o 32obj-y += kstrtox.o
33obj-$(CONFIG_TEST_KSTRTOX) += test-kstrtox.o 33obj-$(CONFIG_TEST_KSTRTOX) += test-kstrtox.o
34obj-$(CONFIG_TEST_MODULE) += test_module.o 34obj-$(CONFIG_TEST_LKM) += test_module.o
35obj-$(CONFIG_TEST_USER_COPY) += test_user_copy.o 35obj-$(CONFIG_TEST_USER_COPY) += test_user_copy.o
36obj-$(CONFIG_TEST_BPF) += test_bpf.o 36obj-$(CONFIG_TEST_BPF) += test_bpf.o
37obj-$(CONFIG_TEST_FIRMWARE) += test_firmware.o
37 38
38ifeq ($(CONFIG_DEBUG_KOBJECT),y) 39ifeq ($(CONFIG_DEBUG_KOBJECT),y)
39CFLAGS_kobject.o += -DDEBUG 40CFLAGS_kobject.o += -DDEBUG
@@ -136,6 +137,8 @@ obj-$(CONFIG_CORDIC) += cordic.o
136 137
137obj-$(CONFIG_DQL) += dynamic_queue_limits.o 138obj-$(CONFIG_DQL) += dynamic_queue_limits.o
138 139
140obj-$(CONFIG_GLOB) += glob.o
141
139obj-$(CONFIG_MPILIB) += mpi/ 142obj-$(CONFIG_MPILIB) += mpi/
140obj-$(CONFIG_SIGNATURE) += digsig.o 143obj-$(CONFIG_SIGNATURE) += digsig.o
141 144
diff --git a/lib/assoc_array.c b/lib/assoc_array.c
index c0b1007011e1..2404d03e251a 100644
--- a/lib/assoc_array.c
+++ b/lib/assoc_array.c
@@ -1723,11 +1723,13 @@ ascend_old_tree:
1723 shortcut = assoc_array_ptr_to_shortcut(ptr); 1723 shortcut = assoc_array_ptr_to_shortcut(ptr);
1724 slot = shortcut->parent_slot; 1724 slot = shortcut->parent_slot;
1725 cursor = shortcut->back_pointer; 1725 cursor = shortcut->back_pointer;
1726 if (!cursor)
1727 goto gc_complete;
1726 } else { 1728 } else {
1727 slot = node->parent_slot; 1729 slot = node->parent_slot;
1728 cursor = ptr; 1730 cursor = ptr;
1729 } 1731 }
1730 BUG_ON(!ptr); 1732 BUG_ON(!cursor);
1731 node = assoc_array_ptr_to_node(cursor); 1733 node = assoc_array_ptr_to_node(cursor);
1732 slot++; 1734 slot++;
1733 goto continue_node; 1735 goto continue_node;
@@ -1735,7 +1737,7 @@ ascend_old_tree:
1735gc_complete: 1737gc_complete:
1736 edit->set[0].to = new_root; 1738 edit->set[0].to = new_root;
1737 assoc_array_apply_edit(edit); 1739 assoc_array_apply_edit(edit);
1738 edit->array->nr_leaves_on_tree = nr_leaves_on_tree; 1740 array->nr_leaves_on_tree = nr_leaves_on_tree;
1739 return 0; 1741 return 0;
1740 1742
1741enomem: 1743enomem:
diff --git a/lib/atomic64.c b/lib/atomic64.c
index 08a4f068e61e..1298c05ef528 100644
--- a/lib/atomic64.c
+++ b/lib/atomic64.c
@@ -70,53 +70,42 @@ void atomic64_set(atomic64_t *v, long long i)
70} 70}
71EXPORT_SYMBOL(atomic64_set); 71EXPORT_SYMBOL(atomic64_set);
72 72
73void atomic64_add(long long a, atomic64_t *v) 73#define ATOMIC64_OP(op, c_op) \
74{ 74void atomic64_##op(long long a, atomic64_t *v) \
75 unsigned long flags; 75{ \
76 raw_spinlock_t *lock = lock_addr(v); 76 unsigned long flags; \
77 77 raw_spinlock_t *lock = lock_addr(v); \
78 raw_spin_lock_irqsave(lock, flags); 78 \
79 v->counter += a; 79 raw_spin_lock_irqsave(lock, flags); \
80 raw_spin_unlock_irqrestore(lock, flags); 80 v->counter c_op a; \
81} 81 raw_spin_unlock_irqrestore(lock, flags); \
82EXPORT_SYMBOL(atomic64_add); 82} \
83 83EXPORT_SYMBOL(atomic64_##op);
84long long atomic64_add_return(long long a, atomic64_t *v) 84
85{ 85#define ATOMIC64_OP_RETURN(op, c_op) \
86 unsigned long flags; 86long long atomic64_##op##_return(long long a, atomic64_t *v) \
87 raw_spinlock_t *lock = lock_addr(v); 87{ \
88 long long val; 88 unsigned long flags; \
89 89 raw_spinlock_t *lock = lock_addr(v); \
90 raw_spin_lock_irqsave(lock, flags); 90 long long val; \
91 val = v->counter += a; 91 \
92 raw_spin_unlock_irqrestore(lock, flags); 92 raw_spin_lock_irqsave(lock, flags); \
93 return val; 93 val = (v->counter c_op a); \
94} 94 raw_spin_unlock_irqrestore(lock, flags); \
95EXPORT_SYMBOL(atomic64_add_return); 95 return val; \
96 96} \
97void atomic64_sub(long long a, atomic64_t *v) 97EXPORT_SYMBOL(atomic64_##op##_return);
98{ 98
99 unsigned long flags; 99#define ATOMIC64_OPS(op, c_op) \
100 raw_spinlock_t *lock = lock_addr(v); 100 ATOMIC64_OP(op, c_op) \
101 101 ATOMIC64_OP_RETURN(op, c_op)
102 raw_spin_lock_irqsave(lock, flags); 102
103 v->counter -= a; 103ATOMIC64_OPS(add, +=)
104 raw_spin_unlock_irqrestore(lock, flags); 104ATOMIC64_OPS(sub, -=)
105} 105
106EXPORT_SYMBOL(atomic64_sub); 106#undef ATOMIC64_OPS
107 107#undef ATOMIC64_OP_RETURN
108long long atomic64_sub_return(long long a, atomic64_t *v) 108#undef ATOMIC64_OP
109{
110 unsigned long flags;
111 raw_spinlock_t *lock = lock_addr(v);
112 long long val;
113
114 raw_spin_lock_irqsave(lock, flags);
115 val = v->counter -= a;
116 raw_spin_unlock_irqrestore(lock, flags);
117 return val;
118}
119EXPORT_SYMBOL(atomic64_sub_return);
120 109
121long long atomic64_dec_if_positive(atomic64_t *v) 110long long atomic64_dec_if_positive(atomic64_t *v)
122{ 111{
diff --git a/lib/bitmap.c b/lib/bitmap.c
index 06f7e4fe8d2d..b499ab6ada29 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -40,9 +40,9 @@
40 * for the best explanations of this ordering. 40 * for the best explanations of this ordering.
41 */ 41 */
42 42
43int __bitmap_empty(const unsigned long *bitmap, int bits) 43int __bitmap_empty(const unsigned long *bitmap, unsigned int bits)
44{ 44{
45 int k, lim = bits/BITS_PER_LONG; 45 unsigned int k, lim = bits/BITS_PER_LONG;
46 for (k = 0; k < lim; ++k) 46 for (k = 0; k < lim; ++k)
47 if (bitmap[k]) 47 if (bitmap[k])
48 return 0; 48 return 0;
@@ -55,9 +55,9 @@ int __bitmap_empty(const unsigned long *bitmap, int bits)
55} 55}
56EXPORT_SYMBOL(__bitmap_empty); 56EXPORT_SYMBOL(__bitmap_empty);
57 57
58int __bitmap_full(const unsigned long *bitmap, int bits) 58int __bitmap_full(const unsigned long *bitmap, unsigned int bits)
59{ 59{
60 int k, lim = bits/BITS_PER_LONG; 60 unsigned int k, lim = bits/BITS_PER_LONG;
61 for (k = 0; k < lim; ++k) 61 for (k = 0; k < lim; ++k)
62 if (~bitmap[k]) 62 if (~bitmap[k])
63 return 0; 63 return 0;
@@ -71,9 +71,9 @@ int __bitmap_full(const unsigned long *bitmap, int bits)
71EXPORT_SYMBOL(__bitmap_full); 71EXPORT_SYMBOL(__bitmap_full);
72 72
73int __bitmap_equal(const unsigned long *bitmap1, 73int __bitmap_equal(const unsigned long *bitmap1,
74 const unsigned long *bitmap2, int bits) 74 const unsigned long *bitmap2, unsigned int bits)
75{ 75{
76 int k, lim = bits/BITS_PER_LONG; 76 unsigned int k, lim = bits/BITS_PER_LONG;
77 for (k = 0; k < lim; ++k) 77 for (k = 0; k < lim; ++k)
78 if (bitmap1[k] != bitmap2[k]) 78 if (bitmap1[k] != bitmap2[k])
79 return 0; 79 return 0;
@@ -86,14 +86,14 @@ int __bitmap_equal(const unsigned long *bitmap1,
86} 86}
87EXPORT_SYMBOL(__bitmap_equal); 87EXPORT_SYMBOL(__bitmap_equal);
88 88
89void __bitmap_complement(unsigned long *dst, const unsigned long *src, int bits) 89void __bitmap_complement(unsigned long *dst, const unsigned long *src, unsigned int bits)
90{ 90{
91 int k, lim = bits/BITS_PER_LONG; 91 unsigned int k, lim = bits/BITS_PER_LONG;
92 for (k = 0; k < lim; ++k) 92 for (k = 0; k < lim; ++k)
93 dst[k] = ~src[k]; 93 dst[k] = ~src[k];
94 94
95 if (bits % BITS_PER_LONG) 95 if (bits % BITS_PER_LONG)
96 dst[k] = ~src[k] & BITMAP_LAST_WORD_MASK(bits); 96 dst[k] = ~src[k];
97} 97}
98EXPORT_SYMBOL(__bitmap_complement); 98EXPORT_SYMBOL(__bitmap_complement);
99 99
@@ -131,7 +131,9 @@ void __bitmap_shift_right(unsigned long *dst,
131 lower = src[off + k]; 131 lower = src[off + k];
132 if (left && off + k == lim - 1) 132 if (left && off + k == lim - 1)
133 lower &= mask; 133 lower &= mask;
134 dst[k] = upper << (BITS_PER_LONG - rem) | lower >> rem; 134 dst[k] = lower >> rem;
135 if (rem)
136 dst[k] |= upper << (BITS_PER_LONG - rem);
135 if (left && k == lim - 1) 137 if (left && k == lim - 1)
136 dst[k] &= mask; 138 dst[k] &= mask;
137 } 139 }
@@ -172,7 +174,9 @@ void __bitmap_shift_left(unsigned long *dst,
172 upper = src[k]; 174 upper = src[k];
173 if (left && k == lim - 1) 175 if (left && k == lim - 1)
174 upper &= (1UL << left) - 1; 176 upper &= (1UL << left) - 1;
175 dst[k + off] = lower >> (BITS_PER_LONG - rem) | upper << rem; 177 dst[k + off] = upper << rem;
178 if (rem)
179 dst[k + off] |= lower >> (BITS_PER_LONG - rem);
176 if (left && k + off == lim - 1) 180 if (left && k + off == lim - 1)
177 dst[k + off] &= (1UL << left) - 1; 181 dst[k + off] &= (1UL << left) - 1;
178 } 182 }
@@ -182,23 +186,26 @@ void __bitmap_shift_left(unsigned long *dst,
182EXPORT_SYMBOL(__bitmap_shift_left); 186EXPORT_SYMBOL(__bitmap_shift_left);
183 187
184int __bitmap_and(unsigned long *dst, const unsigned long *bitmap1, 188int __bitmap_and(unsigned long *dst, const unsigned long *bitmap1,
185 const unsigned long *bitmap2, int bits) 189 const unsigned long *bitmap2, unsigned int bits)
186{ 190{
187 int k; 191 unsigned int k;
188 int nr = BITS_TO_LONGS(bits); 192 unsigned int lim = bits/BITS_PER_LONG;
189 unsigned long result = 0; 193 unsigned long result = 0;
190 194
191 for (k = 0; k < nr; k++) 195 for (k = 0; k < lim; k++)
192 result |= (dst[k] = bitmap1[k] & bitmap2[k]); 196 result |= (dst[k] = bitmap1[k] & bitmap2[k]);
197 if (bits % BITS_PER_LONG)
198 result |= (dst[k] = bitmap1[k] & bitmap2[k] &
199 BITMAP_LAST_WORD_MASK(bits));
193 return result != 0; 200 return result != 0;
194} 201}
195EXPORT_SYMBOL(__bitmap_and); 202EXPORT_SYMBOL(__bitmap_and);
196 203
197void __bitmap_or(unsigned long *dst, const unsigned long *bitmap1, 204void __bitmap_or(unsigned long *dst, const unsigned long *bitmap1,
198 const unsigned long *bitmap2, int bits) 205 const unsigned long *bitmap2, unsigned int bits)
199{ 206{
200 int k; 207 unsigned int k;
201 int nr = BITS_TO_LONGS(bits); 208 unsigned int nr = BITS_TO_LONGS(bits);
202 209
203 for (k = 0; k < nr; k++) 210 for (k = 0; k < nr; k++)
204 dst[k] = bitmap1[k] | bitmap2[k]; 211 dst[k] = bitmap1[k] | bitmap2[k];
@@ -206,10 +213,10 @@ void __bitmap_or(unsigned long *dst, const unsigned long *bitmap1,
206EXPORT_SYMBOL(__bitmap_or); 213EXPORT_SYMBOL(__bitmap_or);
207 214
208void __bitmap_xor(unsigned long *dst, const unsigned long *bitmap1, 215void __bitmap_xor(unsigned long *dst, const unsigned long *bitmap1,
209 const unsigned long *bitmap2, int bits) 216 const unsigned long *bitmap2, unsigned int bits)
210{ 217{
211 int k; 218 unsigned int k;
212 int nr = BITS_TO_LONGS(bits); 219 unsigned int nr = BITS_TO_LONGS(bits);
213 220
214 for (k = 0; k < nr; k++) 221 for (k = 0; k < nr; k++)
215 dst[k] = bitmap1[k] ^ bitmap2[k]; 222 dst[k] = bitmap1[k] ^ bitmap2[k];
@@ -217,22 +224,25 @@ void __bitmap_xor(unsigned long *dst, const unsigned long *bitmap1,
217EXPORT_SYMBOL(__bitmap_xor); 224EXPORT_SYMBOL(__bitmap_xor);
218 225
219int __bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1, 226int __bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1,
220 const unsigned long *bitmap2, int bits) 227 const unsigned long *bitmap2, unsigned int bits)
221{ 228{
222 int k; 229 unsigned int k;
223 int nr = BITS_TO_LONGS(bits); 230 unsigned int lim = bits/BITS_PER_LONG;
224 unsigned long result = 0; 231 unsigned long result = 0;
225 232
226 for (k = 0; k < nr; k++) 233 for (k = 0; k < lim; k++)
227 result |= (dst[k] = bitmap1[k] & ~bitmap2[k]); 234 result |= (dst[k] = bitmap1[k] & ~bitmap2[k]);
235 if (bits % BITS_PER_LONG)
236 result |= (dst[k] = bitmap1[k] & ~bitmap2[k] &
237 BITMAP_LAST_WORD_MASK(bits));
228 return result != 0; 238 return result != 0;
229} 239}
230EXPORT_SYMBOL(__bitmap_andnot); 240EXPORT_SYMBOL(__bitmap_andnot);
231 241
232int __bitmap_intersects(const unsigned long *bitmap1, 242int __bitmap_intersects(const unsigned long *bitmap1,
233 const unsigned long *bitmap2, int bits) 243 const unsigned long *bitmap2, unsigned int bits)
234{ 244{
235 int k, lim = bits/BITS_PER_LONG; 245 unsigned int k, lim = bits/BITS_PER_LONG;
236 for (k = 0; k < lim; ++k) 246 for (k = 0; k < lim; ++k)
237 if (bitmap1[k] & bitmap2[k]) 247 if (bitmap1[k] & bitmap2[k])
238 return 1; 248 return 1;
@@ -245,9 +255,9 @@ int __bitmap_intersects(const unsigned long *bitmap1,
245EXPORT_SYMBOL(__bitmap_intersects); 255EXPORT_SYMBOL(__bitmap_intersects);
246 256
247int __bitmap_subset(const unsigned long *bitmap1, 257int __bitmap_subset(const unsigned long *bitmap1,
248 const unsigned long *bitmap2, int bits) 258 const unsigned long *bitmap2, unsigned int bits)
249{ 259{
250 int k, lim = bits/BITS_PER_LONG; 260 unsigned int k, lim = bits/BITS_PER_LONG;
251 for (k = 0; k < lim; ++k) 261 for (k = 0; k < lim; ++k)
252 if (bitmap1[k] & ~bitmap2[k]) 262 if (bitmap1[k] & ~bitmap2[k])
253 return 0; 263 return 0;
@@ -259,9 +269,10 @@ int __bitmap_subset(const unsigned long *bitmap1,
259} 269}
260EXPORT_SYMBOL(__bitmap_subset); 270EXPORT_SYMBOL(__bitmap_subset);
261 271
262int __bitmap_weight(const unsigned long *bitmap, int bits) 272int __bitmap_weight(const unsigned long *bitmap, unsigned int bits)
263{ 273{
264 int k, w = 0, lim = bits/BITS_PER_LONG; 274 unsigned int k, lim = bits/BITS_PER_LONG;
275 int w = 0;
265 276
266 for (k = 0; k < lim; k++) 277 for (k = 0; k < lim; k++)
267 w += hweight_long(bitmap[k]); 278 w += hweight_long(bitmap[k]);
@@ -273,42 +284,42 @@ int __bitmap_weight(const unsigned long *bitmap, int bits)
273} 284}
274EXPORT_SYMBOL(__bitmap_weight); 285EXPORT_SYMBOL(__bitmap_weight);
275 286
276void bitmap_set(unsigned long *map, int start, int nr) 287void bitmap_set(unsigned long *map, unsigned int start, int len)
277{ 288{
278 unsigned long *p = map + BIT_WORD(start); 289 unsigned long *p = map + BIT_WORD(start);
279 const int size = start + nr; 290 const unsigned int size = start + len;
280 int bits_to_set = BITS_PER_LONG - (start % BITS_PER_LONG); 291 int bits_to_set = BITS_PER_LONG - (start % BITS_PER_LONG);
281 unsigned long mask_to_set = BITMAP_FIRST_WORD_MASK(start); 292 unsigned long mask_to_set = BITMAP_FIRST_WORD_MASK(start);
282 293
283 while (nr - bits_to_set >= 0) { 294 while (len - bits_to_set >= 0) {
284 *p |= mask_to_set; 295 *p |= mask_to_set;
285 nr -= bits_to_set; 296 len -= bits_to_set;
286 bits_to_set = BITS_PER_LONG; 297 bits_to_set = BITS_PER_LONG;
287 mask_to_set = ~0UL; 298 mask_to_set = ~0UL;
288 p++; 299 p++;
289 } 300 }
290 if (nr) { 301 if (len) {
291 mask_to_set &= BITMAP_LAST_WORD_MASK(size); 302 mask_to_set &= BITMAP_LAST_WORD_MASK(size);
292 *p |= mask_to_set; 303 *p |= mask_to_set;
293 } 304 }
294} 305}
295EXPORT_SYMBOL(bitmap_set); 306EXPORT_SYMBOL(bitmap_set);
296 307
297void bitmap_clear(unsigned long *map, int start, int nr) 308void bitmap_clear(unsigned long *map, unsigned int start, int len)
298{ 309{
299 unsigned long *p = map + BIT_WORD(start); 310 unsigned long *p = map + BIT_WORD(start);
300 const int size = start + nr; 311 const unsigned int size = start + len;
301 int bits_to_clear = BITS_PER_LONG - (start % BITS_PER_LONG); 312 int bits_to_clear = BITS_PER_LONG - (start % BITS_PER_LONG);
302 unsigned long mask_to_clear = BITMAP_FIRST_WORD_MASK(start); 313 unsigned long mask_to_clear = BITMAP_FIRST_WORD_MASK(start);
303 314
304 while (nr - bits_to_clear >= 0) { 315 while (len - bits_to_clear >= 0) {
305 *p &= ~mask_to_clear; 316 *p &= ~mask_to_clear;
306 nr -= bits_to_clear; 317 len -= bits_to_clear;
307 bits_to_clear = BITS_PER_LONG; 318 bits_to_clear = BITS_PER_LONG;
308 mask_to_clear = ~0UL; 319 mask_to_clear = ~0UL;
309 p++; 320 p++;
310 } 321 }
311 if (nr) { 322 if (len) {
312 mask_to_clear &= BITMAP_LAST_WORD_MASK(size); 323 mask_to_clear &= BITMAP_LAST_WORD_MASK(size);
313 *p &= ~mask_to_clear; 324 *p &= ~mask_to_clear;
314 } 325 }
@@ -664,13 +675,8 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
664 675
665int bitmap_parselist(const char *bp, unsigned long *maskp, int nmaskbits) 676int bitmap_parselist(const char *bp, unsigned long *maskp, int nmaskbits)
666{ 677{
667 char *nl = strchr(bp, '\n'); 678 char *nl = strchrnul(bp, '\n');
668 int len; 679 int len = nl - bp;
669
670 if (nl)
671 len = nl - bp;
672 else
673 len = strlen(bp);
674 680
675 return __bitmap_parselist(bp, len, 0, maskp, nmaskbits); 681 return __bitmap_parselist(bp, len, 0, maskp, nmaskbits);
676} 682}
@@ -716,7 +722,7 @@ EXPORT_SYMBOL(bitmap_parselist_user);
716 * 722 *
717 * If for example, just bits 4 through 7 are set in @buf, then @pos 723 * If for example, just bits 4 through 7 are set in @buf, then @pos
718 * values 4 through 7 will get mapped to 0 through 3, respectively, 724 * values 4 through 7 will get mapped to 0 through 3, respectively,
719 * and other @pos values will get mapped to 0. When @pos value 7 725 * and other @pos values will get mapped to -1. When @pos value 7
720 * gets mapped to (returns) @ord value 3 in this example, that means 726 * gets mapped to (returns) @ord value 3 in this example, that means
721 * that bit 7 is the 3rd (starting with 0th) set bit in @buf. 727 * that bit 7 is the 3rd (starting with 0th) set bit in @buf.
722 * 728 *
@@ -882,7 +888,7 @@ EXPORT_SYMBOL(bitmap_bitremap);
882 * read it, you're overqualified for your current job.) 888 * read it, you're overqualified for your current job.)
883 * 889 *
884 * In other words, @orig is mapped onto (surjectively) @dst, 890 * In other words, @orig is mapped onto (surjectively) @dst,
885 * using the the map { <n, m> | the n-th bit of @relmap is the 891 * using the map { <n, m> | the n-th bit of @relmap is the
886 * m-th set bit of @relmap }. 892 * m-th set bit of @relmap }.
887 * 893 *
888 * Any set bits in @orig above bit number W, where W is the 894 * Any set bits in @orig above bit number W, where W is the
@@ -930,7 +936,7 @@ EXPORT_SYMBOL(bitmap_bitremap);
930 * 936 *
931 * Further lets say we use the following code, invoking 937 * Further lets say we use the following code, invoking
932 * bitmap_fold() then bitmap_onto, as suggested above to 938 * bitmap_fold() then bitmap_onto, as suggested above to
933 * avoid the possitility of an empty @dst result: 939 * avoid the possibility of an empty @dst result:
934 * 940 *
935 * unsigned long *tmp; // a temporary bitmap's bits 941 * unsigned long *tmp; // a temporary bitmap's bits
936 * 942 *
@@ -1046,7 +1052,7 @@ enum {
1046 REG_OP_RELEASE, /* clear all bits in region */ 1052 REG_OP_RELEASE, /* clear all bits in region */
1047}; 1053};
1048 1054
1049static int __reg_op(unsigned long *bitmap, int pos, int order, int reg_op) 1055static int __reg_op(unsigned long *bitmap, unsigned int pos, int order, int reg_op)
1050{ 1056{
1051 int nbits_reg; /* number of bits in region */ 1057 int nbits_reg; /* number of bits in region */
1052 int index; /* index first long of region in bitmap */ 1058 int index; /* index first long of region in bitmap */
@@ -1112,11 +1118,11 @@ done:
1112 * Return the bit offset in bitmap of the allocated region, 1118 * Return the bit offset in bitmap of the allocated region,
1113 * or -errno on failure. 1119 * or -errno on failure.
1114 */ 1120 */
1115int bitmap_find_free_region(unsigned long *bitmap, int bits, int order) 1121int bitmap_find_free_region(unsigned long *bitmap, unsigned int bits, int order)
1116{ 1122{
1117 int pos, end; /* scans bitmap by regions of size order */ 1123 unsigned int pos, end; /* scans bitmap by regions of size order */
1118 1124
1119 for (pos = 0 ; (end = pos + (1 << order)) <= bits; pos = end) { 1125 for (pos = 0 ; (end = pos + (1U << order)) <= bits; pos = end) {
1120 if (!__reg_op(bitmap, pos, order, REG_OP_ISFREE)) 1126 if (!__reg_op(bitmap, pos, order, REG_OP_ISFREE))
1121 continue; 1127 continue;
1122 __reg_op(bitmap, pos, order, REG_OP_ALLOC); 1128 __reg_op(bitmap, pos, order, REG_OP_ALLOC);
@@ -1137,7 +1143,7 @@ EXPORT_SYMBOL(bitmap_find_free_region);
1137 * 1143 *
1138 * No return value. 1144 * No return value.
1139 */ 1145 */
1140void bitmap_release_region(unsigned long *bitmap, int pos, int order) 1146void bitmap_release_region(unsigned long *bitmap, unsigned int pos, int order)
1141{ 1147{
1142 __reg_op(bitmap, pos, order, REG_OP_RELEASE); 1148 __reg_op(bitmap, pos, order, REG_OP_RELEASE);
1143} 1149}
@@ -1154,12 +1160,11 @@ EXPORT_SYMBOL(bitmap_release_region);
1154 * Return 0 on success, or %-EBUSY if specified region wasn't 1160 * Return 0 on success, or %-EBUSY if specified region wasn't
1155 * free (not all bits were zero). 1161 * free (not all bits were zero).
1156 */ 1162 */
1157int bitmap_allocate_region(unsigned long *bitmap, int pos, int order) 1163int bitmap_allocate_region(unsigned long *bitmap, unsigned int pos, int order)
1158{ 1164{
1159 if (!__reg_op(bitmap, pos, order, REG_OP_ISFREE)) 1165 if (!__reg_op(bitmap, pos, order, REG_OP_ISFREE))
1160 return -EBUSY; 1166 return -EBUSY;
1161 __reg_op(bitmap, pos, order, REG_OP_ALLOC); 1167 return __reg_op(bitmap, pos, order, REG_OP_ALLOC);
1162 return 0;
1163} 1168}
1164EXPORT_SYMBOL(bitmap_allocate_region); 1169EXPORT_SYMBOL(bitmap_allocate_region);
1165 1170
diff --git a/lib/cmdline.c b/lib/cmdline.c
index d4932f745e92..8f13cf73c2ec 100644
--- a/lib/cmdline.c
+++ b/lib/cmdline.c
@@ -121,11 +121,7 @@ EXPORT_SYMBOL(get_options);
121 * @retptr: (output) Optional pointer to next char after parse completes 121 * @retptr: (output) Optional pointer to next char after parse completes
122 * 122 *
123 * Parses a string into a number. The number stored at @ptr is 123 * Parses a string into a number. The number stored at @ptr is
124 * potentially suffixed with %K (for kilobytes, or 1024 bytes), 124 * potentially suffixed with K, M, G, T, P, E.
125 * %M (for megabytes, or 1048576 bytes), or %G (for gigabytes, or
126 * 1073741824). If the number is suffixed with K, M, or G, then
127 * the return value is the number multiplied by one kilobyte, one
128 * megabyte, or one gigabyte, respectively.
129 */ 125 */
130 126
131unsigned long long memparse(const char *ptr, char **retptr) 127unsigned long long memparse(const char *ptr, char **retptr)
@@ -135,6 +131,15 @@ unsigned long long memparse(const char *ptr, char **retptr)
135 unsigned long long ret = simple_strtoull(ptr, &endptr, 0); 131 unsigned long long ret = simple_strtoull(ptr, &endptr, 0);
136 132
137 switch (*endptr) { 133 switch (*endptr) {
134 case 'E':
135 case 'e':
136 ret <<= 10;
137 case 'P':
138 case 'p':
139 ret <<= 10;
140 case 'T':
141 case 't':
142 ret <<= 10;
138 case 'G': 143 case 'G':
139 case 'g': 144 case 'g':
140 ret <<= 10; 145 ret <<= 10;
@@ -155,3 +160,32 @@ unsigned long long memparse(const char *ptr, char **retptr)
155 return ret; 160 return ret;
156} 161}
157EXPORT_SYMBOL(memparse); 162EXPORT_SYMBOL(memparse);
163
164/**
165 * parse_option_str - Parse a string and check an option is set or not
166 * @str: String to be parsed
167 * @option: option name
168 *
169 * This function parses a string containing a comma-separated list of
170 * strings like a=b,c.
171 *
172 * Return true if there's such option in the string, or return false.
173 */
174bool parse_option_str(const char *str, const char *option)
175{
176 while (*str) {
177 if (!strncmp(str, option, strlen(option))) {
178 str += strlen(option);
179 if (!*str || *str == ',')
180 return true;
181 }
182
183 while (*str && *str != ',')
184 str++;
185
186 if (*str == ',')
187 str++;
188 }
189
190 return false;
191}
diff --git a/lib/crc32.c b/lib/crc32.c
index 21a7b2135af6..9a907d489d95 100644
--- a/lib/crc32.c
+++ b/lib/crc32.c
@@ -50,34 +50,10 @@ MODULE_AUTHOR("Matt Domsch <Matt_Domsch@dell.com>");
50MODULE_DESCRIPTION("Various CRC32 calculations"); 50MODULE_DESCRIPTION("Various CRC32 calculations");
51MODULE_LICENSE("GPL"); 51MODULE_LICENSE("GPL");
52 52
53#define GF2_DIM 32
54
55static u32 gf2_matrix_times(u32 *mat, u32 vec)
56{
57 u32 sum = 0;
58
59 while (vec) {
60 if (vec & 1)
61 sum ^= *mat;
62 vec >>= 1;
63 mat++;
64 }
65
66 return sum;
67}
68
69static void gf2_matrix_square(u32 *square, u32 *mat)
70{
71 int i;
72
73 for (i = 0; i < GF2_DIM; i++)
74 square[i] = gf2_matrix_times(mat, mat[i]);
75}
76
77#if CRC_LE_BITS > 8 || CRC_BE_BITS > 8 53#if CRC_LE_BITS > 8 || CRC_BE_BITS > 8
78 54
79/* implements slicing-by-4 or slicing-by-8 algorithm */ 55/* implements slicing-by-4 or slicing-by-8 algorithm */
80static inline u32 56static inline u32 __pure
81crc32_body(u32 crc, unsigned char const *buf, size_t len, const u32 (*tab)[256]) 57crc32_body(u32 crc, unsigned char const *buf, size_t len, const u32 (*tab)[256])
82{ 58{
83# ifdef __LITTLE_ENDIAN 59# ifdef __LITTLE_ENDIAN
@@ -155,51 +131,6 @@ crc32_body(u32 crc, unsigned char const *buf, size_t len, const u32 (*tab)[256])
155} 131}
156#endif 132#endif
157 133
158/* For conditions of distribution and use, see copyright notice in zlib.h */
159static u32 crc32_generic_combine(u32 crc1, u32 crc2, size_t len2,
160 u32 polynomial)
161{
162 u32 even[GF2_DIM]; /* Even-power-of-two zeros operator */
163 u32 odd[GF2_DIM]; /* Odd-power-of-two zeros operator */
164 u32 row;
165 int i;
166
167 if (len2 <= 0)
168 return crc1;
169
170 /* Put operator for one zero bit in odd */
171 odd[0] = polynomial;
172 row = 1;
173 for (i = 1; i < GF2_DIM; i++) {
174 odd[i] = row;
175 row <<= 1;
176 }
177
178 gf2_matrix_square(even, odd); /* Put operator for two zero bits in even */
179 gf2_matrix_square(odd, even); /* Put operator for four zero bits in odd */
180
181 /* Apply len2 zeros to crc1 (first square will put the operator for one
182 * zero byte, eight zero bits, in even).
183 */
184 do {
185 /* Apply zeros operator for this bit of len2 */
186 gf2_matrix_square(even, odd);
187 if (len2 & 1)
188 crc1 = gf2_matrix_times(even, crc1);
189 len2 >>= 1;
190 /* If no more bits set, then done */
191 if (len2 == 0)
192 break;
193 /* Another iteration of the loop with odd and even swapped */
194 gf2_matrix_square(odd, even);
195 if (len2 & 1)
196 crc1 = gf2_matrix_times(odd, crc1);
197 len2 >>= 1;
198 } while (len2 != 0);
199
200 crc1 ^= crc2;
201 return crc1;
202}
203 134
204/** 135/**
205 * crc32_le_generic() - Calculate bitwise little-endian Ethernet AUTODIN II 136 * crc32_le_generic() - Calculate bitwise little-endian Ethernet AUTODIN II
@@ -271,19 +202,81 @@ u32 __pure __crc32c_le(u32 crc, unsigned char const *p, size_t len)
271 (const u32 (*)[256])crc32ctable_le, CRC32C_POLY_LE); 202 (const u32 (*)[256])crc32ctable_le, CRC32C_POLY_LE);
272} 203}
273#endif 204#endif
274u32 __pure crc32_le_combine(u32 crc1, u32 crc2, size_t len2) 205EXPORT_SYMBOL(crc32_le);
206EXPORT_SYMBOL(__crc32c_le);
207
208/*
209 * This multiplies the polynomials x and y modulo the given modulus.
210 * This follows the "little-endian" CRC convention that the lsbit
211 * represents the highest power of x, and the msbit represents x^0.
212 */
213static u32 __attribute_const__ gf2_multiply(u32 x, u32 y, u32 modulus)
275{ 214{
276 return crc32_generic_combine(crc1, crc2, len2, CRCPOLY_LE); 215 u32 product = x & 1 ? y : 0;
216 int i;
217
218 for (i = 0; i < 31; i++) {
219 product = (product >> 1) ^ (product & 1 ? modulus : 0);
220 x >>= 1;
221 product ^= x & 1 ? y : 0;
222 }
223
224 return product;
277} 225}
278 226
279u32 __pure __crc32c_le_combine(u32 crc1, u32 crc2, size_t len2) 227/**
228 * crc32_generic_shift - Append len 0 bytes to crc, in logarithmic time
229 * @crc: The original little-endian CRC (i.e. lsbit is x^31 coefficient)
230 * @len: The number of bytes. @crc is multiplied by x^(8*@len)
231 * @polynomial: The modulus used to reduce the result to 32 bits.
232 *
233 * It's possible to parallelize CRC computations by computing a CRC
234 * over separate ranges of a buffer, then summing them.
235 * This shifts the given CRC by 8*len bits (i.e. produces the same effect
236 * as appending len bytes of zero to the data), in time proportional
237 * to log(len).
238 */
239static u32 __attribute_const__ crc32_generic_shift(u32 crc, size_t len,
240 u32 polynomial)
280{ 241{
281 return crc32_generic_combine(crc1, crc2, len2, CRC32C_POLY_LE); 242 u32 power = polynomial; /* CRC of x^32 */
243 int i;
244
245 /* Shift up to 32 bits in the simple linear way */
246 for (i = 0; i < 8 * (int)(len & 3); i++)
247 crc = (crc >> 1) ^ (crc & 1 ? polynomial : 0);
248
249 len >>= 2;
250 if (!len)
251 return crc;
252
253 for (;;) {
254 /* "power" is x^(2^i), modulo the polynomial */
255 if (len & 1)
256 crc = gf2_multiply(crc, power, polynomial);
257
258 len >>= 1;
259 if (!len)
260 break;
261
262 /* Square power, advancing to x^(2^(i+1)) */
263 power = gf2_multiply(power, power, polynomial);
264 }
265
266 return crc;
282} 267}
283EXPORT_SYMBOL(crc32_le); 268
284EXPORT_SYMBOL(crc32_le_combine); 269u32 __attribute_const__ crc32_le_shift(u32 crc, size_t len)
285EXPORT_SYMBOL(__crc32c_le); 270{
286EXPORT_SYMBOL(__crc32c_le_combine); 271 return crc32_generic_shift(crc, len, CRCPOLY_LE);
272}
273
274u32 __attribute_const__ __crc32c_le_shift(u32 crc, size_t len)
275{
276 return crc32_generic_shift(crc, len, CRC32C_POLY_LE);
277}
278EXPORT_SYMBOL(crc32_le_shift);
279EXPORT_SYMBOL(__crc32c_le_shift);
287 280
288/** 281/**
289 * crc32_be_generic() - Calculate bitwise big-endian Ethernet AUTODIN II CRC32 282 * crc32_be_generic() - Calculate bitwise big-endian Ethernet AUTODIN II CRC32
@@ -351,7 +344,7 @@ EXPORT_SYMBOL(crc32_be);
351#ifdef CONFIG_CRC32_SELFTEST 344#ifdef CONFIG_CRC32_SELFTEST
352 345
353/* 4096 random bytes */ 346/* 4096 random bytes */
354static u8 __attribute__((__aligned__(8))) test_buf[] = 347static u8 const __aligned(8) test_buf[] __initconst =
355{ 348{
356 0x5b, 0x85, 0x21, 0xcb, 0x09, 0x68, 0x7d, 0x30, 349 0x5b, 0x85, 0x21, 0xcb, 0x09, 0x68, 0x7d, 0x30,
357 0xc7, 0x69, 0xd7, 0x30, 0x92, 0xde, 0x59, 0xe4, 350 0xc7, 0x69, 0xd7, 0x30, 0x92, 0xde, 0x59, 0xe4,
@@ -875,7 +868,7 @@ static struct crc_test {
875 u32 crc_le; /* expected crc32_le result */ 868 u32 crc_le; /* expected crc32_le result */
876 u32 crc_be; /* expected crc32_be result */ 869 u32 crc_be; /* expected crc32_be result */
877 u32 crc32c_le; /* expected crc32c_le result */ 870 u32 crc32c_le; /* expected crc32c_le result */
878} test[] = 871} const test[] __initconst =
879{ 872{
880 {0x674bf11d, 0x00000038, 0x00000542, 0x0af6d466, 0xd8b6e4c1, 0xf6e93d6c}, 873 {0x674bf11d, 0x00000038, 0x00000542, 0x0af6d466, 0xd8b6e4c1, 0xf6e93d6c},
881 {0x35c672c6, 0x0000003a, 0x000001aa, 0xc6d3dfba, 0x28aaf3ad, 0x0fe92aca}, 874 {0x35c672c6, 0x0000003a, 0x000001aa, 0xc6d3dfba, 0x28aaf3ad, 0x0fe92aca},
diff --git a/lib/decompress.c b/lib/decompress.c
index 86069d74c062..37f3c786348f 100644
--- a/lib/decompress.c
+++ b/lib/decompress.c
@@ -54,7 +54,7 @@ static const struct compress_format compressed_formats[] __initconst = {
54 { {0, 0}, NULL, NULL } 54 { {0, 0}, NULL, NULL }
55}; 55};
56 56
57decompress_fn __init decompress_method(const unsigned char *inbuf, int len, 57decompress_fn __init decompress_method(const unsigned char *inbuf, long len,
58 const char **name) 58 const char **name)
59{ 59{
60 const struct compress_format *cf; 60 const struct compress_format *cf;
diff --git a/lib/decompress_bunzip2.c b/lib/decompress_bunzip2.c
index 31c5f7675fbf..8290e0bef7ea 100644
--- a/lib/decompress_bunzip2.c
+++ b/lib/decompress_bunzip2.c
@@ -92,8 +92,8 @@ struct bunzip_data {
92 /* State for interrupting output loop */ 92 /* State for interrupting output loop */
93 int writeCopies, writePos, writeRunCountdown, writeCount, writeCurrent; 93 int writeCopies, writePos, writeRunCountdown, writeCount, writeCurrent;
94 /* I/O tracking data (file handles, buffers, positions, etc.) */ 94 /* I/O tracking data (file handles, buffers, positions, etc.) */
95 int (*fill)(void*, unsigned int); 95 long (*fill)(void*, unsigned long);
96 int inbufCount, inbufPos /*, outbufPos*/; 96 long inbufCount, inbufPos /*, outbufPos*/;
97 unsigned char *inbuf /*,*outbuf*/; 97 unsigned char *inbuf /*,*outbuf*/;
98 unsigned int inbufBitCount, inbufBits; 98 unsigned int inbufBitCount, inbufBits;
99 /* The CRC values stored in the block header and calculated from the 99 /* The CRC values stored in the block header and calculated from the
@@ -617,7 +617,7 @@ decode_next_byte:
617 goto decode_next_byte; 617 goto decode_next_byte;
618} 618}
619 619
620static int INIT nofill(void *buf, unsigned int len) 620static long INIT nofill(void *buf, unsigned long len)
621{ 621{
622 return -1; 622 return -1;
623} 623}
@@ -625,8 +625,8 @@ static int INIT nofill(void *buf, unsigned int len)
625/* Allocate the structure, read file header. If in_fd ==-1, inbuf must contain 625/* Allocate the structure, read file header. If in_fd ==-1, inbuf must contain
626 a complete bunzip file (len bytes long). If in_fd!=-1, inbuf and len are 626 a complete bunzip file (len bytes long). If in_fd!=-1, inbuf and len are
627 ignored, and data is read from file handle into temporary buffer. */ 627 ignored, and data is read from file handle into temporary buffer. */
628static int INIT start_bunzip(struct bunzip_data **bdp, void *inbuf, int len, 628static int INIT start_bunzip(struct bunzip_data **bdp, void *inbuf, long len,
629 int (*fill)(void*, unsigned int)) 629 long (*fill)(void*, unsigned long))
630{ 630{
631 struct bunzip_data *bd; 631 struct bunzip_data *bd;
632 unsigned int i, j, c; 632 unsigned int i, j, c;
@@ -675,11 +675,11 @@ static int INIT start_bunzip(struct bunzip_data **bdp, void *inbuf, int len,
675 675
676/* Example usage: decompress src_fd to dst_fd. (Stops at end of bzip2 data, 676/* Example usage: decompress src_fd to dst_fd. (Stops at end of bzip2 data,
677 not end of file.) */ 677 not end of file.) */
678STATIC int INIT bunzip2(unsigned char *buf, int len, 678STATIC int INIT bunzip2(unsigned char *buf, long len,
679 int(*fill)(void*, unsigned int), 679 long (*fill)(void*, unsigned long),
680 int(*flush)(void*, unsigned int), 680 long (*flush)(void*, unsigned long),
681 unsigned char *outbuf, 681 unsigned char *outbuf,
682 int *pos, 682 long *pos,
683 void(*error)(char *x)) 683 void(*error)(char *x))
684{ 684{
685 struct bunzip_data *bd; 685 struct bunzip_data *bd;
@@ -743,11 +743,11 @@ exit_0:
743} 743}
744 744
745#ifdef PREBOOT 745#ifdef PREBOOT
746STATIC int INIT decompress(unsigned char *buf, int len, 746STATIC int INIT decompress(unsigned char *buf, long len,
747 int(*fill)(void*, unsigned int), 747 long (*fill)(void*, unsigned long),
748 int(*flush)(void*, unsigned int), 748 long (*flush)(void*, unsigned long),
749 unsigned char *outbuf, 749 unsigned char *outbuf,
750 int *pos, 750 long *pos,
751 void(*error)(char *x)) 751 void(*error)(char *x))
752{ 752{
753 return bunzip2(buf, len - 4, fill, flush, outbuf, pos, error); 753 return bunzip2(buf, len - 4, fill, flush, outbuf, pos, error);
diff --git a/lib/decompress_inflate.c b/lib/decompress_inflate.c
index 0edfd742a154..d4c7891635ec 100644
--- a/lib/decompress_inflate.c
+++ b/lib/decompress_inflate.c
@@ -27,17 +27,17 @@
27 27
28#define GZIP_IOBUF_SIZE (16*1024) 28#define GZIP_IOBUF_SIZE (16*1024)
29 29
30static int INIT nofill(void *buffer, unsigned int len) 30static long INIT nofill(void *buffer, unsigned long len)
31{ 31{
32 return -1; 32 return -1;
33} 33}
34 34
35/* Included from initramfs et al code */ 35/* Included from initramfs et al code */
36STATIC int INIT gunzip(unsigned char *buf, int len, 36STATIC int INIT gunzip(unsigned char *buf, long len,
37 int(*fill)(void*, unsigned int), 37 long (*fill)(void*, unsigned long),
38 int(*flush)(void*, unsigned int), 38 long (*flush)(void*, unsigned long),
39 unsigned char *out_buf, 39 unsigned char *out_buf,
40 int *pos, 40 long *pos,
41 void(*error)(char *x)) { 41 void(*error)(char *x)) {
42 u8 *zbuf; 42 u8 *zbuf;
43 struct z_stream_s *strm; 43 struct z_stream_s *strm;
@@ -142,7 +142,7 @@ STATIC int INIT gunzip(unsigned char *buf, int len,
142 142
143 /* Write any data generated */ 143 /* Write any data generated */
144 if (flush && strm->next_out > out_buf) { 144 if (flush && strm->next_out > out_buf) {
145 int l = strm->next_out - out_buf; 145 long l = strm->next_out - out_buf;
146 if (l != flush(out_buf, l)) { 146 if (l != flush(out_buf, l)) {
147 rc = -1; 147 rc = -1;
148 error("write error"); 148 error("write error");
diff --git a/lib/decompress_unlz4.c b/lib/decompress_unlz4.c
index 7d1e83caf8ad..40f66ebe57b7 100644
--- a/lib/decompress_unlz4.c
+++ b/lib/decompress_unlz4.c
@@ -31,10 +31,10 @@
31#define LZ4_DEFAULT_UNCOMPRESSED_CHUNK_SIZE (8 << 20) 31#define LZ4_DEFAULT_UNCOMPRESSED_CHUNK_SIZE (8 << 20)
32#define ARCHIVE_MAGICNUMBER 0x184C2102 32#define ARCHIVE_MAGICNUMBER 0x184C2102
33 33
34STATIC inline int INIT unlz4(u8 *input, int in_len, 34STATIC inline int INIT unlz4(u8 *input, long in_len,
35 int (*fill) (void *, unsigned int), 35 long (*fill)(void *, unsigned long),
36 int (*flush) (void *, unsigned int), 36 long (*flush)(void *, unsigned long),
37 u8 *output, int *posp, 37 u8 *output, long *posp,
38 void (*error) (char *x)) 38 void (*error) (char *x))
39{ 39{
40 int ret = -1; 40 int ret = -1;
@@ -43,7 +43,7 @@ STATIC inline int INIT unlz4(u8 *input, int in_len,
43 u8 *inp; 43 u8 *inp;
44 u8 *inp_start; 44 u8 *inp_start;
45 u8 *outp; 45 u8 *outp;
46 int size = in_len; 46 long size = in_len;
47#ifdef PREBOOT 47#ifdef PREBOOT
48 size_t out_len = get_unaligned_le32(input + in_len); 48 size_t out_len = get_unaligned_le32(input + in_len);
49#endif 49#endif
@@ -83,13 +83,20 @@ STATIC inline int INIT unlz4(u8 *input, int in_len,
83 if (posp) 83 if (posp)
84 *posp = 0; 84 *posp = 0;
85 85
86 if (fill) 86 if (fill) {
87 fill(inp, 4); 87 size = fill(inp, 4);
88 if (size < 4) {
89 error("data corrupted");
90 goto exit_2;
91 }
92 }
88 93
89 chunksize = get_unaligned_le32(inp); 94 chunksize = get_unaligned_le32(inp);
90 if (chunksize == ARCHIVE_MAGICNUMBER) { 95 if (chunksize == ARCHIVE_MAGICNUMBER) {
91 inp += 4; 96 if (!fill) {
92 size -= 4; 97 inp += 4;
98 size -= 4;
99 }
93 } else { 100 } else {
94 error("invalid header"); 101 error("invalid header");
95 goto exit_2; 102 goto exit_2;
@@ -100,29 +107,44 @@ STATIC inline int INIT unlz4(u8 *input, int in_len,
100 107
101 for (;;) { 108 for (;;) {
102 109
103 if (fill) 110 if (fill) {
104 fill(inp, 4); 111 size = fill(inp, 4);
112 if (size == 0)
113 break;
114 if (size < 4) {
115 error("data corrupted");
116 goto exit_2;
117 }
118 }
105 119
106 chunksize = get_unaligned_le32(inp); 120 chunksize = get_unaligned_le32(inp);
107 if (chunksize == ARCHIVE_MAGICNUMBER) { 121 if (chunksize == ARCHIVE_MAGICNUMBER) {
108 inp += 4; 122 if (!fill) {
109 size -= 4; 123 inp += 4;
124 size -= 4;
125 }
110 if (posp) 126 if (posp)
111 *posp += 4; 127 *posp += 4;
112 continue; 128 continue;
113 } 129 }
114 inp += 4; 130
115 size -= 4;
116 131
117 if (posp) 132 if (posp)
118 *posp += 4; 133 *posp += 4;
119 134
120 if (fill) { 135 if (!fill) {
136 inp += 4;
137 size -= 4;
138 } else {
121 if (chunksize > lz4_compressbound(uncomp_chunksize)) { 139 if (chunksize > lz4_compressbound(uncomp_chunksize)) {
122 error("chunk length is longer than allocated"); 140 error("chunk length is longer than allocated");
123 goto exit_2; 141 goto exit_2;
124 } 142 }
125 fill(inp, chunksize); 143 size = fill(inp, chunksize);
144 if (size < chunksize) {
145 error("data corrupted");
146 goto exit_2;
147 }
126 } 148 }
127#ifdef PREBOOT 149#ifdef PREBOOT
128 if (out_len >= uncomp_chunksize) { 150 if (out_len >= uncomp_chunksize) {
@@ -149,18 +171,17 @@ STATIC inline int INIT unlz4(u8 *input, int in_len,
149 if (posp) 171 if (posp)
150 *posp += chunksize; 172 *posp += chunksize;
151 173
152 size -= chunksize; 174 if (!fill) {
175 size -= chunksize;
153 176
154 if (size == 0) 177 if (size == 0)
155 break; 178 break;
156 else if (size < 0) { 179 else if (size < 0) {
157 error("data corrupted"); 180 error("data corrupted");
158 goto exit_2; 181 goto exit_2;
182 }
183 inp += chunksize;
159 } 184 }
160
161 inp += chunksize;
162 if (fill)
163 inp = inp_start;
164 } 185 }
165 186
166 ret = 0; 187 ret = 0;
@@ -175,11 +196,11 @@ exit_0:
175} 196}
176 197
177#ifdef PREBOOT 198#ifdef PREBOOT
178STATIC int INIT decompress(unsigned char *buf, int in_len, 199STATIC int INIT decompress(unsigned char *buf, long in_len,
179 int(*fill)(void*, unsigned int), 200 long (*fill)(void*, unsigned long),
180 int(*flush)(void*, unsigned int), 201 long (*flush)(void*, unsigned long),
181 unsigned char *output, 202 unsigned char *output,
182 int *posp, 203 long *posp,
183 void(*error)(char *x) 204 void(*error)(char *x)
184 ) 205 )
185{ 206{
diff --git a/lib/decompress_unlzma.c b/lib/decompress_unlzma.c
index 32adb73a9038..0be83af62b88 100644
--- a/lib/decompress_unlzma.c
+++ b/lib/decompress_unlzma.c
@@ -65,11 +65,11 @@ static long long INIT read_int(unsigned char *ptr, int size)
65#define LZMA_IOBUF_SIZE 0x10000 65#define LZMA_IOBUF_SIZE 0x10000
66 66
67struct rc { 67struct rc {
68 int (*fill)(void*, unsigned int); 68 long (*fill)(void*, unsigned long);
69 uint8_t *ptr; 69 uint8_t *ptr;
70 uint8_t *buffer; 70 uint8_t *buffer;
71 uint8_t *buffer_end; 71 uint8_t *buffer_end;
72 int buffer_size; 72 long buffer_size;
73 uint32_t code; 73 uint32_t code;
74 uint32_t range; 74 uint32_t range;
75 uint32_t bound; 75 uint32_t bound;
@@ -82,7 +82,7 @@ struct rc {
82#define RC_MODEL_TOTAL_BITS 11 82#define RC_MODEL_TOTAL_BITS 11
83 83
84 84
85static int INIT nofill(void *buffer, unsigned int len) 85static long INIT nofill(void *buffer, unsigned long len)
86{ 86{
87 return -1; 87 return -1;
88} 88}
@@ -99,8 +99,8 @@ static void INIT rc_read(struct rc *rc)
99 99
100/* Called once */ 100/* Called once */
101static inline void INIT rc_init(struct rc *rc, 101static inline void INIT rc_init(struct rc *rc,
102 int (*fill)(void*, unsigned int), 102 long (*fill)(void*, unsigned long),
103 char *buffer, int buffer_size) 103 char *buffer, long buffer_size)
104{ 104{
105 if (fill) 105 if (fill)
106 rc->fill = fill; 106 rc->fill = fill;
@@ -280,7 +280,7 @@ struct writer {
280 size_t buffer_pos; 280 size_t buffer_pos;
281 int bufsize; 281 int bufsize;
282 size_t global_pos; 282 size_t global_pos;
283 int(*flush)(void*, unsigned int); 283 long (*flush)(void*, unsigned long);
284 struct lzma_header *header; 284 struct lzma_header *header;
285}; 285};
286 286
@@ -534,11 +534,11 @@ static inline int INIT process_bit1(struct writer *wr, struct rc *rc,
534 534
535 535
536 536
537STATIC inline int INIT unlzma(unsigned char *buf, int in_len, 537STATIC inline int INIT unlzma(unsigned char *buf, long in_len,
538 int(*fill)(void*, unsigned int), 538 long (*fill)(void*, unsigned long),
539 int(*flush)(void*, unsigned int), 539 long (*flush)(void*, unsigned long),
540 unsigned char *output, 540 unsigned char *output,
541 int *posp, 541 long *posp,
542 void(*error)(char *x) 542 void(*error)(char *x)
543 ) 543 )
544{ 544{
@@ -667,11 +667,11 @@ exit_0:
667} 667}
668 668
669#ifdef PREBOOT 669#ifdef PREBOOT
670STATIC int INIT decompress(unsigned char *buf, int in_len, 670STATIC int INIT decompress(unsigned char *buf, long in_len,
671 int(*fill)(void*, unsigned int), 671 long (*fill)(void*, unsigned long),
672 int(*flush)(void*, unsigned int), 672 long (*flush)(void*, unsigned long),
673 unsigned char *output, 673 unsigned char *output,
674 int *posp, 674 long *posp,
675 void(*error)(char *x) 675 void(*error)(char *x)
676 ) 676 )
677{ 677{
diff --git a/lib/decompress_unlzo.c b/lib/decompress_unlzo.c
index 960183d4258f..b94a31bdd87d 100644
--- a/lib/decompress_unlzo.c
+++ b/lib/decompress_unlzo.c
@@ -51,7 +51,7 @@ static const unsigned char lzop_magic[] = {
51#define HEADER_SIZE_MIN (9 + 7 + 4 + 8 + 1 + 4) 51#define HEADER_SIZE_MIN (9 + 7 + 4 + 8 + 1 + 4)
52#define HEADER_SIZE_MAX (9 + 7 + 1 + 8 + 8 + 4 + 1 + 255 + 4) 52#define HEADER_SIZE_MAX (9 + 7 + 1 + 8 + 8 + 4 + 1 + 255 + 4)
53 53
54STATIC inline int INIT parse_header(u8 *input, int *skip, int in_len) 54STATIC inline long INIT parse_header(u8 *input, long *skip, long in_len)
55{ 55{
56 int l; 56 int l;
57 u8 *parse = input; 57 u8 *parse = input;
@@ -108,14 +108,14 @@ STATIC inline int INIT parse_header(u8 *input, int *skip, int in_len)
108 return 1; 108 return 1;
109} 109}
110 110
111STATIC inline int INIT unlzo(u8 *input, int in_len, 111STATIC int INIT unlzo(u8 *input, long in_len,
112 int (*fill) (void *, unsigned int), 112 long (*fill)(void *, unsigned long),
113 int (*flush) (void *, unsigned int), 113 long (*flush)(void *, unsigned long),
114 u8 *output, int *posp, 114 u8 *output, long *posp,
115 void (*error) (char *x)) 115 void (*error) (char *x))
116{ 116{
117 u8 r = 0; 117 u8 r = 0;
118 int skip = 0; 118 long skip = 0;
119 u32 src_len, dst_len; 119 u32 src_len, dst_len;
120 size_t tmp; 120 size_t tmp;
121 u8 *in_buf, *in_buf_save, *out_buf; 121 u8 *in_buf, *in_buf_save, *out_buf;
diff --git a/lib/decompress_unxz.c b/lib/decompress_unxz.c
index 9f34eb56854d..b07a78340e9d 100644
--- a/lib/decompress_unxz.c
+++ b/lib/decompress_unxz.c
@@ -248,10 +248,10 @@ void *memmove(void *dest, const void *src, size_t size)
248 * both input and output buffers are available as a single chunk, i.e. when 248 * both input and output buffers are available as a single chunk, i.e. when
249 * fill() and flush() won't be used. 249 * fill() and flush() won't be used.
250 */ 250 */
251STATIC int INIT unxz(unsigned char *in, int in_size, 251STATIC int INIT unxz(unsigned char *in, long in_size,
252 int (*fill)(void *dest, unsigned int size), 252 long (*fill)(void *dest, unsigned long size),
253 int (*flush)(void *src, unsigned int size), 253 long (*flush)(void *src, unsigned long size),
254 unsigned char *out, int *in_used, 254 unsigned char *out, long *in_used,
255 void (*error)(char *x)) 255 void (*error)(char *x))
256{ 256{
257 struct xz_buf b; 257 struct xz_buf b;
@@ -329,7 +329,7 @@ STATIC int INIT unxz(unsigned char *in, int in_size,
329 * returned by xz_dec_run(), but probably 329 * returned by xz_dec_run(), but probably
330 * it's not too bad. 330 * it's not too bad.
331 */ 331 */
332 if (flush(b.out, b.out_pos) != (int)b.out_pos) 332 if (flush(b.out, b.out_pos) != (long)b.out_pos)
333 ret = XZ_BUF_ERROR; 333 ret = XZ_BUF_ERROR;
334 334
335 b.out_pos = 0; 335 b.out_pos = 0;
diff --git a/lib/devres.c b/lib/devres.c
index f562bf6ff71d..f4a195a6efe4 100644
--- a/lib/devres.c
+++ b/lib/devres.c
@@ -86,8 +86,6 @@ void devm_iounmap(struct device *dev, void __iomem *addr)
86} 86}
87EXPORT_SYMBOL(devm_iounmap); 87EXPORT_SYMBOL(devm_iounmap);
88 88
89#define IOMEM_ERR_PTR(err) (__force void __iomem *)ERR_PTR(err)
90
91/** 89/**
92 * devm_ioremap_resource() - check, request region, and ioremap resource 90 * devm_ioremap_resource() - check, request region, and ioremap resource
93 * @dev: generic device to handle the resource for 91 * @dev: generic device to handle the resource for
@@ -142,34 +140,6 @@ void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res)
142} 140}
143EXPORT_SYMBOL(devm_ioremap_resource); 141EXPORT_SYMBOL(devm_ioremap_resource);
144 142
145/**
146 * devm_request_and_ioremap() - Check, request region, and ioremap resource
147 * @dev: Generic device to handle the resource for
148 * @res: resource to be handled
149 *
150 * Takes all necessary steps to ioremap a mem resource. Uses managed device, so
151 * everything is undone on driver detach. Checks arguments, so you can feed
152 * it the result from e.g. platform_get_resource() directly. Returns the
153 * remapped pointer or NULL on error. Usage example:
154 *
155 * res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
156 * base = devm_request_and_ioremap(&pdev->dev, res);
157 * if (!base)
158 * return -EADDRNOTAVAIL;
159 */
160void __iomem *devm_request_and_ioremap(struct device *dev,
161 struct resource *res)
162{
163 void __iomem *dest_ptr;
164
165 dest_ptr = devm_ioremap_resource(dev, res);
166 if (IS_ERR(dest_ptr))
167 return NULL;
168
169 return dest_ptr;
170}
171EXPORT_SYMBOL(devm_request_and_ioremap);
172
173#ifdef CONFIG_HAS_IOPORT_MAP 143#ifdef CONFIG_HAS_IOPORT_MAP
174/* 144/*
175 * Generic iomap devres 145 * Generic iomap devres
diff --git a/lib/dma-debug.c b/lib/dma-debug.c
index 98f2d7e91a91..add80cc02dbe 100644
--- a/lib/dma-debug.c
+++ b/lib/dma-debug.c
@@ -1149,7 +1149,7 @@ static void check_unmap(struct dma_debug_entry *ref)
1149static void check_for_stack(struct device *dev, void *addr) 1149static void check_for_stack(struct device *dev, void *addr)
1150{ 1150{
1151 if (object_is_on_stack(addr)) 1151 if (object_is_on_stack(addr))
1152 err_printk(dev, NULL, "DMA-API: device driver maps memory from" 1152 err_printk(dev, NULL, "DMA-API: device driver maps memory from "
1153 "stack [addr=%p]\n", addr); 1153 "stack [addr=%p]\n", addr);
1154} 1154}
1155 1155
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 7288e38e1757..dfba05521748 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -537,10 +537,9 @@ static char *dynamic_emit_prefix(const struct _ddebug *desc, char *buf)
537 return buf; 537 return buf;
538} 538}
539 539
540int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...) 540void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...)
541{ 541{
542 va_list args; 542 va_list args;
543 int res;
544 struct va_format vaf; 543 struct va_format vaf;
545 char buf[PREFIX_SIZE]; 544 char buf[PREFIX_SIZE];
546 545
@@ -552,21 +551,17 @@ int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...)
552 vaf.fmt = fmt; 551 vaf.fmt = fmt;
553 vaf.va = &args; 552 vaf.va = &args;
554 553
555 res = printk(KERN_DEBUG "%s%pV", 554 printk(KERN_DEBUG "%s%pV", dynamic_emit_prefix(descriptor, buf), &vaf);
556 dynamic_emit_prefix(descriptor, buf), &vaf);
557 555
558 va_end(args); 556 va_end(args);
559
560 return res;
561} 557}
562EXPORT_SYMBOL(__dynamic_pr_debug); 558EXPORT_SYMBOL(__dynamic_pr_debug);
563 559
564int __dynamic_dev_dbg(struct _ddebug *descriptor, 560void __dynamic_dev_dbg(struct _ddebug *descriptor,
565 const struct device *dev, const char *fmt, ...) 561 const struct device *dev, const char *fmt, ...)
566{ 562{
567 struct va_format vaf; 563 struct va_format vaf;
568 va_list args; 564 va_list args;
569 int res;
570 565
571 BUG_ON(!descriptor); 566 BUG_ON(!descriptor);
572 BUG_ON(!fmt); 567 BUG_ON(!fmt);
@@ -577,30 +572,27 @@ int __dynamic_dev_dbg(struct _ddebug *descriptor,
577 vaf.va = &args; 572 vaf.va = &args;
578 573
579 if (!dev) { 574 if (!dev) {
580 res = printk(KERN_DEBUG "(NULL device *): %pV", &vaf); 575 printk(KERN_DEBUG "(NULL device *): %pV", &vaf);
581 } else { 576 } else {
582 char buf[PREFIX_SIZE]; 577 char buf[PREFIX_SIZE];
583 578
584 res = dev_printk_emit(7, dev, "%s%s %s: %pV", 579 dev_printk_emit(7, dev, "%s%s %s: %pV",
585 dynamic_emit_prefix(descriptor, buf), 580 dynamic_emit_prefix(descriptor, buf),
586 dev_driver_string(dev), dev_name(dev), 581 dev_driver_string(dev), dev_name(dev),
587 &vaf); 582 &vaf);
588 } 583 }
589 584
590 va_end(args); 585 va_end(args);
591
592 return res;
593} 586}
594EXPORT_SYMBOL(__dynamic_dev_dbg); 587EXPORT_SYMBOL(__dynamic_dev_dbg);
595 588
596#ifdef CONFIG_NET 589#ifdef CONFIG_NET
597 590
598int __dynamic_netdev_dbg(struct _ddebug *descriptor, 591void __dynamic_netdev_dbg(struct _ddebug *descriptor,
599 const struct net_device *dev, const char *fmt, ...) 592 const struct net_device *dev, const char *fmt, ...)
600{ 593{
601 struct va_format vaf; 594 struct va_format vaf;
602 va_list args; 595 va_list args;
603 int res;
604 596
605 BUG_ON(!descriptor); 597 BUG_ON(!descriptor);
606 BUG_ON(!fmt); 598 BUG_ON(!fmt);
@@ -613,21 +605,21 @@ int __dynamic_netdev_dbg(struct _ddebug *descriptor,
613 if (dev && dev->dev.parent) { 605 if (dev && dev->dev.parent) {
614 char buf[PREFIX_SIZE]; 606 char buf[PREFIX_SIZE];
615 607
616 res = dev_printk_emit(7, dev->dev.parent, 608 dev_printk_emit(7, dev->dev.parent,
617 "%s%s %s %s: %pV", 609 "%s%s %s %s%s: %pV",
618 dynamic_emit_prefix(descriptor, buf), 610 dynamic_emit_prefix(descriptor, buf),
619 dev_driver_string(dev->dev.parent), 611 dev_driver_string(dev->dev.parent),
620 dev_name(dev->dev.parent), 612 dev_name(dev->dev.parent),
621 netdev_name(dev), &vaf); 613 netdev_name(dev), netdev_reg_state(dev),
614 &vaf);
622 } else if (dev) { 615 } else if (dev) {
623 res = printk(KERN_DEBUG "%s: %pV", netdev_name(dev), &vaf); 616 printk(KERN_DEBUG "%s%s: %pV", netdev_name(dev),
617 netdev_reg_state(dev), &vaf);
624 } else { 618 } else {
625 res = printk(KERN_DEBUG "(NULL net_device): %pV", &vaf); 619 printk(KERN_DEBUG "(NULL net_device): %pV", &vaf);
626 } 620 }
627 621
628 va_end(args); 622 va_end(args);
629
630 return res;
631} 623}
632EXPORT_SYMBOL(__dynamic_netdev_dbg); 624EXPORT_SYMBOL(__dynamic_netdev_dbg);
633 625
@@ -827,22 +819,9 @@ static const struct seq_operations ddebug_proc_seqops = {
827 */ 819 */
828static int ddebug_proc_open(struct inode *inode, struct file *file) 820static int ddebug_proc_open(struct inode *inode, struct file *file)
829{ 821{
830 struct ddebug_iter *iter;
831 int err;
832
833 vpr_info("called\n"); 822 vpr_info("called\n");
834 823 return seq_open_private(file, &ddebug_proc_seqops,
835 iter = kzalloc(sizeof(*iter), GFP_KERNEL); 824 sizeof(struct ddebug_iter));
836 if (iter == NULL)
837 return -ENOMEM;
838
839 err = seq_open(file, &ddebug_proc_seqops);
840 if (err) {
841 kfree(iter);
842 return err;
843 }
844 ((struct seq_file *)file->private_data)->private = iter;
845 return 0;
846} 825}
847 826
848static const struct file_operations ddebug_proc_fops = { 827static const struct file_operations ddebug_proc_fops = {
diff --git a/lib/flex_proportions.c b/lib/flex_proportions.c
index ebf3bac460b0..8f25652f40d4 100644
--- a/lib/flex_proportions.c
+++ b/lib/flex_proportions.c
@@ -34,13 +34,13 @@
34 */ 34 */
35#include <linux/flex_proportions.h> 35#include <linux/flex_proportions.h>
36 36
37int fprop_global_init(struct fprop_global *p) 37int fprop_global_init(struct fprop_global *p, gfp_t gfp)
38{ 38{
39 int err; 39 int err;
40 40
41 p->period = 0; 41 p->period = 0;
42 /* Use 1 to avoid dealing with periods with 0 events... */ 42 /* Use 1 to avoid dealing with periods with 0 events... */
43 err = percpu_counter_init(&p->events, 1); 43 err = percpu_counter_init(&p->events, 1, gfp);
44 if (err) 44 if (err)
45 return err; 45 return err;
46 seqcount_init(&p->sequence); 46 seqcount_init(&p->sequence);
@@ -168,11 +168,11 @@ void fprop_fraction_single(struct fprop_global *p,
168 */ 168 */
169#define PROP_BATCH (8*(1+ilog2(nr_cpu_ids))) 169#define PROP_BATCH (8*(1+ilog2(nr_cpu_ids)))
170 170
171int fprop_local_init_percpu(struct fprop_local_percpu *pl) 171int fprop_local_init_percpu(struct fprop_local_percpu *pl, gfp_t gfp)
172{ 172{
173 int err; 173 int err;
174 174
175 err = percpu_counter_init(&pl->events, 0); 175 err = percpu_counter_init(&pl->events, 0, gfp);
176 if (err) 176 if (err)
177 return err; 177 return err;
178 pl->period = 0; 178 pl->period = 0;
diff --git a/lib/fonts/Kconfig b/lib/fonts/Kconfig
index 34fd931b54b5..e77dfe00de36 100644
--- a/lib/fonts/Kconfig
+++ b/lib/fonts/Kconfig
@@ -79,6 +79,14 @@ config FONT_MINI_4x6
79 bool "Mini 4x6 font" 79 bool "Mini 4x6 font"
80 depends on !SPARC && FONTS 80 depends on !SPARC && FONTS
81 81
82config FONT_6x10
83 bool "Medium-size 6x10 font"
84 depends on !SPARC && FONTS
85 help
86 Medium-size console font. Suitable for framebuffer consoles on
87 embedded devices with a 320x240 screen, to get a reasonable number
88 of characters (53x24) that are still at a readable size.
89
82config FONT_SUN8x16 90config FONT_SUN8x16
83 bool "Sparc console 8x16 font" 91 bool "Sparc console 8x16 font"
84 depends on FRAMEBUFFER_CONSOLE && (!SPARC && FONTS || SPARC) 92 depends on FRAMEBUFFER_CONSOLE && (!SPARC && FONTS || SPARC)
@@ -109,6 +117,7 @@ config FONT_AUTOSELECT
109 depends on !FONT_PEARL_8x8 117 depends on !FONT_PEARL_8x8
110 depends on !FONT_ACORN_8x8 118 depends on !FONT_ACORN_8x8
111 depends on !FONT_MINI_4x6 119 depends on !FONT_MINI_4x6
120 depends on !FONT_6x10
112 depends on !FONT_SUN8x16 121 depends on !FONT_SUN8x16
113 depends on !FONT_SUN12x22 122 depends on !FONT_SUN12x22
114 depends on !FONT_10x18 123 depends on !FONT_10x18
diff --git a/lib/fonts/Makefile b/lib/fonts/Makefile
index 2761560f3f15..e04d010cfbf5 100644
--- a/lib/fonts/Makefile
+++ b/lib/fonts/Makefile
@@ -12,6 +12,7 @@ font-objs-$(CONFIG_FONT_10x18) += font_10x18.o
12font-objs-$(CONFIG_FONT_PEARL_8x8) += font_pearl_8x8.o 12font-objs-$(CONFIG_FONT_PEARL_8x8) += font_pearl_8x8.o
13font-objs-$(CONFIG_FONT_ACORN_8x8) += font_acorn_8x8.o 13font-objs-$(CONFIG_FONT_ACORN_8x8) += font_acorn_8x8.o
14font-objs-$(CONFIG_FONT_MINI_4x6) += font_mini_4x6.o 14font-objs-$(CONFIG_FONT_MINI_4x6) += font_mini_4x6.o
15font-objs-$(CONFIG_FONT_6x10) += font_6x10.o
15 16
16font-objs += $(font-objs-y) 17font-objs += $(font-objs-y)
17 18
diff --git a/lib/fonts/font_6x10.c b/lib/fonts/font_6x10.c
new file mode 100644
index 000000000000..b20620904d31
--- /dev/null
+++ b/lib/fonts/font_6x10.c
@@ -0,0 +1,3086 @@
1#include <linux/font.h>
2
3static const unsigned char fontdata_6x10[] = {
4
5 /* 0 0x00 '^@' */
6 0x00, /* 00000000 */
7 0x00, /* 00000000 */
8 0x00, /* 00000000 */
9 0x00, /* 00000000 */
10 0x00, /* 00000000 */
11 0x00, /* 00000000 */
12 0x00, /* 00000000 */
13 0x00, /* 00000000 */
14 0x00, /* 00000000 */
15 0x00, /* 00000000 */
16
17 /* 1 0x01 '^A' */
18 0x00, /* 00000000 */
19 0x78, /* 01111000 */
20 0x84, /* 10000100 */
21 0xCC, /* 11001100 */
22 0x84, /* 10000100 */
23 0xCC, /* 11001100 */
24 0xB4, /* 10110100 */
25 0x78, /* 01111000 */
26 0x00, /* 00000000 */
27 0x00, /* 00000000 */
28
29 /* 2 0x02 '^B' */
30 0x00, /* 00000000 */
31 0x78, /* 01111000 */
32 0xFC, /* 11111100 */
33 0xB4, /* 10110100 */
34 0xFC, /* 11111100 */
35 0xB4, /* 10110100 */
36 0xCC, /* 11001100 */
37 0x78, /* 01111000 */
38 0x00, /* 00000000 */
39 0x00, /* 00000000 */
40
41 /* 3 0x03 '^C' */
42 0x00, /* 00000000 */
43 0x00, /* 00000000 */
44 0x28, /* 00101000 */
45 0x7C, /* 01111100 */
46 0x7C, /* 01111100 */
47 0x38, /* 00111000 */
48 0x10, /* 00010000 */
49 0x00, /* 00000000 */
50 0x00, /* 00000000 */
51 0x00, /* 00000000 */
52
53 /* 4 0x04 '^D' */
54 0x00, /* 00000000 */
55 0x00, /* 00000000 */
56 0x10, /* 00010000 */
57 0x38, /* 00111000 */
58 0x7C, /* 01111100 */
59 0x38, /* 00111000 */
60 0x10, /* 00010000 */
61 0x00, /* 00000000 */
62 0x00, /* 00000000 */
63 0x00, /* 00000000 */
64
65 /* 5 0x05 '^E' */
66 0x00, /* 00000000 */
67 0x00, /* 00000000 */
68 0x38, /* 00111000 */
69 0x38, /* 00111000 */
70 0x6C, /* 01101100 */
71 0x6C, /* 01101100 */
72 0x10, /* 00010000 */
73 0x38, /* 00111000 */
74 0x00, /* 00000000 */
75 0x00, /* 00000000 */
76
77 /* 6 0x06 '^F' */
78 0x00, /* 00000000 */
79 0x00, /* 00000000 */
80 0x10, /* 00010000 */
81 0x38, /* 00111000 */
82 0x7C, /* 01111100 */
83 0x7C, /* 01111100 */
84 0x10, /* 00010000 */
85 0x38, /* 00111000 */
86 0x00, /* 00000000 */
87 0x00, /* 00000000 */
88
89 /* 7 0x07 '^G' */
90 0x00, /* 00000000 */
91 0x00, /* 00000000 */
92 0x00, /* 00000000 */
93 0x30, /* 00110000 */
94 0x78, /* 01111000 */
95 0x30, /* 00110000 */
96 0x00, /* 00000000 */
97 0x00, /* 00000000 */
98 0x00, /* 00000000 */
99 0x00, /* 00000000 */
100
101 /* 8 0x08 '^H' */
102 0xFC, /* 11111100 */
103 0xFC, /* 11111100 */
104 0xFC, /* 11111100 */
105 0xCC, /* 11001100 */
106 0x84, /* 10000100 */
107 0xCC, /* 11001100 */
108 0xFC, /* 11111100 */
109 0xFC, /* 11111100 */
110 0xFC, /* 11111100 */
111 0xFC, /* 11111100 */
112
113 /* 9 0x09 '^I' */
114 0x00, /* 00000000 */
115 0x00, /* 00000000 */
116 0x30, /* 00110000 */
117 0x48, /* 01001000 */
118 0x84, /* 10000100 */
119 0x48, /* 01001000 */
120 0x30, /* 00110000 */
121 0x00, /* 00000000 */
122 0x00, /* 00000000 */
123 0x00, /* 00000000 */
124
125 /* 10 0x0A '^J' */
126 0xFC, /* 11111100 */
127 0xFC, /* 11111100 */
128 0xCC, /* 11001100 */
129 0xB4, /* 10110100 */
130 0x78, /* 01111000 */
131 0xB4, /* 10110100 */
132 0xCC, /* 11001100 */
133 0xFC, /* 11111100 */
134 0xFC, /* 11111100 */
135 0xFC, /* 11111100 */
136
137 /* 11 0x0B '^K' */
138 0x00, /* 00000000 */
139 0x3C, /* 00111100 */
140 0x14, /* 00010100 */
141 0x20, /* 00100000 */
142 0x78, /* 01111000 */
143 0x44, /* 01000100 */
144 0x44, /* 01000100 */
145 0x38, /* 00111000 */
146 0x00, /* 00000000 */
147 0x00, /* 00000000 */
148
149 /* 12 0x0C '^L' */
150 0x00, /* 00000000 */
151 0x38, /* 00111000 */
152 0x44, /* 01000100 */
153 0x44, /* 01000100 */
154 0x38, /* 00111000 */
155 0x10, /* 00010000 */
156 0x38, /* 00111000 */
157 0x10, /* 00010000 */
158 0x00, /* 00000000 */
159 0x00, /* 00000000 */
160
161 /* 13 0x0D '^M' */
162 0x00, /* 00000000 */
163 0x18, /* 00011000 */
164 0x14, /* 00010100 */
165 0x14, /* 00010100 */
166 0x10, /* 00010000 */
167 0x10, /* 00010000 */
168 0x70, /* 01110000 */
169 0x60, /* 01100000 */
170 0x00, /* 00000000 */
171 0x00, /* 00000000 */
172
173 /* 14 0x0E '^N' */
174 0x00, /* 00000000 */
175 0x3C, /* 00111100 */
176 0x24, /* 00100100 */
177 0x3C, /* 00111100 */
178 0x24, /* 00100100 */
179 0x24, /* 00100100 */
180 0x6C, /* 01101100 */
181 0x6C, /* 01101100 */
182 0x00, /* 00000000 */
183 0x00, /* 00000000 */
184
185 /* 15 0x0F '^O' */
186 0x00, /* 00000000 */
187 0x10, /* 00010000 */
188 0x54, /* 01010100 */
189 0x38, /* 00111000 */
190 0x6C, /* 01101100 */
191 0x38, /* 00111000 */
192 0x54, /* 01010100 */
193 0x10, /* 00010000 */
194 0x00, /* 00000000 */
195 0x00, /* 00000000 */
196
197 /* 16 0x10 '^P' */
198 0x00, /* 00000000 */
199 0x40, /* 01000000 */
200 0x60, /* 01100000 */
201 0x70, /* 01110000 */
202 0x78, /* 01111000 */
203 0x70, /* 01110000 */
204 0x60, /* 01100000 */
205 0x40, /* 01000000 */
206 0x00, /* 00000000 */
207 0x00, /* 00000000 */
208
209 /* 17 0x11 '^Q' */
210 0x00, /* 00000000 */
211 0x04, /* 00000100 */
212 0x0C, /* 00001100 */
213 0x1C, /* 00011100 */
214 0x3C, /* 00111100 */
215 0x1C, /* 00011100 */
216 0x0C, /* 00001100 */
217 0x04, /* 00000100 */
218 0x00, /* 00000000 */
219 0x00, /* 00000000 */
220
221 /* 18 0x12 '^R' */
222 0x00, /* 00000000 */
223 0x10, /* 00010000 */
224 0x38, /* 00111000 */
225 0x54, /* 01010100 */
226 0x10, /* 00010000 */
227 0x54, /* 01010100 */
228 0x38, /* 00111000 */
229 0x10, /* 00010000 */
230 0x00, /* 00000000 */
231 0x00, /* 00000000 */
232
233 /* 19 0x13 '^S' */
234 0x00, /* 00000000 */
235 0x48, /* 01001000 */
236 0x48, /* 01001000 */
237 0x48, /* 01001000 */
238 0x48, /* 01001000 */
239 0x48, /* 01001000 */
240 0x00, /* 00000000 */
241 0x48, /* 01001000 */
242 0x00, /* 00000000 */
243 0x00, /* 00000000 */
244
245 /* 20 0x14 '^T' */
246 0x3C, /* 00111100 */
247 0x54, /* 01010100 */
248 0x54, /* 01010100 */
249 0x54, /* 01010100 */
250 0x3C, /* 00111100 */
251 0x14, /* 00010100 */
252 0x14, /* 00010100 */
253 0x14, /* 00010100 */
254 0x00, /* 00000000 */
255 0x00, /* 00000000 */
256
257 /* 21 0x15 '^U' */
258 0x38, /* 00111000 */
259 0x44, /* 01000100 */
260 0x20, /* 00100000 */
261 0x50, /* 01010000 */
262 0x48, /* 01001000 */
263 0x24, /* 00100100 */
264 0x14, /* 00010100 */
265 0x08, /* 00001000 */
266 0x44, /* 01000100 */
267 0x38, /* 00111000 */
268
269 /* 22 0x16 '^V' */
270 0x00, /* 00000000 */
271 0x00, /* 00000000 */
272 0x00, /* 00000000 */
273 0x00, /* 00000000 */
274 0x00, /* 00000000 */
275 0xF8, /* 11111000 */
276 0xF8, /* 11111000 */
277 0xF8, /* 11111000 */
278 0x00, /* 00000000 */
279 0x00, /* 00000000 */
280
281 /* 23 0x17 '^W' */
282 0x00, /* 00000000 */
283 0x10, /* 00010000 */
284 0x38, /* 00111000 */
285 0x54, /* 01010100 */
286 0x10, /* 00010000 */
287 0x54, /* 01010100 */
288 0x38, /* 00111000 */
289 0x10, /* 00010000 */
290 0x7C, /* 01111100 */
291 0x00, /* 00000000 */
292
293 /* 24 0x18 '^X' */
294 0x00, /* 00000000 */
295 0x10, /* 00010000 */
296 0x38, /* 00111000 */
297 0x54, /* 01010100 */
298 0x10, /* 00010000 */
299 0x10, /* 00010000 */
300 0x10, /* 00010000 */
301 0x10, /* 00010000 */
302 0x00, /* 00000000 */
303 0x00, /* 00000000 */
304
305 /* 25 0x19 '^Y' */
306 0x00, /* 00000000 */
307 0x10, /* 00010000 */
308 0x10, /* 00010000 */
309 0x10, /* 00010000 */
310 0x10, /* 00010000 */
311 0x54, /* 01010100 */
312 0x38, /* 00111000 */
313 0x10, /* 00010000 */
314 0x00, /* 00000000 */
315 0x00, /* 00000000 */
316
317 /* 26 0x1A '^Z' */
318 0x00, /* 00000000 */
319 0x00, /* 00000000 */
320 0x10, /* 00010000 */
321 0x08, /* 00001000 */
322 0x7C, /* 01111100 */
323 0x08, /* 00001000 */
324 0x10, /* 00010000 */
325 0x00, /* 00000000 */
326 0x00, /* 00000000 */
327 0x00, /* 00000000 */
328
329 /* 27 0x1B '^[' */
330 0x00, /* 00000000 */
331 0x00, /* 00000000 */
332 0x10, /* 00010000 */
333 0x20, /* 00100000 */
334 0x7C, /* 01111100 */
335 0x20, /* 00100000 */
336 0x10, /* 00010000 */
337 0x00, /* 00000000 */
338 0x00, /* 00000000 */
339 0x00, /* 00000000 */
340
341 /* 28 0x1C '^\' */
342 0x00, /* 00000000 */
343 0x00, /* 00000000 */
344 0x00, /* 00000000 */
345 0x00, /* 00000000 */
346 0x40, /* 01000000 */
347 0x40, /* 01000000 */
348 0x40, /* 01000000 */
349 0x78, /* 01111000 */
350 0x00, /* 00000000 */
351 0x00, /* 00000000 */
352
353 /* 29 0x1D '^]' */
354 0x00, /* 00000000 */
355 0x00, /* 00000000 */
356 0x48, /* 01001000 */
357 0x84, /* 10000100 */
358 0xFC, /* 11111100 */
359 0x84, /* 10000100 */
360 0x48, /* 01001000 */
361 0x00, /* 00000000 */
362 0x00, /* 00000000 */
363 0x00, /* 00000000 */
364
365 /* 30 0x1E '^^' */
366 0x00, /* 00000000 */
367 0x00, /* 00000000 */
368 0x10, /* 00010000 */
369 0x10, /* 00010000 */
370 0x38, /* 00111000 */
371 0x38, /* 00111000 */
372 0x7C, /* 01111100 */
373 0x7C, /* 01111100 */
374 0x00, /* 00000000 */
375 0x00, /* 00000000 */
376
377 /* 31 0x1F '^_' */
378 0x00, /* 00000000 */
379 0x00, /* 00000000 */
380 0x7C, /* 01111100 */
381 0x7C, /* 01111100 */
382 0x38, /* 00111000 */
383 0x38, /* 00111000 */
384 0x10, /* 00010000 */
385 0x10, /* 00010000 */
386 0x00, /* 00000000 */
387 0x00, /* 00000000 */
388
389 /* 32 0x20 ' ' */
390 0x00, /* 00000000 */
391 0x00, /* 00000000 */
392 0x00, /* 00000000 */
393 0x00, /* 00000000 */
394 0x00, /* 00000000 */
395 0x00, /* 00000000 */
396 0x00, /* 00000000 */
397 0x00, /* 00000000 */
398 0x00, /* 00000000 */
399 0x00, /* 00000000 */
400
401 /* 33 0x21 '!' */
402 0x00, /* 00000000 */
403 0x10, /* 00010000 */
404 0x10, /* 00010000 */
405 0x10, /* 00010000 */
406 0x10, /* 00010000 */
407 0x10, /* 00010000 */
408 0x00, /* 00000000 */
409 0x10, /* 00010000 */
410 0x00, /* 00000000 */
411 0x00, /* 00000000 */
412
413 /* 34 0x22 '"' */
414 0x28, /* 00101000 */
415 0x28, /* 00101000 */
416 0x28, /* 00101000 */
417 0x00, /* 00000000 */
418 0x00, /* 00000000 */
419 0x00, /* 00000000 */
420 0x00, /* 00000000 */
421 0x00, /* 00000000 */
422 0x00, /* 00000000 */
423 0x00, /* 00000000 */
424
425 /* 35 0x23 '#' */
426 0x00, /* 00000000 */
427 0x00, /* 00000000 */
428 0x28, /* 00101000 */
429 0x7C, /* 01111100 */
430 0x28, /* 00101000 */
431 0x28, /* 00101000 */
432 0x7C, /* 01111100 */
433 0x28, /* 00101000 */
434 0x00, /* 00000000 */
435 0x00, /* 00000000 */
436
437 /* 36 0x24 '$' */
438 0x10, /* 00010000 */
439 0x38, /* 00111000 */
440 0x54, /* 01010100 */
441 0x50, /* 01010000 */
442 0x38, /* 00111000 */
443 0x14, /* 00010100 */
444 0x54, /* 01010100 */
445 0x38, /* 00111000 */
446 0x10, /* 00010000 */
447 0x00, /* 00000000 */
448
449 /* 37 0x25 '%' */
450 0x00, /* 00000000 */
451 0x64, /* 01100100 */
452 0x64, /* 01100100 */
453 0x08, /* 00001000 */
454 0x10, /* 00010000 */
455 0x20, /* 00100000 */
456 0x4C, /* 01001100 */
457 0x4C, /* 01001100 */
458 0x00, /* 00000000 */
459 0x00, /* 00000000 */
460
461 /* 38 0x26 '&' */
462 0x00, /* 00000000 */
463 0x30, /* 00110000 */
464 0x48, /* 01001000 */
465 0x50, /* 01010000 */
466 0x20, /* 00100000 */
467 0x54, /* 01010100 */
468 0x48, /* 01001000 */
469 0x34, /* 00110100 */
470 0x00, /* 00000000 */
471 0x00, /* 00000000 */
472
473 /* 39 0x27 ''' */
474 0x10, /* 00010000 */
475 0x10, /* 00010000 */
476 0x10, /* 00010000 */
477 0x00, /* 00000000 */
478 0x00, /* 00000000 */
479 0x00, /* 00000000 */
480 0x00, /* 00000000 */
481 0x00, /* 00000000 */
482 0x00, /* 00000000 */
483 0x00, /* 00000000 */
484
485 /* 40 0x28 '(' */
486 0x08, /* 00001000 */
487 0x10, /* 00010000 */
488 0x20, /* 00100000 */
489 0x20, /* 00100000 */
490 0x20, /* 00100000 */
491 0x20, /* 00100000 */
492 0x20, /* 00100000 */
493 0x10, /* 00010000 */
494 0x08, /* 00001000 */
495 0x00, /* 00000000 */
496
497 /* 41 0x29 ')' */
498 0x20, /* 00100000 */
499 0x10, /* 00010000 */
500 0x08, /* 00001000 */
501 0x08, /* 00001000 */
502 0x08, /* 00001000 */
503 0x08, /* 00001000 */
504 0x08, /* 00001000 */
505 0x10, /* 00010000 */
506 0x20, /* 00100000 */
507 0x00, /* 00000000 */
508
509 /* 42 0x2A '*' */
510 0x00, /* 00000000 */
511 0x10, /* 00010000 */
512 0x54, /* 01010100 */
513 0x38, /* 00111000 */
514 0x54, /* 01010100 */
515 0x10, /* 00010000 */
516 0x00, /* 00000000 */
517 0x00, /* 00000000 */
518 0x00, /* 00000000 */
519 0x00, /* 00000000 */
520
521 /* 43 0x2B '+' */
522 0x00, /* 00000000 */
523 0x00, /* 00000000 */
524 0x10, /* 00010000 */
525 0x10, /* 00010000 */
526 0x7C, /* 01111100 */
527 0x10, /* 00010000 */
528 0x10, /* 00010000 */
529 0x00, /* 00000000 */
530 0x00, /* 00000000 */
531 0x00, /* 00000000 */
532
533 /* 44 0x2C ',' */
534 0x00, /* 00000000 */
535 0x00, /* 00000000 */
536 0x00, /* 00000000 */
537 0x00, /* 00000000 */
538 0x00, /* 00000000 */
539 0x00, /* 00000000 */
540 0x30, /* 00110000 */
541 0x30, /* 00110000 */
542 0x10, /* 00010000 */
543 0x20, /* 00100000 */
544
545 /* 45 0x2D '-' */
546 0x00, /* 00000000 */
547 0x00, /* 00000000 */
548 0x00, /* 00000000 */
549 0x00, /* 00000000 */
550 0x7C, /* 01111100 */
551 0x00, /* 00000000 */
552 0x00, /* 00000000 */
553 0x00, /* 00000000 */
554 0x00, /* 00000000 */
555 0x00, /* 00000000 */
556
557 /* 46 0x2E '.' */
558 0x00, /* 00000000 */
559 0x00, /* 00000000 */
560 0x00, /* 00000000 */
561 0x00, /* 00000000 */
562 0x00, /* 00000000 */
563 0x00, /* 00000000 */
564 0x18, /* 00011000 */
565 0x18, /* 00011000 */
566 0x00, /* 00000000 */
567 0x00, /* 00000000 */
568
569 /* 47 0x2F '/' */
570 0x04, /* 00000100 */
571 0x04, /* 00000100 */
572 0x08, /* 00001000 */
573 0x08, /* 00001000 */
574 0x10, /* 00010000 */
575 0x10, /* 00010000 */
576 0x20, /* 00100000 */
577 0x20, /* 00100000 */
578 0x40, /* 01000000 */
579 0x40, /* 01000000 */
580
581 /* 48 0x30 '0' */
582 0x00, /* 00000000 */
583 0x38, /* 00111000 */
584 0x44, /* 01000100 */
585 0x4C, /* 01001100 */
586 0x54, /* 01010100 */
587 0x64, /* 01100100 */
588 0x44, /* 01000100 */
589 0x38, /* 00111000 */
590 0x00, /* 00000000 */
591 0x00, /* 00000000 */
592
593 /* 49 0x31 '1' */
594 0x00, /* 00000000 */
595 0x10, /* 00010000 */
596 0x30, /* 00110000 */
597 0x50, /* 01010000 */
598 0x10, /* 00010000 */
599 0x10, /* 00010000 */
600 0x10, /* 00010000 */
601 0x7C, /* 01111100 */
602 0x00, /* 00000000 */
603 0x00, /* 00000000 */
604
605 /* 50 0x32 '2' */
606 0x00, /* 00000000 */
607 0x38, /* 00111000 */
608 0x44, /* 01000100 */
609 0x04, /* 00000100 */
610 0x08, /* 00001000 */
611 0x10, /* 00010000 */
612 0x20, /* 00100000 */
613 0x7C, /* 01111100 */
614 0x00, /* 00000000 */
615 0x00, /* 00000000 */
616
617 /* 51 0x33 '3' */
618 0x00, /* 00000000 */
619 0x38, /* 00111000 */
620 0x44, /* 01000100 */
621 0x04, /* 00000100 */
622 0x18, /* 00011000 */
623 0x04, /* 00000100 */
624 0x44, /* 01000100 */
625 0x38, /* 00111000 */
626 0x00, /* 00000000 */
627 0x00, /* 00000000 */
628
629 /* 52 0x34 '4' */
630 0x00, /* 00000000 */
631 0x08, /* 00001000 */
632 0x18, /* 00011000 */
633 0x28, /* 00101000 */
634 0x48, /* 01001000 */
635 0x7C, /* 01111100 */
636 0x08, /* 00001000 */
637 0x08, /* 00001000 */
638 0x00, /* 00000000 */
639 0x00, /* 00000000 */
640
641 /* 53 0x35 '5' */
642 0x00, /* 00000000 */
643 0x7C, /* 01111100 */
644 0x40, /* 01000000 */
645 0x78, /* 01111000 */
646 0x04, /* 00000100 */
647 0x04, /* 00000100 */
648 0x44, /* 01000100 */
649 0x38, /* 00111000 */
650 0x00, /* 00000000 */
651 0x00, /* 00000000 */
652
653 /* 54 0x36 '6' */
654 0x00, /* 00000000 */
655 0x18, /* 00011000 */
656 0x20, /* 00100000 */
657 0x40, /* 01000000 */
658 0x78, /* 01111000 */
659 0x44, /* 01000100 */
660 0x44, /* 01000100 */
661 0x38, /* 00111000 */
662 0x00, /* 00000000 */
663 0x00, /* 00000000 */
664
665 /* 55 0x37 '7' */
666 0x00, /* 00000000 */
667 0x7C, /* 01111100 */
668 0x04, /* 00000100 */
669 0x04, /* 00000100 */
670 0x08, /* 00001000 */
671 0x10, /* 00010000 */
672 0x10, /* 00010000 */
673 0x10, /* 00010000 */
674 0x00, /* 00000000 */
675 0x00, /* 00000000 */
676
677 /* 56 0x38 '8' */
678 0x00, /* 00000000 */
679 0x38, /* 00111000 */
680 0x44, /* 01000100 */
681 0x44, /* 01000100 */
682 0x38, /* 00111000 */
683 0x44, /* 01000100 */
684 0x44, /* 01000100 */
685 0x38, /* 00111000 */
686 0x00, /* 00000000 */
687 0x00, /* 00000000 */
688
689 /* 57 0x39 '9' */
690 0x00, /* 00000000 */
691 0x38, /* 00111000 */
692 0x44, /* 01000100 */
693 0x44, /* 01000100 */
694 0x3C, /* 00111100 */
695 0x04, /* 00000100 */
696 0x08, /* 00001000 */
697 0x30, /* 00110000 */
698 0x00, /* 00000000 */
699 0x00, /* 00000000 */
700
701 /* 58 0x3A ':' */
702 0x00, /* 00000000 */
703 0x00, /* 00000000 */
704 0x00, /* 00000000 */
705 0x18, /* 00011000 */
706 0x18, /* 00011000 */
707 0x00, /* 00000000 */
708 0x18, /* 00011000 */
709 0x18, /* 00011000 */
710 0x00, /* 00000000 */
711 0x00, /* 00000000 */
712
713 /* 59 0x3B ';' */
714 0x00, /* 00000000 */
715 0x00, /* 00000000 */
716 0x00, /* 00000000 */
717 0x30, /* 00110000 */
718 0x30, /* 00110000 */
719 0x00, /* 00000000 */
720 0x30, /* 00110000 */
721 0x30, /* 00110000 */
722 0x10, /* 00010000 */
723 0x20, /* 00100000 */
724
725 /* 60 0x3C '<' */
726 0x00, /* 00000000 */
727 0x04, /* 00000100 */
728 0x08, /* 00001000 */
729 0x10, /* 00010000 */
730 0x20, /* 00100000 */
731 0x10, /* 00010000 */
732 0x08, /* 00001000 */
733 0x04, /* 00000100 */
734 0x00, /* 00000000 */
735 0x00, /* 00000000 */
736
737 /* 61 0x3D '=' */
738 0x00, /* 00000000 */
739 0x00, /* 00000000 */
740 0x00, /* 00000000 */
741 0x7C, /* 01111100 */
742 0x00, /* 00000000 */
743 0x7C, /* 01111100 */
744 0x00, /* 00000000 */
745 0x00, /* 00000000 */
746 0x00, /* 00000000 */
747 0x00, /* 00000000 */
748
749 /* 62 0x3E '>' */
750 0x00, /* 00000000 */
751 0x20, /* 00100000 */
752 0x10, /* 00010000 */
753 0x08, /* 00001000 */
754 0x04, /* 00000100 */
755 0x08, /* 00001000 */
756 0x10, /* 00010000 */
757 0x20, /* 00100000 */
758 0x00, /* 00000000 */
759 0x00, /* 00000000 */
760
761 /* 63 0x3F '?' */
762 0x00, /* 00000000 */
763 0x38, /* 00111000 */
764 0x44, /* 01000100 */
765 0x04, /* 00000100 */
766 0x08, /* 00001000 */
767 0x10, /* 00010000 */
768 0x00, /* 00000000 */
769 0x10, /* 00010000 */
770 0x00, /* 00000000 */
771 0x00, /* 00000000 */
772
773 /* 64 0x40 '@' */
774 0x00, /* 00000000 */
775 0x38, /* 00111000 */
776 0x44, /* 01000100 */
777 0x5C, /* 01011100 */
778 0x54, /* 01010100 */
779 0x5C, /* 01011100 */
780 0x40, /* 01000000 */
781 0x38, /* 00111000 */
782 0x00, /* 00000000 */
783 0x00, /* 00000000 */
784
785 /* 65 0x41 'A' */
786 0x00, /* 00000000 */
787 0x10, /* 00010000 */
788 0x28, /* 00101000 */
789 0x44, /* 01000100 */
790 0x44, /* 01000100 */
791 0x7C, /* 01111100 */
792 0x44, /* 01000100 */
793 0x44, /* 01000100 */
794 0x00, /* 00000000 */
795 0x00, /* 00000000 */
796
797 /* 66 0x42 'B' */
798 0x00, /* 00000000 */
799 0x78, /* 01111000 */
800 0x24, /* 00100100 */
801 0x24, /* 00100100 */
802 0x38, /* 00111000 */
803 0x24, /* 00100100 */
804 0x24, /* 00100100 */
805 0x78, /* 01111000 */
806 0x00, /* 00000000 */
807 0x00, /* 00000000 */
808
809 /* 67 0x43 'C' */
810 0x00, /* 00000000 */
811 0x38, /* 00111000 */
812 0x44, /* 01000100 */
813 0x40, /* 01000000 */
814 0x40, /* 01000000 */
815 0x40, /* 01000000 */
816 0x44, /* 01000100 */
817 0x38, /* 00111000 */
818 0x00, /* 00000000 */
819 0x00, /* 00000000 */
820
821 /* 68 0x44 'D' */
822 0x00, /* 00000000 */
823 0x78, /* 01111000 */
824 0x24, /* 00100100 */
825 0x24, /* 00100100 */
826 0x24, /* 00100100 */
827 0x24, /* 00100100 */
828 0x24, /* 00100100 */
829 0x78, /* 01111000 */
830 0x00, /* 00000000 */
831 0x00, /* 00000000 */
832
833 /* 69 0x45 'E' */
834 0x00, /* 00000000 */
835 0x7C, /* 01111100 */
836 0x40, /* 01000000 */
837 0x40, /* 01000000 */
838 0x78, /* 01111000 */
839 0x40, /* 01000000 */
840 0x40, /* 01000000 */
841 0x7C, /* 01111100 */
842 0x00, /* 00000000 */
843 0x00, /* 00000000 */
844
845 /* 70 0x46 'F' */
846 0x00, /* 00000000 */
847 0x7C, /* 01111100 */
848 0x40, /* 01000000 */
849 0x40, /* 01000000 */
850 0x78, /* 01111000 */
851 0x40, /* 01000000 */
852 0x40, /* 01000000 */
853 0x40, /* 01000000 */
854 0x00, /* 00000000 */
855 0x00, /* 00000000 */
856
857 /* 71 0x47 'G' */
858 0x00, /* 00000000 */
859 0x38, /* 00111000 */
860 0x44, /* 01000100 */
861 0x40, /* 01000000 */
862 0x5C, /* 01011100 */
863 0x44, /* 01000100 */
864 0x44, /* 01000100 */
865 0x38, /* 00111000 */
866 0x00, /* 00000000 */
867 0x00, /* 00000000 */
868
869 /* 72 0x48 'H' */
870 0x00, /* 00000000 */
871 0x44, /* 01000100 */
872 0x44, /* 01000100 */
873 0x44, /* 01000100 */
874 0x7C, /* 01111100 */
875 0x44, /* 01000100 */
876 0x44, /* 01000100 */
877 0x44, /* 01000100 */
878 0x00, /* 00000000 */
879 0x00, /* 00000000 */
880
881 /* 73 0x49 'I' */
882 0x00, /* 00000000 */
883 0x38, /* 00111000 */
884 0x10, /* 00010000 */
885 0x10, /* 00010000 */
886 0x10, /* 00010000 */
887 0x10, /* 00010000 */
888 0x10, /* 00010000 */
889 0x38, /* 00111000 */
890 0x00, /* 00000000 */
891 0x00, /* 00000000 */
892
893 /* 74 0x4A 'J' */
894 0x00, /* 00000000 */
895 0x1C, /* 00011100 */
896 0x08, /* 00001000 */
897 0x08, /* 00001000 */
898 0x08, /* 00001000 */
899 0x48, /* 01001000 */
900 0x48, /* 01001000 */
901 0x30, /* 00110000 */
902 0x00, /* 00000000 */
903 0x00, /* 00000000 */
904
905 /* 75 0x4B 'K' */
906 0x00, /* 00000000 */
907 0x44, /* 01000100 */
908 0x48, /* 01001000 */
909 0x50, /* 01010000 */
910 0x60, /* 01100000 */
911 0x50, /* 01010000 */
912 0x48, /* 01001000 */
913 0x44, /* 01000100 */
914 0x00, /* 00000000 */
915 0x00, /* 00000000 */
916
917 /* 76 0x4C 'L' */
918 0x00, /* 00000000 */
919 0x40, /* 01000000 */
920 0x40, /* 01000000 */
921 0x40, /* 01000000 */
922 0x40, /* 01000000 */
923 0x40, /* 01000000 */
924 0x40, /* 01000000 */
925 0x7C, /* 01111100 */
926 0x00, /* 00000000 */
927 0x00, /* 00000000 */
928
929 /* 77 0x4D 'M' */
930 0x00, /* 00000000 */
931 0x44, /* 01000100 */
932 0x6C, /* 01101100 */
933 0x54, /* 01010100 */
934 0x54, /* 01010100 */
935 0x44, /* 01000100 */
936 0x44, /* 01000100 */
937 0x44, /* 01000100 */
938 0x00, /* 00000000 */
939 0x00, /* 00000000 */
940
941 /* 78 0x4E 'N' */
942 0x00, /* 00000000 */
943 0x44, /* 01000100 */
944 0x64, /* 01100100 */
945 0x54, /* 01010100 */
946 0x4C, /* 01001100 */
947 0x44, /* 01000100 */
948 0x44, /* 01000100 */
949 0x44, /* 01000100 */
950 0x00, /* 00000000 */
951 0x00, /* 00000000 */
952
953 /* 79 0x4F 'O' */
954 0x00, /* 00000000 */
955 0x38, /* 00111000 */
956 0x44, /* 01000100 */
957 0x44, /* 01000100 */
958 0x44, /* 01000100 */
959 0x44, /* 01000100 */
960 0x44, /* 01000100 */
961 0x38, /* 00111000 */
962 0x00, /* 00000000 */
963 0x00, /* 00000000 */
964
965 /* 80 0x50 'P' */
966 0x00, /* 00000000 */
967 0x78, /* 01111000 */
968 0x44, /* 01000100 */
969 0x44, /* 01000100 */
970 0x78, /* 01111000 */
971 0x40, /* 01000000 */
972 0x40, /* 01000000 */
973 0x40, /* 01000000 */
974 0x00, /* 00000000 */
975 0x00, /* 00000000 */
976
977 /* 81 0x51 'Q' */
978 0x00, /* 00000000 */
979 0x38, /* 00111000 */
980 0x44, /* 01000100 */
981 0x44, /* 01000100 */
982 0x44, /* 01000100 */
983 0x54, /* 01010100 */
984 0x48, /* 01001000 */
985 0x34, /* 00110100 */
986 0x00, /* 00000000 */
987 0x00, /* 00000000 */
988
989 /* 82 0x52 'R' */
990 0x00, /* 00000000 */
991 0x78, /* 01111000 */
992 0x44, /* 01000100 */
993 0x44, /* 01000100 */
994 0x78, /* 01111000 */
995 0x50, /* 01010000 */
996 0x48, /* 01001000 */
997 0x44, /* 01000100 */
998 0x00, /* 00000000 */
999 0x00, /* 00000000 */
1000
1001 /* 83 0x53 'S' */
1002 0x00, /* 00000000 */
1003 0x38, /* 00111000 */
1004 0x44, /* 01000100 */
1005 0x40, /* 01000000 */
1006 0x38, /* 00111000 */
1007 0x04, /* 00000100 */
1008 0x44, /* 01000100 */
1009 0x38, /* 00111000 */
1010 0x00, /* 00000000 */
1011 0x00, /* 00000000 */
1012
1013 /* 84 0x54 'T' */
1014 0x00, /* 00000000 */
1015 0x7C, /* 01111100 */
1016 0x10, /* 00010000 */
1017 0x10, /* 00010000 */
1018 0x10, /* 00010000 */
1019 0x10, /* 00010000 */
1020 0x10, /* 00010000 */
1021 0x10, /* 00010000 */
1022 0x00, /* 00000000 */
1023 0x00, /* 00000000 */
1024
1025 /* 85 0x55 'U' */
1026 0x00, /* 00000000 */
1027 0x44, /* 01000100 */
1028 0x44, /* 01000100 */
1029 0x44, /* 01000100 */
1030 0x44, /* 01000100 */
1031 0x44, /* 01000100 */
1032 0x44, /* 01000100 */
1033 0x38, /* 00111000 */
1034 0x00, /* 00000000 */
1035 0x00, /* 00000000 */
1036
1037 /* 86 0x56 'V' */
1038 0x00, /* 00000000 */
1039 0x44, /* 01000100 */
1040 0x44, /* 01000100 */
1041 0x44, /* 01000100 */
1042 0x44, /* 01000100 */
1043 0x44, /* 01000100 */
1044 0x28, /* 00101000 */
1045 0x10, /* 00010000 */
1046 0x00, /* 00000000 */
1047 0x00, /* 00000000 */
1048
1049 /* 87 0x57 'W' */
1050 0x00, /* 00000000 */
1051 0x44, /* 01000100 */
1052 0x44, /* 01000100 */
1053 0x44, /* 01000100 */
1054 0x54, /* 01010100 */
1055 0x54, /* 01010100 */
1056 0x6C, /* 01101100 */
1057 0x44, /* 01000100 */
1058 0x00, /* 00000000 */
1059 0x00, /* 00000000 */
1060
1061 /* 88 0x58 'X' */
1062 0x00, /* 00000000 */
1063 0x44, /* 01000100 */
1064 0x44, /* 01000100 */
1065 0x28, /* 00101000 */
1066 0x10, /* 00010000 */
1067 0x28, /* 00101000 */
1068 0x44, /* 01000100 */
1069 0x44, /* 01000100 */
1070 0x00, /* 00000000 */
1071 0x00, /* 00000000 */
1072
1073 /* 89 0x59 'Y' */
1074 0x00, /* 00000000 */
1075 0x44, /* 01000100 */
1076 0x44, /* 01000100 */
1077 0x44, /* 01000100 */
1078 0x28, /* 00101000 */
1079 0x10, /* 00010000 */
1080 0x10, /* 00010000 */
1081 0x10, /* 00010000 */
1082 0x00, /* 00000000 */
1083 0x00, /* 00000000 */
1084
1085 /* 90 0x5A 'Z' */
1086 0x00, /* 00000000 */
1087 0x7C, /* 01111100 */
1088 0x04, /* 00000100 */
1089 0x08, /* 00001000 */
1090 0x10, /* 00010000 */
1091 0x20, /* 00100000 */
1092 0x40, /* 01000000 */
1093 0x7C, /* 01111100 */
1094 0x00, /* 00000000 */
1095 0x00, /* 00000000 */
1096
1097 /* 91 0x5B '[' */
1098 0x18, /* 00011000 */
1099 0x10, /* 00010000 */
1100 0x10, /* 00010000 */
1101 0x10, /* 00010000 */
1102 0x10, /* 00010000 */
1103 0x10, /* 00010000 */
1104 0x10, /* 00010000 */
1105 0x10, /* 00010000 */
1106 0x18, /* 00011000 */
1107 0x00, /* 00000000 */
1108
1109 /* 92 0x5C '\' */
1110 0x40, /* 01000000 */
1111 0x40, /* 01000000 */
1112 0x20, /* 00100000 */
1113 0x20, /* 00100000 */
1114 0x10, /* 00010000 */
1115 0x10, /* 00010000 */
1116 0x08, /* 00001000 */
1117 0x08, /* 00001000 */
1118 0x04, /* 00000100 */
1119 0x04, /* 00000100 */
1120
1121 /* 93 0x5D ']' */
1122 0x30, /* 00110000 */
1123 0x10, /* 00010000 */
1124 0x10, /* 00010000 */
1125 0x10, /* 00010000 */
1126 0x10, /* 00010000 */
1127 0x10, /* 00010000 */
1128 0x10, /* 00010000 */
1129 0x10, /* 00010000 */
1130 0x30, /* 00110000 */
1131 0x00, /* 00000000 */
1132
1133 /* 94 0x5E '^' */
1134 0x00, /* 00000000 */
1135 0x10, /* 00010000 */
1136 0x28, /* 00101000 */
1137 0x44, /* 01000100 */
1138 0x00, /* 00000000 */
1139 0x00, /* 00000000 */
1140 0x00, /* 00000000 */
1141 0x00, /* 00000000 */
1142 0x00, /* 00000000 */
1143 0x00, /* 00000000 */
1144
1145 /* 95 0x5F '_' */
1146 0x00, /* 00000000 */
1147 0x00, /* 00000000 */
1148 0x00, /* 00000000 */
1149 0x00, /* 00000000 */
1150 0x00, /* 00000000 */
1151 0x00, /* 00000000 */
1152 0x00, /* 00000000 */
1153 0x00, /* 00000000 */
1154 0x7C, /* 01111100 */
1155 0x00, /* 00000000 */
1156
1157 /* 96 0x60 '`' */
1158 0x20, /* 00100000 */
1159 0x10, /* 00010000 */
1160 0x08, /* 00001000 */
1161 0x00, /* 00000000 */
1162 0x00, /* 00000000 */
1163 0x00, /* 00000000 */
1164 0x00, /* 00000000 */
1165 0x00, /* 00000000 */
1166 0x00, /* 00000000 */
1167 0x00, /* 00000000 */
1168
1169 /* 97 0x61 'a' */
1170 0x00, /* 00000000 */
1171 0x00, /* 00000000 */
1172 0x00, /* 00000000 */
1173 0x38, /* 00111000 */
1174 0x04, /* 00000100 */
1175 0x3C, /* 00111100 */
1176 0x44, /* 01000100 */
1177 0x3C, /* 00111100 */
1178 0x00, /* 00000000 */
1179 0x00, /* 00000000 */
1180
1181 /* 98 0x62 'b' */
1182 0x00, /* 00000000 */
1183 0x40, /* 01000000 */
1184 0x40, /* 01000000 */
1185 0x58, /* 01011000 */
1186 0x64, /* 01100100 */
1187 0x44, /* 01000100 */
1188 0x64, /* 01100100 */
1189 0x58, /* 01011000 */
1190 0x00, /* 00000000 */
1191 0x00, /* 00000000 */
1192
1193 /* 99 0x63 'c' */
1194 0x00, /* 00000000 */
1195 0x00, /* 00000000 */
1196 0x00, /* 00000000 */
1197 0x38, /* 00111000 */
1198 0x44, /* 01000100 */
1199 0x40, /* 01000000 */
1200 0x44, /* 01000100 */
1201 0x38, /* 00111000 */
1202 0x00, /* 00000000 */
1203 0x00, /* 00000000 */
1204
1205 /* 100 0x64 'd' */
1206 0x00, /* 00000000 */
1207 0x04, /* 00000100 */
1208 0x04, /* 00000100 */
1209 0x34, /* 00110100 */
1210 0x4C, /* 01001100 */
1211 0x44, /* 01000100 */
1212 0x4C, /* 01001100 */
1213 0x34, /* 00110100 */
1214 0x00, /* 00000000 */
1215 0x00, /* 00000000 */
1216
1217 /* 101 0x65 'e' */
1218 0x00, /* 00000000 */
1219 0x00, /* 00000000 */
1220 0x00, /* 00000000 */
1221 0x38, /* 00111000 */
1222 0x44, /* 01000100 */
1223 0x7C, /* 01111100 */
1224 0x40, /* 01000000 */
1225 0x3C, /* 00111100 */
1226 0x00, /* 00000000 */
1227 0x00, /* 00000000 */
1228
1229 /* 102 0x66 'f' */
1230 0x00, /* 00000000 */
1231 0x0C, /* 00001100 */
1232 0x10, /* 00010000 */
1233 0x10, /* 00010000 */
1234 0x38, /* 00111000 */
1235 0x10, /* 00010000 */
1236 0x10, /* 00010000 */
1237 0x10, /* 00010000 */
1238 0x00, /* 00000000 */
1239 0x00, /* 00000000 */
1240
1241 /* 103 0x67 'g' */
1242 0x00, /* 00000000 */
1243 0x00, /* 00000000 */
1244 0x00, /* 00000000 */
1245 0x34, /* 00110100 */
1246 0x4C, /* 01001100 */
1247 0x44, /* 01000100 */
1248 0x4C, /* 01001100 */
1249 0x34, /* 00110100 */
1250 0x04, /* 00000100 */
1251 0x38, /* 00111000 */
1252
1253 /* 104 0x68 'h' */
1254 0x00, /* 00000000 */
1255 0x40, /* 01000000 */
1256 0x40, /* 01000000 */
1257 0x78, /* 01111000 */
1258 0x44, /* 01000100 */
1259 0x44, /* 01000100 */
1260 0x44, /* 01000100 */
1261 0x44, /* 01000100 */
1262 0x00, /* 00000000 */
1263 0x00, /* 00000000 */
1264
1265 /* 105 0x69 'i' */
1266 0x00, /* 00000000 */
1267 0x10, /* 00010000 */
1268 0x00, /* 00000000 */
1269 0x30, /* 00110000 */
1270 0x10, /* 00010000 */
1271 0x10, /* 00010000 */
1272 0x10, /* 00010000 */
1273 0x38, /* 00111000 */
1274 0x00, /* 00000000 */
1275 0x00, /* 00000000 */
1276
1277 /* 106 0x6A 'j' */
1278 0x00, /* 00000000 */
1279 0x10, /* 00010000 */
1280 0x00, /* 00000000 */
1281 0x30, /* 00110000 */
1282 0x10, /* 00010000 */
1283 0x10, /* 00010000 */
1284 0x10, /* 00010000 */
1285 0x10, /* 00010000 */
1286 0x10, /* 00010000 */
1287 0x60, /* 01100000 */
1288
1289 /* 107 0x6B 'k' */
1290 0x00, /* 00000000 */
1291 0x40, /* 01000000 */
1292 0x40, /* 01000000 */
1293 0x48, /* 01001000 */
1294 0x50, /* 01010000 */
1295 0x70, /* 01110000 */
1296 0x48, /* 01001000 */
1297 0x44, /* 01000100 */
1298 0x00, /* 00000000 */
1299 0x00, /* 00000000 */
1300
1301 /* 108 0x6C 'l' */
1302 0x00, /* 00000000 */
1303 0x30, /* 00110000 */
1304 0x10, /* 00010000 */
1305 0x10, /* 00010000 */
1306 0x10, /* 00010000 */
1307 0x10, /* 00010000 */
1308 0x10, /* 00010000 */
1309 0x38, /* 00111000 */
1310 0x00, /* 00000000 */
1311 0x00, /* 00000000 */
1312
1313 /* 109 0x6D 'm' */
1314 0x00, /* 00000000 */
1315 0x00, /* 00000000 */
1316 0x00, /* 00000000 */
1317 0x68, /* 01101000 */
1318 0x54, /* 01010100 */
1319 0x54, /* 01010100 */
1320 0x54, /* 01010100 */
1321 0x54, /* 01010100 */
1322 0x00, /* 00000000 */
1323 0x00, /* 00000000 */
1324
1325 /* 110 0x6E 'n' */
1326 0x00, /* 00000000 */
1327 0x00, /* 00000000 */
1328 0x00, /* 00000000 */
1329 0x58, /* 01011000 */
1330 0x64, /* 01100100 */
1331 0x44, /* 01000100 */
1332 0x44, /* 01000100 */
1333 0x44, /* 01000100 */
1334 0x00, /* 00000000 */
1335 0x00, /* 00000000 */
1336
1337 /* 111 0x6F 'o' */
1338 0x00, /* 00000000 */
1339 0x00, /* 00000000 */
1340 0x00, /* 00000000 */
1341 0x38, /* 00111000 */
1342 0x44, /* 01000100 */
1343 0x44, /* 01000100 */
1344 0x44, /* 01000100 */
1345 0x38, /* 00111000 */
1346 0x00, /* 00000000 */
1347 0x00, /* 00000000 */
1348
1349 /* 112 0x70 'p' */
1350 0x00, /* 00000000 */
1351 0x00, /* 00000000 */
1352 0x00, /* 00000000 */
1353 0x58, /* 01011000 */
1354 0x64, /* 01100100 */
1355 0x44, /* 01000100 */
1356 0x64, /* 01100100 */
1357 0x58, /* 01011000 */
1358 0x40, /* 01000000 */
1359 0x40, /* 01000000 */
1360
1361 /* 113 0x71 'q' */
1362 0x00, /* 00000000 */
1363 0x00, /* 00000000 */
1364 0x00, /* 00000000 */
1365 0x34, /* 00110100 */
1366 0x4C, /* 01001100 */
1367 0x44, /* 01000100 */
1368 0x4C, /* 01001100 */
1369 0x34, /* 00110100 */
1370 0x04, /* 00000100 */
1371 0x04, /* 00000100 */
1372
1373 /* 114 0x72 'r' */
1374 0x00, /* 00000000 */
1375 0x00, /* 00000000 */
1376 0x00, /* 00000000 */
1377 0x58, /* 01011000 */
1378 0x64, /* 01100100 */
1379 0x40, /* 01000000 */
1380 0x40, /* 01000000 */
1381 0x40, /* 01000000 */
1382 0x00, /* 00000000 */
1383 0x00, /* 00000000 */
1384
1385 /* 115 0x73 's' */
1386 0x00, /* 00000000 */
1387 0x00, /* 00000000 */
1388 0x00, /* 00000000 */
1389 0x3C, /* 00111100 */
1390 0x40, /* 01000000 */
1391 0x38, /* 00111000 */
1392 0x04, /* 00000100 */
1393 0x78, /* 01111000 */
1394 0x00, /* 00000000 */
1395 0x00, /* 00000000 */
1396
1397 /* 116 0x74 't' */
1398 0x00, /* 00000000 */
1399 0x10, /* 00010000 */
1400 0x10, /* 00010000 */
1401 0x38, /* 00111000 */
1402 0x10, /* 00010000 */
1403 0x10, /* 00010000 */
1404 0x10, /* 00010000 */
1405 0x0C, /* 00001100 */
1406 0x00, /* 00000000 */
1407 0x00, /* 00000000 */
1408
1409 /* 117 0x75 'u' */
1410 0x00, /* 00000000 */
1411 0x00, /* 00000000 */
1412 0x00, /* 00000000 */
1413 0x44, /* 01000100 */
1414 0x44, /* 01000100 */
1415 0x44, /* 01000100 */
1416 0x4C, /* 01001100 */
1417 0x34, /* 00110100 */
1418 0x00, /* 00000000 */
1419 0x00, /* 00000000 */
1420
1421 /* 118 0x76 'v' */
1422 0x00, /* 00000000 */
1423 0x00, /* 00000000 */
1424 0x00, /* 00000000 */
1425 0x44, /* 01000100 */
1426 0x44, /* 01000100 */
1427 0x44, /* 01000100 */
1428 0x28, /* 00101000 */
1429 0x10, /* 00010000 */
1430 0x00, /* 00000000 */
1431 0x00, /* 00000000 */
1432
1433 /* 119 0x77 'w' */
1434 0x00, /* 00000000 */
1435 0x00, /* 00000000 */
1436 0x00, /* 00000000 */
1437 0x54, /* 01010100 */
1438 0x54, /* 01010100 */
1439 0x54, /* 01010100 */
1440 0x54, /* 01010100 */
1441 0x28, /* 00101000 */
1442 0x00, /* 00000000 */
1443 0x00, /* 00000000 */
1444
1445 /* 120 0x78 'x' */
1446 0x00, /* 00000000 */
1447 0x00, /* 00000000 */
1448 0x00, /* 00000000 */
1449 0x44, /* 01000100 */
1450 0x28, /* 00101000 */
1451 0x10, /* 00010000 */
1452 0x28, /* 00101000 */
1453 0x44, /* 01000100 */
1454 0x00, /* 00000000 */
1455 0x00, /* 00000000 */
1456
1457 /* 121 0x79 'y' */
1458 0x00, /* 00000000 */
1459 0x00, /* 00000000 */
1460 0x00, /* 00000000 */
1461 0x44, /* 01000100 */
1462 0x44, /* 01000100 */
1463 0x44, /* 01000100 */
1464 0x44, /* 01000100 */
1465 0x3C, /* 00111100 */
1466 0x04, /* 00000100 */
1467 0x38, /* 00111000 */
1468
1469 /* 122 0x7A 'z' */
1470 0x00, /* 00000000 */
1471 0x00, /* 00000000 */
1472 0x00, /* 00000000 */
1473 0x7C, /* 01111100 */
1474 0x08, /* 00001000 */
1475 0x10, /* 00010000 */
1476 0x20, /* 00100000 */
1477 0x7C, /* 01111100 */
1478 0x00, /* 00000000 */
1479 0x00, /* 00000000 */
1480
1481 /* 123 0x7B '{' */
1482 0x08, /* 00001000 */
1483 0x10, /* 00010000 */
1484 0x10, /* 00010000 */
1485 0x10, /* 00010000 */
1486 0x20, /* 00100000 */
1487 0x10, /* 00010000 */
1488 0x10, /* 00010000 */
1489 0x10, /* 00010000 */
1490 0x08, /* 00001000 */
1491 0x00, /* 00000000 */
1492
1493 /* 124 0x7C '|' */
1494 0x10, /* 00010000 */
1495 0x10, /* 00010000 */
1496 0x10, /* 00010000 */
1497 0x10, /* 00010000 */
1498 0x00, /* 00000000 */
1499 0x10, /* 00010000 */
1500 0x10, /* 00010000 */
1501 0x10, /* 00010000 */
1502 0x10, /* 00010000 */
1503 0x00, /* 00000000 */
1504
1505 /* 125 0x7D '}' */
1506 0x20, /* 00100000 */
1507 0x10, /* 00010000 */
1508 0x10, /* 00010000 */
1509 0x10, /* 00010000 */
1510 0x08, /* 00001000 */
1511 0x10, /* 00010000 */
1512 0x10, /* 00010000 */
1513 0x10, /* 00010000 */
1514 0x20, /* 00100000 */
1515 0x00, /* 00000000 */
1516
1517 /* 126 0x7E '~' */
1518 0x00, /* 00000000 */
1519 0x00, /* 00000000 */
1520 0x00, /* 00000000 */
1521 0x00, /* 00000000 */
1522 0x20, /* 00100000 */
1523 0x54, /* 01010100 */
1524 0x08, /* 00001000 */
1525 0x00, /* 00000000 */
1526 0x00, /* 00000000 */
1527 0x00, /* 00000000 */
1528
1529 /* 127 0x7F '' */
1530 0x00, /* 00000000 */
1531 0x00, /* 00000000 */
1532 0x00, /* 00000000 */
1533 0x10, /* 00010000 */
1534 0x28, /* 00101000 */
1535 0x44, /* 01000100 */
1536 0x44, /* 01000100 */
1537 0x7C, /* 01111100 */
1538 0x00, /* 00000000 */
1539 0x00, /* 00000000 */
1540
1541 /* 128 0x80 '\200' */
1542 0x00, /* 00000000 */
1543 0x38, /* 00111000 */
1544 0x44, /* 01000100 */
1545 0x40, /* 01000000 */
1546 0x40, /* 01000000 */
1547 0x40, /* 01000000 */
1548 0x44, /* 01000100 */
1549 0x38, /* 00111000 */
1550 0x10, /* 00010000 */
1551 0x20, /* 00100000 */
1552
1553 /* 129 0x81 '\201' */
1554 0x00, /* 00000000 */
1555 0x28, /* 00101000 */
1556 0x00, /* 00000000 */
1557 0x44, /* 01000100 */
1558 0x44, /* 01000100 */
1559 0x44, /* 01000100 */
1560 0x4C, /* 01001100 */
1561 0x34, /* 00110100 */
1562 0x00, /* 00000000 */
1563 0x00, /* 00000000 */
1564
1565 /* 130 0x82 '\202' */
1566 0x08, /* 00001000 */
1567 0x10, /* 00010000 */
1568 0x00, /* 00000000 */
1569 0x38, /* 00111000 */
1570 0x44, /* 01000100 */
1571 0x7C, /* 01111100 */
1572 0x40, /* 01000000 */
1573 0x3C, /* 00111100 */
1574 0x00, /* 00000000 */
1575 0x00, /* 00000000 */
1576
1577 /* 131 0x83 '\203' */
1578 0x10, /* 00010000 */
1579 0x28, /* 00101000 */
1580 0x00, /* 00000000 */
1581 0x38, /* 00111000 */
1582 0x04, /* 00000100 */
1583 0x3C, /* 00111100 */
1584 0x44, /* 01000100 */
1585 0x3C, /* 00111100 */
1586 0x00, /* 00000000 */
1587 0x00, /* 00000000 */
1588
1589 /* 132 0x84 '\204' */
1590 0x00, /* 00000000 */
1591 0x28, /* 00101000 */
1592 0x00, /* 00000000 */
1593 0x38, /* 00111000 */
1594 0x04, /* 00000100 */
1595 0x3C, /* 00111100 */
1596 0x44, /* 01000100 */
1597 0x3C, /* 00111100 */
1598 0x00, /* 00000000 */
1599 0x00, /* 00000000 */
1600
1601 /* 133 0x85 '\205' */
1602 0x10, /* 00010000 */
1603 0x08, /* 00001000 */
1604 0x00, /* 00000000 */
1605 0x38, /* 00111000 */
1606 0x04, /* 00000100 */
1607 0x3C, /* 00111100 */
1608 0x44, /* 01000100 */
1609 0x3C, /* 00111100 */
1610 0x00, /* 00000000 */
1611 0x00, /* 00000000 */
1612
1613 /* 134 0x86 '\206' */
1614 0x18, /* 00011000 */
1615 0x24, /* 00100100 */
1616 0x18, /* 00011000 */
1617 0x38, /* 00111000 */
1618 0x04, /* 00000100 */
1619 0x3C, /* 00111100 */
1620 0x44, /* 01000100 */
1621 0x3C, /* 00111100 */
1622 0x00, /* 00000000 */
1623 0x00, /* 00000000 */
1624
1625 /* 135 0x87 '\207' */
1626 0x00, /* 00000000 */
1627 0x00, /* 00000000 */
1628 0x00, /* 00000000 */
1629 0x38, /* 00111000 */
1630 0x44, /* 01000100 */
1631 0x40, /* 01000000 */
1632 0x44, /* 01000100 */
1633 0x38, /* 00111000 */
1634 0x10, /* 00010000 */
1635 0x20, /* 00100000 */
1636
1637 /* 136 0x88 '\210' */
1638 0x10, /* 00010000 */
1639 0x28, /* 00101000 */
1640 0x00, /* 00000000 */
1641 0x38, /* 00111000 */
1642 0x44, /* 01000100 */
1643 0x7C, /* 01111100 */
1644 0x40, /* 01000000 */
1645 0x3C, /* 00111100 */
1646 0x00, /* 00000000 */
1647 0x00, /* 00000000 */
1648
1649 /* 137 0x89 '\211' */
1650 0x00, /* 00000000 */
1651 0x28, /* 00101000 */
1652 0x00, /* 00000000 */
1653 0x38, /* 00111000 */
1654 0x44, /* 01000100 */
1655 0x7C, /* 01111100 */
1656 0x40, /* 01000000 */
1657 0x3C, /* 00111100 */
1658 0x00, /* 00000000 */
1659 0x00, /* 00000000 */
1660
1661 /* 138 0x8A '\212' */
1662 0x20, /* 00100000 */
1663 0x10, /* 00010000 */
1664 0x00, /* 00000000 */
1665 0x38, /* 00111000 */
1666 0x44, /* 01000100 */
1667 0x7C, /* 01111100 */
1668 0x40, /* 01000000 */
1669 0x3C, /* 00111100 */
1670 0x00, /* 00000000 */
1671 0x00, /* 00000000 */
1672
1673 /* 139 0x8B '\213' */
1674 0x00, /* 00000000 */
1675 0x28, /* 00101000 */
1676 0x00, /* 00000000 */
1677 0x30, /* 00110000 */
1678 0x10, /* 00010000 */
1679 0x10, /* 00010000 */
1680 0x10, /* 00010000 */
1681 0x38, /* 00111000 */
1682 0x00, /* 00000000 */
1683 0x00, /* 00000000 */
1684
1685 /* 140 0x8C '\214' */
1686 0x10, /* 00010000 */
1687 0x28, /* 00101000 */
1688 0x00, /* 00000000 */
1689 0x30, /* 00110000 */
1690 0x10, /* 00010000 */
1691 0x10, /* 00010000 */
1692 0x10, /* 00010000 */
1693 0x38, /* 00111000 */
1694 0x00, /* 00000000 */
1695 0x00, /* 00000000 */
1696
1697 /* 141 0x8D '\215' */
1698 0x20, /* 00100000 */
1699 0x10, /* 00010000 */
1700 0x00, /* 00000000 */
1701 0x30, /* 00110000 */
1702 0x10, /* 00010000 */
1703 0x10, /* 00010000 */
1704 0x10, /* 00010000 */
1705 0x38, /* 00111000 */
1706 0x00, /* 00000000 */
1707 0x00, /* 00000000 */
1708
1709 /* 142 0x8E '\216' */
1710 0x44, /* 01000100 */
1711 0x10, /* 00010000 */
1712 0x28, /* 00101000 */
1713 0x44, /* 01000100 */
1714 0x44, /* 01000100 */
1715 0x7C, /* 01111100 */
1716 0x44, /* 01000100 */
1717 0x44, /* 01000100 */
1718 0x00, /* 00000000 */
1719 0x00, /* 00000000 */
1720
1721 /* 143 0x8F '\217' */
1722 0x30, /* 00110000 */
1723 0x48, /* 01001000 */
1724 0x38, /* 00111000 */
1725 0x44, /* 01000100 */
1726 0x44, /* 01000100 */
1727 0x7C, /* 01111100 */
1728 0x44, /* 01000100 */
1729 0x44, /* 01000100 */
1730 0x00, /* 00000000 */
1731 0x00, /* 00000000 */
1732
1733 /* 144 0x90 '\220' */
1734 0x10, /* 00010000 */
1735 0x7C, /* 01111100 */
1736 0x40, /* 01000000 */
1737 0x40, /* 01000000 */
1738 0x78, /* 01111000 */
1739 0x40, /* 01000000 */
1740 0x40, /* 01000000 */
1741 0x7C, /* 01111100 */
1742 0x00, /* 00000000 */
1743 0x00, /* 00000000 */
1744
1745 /* 145 0x91 '\221' */
1746 0x00, /* 00000000 */
1747 0x00, /* 00000000 */
1748 0x00, /* 00000000 */
1749 0x78, /* 01111000 */
1750 0x14, /* 00010100 */
1751 0x7C, /* 01111100 */
1752 0x50, /* 01010000 */
1753 0x3C, /* 00111100 */
1754 0x00, /* 00000000 */
1755 0x00, /* 00000000 */
1756
1757 /* 146 0x92 '\222' */
1758 0x00, /* 00000000 */
1759 0x3C, /* 00111100 */
1760 0x50, /* 01010000 */
1761 0x50, /* 01010000 */
1762 0x78, /* 01111000 */
1763 0x50, /* 01010000 */
1764 0x50, /* 01010000 */
1765 0x5C, /* 01011100 */
1766 0x00, /* 00000000 */
1767 0x00, /* 00000000 */
1768
1769 /* 147 0x93 '\223' */
1770 0x10, /* 00010000 */
1771 0x28, /* 00101000 */
1772 0x00, /* 00000000 */
1773 0x38, /* 00111000 */
1774 0x44, /* 01000100 */
1775 0x44, /* 01000100 */
1776 0x44, /* 01000100 */
1777 0x38, /* 00111000 */
1778 0x00, /* 00000000 */
1779 0x00, /* 00000000 */
1780
1781 /* 148 0x94 '\224' */
1782 0x00, /* 00000000 */
1783 0x28, /* 00101000 */
1784 0x00, /* 00000000 */
1785 0x38, /* 00111000 */
1786 0x44, /* 01000100 */
1787 0x44, /* 01000100 */
1788 0x44, /* 01000100 */
1789 0x38, /* 00111000 */
1790 0x00, /* 00000000 */
1791 0x00, /* 00000000 */
1792
1793 /* 149 0x95 '\225' */
1794 0x20, /* 00100000 */
1795 0x10, /* 00010000 */
1796 0x00, /* 00000000 */
1797 0x38, /* 00111000 */
1798 0x44, /* 01000100 */
1799 0x44, /* 01000100 */
1800 0x44, /* 01000100 */
1801 0x38, /* 00111000 */
1802 0x00, /* 00000000 */
1803 0x00, /* 00000000 */
1804
1805 /* 150 0x96 '\226' */
1806 0x10, /* 00010000 */
1807 0x28, /* 00101000 */
1808 0x00, /* 00000000 */
1809 0x44, /* 01000100 */
1810 0x44, /* 01000100 */
1811 0x44, /* 01000100 */
1812 0x4C, /* 01001100 */
1813 0x34, /* 00110100 */
1814 0x00, /* 00000000 */
1815 0x00, /* 00000000 */
1816
1817 /* 151 0x97 '\227' */
1818 0x20, /* 00100000 */
1819 0x10, /* 00010000 */
1820 0x00, /* 00000000 */
1821 0x44, /* 01000100 */
1822 0x44, /* 01000100 */
1823 0x44, /* 01000100 */
1824 0x4C, /* 01001100 */
1825 0x34, /* 00110100 */
1826 0x00, /* 00000000 */
1827 0x00, /* 00000000 */
1828
1829 /* 152 0x98 '\230' */
1830 0x00, /* 00000000 */
1831 0x28, /* 00101000 */
1832 0x00, /* 00000000 */
1833 0x44, /* 01000100 */
1834 0x44, /* 01000100 */
1835 0x44, /* 01000100 */
1836 0x44, /* 01000100 */
1837 0x3C, /* 00111100 */
1838 0x04, /* 00000100 */
1839 0x38, /* 00111000 */
1840
1841 /* 153 0x99 '\231' */
1842 0x84, /* 10000100 */
1843 0x38, /* 00111000 */
1844 0x44, /* 01000100 */
1845 0x44, /* 01000100 */
1846 0x44, /* 01000100 */
1847 0x44, /* 01000100 */
1848 0x44, /* 01000100 */
1849 0x38, /* 00111000 */
1850 0x00, /* 00000000 */
1851 0x00, /* 00000000 */
1852
1853 /* 154 0x9A '\232' */
1854 0x88, /* 10001000 */
1855 0x44, /* 01000100 */
1856 0x44, /* 01000100 */
1857 0x44, /* 01000100 */
1858 0x44, /* 01000100 */
1859 0x44, /* 01000100 */
1860 0x44, /* 01000100 */
1861 0x38, /* 00111000 */
1862 0x00, /* 00000000 */
1863 0x00, /* 00000000 */
1864
1865 /* 155 0x9B '\233' */
1866 0x00, /* 00000000 */
1867 0x00, /* 00000000 */
1868 0x10, /* 00010000 */
1869 0x38, /* 00111000 */
1870 0x54, /* 01010100 */
1871 0x50, /* 01010000 */
1872 0x54, /* 01010100 */
1873 0x38, /* 00111000 */
1874 0x10, /* 00010000 */
1875 0x00, /* 00000000 */
1876
1877 /* 156 0x9C '\234' */
1878 0x30, /* 00110000 */
1879 0x48, /* 01001000 */
1880 0x40, /* 01000000 */
1881 0x70, /* 01110000 */
1882 0x40, /* 01000000 */
1883 0x40, /* 01000000 */
1884 0x44, /* 01000100 */
1885 0x78, /* 01111000 */
1886 0x00, /* 00000000 */
1887 0x00, /* 00000000 */
1888
1889 /* 157 0x9D '\235' */
1890 0x00, /* 00000000 */
1891 0x44, /* 01000100 */
1892 0x28, /* 00101000 */
1893 0x7C, /* 01111100 */
1894 0x10, /* 00010000 */
1895 0x7C, /* 01111100 */
1896 0x10, /* 00010000 */
1897 0x10, /* 00010000 */
1898 0x00, /* 00000000 */
1899 0x00, /* 00000000 */
1900
1901 /* 158 0x9E '\236' */
1902 0x00, /* 00000000 */
1903 0x70, /* 01110000 */
1904 0x48, /* 01001000 */
1905 0x70, /* 01110000 */
1906 0x48, /* 01001000 */
1907 0x5C, /* 01011100 */
1908 0x48, /* 01001000 */
1909 0x44, /* 01000100 */
1910 0x00, /* 00000000 */
1911 0x00, /* 00000000 */
1912
1913 /* 159 0x9F '\237' */
1914 0x00, /* 00000000 */
1915 0x0C, /* 00001100 */
1916 0x10, /* 00010000 */
1917 0x10, /* 00010000 */
1918 0x38, /* 00111000 */
1919 0x10, /* 00010000 */
1920 0x10, /* 00010000 */
1921 0x60, /* 01100000 */
1922 0x00, /* 00000000 */
1923 0x00, /* 00000000 */
1924
1925 /* 160 0xA0 '\240' */
1926 0x08, /* 00001000 */
1927 0x10, /* 00010000 */
1928 0x00, /* 00000000 */
1929 0x38, /* 00111000 */
1930 0x04, /* 00000100 */
1931 0x3C, /* 00111100 */
1932 0x44, /* 01000100 */
1933 0x3C, /* 00111100 */
1934 0x00, /* 00000000 */
1935 0x00, /* 00000000 */
1936
1937 /* 161 0xA1 '\241' */
1938 0x08, /* 00001000 */
1939 0x10, /* 00010000 */
1940 0x00, /* 00000000 */
1941 0x30, /* 00110000 */
1942 0x10, /* 00010000 */
1943 0x10, /* 00010000 */
1944 0x10, /* 00010000 */
1945 0x38, /* 00111000 */
1946 0x00, /* 00000000 */
1947 0x00, /* 00000000 */
1948
1949 /* 162 0xA2 '\242' */
1950 0x08, /* 00001000 */
1951 0x10, /* 00010000 */
1952 0x00, /* 00000000 */
1953 0x38, /* 00111000 */
1954 0x44, /* 01000100 */
1955 0x44, /* 01000100 */
1956 0x44, /* 01000100 */
1957 0x38, /* 00111000 */
1958 0x00, /* 00000000 */
1959 0x00, /* 00000000 */
1960
1961 /* 163 0xA3 '\243' */
1962 0x08, /* 00001000 */
1963 0x10, /* 00010000 */
1964 0x00, /* 00000000 */
1965 0x44, /* 01000100 */
1966 0x44, /* 01000100 */
1967 0x44, /* 01000100 */
1968 0x4C, /* 01001100 */
1969 0x34, /* 00110100 */
1970 0x00, /* 00000000 */
1971 0x00, /* 00000000 */
1972
1973 /* 164 0xA4 '\244' */
1974 0x34, /* 00110100 */
1975 0x58, /* 01011000 */
1976 0x00, /* 00000000 */
1977 0x58, /* 01011000 */
1978 0x64, /* 01100100 */
1979 0x44, /* 01000100 */
1980 0x44, /* 01000100 */
1981 0x44, /* 01000100 */
1982 0x00, /* 00000000 */
1983 0x00, /* 00000000 */
1984
1985 /* 165 0xA5 '\245' */
1986 0x58, /* 01011000 */
1987 0x44, /* 01000100 */
1988 0x64, /* 01100100 */
1989 0x54, /* 01010100 */
1990 0x4C, /* 01001100 */
1991 0x44, /* 01000100 */
1992 0x44, /* 01000100 */
1993 0x44, /* 01000100 */
1994 0x00, /* 00000000 */
1995 0x00, /* 00000000 */
1996
1997 /* 166 0xA6 '\246' */
1998 0x00, /* 00000000 */
1999 0x38, /* 00111000 */
2000 0x04, /* 00000100 */
2001 0x3C, /* 00111100 */
2002 0x44, /* 01000100 */
2003 0x3C, /* 00111100 */
2004 0x00, /* 00000000 */
2005 0x7C, /* 01111100 */
2006 0x00, /* 00000000 */
2007 0x00, /* 00000000 */
2008
2009 /* 167 0xA7 '\247' */
2010 0x00, /* 00000000 */
2011 0x38, /* 00111000 */
2012 0x44, /* 01000100 */
2013 0x44, /* 01000100 */
2014 0x44, /* 01000100 */
2015 0x38, /* 00111000 */
2016 0x00, /* 00000000 */
2017 0x7C, /* 01111100 */
2018 0x00, /* 00000000 */
2019 0x00, /* 00000000 */
2020
2021 /* 168 0xA8 '\250' */
2022 0x00, /* 00000000 */
2023 0x10, /* 00010000 */
2024 0x00, /* 00000000 */
2025 0x10, /* 00010000 */
2026 0x20, /* 00100000 */
2027 0x40, /* 01000000 */
2028 0x44, /* 01000100 */
2029 0x38, /* 00111000 */
2030 0x00, /* 00000000 */
2031 0x00, /* 00000000 */
2032
2033 /* 169 0xA9 '\251' */
2034 0x00, /* 00000000 */
2035 0x00, /* 00000000 */
2036 0x00, /* 00000000 */
2037 0x00, /* 00000000 */
2038 0x7C, /* 01111100 */
2039 0x40, /* 01000000 */
2040 0x40, /* 01000000 */
2041 0x00, /* 00000000 */
2042 0x00, /* 00000000 */
2043 0x00, /* 00000000 */
2044
2045 /* 170 0xAA '\252' */
2046 0x00, /* 00000000 */
2047 0x00, /* 00000000 */
2048 0x00, /* 00000000 */
2049 0x00, /* 00000000 */
2050 0x7C, /* 01111100 */
2051 0x04, /* 00000100 */
2052 0x04, /* 00000100 */
2053 0x00, /* 00000000 */
2054 0x00, /* 00000000 */
2055 0x00, /* 00000000 */
2056
2057 /* 171 0xAB '\253' */
2058 0x20, /* 00100000 */
2059 0x60, /* 01100000 */
2060 0x24, /* 00100100 */
2061 0x28, /* 00101000 */
2062 0x10, /* 00010000 */
2063 0x28, /* 00101000 */
2064 0x44, /* 01000100 */
2065 0x08, /* 00001000 */
2066 0x1C, /* 00011100 */
2067 0x00, /* 00000000 */
2068
2069 /* 172 0xAC '\254' */
2070 0x20, /* 00100000 */
2071 0x60, /* 01100000 */
2072 0x24, /* 00100100 */
2073 0x28, /* 00101000 */
2074 0x10, /* 00010000 */
2075 0x28, /* 00101000 */
2076 0x58, /* 01011000 */
2077 0x3C, /* 00111100 */
2078 0x08, /* 00001000 */
2079 0x00, /* 00000000 */
2080
2081 /* 173 0xAD '\255' */
2082 0x00, /* 00000000 */
2083 0x10, /* 00010000 */
2084 0x00, /* 00000000 */
2085 0x10, /* 00010000 */
2086 0x10, /* 00010000 */
2087 0x10, /* 00010000 */
2088 0x10, /* 00010000 */
2089 0x10, /* 00010000 */
2090 0x00, /* 00000000 */
2091 0x00, /* 00000000 */
2092
2093 /* 174 0xAE '\256' */
2094 0x00, /* 00000000 */
2095 0x00, /* 00000000 */
2096 0x00, /* 00000000 */
2097 0x24, /* 00100100 */
2098 0x48, /* 01001000 */
2099 0x90, /* 10010000 */
2100 0x48, /* 01001000 */
2101 0x24, /* 00100100 */
2102 0x00, /* 00000000 */
2103 0x00, /* 00000000 */
2104
2105 /* 175 0xAF '\257' */
2106 0x00, /* 00000000 */
2107 0x00, /* 00000000 */
2108 0x00, /* 00000000 */
2109 0x90, /* 10010000 */
2110 0x48, /* 01001000 */
2111 0x24, /* 00100100 */
2112 0x48, /* 01001000 */
2113 0x90, /* 10010000 */
2114 0x00, /* 00000000 */
2115 0x00, /* 00000000 */
2116
2117 /* 176 0xB0 '\260' */
2118 0x10, /* 00010000 */
2119 0x44, /* 01000100 */
2120 0x10, /* 00010000 */
2121 0x44, /* 01000100 */
2122 0x10, /* 00010000 */
2123 0x44, /* 01000100 */
2124 0x10, /* 00010000 */
2125 0x44, /* 01000100 */
2126 0x10, /* 00010000 */
2127 0x44, /* 01000100 */
2128
2129 /* 177 0xB1 '\261' */
2130 0xA8, /* 10101000 */
2131 0x54, /* 01010100 */
2132 0xA8, /* 10101000 */
2133 0x54, /* 01010100 */
2134 0xA8, /* 10101000 */
2135 0x54, /* 01010100 */
2136 0xA8, /* 10101000 */
2137 0x54, /* 01010100 */
2138 0xA8, /* 10101000 */
2139 0x54, /* 01010100 */
2140
2141 /* 178 0xB2 '\262' */
2142 0xDC, /* 11011100 */
2143 0x74, /* 01110100 */
2144 0xDC, /* 11011100 */
2145 0x74, /* 01110100 */
2146 0xDC, /* 11011100 */
2147 0x74, /* 01110100 */
2148 0xDC, /* 11011100 */
2149 0x74, /* 01110100 */
2150 0xDC, /* 11011100 */
2151 0x74, /* 01110100 */
2152
2153 /* 179 0xB3 '\263' */
2154 0x10, /* 00010000 */
2155 0x10, /* 00010000 */
2156 0x10, /* 00010000 */
2157 0x10, /* 00010000 */
2158 0x10, /* 00010000 */
2159 0x10, /* 00010000 */
2160 0x10, /* 00010000 */
2161 0x10, /* 00010000 */
2162 0x10, /* 00010000 */
2163 0x10, /* 00010000 */
2164
2165 /* 180 0xB4 '\264' */
2166 0x10, /* 00010000 */
2167 0x10, /* 00010000 */
2168 0x10, /* 00010000 */
2169 0x10, /* 00010000 */
2170 0xF0, /* 11110000 */
2171 0x10, /* 00010000 */
2172 0x10, /* 00010000 */
2173 0x10, /* 00010000 */
2174 0x10, /* 00010000 */
2175 0x10, /* 00010000 */
2176
2177 /* 181 0xB5 '\265' */
2178 0x10, /* 00010000 */
2179 0x10, /* 00010000 */
2180 0x10, /* 00010000 */
2181 0xF0, /* 11110000 */
2182 0x10, /* 00010000 */
2183 0xF0, /* 11110000 */
2184 0x10, /* 00010000 */
2185 0x10, /* 00010000 */
2186 0x10, /* 00010000 */
2187 0x10, /* 00010000 */
2188
2189 /* 182 0xB6 '\266' */
2190 0x28, /* 00101000 */
2191 0x28, /* 00101000 */
2192 0x28, /* 00101000 */
2193 0x28, /* 00101000 */
2194 0xE8, /* 11101000 */
2195 0x28, /* 00101000 */
2196 0x28, /* 00101000 */
2197 0x28, /* 00101000 */
2198 0x28, /* 00101000 */
2199 0x28, /* 00101000 */
2200
2201 /* 183 0xB7 '\267' */
2202 0x00, /* 00000000 */
2203 0x00, /* 00000000 */
2204 0x00, /* 00000000 */
2205 0x00, /* 00000000 */
2206 0xF8, /* 11111000 */
2207 0x28, /* 00101000 */
2208 0x28, /* 00101000 */
2209 0x28, /* 00101000 */
2210 0x28, /* 00101000 */
2211 0x28, /* 00101000 */
2212
2213 /* 184 0xB8 '\270' */
2214 0x00, /* 00000000 */
2215 0x00, /* 00000000 */
2216 0x00, /* 00000000 */
2217 0xF0, /* 11110000 */
2218 0x10, /* 00010000 */
2219 0xF0, /* 11110000 */
2220 0x10, /* 00010000 */
2221 0x10, /* 00010000 */
2222 0x10, /* 00010000 */
2223 0x10, /* 00010000 */
2224
2225 /* 185 0xB9 '\271' */
2226 0x28, /* 00101000 */
2227 0x28, /* 00101000 */
2228 0x28, /* 00101000 */
2229 0xE8, /* 11101000 */
2230 0x08, /* 00001000 */
2231 0xE8, /* 11101000 */
2232 0x28, /* 00101000 */
2233 0x28, /* 00101000 */
2234 0x28, /* 00101000 */
2235 0x28, /* 00101000 */
2236
2237 /* 186 0xBA '\272' */
2238 0x28, /* 00101000 */
2239 0x28, /* 00101000 */
2240 0x28, /* 00101000 */
2241 0x28, /* 00101000 */
2242 0x28, /* 00101000 */
2243 0x28, /* 00101000 */
2244 0x28, /* 00101000 */
2245 0x28, /* 00101000 */
2246 0x28, /* 00101000 */
2247 0x28, /* 00101000 */
2248
2249 /* 187 0xBB '\273' */
2250 0x00, /* 00000000 */
2251 0x00, /* 00000000 */
2252 0x00, /* 00000000 */
2253 0xF8, /* 11111000 */
2254 0x08, /* 00001000 */
2255 0xE8, /* 11101000 */
2256 0x28, /* 00101000 */
2257 0x28, /* 00101000 */
2258 0x28, /* 00101000 */
2259 0x28, /* 00101000 */
2260
2261 /* 188 0xBC '\274' */
2262 0x28, /* 00101000 */
2263 0x28, /* 00101000 */
2264 0x28, /* 00101000 */
2265 0xE8, /* 11101000 */
2266 0x08, /* 00001000 */
2267 0xF8, /* 11111000 */
2268 0x00, /* 00000000 */
2269 0x00, /* 00000000 */
2270 0x00, /* 00000000 */
2271 0x00, /* 00000000 */
2272
2273 /* 189 0xBD '\275' */
2274 0x28, /* 00101000 */
2275 0x28, /* 00101000 */
2276 0x28, /* 00101000 */
2277 0x28, /* 00101000 */
2278 0xF8, /* 11111000 */
2279 0x00, /* 00000000 */
2280 0x00, /* 00000000 */
2281 0x00, /* 00000000 */
2282 0x00, /* 00000000 */
2283 0x00, /* 00000000 */
2284
2285 /* 190 0xBE '\276' */
2286 0x10, /* 00010000 */
2287 0x10, /* 00010000 */
2288 0x10, /* 00010000 */
2289 0xF0, /* 11110000 */
2290 0x10, /* 00010000 */
2291 0xF0, /* 11110000 */
2292 0x00, /* 00000000 */
2293 0x00, /* 00000000 */
2294 0x00, /* 00000000 */
2295 0x00, /* 00000000 */
2296
2297 /* 191 0xBF '\277' */
2298 0x00, /* 00000000 */
2299 0x00, /* 00000000 */
2300 0x00, /* 00000000 */
2301 0x00, /* 00000000 */
2302 0xF0, /* 11110000 */
2303 0x10, /* 00010000 */
2304 0x10, /* 00010000 */
2305 0x10, /* 00010000 */
2306 0x10, /* 00010000 */
2307 0x10, /* 00010000 */
2308
2309 /* 192 0xC0 '\300' */
2310 0x10, /* 00010000 */
2311 0x10, /* 00010000 */
2312 0x10, /* 00010000 */
2313 0x10, /* 00010000 */
2314 0x1C, /* 00011100 */
2315 0x00, /* 00000000 */
2316 0x00, /* 00000000 */
2317 0x00, /* 00000000 */
2318 0x00, /* 00000000 */
2319 0x00, /* 00000000 */
2320
2321 /* 193 0xC1 '\301' */
2322 0x10, /* 00010000 */
2323 0x10, /* 00010000 */
2324 0x10, /* 00010000 */
2325 0x10, /* 00010000 */
2326 0xFC, /* 11111100 */
2327 0x00, /* 00000000 */
2328 0x00, /* 00000000 */
2329 0x00, /* 00000000 */
2330 0x00, /* 00000000 */
2331 0x00, /* 00000000 */
2332
2333 /* 194 0xC2 '\302' */
2334 0x00, /* 00000000 */
2335 0x00, /* 00000000 */
2336 0x00, /* 00000000 */
2337 0x00, /* 00000000 */
2338 0xFC, /* 11111100 */
2339 0x10, /* 00010000 */
2340 0x10, /* 00010000 */
2341 0x10, /* 00010000 */
2342 0x10, /* 00010000 */
2343 0x10, /* 00010000 */
2344
2345 /* 195 0xC3 '\303' */
2346 0x10, /* 00010000 */
2347 0x10, /* 00010000 */
2348 0x10, /* 00010000 */
2349 0x10, /* 00010000 */
2350 0x1C, /* 00011100 */
2351 0x10, /* 00010000 */
2352 0x10, /* 00010000 */
2353 0x10, /* 00010000 */
2354 0x10, /* 00010000 */
2355 0x10, /* 00010000 */
2356
2357 /* 196 0xC4 '\304' */
2358 0x00, /* 00000000 */
2359 0x00, /* 00000000 */
2360 0x00, /* 00000000 */
2361 0x00, /* 00000000 */
2362 0xFC, /* 11111100 */
2363 0x00, /* 00000000 */
2364 0x00, /* 00000000 */
2365 0x00, /* 00000000 */
2366 0x00, /* 00000000 */
2367 0x00, /* 00000000 */
2368
2369 /* 197 0xC5 '\305' */
2370 0x10, /* 00010000 */
2371 0x10, /* 00010000 */
2372 0x10, /* 00010000 */
2373 0x10, /* 00010000 */
2374 0xFC, /* 11111100 */
2375 0x10, /* 00010000 */
2376 0x10, /* 00010000 */
2377 0x10, /* 00010000 */
2378 0x10, /* 00010000 */
2379 0x10, /* 00010000 */
2380
2381 /* 198 0xC6 '\306' */
2382 0x10, /* 00010000 */
2383 0x10, /* 00010000 */
2384 0x10, /* 00010000 */
2385 0x1C, /* 00011100 */
2386 0x10, /* 00010000 */
2387 0x1C, /* 00011100 */
2388 0x10, /* 00010000 */
2389 0x10, /* 00010000 */
2390 0x10, /* 00010000 */
2391 0x10, /* 00010000 */
2392
2393 /* 199 0xC7 '\307' */
2394 0x28, /* 00101000 */
2395 0x28, /* 00101000 */
2396 0x28, /* 00101000 */
2397 0x28, /* 00101000 */
2398 0x2C, /* 00101100 */
2399 0x28, /* 00101000 */
2400 0x28, /* 00101000 */
2401 0x28, /* 00101000 */
2402 0x28, /* 00101000 */
2403 0x28, /* 00101000 */
2404
2405 /* 200 0xC8 '\310' */
2406 0x28, /* 00101000 */
2407 0x28, /* 00101000 */
2408 0x28, /* 00101000 */
2409 0x2C, /* 00101100 */
2410 0x20, /* 00100000 */
2411 0x3C, /* 00111100 */
2412 0x00, /* 00000000 */
2413 0x00, /* 00000000 */
2414 0x00, /* 00000000 */
2415 0x00, /* 00000000 */
2416
2417 /* 201 0xC9 '\311' */
2418 0x00, /* 00000000 */
2419 0x00, /* 00000000 */
2420 0x00, /* 00000000 */
2421 0x3C, /* 00111100 */
2422 0x20, /* 00100000 */
2423 0x2C, /* 00101100 */
2424 0x28, /* 00101000 */
2425 0x28, /* 00101000 */
2426 0x28, /* 00101000 */
2427 0x28, /* 00101000 */
2428
2429 /* 202 0xCA '\312' */
2430 0x28, /* 00101000 */
2431 0x28, /* 00101000 */
2432 0x28, /* 00101000 */
2433 0xEC, /* 11101100 */
2434 0x00, /* 00000000 */
2435 0xFC, /* 11111100 */
2436 0x00, /* 00000000 */
2437 0x00, /* 00000000 */
2438 0x00, /* 00000000 */
2439 0x00, /* 00000000 */
2440
2441 /* 203 0xCB '\313' */
2442 0x00, /* 00000000 */
2443 0x00, /* 00000000 */
2444 0x00, /* 00000000 */
2445 0xFC, /* 11111100 */
2446 0x00, /* 00000000 */
2447 0xEC, /* 11101100 */
2448 0x28, /* 00101000 */
2449 0x28, /* 00101000 */
2450 0x28, /* 00101000 */
2451 0x28, /* 00101000 */
2452
2453 /* 204 0xCC '\314' */
2454 0x28, /* 00101000 */
2455 0x28, /* 00101000 */
2456 0x28, /* 00101000 */
2457 0x2C, /* 00101100 */
2458 0x20, /* 00100000 */
2459 0x2C, /* 00101100 */
2460 0x28, /* 00101000 */
2461 0x28, /* 00101000 */
2462 0x28, /* 00101000 */
2463 0x28, /* 00101000 */
2464
2465 /* 205 0xCD '\315' */
2466 0x00, /* 00000000 */
2467 0x00, /* 00000000 */
2468 0x00, /* 00000000 */
2469 0xFC, /* 11111100 */
2470 0x00, /* 00000000 */
2471 0xFC, /* 11111100 */
2472 0x00, /* 00000000 */
2473 0x00, /* 00000000 */
2474 0x00, /* 00000000 */
2475 0x00, /* 00000000 */
2476
2477 /* 206 0xCE '\316' */
2478 0x28, /* 00101000 */
2479 0x28, /* 00101000 */
2480 0x28, /* 00101000 */
2481 0xEC, /* 11101100 */
2482 0x00, /* 00000000 */
2483 0xEC, /* 11101100 */
2484 0x28, /* 00101000 */
2485 0x28, /* 00101000 */
2486 0x28, /* 00101000 */
2487 0x28, /* 00101000 */
2488
2489 /* 207 0xCF '\317' */
2490 0x10, /* 00010000 */
2491 0x10, /* 00010000 */
2492 0x10, /* 00010000 */
2493 0xFC, /* 11111100 */
2494 0x00, /* 00000000 */
2495 0xFC, /* 11111100 */
2496 0x00, /* 00000000 */
2497 0x00, /* 00000000 */
2498 0x00, /* 00000000 */
2499 0x00, /* 00000000 */
2500
2501 /* 208 0xD0 '\320' */
2502 0x28, /* 00101000 */
2503 0x28, /* 00101000 */
2504 0x28, /* 00101000 */
2505 0x28, /* 00101000 */
2506 0xFC, /* 11111100 */
2507 0x00, /* 00000000 */
2508 0x00, /* 00000000 */
2509 0x00, /* 00000000 */
2510 0x00, /* 00000000 */
2511 0x00, /* 00000000 */
2512
2513 /* 209 0xD1 '\321' */
2514 0x00, /* 00000000 */
2515 0x00, /* 00000000 */
2516 0x00, /* 00000000 */
2517 0xFC, /* 11111100 */
2518 0x00, /* 00000000 */
2519 0xFC, /* 11111100 */
2520 0x10, /* 00010000 */
2521 0x10, /* 00010000 */
2522 0x10, /* 00010000 */
2523 0x10, /* 00010000 */
2524
2525 /* 210 0xD2 '\322' */
2526 0x00, /* 00000000 */
2527 0x00, /* 00000000 */
2528 0x00, /* 00000000 */
2529 0x00, /* 00000000 */
2530 0xFC, /* 11111100 */
2531 0x28, /* 00101000 */
2532 0x28, /* 00101000 */
2533 0x28, /* 00101000 */
2534 0x28, /* 00101000 */
2535 0x28, /* 00101000 */
2536
2537 /* 211 0xD3 '\323' */
2538 0x28, /* 00101000 */
2539 0x28, /* 00101000 */
2540 0x28, /* 00101000 */
2541 0x28, /* 00101000 */
2542 0x3C, /* 00111100 */
2543 0x00, /* 00000000 */
2544 0x00, /* 00000000 */
2545 0x00, /* 00000000 */
2546 0x00, /* 00000000 */
2547 0x00, /* 00000000 */
2548
2549 /* 212 0xD4 '\324' */
2550 0x10, /* 00010000 */
2551 0x10, /* 00010000 */
2552 0x10, /* 00010000 */
2553 0x1C, /* 00011100 */
2554 0x10, /* 00010000 */
2555 0x1C, /* 00011100 */
2556 0x00, /* 00000000 */
2557 0x00, /* 00000000 */
2558 0x00, /* 00000000 */
2559 0x00, /* 00000000 */
2560
2561 /* 213 0xD5 '\325' */
2562 0x00, /* 00000000 */
2563 0x00, /* 00000000 */
2564 0x00, /* 00000000 */
2565 0x1C, /* 00011100 */
2566 0x10, /* 00010000 */
2567 0x1C, /* 00011100 */
2568 0x10, /* 00010000 */
2569 0x10, /* 00010000 */
2570 0x10, /* 00010000 */
2571 0x10, /* 00010000 */
2572
2573 /* 214 0xD6 '\326' */
2574 0x00, /* 00000000 */
2575 0x00, /* 00000000 */
2576 0x00, /* 00000000 */
2577 0x00, /* 00000000 */
2578 0x3C, /* 00111100 */
2579 0x28, /* 00101000 */
2580 0x28, /* 00101000 */
2581 0x28, /* 00101000 */
2582 0x28, /* 00101000 */
2583 0x28, /* 00101000 */
2584
2585 /* 215 0xD7 '\327' */
2586 0x28, /* 00101000 */
2587 0x28, /* 00101000 */
2588 0x28, /* 00101000 */
2589 0x28, /* 00101000 */
2590 0xFC, /* 11111100 */
2591 0x28, /* 00101000 */
2592 0x28, /* 00101000 */
2593 0x28, /* 00101000 */
2594 0x28, /* 00101000 */
2595 0x28, /* 00101000 */
2596
2597 /* 216 0xD8 '\330' */
2598 0x10, /* 00010000 */
2599 0x10, /* 00010000 */
2600 0x10, /* 00010000 */
2601 0xFC, /* 11111100 */
2602 0x10, /* 00010000 */
2603 0xFC, /* 11111100 */
2604 0x10, /* 00010000 */
2605 0x10, /* 00010000 */
2606 0x10, /* 00010000 */
2607 0x10, /* 00010000 */
2608
2609 /* 217 0xD9 '\331' */
2610 0x10, /* 00010000 */
2611 0x10, /* 00010000 */
2612 0x10, /* 00010000 */
2613 0x10, /* 00010000 */
2614 0xF0, /* 11110000 */
2615 0x00, /* 00000000 */
2616 0x00, /* 00000000 */
2617 0x00, /* 00000000 */
2618 0x00, /* 00000000 */
2619 0x00, /* 00000000 */
2620
2621 /* 218 0xDA '\332' */
2622 0x00, /* 00000000 */
2623 0x00, /* 00000000 */
2624 0x00, /* 00000000 */
2625 0x00, /* 00000000 */
2626 0x1C, /* 00011100 */
2627 0x10, /* 00010000 */
2628 0x10, /* 00010000 */
2629 0x10, /* 00010000 */
2630 0x10, /* 00010000 */
2631 0x10, /* 00010000 */
2632
2633 /* 219 0xDB '\333' */
2634 0xFC, /* 11111100 */
2635 0xFC, /* 11111100 */
2636 0xFC, /* 11111100 */
2637 0xFC, /* 11111100 */
2638 0xFC, /* 11111100 */
2639 0xFC, /* 11111100 */
2640 0xFC, /* 11111100 */
2641 0xFC, /* 11111100 */
2642 0xFC, /* 11111100 */
2643 0xFC, /* 11111100 */
2644
2645 /* 220 0xDC '\334' */
2646 0x00, /* 00000000 */
2647 0x00, /* 00000000 */
2648 0x00, /* 00000000 */
2649 0x00, /* 00000000 */
2650 0x00, /* 00000000 */
2651 0xFC, /* 11111100 */
2652 0xFC, /* 11111100 */
2653 0xFC, /* 11111100 */
2654 0xFC, /* 11111100 */
2655 0xFC, /* 11111100 */
2656
2657 /* 221 0xDD '\335' */
2658 0xE0, /* 11100000 */
2659 0xE0, /* 11100000 */
2660 0xE0, /* 11100000 */
2661 0xE0, /* 11100000 */
2662 0xE0, /* 11100000 */
2663 0xE0, /* 11100000 */
2664 0xE0, /* 11100000 */
2665 0xE0, /* 11100000 */
2666 0xE0, /* 11100000 */
2667 0xE0, /* 11100000 */
2668
2669 /* 222 0xDE '\336' */
2670 0x1C, /* 00011100 */
2671 0x1C, /* 00011100 */
2672 0x1C, /* 00011100 */
2673 0x1C, /* 00011100 */
2674 0x1C, /* 00011100 */
2675 0x1C, /* 00011100 */
2676 0x1C, /* 00011100 */
2677 0x1C, /* 00011100 */
2678 0x1C, /* 00011100 */
2679 0x1C, /* 00011100 */
2680
2681 /* 223 0xDF '\337' */
2682 0xFC, /* 11111100 */
2683 0xFC, /* 11111100 */
2684 0xFC, /* 11111100 */
2685 0xFC, /* 11111100 */
2686 0xFC, /* 11111100 */
2687 0x00, /* 00000000 */
2688 0x00, /* 00000000 */
2689 0x00, /* 00000000 */
2690 0x00, /* 00000000 */
2691 0x00, /* 00000000 */
2692
2693 /* 224 0xE0 '\340' */
2694 0x00, /* 00000000 */
2695 0x00, /* 00000000 */
2696 0x00, /* 00000000 */
2697 0x34, /* 00110100 */
2698 0x48, /* 01001000 */
2699 0x48, /* 01001000 */
2700 0x48, /* 01001000 */
2701 0x34, /* 00110100 */
2702 0x00, /* 00000000 */
2703 0x00, /* 00000000 */
2704
2705 /* 225 0xE1 '\341' */
2706 0x18, /* 00011000 */
2707 0x24, /* 00100100 */
2708 0x44, /* 01000100 */
2709 0x48, /* 01001000 */
2710 0x48, /* 01001000 */
2711 0x44, /* 01000100 */
2712 0x44, /* 01000100 */
2713 0x58, /* 01011000 */
2714 0x40, /* 01000000 */
2715 0x00, /* 00000000 */
2716
2717 /* 226 0xE2 '\342' */
2718 0x00, /* 00000000 */
2719 0x7C, /* 01111100 */
2720 0x44, /* 01000100 */
2721 0x44, /* 01000100 */
2722 0x40, /* 01000000 */
2723 0x40, /* 01000000 */
2724 0x40, /* 01000000 */
2725 0x40, /* 01000000 */
2726 0x00, /* 00000000 */
2727 0x00, /* 00000000 */
2728
2729 /* 227 0xE3 '\343' */
2730 0x00, /* 00000000 */
2731 0x00, /* 00000000 */
2732 0x00, /* 00000000 */
2733 0x7C, /* 01111100 */
2734 0x28, /* 00101000 */
2735 0x28, /* 00101000 */
2736 0x28, /* 00101000 */
2737 0x28, /* 00101000 */
2738 0x00, /* 00000000 */
2739 0x00, /* 00000000 */
2740
2741 /* 228 0xE4 '\344' */
2742 0x00, /* 00000000 */
2743 0x7C, /* 01111100 */
2744 0x24, /* 00100100 */
2745 0x10, /* 00010000 */
2746 0x08, /* 00001000 */
2747 0x10, /* 00010000 */
2748 0x24, /* 00100100 */
2749 0x7C, /* 01111100 */
2750 0x00, /* 00000000 */
2751 0x00, /* 00000000 */
2752
2753 /* 229 0xE5 '\345' */
2754 0x00, /* 00000000 */
2755 0x00, /* 00000000 */
2756 0x00, /* 00000000 */
2757 0x3C, /* 00111100 */
2758 0x48, /* 01001000 */
2759 0x48, /* 01001000 */
2760 0x48, /* 01001000 */
2761 0x30, /* 00110000 */
2762 0x00, /* 00000000 */
2763 0x00, /* 00000000 */
2764
2765 /* 230 0xE6 '\346' */
2766 0x00, /* 00000000 */
2767 0x00, /* 00000000 */
2768 0x00, /* 00000000 */
2769 0x48, /* 01001000 */
2770 0x48, /* 01001000 */
2771 0x48, /* 01001000 */
2772 0x48, /* 01001000 */
2773 0x74, /* 01110100 */
2774 0x40, /* 01000000 */
2775 0x40, /* 01000000 */
2776
2777 /* 231 0xE7 '\347' */
2778 0x00, /* 00000000 */
2779 0x00, /* 00000000 */
2780 0x00, /* 00000000 */
2781 0x7C, /* 01111100 */
2782 0x10, /* 00010000 */
2783 0x10, /* 00010000 */
2784 0x10, /* 00010000 */
2785 0x0C, /* 00001100 */
2786 0x00, /* 00000000 */
2787 0x00, /* 00000000 */
2788
2789 /* 232 0xE8 '\350' */
2790 0x38, /* 00111000 */
2791 0x10, /* 00010000 */
2792 0x38, /* 00111000 */
2793 0x44, /* 01000100 */
2794 0x44, /* 01000100 */
2795 0x38, /* 00111000 */
2796 0x10, /* 00010000 */
2797 0x38, /* 00111000 */
2798 0x00, /* 00000000 */
2799 0x00, /* 00000000 */
2800
2801 /* 233 0xE9 '\351' */
2802 0x00, /* 00000000 */
2803 0x38, /* 00111000 */
2804 0x44, /* 01000100 */
2805 0x44, /* 01000100 */
2806 0x7C, /* 01111100 */
2807 0x44, /* 01000100 */
2808 0x44, /* 01000100 */
2809 0x38, /* 00111000 */
2810 0x00, /* 00000000 */
2811 0x00, /* 00000000 */
2812
2813 /* 234 0xEA '\352' */
2814 0x00, /* 00000000 */
2815 0x38, /* 00111000 */
2816 0x44, /* 01000100 */
2817 0x44, /* 01000100 */
2818 0x44, /* 01000100 */
2819 0x44, /* 01000100 */
2820 0x28, /* 00101000 */
2821 0x6C, /* 01101100 */
2822 0x00, /* 00000000 */
2823 0x00, /* 00000000 */
2824
2825 /* 235 0xEB '\353' */
2826 0x00, /* 00000000 */
2827 0x18, /* 00011000 */
2828 0x20, /* 00100000 */
2829 0x18, /* 00011000 */
2830 0x24, /* 00100100 */
2831 0x24, /* 00100100 */
2832 0x24, /* 00100100 */
2833 0x18, /* 00011000 */
2834 0x00, /* 00000000 */
2835 0x00, /* 00000000 */
2836
2837 /* 236 0xEC '\354' */
2838 0x00, /* 00000000 */
2839 0x00, /* 00000000 */
2840 0x00, /* 00000000 */
2841 0x38, /* 00111000 */
2842 0x54, /* 01010100 */
2843 0x54, /* 01010100 */
2844 0x54, /* 01010100 */
2845 0x38, /* 00111000 */
2846 0x00, /* 00000000 */
2847 0x00, /* 00000000 */
2848
2849 /* 237 0xED '\355' */
2850 0x00, /* 00000000 */
2851 0x00, /* 00000000 */
2852 0x04, /* 00000100 */
2853 0x38, /* 00111000 */
2854 0x54, /* 01010100 */
2855 0x54, /* 01010100 */
2856 0x38, /* 00111000 */
2857 0x40, /* 01000000 */
2858 0x00, /* 00000000 */
2859 0x00, /* 00000000 */
2860
2861 /* 238 0xEE '\356' */
2862 0x00, /* 00000000 */
2863 0x3C, /* 00111100 */
2864 0x40, /* 01000000 */
2865 0x40, /* 01000000 */
2866 0x38, /* 00111000 */
2867 0x40, /* 01000000 */
2868 0x40, /* 01000000 */
2869 0x3C, /* 00111100 */
2870 0x00, /* 00000000 */
2871 0x00, /* 00000000 */
2872
2873 /* 239 0xEF '\357' */
2874 0x00, /* 00000000 */
2875 0x38, /* 00111000 */
2876 0x44, /* 01000100 */
2877 0x44, /* 01000100 */
2878 0x44, /* 01000100 */
2879 0x44, /* 01000100 */
2880 0x44, /* 01000100 */
2881 0x44, /* 01000100 */
2882 0x00, /* 00000000 */
2883 0x00, /* 00000000 */
2884
2885 /* 240 0xF0 '\360' */
2886 0x00, /* 00000000 */
2887 0x00, /* 00000000 */
2888 0xFC, /* 11111100 */
2889 0x00, /* 00000000 */
2890 0xFC, /* 11111100 */
2891 0x00, /* 00000000 */
2892 0xFC, /* 11111100 */
2893 0x00, /* 00000000 */
2894 0x00, /* 00000000 */
2895 0x00, /* 00000000 */
2896
2897 /* 241 0xF1 '\361' */
2898 0x00, /* 00000000 */
2899 0x10, /* 00010000 */
2900 0x10, /* 00010000 */
2901 0x7C, /* 01111100 */
2902 0x10, /* 00010000 */
2903 0x10, /* 00010000 */
2904 0x00, /* 00000000 */
2905 0x7C, /* 01111100 */
2906 0x00, /* 00000000 */
2907 0x00, /* 00000000 */
2908
2909 /* 242 0xF2 '\362' */
2910 0x00, /* 00000000 */
2911 0x20, /* 00100000 */
2912 0x10, /* 00010000 */
2913 0x08, /* 00001000 */
2914 0x10, /* 00010000 */
2915 0x20, /* 00100000 */
2916 0x00, /* 00000000 */
2917 0x38, /* 00111000 */
2918 0x00, /* 00000000 */
2919 0x00, /* 00000000 */
2920
2921 /* 243 0xF3 '\363' */
2922 0x00, /* 00000000 */
2923 0x08, /* 00001000 */
2924 0x10, /* 00010000 */
2925 0x20, /* 00100000 */
2926 0x10, /* 00010000 */
2927 0x08, /* 00001000 */
2928 0x00, /* 00000000 */
2929 0x38, /* 00111000 */
2930 0x00, /* 00000000 */
2931 0x00, /* 00000000 */
2932
2933 /* 244 0xF4 '\364' */
2934 0x00, /* 00000000 */
2935 0x0C, /* 00001100 */
2936 0x10, /* 00010000 */
2937 0x10, /* 00010000 */
2938 0x10, /* 00010000 */
2939 0x10, /* 00010000 */
2940 0x10, /* 00010000 */
2941 0x10, /* 00010000 */
2942 0x10, /* 00010000 */
2943 0x10, /* 00010000 */
2944
2945 /* 245 0xF5 '\365' */
2946 0x10, /* 00010000 */
2947 0x10, /* 00010000 */
2948 0x10, /* 00010000 */
2949 0x10, /* 00010000 */
2950 0x10, /* 00010000 */
2951 0x10, /* 00010000 */
2952 0x10, /* 00010000 */
2953 0x10, /* 00010000 */
2954 0x60, /* 01100000 */
2955 0x00, /* 00000000 */
2956
2957 /* 246 0xF6 '\366' */
2958 0x00, /* 00000000 */
2959 0x00, /* 00000000 */
2960 0x10, /* 00010000 */
2961 0x00, /* 00000000 */
2962 0x7C, /* 01111100 */
2963 0x00, /* 00000000 */
2964 0x10, /* 00010000 */
2965 0x00, /* 00000000 */
2966 0x00, /* 00000000 */
2967 0x00, /* 00000000 */
2968
2969 /* 247 0xF7 '\367' */
2970 0x00, /* 00000000 */
2971 0x00, /* 00000000 */
2972 0x20, /* 00100000 */
2973 0x54, /* 01010100 */
2974 0x08, /* 00001000 */
2975 0x20, /* 00100000 */
2976 0x54, /* 01010100 */
2977 0x08, /* 00001000 */
2978 0x00, /* 00000000 */
2979 0x00, /* 00000000 */
2980
2981 /* 248 0xF8 '\370' */
2982 0x30, /* 00110000 */
2983 0x48, /* 01001000 */
2984 0x48, /* 01001000 */
2985 0x30, /* 00110000 */
2986 0x00, /* 00000000 */
2987 0x00, /* 00000000 */
2988 0x00, /* 00000000 */
2989 0x00, /* 00000000 */
2990 0x00, /* 00000000 */
2991 0x00, /* 00000000 */
2992
2993 /* 249 0xF9 '\371' */
2994 0x00, /* 00000000 */
2995 0x00, /* 00000000 */
2996 0x00, /* 00000000 */
2997 0x10, /* 00010000 */
2998 0x38, /* 00111000 */
2999 0x10, /* 00010000 */
3000 0x00, /* 00000000 */
3001 0x00, /* 00000000 */
3002 0x00, /* 00000000 */
3003 0x00, /* 00000000 */
3004
3005 /* 250 0xFA '\372' */
3006 0x00, /* 00000000 */
3007 0x00, /* 00000000 */
3008 0x00, /* 00000000 */
3009 0x00, /* 00000000 */
3010 0x10, /* 00010000 */
3011 0x00, /* 00000000 */
3012 0x00, /* 00000000 */
3013 0x00, /* 00000000 */
3014 0x00, /* 00000000 */
3015 0x00, /* 00000000 */
3016
3017 /* 251 0xFB '\373' */
3018 0x00, /* 00000000 */
3019 0x04, /* 00000100 */
3020 0x08, /* 00001000 */
3021 0x08, /* 00001000 */
3022 0x50, /* 01010000 */
3023 0x50, /* 01010000 */
3024 0x20, /* 00100000 */
3025 0x20, /* 00100000 */
3026 0x00, /* 00000000 */
3027 0x00, /* 00000000 */
3028
3029 /* 252 0xFC '\374' */
3030 0x60, /* 01100000 */
3031 0x50, /* 01010000 */
3032 0x50, /* 01010000 */
3033 0x50, /* 01010000 */
3034 0x00, /* 00000000 */
3035 0x00, /* 00000000 */
3036 0x00, /* 00000000 */
3037 0x00, /* 00000000 */
3038 0x00, /* 00000000 */
3039 0x00, /* 00000000 */
3040
3041 /* 253 0xFD '\375' */
3042 0x60, /* 01100000 */
3043 0x10, /* 00010000 */
3044 0x20, /* 00100000 */
3045 0x70, /* 01110000 */
3046 0x00, /* 00000000 */
3047 0x00, /* 00000000 */
3048 0x00, /* 00000000 */
3049 0x00, /* 00000000 */
3050 0x00, /* 00000000 */
3051 0x00, /* 00000000 */
3052
3053 /* 254 0xFE '\376' */
3054 0x00, /* 00000000 */
3055 0x00, /* 00000000 */
3056 0x38, /* 00111000 */
3057 0x38, /* 00111000 */
3058 0x38, /* 00111000 */
3059 0x38, /* 00111000 */
3060 0x38, /* 00111000 */
3061 0x38, /* 00111000 */
3062 0x00, /* 00000000 */
3063 0x00, /* 00000000 */
3064
3065 /* 255 0xFF '\377' */
3066 0x00, /* 00000000 */
3067 0x00, /* 00000000 */
3068 0x00, /* 00000000 */
3069 0x00, /* 00000000 */
3070 0x00, /* 00000000 */
3071 0x00, /* 00000000 */
3072 0x00, /* 00000000 */
3073 0x00, /* 00000000 */
3074 0x00, /* 00000000 */
3075 0x00, /* 00000000 */
3076
3077};
3078
3079const struct font_desc font_6x10 = {
3080 .idx = FONT6x10_IDX,
3081 .name = "6x10",
3082 .width = 6,
3083 .height = 10,
3084 .data = fontdata_6x10,
3085 .pref = 0,
3086};
diff --git a/lib/fonts/fonts.c b/lib/fonts/fonts.c
index f947189efe6d..823376ca0a8b 100644
--- a/lib/fonts/fonts.c
+++ b/lib/fonts/fonts.c
@@ -63,6 +63,10 @@ static const struct font_desc *fonts[] = {
63#undef NO_FONTS 63#undef NO_FONTS
64 &font_mini_4x6, 64 &font_mini_4x6,
65#endif 65#endif
66#ifdef CONFIG_FONT_6x10
67#undef NO_FONTS
68 &font_6x10,
69#endif
66}; 70};
67 71
68#define num_fonts ARRAY_SIZE(fonts) 72#define num_fonts ARRAY_SIZE(fonts)
diff --git a/lib/genalloc.c b/lib/genalloc.c
index bdb9a456bcbb..cce4dd68c40d 100644
--- a/lib/genalloc.c
+++ b/lib/genalloc.c
@@ -403,6 +403,35 @@ void gen_pool_for_each_chunk(struct gen_pool *pool,
403EXPORT_SYMBOL(gen_pool_for_each_chunk); 403EXPORT_SYMBOL(gen_pool_for_each_chunk);
404 404
405/** 405/**
406 * addr_in_gen_pool - checks if an address falls within the range of a pool
407 * @pool: the generic memory pool
408 * @start: start address
409 * @size: size of the region
410 *
411 * Check if the range of addresses falls within the specified pool. Returns
412 * true if the entire range is contained in the pool and false otherwise.
413 */
414bool addr_in_gen_pool(struct gen_pool *pool, unsigned long start,
415 size_t size)
416{
417 bool found = false;
418 unsigned long end = start + size;
419 struct gen_pool_chunk *chunk;
420
421 rcu_read_lock();
422 list_for_each_entry_rcu(chunk, &(pool)->chunks, next_chunk) {
423 if (start >= chunk->start_addr && start <= chunk->end_addr) {
424 if (end <= chunk->end_addr) {
425 found = true;
426 break;
427 }
428 }
429 }
430 rcu_read_unlock();
431 return found;
432}
433
434/**
406 * gen_pool_avail - get available free space of the pool 435 * gen_pool_avail - get available free space of the pool
407 * @pool: pool to get available free space 436 * @pool: pool to get available free space
408 * 437 *
@@ -481,6 +510,26 @@ unsigned long gen_pool_first_fit(unsigned long *map, unsigned long size,
481EXPORT_SYMBOL(gen_pool_first_fit); 510EXPORT_SYMBOL(gen_pool_first_fit);
482 511
483/** 512/**
513 * gen_pool_first_fit_order_align - find the first available region
514 * of memory matching the size requirement. The region will be aligned
515 * to the order of the size specified.
516 * @map: The address to base the search on
517 * @size: The bitmap size in bits
518 * @start: The bitnumber to start searching at
519 * @nr: The number of zeroed bits we're looking for
520 * @data: additional data - unused
521 */
522unsigned long gen_pool_first_fit_order_align(unsigned long *map,
523 unsigned long size, unsigned long start,
524 unsigned int nr, void *data)
525{
526 unsigned long align_mask = roundup_pow_of_two(nr) - 1;
527
528 return bitmap_find_next_zero_area(map, size, start, nr, align_mask);
529}
530EXPORT_SYMBOL(gen_pool_first_fit_order_align);
531
532/**
484 * gen_pool_best_fit - find the best fitting region of memory 533 * gen_pool_best_fit - find the best fitting region of memory
485 * macthing the size requirement (no alignment constraint) 534 * macthing the size requirement (no alignment constraint)
486 * @map: The address to base the search on 535 * @map: The address to base the search on
@@ -588,6 +637,7 @@ struct gen_pool *of_get_named_gen_pool(struct device_node *np,
588 if (!np_pool) 637 if (!np_pool)
589 return NULL; 638 return NULL;
590 pdev = of_find_device_by_node(np_pool); 639 pdev = of_find_device_by_node(np_pool);
640 of_node_put(np_pool);
591 if (!pdev) 641 if (!pdev)
592 return NULL; 642 return NULL;
593 return dev_get_gen_pool(&pdev->dev); 643 return dev_get_gen_pool(&pdev->dev);
diff --git a/lib/glob.c b/lib/glob.c
new file mode 100644
index 000000000000..500fc80d23e1
--- /dev/null
+++ b/lib/glob.c
@@ -0,0 +1,287 @@
1#include <linux/module.h>
2#include <linux/glob.h>
3
4/*
5 * The only reason this code can be compiled as a module is because the
6 * ATA code that depends on it can be as well. In practice, they're
7 * both usually compiled in and the module overhead goes away.
8 */
9MODULE_DESCRIPTION("glob(7) matching");
10MODULE_LICENSE("Dual MIT/GPL");
11
12/**
13 * glob_match - Shell-style pattern matching, like !fnmatch(pat, str, 0)
14 * @pat: Shell-style pattern to match, e.g. "*.[ch]".
15 * @str: String to match. The pattern must match the entire string.
16 *
17 * Perform shell-style glob matching, returning true (1) if the match
18 * succeeds, or false (0) if it fails. Equivalent to !fnmatch(@pat, @str, 0).
19 *
20 * Pattern metacharacters are ?, *, [ and \.
21 * (And, inside character classes, !, - and ].)
22 *
23 * This is small and simple implementation intended for device blacklists
24 * where a string is matched against a number of patterns. Thus, it
25 * does not preprocess the patterns. It is non-recursive, and run-time
26 * is at most quadratic: strlen(@str)*strlen(@pat).
27 *
28 * An example of the worst case is glob_match("*aaaaa", "aaaaaaaaaa");
29 * it takes 6 passes over the pattern before matching the string.
30 *
31 * Like !fnmatch(@pat, @str, 0) and unlike the shell, this does NOT
32 * treat / or leading . specially; it isn't actually used for pathnames.
33 *
34 * Note that according to glob(7) (and unlike bash), character classes
35 * are complemented by a leading !; this does not support the regex-style
36 * [^a-z] syntax.
37 *
38 * An opening bracket without a matching close is matched literally.
39 */
40bool __pure glob_match(char const *pat, char const *str)
41{
42 /*
43 * Backtrack to previous * on mismatch and retry starting one
44 * character later in the string. Because * matches all characters
45 * (no exception for /), it can be easily proved that there's
46 * never a need to backtrack multiple levels.
47 */
48 char const *back_pat = NULL, *back_str = back_str;
49
50 /*
51 * Loop over each token (character or class) in pat, matching
52 * it against the remaining unmatched tail of str. Return false
53 * on mismatch, or true after matching the trailing nul bytes.
54 */
55 for (;;) {
56 unsigned char c = *str++;
57 unsigned char d = *pat++;
58
59 switch (d) {
60 case '?': /* Wildcard: anything but nul */
61 if (c == '\0')
62 return false;
63 break;
64 case '*': /* Any-length wildcard */
65 if (*pat == '\0') /* Optimize trailing * case */
66 return true;
67 back_pat = pat;
68 back_str = --str; /* Allow zero-length match */
69 break;
70 case '[': { /* Character class */
71 bool match = false, inverted = (*pat == '!');
72 char const *class = pat + inverted;
73 unsigned char a = *class++;
74
75 /*
76 * Iterate over each span in the character class.
77 * A span is either a single character a, or a
78 * range a-b. The first span may begin with ']'.
79 */
80 do {
81 unsigned char b = a;
82
83 if (a == '\0') /* Malformed */
84 goto literal;
85
86 if (class[0] == '-' && class[1] != ']') {
87 b = class[1];
88
89 if (b == '\0')
90 goto literal;
91
92 class += 2;
93 /* Any special action if a > b? */
94 }
95 match |= (a <= c && c <= b);
96 } while ((a = *class++) != ']');
97
98 if (match == inverted)
99 goto backtrack;
100 pat = class;
101 }
102 break;
103 case '\\':
104 d = *pat++;
105 /*FALLTHROUGH*/
106 default: /* Literal character */
107literal:
108 if (c == d) {
109 if (d == '\0')
110 return true;
111 break;
112 }
113backtrack:
114 if (c == '\0' || !back_pat)
115 return false; /* No point continuing */
116 /* Try again from last *, one character later in str. */
117 pat = back_pat;
118 str = ++back_str;
119 break;
120 }
121 }
122}
123EXPORT_SYMBOL(glob_match);
124
125
126#ifdef CONFIG_GLOB_SELFTEST
127
128#include <linux/printk.h>
129#include <linux/moduleparam.h>
130
131/* Boot with "glob.verbose=1" to show successful tests, too */
132static bool verbose = false;
133module_param(verbose, bool, 0);
134
135struct glob_test {
136 char const *pat, *str;
137 bool expected;
138};
139
140static bool __pure __init test(char const *pat, char const *str, bool expected)
141{
142 bool match = glob_match(pat, str);
143 bool success = match == expected;
144
145 /* Can't get string literals into a particular section, so... */
146 static char const msg_error[] __initconst =
147 KERN_ERR "glob: \"%s\" vs. \"%s\": %s *** ERROR ***\n";
148 static char const msg_ok[] __initconst =
149 KERN_DEBUG "glob: \"%s\" vs. \"%s\": %s OK\n";
150 static char const mismatch[] __initconst = "mismatch";
151 char const *message;
152
153 if (!success)
154 message = msg_error;
155 else if (verbose)
156 message = msg_ok;
157 else
158 return success;
159
160 printk(message, pat, str, mismatch + 3*match);
161 return success;
162}
163
164/*
165 * The tests are all jammed together in one array to make it simpler
166 * to place that array in the .init.rodata section. The obvious
167 * "array of structures containing char *" has no way to force the
168 * pointed-to strings to be in a particular section.
169 *
170 * Anyway, a test consists of:
171 * 1. Expected glob_match result: '1' or '0'.
172 * 2. Pattern to match: null-terminated string
173 * 3. String to match against: null-terminated string
174 *
175 * The list of tests is terminated with a final '\0' instead of
176 * a glob_match result character.
177 */
178static char const glob_tests[] __initconst =
179 /* Some basic tests */
180 "1" "a\0" "a\0"
181 "0" "a\0" "b\0"
182 "0" "a\0" "aa\0"
183 "0" "a\0" "\0"
184 "1" "\0" "\0"
185 "0" "\0" "a\0"
186 /* Simple character class tests */
187 "1" "[a]\0" "a\0"
188 "0" "[a]\0" "b\0"
189 "0" "[!a]\0" "a\0"
190 "1" "[!a]\0" "b\0"
191 "1" "[ab]\0" "a\0"
192 "1" "[ab]\0" "b\0"
193 "0" "[ab]\0" "c\0"
194 "1" "[!ab]\0" "c\0"
195 "1" "[a-c]\0" "b\0"
196 "0" "[a-c]\0" "d\0"
197 /* Corner cases in character class parsing */
198 "1" "[a-c-e-g]\0" "-\0"
199 "0" "[a-c-e-g]\0" "d\0"
200 "1" "[a-c-e-g]\0" "f\0"
201 "1" "[]a-ceg-ik[]\0" "a\0"
202 "1" "[]a-ceg-ik[]\0" "]\0"
203 "1" "[]a-ceg-ik[]\0" "[\0"
204 "1" "[]a-ceg-ik[]\0" "h\0"
205 "0" "[]a-ceg-ik[]\0" "f\0"
206 "0" "[!]a-ceg-ik[]\0" "h\0"
207 "0" "[!]a-ceg-ik[]\0" "]\0"
208 "1" "[!]a-ceg-ik[]\0" "f\0"
209 /* Simple wild cards */
210 "1" "?\0" "a\0"
211 "0" "?\0" "aa\0"
212 "0" "??\0" "a\0"
213 "1" "?x?\0" "axb\0"
214 "0" "?x?\0" "abx\0"
215 "0" "?x?\0" "xab\0"
216 /* Asterisk wild cards (backtracking) */
217 "0" "*??\0" "a\0"
218 "1" "*??\0" "ab\0"
219 "1" "*??\0" "abc\0"
220 "1" "*??\0" "abcd\0"
221 "0" "??*\0" "a\0"
222 "1" "??*\0" "ab\0"
223 "1" "??*\0" "abc\0"
224 "1" "??*\0" "abcd\0"
225 "0" "?*?\0" "a\0"
226 "1" "?*?\0" "ab\0"
227 "1" "?*?\0" "abc\0"
228 "1" "?*?\0" "abcd\0"
229 "1" "*b\0" "b\0"
230 "1" "*b\0" "ab\0"
231 "0" "*b\0" "ba\0"
232 "1" "*b\0" "bb\0"
233 "1" "*b\0" "abb\0"
234 "1" "*b\0" "bab\0"
235 "1" "*bc\0" "abbc\0"
236 "1" "*bc\0" "bc\0"
237 "1" "*bc\0" "bbc\0"
238 "1" "*bc\0" "bcbc\0"
239 /* Multiple asterisks (complex backtracking) */
240 "1" "*ac*\0" "abacadaeafag\0"
241 "1" "*ac*ae*ag*\0" "abacadaeafag\0"
242 "1" "*a*b*[bc]*[ef]*g*\0" "abacadaeafag\0"
243 "0" "*a*b*[ef]*[cd]*g*\0" "abacadaeafag\0"
244 "1" "*abcd*\0" "abcabcabcabcdefg\0"
245 "1" "*ab*cd*\0" "abcabcabcabcdefg\0"
246 "1" "*abcd*abcdef*\0" "abcabcdabcdeabcdefg\0"
247 "0" "*abcd*\0" "abcabcabcabcefg\0"
248 "0" "*ab*cd*\0" "abcabcabcabcefg\0";
249
250static int __init glob_init(void)
251{
252 unsigned successes = 0;
253 unsigned n = 0;
254 char const *p = glob_tests;
255 static char const message[] __initconst =
256 KERN_INFO "glob: %u self-tests passed, %u failed\n";
257
258 /*
259 * Tests are jammed together in a string. The first byte is '1'
260 * or '0' to indicate the expected outcome, or '\0' to indicate the
261 * end of the tests. Then come two null-terminated strings: the
262 * pattern and the string to match it against.
263 */
264 while (*p) {
265 bool expected = *p++ & 1;
266 char const *pat = p;
267
268 p += strlen(p) + 1;
269 successes += test(pat, p, expected);
270 p += strlen(p) + 1;
271 n++;
272 }
273
274 n -= successes;
275 printk(message, successes, n);
276
277 /* What's the errno for "kernel bug detected"? Guess... */
278 return n ? -ECANCELED : 0;
279}
280
281/* We need a dummy exit function to allow unload */
282static void __exit glob_fini(void) { }
283
284module_init(glob_init);
285module_exit(glob_fini);
286
287#endif /* CONFIG_GLOB_SELFTEST */
diff --git a/lib/hexdump.c b/lib/hexdump.c
index 8499c810909a..270773b91923 100644
--- a/lib/hexdump.c
+++ b/lib/hexdump.c
@@ -59,6 +59,22 @@ int hex2bin(u8 *dst, const char *src, size_t count)
59EXPORT_SYMBOL(hex2bin); 59EXPORT_SYMBOL(hex2bin);
60 60
61/** 61/**
62 * bin2hex - convert binary data to an ascii hexadecimal string
63 * @dst: ascii hexadecimal result
64 * @src: binary data
65 * @count: binary data length
66 */
67char *bin2hex(char *dst, const void *src, size_t count)
68{
69 const unsigned char *_src = src;
70
71 while (count--)
72 dst = hex_byte_pack(dst, *_src++);
73 return dst;
74}
75EXPORT_SYMBOL(bin2hex);
76
77/**
62 * hex_dump_to_buffer - convert a blob of data to "hex ASCII" in memory 78 * hex_dump_to_buffer - convert a blob of data to "hex ASCII" in memory
63 * @buf: data blob to dump 79 * @buf: data blob to dump
64 * @len: number of bytes in the @buf 80 * @len: number of bytes in the @buf
diff --git a/lib/hweight.c b/lib/hweight.c
index b7d81ba143d1..9a5c1f221558 100644
--- a/lib/hweight.c
+++ b/lib/hweight.c
@@ -11,7 +11,7 @@
11 11
12unsigned int __sw_hweight32(unsigned int w) 12unsigned int __sw_hweight32(unsigned int w)
13{ 13{
14#ifdef ARCH_HAS_FAST_MULTIPLIER 14#ifdef CONFIG_ARCH_HAS_FAST_MULTIPLIER
15 w -= (w >> 1) & 0x55555555; 15 w -= (w >> 1) & 0x55555555;
16 w = (w & 0x33333333) + ((w >> 2) & 0x33333333); 16 w = (w & 0x33333333) + ((w >> 2) & 0x33333333);
17 w = (w + (w >> 4)) & 0x0f0f0f0f; 17 w = (w + (w >> 4)) & 0x0f0f0f0f;
@@ -49,7 +49,7 @@ unsigned long __sw_hweight64(__u64 w)
49 return __sw_hweight32((unsigned int)(w >> 32)) + 49 return __sw_hweight32((unsigned int)(w >> 32)) +
50 __sw_hweight32((unsigned int)w); 50 __sw_hweight32((unsigned int)w);
51#elif BITS_PER_LONG == 64 51#elif BITS_PER_LONG == 64
52#ifdef ARCH_HAS_FAST_MULTIPLIER 52#ifdef CONFIG_ARCH_HAS_FAST_MULTIPLIER
53 w -= (w >> 1) & 0x5555555555555555ul; 53 w -= (w >> 1) & 0x5555555555555555ul;
54 w = (w & 0x3333333333333333ul) + ((w >> 2) & 0x3333333333333333ul); 54 w = (w & 0x3333333333333333ul) + ((w >> 2) & 0x3333333333333333ul);
55 w = (w + (w >> 4)) & 0x0f0f0f0f0f0f0f0ful; 55 w = (w + (w >> 4)) & 0x0f0f0f0f0f0f0f0ful;
diff --git a/lib/idr.c b/lib/idr.c
index 39158abebad1..e654aebd5f80 100644
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -590,26 +590,27 @@ static void __idr_remove_all(struct idr *idp)
590 struct idr_layer **paa = &pa[0]; 590 struct idr_layer **paa = &pa[0];
591 591
592 n = idp->layers * IDR_BITS; 592 n = idp->layers * IDR_BITS;
593 p = idp->top; 593 *paa = idp->top;
594 RCU_INIT_POINTER(idp->top, NULL); 594 RCU_INIT_POINTER(idp->top, NULL);
595 max = idr_max(idp->layers); 595 max = idr_max(idp->layers);
596 596
597 id = 0; 597 id = 0;
598 while (id >= 0 && id <= max) { 598 while (id >= 0 && id <= max) {
599 p = *paa;
599 while (n > IDR_BITS && p) { 600 while (n > IDR_BITS && p) {
600 n -= IDR_BITS; 601 n -= IDR_BITS;
601 *paa++ = p;
602 p = p->ary[(id >> n) & IDR_MASK]; 602 p = p->ary[(id >> n) & IDR_MASK];
603 *++paa = p;
603 } 604 }
604 605
605 bt_mask = id; 606 bt_mask = id;
606 id += 1 << n; 607 id += 1 << n;
607 /* Get the highest bit that the above add changed from 0->1. */ 608 /* Get the highest bit that the above add changed from 0->1. */
608 while (n < fls(id ^ bt_mask)) { 609 while (n < fls(id ^ bt_mask)) {
609 if (p) 610 if (*paa)
610 free_layer(idp, p); 611 free_layer(idp, *paa);
611 n += IDR_BITS; 612 n += IDR_BITS;
612 p = *--paa; 613 --paa;
613 } 614 }
614 } 615 }
615 idp->layers = 0; 616 idp->layers = 0;
@@ -625,7 +626,7 @@ static void __idr_remove_all(struct idr *idp)
625 * idr_destroy(). 626 * idr_destroy().
626 * 627 *
627 * A typical clean-up sequence for objects stored in an idr tree will use 628 * A typical clean-up sequence for objects stored in an idr tree will use
628 * idr_for_each() to free all objects, if necessay, then idr_destroy() to 629 * idr_for_each() to free all objects, if necessary, then idr_destroy() to
629 * free up the id mappings and cached idr_layers. 630 * free up the id mappings and cached idr_layers.
630 */ 631 */
631void idr_destroy(struct idr *idp) 632void idr_destroy(struct idr *idp)
@@ -692,15 +693,16 @@ int idr_for_each(struct idr *idp,
692 struct idr_layer **paa = &pa[0]; 693 struct idr_layer **paa = &pa[0];
693 694
694 n = idp->layers * IDR_BITS; 695 n = idp->layers * IDR_BITS;
695 p = rcu_dereference_raw(idp->top); 696 *paa = rcu_dereference_raw(idp->top);
696 max = idr_max(idp->layers); 697 max = idr_max(idp->layers);
697 698
698 id = 0; 699 id = 0;
699 while (id >= 0 && id <= max) { 700 while (id >= 0 && id <= max) {
701 p = *paa;
700 while (n > 0 && p) { 702 while (n > 0 && p) {
701 n -= IDR_BITS; 703 n -= IDR_BITS;
702 *paa++ = p;
703 p = rcu_dereference_raw(p->ary[(id >> n) & IDR_MASK]); 704 p = rcu_dereference_raw(p->ary[(id >> n) & IDR_MASK]);
705 *++paa = p;
704 } 706 }
705 707
706 if (p) { 708 if (p) {
@@ -712,7 +714,7 @@ int idr_for_each(struct idr *idp,
712 id += 1 << n; 714 id += 1 << n;
713 while (n < fls(id)) { 715 while (n < fls(id)) {
714 n += IDR_BITS; 716 n += IDR_BITS;
715 p = *--paa; 717 --paa;
716 } 718 }
717 } 719 }
718 720
@@ -740,17 +742,18 @@ void *idr_get_next(struct idr *idp, int *nextidp)
740 int n, max; 742 int n, max;
741 743
742 /* find first ent */ 744 /* find first ent */
743 p = rcu_dereference_raw(idp->top); 745 p = *paa = rcu_dereference_raw(idp->top);
744 if (!p) 746 if (!p)
745 return NULL; 747 return NULL;
746 n = (p->layer + 1) * IDR_BITS; 748 n = (p->layer + 1) * IDR_BITS;
747 max = idr_max(p->layer + 1); 749 max = idr_max(p->layer + 1);
748 750
749 while (id >= 0 && id <= max) { 751 while (id >= 0 && id <= max) {
752 p = *paa;
750 while (n > 0 && p) { 753 while (n > 0 && p) {
751 n -= IDR_BITS; 754 n -= IDR_BITS;
752 *paa++ = p;
753 p = rcu_dereference_raw(p->ary[(id >> n) & IDR_MASK]); 755 p = rcu_dereference_raw(p->ary[(id >> n) & IDR_MASK]);
756 *++paa = p;
754 } 757 }
755 758
756 if (p) { 759 if (p) {
@@ -768,7 +771,7 @@ void *idr_get_next(struct idr *idp, int *nextidp)
768 id = round_up(id + 1, 1 << n); 771 id = round_up(id + 1, 1 << n);
769 while (n < fls(id)) { 772 while (n < fls(id)) {
770 n += IDR_BITS; 773 n += IDR_BITS;
771 p = *--paa; 774 --paa;
772 } 775 }
773 } 776 }
774 return NULL; 777 return NULL;
diff --git a/lib/iovec.c b/lib/iovec.c
index 7a7c2da4cddf..df3abd1eaa4a 100644
--- a/lib/iovec.c
+++ b/lib/iovec.c
@@ -85,6 +85,10 @@ EXPORT_SYMBOL(memcpy_toiovecend);
85int memcpy_fromiovecend(unsigned char *kdata, const struct iovec *iov, 85int memcpy_fromiovecend(unsigned char *kdata, const struct iovec *iov,
86 int offset, int len) 86 int offset, int len)
87{ 87{
88 /* No data? Done! */
89 if (len == 0)
90 return 0;
91
88 /* Skip over the finished iovecs */ 92 /* Skip over the finished iovecs */
89 while (offset >= iov->iov_len) { 93 while (offset >= iov->iov_len) {
90 offset -= iov->iov_len; 94 offset -= iov->iov_len;
diff --git a/lib/kfifo.c b/lib/kfifo.c
index d79b9d222065..90ba1eb1df06 100644
--- a/lib/kfifo.c
+++ b/lib/kfifo.c
@@ -561,8 +561,7 @@ EXPORT_SYMBOL(__kfifo_to_user_r);
561unsigned int __kfifo_dma_in_prepare_r(struct __kfifo *fifo, 561unsigned int __kfifo_dma_in_prepare_r(struct __kfifo *fifo,
562 struct scatterlist *sgl, int nents, unsigned int len, size_t recsize) 562 struct scatterlist *sgl, int nents, unsigned int len, size_t recsize)
563{ 563{
564 if (!nents) 564 BUG_ON(!nents);
565 BUG();
566 565
567 len = __kfifo_max_r(len, recsize); 566 len = __kfifo_max_r(len, recsize);
568 567
@@ -585,8 +584,7 @@ EXPORT_SYMBOL(__kfifo_dma_in_finish_r);
585unsigned int __kfifo_dma_out_prepare_r(struct __kfifo *fifo, 584unsigned int __kfifo_dma_out_prepare_r(struct __kfifo *fifo,
586 struct scatterlist *sgl, int nents, unsigned int len, size_t recsize) 585 struct scatterlist *sgl, int nents, unsigned int len, size_t recsize)
587{ 586{
588 if (!nents) 587 BUG_ON(!nents);
589 BUG();
590 588
591 len = __kfifo_max_r(len, recsize); 589 len = __kfifo_max_r(len, recsize);
592 590
diff --git a/lib/klist.c b/lib/klist.c
index 358a368a2947..89b485a2a58d 100644
--- a/lib/klist.c
+++ b/lib/klist.c
@@ -140,11 +140,11 @@ void klist_add_tail(struct klist_node *n, struct klist *k)
140EXPORT_SYMBOL_GPL(klist_add_tail); 140EXPORT_SYMBOL_GPL(klist_add_tail);
141 141
142/** 142/**
143 * klist_add_after - Init a klist_node and add it after an existing node 143 * klist_add_behind - Init a klist_node and add it after an existing node
144 * @n: node we're adding. 144 * @n: node we're adding.
145 * @pos: node to put @n after 145 * @pos: node to put @n after
146 */ 146 */
147void klist_add_after(struct klist_node *n, struct klist_node *pos) 147void klist_add_behind(struct klist_node *n, struct klist_node *pos)
148{ 148{
149 struct klist *k = knode_klist(pos); 149 struct klist *k = knode_klist(pos);
150 150
@@ -153,7 +153,7 @@ void klist_add_after(struct klist_node *n, struct klist_node *pos)
153 list_add(&n->n_node, &pos->n_node); 153 list_add(&n->n_node, &pos->n_node);
154 spin_unlock(&k->k_lock); 154 spin_unlock(&k->k_lock);
155} 155}
156EXPORT_SYMBOL_GPL(klist_add_after); 156EXPORT_SYMBOL_GPL(klist_add_behind);
157 157
158/** 158/**
159 * klist_add_before - Init a klist_node and add it before an existing node 159 * klist_add_before - Init a klist_node and add it before an existing node
diff --git a/lib/libcrc32c.c b/lib/libcrc32c.c
index b3131f5cf8a2..6a08ce7d6adc 100644
--- a/lib/libcrc32c.c
+++ b/lib/libcrc32c.c
@@ -41,20 +41,18 @@ static struct crypto_shash *tfm;
41 41
42u32 crc32c(u32 crc, const void *address, unsigned int length) 42u32 crc32c(u32 crc, const void *address, unsigned int length)
43{ 43{
44 struct { 44 SHASH_DESC_ON_STACK(shash, tfm);
45 struct shash_desc shash; 45 u32 *ctx = (u32 *)shash_desc_ctx(shash);
46 char ctx[crypto_shash_descsize(tfm)];
47 } desc;
48 int err; 46 int err;
49 47
50 desc.shash.tfm = tfm; 48 shash->tfm = tfm;
51 desc.shash.flags = 0; 49 shash->flags = 0;
52 *(u32 *)desc.ctx = crc; 50 *ctx = crc;
53 51
54 err = crypto_shash_update(&desc.shash, address, length); 52 err = crypto_shash_update(shash, address, length);
55 BUG_ON(err); 53 BUG_ON(err);
56 54
57 return *(u32 *)desc.ctx; 55 return *ctx;
58} 56}
59 57
60EXPORT_SYMBOL(crc32c); 58EXPORT_SYMBOL(crc32c);
diff --git a/lib/list_sort.c b/lib/list_sort.c
index 1183fa70a44d..12bcba1c8612 100644
--- a/lib/list_sort.c
+++ b/lib/list_sort.c
@@ -1,3 +1,6 @@
1
2#define pr_fmt(fmt) "list_sort_test: " fmt
3
1#include <linux/kernel.h> 4#include <linux/kernel.h>
2#include <linux/module.h> 5#include <linux/module.h>
3#include <linux/list_sort.h> 6#include <linux/list_sort.h>
@@ -47,6 +50,7 @@ static void merge_and_restore_back_links(void *priv,
47 struct list_head *a, struct list_head *b) 50 struct list_head *a, struct list_head *b)
48{ 51{
49 struct list_head *tail = head; 52 struct list_head *tail = head;
53 u8 count = 0;
50 54
51 while (a && b) { 55 while (a && b) {
52 /* if equal, take 'a' -- important for sort stability */ 56 /* if equal, take 'a' -- important for sort stability */
@@ -70,7 +74,8 @@ static void merge_and_restore_back_links(void *priv,
70 * element comparison is needed, so the client's cmp() 74 * element comparison is needed, so the client's cmp()
71 * routine can invoke cond_resched() periodically. 75 * routine can invoke cond_resched() periodically.
72 */ 76 */
73 (*cmp)(priv, tail->next, tail->next); 77 if (unlikely(!(++count)))
78 (*cmp)(priv, tail->next, tail->next);
74 79
75 tail->next->prev = tail; 80 tail->next->prev = tail;
76 tail = tail->next; 81 tail = tail->next;
@@ -123,9 +128,7 @@ void list_sort(void *priv, struct list_head *head,
123 } 128 }
124 if (lev > max_lev) { 129 if (lev > max_lev) {
125 if (unlikely(lev >= ARRAY_SIZE(part)-1)) { 130 if (unlikely(lev >= ARRAY_SIZE(part)-1)) {
126 printk_once(KERN_DEBUG "list passed to" 131 printk_once(KERN_DEBUG "list too long for efficiency\n");
127 " list_sort() too long for"
128 " efficiency\n");
129 lev--; 132 lev--;
130 } 133 }
131 max_lev = lev; 134 max_lev = lev;
@@ -168,27 +171,25 @@ static struct debug_el **elts __initdata;
168static int __init check(struct debug_el *ela, struct debug_el *elb) 171static int __init check(struct debug_el *ela, struct debug_el *elb)
169{ 172{
170 if (ela->serial >= TEST_LIST_LEN) { 173 if (ela->serial >= TEST_LIST_LEN) {
171 printk(KERN_ERR "list_sort_test: error: incorrect serial %d\n", 174 pr_err("error: incorrect serial %d\n", ela->serial);
172 ela->serial);
173 return -EINVAL; 175 return -EINVAL;
174 } 176 }
175 if (elb->serial >= TEST_LIST_LEN) { 177 if (elb->serial >= TEST_LIST_LEN) {
176 printk(KERN_ERR "list_sort_test: error: incorrect serial %d\n", 178 pr_err("error: incorrect serial %d\n", elb->serial);
177 elb->serial);
178 return -EINVAL; 179 return -EINVAL;
179 } 180 }
180 if (elts[ela->serial] != ela || elts[elb->serial] != elb) { 181 if (elts[ela->serial] != ela || elts[elb->serial] != elb) {
181 printk(KERN_ERR "list_sort_test: error: phantom element\n"); 182 pr_err("error: phantom element\n");
182 return -EINVAL; 183 return -EINVAL;
183 } 184 }
184 if (ela->poison1 != TEST_POISON1 || ela->poison2 != TEST_POISON2) { 185 if (ela->poison1 != TEST_POISON1 || ela->poison2 != TEST_POISON2) {
185 printk(KERN_ERR "list_sort_test: error: bad poison: %#x/%#x\n", 186 pr_err("error: bad poison: %#x/%#x\n",
186 ela->poison1, ela->poison2); 187 ela->poison1, ela->poison2);
187 return -EINVAL; 188 return -EINVAL;
188 } 189 }
189 if (elb->poison1 != TEST_POISON1 || elb->poison2 != TEST_POISON2) { 190 if (elb->poison1 != TEST_POISON1 || elb->poison2 != TEST_POISON2) {
190 printk(KERN_ERR "list_sort_test: error: bad poison: %#x/%#x\n", 191 pr_err("error: bad poison: %#x/%#x\n",
191 elb->poison1, elb->poison2); 192 elb->poison1, elb->poison2);
192 return -EINVAL; 193 return -EINVAL;
193 } 194 }
194 return 0; 195 return 0;
@@ -207,25 +208,23 @@ static int __init cmp(void *priv, struct list_head *a, struct list_head *b)
207 208
208static int __init list_sort_test(void) 209static int __init list_sort_test(void)
209{ 210{
210 int i, count = 1, err = -EINVAL; 211 int i, count = 1, err = -ENOMEM;
211 struct debug_el *el; 212 struct debug_el *el;
212 struct list_head *cur, *tmp; 213 struct list_head *cur;
213 LIST_HEAD(head); 214 LIST_HEAD(head);
214 215
215 printk(KERN_DEBUG "list_sort_test: start testing list_sort()\n"); 216 pr_debug("start testing list_sort()\n");
216 217
217 elts = kmalloc(sizeof(void *) * TEST_LIST_LEN, GFP_KERNEL); 218 elts = kcalloc(TEST_LIST_LEN, sizeof(*elts), GFP_KERNEL);
218 if (!elts) { 219 if (!elts) {
219 printk(KERN_ERR "list_sort_test: error: cannot allocate " 220 pr_err("error: cannot allocate memory\n");
220 "memory\n"); 221 return err;
221 goto exit;
222 } 222 }
223 223
224 for (i = 0; i < TEST_LIST_LEN; i++) { 224 for (i = 0; i < TEST_LIST_LEN; i++) {
225 el = kmalloc(sizeof(*el), GFP_KERNEL); 225 el = kmalloc(sizeof(*el), GFP_KERNEL);
226 if (!el) { 226 if (!el) {
227 printk(KERN_ERR "list_sort_test: error: cannot " 227 pr_err("error: cannot allocate memory\n");
228 "allocate memory\n");
229 goto exit; 228 goto exit;
230 } 229 }
231 /* force some equivalencies */ 230 /* force some equivalencies */
@@ -239,52 +238,52 @@ static int __init list_sort_test(void)
239 238
240 list_sort(NULL, &head, cmp); 239 list_sort(NULL, &head, cmp);
241 240
241 err = -EINVAL;
242 for (cur = head.next; cur->next != &head; cur = cur->next) { 242 for (cur = head.next; cur->next != &head; cur = cur->next) {
243 struct debug_el *el1; 243 struct debug_el *el1;
244 int cmp_result; 244 int cmp_result;
245 245
246 if (cur->next->prev != cur) { 246 if (cur->next->prev != cur) {
247 printk(KERN_ERR "list_sort_test: error: list is " 247 pr_err("error: list is corrupted\n");
248 "corrupted\n");
249 goto exit; 248 goto exit;
250 } 249 }
251 250
252 cmp_result = cmp(NULL, cur, cur->next); 251 cmp_result = cmp(NULL, cur, cur->next);
253 if (cmp_result > 0) { 252 if (cmp_result > 0) {
254 printk(KERN_ERR "list_sort_test: error: list is not " 253 pr_err("error: list is not sorted\n");
255 "sorted\n");
256 goto exit; 254 goto exit;
257 } 255 }
258 256
259 el = container_of(cur, struct debug_el, list); 257 el = container_of(cur, struct debug_el, list);
260 el1 = container_of(cur->next, struct debug_el, list); 258 el1 = container_of(cur->next, struct debug_el, list);
261 if (cmp_result == 0 && el->serial >= el1->serial) { 259 if (cmp_result == 0 && el->serial >= el1->serial) {
262 printk(KERN_ERR "list_sort_test: error: order of " 260 pr_err("error: order of equivalent elements not "
263 "equivalent elements not preserved\n"); 261 "preserved\n");
264 goto exit; 262 goto exit;
265 } 263 }
266 264
267 if (check(el, el1)) { 265 if (check(el, el1)) {
268 printk(KERN_ERR "list_sort_test: error: element check " 266 pr_err("error: element check failed\n");
269 "failed\n");
270 goto exit; 267 goto exit;
271 } 268 }
272 count++; 269 count++;
273 } 270 }
271 if (head.prev != cur) {
272 pr_err("error: list is corrupted\n");
273 goto exit;
274 }
275
274 276
275 if (count != TEST_LIST_LEN) { 277 if (count != TEST_LIST_LEN) {
276 printk(KERN_ERR "list_sort_test: error: bad list length %d", 278 pr_err("error: bad list length %d", count);
277 count);
278 goto exit; 279 goto exit;
279 } 280 }
280 281
281 err = 0; 282 err = 0;
282exit: 283exit:
284 for (i = 0; i < TEST_LIST_LEN; i++)
285 kfree(elts[i]);
283 kfree(elts); 286 kfree(elts);
284 list_for_each_safe(cur, tmp, &head) {
285 list_del(cur);
286 kfree(container_of(cur, struct debug_el, list));
287 }
288 return err; 287 return err;
289} 288}
290module_init(list_sort_test); 289module_init(list_sort_test);
diff --git a/lib/lru_cache.c b/lib/lru_cache.c
index 4a83ecd03650..852c81e3ba9a 100644
--- a/lib/lru_cache.c
+++ b/lib/lru_cache.c
@@ -169,7 +169,7 @@ out_fail:
169 return NULL; 169 return NULL;
170} 170}
171 171
172void lc_free_by_index(struct lru_cache *lc, unsigned i) 172static void lc_free_by_index(struct lru_cache *lc, unsigned i)
173{ 173{
174 void *p = lc->lc_element[i]; 174 void *p = lc->lc_element[i];
175 WARN_ON(!p); 175 WARN_ON(!p);
@@ -643,9 +643,10 @@ void lc_set(struct lru_cache *lc, unsigned int enr, int index)
643 * lc_dump - Dump a complete LRU cache to seq in textual form. 643 * lc_dump - Dump a complete LRU cache to seq in textual form.
644 * @lc: the lru cache to operate on 644 * @lc: the lru cache to operate on
645 * @seq: the &struct seq_file pointer to seq_printf into 645 * @seq: the &struct seq_file pointer to seq_printf into
646 * @utext: user supplied "heading" or other info 646 * @utext: user supplied additional "heading" or other info
647 * @detail: function pointer the user may provide to dump further details 647 * @detail: function pointer the user may provide to dump further details
648 * of the object the lc_element is embedded in. 648 * of the object the lc_element is embedded in. May be NULL.
649 * Note: a leading space ' ' and trailing newline '\n' is implied.
649 */ 650 */
650void lc_seq_dump_details(struct seq_file *seq, struct lru_cache *lc, char *utext, 651void lc_seq_dump_details(struct seq_file *seq, struct lru_cache *lc, char *utext,
651 void (*detail) (struct seq_file *, struct lc_element *)) 652 void (*detail) (struct seq_file *, struct lc_element *))
@@ -654,16 +655,18 @@ void lc_seq_dump_details(struct seq_file *seq, struct lru_cache *lc, char *utext
654 struct lc_element *e; 655 struct lc_element *e;
655 int i; 656 int i;
656 657
657 seq_printf(seq, "\tnn: lc_number refcnt %s\n ", utext); 658 seq_printf(seq, "\tnn: lc_number (new nr) refcnt %s\n ", utext);
658 for (i = 0; i < nr_elements; i++) { 659 for (i = 0; i < nr_elements; i++) {
659 e = lc_element_by_index(lc, i); 660 e = lc_element_by_index(lc, i);
660 if (e->lc_number == LC_FREE) { 661 if (e->lc_number != e->lc_new_number)
661 seq_printf(seq, "\t%2d: FREE\n", i); 662 seq_printf(seq, "\t%5d: %6d %8d %6d ",
662 } else { 663 i, e->lc_number, e->lc_new_number, e->refcnt);
663 seq_printf(seq, "\t%2d: %4u %4u ", i, 664 else
664 e->lc_number, e->refcnt); 665 seq_printf(seq, "\t%5d: %6d %-8s %6d ",
666 i, e->lc_number, "-\"-", e->refcnt);
667 if (detail)
665 detail(seq, e); 668 detail(seq, e);
666 } 669 seq_putc(seq, '\n');
667 } 670 }
668} 671}
669 672
diff --git a/lib/lzo/lzo1x_decompress_safe.c b/lib/lzo/lzo1x_decompress_safe.c
index 8563081e8da3..a1c387f6afba 100644
--- a/lib/lzo/lzo1x_decompress_safe.c
+++ b/lib/lzo/lzo1x_decompress_safe.c
@@ -19,31 +19,21 @@
19#include <linux/lzo.h> 19#include <linux/lzo.h>
20#include "lzodefs.h" 20#include "lzodefs.h"
21 21
22#define HAVE_IP(t, x) \ 22#define HAVE_IP(x) ((size_t)(ip_end - ip) >= (size_t)(x))
23 (((size_t)(ip_end - ip) >= (size_t)(t + x)) && \ 23#define HAVE_OP(x) ((size_t)(op_end - op) >= (size_t)(x))
24 (((t + x) >= t) && ((t + x) >= x))) 24#define NEED_IP(x) if (!HAVE_IP(x)) goto input_overrun
25#define NEED_OP(x) if (!HAVE_OP(x)) goto output_overrun
26#define TEST_LB(m_pos) if ((m_pos) < out) goto lookbehind_overrun
25 27
26#define HAVE_OP(t, x) \ 28/* This MAX_255_COUNT is the maximum number of times we can add 255 to a base
27 (((size_t)(op_end - op) >= (size_t)(t + x)) && \ 29 * count without overflowing an integer. The multiply will overflow when
28 (((t + x) >= t) && ((t + x) >= x))) 30 * multiplying 255 by more than MAXINT/255. The sum will overflow earlier
29 31 * depending on the base count. Since the base count is taken from a u8
30#define NEED_IP(t, x) \ 32 * and a few bits, it is safe to assume that it will always be lower than
31 do { \ 33 * or equal to 2*255, thus we can always prevent any overflow by accepting
32 if (!HAVE_IP(t, x)) \ 34 * two less 255 steps. See Documentation/lzo.txt for more information.
33 goto input_overrun; \ 35 */
34 } while (0) 36#define MAX_255_COUNT ((((size_t)~0) / 255) - 2)
35
36#define NEED_OP(t, x) \
37 do { \
38 if (!HAVE_OP(t, x)) \
39 goto output_overrun; \
40 } while (0)
41
42#define TEST_LB(m_pos) \
43 do { \
44 if ((m_pos) < out) \
45 goto lookbehind_overrun; \
46 } while (0)
47 37
48int lzo1x_decompress_safe(const unsigned char *in, size_t in_len, 38int lzo1x_decompress_safe(const unsigned char *in, size_t in_len,
49 unsigned char *out, size_t *out_len) 39 unsigned char *out, size_t *out_len)
@@ -75,17 +65,24 @@ int lzo1x_decompress_safe(const unsigned char *in, size_t in_len,
75 if (t < 16) { 65 if (t < 16) {
76 if (likely(state == 0)) { 66 if (likely(state == 0)) {
77 if (unlikely(t == 0)) { 67 if (unlikely(t == 0)) {
68 size_t offset;
69 const unsigned char *ip_last = ip;
70
78 while (unlikely(*ip == 0)) { 71 while (unlikely(*ip == 0)) {
79 t += 255;
80 ip++; 72 ip++;
81 NEED_IP(1, 0); 73 NEED_IP(1);
82 } 74 }
83 t += 15 + *ip++; 75 offset = ip - ip_last;
76 if (unlikely(offset > MAX_255_COUNT))
77 return LZO_E_ERROR;
78
79 offset = (offset << 8) - offset;
80 t += offset + 15 + *ip++;
84 } 81 }
85 t += 3; 82 t += 3;
86copy_literal_run: 83copy_literal_run:
87#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) 84#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
88 if (likely(HAVE_IP(t, 15) && HAVE_OP(t, 15))) { 85 if (likely(HAVE_IP(t + 15) && HAVE_OP(t + 15))) {
89 const unsigned char *ie = ip + t; 86 const unsigned char *ie = ip + t;
90 unsigned char *oe = op + t; 87 unsigned char *oe = op + t;
91 do { 88 do {
@@ -101,8 +98,8 @@ copy_literal_run:
101 } else 98 } else
102#endif 99#endif
103 { 100 {
104 NEED_OP(t, 0); 101 NEED_OP(t);
105 NEED_IP(t, 3); 102 NEED_IP(t + 3);
106 do { 103 do {
107 *op++ = *ip++; 104 *op++ = *ip++;
108 } while (--t > 0); 105 } while (--t > 0);
@@ -115,7 +112,7 @@ copy_literal_run:
115 m_pos -= t >> 2; 112 m_pos -= t >> 2;
116 m_pos -= *ip++ << 2; 113 m_pos -= *ip++ << 2;
117 TEST_LB(m_pos); 114 TEST_LB(m_pos);
118 NEED_OP(2, 0); 115 NEED_OP(2);
119 op[0] = m_pos[0]; 116 op[0] = m_pos[0];
120 op[1] = m_pos[1]; 117 op[1] = m_pos[1];
121 op += 2; 118 op += 2;
@@ -136,13 +133,20 @@ copy_literal_run:
136 } else if (t >= 32) { 133 } else if (t >= 32) {
137 t = (t & 31) + (3 - 1); 134 t = (t & 31) + (3 - 1);
138 if (unlikely(t == 2)) { 135 if (unlikely(t == 2)) {
136 size_t offset;
137 const unsigned char *ip_last = ip;
138
139 while (unlikely(*ip == 0)) { 139 while (unlikely(*ip == 0)) {
140 t += 255;
141 ip++; 140 ip++;
142 NEED_IP(1, 0); 141 NEED_IP(1);
143 } 142 }
144 t += 31 + *ip++; 143 offset = ip - ip_last;
145 NEED_IP(2, 0); 144 if (unlikely(offset > MAX_255_COUNT))
145 return LZO_E_ERROR;
146
147 offset = (offset << 8) - offset;
148 t += offset + 31 + *ip++;
149 NEED_IP(2);
146 } 150 }
147 m_pos = op - 1; 151 m_pos = op - 1;
148 next = get_unaligned_le16(ip); 152 next = get_unaligned_le16(ip);
@@ -154,13 +158,20 @@ copy_literal_run:
154 m_pos -= (t & 8) << 11; 158 m_pos -= (t & 8) << 11;
155 t = (t & 7) + (3 - 1); 159 t = (t & 7) + (3 - 1);
156 if (unlikely(t == 2)) { 160 if (unlikely(t == 2)) {
161 size_t offset;
162 const unsigned char *ip_last = ip;
163
157 while (unlikely(*ip == 0)) { 164 while (unlikely(*ip == 0)) {
158 t += 255;
159 ip++; 165 ip++;
160 NEED_IP(1, 0); 166 NEED_IP(1);
161 } 167 }
162 t += 7 + *ip++; 168 offset = ip - ip_last;
163 NEED_IP(2, 0); 169 if (unlikely(offset > MAX_255_COUNT))
170 return LZO_E_ERROR;
171
172 offset = (offset << 8) - offset;
173 t += offset + 7 + *ip++;
174 NEED_IP(2);
164 } 175 }
165 next = get_unaligned_le16(ip); 176 next = get_unaligned_le16(ip);
166 ip += 2; 177 ip += 2;
@@ -174,7 +185,7 @@ copy_literal_run:
174#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) 185#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
175 if (op - m_pos >= 8) { 186 if (op - m_pos >= 8) {
176 unsigned char *oe = op + t; 187 unsigned char *oe = op + t;
177 if (likely(HAVE_OP(t, 15))) { 188 if (likely(HAVE_OP(t + 15))) {
178 do { 189 do {
179 COPY8(op, m_pos); 190 COPY8(op, m_pos);
180 op += 8; 191 op += 8;
@@ -184,7 +195,7 @@ copy_literal_run:
184 m_pos += 8; 195 m_pos += 8;
185 } while (op < oe); 196 } while (op < oe);
186 op = oe; 197 op = oe;
187 if (HAVE_IP(6, 0)) { 198 if (HAVE_IP(6)) {
188 state = next; 199 state = next;
189 COPY4(op, ip); 200 COPY4(op, ip);
190 op += next; 201 op += next;
@@ -192,7 +203,7 @@ copy_literal_run:
192 continue; 203 continue;
193 } 204 }
194 } else { 205 } else {
195 NEED_OP(t, 0); 206 NEED_OP(t);
196 do { 207 do {
197 *op++ = *m_pos++; 208 *op++ = *m_pos++;
198 } while (op < oe); 209 } while (op < oe);
@@ -201,7 +212,7 @@ copy_literal_run:
201#endif 212#endif
202 { 213 {
203 unsigned char *oe = op + t; 214 unsigned char *oe = op + t;
204 NEED_OP(t, 0); 215 NEED_OP(t);
205 op[0] = m_pos[0]; 216 op[0] = m_pos[0];
206 op[1] = m_pos[1]; 217 op[1] = m_pos[1];
207 op += 2; 218 op += 2;
@@ -214,15 +225,15 @@ match_next:
214 state = next; 225 state = next;
215 t = next; 226 t = next;
216#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) 227#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
217 if (likely(HAVE_IP(6, 0) && HAVE_OP(4, 0))) { 228 if (likely(HAVE_IP(6) && HAVE_OP(4))) {
218 COPY4(op, ip); 229 COPY4(op, ip);
219 op += t; 230 op += t;
220 ip += t; 231 ip += t;
221 } else 232 } else
222#endif 233#endif
223 { 234 {
224 NEED_IP(t, 3); 235 NEED_IP(t + 3);
225 NEED_OP(t, 0); 236 NEED_OP(t);
226 while (t > 0) { 237 while (t > 0) {
227 *op++ = *ip++; 238 *op++ = *ip++;
228 t--; 239 t--;
diff --git a/lib/net_utils.c b/lib/net_utils.c
index 2e3c52c8d050..148fc6e99ef6 100644
--- a/lib/net_utils.c
+++ b/lib/net_utils.c
@@ -3,24 +3,24 @@
3#include <linux/ctype.h> 3#include <linux/ctype.h>
4#include <linux/kernel.h> 4#include <linux/kernel.h>
5 5
6int mac_pton(const char *s, u8 *mac) 6bool mac_pton(const char *s, u8 *mac)
7{ 7{
8 int i; 8 int i;
9 9
10 /* XX:XX:XX:XX:XX:XX */ 10 /* XX:XX:XX:XX:XX:XX */
11 if (strlen(s) < 3 * ETH_ALEN - 1) 11 if (strlen(s) < 3 * ETH_ALEN - 1)
12 return 0; 12 return false;
13 13
14 /* Don't dirty result unless string is valid MAC. */ 14 /* Don't dirty result unless string is valid MAC. */
15 for (i = 0; i < ETH_ALEN; i++) { 15 for (i = 0; i < ETH_ALEN; i++) {
16 if (!isxdigit(s[i * 3]) || !isxdigit(s[i * 3 + 1])) 16 if (!isxdigit(s[i * 3]) || !isxdigit(s[i * 3 + 1]))
17 return 0; 17 return false;
18 if (i != ETH_ALEN - 1 && s[i * 3 + 2] != ':') 18 if (i != ETH_ALEN - 1 && s[i * 3 + 2] != ':')
19 return 0; 19 return false;
20 } 20 }
21 for (i = 0; i < ETH_ALEN; i++) { 21 for (i = 0; i < ETH_ALEN; i++) {
22 mac[i] = (hex_to_bin(s[i * 3]) << 4) | hex_to_bin(s[i * 3 + 1]); 22 mac[i] = (hex_to_bin(s[i * 3]) << 4) | hex_to_bin(s[i * 3 + 1]);
23 } 23 }
24 return 1; 24 return true;
25} 25}
26EXPORT_SYMBOL(mac_pton); 26EXPORT_SYMBOL(mac_pton);
diff --git a/lib/percpu-refcount.c b/lib/percpu-refcount.c
index fe5a3342e960..6111bcb28376 100644
--- a/lib/percpu-refcount.c
+++ b/lib/percpu-refcount.c
@@ -1,6 +1,8 @@
1#define pr_fmt(fmt) "%s: " fmt "\n", __func__ 1#define pr_fmt(fmt) "%s: " fmt "\n", __func__
2 2
3#include <linux/kernel.h> 3#include <linux/kernel.h>
4#include <linux/sched.h>
5#include <linux/wait.h>
4#include <linux/percpu-refcount.h> 6#include <linux/percpu-refcount.h>
5 7
6/* 8/*
@@ -11,8 +13,8 @@
11 * percpu counters will all sum to the correct value 13 * percpu counters will all sum to the correct value
12 * 14 *
13 * (More precisely: because moduler arithmatic is commutative the sum of all the 15 * (More precisely: because moduler arithmatic is commutative the sum of all the
14 * pcpu_count vars will be equal to what it would have been if all the gets and 16 * percpu_count vars will be equal to what it would have been if all the gets
15 * puts were done to a single integer, even if some of the percpu integers 17 * and puts were done to a single integer, even if some of the percpu integers
16 * overflow or underflow). 18 * overflow or underflow).
17 * 19 *
18 * The real trick to implementing percpu refcounts is shutdown. We can't detect 20 * The real trick to implementing percpu refcounts is shutdown. We can't detect
@@ -25,75 +27,64 @@
25 * works. 27 * works.
26 * 28 *
27 * Converting to non percpu mode is done with some RCUish stuff in 29 * Converting to non percpu mode is done with some RCUish stuff in
28 * percpu_ref_kill. Additionally, we need a bias value so that the atomic_t 30 * percpu_ref_kill. Additionally, we need a bias value so that the
29 * can't hit 0 before we've added up all the percpu refs. 31 * atomic_long_t can't hit 0 before we've added up all the percpu refs.
30 */ 32 */
31 33
32#define PCPU_COUNT_BIAS (1U << 31) 34#define PERCPU_COUNT_BIAS (1LU << (BITS_PER_LONG - 1))
33 35
34static unsigned __percpu *pcpu_count_ptr(struct percpu_ref *ref) 36static DECLARE_WAIT_QUEUE_HEAD(percpu_ref_switch_waitq);
37
38static unsigned long __percpu *percpu_count_ptr(struct percpu_ref *ref)
35{ 39{
36 return (unsigned __percpu *)(ref->pcpu_count_ptr & ~PCPU_REF_DEAD); 40 return (unsigned long __percpu *)
41 (ref->percpu_count_ptr & ~__PERCPU_REF_ATOMIC_DEAD);
37} 42}
38 43
39/** 44/**
40 * percpu_ref_init - initialize a percpu refcount 45 * percpu_ref_init - initialize a percpu refcount
41 * @ref: percpu_ref to initialize 46 * @ref: percpu_ref to initialize
42 * @release: function which will be called when refcount hits 0 47 * @release: function which will be called when refcount hits 0
48 * @flags: PERCPU_REF_INIT_* flags
49 * @gfp: allocation mask to use
43 * 50 *
44 * Initializes the refcount in single atomic counter mode with a refcount of 1; 51 * Initializes @ref. If @flags is zero, @ref starts in percpu mode with a
45 * analagous to atomic_set(ref, 1). 52 * refcount of 1; analagous to atomic_long_set(ref, 1). See the
53 * definitions of PERCPU_REF_INIT_* flags for flag behaviors.
46 * 54 *
47 * Note that @release must not sleep - it may potentially be called from RCU 55 * Note that @release must not sleep - it may potentially be called from RCU
48 * callback context by percpu_ref_kill(). 56 * callback context by percpu_ref_kill().
49 */ 57 */
50int percpu_ref_init(struct percpu_ref *ref, percpu_ref_func_t *release) 58int percpu_ref_init(struct percpu_ref *ref, percpu_ref_func_t *release,
59 unsigned int flags, gfp_t gfp)
51{ 60{
52 atomic_set(&ref->count, 1 + PCPU_COUNT_BIAS); 61 size_t align = max_t(size_t, 1 << __PERCPU_REF_FLAG_BITS,
62 __alignof__(unsigned long));
63 unsigned long start_count = 0;
53 64
54 ref->pcpu_count_ptr = (unsigned long)alloc_percpu(unsigned); 65 ref->percpu_count_ptr = (unsigned long)
55 if (!ref->pcpu_count_ptr) 66 __alloc_percpu_gfp(sizeof(unsigned long), align, gfp);
67 if (!ref->percpu_count_ptr)
56 return -ENOMEM; 68 return -ENOMEM;
57 69
58 ref->release = release; 70 ref->force_atomic = flags & PERCPU_REF_INIT_ATOMIC;
59 return 0;
60}
61EXPORT_SYMBOL_GPL(percpu_ref_init);
62 71
63/** 72 if (flags & (PERCPU_REF_INIT_ATOMIC | PERCPU_REF_INIT_DEAD))
64 * percpu_ref_reinit - re-initialize a percpu refcount 73 ref->percpu_count_ptr |= __PERCPU_REF_ATOMIC;
65 * @ref: perpcu_ref to re-initialize 74 else
66 * 75 start_count += PERCPU_COUNT_BIAS;
67 * Re-initialize @ref so that it's in the same state as when it finished
68 * percpu_ref_init(). @ref must have been initialized successfully, killed
69 * and reached 0 but not exited.
70 *
71 * Note that percpu_ref_tryget[_live]() are safe to perform on @ref while
72 * this function is in progress.
73 */
74void percpu_ref_reinit(struct percpu_ref *ref)
75{
76 unsigned __percpu *pcpu_count = pcpu_count_ptr(ref);
77 int cpu;
78
79 BUG_ON(!pcpu_count);
80 WARN_ON(!percpu_ref_is_zero(ref));
81 76
82 atomic_set(&ref->count, 1 + PCPU_COUNT_BIAS); 77 if (flags & PERCPU_REF_INIT_DEAD)
78 ref->percpu_count_ptr |= __PERCPU_REF_DEAD;
79 else
80 start_count++;
83 81
84 /* 82 atomic_long_set(&ref->count, start_count);
85 * Restore per-cpu operation. smp_store_release() is paired with
86 * smp_read_barrier_depends() in __pcpu_ref_alive() and guarantees
87 * that the zeroing is visible to all percpu accesses which can see
88 * the following PCPU_REF_DEAD clearing.
89 */
90 for_each_possible_cpu(cpu)
91 *per_cpu_ptr(pcpu_count, cpu) = 0;
92 83
93 smp_store_release(&ref->pcpu_count_ptr, 84 ref->release = release;
94 ref->pcpu_count_ptr & ~PCPU_REF_DEAD); 85 return 0;
95} 86}
96EXPORT_SYMBOL_GPL(percpu_ref_reinit); 87EXPORT_SYMBOL_GPL(percpu_ref_init);
97 88
98/** 89/**
99 * percpu_ref_exit - undo percpu_ref_init() 90 * percpu_ref_exit - undo percpu_ref_init()
@@ -107,26 +98,39 @@ EXPORT_SYMBOL_GPL(percpu_ref_reinit);
107 */ 98 */
108void percpu_ref_exit(struct percpu_ref *ref) 99void percpu_ref_exit(struct percpu_ref *ref)
109{ 100{
110 unsigned __percpu *pcpu_count = pcpu_count_ptr(ref); 101 unsigned long __percpu *percpu_count = percpu_count_ptr(ref);
111 102
112 if (pcpu_count) { 103 if (percpu_count) {
113 free_percpu(pcpu_count); 104 free_percpu(percpu_count);
114 ref->pcpu_count_ptr = PCPU_REF_DEAD; 105 ref->percpu_count_ptr = __PERCPU_REF_ATOMIC_DEAD;
115 } 106 }
116} 107}
117EXPORT_SYMBOL_GPL(percpu_ref_exit); 108EXPORT_SYMBOL_GPL(percpu_ref_exit);
118 109
119static void percpu_ref_kill_rcu(struct rcu_head *rcu) 110static void percpu_ref_call_confirm_rcu(struct rcu_head *rcu)
111{
112 struct percpu_ref *ref = container_of(rcu, struct percpu_ref, rcu);
113
114 ref->confirm_switch(ref);
115 ref->confirm_switch = NULL;
116 wake_up_all(&percpu_ref_switch_waitq);
117
118 /* drop ref from percpu_ref_switch_to_atomic() */
119 percpu_ref_put(ref);
120}
121
122static void percpu_ref_switch_to_atomic_rcu(struct rcu_head *rcu)
120{ 123{
121 struct percpu_ref *ref = container_of(rcu, struct percpu_ref, rcu); 124 struct percpu_ref *ref = container_of(rcu, struct percpu_ref, rcu);
122 unsigned __percpu *pcpu_count = pcpu_count_ptr(ref); 125 unsigned long __percpu *percpu_count = percpu_count_ptr(ref);
123 unsigned count = 0; 126 unsigned long count = 0;
124 int cpu; 127 int cpu;
125 128
126 for_each_possible_cpu(cpu) 129 for_each_possible_cpu(cpu)
127 count += *per_cpu_ptr(pcpu_count, cpu); 130 count += *per_cpu_ptr(percpu_count, cpu);
128 131
129 pr_debug("global %i pcpu %i", atomic_read(&ref->count), (int) count); 132 pr_debug("global %ld percpu %ld",
133 atomic_long_read(&ref->count), (long)count);
130 134
131 /* 135 /*
132 * It's crucial that we sum the percpu counters _before_ adding the sum 136 * It's crucial that we sum the percpu counters _before_ adding the sum
@@ -140,21 +144,137 @@ static void percpu_ref_kill_rcu(struct rcu_head *rcu)
140 * reaching 0 before we add the percpu counts. But doing it at the same 144 * reaching 0 before we add the percpu counts. But doing it at the same
141 * time is equivalent and saves us atomic operations: 145 * time is equivalent and saves us atomic operations:
142 */ 146 */
147 atomic_long_add((long)count - PERCPU_COUNT_BIAS, &ref->count);
148
149 WARN_ONCE(atomic_long_read(&ref->count) <= 0,
150 "percpu ref (%pf) <= 0 (%ld) after switching to atomic",
151 ref->release, atomic_long_read(&ref->count));
152
153 /* @ref is viewed as dead on all CPUs, send out switch confirmation */
154 percpu_ref_call_confirm_rcu(rcu);
155}
156
157static void percpu_ref_noop_confirm_switch(struct percpu_ref *ref)
158{
159}
160
161static void __percpu_ref_switch_to_atomic(struct percpu_ref *ref,
162 percpu_ref_func_t *confirm_switch)
163{
164 if (!(ref->percpu_count_ptr & __PERCPU_REF_ATOMIC)) {
165 /* switching from percpu to atomic */
166 ref->percpu_count_ptr |= __PERCPU_REF_ATOMIC;
167
168 /*
169 * Non-NULL ->confirm_switch is used to indicate that
170 * switching is in progress. Use noop one if unspecified.
171 */
172 WARN_ON_ONCE(ref->confirm_switch);
173 ref->confirm_switch =
174 confirm_switch ?: percpu_ref_noop_confirm_switch;
175
176 percpu_ref_get(ref); /* put after confirmation */
177 call_rcu_sched(&ref->rcu, percpu_ref_switch_to_atomic_rcu);
178 } else if (confirm_switch) {
179 /*
180 * Somebody already set ATOMIC. Switching may still be in
181 * progress. @confirm_switch must be invoked after the
182 * switching is complete and a full sched RCU grace period
183 * has passed. Wait synchronously for the previous
184 * switching and schedule @confirm_switch invocation.
185 */
186 wait_event(percpu_ref_switch_waitq, !ref->confirm_switch);
187 ref->confirm_switch = confirm_switch;
188
189 percpu_ref_get(ref); /* put after confirmation */
190 call_rcu_sched(&ref->rcu, percpu_ref_call_confirm_rcu);
191 }
192}
193
194/**
195 * percpu_ref_switch_to_atomic - switch a percpu_ref to atomic mode
196 * @ref: percpu_ref to switch to atomic mode
197 * @confirm_switch: optional confirmation callback
198 *
199 * There's no reason to use this function for the usual reference counting.
200 * Use percpu_ref_kill[_and_confirm]().
201 *
202 * Schedule switching of @ref to atomic mode. All its percpu counts will
203 * be collected to the main atomic counter. On completion, when all CPUs
204 * are guaraneed to be in atomic mode, @confirm_switch, which may not
205 * block, is invoked. This function may be invoked concurrently with all
206 * the get/put operations and can safely be mixed with kill and reinit
207 * operations. Note that @ref will stay in atomic mode across kill/reinit
208 * cycles until percpu_ref_switch_to_percpu() is called.
209 *
210 * This function normally doesn't block and can be called from any context
211 * but it may block if @confirm_kill is specified and @ref is already in
212 * the process of switching to atomic mode. In such cases, @confirm_switch
213 * will be invoked after the switching is complete.
214 *
215 * Due to the way percpu_ref is implemented, @confirm_switch will be called
216 * after at least one full sched RCU grace period has passed but this is an
217 * implementation detail and must not be depended upon.
218 */
219void percpu_ref_switch_to_atomic(struct percpu_ref *ref,
220 percpu_ref_func_t *confirm_switch)
221{
222 ref->force_atomic = true;
223 __percpu_ref_switch_to_atomic(ref, confirm_switch);
224}
143 225
144 atomic_add((int) count - PCPU_COUNT_BIAS, &ref->count); 226static void __percpu_ref_switch_to_percpu(struct percpu_ref *ref)
227{
228 unsigned long __percpu *percpu_count = percpu_count_ptr(ref);
229 int cpu;
145 230
146 WARN_ONCE(atomic_read(&ref->count) <= 0, "percpu ref <= 0 (%i)", 231 BUG_ON(!percpu_count);
147 atomic_read(&ref->count));
148 232
149 /* @ref is viewed as dead on all CPUs, send out kill confirmation */ 233 if (!(ref->percpu_count_ptr & __PERCPU_REF_ATOMIC))
150 if (ref->confirm_kill) 234 return;
151 ref->confirm_kill(ref); 235
236 wait_event(percpu_ref_switch_waitq, !ref->confirm_switch);
237
238 atomic_long_add(PERCPU_COUNT_BIAS, &ref->count);
152 239
153 /* 240 /*
154 * Now we're in single atomic_t mode with a consistent refcount, so it's 241 * Restore per-cpu operation. smp_store_release() is paired with
155 * safe to drop our initial ref: 242 * smp_read_barrier_depends() in __ref_is_percpu() and guarantees
243 * that the zeroing is visible to all percpu accesses which can see
244 * the following __PERCPU_REF_ATOMIC clearing.
156 */ 245 */
157 percpu_ref_put(ref); 246 for_each_possible_cpu(cpu)
247 *per_cpu_ptr(percpu_count, cpu) = 0;
248
249 smp_store_release(&ref->percpu_count_ptr,
250 ref->percpu_count_ptr & ~__PERCPU_REF_ATOMIC);
251}
252
253/**
254 * percpu_ref_switch_to_percpu - switch a percpu_ref to percpu mode
255 * @ref: percpu_ref to switch to percpu mode
256 *
257 * There's no reason to use this function for the usual reference counting.
258 * To re-use an expired ref, use percpu_ref_reinit().
259 *
260 * Switch @ref to percpu mode. This function may be invoked concurrently
261 * with all the get/put operations and can safely be mixed with kill and
262 * reinit operations. This function reverses the sticky atomic state set
263 * by PERCPU_REF_INIT_ATOMIC or percpu_ref_switch_to_atomic(). If @ref is
264 * dying or dead, the actual switching takes place on the following
265 * percpu_ref_reinit().
266 *
267 * This function normally doesn't block and can be called from any context
268 * but it may block if @ref is in the process of switching to atomic mode
269 * by percpu_ref_switch_atomic().
270 */
271void percpu_ref_switch_to_percpu(struct percpu_ref *ref)
272{
273 ref->force_atomic = false;
274
275 /* a dying or dead ref can't be switched to percpu mode w/o reinit */
276 if (!(ref->percpu_count_ptr & __PERCPU_REF_DEAD))
277 __percpu_ref_switch_to_percpu(ref);
158} 278}
159 279
160/** 280/**
@@ -164,23 +284,48 @@ static void percpu_ref_kill_rcu(struct rcu_head *rcu)
164 * 284 *
165 * Equivalent to percpu_ref_kill() but also schedules kill confirmation if 285 * Equivalent to percpu_ref_kill() but also schedules kill confirmation if
166 * @confirm_kill is not NULL. @confirm_kill, which may not block, will be 286 * @confirm_kill is not NULL. @confirm_kill, which may not block, will be
167 * called after @ref is seen as dead from all CPUs - all further 287 * called after @ref is seen as dead from all CPUs at which point all
168 * invocations of percpu_ref_tryget() will fail. See percpu_ref_tryget() 288 * further invocations of percpu_ref_tryget_live() will fail. See
169 * for more details. 289 * percpu_ref_tryget_live() for details.
290 *
291 * This function normally doesn't block and can be called from any context
292 * but it may block if @confirm_kill is specified and @ref is in the
293 * process of switching to atomic mode by percpu_ref_switch_atomic().
170 * 294 *
171 * Due to the way percpu_ref is implemented, @confirm_kill will be called 295 * Due to the way percpu_ref is implemented, @confirm_switch will be called
172 * after at least one full RCU grace period has passed but this is an 296 * after at least one full sched RCU grace period has passed but this is an
173 * implementation detail and callers must not depend on it. 297 * implementation detail and must not be depended upon.
174 */ 298 */
175void percpu_ref_kill_and_confirm(struct percpu_ref *ref, 299void percpu_ref_kill_and_confirm(struct percpu_ref *ref,
176 percpu_ref_func_t *confirm_kill) 300 percpu_ref_func_t *confirm_kill)
177{ 301{
178 WARN_ONCE(ref->pcpu_count_ptr & PCPU_REF_DEAD, 302 WARN_ONCE(ref->percpu_count_ptr & __PERCPU_REF_DEAD,
179 "percpu_ref_kill() called more than once!\n"); 303 "%s called more than once on %pf!", __func__, ref->release);
180 304
181 ref->pcpu_count_ptr |= PCPU_REF_DEAD; 305 ref->percpu_count_ptr |= __PERCPU_REF_DEAD;
182 ref->confirm_kill = confirm_kill; 306 __percpu_ref_switch_to_atomic(ref, confirm_kill);
183 307 percpu_ref_put(ref);
184 call_rcu_sched(&ref->rcu, percpu_ref_kill_rcu);
185} 308}
186EXPORT_SYMBOL_GPL(percpu_ref_kill_and_confirm); 309EXPORT_SYMBOL_GPL(percpu_ref_kill_and_confirm);
310
311/**
312 * percpu_ref_reinit - re-initialize a percpu refcount
313 * @ref: perpcu_ref to re-initialize
314 *
315 * Re-initialize @ref so that it's in the same state as when it finished
316 * percpu_ref_init() ignoring %PERCPU_REF_INIT_DEAD. @ref must have been
317 * initialized successfully and reached 0 but not exited.
318 *
319 * Note that percpu_ref_tryget[_live]() are safe to perform on @ref while
320 * this function is in progress.
321 */
322void percpu_ref_reinit(struct percpu_ref *ref)
323{
324 WARN_ON_ONCE(!percpu_ref_is_zero(ref));
325
326 ref->percpu_count_ptr &= ~__PERCPU_REF_DEAD;
327 percpu_ref_get(ref);
328 if (!ref->force_atomic)
329 __percpu_ref_switch_to_percpu(ref);
330}
331EXPORT_SYMBOL_GPL(percpu_ref_reinit);
diff --git a/lib/percpu_counter.c b/lib/percpu_counter.c
index 7dd33577b905..48144cdae819 100644
--- a/lib/percpu_counter.c
+++ b/lib/percpu_counter.c
@@ -112,13 +112,15 @@ s64 __percpu_counter_sum(struct percpu_counter *fbc)
112} 112}
113EXPORT_SYMBOL(__percpu_counter_sum); 113EXPORT_SYMBOL(__percpu_counter_sum);
114 114
115int __percpu_counter_init(struct percpu_counter *fbc, s64 amount, 115int __percpu_counter_init(struct percpu_counter *fbc, s64 amount, gfp_t gfp,
116 struct lock_class_key *key) 116 struct lock_class_key *key)
117{ 117{
118 unsigned long flags __maybe_unused;
119
118 raw_spin_lock_init(&fbc->lock); 120 raw_spin_lock_init(&fbc->lock);
119 lockdep_set_class(&fbc->lock, key); 121 lockdep_set_class(&fbc->lock, key);
120 fbc->count = amount; 122 fbc->count = amount;
121 fbc->counters = alloc_percpu(s32); 123 fbc->counters = alloc_percpu_gfp(s32, gfp);
122 if (!fbc->counters) 124 if (!fbc->counters)
123 return -ENOMEM; 125 return -ENOMEM;
124 126
@@ -126,9 +128,9 @@ int __percpu_counter_init(struct percpu_counter *fbc, s64 amount,
126 128
127#ifdef CONFIG_HOTPLUG_CPU 129#ifdef CONFIG_HOTPLUG_CPU
128 INIT_LIST_HEAD(&fbc->list); 130 INIT_LIST_HEAD(&fbc->list);
129 spin_lock(&percpu_counters_lock); 131 spin_lock_irqsave(&percpu_counters_lock, flags);
130 list_add(&fbc->list, &percpu_counters); 132 list_add(&fbc->list, &percpu_counters);
131 spin_unlock(&percpu_counters_lock); 133 spin_unlock_irqrestore(&percpu_counters_lock, flags);
132#endif 134#endif
133 return 0; 135 return 0;
134} 136}
@@ -136,15 +138,17 @@ EXPORT_SYMBOL(__percpu_counter_init);
136 138
137void percpu_counter_destroy(struct percpu_counter *fbc) 139void percpu_counter_destroy(struct percpu_counter *fbc)
138{ 140{
141 unsigned long flags __maybe_unused;
142
139 if (!fbc->counters) 143 if (!fbc->counters)
140 return; 144 return;
141 145
142 debug_percpu_counter_deactivate(fbc); 146 debug_percpu_counter_deactivate(fbc);
143 147
144#ifdef CONFIG_HOTPLUG_CPU 148#ifdef CONFIG_HOTPLUG_CPU
145 spin_lock(&percpu_counters_lock); 149 spin_lock_irqsave(&percpu_counters_lock, flags);
146 list_del(&fbc->list); 150 list_del(&fbc->list);
147 spin_unlock(&percpu_counters_lock); 151 spin_unlock_irqrestore(&percpu_counters_lock, flags);
148#endif 152#endif
149 free_percpu(fbc->counters); 153 free_percpu(fbc->counters);
150 fbc->counters = NULL; 154 fbc->counters = NULL;
@@ -173,7 +177,7 @@ static int percpu_counter_hotcpu_callback(struct notifier_block *nb,
173 return NOTIFY_OK; 177 return NOTIFY_OK;
174 178
175 cpu = (unsigned long)hcpu; 179 cpu = (unsigned long)hcpu;
176 spin_lock(&percpu_counters_lock); 180 spin_lock_irq(&percpu_counters_lock);
177 list_for_each_entry(fbc, &percpu_counters, list) { 181 list_for_each_entry(fbc, &percpu_counters, list) {
178 s32 *pcount; 182 s32 *pcount;
179 unsigned long flags; 183 unsigned long flags;
@@ -184,7 +188,7 @@ static int percpu_counter_hotcpu_callback(struct notifier_block *nb,
184 *pcount = 0; 188 *pcount = 0;
185 raw_spin_unlock_irqrestore(&fbc->lock, flags); 189 raw_spin_unlock_irqrestore(&fbc->lock, flags);
186 } 190 }
187 spin_unlock(&percpu_counters_lock); 191 spin_unlock_irq(&percpu_counters_lock);
188#endif 192#endif
189 return NOTIFY_OK; 193 return NOTIFY_OK;
190} 194}
diff --git a/lib/prio_heap.c b/lib/prio_heap.c
deleted file mode 100644
index a7af6f85eca8..000000000000
--- a/lib/prio_heap.c
+++ /dev/null
@@ -1,70 +0,0 @@
1/*
2 * Simple insertion-only static-sized priority heap containing
3 * pointers, based on CLR, chapter 7
4 */
5
6#include <linux/slab.h>
7#include <linux/prio_heap.h>
8
9int heap_init(struct ptr_heap *heap, size_t size, gfp_t gfp_mask,
10 int (*gt)(void *, void *))
11{
12 heap->ptrs = kmalloc(size, gfp_mask);
13 if (!heap->ptrs)
14 return -ENOMEM;
15 heap->size = 0;
16 heap->max = size / sizeof(void *);
17 heap->gt = gt;
18 return 0;
19}
20
21void heap_free(struct ptr_heap *heap)
22{
23 kfree(heap->ptrs);
24}
25
26void *heap_insert(struct ptr_heap *heap, void *p)
27{
28 void *res;
29 void **ptrs = heap->ptrs;
30 int pos;
31
32 if (heap->size < heap->max) {
33 /* Heap insertion */
34 pos = heap->size++;
35 while (pos > 0 && heap->gt(p, ptrs[(pos-1)/2])) {
36 ptrs[pos] = ptrs[(pos-1)/2];
37 pos = (pos-1)/2;
38 }
39 ptrs[pos] = p;
40 return NULL;
41 }
42
43 /* The heap is full, so something will have to be dropped */
44
45 /* If the new pointer is greater than the current max, drop it */
46 if (heap->gt(p, ptrs[0]))
47 return p;
48
49 /* Replace the current max and heapify */
50 res = ptrs[0];
51 ptrs[0] = p;
52 pos = 0;
53
54 while (1) {
55 int left = 2 * pos + 1;
56 int right = 2 * pos + 2;
57 int largest = pos;
58 if (left < heap->size && heap->gt(ptrs[left], p))
59 largest = left;
60 if (right < heap->size && heap->gt(ptrs[right], ptrs[largest]))
61 largest = right;
62 if (largest == pos)
63 break;
64 /* Push p down the heap one level and bump one up */
65 ptrs[pos] = ptrs[largest];
66 ptrs[largest] = p;
67 pos = largest;
68 }
69 return res;
70}
diff --git a/lib/proportions.c b/lib/proportions.c
index 05df84801b56..6f724298f67a 100644
--- a/lib/proportions.c
+++ b/lib/proportions.c
@@ -73,7 +73,7 @@
73#include <linux/proportions.h> 73#include <linux/proportions.h>
74#include <linux/rcupdate.h> 74#include <linux/rcupdate.h>
75 75
76int prop_descriptor_init(struct prop_descriptor *pd, int shift) 76int prop_descriptor_init(struct prop_descriptor *pd, int shift, gfp_t gfp)
77{ 77{
78 int err; 78 int err;
79 79
@@ -83,11 +83,11 @@ int prop_descriptor_init(struct prop_descriptor *pd, int shift)
83 pd->index = 0; 83 pd->index = 0;
84 pd->pg[0].shift = shift; 84 pd->pg[0].shift = shift;
85 mutex_init(&pd->mutex); 85 mutex_init(&pd->mutex);
86 err = percpu_counter_init(&pd->pg[0].events, 0); 86 err = percpu_counter_init(&pd->pg[0].events, 0, gfp);
87 if (err) 87 if (err)
88 goto out; 88 goto out;
89 89
90 err = percpu_counter_init(&pd->pg[1].events, 0); 90 err = percpu_counter_init(&pd->pg[1].events, 0, gfp);
91 if (err) 91 if (err)
92 percpu_counter_destroy(&pd->pg[0].events); 92 percpu_counter_destroy(&pd->pg[0].events);
93 93
@@ -188,12 +188,12 @@ prop_adjust_shift(int *pl_shift, unsigned long *pl_period, int new_shift)
188 188
189#define PROP_BATCH (8*(1+ilog2(nr_cpu_ids))) 189#define PROP_BATCH (8*(1+ilog2(nr_cpu_ids)))
190 190
191int prop_local_init_percpu(struct prop_local_percpu *pl) 191int prop_local_init_percpu(struct prop_local_percpu *pl, gfp_t gfp)
192{ 192{
193 raw_spin_lock_init(&pl->lock); 193 raw_spin_lock_init(&pl->lock);
194 pl->shift = 0; 194 pl->shift = 0;
195 pl->period = 0; 195 pl->period = 0;
196 return percpu_counter_init(&pl->events, 0); 196 return percpu_counter_init(&pl->events, 0, gfp);
197} 197}
198 198
199void prop_local_destroy_percpu(struct prop_local_percpu *pl) 199void prop_local_destroy_percpu(struct prop_local_percpu *pl)
diff --git a/lib/raid6/algos.c b/lib/raid6/algos.c
index f0b1aa3586d1..7d0e5cd7b570 100644
--- a/lib/raid6/algos.c
+++ b/lib/raid6/algos.c
@@ -121,9 +121,9 @@ static inline const struct raid6_recov_calls *raid6_choose_recov(void)
121 raid6_2data_recov = best->data2; 121 raid6_2data_recov = best->data2;
122 raid6_datap_recov = best->datap; 122 raid6_datap_recov = best->datap;
123 123
124 printk("raid6: using %s recovery algorithm\n", best->name); 124 pr_info("raid6: using %s recovery algorithm\n", best->name);
125 } else 125 } else
126 printk("raid6: Yikes! No recovery algorithm found!\n"); 126 pr_err("raid6: Yikes! No recovery algorithm found!\n");
127 127
128 return best; 128 return best;
129} 129}
@@ -157,18 +157,18 @@ static inline const struct raid6_calls *raid6_choose_gen(
157 bestperf = perf; 157 bestperf = perf;
158 best = *algo; 158 best = *algo;
159 } 159 }
160 printk("raid6: %-8s %5ld MB/s\n", (*algo)->name, 160 pr_info("raid6: %-8s %5ld MB/s\n", (*algo)->name,
161 (perf*HZ) >> (20-16+RAID6_TIME_JIFFIES_LG2)); 161 (perf*HZ) >> (20-16+RAID6_TIME_JIFFIES_LG2));
162 } 162 }
163 } 163 }
164 164
165 if (best) { 165 if (best) {
166 printk("raid6: using algorithm %s (%ld MB/s)\n", 166 pr_info("raid6: using algorithm %s (%ld MB/s)\n",
167 best->name, 167 best->name,
168 (bestperf*HZ) >> (20-16+RAID6_TIME_JIFFIES_LG2)); 168 (bestperf*HZ) >> (20-16+RAID6_TIME_JIFFIES_LG2));
169 raid6_call = *best; 169 raid6_call = *best;
170 } else 170 } else
171 printk("raid6: Yikes! No algorithm found!\n"); 171 pr_err("raid6: Yikes! No algorithm found!\n");
172 172
173 return best; 173 return best;
174} 174}
@@ -194,7 +194,7 @@ int __init raid6_select_algo(void)
194 syndromes = (void *) __get_free_pages(GFP_KERNEL, 1); 194 syndromes = (void *) __get_free_pages(GFP_KERNEL, 1);
195 195
196 if (!syndromes) { 196 if (!syndromes) {
197 printk("raid6: Yikes! No memory available.\n"); 197 pr_err("raid6: Yikes! No memory available.\n");
198 return -ENOMEM; 198 return -ENOMEM;
199 } 199 }
200 200
diff --git a/lib/random32.c b/lib/random32.c
index fa5da61ce7ad..0bee183fa18f 100644
--- a/lib/random32.c
+++ b/lib/random32.c
@@ -37,9 +37,14 @@
37#include <linux/jiffies.h> 37#include <linux/jiffies.h>
38#include <linux/random.h> 38#include <linux/random.h>
39#include <linux/sched.h> 39#include <linux/sched.h>
40#include <asm/unaligned.h>
40 41
41#ifdef CONFIG_RANDOM32_SELFTEST 42#ifdef CONFIG_RANDOM32_SELFTEST
42static void __init prandom_state_selftest(void); 43static void __init prandom_state_selftest(void);
44#else
45static inline void prandom_state_selftest(void)
46{
47}
43#endif 48#endif
44 49
45static DEFINE_PER_CPU(struct rnd_state, net_rand_state); 50static DEFINE_PER_CPU(struct rnd_state, net_rand_state);
@@ -53,8 +58,7 @@ static DEFINE_PER_CPU(struct rnd_state, net_rand_state);
53 */ 58 */
54u32 prandom_u32_state(struct rnd_state *state) 59u32 prandom_u32_state(struct rnd_state *state)
55{ 60{
56#define TAUSWORTHE(s,a,b,c,d) ((s&c)<<d) ^ (((s <<a) ^ s)>>b) 61#define TAUSWORTHE(s, a, b, c, d) ((s & c) << d) ^ (((s << a) ^ s) >> b)
57
58 state->s1 = TAUSWORTHE(state->s1, 6U, 13U, 4294967294U, 18U); 62 state->s1 = TAUSWORTHE(state->s1, 6U, 13U, 4294967294U, 18U);
59 state->s2 = TAUSWORTHE(state->s2, 2U, 27U, 4294967288U, 2U); 63 state->s2 = TAUSWORTHE(state->s2, 2U, 27U, 4294967288U, 2U);
60 state->s3 = TAUSWORTHE(state->s3, 13U, 21U, 4294967280U, 7U); 64 state->s3 = TAUSWORTHE(state->s3, 13U, 21U, 4294967280U, 7U);
@@ -93,27 +97,23 @@ EXPORT_SYMBOL(prandom_u32);
93 * This is used for pseudo-randomness with no outside seeding. 97 * This is used for pseudo-randomness with no outside seeding.
94 * For more random results, use prandom_bytes(). 98 * For more random results, use prandom_bytes().
95 */ 99 */
96void prandom_bytes_state(struct rnd_state *state, void *buf, int bytes) 100void prandom_bytes_state(struct rnd_state *state, void *buf, size_t bytes)
97{ 101{
98 unsigned char *p = buf; 102 u8 *ptr = buf;
99 int i;
100 103
101 for (i = 0; i < round_down(bytes, sizeof(u32)); i += sizeof(u32)) { 104 while (bytes >= sizeof(u32)) {
102 u32 random = prandom_u32_state(state); 105 put_unaligned(prandom_u32_state(state), (u32 *) ptr);
103 int j; 106 ptr += sizeof(u32);
104 107 bytes -= sizeof(u32);
105 for (j = 0; j < sizeof(u32); j++) {
106 p[i + j] = random;
107 random >>= BITS_PER_BYTE;
108 }
109 } 108 }
110 if (i < bytes) {
111 u32 random = prandom_u32_state(state);
112 109
113 for (; i < bytes; i++) { 110 if (bytes > 0) {
114 p[i] = random; 111 u32 rem = prandom_u32_state(state);
115 random >>= BITS_PER_BYTE; 112 do {
116 } 113 *ptr++ = (u8) rem;
114 bytes--;
115 rem >>= BITS_PER_BYTE;
116 } while (bytes > 0);
117 } 117 }
118} 118}
119EXPORT_SYMBOL(prandom_bytes_state); 119EXPORT_SYMBOL(prandom_bytes_state);
@@ -123,7 +123,7 @@ EXPORT_SYMBOL(prandom_bytes_state);
123 * @buf: where to copy the pseudo-random bytes to 123 * @buf: where to copy the pseudo-random bytes to
124 * @bytes: the requested number of bytes 124 * @bytes: the requested number of bytes
125 */ 125 */
126void prandom_bytes(void *buf, int bytes) 126void prandom_bytes(void *buf, size_t bytes)
127{ 127{
128 struct rnd_state *state = &get_cpu_var(net_rand_state); 128 struct rnd_state *state = &get_cpu_var(net_rand_state);
129 129
@@ -134,7 +134,7 @@ EXPORT_SYMBOL(prandom_bytes);
134 134
135static void prandom_warmup(struct rnd_state *state) 135static void prandom_warmup(struct rnd_state *state)
136{ 136{
137 /* Calling RNG ten times to satify recurrence condition */ 137 /* Calling RNG ten times to satisfy recurrence condition */
138 prandom_u32_state(state); 138 prandom_u32_state(state);
139 prandom_u32_state(state); 139 prandom_u32_state(state);
140 prandom_u32_state(state); 140 prandom_u32_state(state);
@@ -147,21 +147,25 @@ static void prandom_warmup(struct rnd_state *state)
147 prandom_u32_state(state); 147 prandom_u32_state(state);
148} 148}
149 149
150static void prandom_seed_very_weak(struct rnd_state *state, u32 seed) 150static u32 __extract_hwseed(void)
151{ 151{
152 /* Note: This sort of seeding is ONLY used in test cases and 152 unsigned int val = 0;
153 * during boot at the time from core_initcall until late_initcall 153
154 * as we don't have a stronger entropy source available yet. 154 (void)(arch_get_random_seed_int(&val) ||
155 * After late_initcall, we reseed entire state, we have to (!), 155 arch_get_random_int(&val));
156 * otherwise an attacker just needs to search 32 bit space to 156
157 * probe for our internal 128 bit state if he knows a couple 157 return val;
158 * of prandom32 outputs! 158}
159 */ 159
160#define LCG(x) ((x) * 69069U) /* super-duper LCG */ 160static void prandom_seed_early(struct rnd_state *state, u32 seed,
161 state->s1 = __seed(LCG(seed), 2U); 161 bool mix_with_hwseed)
162 state->s2 = __seed(LCG(state->s1), 8U); 162{
163 state->s3 = __seed(LCG(state->s2), 16U); 163#define LCG(x) ((x) * 69069U) /* super-duper LCG */
164 state->s4 = __seed(LCG(state->s3), 128U); 164#define HWSEED() (mix_with_hwseed ? __extract_hwseed() : 0)
165 state->s1 = __seed(HWSEED() ^ LCG(seed), 2U);
166 state->s2 = __seed(HWSEED() ^ LCG(state->s1), 8U);
167 state->s3 = __seed(HWSEED() ^ LCG(state->s2), 16U);
168 state->s4 = __seed(HWSEED() ^ LCG(state->s3), 128U);
165} 169}
166 170
167/** 171/**
@@ -194,14 +198,13 @@ static int __init prandom_init(void)
194{ 198{
195 int i; 199 int i;
196 200
197#ifdef CONFIG_RANDOM32_SELFTEST
198 prandom_state_selftest(); 201 prandom_state_selftest();
199#endif
200 202
201 for_each_possible_cpu(i) { 203 for_each_possible_cpu(i) {
202 struct rnd_state *state = &per_cpu(net_rand_state,i); 204 struct rnd_state *state = &per_cpu(net_rand_state,i);
205 u32 weak_seed = (i + jiffies) ^ random_get_entropy();
203 206
204 prandom_seed_very_weak(state, (i + jiffies) ^ random_get_entropy()); 207 prandom_seed_early(state, weak_seed, true);
205 prandom_warmup(state); 208 prandom_warmup(state);
206 } 209 }
207 210
@@ -210,6 +213,7 @@ static int __init prandom_init(void)
210core_initcall(prandom_init); 213core_initcall(prandom_init);
211 214
212static void __prandom_timer(unsigned long dontcare); 215static void __prandom_timer(unsigned long dontcare);
216
213static DEFINE_TIMER(seed_timer, __prandom_timer, 0, 0); 217static DEFINE_TIMER(seed_timer, __prandom_timer, 0, 0);
214 218
215static void __prandom_timer(unsigned long dontcare) 219static void __prandom_timer(unsigned long dontcare)
@@ -221,7 +225,7 @@ static void __prandom_timer(unsigned long dontcare)
221 prandom_seed(entropy); 225 prandom_seed(entropy);
222 226
223 /* reseed every ~60 seconds, in [40 .. 80) interval with slack */ 227 /* reseed every ~60 seconds, in [40 .. 80) interval with slack */
224 expires = 40 + (prandom_u32() % 40); 228 expires = 40 + prandom_u32_max(40);
225 seed_timer.expires = jiffies + msecs_to_jiffies(expires * MSEC_PER_SEC); 229 seed_timer.expires = jiffies + msecs_to_jiffies(expires * MSEC_PER_SEC);
226 230
227 add_timer(&seed_timer); 231 add_timer(&seed_timer);
@@ -419,7 +423,7 @@ static void __init prandom_state_selftest(void)
419 for (i = 0; i < ARRAY_SIZE(test1); i++) { 423 for (i = 0; i < ARRAY_SIZE(test1); i++) {
420 struct rnd_state state; 424 struct rnd_state state;
421 425
422 prandom_seed_very_weak(&state, test1[i].seed); 426 prandom_seed_early(&state, test1[i].seed, false);
423 prandom_warmup(&state); 427 prandom_warmup(&state);
424 428
425 if (test1[i].result != prandom_u32_state(&state)) 429 if (test1[i].result != prandom_u32_state(&state))
@@ -434,7 +438,7 @@ static void __init prandom_state_selftest(void)
434 for (i = 0; i < ARRAY_SIZE(test2); i++) { 438 for (i = 0; i < ARRAY_SIZE(test2); i++) {
435 struct rnd_state state; 439 struct rnd_state state;
436 440
437 prandom_seed_very_weak(&state, test2[i].seed); 441 prandom_seed_early(&state, test2[i].seed, false);
438 prandom_warmup(&state); 442 prandom_warmup(&state);
439 443
440 for (j = 0; j < test2[i].iteration - 1; j++) 444 for (j = 0; j < test2[i].iteration - 1; j++)
diff --git a/lib/rbtree.c b/lib/rbtree.c
index 65f4effd117f..c16c81a3d430 100644
--- a/lib/rbtree.c
+++ b/lib/rbtree.c
@@ -101,7 +101,7 @@ __rb_insert(struct rb_node *node, struct rb_root *root,
101 * / \ / \ 101 * / \ / \
102 * p u --> P U 102 * p u --> P U
103 * / / 103 * / /
104 * n N 104 * n n
105 * 105 *
106 * However, since g's parent might be red, and 106 * However, since g's parent might be red, and
107 * 4) does not allow this, we need to recurse 107 * 4) does not allow this, we need to recurse
diff --git a/lib/rhashtable.c b/lib/rhashtable.c
new file mode 100644
index 000000000000..081be3ba9ea8
--- /dev/null
+++ b/lib/rhashtable.c
@@ -0,0 +1,794 @@
1/*
2 * Resizable, Scalable, Concurrent Hash Table
3 *
4 * Copyright (c) 2014 Thomas Graf <tgraf@suug.ch>
5 * Copyright (c) 2008-2014 Patrick McHardy <kaber@trash.net>
6 *
7 * Based on the following paper:
8 * https://www.usenix.org/legacy/event/atc11/tech/final_files/Triplett.pdf
9 *
10 * Code partially derived from nft_hash
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
15 */
16
17#include <linux/kernel.h>
18#include <linux/init.h>
19#include <linux/log2.h>
20#include <linux/slab.h>
21#include <linux/vmalloc.h>
22#include <linux/mm.h>
23#include <linux/hash.h>
24#include <linux/random.h>
25#include <linux/rhashtable.h>
26
27#define HASH_DEFAULT_SIZE 64UL
28#define HASH_MIN_SIZE 4UL
29
30#define ASSERT_RHT_MUTEX(HT) BUG_ON(!lockdep_rht_mutex_is_held(HT))
31
32#ifdef CONFIG_PROVE_LOCKING
33int lockdep_rht_mutex_is_held(const struct rhashtable *ht)
34{
35 return ht->p.mutex_is_held();
36}
37EXPORT_SYMBOL_GPL(lockdep_rht_mutex_is_held);
38#endif
39
40static void *rht_obj(const struct rhashtable *ht, const struct rhash_head *he)
41{
42 return (void *) he - ht->p.head_offset;
43}
44
45static u32 __hashfn(const struct rhashtable *ht, const void *key,
46 u32 len, u32 hsize)
47{
48 u32 h;
49
50 h = ht->p.hashfn(key, len, ht->p.hash_rnd);
51
52 return h & (hsize - 1);
53}
54
55/**
56 * rhashtable_hashfn - compute hash for key of given length
57 * @ht: hash table to compute for
58 * @key: pointer to key
59 * @len: length of key
60 *
61 * Computes the hash value using the hash function provided in the 'hashfn'
62 * of struct rhashtable_params. The returned value is guaranteed to be
63 * smaller than the number of buckets in the hash table.
64 */
65u32 rhashtable_hashfn(const struct rhashtable *ht, const void *key, u32 len)
66{
67 struct bucket_table *tbl = rht_dereference_rcu(ht->tbl, ht);
68
69 return __hashfn(ht, key, len, tbl->size);
70}
71EXPORT_SYMBOL_GPL(rhashtable_hashfn);
72
73static u32 obj_hashfn(const struct rhashtable *ht, const void *ptr, u32 hsize)
74{
75 if (unlikely(!ht->p.key_len)) {
76 u32 h;
77
78 h = ht->p.obj_hashfn(ptr, ht->p.hash_rnd);
79
80 return h & (hsize - 1);
81 }
82
83 return __hashfn(ht, ptr + ht->p.key_offset, ht->p.key_len, hsize);
84}
85
86/**
87 * rhashtable_obj_hashfn - compute hash for hashed object
88 * @ht: hash table to compute for
89 * @ptr: pointer to hashed object
90 *
91 * Computes the hash value using the hash function `hashfn` respectively
92 * 'obj_hashfn' depending on whether the hash table is set up to work with
93 * a fixed length key. The returned value is guaranteed to be smaller than
94 * the number of buckets in the hash table.
95 */
96u32 rhashtable_obj_hashfn(const struct rhashtable *ht, void *ptr)
97{
98 struct bucket_table *tbl = rht_dereference_rcu(ht->tbl, ht);
99
100 return obj_hashfn(ht, ptr, tbl->size);
101}
102EXPORT_SYMBOL_GPL(rhashtable_obj_hashfn);
103
104static u32 head_hashfn(const struct rhashtable *ht,
105 const struct rhash_head *he, u32 hsize)
106{
107 return obj_hashfn(ht, rht_obj(ht, he), hsize);
108}
109
110static struct bucket_table *bucket_table_alloc(size_t nbuckets, gfp_t flags)
111{
112 struct bucket_table *tbl;
113 size_t size;
114
115 size = sizeof(*tbl) + nbuckets * sizeof(tbl->buckets[0]);
116 tbl = kzalloc(size, flags);
117 if (tbl == NULL)
118 tbl = vzalloc(size);
119
120 if (tbl == NULL)
121 return NULL;
122
123 tbl->size = nbuckets;
124
125 return tbl;
126}
127
128static void bucket_table_free(const struct bucket_table *tbl)
129{
130 kvfree(tbl);
131}
132
133/**
134 * rht_grow_above_75 - returns true if nelems > 0.75 * table-size
135 * @ht: hash table
136 * @new_size: new table size
137 */
138bool rht_grow_above_75(const struct rhashtable *ht, size_t new_size)
139{
140 /* Expand table when exceeding 75% load */
141 return ht->nelems > (new_size / 4 * 3);
142}
143EXPORT_SYMBOL_GPL(rht_grow_above_75);
144
145/**
146 * rht_shrink_below_30 - returns true if nelems < 0.3 * table-size
147 * @ht: hash table
148 * @new_size: new table size
149 */
150bool rht_shrink_below_30(const struct rhashtable *ht, size_t new_size)
151{
152 /* Shrink table beneath 30% load */
153 return ht->nelems < (new_size * 3 / 10);
154}
155EXPORT_SYMBOL_GPL(rht_shrink_below_30);
156
157static void hashtable_chain_unzip(const struct rhashtable *ht,
158 const struct bucket_table *new_tbl,
159 struct bucket_table *old_tbl, size_t n)
160{
161 struct rhash_head *he, *p, *next;
162 unsigned int h;
163
164 /* Old bucket empty, no work needed. */
165 p = rht_dereference(old_tbl->buckets[n], ht);
166 if (!p)
167 return;
168
169 /* Advance the old bucket pointer one or more times until it
170 * reaches a node that doesn't hash to the same bucket as the
171 * previous node p. Call the previous node p;
172 */
173 h = head_hashfn(ht, p, new_tbl->size);
174 rht_for_each(he, p->next, ht) {
175 if (head_hashfn(ht, he, new_tbl->size) != h)
176 break;
177 p = he;
178 }
179 RCU_INIT_POINTER(old_tbl->buckets[n], p->next);
180
181 /* Find the subsequent node which does hash to the same
182 * bucket as node P, or NULL if no such node exists.
183 */
184 next = NULL;
185 if (he) {
186 rht_for_each(he, he->next, ht) {
187 if (head_hashfn(ht, he, new_tbl->size) == h) {
188 next = he;
189 break;
190 }
191 }
192 }
193
194 /* Set p's next pointer to that subsequent node pointer,
195 * bypassing the nodes which do not hash to p's bucket
196 */
197 RCU_INIT_POINTER(p->next, next);
198}
199
200/**
201 * rhashtable_expand - Expand hash table while allowing concurrent lookups
202 * @ht: the hash table to expand
203 * @flags: allocation flags
204 *
205 * A secondary bucket array is allocated and the hash entries are migrated
206 * while keeping them on both lists until the end of the RCU grace period.
207 *
208 * This function may only be called in a context where it is safe to call
209 * synchronize_rcu(), e.g. not within a rcu_read_lock() section.
210 *
211 * The caller must ensure that no concurrent table mutations take place.
212 * It is however valid to have concurrent lookups if they are RCU protected.
213 */
214int rhashtable_expand(struct rhashtable *ht, gfp_t flags)
215{
216 struct bucket_table *new_tbl, *old_tbl = rht_dereference(ht->tbl, ht);
217 struct rhash_head *he;
218 unsigned int i, h;
219 bool complete;
220
221 ASSERT_RHT_MUTEX(ht);
222
223 if (ht->p.max_shift && ht->shift >= ht->p.max_shift)
224 return 0;
225
226 new_tbl = bucket_table_alloc(old_tbl->size * 2, flags);
227 if (new_tbl == NULL)
228 return -ENOMEM;
229
230 ht->shift++;
231
232 /* For each new bucket, search the corresponding old bucket
233 * for the first entry that hashes to the new bucket, and
234 * link the new bucket to that entry. Since all the entries
235 * which will end up in the new bucket appear in the same
236 * old bucket, this constructs an entirely valid new hash
237 * table, but with multiple buckets "zipped" together into a
238 * single imprecise chain.
239 */
240 for (i = 0; i < new_tbl->size; i++) {
241 h = i & (old_tbl->size - 1);
242 rht_for_each(he, old_tbl->buckets[h], ht) {
243 if (head_hashfn(ht, he, new_tbl->size) == i) {
244 RCU_INIT_POINTER(new_tbl->buckets[i], he);
245 break;
246 }
247 }
248 }
249
250 /* Publish the new table pointer. Lookups may now traverse
251 * the new table, but they will not benefit from any
252 * additional efficiency until later steps unzip the buckets.
253 */
254 rcu_assign_pointer(ht->tbl, new_tbl);
255
256 /* Unzip interleaved hash chains */
257 do {
258 /* Wait for readers. All new readers will see the new
259 * table, and thus no references to the old table will
260 * remain.
261 */
262 synchronize_rcu();
263
264 /* For each bucket in the old table (each of which
265 * contains items from multiple buckets of the new
266 * table): ...
267 */
268 complete = true;
269 for (i = 0; i < old_tbl->size; i++) {
270 hashtable_chain_unzip(ht, new_tbl, old_tbl, i);
271 if (old_tbl->buckets[i] != NULL)
272 complete = false;
273 }
274 } while (!complete);
275
276 bucket_table_free(old_tbl);
277 return 0;
278}
279EXPORT_SYMBOL_GPL(rhashtable_expand);
280
281/**
282 * rhashtable_shrink - Shrink hash table while allowing concurrent lookups
283 * @ht: the hash table to shrink
284 * @flags: allocation flags
285 *
286 * This function may only be called in a context where it is safe to call
287 * synchronize_rcu(), e.g. not within a rcu_read_lock() section.
288 *
289 * The caller must ensure that no concurrent table mutations take place.
290 * It is however valid to have concurrent lookups if they are RCU protected.
291 */
292int rhashtable_shrink(struct rhashtable *ht, gfp_t flags)
293{
294 struct bucket_table *ntbl, *tbl = rht_dereference(ht->tbl, ht);
295 struct rhash_head __rcu **pprev;
296 unsigned int i;
297
298 ASSERT_RHT_MUTEX(ht);
299
300 if (ht->shift <= ht->p.min_shift)
301 return 0;
302
303 ntbl = bucket_table_alloc(tbl->size / 2, flags);
304 if (ntbl == NULL)
305 return -ENOMEM;
306
307 ht->shift--;
308
309 /* Link each bucket in the new table to the first bucket
310 * in the old table that contains entries which will hash
311 * to the new bucket.
312 */
313 for (i = 0; i < ntbl->size; i++) {
314 ntbl->buckets[i] = tbl->buckets[i];
315
316 /* Link each bucket in the new table to the first bucket
317 * in the old table that contains entries which will hash
318 * to the new bucket.
319 */
320 for (pprev = &ntbl->buckets[i]; *pprev != NULL;
321 pprev = &rht_dereference(*pprev, ht)->next)
322 ;
323 RCU_INIT_POINTER(*pprev, tbl->buckets[i + ntbl->size]);
324 }
325
326 /* Publish the new, valid hash table */
327 rcu_assign_pointer(ht->tbl, ntbl);
328
329 /* Wait for readers. No new readers will have references to the
330 * old hash table.
331 */
332 synchronize_rcu();
333
334 bucket_table_free(tbl);
335
336 return 0;
337}
338EXPORT_SYMBOL_GPL(rhashtable_shrink);
339
340/**
341 * rhashtable_insert - insert object into hash hash table
342 * @ht: hash table
343 * @obj: pointer to hash head inside object
344 * @flags: allocation flags (table expansion)
345 *
346 * Will automatically grow the table via rhashtable_expand() if the the
347 * grow_decision function specified at rhashtable_init() returns true.
348 *
349 * The caller must ensure that no concurrent table mutations occur. It is
350 * however valid to have concurrent lookups if they are RCU protected.
351 */
352void rhashtable_insert(struct rhashtable *ht, struct rhash_head *obj,
353 gfp_t flags)
354{
355 struct bucket_table *tbl = rht_dereference(ht->tbl, ht);
356 u32 hash;
357
358 ASSERT_RHT_MUTEX(ht);
359
360 hash = head_hashfn(ht, obj, tbl->size);
361 RCU_INIT_POINTER(obj->next, tbl->buckets[hash]);
362 rcu_assign_pointer(tbl->buckets[hash], obj);
363 ht->nelems++;
364
365 if (ht->p.grow_decision && ht->p.grow_decision(ht, tbl->size))
366 rhashtable_expand(ht, flags);
367}
368EXPORT_SYMBOL_GPL(rhashtable_insert);
369
370/**
371 * rhashtable_remove_pprev - remove object from hash table given previous element
372 * @ht: hash table
373 * @obj: pointer to hash head inside object
374 * @pprev: pointer to previous element
375 * @flags: allocation flags (table expansion)
376 *
377 * Identical to rhashtable_remove() but caller is alreayd aware of the element
378 * in front of the element to be deleted. This is in particular useful for
379 * deletion when combined with walking or lookup.
380 */
381void rhashtable_remove_pprev(struct rhashtable *ht, struct rhash_head *obj,
382 struct rhash_head __rcu **pprev, gfp_t flags)
383{
384 struct bucket_table *tbl = rht_dereference(ht->tbl, ht);
385
386 ASSERT_RHT_MUTEX(ht);
387
388 RCU_INIT_POINTER(*pprev, obj->next);
389 ht->nelems--;
390
391 if (ht->p.shrink_decision &&
392 ht->p.shrink_decision(ht, tbl->size))
393 rhashtable_shrink(ht, flags);
394}
395EXPORT_SYMBOL_GPL(rhashtable_remove_pprev);
396
397/**
398 * rhashtable_remove - remove object from hash table
399 * @ht: hash table
400 * @obj: pointer to hash head inside object
401 * @flags: allocation flags (table expansion)
402 *
403 * Since the hash chain is single linked, the removal operation needs to
404 * walk the bucket chain upon removal. The removal operation is thus
405 * considerable slow if the hash table is not correctly sized.
406 *
407 * Will automatically shrink the table via rhashtable_expand() if the the
408 * shrink_decision function specified at rhashtable_init() returns true.
409 *
410 * The caller must ensure that no concurrent table mutations occur. It is
411 * however valid to have concurrent lookups if they are RCU protected.
412 */
413bool rhashtable_remove(struct rhashtable *ht, struct rhash_head *obj,
414 gfp_t flags)
415{
416 struct bucket_table *tbl = rht_dereference(ht->tbl, ht);
417 struct rhash_head __rcu **pprev;
418 struct rhash_head *he;
419 u32 h;
420
421 ASSERT_RHT_MUTEX(ht);
422
423 h = head_hashfn(ht, obj, tbl->size);
424
425 pprev = &tbl->buckets[h];
426 rht_for_each(he, tbl->buckets[h], ht) {
427 if (he != obj) {
428 pprev = &he->next;
429 continue;
430 }
431
432 rhashtable_remove_pprev(ht, he, pprev, flags);
433 return true;
434 }
435
436 return false;
437}
438EXPORT_SYMBOL_GPL(rhashtable_remove);
439
440/**
441 * rhashtable_lookup - lookup key in hash table
442 * @ht: hash table
443 * @key: pointer to key
444 *
445 * Computes the hash value for the key and traverses the bucket chain looking
446 * for a entry with an identical key. The first matching entry is returned.
447 *
448 * This lookup function may only be used for fixed key hash table (key_len
449 * paramter set). It will BUG() if used inappropriately.
450 *
451 * Lookups may occur in parallel with hash mutations as long as the lookup is
452 * guarded by rcu_read_lock(). The caller must take care of this.
453 */
454void *rhashtable_lookup(const struct rhashtable *ht, const void *key)
455{
456 const struct bucket_table *tbl = rht_dereference_rcu(ht->tbl, ht);
457 struct rhash_head *he;
458 u32 h;
459
460 BUG_ON(!ht->p.key_len);
461
462 h = __hashfn(ht, key, ht->p.key_len, tbl->size);
463 rht_for_each_rcu(he, tbl->buckets[h], ht) {
464 if (memcmp(rht_obj(ht, he) + ht->p.key_offset, key,
465 ht->p.key_len))
466 continue;
467 return (void *) he - ht->p.head_offset;
468 }
469
470 return NULL;
471}
472EXPORT_SYMBOL_GPL(rhashtable_lookup);
473
474/**
475 * rhashtable_lookup_compare - search hash table with compare function
476 * @ht: hash table
477 * @hash: hash value of desired entry
478 * @compare: compare function, must return true on match
479 * @arg: argument passed on to compare function
480 *
481 * Traverses the bucket chain behind the provided hash value and calls the
482 * specified compare function for each entry.
483 *
484 * Lookups may occur in parallel with hash mutations as long as the lookup is
485 * guarded by rcu_read_lock(). The caller must take care of this.
486 *
487 * Returns the first entry on which the compare function returned true.
488 */
489void *rhashtable_lookup_compare(const struct rhashtable *ht, u32 hash,
490 bool (*compare)(void *, void *), void *arg)
491{
492 const struct bucket_table *tbl = rht_dereference_rcu(ht->tbl, ht);
493 struct rhash_head *he;
494
495 if (unlikely(hash >= tbl->size))
496 return NULL;
497
498 rht_for_each_rcu(he, tbl->buckets[hash], ht) {
499 if (!compare(rht_obj(ht, he), arg))
500 continue;
501 return (void *) he - ht->p.head_offset;
502 }
503
504 return NULL;
505}
506EXPORT_SYMBOL_GPL(rhashtable_lookup_compare);
507
508static size_t rounded_hashtable_size(struct rhashtable_params *params)
509{
510 return max(roundup_pow_of_two(params->nelem_hint * 4 / 3),
511 1UL << params->min_shift);
512}
513
514/**
515 * rhashtable_init - initialize a new hash table
516 * @ht: hash table to be initialized
517 * @params: configuration parameters
518 *
519 * Initializes a new hash table based on the provided configuration
520 * parameters. A table can be configured either with a variable or
521 * fixed length key:
522 *
523 * Configuration Example 1: Fixed length keys
524 * struct test_obj {
525 * int key;
526 * void * my_member;
527 * struct rhash_head node;
528 * };
529 *
530 * struct rhashtable_params params = {
531 * .head_offset = offsetof(struct test_obj, node),
532 * .key_offset = offsetof(struct test_obj, key),
533 * .key_len = sizeof(int),
534 * .hashfn = arch_fast_hash,
535 * .mutex_is_held = &my_mutex_is_held,
536 * };
537 *
538 * Configuration Example 2: Variable length keys
539 * struct test_obj {
540 * [...]
541 * struct rhash_head node;
542 * };
543 *
544 * u32 my_hash_fn(const void *data, u32 seed)
545 * {
546 * struct test_obj *obj = data;
547 *
548 * return [... hash ...];
549 * }
550 *
551 * struct rhashtable_params params = {
552 * .head_offset = offsetof(struct test_obj, node),
553 * .hashfn = arch_fast_hash,
554 * .obj_hashfn = my_hash_fn,
555 * .mutex_is_held = &my_mutex_is_held,
556 * };
557 */
558int rhashtable_init(struct rhashtable *ht, struct rhashtable_params *params)
559{
560 struct bucket_table *tbl;
561 size_t size;
562
563 size = HASH_DEFAULT_SIZE;
564
565 if ((params->key_len && !params->hashfn) ||
566 (!params->key_len && !params->obj_hashfn))
567 return -EINVAL;
568
569 params->min_shift = max_t(size_t, params->min_shift,
570 ilog2(HASH_MIN_SIZE));
571
572 if (params->nelem_hint)
573 size = rounded_hashtable_size(params);
574
575 tbl = bucket_table_alloc(size, GFP_KERNEL);
576 if (tbl == NULL)
577 return -ENOMEM;
578
579 memset(ht, 0, sizeof(*ht));
580 ht->shift = ilog2(tbl->size);
581 memcpy(&ht->p, params, sizeof(*params));
582 RCU_INIT_POINTER(ht->tbl, tbl);
583
584 if (!ht->p.hash_rnd)
585 get_random_bytes(&ht->p.hash_rnd, sizeof(ht->p.hash_rnd));
586
587 return 0;
588}
589EXPORT_SYMBOL_GPL(rhashtable_init);
590
591/**
592 * rhashtable_destroy - destroy hash table
593 * @ht: the hash table to destroy
594 *
595 * Frees the bucket array. This function is not rcu safe, therefore the caller
596 * has to make sure that no resizing may happen by unpublishing the hashtable
597 * and waiting for the quiescent cycle before releasing the bucket array.
598 */
599void rhashtable_destroy(const struct rhashtable *ht)
600{
601 bucket_table_free(ht->tbl);
602}
603EXPORT_SYMBOL_GPL(rhashtable_destroy);
604
605/**************************************************************************
606 * Self Test
607 **************************************************************************/
608
609#ifdef CONFIG_TEST_RHASHTABLE
610
611#define TEST_HT_SIZE 8
612#define TEST_ENTRIES 2048
613#define TEST_PTR ((void *) 0xdeadbeef)
614#define TEST_NEXPANDS 4
615
616static int test_mutex_is_held(void)
617{
618 return 1;
619}
620
621struct test_obj {
622 void *ptr;
623 int value;
624 struct rhash_head node;
625};
626
627static int __init test_rht_lookup(struct rhashtable *ht)
628{
629 unsigned int i;
630
631 for (i = 0; i < TEST_ENTRIES * 2; i++) {
632 struct test_obj *obj;
633 bool expected = !(i % 2);
634 u32 key = i;
635
636 obj = rhashtable_lookup(ht, &key);
637
638 if (expected && !obj) {
639 pr_warn("Test failed: Could not find key %u\n", key);
640 return -ENOENT;
641 } else if (!expected && obj) {
642 pr_warn("Test failed: Unexpected entry found for key %u\n",
643 key);
644 return -EEXIST;
645 } else if (expected && obj) {
646 if (obj->ptr != TEST_PTR || obj->value != i) {
647 pr_warn("Test failed: Lookup value mismatch %p!=%p, %u!=%u\n",
648 obj->ptr, TEST_PTR, obj->value, i);
649 return -EINVAL;
650 }
651 }
652 }
653
654 return 0;
655}
656
657static void test_bucket_stats(struct rhashtable *ht,
658 struct bucket_table *tbl,
659 bool quiet)
660{
661 unsigned int cnt, i, total = 0;
662 struct test_obj *obj;
663
664 for (i = 0; i < tbl->size; i++) {
665 cnt = 0;
666
667 if (!quiet)
668 pr_info(" [%#4x/%zu]", i, tbl->size);
669
670 rht_for_each_entry_rcu(obj, tbl->buckets[i], node) {
671 cnt++;
672 total++;
673 if (!quiet)
674 pr_cont(" [%p],", obj);
675 }
676
677 if (!quiet)
678 pr_cont("\n [%#x] first element: %p, chain length: %u\n",
679 i, tbl->buckets[i], cnt);
680 }
681
682 pr_info(" Traversal complete: counted=%u, nelems=%zu, entries=%d\n",
683 total, ht->nelems, TEST_ENTRIES);
684}
685
686static int __init test_rhashtable(struct rhashtable *ht)
687{
688 struct bucket_table *tbl;
689 struct test_obj *obj, *next;
690 int err;
691 unsigned int i;
692
693 /*
694 * Insertion Test:
695 * Insert TEST_ENTRIES into table with all keys even numbers
696 */
697 pr_info(" Adding %d keys\n", TEST_ENTRIES);
698 for (i = 0; i < TEST_ENTRIES; i++) {
699 struct test_obj *obj;
700
701 obj = kzalloc(sizeof(*obj), GFP_KERNEL);
702 if (!obj) {
703 err = -ENOMEM;
704 goto error;
705 }
706
707 obj->ptr = TEST_PTR;
708 obj->value = i * 2;
709
710 rhashtable_insert(ht, &obj->node, GFP_KERNEL);
711 }
712
713 rcu_read_lock();
714 tbl = rht_dereference_rcu(ht->tbl, ht);
715 test_bucket_stats(ht, tbl, true);
716 test_rht_lookup(ht);
717 rcu_read_unlock();
718
719 for (i = 0; i < TEST_NEXPANDS; i++) {
720 pr_info(" Table expansion iteration %u...\n", i);
721 rhashtable_expand(ht, GFP_KERNEL);
722
723 rcu_read_lock();
724 pr_info(" Verifying lookups...\n");
725 test_rht_lookup(ht);
726 rcu_read_unlock();
727 }
728
729 for (i = 0; i < TEST_NEXPANDS; i++) {
730 pr_info(" Table shrinkage iteration %u...\n", i);
731 rhashtable_shrink(ht, GFP_KERNEL);
732
733 rcu_read_lock();
734 pr_info(" Verifying lookups...\n");
735 test_rht_lookup(ht);
736 rcu_read_unlock();
737 }
738
739 pr_info(" Deleting %d keys\n", TEST_ENTRIES);
740 for (i = 0; i < TEST_ENTRIES; i++) {
741 u32 key = i * 2;
742
743 obj = rhashtable_lookup(ht, &key);
744 BUG_ON(!obj);
745
746 rhashtable_remove(ht, &obj->node, GFP_KERNEL);
747 kfree(obj);
748 }
749
750 return 0;
751
752error:
753 tbl = rht_dereference_rcu(ht->tbl, ht);
754 for (i = 0; i < tbl->size; i++)
755 rht_for_each_entry_safe(obj, next, tbl->buckets[i], ht, node)
756 kfree(obj);
757
758 return err;
759}
760
761static int __init test_rht_init(void)
762{
763 struct rhashtable ht;
764 struct rhashtable_params params = {
765 .nelem_hint = TEST_HT_SIZE,
766 .head_offset = offsetof(struct test_obj, node),
767 .key_offset = offsetof(struct test_obj, value),
768 .key_len = sizeof(int),
769 .hashfn = arch_fast_hash,
770 .mutex_is_held = &test_mutex_is_held,
771 .grow_decision = rht_grow_above_75,
772 .shrink_decision = rht_shrink_below_30,
773 };
774 int err;
775
776 pr_info("Running resizable hashtable tests...\n");
777
778 err = rhashtable_init(&ht, &params);
779 if (err < 0) {
780 pr_warn("Test failed: Unable to initialize hashtable: %d\n",
781 err);
782 return err;
783 }
784
785 err = test_rhashtable(&ht);
786
787 rhashtable_destroy(&ht);
788
789 return err;
790}
791
792subsys_initcall(test_rht_init);
793
794#endif /* CONFIG_TEST_RHASHTABLE */
diff --git a/lib/scatterlist.c b/lib/scatterlist.c
index 3a8e8e8fb2a5..c9f2e8c6ccc9 100644
--- a/lib/scatterlist.c
+++ b/lib/scatterlist.c
@@ -73,7 +73,7 @@ EXPORT_SYMBOL(sg_nents);
73 **/ 73 **/
74struct scatterlist *sg_last(struct scatterlist *sgl, unsigned int nents) 74struct scatterlist *sg_last(struct scatterlist *sgl, unsigned int nents)
75{ 75{
76#ifndef ARCH_HAS_SG_CHAIN 76#ifndef CONFIG_ARCH_HAS_SG_CHAIN
77 struct scatterlist *ret = &sgl[nents - 1]; 77 struct scatterlist *ret = &sgl[nents - 1];
78#else 78#else
79 struct scatterlist *sg, *ret = NULL; 79 struct scatterlist *sg, *ret = NULL;
@@ -165,6 +165,7 @@ static void sg_kfree(struct scatterlist *sg, unsigned int nents)
165 * __sg_free_table - Free a previously mapped sg table 165 * __sg_free_table - Free a previously mapped sg table
166 * @table: The sg table header to use 166 * @table: The sg table header to use
167 * @max_ents: The maximum number of entries per single scatterlist 167 * @max_ents: The maximum number of entries per single scatterlist
168 * @skip_first_chunk: don't free the (preallocated) first scatterlist chunk
168 * @free_fn: Free function 169 * @free_fn: Free function
169 * 170 *
170 * Description: 171 * Description:
@@ -174,7 +175,7 @@ static void sg_kfree(struct scatterlist *sg, unsigned int nents)
174 * 175 *
175 **/ 176 **/
176void __sg_free_table(struct sg_table *table, unsigned int max_ents, 177void __sg_free_table(struct sg_table *table, unsigned int max_ents,
177 sg_free_fn *free_fn) 178 bool skip_first_chunk, sg_free_fn *free_fn)
178{ 179{
179 struct scatterlist *sgl, *next; 180 struct scatterlist *sgl, *next;
180 181
@@ -202,7 +203,10 @@ void __sg_free_table(struct sg_table *table, unsigned int max_ents,
202 } 203 }
203 204
204 table->orig_nents -= sg_size; 205 table->orig_nents -= sg_size;
205 free_fn(sgl, alloc_size); 206 if (skip_first_chunk)
207 skip_first_chunk = false;
208 else
209 free_fn(sgl, alloc_size);
206 sgl = next; 210 sgl = next;
207 } 211 }
208 212
@@ -217,7 +221,7 @@ EXPORT_SYMBOL(__sg_free_table);
217 **/ 221 **/
218void sg_free_table(struct sg_table *table) 222void sg_free_table(struct sg_table *table)
219{ 223{
220 __sg_free_table(table, SG_MAX_SINGLE_ALLOC, sg_kfree); 224 __sg_free_table(table, SG_MAX_SINGLE_ALLOC, false, sg_kfree);
221} 225}
222EXPORT_SYMBOL(sg_free_table); 226EXPORT_SYMBOL(sg_free_table);
223 227
@@ -241,8 +245,8 @@ EXPORT_SYMBOL(sg_free_table);
241 * 245 *
242 **/ 246 **/
243int __sg_alloc_table(struct sg_table *table, unsigned int nents, 247int __sg_alloc_table(struct sg_table *table, unsigned int nents,
244 unsigned int max_ents, gfp_t gfp_mask, 248 unsigned int max_ents, struct scatterlist *first_chunk,
245 sg_alloc_fn *alloc_fn) 249 gfp_t gfp_mask, sg_alloc_fn *alloc_fn)
246{ 250{
247 struct scatterlist *sg, *prv; 251 struct scatterlist *sg, *prv;
248 unsigned int left; 252 unsigned int left;
@@ -251,7 +255,7 @@ int __sg_alloc_table(struct sg_table *table, unsigned int nents,
251 255
252 if (nents == 0) 256 if (nents == 0)
253 return -EINVAL; 257 return -EINVAL;
254#ifndef ARCH_HAS_SG_CHAIN 258#ifndef CONFIG_ARCH_HAS_SG_CHAIN
255 if (WARN_ON_ONCE(nents > max_ents)) 259 if (WARN_ON_ONCE(nents > max_ents))
256 return -EINVAL; 260 return -EINVAL;
257#endif 261#endif
@@ -269,7 +273,12 @@ int __sg_alloc_table(struct sg_table *table, unsigned int nents,
269 273
270 left -= sg_size; 274 left -= sg_size;
271 275
272 sg = alloc_fn(alloc_size, gfp_mask); 276 if (first_chunk) {
277 sg = first_chunk;
278 first_chunk = NULL;
279 } else {
280 sg = alloc_fn(alloc_size, gfp_mask);
281 }
273 if (unlikely(!sg)) { 282 if (unlikely(!sg)) {
274 /* 283 /*
275 * Adjust entry count to reflect that the last 284 * Adjust entry count to reflect that the last
@@ -324,9 +333,9 @@ int sg_alloc_table(struct sg_table *table, unsigned int nents, gfp_t gfp_mask)
324 int ret; 333 int ret;
325 334
326 ret = __sg_alloc_table(table, nents, SG_MAX_SINGLE_ALLOC, 335 ret = __sg_alloc_table(table, nents, SG_MAX_SINGLE_ALLOC,
327 gfp_mask, sg_kmalloc); 336 NULL, gfp_mask, sg_kmalloc);
328 if (unlikely(ret)) 337 if (unlikely(ret))
329 __sg_free_table(table, SG_MAX_SINGLE_ALLOC, sg_kfree); 338 __sg_free_table(table, SG_MAX_SINGLE_ALLOC, false, sg_kfree);
330 339
331 return ret; 340 return ret;
332} 341}
diff --git a/lib/string.c b/lib/string.c
index 992bf30af759..10063300b830 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -27,14 +27,14 @@
27#include <linux/bug.h> 27#include <linux/bug.h>
28#include <linux/errno.h> 28#include <linux/errno.h>
29 29
30#ifndef __HAVE_ARCH_STRNICMP 30#ifndef __HAVE_ARCH_STRNCASECMP
31/** 31/**
32 * strnicmp - Case insensitive, length-limited string comparison 32 * strncasecmp - Case insensitive, length-limited string comparison
33 * @s1: One string 33 * @s1: One string
34 * @s2: The other string 34 * @s2: The other string
35 * @len: the maximum number of characters to compare 35 * @len: the maximum number of characters to compare
36 */ 36 */
37int strnicmp(const char *s1, const char *s2, size_t len) 37int strncasecmp(const char *s1, const char *s2, size_t len)
38{ 38{
39 /* Yes, Virginia, it had better be unsigned */ 39 /* Yes, Virginia, it had better be unsigned */
40 unsigned char c1, c2; 40 unsigned char c1, c2;
@@ -56,6 +56,14 @@ int strnicmp(const char *s1, const char *s2, size_t len)
56 } while (--len); 56 } while (--len);
57 return (int)c1 - (int)c2; 57 return (int)c1 - (int)c2;
58} 58}
59EXPORT_SYMBOL(strncasecmp);
60#endif
61#ifndef __HAVE_ARCH_STRNICMP
62#undef strnicmp
63int strnicmp(const char *s1, const char *s2, size_t len)
64{
65 return strncasecmp(s1, s2, len);
66}
59EXPORT_SYMBOL(strnicmp); 67EXPORT_SYMBOL(strnicmp);
60#endif 68#endif
61 69
@@ -73,20 +81,6 @@ int strcasecmp(const char *s1, const char *s2)
73EXPORT_SYMBOL(strcasecmp); 81EXPORT_SYMBOL(strcasecmp);
74#endif 82#endif
75 83
76#ifndef __HAVE_ARCH_STRNCASECMP
77int strncasecmp(const char *s1, const char *s2, size_t n)
78{
79 int c1, c2;
80
81 do {
82 c1 = tolower(*s1++);
83 c2 = tolower(*s2++);
84 } while ((--n > 0) && c1 == c2 && c1 != 0);
85 return c1 - c2;
86}
87EXPORT_SYMBOL(strncasecmp);
88#endif
89
90#ifndef __HAVE_ARCH_STRCPY 84#ifndef __HAVE_ARCH_STRCPY
91/** 85/**
92 * strcpy - Copy a %NUL terminated string 86 * strcpy - Copy a %NUL terminated string
@@ -604,6 +598,22 @@ void *memset(void *s, int c, size_t count)
604EXPORT_SYMBOL(memset); 598EXPORT_SYMBOL(memset);
605#endif 599#endif
606 600
601/**
602 * memzero_explicit - Fill a region of memory (e.g. sensitive
603 * keying data) with 0s.
604 * @s: Pointer to the start of the area.
605 * @count: The size of the area.
606 *
607 * memzero_explicit() doesn't need an arch-specific version as
608 * it just invokes the one of memset() implicitly.
609 */
610void memzero_explicit(void *s, size_t count)
611{
612 memset(s, 0, count);
613 OPTIMIZER_HIDE_VAR(s);
614}
615EXPORT_SYMBOL(memzero_explicit);
616
607#ifndef __HAVE_ARCH_MEMCPY 617#ifndef __HAVE_ARCH_MEMCPY
608/** 618/**
609 * memcpy - Copy one area of memory to another 619 * memcpy - Copy one area of memory to another
@@ -807,9 +817,9 @@ void *memchr_inv(const void *start, int c, size_t bytes)
807 return check_bytes8(start, value, bytes); 817 return check_bytes8(start, value, bytes);
808 818
809 value64 = value; 819 value64 = value;
810#if defined(ARCH_HAS_FAST_MULTIPLIER) && BITS_PER_LONG == 64 820#if defined(CONFIG_ARCH_HAS_FAST_MULTIPLIER) && BITS_PER_LONG == 64
811 value64 *= 0x0101010101010101; 821 value64 *= 0x0101010101010101;
812#elif defined(ARCH_HAS_FAST_MULTIPLIER) 822#elif defined(CONFIG_ARCH_HAS_FAST_MULTIPLIER)
813 value64 *= 0x01010101; 823 value64 *= 0x01010101;
814 value64 |= value64 << 32; 824 value64 |= value64 << 32;
815#else 825#else
diff --git a/lib/string_helpers.c b/lib/string_helpers.c
index ed5c1454dd62..58b78ba57439 100644
--- a/lib/string_helpers.c
+++ b/lib/string_helpers.c
@@ -8,6 +8,8 @@
8#include <linux/math64.h> 8#include <linux/math64.h>
9#include <linux/export.h> 9#include <linux/export.h>
10#include <linux/ctype.h> 10#include <linux/ctype.h>
11#include <linux/errno.h>
12#include <linux/string.h>
11#include <linux/string_helpers.h> 13#include <linux/string_helpers.h>
12 14
13/** 15/**
@@ -25,12 +27,15 @@
25int string_get_size(u64 size, const enum string_size_units units, 27int string_get_size(u64 size, const enum string_size_units units,
26 char *buf, int len) 28 char *buf, int len)
27{ 29{
28 static const char *units_10[] = { "B", "kB", "MB", "GB", "TB", "PB", 30 static const char *const units_10[] = {
29 "EB", "ZB", "YB", NULL}; 31 "B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB", NULL
30 static const char *units_2[] = {"B", "KiB", "MiB", "GiB", "TiB", "PiB", 32 };
31 "EiB", "ZiB", "YiB", NULL }; 33 static const char *const units_2[] = {
32 static const char **units_str[] = { 34 "B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB",
33 [STRING_UNITS_10] = units_10, 35 NULL
36 };
37 static const char *const *const units_str[] = {
38 [STRING_UNITS_10] = units_10,
34 [STRING_UNITS_2] = units_2, 39 [STRING_UNITS_2] = units_2,
35 }; 40 };
36 static const unsigned int divisor[] = { 41 static const unsigned int divisor[] = {
@@ -165,6 +170,44 @@ static bool unescape_special(char **src, char **dst)
165 return true; 170 return true;
166} 171}
167 172
173/**
174 * string_unescape - unquote characters in the given string
175 * @src: source buffer (escaped)
176 * @dst: destination buffer (unescaped)
177 * @size: size of the destination buffer (0 to unlimit)
178 * @flags: combination of the flags (bitwise OR):
179 * %UNESCAPE_SPACE:
180 * '\f' - form feed
181 * '\n' - new line
182 * '\r' - carriage return
183 * '\t' - horizontal tab
184 * '\v' - vertical tab
185 * %UNESCAPE_OCTAL:
186 * '\NNN' - byte with octal value NNN (1 to 3 digits)
187 * %UNESCAPE_HEX:
188 * '\xHH' - byte with hexadecimal value HH (1 to 2 digits)
189 * %UNESCAPE_SPECIAL:
190 * '\"' - double quote
191 * '\\' - backslash
192 * '\a' - alert (BEL)
193 * '\e' - escape
194 * %UNESCAPE_ANY:
195 * all previous together
196 *
197 * Description:
198 * The function unquotes characters in the given string.
199 *
200 * Because the size of the output will be the same as or less than the size of
201 * the input, the transformation may be performed in place.
202 *
203 * Caller must provide valid source and destination pointers. Be aware that
204 * destination buffer will always be NULL-terminated. Source string must be
205 * NULL-terminated as well.
206 *
207 * Return:
208 * The amount of the characters processed to the destination buffer excluding
209 * trailing '\0' is returned.
210 */
168int string_unescape(char *src, char *dst, size_t size, unsigned int flags) 211int string_unescape(char *src, char *dst, size_t size, unsigned int flags)
169{ 212{
170 char *out = dst; 213 char *out = dst;
@@ -199,3 +242,275 @@ int string_unescape(char *src, char *dst, size_t size, unsigned int flags)
199 return out - dst; 242 return out - dst;
200} 243}
201EXPORT_SYMBOL(string_unescape); 244EXPORT_SYMBOL(string_unescape);
245
246static int escape_passthrough(unsigned char c, char **dst, size_t *osz)
247{
248 char *out = *dst;
249
250 if (*osz < 1)
251 return -ENOMEM;
252
253 *out++ = c;
254
255 *dst = out;
256 *osz -= 1;
257
258 return 1;
259}
260
261static int escape_space(unsigned char c, char **dst, size_t *osz)
262{
263 char *out = *dst;
264 unsigned char to;
265
266 if (*osz < 2)
267 return -ENOMEM;
268
269 switch (c) {
270 case '\n':
271 to = 'n';
272 break;
273 case '\r':
274 to = 'r';
275 break;
276 case '\t':
277 to = 't';
278 break;
279 case '\v':
280 to = 'v';
281 break;
282 case '\f':
283 to = 'f';
284 break;
285 default:
286 return 0;
287 }
288
289 *out++ = '\\';
290 *out++ = to;
291
292 *dst = out;
293 *osz -= 2;
294
295 return 1;
296}
297
298static int escape_special(unsigned char c, char **dst, size_t *osz)
299{
300 char *out = *dst;
301 unsigned char to;
302
303 if (*osz < 2)
304 return -ENOMEM;
305
306 switch (c) {
307 case '\\':
308 to = '\\';
309 break;
310 case '\a':
311 to = 'a';
312 break;
313 case '\e':
314 to = 'e';
315 break;
316 default:
317 return 0;
318 }
319
320 *out++ = '\\';
321 *out++ = to;
322
323 *dst = out;
324 *osz -= 2;
325
326 return 1;
327}
328
329static int escape_null(unsigned char c, char **dst, size_t *osz)
330{
331 char *out = *dst;
332
333 if (*osz < 2)
334 return -ENOMEM;
335
336 if (c)
337 return 0;
338
339 *out++ = '\\';
340 *out++ = '0';
341
342 *dst = out;
343 *osz -= 2;
344
345 return 1;
346}
347
348static int escape_octal(unsigned char c, char **dst, size_t *osz)
349{
350 char *out = *dst;
351
352 if (*osz < 4)
353 return -ENOMEM;
354
355 *out++ = '\\';
356 *out++ = ((c >> 6) & 0x07) + '0';
357 *out++ = ((c >> 3) & 0x07) + '0';
358 *out++ = ((c >> 0) & 0x07) + '0';
359
360 *dst = out;
361 *osz -= 4;
362
363 return 1;
364}
365
366static int escape_hex(unsigned char c, char **dst, size_t *osz)
367{
368 char *out = *dst;
369
370 if (*osz < 4)
371 return -ENOMEM;
372
373 *out++ = '\\';
374 *out++ = 'x';
375 *out++ = hex_asc_hi(c);
376 *out++ = hex_asc_lo(c);
377
378 *dst = out;
379 *osz -= 4;
380
381 return 1;
382}
383
384/**
385 * string_escape_mem - quote characters in the given memory buffer
386 * @src: source buffer (unescaped)
387 * @isz: source buffer size
388 * @dst: destination buffer (escaped)
389 * @osz: destination buffer size
390 * @flags: combination of the flags (bitwise OR):
391 * %ESCAPE_SPACE:
392 * '\f' - form feed
393 * '\n' - new line
394 * '\r' - carriage return
395 * '\t' - horizontal tab
396 * '\v' - vertical tab
397 * %ESCAPE_SPECIAL:
398 * '\\' - backslash
399 * '\a' - alert (BEL)
400 * '\e' - escape
401 * %ESCAPE_NULL:
402 * '\0' - null
403 * %ESCAPE_OCTAL:
404 * '\NNN' - byte with octal value NNN (3 digits)
405 * %ESCAPE_ANY:
406 * all previous together
407 * %ESCAPE_NP:
408 * escape only non-printable characters (checked by isprint)
409 * %ESCAPE_ANY_NP:
410 * all previous together
411 * %ESCAPE_HEX:
412 * '\xHH' - byte with hexadecimal value HH (2 digits)
413 * @esc: NULL-terminated string of characters any of which, if found in
414 * the source, has to be escaped
415 *
416 * Description:
417 * The process of escaping byte buffer includes several parts. They are applied
418 * in the following sequence.
419 * 1. The character is matched to the printable class, if asked, and in
420 * case of match it passes through to the output.
421 * 2. The character is not matched to the one from @esc string and thus
422 * must go as is to the output.
423 * 3. The character is checked if it falls into the class given by @flags.
424 * %ESCAPE_OCTAL and %ESCAPE_HEX are going last since they cover any
425 * character. Note that they actually can't go together, otherwise
426 * %ESCAPE_HEX will be ignored.
427 *
428 * Caller must provide valid source and destination pointers. Be aware that
429 * destination buffer will not be NULL-terminated, thus caller have to append
430 * it if needs.
431 *
432 * Return:
433 * The amount of the characters processed to the destination buffer, or
434 * %-ENOMEM if the size of buffer is not enough to put an escaped character is
435 * returned.
436 *
437 * Even in the case of error @dst pointer will be updated to point to the byte
438 * after the last processed character.
439 */
440int string_escape_mem(const char *src, size_t isz, char **dst, size_t osz,
441 unsigned int flags, const char *esc)
442{
443 char *out = *dst, *p = out;
444 bool is_dict = esc && *esc;
445 int ret = 0;
446
447 while (isz--) {
448 unsigned char c = *src++;
449
450 /*
451 * Apply rules in the following sequence:
452 * - the character is printable, when @flags has
453 * %ESCAPE_NP bit set
454 * - the @esc string is supplied and does not contain a
455 * character under question
456 * - the character doesn't fall into a class of symbols
457 * defined by given @flags
458 * In these cases we just pass through a character to the
459 * output buffer.
460 */
461 if ((flags & ESCAPE_NP && isprint(c)) ||
462 (is_dict && !strchr(esc, c))) {
463 /* do nothing */
464 } else {
465 if (flags & ESCAPE_SPACE) {
466 ret = escape_space(c, &p, &osz);
467 if (ret < 0)
468 break;
469 if (ret > 0)
470 continue;
471 }
472
473 if (flags & ESCAPE_SPECIAL) {
474 ret = escape_special(c, &p, &osz);
475 if (ret < 0)
476 break;
477 if (ret > 0)
478 continue;
479 }
480
481 if (flags & ESCAPE_NULL) {
482 ret = escape_null(c, &p, &osz);
483 if (ret < 0)
484 break;
485 if (ret > 0)
486 continue;
487 }
488
489 /* ESCAPE_OCTAL and ESCAPE_HEX always go last */
490 if (flags & ESCAPE_OCTAL) {
491 ret = escape_octal(c, &p, &osz);
492 if (ret < 0)
493 break;
494 continue;
495 }
496 if (flags & ESCAPE_HEX) {
497 ret = escape_hex(c, &p, &osz);
498 if (ret < 0)
499 break;
500 continue;
501 }
502 }
503
504 ret = escape_passthrough(c, &p, &osz);
505 if (ret < 0)
506 break;
507 }
508
509 *dst = p;
510
511 if (ret < 0)
512 return ret;
513
514 return p - out;
515}
516EXPORT_SYMBOL(string_escape_mem);
diff --git a/lib/test-kstrtox.c b/lib/test-kstrtox.c
index bea3f3fa3f02..4137bca5f8e8 100644
--- a/lib/test-kstrtox.c
+++ b/lib/test-kstrtox.c
@@ -3,7 +3,7 @@
3#include <linux/module.h> 3#include <linux/module.h>
4 4
5#define for_each_test(i, test) \ 5#define for_each_test(i, test) \
6 for (i = 0; i < sizeof(test) / sizeof(test[0]); i++) 6 for (i = 0; i < ARRAY_SIZE(test); i++)
7 7
8struct test_fail { 8struct test_fail {
9 const char *str; 9 const char *str;
diff --git a/lib/test-string_helpers.c b/lib/test-string_helpers.c
index 6ac48de04c0e..ab0d30e1e18f 100644
--- a/lib/test-string_helpers.c
+++ b/lib/test-string_helpers.c
@@ -5,11 +5,32 @@
5 5
6#include <linux/init.h> 6#include <linux/init.h>
7#include <linux/kernel.h> 7#include <linux/kernel.h>
8#include <linux/slab.h>
8#include <linux/module.h> 9#include <linux/module.h>
9#include <linux/random.h> 10#include <linux/random.h>
10#include <linux/string.h> 11#include <linux/string.h>
11#include <linux/string_helpers.h> 12#include <linux/string_helpers.h>
12 13
14static __init bool test_string_check_buf(const char *name, unsigned int flags,
15 char *in, size_t p,
16 char *out_real, size_t q_real,
17 char *out_test, size_t q_test)
18{
19 if (q_real == q_test && !memcmp(out_test, out_real, q_test))
20 return true;
21
22 pr_warn("Test '%s' failed: flags = %u\n", name, flags);
23
24 print_hex_dump(KERN_WARNING, "Input: ", DUMP_PREFIX_NONE, 16, 1,
25 in, p, true);
26 print_hex_dump(KERN_WARNING, "Expected: ", DUMP_PREFIX_NONE, 16, 1,
27 out_test, q_test, true);
28 print_hex_dump(KERN_WARNING, "Got: ", DUMP_PREFIX_NONE, 16, 1,
29 out_real, q_real, true);
30
31 return false;
32}
33
13struct test_string { 34struct test_string {
14 const char *in; 35 const char *in;
15 const char *out; 36 const char *out;
@@ -39,12 +60,17 @@ static const struct test_string strings[] __initconst = {
39 }, 60 },
40}; 61};
41 62
42static void __init test_string_unescape(unsigned int flags, bool inplace) 63static void __init test_string_unescape(const char *name, unsigned int flags,
64 bool inplace)
43{ 65{
44 char in[256]; 66 int q_real = 256;
45 char out_test[256]; 67 char *in = kmalloc(q_real, GFP_KERNEL);
46 char out_real[256]; 68 char *out_test = kmalloc(q_real, GFP_KERNEL);
47 int i, p = 0, q_test = 0, q_real = sizeof(out_real); 69 char *out_real = kmalloc(q_real, GFP_KERNEL);
70 int i, p = 0, q_test = 0;
71
72 if (!in || !out_test || !out_real)
73 goto out;
48 74
49 for (i = 0; i < ARRAY_SIZE(strings); i++) { 75 for (i = 0; i < ARRAY_SIZE(strings); i++) {
50 const char *s = strings[i].in; 76 const char *s = strings[i].in;
@@ -77,15 +103,225 @@ static void __init test_string_unescape(unsigned int flags, bool inplace)
77 q_real = string_unescape(in, out_real, q_real, flags); 103 q_real = string_unescape(in, out_real, q_real, flags);
78 } 104 }
79 105
80 if (q_real != q_test || memcmp(out_test, out_real, q_test)) { 106 test_string_check_buf(name, flags, in, p - 1, out_real, q_real,
81 pr_warn("Test failed: flags = %u\n", flags); 107 out_test, q_test);
82 print_hex_dump(KERN_WARNING, "Input: ", 108out:
83 DUMP_PREFIX_NONE, 16, 1, in, p - 1, true); 109 kfree(out_real);
84 print_hex_dump(KERN_WARNING, "Expected: ", 110 kfree(out_test);
85 DUMP_PREFIX_NONE, 16, 1, out_test, q_test, true); 111 kfree(in);
86 print_hex_dump(KERN_WARNING, "Got: ", 112}
87 DUMP_PREFIX_NONE, 16, 1, out_real, q_real, true); 113
114struct test_string_1 {
115 const char *out;
116 unsigned int flags;
117};
118
119#define TEST_STRING_2_MAX_S1 32
120struct test_string_2 {
121 const char *in;
122 struct test_string_1 s1[TEST_STRING_2_MAX_S1];
123};
124
125#define TEST_STRING_2_DICT_0 NULL
126static const struct test_string_2 escape0[] __initconst = {{
127 .in = "\f\\ \n\r\t\v",
128 .s1 = {{
129 .out = "\\f\\ \\n\\r\\t\\v",
130 .flags = ESCAPE_SPACE,
131 },{
132 .out = "\\f\\134\\040\\n\\r\\t\\v",
133 .flags = ESCAPE_SPACE | ESCAPE_OCTAL,
134 },{
135 .out = "\\f\\x5c\\x20\\n\\r\\t\\v",
136 .flags = ESCAPE_SPACE | ESCAPE_HEX,
137 },{
138 /* terminator */
139 }},
140},{
141 .in = "\\h\\\"\a\e\\",
142 .s1 = {{
143 .out = "\\\\h\\\\\"\\a\\e\\\\",
144 .flags = ESCAPE_SPECIAL,
145 },{
146 .out = "\\\\\\150\\\\\\042\\a\\e\\\\",
147 .flags = ESCAPE_SPECIAL | ESCAPE_OCTAL,
148 },{
149 .out = "\\\\\\x68\\\\\\x22\\a\\e\\\\",
150 .flags = ESCAPE_SPECIAL | ESCAPE_HEX,
151 },{
152 /* terminator */
153 }},
154},{
155 .in = "\eb \\C\007\"\x90\r]",
156 .s1 = {{
157 .out = "\eb \\C\007\"\x90\\r]",
158 .flags = ESCAPE_SPACE,
159 },{
160 .out = "\\eb \\\\C\\a\"\x90\r]",
161 .flags = ESCAPE_SPECIAL,
162 },{
163 .out = "\\eb \\\\C\\a\"\x90\\r]",
164 .flags = ESCAPE_SPACE | ESCAPE_SPECIAL,
165 },{
166 .out = "\\033\\142\\040\\134\\103\\007\\042\\220\\015\\135",
167 .flags = ESCAPE_OCTAL,
168 },{
169 .out = "\\033\\142\\040\\134\\103\\007\\042\\220\\r\\135",
170 .flags = ESCAPE_SPACE | ESCAPE_OCTAL,
171 },{
172 .out = "\\e\\142\\040\\\\\\103\\a\\042\\220\\015\\135",
173 .flags = ESCAPE_SPECIAL | ESCAPE_OCTAL,
174 },{
175 .out = "\\e\\142\\040\\\\\\103\\a\\042\\220\\r\\135",
176 .flags = ESCAPE_SPACE | ESCAPE_SPECIAL | ESCAPE_OCTAL,
177 },{
178 .out = "\eb \\C\007\"\x90\r]",
179 .flags = ESCAPE_NP,
180 },{
181 .out = "\eb \\C\007\"\x90\\r]",
182 .flags = ESCAPE_SPACE | ESCAPE_NP,
183 },{
184 .out = "\\eb \\C\\a\"\x90\r]",
185 .flags = ESCAPE_SPECIAL | ESCAPE_NP,
186 },{
187 .out = "\\eb \\C\\a\"\x90\\r]",
188 .flags = ESCAPE_SPACE | ESCAPE_SPECIAL | ESCAPE_NP,
189 },{
190 .out = "\\033b \\C\\007\"\\220\\015]",
191 .flags = ESCAPE_OCTAL | ESCAPE_NP,
192 },{
193 .out = "\\033b \\C\\007\"\\220\\r]",
194 .flags = ESCAPE_SPACE | ESCAPE_OCTAL | ESCAPE_NP,
195 },{
196 .out = "\\eb \\C\\a\"\\220\\r]",
197 .flags = ESCAPE_SPECIAL | ESCAPE_SPACE | ESCAPE_OCTAL |
198 ESCAPE_NP,
199 },{
200 .out = "\\x1bb \\C\\x07\"\\x90\\x0d]",
201 .flags = ESCAPE_NP | ESCAPE_HEX,
202 },{
203 /* terminator */
204 }},
205},{
206 /* terminator */
207}};
208
209#define TEST_STRING_2_DICT_1 "b\\ \t\r"
210static const struct test_string_2 escape1[] __initconst = {{
211 .in = "\f\\ \n\r\t\v",
212 .s1 = {{
213 .out = "\f\\134\\040\n\\015\\011\v",
214 .flags = ESCAPE_OCTAL,
215 },{
216 .out = "\f\\x5c\\x20\n\\x0d\\x09\v",
217 .flags = ESCAPE_HEX,
218 },{
219 /* terminator */
220 }},
221},{
222 .in = "\\h\\\"\a\e\\",
223 .s1 = {{
224 .out = "\\134h\\134\"\a\e\\134",
225 .flags = ESCAPE_OCTAL,
226 },{
227 /* terminator */
228 }},
229},{
230 .in = "\eb \\C\007\"\x90\r]",
231 .s1 = {{
232 .out = "\e\\142\\040\\134C\007\"\x90\\015]",
233 .flags = ESCAPE_OCTAL,
234 },{
235 /* terminator */
236 }},
237},{
238 /* terminator */
239}};
240
241static __init const char *test_string_find_match(const struct test_string_2 *s2,
242 unsigned int flags)
243{
244 const struct test_string_1 *s1 = s2->s1;
245 unsigned int i;
246
247 if (!flags)
248 return s2->in;
249
250 /* Test cases are NULL-aware */
251 flags &= ~ESCAPE_NULL;
252
253 /* ESCAPE_OCTAL has a higher priority */
254 if (flags & ESCAPE_OCTAL)
255 flags &= ~ESCAPE_HEX;
256
257 for (i = 0; i < TEST_STRING_2_MAX_S1 && s1->out; i++, s1++)
258 if (s1->flags == flags)
259 return s1->out;
260 return NULL;
261}
262
263static __init void test_string_escape(const char *name,
264 const struct test_string_2 *s2,
265 unsigned int flags, const char *esc)
266{
267 int q_real = 512;
268 char *out_test = kmalloc(q_real, GFP_KERNEL);
269 char *out_real = kmalloc(q_real, GFP_KERNEL);
270 char *in = kmalloc(256, GFP_KERNEL);
271 char *buf = out_real;
272 int p = 0, q_test = 0;
273
274 if (!out_test || !out_real || !in)
275 goto out;
276
277 for (; s2->in; s2++) {
278 const char *out;
279 int len;
280
281 /* NULL injection */
282 if (flags & ESCAPE_NULL) {
283 in[p++] = '\0';
284 out_test[q_test++] = '\\';
285 out_test[q_test++] = '0';
286 }
287
288 /* Don't try strings that have no output */
289 out = test_string_find_match(s2, flags);
290 if (!out)
291 continue;
292
293 /* Copy string to in buffer */
294 len = strlen(s2->in);
295 memcpy(&in[p], s2->in, len);
296 p += len;
297
298 /* Copy expected result for given flags */
299 len = strlen(out);
300 memcpy(&out_test[q_test], out, len);
301 q_test += len;
88 } 302 }
303
304 q_real = string_escape_mem(in, p, &buf, q_real, flags, esc);
305
306 test_string_check_buf(name, flags, in, p, out_real, q_real, out_test,
307 q_test);
308out:
309 kfree(in);
310 kfree(out_real);
311 kfree(out_test);
312}
313
314static __init void test_string_escape_nomem(void)
315{
316 char *in = "\eb \\C\007\"\x90\r]";
317 char out[64], *buf = out;
318 int rc = -ENOMEM, ret;
319
320 ret = string_escape_str_any_np(in, &buf, strlen(in), NULL);
321 if (ret == rc)
322 return;
323
324 pr_err("Test 'escape nomem' failed: got %d instead of %d\n", ret, rc);
89} 325}
90 326
91static int __init test_string_helpers_init(void) 327static int __init test_string_helpers_init(void)
@@ -94,8 +330,19 @@ static int __init test_string_helpers_init(void)
94 330
95 pr_info("Running tests...\n"); 331 pr_info("Running tests...\n");
96 for (i = 0; i < UNESCAPE_ANY + 1; i++) 332 for (i = 0; i < UNESCAPE_ANY + 1; i++)
97 test_string_unescape(i, false); 333 test_string_unescape("unescape", i, false);
98 test_string_unescape(get_random_int() % (UNESCAPE_ANY + 1), true); 334 test_string_unescape("unescape inplace",
335 get_random_int() % (UNESCAPE_ANY + 1), true);
336
337 /* Without dictionary */
338 for (i = 0; i < (ESCAPE_ANY_NP | ESCAPE_HEX) + 1; i++)
339 test_string_escape("escape 0", escape0, i, TEST_STRING_2_DICT_0);
340
341 /* With dictionary */
342 for (i = 0; i < (ESCAPE_ANY_NP | ESCAPE_HEX) + 1; i++)
343 test_string_escape("escape 1", escape1, i, TEST_STRING_2_DICT_1);
344
345 test_string_escape_nomem();
99 346
100 return -EINVAL; 347 return -EINVAL;
101} 348}
diff --git a/lib/test_bpf.c b/lib/test_bpf.c
index c579e0f58818..23e070bcf72d 100644
--- a/lib/test_bpf.c
+++ b/lib/test_bpf.c
@@ -66,7 +66,7 @@ struct bpf_test {
66 const char *descr; 66 const char *descr;
67 union { 67 union {
68 struct sock_filter insns[MAX_INSNS]; 68 struct sock_filter insns[MAX_INSNS];
69 struct sock_filter_int insns_int[MAX_INSNS]; 69 struct bpf_insn insns_int[MAX_INSNS];
70 } u; 70 } u;
71 __u8 aux; 71 __u8 aux;
72 __u8 data[MAX_DATA]; 72 __u8 data[MAX_DATA];
@@ -1342,6 +1342,44 @@ static struct bpf_test tests[] = {
1342 { { 0, -1 } } 1342 { { 0, -1 } }
1343 }, 1343 },
1344 { 1344 {
1345 "INT: shifts by register",
1346 .u.insns_int = {
1347 BPF_MOV64_IMM(R0, -1234),
1348 BPF_MOV64_IMM(R1, 1),
1349 BPF_ALU32_REG(BPF_RSH, R0, R1),
1350 BPF_JMP_IMM(BPF_JEQ, R0, 0x7ffffd97, 1),
1351 BPF_EXIT_INSN(),
1352 BPF_MOV64_IMM(R2, 1),
1353 BPF_ALU64_REG(BPF_LSH, R0, R2),
1354 BPF_MOV32_IMM(R4, -1234),
1355 BPF_JMP_REG(BPF_JEQ, R0, R4, 1),
1356 BPF_EXIT_INSN(),
1357 BPF_ALU64_IMM(BPF_AND, R4, 63),
1358 BPF_ALU64_REG(BPF_LSH, R0, R4), /* R0 <= 46 */
1359 BPF_MOV64_IMM(R3, 47),
1360 BPF_ALU64_REG(BPF_ARSH, R0, R3),
1361 BPF_JMP_IMM(BPF_JEQ, R0, -617, 1),
1362 BPF_EXIT_INSN(),
1363 BPF_MOV64_IMM(R2, 1),
1364 BPF_ALU64_REG(BPF_LSH, R4, R2), /* R4 = 46 << 1 */
1365 BPF_JMP_IMM(BPF_JEQ, R4, 92, 1),
1366 BPF_EXIT_INSN(),
1367 BPF_MOV64_IMM(R4, 4),
1368 BPF_ALU64_REG(BPF_LSH, R4, R4), /* R4 = 4 << 4 */
1369 BPF_JMP_IMM(BPF_JEQ, R4, 64, 1),
1370 BPF_EXIT_INSN(),
1371 BPF_MOV64_IMM(R4, 5),
1372 BPF_ALU32_REG(BPF_LSH, R4, R4), /* R4 = 5 << 5 */
1373 BPF_JMP_IMM(BPF_JEQ, R4, 160, 1),
1374 BPF_EXIT_INSN(),
1375 BPF_MOV64_IMM(R0, -1),
1376 BPF_EXIT_INSN(),
1377 },
1378 INTERNAL,
1379 { },
1380 { { 0, -1 } }
1381 },
1382 {
1345 "INT: DIV + ABS", 1383 "INT: DIV + ABS",
1346 .u.insns_int = { 1384 .u.insns_int = {
1347 BPF_ALU64_REG(BPF_MOV, R6, R1), 1385 BPF_ALU64_REG(BPF_MOV, R6, R1),
@@ -1697,6 +1735,27 @@ static struct bpf_test tests[] = {
1697 { }, 1735 { },
1698 { { 1, 0 } }, 1736 { { 1, 0 } },
1699 }, 1737 },
1738 {
1739 "load 64-bit immediate",
1740 .u.insns_int = {
1741 BPF_LD_IMM64(R1, 0x567800001234LL),
1742 BPF_MOV64_REG(R2, R1),
1743 BPF_MOV64_REG(R3, R2),
1744 BPF_ALU64_IMM(BPF_RSH, R2, 32),
1745 BPF_ALU64_IMM(BPF_LSH, R3, 32),
1746 BPF_ALU64_IMM(BPF_RSH, R3, 32),
1747 BPF_ALU64_IMM(BPF_MOV, R0, 0),
1748 BPF_JMP_IMM(BPF_JEQ, R2, 0x5678, 1),
1749 BPF_EXIT_INSN(),
1750 BPF_JMP_IMM(BPF_JEQ, R3, 0x1234, 1),
1751 BPF_EXIT_INSN(),
1752 BPF_ALU64_IMM(BPF_MOV, R0, 1),
1753 BPF_EXIT_INSN(),
1754 },
1755 INTERNAL,
1756 { },
1757 { { 0, 1 } }
1758 },
1700}; 1759};
1701 1760
1702static struct net_device dev; 1761static struct net_device dev;
@@ -1761,9 +1820,9 @@ static int probe_filter_length(struct sock_filter *fp)
1761 return len + 1; 1820 return len + 1;
1762} 1821}
1763 1822
1764static struct sk_filter *generate_filter(int which, int *err) 1823static struct bpf_prog *generate_filter(int which, int *err)
1765{ 1824{
1766 struct sk_filter *fp; 1825 struct bpf_prog *fp;
1767 struct sock_fprog_kern fprog; 1826 struct sock_fprog_kern fprog;
1768 unsigned int flen = probe_filter_length(tests[which].u.insns); 1827 unsigned int flen = probe_filter_length(tests[which].u.insns);
1769 __u8 test_type = tests[which].aux & TEST_TYPE_MASK; 1828 __u8 test_type = tests[which].aux & TEST_TYPE_MASK;
@@ -1773,7 +1832,7 @@ static struct sk_filter *generate_filter(int which, int *err)
1773 fprog.filter = tests[which].u.insns; 1832 fprog.filter = tests[which].u.insns;
1774 fprog.len = flen; 1833 fprog.len = flen;
1775 1834
1776 *err = sk_unattached_filter_create(&fp, &fprog); 1835 *err = bpf_prog_create(&fp, &fprog);
1777 if (tests[which].aux & FLAG_EXPECTED_FAIL) { 1836 if (tests[which].aux & FLAG_EXPECTED_FAIL) {
1778 if (*err == -EINVAL) { 1837 if (*err == -EINVAL) {
1779 pr_cont("PASS\n"); 1838 pr_cont("PASS\n");
@@ -1798,7 +1857,7 @@ static struct sk_filter *generate_filter(int which, int *err)
1798 break; 1857 break;
1799 1858
1800 case INTERNAL: 1859 case INTERNAL:
1801 fp = kzalloc(sk_filter_size(flen), GFP_KERNEL); 1860 fp = bpf_prog_alloc(bpf_prog_size(flen), 0);
1802 if (fp == NULL) { 1861 if (fp == NULL) {
1803 pr_cont("UNEXPECTED_FAIL no memory left\n"); 1862 pr_cont("UNEXPECTED_FAIL no memory left\n");
1804 *err = -ENOMEM; 1863 *err = -ENOMEM;
@@ -1807,9 +1866,9 @@ static struct sk_filter *generate_filter(int which, int *err)
1807 1866
1808 fp->len = flen; 1867 fp->len = flen;
1809 memcpy(fp->insnsi, tests[which].u.insns_int, 1868 memcpy(fp->insnsi, tests[which].u.insns_int,
1810 fp->len * sizeof(struct sock_filter_int)); 1869 fp->len * sizeof(struct bpf_insn));
1811 1870
1812 sk_filter_select_runtime(fp); 1871 bpf_prog_select_runtime(fp);
1813 break; 1872 break;
1814 } 1873 }
1815 1874
@@ -1817,30 +1876,30 @@ static struct sk_filter *generate_filter(int which, int *err)
1817 return fp; 1876 return fp;
1818} 1877}
1819 1878
1820static void release_filter(struct sk_filter *fp, int which) 1879static void release_filter(struct bpf_prog *fp, int which)
1821{ 1880{
1822 __u8 test_type = tests[which].aux & TEST_TYPE_MASK; 1881 __u8 test_type = tests[which].aux & TEST_TYPE_MASK;
1823 1882
1824 switch (test_type) { 1883 switch (test_type) {
1825 case CLASSIC: 1884 case CLASSIC:
1826 sk_unattached_filter_destroy(fp); 1885 bpf_prog_destroy(fp);
1827 break; 1886 break;
1828 case INTERNAL: 1887 case INTERNAL:
1829 sk_filter_free(fp); 1888 bpf_prog_free(fp);
1830 break; 1889 break;
1831 } 1890 }
1832} 1891}
1833 1892
1834static int __run_one(const struct sk_filter *fp, const void *data, 1893static int __run_one(const struct bpf_prog *fp, const void *data,
1835 int runs, u64 *duration) 1894 int runs, u64 *duration)
1836{ 1895{
1837 u64 start, finish; 1896 u64 start, finish;
1838 int ret, i; 1897 int ret = 0, i;
1839 1898
1840 start = ktime_to_us(ktime_get()); 1899 start = ktime_to_us(ktime_get());
1841 1900
1842 for (i = 0; i < runs; i++) 1901 for (i = 0; i < runs; i++)
1843 ret = SK_RUN_FILTER(fp, data); 1902 ret = BPF_PROG_RUN(fp, data);
1844 1903
1845 finish = ktime_to_us(ktime_get()); 1904 finish = ktime_to_us(ktime_get());
1846 1905
@@ -1850,7 +1909,7 @@ static int __run_one(const struct sk_filter *fp, const void *data,
1850 return ret; 1909 return ret;
1851} 1910}
1852 1911
1853static int run_one(const struct sk_filter *fp, struct bpf_test *test) 1912static int run_one(const struct bpf_prog *fp, struct bpf_test *test)
1854{ 1913{
1855 int err_cnt = 0, i, runs = MAX_TESTRUNS; 1914 int err_cnt = 0, i, runs = MAX_TESTRUNS;
1856 1915
@@ -1884,7 +1943,7 @@ static __init int test_bpf(void)
1884 int i, err_cnt = 0, pass_cnt = 0; 1943 int i, err_cnt = 0, pass_cnt = 0;
1885 1944
1886 for (i = 0; i < ARRAY_SIZE(tests); i++) { 1945 for (i = 0; i < ARRAY_SIZE(tests); i++) {
1887 struct sk_filter *fp; 1946 struct bpf_prog *fp;
1888 int err; 1947 int err;
1889 1948
1890 pr_info("#%d %s ", i, tests[i].descr); 1949 pr_info("#%d %s ", i, tests[i].descr);
diff --git a/lib/test_firmware.c b/lib/test_firmware.c
new file mode 100644
index 000000000000..86374c1c49a4
--- /dev/null
+++ b/lib/test_firmware.c
@@ -0,0 +1,117 @@
1/*
2 * This module provides an interface to trigger and test firmware loading.
3 *
4 * It is designed to be used for basic evaluation of the firmware loading
5 * subsystem (for example when validating firmware verification). It lacks
6 * any extra dependencies, and will not normally be loaded by the system
7 * unless explicitly requested by name.
8 */
9
10#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
11
12#include <linux/init.h>
13#include <linux/module.h>
14#include <linux/printk.h>
15#include <linux/firmware.h>
16#include <linux/device.h>
17#include <linux/fs.h>
18#include <linux/miscdevice.h>
19#include <linux/slab.h>
20#include <linux/uaccess.h>
21
22static DEFINE_MUTEX(test_fw_mutex);
23static const struct firmware *test_firmware;
24
25static ssize_t test_fw_misc_read(struct file *f, char __user *buf,
26 size_t size, loff_t *offset)
27{
28 ssize_t rc = 0;
29
30 mutex_lock(&test_fw_mutex);
31 if (test_firmware)
32 rc = simple_read_from_buffer(buf, size, offset,
33 test_firmware->data,
34 test_firmware->size);
35 mutex_unlock(&test_fw_mutex);
36 return rc;
37}
38
39static const struct file_operations test_fw_fops = {
40 .owner = THIS_MODULE,
41 .read = test_fw_misc_read,
42};
43
44static struct miscdevice test_fw_misc_device = {
45 .minor = MISC_DYNAMIC_MINOR,
46 .name = "test_firmware",
47 .fops = &test_fw_fops,
48};
49
50static ssize_t trigger_request_store(struct device *dev,
51 struct device_attribute *attr,
52 const char *buf, size_t count)
53{
54 int rc;
55 char *name;
56
57 name = kzalloc(count + 1, GFP_KERNEL);
58 if (!name)
59 return -ENOSPC;
60 memcpy(name, buf, count);
61
62 pr_info("loading '%s'\n", name);
63
64 mutex_lock(&test_fw_mutex);
65 release_firmware(test_firmware);
66 test_firmware = NULL;
67 rc = request_firmware(&test_firmware, name, dev);
68 if (rc)
69 pr_info("load of '%s' failed: %d\n", name, rc);
70 pr_info("loaded: %zu\n", test_firmware ? test_firmware->size : 0);
71 mutex_unlock(&test_fw_mutex);
72
73 kfree(name);
74
75 return count;
76}
77static DEVICE_ATTR_WO(trigger_request);
78
79static int __init test_firmware_init(void)
80{
81 int rc;
82
83 rc = misc_register(&test_fw_misc_device);
84 if (rc) {
85 pr_err("could not register misc device: %d\n", rc);
86 return rc;
87 }
88 rc = device_create_file(test_fw_misc_device.this_device,
89 &dev_attr_trigger_request);
90 if (rc) {
91 pr_err("could not create sysfs interface: %d\n", rc);
92 goto dereg;
93 }
94
95 pr_warn("interface ready\n");
96
97 return 0;
98dereg:
99 misc_deregister(&test_fw_misc_device);
100 return rc;
101}
102
103module_init(test_firmware_init);
104
105static void __exit test_firmware_exit(void)
106{
107 release_firmware(test_firmware);
108 device_remove_file(test_fw_misc_device.this_device,
109 &dev_attr_trigger_request);
110 misc_deregister(&test_fw_misc_device);
111 pr_warn("removed interface\n");
112}
113
114module_exit(test_firmware_exit);
115
116MODULE_AUTHOR("Kees Cook <keescook@chromium.org>");
117MODULE_LICENSE("GPL");
diff --git a/lib/textsearch.c b/lib/textsearch.c
index 0c7e9ab2d88f..0b79908dfe89 100644
--- a/lib/textsearch.c
+++ b/lib/textsearch.c
@@ -249,9 +249,7 @@ EXPORT_SYMBOL(textsearch_find_continuous);
249 * @flags: search flags 249 * @flags: search flags
250 * 250 *
251 * Looks up the search algorithm module and creates a new textsearch 251 * Looks up the search algorithm module and creates a new textsearch
252 * configuration for the specified pattern. Upon completion all 252 * configuration for the specified pattern.
253 * necessary refcnts are held and the configuration must be put back
254 * using textsearch_put() after usage.
255 * 253 *
256 * Note: The format of the pattern may not be compatible between 254 * Note: The format of the pattern may not be compatible between
257 * the various search algorithms. 255 * the various search algorithms.
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 6fe2c84eb055..ec337f64f52d 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -33,6 +33,7 @@
33#include <asm/page.h> /* for PAGE_SIZE */ 33#include <asm/page.h> /* for PAGE_SIZE */
34#include <asm/sections.h> /* for dereference_function_descriptor() */ 34#include <asm/sections.h> /* for dereference_function_descriptor() */
35 35
36#include <linux/string_helpers.h>
36#include "kstrtox.h" 37#include "kstrtox.h"
37 38
38/** 39/**
@@ -1101,6 +1102,62 @@ char *ip4_addr_string_sa(char *buf, char *end, const struct sockaddr_in *sa,
1101} 1102}
1102 1103
1103static noinline_for_stack 1104static noinline_for_stack
1105char *escaped_string(char *buf, char *end, u8 *addr, struct printf_spec spec,
1106 const char *fmt)
1107{
1108 bool found = true;
1109 int count = 1;
1110 unsigned int flags = 0;
1111 int len;
1112
1113 if (spec.field_width == 0)
1114 return buf; /* nothing to print */
1115
1116 if (ZERO_OR_NULL_PTR(addr))
1117 return string(buf, end, NULL, spec); /* NULL pointer */
1118
1119
1120 do {
1121 switch (fmt[count++]) {
1122 case 'a':
1123 flags |= ESCAPE_ANY;
1124 break;
1125 case 'c':
1126 flags |= ESCAPE_SPECIAL;
1127 break;
1128 case 'h':
1129 flags |= ESCAPE_HEX;
1130 break;
1131 case 'n':
1132 flags |= ESCAPE_NULL;
1133 break;
1134 case 'o':
1135 flags |= ESCAPE_OCTAL;
1136 break;
1137 case 'p':
1138 flags |= ESCAPE_NP;
1139 break;
1140 case 's':
1141 flags |= ESCAPE_SPACE;
1142 break;
1143 default:
1144 found = false;
1145 break;
1146 }
1147 } while (found);
1148
1149 if (!flags)
1150 flags = ESCAPE_ANY_NP;
1151
1152 len = spec.field_width < 0 ? 1 : spec.field_width;
1153
1154 /* Ignore the error. We print as many characters as we can */
1155 string_escape_mem(addr, len, &buf, end - buf, flags, NULL);
1156
1157 return buf;
1158}
1159
1160static noinline_for_stack
1104char *uuid_string(char *buf, char *end, const u8 *addr, 1161char *uuid_string(char *buf, char *end, const u8 *addr,
1105 struct printf_spec spec, const char *fmt) 1162 struct printf_spec spec, const char *fmt)
1106{ 1163{
@@ -1221,6 +1278,17 @@ int kptr_restrict __read_mostly;
1221 * - '[Ii][4S][hnbl]' IPv4 addresses in host, network, big or little endian order 1278 * - '[Ii][4S][hnbl]' IPv4 addresses in host, network, big or little endian order
1222 * - 'I[6S]c' for IPv6 addresses printed as specified by 1279 * - 'I[6S]c' for IPv6 addresses printed as specified by
1223 * http://tools.ietf.org/html/rfc5952 1280 * http://tools.ietf.org/html/rfc5952
1281 * - 'E[achnops]' For an escaped buffer, where rules are defined by combination
1282 * of the following flags (see string_escape_mem() for the
1283 * details):
1284 * a - ESCAPE_ANY
1285 * c - ESCAPE_SPECIAL
1286 * h - ESCAPE_HEX
1287 * n - ESCAPE_NULL
1288 * o - ESCAPE_OCTAL
1289 * p - ESCAPE_NP
1290 * s - ESCAPE_SPACE
1291 * By default ESCAPE_ANY_NP is used.
1224 * - 'U' For a 16 byte UUID/GUID, it prints the UUID/GUID in the form 1292 * - 'U' For a 16 byte UUID/GUID, it prints the UUID/GUID in the form
1225 * "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" 1293 * "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
1226 * Options for %pU are: 1294 * Options for %pU are:
@@ -1321,6 +1389,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
1321 }} 1389 }}
1322 } 1390 }
1323 break; 1391 break;
1392 case 'E':
1393 return escaped_string(buf, end, ptr, spec, fmt);
1324 case 'U': 1394 case 'U':
1325 return uuid_string(buf, end, ptr, spec, fmt); 1395 return uuid_string(buf, end, ptr, spec, fmt);
1326 case 'V': 1396 case 'V':
@@ -1633,6 +1703,7 @@ qualifier:
1633 * %piS depending on sa_family of 'struct sockaddr *' print IPv4/IPv6 address 1703 * %piS depending on sa_family of 'struct sockaddr *' print IPv4/IPv6 address
1634 * %pU[bBlL] print a UUID/GUID in big or little endian using lower or upper 1704 * %pU[bBlL] print a UUID/GUID in big or little endian using lower or upper
1635 * case. 1705 * case.
1706 * %*pE[achnops] print an escaped buffer
1636 * %*ph[CDN] a variable-length hex string with a separator (supports up to 64 1707 * %*ph[CDN] a variable-length hex string with a separator (supports up to 64
1637 * bytes of the input) 1708 * bytes of the input)
1638 * %n is ignored 1709 * %n is ignored
@@ -1937,7 +2008,7 @@ EXPORT_SYMBOL(sprintf);
1937 * @args: Arguments for the format string 2008 * @args: Arguments for the format string
1938 * 2009 *
1939 * The format follows C99 vsnprintf, except %n is ignored, and its argument 2010 * The format follows C99 vsnprintf, except %n is ignored, and its argument
1940 * is skiped. 2011 * is skipped.
1941 * 2012 *
1942 * The return value is the number of words(32bits) which would be generated for 2013 * The return value is the number of words(32bits) which would be generated for
1943 * the given input. 2014 * the given input.
diff --git a/lib/zlib_deflate/deflate.c b/lib/zlib_deflate/deflate.c
index d63381e8e333..d20ef458f137 100644
--- a/lib/zlib_deflate/deflate.c
+++ b/lib/zlib_deflate/deflate.c
@@ -250,52 +250,6 @@ int zlib_deflateInit2(
250} 250}
251 251
252/* ========================================================================= */ 252/* ========================================================================= */
253#if 0
254int zlib_deflateSetDictionary(
255 z_streamp strm,
256 const Byte *dictionary,
257 uInt dictLength
258)
259{
260 deflate_state *s;
261 uInt length = dictLength;
262 uInt n;
263 IPos hash_head = 0;
264
265 if (strm == NULL || strm->state == NULL || dictionary == NULL)
266 return Z_STREAM_ERROR;
267
268 s = (deflate_state *) strm->state;
269 if (s->status != INIT_STATE) return Z_STREAM_ERROR;
270
271 strm->adler = zlib_adler32(strm->adler, dictionary, dictLength);
272
273 if (length < MIN_MATCH) return Z_OK;
274 if (length > MAX_DIST(s)) {
275 length = MAX_DIST(s);
276#ifndef USE_DICT_HEAD
277 dictionary += dictLength - length; /* use the tail of the dictionary */
278#endif
279 }
280 memcpy((char *)s->window, dictionary, length);
281 s->strstart = length;
282 s->block_start = (long)length;
283
284 /* Insert all strings in the hash table (except for the last two bytes).
285 * s->lookahead stays null, so s->ins_h will be recomputed at the next
286 * call of fill_window.
287 */
288 s->ins_h = s->window[0];
289 UPDATE_HASH(s, s->ins_h, s->window[1]);
290 for (n = 0; n <= length - MIN_MATCH; n++) {
291 INSERT_STRING(s, n, hash_head);
292 }
293 if (hash_head) hash_head = 0; /* to make compiler happy */
294 return Z_OK;
295}
296#endif /* 0 */
297
298/* ========================================================================= */
299int zlib_deflateReset( 253int zlib_deflateReset(
300 z_streamp strm 254 z_streamp strm
301) 255)
@@ -326,45 +280,6 @@ int zlib_deflateReset(
326 return Z_OK; 280 return Z_OK;
327} 281}
328 282
329/* ========================================================================= */
330#if 0
331int zlib_deflateParams(
332 z_streamp strm,
333 int level,
334 int strategy
335)
336{
337 deflate_state *s;
338 compress_func func;
339 int err = Z_OK;
340
341 if (strm == NULL || strm->state == NULL) return Z_STREAM_ERROR;
342 s = (deflate_state *) strm->state;
343
344 if (level == Z_DEFAULT_COMPRESSION) {
345 level = 6;
346 }
347 if (level < 0 || level > 9 || strategy < 0 || strategy > Z_HUFFMAN_ONLY) {
348 return Z_STREAM_ERROR;
349 }
350 func = configuration_table[s->level].func;
351
352 if (func != configuration_table[level].func && strm->total_in != 0) {
353 /* Flush the last buffer: */
354 err = zlib_deflate(strm, Z_PARTIAL_FLUSH);
355 }
356 if (s->level != level) {
357 s->level = level;
358 s->max_lazy_match = configuration_table[level].max_lazy;
359 s->good_match = configuration_table[level].good_length;
360 s->nice_match = configuration_table[level].nice_length;
361 s->max_chain_length = configuration_table[level].max_chain;
362 }
363 s->strategy = strategy;
364 return err;
365}
366#endif /* 0 */
367
368/* ========================================================================= 283/* =========================================================================
369 * Put a short in the pending buffer. The 16-bit value is put in MSB order. 284 * Put a short in the pending buffer. The 16-bit value is put in MSB order.
370 * IN assertion: the stream state is correct and there is enough room in 285 * IN assertion: the stream state is correct and there is enough room in
@@ -568,64 +483,6 @@ int zlib_deflateEnd(
568 return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK; 483 return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK;
569} 484}
570 485
571/* =========================================================================
572 * Copy the source state to the destination state.
573 */
574#if 0
575int zlib_deflateCopy (
576 z_streamp dest,
577 z_streamp source
578)
579{
580#ifdef MAXSEG_64K
581 return Z_STREAM_ERROR;
582#else
583 deflate_state *ds;
584 deflate_state *ss;
585 ush *overlay;
586 deflate_workspace *mem;
587
588
589 if (source == NULL || dest == NULL || source->state == NULL) {
590 return Z_STREAM_ERROR;
591 }
592
593 ss = (deflate_state *) source->state;
594
595 *dest = *source;
596
597 mem = (deflate_workspace *) dest->workspace;
598
599 ds = &(mem->deflate_memory);
600
601 dest->state = (struct internal_state *) ds;
602 *ds = *ss;
603 ds->strm = dest;
604
605 ds->window = (Byte *) mem->window_memory;
606 ds->prev = (Pos *) mem->prev_memory;
607 ds->head = (Pos *) mem->head_memory;
608 overlay = (ush *) mem->overlay_memory;
609 ds->pending_buf = (uch *) overlay;
610
611 memcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte));
612 memcpy(ds->prev, ss->prev, ds->w_size * sizeof(Pos));
613 memcpy(ds->head, ss->head, ds->hash_size * sizeof(Pos));
614 memcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size);
615
616 ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf);
617 ds->d_buf = overlay + ds->lit_bufsize/sizeof(ush);
618 ds->l_buf = ds->pending_buf + (1+sizeof(ush))*ds->lit_bufsize;
619
620 ds->l_desc.dyn_tree = ds->dyn_ltree;
621 ds->d_desc.dyn_tree = ds->dyn_dtree;
622 ds->bl_desc.dyn_tree = ds->bl_tree;
623
624 return Z_OK;
625#endif
626}
627#endif /* 0 */
628
629/* =========================================================================== 486/* ===========================================================================
630 * Read a new buffer from the current input stream, update the adler32 487 * Read a new buffer from the current input stream, update the adler32
631 * and total number of bytes read. All deflate() input goes through 488 * and total number of bytes read. All deflate() input goes through
diff --git a/lib/zlib_inflate/inflate.c b/lib/zlib_inflate/inflate.c
index f5ce87b0800e..58a733b10387 100644
--- a/lib/zlib_inflate/inflate.c
+++ b/lib/zlib_inflate/inflate.c
@@ -45,21 +45,6 @@ int zlib_inflateReset(z_streamp strm)
45 return Z_OK; 45 return Z_OK;
46} 46}
47 47
48#if 0
49int zlib_inflatePrime(z_streamp strm, int bits, int value)
50{
51 struct inflate_state *state;
52
53 if (strm == NULL || strm->state == NULL) return Z_STREAM_ERROR;
54 state = (struct inflate_state *)strm->state;
55 if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR;
56 value &= (1L << bits) - 1;
57 state->hold += value << state->bits;
58 state->bits += bits;
59 return Z_OK;
60}
61#endif
62
63int zlib_inflateInit2(z_streamp strm, int windowBits) 48int zlib_inflateInit2(z_streamp strm, int windowBits)
64{ 49{
65 struct inflate_state *state; 50 struct inflate_state *state;
@@ -761,123 +746,6 @@ int zlib_inflateEnd(z_streamp strm)
761 return Z_OK; 746 return Z_OK;
762} 747}
763 748
764#if 0
765int zlib_inflateSetDictionary(z_streamp strm, const Byte *dictionary,
766 uInt dictLength)
767{
768 struct inflate_state *state;
769 unsigned long id;
770
771 /* check state */
772 if (strm == NULL || strm->state == NULL) return Z_STREAM_ERROR;
773 state = (struct inflate_state *)strm->state;
774 if (state->wrap != 0 && state->mode != DICT)
775 return Z_STREAM_ERROR;
776
777 /* check for correct dictionary id */
778 if (state->mode == DICT) {
779 id = zlib_adler32(0L, NULL, 0);
780 id = zlib_adler32(id, dictionary, dictLength);
781 if (id != state->check)
782 return Z_DATA_ERROR;
783 }
784
785 /* copy dictionary to window */
786 zlib_updatewindow(strm, strm->avail_out);
787
788 if (dictLength > state->wsize) {
789 memcpy(state->window, dictionary + dictLength - state->wsize,
790 state->wsize);
791 state->whave = state->wsize;
792 }
793 else {
794 memcpy(state->window + state->wsize - dictLength, dictionary,
795 dictLength);
796 state->whave = dictLength;
797 }
798 state->havedict = 1;
799 return Z_OK;
800}
801#endif
802
803#if 0
804/*
805 Search buf[0..len-1] for the pattern: 0, 0, 0xff, 0xff. Return when found
806 or when out of input. When called, *have is the number of pattern bytes
807 found in order so far, in 0..3. On return *have is updated to the new
808 state. If on return *have equals four, then the pattern was found and the
809 return value is how many bytes were read including the last byte of the
810 pattern. If *have is less than four, then the pattern has not been found
811 yet and the return value is len. In the latter case, zlib_syncsearch() can be
812 called again with more data and the *have state. *have is initialized to
813 zero for the first call.
814 */
815static unsigned zlib_syncsearch(unsigned *have, unsigned char *buf,
816 unsigned len)
817{
818 unsigned got;
819 unsigned next;
820
821 got = *have;
822 next = 0;
823 while (next < len && got < 4) {
824 if ((int)(buf[next]) == (got < 2 ? 0 : 0xff))
825 got++;
826 else if (buf[next])
827 got = 0;
828 else
829 got = 4 - got;
830 next++;
831 }
832 *have = got;
833 return next;
834}
835#endif
836
837#if 0
838int zlib_inflateSync(z_streamp strm)
839{
840 unsigned len; /* number of bytes to look at or looked at */
841 unsigned long in, out; /* temporary to save total_in and total_out */
842 unsigned char buf[4]; /* to restore bit buffer to byte string */
843 struct inflate_state *state;
844
845 /* check parameters */
846 if (strm == NULL || strm->state == NULL) return Z_STREAM_ERROR;
847 state = (struct inflate_state *)strm->state;
848 if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR;
849
850 /* if first time, start search in bit buffer */
851 if (state->mode != SYNC) {
852 state->mode = SYNC;
853 state->hold <<= state->bits & 7;
854 state->bits -= state->bits & 7;
855 len = 0;
856 while (state->bits >= 8) {
857 buf[len++] = (unsigned char)(state->hold);
858 state->hold >>= 8;
859 state->bits -= 8;
860 }
861 state->have = 0;
862 zlib_syncsearch(&(state->have), buf, len);
863 }
864
865 /* search available input */
866 len = zlib_syncsearch(&(state->have), strm->next_in, strm->avail_in);
867 strm->avail_in -= len;
868 strm->next_in += len;
869 strm->total_in += len;
870
871 /* return no joy or set up to restart inflate() on a new block */
872 if (state->have != 4) return Z_DATA_ERROR;
873 in = strm->total_in; out = strm->total_out;
874 zlib_inflateReset(strm);
875 strm->total_in = in; strm->total_out = out;
876 state->mode = TYPE;
877 return Z_OK;
878}
879#endif
880
881/* 749/*
882 * This subroutine adds the data at next_in/avail_in to the output history 750 * This subroutine adds the data at next_in/avail_in to the output history
883 * without performing any output. The output buffer must be "caught up"; 751 * without performing any output. The output buffer must be "caught up";