]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
um: Remove file-based iomem emulation support
authorTiwei Bie <tiwei.btw@antgroup.com>
Mon, 27 Oct 2025 05:45:19 +0000 (13:45 +0800)
committerJohannes Berg <johannes.berg@intel.com>
Mon, 27 Oct 2025 15:37:12 +0000 (16:37 +0100)
The file-based iomem emulation was introduced to support writing
paravirtualized drivers based on emulated iomem regions. However,
the only driver that makes use of it is an example driver called
mmapper, which was written over two decades ago.

We now have several modern device emulation mechanisms, such as
vhost-user-based virtio-uml. Remove the file-based iomem emulation
support to reduce the maintenance burden.

Signed-off-by: Tiwei Bie <tiwei.btw@antgroup.com>
Link: https://patch.msgid.link/20251027054519.1996090-5-tiwei.bie@linux.dev
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
arch/um/Kconfig
arch/um/drivers/Makefile
arch/um/drivers/mmapper_kern.c [deleted file]
arch/um/include/asm/pgtable.h
arch/um/include/shared/kern_util.h
arch/um/include/shared/mem_user.h
arch/um/kernel/mem.c
arch/um/kernel/physmem.c
arch/um/kernel/um_arch.c
arch/um/os-Linux/skas/process.c
arch/um/os-Linux/start_up.c

index 49781bee7905804d47f8687f40ad29581f8649b4..0b4d00596a8c7355cefe2720093ca433c013d01e 100644 (file)
@@ -200,12 +200,6 @@ config KERNEL_STACK_ORDER
          increase in the size of the state which needs to be saved when handling
          signals.
 
-config MMAPPER
-       tristate "iomem emulation driver"
-       help
-         This driver allows a host file to be used as emulated IO memory inside
-         UML.
-
 config PGTABLE_LEVELS
        int
        default 4 if 64BIT
index 6bf8cbf71d3cab0cc5e485b7644dd2b884be9e40..36dc5784008445cb06b3d7908dae632076ed991a 100644 (file)
@@ -29,7 +29,6 @@ obj-$(CONFIG_STDERR_CONSOLE) += stderr_console.o
 
 obj-$(CONFIG_UML_NET_VECTOR) += vector.o
 obj-$(CONFIG_MCONSOLE) += mconsole.o
-obj-$(CONFIG_MMAPPER) += mmapper_kern.o 
 obj-$(CONFIG_BLK_DEV_UBD) += ubd.o 
 obj-$(CONFIG_UML_SOUND) += hostaudio.o
 obj-$(CONFIG_NULL_CHAN) += null.o 
