diff --git a/repos/dde_linux/src/app/wireguard/lx_emul.c b/repos/dde_linux/src/app/wireguard/lx_emul.c index f365fe9c17..19adc25fea 100644 --- a/repos/dde_linux/src/app/wireguard/lx_emul.c +++ b/repos/dde_linux/src/app/wireguard/lx_emul.c @@ -1,6 +1,7 @@ /** * \brief Dummy definitions of lx_emul * \author Stefan Kalkowski + * \author Christian Helmuth * \date 2022-01-10 */ @@ -48,9 +49,7 @@ int wait_for_random_bytes(void) u32 get_random_u32(void) { - u8 buf[4]; - lx_emul_gen_random_bytes(buf, sizeof(buf)); - return *((u32*)&buf); + return lx_emul_gen_random_uint(); } @@ -58,18 +57,16 @@ u32 get_random_u32(void) u32 prandom_u32(void) { - u8 buf[4]; - lx_emul_gen_random_bytes(buf, sizeof(buf)); - return *((u32*)&buf); + return lx_emul_gen_random_uint(); } #include -int __must_check get_random_bytes_arch(void * buf,int nbytes) +int __must_check get_random_bytes_arch(void * buf, int nbytes) { lx_emul_gen_random_bytes(buf, nbytes); - return 0; + return nbytes; } diff --git a/repos/dde_linux/src/include/lx_emul/random.h b/repos/dde_linux/src/include/lx_emul/random.h index f1dc75d289..52a3b65ad9 100644 --- a/repos/dde_linux/src/include/lx_emul/random.h +++ b/repos/dde_linux/src/include/lx_emul/random.h @@ -3,6 +3,7 @@ * \author Josef Soentgen * \author Stefan Kalkowski * \author Martin Stein + * \author Christian Helmuth * \date 2022-05-19 * * :Warning: @@ -41,6 +42,7 @@ void lx_emul_gen_random_bytes(void *dst, * Return a random unsigned integer value. */ unsigned int lx_emul_gen_random_uint(void); +unsigned long long lx_emul_gen_random_u64(void); #ifdef __cplusplus } diff --git a/repos/dde_linux/src/lib/lx_emul/random.cc b/repos/dde_linux/src/lib/lx_emul/random.cc index f679079454..a48f1515cb 100644 --- a/repos/dde_linux/src/lib/lx_emul/random.cc +++ b/repos/dde_linux/src/lib/lx_emul/random.cc @@ -3,6 +3,7 @@ * \author Josef Soentgen * \author Stefan Kalkowski * \author Martin Stein + * \author Christian Helmuth * \date 2022-05-19 * * :Warning: @@ -220,3 +221,9 @@ unsigned int lx_emul_gen_random_uint() { return (unsigned int)xoroshiro().get_u64(); } + + +unsigned long long lx_emul_gen_random_u64() +{ + return xoroshiro().get_u64(); +} diff --git a/repos/pc/lib/import/import-pc_lx_emul.mk b/repos/pc/lib/import/import-pc_lx_emul.mk index 73bb3d90a5..9c02a30e74 100644 --- a/repos/pc/lib/import/import-pc_lx_emul.mk +++ b/repos/pc/lib/import/import-pc_lx_emul.mk @@ -18,6 +18,7 @@ SRC_CC += lx_emul/clock.cc SRC_CC += lx_emul/io_mem.cc SRC_CC += lx_emul/io_port.cc 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/rcu/tree.c @@ -51,6 +52,7 @@ SRC_C += lx_emul/shadow/fs/libfs.c SRC_C += lx_emul/shadow/kernel/rcu/tiny.c SRC_C += lx_emul/shadow/lib/logic_iomem.c +SRC_C += lx_emul/shadow/drivers/char/random.c SRC_C += lx_emul/shadow/drivers/acpi/bus.c SRC_C += lx_emul/shadow/drivers/acpi/device_sysfs.c SRC_C += lx_emul/shadow/drivers/acpi/glue.c diff --git a/repos/pc/recipes/src/pc_intel_fb_drv/used_apis b/repos/pc/recipes/src/pc_intel_fb_drv/used_apis index ba755919c7..ee690e84de 100644 --- a/repos/pc/recipes/src/pc_intel_fb_drv/used_apis +++ b/repos/pc/recipes/src/pc_intel_fb_drv/used_apis @@ -1,9 +1,10 @@ base -os -platform_session -timer_session -report_session -capture_session blit +capture_session genode_c_api +jitterentropy +os pc_linux +platform_session +report_session +timer_session diff --git a/repos/pc/recipes/src/pc_usb_host_drv/used_apis b/repos/pc/recipes/src/pc_usb_host_drv/used_apis index afb8da2145..eb4df41388 100644 --- a/repos/pc/recipes/src/pc_usb_host_drv/used_apis +++ b/repos/pc/recipes/src/pc_usb_host_drv/used_apis @@ -1,8 +1,9 @@ base +genode_c_api +jitterentropy os +pc_linux platform_session +report_session timer_session usb_session -report_session -genode_c_api -pc_linux 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 888c36eb27..898a69f001 100644 --- a/repos/pc/src/drivers/framebuffer/intel/pc/generated_dummies.c +++ b/repos/pc/src/drivers/framebuffer/intel/pc/generated_dummies.c @@ -1,7 +1,7 @@ /* * \brief Dummy definitions of Linux Kernel functions * \author Automatically generated file - do no edit - * \date 2022-05-06 + * \date 2022-06-24 */ #include @@ -620,22 +620,6 @@ int get_option(char ** str,int * pint) } -#include - -u32 get_random_u32(void) -{ - lx_emul_trace_and_stop(__func__); -} - - -#include - -u64 get_random_u64(void) -{ - lx_emul_trace_and_stop(__func__); -} - - #include s32 i2c_smbus_read_block_data(const struct i2c_client * client,u8 command,u8 * values) diff --git a/repos/pc/src/drivers/framebuffer/intel/pc/target.inc b/repos/pc/src/drivers/framebuffer/intel/pc/target.inc index 235ce2e1b5..0d6b27b0a1 100644 --- a/repos/pc/src/drivers/framebuffer/intel/pc/target.inc +++ b/repos/pc/src/drivers/framebuffer/intel/pc/target.inc @@ -3,7 +3,7 @@ REQUIRES := x86 REL_PRG_DIR := $(PRG_DIR)/../.. TARGET := pc_intel_fb_drv -LIBS := base pc_lx_emul blit +LIBS := base pc_lx_emul blit jitterentropy INC_DIR += $(REL_PRG_DIR) INC_DIR += $(REL_PRG_DIR)/shadow @@ -22,7 +22,6 @@ SRC_C += timeout.c SRC_C += lx_emul/common_dummies.c SRC_C += lx_emul/spec/x86/pci.c SRC_C += lx_emul/shadow/mm/page_alloc.c -SRC_C += lx_emul/shadow/drivers/char/random.c vpath %.c $(REL_PRG_DIR) vpath %.cc $(REL_PRG_DIR) diff --git a/repos/pc/src/drivers/usb_host/pc/target.inc b/repos/pc/src/drivers/usb_host/pc/target.inc index bdee0a8fb2..3a27cb1712 100644 --- a/repos/pc/src/drivers/usb_host/pc/target.inc +++ b/repos/pc/src/drivers/usb_host/pc/target.inc @@ -3,7 +3,7 @@ REQUIRES := x86 REL_PRG_DIR := $(PRG_DIR)/../.. TARGET := pc_usb_host_drv -LIBS := base pc_lx_emul +LIBS := base pc_lx_emul jitterentropy INC_DIR += $(REL_PRG_DIR) SRC_CC += main.cc @@ -15,7 +15,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/drivers/char/random.c SRC_C += lx_emul/shadow/lib/kobject_uevent.c vpath %.c $(REP_DIR)/src/lib/pc diff --git a/repos/pc/src/lib/pc/lx_emul/shadow/drivers/char/random.c b/repos/pc/src/lib/pc/lx_emul/shadow/drivers/char/random.c index e1e6d9d818..07b57fcca6 100644 --- a/repos/pc/src/lib/pc/lx_emul/shadow/drivers/char/random.c +++ b/repos/pc/src/lib/pc/lx_emul/shadow/drivers/char/random.c @@ -1,6 +1,7 @@ /* * \brief Replaces drivers/char/random.c * \author Josef Soentgen + * \author Christian Helmuth * \date 2022-04-05 */ @@ -12,17 +13,40 @@ */ #include +#include #include -void get_random_bytes(void * buf,int nbytes) + +void add_input_randomness(unsigned int type,unsigned int code,unsigned int value) { - lx_emul_trace(__func__); + lx_emul_trace(__func__); } -int __must_check get_random_bytes_arch(void * buf,int nbytes) +u32 get_random_u32(void) { - lx_emul_trace(__func__); - return 0; + return lx_emul_gen_random_uint(); +} + + +u64 get_random_u64(void) +{ + return lx_emul_gen_random_u64(); +} + + +int __must_check get_random_bytes_arch(void *buf, int nbytes) +{ + if (nbytes < 0) + return -1; + + lx_emul_gen_random_bytes(buf, nbytes); + return nbytes; +} + + +void get_random_bytes(void *buf, int nbytes) +{ + nbytes = get_random_bytes_arch(buf, nbytes); } diff --git a/repos/pc/src/lib/wifi/generated_dummies.c b/repos/pc/src/lib/wifi/generated_dummies.c index 169d98ec4a..4fa6817810 100644 --- a/repos/pc/src/lib/wifi/generated_dummies.c +++ b/repos/pc/src/lib/wifi/generated_dummies.c @@ -1,7 +1,7 @@ /* * \brief Dummy definitions of Linux Kernel functions * \author Automatically generated file - do no edit - * \date 2022-05-06 + * \date 2022-06-24 */ #include @@ -578,11 +578,6 @@ bool is_software_node(const struct fwnode_handle * fwnode) } -#include - -unsigned long volatile __cacheline_aligned_in_smp __jiffy_arch_data jiffies; - - #include struct kobject *kernel_kobj; diff --git a/repos/pc/src/lib/wifi/lx_emul.c b/repos/pc/src/lib/wifi/lx_emul.c index 92aa7c210a..7d56801eaa 100644 --- a/repos/pc/src/lib/wifi/lx_emul.c +++ b/repos/pc/src/lib/wifi/lx_emul.c @@ -455,31 +455,6 @@ void __put_page(struct page * page) } -#include - -u32 get_random_u32(void) -{ - return lx_emul_gen_random_uint(); -} - - -int __must_check get_random_bytes_arch(void *buf, int nbytes) -{ - if (nbytes < 0) - return -1; - - lx_emul_gen_random_bytes(buf, (unsigned long)nbytes); - return 0; -} - - -void get_random_bytes(void *buf, int nbytes) -{ - int const err = get_random_bytes_arch(buf, nbytes); - (void)err; -} - - #include void prandom_bytes(void *buf, size_t bytes)