Commit a7f7dbae authored by Tiwei Bie's avatar Tiwei Bie Committed by Johannes Berg
Browse files

um: Remove file-based iomem emulation support



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: default avatarTiwei Bie <tiwei.btw@antgroup.com>
Link: https://patch.msgid.link/20251027054519.1996090-5-tiwei.bie@linux.dev


Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 9c84022c
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -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
+0 −1
Original line number Diff line number Diff line
@@ -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 

arch/um/drivers/mmapper_kern.c

deleted100644 → 0
+0 −135
Original line number Diff line number Diff line
// 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");
+2 −2
Original line number Diff line number Diff line
@@ -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
+0 −1
Original line number Diff line number Diff line
@@ -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);
Loading