diff --git a/arch/um/drivers/mmapper_kern.c b/arch/um/drivers/mmapper_kern.c
deleted file mode 100644 (file)
index 807cd33..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * arch/um/drivers/mmapper_kern.c
- *
- * BRIEF MODULE DESCRIPTION
- *
- * Copyright (C) 2000 RidgeRun, Inc.
- * Author: RidgeRun, Inc.
- *         Greg Lonnon glonnon@ridgerun.com or info@ridgerun.com
- *
- */
-
-#include <linux/stddef.h>
-#include <linux/types.h>
-#include <linux/fs.h>
-#include <linux/init.h>
-#include <linux/miscdevice.h>
-#include <linux/module.h>
-#include <linux/mm.h>
-
-#include <linux/uaccess.h>
-#include <mem_user.h>
-
-/* These are set in mmapper_init, which is called at boot time */
-static unsigned long mmapper_size;
-static unsigned long p_buf;
-static char *v_buf;
-
-static ssize_t mmapper_read(struct file *file, char __user *buf, size_t count,
-                           loff_t *ppos)
-{
-       return simple_read_from_buffer(buf, count, ppos, v_buf, mmapper_size);
-}
-
-static ssize_t mmapper_write(struct file *file, const char __user *buf,
-                            size_t count, loff_t *ppos)
-{
-       if (*ppos > mmapper_size)
-               return -EINVAL;
-
-       return simple_write_to_buffer(v_buf, mmapper_size, ppos, buf, count);
-}
-
-static long mmapper_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-       return -ENOIOCTLCMD;
-}
-
-static int mmapper_mmap(struct file *file, struct vm_area_struct *vma)
-{
-       int ret = -EINVAL;
-       int size;
-
-       if (vma->vm_pgoff != 0)
-               goto out;
-
-       size = vma->vm_end - vma->vm_start;
-       if (size > mmapper_size)
-               return -EFAULT;
-
-       /*
-        * XXX A comment above remap_pfn_range says it should only be
-        * called when the mm semaphore is held
-        */
-       if (remap_pfn_range(vma, vma->vm_start, p_buf >> PAGE_SHIFT, size,
-                           vma->vm_page_prot))
-               goto out;
-       ret = 0;
-out:
-       return ret;
-}
-
-static int mmapper_open(struct inode *inode, struct file *file)
-{
-       return 0;
-}
-
-static int mmapper_release(struct inode *inode, struct file *file)
-{
-       return 0;
-}
-
-static const struct file_operations mmapper_fops = {
-       .owner          = THIS_MODULE,
-       .read           = mmapper_read,
-       .write          = mmapper_write,
-       .unlocked_ioctl = mmapper_ioctl,
-       .mmap           = mmapper_mmap,
-       .open           = mmapper_open,
-       .release        = mmapper_release,
-       .llseek         = default_llseek,
-};
-
-/*
- * No locking needed - only used (and modified) by below initcall and exitcall.
- */
-static struct miscdevice mmapper_dev = {
-       .minor          = MISC_DYNAMIC_MINOR,
-       .name           = "mmapper",
-       .fops           = &mmapper_fops
-};
-
-static int __init mmapper_init(void)
-{
-       int err;
-
-       printk(KERN_INFO "Mapper v0.1\n");
-
-       v_buf = (char *) find_iomem("mmapper", &mmapper_size);
-       if (mmapper_size == 0) {
-               printk(KERN_ERR "mmapper_init - find_iomem failed\n");
-               return -ENODEV;
-       }
-       p_buf = __pa(v_buf);
-
-       err = misc_register(&mmapper_dev);
-       if (err) {
-               printk(KERN_ERR "mmapper - misc_register failed, err = %d\n",
-                      err);
-               return err;
-       }
-       return 0;
-}
-
-static void __exit mmapper_exit(void)
-{
-       misc_deregister(&mmapper_dev);
-}
-
-module_init(mmapper_init);
-module_exit(mmapper_exit);
-
-MODULE_AUTHOR("Greg Lonnon <glonnon@ridgerun.com>");
-MODULE_DESCRIPTION("DSPLinux simulator mmapper driver");
-MODULE_LICENSE("GPL");
index 24fdea6f88c37f4672876f76e9d5067610a87c2f..6ca7583003cd9dac6c4a0c779737e6923e4654b8 100644 (file)
@@ -45,10 +45,10 @@ extern unsigned long *empty_zero_page;
  * area for the same reason. ;)
  */
 
-extern unsigned long end_iomem;
+#include <as-layout.h> /* for high_physmem */
 
 #define VMALLOC_OFFSET (__va_space)
-#define VMALLOC_START ((end_iomem + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
+#define VMALLOC_START  ((high_physmem + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
 #define VMALLOC_END    (TASK_SIZE-2*PAGE_SIZE)
 #define MODULES_VADDR  VMALLOC_START
 #define MODULES_END    VMALLOC_END
index 949a03c7861ecd865543701166d6fa785b55f068..3ca589f3cd9745d04ae2437a4be00f40dbaa6a9d 100644 (file)
@@ -39,7 +39,6 @@ extern void uml_pm_wake(void);
 
 extern int start_uml(void);
 extern void paging_init(void);
-extern int parse_iomem(char *str, int *add);
 
 extern void uml_cleanup(void);
 extern void do_uml_exitcalls(void);
index d4727efcf23d065b0bdfbb522644ddeeb4acbe08..8a5b72872ff8e5b81d33162ae13cc65295d0bb6c 100644 (file)
 #ifndef _MEM_USER_H
 #define _MEM_USER_H
 
