View | Details | Raw Unified | Return to bug 1447
Collapse All | Expand All

(-)a/Makefile (-15 / +21 lines)
 Lines 1-9    Link Here 
1
SRCDIR=$(dir $(firstword $(MAKEFILE_LIST)))
1
SRCDIR=$(dir $(firstword $(MAKEFILE_LIST)))
2
INSTALL_DIR=/usr
2
INSTALL_DIR=/usr
3
VPATH=$(SRCDIR)
3
VPATH=$(SRCDIR)
4
KERNEL_DIR=net-next-2.6
4
KERNEL_DIR=linux-stable
5
KERNEL_VERSION=fed66381d65a35198639f564365e61a7f256bf79
5
KERNEL_VERSION=763c71b1319c56272e42cf6ada6994131f0193a7
6
KERNEL_DOWNLOAD=git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git
6
KERNEL_DOWNLOAD=git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
7
7
8
SIM_SRC=\
8
SIM_SRC=\
9
fs.c random.c sim.c softirq.c time.c \
9
fs.c random.c sim.c softirq.c time.c \
 Lines 11-20    Link Here 
11
hrtimer.c sched.c sim-socket.c sysfs.c workqueue.c \
11
hrtimer.c sched.c sim-socket.c sysfs.c workqueue.c \
12
print.c security.c slab.c tasklet.c \
12
print.c security.c slab.c tasklet.c \
13
proc.c seq.c socket.c tasklet-hrtimer.c \
13
proc.c seq.c socket.c tasklet-hrtimer.c \
14
cred.c pid.c modules.c
14
cred.c pid.c modules.c filemap.c splice.c vmscan.c dcache.o super.o inode.o \
15
atomic64.o
15
16
16
17
17
OPT?=no
18
OPT?=yes
18
opt_yes=-O3 -fomit-frame-pointer 
19
opt_yes=-O3 -fomit-frame-pointer 
19
opt_no=-O0
20
opt_no=-O0
20
PIC?=yes
21
PIC?=yes
 Lines 29-39    Link Here 
29
 -fno-strict-aliasing -fno-common -fno-delete-null-pointer-checks \
30
 -fno-strict-aliasing -fno-common -fno-delete-null-pointer-checks \
30
 -fno-stack-protector \
31
 -fno-stack-protector \
31
 -DKBUILD_MODNAME=\"nsc\" -DMODVERSIONS -DEXPORT_SYMTAB \
32
 -DKBUILD_MODNAME=\"nsc\" -DMODVERSIONS -DEXPORT_SYMTAB \
32
 -include autoconf.h \
33
 -include $(SRCDIR)$(KERNEL_DIR)/include/linux/kconfig.h \
33
 -U__FreeBSD__ -D__linux__=1 -Dlinux=1 -D__linux=1 \
34
 -U__FreeBSD__ -D__linux__=1 -Dlinux=1 -D__linux=1 \
34
 -I$(SRCDIR)sim/include -I$(SRCDIR)$(KERNEL_DIR)/include \
35
 -I$(SRCDIR)sim/include -I$(SRCDIR)$(KERNEL_DIR)/include -I$(SRCDIR)$(KERNEL_DIR)/ \
35
 $(PIC_CFLAGS) -D_DEBUG -I$(PWD)
36
 $(PIC_CFLAGS) -D_DEBUG -I$(PWD)
36
37
38
37
include $(SRCDIR)processor.mk
39
include $(SRCDIR)processor.mk
38
40
39
ifeq ($(PROCESSOR_SIZE),64)
41
ifeq ($(PROCESSOR_SIZE),64)
 Lines 51-57    Link Here 
51
53
52
AUTOCONF=autoconf.h
54
AUTOCONF=autoconf.h
53
# note: the directory order below matters to ensure that we match the kernel order
55
# note: the directory order below matters to ensure that we match the kernel order
54
dirs=kernel/ mm/ crypto/ lib/ drivers/base/ drivers/net/ net/
56
dirs=kernel/ mm/ fs/ fs/proc/ crypto/ lib/ drivers/base/ drivers/net/ net/
55
empty:=
57
empty:=
56
space:= $(empty) $(empty)
58
space:= $(empty) $(empty)
57
colon:= :
59
colon:= :
 Lines 66-77    Link Here 
66
find_last_bit.o find_next_bit.o bitmap.o nlattr.o idr.o libcrc32c.o \
68
find_last_bit.o find_next_bit.o bitmap.o nlattr.o idr.o libcrc32c.o \
67
ctype.o string.o kasprintf.o rbtree.o sha1.o textsearch.o vsprintf.o \
69
ctype.o string.o kasprintf.o rbtree.o sha1.o textsearch.o vsprintf.o \
68
rwsem-spinlock.o scatterlist.o ratelimit.o hexdump.o dec_and_lock.o \
70
rwsem-spinlock.o scatterlist.o ratelimit.o hexdump.o dec_and_lock.o \
69
div64.o
71
div64.o dynamic_queue_limits.o md5.o kstrtox.o
72
fs/_to_keep=read_write.o libfs.o namei.o
73
fs/proc/_to_keep=proc_sysctl.o
70
74
71
objs.mk: Makefile.print $(KERNEL_DIR)/.config
75
objs.mk: Makefile.print $(KERNEL_DIR)/.config
72
	-for i in 1; do \
76
	-for i in 1; do \
73
	$(foreach d,$(dirs), \
77
	$(foreach d,$(dirs), \
74
           $(MAKE) -s -f $< srcdir=$(SRCDIR)$(KERNEL_DIR)/$(d) \
78
           $(MAKE) -i -s -f $< srcdir=$(SRCDIR)$(KERNEL_DIR)/$(d) \
75
	    objdir=$(KERNEL_DIR)/$(d) \
79
	    objdir=$(KERNEL_DIR)/$(d) \
76
            config=$(KERNEL_DIR)/.config \
80
            config=$(KERNEL_DIR)/.config \
77
	    to_keep=$(subst $(space),$(colon),$($(d)_to_keep)) print;) \
81
	    to_keep=$(subst $(space),$(colon),$($(d)_to_keep)) print;) \
 Lines 83-88    Link Here 
83
87
84
$(AUTOCONF): generate-autoconf.py $(KERNEL_DIR)/.config timeconst.h
88
$(AUTOCONF): generate-autoconf.py $(KERNEL_DIR)/.config timeconst.h
85
	./generate-autoconf.py $(KERNEL_DIR)/.config > $@
89
	./generate-autoconf.py $(KERNEL_DIR)/.config > $@
90
	cp -u autoconf.h sim/include/generated/autoconf.h
91
	
86
timeconst.h: $(KERNEL_DIR)/.config
92
timeconst.h: $(KERNEL_DIR)/.config
87
	perl $(SRCDIR)$(KERNEL_DIR)/kernel/timeconst.pl $(CONFIG_HZ) > $@
93
	perl $(SRCDIR)$(KERNEL_DIR)/kernel/timeconst.pl $(CONFIG_HZ) > $@
88
linker.lds: ./generate-linker-script.py
94
linker.lds: ./generate-linker-script.py
 Lines 121-137    Link Here 
121
install-dir:
127
install-dir:
122
128
123
setup: $(KERNEL_DIR) .patch.ts $(KERNEL_DIR)/arch/sim
129
setup: $(KERNEL_DIR) .patch.ts $(KERNEL_DIR)/arch/sim
130
.patch.ts: kernel345.patch
131
	CWD=`pwd` && cd $(KERNEL_DIR) && patch -p1 < $$CWD/kernel345.patch && cd $$CWD && touch .patch.ts
132
unpatch: 
133
	CWD=`pwd` && cd $(KERNEL_DIR) && git reset --hard $(KERNEL_VERSION) && cd $$CWD && rm -f .patch.ts
124
$(KERNEL_DIR)/arch/sim:
134
$(KERNEL_DIR)/arch/sim:
125
	if test ! -L $@; then ln -s $(PWD)/sim $(KERNEL_DIR)/arch/sim; fi
135
	if test ! -L $@; then ln -s $(PWD)/sim $(KERNEL_DIR)/arch/sim; fi
126
.patch.ts: kernel.patch
127
	CWD=`pwd` && cd $(KERNEL_DIR) && patch -p1 < $$CWD/kernel.patch && cd $$CWD && touch .patch.ts
128
unpatch: 
129
	CWD=`pwd` && cd $(KERNEL_DIR) && git reset --hard $(KERNEL_VERSION) && cd $$CWD && rm -f .patch.ts
130
$(KERNEL_DIR):
136
$(KERNEL_DIR):
131
	git clone $(KERNEL_DOWNLOAD) $(KERNEL_DIR); cd $(KERNEL_DIR) && git reset --hard \
137
	git clone $(KERNEL_DOWNLOAD) $(KERNEL_DIR); cd $(KERNEL_DIR) && git reset --hard \
132
	$(KERNEL_VERSION)
138
	$(KERNEL_VERSION)
133
ALL_OBJS=$(OBJS) $(KERNEL_LIB) $(modules) $(all-obj-for-clean)
139
ALL_OBJS=$(OBJS) $(KERNEL_LIB) $(modules) $(all-obj-for-clean)
134
clean: unpatch
140
clean:
135
	@for f in $(foreach m,$(modules),$($(m))) ; do rm -f $$f 2>/dev/null; done
