import PULS_20160108

This commit is contained in:
Stricted
2018-03-13 20:29:02 +01:00
parent a8d97b1bd0
commit 6fa3eb70c0
6257 changed files with 2910927 additions and 5489 deletions
+4
View File
@@ -189,6 +189,10 @@ config LZO_COMPRESS
config LZO_DECOMPRESS
tristate
config LZ4K
bool "LZ4K compression"
default n
source "lib/xz/Kconfig"
#
+15 -2
View File
@@ -191,15 +191,27 @@ config LOCKUP_DETECTOR
The overhead should be minimal. A periodic hrtimer runs to
generate interrupts and kick the watchdog task every 4 seconds.
An NMI is generated every 10 seconds or so to check for hardlockups.
If NMIs are not available on the platform, every 12 seconds the
hrtimer interrupt on one cpu will be used to check for hardlockups
on the next cpu.
The frequency of hrtimer and NMI events and the soft and hard lockup
thresholds can be controlled through the sysctl watchdog_thresh.
config HARDLOCKUP_DETECTOR
config HARDLOCKUP_DETECTOR_NMI
def_bool y
depends on LOCKUP_DETECTOR && !HAVE_NMI_WATCHDOG
depends on PERF_EVENTS && HAVE_PERF_EVENTS_NMI
config HARDLOCKUP_DETECTOR_OTHER_CPU
def_bool y
depends on LOCKUP_DETECTOR && SMP
depends on !HARDLOCKUP_DETECTOR_NMI && !HAVE_NMI_WATCHDOG
config HARDLOCKUP_DETECTOR
def_bool y
depends on HARDLOCKUP_DETECTOR_NMI || HARDLOCKUP_DETECTOR_OTHER_CPU
config BOOTPARAM_HARDLOCKUP_PANIC
bool "Panic (Reboot) On Hard Lockups"
depends on HARDLOCKUP_DETECTOR
@@ -669,8 +681,9 @@ config DEBUG_LOCKING_API_SELFTESTS
mutexes and rwsems.
config STACKTRACE
bool
bool "Stacktrace"
depends on STACKTRACE_SUPPORT
default y
config DEBUG_STACK_USAGE
bool "Stack utilization instrumentation"
+3
View File
@@ -180,3 +180,6 @@ quiet_cmd_build_OID_registry = GEN $@
clean-files += oid_registry_data.c
obj-$(CONFIG_UCS2_STRING) += ucs2_string.o
obj-$(CONFIG_LZ4K) += lz4k/
+10 -5
View File
@@ -8,6 +8,7 @@
* By Greg Banks <gnb@melbourne.sgi.com>
* Copyright (c) 2008 Silicon Graphics Inc. All Rights Reserved.
* Copyright (C) 2011 Bart Van Assche. All Rights Reserved.
* Copyright (C) 2013 Du, Changbin <changbin.du@gmail.com>
*/
#define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__
@@ -24,6 +25,7 @@
#include <linux/sysctl.h>
#include <linux/ctype.h>
#include <linux/string.h>
#include <linux/parser.h>
#include <linux/string_helpers.h>
#include <linux/uaccess.h>
#include <linux/dynamic_debug.h>
@@ -147,7 +149,8 @@ static int ddebug_change(const struct ddebug_query *query,
list_for_each_entry(dt, &ddebug_tables, link) {
/* match against the module name */
if (query->module && strcmp(query->module, dt->mod_name))
if (query->module &&
!match_wildcard(query->module, dt->mod_name))
continue;
for (i = 0; i < dt->num_ddebugs; i++) {
@@ -155,14 +158,16 @@ static int ddebug_change(const struct ddebug_query *query,
/* match against the source filename */
if (query->filename &&
strcmp(query->filename, dp->filename) &&
strcmp(query->filename, kbasename(dp->filename)) &&
strcmp(query->filename, trim_prefix(dp->filename)))
!match_wildcard(query->filename, dp->filename) &&
!match_wildcard(query->filename,
kbasename(dp->filename)) &&
!match_wildcard(query->filename,
trim_prefix(dp->filename)))
continue;
/* match against the function */
if (query->function &&
strcmp(query->function, dp->function))
!match_wildcard(query->function, dp->function))
continue;
/* match against the format */
+2
View File
@@ -0,0 +1,2 @@
lz4k-objs := lz4k_compress.o lz4k_decompress.o lz4k_init.o
obj-y += lz4k.o
+305
View File
@@ -0,0 +1,305 @@
/*
* LZ4K Compressor by Vovo
*/
#include <linux/lz4k.h>
#include <linux/types.h>
#include <linux/string.h>
unsigned short lz4k_matchlen_encode[32] =
{ 0, 0, 0, 1024, 1026, 2049, 2053, 2057, 2061, 3091, 3123, 3083, 2563, 3643, 3707, 3115, 3099,
4119, 3591, 4247, 3655, 4791, 4183, 4311, 3623, 5047, 4727, 4983, 3687, 4855, 5111, 4151, };
unsigned short lz4k_matchoff_encode[32] =
{ 1024, 1032, 1292, 1028, 1554, 1308, 1586, 1546, 1578, 1562, 1830, 1594, 1894, 1282, 1814,
1542, 2158, 1878, 2286, 1846, 2078, 1910, 2206, 1806, 2142, 2270, 2110, 1870, 2238, 1838, 2174, 2302, };
unsigned short lz4k_literallen_encode[18] =
{ 0, 128, 385, 517, 525, 515, 651, 775, 807, 667, 919, 983, 951, 1015, 911, 975, 943, 1007, };
unsigned short lz4k_literalch_encode[256] =
{ 2048, 3092, 3596, 3660, 3628, 4154, 4282, 4218, 3692, 3612, 3676, 4346, 4102, 4230, 4166,
4294, 3644, 4134, 4262, 4198, 4326, 4861, 5117, 4611, 4118, 4867, 4246, 4182, 4310, 4150, 4278, 4214, 3124, 4342, 4110, 4238,
4174, 4302, 4739, 4995, 3708, 4142, 4675, 4931, 4270, 4803, 4206, 4334, 3586, 4126, 4254, 4190, 4318, 5059, 4643, 4899, 4158,
4771, 5027, 4707, 4963, 4835, 5091, 4627, 2564, 3650, 4286, 4222, 4350, 4883, 4755, 5011, 4097, 4691, 4947, 4225, 4161, 4289,
4129, 4257, 3618, 3682, 4193, 4321, 4113, 4819, 5075, 4659, 4241, 4915, 4787, 5043, 4723, 4979, 4851, 4177, 4305, 3602, 4145,
4273, 4209, 3666, 4337, 4105, 4233, 3634, 5107, 4619, 4169, 4297, 3698, 3594, 3658, 4137, 3626, 4265, 3690, 4201, 4329, 4875,
4121, 4249, 4747, 5003, 4683, 4939, 4811, 5067, 3610, 4651, 4907, 4779, 4185, 5035, 4715, 4971, 4313, 4843, 5099, 4635, 4891,
4763, 5019, 4699, 4153, 4955, 4827, 5083, 4667, 4923, 4795, 5051, 4281, 4731, 4987, 4859, 5115, 4615, 4871, 4743, 4217, 4999,
4679, 4935, 4807, 5063, 4647, 4903, 4345, 4775, 5031, 4711, 4967, 4839, 5095, 4631, 4101, 4887, 4759, 5015, 4229, 4695, 4951,
4823, 4165, 5079, 4663, 4919, 4293, 4791, 5047, 4727, 4133, 4983, 4855, 5111, 4623, 4879, 4751, 5007, 4261, 4687, 4943, 4815,
5071, 4655, 4911, 4783, 4197, 4325, 4117, 4245, 4181, 4309, 5039, 4719, 4149, 4975, 4847, 5103, 4639, 4895, 4767, 5023, 3674,
4277, 4703, 4213, 4959, 4341, 4831, 5087, 4109, 4671, 4927, 4799, 4237, 4173, 4301, 5055, 4141, 4269, 4205, 4333, 4125, 4253,
4735, 4189, 4317, 4157, 4285, 4991, 4221, 4863, 5119, 2056, };
#define RESERVE_16_BITS() \
if (bitstobeoutput >= 16) { \
*((unsigned short *)op) = (unsigned short) (bits_buffer32 & 0xffff); \
op += 2; \
bits_buffer32 = bits_buffer32 >> 16; \
bitstobeoutput -= 16; \
}
#define STORE_BITS(bits, code) \
bits_buffer32 |= (code) << bitstobeoutput; \
bitstobeoutput += (bits);
static size_t
_lz4k_do_compress(const unsigned char *in, size_t in_len,
unsigned char *out, size_t *out_len, void *wrkmem)
{
const unsigned char *ip = in;
unsigned char *op = out;
const unsigned char *const in_end = in + in_len;
const unsigned char *const ip_end = in + in_len - 3;
const unsigned char *ii = ip;
const unsigned char **const dict = wrkmem;
unsigned int bitstobeoutput = 0;
unsigned int bits_buffer32 = 0;
bitstobeoutput = 1;
for (;;) {
const unsigned char *m_pos;
{
size_t dindex;
unsigned int ip_content = *(unsigned int *)ip;
unsigned int hash_temp = ip_content ^ (ip_content >> 12);
dindex = hash_temp & 0xfff;
m_pos = dict[dindex];
dict[dindex] = ip;
if (m_pos < in || m_pos >= ip
|| ((*(unsigned int *)m_pos << 8) != (ip_content << 8))) {
++ip;
dindex = (hash_temp >> 8) & 0xfff;
m_pos = dict[dindex];
dict[dindex] = ip;
if (m_pos < in || m_pos >= ip
|| ((*(unsigned int *)m_pos << 8) !=
(ip_content & 0xffffff00))) {
++ip;
if (__builtin_expect(!!(ip >= ip_end), 0))
break;
continue;
}
}
}
{
size_t lit = ip - ii;
if (lit > 0) {
if (lit == 1) {
int value, bits, code;
RESERVE_16_BITS();
value = lz4k_literalch_encode[*ii++];
bits = value >> 9;
code = (value & 0x1ff) << 2;
STORE_BITS(bits + 2, code);
} else if (lit == 2) {
int value, bits, code;
int value2, bits2, code2;
RESERVE_16_BITS();
if (bitstobeoutput > (32 - 22)) {
*op++ = (unsigned char)(bits_buffer32 & 0xff);
bits_buffer32 = bits_buffer32 >> 8;
bitstobeoutput -= 8;
}
value = lz4k_literalch_encode[*ii++];
bits = value >> 9;
code = value & 0x1ff;
value2 = lz4k_literalch_encode[*ii++];
bits2 = value2 >> 9;
code2 = value2 & 0x1ff;
bits_buffer32 |=
((((code2 << bits) | code) << 4) | 2) << bitstobeoutput;
bitstobeoutput += bits2 + bits + 4;
} else {
if (lit <= 17) {
int value, bits, code;
RESERVE_16_BITS();
value = lz4k_literallen_encode[lit];
bits = value >> 7;
code = (value & 0x7f) << 1;
STORE_BITS(bits + 1, code);
} else {
int code = ((lit - 1) << 6) | 0x3e;
RESERVE_16_BITS();
if (bitstobeoutput > (32 - 18)) {
*op++ =
(unsigned char)(bits_buffer32 & 0xff);
bits_buffer32 = bits_buffer32 >> 8;
bitstobeoutput -= 8;
}
STORE_BITS(17 + 1, code);
}
while (1) {
while (bitstobeoutput < 24) {
int value, bits, code;
value = lz4k_literalch_encode[*ii++];
bits = value >> 9;
code = value & 0x1ff;
STORE_BITS(bits, code);
if (__builtin_expect(!!(ii == ip), 0)) {
goto break_literal_1;
}
}
*((unsigned int *)op) = bits_buffer32;
op += 3;
bits_buffer32 = bits_buffer32 >> 24;
bitstobeoutput -= 24;
}
}
} else {
if (bitstobeoutput == 32) {
*((unsigned int *)op) = bits_buffer32;
op += 4;
bits_buffer32 = 1;
bitstobeoutput = 1;
} else {
bits_buffer32 |= 1 << bitstobeoutput;
bitstobeoutput += 1;
}
}
}
break_literal_1:
m_pos += 3;
ip += 3;
if (__builtin_expect(!!(ip < in_end), 1) && *m_pos == *ip) {
m_pos++, ip++;
while (__builtin_expect(!!(ip < (in_end - 1)), 1)
&& *(unsigned short *)m_pos == *(unsigned short *)ip)
m_pos += 2, ip += 2;
if (__builtin_expect(!!(ip < in_end), 1) && *m_pos == *ip)
m_pos += 1, ip += 1;
}
RESERVE_16_BITS();
{
size_t m_off = ip - m_pos;
if ((m_off & 3) == 0 && m_off <= 128) {
int value = lz4k_matchoff_encode[(m_off / 4) - 1];
int bits = value >> 8;
int code = value & 0xff;
STORE_BITS(bits, code);
} else {
int code = (m_off << 1) | 0x1;
STORE_BITS(13, code);
}
}
RESERVE_16_BITS();
{
size_t m_len = ip - ii;
if (m_len < 32) {
int value = lz4k_matchlen_encode[m_len];
int bits = value >> 9;
int code = value & 0x1ff;
STORE_BITS(bits, code);
} else {
int code = (m_len << 4) | 0xf;
STORE_BITS(16, code);
}
}
ii = ip;
if (__builtin_expect(!!(ip >= ip_end), 0))
break;
}
if ((in_end - ii) > 0) {
size_t t = in_end - ii;
if (t == 1) {
int value, bits, code;
RESERVE_16_BITS();
value = lz4k_literalch_encode[*ii++];
bits = value >> 9;
code = (value & 0x1ff) << 2;
bits_buffer32 |= code << bitstobeoutput;
bitstobeoutput += bits + 2;
} else {
while (bitstobeoutput >= 8) {
*op++ = (unsigned char)(bits_buffer32 & 0xff);
bits_buffer32 = bits_buffer32 >> 8;
bitstobeoutput -= 8;
}
bitstobeoutput += 1;
if (t <= 17) {
int value = lz4k_literallen_encode[t];
int bits = value >> 7;
int code = value & 0x7f;
bits_buffer32 |= code << bitstobeoutput;
bitstobeoutput += bits;
} else {
int code = ((t - 1) << 5) | 0x1f;
bits_buffer32 |= code << bitstobeoutput;
bitstobeoutput += 17;
}
while (1) {
while (bitstobeoutput < 24) {
int value, bits, code;
value = lz4k_literalch_encode[*ii++];
bits = value >> 9;
code = value & 0x1ff;
bits_buffer32 |= code << bitstobeoutput;
bitstobeoutput += bits;
if (__builtin_expect(!!(--t == 0), 0))
goto break_literal_2;
}
*((unsigned int *)op) = bits_buffer32;
op += 3;
bits_buffer32 = bits_buffer32 >> 24;
bitstobeoutput -= 24;
}
}
}
break_literal_2:
while (bitstobeoutput >= 8) {
*op++ = (unsigned char)(bits_buffer32 & 0xff);
bits_buffer32 = bits_buffer32 >> 8;
bitstobeoutput -= 8;
}
if (bitstobeoutput != 0) {
*op++ = (unsigned char)(bits_buffer32 & 0xff);
}
*((unsigned int *)op) = LZ4K_TAG;
op += 4;
*out_len = op - out;
return 0;
}
int lz4k_compress(const unsigned char *in, size_t in_len, unsigned char *out,
size_t *out_len, void *wrkmem)
{
unsigned char *op = out;
if (in_len > 4096) {
return -1;
}
if (__builtin_expect(!!(in_len == 0), 0)) {
*out_len = 0;
return -1;
} else {
memset(wrkmem, 0, LZ4K_MEM_COMPRESS);
_lz4k_do_compress(in, in_len, op, out_len, wrkmem);
}
if (*out_len <= 0) {
return -1;
}
return 0;
}
+519
View File
@@ -0,0 +1,519 @@
/*
* LZ4K Decompressor by Vovo
*/
#include <linux/lz4k.h>
#include <linux/types.h>
//#define CONFIG_UBIFS_FS
static unsigned short lz4k_matchlen_decode[128] =
{ 780, 1298, 1035, 0, 1033, 1553, 1040, 0, 780, 1304, 1039, 0, 1034, 1567, 1293, 0, 780, 1300,
1035, 0, 1033, 1558, 1040, 0, 780, 1308, 1039, 0, 1034, 1818, 1294, 0, 780, 1298, 1035, 0, 1033, 1555, 1040, 0, 780, 1304, 1039, 0,
1034, 1813, 1293, 0, 780, 1300, 1035, 0, 1033, 1559, 1040, 0, 780, 1308, 1039, 0, 1034, 1821, 1294, 0,
780, 1298, 1035, 0, 1033, 1553, 1040, 0, 780, 1304, 1039, 0, 1034, 1567, 1293, 0, 780, 1300,
1035, 0, 1033, 1558, 1040, 0, 780, 1308, 1039, 0, 1034, 1819, 1294, 0, 780, 1298, 1035,
0, 1033, 1555, 1040, 0, 780, 1304, 1039, 0, 1034, 1817, 1293, 0, 780, 1300, 1035, 0,
1033, 1559, 1040, 0, 780, 1308, 1039, 0, 1034, 1822, 1294, 0,
};
#ifdef CONFIG_UBIFS_FS
static unsigned short lz4k_matchlen_decode_hc[256] =
{ 514, 772, 515, 1031, 514, 1029, 515, 1545, 514, 772, 515, 1288, 514, 1030, 515, 2061, 514,
772, 515, 1031, 514, 1029, 515, 1551, 514, 772, 515, 1291, 514, 1030, 515, 0, 514, 772, 515, 1031, 514, 1029, 515, 1548, 514, 772, 515,
1288, 514, 1030, 515, 2067, 514, 772, 515, 1031, 514, 1029, 515, 1802, 514, 772, 515, 1291, 514, 1030, 515, 0,
514, 772, 515, 1031, 514, 1029, 515, 1545, 514, 772, 515, 1288, 514, 1030, 515, 2065, 514,
772, 515, 1031, 514, 1029, 515, 1551, 514, 772, 515, 1291, 514, 1030, 515, 0, 514, 772,
515, 1031, 514, 1029, 515, 1548, 514, 772, 515, 1288, 514, 1030, 515, 2072, 514, 772,
515, 1031, 514, 1029, 515, 1808, 514, 772, 515, 1291, 514, 1030, 515, 0,
514, 772, 515, 1031, 514, 1029, 515, 1545, 514, 772, 515, 1288, 514, 1030, 515, 2062, 514,
772, 515, 1031, 514, 1029, 515, 1551, 514, 772, 515, 1291, 514, 1030, 515, 0, 514, 772,
515, 1031, 514, 1029, 515, 1548, 514, 772, 515, 1288, 514, 1030, 515, 2068, 514, 772,
515, 1031, 514, 1029, 515, 1802, 514, 772, 515, 1291, 514, 1030, 515, 0,
514, 772, 515, 1031, 514, 1029, 515, 1545, 514, 772, 515, 1288, 514, 1030, 515, 2066, 514,
772, 515, 1031, 514, 1029, 515, 1551, 514, 772, 515, 1291, 514, 1030, 515, 0, 514, 772,
515, 1031, 514, 1029, 515, 1548, 514, 772, 515, 1288, 514, 1030, 515, 2076, 514, 772,
515, 1031, 514, 1029, 515, 1808, 514, 772, 515, 1291, 514, 1030, 515, 0,
};
#endif /* CONFIG_UBIFS_FS */
static unsigned short lz4k_matchoff_decode[128] =
{ 1028, 1336, 1040, 1600, 1032, 1568, 1292, 1888, 1028, 1556, 1040, 1852, 1032, 1576, 1304,
2132, 1028, 1336, 1040, 1836, 1032, 1572, 1292, 1912, 1028, 1564, 1040, 1872, 1032, 1584, 1304, 2156, 1028, 1336, 1040, 1600, 1032,
1568, 1292, 1904, 1028, 1556, 1040, 1864, 1032, 1576, 1304, 2148, 1028, 1336, 1040, 1844, 1032, 1572, 1292, 2116, 1028, 1564, 1040,
1880, 1032, 1584, 1304, 2172,
1028, 1336, 1040, 1600, 1032, 1568, 1292, 1888, 1028, 1556, 1040, 1852, 1032, 1576, 1304,
2140, 1028, 1336, 1040, 1836, 1032, 1572, 1292, 1912, 1028, 1564, 1040, 1872, 1032,
1584, 1304, 2164, 1028, 1336, 1040, 1600, 1032, 1568, 1292, 1904, 1028, 1556, 1040,
1864, 1032, 1576, 1304, 2152, 1028, 1336, 1040, 1844, 1032, 1572, 1292, 2124, 1028,
1564, 1040, 1880, 1032, 1584, 1304, 2176,
};
#ifdef CONFIG_UBIFS_FS
static unsigned short lz4k_matchoff_decode_hc[128] =
{ 768, 1560, 1284, 1814, 768, 1836, 1296, 1876, 768, 1820, 1288, 1860, 768, 1856, 1548, 2160,
768, 1793, 1284, 1822, 768, 1848, 1296, 2144, 768, 1828, 1288, 1868, 768, 1806, 1556, 2176, 768, 1560, 1284, 1818, 768, 1840, 1296, 2136,
768, 1824, 1288, 1864, 768, 1802, 1548, 2168, 768, 1798, 1284, 1844, 768, 1852, 1296, 2152, 768, 1832, 1288, 1872, 768, 1810, 1556, 2082,
768, 1560, 1284, 1814, 768, 1836, 1296, 1876, 768, 1820, 1288, 1860, 768, 1856, 1548, 2164,
768, 1793, 1284, 1822, 768, 1848, 1296, 2148, 768, 1828, 1288, 1868, 768, 1806, 1556,
2050, 768, 1560, 1284, 1818, 768, 1840, 1296, 2140, 768, 1824, 1288, 1864, 768, 1802,
1548, 2172, 768, 1798, 1284, 1844, 768, 1852, 1296, 2156, 768, 1832, 1288, 1872, 768,
1810, 1556, 2180,
};
#endif /* CONFIG_UBIFS_FS */
static unsigned short lz4k_literallen_decode[128] =
{ 257, 770, 257, 1029, 257, 1027, 257, 1543, 257, 770, 257, 1286, 257, 1028, 257, 1806, 257,
770, 257, 1029, 257, 1027, 257, 1802, 257, 770, 257, 1289, 257, 1028, 257, 0, 257, 770, 257, 1029, 257, 1027, 257, 1544, 257, 770, 257,
1286, 257, 1028, 257, 1808, 257, 770, 257, 1029, 257, 1027, 257, 1804, 257, 770, 257, 1289, 257, 1028, 257, 0,
257, 770, 257, 1029, 257, 1027, 257, 1543, 257, 770, 257, 1286, 257, 1028, 257, 1807, 257,
770, 257, 1029, 257, 1027, 257, 1803, 257, 770, 257, 1289, 257, 1028, 257, 0, 257, 770,
257, 1029, 257, 1027, 257, 1544, 257, 770, 257, 1286, 257, 1028, 257, 1809, 257, 770,
257, 1029, 257, 1027, 257, 1805, 257, 770, 257, 1289, 257, 1028, 257, 0,
};
static unsigned short lz4k_literalch_decode[512] =
{ 1024, 2120, 1840, 2327, 1344, 2224, 2060, 2461, 1279, 2151, 1903, 2411, 1794, 2280, 2082,
2500, 1024, 2132, 1889, 2367, 1537, 2258, 2072, 2479, 1279, 2168, 1920, 2443, 1801, 2292, 2097, 2524, 1024, 2126, 1872, 2358, 1344,
2240, 2065, 2470, 1279, 2161, 1906, 2433, 1796, 2288, 2089, 2509, 1024, 2146, 1897, 2391, 1568, 2264, 2077, 2490, 1279, 2192, 2053,
2452, 1808, 2297, 2104, 2537,
1024, 2124, 1857, 2346, 1344, 2232, 2062, 2466, 1279, 2156, 1904, 2428, 1795, 2285, 2084,
2505, 1024, 2143, 1893, 2377, 1537, 2260, 2075, 2485, 1279, 2180, 2016, 2447, 1802,
2295, 2099, 2530, 1024, 2130, 1873, 2363, 1344, 2256, 2067, 2475, 1279, 2165, 1908,
2438, 1800, 2290, 2094, 2519, 1024, 2148, 1902, 2396, 1568, 2275, 2079, 2495, 1279,
2208, 2055, 2457, 1832, 2300, 2115, 2550,
1024, 2123, 1840, 2342, 1344, 2228, 2061, 2463, 1279, 2152, 1903, 2426, 1794, 2284, 2083,
2502, 1024, 2136, 1889, 2374, 1537, 2259, 2074, 2482, 1279, 2169, 1920, 2445, 1801,
2293, 2098, 2526, 1024, 2127, 1872, 2361, 1344, 2248, 2066, 2473, 1279, 2163, 1906,
2435, 1796, 2289, 2092, 2511, 1024, 2147, 1897, 2394, 1568, 2273, 2078, 2493, 1279,
2200, 2054, 2454, 1808, 2298, 2114, 2539,
1024, 2125, 1857, 2349, 1344, 2236, 2063, 2468, 1279, 2157, 1904, 2430, 1795, 2286, 2085,
2507, 1024, 2144, 1893, 2389, 1537, 2261, 2076, 2487, 1279, 2184, 2016, 2450, 1802,
2296, 2100, 2534, 1024, 2131, 1873, 2365, 1344, 2257, 2068, 2477, 1279, 2166, 1908,
2441, 1800, 2291, 2095, 2522, 1024, 2150, 1902, 2398, 1568, 2277, 2081, 2498, 1279,
2216, 2059, 2459, 1832, 2325, 2116, 2557,
1024, 2120, 1840, 2329, 1344, 2224, 2060, 2462, 1279, 2151, 1903, 2423, 1794, 2280, 2082,
2501, 1024, 2132, 1889, 2373, 1537, 2258, 2072, 2481, 1279, 2168, 1920, 2444, 1801,
2292, 2097, 2525, 1024, 2126, 1872, 2359, 1344, 2240, 2065, 2471, 1279, 2161, 1906,
2434, 1796, 2288, 2089, 2510, 1024, 2146, 1897, 2393, 1568, 2264, 2077, 2491, 1279,
2192, 2053, 2453, 1808, 2297, 2104, 2538,
1024, 2124, 1857, 2347, 1344, 2232, 2062, 2467, 1279, 2156, 1904, 2429, 1795, 2285, 2084,
2506, 1024, 2143, 1893, 2378, 1537, 2260, 2075, 2486, 1279, 2180, 2016, 2449, 1802,
2295, 2099, 2532, 1024, 2130, 1873, 2364, 1344, 2256, 2067, 2476, 1279, 2165, 1908,
2439, 1800, 2290, 2094, 2521, 1024, 2148, 1902, 2397, 1568, 2275, 2079, 2497, 1279,
2208, 2055, 2458, 1832, 2300, 2115, 2555,
1024, 2123, 1840, 2343, 1344, 2228, 2061, 2465, 1279, 2152, 1903, 2427, 1794, 2284, 2083,
2503, 1024, 2136, 1889, 2375, 1537, 2259, 2074, 2483, 1279, 2169, 1920, 2446, 1801,
2293, 2098, 2527, 1024, 2127, 1872, 2362, 1344, 2248, 2066, 2474, 1279, 2163, 1906,
2437, 1796, 2289, 2092, 2518, 1024, 2147, 1897, 2395, 1568, 2273, 2078, 2494, 1279,
2200, 2054, 2455, 1808, 2298, 2114, 2543,
1024, 2125, 1857, 2357, 1344, 2236, 2063, 2469, 1279, 2157, 1904, 2431, 1795, 2286, 2085,
2508, 1024, 2144, 1893, 2390, 1537, 2261, 2076, 2489, 1279, 2184, 2016, 2451, 1802,
2296, 2100, 2535, 1024, 2131, 1873, 2366, 1344, 2257, 2068, 2478, 1279, 2166, 1908,
2442, 1800, 2291, 2095, 2523, 1024, 2150, 1902, 2410, 1568, 2277, 2081, 2499, 1279,
2216, 2059, 2460, 1832, 2326, 2116, 2558,
};
#define RESERVE_16_BITS() \
if (remaining_bits <= 16) { \
bits_buffer32 = bits_buffer32 | (*((unsigned short *)ip)) << remaining_bits; \
ip += 2; \
remaining_bits += 16; \
}
static int lz4k_decompress_simple(const unsigned char *in, size_t in_len, unsigned char *out,
unsigned char *const op_end)
{
unsigned char *op = out;
const unsigned char *ip = in;
unsigned int bits_buffer32 = 0;
unsigned int remaining_bits = 32;
bits_buffer32 = *((unsigned int *)ip);
ip += 4;
bits_buffer32 = bits_buffer32 >> 1;
remaining_bits -= 1;
/* check lz4k tag */
if (*((unsigned int *)(in + in_len - 4)) != LZ4K_TAG) {
return -1;
}
while (1) {
RESERVE_16_BITS();
if ((bits_buffer32 & 1) == 0) {
if ((bits_buffer32 & 2) == 0) {
unsigned short value;
int bits;
value = lz4k_literalch_decode[(bits_buffer32 >> 2) & 0x1ff];
bits = value >> 8;
*op++ = value & 0xff;
bits_buffer32 = bits_buffer32 >> (bits + 2);
remaining_bits -= bits + 2;
} else {
int litlen;
unsigned short value;
value = lz4k_literallen_decode[(bits_buffer32 >> 1) & 0x7f];
if (value != 0) {
int bits = value >> 8;
litlen = value & 0xff;
bits_buffer32 = bits_buffer32 >> (bits + 1);
remaining_bits -= bits + 1;
} else {
if (remaining_bits < 18) {
bits_buffer32 =
bits_buffer32 | ((*ip) << remaining_bits);
ip += 1;
remaining_bits += 8;
}
litlen = ((bits_buffer32 >> 6) & 0xfff) + 1;
bits_buffer32 = bits_buffer32 >> 18;
remaining_bits -= 18;
}
while (1) {
while (remaining_bits > 8) {
unsigned short value;
int bits;
value =
lz4k_literalch_decode[bits_buffer32 & 0x1ff];
bits = value >> 8;
*op++ = value & 0xff;
bits_buffer32 = bits_buffer32 >> bits;
remaining_bits -= bits;
if (--litlen == 0) {
goto break_literal;
}
}
bits_buffer32 =
bits_buffer32 | (*((unsigned int *)ip)) <<
remaining_bits;
ip += 3;
remaining_bits += 24;
}
}
break_literal:
if (__builtin_expect(!!(op == op_end), 0))
break;
} else {
bits_buffer32 = bits_buffer32 >> 1;
remaining_bits -= 1;
}
{
int offset;
int len;
RESERVE_16_BITS();
if ((bits_buffer32 & 1) == 0) {
unsigned short value =
lz4k_matchoff_decode[(bits_buffer32 & 0xff) >> 1];
int bits = value >> 8;
offset = value & 0xff;
bits_buffer32 = bits_buffer32 >> bits;
remaining_bits -= bits;
} else {
offset = (bits_buffer32 >> 1) & 0xfff;
bits_buffer32 = bits_buffer32 >> 13;
remaining_bits -= 13;
}
RESERVE_16_BITS();
if ((bits_buffer32 & 1) == 0) {
len = 3 + ((bits_buffer32 >> 1) & 1);
bits_buffer32 = bits_buffer32 >> 2;
remaining_bits -= 2;
} else if ((bits_buffer32 & 2) == 0) {
len = 5 + ((bits_buffer32 >> 2) & 3);
bits_buffer32 = bits_buffer32 >> 4;
remaining_bits -= 4;
} else {
unsigned short value =
lz4k_matchlen_decode[(bits_buffer32 >> 2) & 0x7f];
if (value != 0) {
int bits = value >> 8;
len = value & 0xff;
bits_buffer32 = bits_buffer32 >> (bits + 2);
remaining_bits -= (bits + 2);
} else {
len = (bits_buffer32 >> 4) & 0xfff;
bits_buffer32 = bits_buffer32 >> 16;
remaining_bits -= 16;
}
}
if (__builtin_expect(!!((offset >> 2) != 0), 1)) {
const unsigned char *m_pos = op - offset;
if ((len & 1) != 0) {
*op++ = *m_pos++;
--len;
}
if ((len & 2) != 0) {
*(unsigned short *)op = *(unsigned short *)m_pos;
op += 2;
m_pos += 2;
len -= 2;
}
while (len > 0) {
*(unsigned int *)op = *(unsigned int *)m_pos;
op += 4;
m_pos += 4;
len -= 4;
}
} else if (__builtin_expect(!!(offset == 1), 1)) {
unsigned int value = *(op - 1);
value = value | (value << 8);
value = value | (value << 16);
if ((len & 1) != 0) {
*op++ = (unsigned char)value;
--len;
}
if ((len & 2) != 0) {
*(unsigned short *)op = (unsigned short)value;
op += 2;
len -= 2;
}
while (len > 0) {
*(unsigned int *)op = (unsigned int)value;
op += 4;
len -= 4;
}
} else {
const unsigned char *m_pos = op - offset;
if ((len & 1) != 0) {
*op++ = *m_pos++;
--len;
}
do {
*((unsigned short *)op) = *((unsigned short *)m_pos);
op += 2;
m_pos += 2;
len -= 2;
} while (len != 0);
}
}
if (__builtin_expect(!!(op == op_end), 0))
break;
}
if (op != op_end) {
return -1;
}
return 0;
}
#ifdef CONFIG_UBIFS_FS
static int lz4k_decompress_hc(const unsigned char *in, size_t in_len, unsigned char *out,
unsigned char *const op_end)
{
unsigned char *op = out;
const unsigned char *ip = in;
unsigned int bits_buffer32 = 0;
unsigned int remaining_bits = 32;
int previous_off;
bits_buffer32 = *((unsigned int *)ip);
ip += 4;
bits_buffer32 = bits_buffer32 >> 1;
remaining_bits -= 1;
while (1) {
RESERVE_16_BITS();
if ((bits_buffer32 & 1) == 0) {
if ((bits_buffer32 & 2) == 0) {
*op++ = (bits_buffer32 >> 2) & 0xff;
bits_buffer32 = bits_buffer32 >> (8 + 2);
remaining_bits -= 8 + 2;
} else {
int litlen;
unsigned short value;
value = lz4k_literallen_decode[(bits_buffer32 >> 1) & 0x7f];
if (value != 0) {
int bits = value >> 8;
litlen = value & 0xff;
bits_buffer32 = bits_buffer32 >> (bits + 1);
remaining_bits -= bits + 1;
} else {
if (remaining_bits < 18) {
bits_buffer32 =
bits_buffer32 | ((*ip) << remaining_bits);
ip += 1;
remaining_bits += 8;
}
litlen = ((bits_buffer32 >> 6) & 0xfff) + 1;
bits_buffer32 = bits_buffer32 >> 18;
remaining_bits -= 18;
}
RESERVE_16_BITS();
if ((litlen & 1) != 0) {
*op++ = bits_buffer32 & 0xff;
bits_buffer32 = bits_buffer32 >> 8;
remaining_bits -= 8;
--litlen;
RESERVE_16_BITS();
}
do {
*(unsigned short *)op = bits_buffer32 & 0xffff;
bits_buffer32 =
(bits_buffer32 >> 16) | (*(unsigned short *)ip) <<
(remaining_bits - 16);
ip += 2;
op += 2;
litlen -= 2;
} while (litlen > 0);
}
break_literal:
if (__builtin_expect(!!(op == op_end), 0))
break;
} else {
bits_buffer32 = bits_buffer32 >> 1;
remaining_bits -= 1;
}
{
int offset;
int len;
RESERVE_16_BITS();
if ((bits_buffer32 & 1) == 0) {
unsigned short value =
lz4k_matchoff_decode_hc[(bits_buffer32 & 0xff) >> 1];
int bits = value >> 8;
int code = value & 0xff;
if (code == 0) { /* previous */
offset = previous_off;
} else {
offset = code;
}
bits_buffer32 = bits_buffer32 >> bits;
remaining_bits -= bits;
} else {
int index = op - out;
int bits = 32 - __builtin_clz(index);
offset = (bits_buffer32 >> 1) & ((1 << bits) - 1);
bits_buffer32 = bits_buffer32 >> bits + 1;
remaining_bits -= bits + 1;
}
previous_off = offset;
RESERVE_16_BITS();
{
if ((bits_buffer32 & 0x1f) != 0x1f) {
unsigned short value =
lz4k_matchlen_decode_hc[(bits_buffer32) & 0xff];
int bits = value >> 8;
len = value & 0xff;
bits_buffer32 = bits_buffer32 >> bits;
remaining_bits -= bits;
} else {
len = (bits_buffer32 >> 5) & 0xfff;
bits_buffer32 = bits_buffer32 >> 17;
remaining_bits -= 17;
}
}
if (__builtin_expect(!!((offset >> 2) != 0), 1)) {
const unsigned char *m_pos = op - offset;
if ((len & 1) != 0) {
*op++ = *m_pos++;
--len;
}
if ((len & 2) != 0) {
*(unsigned short *)op = *(unsigned short *)m_pos;
op += 2;
m_pos += 2;
len -= 2;
}
while (len > 0) {
*(unsigned int *)op = *(unsigned int *)m_pos;
op += 4;
m_pos += 4;
len -= 4;
}
} else if (__builtin_expect(!!(offset == 1), 1)) {
unsigned int value = *(op - 1);
value = value | (value << 8);
value = value | (value << 16);
if ((len & 1) != 0) {
*op++ = (unsigned char)value;
--len;
}
if ((len & 2) != 0) {
*(unsigned short *)op = (unsigned short)value;
op += 2;
len -= 2;
}
while (len > 0) {
*(unsigned int *)op = (unsigned int)value;
op += 4;
len -= 4;
}
} else {
const unsigned char *m_pos = op - offset;
if ((len & 1) != 0) {
*op++ = *m_pos++;
--len;
}
do {
*((unsigned short *)op) = *((unsigned short *)m_pos);
op += 2;
m_pos += 2;
len -= 2;
} while (len != 0);
}
}
if (__builtin_expect(!!(op == op_end), 0))
break;
}
if (op != op_end) {
return -1;
}
return 0;
}
#endif /* CONFIG_UBIFS_FS */
int lz4k_decompress_safe(const unsigned char *in, size_t in_len, unsigned char *out,
size_t *pout_len)
{
int result = 0;
unsigned char *const op_end = out + *pout_len;
if (*pout_len > 4096) {
return -1;
}
if (in_len == 0) {
return -1;
}
result = lz4k_decompress_simple(in, in_len, out, op_end);
return result;
}
#ifdef CONFIG_UBIFS_FS
int lz4k_decompress_ubifs(const unsigned char *in, size_t in_len, unsigned char *out,
size_t *pout_len)
{
int result = 0;
unsigned char *const op_end = out + *pout_len;
if (*pout_len > 4096) {
return -1;
}
if (in_len == 0) {
return -1;
}
if ((*in & 1) == 0) {
result = lz4k_decompress_simple(in, in_len, out, op_end);
} else {
result = lz4k_decompress_hc(in, in_len, out, op_end);
}
return result;
}
#endif /* CONFIG_UBIFS_FS */
+23
View File
@@ -0,0 +1,23 @@
#include <linux/version.h>
#include <linux/module.h>
#include <linux/kernel.h>
int lz4k_compress(const unsigned char *src, size_t src_len,
unsigned char *dst, size_t *dst_len, void *wrkmem);
int lz4k_decompress_safe(const unsigned char *src, size_t src_len,
unsigned char *dst, size_t *dst_len);
/* Set ZRAM hooks */
extern void zram_set_hooks(void *compress_func, void *decompress_func, const char *name);
static int __init lz4k_init(void)
{
zram_set_hooks(&lz4k_compress, &lz4k_decompress_safe, "LZ4K");
return 0;
}
static void __exit lz4k_exit(void)
{
printk(KERN_INFO "Bye LZ4K!\n");
}
module_init(lz4k_init);
module_exit(lz4k_exit);
+300
View File
@@ -212,6 +212,214 @@ m_len_done:
*out_len = op - out;
return in_end - (ii - ti);
}
lzo1x_1_do_compress_zram(const unsigned char *in, size_t in_len,
unsigned char *out, size_t *out_len,
size_t ti, void *wrkmem,int *tmp_hash)
{
const unsigned char *ip;
unsigned char *op;
const unsigned char * const in_end = in + in_len;
const unsigned char * const ip_end = in + in_len - 20;
const unsigned char *ii;
int t_total = 0,old_t = 0;
lzo_dict_t * const dict = (lzo_dict_t *) wrkmem;
op = out;
ip = in;
ii = ip;
ip += ti < 4 ? 4 - ti : 0;
for (;;) {
const unsigned char *m_pos;
size_t t, m_len, m_off;
u32 dv;
literal2:
ip += 1 + ((ip - ii) >> 5);
next2:
if (unlikely(ip >= ip_end))
break;
dv = get_unaligned_le32(ip);
t = ((dv * 0x1824429d) >> (32 - D_BITS));
if(tmp_hash != NULL)
{
*tmp_hash += (int)(t - old_t);
old_t = t;
t_total += t;
}
t = t & D_MASK;
m_pos = in + dict[t];
dict[t] = (lzo_dict_t) (ip - in);
if (unlikely(dv != get_unaligned_le32(m_pos)))
goto literal2;
ii -= ti;
ti = 0;
t = ip - ii;
if (t != 0) {
if (t <= 3) {
op[-2] |= t;
COPY4(op, ii);
op += t;
} else if (t <= 16) {
*op++ = (t - 3);
COPY8(op, ii);
COPY8(op + 8, ii + 8);
op += t;
} else {
if (t <= 18) {
*op++ = (t - 3);
} else {
size_t tt = t - 18;
*op++ = 0;
while (unlikely(tt > 255)) {
tt -= 255;
*op++ = 0;
}
*op++ = tt;
}
do {
COPY8(op, ii);
COPY8(op + 8, ii + 8);
op += 16;
ii += 16;
t -= 16;
} while (t >= 16);
if (t > 0) do {
*op++ = *ii++;
} while (--t > 0);
}
}
m_len = 4;
{
#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && defined(LZO_USE_CTZ64)
u64 v;
v = get_unaligned((const u64 *) (ip + m_len)) ^
get_unaligned((const u64 *) (m_pos + m_len));
if (unlikely(v == 0)) {
do {
m_len += 8;
v = get_unaligned((const u64 *) (ip + m_len)) ^
get_unaligned((const u64 *) (m_pos + m_len));
if (unlikely(ip + m_len >= ip_end))
goto m_len_done2;
} while (v == 0);
}
# if defined(__LITTLE_ENDIAN)
m_len += (unsigned) __builtin_ctzll(v) / 8;
# elif defined(__BIG_ENDIAN)
m_len += (unsigned) __builtin_clzll(v) / 8;
# else
# error "missing endian definition"
# endif
#elif defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && defined(LZO_USE_CTZ32)
u32 v;
v = get_unaligned((const u32 *) (ip + m_len)) ^
get_unaligned((const u32 *) (m_pos + m_len));
if (unlikely(v == 0)) {
do {
m_len += 4;
v = get_unaligned((const u32 *) (ip + m_len)) ^
get_unaligned((const u32 *) (m_pos + m_len));
if (v != 0)
break;
m_len += 4;
v = get_unaligned((const u32 *) (ip + m_len)) ^
get_unaligned((const u32 *) (m_pos + m_len));
if (unlikely(ip + m_len >= ip_end))
goto m_len_done2;
} while (v == 0);
}
# if defined(__LITTLE_ENDIAN)
m_len += (unsigned) __builtin_ctz(v) / 8;
# elif defined(__BIG_ENDIAN)
m_len += (unsigned) __builtin_clz(v) / 8;
# else
# error "missing endian definition"
# endif
#else
if (unlikely(ip[m_len] == m_pos[m_len])) {
do {
m_len += 1;
if (ip[m_len] != m_pos[m_len])
break;
m_len += 1;
if (ip[m_len] != m_pos[m_len])
break;
m_len += 1;
if (ip[m_len] != m_pos[m_len])
break;
m_len += 1;
if (ip[m_len] != m_pos[m_len])
break;
m_len += 1;
if (ip[m_len] != m_pos[m_len])
break;
m_len += 1;
if (ip[m_len] != m_pos[m_len])
break;
m_len += 1;
if (ip[m_len] != m_pos[m_len])
break;
m_len += 1;
if (unlikely(ip + m_len >= ip_end))
goto m_len_done2;
} while (ip[m_len] == m_pos[m_len]);
}
#endif
}
m_len_done2:
m_off = ip - m_pos;
ip += m_len;
ii = ip;
if (m_len <= M2_MAX_LEN && m_off <= M2_MAX_OFFSET) {
m_off -= 1;
*op++ = (((m_len - 1) << 5) | ((m_off & 7) << 2));
*op++ = (m_off >> 3);
} else if (m_off <= M3_MAX_OFFSET) {
m_off -= 1;
if (m_len <= M3_MAX_LEN)
*op++ = (M3_MARKER | (m_len - 2));
else {
m_len -= M3_MAX_LEN;
*op++ = M3_MARKER | 0;
while (unlikely(m_len > 255)) {
m_len -= 255;
*op++ = 0;
}
*op++ = (m_len);
}
*op++ = (m_off << 2);
*op++ = (m_off >> 6);
} else {
m_off -= 0x4000;
if (m_len <= M4_MAX_LEN)
*op++ = (M4_MARKER | ((m_off >> 11) & 8)
| (m_len - 2));
else {
m_len -= M4_MAX_LEN;
*op++ = (M4_MARKER | ((m_off >> 11) & 8));
while (unlikely(m_len > 255)) {
m_len -= 255;
*op++ = 0;
}
*op++ = (m_len);
}
*op++ = (m_off << 2);
*op++ = (m_off >> 6);
}
goto next2;
}
*out_len = op - out;
if(t_total > *tmp_hash)
{
*tmp_hash = t_total;
}
return in_end - (ii - ti);
}
int lzo1x_1_compress(const unsigned char *in, size_t in_len,
unsigned char *out, size_t *out_len,
@@ -274,6 +482,98 @@ int lzo1x_1_compress(const unsigned char *in, size_t in_len,
return LZO_E_OK;
}
EXPORT_SYMBOL_GPL(lzo1x_1_compress);
int lzo1x_1_compress_zram(const unsigned char *in, size_t in_len,
unsigned char *out, size_t *out_len,
void *wrkmem,int *checksum)
{
const unsigned char *ip = in;
unsigned char *op = out;
unsigned int tmp_hash = 0;
unsigned int old_hash = 0;
unsigned int hash_total = 0;
size_t l = in_len;
size_t t = 0;
unsigned int out_hash = 0;
while (l > 20) {
size_t ll = l <= (M4_MAX_OFFSET + 1) ? l : (M4_MAX_OFFSET + 1);
uintptr_t ll_end = (uintptr_t) ip + ll;
if ((ll_end + ((t + ll) >> 5)) <= ll_end)
break;
BUILD_BUG_ON(D_SIZE * sizeof(lzo_dict_t) > LZO1X_1_MEM_COMPRESS);
memset(wrkmem, 0, D_SIZE * sizeof(lzo_dict_t));
t = lzo1x_1_do_compress_zram(ip, ll, op, out_len, t, wrkmem,&tmp_hash);
if(checksum != NULL)
{
(*checksum) += (tmp_hash - old_hash);
old_hash = tmp_hash;
hash_total += tmp_hash;
}
if(*out_len >= 4)
{ unsigned int *tmp_op = op;
out_hash = out_hash ^*tmp_op;
}
ip += ll;
op += *out_len;
l -= ll;
}
t += l;
if (t > 0) {
const unsigned char *ii = in + in_len - t;
if (op == out && t <= 238) {
*op++ = (17 + t);
} else if (t <= 3) {
op[-2] |= t;
} else if (t <= 18) {
*op++ = (t - 3);
} else {
size_t tt = t - 18;
*op++ = 0;
while (tt > 255) {
tt -= 255;
*op++ = 0;
}
*op++ = tt;
}
if (t >= 16) do {
COPY8(op, ii);
COPY8(op + 8, ii + 8);
op += 16;
ii += 16;
t -= 16;
} while (t >= 16);
if (t > 0) do {
*op++ = *ii++;
} while (--t > 0);
}
*op++ = M4_MARKER | 1;
*op++ = 0;
*op++ = 0;
*out_len = op - out;
if(hash_total > (unsigned int)*checksum)
{
*checksum = hash_total;
}
if(out_hash != 0)
{
*checksum = out_hash^(unsigned int)*checksum;
}
if(*out_len >= 4)
{
unsigned int *tmp_out = out;
unsigned int tmp_checksum = 0;
tmp_checksum = (unsigned int)*checksum+(unsigned int)*tmp_out;
//if(tmp_checksum > (unsigned int)*checksum)
*checksum = (int)tmp_checksum;
}
return LZO_E_OK;
}
EXPORT_SYMBOL_GPL(lzo1x_1_compress_zram);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("LZO1X-1 Compressor");
+51
View File
@@ -192,6 +192,56 @@ int match_hex(substring_t *s, int *result)
return match_number(s, result, 16);
}
/**
* match_wildcard: - parse if a string matches given wildcard pattern
* @pattern: wildcard pattern
* @str: the string to be parsed
*
* Description: Parse the string @str to check if matches wildcard
* pattern @pattern. The pattern may contain two type wildcardes:
* '*' - matches zero or more characters
* '?' - matches one character
* If it's matched, return true, else return false.
*/
bool match_wildcard(const char *pattern, const char *str)
{
const char *s = str;
const char *p = pattern;
bool star = false;
while (*s) {
switch (*p) {
case '?':
s++;
p++;
break;
case '*':
star = true;
str = s;
if (!*++p)
return true;
pattern = p;
break;
default:
if (*s == *p) {
s++;
p++;
} else {
if (!star)
return false;
str++;
s = str;
p = pattern;
}
break;
}
}
if (*p == '*')
++p;
return !*p;
}
/**
* match_strlcpy: - Copy the characters from a substring_t to a sized buffer
* @dest: where to copy to
@@ -235,5 +285,6 @@ EXPORT_SYMBOL(match_token);
EXPORT_SYMBOL(match_int);
EXPORT_SYMBOL(match_octal);
EXPORT_SYMBOL(match_hex);
EXPORT_SYMBOL(match_wildcard);
EXPORT_SYMBOL(match_strlcpy);
EXPORT_SYMBOL(match_strdup);
+66 -6
View File
@@ -12,6 +12,11 @@
#include <linux/debug_locks.h>
#include <linux/delay.h>
#include <linux/export.h>
#include <linux/kernel.h>
#include <linux/aee.h>
extern int InDumpAllStack;
void __raw_spin_lock_init(raw_spinlock_t *lock, const char *name,
struct lock_class_key *key)
@@ -59,20 +64,28 @@ static void spin_dump(raw_spinlock_t *lock, const char *msg)
msg, raw_smp_processor_id(),
current->comm, task_pid_nr(current));
printk(KERN_EMERG " lock: %pS, .magic: %08x, .owner: %s/%d, "
".owner_cpu: %d\n",
".owner_cpu: %d value:0x%08x\n",
lock, lock->magic,
owner ? owner->comm : "<none>",
owner ? task_pid_nr(owner) : -1,
lock->owner_cpu);
lock->owner_cpu, *((unsigned int *)&lock->raw_lock));
dump_stack();
}
static void spin_bug(raw_spinlock_t *lock, const char *msg)
{
if (!debug_locks_off())
return;
char aee_str[50];
// if (!debug_locks_off())
// return;
spin_dump(lock, msg);
spin_dump(lock, msg);
snprintf( aee_str, 50, "Spinlock %s :%s\n", current->comm, msg);
if(!strcmp(msg,"bad magic")){
printk("[spin lock debug] bad magic:%08x, should be %08x, may use an un-initial spin_lock or mem corrupt\n", lock->magic, SPINLOCK_MAGIC);
printk(">>>>>>>>>>>>>> Let's KE <<<<<<<<<<<<<<\n");
BUG_ON(1);
}
aee_kernel_warning_api(__FILE__, __LINE__, DB_OPT_DUMMY_DUMP | DB_OPT_FTRACE, aee_str,"spinlock debugger\n");
}
#define SPIN_BUG_ON(cond, lock, msg) if (unlikely(cond)) spin_bug(lock, msg)
@@ -103,11 +116,57 @@ static inline void debug_spin_unlock(raw_spinlock_t *lock)
lock->owner_cpu = -1;
}
/*
Select appropriate loop counts to 1~2sec
*/
#if HZ == 100
#define LOOP_HZ 100 // temp 10
#elif HZ == 10
#define LOOP_HZ 2 // temp 2
#else
#define LOOP_HZ HZ
#endif
#define WARNING_TIME 1000000000 // warning time 1 seconds
static void __spin_lock_debug(raw_spinlock_t *lock)
{
#ifdef CONFIG_MTK_MUTATION
u64 i;
u64 loops = loops_per_jiffy * LOOP_HZ;
int print_once = 1;
char aee_str[50];
unsigned long long t1,t2;
t1 = sched_clock();
t2 = t1;
for (;;) {
for (i = 0; i < loops; i++) {
if (arch_spin_trylock(&lock->raw_lock))
return;
__delay(1);
}
if(sched_clock() - t2 < WARNING_TIME*3) continue;
t2 = sched_clock();
#ifdef CONFIG_MTK_AEE_FEATURE
if((oops_in_progress != 0) || (InDumpAllStack == 1)) continue; // in exception follow, printk maybe spinlock error
#else
if(oops_in_progress != 0) continue; // in exception follow, printk maybe spinlock error
#endif
/* lockup suspected: */
printk("spin time: %llu ns(start:%llu ns, lpj:%lu, LPHZ:%d), value: 0x%08x\n", sched_clock() - t1, t1, loops_per_jiffy, (int)LOOP_HZ, *((unsigned int *)&lock->raw_lock));
if (print_once) {
print_once = 0;
spin_dump(lock, "lockup suspected");
#ifdef CONFIG_SMP
trigger_all_cpu_backtrace();
#endif
debug_show_all_locks();
snprintf( aee_str, 50, "Spinlock lockup:%s\n", current->comm);
aee_kernel_warning_api(__FILE__, __LINE__, DB_OPT_DUMMY_DUMP | DB_OPT_FTRACE, aee_str,"spinlock debugger\n");
}
}
#else //CONFIG_MTK_MUTATION
u64 i;
u64 loops = loops_per_jiffy * HZ;
for (i = 0; i < loops; i++) {
if (arch_spin_trylock(&lock->raw_lock))
return;
@@ -128,6 +187,7 @@ static void __spin_lock_debug(raw_spinlock_t *lock)
* progress.
*/
arch_spin_lock(&lock->raw_lock);
#endif //CONFIG_MTK_MUTATION
}
void do_raw_spin_lock(raw_spinlock_t *lock)
+7 -2
View File
@@ -117,7 +117,11 @@ unsigned long swiotlb_nr_tbl(void)
EXPORT_SYMBOL_GPL(swiotlb_nr_tbl);
/* default to 64MB */
#define IO_TLB_DEFAULT_SIZE (64UL<<20)
#ifdef CONFIG_MTK_LM_MODE
#define IO_TLB_DEFAULT_SIZE (SZ_64M)
#else
#define IO_TLB_DEFAULT_SIZE ((1 << IO_TLB_SHIFT) * IO_TLB_SEGSIZE)
#endif // end of CONFIG_MTK_LM_MODE
unsigned long swiotlb_size_or_default(void)
{
unsigned long size;
@@ -149,7 +153,7 @@ void swiotlb_print_info(void)
vstart = phys_to_virt(io_tlb_start);
vend = phys_to_virt(io_tlb_end);
printk(KERN_INFO "software IO TLB [mem %#010llx-%#010llx] (%luMB) mapped at [%p-%p]\n",
printk(KERN_ALERT"software IO TLB [mem %#010llx-%#010llx] (%luMB) mapped at [%p-%p]\n",
(unsigned long long)io_tlb_start,
(unsigned long long)io_tlb_end,
bytes >> 20, vstart, vend - 1);
@@ -690,6 +694,7 @@ swiotlb_full(struct device *dev, size_t size, enum dma_data_direction dir,
*/
printk(KERN_ERR "DMA: Out of SW-IOMMU space for %zu bytes at "
"device %s\n", size, dev ? dev_name(dev) : "?");
BUG();
if (size <= io_tlb_overflow || !do_panic)
return;