Applied assortment of Arch Linux ARM patches
This commit is contained in:
parent
25c6d769f4
commit
4822424518
@ -45,7 +45,7 @@ void *return_address(unsigned int);
|
||||
|
||||
#else
|
||||
|
||||
extern inline void *return_address(unsigned int level)
|
||||
static inline void *return_address(unsigned int level)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#include <uapi/asm/unistd.h>
|
||||
|
||||
#define __NR_syscalls (384)
|
||||
#define __NR_syscalls (388)
|
||||
#define __ARM_NR_cmpxchg (__ARM_NR_BASE+0x00fff0)
|
||||
|
||||
#define __ARCH_WANT_STAT64
|
||||
|
@ -410,6 +410,7 @@
|
||||
#define __NR_sched_getattr (__NR_SYSCALL_BASE+381)
|
||||
#define __NR_renameat2 (__NR_SYSCALL_BASE+382)
|
||||
#define __NR_seccomp (__NR_SYSCALL_BASE+383)
|
||||
#define __NR_getrandom (__NR_SYSCALL_BASE+384)
|
||||
|
||||
/*
|
||||
* This may need to be greater than __NR_last_syscall+1 in order to
|
||||
|
@ -393,6 +393,7 @@
|
||||
CALL(sys_ni_syscall) /* CALL(sys_sched_getattr) */
|
||||
CALL(sys_ni_syscall) /* CALL(sys_renameat2) */
|
||||
CALL(sys_seccomp)
|
||||
CALL(sys_getrandom)
|
||||
#ifndef syscalls_counted
|
||||
.equ syscalls_padding, ((NR_syscalls + 3) & ~3) - NR_syscalls
|
||||
#define syscalls_counted
|
||||
|
@ -63,10 +63,12 @@ void *return_address(unsigned int level)
|
||||
#warning "TODO: return_address should use unwind tables"
|
||||
#endif
|
||||
|
||||
/*
|
||||
void *return_address(unsigned int level)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
*/
|
||||
|
||||
#endif /* if defined(CONFIG_FRAME_POINTER) && !defined(CONFIG_ARM_UNWIND) / else */
|
||||
|
||||
|
@ -361,3 +361,4 @@
|
||||
352 i386 sched_getattr sys_ni_syscall
|
||||
353 i386 renameat2 sys_ni_syscall
|
||||
354 i386 seccomp sys_seccomp
|
||||
355 i386 getrandom sys_getrandom
|
||||
|
@ -324,6 +324,7 @@
|
||||
315 common sched_getattr sys_ni_syscall
|
||||
316 common renameat2 sys_ni_syscall
|
||||
317 common seccomp sys_seccomp
|
||||
318 common getrandom sys_getrandom
|
||||
|
||||
#
|
||||
# x32-specific system call numbers start at 512 to avoid cache impact
|
||||
|
@ -23,14 +23,16 @@ static int regcache_rbtree_write(struct regmap *map, unsigned int reg,
|
||||
static int regcache_rbtree_exit(struct regmap *map);
|
||||
|
||||
struct regcache_rbtree_node {
|
||||
/* the actual rbtree node holding this block */
|
||||
struct rb_node node;
|
||||
/* base register handled by this block */
|
||||
unsigned int base_reg;
|
||||
/* block of adjacent registers */
|
||||
void *block;
|
||||
/* Which registers are present */
|
||||
long *cache_present;
|
||||
/* base register handled by this block */
|
||||
unsigned int base_reg;
|
||||
/* number of registers available in the block */
|
||||
unsigned int blklen;
|
||||
/* the actual rbtree node holding this block */
|
||||
struct rb_node node;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct regcache_rbtree_ctx {
|
||||
|
@ -265,6 +265,9 @@
|
||||
#include <asm/irq.h>
|
||||
#include <asm/irq_regs.h>
|
||||
#include <asm/io.h>
|
||||
#include <linux/syscalls.h>
|
||||
#include <linux/completion.h>
|
||||
|
||||
|
||||
#define CREATE_TRACE_POINTS
|
||||
#include <trace/events/random.h>
|
||||
@ -397,6 +400,7 @@ static struct poolinfo {
|
||||
*/
|
||||
static DECLARE_WAIT_QUEUE_HEAD(random_read_wait);
|
||||
static DECLARE_WAIT_QUEUE_HEAD(random_write_wait);
|
||||
static DECLARE_WAIT_QUEUE_HEAD(urandom_init_wait);
|
||||
static struct fasync_struct *fasync;
|
||||
|
||||
static bool debug;
|
||||
@ -606,8 +610,11 @@ retry:
|
||||
|
||||
if (!r->initialized && nbits > 0) {
|
||||
r->entropy_total += nbits;
|
||||
if (r->entropy_total > 128)
|
||||
if (r->entropy_total > 128) {
|
||||
r->initialized = 1;
|
||||
if (r == &nonblocking_pool)
|
||||
prandom_reseed_late();
|
||||
}
|
||||
}
|
||||
|
||||
trace_credit_entropy_bits(r->name, nbits, entropy_count,
|
||||
@ -1015,13 +1022,14 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
|
||||
{
|
||||
ssize_t ret = 0, i;
|
||||
__u8 tmp[EXTRACT_SIZE];
|
||||
int large_request = (nbytes > 256);
|
||||
|
||||
trace_extract_entropy_user(r->name, nbytes, r->entropy_count, _RET_IP_);
|
||||
xfer_secondary_pool(r, nbytes);
|
||||
nbytes = account(r, nbytes, 0, 0);
|
||||
|
||||
while (nbytes) {
|
||||
if (need_resched()) {
|
||||
if (large_request && need_resched()) {
|
||||
if (signal_pending(current)) {
|
||||
if (ret == 0)
|
||||
ret = -ERESTARTSYS;
|
||||
@ -1155,8 +1163,7 @@ void rand_initialize_disk(struct gendisk *disk)
|
||||
#endif
|
||||
|
||||
static ssize_t
|
||||
random_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
|
||||
{
|
||||
_random_read(int nonblock, char __user *buf, size_t nbytes){
|
||||
ssize_t n, retval = 0, count = 0;
|
||||
|
||||
if (nbytes == 0)
|
||||
@ -1180,7 +1187,7 @@ random_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
|
||||
n*8, (nbytes-n)*8);
|
||||
|
||||
if (n == 0) {
|
||||
if (file->f_flags & O_NONBLOCK) {
|
||||
if (nonblock) {
|
||||
retval = -EAGAIN;
|
||||
break;
|
||||
}
|
||||
@ -1211,6 +1218,12 @@ random_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
|
||||
return (count ? count : retval);
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
random_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
|
||||
{
|
||||
return _random_read(file->f_flags & O_NONBLOCK, buf, nbytes);
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
urandom_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
|
||||
{
|
||||
@ -1337,6 +1350,29 @@ const struct file_operations urandom_fops = {
|
||||
.llseek = noop_llseek,
|
||||
};
|
||||
|
||||
SYSCALL_DEFINE3(getrandom, char __user *, buf, size_t, count,
|
||||
unsigned int, flags)
|
||||
{
|
||||
if (flags & ~(GRND_NONBLOCK|GRND_RANDOM))
|
||||
return -EINVAL;
|
||||
|
||||
if (count > INT_MAX)
|
||||
count = INT_MAX;
|
||||
|
||||
if (flags & GRND_RANDOM)
|
||||
return _random_read(flags & GRND_NONBLOCK, buf, count);
|
||||
|
||||
if (unlikely(nonblocking_pool.initialized == 0)) {
|
||||
if (flags & GRND_NONBLOCK)
|
||||
return -EAGAIN;
|
||||
wait_event_interruptible(urandom_init_wait,
|
||||
nonblocking_pool.initialized);
|
||||
if (signal_pending(current))
|
||||
return -ERESTARTSYS;
|
||||
}
|
||||
return urandom_read(NULL, buf, count, NULL);
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* Random UUID interface
|
||||
*
|
||||
|
@ -6212,7 +6212,7 @@ static int update_array_info(struct mddev *mddev, mdu_array_info_t *info)
|
||||
mddev->ctime != info->ctime ||
|
||||
mddev->level != info->level ||
|
||||
/* mddev->layout != info->layout || */
|
||||
!mddev->persistent != info->not_persistent||
|
||||
mddev->persistent == info->not_persistent||
|
||||
mddev->chunk_sectors != info->chunk_size >> 9 ||
|
||||
/* ignore bottom 8 bits of state, and allow SB_BITMAP_PRESENT to change */
|
||||
((state^info->state) & 0xfffffe00)
|
||||
|
@ -1530,7 +1530,7 @@ static void imon_incoming_packet(struct imon_context *ictx,
|
||||
if (kc == KEY_KEYBOARD && !ictx->release_code) {
|
||||
ictx->last_keycode = kc;
|
||||
if (!nomouse) {
|
||||
ictx->pad_mouse = ~(ictx->pad_mouse) & 0x1;
|
||||
ictx->pad_mouse = !ictx->pad_mouse;
|
||||
dev_dbg(dev, "toggling to %s mode\n",
|
||||
ictx->pad_mouse ? "mouse" : "keyboard");
|
||||
spin_unlock_irqrestore(&ictx->kc_lock, flags);
|
||||
|
@ -67,7 +67,7 @@ static int ec_get_version(struct cros_ec_device *ec, char *str, int maxlen)
|
||||
}
|
||||
if (resp.current_image >= ARRAY_SIZE(current_image_name))
|
||||
resp.current_image = 3; /* invalid */
|
||||
snprintf(str, maxlen, "%s\n%s\n%s\n\%s\n", CROS_EC_DEV_VERSION,
|
||||
snprintf(str, maxlen, "%s\n%s\n%s\n%s\n", CROS_EC_DEV_VERSION,
|
||||
resp.version_string_ro, resp.version_string_rw,
|
||||
current_image_name[resp.current_image]);
|
||||
|
||||
|
@ -244,7 +244,7 @@ static ssize_t store_rgb(struct device *dev, struct device_attribute *attr,
|
||||
return (ok && i == 0) ? count : -EINVAL;
|
||||
}
|
||||
|
||||
static const char const *seqname[] = {
|
||||
static const char *seqname[] = {
|
||||
"ERROR", "S5", "S3", "S0", "S5S3", "S3S0",
|
||||
"S0S3", "S3S5", "STOP", "RUN", "PULSE", "TEST", "KONAMI",
|
||||
};
|
||||
|
@ -537,21 +537,6 @@ static void mwifiex_fw_dpc(const struct firmware *firmware, void *context)
|
||||
goto err_add_intf;
|
||||
}
|
||||
|
||||
/* Create AP interface by default */
|
||||
if (!mwifiex_add_virtual_intf(adapter->wiphy, "uap%d",
|
||||
NL80211_IFTYPE_AP, NULL, NULL)) {
|
||||
mwifiex_dbg(adapter, ERROR,
|
||||
"cannot create default AP interface\n");
|
||||
goto err_add_intf;
|
||||
}
|
||||
|
||||
/* Create P2P interface by default */
|
||||
if (!mwifiex_add_virtual_intf(adapter->wiphy, "p2p%d",
|
||||
NL80211_IFTYPE_P2P_CLIENT, NULL, NULL)) {
|
||||
mwifiex_dbg(adapter, ERROR,
|
||||
"cannot create default P2P interface\n");
|
||||
goto err_add_intf;
|
||||
}
|
||||
rtnl_unlock();
|
||||
|
||||
mwifiex_drv_get_driver_version(adapter, fmt, sizeof(fmt) - 1);
|
||||
|
@ -30,9 +30,9 @@
|
||||
#include "main.h"
|
||||
|
||||
#define SD8786_DEFAULT_FW_NAME "mrvl/sd8786_uapsta.bin"
|
||||
#define SD8787_DEFAULT_FW_NAME "mrvl/sd8787_uapsta.bin"
|
||||
#define SD8797_DEFAULT_FW_NAME "mrvl/sd8797_uapsta.bin"
|
||||
#define SD8897_DEFAULT_FW_NAME "mrvl/sd8897_uapsta.bin"
|
||||
#define SD8787_DEFAULT_FW_NAME "mrvl/sd8787_uapsta_cros.bin"
|
||||
#define SD8797_DEFAULT_FW_NAME "mrvl/sd8797_uapsta_cros.bin"
|
||||
#define SD8897_DEFAULT_FW_NAME "mrvl/sd8897_uapsta_cros.bin"
|
||||
|
||||
#define BLOCK_MODE 1
|
||||
#define BYTE_MODE 0
|
||||
|
@ -309,7 +309,6 @@ static void zd1201_usbrx(struct urb *urb)
|
||||
if (data[urb->actual_length-1] == ZD1201_PACKET_RXDATA) {
|
||||
int datalen = urb->actual_length-1;
|
||||
unsigned short len, fc, seq;
|
||||
struct hlist_node *node;
|
||||
|
||||
len = ntohs(*(__be16 *)&data[datalen-2]);
|
||||
if (len>datalen)
|
||||
@ -362,7 +361,7 @@ static void zd1201_usbrx(struct urb *urb)
|
||||
hlist_add_head(&frag->fnode, &zd->fraglist);
|
||||
goto resubmit;
|
||||
}
|
||||
hlist_for_each_entry(frag, node, &zd->fraglist, fnode)
|
||||
hlist_for_each_entry(frag, &zd->fraglist, fnode)
|
||||
if (frag->seq == (seq&IEEE80211_SCTL_SEQ))
|
||||
break;
|
||||
if (!frag)
|
||||
@ -1831,14 +1830,14 @@ err_zd:
|
||||
static void zd1201_disconnect(struct usb_interface *interface)
|
||||
{
|
||||
struct zd1201 *zd = usb_get_intfdata(interface);
|
||||
struct hlist_node *node, *node2;
|
||||
struct hlist_node *node2;
|
||||
struct zd1201_frag *frag;
|
||||
|
||||
if (!zd)
|
||||
return;
|
||||
usb_set_intfdata(interface, NULL);
|
||||
|
||||
hlist_for_each_entry_safe(frag, node, node2, &zd->fraglist, fnode) {
|
||||
hlist_for_each_entry_safe(frag, node2, &zd->fraglist, fnode) {
|
||||
hlist_del_init(&frag->fnode);
|
||||
kfree_skb(frag->skb);
|
||||
kfree(frag);
|
||||
|
@ -77,7 +77,7 @@
|
||||
#define CONT_MODE_IR 2
|
||||
#define CONT_MODE_PROX 3
|
||||
|
||||
static const char const *isl29018_cont_modes[] = {
|
||||
static const char *isl29018_cont_modes[] = {
|
||||
"once",
|
||||
"als",
|
||||
"ir",
|
||||
|
@ -767,30 +767,35 @@ static int plugimage(struct imgchunk *fchunk, unsigned int nfchunks,
|
||||
static int read_cardpda(struct pda *pda, wlandevice_t *wlandev)
|
||||
{
|
||||
int result = 0;
|
||||
struct p80211msg_p2req_readpda msg;
|
||||
struct p80211msg_p2req_readpda *msg;
|
||||
|
||||
msg = kzalloc(sizeof(*msg), GFP_KERNEL);
|
||||
if (!msg)
|
||||
return -ENOMEM;
|
||||
|
||||
/* set up the msg */
|
||||
msg.msgcode = DIDmsg_p2req_readpda;
|
||||
msg.msglen = sizeof(msg);
|
||||
strcpy(msg.devname, wlandev->name);
|
||||
msg.pda.did = DIDmsg_p2req_readpda_pda;
|
||||
msg.pda.len = HFA384x_PDA_LEN_MAX;
|
||||
msg.pda.status = P80211ENUM_msgitem_status_no_value;
|
||||
msg.resultcode.did = DIDmsg_p2req_readpda_resultcode;
|
||||
msg.resultcode.len = sizeof(u32);
|
||||
msg.resultcode.status = P80211ENUM_msgitem_status_no_value;
|
||||
msg->msgcode = DIDmsg_p2req_readpda;
|
||||
msg->msglen = sizeof(msg);
|
||||
strcpy(msg->devname, wlandev->name);
|
||||
msg->pda.did = DIDmsg_p2req_readpda_pda;
|
||||
msg->pda.len = HFA384x_PDA_LEN_MAX;
|
||||
msg->pda.status = P80211ENUM_msgitem_status_no_value;
|
||||
msg->resultcode.did = DIDmsg_p2req_readpda_resultcode;
|
||||
msg->resultcode.len = sizeof(u32);
|
||||
msg->resultcode.status = P80211ENUM_msgitem_status_no_value;
|
||||
|
||||
if (prism2mgmt_readpda(wlandev, &msg) != 0) {
|
||||
if (prism2mgmt_readpda(wlandev, msg) != 0) {
|
||||
/* prism2mgmt_readpda prints an errno if appropriate */
|
||||
result = -1;
|
||||
} else if (msg.resultcode.data == P80211ENUM_resultcode_success) {
|
||||
memcpy(pda->buf, msg.pda.data, HFA384x_PDA_LEN_MAX);
|
||||
} else if (msg->resultcode.data == P80211ENUM_resultcode_success) {
|
||||
memcpy(pda->buf, msg->pda.data, HFA384x_PDA_LEN_MAX);
|
||||
result = mkpdrlist(pda);
|
||||
} else {
|
||||
/* resultcode must've been something other than success */
|
||||
result = -1;
|
||||
}
|
||||
|
||||
kfree(msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1406,7 +1406,7 @@ static int soctherm_init_platform_data(struct platform_device *pdev)
|
||||
therm = &plat_data->therm[tsensor2therm_map[i]];
|
||||
s = &plat_data->sensor_data[i];
|
||||
s->sensor_enable = s->zone_enable;
|
||||
s->sensor_enable = s->sensor_enable ?: therm->zone_enable;
|
||||
s->sensor_enable = s->sensor_enable ? s->sensor_enable : therm->zone_enable;
|
||||
}
|
||||
|
||||
/* Pdiv */
|
||||
|
@ -1129,7 +1129,7 @@ void fb_edid_add_monspecs(unsigned char *edid, struct fb_monspecs *specs)
|
||||
|
||||
for (i = 0; i < (128 - edid[2]) / DETAILED_TIMING_DESCRIPTION_SIZE;
|
||||
i++, block += DETAILED_TIMING_DESCRIPTION_SIZE)
|
||||
if (PIXEL_CLOCK)
|
||||
if (PIXEL_CLOCK != 0)
|
||||
edt[num++] = block - edid;
|
||||
|
||||
/* Yikes, EDID data is totally useless */
|
||||
|
@ -387,7 +387,7 @@ static void remove_dir(struct dentry * d)
|
||||
if (d->d_inode)
|
||||
simple_rmdir(parent->d_inode,d);
|
||||
|
||||
pr_debug(" o %s removing done (%d)\n",d->d_name.name, d->d_count);
|
||||
pr_debug(" o %s removing done (%d)\n",d->d_name.name, d->d_lockref.count);
|
||||
|
||||
dput(parent);
|
||||
}
|
||||
|
@ -1024,15 +1024,14 @@ killed:
|
||||
return -EAGAIN;
|
||||
}
|
||||
|
||||
char *get_task_comm(char *buf, struct task_struct *tsk)
|
||||
char *__get_task_comm(char *buf, size_t buf_size, struct task_struct *tsk)
|
||||
{
|
||||
/* buf must be at least sizeof(tsk->comm) in size */
|
||||
task_lock(tsk);
|
||||
strncpy(buf, tsk->comm, sizeof(tsk->comm));
|
||||
strncpy(buf, tsk->comm, buf_size);
|
||||
task_unlock(tsk);
|
||||
return buf;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(get_task_comm);
|
||||
EXPORT_SYMBOL_GPL(__get_task_comm);
|
||||
|
||||
/*
|
||||
* These functions flushes out all traces of the currently running executable
|
||||
|
@ -241,7 +241,7 @@ static int copy_name(char *buffer, const char *xattr_name, int name_len)
|
||||
int offset = 0;
|
||||
|
||||
if (is_osx_xattr(xattr_name)) {
|
||||
strncpy(buffer, XATTR_MAC_OSX_PREFIX, XATTR_MAC_OSX_PREFIX_LEN);
|
||||
memcpy(buffer, XATTR_MAC_OSX_PREFIX, XATTR_MAC_OSX_PREFIX_LEN);
|
||||
offset += XATTR_MAC_OSX_PREFIX_LEN;
|
||||
len += XATTR_MAC_OSX_PREFIX_LEN;
|
||||
}
|
||||
|
@ -1373,27 +1373,29 @@ static int nfs_volume_list_show(struct seq_file *m, void *v)
|
||||
{
|
||||
struct nfs_server *server;
|
||||
struct nfs_client *clp;
|
||||
char dev[8], fsid[17];
|
||||
char dev[13]; // 8 for 2^24, 1 for ':', 3 for 2^8, 1 for '\0'
|
||||
char fsid[34]; // 2 * 16 for %llx, 1 for ':', 1 for '\0'
|
||||
struct nfs_net *nn = net_generic(m->private, nfs_net_id);
|
||||
|
||||
/* display header on line 1 */
|
||||
if (v == &nn->nfs_volume_list) {
|
||||
seq_puts(m, "NV SERVER PORT DEV FSID FSC\n");
|
||||
seq_puts(m, "NV SERVER PORT DEV FSID"
|
||||
" FSC\n");
|
||||
return 0;
|
||||
}
|
||||
/* display one transport per line on subsequent lines */
|
||||
server = list_entry(v, struct nfs_server, master_link);
|
||||
clp = server->nfs_client;
|
||||
|
||||
snprintf(dev, 8, "%u:%u",
|
||||
snprintf(dev, sizeof(dev), "%u:%u",
|
||||
MAJOR(server->s_dev), MINOR(server->s_dev));
|
||||
|
||||
snprintf(fsid, 17, "%llx:%llx",
|
||||
snprintf(fsid, sizeof(fsid), "%llx:%llx",
|
||||
(unsigned long long) server->fsid.major,
|
||||
(unsigned long long) server->fsid.minor);
|
||||
|
||||
rcu_read_lock();
|
||||
seq_printf(m, "v%u %s %s %-7s %-17s %s\n",
|
||||
seq_printf(m, "v%u %s %s %-12s %-33s %s\n",
|
||||
clp->rpc_ops->version,
|
||||
rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_HEX_ADDR),
|
||||
rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_HEX_PORT),
|
||||
|
@ -33,12 +33,18 @@
|
||||
* case either is valid.
|
||||
*/
|
||||
#define RELOC_HIDE(ptr, off) \
|
||||
({ unsigned long __ptr; \
|
||||
({ \
|
||||
unsigned long __ptr; \
|
||||
__asm__ ("" : "=r"(__ptr) : "0"(ptr)); \
|
||||
(typeof(ptr)) (__ptr + (off)); })
|
||||
(typeof(ptr)) (__ptr + (off)); \
|
||||
})
|
||||
|
||||
/* Make the optimizer believe the variable can be manipulated arbitrarily. */
|
||||
#define OPTIMIZER_HIDE_VAR(var) \
|
||||
__asm__ ("" : "=r" (var) : "0" (var))
|
||||
|
||||
#ifdef __CHECKER__
|
||||
#define __must_be_array(arr) 0
|
||||
#define __must_be_array(a) 0
|
||||
#else
|
||||
/* &a[0] degrades to a pointer: a different type from an array */
|
||||
#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
|
||||
@ -60,19 +66,25 @@
|
||||
#define __inline __inline notrace
|
||||
#endif
|
||||
|
||||
#define __always_inline inline __attribute__((always_inline))
|
||||
#define noinline __attribute__((noinline))
|
||||
|
||||
#define __deprecated __attribute__((deprecated))
|
||||
#define __packed __attribute__((packed))
|
||||
#define __weak __attribute__((weak))
|
||||
#define __alias(symbol) __attribute__((alias(#symbol)))
|
||||
|
||||
/*
|
||||
* it doesn't make sense on ARM (currently the only user of __naked) to trace
|
||||
* naked functions because then mcount is called without stack and frame pointer
|
||||
* being set up and there is no chance to restore the lr register to the value
|
||||
* before mcount was called.
|
||||
* it doesn't make sense on ARM (currently the only user of __naked)
|
||||
* to trace naked functions because then mcount is called without
|
||||
* stack and frame pointer being set up and there is no chance to
|
||||
* restore the lr register to the value before mcount was called.
|
||||
*
|
||||
* The asm() bodies of naked functions often depend on standard calling conventions,
|
||||
* therefore they must be noinline and noclone. GCC 4.[56] currently fail to enforce
|
||||
* this, so we must do so ourselves. See GCC PR44290.
|
||||
* The asm() bodies of naked functions often depend on standard calling
|
||||
* conventions, therefore they must be noinline and noclone.
|
||||
*
|
||||
* GCC 4.[56] currently fail to enforce this, so we must do so ourselves.
|
||||
* See GCC PR44290.
|
||||
*/
|
||||
#define __naked __attribute__((naked)) noinline __noclone notrace
|
||||
|
||||
@ -92,15 +104,145 @@
|
||||
#define __aligned(x) __attribute__((aligned(x)))
|
||||
#define __printf(a, b) __attribute__((format(printf, a, b)))
|
||||
#define __scanf(a, b) __attribute__((format(scanf, a, b)))
|
||||
#define noinline __attribute__((noinline))
|
||||
#define __attribute_const__ __attribute__((__const__))
|
||||
#define __maybe_unused __attribute__((unused))
|
||||
#define __always_unused __attribute__((unused))
|
||||
|
||||
#define __gcc_header(x) #x
|
||||
#define _gcc_header(x) __gcc_header(linux/compiler-gcc##x.h)
|
||||
#define gcc_header(x) _gcc_header(x)
|
||||
#include gcc_header(__GNUC__)
|
||||
/* gcc version specific checks */
|
||||
|
||||
#if GCC_VERSION < 30200
|
||||
# error Sorry, your compiler is too old - please upgrade it.
|
||||
#endif
|
||||
|
||||
#if GCC_VERSION < 30300
|
||||
# define __used __attribute__((__unused__))
|
||||
#else
|
||||
# define __used __attribute__((__used__))
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_GCOV_KERNEL
|
||||
# if GCC_VERSION < 30400
|
||||
# error "GCOV profiling support for gcc versions below 3.4 not included"
|
||||
# endif /* __GNUC_MINOR__ */
|
||||
#endif /* CONFIG_GCOV_KERNEL */
|
||||
|
||||
#if GCC_VERSION >= 30400
|
||||
#define __must_check __attribute__((warn_unused_result))
|
||||
#endif
|
||||
|
||||
#if GCC_VERSION >= 40000
|
||||
|
||||
/* GCC 4.1.[01] miscompiles __weak */
|
||||
#ifdef __KERNEL__
|
||||
# if GCC_VERSION >= 40100 && GCC_VERSION <= 40101
|
||||
# error Your version of gcc miscompiles the __weak directive
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define __used __attribute__((__used__))
|
||||
#define __compiler_offsetof(a, b) \
|
||||
__builtin_offsetof(a, b)
|
||||
|
||||
#if GCC_VERSION >= 40100 && GCC_VERSION < 40600
|
||||
# define __compiletime_object_size(obj) __builtin_object_size(obj, 0)
|
||||
#endif
|
||||
|
||||
#if GCC_VERSION >= 40300
|
||||
/* Mark functions as cold. gcc will assume any path leading to a call
|
||||
* to them will be unlikely. This means a lot of manual unlikely()s
|
||||
* are unnecessary now for any paths leading to the usual suspects
|
||||
* like BUG(), printk(), panic() etc. [but let's keep them for now for
|
||||
* older compilers]
|
||||
*
|
||||
* Early snapshots of gcc 4.3 don't support this and we can't detect this
|
||||
* in the preprocessor, but we can live with this because they're unreleased.
|
||||
* Maketime probing would be overkill here.
|
||||
*
|
||||
* gcc also has a __attribute__((__hot__)) to move hot functions into
|
||||
* a special section, but I don't see any sense in this right now in
|
||||
* the kernel context
|
||||
*/
|
||||
#define __cold __attribute__((__cold__))
|
||||
|
||||
#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
|
||||
|
||||
#ifndef __CHECKER__
|
||||
# define __compiletime_warning(message) __attribute__((warning(message)))
|
||||
# define __compiletime_error(message) __attribute__((error(message)))
|
||||
#endif /* __CHECKER__ */
|
||||
#endif /* GCC_VERSION >= 40300 */
|
||||
|
||||
#if GCC_VERSION >= 40500
|
||||
/*
|
||||
* Mark a position in code as unreachable. This can be used to
|
||||
* suppress control flow warnings after asm blocks that transfer
|
||||
* control elsewhere.
|
||||
*
|
||||
* Early snapshots of gcc 4.5 don't support this and we can't detect
|
||||
* this in the preprocessor, but we can live with this because they're
|
||||
* unreleased. Really, we need to have autoconf for the kernel.
|
||||
*/
|
||||
#define unreachable() __builtin_unreachable()
|
||||
|
||||
/* Mark a function definition as prohibited from being cloned. */
|
||||
#define __noclone __attribute__((__noclone__, __optimize__("no-tracer")))
|
||||
|
||||
#endif /* GCC_VERSION >= 40500 */
|
||||
|
||||
#if GCC_VERSION >= 40600
|
||||
/*
|
||||
* When used with Link Time Optimization, gcc can optimize away C functions or
|
||||
* variables which are referenced only from assembly code. __visible tells the
|
||||
* optimizer that something else uses this function or variable, thus preventing
|
||||
* this.
|
||||
*/
|
||||
#define __visible __attribute__((externally_visible))
|
||||
#endif
|
||||
|
||||
#if GCC_VERSION >= 40900 && !defined(__CHECKER__)
|
||||
/*
|
||||
* __assume_aligned(n, k): Tell the optimizer that the returned
|
||||
* pointer can be assumed to be k modulo n. The second argument is
|
||||
* optional (default 0), so we use a variadic macro to make the
|
||||
* shorthand.
|
||||
*
|
||||
* Beware: Do not apply this to functions which may return
|
||||
* ERR_PTRs. Also, it is probably unwise to apply it to functions
|
||||
* returning extra information in the low bits (but in that case the
|
||||
* compiler should see some alignment anyway, when the return value is
|
||||
* massaged by 'flags = ptr & 3; ptr &= ~3;').
|
||||
*/
|
||||
#define __assume_aligned(a, ...) __attribute__((__assume_aligned__(a, ## __VA_ARGS__)))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* GCC 'asm goto' miscompiles certain code sequences:
|
||||
*
|
||||
* http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670
|
||||
*
|
||||
* Work it around via a compiler barrier quirk suggested by Jakub Jelinek.
|
||||
*
|
||||
* (asm goto is automatically volatile - the naming reflects this.)
|
||||
*/
|
||||
#define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0)
|
||||
|
||||
#ifdef CONFIG_ARCH_USE_BUILTIN_BSWAP
|
||||
#if GCC_VERSION >= 40400
|
||||
#define __HAVE_BUILTIN_BSWAP32__
|
||||
#define __HAVE_BUILTIN_BSWAP64__
|
||||
#endif
|
||||
#if GCC_VERSION >= 40800
|
||||
#define __HAVE_BUILTIN_BSWAP16__
|
||||
#endif
|
||||
#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */
|
||||
|
||||
#if GCC_VERSION >= 50000
|
||||
#define KASAN_ABI_VERSION 4
|
||||
#elif GCC_VERSION >= 40902
|
||||
#define KASAN_ABI_VERSION 3
|
||||
#endif
|
||||
|
||||
#endif /* gcc version >= 40000 specific checks */
|
||||
|
||||
#if !defined(__noclone)
|
||||
#define __noclone /* not needed */
|
||||
@ -111,5 +253,3 @@
|
||||
* code
|
||||
*/
|
||||
#define uninitialized_var(x) x = x
|
||||
|
||||
#define __always_inline inline __attribute__((always_inline))
|
||||
|
@ -1,23 +0,0 @@
|
||||
#ifndef __LINUX_COMPILER_H
|
||||
#error "Please don't include <linux/compiler-gcc3.h> directly, include <linux/compiler.h> instead."
|
||||
#endif
|
||||
|
||||
#if GCC_VERSION < 30200
|
||||
# error Sorry, your compiler is too old - please upgrade it.
|
||||
#endif
|
||||
|
||||
#if GCC_VERSION >= 30300
|
||||
# define __used __attribute__((__used__))
|
||||
#else
|
||||
# define __used __attribute__((__unused__))
|
||||
#endif
|
||||
|
||||
#if GCC_VERSION >= 30400
|
||||
#define __must_check __attribute__((warn_unused_result))
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_GCOV_KERNEL
|
||||
# if GCC_VERSION < 30400
|
||||
# error "GCOV profiling support for gcc versions below 3.4 not included"
|
||||
# endif /* __GNUC_MINOR__ */
|
||||
#endif /* CONFIG_GCOV_KERNEL */
|
@ -1,92 +0,0 @@
|
||||
#ifndef __LINUX_COMPILER_H
|
||||
#error "Please don't include <linux/compiler-gcc4.h> directly, include <linux/compiler.h> instead."
|
||||
#endif
|
||||
|
||||
/* GCC 4.1.[01] miscompiles __weak */
|
||||
#ifdef __KERNEL__
|
||||
# if GCC_VERSION >= 40100 && GCC_VERSION <= 40101
|
||||
# error Your version of gcc miscompiles the __weak directive
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define __used __attribute__((__used__))
|
||||
#define __must_check __attribute__((warn_unused_result))
|
||||
#define __compiler_offsetof(a,b) __builtin_offsetof(a,b)
|
||||
|
||||
#if GCC_VERSION >= 40100 && GCC_VERSION < 40600
|
||||
# define __compiletime_object_size(obj) __builtin_object_size(obj, 0)
|
||||
#endif
|
||||
|
||||
#if GCC_VERSION >= 40300
|
||||
/* Mark functions as cold. gcc will assume any path leading to a call
|
||||
to them will be unlikely. This means a lot of manual unlikely()s
|
||||
are unnecessary now for any paths leading to the usual suspects
|
||||
like BUG(), printk(), panic() etc. [but let's keep them for now for
|
||||
older compilers]
|
||||
|
||||
Early snapshots of gcc 4.3 don't support this and we can't detect this
|
||||
in the preprocessor, but we can live with this because they're unreleased.
|
||||
Maketime probing would be overkill here.
|
||||
|
||||
gcc also has a __attribute__((__hot__)) to move hot functions into
|
||||
a special section, but I don't see any sense in this right now in
|
||||
the kernel context */
|
||||
#define __cold __attribute__((__cold__))
|
||||
|
||||
#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
|
||||
|
||||
#ifndef __CHECKER__
|
||||
# define __compiletime_warning(message) __attribute__((warning(message)))
|
||||
# define __compiletime_error(message) __attribute__((error(message)))
|
||||
#endif /* __CHECKER__ */
|
||||
#endif /* GCC_VERSION >= 40300 */
|
||||
|
||||
#if GCC_VERSION >= 40500
|
||||
/*
|
||||
* Mark a position in code as unreachable. This can be used to
|
||||
* suppress control flow warnings after asm blocks that transfer
|
||||
* control elsewhere.
|
||||
*
|
||||
* Early snapshots of gcc 4.5 don't support this and we can't detect
|
||||
* this in the preprocessor, but we can live with this because they're
|
||||
* unreleased. Really, we need to have autoconf for the kernel.
|
||||
*/
|
||||
#define unreachable() __builtin_unreachable()
|
||||
|
||||
/* Mark a function definition as prohibited from being cloned. */
|
||||
#define __noclone __attribute__((__noclone__))
|
||||
|
||||
#endif /* GCC_VERSION >= 40500 */
|
||||
|
||||
#if GCC_VERSION >= 40600
|
||||
/*
|
||||
* Tell the optimizer that something else uses this function or variable.
|
||||
*/
|
||||
#define __visible __attribute__((externally_visible))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* GCC 'asm goto' miscompiles certain code sequences:
|
||||
*
|
||||
* http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670
|
||||
*
|
||||
* Work it around via a compiler barrier quirk suggested by Jakub Jelinek.
|
||||
* Fixed in GCC 4.8.2 and later versions.
|
||||
*
|
||||
* (asm goto is automatically volatile - the naming reflects this.)
|
||||
*/
|
||||
#if GCC_VERSION <= 40801
|
||||
# define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0)
|
||||
#else
|
||||
# define asm_volatile_goto(x...) do { asm goto(x); } while (0)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ARCH_USE_BUILTIN_BSWAP
|
||||
#if GCC_VERSION >= 40400
|
||||
#define __HAVE_BUILTIN_BSWAP32__
|
||||
#define __HAVE_BUILTIN_BSWAP64__
|
||||
#endif
|
||||
#if GCC_VERSION >= 40800 || (defined(__powerpc__) && GCC_VERSION >= 40600)
|
||||
#define __HAVE_BUILTIN_BSWAP16__
|
||||
#endif
|
||||
#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */
|
@ -95,7 +95,7 @@ struct elevator_type
|
||||
struct module *elevator_owner;
|
||||
|
||||
/* managed by elevator core */
|
||||
char icq_cache_name[ELV_NAME_MAX + 5]; /* elvname + "_io_cq" */
|
||||
char icq_cache_name[ELV_NAME_MAX + 6]; /* elvname + "_io_cq" */
|
||||
struct list_head list;
|
||||
};
|
||||
|
||||
|
@ -15,12 +15,6 @@
|
||||
#include <linux/types.h>
|
||||
#include <linux/bitops.h>
|
||||
|
||||
/*
|
||||
* deal with unrepresentable constant logarithms
|
||||
*/
|
||||
extern __attribute__((const, noreturn))
|
||||
int ____ilog2_NaN(void);
|
||||
|
||||
/*
|
||||
* non-constant log of base 2 calculators
|
||||
* - the arch may override these in asm/bitops.h if they can be implemented
|
||||
@ -43,19 +37,23 @@ int __ilog2_u64(u64 n)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
/**
|
||||
* is_power_of_2() - check if a value is a power of two
|
||||
* @n: the value to check
|
||||
*
|
||||
* Determine whether some value is a power of two, where zero is
|
||||
* *not* considered a power of two.
|
||||
* Return: true if @n is a power of 2, otherwise false.
|
||||
*/
|
||||
|
||||
static inline __attribute__((const))
|
||||
bool is_power_of_2(unsigned long n)
|
||||
{
|
||||
return (n != 0 && ((n & (n - 1)) == 0));
|
||||
}
|
||||
|
||||
/*
|
||||
* round up to nearest power of two
|
||||
/**
|
||||
* __roundup_pow_of_two() - round up to nearest power of two
|
||||
* @n: value to round up
|
||||
*/
|
||||
static inline __attribute__((const))
|
||||
unsigned long __roundup_pow_of_two(unsigned long n)
|
||||
@ -63,8 +61,9 @@ unsigned long __roundup_pow_of_two(unsigned long n)
|
||||
return 1UL << fls_long(n - 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* round down to nearest power of two
|
||||
/**
|
||||
* __rounddown_pow_of_two() - round down to nearest power of two
|
||||
* @n: value to round down
|
||||
*/
|
||||
static inline __attribute__((const))
|
||||
unsigned long __rounddown_pow_of_two(unsigned long n)
|
||||
@ -73,19 +72,16 @@ unsigned long __rounddown_pow_of_two(unsigned long n)
|
||||
}
|
||||
|
||||
/**
|
||||
* ilog2 - log of base 2 of 32-bit or a 64-bit unsigned value
|
||||
* @n - parameter
|
||||
* const_ilog2 - log base 2 of 32-bit or a 64-bit constant unsigned value
|
||||
* @n: parameter
|
||||
*
|
||||
* constant-capable log of base 2 calculation
|
||||
* - this can be used to initialise global variables from constant data, hence
|
||||
* the massive ternary operator construction
|
||||
*
|
||||
* selects the appropriately-sized optimised version depending on sizeof(n)
|
||||
* Use this where sparse expects a true constant expression, e.g. for array
|
||||
* indices.
|
||||
*/
|
||||
#define ilog2(n) \
|
||||
#define const_ilog2(n) \
|
||||
( \
|
||||
__builtin_constant_p(n) ? ( \
|
||||
(n) < 1 ? ____ilog2_NaN() : \
|
||||
(n) < 2 ? 0 : \
|
||||
(n) & (1ULL << 63) ? 63 : \
|
||||
(n) & (1ULL << 62) ? 62 : \
|
||||
(n) & (1ULL << 61) ? 61 : \
|
||||
@ -148,10 +144,23 @@ unsigned long __rounddown_pow_of_two(unsigned long n)
|
||||
(n) & (1ULL << 4) ? 4 : \
|
||||
(n) & (1ULL << 3) ? 3 : \
|
||||
(n) & (1ULL << 2) ? 2 : \
|
||||
(n) & (1ULL << 1) ? 1 : \
|
||||
(n) & (1ULL << 0) ? 0 : \
|
||||
____ilog2_NaN() \
|
||||
) : \
|
||||
1) : \
|
||||
-1)
|
||||
|
||||
/**
|
||||
* ilog2 - log base 2 of 32-bit or a 64-bit unsigned value
|
||||
* @n: parameter
|
||||
*
|
||||
* constant-capable log of base 2 calculation
|
||||
* - this can be used to initialise global variables from constant data, hence
|
||||
* the massive ternary operator construction
|
||||
*
|
||||
* selects the appropriately-sized optimised version depending on sizeof(n)
|
||||
*/
|
||||
#define ilog2(n) \
|
||||
( \
|
||||
__builtin_constant_p(n) ? \
|
||||
const_ilog2(n) : \
|
||||
(sizeof(n) <= 4) ? \
|
||||
__ilog2_u32(n) : \
|
||||
__ilog2_u64(n) \
|
||||
@ -159,7 +168,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n)
|
||||
|
||||
/**
|
||||
* roundup_pow_of_two - round the given value up to nearest power of two
|
||||
* @n - parameter
|
||||
* @n: parameter
|
||||
*
|
||||
* round the given value up to the nearest power of two
|
||||
* - the result is undefined when n == 0
|
||||
@ -176,7 +185,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n)
|
||||
|
||||
/**
|
||||
* rounddown_pow_of_two - round the given value down to nearest power of two
|
||||
* @n - parameter
|
||||
* @n: parameter
|
||||
*
|
||||
* round the given value down to the nearest power of two
|
||||
* - the result is undefined when n == 0
|
||||
@ -189,6 +198,12 @@ unsigned long __rounddown_pow_of_two(unsigned long n)
|
||||
__rounddown_pow_of_two(n) \
|
||||
)
|
||||
|
||||
static inline __attribute_const__
|
||||
int __order_base_2(unsigned long n)
|
||||
{
|
||||
return n > 1 ? ilog2(n - 1) + 1 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* order_base_2 - calculate the (rounded up) base 2 order of the argument
|
||||
* @n: parameter
|
||||
@ -202,7 +217,11 @@ unsigned long __rounddown_pow_of_two(unsigned long n)
|
||||
* ob2(5) = 3
|
||||
* ... and so on.
|
||||
*/
|
||||
|
||||
#define order_base_2(n) ilog2(roundup_pow_of_two(n))
|
||||
|
||||
#define order_base_2(n) \
|
||||
( \
|
||||
__builtin_constant_p(n) ? ( \
|
||||
((n) == 0 || (n) == 1) ? 0 : \
|
||||
ilog2((n) - 1) + 1) : \
|
||||
__order_base_2(n) \
|
||||
)
|
||||
#endif /* _LINUX_LOG2_H */
|
||||
|
@ -29,6 +29,7 @@ unsigned long randomize_range(unsigned long start, unsigned long end, unsigned l
|
||||
u32 prandom_u32(void);
|
||||
void prandom_bytes(void *buf, int nbytes);
|
||||
void prandom_seed(u32 seed);
|
||||
void prandom_reseed_late(void);
|
||||
|
||||
u32 prandom_u32_state(struct rnd_state *);
|
||||
void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
|
||||
@ -50,9 +51,9 @@ static inline void prandom_seed_state(struct rnd_state *state, u64 seed)
|
||||
{
|
||||
u32 i = (seed >> 32) ^ (seed << 10) ^ seed;
|
||||
|
||||
state->s1 = __seed(i, 1);
|
||||
state->s2 = __seed(i, 7);
|
||||
state->s3 = __seed(i, 15);
|
||||
state->s1 = __seed(i, 2);
|
||||
state->s2 = __seed(i, 8);
|
||||
state->s3 = __seed(i, 16);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_ARCH_RANDOM
|
||||
|
@ -2151,7 +2151,11 @@ struct task_struct *fork_idle(int);
|
||||
extern pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
|
||||
|
||||
extern void set_task_comm(struct task_struct *tsk, char *from);
|
||||
extern char *get_task_comm(char *to, struct task_struct *tsk);
|
||||
extern char *__get_task_comm(char *to, size_t len, struct task_struct *tsk);
|
||||
#define get_task_comm(buf, tsk) ({ \
|
||||
BUILD_BUG_ON(sizeof(buf) != TASK_COMM_LEN); \
|
||||
__get_task_comm(buf, sizeof(buf), tsk); \
|
||||
})
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
void scheduler_ipi(void);
|
||||
|
@ -848,4 +848,7 @@ asmlinkage long sys_kcmp(pid_t pid1, pid_t pid2, int type,
|
||||
asmlinkage long sys_finit_module(int fd, const char __user *uargs, int flags);
|
||||
asmlinkage long sys_seccomp(unsigned int op, unsigned int flags,
|
||||
const char __user *uargs);
|
||||
asmlinkage long sys_getrandom(char __user *buf, size_t count,
|
||||
unsigned int flags);
|
||||
|
||||
#endif
|
||||
|
@ -702,9 +702,11 @@ __SYSCALL(__NR_renameat2, sys_renameat2)
|
||||
*/
|
||||
#define __NR_seccomp 277
|
||||
__SYSCALL(__NR_seccomp, sys_seccomp)
|
||||
#define __NR_getrandom 278
|
||||
__SYSCALL(__NR_getrandom, sys_getrandom)
|
||||
|
||||
#undef __NR_syscalls
|
||||
#define __NR_syscalls 278
|
||||
#define __NR_syscalls 279
|
||||
|
||||
/*
|
||||
* All syscalls below here should go away really,
|
||||
|
@ -44,6 +44,15 @@ struct rnd_state {
|
||||
__u32 s1, s2, s3;
|
||||
};
|
||||
|
||||
/*
|
||||
* Flags for getrandom(2)
|
||||
*
|
||||
* GRND_NONBLOCK Don't block and return EAGAIN instead
|
||||
* GRND_RANDOM Use the /dev/random pool instead of /dev/urandom
|
||||
*/
|
||||
#define GRND_NONBLOCK 0x0001
|
||||
#define GRND_RANDOM 0x0002
|
||||
|
||||
/* Exported functions */
|
||||
|
||||
|
||||
|
@ -51,7 +51,7 @@ static const unsigned char lzop_magic[] = {
|
||||
#define HEADER_SIZE_MIN (9 + 7 + 4 + 8 + 1 + 4)
|
||||
#define HEADER_SIZE_MAX (9 + 7 + 1 + 8 + 8 + 4 + 1 + 255 + 4)
|
||||
|
||||
STATIC inline int INIT parse_header(u8 *input, int *skip, int in_len)
|
||||
static inline int INIT parse_header(u8 *input, int *skip, int in_len)
|
||||
{
|
||||
int l;
|
||||
u8 *parse = input;
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include <linux/export.h>
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/random.h>
|
||||
#include <linux/timer.h>
|
||||
|
||||
static DEFINE_PER_CPU(struct rnd_state, net_rand_state);
|
||||
|
||||
@ -141,7 +142,8 @@ void prandom_seed(u32 entropy)
|
||||
*/
|
||||
for_each_possible_cpu (i) {
|
||||
struct rnd_state *state = &per_cpu(net_rand_state, i);
|
||||
state->s1 = __seed(state->s1 ^ entropy, 1);
|
||||
state->s1 = __seed(state->s1 ^ entropy, 2);
|
||||
prandom_u32_state(state);
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL(prandom_seed);
|
||||
@ -158,9 +160,9 @@ static int __init prandom_init(void)
|
||||
struct rnd_state *state = &per_cpu(net_rand_state,i);
|
||||
|
||||
#define LCG(x) ((x) * 69069) /* super-duper LCG */
|
||||
state->s1 = __seed(LCG(i + jiffies), 1);
|
||||
state->s2 = __seed(LCG(state->s1), 7);
|
||||
state->s3 = __seed(LCG(state->s2), 15);
|
||||
state->s1 = __seed(LCG(i + jiffies), 2);
|
||||
state->s2 = __seed(LCG(state->s1), 8);
|
||||
state->s3 = __seed(LCG(state->s2), 16);
|
||||
|
||||
/* "warm it up" */
|
||||
prandom_u32_state(state);
|
||||
@ -174,26 +176,69 @@ static int __init prandom_init(void)
|
||||
}
|
||||
core_initcall(prandom_init);
|
||||
|
||||
static void __prandom_timer(unsigned long dontcare);
|
||||
static DEFINE_TIMER(seed_timer, __prandom_timer, 0, 0);
|
||||
|
||||
static void __prandom_timer(unsigned long dontcare)
|
||||
{
|
||||
u32 entropy;
|
||||
|
||||
get_random_bytes(&entropy, sizeof(entropy));
|
||||
prandom_seed(entropy);
|
||||
/* reseed every ~60 seconds, in [40 .. 80) interval with slack */
|
||||
seed_timer.expires = jiffies + (40 * HZ + (prandom_u32() % (40 * HZ)));
|
||||
add_timer(&seed_timer);
|
||||
}
|
||||
|
||||
static void prandom_start_seed_timer(void)
|
||||
{
|
||||
set_timer_slack(&seed_timer, HZ);
|
||||
seed_timer.expires = jiffies + 40 * HZ;
|
||||
add_timer(&seed_timer);
|
||||
}
|
||||
|
||||
/*
|
||||
* Generate better values after random number generator
|
||||
* is fully initialized.
|
||||
*/
|
||||
static int __init prandom_reseed(void)
|
||||
static void __prandom_reseed(bool late)
|
||||
{
|
||||
int i;
|
||||
unsigned long flags;
|
||||
static bool latch = false;
|
||||
static DEFINE_SPINLOCK(lock);
|
||||
|
||||
/* only allow initial seeding (late == false) once */
|
||||
spin_lock_irqsave(&lock, flags);
|
||||
if (latch && !late)
|
||||
goto out;
|
||||
latch = true;
|
||||
|
||||
for_each_possible_cpu(i) {
|
||||
struct rnd_state *state = &per_cpu(net_rand_state,i);
|
||||
u32 seeds[3];
|
||||
|
||||
get_random_bytes(&seeds, sizeof(seeds));
|
||||
state->s1 = __seed(seeds[0], 1);
|
||||
state->s2 = __seed(seeds[1], 7);
|
||||
state->s3 = __seed(seeds[2], 15);
|
||||
state->s1 = __seed(seeds[0], 2);
|
||||
state->s2 = __seed(seeds[1], 8);
|
||||
state->s3 = __seed(seeds[2], 16);
|
||||
|
||||
/* mix it in */
|
||||
prandom_u32_state(state);
|
||||
}
|
||||
out:
|
||||
spin_unlock_irqrestore(&lock, flags);
|
||||
}
|
||||
|
||||
void prandom_reseed_late(void)
|
||||
{
|
||||
__prandom_reseed(true);
|
||||
}
|
||||
|
||||
static int __init prandom_reseed(void)
|
||||
{
|
||||
__prandom_reseed(false);
|
||||
prandom_start_seed_timer();
|
||||
return 0;
|
||||
}
|
||||
late_initcall(prandom_reseed);
|
||||
|
@ -523,7 +523,7 @@ __vma_address(struct page *page, struct vm_area_struct *vma)
|
||||
return vma->vm_start + ((pgoff - vma->vm_pgoff) << PAGE_SHIFT);
|
||||
}
|
||||
|
||||
inline unsigned long
|
||||
static inline unsigned long
|
||||
vma_address(struct page *page, struct vm_area_struct *vma)
|
||||
{
|
||||
unsigned long address = __vma_address(page, vma);
|
||||
|
@ -338,7 +338,8 @@ static netdev_tx_t vti_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
|
||||
be32_to_cpu(tunnel->parms.o_key), RT_TOS(tos),
|
||||
RT_SCOPE_UNIVERSE,
|
||||
IPPROTO_IPIP, 0,
|
||||
dst, tiph->saddr, 0, 0);
|
||||
dst, tiph->saddr, 0, 0,
|
||||
sock_net_uid(dev_net(dev), NULL));
|
||||
rt = ip_route_output_key(dev_net(dev), &fl4);
|
||||
if (IS_ERR(rt)) {
|
||||
dev->stats.tx_carrier_errors++;
|
||||
@ -404,7 +405,8 @@ static int vti_tunnel_bind_dev(struct net_device *dev)
|
||||
be32_to_cpu(tunnel->parms.i_key),
|
||||
RT_TOS(iph->tos), RT_SCOPE_UNIVERSE,
|
||||
IPPROTO_IPIP, 0,
|
||||
iph->daddr, iph->saddr, 0, 0);
|
||||
iph->daddr, iph->saddr, 0, 0,
|
||||
sock_net_uid(dev_net(dev), NULL));
|
||||
rt = ip_route_output_key(dev_net(dev), &fl4);
|
||||
if (!IS_ERR(rt)) {
|
||||
tdev = rt->dst.dev;
|
||||
|
@ -83,7 +83,7 @@ nfnl_cthelper_parse_tuple(struct nf_conntrack_tuple *tuple,
|
||||
static int
|
||||
nfnl_cthelper_from_nlattr(struct nlattr *attr, struct nf_conn *ct)
|
||||
{
|
||||
const struct nf_conn_help *help = nfct_help(ct);
|
||||
struct nf_conn_help *help = nfct_help(ct);
|
||||
|
||||
if (attr == NULL)
|
||||
return -EINVAL;
|
||||
@ -91,7 +91,7 @@ nfnl_cthelper_from_nlattr(struct nlattr *attr, struct nf_conn *ct)
|
||||
if (help->helper->data_len == 0)
|
||||
return -EINVAL;
|
||||
|
||||
memcpy(&help->data, nla_data(attr), help->helper->data_len);
|
||||
memcpy(help->data, nla_data(attr), help->helper->data_len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user