141
	@for f in $(foreach m,$(modules),$($(m))) ; do rm -f $$f 2>/dev/null; done
136
	@for f in $(OBJS) $(KERNEL_LIB) $(modules) $(all-obj-for-clean); do rm -f $$f; done 2>/dev/null
142
	@for f in $(OBJS) $(KERNEL_LIB) $(modules) $(all-obj-for-clean); do rm -f $$f; done 2>/dev/null
137
	@rm -rf linker.lds $(AUTOCONF) objs.mk $(KERNEL_DIR)/.config timeconst.h 2>/dev/null
143
	@rm -rf linker.lds $(AUTOCONF) objs.mk $(KERNEL_DIR)/.config timeconst.h 2>/dev/null
(-)84912269f151 (+13 lines)
Added Link Here 
1
diff --git a/include/linux/slab.h b/include/linux/slab.h
2
index a595dce..4a4dea3 100644
3
--- a/include/linux/slab.h
4
+++ b/include/linux/slab.h
5
@@ -185,6 +185,8 @@ size_t ksize(const void *);
6
 #include <linux/slub_def.h>
7
 #elif defined(CONFIG_SLOB)
8
 #include <linux/slob_def.h>
9
+#elif defined(CONFIG_SIM)
10
+#include <asm/slab.h>
11
 #else
12
 #include <linux/slab_def.h>
13
 #endif
(-)84912269f151 (+18 lines)
Added Link Here 
1
#include <asm/atomic.h>
2
#include "sim-assert.h"
3
4
long atomic64_read(const atomic64_t *v)
5
{
6
	return &(v)->counter;
7
}
8
9
long atomic64_add_return(long i, atomic64_t *v)
10
 {
11
	v->counter += i;
12
    return v->counter;
13
 }
14
15
void atomic64_sub(long i, atomic64_t *v)
16
{
17
	v->counter -= i;
18
}
(-)84912269f151 (+85 lines)
Added Link Here 
1
#include <linux/fs.h>
2
#include <linux/dcache.h>
3
#include <linux/slab.h>
4
#include "sim-assert.h"
5
6
static struct kmem_cache *dentry_cache __read_mostly;
7
struct kmem_cache *names_cachep __read_mostly;
8
9
/**
10
 * __d_alloc	-	allocate a dcache entry
11
 * @sb: filesystem it will belong to
12
 * @name: qstr of the name
13
 *
14
 * Allocates a dentry. It returns %NULL if there is insufficient memory
15
 * available. On a success the dentry is returned. The name passed in is
16
 * copied and the copy passed in may be reused after this call.
17
 */
18
struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name)
19
{
20
	struct dentry *dentry;
21
	char *dname;
22
23
	dentry =	dentry =  kmalloc(sizeof (struct dentry), GFP_KERNEL); //  kmem_cache_alloc(dentry_cache, GFP_KERNEL);
24
	if (!dentry)
25
		return NULL;
26
27
	if (name->len > DNAME_INLINE_LEN-1) {
28
		dname = kmalloc(name->len + 1, GFP_KERNEL);
29
		if (!dname) {
30
			kmem_cache_free(dentry_cache, dentry);
31
			return NULL;
32
		}
33
	} else  {
34
		dname = dentry->d_iname;
35
	}
36
	dentry->d_name.name = dname;
37
38
	dentry->d_name.len = name->len;
39
	dentry->d_name.hash = name->hash;
40
	memcpy(dname, name->name, name->len);
41
	dname[name->len] = 0;
42
43
	dentry->d_count = 1;
44
	dentry->d_flags = 0;
45
	spin_lock_init(&dentry->d_lock);
46
	seqcount_init(&dentry->d_seq);
47
	dentry->d_inode = NULL;
48
	dentry->d_parent = dentry;
49
	dentry->d_sb = sb;
50
	dentry->d_op = NULL;
51
	dentry->d_fsdata = NULL;
52
	INIT_HLIST_BL_NODE(&dentry->d_hash);
53
	INIT_LIST_HEAD(&dentry->d_lru);
54
	INIT_LIST_HEAD(&dentry->d_subdirs);
55
	INIT_LIST_HEAD(&dentry->d_alias);
56
	INIT_LIST_HEAD(&dentry->d_u.d_child);
57
	d_set_d_op(dentry, dentry->d_sb->s_d_op);
58
59
//	this_cpu_inc(nr_dentry);
60
61
	return dentry;
62
}
63
64
void d_set_d_op(struct dentry *dentry, const struct dentry_operations *op)
65
{
66
	WARN_ON_ONCE(dentry->d_op);
67
	WARN_ON_ONCE(dentry->d_flags & (DCACHE_OP_HASH	|
68
				DCACHE_OP_COMPARE	|
69
				DCACHE_OP_REVALIDATE	|
70
				DCACHE_OP_DELETE ));
71
	dentry->d_op = op;
72
	if (!op)
73
		return;
74
	if (op->d_hash)
75
		dentry->d_flags |= DCACHE_OP_HASH;
76
	if (op->d_compare)
77
		dentry->d_flags |= DCACHE_OP_COMPARE;
78
	if (op->d_revalidate)
79
		dentry->d_flags |= DCACHE_OP_REVALIDATE;
80
	if (op->d_delete)
81
		dentry->d_flags |= DCACHE_OP_DELETE;
82
	if (op->d_prune)
83
		dentry->d_flags |= DCACHE_OP_PRUNE;
84
85
}
(-)84912269f151 (+17 lines)
Added Link Here 
1
#include "sim.h"
2
#include "sim-assert.h"
3
#include <linux/fs.h>
4
5
6
ssize_t generic_file_aio_read(struct kiocb *a, const struct iovec *b, unsigned long c, loff_t d)
7
{
8
	sim_assert (false);
9
10
	return 0;
11
}
12
13
int generic_file_readonly_mmap(struct file * file, struct vm_area_struct * vma)
14
{
15
	return -ENOSYS;
16
}
17
(-)a/sim/fs.c (-34 / +83 lines)
 Lines 1-13    Link Here 
1
#include <linux/fs.h>
1
#include <linux/fs.h>
2
#include <linux/splice.h>
2
#include <linux/splice.h>
3
#include <linux/mount.h>
3
#include <linux/mount.h>
4
#include <linux/sysctl.h>
5
#include <fs/mount.h>
6
#include <linux/slab.h>
7
#include <linux/backing-dev.h>
8
#include <linux/pagemap.h>
9
#include <linux/user_namespace.h>
10
4
#include "sim-assert.h"
11
#include "sim-assert.h"
5
12
6
struct super_block;
13
struct super_block;
7
void kill_anon_super(struct super_block *sb)
14
8
{
15
struct backing_dev_info default_backing_dev_info = {
9
  sim_assert (false);
16
	.name		= "default",
10
}
17
	.ra_pages	= VM_MAX_READAHEAD * 1024 / PAGE_CACHE_SIZE,
18
	.state		= 0,
19
	.capabilities	= BDI_CAP_MAP_COPY,
20
};
21
struct user_namespace init_user_ns ;
22
11
int get_sb_pseudo(struct file_system_type *type, char *str,
23
int get_sb_pseudo(struct file_system_type *type, char *str,
12
		  const struct super_operations *ops, unsigned long z,
24
		  const struct super_operations *ops, unsigned long z,
13
		  struct vfsmount *mnt)
25
		  struct vfsmount *mnt)
 Lines 39-53    Link Here 
39
{
51
{
40
  memset(inode, 0, sizeof(*inode));
52
  memset(inode, 0, sizeof(*inode));
41
}
53
}
42
struct vfsmount *kern_mount_data(struct file_system_type *fs, void *data)
54
55
// Implementation taken from vfs_kern_mount from linux/namespace.c
56
struct vfsmount *kern_mount_data(struct file_system_type *type, void *data)
43
{
57
{
44
  // minimum stuff needed by the network stack to avoid segfaults.
58
	static struct mount local_mnt;
45
  static struct vfsmount mnt;
59
	struct mount *mnt = &local_mnt;
46
  static struct super_block sb;
60
	struct dentry *root = 0;
47
  mnt.mnt_sb = &sb;
61
48
  // initialize the superblock
62
	memset (mnt,0,sizeof (struct mount));
49
  fs->get_sb (fs, 0, 0, 0, &mnt);
63
	if (!type)
50
  return &mnt;
64
		return ERR_PTR(-ENODEV);
65
	int flags = MS_KERNMOUNT;
66
	char *name = type->name;
67
	if (flags & MS_KERNMOUNT)
68
		mnt->mnt.mnt_flags = MNT_INTERNAL;
69
70
	root = type->mount(type, flags, name, data);
71
	if (IS_ERR(root)) {
72
		return ERR_CAST(root);
73
	}
74
75
	mnt->mnt.mnt_root = root;
76
	mnt->mnt.mnt_sb = root->d_sb;
77
	mnt->mnt_mountpoint = mnt->mnt.mnt_root;
78
	mnt->mnt_parent = mnt;
79
//	br_write_lock(vfsmount_lock);   DCE is monothreaded , so we do not care of lock here
80
	list_add_tail(&mnt->mnt_instance, &root->d_sb->s_mounts);
81
//	br_write_unlock(vfsmount_lock);  DCE is monothreaded , so we do not care of lock here
82
83
	return &mnt->mnt;
51
}
84
}
52
85
53
int register_filesystem(struct file_system_type *fs)
86
int register_filesystem(struct file_system_type *fs)
 Lines 100-106    Link Here 