-struct iomem_region {
-       struct iomem_region *next;
-       char *driver;
-       int fd;
-       int size;
-       unsigned long phys;
-       unsigned long virt;
-};
-
-extern struct iomem_region *iomem_regions;
-extern int iomem_size;
-
 #define ROUND_4M(n) ((((unsigned long) (n)) + (1 << 22)) & ~((1 << 22) - 1))
 
-extern unsigned long find_iomem(char *driver, unsigned long *len_out);
 extern void setup_physmem(unsigned long start, unsigned long usable,
                          unsigned long len);
 extern void map_memory(unsigned long virt, unsigned long phys,
index 19d40b58eac44bdda15302fd8fbcdd58dfa876ec..dc938715ec9d0d15de0dd71296df5fb375f886a4 100644 (file)
@@ -197,7 +197,7 @@ void __init paging_init(void)
                panic("%s: Failed to allocate %lu bytes align=%lx\n",
                      __func__, PAGE_SIZE, PAGE_SIZE);
 
-       max_zone_pfn[ZONE_NORMAL] = end_iomem >> PAGE_SHIFT;
+       max_zone_pfn[ZONE_NORMAL] = high_physmem >> PAGE_SHIFT;
        free_area_init(max_zone_pfn);
 
 #if IS_ENABLED(CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA)
index af02b5f9911d343b3089f40aea3d6d595b47f7f4..ae6ca373c26109d4f4be904c5615481f07966f24 100644 (file)
@@ -105,19 +105,6 @@ int phys_mapping(unsigned long phys, unsigned long long *offset_out)
                fd = physmem_fd;
                *offset_out = phys;
        }
-       else if (phys < __pa(end_iomem)) {
-               struct iomem_region *region = iomem_regions;
-
-               while (region != NULL) {
-                       if ((phys >= region->phys) &&
-                           (phys < region->phys + region->size)) {
-                               fd = region->fd;
-                               *offset_out = phys - region->phys;
-                               break;
-                       }
-                       region = region->next;
-               }
-       }
 
        return fd;
 }
@@ -140,61 +127,3 @@ __uml_setup("mem=", uml_mem_setup,
 "    be more, and the excess, if it's ever used, will just be swapped out.\n"
 "      Example: mem=64M\n\n"
 );
-
-__uml_setup("iomem=", parse_iomem,
-"iomem=<name>,<file>\n"
-"    Configure <file> as an IO memory region named <name>.\n\n"
-);
-
-/*
- * This list is constructed in parse_iomem and addresses filled in
- * setup_iomem, both of which run during early boot.  Afterwards, it's
- * unchanged.
- */
-struct iomem_region *iomem_regions;
-
-/* Initialized in parse_iomem and unchanged thereafter */
-int iomem_size;
-
-unsigned long find_iomem(char *driver, unsigned long *len_out)
-{
-       struct iomem_region *region = iomem_regions;
-
-       while (region != NULL) {
-               if (!strcmp(region->driver, driver)) {
-                       *len_out = region->size;
-                       return region->virt;
-               }
-
-               region = region->next;
-       }
-
-       return 0;
-}
-EXPORT_SYMBOL(find_iomem);
-
-static int setup_iomem(void)
-{
-       struct iomem_region *region = iomem_regions;
-       unsigned long iomem_start = high_physmem + PAGE_SIZE;
-       int err;
-
-       while (region != NULL) {
-               err = os_map_memory((void *) iomem_start, region->fd, 0,
-                                   region->size, 1, 1, 0);
-               if (err)
-                       printk(KERN_ERR "Mapping iomem region for driver '%s' "
-                              "failed, errno = %d\n", region->driver, -err);
-               else {
-                       region->virt = iomem_start;
-                       region->phys = __pa(region->virt);
-               }
-
-               iomem_start += region->size + PAGE_SIZE;
-               region = region->next;
-       }
-
-       return 0;
-}
-
-__initcall(setup_iomem);
index 6f9a49e6c6a045f32395c94da55c76d633976b64..cf06bb732ed8512e9b0f62c6b398c2e3d21153e8 100644 (file)
@@ -253,8 +253,6 @@ unsigned long task_size;
 EXPORT_SYMBOL(task_size);
 
 unsigned long brk_start;
