From 596c20c199ce18ef414a55d3b69fe205944fad80 Mon Sep 17 00:00:00 2001 From: Stefan Kalkowski Date: Tue, 19 Jul 2022 11:06:52 +0200 Subject: [PATCH] pc: enable SMP and softirq/tasklets in lx_emul Enables symetric-multi-processor support in the Linux kernel configuration used as base for the driver ports for PC. This is done to be compliant with common usage of x86 drivers today. Moreover, this commit uses the original kernel source for softirq/tasklet implementation to get rid of the insufficient shadow implementation in the lx_emul sources. Ref genodelabs/genode#4562 --- .../shadow/arch/x86/include/asm/irq_stack.h | 6 + .../shadow/arch/x86/include/asm/percpu.h | 21 +++ .../lx_emul/shadow/arch/x86/kernel/irq_32.c | 25 +++ .../lx_emul/shadow/kernel/locking/spinlock.c | 136 ++++++++++++-- repos/pc/lib/import/import-pc_lx_emul.mk | 3 +- repos/pc/lib/mk/spec/x86_32/wifi.mk | 1 + repos/pc/lib/mk/wifi.inc | 1 - repos/pc/recipes/api/pc_linux/content.mk | 4 + .../drivers/framebuffer/intel/pc/dummies.c | 21 ++- .../framebuffer/intel/pc/generated_dummies.c | 25 +-- .../drivers/framebuffer/intel/pc/lx_emul.c | 1 - .../intel/pc/spec/x86_32/source.list | 2 + .../intel/pc/spec/x86_32/target.mk | 1 + .../intel/pc/spec/x86_64/source.list | 1 + .../drivers/framebuffer/intel/pc/target.inc | 1 - repos/pc/src/drivers/usb_host/pc/dummies.c | 8 + .../drivers/usb_host/pc/generated_dummies.c | 17 -- .../usb_host/pc/spec/x86_32/source.list | 4 + .../drivers/usb_host/pc/spec/x86_32/target.mk | 1 + .../usb_host/pc/spec/x86_64/source.list | 2 + repos/pc/src/drivers/usb_host/pc/target.inc | 2 - repos/pc/src/lib/pc/lx_emul/common_dummies.c | 173 ++++++++++++++++++ repos/pc/src/lib/pc/lx_emul/dep.list | 20 +- .../lib/pc/lx_emul/shadow/kernel/rcu/tiny.c | 1 + repos/pc/src/lib/pc/lx_emul/softirq.c | 40 ---- repos/pc/src/lib/wifi/dummies.c | 12 ++ repos/pc/src/lib/wifi/generated_dummies.c | 48 ++--- repos/pc/src/lib/wifi/lx_emul.c | 24 ++- repos/pc/src/lib/wifi/spec/x86_32/source.list | 3 + repos/pc/src/lib/wifi/spec/x86_64/source.list | 2 + repos/pc/src/pc_linux/target.inc | 2 +- repos/pc/src/test/driver_time/dummies.c | 8 + .../src/test/driver_time/generated_dummies.c | 32 +--- repos/pc/src/test/driver_time/source.list | 1 + repos/pc/src/test/driver_time/target.mk | 1 - 35 files changed, 485 insertions(+), 165 deletions(-) create mode 100644 repos/dde_linux/src/include/lx_emul/shadow/arch/x86/include/asm/percpu.h create mode 100644 repos/dde_linux/src/lib/lx_emul/shadow/arch/x86/kernel/irq_32.c delete mode 100644 repos/pc/src/lib/pc/lx_emul/softirq.c diff --git a/repos/dde_linux/src/include/lx_emul/shadow/arch/x86/include/asm/irq_stack.h b/repos/dde_linux/src/include/lx_emul/shadow/arch/x86/include/asm/irq_stack.h index 26f321cd7e..78e8fc33fe 100644 --- a/repos/dde_linux/src/include/lx_emul/shadow/arch/x86/include/asm/irq_stack.h +++ b/repos/dde_linux/src/include/lx_emul/shadow/arch/x86/include/asm/irq_stack.h @@ -11,6 +11,7 @@ #undef call_on_stack #undef ASM_CALL_ARG0 +#undef do_softirq_own_stack #define call_on_stack(stack, func, asm_call, argconstr...) \ { \ @@ -36,4 +37,9 @@ #define ASM_CALL_ARG0 \ "call *%P[__func] \n" +#define do_softirq_own_stack() \ +{ \ + __do_softirq(); \ +} + #endif /* _LX_EMUL__SHADOW__ARCH__X89__INCLUDE__ASM__IRQ_STACK_H_ */ diff --git a/repos/dde_linux/src/include/lx_emul/shadow/arch/x86/include/asm/percpu.h b/repos/dde_linux/src/include/lx_emul/shadow/arch/x86/include/asm/percpu.h new file mode 100644 index 0000000000..a053075138 --- /dev/null +++ b/repos/dde_linux/src/include/lx_emul/shadow/arch/x86/include/asm/percpu.h @@ -0,0 +1,21 @@ +/** + * \brief Shadow copy of asm/percpu.h + * \author Stefan Kalkowski + * \date 2022-06-29 + */ + +#ifndef _LX_EMUL__SHADOW__ARCH__X86__INCLUDE__ASM__PERCPU_H_ +#define _LX_EMUL__SHADOW__ARCH__X86__INCLUDE__ASM__PERCPU_H_ + +#include_next + +/* + * The original implementation uses gs or fs register + * to hold an cpu offset, which is not set correctly in our use-case + * where we use one cpu only anyway. + */ +#undef __percpu_prefix +#define __percpu_prefix "" + +#endif /* _LX_EMUL__SHADOW__ARCH__X86__INCLUDE__ASM__PERCPU_H_ */ + diff --git a/repos/dde_linux/src/lib/lx_emul/shadow/arch/x86/kernel/irq_32.c b/repos/dde_linux/src/lib/lx_emul/shadow/arch/x86/kernel/irq_32.c new file mode 100644 index 0000000000..e8ff99c746 --- /dev/null +++ b/repos/dde_linux/src/lib/lx_emul/shadow/arch/x86/kernel/irq_32.c @@ -0,0 +1,25 @@ +/* + * \brief Replaces arch/x86/kernel/irq_32.c + * \author Stefan Kalkowski + * \date 2022-07-20 + */ + +/* + * Copyright (C) 2022 Genode Labs GmbH + * + * This file is distributed under the terms of the GNU General Public License + * version 2. + */ + +#include + + +void do_softirq_own_stack(void) +{ + /* + * We have no IRQ stack to switch to anyway, + * so we stay here in contrast to the original + * implementation + */ + __do_softirq(); +} diff --git a/repos/dde_linux/src/lib/lx_emul/shadow/kernel/locking/spinlock.c b/repos/dde_linux/src/lib/lx_emul/shadow/kernel/locking/spinlock.c index e3c7fcf73a..f9d1d87e1b 100644 --- a/repos/dde_linux/src/lib/lx_emul/shadow/kernel/locking/spinlock.c +++ b/repos/dde_linux/src/lib/lx_emul/shadow/kernel/locking/spinlock.c @@ -21,12 +21,32 @@ #include +#ifndef CONFIG_INLINE_SPIN_LOCK void __lockfunc _raw_spin_lock(raw_spinlock_t * lock) { arch_spin_lock(&lock->raw_lock); } +#endif +#ifndef CONFIG_INLINE_SPIN_LOCK_BH +void __lockfunc _raw_spin_lock_bh(raw_spinlock_t * lock) +{ + __local_bh_disable_ip(_RET_IP_, SOFTIRQ_LOCK_OFFSET); + _raw_spin_lock(lock); +} +#endif + + +#ifndef CONFIG_INLINE_SPIN_LOCK_IRQ +void __lockfunc _raw_spin_lock_irq(raw_spinlock_t * lock) +{ + _raw_spin_lock_irqsave(lock); +} +#endif + + +#ifndef CONFIG_INLINE_SPIN_LOCK_IRQSAVE unsigned long __lockfunc _raw_spin_lock_irqsave(raw_spinlock_t * lock) { unsigned long flags; @@ -34,49 +54,131 @@ unsigned long __lockfunc _raw_spin_lock_irqsave(raw_spinlock_t * lock) _raw_spin_lock(lock); return flags; } +#endif +#ifndef CONFIG_INLINE_SPIN_TRYLOCK +int __lockfunc _raw_spin_trylock(raw_spinlock_t * lock) +{ + return arch_spin_trylock(&lock->raw_lock); +} +#endif + + +#ifdef CONFIG_UNINLINE_SPIN_UNLOCK +void __lockfunc _raw_spin_unlock(raw_spinlock_t * lock) +{ + arch_spin_unlock(&lock->raw_lock); +} +#endif + + +#ifndef CONFIG_INLINE_SPIN_UNLOCK_BH +void __lockfunc _raw_spin_unlock_bh(raw_spinlock_t * lock) +{ + _raw_spin_unlock(lock); + __local_bh_enable_ip(_RET_IP_, SOFTIRQ_LOCK_OFFSET); +} +#endif + + +#ifndef CONFIG_INLINE_SPIN_UNLOCK_IRQ +void __lockfunc _raw_spin_unlock_irq(raw_spinlock_t * lock) +{ + _raw_spin_unlock_irqrestore(lock, 0); +} +#endif + + +#ifndef CONFIG_INLINE_SPIN_UNLOCK_IRQRESTORE void __lockfunc _raw_spin_unlock_irqrestore(raw_spinlock_t * lock, unsigned long flags) { _raw_spin_unlock(lock); local_irq_restore(flags); } +#endif -void __lockfunc _raw_spin_lock_irq(raw_spinlock_t * lock) +#ifndef CONFIG_INLINE_READ_LOCK +void __lockfunc _raw_read_lock(rwlock_t * lock) { - _raw_spin_lock_irqsave(lock); + lx_emul_trace_and_stop(__func__); } +#endif -int __lockfunc _raw_spin_trylock(raw_spinlock_t * lock) +#ifndef CONFIG_INLINE_READ_LOCK_IRQSAVE +unsigned long __lockfunc _raw_read_lock_irqsave(rwlock_t * lock) { - return arch_spin_trylock(&lock->raw_lock); + unsigned long flags; + local_irq_save(flags); + arch_read_lock(&(lock)->raw_lock); + return flags; } +#endif +#ifndef CONFIG_INLINE_WRITE_UNLOCK_BH +void __lockfunc _raw_write_unlock_bh(rwlock_t * lock) +{ + arch_write_unlock(&(lock)->raw_lock); +} +#endif + + +#ifndef CONFIG_INLINE_READ_UNLOCK_BH +void __lockfunc _raw_read_unlock_bh(rwlock_t * lock) +{ + arch_read_unlock(&(lock)->raw_lock); +} +#endif + + +#ifndef CONFIG_INLINE_WRITE_LOCK void __lockfunc _raw_write_lock(rwlock_t * lock) { arch_write_lock(&(lock)->raw_lock); } +#endif -#ifndef CONFIG_X86 -void __lockfunc __raw_spin_unlock(raw_spinlock_t * lock) -{ - arch_spin_unlock(&lock->raw_lock); -} - - -void __lockfunc _raw_spin_unlock_irq(raw_spinlock_t * lock) -{ - _raw_spin_unlock_irqrestore(lock, 0); -} - - +#ifndef CONFIG_INLINE_WRITE_UNLOCK void __lockfunc _raw_write_unlock(rwlock_t * lock) { arch_write_unlock(&(lock)->raw_lock); } #endif + + +#ifndef CONFIG_INLINE_READ_UNLOCK_IRQRESTORE +void __lockfunc _raw_read_unlock_irqrestore(rwlock_t * lock,unsigned long flags) +{ + arch_read_unlock(&(lock)->raw_lock); + local_irq_restore(flags); +} +#endif + + +#ifndef CONFIG_INLINE_WRITE_LOCK_BH +void __lockfunc _raw_write_lock_bh(rwlock_t * lock) +{ + arch_write_lock(&(lock)->raw_lock); +} +#endif + + +#ifndef CONFIG_INLINE_WRITE_LOCK_IRQ +void __lockfunc _raw_write_lock_irq(rwlock_t * lock) +{ + arch_write_lock(&(lock)->raw_lock); +} +#endif + + +#ifndef CONFIG_INLINE_READ_LOCK_BH +void __lockfunc _raw_read_lock_bh(rwlock_t * lock) +{ + arch_read_lock(&(lock)->raw_lock); +} +#endif diff --git a/repos/pc/lib/import/import-pc_lx_emul.mk b/repos/pc/lib/import/import-pc_lx_emul.mk index 4e298d8c84..9cfc937409 100644 --- a/repos/pc/lib/import/import-pc_lx_emul.mk +++ b/repos/pc/lib/import/import-pc_lx_emul.mk @@ -21,8 +21,10 @@ SRC_CC += lx_emul/irq.cc SRC_CC += lx_emul/random.cc SRC_C += lx_emul/shadow/kernel/dma/mapping.c SRC_C += lx_emul/shadow/kernel/irq/spurious.c +SRC_C += lx_emul/shadow/kernel/locking/spinlock.c SRC_C += lx_emul/shadow/kernel/rcu/tree.c SRC_C += lx_emul/shadow/kernel/sched/sched.c +SRC_C += lx_emul/shadow/kernel/stop_machine.c SRC_C += lx_emul/shadow/lib/devres.c SRC_C += lx_emul/shadow/lib/smp_processor_id.c SRC_C += lx_emul/shadow/mm/memblock.c @@ -45,7 +47,6 @@ SRC_C += lx_emul/mapping.c SRC_C += lx_emul/page_alloc.c SRC_C += lx_emul/sched_core.c SRC_C += lx_emul/slab_common.c -SRC_C += lx_emul/softirq.c SRC_C += lx_emul/vmalloc.c SRC_C += lx_emul/delay.c diff --git a/repos/pc/lib/mk/spec/x86_32/wifi.mk b/repos/pc/lib/mk/spec/x86_32/wifi.mk index 6160802395..f136e992a4 100644 --- a/repos/pc/lib/mk/spec/x86_32/wifi.mk +++ b/repos/pc/lib/mk/spec/x86_32/wifi.mk @@ -3,3 +3,4 @@ include $(REP_DIR)/lib/mk/wifi.inc REQUIRES += 32bit SRC_C += lx_emul/spec/x86_32/atomic64_32.c +SRC_C += lx_emul/shadow/arch/x86/kernel/irq_32.c diff --git a/repos/pc/lib/mk/wifi.inc b/repos/pc/lib/mk/wifi.inc index aaa1a1aba8..1510384a19 100644 --- a/repos/pc/lib/mk/wifi.inc +++ b/repos/pc/lib/mk/wifi.inc @@ -40,7 +40,6 @@ CC_C_OPT += -DCONFIG_RFKILL_INPUT #CC_OPT += -DCONFIG_IWLWIFI_DEBUG -SRC_C += lx_emul/shadow/kernel/softirq.c SRC_C += lx_emul/shadow/lib/kobject_uevent.c vpath %.c $(REP_DIR)/src/lib/pc vpath %.cc $(REP_DIR)/src/lib/pc diff --git a/repos/pc/recipes/api/pc_linux/content.mk b/repos/pc/recipes/api/pc_linux/content.mk index 8da1762ab4..3f5fd64d3a 100644 --- a/repos/pc/recipes/api/pc_linux/content.mk +++ b/repos/pc/recipes/api/pc_linux/content.mk @@ -141,7 +141,10 @@ LX_FILES += arch/x86/include/asm/boot.h \ arch/x86/include/asm/pgtable_64.h \ arch/x86/include/asm/pgtable-invert.h \ arch/x86/include/asm/pkru.h \ + arch/x86/include/asm/qrwlock.h \ + arch/x86/include/asm/qspinlock.h \ arch/x86/include/asm/sigframe.h \ + arch/x86/include/asm/spinlock.h \ arch/x86/include/asm/suspend.h \ arch/x86/include/asm/suspend_32.h \ arch/x86/include/asm/suspend_64.h \ @@ -159,6 +162,7 @@ LX_FILES += arch/x86/include/asm/boot.h \ include/asm-generic/pgtable_uffd.h \ include/asm-generic/pgtable-nopmd.h \ include/asm-generic/pgtable-nopud.h \ + include/asm-generic/qrwlock.h \ include/asm-generic/qspinlock.h \ include/linux/arm-smccc.h \ include/linux/arm_sdei.h \ diff --git a/repos/pc/src/drivers/framebuffer/intel/pc/dummies.c b/repos/pc/src/drivers/framebuffer/intel/pc/dummies.c index f70a11b8fd..32707a9de0 100644 --- a/repos/pc/src/drivers/framebuffer/intel/pc/dummies.c +++ b/repos/pc/src/drivers/framebuffer/intel/pc/dummies.c @@ -40,7 +40,6 @@ const guid_t pci_acpi_dsm_guid = void register_syscore_ops(struct syscore_ops * ops) { - wait_bit_init(); lx_emul_trace(__func__); } @@ -551,3 +550,23 @@ bool irq_work_needs_cpu(void) { return false; } + + +#include + +struct smp_ops smp_ops = { }; +EXPORT_SYMBOL_GPL(smp_ops); + + +#include + +u32 prandom_u32(void) +{ + lx_emul_trace_and_stop(__func__); +} + + +int wbinvd_on_all_cpus(void) +{ + lx_emul_trace(__func__); +} diff --git a/repos/pc/src/drivers/framebuffer/intel/pc/generated_dummies.c b/repos/pc/src/drivers/framebuffer/intel/pc/generated_dummies.c index 898a69f001..e6c1c56582 100644 --- a/repos/pc/src/drivers/framebuffer/intel/pc/generated_dummies.c +++ b/repos/pc/src/drivers/framebuffer/intel/pc/generated_dummies.c @@ -1509,6 +1509,14 @@ void kmsg_dump(enum kmsg_dump_reason reason) } +#include + +void kvfree_call_rcu(struct rcu_head * head,rcu_callback_t func) +{ + lx_emul_trace_and_stop(__func__); +} + + #include void mark_page_accessed(struct page * page) @@ -1897,14 +1905,6 @@ int smp_call_function_single(int cpu,void (* func)(void * info),void * info,int } -#include - -void srcu_drive_gp(struct work_struct * wp) -{ - lx_emul_trace_and_stop(__func__); -} - - #include bool static_key_initialized; @@ -1931,14 +1931,6 @@ void synchronize_rcu(void) } -#include - -void synchronize_srcu(struct srcu_struct * ssp) -{ - lx_emul_trace_and_stop(__func__); -} - - #include int task_work_add(struct task_struct * task,struct callback_head * work,enum task_work_notify_mode notify) @@ -2024,4 +2016,3 @@ void wake_q_add_safe(struct wake_q_head * head,struct task_struct * task) { lx_emul_trace_and_stop(__func__); } - diff --git a/repos/pc/src/drivers/framebuffer/intel/pc/lx_emul.c b/repos/pc/src/drivers/framebuffer/intel/pc/lx_emul.c index 2c0c20a3b3..b26b9d32e2 100644 --- a/repos/pc/src/drivers/framebuffer/intel/pc/lx_emul.c +++ b/repos/pc/src/drivers/framebuffer/intel/pc/lx_emul.c @@ -36,7 +36,6 @@ int acpi_disabled = 0; void intel_wopcm_init_early(struct intel_wopcm * wopcm) { - wait_bit_init(); lx_emul_trace(__func__); } diff --git a/repos/pc/src/drivers/framebuffer/intel/pc/spec/x86_32/source.list b/repos/pc/src/drivers/framebuffer/intel/pc/spec/x86_32/source.list index 4defc3d70a..0e717db882 100644 --- a/repos/pc/src/drivers/framebuffer/intel/pc/spec/x86_32/source.list +++ b/repos/pc/src/drivers/framebuffer/intel/pc/spec/x86_32/source.list @@ -222,11 +222,13 @@ kernel/sched/swait.c kernel/sched/wait.c kernel/sched/wait_bit.c kernel/smpboot.c +kernel/softirq.c kernel/time/clockevents.c kernel/time/clocksource.c kernel/time/hrtimer.c kernel/time/jiffies.c kernel/time/ntp.c +kernel/time/tick-broadcast.c kernel/time/tick-common.c kernel/time/tick-oneshot.c kernel/time/tick-sched.c diff --git a/repos/pc/src/drivers/framebuffer/intel/pc/spec/x86_32/target.mk b/repos/pc/src/drivers/framebuffer/intel/pc/spec/x86_32/target.mk index 6b20840600..d74c56df41 100644 --- a/repos/pc/src/drivers/framebuffer/intel/pc/spec/x86_32/target.mk +++ b/repos/pc/src/drivers/framebuffer/intel/pc/spec/x86_32/target.mk @@ -2,3 +2,4 @@ include $(REP_DIR)/src/drivers/framebuffer/intel/pc/target.inc REQUIRES += 32bit SRC_C += lx_emul/spec/x86_32/atomic64_32.c +SRC_C += lx_emul/shadow/arch/x86/kernel/irq_32.c diff --git a/repos/pc/src/drivers/framebuffer/intel/pc/spec/x86_64/source.list b/repos/pc/src/drivers/framebuffer/intel/pc/spec/x86_64/source.list index 518849f5cb..abdcec0de1 100644 --- a/repos/pc/src/drivers/framebuffer/intel/pc/spec/x86_64/source.list +++ b/repos/pc/src/drivers/framebuffer/intel/pc/spec/x86_64/source.list @@ -225,6 +225,7 @@ kernel/sched/swait.c kernel/sched/wait.c kernel/sched/wait_bit.c kernel/smpboot.c +kernel/softirq.c kernel/time/clockevents.c kernel/time/clocksource.c kernel/time/hrtimer.c diff --git a/repos/pc/src/drivers/framebuffer/intel/pc/target.inc b/repos/pc/src/drivers/framebuffer/intel/pc/target.inc index 04788d6894..5a50f3cf6e 100644 --- a/repos/pc/src/drivers/framebuffer/intel/pc/target.inc +++ b/repos/pc/src/drivers/framebuffer/intel/pc/target.inc @@ -21,7 +21,6 @@ SRC_C += lx_user.c SRC_C += gem.c SRC_C += lx_emul/common_dummies.c SRC_C += lx_emul/spec/x86/pci.c -SRC_C += lx_emul/shadow/kernel/softirq.c SRC_C += lx_emul/shadow/mm/page_alloc.c vpath %.c $(REL_PRG_DIR) diff --git a/repos/pc/src/drivers/usb_host/pc/dummies.c b/repos/pc/src/drivers/usb_host/pc/dummies.c index 7d7eb92d46..25bdeeaf2d 100644 --- a/repos/pc/src/drivers/usb_host/pc/dummies.c +++ b/repos/pc/src/drivers/usb_host/pc/dummies.c @@ -106,3 +106,11 @@ bool irq_work_needs_cpu(void) { return false; } + + +#include + +u32 prandom_u32(void) +{ + lx_emul_trace_and_stop(__func__); +} diff --git a/repos/pc/src/drivers/usb_host/pc/generated_dummies.c b/repos/pc/src/drivers/usb_host/pc/generated_dummies.c index aa37090621..2befa28591 100644 --- a/repos/pc/src/drivers/usb_host/pc/generated_dummies.c +++ b/repos/pc/src/drivers/usb_host/pc/generated_dummies.c @@ -517,14 +517,6 @@ int smp_call_function_single(int cpu,void (* func)(void * info),void * info,int } -#include - -void srcu_drive_gp(struct work_struct * wp) -{ - lx_emul_trace_and_stop(__func__); -} - - #include bool static_key_initialized; @@ -538,14 +530,6 @@ int string_escape_mem(const char * src,size_t isz,char * dst,size_t osz,unsigned } -#include - -void synchronize_srcu(struct srcu_struct * ssp) -{ - lx_emul_trace_and_stop(__func__); -} - - #include int task_work_add(struct task_struct * task,struct callback_head * work,enum task_work_notify_mode notify) @@ -588,4 +572,3 @@ void wake_q_add_safe(struct wake_q_head * head,struct task_struct * task) { lx_emul_trace_and_stop(__func__); } - diff --git a/repos/pc/src/drivers/usb_host/pc/spec/x86_32/source.list b/repos/pc/src/drivers/usb_host/pc/spec/x86_32/source.list index cde37ec2aa..1c750d29c8 100644 --- a/repos/pc/src/drivers/usb_host/pc/spec/x86_32/source.list +++ b/repos/pc/src/drivers/usb_host/pc/spec/x86_32/source.list @@ -62,6 +62,7 @@ kernel/irq/chip.c kernel/irq/devres.c kernel/irq/handle.c kernel/irq/irqdesc.c +kernel/irq/irqdomain.c kernel/irq/manage.c kernel/irq/resend.c kernel/kthread.c @@ -75,12 +76,15 @@ kernel/sched/clock.c kernel/sched/completion.c kernel/sched/swait.c kernel/sched/wait.c +kernel/sched/wait_bit.c kernel/smpboot.c +kernel/softirq.c kernel/time/clockevents.c kernel/time/clocksource.c kernel/time/hrtimer.c kernel/time/jiffies.c kernel/time/ntp.c +kernel/time/tick-broadcast.c kernel/time/tick-common.c kernel/time/tick-oneshot.c kernel/time/tick-sched.c diff --git a/repos/pc/src/drivers/usb_host/pc/spec/x86_32/target.mk b/repos/pc/src/drivers/usb_host/pc/spec/x86_32/target.mk index 998cd5af96..571119e8fb 100644 --- a/repos/pc/src/drivers/usb_host/pc/spec/x86_32/target.mk +++ b/repos/pc/src/drivers/usb_host/pc/spec/x86_32/target.mk @@ -3,3 +3,4 @@ include $(REP_DIR)/src/drivers/usb_host/pc/target.inc REQUIRES += 32bit SRC_C += lx_emul/spec/x86_32/atomic64_32.c +SRC_C += lx_emul/shadow/arch/x86/kernel/irq_32.c diff --git a/repos/pc/src/drivers/usb_host/pc/spec/x86_64/source.list b/repos/pc/src/drivers/usb_host/pc/spec/x86_64/source.list index d16cd6ae87..38d72247eb 100644 --- a/repos/pc/src/drivers/usb_host/pc/spec/x86_64/source.list +++ b/repos/pc/src/drivers/usb_host/pc/spec/x86_64/source.list @@ -76,7 +76,9 @@ kernel/sched/clock.c kernel/sched/completion.c kernel/sched/swait.c kernel/sched/wait.c +kernel/sched/wait_bit.c kernel/smpboot.c +kernel/softirq.c kernel/time/clockevents.c kernel/time/clocksource.c kernel/time/hrtimer.c diff --git a/repos/pc/src/drivers/usb_host/pc/target.inc b/repos/pc/src/drivers/usb_host/pc/target.inc index 66dba2679f..1a6b805031 100644 --- a/repos/pc/src/drivers/usb_host/pc/target.inc +++ b/repos/pc/src/drivers/usb_host/pc/target.inc @@ -16,8 +16,6 @@ SRC_C += $(notdir $(wildcard $(REL_PRG_DIR)/generated_dummies.c)) SRC_C += common_dummies.c SRC_C += lx_emul/spec/x86/pci.c SRC_C += lx_emul/usb.c -SRC_C += lx_emul/shadow/kernel/softirq.c - SRC_C += lx_emul/shadow/lib/kobject_uevent.c vpath %.c $(REP_DIR)/src/lib/pc vpath %.cc $(REP_DIR)/src/lib/pc diff --git a/repos/pc/src/lib/pc/lx_emul/common_dummies.c b/repos/pc/src/lib/pc/lx_emul/common_dummies.c index a4086eccf5..140c876fd9 100644 --- a/repos/pc/src/lib/pc/lx_emul/common_dummies.c +++ b/repos/pc/src/lib/pc/lx_emul/common_dummies.c @@ -369,3 +369,176 @@ bool pat_enabled(void) lx_emul_trace(__func__); return true; } + + +#include + +atomic_t __num_online_cpus = ATOMIC_INIT(1); + +unsigned long __per_cpu_offset[NR_CPUS] = { 0UL }; + + +struct srcu_struct; +extern int __srcu_read_lock(struct srcu_struct * ssp); +int __srcu_read_lock(struct srcu_struct * ssp) +{ + lx_emul_trace_and_stop(__func__); +} + + +#include + +void cpu_hotplug_disable(void) +{ + lx_emul_trace(__func__); +} + + +#include + +void cpu_hotplug_enable(void) +{ + lx_emul_trace(__func__); +} + + +#include + +unsigned int cpumask_next(int n,const struct cpumask * srcp) +{ + lx_emul_trace(__func__); + return n + 1; +} + + +#include + +int cpumask_next_and(int n,const struct cpumask * src1p,const struct cpumask * src2p) +{ + lx_emul_trace_and_stop(__func__); +} + + +#include + +void do_set_cpus_allowed(struct task_struct * p,const struct cpumask * new_mask) +{ + lx_emul_trace(__func__); +} + + +#include + +const struct cpumask * housekeeping_cpumask(enum hk_flags flags) +{ + static struct cpumask ret; + lx_emul_trace(__func__); + return &ret; +} + + +#include + +bool housekeeping_enabled(enum hk_flags flags) +{ + lx_emul_trace_and_stop(__func__); +} + + +#include + +unsigned int nr_cpu_ids = 1; + + +#include + +noinstr void rcu_irq_enter(void) +{ + lx_emul_trace(__func__); +} + + +#include + +void noinstr rcu_irq_exit(void) +{ + lx_emul_trace(__func__); +} + + +#include + +void rcu_softirq_qs(void) +{ + lx_emul_trace(__func__); +} + + +extern void synchronize_srcu(struct srcu_struct * ssp); +void synchronize_srcu(struct srcu_struct * ssp) +{ + lx_emul_trace_and_stop(__func__); +} + + +int cpu_number = 0; + +#ifdef CONFIG_X86_64 +DEFINE_PER_CPU(void *, hardirq_stack_ptr); +#endif +DEFINE_PER_CPU(bool, hardirq_stack_inuse); + + +#include + +DEFINE_PER_CPU_SHARED_ALIGNED(irq_cpustat_t, irq_stat); +EXPORT_PER_CPU_SYMBOL(irq_stat); + + +extern void rcu_read_unlock_strict(void); +void rcu_read_unlock_strict(void) +{ + lx_emul_trace(__func__); +} + + +DEFINE_PER_CPU_READ_MOSTLY(unsigned long, this_cpu_off) = 0; +EXPORT_PER_CPU_SYMBOL(this_cpu_off); + + +#include + +DEFINE_PER_CPU_READ_MOSTLY(struct cpuinfo_x86, cpu_info); +EXPORT_PER_CPU_SYMBOL(cpu_info); + + +#include + +void wake_up_nohz_cpu(int cpu) +{ + lx_emul_trace(__func__); +} + + +#include + +void nohz_balance_enter_idle(int cpu) +{ + lx_emul_trace(__func__); +} + + +#include + +void quiet_vmstat(void) +{ + lx_emul_trace(__func__); +} + + +extern int idle_cpu(int cpu); +int idle_cpu(int cpu) +{ + lx_emul_trace(__func__); + return 1; +} diff --git a/repos/pc/src/lib/pc/lx_emul/dep.list b/repos/pc/src/lib/pc/lx_emul/dep.list index af3a269135..93acfc32d9 100644 --- a/repos/pc/src/lib/pc/lx_emul/dep.list +++ b/repos/pc/src/lib/pc/lx_emul/dep.list @@ -1,6 +1,7 @@ arch/x86/include/asm/acenv.h arch/x86/include/asm/acpi.h arch/x86/include/asm/alternative.h +arch/x86/include/asm/apic.h arch/x86/include/asm/apicdef.h arch/x86/include/asm/arch_hweight.h arch/x86/include/asm/asm.h @@ -39,6 +40,7 @@ arch/x86/include/asm/hw_irq.h arch/x86/include/asm/intel_ds.h arch/x86/include/asm/invpcid.h arch/x86/include/asm/irq.h +arch/x86/include/asm/irq_stack.h arch/x86/include/asm/irq_vectors.h arch/x86/include/asm/irq_work.h arch/x86/include/asm/irqdomain.h @@ -91,6 +93,8 @@ arch/x86/include/asm/shmparam.h arch/x86/include/asm/signal.h arch/x86/include/asm/smap.h arch/x86/include/asm/smp.h +arch/x86/include/asm/softirq_stack.h +arch/x86/include/asm/spinlock_types.h arch/x86/include/asm/stacktrace.h arch/x86/include/asm/static_call.h arch/x86/include/asm/string.h @@ -140,6 +144,7 @@ arch/x86/include/uapi/asm/signal.h arch/x86/include/uapi/asm/stat.h arch/x86/include/uapi/asm/swab.h arch/x86/include/uapi/asm/unistd.h +arch/x86/include/uapi/asm/vsyscall.h drivers/base/base.h drivers/base/power/power.h drivers/base/trace.h @@ -186,6 +191,7 @@ include/asm-generic/bug.h include/asm-generic/cacheflush.h include/asm-generic/compat.h include/asm-generic/delay.h +include/asm-generic/div64.h include/asm-generic/early_ioremap.h include/asm-generic/error-injection.h include/asm-generic/fixmap.h @@ -207,10 +213,13 @@ include/asm-generic/pci.h include/asm-generic/pci_iomap.h include/asm-generic/percpu.h include/asm-generic/pgtable-nop4d.h +include/asm-generic/qrwlock_types.h +include/asm-generic/qspinlock_types.h include/asm-generic/resource.h include/asm-generic/rwonce.h include/asm-generic/sections.h include/asm-generic/set_memory.h +include/asm-generic/softirq_stack.h include/asm-generic/termios.h include/asm-generic/tlb.h include/asm-generic/topology.h @@ -560,6 +569,7 @@ include/linux/ratelimit_types.h include/linux/rbtree.h include/linux/rbtree_augmented.h include/linux/rbtree_latch.h +include/linux/rcu_node_tree.h include/linux/rcu_segcblist.h include/linux/rcu_sync.h include/linux/rculist.h @@ -567,7 +577,7 @@ include/linux/rculist_bl.h include/linux/rculist_nulls.h include/linux/rcupdate.h include/linux/rcupdate_wait.h -include/linux/rcutiny.h +include/linux/rcutree.h include/linux/rcuwait.h include/linux/reboot.h include/linux/refcount.h @@ -579,6 +589,7 @@ include/linux/ring_buffer.h include/linux/rtc.h include/linux/rtnetlink.h include/linux/rwlock.h +include/linux/rwlock_api_smp.h include/linux/rwlock_types.h include/linux/rwsem.h include/linux/sbitmap.h @@ -602,6 +613,7 @@ include/linux/sched/nohz.h include/linux/sched/numa_balancing.h include/linux/sched/prio.h include/linux/sched/rt.h +include/linux/sched/sd_flags.h include/linux/sched/signal.h include/linux/sched/smt.h include/linux/sched/stat.h @@ -640,13 +652,11 @@ include/linux/socket.h include/linux/sockptr.h include/linux/sort.h include/linux/spinlock.h -include/linux/spinlock_api_up.h +include/linux/spinlock_api_smp.h include/linux/spinlock_types.h -include/linux/spinlock_types_up.h -include/linux/spinlock_up.h include/linux/splice.h include/linux/srcu.h -include/linux/srcutiny.h +include/linux/srcutree.h include/linux/stackdepot.h include/linux/stacktrace.h include/linux/stat.h diff --git a/repos/pc/src/lib/pc/lx_emul/shadow/kernel/rcu/tiny.c b/repos/pc/src/lib/pc/lx_emul/shadow/kernel/rcu/tiny.c index 4f8298cf0d..f7bfbe57a4 100644 --- a/repos/pc/src/lib/pc/lx_emul/shadow/kernel/rcu/tiny.c +++ b/repos/pc/src/lib/pc/lx_emul/shadow/kernel/rcu/tiny.c @@ -12,6 +12,7 @@ */ +#include #include void call_rcu(struct rcu_head * head,rcu_callback_t func) diff --git a/repos/pc/src/lib/pc/lx_emul/softirq.c b/repos/pc/src/lib/pc/lx_emul/softirq.c deleted file mode 100644 index 81c1440d98..0000000000 --- a/repos/pc/src/lib/pc/lx_emul/softirq.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - * \brief Supplement for emulation of kernel/softirq.c - * \author Josef Soentgen - * \date 2022-04-05 - */ - -/* - * Copyright (C) 2022 Genode Labs GmbH - * - * This file is distributed under the terms of the GNU General Public License - * version 2. - */ - - -#include - -void tasklet_setup(struct tasklet_struct * t, - void (* callback)(struct tasklet_struct *)) -{ - t->next = NULL; - t->state = 0; - atomic_set(&t->count, 0); - t->callback = callback; - t->use_callback = true; - t->data = 0; -} - - -void __tasklet_schedule(struct tasklet_struct * t) -{ - if (test_and_clear_bit(TASKLET_STATE_SCHED, &t->state)) - t->callback(t); -} - - -void __tasklet_hi_schedule(struct tasklet_struct * t) -{ - if (test_and_clear_bit(TASKLET_STATE_SCHED, &t->state)) - t->callback(t); -} diff --git a/repos/pc/src/lib/wifi/dummies.c b/repos/pc/src/lib/wifi/dummies.c index d1a6c29d2b..82af883041 100644 --- a/repos/pc/src/lib/wifi/dummies.c +++ b/repos/pc/src/lib/wifi/dummies.c @@ -318,3 +318,15 @@ bool irq_work_needs_cpu(void) { return false; } + + +#include + +struct smp_ops smp_ops = { }; +EXPORT_SYMBOL_GPL(smp_ops); + + +void synchronize_rcu_expedited(void) +{ + lx_emul_trace(__func__); +} diff --git a/repos/pc/src/lib/wifi/generated_dummies.c b/repos/pc/src/lib/wifi/generated_dummies.c index 4fa6817810..958ae3b0b2 100644 --- a/repos/pc/src/lib/wifi/generated_dummies.c +++ b/repos/pc/src/lib/wifi/generated_dummies.c @@ -283,14 +283,6 @@ int dev_ioctl(struct net * net,unsigned int cmd,struct ifreq * ifr,bool * need_c } -#include - -asmlinkage __visible void do_softirq(void) -{ - lx_emul_trace_and_stop(__func__); -} - - #include void dst_release(struct dst_entry * dst) @@ -655,6 +647,22 @@ unsigned long long memparse(const char * ptr,char ** retptr) } +#include + +void migrate_disable(void) +{ + lx_emul_trace_and_stop(__func__); +} + + +#include + +void migrate_enable(void) +{ + lx_emul_trace_and_stop(__func__); +} + + #include const struct nla_policy nda_policy[] = {}; @@ -1110,17 +1118,17 @@ int smp_call_function_single(int cpu,void (* func)(void * info),void * info,int } -#include +#include -void sock_diag_broadcast_destroy(struct sock * sk) +int smp_call_function_single_async(int cpu,struct __call_single_data * csd) { lx_emul_trace_and_stop(__func__); } -#include +#include -void srcu_drive_gp(struct work_struct * wp) +void sock_diag_broadcast_destroy(struct sock * sk) { lx_emul_trace_and_stop(__func__); } @@ -1152,14 +1160,6 @@ int string_escape_mem(const char * src,size_t isz,char * dst,size_t osz,unsigned int suppress_printk; -#include - -void synchronize_srcu(struct srcu_struct * ssp) -{ - lx_emul_trace_and_stop(__func__); -} - - #include int sysfs_rename_dir_ns(struct kobject * kobj,const char * new_name,const void * new_ns) @@ -1184,14 +1184,6 @@ struct callback_head * task_work_cancel(struct task_struct * task,task_work_func } -#include - -void tasklet_kill(struct tasklet_struct * t) -{ - lx_emul_trace_and_stop(__func__); -} - - #include void unblank_screen(void) diff --git a/repos/pc/src/lib/wifi/lx_emul.c b/repos/pc/src/lib/wifi/lx_emul.c index c2d6dc2a3c..e5340ddf20 100644 --- a/repos/pc/src/lib/wifi/lx_emul.c +++ b/repos/pc/src/lib/wifi/lx_emul.c @@ -302,14 +302,6 @@ int task_work_add(struct task_struct * task,struct callback_head * work,enum tas } -#include - -void __raise_softirq_irqoff(unsigned int nr) -{ - raise_softirq(nr); -} - - #include void kfree_sensitive(const void *p) @@ -566,3 +558,19 @@ void rfkill_init(void) rfkill_task_struct_ptr = find_task_by_pid_ns(pid, NULL); } + + +#ifdef CONFIG_X86_32 +s64 arch_atomic64_add_return(s64 i, atomic64_t *v) +{ + v->counter += i; + return v->counter; +} +#endif + + +void kvfree_call_rcu(struct rcu_head * head,rcu_callback_t func) +{ + void *ptr = (void *) head - (unsigned long) func; + kvfree(ptr); +} diff --git a/repos/pc/src/lib/wifi/spec/x86_32/source.list b/repos/pc/src/lib/wifi/spec/x86_32/source.list index 3bc7badd53..94cbcb048b 100644 --- a/repos/pc/src/lib/wifi/spec/x86_32/source.list +++ b/repos/pc/src/lib/wifi/spec/x86_32/source.list @@ -148,12 +148,15 @@ kernel/sched/clock.c kernel/sched/completion.c kernel/sched/swait.c kernel/sched/wait.c +kernel/sched/wait_bit.c kernel/smpboot.c +kernel/softirq.c kernel/time/clockevents.c kernel/time/clocksource.c kernel/time/hrtimer.c kernel/time/jiffies.c kernel/time/ntp.c +kernel/time/tick-broadcast.c kernel/time/tick-common.c kernel/time/tick-oneshot.c kernel/time/tick-sched.c diff --git a/repos/pc/src/lib/wifi/spec/x86_64/source.list b/repos/pc/src/lib/wifi/spec/x86_64/source.list index 2f7e2963c0..f6e3ae909b 100644 --- a/repos/pc/src/lib/wifi/spec/x86_64/source.list +++ b/repos/pc/src/lib/wifi/spec/x86_64/source.list @@ -148,7 +148,9 @@ kernel/sched/clock.c kernel/sched/completion.c kernel/sched/swait.c kernel/sched/wait.c +kernel/sched/wait_bit.c kernel/smpboot.c +kernel/softirq.c kernel/time/clockevents.c kernel/time/clocksource.c kernel/time/hrtimer.c diff --git a/repos/pc/src/pc_linux/target.inc b/repos/pc/src/pc_linux/target.inc index 90cb0bb1c5..ea452d107f 100644 --- a/repos/pc/src/pc_linux/target.inc +++ b/repos/pc/src/pc_linux/target.inc @@ -3,7 +3,7 @@ # # kernel fundamentals -LX_ENABLE += TTY SERIAL_EARLYCON SERIAL_OF_PLATFORM PRINTK HAS_IOMEM +LX_ENABLE += TTY SERIAL_EARLYCON SERIAL_OF_PLATFORM PRINTK HAS_IOMEM SMP # support disabling ticking during idle LX_ENABLE += NO_HZ_IDLE diff --git a/repos/pc/src/test/driver_time/dummies.c b/repos/pc/src/test/driver_time/dummies.c index 12522c1b78..7d57dedf2a 100644 --- a/repos/pc/src/test/driver_time/dummies.c +++ b/repos/pc/src/test/driver_time/dummies.c @@ -69,3 +69,11 @@ void register_syscore_ops(struct syscore_ops * ops) { lx_emul_trace(__func__); } + + +#include + +u32 prandom_u32(void) +{ + lx_emul_trace_and_stop(__func__); +} diff --git a/repos/pc/src/test/driver_time/generated_dummies.c b/repos/pc/src/test/driver_time/generated_dummies.c index ffd8e13205..a9436b07b2 100644 --- a/repos/pc/src/test/driver_time/generated_dummies.c +++ b/repos/pc/src/test/driver_time/generated_dummies.c @@ -23,6 +23,14 @@ const char * __clk_get_name(const struct clk * clk) } +#include + +void __srcu_read_unlock(struct srcu_struct * ssp,int idx) +{ + lx_emul_trace_and_stop(__func__); +} + + #include int printk_deferred(const char * fmt,...) @@ -86,22 +94,6 @@ int kobject_synth_uevent(struct kobject * kobj,const char * buf,size_t count) } -#include - -void synchronize_srcu(struct srcu_struct * ssp) -{ - lx_emul_trace_and_stop(__func__); -} - - -#include - -void __srcu_read_unlock(struct srcu_struct * ssp,int idx) -{ - lx_emul_trace_and_stop(__func__); -} - - #include int add_uevent_var(struct kobj_uevent_env * env,const char * format,...) @@ -205,14 +197,6 @@ int smp_call_function_single(int cpu,void (* func)(void * info),void * info,int } -#include - -void srcu_drive_gp(struct work_struct * wp) -{ - lx_emul_trace_and_stop(__func__); -} - - #include unsigned long _copy_to_user(void __user * to,const void * from,unsigned long n) diff --git a/repos/pc/src/test/driver_time/source.list b/repos/pc/src/test/driver_time/source.list index de86489245..0bcffb7da8 100644 --- a/repos/pc/src/test/driver_time/source.list +++ b/repos/pc/src/test/driver_time/source.list @@ -29,6 +29,7 @@ kernel/sched/swait.c kernel/sched/wait.c kernel/sched/wait_bit.c kernel/smpboot.c +kernel/softirq.c kernel/time/clockevents.c kernel/time/clocksource.c kernel/time/hrtimer.c diff --git a/repos/pc/src/test/driver_time/target.mk b/repos/pc/src/test/driver_time/target.mk index 9f7387e135..ba7f8e5769 100644 --- a/repos/pc/src/test/driver_time/target.mk +++ b/repos/pc/src/test/driver_time/target.mk @@ -11,7 +11,6 @@ SRC_C += generated_dummies.c SRC_C += lx_emul/common_dummies.c SRC_C += lx_emul/shadow/lib/kobject_uevent.c SRC_C += lx_emul/shadow/drivers/char/random.c -SRC_C += lx_emul/shadow/kernel/softirq.c vpath %.c $(REP_DIR)/src/lib/pc vpath %.cc $(REP_DIR)/src/lib/pc