Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'for-linus-5.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/uml

Pull UML updates from Richard Weinberger:

- set_fs removal

- Devicetree support

- Many cleanups from Al

- Various virtio and build related fixes

* tag 'for-linus-5.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/uml: (31 commits)
um: virtio_uml: Allow probing from devicetree
um: Add devicetree support
um: Extract load file helper from initrd.c
um: remove set_fs
hostfs: Fix writeback of dirty pages
um: Use swap() to make code cleaner
um: header debriding - sigio.h
um: header debriding - os.h
um: header debriding - net_*.h
um: header debriding - mem_user.h
um: header debriding - activate_ipi()
um: common-offsets.h debriding...
um, x86: bury crypto_tfm_ctx_offset
um: unexport handle_page_fault()
um: remove a dangling extern of syscall_trace()
um: kill unused cpu()
uml/i386: missing include in barrier.h
um: stop polluting the namespace with registers.h contents
logic_io instance of iounmap() needs volatile on argument
um: move amd64 variant of mmap(2) to arch/x86/um/syscalls_64.c
...

+265 -235
+1
arch/um/.gitignore
··· 2 2 kernel/config.c 3 3 kernel/config.tmp 4 4 kernel/vmlinux.lds 5 + kernel/capflags.c
+1 -1
arch/um/Kconfig
··· 18 18 select HAVE_DEBUG_KMEMLEAK 19 19 select HAVE_DEBUG_BUGVERBOSE 20 20 select NO_DMA if !UML_DMA_EMULATION 21 + select OF_EARLY_FLATTREE if OF 21 22 select GENERIC_IRQ_SHOW 22 23 select GENERIC_CPU_DEVICES 23 24 select HAVE_GCC_PLUGINS 24 - select SET_FS 25 25 select TRACE_IRQFLAGS_SUPPORT 26 26 select TTY # Needed for line.c 27 27 select HAVE_ARCH_VMAP_STACK
+4 -4
arch/um/drivers/virt-pci.c
··· 181 181 /* buf->data is maximum size - we may only use parts of it */ 182 182 struct um_pci_message_buffer *buf; 183 183 u8 *data; 184 - unsigned long ret = ~0ULL; 184 + unsigned long ret = ULONG_MAX; 185 185 186 186 if (!dev) 187 - return ~0ULL; 187 + return ULONG_MAX; 188 188 189 189 buf = get_cpu_var(um_pci_msg_bufs); 190 190 data = buf->data; 191 191 192 - memset(data, 0xff, sizeof(data)); 192 + memset(buf->data, 0xff, sizeof(buf->data)); 193 193 194 194 switch (size) { 195 195 case 1: ··· 304 304 /* buf->data is maximum size - we may only use parts of it */ 305 305 struct um_pci_message_buffer *buf; 306 306 u8 *data; 307 - unsigned long ret = ~0ULL; 307 + unsigned long ret = ULONG_MAX; 308 308 309 309 buf = get_cpu_var(um_pci_msg_bufs); 310 310 data = buf->data;
+51 -3
arch/um/drivers/virtio_uml.c
··· 21 21 * Based on Virtio MMIO driver by Pawel Moll, copyright 2011-2014, ARM Ltd. 22 22 */ 23 23 #include <linux/module.h> 24 + #include <linux/of.h> 24 25 #include <linux/platform_device.h> 25 26 #include <linux/slab.h> 26 27 #include <linux/virtio.h> ··· 50 49 struct virtio_uml_device { 51 50 struct virtio_device vdev; 52 51 struct platform_device *pdev; 52 + struct virtio_uml_platform_data *pdata; 53 53 54 54 spinlock_t sock_lock; 55 55 int sock, req_fd, irq; ··· 151 149 if (rc == -ECONNRESET && vu_dev->registered) { 152 150 struct virtio_uml_platform_data *pdata; 153 151 154 - pdata = vu_dev->pdev->dev.platform_data; 152 + pdata = vu_dev->pdata; 155 153 156 154 virtio_break_device(&vu_dev->vdev); 157 155 schedule_work(&pdata->conn_broken_wk); ··· 1092 1090 container_of(d, struct virtio_device, dev); 1093 1091 struct virtio_uml_device *vu_dev = to_virtio_uml_device(vdev); 1094 1092 1093 + time_travel_propagate_time(); 1094 + 1095 1095 /* might not have been opened due to not negotiating the feature */ 1096 1096 if (vu_dev->req_fd >= 0) { 1097 1097 um_free_irq(vu_dev->irq, vu_dev); ··· 1117 1113 no_vq_suspend ? "dis" : "en"); 1118 1114 } 1119 1115 1116 + static void vu_of_conn_broken(struct work_struct *wk) 1117 + { 1118 + /* 1119 + * We can't remove the device from the devicetree so the only thing we 1120 + * can do is warn. 1121 + */ 1122 + WARN_ON(1); 1123 + } 1124 + 1120 1125 /* Platform device */ 1126 + 1127 + static struct virtio_uml_platform_data * 1128 + virtio_uml_create_pdata(struct platform_device *pdev) 1129 + { 1130 + struct device_node *np = pdev->dev.of_node; 1131 + struct virtio_uml_platform_data *pdata; 1132 + int ret; 1133 + 1134 + if (!np) 1135 + return ERR_PTR(-EINVAL); 1136 + 1137 + pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); 1138 + if (!pdata) 1139 + return ERR_PTR(-ENOMEM); 1140 + 1141 + INIT_WORK(&pdata->conn_broken_wk, vu_of_conn_broken); 1142 + pdata->pdev = pdev; 1143 + 1144 + ret = of_property_read_string(np, "socket-path", &pdata->socket_path); 1145 + if (ret) 1146 + return ERR_PTR(ret); 1147 + 1148 + ret = of_property_read_u32(np, "virtio-device-id", 1149 + &pdata->virtio_device_id); 1150 + if (ret) 1151 + return ERR_PTR(ret); 1152 + 1153 + return pdata; 1154 + } 1121 1155 1122 1156 static int virtio_uml_probe(struct platform_device *pdev) 1123 1157 { ··· 1163 1121 struct virtio_uml_device *vu_dev; 1164 1122 int rc; 1165 1123 1166 - if (!pdata) 1167 - return -EINVAL; 1124 + if (!pdata) { 1125 + pdata = virtio_uml_create_pdata(pdev); 1126 + if (IS_ERR(pdata)) 1127 + return PTR_ERR(pdata); 1128 + } 1168 1129 1169 1130 vu_dev = kzalloc(sizeof(*vu_dev), GFP_KERNEL); 1170 1131 if (!vu_dev) 1171 1132 return -ENOMEM; 1172 1133 1134 + vu_dev->pdata = pdata; 1173 1135 vu_dev->vdev.dev.parent = &pdev->dev; 1174 1136 vu_dev->vdev.dev.release = virtio_uml_release_dev; 1175 1137 vu_dev->vdev.config = &virtio_uml_config_ops; ··· 1181 1135 vu_dev->vdev.id.vendor = VIRTIO_DEV_ANY_ID; 1182 1136 vu_dev->pdev = pdev; 1183 1137 vu_dev->req_fd = -1; 1138 + 1139 + time_travel_propagate_time(); 1184 1140 1185 1141 do { 1186 1142 rc = os_connect_socket(pdata->socket_path);
+2 -2
arch/um/include/asm/delay.h
··· 14 14 ndelay(nsecs); 15 15 } 16 16 #undef ndelay 17 - #define ndelay um_ndelay 17 + #define ndelay(n) um_ndelay(n) 18 18 19 19 static inline void um_udelay(unsigned long usecs) 20 20 { ··· 26 26 udelay(usecs); 27 27 } 28 28 #undef udelay 29 - #define udelay um_udelay 29 + #define udelay(n) um_udelay(n) 30 30 #endif /* __UM_DELAY_H */
+2 -2
arch/um/include/asm/irqflags.h
··· 3 3 #define __UM_IRQFLAGS_H 4 4 5 5 extern int signals_enabled; 6 - int set_signals(int enable); 6 + int um_set_signals(int enable); 7 7 void block_signals(void); 8 8 void unblock_signals(void); 9 9 ··· 16 16 #define arch_local_irq_restore arch_local_irq_restore 17 17 static inline void arch_local_irq_restore(unsigned long flags) 18 18 { 19 - set_signals(flags); 19 + um_set_signals(flags); 20 20 } 21 21 22 22 #define arch_local_irq_enable arch_local_irq_enable
+1 -1
arch/um/include/asm/processor-generic.h
··· 11 11 struct task_struct; 12 12 13 13 #include <asm/ptrace.h> 14 - #include <registers.h> 15 14 #include <sysdep/archsetjmp.h> 16 15 17 16 #include <linux/prefetch.h> ··· 104 105 #define current_cpu_data boot_cpu_data 105 106 #define cache_line_size() (boot_cpu_data.cache_alignment) 106 107 108 + extern unsigned long get_thread_reg(int reg, jmp_buf *buf); 107 109 #define KSTK_REG(tsk, reg) get_thread_reg(reg, &tsk->thread.switch_buf) 108 110 extern unsigned long __get_wchan(struct task_struct *p); 109 111
-4
arch/um/include/asm/thread_info.h
··· 22 22 __u32 cpu; /* current CPU */ 23 23 int preempt_count; /* 0 => preemptable, 24 24 <0 => BUG */ 25 - mm_segment_t addr_limit; /* thread address space: 26 - 0-0xBFFFFFFF for user 27 - 0-0xFFFFFFFF for kernel */ 28 25 struct thread_info *real_thread; /* Points to non-IRQ stack */ 29 26 unsigned long aux_fp_regs[FP_SIZE]; /* auxiliary fp_regs to save/restore 30 27 them out-of-band */ ··· 33 36 .flags = 0, \ 34 37 .cpu = 0, \ 35 38 .preempt_count = INIT_PREEMPT_COUNT, \ 36 - .addr_limit = KERNEL_DS, \ 37 39 .real_thread = NULL, \ 38 40 } 39 41
+19 -2
arch/um/include/asm/uaccess.h
··· 8 8 #define __UM_UACCESS_H 9 9 10 10 #include <asm/elf.h> 11 + #include <asm/unaligned.h> 11 12 12 13 #define __under_task_size(addr, size) \ 13 14 (((unsigned long) (addr) < TASK_SIZE) && \ ··· 40 39 { 41 40 return __addr_range_nowrap(addr, size) && 42 41 (__under_task_size(addr, size) || 43 - __access_ok_vsyscall(addr, size) || 44 - uaccess_kernel()); 42 + __access_ok_vsyscall(addr, size)); 45 43 } 44 + 45 + /* no pagefaults for kernel addresses in um */ 46 + #define HAVE_GET_KERNEL_NOFAULT 1 47 + 48 + #define __get_kernel_nofault(dst, src, type, err_label) \ 49 + do { \ 50 + *((type *)dst) = get_unaligned((type *)(src)); \ 51 + if (0) /* make sure the label looks used to the compiler */ \ 52 + goto err_label; \ 53 + } while (0) 54 + 55 + #define __put_kernel_nofault(dst, src, type, err_label) \ 56 + do { \ 57 + put_unaligned(*((type *)src), (type *)(dst)); \ 58 + if (0) /* make sure the label looks used to the compiler */ \ 59 + goto err_label; \ 60 + } while (0) 46 61 47 62 #endif
-15
arch/um/include/shared/common-offsets.h
··· 9 9 DEFINE(UM_KERN_PAGE_SHIFT, PAGE_SHIFT); 10 10 DEFINE(UM_NSEC_PER_SEC, NSEC_PER_SEC); 11 11 12 - DEFINE(UM_ELF_CLASS, ELF_CLASS); 13 - DEFINE(UM_ELFCLASS32, ELFCLASS32); 14 - DEFINE(UM_ELFCLASS64, ELFCLASS64); 15 - 16 - DEFINE(UM_NR_CPUS, NR_CPUS); 17 - 18 12 DEFINE(UM_GFP_KERNEL, GFP_KERNEL); 19 13 DEFINE(UM_GFP_ATOMIC, GFP_ATOMIC); 20 14 21 - /* For crypto assembler code. */ 22 - DEFINE(crypto_tfm_ctx_offset, offsetof(struct crypto_tfm, __crt_ctx)); 23 - 24 15 DEFINE(UM_THREAD_SIZE, THREAD_SIZE); 25 16 26 - DEFINE(UM_HZ, HZ); 27 - 28 - DEFINE(UM_USEC_PER_SEC, USEC_PER_SEC); 29 17 DEFINE(UM_NSEC_PER_SEC, NSEC_PER_SEC); 30 18 DEFINE(UM_NSEC_PER_USEC, NSEC_PER_USEC); 31 19 32 20 #ifdef CONFIG_PRINTK 33 21 DEFINE(UML_CONFIG_PRINTK, CONFIG_PRINTK); 34 - #endif 35 - #ifdef CONFIG_NO_HZ_COMMON 36 - DEFINE(UML_CONFIG_NO_HZ_COMMON, CONFIG_NO_HZ_COMMON); 37 22 #endif 38 23 #ifdef CONFIG_UML_X86 39 24 DEFINE(UML_CONFIG_UML_X86, CONFIG_UML_X86);
-1
arch/um/include/shared/irq_user.h
··· 20 20 extern void free_irq_by_fd(int fd); 21 21 extern void deactivate_fd(int fd, int irqnum); 22 22 extern int deactivate_all_fds(void); 23 - extern int activate_ipi(int fd, int pid); 24 23 25 24 #endif
-2
arch/um/include/shared/kern_util.h
··· 53 53 extern int __cant_sleep(void); 54 54 extern int get_current_pid(void); 55 55 extern int copy_from_user_proc(void *to, void *from, int size); 56 - extern int cpu(void); 57 56 extern char *uml_strdup(const char *string); 58 57 59 58 extern unsigned long to_irq_stack(unsigned long *mask_out); 60 59 extern unsigned long from_irq_stack(int nested); 61 60 62 - extern void syscall_trace(struct uml_pt_regs *regs, int entryexit); 63 61 extern int singlestepping(void *t); 64 62 65 63 extern void segv_handler(int sig, struct siginfo *unused_si, struct uml_pt_regs *regs);
+1 -1
arch/um/include/shared/longjmp.h
··· 18 18 enable = *(volatile int *)&signals_enabled; \ 19 19 n = setjmp(*buf); \ 20 20 if(n != 0) \ 21 - set_signals_trace(enable); \ 21 + um_set_signals_trace(enable); \ 22 22 n; }) 23 23 24 24 #endif
-5
arch/um/include/shared/mem_user.h
··· 46 46 47 47 #define ROUND_4M(n) ((((unsigned long) (n)) + (1 << 22)) & ~((1 << 22) - 1)) 48 48 49 - extern int init_mem_user(void); 50 - extern void setup_memory(void *entry); 51 49 extern unsigned long find_iomem(char *driver, unsigned long *len_out); 52 50 extern void mem_total_pages(unsigned long physmem, unsigned long iomem, 53 51 unsigned long highmem); 54 - extern unsigned long get_vm(unsigned long len); 55 52 extern void setup_physmem(unsigned long start, unsigned long usable, 56 53 unsigned long len, unsigned long long highmem); 57 - extern void add_iomem(char *name, int fd, unsigned long size); 58 - extern unsigned long phys_offset(unsigned long phys); 59 54 extern void map_memory(unsigned long virt, unsigned long phys, 60 55 unsigned long len, int r, int w, int x); 61 56
-2
arch/um/include/shared/net_kern.h
··· 59 59 const int setup_size; 60 60 }; 61 61 62 - extern struct net_device *ether_init(int); 63 - extern unsigned short ether_protocol(struct sk_buff *); 64 62 extern int tap_setup_common(char *str, char *type, char **dev_name, 65 63 char **mac_out, char **gate_addr); 66 64 extern void register_transport(struct transport *new);
-1
arch/um/include/shared/net_user.h
··· 24 24 int mtu; 25 25 }; 26 26 27 - extern void ether_user_init(void *data, void *dev); 28 27 extern void iter_addresses(void *d, void (*cb)(unsigned char *, 29 28 unsigned char *, void *), 30 29 void *arg);
+2 -15
arch/um/include/shared/os.h
··· 159 159 extern int os_shutdown_socket(int fd, int r, int w); 160 160 extern void os_close_file(int fd); 161 161 extern int os_rcv_fd(int fd, int *helper_pid_out); 162 - extern int create_unix_socket(char *file, int len, int close_on_exec); 163 162 extern int os_connect_socket(const char *name); 164 163 extern int os_file_type(char *file); 165 164 extern int os_file_mode(const char *file, struct openflags *mode_out); 166 165 extern int os_lock_file(int fd, int excl); 167 166 extern void os_flush_stdout(void); 168 - extern int os_stat_filesystem(char *path, long *bsize_out, 169 - long long *blocks_out, long long *bfree_out, 170 - long long *bavail_out, long long *files_out, 171 - long long *ffree_out, void *fsid_out, 172 - int fsid_size, long *namelen_out, 173 - long *spare_out); 174 - extern int os_change_dir(char *dir); 175 - extern int os_fchange_dir(int fd); 176 167 extern unsigned os_major(unsigned long long dev); 177 168 extern unsigned os_minor(unsigned long long dev); 178 169 extern unsigned long long os_makedev(unsigned major, unsigned minor); ··· 223 232 /* signal.c */ 224 233 extern void timer_set_signal_handler(void); 225 234 extern void set_sigstack(void *sig_stack, int size); 226 - extern void remove_sigstack(void); 227 235 extern void set_handler(int sig); 228 236 extern void send_sigio_to_self(void); 229 237 extern int change_sig(int signal, int on); 230 238 extern void block_signals(void); 231 239 extern void unblock_signals(void); 232 - extern int set_signals(int enable); 233 - extern int set_signals_trace(int enable); 240 + extern int um_set_signals(int enable); 241 + extern int um_set_signals_trace(int enable); 234 242 extern int os_is_signal_stack(void); 235 243 extern void deliver_alarm(void); 236 244 extern void register_pm_wake_signal(void); ··· 256 266 extern int os_timer_set_interval(unsigned long long nsecs); 257 267 extern int os_timer_one_shot(unsigned long long nsecs); 258 268 extern void os_timer_disable(void); 259 - extern void uml_idle_timer(void); 260 269 extern long long os_persistent_clock_emulation(void); 261 270 extern long long os_nsecs(void); 262 271 ··· 279 290 extern int start_userspace(unsigned long stub_stack); 280 291 extern int copy_context_skas0(unsigned long stack, int pid); 281 292 extern void userspace(struct uml_pt_regs *regs, unsigned long *aux_fp_regs); 282 - extern int map_stub_pages(int fd, unsigned long code, unsigned long data, 283 - unsigned long stack); 284 293 extern void new_thread(void *stack, jmp_buf *buf, void (*handler)(void)); 285 294 extern void switch_threads(jmp_buf *me, jmp_buf *you); 286 295 extern int start_idle_thread(void *stack, jmp_buf *switch_buf);
+2 -4
arch/um/include/shared/registers.h
··· 7 7 #define __REGISTERS_H 8 8 9 9 #include <sysdep/ptrace.h> 10 - #include <sysdep/archsetjmp.h> 11 10 12 11 extern int save_i387_registers(int pid, unsigned long *fp_regs); 13 12 extern int restore_i387_registers(int pid, unsigned long *fp_regs); ··· 15 16 extern int save_fpx_registers(int pid, unsigned long *fp_regs); 16 17 extern int restore_fpx_registers(int pid, unsigned long *fp_regs); 17 18 extern int save_registers(int pid, struct uml_pt_regs *regs); 18 - extern int restore_registers(int pid, struct uml_pt_regs *regs); 19 - extern int init_registers(int pid); 19 + extern int restore_pid_registers(int pid, struct uml_pt_regs *regs); 20 + extern int init_pid_registers(int pid); 20 21 extern void get_safe_registers(unsigned long *regs, unsigned long *fp_regs); 21 - extern unsigned long get_thread_reg(int reg, jmp_buf *buf); 22 22 extern int get_fp_registers(int pid, unsigned long *regs); 23 23 extern int put_fp_registers(int pid, unsigned long *regs); 24 24
-1
arch/um/include/shared/sigio.h
··· 7 7 #define __SIGIO_H__ 8 8 9 9 extern int write_sigio_irq(int fd); 10 - extern int register_sigio_fd(int fd); 11 10 extern void sigio_lock(void); 12 11 extern void sigio_unlock(void); 13 12
+3 -1
arch/um/kernel/Makefile
··· 16 16 17 17 obj-y = config.o exec.o exitcode.o irq.o ksyms.o mem.o \ 18 18 physmem.o process.o ptrace.o reboot.o sigio.o \ 19 - signal.o syscall.o sysrq.o time.o tlb.o trap.o \ 19 + signal.o sysrq.o time.o tlb.o trap.o \ 20 20 um_arch.o umid.o maccess.o kmsg_dump.o capflags.o skas/ 21 + obj-y += load_file.o 21 22 22 23 obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o 23 24 obj-$(CONFIG_GPROF) += gprof_syms.o 25 + obj-$(CONFIG_OF) += dtb.o 24 26 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o 25 27 obj-$(CONFIG_STACKTRACE) += stacktrace.o 26 28 obj-$(CONFIG_GENERIC_PCI_IOMAP) += ioport.o
+41
arch/um/kernel/dtb.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + 3 + #include <linux/init.h> 4 + #include <linux/of_fdt.h> 5 + #include <linux/printk.h> 6 + #include <linux/memblock.h> 7 + #include <init.h> 8 + 9 + #include "um_arch.h" 10 + 11 + static char *dtb __initdata; 12 + 13 + void uml_dtb_init(void) 14 + { 15 + long long size; 16 + void *area; 17 + 18 + area = uml_load_file(dtb, &size); 19 + if (!area) 20 + return; 21 + 22 + if (!early_init_dt_scan(area)) { 23 + pr_err("invalid DTB %s\n", dtb); 24 + memblock_free(area, size); 25 + return; 26 + } 27 + 28 + unflatten_device_tree(); 29 + early_init_fdt_scan_reserved_mem(); 30 + } 31 + 32 + static int __init uml_dtb_setup(char *line, int *add) 33 + { 34 + dtb = line; 35 + return 0; 36 + } 37 + 38 + __uml_setup("dtb=", uml_dtb_setup, 39 + "dtb=<file>\n" 40 + " Boot the kernel with the devicetree blob from the specified file.\n" 41 + );
+1
arch/um/kernel/exec.c
··· 16 16 #include <linux/uaccess.h> 17 17 #include <as-layout.h> 18 18 #include <mem_user.h> 19 + #include <registers.h> 19 20 #include <skas.h> 20 21 #include <os.h> 21 22
+5 -43
arch/um/kernel/initrd.c
··· 10 10 #include <init.h> 11 11 #include <os.h> 12 12 13 + #include "um_arch.h" 14 + 13 15 /* Changed by uml_initrd_setup, which is a setup */ 14 16 static char *initrd __initdata = NULL; 15 - static int load_initrd(char *filename, void *buf, int size); 16 17 17 18 int __init read_initrd(void) 18 19 { 20 + unsigned long long size; 19 21 void *area; 20 - long long size; 21 - int err; 22 22 23 - if (initrd == NULL) 23 + if (!initrd) 24 24 return 0; 25 25 26 - err = os_file_size(initrd, &size); 27 - if (err) 28 - return 0; 29 - 30 - /* 31 - * This is necessary because alloc_bootmem craps out if you 32 - * ask for no memory. 33 - */ 34 - if (size == 0) { 35 - printk(KERN_ERR "\"%s\" is a zero-size initrd\n", initrd); 36 - return 0; 37 - } 38 - 39 - area = memblock_alloc(size, SMP_CACHE_BYTES); 26 + area = uml_load_file(initrd, &size); 40 27 if (!area) 41 - panic("%s: Failed to allocate %llu bytes\n", __func__, size); 42 - 43 - if (load_initrd(initrd, area, size) == -1) 44 28 return 0; 45 29 46 30 initrd_start = (unsigned long) area; ··· 43 59 " This is used to boot UML from an initrd image. The argument is the\n" 44 60 " name of the file containing the image.\n\n" 45 61 ); 46 - 47 - static int load_initrd(char *filename, void *buf, int size) 48 - { 49 - int fd, n; 50 - 51 - fd = os_open_file(filename, of_read(OPENFLAGS()), 0); 52 - if (fd < 0) { 53 - printk(KERN_ERR "Opening '%s' failed - err = %d\n", filename, 54 - -fd); 55 - return -1; 56 - } 57 - n = os_read_file(fd, buf, size); 58 - if (n != size) { 59 - printk(KERN_ERR "Read of %d bytes from '%s' failed, " 60 - "err = %d\n", size, 61 - filename, -n); 62 - return -1; 63 - } 64 - 65 - os_close_file(fd); 66 - return 0; 67 - }
+1 -1
arch/um/kernel/ksyms.c
··· 6 6 #include <linux/module.h> 7 7 #include <os.h> 8 8 9 - EXPORT_SYMBOL(set_signals); 9 + EXPORT_SYMBOL(um_set_signals); 10 10 EXPORT_SYMBOL(signals_enabled); 11 11 12 12 EXPORT_SYMBOL(os_stat_fd);
+61
arch/um/kernel/load_file.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) 4 + */ 5 + #include <linux/memblock.h> 6 + #include <os.h> 7 + 8 + #include "um_arch.h" 9 + 10 + static int __init __uml_load_file(const char *filename, void *buf, int size) 11 + { 12 + int fd, n; 13 + 14 + fd = os_open_file(filename, of_read(OPENFLAGS()), 0); 15 + if (fd < 0) { 16 + printk(KERN_ERR "Opening '%s' failed - err = %d\n", filename, 17 + -fd); 18 + return -1; 19 + } 20 + n = os_read_file(fd, buf, size); 21 + if (n != size) { 22 + printk(KERN_ERR "Read of %d bytes from '%s' failed, " 23 + "err = %d\n", size, 24 + filename, -n); 25 + return -1; 26 + } 27 + 28 + os_close_file(fd); 29 + return 0; 30 + } 31 + 32 + void *uml_load_file(const char *filename, unsigned long long *size) 33 + { 34 + void *area; 35 + int err; 36 + 37 + *size = 0; 38 + 39 + if (!filename) 40 + return NULL; 41 + 42 + err = os_file_size(filename, size); 43 + if (err) 44 + return NULL; 45 + 46 + if (*size == 0) { 47 + printk(KERN_ERR "\"%s\" is empty\n", filename); 48 + return NULL; 49 + } 50 + 51 + area = memblock_alloc(*size, SMP_CACHE_BYTES); 52 + if (!area) 53 + panic("%s: Failed to allocate %llu bytes\n", __func__, *size); 54 + 55 + if (__uml_load_file(filename, area, *size)) { 56 + memblock_free(area, *size); 57 + return NULL; 58 + } 59 + 60 + return area; 61 + }
+1 -2
arch/um/kernel/mem.c
··· 85 85 __func__, PAGE_SIZE, PAGE_SIZE); 86 86 87 87 set_pud(pud, __pud(_KERNPG_TABLE + (unsigned long) __pa(pmd_table))); 88 - if (pmd_table != pmd_offset(pud, 0)) 89 - BUG(); 88 + BUG_ON(pmd_table != pmd_offset(pud, 0)); 90 89 #endif 91 90 } 92 91
+1 -5
arch/um/kernel/process.c
··· 31 31 #include <kern_util.h> 32 32 #include <os.h> 33 33 #include <skas.h> 34 + #include <registers.h> 34 35 #include <linux/time-internal.h> 35 36 36 37 /* ··· 262 261 int clear_user_proc(void __user *buf, int size) 263 262 { 264 263 return clear_user(buf, size); 265 - } 266 - 267 - int cpu(void) 268 - { 269 - return current_thread_info()->cpu; 270 264 } 271 265 272 266 static atomic_t using_sysemu = ATOMIC_INIT(0);
-25
arch/um/kernel/skas/uaccess.c
··· 146 146 147 147 unsigned long raw_copy_from_user(void *to, const void __user *from, unsigned long n) 148 148 { 149 - if (uaccess_kernel()) { 150 - memcpy(to, (__force void*)from, n); 151 - return 0; 152 - } 153 - 154 149 return buffer_op((unsigned long) from, n, 0, copy_chunk_from_user, &to); 155 150 } 156 151 EXPORT_SYMBOL(raw_copy_from_user); ··· 161 166 162 167 unsigned long raw_copy_to_user(void __user *to, const void *from, unsigned long n) 163 168 { 164 - if (uaccess_kernel()) { 165 - memcpy((__force void *) to, from, n); 166 - return 0; 167 - } 168 - 169 169 return buffer_op((unsigned long) to, n, 1, copy_chunk_to_user, &from); 170 170 } 171 171 EXPORT_SYMBOL(raw_copy_to_user); ··· 186 196 187 197 if (!access_ok(src, 1)) 188 198 return -EFAULT; 189 - 190 - if (uaccess_kernel()) { 191 - strncpy(dst, (__force void *) src, count); 192 - return strnlen(dst, count); 193 - } 194 - 195 199 n = buffer_op((unsigned long) src, count, 0, strncpy_chunk_from_user, 196 200 &ptr); 197 201 if (n != 0) ··· 202 218 203 219 unsigned long __clear_user(void __user *mem, unsigned long len) 204 220 { 205 - if (uaccess_kernel()) { 206 - memset((__force void*)mem, 0, len); 207 - return 0; 208 - } 209 - 210 221 return buffer_op((unsigned long) mem, len, 1, clear_chunk, NULL); 211 222 } 212 223 EXPORT_SYMBOL(__clear_user); ··· 224 245 225 246 if (!access_ok(str, 1)) 226 247 return -EFAULT; 227 - 228 - if (uaccess_kernel()) 229 - return strnlen((__force char*)str, len) + 1; 230 - 231 248 n = buffer_op((unsigned long) str, len, 0, strnlen_chunk, &count); 232 249 if (n == 0) 233 250 return count + 1;
-28
arch/um/kernel/syscall.c
··· 1 - // SPDX-License-Identifier: GPL-2.0 2 - /* 3 - * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) 4 - */ 5 - 6 - #include <linux/file.h> 7 - #include <linux/fs.h> 8 - #include <linux/mm.h> 9 - #include <linux/sched.h> 10 - #include <linux/utsname.h> 11 - #include <linux/syscalls.h> 12 - #include <asm/current.h> 13 - #include <asm/mman.h> 14 - #include <linux/uaccess.h> 15 - #include <asm/unistd.h> 16 - 17 - long old_mmap(unsigned long addr, unsigned long len, 18 - unsigned long prot, unsigned long flags, 19 - unsigned long fd, unsigned long offset) 20 - { 21 - long err = -EINVAL; 22 - if (offset & ~PAGE_MASK) 23 - goto out; 24 - 25 - err = ksys_mmap_pgoff(addr, len, prot, flags, fd, offset >> PAGE_SHIFT); 26 - out: 27 - return err; 28 - }
-1
arch/um/kernel/trap.c
··· 127 127 pagefault_out_of_memory(); 128 128 return 0; 129 129 } 130 - EXPORT_SYMBOL(handle_page_fault); 131 130 132 131 static void show_segv_info(struct uml_pt_regs *regs) 133 132 {
+3
arch/um/kernel/um_arch.c
··· 29 29 #include <mem_user.h> 30 30 #include <os.h> 31 31 32 + #include "um_arch.h" 33 + 32 34 #define DEFAULT_COMMAND_LINE_ROOT "root=98:0" 33 35 #define DEFAULT_COMMAND_LINE_CONSOLE "console=tty" 34 36 ··· 409 407 stack_protections((unsigned long) &init_thread_info); 410 408 setup_physmem(uml_physmem, uml_reserved, physmem_size, highmem); 411 409 mem_total_pages(physmem_size, iomem_size, highmem); 410 + uml_dtb_init(); 412 411 read_initrd(); 413 412 414 413 paging_init();
+14
arch/um/kernel/um_arch.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-only */ 2 + 3 + #ifndef __UML_ARCH_H__ 4 + #define __UML_ARCH_H__ 5 + 6 + extern void * __init uml_load_file(const char *filename, unsigned long long *size); 7 + 8 + #ifdef CONFIG_OF 9 + extern void __init uml_dtb_init(void); 10 + #else 11 + static inline void uml_dtb_init(void) { } 12 + #endif 13 + 14 + #endif
+2 -2
arch/um/os-Linux/registers.c
··· 21 21 return 0; 22 22 } 23 23 24 - int restore_registers(int pid, struct uml_pt_regs *regs) 24 + int restore_pid_registers(int pid, struct uml_pt_regs *regs) 25 25 { 26 26 int err; 27 27 ··· 36 36 static unsigned long exec_regs[MAX_REG_NR]; 37 37 static unsigned long exec_fp_regs[FP_SIZE]; 38 38 39 - int init_registers(int pid) 39 + int init_pid_registers(int pid) 40 40 { 41 41 int err; 42 42
+6 -7
arch/um/os-Linux/sigio.c
··· 3 3 * Copyright (C) 2002 - 2008 Jeff Dike (jdike@{addtoit,linux.intel}.com) 4 4 */ 5 5 6 + #include <linux/minmax.h> 6 7 #include <unistd.h> 7 8 #include <errno.h> 8 9 #include <fcntl.h> ··· 51 50 52 51 static int write_sigio_thread(void *unused) 53 52 { 54 - struct pollfds *fds, tmp; 53 + struct pollfds *fds; 55 54 struct pollfd *p; 56 55 int i, n, respond_fd; 57 56 char c; ··· 78 77 "write_sigio_thread : " 79 78 "read on socket failed, " 80 79 "err = %d\n", errno); 81 - tmp = current_poll; 82 - current_poll = next_poll; 83 - next_poll = tmp; 80 + swap(current_poll, next_poll); 84 81 respond_fd = sigio_private[1]; 85 82 } 86 83 else { ··· 131 132 int n; 132 133 char c; 133 134 134 - flags = set_signals_trace(0); 135 + flags = um_set_signals_trace(0); 135 136 CATCH_EINTR(n = write(sigio_private[0], &c, sizeof(c))); 136 137 if (n != sizeof(c)) { 137 138 printk(UM_KERN_ERR "update_thread : write failed, err = %d\n", ··· 146 147 goto fail; 147 148 } 148 149 149 - set_signals_trace(flags); 150 + um_set_signals_trace(flags); 150 151 return; 151 152 fail: 152 153 /* Critical section start */ ··· 160 161 close(write_sigio_fds[0]); 161 162 close(write_sigio_fds[1]); 162 163 /* Critical section end */ 163 - set_signals_trace(flags); 164 + um_set_signals_trace(flags); 164 165 } 165 166 166 167 int __add_sigio_fd(int fd)
+4 -4
arch/um/os-Linux/signal.c
··· 94 94 95 95 sig_handler_common(sig, si, mc); 96 96 97 - set_signals_trace(enabled); 97 + um_set_signals_trace(enabled); 98 98 } 99 99 100 100 static void timer_real_alarm_handler(mcontext_t *mc) ··· 126 126 127 127 signals_active &= ~SIGALRM_MASK; 128 128 129 - set_signals_trace(enabled); 129 + um_set_signals_trace(enabled); 130 130 } 131 131 132 132 void deliver_alarm(void) { ··· 348 348 } 349 349 } 350 350 351 - int set_signals(int enable) 351 + int um_set_signals(int enable) 352 352 { 353 353 int ret; 354 354 if (signals_enabled == enable) ··· 362 362 return ret; 363 363 } 364 364 365 - int set_signals_trace(int enable) 365 + int um_set_signals_trace(int enable) 366 366 { 367 367 int ret; 368 368 if (signals_enabled == enable)
+1 -1
arch/um/os-Linux/start_up.c
··· 368 368 check_tmpexec(); 369 369 370 370 pid = start_ptraced_child(); 371 - if (init_registers(pid)) 371 + if (init_pid_registers(pid)) 372 372 fatal("Failed to initialize default registers"); 373 373 stop_ptraced_child(pid, 1, 1); 374 374 }
-3
arch/x86/kernel/asm-offsets.c
··· 38 38 #endif 39 39 40 40 BLANK(); 41 - OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx); 42 - 43 - BLANK(); 44 41 OFFSET(pbe_address, pbe, address); 45 42 OFFSET(pbe_orig_address, pbe, orig_address); 46 43 OFFSET(pbe_next, pbe, next);
+1 -1
arch/x86/um/Makefile
··· 40 40 -Iarch/x86/include/generated 41 41 targets += user-offsets.s 42 42 43 - include/generated/user_constants.h: $(obj)/user-offsets.s 43 + include/generated/user_constants.h: $(obj)/user-offsets.s FORCE 44 44 $(call filechk,offsets,__USER_CONSTANT_H__) 45 45 46 46 UNPROFILE_OBJS := stub_segv.o
+1
arch/x86/um/asm/barrier.h
··· 2 2 #ifndef _ASM_UM_BARRIER_H_ 3 3 #define _ASM_UM_BARRIER_H_ 4 4 5 + #include <asm/cpufeatures.h> 5 6 #include <asm/alternative.h> 6 7 7 8 /*
-8
arch/x86/um/asm/segment.h
··· 8 8 #define GDT_ENTRY_TLS_MIN host_gdt_entry_tls_min 9 9 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1) 10 10 11 - typedef struct { 12 - unsigned long seg; 13 - } mm_segment_t; 14 - 15 - #define MAKE_MM_SEG(s) ((mm_segment_t) { (s) }) 16 - #define KERNEL_DS MAKE_MM_SEG(~0UL) 17 - #define USER_DS MAKE_MM_SEG(TASK_SIZE) 18 - 19 11 #endif
+1
arch/x86/um/os-Linux/registers.c
··· 15 15 #include <sys/uio.h> 16 16 #include <asm/sigcontext.h> 17 17 #include <linux/elf.h> 18 + #include <registers.h> 18 19 19 20 int have_xstate_support; 20 21
+1
arch/x86/um/ptrace_32.c
··· 7 7 #include <linux/sched.h> 8 8 #include <linux/uaccess.h> 9 9 #include <asm/ptrace-abi.h> 10 + #include <registers.h> 10 11 #include <skas.h> 11 12 12 13 extern int arch_switch_tls(struct task_struct *to);
+1
arch/x86/um/ptrace_64.c
··· 11 11 #define __FRAME_OFFSETS 12 12 #include <asm/ptrace.h> 13 13 #include <linux/uaccess.h> 14 + #include <registers.h> 14 15 #include <asm/ptrace-abi.h> 15 16 16 17 /*
-3
arch/x86/um/shared/sysdep/syscalls_64.h
··· 23 23 UPT_SYSCALL_ARG5(&regs->regs), \ 24 24 UPT_SYSCALL_ARG6(&regs->regs))) 25 25 26 - extern long old_mmap(unsigned long addr, unsigned long len, 27 - unsigned long prot, unsigned long flags, 28 - unsigned long fd, unsigned long pgoff); 29 26 extern syscall_handler_t sys_modify_ldt; 30 27 extern syscall_handler_t sys_arch_prctl; 31 28
+1
arch/x86/um/signal.c
··· 12 12 #include <linux/uaccess.h> 13 13 #include <asm/ucontext.h> 14 14 #include <frame_kern.h> 15 + #include <registers.h> 15 16 #include <skas.h> 16 17 17 18 #ifdef CONFIG_X86_32
-4
arch/x86/um/sys_call_table_32.c
··· 9 9 #include <linux/cache.h> 10 10 #include <asm/syscall.h> 11 11 12 - #define __NO_STUBS 13 - 14 12 /* 15 13 * Below you can see, in terms of #define's, the differences between the x86-64 16 14 * and the UML syscall table. ··· 20 22 21 23 #define sys_vm86old sys_ni_syscall 22 24 #define sys_vm86 sys_ni_syscall 23 - 24 - #define old_mmap sys_old_mmap 25 25 26 26 #define __SYSCALL_WITH_COMPAT(nr, native, compat) __SYSCALL(nr, native) 27 27
-17
arch/x86/um/sys_call_table_64.c
··· 9 9 #include <linux/cache.h> 10 10 #include <asm/syscall.h> 11 11 12 - #define __NO_STUBS 13 - 14 12 /* 15 13 * Below you can see, in terms of #define's, the differences between the x86-64 16 14 * and the UML syscall table. ··· 17 19 /* Not going to be implemented by UML, since we have no hardware. */ 18 20 #define sys_iopl sys_ni_syscall 19 21 #define sys_ioperm sys_ni_syscall 20 - 21 - /* 22 - * The UML TLS problem. Note that x86_64 does not implement this, so the below 23 - * is needed only for the ia32 compatibility. 24 - */ 25 - 26 - /* On UML we call it this way ("old" means it's not mmap2) */ 27 - #define sys_mmap old_mmap 28 - 29 - #define stub_clone sys_clone 30 - #define stub_fork sys_fork 31 - #define stub_vfork sys_vfork 32 - #define stub_execve sys_execve 33 - #define stub_execveat sys_execveat 34 - #define stub_rt_sigreturn sys_rt_sigreturn 35 22 36 23 #define __SYSCALL(nr, sym) extern asmlinkage long sym(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long); 37 24 #include <asm/syscalls_64.h>
+13 -1
arch/x86/um/syscalls_64.c
··· 10 10 #include <linux/syscalls.h> 11 11 #include <linux/uaccess.h> 12 12 #include <asm/prctl.h> /* XXX This should get the constants from libc */ 13 + #include <registers.h> 13 14 #include <os.h> 15 + #include <registers.h> 14 16 15 17 long arch_prctl(struct task_struct *task, int option, 16 18 unsigned long __user *arg2) ··· 37 35 switch (option) { 38 36 case ARCH_SET_FS: 39 37 case ARCH_SET_GS: 40 - ret = restore_registers(pid, &current->thread.regs.regs); 38 + ret = restore_pid_registers(pid, &current->thread.regs.regs); 41 39 if (ret) 42 40 return ret; 43 41 break; ··· 88 86 return; 89 87 90 88 arch_prctl(to, ARCH_SET_FS, (void __user *) to->thread.arch.fs); 89 + } 90 + 91 + SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len, 92 + unsigned long, prot, unsigned long, flags, 93 + unsigned long, fd, unsigned long, off) 94 + { 95 + if (off & ~PAGE_MASK) 96 + return -EINVAL; 97 + 98 + return ksys_mmap_pgoff(addr, len, prot, flags, fd, off >> PAGE_SHIFT); 91 99 }
+3
fs/hostfs/hostfs_kern.c
··· 924 924 sb->s_op = &hostfs_sbops; 925 925 sb->s_d_op = &simple_dentry_operations; 926 926 sb->s_maxbytes = MAX_LFS_FILESIZE; 927 + err = super_setup_bdi(sb); 928 + if (err) 929 + goto out; 927 930 928 931 /* NULL is printed as '(null)' by printf(): avoid that. */ 929 932 if (req_root == NULL)
+1 -1
include/asm-generic/logic_io.h
··· 34 34 void __iomem *ioremap(phys_addr_t offset, size_t size); 35 35 36 36 #define iounmap iounmap 37 - void iounmap(void __iomem *addr); 37 + void iounmap(void volatile __iomem *addr); 38 38 39 39 #define __raw_readb __raw_readb 40 40 u8 __raw_readb(const volatile void __iomem *addr);
+12 -11
lib/logic_iomem.c
··· 21 21 22 22 #define AREA_SHIFT 24 23 23 #define MAX_AREA_SIZE (1 << AREA_SHIFT) 24 - #define MAX_AREAS ((1ULL<<32) / MAX_AREA_SIZE) 24 + #define MAX_AREAS ((1U << 31) / MAX_AREA_SIZE) 25 25 #define AREA_BITS ((MAX_AREAS - 1) << AREA_SHIFT) 26 26 #define AREA_MASK (MAX_AREA_SIZE - 1) 27 27 #ifdef CONFIG_64BIT 28 28 #define IOREMAP_BIAS 0xDEAD000000000000UL 29 29 #define IOREMAP_MASK 0xFFFFFFFF00000000UL 30 30 #else 31 - #define IOREMAP_BIAS 0 32 - #define IOREMAP_MASK 0 31 + #define IOREMAP_BIAS 0x80000000UL 32 + #define IOREMAP_MASK 0x80000000UL 33 33 #endif 34 34 35 35 static DEFINE_MUTEX(regions_mtx); ··· 76 76 return NULL; 77 77 } 78 78 79 - static void real_iounmap(void __iomem *addr) 79 + static void real_iounmap(volatile void __iomem *addr) 80 80 { 81 81 WARN(1, "invalid iounmap for addr 0x%llx\n", 82 - (unsigned long long __force)addr); 82 + (unsigned long long)(uintptr_t __force)addr); 83 83 } 84 84 #endif /* CONFIG_LOGIC_IOMEM_FALLBACK */ 85 85 ··· 149 149 return NULL; 150 150 } 151 151 152 - void iounmap(void __iomem *addr) 152 + void iounmap(volatile void __iomem *addr) 153 153 { 154 154 struct logic_iomem_area *area = get_area(addr); 155 155 ··· 173 173 static u##sz real_raw_read ## op(const volatile void __iomem *addr) \ 174 174 { \ 175 175 WARN(1, "Invalid read" #op " at address %llx\n", \ 176 - (unsigned long long __force)addr); \ 176 + (unsigned long long)(uintptr_t __force)addr); \ 177 177 return (u ## sz)~0ULL; \ 178 178 } \ 179 179 \ ··· 181 181 volatile void __iomem *addr) \ 182 182 { \ 183 183 WARN(1, "Invalid writeq" #op " of 0x%llx at address %llx\n", \ 184 - (unsigned long long)val, (unsigned long long __force)addr);\ 184 + (unsigned long long)val, \ 185 + (unsigned long long)(uintptr_t __force)addr);\ 185 186 } \ 186 187 187 188 MAKE_FALLBACK(b, 8); ··· 195 194 static void real_memset_io(volatile void __iomem *addr, int value, size_t size) 196 195 { 197 196 WARN(1, "Invalid memset_io at address 0x%llx\n", 198 - (unsigned long long __force)addr); 197 + (unsigned long long)(uintptr_t __force)addr); 199 198 } 200 199 201 200 static void real_memcpy_fromio(void *buffer, const volatile void __iomem *addr, 202 201 size_t size) 203 202 { 204 203 WARN(1, "Invalid memcpy_fromio at address 0x%llx\n", 205 - (unsigned long long __force)addr); 204 + (unsigned long long)(uintptr_t __force)addr); 206 205 207 206 memset(buffer, 0xff, size); 208 207 } ··· 211 210 size_t size) 212 211 { 213 212 WARN(1, "Invalid memcpy_toio at address 0x%llx\n", 214 - (unsigned long long __force)addr); 213 + (unsigned long long)(uintptr_t __force)addr); 215 214 } 216 215 #endif /* CONFIG_LOGIC_IOMEM_FALLBACK */ 217 216