-unsigned long end_iomem;
-EXPORT_SYMBOL(end_iomem);
 
 #define MIN_VMALLOC (32 * 1024 * 1024)
 
@@ -363,9 +361,7 @@ int __init linux_main(int argc, char **argv, char **envp)
        setup_machinename(init_utsname()->machine);
 
        physmem_size = PAGE_ALIGN(physmem_size);
-       iomem_size = PAGE_ALIGN(iomem_size);
-
-       max_physmem = TASK_SIZE - uml_physmem - iomem_size - MIN_VMALLOC;
+       max_physmem = TASK_SIZE - uml_physmem - MIN_VMALLOC;
        if (physmem_size > max_physmem) {
                physmem_size = max_physmem;
                os_info("Physical memory size shrunk to %llu bytes\n",
@@ -373,7 +369,6 @@ int __init linux_main(int argc, char **argv, char **envp)
        }
 
        high_physmem = uml_physmem + physmem_size;
-       end_iomem = high_physmem + iomem_size;
 
        start_vm = VMALLOC_START;
 
index 0bc10cd4cbed418752272bd4c0e8f8ed3c8ec12f..820846ff7179e991282cc6ff1dd7483f06e13b29 100644 (file)
@@ -298,7 +298,6 @@ static int userspace_tramp(void *data)
                .seccomp = using_seccomp,
                .stub_start = STUB_START,
        };
-       struct iomem_region *iomem;
        int ret;
 
        if (using_seccomp) {
@@ -332,12 +331,6 @@ static int userspace_tramp(void *data)
 
        fcntl(init_data.stub_data_fd, F_SETFD, 0);
 
-       /* In SECCOMP mode, these FDs are passed when needed */
-       if (!using_seccomp) {
-               for (iomem = iomem_regions; iomem; iomem = iomem->next)
-                       fcntl(iomem->fd, F_SETFD, 0);
-       }
-
        /* dup2 signaling FD/socket to STDIN */
        if (dup2(tramp_data->sockpair[0], 0) < 0)
                exit(3);
index a827c2e01aa53a5ad927d92bd2cd1c19ead67dd2..8b19dca83f717d45c46bb7bdb21135c07f92376e 100644 (file)
@@ -489,53 +489,3 @@ void __init os_early_checks(void)
                fatal("Failed to initialize default registers");
        stop_ptraced_child(pid, 1);
 }
-
-int __init parse_iomem(char *str, int *add)
-{
-       struct iomem_region *new;
-       struct stat64 buf;
-       char *file, *driver;
-       int fd, size;
-
-       driver = str;
-       file = strchr(str,',');
-       if (file == NULL) {
-               os_warn("parse_iomem : failed to parse iomem\n");
-               goto out;
-       }
-       *file = '\0';
-       file++;
-       fd = open(file, O_RDWR, 0);
-       if (fd < 0) {
-               perror("parse_iomem - Couldn't open io file");
-               goto out;
-       }
-
-       if (fstat64(fd, &buf) < 0) {
-               perror("parse_iomem - cannot stat_fd file");
-               goto out_close;
-       }
-
-       new = malloc(sizeof(*new));
-       if (new == NULL) {
-               perror("Couldn't allocate iomem_region struct");
-               goto out_close;
-       }
-
-       size = (buf.st_size + UM_KERN_PAGE_SIZE) & ~(UM_KERN_PAGE_SIZE - 1);
-
-       *new = ((struct iomem_region) { .next           = iomem_regions,
-                                       .driver         = driver,
-                                       .fd             = fd,
-                                       .size           = size,
-                                       .phys           = 0,
-                                       .virt           = 0 });
-       iomem_regions = new;
-       iomem_size += new->size + UM_KERN_PAGE_SIZE;
-
-       return 0;
- out_close:
-       close(fd);
- out:
-       return 1;
-}