100
}
133
}
101
void d_instantiate(struct dentry *entry, struct inode *inode)
134
void d_instantiate(struct dentry *entry, struct inode *inode)
102
{
135
{
103
  sim_assert (false);
104
}
136
}
105
char *dynamic_dname(struct dentry *dentry, char *buffer, int buflen,
137
char *dynamic_dname(struct dentry *dentry, char *buffer, int buflen,
106
		    const char *fmt, ...)
138
		    const char *fmt, ...)
 Lines 134-175    Link Here 
134
  sim_assert (false);
166
  sim_assert (false);
135
  return 0;
167
  return 0;
136
}
168
}
137
loff_t no_llseek(struct file *file, loff_t offset, int origin)
138
{
139
  sim_assert (false);
140
  return 0;
141
}
142
void path_put(struct path *path)
143
{
144
  sim_assert (false);
145
}
146
int simple_statfs(struct dentry *entry, struct kstatfs *statfs)
147
{
148
  sim_assert (false);
149
  return 0;
150
}
151
long sys_close(unsigned int fd)
169
long sys_close(unsigned int fd)
152
{
170
{
153
  sim_assert (false);
171
  sim_assert (false);
154
  return 0;
172
  return 0;
155
}
173
}
156
157
ssize_t splice_to_pipe(struct pipe_inode_info *info,
174
ssize_t splice_to_pipe(struct pipe_inode_info *info,
158
		       struct splice_pipe_desc *desc)
175
		       struct splice_pipe_desc *desc)
159
{
176
{
160
  sim_assert (false);
177
  sim_assert (false);
161
  return 0;
178
  return 0;
162
}
179
}
163
int splice_grow_spd(struct pipe_inode_info *info, struct splice_pipe_desc *desc)
180
int splice_grow_spd(const struct pipe_inode_info *info, struct splice_pipe_desc *desc)
164
{
181
{
165
  sim_assert (false);
182
  sim_assert (false);
166
  return 0;
183
  return 0;
167
}
184
}
168
void splice_shrink_spd(struct pipe_inode_info *info,
185
void splice_shrink_spd(struct splice_pipe_desc *desc)
169
		       struct splice_pipe_desc *desc)
