Skip to content

Commit

Permalink
Merge tag 'for-linus-5.17-rc1' of git://git.kernel.org/pub/scm/linux/…
Browse files Browse the repository at this point in the history
…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
  ...
  • Loading branch information
Linus Torvalds committed Jan 11, 2022
2 parents 5672cdf + db0dd9c commit f692121
Show file tree
Hide file tree
Showing 51 changed files with 265 additions and 235 deletions.
1 change: 1 addition & 0 deletions arch/um/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
kernel/config.c
kernel/config.tmp
kernel/vmlinux.lds
kernel/capflags.c
2 changes: 1 addition & 1 deletion arch/um/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ config UML
select HAVE_DEBUG_KMEMLEAK
select HAVE_DEBUG_BUGVERBOSE
select NO_DMA if !UML_DMA_EMULATION
select OF_EARLY_FLATTREE if OF
select GENERIC_IRQ_SHOW
select GENERIC_CPU_DEVICES
select HAVE_GCC_PLUGINS
select SET_FS
select TRACE_IRQFLAGS_SUPPORT
select TTY # Needed for line.c
select HAVE_ARCH_VMAP_STACK
Expand Down
8 changes: 4 additions & 4 deletions arch/um/drivers/virt-pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,15 @@ static unsigned long um_pci_cfgspace_read(void *priv, unsigned int offset,
/* buf->data is maximum size - we may only use parts of it */
struct um_pci_message_buffer *buf;
u8 *data;
unsigned long ret = ~0ULL;
unsigned long ret = ULONG_MAX;

if (!dev)
return ~0ULL;
return ULONG_MAX;

buf = get_cpu_var(um_pci_msg_bufs);
data = buf->data;

memset(data, 0xff, sizeof(data));
memset(buf->data, 0xff, sizeof(buf->data));

switch (size) {
case 1:
Expand Down Expand Up @@ -304,7 +304,7 @@ static unsigned long um_pci_bar_read(void *priv, unsigned int offset,
/* buf->data is maximum size - we may only use parts of it */
struct um_pci_message_buffer *buf;
u8 *data;
unsigned long ret = ~0ULL;
unsigned long ret = ULONG_MAX;

buf = get_cpu_var(um_pci_msg_bufs);
data = buf->data;
Expand Down
54 changes: 51 additions & 3 deletions arch/um/drivers/virtio_uml.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* Based on Virtio MMIO driver by Pawel Moll, copyright 2011-2014, ARM Ltd.
*/
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/virtio.h>
Expand Down Expand Up @@ -49,6 +50,7 @@ struct virtio_uml_platform_data {
struct virtio_uml_device {
struct virtio_device vdev;
struct platform_device *pdev;
struct virtio_uml_platform_data *pdata;

spinlock_t sock_lock;
int sock, req_fd, irq;
Expand Down Expand Up @@ -149,7 +151,7 @@ static int vhost_user_recv(struct virtio_uml_device *vu_dev,
if (rc == -ECONNRESET && vu_dev->registered) {
struct virtio_uml_platform_data *pdata;

pdata = vu_dev->pdev->dev.platform_data;
pdata = vu_dev->pdata;

virtio_break_device(&vu_dev->vdev);
schedule_work(&pdata->conn_broken_wk);
Expand Down Expand Up @@ -1090,6 +1092,8 @@ static void virtio_uml_release_dev(struct device *d)
container_of(d, struct virtio_device, dev);
struct virtio_uml_device *vu_dev = to_virtio_uml_device(vdev);

time_travel_propagate_time();

/* might not have been opened due to not negotiating the feature */
if (vu_dev->req_fd >= 0) {
um_free_irq(vu_dev->irq, vu_dev);
Expand All @@ -1113,21 +1117,63 @@ void virtio_uml_set_no_vq_suspend(struct virtio_device *vdev,
no_vq_suspend ? "dis" : "en");
}

static void vu_of_conn_broken(struct work_struct *wk)
{
/*
* We can't remove the device from the devicetree so the only thing we
* can do is warn.
*/
WARN_ON(1);
}

/* Platform device */

static struct virtio_uml_platform_data *
virtio_uml_create_pdata(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
struct virtio_uml_platform_data *pdata;
int ret;

if (!np)
return ERR_PTR(-EINVAL);

pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
if (!pdata)
return ERR_PTR(-ENOMEM);

INIT_WORK(&pdata->conn_broken_wk, vu_of_conn_broken);
pdata->pdev = pdev;

ret = of_property_read_string(np, "socket-path", &pdata->socket_path);
if (ret)
return ERR_PTR(ret);

ret = of_property_read_u32(np, "virtio-device-id",
&pdata->virtio_device_id);
if (ret)
return ERR_PTR(ret);

return pdata;
}

static int virtio_uml_probe(struct platform_device *pdev)
{
struct virtio_uml_platform_data *pdata = pdev->dev.platform_data;
struct virtio_uml_device *vu_dev;
int rc;

if (!pdata)
return -EINVAL;
if (!pdata) {
pdata = virtio_uml_create_pdata(pdev);
if (IS_ERR(pdata))
return PTR_ERR(pdata);
}

vu_dev = kzalloc(sizeof(*vu_dev), GFP_KERNEL);
if (!vu_dev)
return -ENOMEM;

vu_dev->pdata = pdata;
vu_dev->vdev.dev.parent = &pdev->dev;
vu_dev->vdev.dev.release = virtio_uml_release_dev;
vu_dev->vdev.config = &virtio_uml_config_ops;
Expand All @@ -1136,6 +1182,8 @@ static int virtio_uml_probe(struct platform_device *pdev)
vu_dev->pdev = pdev;
vu_dev->req_fd = -1;

time_travel_propagate_time();

do {
rc = os_connect_socket(pdata->socket_path);
} while (rc == -EINTR);
Expand Down
4 changes: 2 additions & 2 deletions arch/um/include/asm/delay.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ static inline void um_ndelay(unsigned long nsecs)
ndelay(nsecs);
}
#undef ndelay
#define ndelay um_ndelay
#define ndelay(n) um_ndelay(n)

static inline void um_udelay(unsigned long usecs)
{
Expand All @@ -26,5 +26,5 @@ static inline void um_udelay(unsigned long usecs)
udelay(usecs);
}
#undef udelay
#define udelay um_udelay
#define udelay(n) um_udelay(n)
#endif /* __UM_DELAY_H */
4 changes: 2 additions & 2 deletions arch/um/include/asm/irqflags.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#define __UM_IRQFLAGS_H

extern int signals_enabled;
int set_signals(int enable);
int um_set_signals(int enable);
void block_signals(void);
void unblock_signals(void);

Expand All @@ -16,7 +16,7 @@ static inline unsigned long arch_local_save_flags(void)
#define arch_local_irq_restore arch_local_irq_restore
static inline void arch_local_irq_restore(unsigned long flags)
{
set_signals(flags);
um_set_signals(flags);
}

#define arch_local_irq_enable arch_local_irq_enable
Expand Down
2 changes: 1 addition & 1 deletion arch/um/include/asm/processor-generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ struct pt_regs;
struct task_struct;

#include <asm/ptrace.h>
#include <registers.h>
#include <sysdep/archsetjmp.h>

#include <linux/prefetch.h>
Expand Down Expand Up @@ -105,6 +104,7 @@ extern struct cpuinfo_um boot_cpu_data;
#define current_cpu_data boot_cpu_data
#define cache_line_size() (boot_cpu_data.cache_alignment)

extern unsigned long get_thread_reg(int reg, jmp_buf *buf);
#define KSTK_REG(tsk, reg) get_thread_reg(reg, &tsk->thread.switch_buf)
extern unsigned long __get_wchan(struct task_struct *p);

Expand Down
4 changes: 0 additions & 4 deletions arch/um/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ struct thread_info {
__u32 cpu; /* current CPU */
int preempt_count; /* 0 => preemptable,
<0 => BUG */
mm_segment_t addr_limit; /* thread address space:
0-0xBFFFFFFF for user
0-0xFFFFFFFF for kernel */
struct thread_info *real_thread; /* Points to non-IRQ stack */
unsigned long aux_fp_regs[FP_SIZE]; /* auxiliary fp_regs to save/restore
them out-of-band */
Expand All @@ -36,7 +33,6 @@ struct thread_info {
.flags = 0, \
.cpu = 0, \
.preempt_count = INIT_PREEMPT_COUNT, \
.addr_limit = KERNEL_DS, \
.real_thread = NULL, \
}

Expand Down
21 changes: 19 additions & 2 deletions arch/um/include/asm/uaccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#define __UM_UACCESS_H

#include <asm/elf.h>
#include <asm/unaligned.h>

#define __under_task_size(addr, size) \
(((unsigned long) (addr) < TASK_SIZE) && \
Expand Down Expand Up @@ -39,8 +40,24 @@ static inline int __access_ok(unsigned long addr, unsigned long size)
{
return __addr_range_nowrap(addr, size) &&
(__under_task_size(addr, size) ||
__access_ok_vsyscall(addr, size) ||
uaccess_kernel());
__access_ok_vsyscall(addr, size));
}

/* no pagefaults for kernel addresses in um */
#define HAVE_GET_KERNEL_NOFAULT 1

#define __get_kernel_nofault(dst, src, type, err_label) \
do { \
*((type *)dst) = get_unaligned((type *)(src)); \
if (0) /* make sure the label looks used to the compiler */ \
goto err_label; \
} while (0)

#define __put_kernel_nofault(dst, src, type, err_label) \
do { \
put_unaligned(*((type *)src), (type *)(dst)); \
if (0) /* make sure the label looks used to the compiler */ \
goto err_label; \
} while (0)

#endif
15 changes: 0 additions & 15 deletions arch/um/include/shared/common-offsets.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,17 @@ DEFINE(UM_KERN_PAGE_MASK, PAGE_MASK);
DEFINE(UM_KERN_PAGE_SHIFT, PAGE_SHIFT);
DEFINE(UM_NSEC_PER_SEC, NSEC_PER_SEC);

DEFINE(UM_ELF_CLASS, ELF_CLASS);
DEFINE(UM_ELFCLASS32, ELFCLASS32);
DEFINE(UM_ELFCLASS64, ELFCLASS64);

DEFINE(UM_NR_CPUS, NR_CPUS);

DEFINE(UM_GFP_KERNEL, GFP_KERNEL);
DEFINE(UM_GFP_ATOMIC, GFP_ATOMIC);

/* For crypto assembler code. */
DEFINE(crypto_tfm_ctx_offset, offsetof(struct crypto_tfm, __crt_ctx));

DEFINE(UM_THREAD_SIZE, THREAD_SIZE);

DEFINE(UM_HZ, HZ);

DEFINE(UM_USEC_PER_SEC, USEC_PER_SEC);
DEFINE(UM_NSEC_PER_SEC, NSEC_PER_SEC);
DEFINE(UM_NSEC_PER_USEC, NSEC_PER_USEC);

#ifdef CONFIG_PRINTK
DEFINE(UML_CONFIG_PRINTK, CONFIG_PRINTK);
#endif
#ifdef CONFIG_NO_HZ_COMMON
DEFINE(UML_CONFIG_NO_HZ_COMMON, CONFIG_NO_HZ_COMMON);
#endif
#ifdef CONFIG_UML_X86
DEFINE(UML_CONFIG_UML_X86, CONFIG_UML_X86);
#endif
Expand Down
1 change: 0 additions & 1 deletion arch/um/include/shared/irq_user.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@ void sigio_run_timetravel_handlers(void);
extern void free_irq_by_fd(int fd);
extern void deactivate_fd(int fd, int irqnum);
extern int deactivate_all_fds(void);
extern int activate_ipi(int fd, int pid);

#endif
2 changes: 0 additions & 2 deletions arch/um/include/shared/kern_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,11 @@ extern void do_uml_exitcalls(void);
extern int __cant_sleep(void);
extern int get_current_pid(void);
extern int copy_from_user_proc(void *to, void *from, int size);
extern int cpu(void);
extern char *uml_strdup(const char *string);

extern unsigned long to_irq_stack(unsigned long *mask_out);
extern unsigned long from_irq_stack(int nested);

extern void syscall_trace(struct uml_pt_regs *regs, int entryexit);
extern int singlestepping(void *t);

extern void segv_handler(int sig, struct siginfo *unused_si, struct uml_pt_regs *regs);
Expand Down
2 changes: 1 addition & 1 deletion arch/um/include/shared/longjmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ extern void longjmp(jmp_buf, int);
enable = *(volatile int *)&signals_enabled; \
n = setjmp(*buf); \
if(n != 0) \
set_signals_trace(enable); \
um_set_signals_trace(enable); \
n; })

#endif
5 changes: 0 additions & 5 deletions arch/um/include/shared/mem_user.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,11 @@ extern int iomem_size;

#define ROUND_4M(n) ((((unsigned long) (n)) + (1 << 22)) & ~((1 << 22) - 1))

extern int init_mem_user(void);
extern void setup_memory(void *entry);
extern unsigned long find_iomem(char *driver, unsigned long *len_out);
extern void mem_total_pages(unsigned long physmem, unsigned long iomem,
unsigned long highmem);
extern unsigned long get_vm(unsigned long len);
extern void setup_physmem(unsigned long start, unsigned long usable,
unsigned long len, unsigned long long highmem);
extern void add_iomem(char *name, int fd, unsigned long size);
extern unsigned long phys_offset(unsigned long phys);
extern void map_memory(unsigned long virt, unsigned long phys,
unsigned long len, int r, int w, int x);

Expand Down
2 changes: 0 additions & 2 deletions arch/um/include/shared/net_kern.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ struct transport {
const int setup_size;
};

extern struct net_device *ether_init(int);
extern unsigned short ether_protocol(struct sk_buff *);
extern int tap_setup_common(char *str, char *type, char **dev_name,
char **mac_out, char **gate_addr);
extern void register_transport(struct transport *new);
Expand Down
1 change: 0 additions & 1 deletion arch/um/include/shared/net_user.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ struct net_user_info {
int mtu;
};

extern void ether_user_init(void *data, void *dev);
extern void iter_addresses(void *d, void (*cb)(unsigned char *,
unsigned char *, void *),
void *arg);
Expand Down
Loading

0 comments on commit f692121

Please sign in to comment.