170
{
186
{
171
  sim_assert (false);
187
  sim_assert (false);
172
  return 0;
173
}
188
}
174
189
175
ssize_t generic_splice_sendpage(struct pipe_inode_info *pipe,
190
ssize_t generic_splice_sendpage(struct pipe_inode_info *pipe,
 Lines 192-197    Link Here 
192
207
193
int generic_pipe_buf_confirm(struct pipe_inode_info *pipe, struct pipe_buffer *buf)
208
int generic_pipe_buf_confirm(struct pipe_inode_info *pipe, struct pipe_buffer *buf)
194
{
209
{
195
  sim_assert (false);
210
	  sim_assert (false);
196
  return 0;
211
	  return 0;
197
}
212
}
213
214
int proc_nr_inodes(ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos)
215
{
216
	  sim_assert (false);
217
	  return 0;
218
}
219
220
int proc_nr_dentry(ctl_table *table, int write, void __user *buffer,
221
		   size_t *lenp, loff_t *ppos)
222
{
223
	sim_assert (false);
224
		  return 0;
225
}
226
227
/*
228
 * Handle writeback of dirty data for the device backed by this bdi. Also
229
 * wakes up periodically and does kupdated style flushing.
230
 */
231
int bdi_writeback_thread(void *data)
232
{
233
	sim_assert (false);
234
235
	return 0;
236
}
237
238
void get_filesystem(struct file_system_type *fs)
239
{
240
	return;
241
}
242
//#include <fs/proc/proc_sysctl.c>
243
unsigned int nr_free_buffer_pages(void)
244
{
245
	return 1024;
246
}
(-)a/sim/glue.c (-3 / +8 lines)
 Lines 49-54    Link Here 
49
// XXX figure out initial value
49
// XXX figure out initial value
50
unsigned int interrupt_pending = 0;
50
unsigned int interrupt_pending = 0;
51
static unsigned long g_irqflags = 0;
51
static unsigned long g_irqflags = 0;
52
static unsigned long local_irqflags = 0;
52
int overflowgid = 0;
53
int overflowgid = 0;
53
int overflowuid = 0;
54
int overflowuid = 0;
54
int fs_overflowgid = 0;
55
int fs_overflowgid = 0;
 Lines 58-68    Link Here 
58
{
59
{
59
  return g_irqflags;
60
  return g_irqflags;
60
}
61
}
61
void raw_local_irq_restore(unsigned long flags)
62
unsigned long arch_local_save_flags(void)
62
{
63
{
63
  g_irqflags = flags;
64
	return local_irqflags;
64
}
65
}
65
66
void arch_local_irq_restore(unsigned long flags)
67
{
68
	local_irqflags = flags;
69
}
66
70
67
int in_egroup_p(gid_t grp)
71
int in_egroup_p(gid_t grp)
68
{
72
{
 Lines 289-291    Link Here 
289
void add_taint(unsigned flag)
293
void add_taint(unsigned flag)
290
{}
294
{}
291
struct pid *cad_pid = 0;
295
struct pid *cad_pid = 0;
296
(-)a/sim/hrtimer.c (-2 / +1 lines)
 Lines 19-25    Link Here 
19
  enum hrtimer_restart restart = timer->function (timer);
19
  enum hrtimer_restart restart = timer->function (timer);
20
  if (restart == HRTIMER_RESTART)
20
  if (restart == HRTIMER_RESTART)
21
    {
21
    {
22
      void *event = sim_event_schedule_ns (ktime_to_ns (timer->_expires),
22
      void *event = sim_event_schedule_ns (ktime_to_ns (timer->_softexpires),
23
						  &trampoline, timer);
23
						  &trampoline, timer);
24
      timer->base = event;
24
      timer->base = event;
25
    }
25
    }
 Lines 50-56    Link Here 
50
    {
50
    {
51
      ns -= sim_current_ns ();
51
      ns -= sim_current_ns ();
52
    }
52
    }
53
  timer->_expires = ns_to_ktime (ns);
54
  timer->_softexpires = ns_to_ktime (ns);
53
  timer->_softexpires = ns_to_ktime (ns);
55
  void *event = sim_event_schedule_ns (ns, &trampoline, timer);
54
  void *event = sim_event_schedule_ns (ns, &trampoline, timer);
56
  timer->base = event;
55
  timer->base = event;
(-)84912269f151 (+2 lines)
Added Link Here 
1
#include <asm-generic/barrier.h>
2
(-)a/sim/include/asm/irqflags.h (-2 lines)
 Lines 2-11    Link Here 
2
#define _ASM_SIM_IRQFLAGS_H
2
#define _ASM_SIM_IRQFLAGS_H
3
3
4
unsigned long __raw_local_save_flags(void);
4
unsigned long __raw_local_save_flags(void);
5
void raw_local_irq_restore(unsigned long flags);
6
5
7
#define __raw_local_save_flags __raw_local_save_flags
6
#define __raw_local_save_flags __raw_local_save_flags
8
#define raw_local_irq_restore raw_local_irq_restore
9
7
10
#include <asm-generic/irqflags.h>
8
#include <asm-generic/irqflags.h>
11
9
(-)a/sim/include/asm/slab.h (-2 lines)
 Lines 5-10    Link Here 
5
void *__kmalloc(size_t size, gfp_t flags);
5
void *__kmalloc(size_t size, gfp_t flags);
6
void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
6
void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
7
7
8
#define ARCH_KMALLOC_MINALIGN __alignof__(unsigned long)
9
10
#endif /* _ASM_SIM_SLAB_H */
8
#endif /* _ASM_SIM_SLAB_H */
(-)84912269f151 (+238 lines)
Added Link Here 
1
#define CONFIG_SIM 1
2
#define CONFIG_EXPERIMENTAL 1
3
#define CONFIG_KTIME_SCALAR 1
4
#define CONFIG_MODULES 1
5
#define CONFIG_GENERIC_CSUM 1
6
#define CONFIG_PRINTK 1
7
#define CONFIG_RWSEM_GENERIC_SPINLOCK 1
8
#define CONFIG_GENERIC_FIND_NEXT_BIT 1
9
#define CONFIG_GENERIC_HWEIGHT 1
10
#define CONFIG_TRACE_IRQFLAGS_SUPPORT 1
11
#define CONFIG_NO_HZ 1
12
#define CONFIG_HZ 250
13
#define CONFIG_TINY_RCU 1
14
#define CONFIG_HZ_250 1
15
#define CONFIG_BASE_SMALL 1
16
#define CONFIG_SPLIT_PTLOCK_CPUS 1
17
#define CONFIG_FLATMEM 1
18
#define CONFIG_SYSCTL 1
19
#define CONFIG_PROC_FS 1
20
#define CONFIG_SYSFS 1
21
#define CONFIG_PROC_SYSCTL 1
22
#define CONFIG_NET 1
23
#define CONFIG_PACKET 1
24
#define CONFIG_UNIX 1
25
#define CONFIG_XFRM 1
26
#define CONFIG_XFRM_USER 1
27
#define CONFIG_XFRM_SUB_POLICY 1
28
#define CONFIG_XFRM_MIGRATE 1
29
#define CONFIG_XFRM_STATISTICS 1
30
#define CONFIG_XFRM_IPCOMP_MODULE 1
31
#define CONFIG_NET_KEY 1
32
#define CONFIG_NET_KEY_MIGRATE 1
33
#define CONFIG_INET 1
34
#define CONFIG_IP_MULTICAST 1
35
#define CONFIG_IP_ADVANCED_ROUTER 1
36
#define CONFIG_IP_MULTIPLE_TABLES 1
37
#define CONFIG_IP_ROUTE_MULTIPATH 1
38
#define CONFIG_IP_ROUTE_VERBOSE 1
39
#define CONFIG_NET_IPIP_MODULE 1
40
#define CONFIG_IP_MROUTE 1
41
#define CONFIG_IP_MROUTE_MULTIPLE_TABLES 1
42
#define CONFIG_IP_PIMSM_V1 1
43
#define CONFIG_IP_PIMSM_V2 1
44
#define CONFIG_ARPD 1
45
#define CONFIG_SYN_COOKIES 1
46
#define CONFIG_INET_AH_MODULE 1
47
#define CONFIG_INET_ESP_MODULE 1
48
#define CONFIG_INET_IPCOMP_MODULE 1
49
#define CONFIG_INET_XFRM_TUNNEL_MODULE 1
50
#define CONFIG_INET_TUNNEL 1
51
#define CONFIG_INET_XFRM_MODE_TRANSPORT 1
52
#define CONFIG_INET_XFRM_MODE_TUNNEL 1
53
#define CONFIG_INET_XFRM_MODE_BEET 1
54
#define CONFIG_INET_DIAG_MODULE 1
55
#define CONFIG_INET_TCP_DIAG_MODULE 1
56
#define CONFIG_TCP_CONG_ADVANCED 1
57
#define CONFIG_TCP_CONG_BIC_MODULE 1
58
#define CONFIG_TCP_CONG_CUBIC_MODULE 1
59
#define CONFIG_TCP_CONG_WESTWOOD_MODULE 1
60
#define CONFIG_TCP_CONG_HTCP_MODULE 1
61
#define CONFIG_DEFAULT_RENO 1
62
#define CONFIG_DEFAULT_TCP_CONG "reno"
63
#define CONFIG_IPV6 1
64
#define CONFIG_IPV6_PRIVACY 1
65
#define CONFIG_IPV6_ROUTER_PREF 1
66
#define CONFIG_INET6_AH_MODULE 1
67
#define CONFIG_INET6_ESP_MODULE 1
68
#define CONFIG_INET6_IPCOMP_MODULE 1
69
#define CONFIG_IPV6_MIP6 1
70
#define CONFIG_INET6_XFRM_TUNNEL_MODULE 1
71
#define CONFIG_INET6_TUNNEL 1
72
#define CONFIG_INET6_XFRM_MODE_TRANSPORT 1
73
#define CONFIG_INET6_XFRM_MODE_TUNNEL 1
74
#define CONFIG_INET6_XFRM_MODE_BEET 1
75
#define CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION 1
76
#define CONFIG_IPV6_SIT 1
77
#define CONFIG_IPV6_NDISC_NODETYPE 1
78
#define CONFIG_IPV6_TUNNEL 1
79
#define CONFIG_IPV6_MULTIPLE_TABLES 1
80
#define CONFIG_IPV6_SUBTREES 1
81
#define CONFIG_ATM_MODULE 1
82
#define CONFIG_ATM_CLIP_MODULE 1
83
#define CONFIG_ATM_CLIP_NO_ICMP 1
84
#define CONFIG_ATM_LANE_MODULE 1
85
#define CONFIG_ATM_MPOA_MODULE 1
86
#define CONFIG_ATM_BR2684_MODULE 1
87
#define CONFIG_ATM_BR2684_IPFILTER 1
88
#define CONFIG_L2TP_MODULE 1
89
#define CONFIG_STP_MODULE 1
90
#define CONFIG_GARP_MODULE 1
91
#define CONFIG_BRIDGE_MODULE 1
92
#define CONFIG_BRIDGE_IGMP_SNOOPING 1
93
#define CONFIG_VLAN_8021Q_MODULE 1
94
#define CONFIG_VLAN_8021Q_GVRP 1
95
#define CONFIG_DECNET_MODULE 1
96
#define CONFIG_LLC_MODULE 1
97
#define CONFIG_LLC2_MODULE 1
98
#define CONFIG_IPX_MODULE 1
99
#define CONFIG_IPX_INTERN 1
100
#define CONFIG_ATALK_MODULE 1
101
#define CONFIG_DEV_APPLETALK_MODULE 1
102
#define CONFIG_IPDDP_MODULE 1
103
#define CONFIG_IPDDP_ENCAP 1
104
#define CONFIG_IPDDP_DECAP 1
105
#define CONFIG_PHONET_MODULE 1
106
#define CONFIG_BQL 1
107
#define CONFIG_NET_PKTGEN_MODULE 1
108
#define CONFIG_CAN_MODULE 1
109
#define CONFIG_CAN_RAW_MODULE 1
110
#define CONFIG_CAN_BCM_MODULE 1
111
#define CONFIG_CAN_VCAN_MODULE 1
112
#define CONFIG_CAN_DEV_MODULE 1
113
#define CONFIG_CAN_CALC_BITTIMING 1
114
#define CONFIG_CAN_SJA1000_MODULE 1
115
#define CONFIG_CAN_SJA1000_PLATFORM_MODULE 1
116
#define CONFIG_CAN_DEBUG_DEVICES 1
117
#define CONFIG_IRDA_MODULE 1
118
#define CONFIG_IRLAN_MODULE 1
119
#define CONFIG_IRCOMM_MODULE 1
120
#define CONFIG_IRDA_ULTRA 1
121
#define CONFIG_IRDA_CACHE_LAST_LSAP 1
122
#define CONFIG_IRDA_FAST_RR 1
123
#define CONFIG_IRDA_DEBUG 1
124
#define CONFIG_IRTTY_SIR_MODULE 1
125
#define CONFIG_DONGLE 1
126
#define CONFIG_ESI_DONGLE_MODULE 1
127
#define CONFIG_ACTISYS_DONGLE_MODULE 1
128
#define CONFIG_TEKRAM_DONGLE_MODULE 1
129
#define CONFIG_TOIM3232_DONGLE_MODULE 1
130
#define CONFIG_LITELINK_DONGLE_MODULE 1
131
#define CONFIG_BT_MODULE 1
132
#define CONFIG_BT_RFCOMM_MODULE 1
133
#define CONFIG_BT_RFCOMM_TTY 1
134
#define CONFIG_BT_BNEP_MODULE 1
135
#define CONFIG_BT_BNEP_MC_FILTER 1
136
#define CONFIG_BT_BNEP_PROTO_FILTER 1
137
#define CONFIG_BT_HCIUART_MODULE 1
138
#define CONFIG_BT_HCIUART_H4 1
139
#define CONFIG_BT_HCIUART_BCSP 1
140
#define CONFIG_BT_HCIUART_LL 1
141
#define CONFIG_BT_HCIVHCI_MODULE 1
142
#define CONFIG_BT_MRVL_MODULE 1
143
#define CONFIG_FIB_RULES 1
144
#define CONFIG_WIMAX_MODULE 1
145
#define CONFIG_WIMAX_DEBUG_LEVEL 8
146
#define CONFIG_RFKILL_MODULE 1
147
#define CONFIG_CAIF_MODULE 1
148
#define CONFIG_CAIF_DEBUG 1
149
#define CONFIG_CAIF_NETDEV_MODULE 1
150
#define CONFIG_STANDALONE 1
151
#define CONFIG_PREVENT_FIRMWARE_BUILD 1
152
#define CONFIG_FW_LOADER 1
153
#define CONFIG_FIRMWARE_IN_KERNEL 1
154
#define CONFIG_EXTRA_FIRMWARE ""
155
#define CONFIG_CRYPTO 1
156
#define CONFIG_CRYPTO_ALGAPI_MODULE 1
157
#define CONFIG_CRYPTO_ALGAPI2_MODULE 1
158
#define CONFIG_CRYPTO_AEAD_MODULE 1
159
#define CONFIG_CRYPTO_AEAD2_MODULE 1
160
#define CONFIG_CRYPTO_BLKCIPHER_MODULE 1
161
#define CONFIG_CRYPTO_BLKCIPHER2_MODULE 1
162
#define CONFIG_CRYPTO_HASH_MODULE 1
163
#define CONFIG_CRYPTO_HASH2_MODULE 1
164
#define CONFIG_CRYPTO_RNG_MODULE 1
165
#define CONFIG_CRYPTO_RNG2_MODULE 1
166
#define CONFIG_CRYPTO_PCOMP_MODULE 1
167
#define CONFIG_CRYPTO_PCOMP2_MODULE 1
168
#define CONFIG_CRYPTO_MANAGER_MODULE 1
169
#define CONFIG_CRYPTO_MANAGER2_MODULE 1
170
#define CONFIG_CRYPTO_MANAGER_DISABLE_TESTS 1
171
#define CONFIG_CRYPTO_GF128MUL_MODULE 1
172
#define CONFIG_CRYPTO_NULL_MODULE 1
173
#define CONFIG_CRYPTO_WORKQUEUE_MODULE 1
174
#define CONFIG_CRYPTO_CRYPTD_MODULE 1
175
#define CONFIG_CRYPTO_AUTHENC_MODULE 1
176
#define CONFIG_CRYPTO_TEST_MODULE 1
177
#define CONFIG_CRYPTO_CCM_MODULE 1
178
#define CONFIG_CRYPTO_GCM_MODULE 1
179
#define CONFIG_CRYPTO_SEQIV_MODULE 1
180
#define CONFIG_CRYPTO_CBC_MODULE 1
181
#define CONFIG_CRYPTO_CTR_MODULE 1
182
#define CONFIG_CRYPTO_CTS_MODULE 1
183
#define CONFIG_CRYPTO_ECB_MODULE 1
184
#define CONFIG_CRYPTO_PCBC_MODULE 1
185
#define CONFIG_CRYPTO_HMAC_MODULE 1
186
#define CONFIG_CRYPTO_CRC32C_MODULE 1
187
#define CONFIG_CRYPTO_GHASH_MODULE 1
188
#define CONFIG_CRYPTO_MD4_MODULE 1
189
#define CONFIG_CRYPTO_MD5_MODULE 1
190
#define CONFIG_CRYPTO_MICHAEL_MIC_MODULE 1
191
#define CONFIG_CRYPTO_RMD128_MODULE 1
192
#define CONFIG_CRYPTO_RMD160_MODULE 1
193
#define CONFIG_CRYPTO_RMD256_MODULE 1
194
#define CONFIG_CRYPTO_RMD320_MODULE 1
195
#define CONFIG_CRYPTO_SHA1_MODULE 1
196
#define CONFIG_CRYPTO_SHA256_MODULE 1
197
#define CONFIG_CRYPTO_SHA512_MODULE 1
198
#define CONFIG_CRYPTO_TGR192_MODULE 1
199
#define CONFIG_CRYPTO_WP512_MODULE 1
200
#define CONFIG_CRYPTO_AES_MODULE 1
201
#define CONFIG_CRYPTO_ANUBIS_MODULE 1
202
#define CONFIG_CRYPTO_ARC4_MODULE 1
203
#define CONFIG_CRYPTO_BLOWFISH_MODULE 1
204
#define CONFIG_CRYPTO_BLOWFISH_COMMON_MODULE 1
205
#define CONFIG_CRYPTO_CAMELLIA_MODULE 1
206
#define CONFIG_CRYPTO_CAST5_MODULE 1
207
#define CONFIG_CRYPTO_CAST6_MODULE 1
208
#define CONFIG_CRYPTO_DES_MODULE 1
209
#define CONFIG_CRYPTO_FCRYPT_MODULE 1
210
#define CONFIG_CRYPTO_KHAZAD_MODULE 1
211
#define CONFIG_CRYPTO_SEED_MODULE 1
212
#define CONFIG_CRYPTO_SERPENT_MODULE 1
213
#define CONFIG_CRYPTO_TEA_MODULE 1
214
#define CONFIG_CRYPTO_TWOFISH_MODULE 1
215
#define CONFIG_CRYPTO_TWOFISH_COMMON_MODULE 1
216
#define CONFIG_CRYPTO_DEFLATE_MODULE 1
217
#define CONFIG_CRYPTO_ZLIB_MODULE 1
218
#define CONFIG_CRYPTO_LZO_MODULE 1
219
#define CONFIG_CRYPTO_ANSI_CPRNG_MODULE 1
220
#define CONFIG_CRYPTO_HW 1
221
#define CONFIG_BITREVERSE_MODULE 1
222
#define CONFIG_GENERIC_IO 1
223
#define CONFIG_CRC_CCITT_MODULE 1
224
#define CONFIG_CRC16_MODULE 1
225
#define CONFIG_CRC_T10DIF_MODULE 1
226
#define CONFIG_CRC_ITU_T_MODULE 1
227
#define CONFIG_CRC32_MODULE 1
228
#define CONFIG_CRC32_SLICEBY8 1
229
#define CONFIG_CRC7_MODULE 1
230
#define CONFIG_LIBCRC32C_MODULE 1
231
#define CONFIG_ZLIB_INFLATE_MODULE 1
232
#define CONFIG_ZLIB_DEFLATE_MODULE 1
233
#define CONFIG_LZO_COMPRESS_MODULE 1
234
#define CONFIG_LZO_DECOMPRESS_MODULE 1
235
#define CONFIG_HAS_IOMEM 1
236
#define CONFIG_HAS_IOPORT 1
237
#define CONFIG_DQL 1
238
#define CONFIG_NLATTR 1
(-)84912269f151 (+154 lines)
Added Link Here 
1
#include <linux/fs.h>
2
#include <linux/slab.h>
3
#include <linux/dcache.h>
4
#include <linux/security.h>
5
#include <linux/pagemap.h>
6
#include <linux/backing-dev.h>
7
8
9
static struct kmem_cache *inode_cachep __read_mostly;
10
/*
11
 * Empty aops. Can be used for the cases where the user does not
12
 * define any of the address_space operations.
13
 */
14
const struct address_space_operations empty_aops = {
15
};
16
17
unsigned int get_next_ino(void)
18
{
19
	static unsigned int res = 0;
20
21
	return ++res;
22
}
23
24
/**
25
 * inode_init_always - perform inode structure intialisation
26
 * @sb: superblock inode belongs to
27
 * @inode: inode to initialise
28
 *
29
 * These are initializations that need to be done on every inode
30
 * allocation as the fields are not initialised by slab allocation.
31
 */
32
int inode_init_always(struct super_block *sb, struct inode *inode)
33
{
34
	static const struct inode_operations empty_iops;
35
	static const struct file_operations empty_fops;
36
	struct address_space *const mapping = &inode->i_data;
37
38
	inode->i_sb = sb;
39
	inode->i_blkbits = sb->s_blocksize_bits;
40
	inode->i_flags = 0;
41
	atomic_set(&inode->i_count, 1);
42
	inode->i_op = &empty_iops;
43
	inode->i_fop = &empty_fops;
44
	inode->__i_nlink = 1;
45
	inode->i_opflags = 0;
46
	inode->i_uid = 0;
47
	inode->i_gid = 0;
48
	atomic_set(&inode->i_writecount, 0);
49
	inode->i_size = 0;
50
	inode->i_blocks = 0;
51
	inode->i_bytes = 0;
52
	inode->i_generation = 0;
53
#ifdef CONFIG_QUOTA
54
	memset(&inode->i_dquot, 0, sizeof(inode->i_dquot));
55
#endif
56
	inode->i_pipe = NULL;
57
	inode->i_bdev = NULL;
58
	inode->i_cdev = NULL;
59
	inode->i_rdev = 0;
60
	inode->dirtied_when = 0;
61
62
	if (security_inode_alloc(inode))
63
		goto out;
64
	spin_lock_init(&inode->i_lock);
65
	lockdep_set_class(&inode->i_lock, &sb->s_type->i_lock_key);
66
67
	mutex_init(&inode->i_mutex);
68
	lockdep_set_class(&inode->i_mutex, &sb->s_type->i_mutex_key);
69
70
	atomic_set(&inode->i_dio_count, 0);
71
72
	mapping->a_ops = &empty_aops;
73
	mapping->host = inode;
74
	mapping->flags = 0;
75
	mapping_set_gfp_mask(mapping, GFP_HIGHUSER_MOVABLE);
76
	mapping->assoc_mapping = NULL;
77
	mapping->backing_dev_info = &default_backing_dev_info;
78
	mapping->writeback_index = 0;
79
80
	/*
81
	 * If the block_device provides a backing_dev_info for client
82
	 * inodes then use that.  Otherwise the inode share the bdev's
83
	 * backing_dev_info.
84
	 */
85
	if (sb->s_bdev) {
86
		struct backing_dev_info *bdi;
87
88
		bdi = sb->s_bdev->bd_inode->i_mapping->backing_dev_info;
89
		mapping->backing_dev_info = bdi;
90
	}
91
	inode->i_private = NULL;
92
	inode->i_mapping = mapping;
93
	INIT_LIST_HEAD(&inode->i_dentry);	/* buggered by rcu freeing */
94
#ifdef CONFIG_FS_POSIX_ACL
95
	inode->i_acl = inode->i_default_acl = ACL_NOT_CACHED;
96
#endif
97
98
#ifdef CONFIG_FSNOTIFY
99
	inode->i_fsnotify_mask = 0;
100
#endif
101
102
//	this_cpu_inc(nr_inodes);
103
104
	return 0;
105
out:
106
	return -ENOMEM;
107
}
108
109
110
static struct inode *alloc_inode(struct super_block *sb)
111
{
112
	struct inode *inode;
113
114
	if (sb->s_op->alloc_inode)
115
		inode = sb->s_op->alloc_inode(sb);
116
	else
117
		inode = kmem_cache_alloc(inode_cachep, GFP_KERNEL);
118
119
	if (!inode)
120
		return NULL;
121
122
	if (unlikely(inode_init_always(sb, inode))) {
123
		if (inode->i_sb->s_op->destroy_inode)
124
			inode->i_sb->s_op->destroy_inode(inode);
125
		else
126
			kmem_cache_free(inode_cachep, inode);
127
		return NULL;
128
	}
129
130
	return inode;
131
}
132
133
/**
134
 *	new_inode_pseudo 	- obtain an inode
135
 *	@sb: superblock
136
 *
137
 *	Allocates a new inode for given superblock.
138
 *	Inode wont be chained in superblock s_inodes list
139
 *	This means :
140
 *	- fs can't be unmount
141
 *	- quotas, fsnotify, writeback can't work
142
 */
143
struct inode *new_inode_pseudo(struct super_block *sb)
144
{
145
	struct inode *inode = alloc_inode(sb);
146
147
	if (inode) {
148
		spin_lock(&inode->i_lock);
149
		inode->i_state = 0;
150
		spin_unlock(&inode->i_lock);
151
		INIT_LIST_HEAD(&inode->i_sb_list);
152
	}
153
	return inode;
154
}
(-)a/sim/modules.c (-1 / +33 lines)
 Lines 1-6    Link Here 
1
#include "sim-assert.h"
1
#include "sim-assert.h"
2
#include <linux/moduleparam.h>
2
#include <linux/moduleparam.h>
3
#include <linux/kmod.h>
3
#include <linux/kmod.h>
4
#include <linux/module.h>
4
5
5
int modules_disabled = 0;
6
int modules_disabled = 0;
6
char modprobe_path[KMOD_PATH_LEN] = "/sbin/modprobe";
7
char modprobe_path[KMOD_PATH_LEN] = "/sbin/modprobe";
 Lines 11-19    Link Here 
11
struct kernel_param *__start___param = &g_empty_param_buffer;
12
struct kernel_param *__start___param = &g_empty_param_buffer;
12
struct kernel_param *__stop___param = &g_empty_param_buffer;
13
struct kernel_param *__stop___param = &g_empty_param_buffer;
13
14
15
const struct module_version_attribute no_modules[1] = {
16
		{
17
		.mattr	= {
18
			.attr	= {
19
				.name	= "version",
20
				.mode	= S_IRUGO,
21
			},
22
			.show	= __modver_version_show,
23
		},
24
		.module_name	= KBUILD_MODNAME,
25
		.version	= "V0",
26
	}
27
};
28
29
const struct module_version_attribute **__start___modver = &no_modules;
30
const struct module_version_attribute **__stop___modver  = &no_modules;
31
32
static ssize_t store_uevent(struct module_attribute *mattr,
33
			    struct module_kobject *mk,
34
			    const char *buffer, size_t count)
35
{
36
	sim_assert (false);
37
	return 0;
38
}
39
40
struct module_attribute module_uevent =
41
	__ATTR(uevent, 0200, NULL, store_uevent);
42
14
int __request_module(bool wait, const char *fmt, ...)
43
int __request_module(bool wait, const char *fmt, ...)
15
{
44
{
16
  // we really should never be trying to load modules that way.
45
  // we really should never be trying to load modules that way.
17
  sim_assert (false);
18
  return 0;
46
  return 0;
19
}
47
}
48
49
struct ctl_table usermodehelper_table[] = {
50
	{ }
51
};
(-)a/sim/print.c (+2 lines)
 Lines 3-8    Link Here 
3
#include "sim.h"
3
#include "sim.h"
4
#include "sim-assert.h"
4
#include "sim-assert.h"
5
5
6
int dmesg_restrict = 1;
7
6
int printk(const char * fmt, ...)
8
int printk(const char * fmt, ...)
7
{
9
{
8
  va_list args;
10
  va_list args;
(-)a/sim/proc.c (-32 / +39 lines)
 Lines 5-28    Link Here 
5
#include <linux/string.h>
5
#include <linux/string.h>
6
#include <net/net_namespace.h>
6
#include <net/net_namespace.h>
7
#include "sim-types.h"
7
#include "sim-types.h"
8
#include "sim-assert.h"
8
9
9
static struct proc_dir_entry proc_root;
10
static char proc_root_data[sizeof(struct proc_dir_entry)+4];
11
12
static struct proc_dir_entry *proc_root  = (struct proc_dir_entry *) proc_root_data;
10
13
11
void sim_proc_net_initialize(void)
14
void sim_proc_net_initialize(void)
12
{
15
{
13
  proc_root.parent = &proc_root;
16
  proc_root->parent = proc_root;
14
  proc_root.name = "net";
17
  strcpy ( proc_root->name , "net");
15
  proc_root.mode = S_IFDIR | S_IRUGO | S_IXUGO;
18
  proc_root->mode = S_IFDIR | S_IRUGO | S_IXUGO;
16
  proc_root.next = 0;
19
  proc_root->next = 0;
17
  proc_root.subdir = 0;
20
  proc_root->subdir = 0;
18
  init_net.proc_net = &proc_root;
21
  init_net.proc_net = proc_root;
19
  init_net.proc_net_stat = proc_mkdir("stat", &proc_root);
22
  init_net.proc_net_stat = proc_mkdir("stat", proc_root);
20
}
23
}
21
22
struct proc_dir_entry *
24
struct proc_dir_entry *
23
proc_net_fops_create(struct net *net,
25
proc_net_fops_create(struct net *net,
24
		     const char *name, 
26
		     const char *name, 
25
		     mode_t mode, const struct file_operations *fops)
27
		     umode_t mode, const struct file_operations *fops)
26
{
28
{
27
  return proc_create_data (name, mode, net->proc_net, fops, 0);
29
  return proc_create_data (name, mode, net->proc_net, fops, 0);
28
}
30
}
 Lines 32-39    Link Here 
32
		  struct proc_dir_entry *parent)
34
		  struct proc_dir_entry *parent)
33
{
35
{
34
  // insert new entry at head of subdir list in parent
36
  // insert new entry at head of subdir list in parent
35
  struct proc_dir_entry * child = kzalloc (sizeof(struct proc_dir_entry), GFP_KERNEL);
37
  struct proc_dir_entry * child = kzalloc (sizeof(struct proc_dir_entry)
36
  child->name = kstrdup (name, GFP_KERNEL);
38
		  + strlen (name) + 1
39
		  , GFP_KERNEL);
40
41
  strcpy ( child->name, name );
42
37
  child->namelen = strlen (name);
43
  child->namelen = strlen (name);
38
  child->parent = parent;
44
  child->parent = parent;
39
  if (parent == 0)
45
  if (parent == 0)
 Lines 45-80    Link Here 
45
  parent->subdir = child;
51
  parent->subdir = child;
46
  return child;
52
  return child;
47
}
53
}
48
54
struct proc_dir_entry *proc_create_data(const char *name, umode_t mode,
49
struct proc_dir_entry *proc_create_data(const char *name, mode_t mode,
55
				struct proc_dir_entry *parent,
50
                                        struct proc_dir_entry *parent,
56
				const struct file_operations *proc_fops,
51
                                        const struct file_operations *proc_fops,
57
				void *data)
52
                                        void *data)
53
{
58
{
54
  struct proc_dir_entry *de = proc_create_entry (name, mode, parent);
59
  struct proc_dir_entry *de = proc_create_entry (name, mode, parent);
55
  de->proc_fops = proc_fops;
60
  de->proc_fops = proc_fops;
56
  de->data = data;
61
  de->data = data;
57
  return de;
62
  return de;
58
}
63
}
59
struct proc_dir_entry *proc_mkdir(const char *name,
60
				  struct proc_dir_entry *parent)
61
{
62
  return proc_create_entry (name, S_IRUGO | S_IXUGO, parent);
63
}
64
void remove_proc_entry(const char *name, struct proc_dir_entry *parent)
64
void remove_proc_entry(const char *name, struct proc_dir_entry *parent)
65
{
65
{
66
  struct proc_dir_entry   *de, **prev;
66
	struct proc_dir_entry   *de, **prev;
67
  for (de = parent->subdir, prev = &parent->subdir; de ; prev = &de->next, de = de->next) 
67
	for (de = parent->subdir, prev = &parent->subdir; de ; prev = &de->next, de = de->next)
68
    {
69
      if (strcmp (name, de->name) == 0)
70
	{
68
	{
71
	  *prev = de->next;
69
		if (strcmp (name, de->name) == 0)
72
	  kfree (de->name);
70
		{
73
	  kfree (de);
71
			*prev = de->next;
74
	  break;
72
			kfree (de->name);
73
			kfree (de);
74
			break;
75
		}
75
	}
76
	}
76
    }
77
78
}
77
}
79
void proc_net_remove(struct net *net, const char *name)
78
void proc_net_remove(struct net *net, const char *name)
80
{
79
{
 Lines 85-87    Link Here 
85
{
84
{
86
  return -ENOSYS;
85
  return -ENOSYS;
87
}
86
}
87
88
struct proc_dir_entry *proc_mkdir(const char *name,
89
				  struct proc_dir_entry *parent)
90
{
91
  return proc_create_entry (name, S_IRUGO | S_IXUGO, parent);
92
}
93
94
(-)a/sim/random.c (-29 lines)
 Lines 1-35    Link Here 
1
#include "sim.h"
1
#include "sim.h"
2
#include <linux/random.h>
2
#include <linux/random.h>
3
3
4
__u32 secure_tcpv6_sequence_number(__be32 *saddr, __be32 *daddr,
5
                                   __be16 sport, __be16 dport)
6
{
7
  return sim_random ();
8
}
9
__u32 secure_ip_id(__be32 daddr)
10
{
11
  return sim_random ();
12
}
13
__u32 secure_tcp_sequence_number(__be32 saddr, __be32 daddr,
14
                                 __be16 sport, __be16 dport)
15
{
16
  return sim_random ();
17
}
18
u64 secure_dccp_sequence_number(__be32 saddr, __be32 daddr,
19
                                __be16 sport, __be16 dport)
20
{
21
  return sim_random ();
22
}
23
24
u32 secure_ipv4_port_ephemeral(__be32 saddr, __be32 daddr, __be16 dport)
25
{
26
  return sim_random ();
27
}
28
u32 secure_ipv6_port_ephemeral(const __be32 *saddr, const __be32 *daddr,
29
                               __be16 dport)
30
{
31
  return sim_random ();
32
}
33
u32 random32(void)
4
u32 random32(void)
34
{
5
{
35
  return sim_random ();
6
  return sim_random ();
(-)a/sim/sched.c (-7 / +4 lines)
 Lines 148-154    Link Here 
148
  return ret;
148
  return ret;
149
}
149
}
150
150
151
void __init_waitqueue_head(wait_queue_head_t *q, struct lock_class_key *key)
151
void __init_waitqueue_head(wait_queue_head_t *q, const char *name, struct lock_class_key *k)
152
{
152
{
153
  INIT_LIST_HEAD(&q->task_list);
153
  INIT_LIST_HEAD(&q->task_list);
154
}
154
}
 Lines 273-280    Link Here 
273
  x->done++;
273
  x->done++;
274
  __wake_up(&x->wait, TASK_NORMAL, 1, 0);
274
  __wake_up(&x->wait, TASK_NORMAL, 1, 0);
275
}
275
}
276
unsigned long 
276
277
wait_for_completion_interruptible_timeout(struct completion *x, unsigned long timeout)
277
long wait_for_completion_interruptible_timeout(
278
	struct completion *x, unsigned long timeout)
278
{
279
{
279
  return wait_for_completion_timeout(x, timeout);
280
  return wait_for_completion_timeout(x, timeout);
280
}
281
}
 Lines 292-301    Link Here 
292
  // we never schedule to decrease latency.
293
  // we never schedule to decrease latency.
293
  return 0;
294
  return 0;
294
}
295
}
295
void synchronize_sched_expedited(void)
296
{
297
  // nothing to do because we have !CONFIG_SMP
298
}
299
int idle_cpu (int cpu)
296
int idle_cpu (int cpu)
300
{
297
{
301
  // we are never idle: we call this from rcutiny.c and the answer
298
  // we are never idle: we call this from rcutiny.c and the answer
(-)a/sim/security.c (-1 / +1 lines)
 Lines 3-9    Link Here 
3
struct sock;
3
struct sock;
4
struct sk_buff;
4
struct sk_buff;
5
5
6
int capable(int cap)
6
bool capable(int cap)
7
{
7
{
8
  switch (cap)
8
  switch (cap)
9
  {
9
  {
(-)a/sim/sim-device.c (-2 lines)
 Lines 31-37    Link Here 
31
31
32
static const struct ethtool_ops sim_ethtool_ops = {
32
static const struct ethtool_ops sim_ethtool_ops = {
33
  .get_link               = always_on,
33
  .get_link               = always_on,
34
  .get_sg                 = always_on,
35
};
34
};
36
35
37
static const struct net_device_ops sim_dev_ops = {
36
static const struct net_device_ops sim_dev_ops = {
 Lines 50-56    Link Here 
50
  dev->flags              = 0; 
49
  dev->flags              = 0; 
51
  //dev->priv_flags        &= ~IFF_XMIT_DST_RELEASE;
50
  //dev->priv_flags        &= ~IFF_XMIT_DST_RELEASE;
52
  dev->features           = 0
51
  dev->features           = 0
53
    | NETIF_F_NO_CSUM
54
    | NETIF_F_HIGHDMA
52
    | NETIF_F_HIGHDMA
55
    | NETIF_F_NETNS_LOCAL;
53
    | NETIF_F_NETNS_LOCAL;
56
  // disabled  NETIF_F_TSO NETIF_F_SG  NETIF_F_FRAGLIST NETIF_F_LLTX
54
  // disabled  NETIF_F_TSO NETIF_F_SG  NETIF_F_FRAGLIST NETIF_F_LLTX
(-)a/sim/softirq.c (+5 lines)
 Lines 80-85    Link Here 
80
80
81
  sim_softirq_wakeup ();
81
  sim_softirq_wakeup ();
82
}
82
}
83
void __raise_softirq_irqoff(unsigned int nr)
84
{
85
	//trace_softirq_raise(nr);
86
	or_softirq_pending(1UL << nr);
87
}
83
int __cond_resched_softirq(void)
88
int __cond_resched_softirq(void)
84
{
89
{
85
  // tell the caller that we did not need to re-schedule.
90
  // tell the caller that we did not need to re-schedule.
(-)84912269f151 (+12 lines)
Added Link Here 
1
#include "sim.h"
2
#include "sim-assert.h"
3
#include <linux/fs.h>
4
5
ssize_t generic_file_splice_read(struct file *in, loff_t *ppos,
6
				 struct pipe_inode_info *pipe, size_t len,
7
				 unsigned int flags)
8
{
9
	sim_assert (false);
10
11
	return 0;
12
}
(-)84912269f151 (+212 lines)
Added Link Here 
1
#include <linux/export.h>
2
#include <linux/slab.h>
3
#include <linux/acct.h>
4
#include <linux/blkdev.h>
5
#include <linux/mount.h>
6
#include <linux/security.h>
7
#include <linux/writeback.h>		/* for the emergency remount stuff */
8
#include <linux/idr.h>
9
#include <linux/mutex.h>
10
#include <linux/backing-dev.h>
11
#include <linux/rculist_bl.h>
12
#include <linux/cleancache.h>
13
#include <linux/fsnotify.h>
14
#include <sim-assert.h>
15
16
17
int set_anon_super(struct super_block *s, void *data)
18
{
19
	  return 0;
20
}
21
22
struct super_block;
23
LIST_HEAD(super_blocks);
24
25
/**
26
 *	alloc_super	-	create new superblock
27
 *	@type:	filesystem type superblock should belong to
28
 *
29
 *	Allocates and initializes a new &struct super_block.  alloc_super()
30
 *	returns a pointer new superblock or %NULL if allocation had failed.
31
 */
32
static struct super_block *alloc_super(struct file_system_type *type)
33
{
34
	struct super_block *s = kzalloc(sizeof(struct super_block),  GFP_USER);
35
	static const struct super_operations default_op;
36
37
	if (s) {
38
		if (security_sb_alloc(s)) {
39
			kfree(s);
40
			s = NULL;
41
			goto out;
42
		}
43
#ifdef CONFIG_SMP
44
		s->s_files = alloc_percpu(struct list_head);
45
		if (!s->s_files) {
46
			security_sb_free(s);
47
			kfree(s);
48
			s = NULL;
49
			goto out;
50
		} else {
51
			int i;
52
53
			for_each_possible_cpu(i)
54
				INIT_LIST_HEAD(per_cpu_ptr(s->s_files, i));
55
		}
56
#else
57
		INIT_LIST_HEAD(&s->s_files);
58
#endif
59
		s->s_bdi = &default_backing_dev_info;
60
		INIT_HLIST_NODE(&s->s_instances);
61
		INIT_HLIST_BL_HEAD(&s->s_anon);
62
		INIT_LIST_HEAD(&s->s_inodes);
63
		INIT_LIST_HEAD(&s->s_dentry_lru);
64
		INIT_LIST_HEAD(&s->s_inode_lru);
65
		spin_lock_init(&s->s_inode_lru_lock);
66
		INIT_LIST_HEAD(&s->s_mounts);
67
		init_rwsem(&s->s_umount);
68
		mutex_init(&s->s_lock);
69
		lockdep_set_class(&s->s_umount, &type->s_umount_key);
70
		/*
71
		 * The locking rules for s_lock are up to the
72
		 * filesystem. For example ext3fs has different
73
		 * lock ordering than usbfs:
74
		 */
75
		lockdep_set_class(&s->s_lock, &type->s_lock_key);
76
		/*
77
		 * sget() can have s_umount recursion.
78
		 *
79
		 * When it cannot find a suitable sb, it allocates a new
80
		 * one (this one), and tries again to find a suitable old
81
		 * one.
82
		 *
83
		 * In case that succeeds, it will acquire the s_umount
84
		 * lock of the old one. Since these are clearly distrinct
85
		 * locks, and this object isn't exposed yet, there's no
86
		 * risk of deadlocks.
87
		 *
88
		 * Annotate this by putting this lock in a different
89
		 * subclass.
90
		 */
91
		down_write_nested(&s->s_umount, SINGLE_DEPTH_NESTING);
92
		s->s_count = 1;
93
		atomic_set(&s->s_active, 1);
94
		mutex_init(&s->s_vfs_rename_mutex);
95
		lockdep_set_class(&s->s_vfs_rename_mutex, &type->s_vfs_rename_key);
96
		mutex_init(&s->s_dquot.dqio_mutex);
97
		mutex_init(&s->s_dquot.dqonoff_mutex);
98
		init_rwsem(&s->s_dquot.dqptr_sem);
99
		init_waitqueue_head(&s->s_wait_unfrozen);
100
		s->s_maxbytes = MAX_NON_LFS;
101
		s->s_op = &default_op;
102
		s->s_time_gran = 1000000000;
103
		s->cleancache_poolid = -1;
104
105
		s->s_shrink.seeks = DEFAULT_SEEKS;
106
		s->s_shrink.shrink = 0; // prune_super;
107
		s->s_shrink.batch = 1024;
108
	}
109
out:
110
	return s;
111
}
112
113
/**
114
 *	deactivate_locked_super	-	drop an active reference to superblock
115
 *	@s: superblock to deactivate
116
 *
117
 *	Drops an active reference to superblock, converting it into a temprory
118
 *	one if there is no other active references left.  In that case we
119
 *	tell fs driver to shut it down and drop the temporary reference we
120
 *	had just acquired.
121
 *
122
 *	Caller holds exclusive lock on superblock; that lock is released.
123
 */
124
void deactivate_locked_super(struct super_block *s)
125
{
126
	struct file_system_type *fs = s->s_type;
127
	if (atomic_dec_and_test(&s->s_active)) {
128
		cleancache_invalidate_fs(s);
129
		fs->kill_sb(s);
130
131
		/* caches are now gone, we can safely kill the shrinker now */
132
		unregister_shrinker(&s->s_shrink);
133
134
		/*
135
		 * We need to call rcu_barrier so all the delayed rcu free
136
		 * inodes are flushed before we release the fs module.
137
		 */
138
		rcu_barrier();
139
		put_filesystem(fs);
140
		put_super(s);
141
	} else {
142
		up_write(&s->s_umount);
143
	}
144
}
145
146
/**
147
 *	sget	-	find or create a superblock
148
 *	@type:	filesystem type superblock should belong to
149
 *	@test:	comparison callback
150
 *	@set:	setup callback
151
 *	@data:	argument to each of them
152
 */
153
struct super_block *sget(struct file_system_type *type,
154
			int (*test)(struct super_block *,void *),
155
			int (*set)(struct super_block *,void *),
156
			void *data)
157
{
158
	struct super_block *s = NULL;
159
	struct hlist_node *node;
160
	struct super_block *old;
161
	int err;
162
163
retry:
164
	spin_lock(&sb_lock);
165
	if (test) {
166
		hlist_for_each_entry(old, node, &type->fs_supers, s_instances) {
167
			if (!test(old, data))
168
				continue;
169
			if (!grab_super(old))
170
				goto retry;
171
			if (s) {
172
				up_write(&s->s_umount);
173
				destroy_super(s);
174
				s = NULL;
175
			}
176
			down_write(&old->s_umount);
177
			if (unlikely(!(old->s_flags & MS_BORN))) {
178
				deactivate_locked_super(old);
179
				goto retry;
180
			}
181
			return old;
182
		}
183
	}
184
	if (!s) {
185
		spin_unlock(&sb_lock);
186
		s = alloc_super(type);
187
		if (!s)
188
			return ERR_PTR(-ENOMEM);
189
		goto retry;
190
	}
191
192
	err = set(s, data);
193
	if (err) {
194
		spin_unlock(&sb_lock);
195
		up_write(&s->s_umount);
196
		destroy_super(s);
197
		return ERR_PTR(err);
198
	}
199
	s->s_type = type;
200
	strlcpy(s->s_id, type->name, sizeof(s->s_id));
201
	list_add_tail(&s->s_list, &super_blocks);
202
	hlist_add_head(&s->s_instances, &type->fs_supers);
203
	spin_unlock(&sb_lock);
204
//	get_filesystem(type);
205
//	register_shrinker(&s->s_shrink);
206
	return s;
207
}
208
209
void kill_anon_super(struct super_block *sb)
210
{
211
212
}
(-)a/sim/sysctl.c (-2 / +4 lines)
 Lines 191-201    Link Here 
191
  iterate_table_recursive (iter, table);
191
  iterate_table_recursive (iter, table);
192
  for (cur = root; cur != 0; cur = sysctl_head_next (cur))
192
  for (cur = root; cur != 0; cur = sysctl_head_next (cur))
193
    {
193
    {
194
      if (cur->attached_to != table)
194
      if (cur->set != table)
195
	{
195
	{
196
	  continue;
196
	  continue;
197
	}
197
	}
198
      iterate_table_recursive (iter, cur->attached_by);
198
      iterate_table_recursive (iter, cur->root);
199
    }
199
    }
200
200
201
}
201
}
 Lines 204-209    Link Here 
204
204
205
void sim_sys_iterate_files (const struct SimSysIterator *iter)
205
void sim_sys_iterate_files (const struct SimSysIterator *iter)
206
{
206
{
207
//	sim_assert (0);
208
	return;
207
  struct ctl_table_header *root = sysctl_head_next (NULL);
209
  struct ctl_table_header *root = sysctl_head_next (NULL);
208
  iterate_recursive (iter, root->ctl_table);
210
  iterate_recursive (iter, root->ctl_table);
209
}
211
}
(-)a/sim/time.c (-1 / +1 lines)
 Lines 39-45    Link Here 
39
  *tv = ns_to_timeval (ns);
39
  *tv = ns_to_timeval (ns);
40
}
40
}
41
41
42
int do_settimeofday(struct timespec *tv)
42
int do_settimeofday(const struct timespec *tv)
43
{
43
{
44
  sim_assert (false);
44
  sim_assert (false);
45
  return -EPERM; // quiet compiler
45
  return -EPERM; // quiet compiler
(-)84912269f151 (+19 lines)
Added Link Here 
1
#include <linux/mm.h>
2
#include <linux/shrinker.h>
3
4
/*
5
 * Add a shrinker callback to be called from the vm
6
 */
7
void register_shrinker(struct shrinker *shrinker)
8
{
9
10
}
11
12
/*
13
 * Remove one
14
 */
15
void unregister_shrinker(struct shrinker *shrinker)
16
{
17
18
}
19
(-)a/sim/workqueue.c (-3 / +11 lines)
 Lines 58-64    Link Here 
58
  if (!list_empty(&g_work))
58
  if (!list_empty(&g_work))
59
    {
59
    {
60
      active = 1;
60
      active = 1;
61
      INIT_WORK_ON_STACK(&barr.work, &workqueue_barrier_fn);
61
      INIT_WORK_ONSTACK(&barr.work, &workqueue_barrier_fn);
62
      __set_bit(WORK_STRUCT_PENDING, work_data_bits(&barr.work));
62
      __set_bit(WORK_STRUCT_PENDING, work_data_bits(&barr.work));
63
      list_add(&barr.work.entry, prev);
63
      list_add(&barr.work.entry, prev);
64
      sim_task_wakeup (workqueue_task ());
64
      sim_task_wakeup (workqueue_task ());
 Lines 99-109    Link Here 
99
{
99
{
100
  flush_entry (g_work.prev);
100
  flush_entry (g_work.prev);
101
}
101
}
102
int flush_work(struct work_struct *work)
102
bool flush_work(struct work_struct *work)
103
{
103
{
104
  return flush_entry (&work->entry);
104
  return flush_entry (&work->entry);
105
}
105
}
106
int cancel_work_sync(struct work_struct *work)
106
bool cancel_work_sync(struct work_struct *work)
107
{
107
{
108
  int retval = 0;
108
  int retval = 0;
109
  if (!test_and_set_bit(WORK_STRUCT_PENDING, work_data_bits(work)))
109
  if (!test_and_set_bit(WORK_STRUCT_PENDING, work_data_bits(work)))
 Lines 142-144    Link Here 
142
    }
142
    }
143
  return ret;
143
  return ret;
144
}
144
}
145
struct workqueue_struct *__alloc_workqueue_key(const char *fmt,
146
					       unsigned int flags,
147
					       int max_active,
148
					       struct lock_class_key *key,
149
					       const char *lock_name, ...)
150
{
151
	return 0;
152
}

Return to bug 1447