From hch at lst.de  Sun Jun 13 23:07:57 2021
From: hch at lst.de (Christoph Hellwig)
Date: Mon, 14 Jun 2021 08:07:57 +0200
Subject: cleanup ubd gendisk registration
Message-ID: <20210614060759.3965724-1-hch@lst.de>

Hi all,

this series sits on top of Jens' for-5.14/block branch and tries to
convert ubd to the new gendisk and request_queue registration helpers.
As part of that I found that the ide emulation code currently registers
two gendisk for a request_queue which leads to a bunch of problems we've
avoided in other drivers (only the mmc subsystem has a similar issue).
Given that the legacy IDE driver isn't practically used any more and
modern userspace doesn't hard code specific block drivers, so I think
we can just drop it.  Let me know if this is ok.


From hch at lst.de  Sun Jun 13 23:07:58 2021
From: hch at lst.de (Christoph Hellwig)
Date: Mon, 14 Jun 2021 08:07:58 +0200
Subject: [PATCH 1/2] ubd: remove the code to register as the legacy IDE driver
In-Reply-To: <20210614060759.3965724-1-hch@lst.de>
References: <20210614060759.3965724-1-hch@lst.de>
Message-ID: <20210614060759.3965724-2-hch@lst.de>

With the legacy IDE driver long deprecated, and modern userspace being
much more flexible about dev_t assignments there is no reason to fake
a registration as the legacy IDE driver in ubd.  This registeration
is a little problematic as it registers the same request_queue for
multiple gendisks, so just remove it.

Signed-off-by: Christoph Hellwig <hch at lst.de>
---
 arch/um/drivers/ubd_kern.c | 106 +++++--------------------------------
 1 file changed, 12 insertions(+), 94 deletions(-)

diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index 8e0b43cf089f..f508d45f7a69 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -125,9 +125,7 @@ static const struct block_device_operations ubd_blops = {
 };
 
 /* Protected by ubd_lock */
-static int fake_major = UBD_MAJOR;
 static struct gendisk *ubd_gendisk[MAX_DEV];
-static struct gendisk *fake_gendisk[MAX_DEV];
 
 #ifdef CONFIG_BLK_DEV_UBD_SYNC
 #define OPEN_FLAGS ((struct openflags) { .r = 1, .w = 1, .s = 1, .c = 0, \
@@ -197,54 +195,19 @@ struct ubd {
 /* Protected by ubd_lock */
 static struct ubd ubd_devs[MAX_DEV] = { [0 ... MAX_DEV - 1] = DEFAULT_UBD };
 
-/* Only changed by fake_ide_setup which is a setup */
-static int fake_ide = 0;
-static struct proc_dir_entry *proc_ide_root = NULL;
-static struct proc_dir_entry *proc_ide = NULL;
-
 static blk_status_t ubd_queue_rq(struct blk_mq_hw_ctx *hctx,
 				 const struct blk_mq_queue_data *bd);
 
-static void make_proc_ide(void)
-{
-	proc_ide_root = proc_mkdir("ide", NULL);
-	proc_ide = proc_mkdir("ide0", proc_ide_root);
-}
-
-static int fake_ide_media_proc_show(struct seq_file *m, void *v)
-{
-	seq_puts(m, "disk\n");
-	return 0;
-}
-
-static void make_ide_entries(const char *dev_name)
-{
-	struct proc_dir_entry *dir, *ent;
-	char name[64];
-
-	if(proc_ide_root == NULL) make_proc_ide();
-
-	dir = proc_mkdir(dev_name, proc_ide);
-	if(!dir) return;
-
-	ent = proc_create_single("media", S_IRUGO, dir,
-			fake_ide_media_proc_show);
-	if(!ent) return;
-	snprintf(name, sizeof(name), "ide0/%s", dev_name);
-	proc_symlink(dev_name, proc_ide_root, name);
-}
-
 static int fake_ide_setup(char *str)
 {
-	fake_ide = 1;
+	pr_warn("The fake_ide option has been removed\n");
 	return 1;
 }
-
 __setup("fake_ide", fake_ide_setup);
 
 __uml_help(fake_ide_setup,
 "fake_ide\n"
-"    Create ide0 entries that map onto ubd devices.\n\n"
+"    Obsolete stub.\n\n"
 );
 
 static int parse_unit(char **ptr)
@@ -296,20 +259,8 @@ static int ubd_setup_common(char *str, int *index_out, char **error_out)
 			return err;
 		}
 
-		mutex_lock(&ubd_lock);
-		if (fake_major != UBD_MAJOR) {
-			*error_out = "Can't assign a fake major twice";
-			goto out1;
-		}
-
-		fake_major = major;
-
-		printk(KERN_INFO "Setting extra ubd major number to %d\n",
-		       major);
-		err = 0;
-	out1:
-		mutex_unlock(&ubd_lock);
-		return err;
+		pr_warn("fake major not supported any more\n");
+		return 0;
 	}
 
 	n = parse_unit(&str);
@@ -917,7 +868,6 @@ static const struct attribute_group *ubd_attr_groups[] = {
 static int ubd_disk_register(int major, u64 size, int unit,
 			     struct gendisk **disk_out)
 {
-	struct device *parent = NULL;
 	struct gendisk *disk;
 
 	disk = alloc_disk(1 << UBD_SHIFT);
@@ -928,24 +878,17 @@ static int ubd_disk_register(int major, u64 size, int unit,
 	disk->first_minor = unit << UBD_SHIFT;
 	disk->fops = &ubd_blops;
 	set_capacity(disk, size / 512);
-	if (major == UBD_MAJOR)
-		sprintf(disk->disk_name, "ubd%c", 'a' + unit);
-	else
-		sprintf(disk->disk_name, "ubd_fake%d", unit);
-
-	/* sysfs register (not for ide fake devices) */
-	if (major == UBD_MAJOR) {
-		ubd_devs[unit].pdev.id   = unit;
-		ubd_devs[unit].pdev.name = DRIVER_NAME;
-		ubd_devs[unit].pdev.dev.release = ubd_device_release;
-		dev_set_drvdata(&ubd_devs[unit].pdev.dev, &ubd_devs[unit]);
-		platform_device_register(&ubd_devs[unit].pdev);
-		parent = &ubd_devs[unit].pdev.dev;
-	}
+	sprintf(disk->disk_name, "ubd%c", 'a' + unit);
+
+	ubd_devs[unit].pdev.id   = unit;
+	ubd_devs[unit].pdev.name = DRIVER_NAME;
+	ubd_devs[unit].pdev.dev.release = ubd_device_release;
+	dev_set_drvdata(&ubd_devs[unit].pdev.dev, &ubd_devs[unit]);
+	platform_device_register(&ubd_devs[unit].pdev);
 
 	disk->private_data = &ubd_devs[unit];
 	disk->queue = ubd_devs[unit].queue;
-	device_add_disk(parent, disk, ubd_attr_groups);
+	device_add_disk(&ubd_devs[unit].pdev.dev, disk, ubd_attr_groups);
 
 	*disk_out = disk;
 	return 0;
@@ -1001,17 +944,6 @@ static int ubd_add(int n, char **error_out)
 		goto out_cleanup_tags;
 	}
 
-	if (fake_major != UBD_MAJOR)
-		ubd_disk_register(fake_major, ubd_dev->size, n,
-				  &fake_gendisk[n]);
-
-	/*
-	 * Perhaps this should also be under the "if (fake_major)" above
-	 * using the fake_disk->disk_name
-	 */
-	if (fake_ide)
-		make_ide_entries(ubd_gendisk[n]->disk_name);
-
 	err = 0;
 out:
 	return err;
@@ -1126,12 +1058,6 @@ static int ubd_remove(int n, char **error_out)
 		put_disk(disk);
 	}
 
-	if(fake_gendisk[n] != NULL){
-		del_gendisk(fake_gendisk[n]);
-		put_disk(fake_gendisk[n]);
-		fake_gendisk[n] = NULL;
-	}
-
 	err = 0;
 	platform_device_unregister(&ubd_dev->pdev);
 out:
@@ -1188,14 +1114,6 @@ static int __init ubd_init(void)
 	if (register_blkdev(UBD_MAJOR, "ubd"))
 		return -1;
 
-	if (fake_major != UBD_MAJOR) {
-		char name[sizeof("ubd_nnn\0")];
-
-		snprintf(name, sizeof(name), "ubd_%d", fake_major);
-		if (register_blkdev(fake_major, "ubd"))
-			return -1;
-	}
-
 	irq_req_buffer = kmalloc_array(UBD_REQ_BUFFER_SIZE,
 				       sizeof(struct io_thread_req *),
 				       GFP_KERNEL
-- 
2.30.2



From hch at lst.de  Sun Jun 13 23:07:59 2021
From: hch at lst.de (Christoph Hellwig)
Date: Mon, 14 Jun 2021 08:07:59 +0200
Subject: [PATCH 2/2] ubd: use blk_mq_alloc_disk and blk_cleanup_disk
In-Reply-To: <20210614060759.3965724-1-hch@lst.de>
References: <20210614060759.3965724-1-hch@lst.de>
Message-ID: <20210614060759.3965724-3-hch@lst.de>

Use blk_mq_alloc_disk and blk_cleanup_disk to simplify the gendisk and
request_queue allocation.

Signed-off-by: Christoph Hellwig <hch at lst.de>
---
 arch/um/drivers/ubd_kern.c | 44 ++++++++++++--------------------------
 1 file changed, 14 insertions(+), 30 deletions(-)

diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index f508d45f7a69..0b86aa1b12f1 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -825,7 +825,6 @@ static void ubd_device_release(struct device *dev)
 {
 	struct ubd *ubd_dev = dev_get_drvdata(dev);
 
-	blk_cleanup_queue(ubd_dev->queue);
 	blk_mq_free_tag_set(&ubd_dev->tag_set);
 	*ubd_dev = ((struct ubd) DEFAULT_UBD);
 }
@@ -865,17 +864,12 @@ static const struct attribute_group *ubd_attr_groups[] = {
 	NULL,
 };
 
-static int ubd_disk_register(int major, u64 size, int unit,
-			     struct gendisk **disk_out)
+static void ubd_disk_register(int major, u64 size, int unit,
+			      struct gendisk *disk)
 {
-	struct gendisk *disk;
-
-	disk = alloc_disk(1 << UBD_SHIFT);
-	if(disk == NULL)
-		return -ENOMEM;
-
 	disk->major = major;
 	disk->first_minor = unit << UBD_SHIFT;
+	disk->minors = 1 << UBD_SHIFT;
 	disk->fops = &ubd_blops;
 	set_capacity(disk, size / 512);
 	sprintf(disk->disk_name, "ubd%c", 'a' + unit);
@@ -889,9 +883,6 @@ static int ubd_disk_register(int major, u64 size, int unit,
 	disk->private_data = &ubd_devs[unit];
 	disk->queue = ubd_devs[unit].queue;
 	device_add_disk(&ubd_devs[unit].pdev.dev, disk, ubd_attr_groups);
-
-	*disk_out = disk;
-	return 0;
 }
 
 #define ROUND_BLOCK(n) ((n + (SECTOR_SIZE - 1)) & (-SECTOR_SIZE))
@@ -903,6 +894,7 @@ static const struct blk_mq_ops ubd_mq_ops = {
 static int ubd_add(int n, char **error_out)
 {
 	struct ubd *ubd_dev = &ubd_devs[n];
+	struct gendisk *disk;
 	int err = 0;
 
 	if(ubd_dev->file == NULL)
@@ -927,32 +919,24 @@ static int ubd_add(int n, char **error_out)
 	if (err)
 		goto out;
 
-	ubd_dev->queue = blk_mq_init_queue(&ubd_dev->tag_set);
-	if (IS_ERR(ubd_dev->queue)) {
-		err = PTR_ERR(ubd_dev->queue);
+	disk = blk_mq_alloc_disk(&ubd_dev->tag_set, ubd_dev);
+	if (IS_ERR(disk)) {
+		err = PTR_ERR(disk);
 		goto out_cleanup_tags;
 	}
+	ubd_dev->queue = disk->queue;
 
-	ubd_dev->queue->queuedata = ubd_dev;
 	blk_queue_write_cache(ubd_dev->queue, true, false);
-
 	blk_queue_max_segments(ubd_dev->queue, MAX_SG);
 	blk_queue_segment_boundary(ubd_dev->queue, PAGE_SIZE - 1);
-	err = ubd_disk_register(UBD_MAJOR, ubd_dev->size, n, &ubd_gendisk[n]);
-	if(err){
-		*error_out = "Failed to register device";
-		goto out_cleanup_tags;
-	}
-
-	err = 0;
-out:
-	return err;
+	ubd_disk_register(UBD_MAJOR, ubd_dev->size, n, disk);
+	ubd_gendisk[n] = disk;
+	return 0;
 
 out_cleanup_tags:
 	blk_mq_free_tag_set(&ubd_dev->tag_set);
-	if (!(IS_ERR(ubd_dev->queue)))
-		blk_cleanup_queue(ubd_dev->queue);
-	goto out;
+out:
+	return err;
 }
 
 static int ubd_config(char *str, char **error_out)
@@ -1055,7 +1039,7 @@ static int ubd_remove(int n, char **error_out)
 	ubd_gendisk[n] = NULL;
 	if(disk != NULL){
 		del_gendisk(disk);
-		put_disk(disk);
+		blk_cleanup_disk(disk);
 	}
 
 	err = 0;
-- 
2.30.2



From anton.ivanov at cambridgegreys.com  Mon Jun 14 01:26:58 2021
From: anton.ivanov at cambridgegreys.com (Anton Ivanov)
Date: Mon, 14 Jun 2021 09:26:58 +0100
Subject: [PATCH 2/2] ubd: use blk_mq_alloc_disk and blk_cleanup_disk
In-Reply-To: <20210614060759.3965724-3-hch@lst.de>
References: <20210614060759.3965724-1-hch@lst.de>
 <20210614060759.3965724-3-hch@lst.de>
Message-ID: <847f7608-1d11-1410-5394-b5aa5de9f45e@cambridgegreys.com>



On 14/06/2021 07:07, Christoph Hellwig wrote:
> Use blk_mq_alloc_disk and blk_cleanup_disk to simplify the gendisk and
> request_queue allocation.
> 
> Signed-off-by: Christoph Hellwig <hch at lst.de>
> ---
>   arch/um/drivers/ubd_kern.c | 44 ++++++++++++--------------------------
>   1 file changed, 14 insertions(+), 30 deletions(-)
> 
> diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
> index f508d45f7a69..0b86aa1b12f1 100644
> --- a/arch/um/drivers/ubd_kern.c
> +++ b/arch/um/drivers/ubd_kern.c
> @@ -825,7 +825,6 @@ static void ubd_device_release(struct device *dev)
>   {
>   	struct ubd *ubd_dev = dev_get_drvdata(dev);
>   
> -	blk_cleanup_queue(ubd_dev->queue);
>   	blk_mq_free_tag_set(&ubd_dev->tag_set);
>   	*ubd_dev = ((struct ubd) DEFAULT_UBD);
>   }
> @@ -865,17 +864,12 @@ static const struct attribute_group *ubd_attr_groups[] = {
>   	NULL,
>   };
>   
> -static int ubd_disk_register(int major, u64 size, int unit,
> -			     struct gendisk **disk_out)
> +static void ubd_disk_register(int major, u64 size, int unit,
> +			      struct gendisk *disk)
>   {
> -	struct gendisk *disk;
> -
> -	disk = alloc_disk(1 << UBD_SHIFT);
> -	if(disk == NULL)
> -		return -ENOMEM;
> -
>   	disk->major = major;
>   	disk->first_minor = unit << UBD_SHIFT;
> +	disk->minors = 1 << UBD_SHIFT;
>   	disk->fops = &ubd_blops;
>   	set_capacity(disk, size / 512);
>   	sprintf(disk->disk_name, "ubd%c", 'a' + unit);
> @@ -889,9 +883,6 @@ static int ubd_disk_register(int major, u64 size, int unit,
>   	disk->private_data = &ubd_devs[unit];
>   	disk->queue = ubd_devs[unit].queue;
>   	device_add_disk(&ubd_devs[unit].pdev.dev, disk, ubd_attr_groups);
> -
> -	*disk_out = disk;
> -	return 0;
>   }
>   
>   #define ROUND_BLOCK(n) ((n + (SECTOR_SIZE - 1)) & (-SECTOR_SIZE))
> @@ -903,6 +894,7 @@ static const struct blk_mq_ops ubd_mq_ops = {
>   static int ubd_add(int n, char **error_out)
>   {
>   	struct ubd *ubd_dev = &ubd_devs[n];
> +	struct gendisk *disk;
>   	int err = 0;
>   
>   	if(ubd_dev->file == NULL)
> @@ -927,32 +919,24 @@ static int ubd_add(int n, char **error_out)
>   	if (err)
>   		goto out;
>   
> -	ubd_dev->queue = blk_mq_init_queue(&ubd_dev->tag_set);
> -	if (IS_ERR(ubd_dev->queue)) {
> -		err = PTR_ERR(ubd_dev->queue);
> +	disk = blk_mq_alloc_disk(&ubd_dev->tag_set, ubd_dev);
> +	if (IS_ERR(disk)) {
> +		err = PTR_ERR(disk);
>   		goto out_cleanup_tags;
>   	}
> +	ubd_dev->queue = disk->queue;
>   
> -	ubd_dev->queue->queuedata = ubd_dev;
>   	blk_queue_write_cache(ubd_dev->queue, true, false);
> -
>   	blk_queue_max_segments(ubd_dev->queue, MAX_SG);
>   	blk_queue_segment_boundary(ubd_dev->queue, PAGE_SIZE - 1);
> -	err = ubd_disk_register(UBD_MAJOR, ubd_dev->size, n, &ubd_gendisk[n]);
> -	if(err){
> -		*error_out = "Failed to register device";
> -		goto out_cleanup_tags;
> -	}
> -
> -	err = 0;
> -out:
> -	return err;
> +	ubd_disk_register(UBD_MAJOR, ubd_dev->size, n, disk);
> +	ubd_gendisk[n] = disk;
> +	return 0;
>   
>   out_cleanup_tags:
>   	blk_mq_free_tag_set(&ubd_dev->tag_set);
> -	if (!(IS_ERR(ubd_dev->queue)))
> -		blk_cleanup_queue(ubd_dev->queue);
> -	goto out;
> +out:
> +	return err;
>   }
>   
>   static int ubd_config(char *str, char **error_out)
> @@ -1055,7 +1039,7 @@ static int ubd_remove(int n, char **error_out)
>   	ubd_gendisk[n] = NULL;
>   	if(disk != NULL){
>   		del_gendisk(disk);
> -		put_disk(disk);
> +		blk_cleanup_disk(disk);
>   	}
>   
>   	err = 0;
> 

This does not build for me when applied to master:


arch/um/drivers/ubd_kern.c: In function ?ubd_add?:
arch/um/drivers/ubd_kern.c:922:9: error: implicit declaration of function ?blk_mq_alloc_disk?; did you mean ?blk_mq_alloc_request?? [-Werror=implicit-function-declaration]
   disk = blk_mq_alloc_disk(&ubd_dev->tag_set, ubd_dev);
          ^~~~~~~~~~~~~~~~~
          blk_mq_alloc_request
arch/um/drivers/ubd_kern.c:922:7: warning: assignment to ?struct gendisk *? from ?int? makes pointer from integer without a cast [-Wint-conversion]
   disk = blk_mq_alloc_disk(&ubd_dev->tag_set, ubd_dev);
        ^
arch/um/drivers/ubd_kern.c: In function ?ubd_remove?:
arch/um/drivers/ubd_kern.c:1042:3: error: implicit declaration of function ?blk_cleanup_disk?; did you mean ?blk_cleanup_queue?? [-Werror=implicit-function-declaration]
    blk_cleanup_disk(disk);

-- 
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/


From anton.ivanov at cambridgegreys.com  Mon Jun 14 01:22:51 2021
From: anton.ivanov at cambridgegreys.com (Anton Ivanov)
Date: Mon, 14 Jun 2021 09:22:51 +0100
Subject: [PATCH 1/2] ubd: remove the code to register as the legacy IDE
 driver
In-Reply-To: <20210614060759.3965724-2-hch@lst.de>
References: <20210614060759.3965724-1-hch@lst.de>
 <20210614060759.3965724-2-hch@lst.de>
Message-ID: <5a9207a0-91e9-d843-9968-2db26946be73@cambridgegreys.com>



On 14/06/2021 07:07, Christoph Hellwig wrote:
> With the legacy IDE driver long deprecated, and modern userspace being
> much more flexible about dev_t assignments there is no reason to fake
> a registration as the legacy IDE driver in ubd.  This registeration
> is a little problematic as it registers the same request_queue for
> multiple gendisks, so just remove it.
> 
> Signed-off-by: Christoph Hellwig <hch at lst.de>
> ---
>   arch/um/drivers/ubd_kern.c | 106 +++++--------------------------------
>   1 file changed, 12 insertions(+), 94 deletions(-)
> 
> diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
> index 8e0b43cf089f..f508d45f7a69 100644
> --- a/arch/um/drivers/ubd_kern.c
> +++ b/arch/um/drivers/ubd_kern.c
> @@ -125,9 +125,7 @@ static const struct block_device_operations ubd_blops = {
>   };
>   
>   /* Protected by ubd_lock */
> -static int fake_major = UBD_MAJOR;
>   static struct gendisk *ubd_gendisk[MAX_DEV];
> -static struct gendisk *fake_gendisk[MAX_DEV];
>   
>   #ifdef CONFIG_BLK_DEV_UBD_SYNC
>   #define OPEN_FLAGS ((struct openflags) { .r = 1, .w = 1, .s = 1, .c = 0, \
> @@ -197,54 +195,19 @@ struct ubd {
>   /* Protected by ubd_lock */
>   static struct ubd ubd_devs[MAX_DEV] = { [0 ... MAX_DEV - 1] = DEFAULT_UBD };
>   
> -/* Only changed by fake_ide_setup which is a setup */
> -static int fake_ide = 0;
> -static struct proc_dir_entry *proc_ide_root = NULL;
> -static struct proc_dir_entry *proc_ide = NULL;
> -
>   static blk_status_t ubd_queue_rq(struct blk_mq_hw_ctx *hctx,
>   				 const struct blk_mq_queue_data *bd);
>   
> -static void make_proc_ide(void)
> -{
> -	proc_ide_root = proc_mkdir("ide", NULL);
> -	proc_ide = proc_mkdir("ide0", proc_ide_root);
> -}
> -
> -static int fake_ide_media_proc_show(struct seq_file *m, void *v)
> -{
> -	seq_puts(m, "disk\n");
> -	return 0;
> -}
> -
> -static void make_ide_entries(const char *dev_name)
> -{
> -	struct proc_dir_entry *dir, *ent;
> -	char name[64];
> -
> -	if(proc_ide_root == NULL) make_proc_ide();
> -
> -	dir = proc_mkdir(dev_name, proc_ide);
> -	if(!dir) return;
> -
> -	ent = proc_create_single("media", S_IRUGO, dir,
> -			fake_ide_media_proc_show);
> -	if(!ent) return;
> -	snprintf(name, sizeof(name), "ide0/%s", dev_name);
> -	proc_symlink(dev_name, proc_ide_root, name);
> -}
> -
>   static int fake_ide_setup(char *str)
>   {
> -	fake_ide = 1;
> +	pr_warn("The fake_ide option has been removed\n");
>   	return 1;
>   }
> -
>   __setup("fake_ide", fake_ide_setup);
>   
>   __uml_help(fake_ide_setup,
>   "fake_ide\n"
> -"    Create ide0 entries that map onto ubd devices.\n\n"
> +"    Obsolete stub.\n\n"
>   );
>   
>   static int parse_unit(char **ptr)
> @@ -296,20 +259,8 @@ static int ubd_setup_common(char *str, int *index_out, char **error_out)
>   			return err;
>   		}
>   
> -		mutex_lock(&ubd_lock);
> -		if (fake_major != UBD_MAJOR) {
> -			*error_out = "Can't assign a fake major twice";
> -			goto out1;
> -		}
> -
> -		fake_major = major;
> -
> -		printk(KERN_INFO "Setting extra ubd major number to %d\n",
> -		       major);
> -		err = 0;
> -	out1:
> -		mutex_unlock(&ubd_lock);
> -		return err;
> +		pr_warn("fake major not supported any more\n");
> +		return 0;
>   	}
>   
>   	n = parse_unit(&str);
> @@ -917,7 +868,6 @@ static const struct attribute_group *ubd_attr_groups[] = {
>   static int ubd_disk_register(int major, u64 size, int unit,
>   			     struct gendisk **disk_out)
>   {
> -	struct device *parent = NULL;
>   	struct gendisk *disk;
>   
>   	disk = alloc_disk(1 << UBD_SHIFT);
> @@ -928,24 +878,17 @@ static int ubd_disk_register(int major, u64 size, int unit,
>   	disk->first_minor = unit << UBD_SHIFT;
>   	disk->fops = &ubd_blops;
>   	set_capacity(disk, size / 512);
> -	if (major == UBD_MAJOR)
> -		sprintf(disk->disk_name, "ubd%c", 'a' + unit);
> -	else
> -		sprintf(disk->disk_name, "ubd_fake%d", unit);
> -
> -	/* sysfs register (not for ide fake devices) */
> -	if (major == UBD_MAJOR) {
> -		ubd_devs[unit].pdev.id   = unit;
> -		ubd_devs[unit].pdev.name = DRIVER_NAME;
> -		ubd_devs[unit].pdev.dev.release = ubd_device_release;
> -		dev_set_drvdata(&ubd_devs[unit].pdev.dev, &ubd_devs[unit]);
> -		platform_device_register(&ubd_devs[unit].pdev);
> -		parent = &ubd_devs[unit].pdev.dev;
> -	}
> +	sprintf(disk->disk_name, "ubd%c", 'a' + unit);
> +
> +	ubd_devs[unit].pdev.id   = unit;
> +	ubd_devs[unit].pdev.name = DRIVER_NAME;
> +	ubd_devs[unit].pdev.dev.release = ubd_device_release;
> +	dev_set_drvdata(&ubd_devs[unit].pdev.dev, &ubd_devs[unit]);
> +	platform_device_register(&ubd_devs[unit].pdev);
>   
>   	disk->private_data = &ubd_devs[unit];
>   	disk->queue = ubd_devs[unit].queue;
> -	device_add_disk(parent, disk, ubd_attr_groups);
> +	device_add_disk(&ubd_devs[unit].pdev.dev, disk, ubd_attr_groups);
>   
>   	*disk_out = disk;
>   	return 0;
> @@ -1001,17 +944,6 @@ static int ubd_add(int n, char **error_out)
>   		goto out_cleanup_tags;
>   	}
>   
> -	if (fake_major != UBD_MAJOR)
> -		ubd_disk_register(fake_major, ubd_dev->size, n,
> -				  &fake_gendisk[n]);
> -
> -	/*
> -	 * Perhaps this should also be under the "if (fake_major)" above
> -	 * using the fake_disk->disk_name
> -	 */
> -	if (fake_ide)
> -		make_ide_entries(ubd_gendisk[n]->disk_name);
> -
>   	err = 0;
>   out:
>   	return err;
> @@ -1126,12 +1058,6 @@ static int ubd_remove(int n, char **error_out)
>   		put_disk(disk);
>   	}
>   
> -	if(fake_gendisk[n] != NULL){
> -		del_gendisk(fake_gendisk[n]);
> -		put_disk(fake_gendisk[n]);
> -		fake_gendisk[n] = NULL;
> -	}
> -
>   	err = 0;
>   	platform_device_unregister(&ubd_dev->pdev);
>   out:
> @@ -1188,14 +1114,6 @@ static int __init ubd_init(void)
>   	if (register_blkdev(UBD_MAJOR, "ubd"))
>   		return -1;
>   
> -	if (fake_major != UBD_MAJOR) {
> -		char name[sizeof("ubd_nnn\0")];
> -
> -		snprintf(name, sizeof(name), "ubd_%d", fake_major);
> -		if (register_blkdev(fake_major, "ubd"))
> -			return -1;
> -	}
> -
>   	irq_req_buffer = kmalloc_array(UBD_REQ_BUFFER_SIZE,
>   				       sizeof(struct io_thread_req *),
>   				       GFP_KERNEL
> 

Acked-By: Anton Ivanov <anton.ivanov at cambridgegreys.com>

-- 
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/


From hch at lst.de  Mon Jun 14 02:49:19 2021
From: hch at lst.de (Christoph Hellwig)
Date: Mon, 14 Jun 2021 11:49:19 +0200
Subject: [PATCH 2/2] ubd: use blk_mq_alloc_disk and blk_cleanup_disk
In-Reply-To: <847f7608-1d11-1410-5394-b5aa5de9f45e@cambridgegreys.com>
References: <20210614060759.3965724-1-hch@lst.de>
 <20210614060759.3965724-3-hch@lst.de>
 <847f7608-1d11-1410-5394-b5aa5de9f45e@cambridgegreys.com>
Message-ID: <20210614094919.GA9501@lst.de>

On Mon, Jun 14, 2021 at 09:26:58AM +0100, Anton Ivanov wrote:
> This does not build for me when applied to master:

Yes, as mentioned in the cover letter it needs for-5.14/block branch
from here:

   git://git.kernel.dk/linux-block for-5.14/block

Gitweb:

   https://git.kernel.dk/cgit/linux-block/log/?h=for-5.14/block


From aneesh.kumar at linux.ibm.com  Tue Jun 15 04:08:58 2021
From: aneesh.kumar at linux.ibm.com (Aneesh Kumar K.V)
Date: Tue, 15 Jun 2021 16:38:58 +0530
Subject: [PATCH v2 1/2] mm: rename pud_page_vaddr to pud_pgtable and make it
 return pmd_t *
Message-ID: <20210615110859.320299-1-aneesh.kumar@linux.ibm.com>

No functional change in this patch.

Cc: linux-alpha at vger.kernel.org
Cc: linux-kernel at vger.kernel.org
Cc: linux-arm-kernel at lists.infradead.org
Cc: linux-ia64 at vger.kernel.org
Cc: linux-m68k at lists.linux-m68k.org
Cc: linux-mips at vger.kernel.org
Cc: linux-parisc at vger.kernel.org
Cc: linuxppc-dev at lists.ozlabs.org
Cc: linux-riscv at lists.infradead.org
Cc: linux-sh at vger.kernel.org
Cc: sparclinux at vger.kernel.org
Cc: linux-um at lists.infradead.org
Cc: linux-arch at vger.kernel.org

Link: https://lore.kernel.org/linuxppc-dev/CAHk-=wi+J+iodze9FtjM3Zi4j4OeS+qqbKxME9QN4roxPEXH9Q at mail.gmail.com/
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar at linux.ibm.com>
---
 arch/alpha/include/asm/pgtable.h             | 8 +++++---
 arch/arm/include/asm/pgtable-3level.h        | 2 +-
 arch/arm64/include/asm/pgtable.h             | 4 ++--
 arch/ia64/include/asm/pgtable.h              | 2 +-
 arch/m68k/include/asm/motorola_pgtable.h     | 2 +-
 arch/mips/include/asm/pgtable-64.h           | 4 ++--
 arch/parisc/include/asm/pgtable.h            | 4 ++--
 arch/powerpc/include/asm/book3s/64/pgtable.h | 6 +++++-
 arch/powerpc/include/asm/nohash/64/pgtable.h | 6 +++++-
 arch/powerpc/mm/book3s64/radix_pgtable.c     | 4 ++--
 arch/powerpc/mm/pgtable_64.c                 | 2 +-
 arch/riscv/include/asm/pgtable-64.h          | 4 ++--
 arch/sh/include/asm/pgtable-3level.h         | 4 ++--
 arch/sparc/include/asm/pgtable_32.h          | 4 ++--
 arch/sparc/include/asm/pgtable_64.h          | 6 +++---
 arch/um/include/asm/pgtable-3level.h         | 2 +-
 arch/x86/include/asm/pgtable.h               | 4 ++--
 arch/x86/mm/pat/set_memory.c                 | 4 ++--
 arch/x86/mm/pgtable.c                        | 2 +-
 include/asm-generic/pgtable-nopmd.h          | 2 +-
 include/asm-generic/pgtable-nopud.h          | 2 +-
 include/linux/pgtable.h                      | 2 +-
 22 files changed, 45 insertions(+), 35 deletions(-)

diff --git a/arch/alpha/include/asm/pgtable.h b/arch/alpha/include/asm/pgtable.h
index 8d856c62e22a..be02e4e403d1 100644
--- a/arch/alpha/include/asm/pgtable.h
+++ b/arch/alpha/include/asm/pgtable.h
@@ -239,8 +239,10 @@ pmd_page_vaddr(pmd_t pmd)
 #define pmd_page(pmd)	(pfn_to_page(pmd_val(pmd) >> 32))
 #define pud_page(pud)	(pfn_to_page(pud_val(pud) >> 32))
 
-extern inline unsigned long pud_page_vaddr(pud_t pgd)
-{ return PAGE_OFFSET + ((pud_val(pgd) & _PFN_MASK) >> (32-PAGE_SHIFT)); }
+static inline pmd_t *pud_pgtable(pud_t pgd)
+{
+	return (pmd_t *)(PAGE_OFFSET + ((pud_val(pgd) & _PFN_MASK) >> (32-PAGE_SHIFT)));
+}
 
 extern inline int pte_none(pte_t pte)		{ return !pte_val(pte); }
 extern inline int pte_present(pte_t pte)	{ return pte_val(pte) & _PAGE_VALID; }
@@ -290,7 +292,7 @@ extern inline pte_t pte_mkyoung(pte_t pte)	{ pte_val(pte) |= __ACCESS_BITS; retu
 /* Find an entry in the second-level page table.. */
 extern inline pmd_t * pmd_offset(pud_t * dir, unsigned long address)
 {
-	pmd_t *ret = (pmd_t *) pud_page_vaddr(*dir) + ((address >> PMD_SHIFT) & (PTRS_PER_PAGE - 1));
+	pmd_t *ret = pud_pgtable(*dir) + ((address >> PMD_SHIFT) & (PTRS_PER_PAGE - 1));
 	smp_rmb(); /* see above */
 	return ret;
 }
diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
index d4edab51a77c..eabe72ff7381 100644
--- a/arch/arm/include/asm/pgtable-3level.h
+++ b/arch/arm/include/asm/pgtable-3level.h
@@ -130,7 +130,7 @@
 		flush_pmd_entry(pudp);	\
 	} while (0)
 
-static inline pmd_t *pud_page_vaddr(pud_t pud)
+static inline pmd_t *pud_pgtable(pud_t pud)
 {
 	return __va(pud_val(pud) & PHYS_MASK & (s32)PAGE_MASK);
 }
diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index 0b10204e72fc..53a415b329b0 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -636,9 +636,9 @@ static inline phys_addr_t pud_page_paddr(pud_t pud)
 	return __pud_to_phys(pud);
 }
 
-static inline unsigned long pud_page_vaddr(pud_t pud)
+static inline pmd_t *pud_pgtable(pud_t pud)
 {
-	return (unsigned long)__va(pud_page_paddr(pud));
+	return (pmd_t *)__va(pud_page_paddr(pud));
 }
 
 /* Find an entry in the second-level page table. */
diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
index d765fd948fae..b2ddfbe70365 100644
--- a/arch/ia64/include/asm/pgtable.h
+++ b/arch/ia64/include/asm/pgtable.h
@@ -274,7 +274,7 @@ ia64_phys_addr_valid (unsigned long addr)
 #define pud_bad(pud)			(!ia64_phys_addr_valid(pud_val(pud)))
 #define pud_present(pud)		(pud_val(pud) != 0UL)
 #define pud_clear(pudp)			(pud_val(*(pudp)) = 0UL)
-#define pud_page_vaddr(pud)		((unsigned long) __va(pud_val(pud) & _PFN_MASK))
+#define pud_pgtable(pud)		((pmd_t *) __va(pud_val(pud) & _PFN_MASK))
 #define pud_page(pud)			virt_to_page((pud_val(pud) + PAGE_OFFSET))
 
 #if CONFIG_PGTABLE_LEVELS == 4
diff --git a/arch/m68k/include/asm/motorola_pgtable.h b/arch/m68k/include/asm/motorola_pgtable.h
index 8076467eff4b..956c80874f98 100644
--- a/arch/m68k/include/asm/motorola_pgtable.h
+++ b/arch/m68k/include/asm/motorola_pgtable.h
@@ -129,7 +129,7 @@ static inline void pud_set(pud_t *pudp, pmd_t *pmdp)
 
 #define __pte_page(pte) ((unsigned long)__va(pte_val(pte) & PAGE_MASK))
 #define pmd_page_vaddr(pmd) ((unsigned long)__va(pmd_val(pmd) & _TABLE_MASK))
-#define pud_page_vaddr(pud) ((unsigned long)__va(pud_val(pud) & _TABLE_MASK))
+#define pud_pgtable(pud) ((pmd_t *)__va(pud_val(pud) & _TABLE_MASK))
 
 
 #define pte_none(pte)		(!pte_val(pte))
diff --git a/arch/mips/include/asm/pgtable-64.h b/arch/mips/include/asm/pgtable-64.h
index 1e7d6ce9d8d6..ab305453e90f 100644
--- a/arch/mips/include/asm/pgtable-64.h
+++ b/arch/mips/include/asm/pgtable-64.h
@@ -314,9 +314,9 @@ static inline void pud_clear(pud_t *pudp)
 #endif
 
 #ifndef __PAGETABLE_PMD_FOLDED
-static inline unsigned long pud_page_vaddr(pud_t pud)
+static inline pmd_t *pud_pgtable(pud_t pud)
 {
-	return pud_val(pud);
+	return (pmd_t *)pud_val(pud);
 }
 #define pud_phys(pud)		virt_to_phys((void *)pud_val(pud))
 #define pud_page(pud)		(pfn_to_page(pud_phys(pud) >> PAGE_SHIFT))
diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
index 39017210dbf0..7218345a447f 100644
--- a/arch/parisc/include/asm/pgtable.h
+++ b/arch/parisc/include/asm/pgtable.h
@@ -324,8 +324,8 @@ static inline void pmd_clear(pmd_t *pmd) {
 
 
 #if CONFIG_PGTABLE_LEVELS == 3
-#define pud_page_vaddr(pud) ((unsigned long) __va(pud_address(pud)))
-#define pud_page(pud)	virt_to_page((void *)pud_page_vaddr(pud))
+#define pud_pgtable(pud) ((pmd_t *) __va(pud_address(pud)))
+#define pud_page(pud)	virt_to_page((void *)pud_pgtable(pud))
 
 /* For 64 bit we have three level tables */
 
diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h
index a666d561b44d..40bafe1e80c9 100644
--- a/arch/powerpc/include/asm/book3s/64/pgtable.h
+++ b/arch/powerpc/include/asm/book3s/64/pgtable.h
@@ -1048,9 +1048,13 @@ extern struct page *p4d_page(p4d_t p4d);
 /* Pointers in the page table tree are physical addresses */
 #define __pgtable_ptr_val(ptr)	__pa(ptr)
 
-#define pud_page_vaddr(pud)	__va(pud_val(pud) & ~PUD_MASKED_BITS)
 #define p4d_page_vaddr(p4d)	__va(p4d_val(p4d) & ~P4D_MASKED_BITS)
 
+static inline pmd_t *pud_pgtable(pud_t pud)
+{
+	return (pmd_t *)__va(pud_val(pud) & ~PUD_MASKED_BITS);
+}
+
 #define pte_ERROR(e) \
 	pr_err("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, pte_val(e))
 #define pmd_ERROR(e) \
diff --git a/arch/powerpc/include/asm/nohash/64/pgtable.h b/arch/powerpc/include/asm/nohash/64/pgtable.h
index 57cd3892bfe0..4158c90c572a 100644
--- a/arch/powerpc/include/asm/nohash/64/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/64/pgtable.h
@@ -164,7 +164,11 @@ static inline void pud_clear(pud_t *pudp)
 #define	pud_bad(pud)		(!is_kernel_addr(pud_val(pud)) \
 				 || (pud_val(pud) & PUD_BAD_BITS))
 #define pud_present(pud)	(pud_val(pud) != 0)
-#define pud_page_vaddr(pud)	(pud_val(pud) & ~PUD_MASKED_BITS)
+
+static inline pmd_t *pud_pgtable(pud_t pud)
+{
+	return (pmd_t *)(pud_val(pud) & ~PUD_MASKED_BITS);
+}
 
 extern struct page *pud_page(pud_t pud);
 
diff --git a/arch/powerpc/mm/book3s64/radix_pgtable.c b/arch/powerpc/mm/book3s64/radix_pgtable.c
index 5fef8db3b463..b663d8f9f05c 100644
--- a/arch/powerpc/mm/book3s64/radix_pgtable.c
+++ b/arch/powerpc/mm/book3s64/radix_pgtable.c
@@ -825,7 +825,7 @@ static void __meminit remove_pud_table(pud_t *pud_start, unsigned long addr,
 			continue;
 		}
 
-		pmd_base = (pmd_t *)pud_page_vaddr(*pud);
+		pmd_base = pud_pgtable(*pud);
 		remove_pmd_table(pmd_base, addr, next);
 		free_pmd_table(pmd_base, pud);
 	}
@@ -1110,7 +1110,7 @@ int pud_free_pmd_page(pud_t *pud, unsigned long addr)
 	pmd_t *pmd;
 	int i;
 
-	pmd = (pmd_t *)pud_page_vaddr(*pud);
+	pmd = pud_pgtable(*pud);
 	pud_clear(pud);
 
 	flush_tlb_kernel_range(addr, addr + PUD_SIZE);
diff --git a/arch/powerpc/mm/pgtable_64.c b/arch/powerpc/mm/pgtable_64.c
index cc6e2f94517f..4ba311808bdb 100644
--- a/arch/powerpc/mm/pgtable_64.c
+++ b/arch/powerpc/mm/pgtable_64.c
@@ -115,7 +115,7 @@ struct page *pud_page(pud_t pud)
 		VM_WARN_ON(!pud_huge(pud));
 		return pte_page(pud_pte(pud));
 	}
-	return virt_to_page(pud_page_vaddr(pud));
+	return virt_to_page(pud_pgtable(pud));
 }
 
 /*
diff --git a/arch/riscv/include/asm/pgtable-64.h b/arch/riscv/include/asm/pgtable-64.h
index f3b0da64c6c8..0e863f3f7187 100644
--- a/arch/riscv/include/asm/pgtable-64.h
+++ b/arch/riscv/include/asm/pgtable-64.h
@@ -60,9 +60,9 @@ static inline void pud_clear(pud_t *pudp)
 	set_pud(pudp, __pud(0));
 }
 
-static inline unsigned long pud_page_vaddr(pud_t pud)
+static inline pmd_t *pud_pgtable(pud_t pud)
 {
-	return (unsigned long)pfn_to_virt(pud_val(pud) >> _PAGE_PFN_SHIFT);
+	return (pmd_t *)pfn_to_virt(pud_val(pud) >> _PAGE_PFN_SHIFT);
 }
 
 static inline struct page *pud_page(pud_t pud)
diff --git a/arch/sh/include/asm/pgtable-3level.h b/arch/sh/include/asm/pgtable-3level.h
index 82d74472dfcd..56bf35c2f29c 100644
--- a/arch/sh/include/asm/pgtable-3level.h
+++ b/arch/sh/include/asm/pgtable-3level.h
@@ -32,9 +32,9 @@ typedef struct { unsigned long long pmd; } pmd_t;
 #define pmd_val(x)	((x).pmd)
 #define __pmd(x)	((pmd_t) { (x) } )
 
-static inline unsigned long pud_page_vaddr(pud_t pud)
+static inline pmd_t *pud_pgtable(pud_t pud)
 {
-	return pud_val(pud);
+	return (pmd_t *)pud_val(pud);
 }
 
 /* only used by the stubbed out hugetlb gup code, should never be called */
diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
index a5cf79c149fe..affd70ab02c8 100644
--- a/arch/sparc/include/asm/pgtable_32.h
+++ b/arch/sparc/include/asm/pgtable_32.h
@@ -152,13 +152,13 @@ static inline unsigned long pmd_page_vaddr(pmd_t pmd)
 	return (unsigned long)__nocache_va(v << 4);
 }
 
-static inline unsigned long pud_page_vaddr(pud_t pud)
+static inline pmd_t *pud_pgtable(pud_t pud)
 {
 	if (srmmu_device_memory(pud_val(pud))) {
 		return ~0;
 	} else {
 		unsigned long v = pud_val(pud) & SRMMU_PTD_PMASK;
-		return (unsigned long)__nocache_va(v << 4);
+		return (pmd_t *)__nocache_va(v << 4);
 	}
 }
 
diff --git a/arch/sparc/include/asm/pgtable_64.h b/arch/sparc/include/asm/pgtable_64.h
index 550d3904de65..534ec872fa2c 100644
--- a/arch/sparc/include/asm/pgtable_64.h
+++ b/arch/sparc/include/asm/pgtable_64.h
@@ -845,18 +845,18 @@ static inline unsigned long pmd_page_vaddr(pmd_t pmd)
 	return ((unsigned long) __va(pfn << PAGE_SHIFT));
 }
 
-static inline unsigned long pud_page_vaddr(pud_t pud)
+static inline pmd_t *pud_pgtable(pud_t pud)
 {
 	pte_t pte = __pte(pud_val(pud));
 	unsigned long pfn;
 
 	pfn = pte_pfn(pte);
 
-	return ((unsigned long) __va(pfn << PAGE_SHIFT));
+	return ((pmd_t *) __va(pfn << PAGE_SHIFT));
 }
 
 #define pmd_page(pmd) 			virt_to_page((void *)pmd_page_vaddr(pmd))
-#define pud_page(pud) 			virt_to_page((void *)pud_page_vaddr(pud))
+#define pud_page(pud)			virt_to_page((void *)pud_pgtable(pud))
 #define pmd_clear(pmdp)			(pmd_val(*(pmdp)) = 0UL)
 #define pud_present(pud)		(pud_val(pud) != 0U)
 #define pud_clear(pudp)			(pud_val(*(pudp)) = 0UL)
diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
index 7e6a4180db9d..091bff319ccd 100644
--- a/arch/um/include/asm/pgtable-3level.h
+++ b/arch/um/include/asm/pgtable-3level.h
@@ -84,7 +84,7 @@ static inline void pud_clear (pud_t *pud)
 }
 
 #define pud_page(pud) phys_to_page(pud_val(pud) & PAGE_MASK)
-#define pud_page_vaddr(pud) ((unsigned long) __va(pud_val(pud) & PAGE_MASK))
+#define pud_pgtable(pud) ((pmd_t *) __va(pud_val(pud) & PAGE_MASK))
 
 static inline unsigned long pte_pfn(pte_t pte)
 {
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index b1099f2d9800..35a34ca6f2e9 100644
--- a/arch/x86/include/asm/pgtable.h
+++ b/arch/x86/include/asm/pgtable.h
@@ -865,9 +865,9 @@ static inline int pud_present(pud_t pud)
 	return pud_flags(pud) & _PAGE_PRESENT;
 }
 
-static inline unsigned long pud_page_vaddr(pud_t pud)
+static inline pmd_t *pud_pgtable(pud_t pud)
 {
-	return (unsigned long)__va(pud_val(pud) & pud_pfn_mask(pud));
+	return (pmd_t *)__va(pud_val(pud) & pud_pfn_mask(pud));
 }
 
 /*
diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c
index 156cd235659f..ad8a5c586a35 100644
--- a/arch/x86/mm/pat/set_memory.c
+++ b/arch/x86/mm/pat/set_memory.c
@@ -1134,7 +1134,7 @@ static void __unmap_pmd_range(pud_t *pud, pmd_t *pmd,
 			      unsigned long start, unsigned long end)
 {
 	if (unmap_pte_range(pmd, start, end))
-		if (try_to_free_pmd_page((pmd_t *)pud_page_vaddr(*pud)))
+		if (try_to_free_pmd_page(pud_pgtable(*pud)))
 			pud_clear(pud);
 }
 
@@ -1178,7 +1178,7 @@ static void unmap_pmd_range(pud_t *pud, unsigned long start, unsigned long end)
 	 * Try again to free the PMD page if haven't succeeded above.
 	 */
 	if (!pud_none(*pud))
-		if (try_to_free_pmd_page((pmd_t *)pud_page_vaddr(*pud)))
+		if (try_to_free_pmd_page(pud_pgtable(*pud)))
 			pud_clear(pud);
 }
 
diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
index d27cf69e811d..3481b35cb4ec 100644
--- a/arch/x86/mm/pgtable.c
+++ b/arch/x86/mm/pgtable.c
@@ -797,7 +797,7 @@ int pud_free_pmd_page(pud_t *pud, unsigned long addr)
 	pte_t *pte;
 	int i;
 
-	pmd = (pmd_t *)pud_page_vaddr(*pud);
+	pmd = pud_pgtable(*pud);
 	pmd_sv = (pmd_t *)__get_free_page(GFP_KERNEL);
 	if (!pmd_sv)
 		return 0;
diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
index 3e13acd019ae..10789cf51d16 100644
--- a/include/asm-generic/pgtable-nopmd.h
+++ b/include/asm-generic/pgtable-nopmd.h
@@ -51,7 +51,7 @@ static inline pmd_t * pmd_offset(pud_t * pud, unsigned long address)
 #define __pmd(x)				((pmd_t) { __pud(x) } )
 
 #define pud_page(pud)				(pmd_page((pmd_t){ pud }))
-#define pud_page_vaddr(pud)			(pmd_page_vaddr((pmd_t){ pud }))
+#define pud_pgtable(pud)			((pmd_t *)(pmd_page_vaddr((pmd_t){ pud })))
 
 /*
  * allocating and freeing a pmd is trivial: the 1-entry pmd is
diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
index a9d751fbda9e..7cbd15f70bf5 100644
--- a/include/asm-generic/pgtable-nopud.h
+++ b/include/asm-generic/pgtable-nopud.h
@@ -49,7 +49,7 @@ static inline pud_t *pud_offset(p4d_t *p4d, unsigned long address)
 #define __pud(x)				((pud_t) { __p4d(x) })
 
 #define p4d_page(p4d)				(pud_page((pud_t){ p4d }))
-#define p4d_page_vaddr(p4d)			(pud_page_vaddr((pud_t){ p4d }))
+#define p4d_page_vaddr(p4d)			(pud_pgtable((pud_t){ p4d }))
 
 /*
  * allocating and freeing a pud is trivial: the 1-entry pud is
diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h
index a43047b1030d..311984f87cf9 100644
--- a/include/linux/pgtable.h
+++ b/include/linux/pgtable.h
@@ -88,7 +88,7 @@ static inline pte_t *pte_offset_kernel(pmd_t *pmd, unsigned long address)
 #ifndef pmd_offset
 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
 {
-	return (pmd_t *)pud_page_vaddr(*pud) + pmd_index(address);
+	return pud_pgtable(*pud) + pmd_index(address);
 }
 #define pmd_offset pmd_offset
 #endif
-- 
2.31.1



From aneesh.kumar at linux.ibm.com  Tue Jun 15 04:08:59 2021
From: aneesh.kumar at linux.ibm.com (Aneesh Kumar K.V)
Date: Tue, 15 Jun 2021 16:38:59 +0530
Subject: [PATCH v2 2/2] mm: rename p4d_page_vaddr to p4d_pgtable and make it
 return pud_t *
In-Reply-To: <20210615110859.320299-1-aneesh.kumar@linux.ibm.com>
References: <20210615110859.320299-1-aneesh.kumar@linux.ibm.com>
Message-ID: <20210615110859.320299-2-aneesh.kumar@linux.ibm.com>

No functional change in this patch.

Cc: linux-alpha at vger.kernel.org
Cc: linux-kernel at vger.kernel.org
Cc: linux-arm-kernel at lists.infradead.org
Cc: linux-ia64 at vger.kernel.org
Cc: linux-m68k at lists.linux-m68k.org
Cc: linux-mips at vger.kernel.org
Cc: linux-parisc at vger.kernel.org
Cc: linuxppc-dev at lists.ozlabs.org
Cc: linux-riscv at lists.infradead.org
Cc: linux-sh at vger.kernel.org
Cc: sparclinux at vger.kernel.org
Cc: linux-um at lists.infradead.org
Cc: linux-arch at vger.kernel.org

Link: https://lore.kernel.org/linuxppc-dev/CAHk-=wi+J+iodze9FtjM3Zi4j4OeS+qqbKxME9QN4roxPEXH9Q at mail.gmail.com/
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar at linux.ibm.com>
---
 arch/arm64/include/asm/pgtable.h                | 4 ++--
 arch/ia64/include/asm/pgtable.h                 | 2 +-
 arch/mips/include/asm/pgtable-64.h              | 4 ++--
 arch/powerpc/include/asm/book3s/64/pgtable.h    | 5 ++++-
 arch/powerpc/include/asm/nohash/64/pgtable-4k.h | 6 +++++-
 arch/powerpc/mm/book3s64/radix_pgtable.c        | 2 +-
 arch/powerpc/mm/pgtable_64.c                    | 2 +-
 arch/sparc/include/asm/pgtable_64.h             | 4 ++--
 arch/x86/include/asm/pgtable.h                  | 4 ++--
 arch/x86/mm/init_64.c                           | 4 ++--
 include/asm-generic/pgtable-nop4d.h             | 2 +-
 include/asm-generic/pgtable-nopud.h             | 2 +-
 include/linux/pgtable.h                         | 2 +-
 13 files changed, 25 insertions(+), 18 deletions(-)

diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index 53a415b329b0..fde06639fff8 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -697,9 +697,9 @@ static inline phys_addr_t p4d_page_paddr(p4d_t p4d)
 	return __p4d_to_phys(p4d);
 }
 
-static inline unsigned long p4d_page_vaddr(p4d_t p4d)
+static inline pud_t *p4d_pgtable(p4d_t p4d)
 {
-	return (unsigned long)__va(p4d_page_paddr(p4d));
+	return (pud_t *)__va(p4d_page_paddr(p4d));
 }
 
 /* Find an entry in the frst-level page table. */
diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
index b2ddfbe70365..a2d5098b299a 100644
--- a/arch/ia64/include/asm/pgtable.h
+++ b/arch/ia64/include/asm/pgtable.h
@@ -282,7 +282,7 @@ ia64_phys_addr_valid (unsigned long addr)
 #define p4d_bad(p4d)			(!ia64_phys_addr_valid(p4d_val(p4d)))
 #define p4d_present(p4d)		(p4d_val(p4d) != 0UL)
 #define p4d_clear(p4dp)			(p4d_val(*(p4dp)) = 0UL)
-#define p4d_page_vaddr(p4d)		((unsigned long) __va(p4d_val(p4d) & _PFN_MASK))
+#define p4d_pgtable(p4d)		((pud_t *) __va(p4d_val(p4d) & _PFN_MASK))
 #define p4d_page(p4d)			virt_to_page((p4d_val(p4d) + PAGE_OFFSET))
 #endif
 
diff --git a/arch/mips/include/asm/pgtable-64.h b/arch/mips/include/asm/pgtable-64.h
index ab305453e90f..b865edff2670 100644
--- a/arch/mips/include/asm/pgtable-64.h
+++ b/arch/mips/include/asm/pgtable-64.h
@@ -210,9 +210,9 @@ static inline void p4d_clear(p4d_t *p4dp)
 	p4d_val(*p4dp) = (unsigned long)invalid_pud_table;
 }
 
-static inline unsigned long p4d_page_vaddr(p4d_t p4d)
+static inline pud_t *p4d_pgtable(p4d_t p4d)
 {
-	return p4d_val(p4d);
+	return (pud_t *)p4d_val(p4d);
 }
 
 #define p4d_phys(p4d)		virt_to_phys((void *)p4d_val(p4d))
diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h
index 40bafe1e80c9..cbedc7c8959d 100644
--- a/arch/powerpc/include/asm/book3s/64/pgtable.h
+++ b/arch/powerpc/include/asm/book3s/64/pgtable.h
@@ -1048,7 +1048,10 @@ extern struct page *p4d_page(p4d_t p4d);
 /* Pointers in the page table tree are physical addresses */
 #define __pgtable_ptr_val(ptr)	__pa(ptr)
 
-#define p4d_page_vaddr(p4d)	__va(p4d_val(p4d) & ~P4D_MASKED_BITS)
+static inline pud_t *p4d_pgtable(p4d_t p4d)
+{
+	return (pud_t *)__va(p4d_val(p4d) & ~P4D_MASKED_BITS);
+}
 
 static inline pmd_t *pud_pgtable(pud_t pud)
 {
diff --git a/arch/powerpc/include/asm/nohash/64/pgtable-4k.h b/arch/powerpc/include/asm/nohash/64/pgtable-4k.h
index fe2f4c9acd9e..10f5cf444d72 100644
--- a/arch/powerpc/include/asm/nohash/64/pgtable-4k.h
+++ b/arch/powerpc/include/asm/nohash/64/pgtable-4k.h
@@ -56,10 +56,14 @@
 #define p4d_none(p4d)		(!p4d_val(p4d))
 #define p4d_bad(p4d)		(p4d_val(p4d) == 0)
 #define p4d_present(p4d)	(p4d_val(p4d) != 0)
-#define p4d_page_vaddr(p4d)	(p4d_val(p4d) & ~P4D_MASKED_BITS)
 
 #ifndef __ASSEMBLY__
 
+static inline pud_t *p4d_pgtable(p4d_t p4d)
+{
+	return (pud_t *) (p4d_val(p4d) & ~P4D_MASKED_BITS);
+}
+
 static inline void p4d_clear(p4d_t *p4dp)
 {
 	*p4dp = __p4d(0);
diff --git a/arch/powerpc/mm/book3s64/radix_pgtable.c b/arch/powerpc/mm/book3s64/radix_pgtable.c
index b663d8f9f05c..1ba6d9291c10 100644
--- a/arch/powerpc/mm/book3s64/radix_pgtable.c
+++ b/arch/powerpc/mm/book3s64/radix_pgtable.c
@@ -859,7 +859,7 @@ static void __meminit remove_pagetable(unsigned long start, unsigned long end)
 			continue;
 		}
 
-		pud_base = (pud_t *)p4d_page_vaddr(*p4d);
+		pud_base = p4d_pgtable(*p4d);
 		remove_pud_table(pud_base, addr, next);
 		free_pud_table(pud_base, p4d);
 	}
diff --git a/arch/powerpc/mm/pgtable_64.c b/arch/powerpc/mm/pgtable_64.c
index 4ba311808bdb..78c8cf01db5f 100644
--- a/arch/powerpc/mm/pgtable_64.c
+++ b/arch/powerpc/mm/pgtable_64.c
@@ -105,7 +105,7 @@ struct page *p4d_page(p4d_t p4d)
 		VM_WARN_ON(!p4d_huge(p4d));
 		return pte_page(p4d_pte(p4d));
 	}
-	return virt_to_page(p4d_page_vaddr(p4d));
+	return virt_to_page(p4d_pgtable(p4d));
 }
 #endif
 
diff --git a/arch/sparc/include/asm/pgtable_64.h b/arch/sparc/include/asm/pgtable_64.h
index 534ec872fa2c..c0f56da1c205 100644
--- a/arch/sparc/include/asm/pgtable_64.h
+++ b/arch/sparc/include/asm/pgtable_64.h
@@ -860,8 +860,8 @@ static inline pmd_t *pud_pgtable(pud_t pud)
 #define pmd_clear(pmdp)			(pmd_val(*(pmdp)) = 0UL)
 #define pud_present(pud)		(pud_val(pud) != 0U)
 #define pud_clear(pudp)			(pud_val(*(pudp)) = 0UL)
-#define p4d_page_vaddr(p4d)		\
-	((unsigned long) __va(p4d_val(p4d)))
+#define p4d_pgtable(p4d)		\
+	((pud_t *) __va(p4d_val(p4d)))
 #define p4d_present(p4d)		(p4d_val(p4d) != 0U)
 #define p4d_clear(p4dp)			(p4d_val(*(p4dp)) = 0UL)
 
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index 35a34ca6f2e9..b6c97b8f59ec 100644
--- a/arch/x86/include/asm/pgtable.h
+++ b/arch/x86/include/asm/pgtable.h
@@ -906,9 +906,9 @@ static inline int p4d_present(p4d_t p4d)
 	return p4d_flags(p4d) & _PAGE_PRESENT;
 }
 
-static inline unsigned long p4d_page_vaddr(p4d_t p4d)
+static inline pud_t *p4d_pgtable(p4d_t p4d)
 {
-	return (unsigned long)__va(p4d_val(p4d) & p4d_pfn_mask(p4d));
+	return (pud_t *)__va(p4d_val(p4d) & p4d_pfn_mask(p4d));
 }
 
 /*
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index e527d829e1ed..ffb3da2cb038 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -193,8 +193,8 @@ static void sync_global_pgds_l4(unsigned long start, unsigned long end)
 			spin_lock(pgt_lock);
 
 			if (!p4d_none(*p4d_ref) && !p4d_none(*p4d))
-				BUG_ON(p4d_page_vaddr(*p4d)
-				       != p4d_page_vaddr(*p4d_ref));
+				BUG_ON(p4d_pgtable(*p4d)
+				       != p4d_pgtable(*p4d_ref));
 
 			if (p4d_none(*p4d))
 				set_p4d(p4d, *p4d_ref);
diff --git a/include/asm-generic/pgtable-nop4d.h b/include/asm-generic/pgtable-nop4d.h
index ce2cbb3c380f..982de5102fc1 100644
--- a/include/asm-generic/pgtable-nop4d.h
+++ b/include/asm-generic/pgtable-nop4d.h
@@ -42,7 +42,7 @@ static inline p4d_t *p4d_offset(pgd_t *pgd, unsigned long address)
 #define __p4d(x)				((p4d_t) { __pgd(x) })
 
 #define pgd_page(pgd)				(p4d_page((p4d_t){ pgd }))
-#define pgd_page_vaddr(pgd)			(p4d_page_vaddr((p4d_t){ pgd }))
+#define pgd_page_vaddr(pgd)			(p4d_pgtable((p4d_t){ pgd }))
 
 /*
  * allocating and freeing a p4d is trivial: the 1-entry p4d is
diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
index 7cbd15f70bf5..eb70c6d7ceff 100644
--- a/include/asm-generic/pgtable-nopud.h
+++ b/include/asm-generic/pgtable-nopud.h
@@ -49,7 +49,7 @@ static inline pud_t *pud_offset(p4d_t *p4d, unsigned long address)
 #define __pud(x)				((pud_t) { __p4d(x) })
 
 #define p4d_page(p4d)				(pud_page((pud_t){ p4d }))
-#define p4d_page_vaddr(p4d)			(pud_pgtable((pud_t){ p4d }))
+#define p4d_pgtable(p4d)			((pud_t *)(pud_pgtable((pud_t){ p4d })))
 
 /*
  * allocating and freeing a pud is trivial: the 1-entry pud is
diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h
index 311984f87cf9..d355290bf70e 100644
--- a/include/linux/pgtable.h
+++ b/include/linux/pgtable.h
@@ -96,7 +96,7 @@ static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
 #ifndef pud_offset
 static inline pud_t *pud_offset(p4d_t *p4d, unsigned long address)
 {
-	return (pud_t *)p4d_page_vaddr(*p4d) + pud_index(address);
+	return p4d_pgtable(*p4d) + pud_index(address);
 }
 #define pud_offset pud_offset
 #endif
-- 
2.31.1



From geert at linux-m68k.org  Tue Jun 15 04:41:53 2021
From: geert at linux-m68k.org (Geert Uytterhoeven)
Date: Tue, 15 Jun 2021 13:41:53 +0200
Subject: [PATCH v2 1/2] mm: rename pud_page_vaddr to pud_pgtable and make
 it return pmd_t *
In-Reply-To: <20210615110859.320299-1-aneesh.kumar@linux.ibm.com>
References: <20210615110859.320299-1-aneesh.kumar@linux.ibm.com>
Message-ID: <CAMuHMdVdG10w4mUP_nLpPkDCP-tb3waPg_AOSJPch9b7AsLGsw@mail.gmail.com>

On Tue, Jun 15, 2021 at 1:32 PM Aneesh Kumar K.V
<aneesh.kumar at linux.ibm.com> wrote:
> No functional change in this patch.

> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar at linux.ibm.com>

>  arch/m68k/include/asm/motorola_pgtable.h     | 2 +-

Acked-by: Geert Uytterhoeven <geert at linux-m68k.org>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds


From axboe at kernel.dk  Tue Jun 15 14:57:35 2021
From: axboe at kernel.dk (Jens Axboe)
Date: Tue, 15 Jun 2021 15:57:35 -0600
Subject: cleanup ubd gendisk registration
In-Reply-To: <20210614060759.3965724-1-hch@lst.de>
References: <20210614060759.3965724-1-hch@lst.de>
Message-ID: <920a6605-f920-ef10-55a0-733219abee6b@kernel.dk>

On 6/14/21 12:07 AM, Christoph Hellwig wrote:
> Hi all,
> 
> this series sits on top of Jens' for-5.14/block branch and tries to
> convert ubd to the new gendisk and request_queue registration helpers.
> As part of that I found that the ide emulation code currently registers
> two gendisk for a request_queue which leads to a bunch of problems we've
> avoided in other drivers (only the mmc subsystem has a similar issue).
> Given that the legacy IDE driver isn't practically used any more and
> modern userspace doesn't hard code specific block drivers, so I think
> we can just drop it.  Let me know if this is ok.

Applied, thanks.

-- 
Jens Axboe



From akpm at linux-foundation.org  Tue Jun 15 16:38:08 2021
From: akpm at linux-foundation.org (akpm at linux-foundation.org)
Date: Tue, 15 Jun 2021 16:38:08 -0700
Subject: +
 mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t.patch
 added to -mm tree
Message-ID: <20210615233808.hzjGO1gF2%akpm@linux-foundation.org>


The patch titled
     Subject: mm: rename pud_page_vaddr to pud_pgtable and make it return pmd_t *
has been added to the -mm tree.  Its filename is
     mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t.patch

This patch should soon appear at
    https://ozlabs.org/~akpm/mmots/broken-out/mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t.patch
and later at
    https://ozlabs.org/~akpm/mmotm/broken-out/mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: "Aneesh Kumar K.V" <aneesh.kumar at linux.ibm.com>
Subject: mm: rename pud_page_vaddr to pud_pgtable and make it return pmd_t *

No functional change in this patch.

Link: https://lkml.kernel.org/r/20210615110859.320299-1-aneesh.kumar at linux.ibm.com
Link: https://lore.kernel.org/linuxppc-dev/CAHk-=wi+J+iodze9FtjM3Zi4j4OeS+qqbKxME9QN4roxPEXH9Q at mail.gmail.com/
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar at linux.ibm.com>
Cc: <linux-alpha at vger.kernel.org>
Cc: <linux-kernel at vger.kernel.org>
Cc: <linux-arm-kernel at lists.infradead.org>
Cc: <linux-ia64 at vger.kernel.org>
Cc: <linux-m68k at lists.linux-m68k.org>
Cc: <linux-mips at vger.kernel.org>
Cc: <linux-parisc at vger.kernel.org>
Cc: <linuxppc-dev at lists.ozlabs.org>
Cc: <linux-riscv at lists.infradead.org>
Cc: <linux-sh at vger.kernel.org>
Cc: <sparclinux at vger.kernel.org>
Cc: <linux-um at lists.infradead.org>
Cc: <linux-arch at vger.kernel.org>
Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
---

 arch/alpha/include/asm/pgtable.h             |    8 +++++---
 arch/arm/include/asm/pgtable-3level.h        |    2 +-
 arch/arm64/include/asm/pgtable.h             |    4 ++--
 arch/ia64/include/asm/pgtable.h              |    2 +-
 arch/m68k/include/asm/motorola_pgtable.h     |    2 +-
 arch/mips/include/asm/pgtable-64.h           |    4 ++--
 arch/parisc/include/asm/pgtable.h            |    4 ++--
 arch/powerpc/include/asm/book3s/64/pgtable.h |    6 +++++-
 arch/powerpc/include/asm/nohash/64/pgtable.h |    6 +++++-
 arch/powerpc/mm/book3s64/radix_pgtable.c     |    4 ++--
 arch/powerpc/mm/pgtable_64.c                 |    2 +-
 arch/riscv/include/asm/pgtable-64.h          |    4 ++--
 arch/sh/include/asm/pgtable-3level.h         |    4 ++--
 arch/sparc/include/asm/pgtable_32.h          |    4 ++--
 arch/sparc/include/asm/pgtable_64.h          |    6 +++---
 arch/um/include/asm/pgtable-3level.h         |    2 +-
 arch/x86/include/asm/pgtable.h               |    4 ++--
 arch/x86/mm/pat/set_memory.c                 |    4 ++--
 arch/x86/mm/pgtable.c                        |    2 +-
 include/asm-generic/pgtable-nopmd.h          |    2 +-
 include/asm-generic/pgtable-nopud.h          |    2 +-
 include/linux/pgtable.h                      |    2 +-
 22 files changed, 45 insertions(+), 35 deletions(-)

--- a/arch/alpha/include/asm/pgtable.h~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/arch/alpha/include/asm/pgtable.h
@@ -236,8 +236,10 @@ pmd_page_vaddr(pmd_t pmd)
 #define pmd_page(pmd)	(pfn_to_page(pmd_val(pmd) >> 32))
 #define pud_page(pud)	(pfn_to_page(pud_val(pud) >> 32))
 
-extern inline unsigned long pud_page_vaddr(pud_t pgd)
-{ return PAGE_OFFSET + ((pud_val(pgd) & _PFN_MASK) >> (32-PAGE_SHIFT)); }
+static inline pmd_t *pud_pgtable(pud_t pgd)
+{
+	return (pmd_t *)(PAGE_OFFSET + ((pud_val(pgd) & _PFN_MASK) >> (32-PAGE_SHIFT)));
+}
 
 extern inline int pte_none(pte_t pte)		{ return !pte_val(pte); }
 extern inline int pte_present(pte_t pte)	{ return pte_val(pte) & _PAGE_VALID; }
@@ -287,7 +289,7 @@ extern inline pte_t pte_mkyoung(pte_t pt
 /* Find an entry in the second-level page table.. */
 extern inline pmd_t * pmd_offset(pud_t * dir, unsigned long address)
 {
-	pmd_t *ret = (pmd_t *) pud_page_vaddr(*dir) + ((address >> PMD_SHIFT) & (PTRS_PER_PAGE - 1));
+	pmd_t *ret = pud_pgtable(*dir) + ((address >> PMD_SHIFT) & (PTRS_PER_PAGE - 1));
 	smp_rmb(); /* see above */
 	return ret;
 }
--- a/arch/arm64/include/asm/pgtable.h~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/arch/arm64/include/asm/pgtable.h
@@ -633,9 +633,9 @@ static inline phys_addr_t pud_page_paddr
 	return __pud_to_phys(pud);
 }
 
-static inline unsigned long pud_page_vaddr(pud_t pud)
+static inline pmd_t *pud_pgtable(pud_t pud)
 {
-	return (unsigned long)__va(pud_page_paddr(pud));
+	return (pmd_t *)__va(pud_page_paddr(pud));
 }
 
 /* Find an entry in the second-level page table. */
--- a/arch/arm/include/asm/pgtable-3level.h~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/arch/arm/include/asm/pgtable-3level.h
@@ -130,7 +130,7 @@
 		flush_pmd_entry(pudp);	\
 	} while (0)
 
-static inline pmd_t *pud_page_vaddr(pud_t pud)
+static inline pmd_t *pud_pgtable(pud_t pud)
 {
 	return __va(pud_val(pud) & PHYS_MASK & (s32)PAGE_MASK);
 }
--- a/arch/ia64/include/asm/pgtable.h~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/arch/ia64/include/asm/pgtable.h
@@ -273,7 +273,7 @@ ia64_phys_addr_valid (unsigned long addr
 #define pud_bad(pud)			(!ia64_phys_addr_valid(pud_val(pud)))
 #define pud_present(pud)		(pud_val(pud) != 0UL)
 #define pud_clear(pudp)			(pud_val(*(pudp)) = 0UL)
-#define pud_page_vaddr(pud)		((unsigned long) __va(pud_val(pud) & _PFN_MASK))
+#define pud_pgtable(pud)		((pmd_t *) __va(pud_val(pud) & _PFN_MASK))
 #define pud_page(pud)			virt_to_page((pud_val(pud) + PAGE_OFFSET))
 
 #if CONFIG_PGTABLE_LEVELS == 4
--- a/arch/m68k/include/asm/motorola_pgtable.h~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/arch/m68k/include/asm/motorola_pgtable.h
@@ -131,7 +131,7 @@ static inline void pud_set(pud_t *pudp,
 
 #define __pte_page(pte) ((unsigned long)__va(pte_val(pte) & PAGE_MASK))
 #define pmd_page_vaddr(pmd) ((unsigned long)__va(pmd_val(pmd) & _TABLE_MASK))
-#define pud_page_vaddr(pud) ((unsigned long)__va(pud_val(pud) & _TABLE_MASK))
+#define pud_pgtable(pud) ((pmd_t *)__va(pud_val(pud) & _TABLE_MASK))
 
 
 #define pte_none(pte)		(!pte_val(pte))
--- a/arch/mips/include/asm/pgtable-64.h~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/arch/mips/include/asm/pgtable-64.h
@@ -313,9 +313,9 @@ static inline void pud_clear(pud_t *pudp
 #endif
 
 #ifndef __PAGETABLE_PMD_FOLDED
-static inline unsigned long pud_page_vaddr(pud_t pud)
+static inline pmd_t *pud_pgtable(pud_t pud)
 {
-	return pud_val(pud);
+	return (pmd_t *)pud_val(pud);
 }
 #define pud_phys(pud)		virt_to_phys((void *)pud_val(pud))
 #define pud_page(pud)		(pfn_to_page(pud_phys(pud) >> PAGE_SHIFT))
--- a/arch/parisc/include/asm/pgtable.h~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/arch/parisc/include/asm/pgtable.h
@@ -322,8 +322,8 @@ static inline void pmd_clear(pmd_t *pmd)
 
 
 #if CONFIG_PGTABLE_LEVELS == 3
-#define pud_page_vaddr(pud) ((unsigned long) __va(pud_address(pud)))
-#define pud_page(pud)	virt_to_page((void *)pud_page_vaddr(pud))
+#define pud_pgtable(pud) ((pmd_t *) __va(pud_address(pud)))
+#define pud_page(pud)	virt_to_page((void *)pud_pgtable(pud))
 
 /* For 64 bit we have three level tables */
 
--- a/arch/powerpc/include/asm/book3s/64/pgtable.h~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/arch/powerpc/include/asm/book3s/64/pgtable.h
@@ -1048,9 +1048,13 @@ extern struct page *p4d_page(p4d_t p4d);
 /* Pointers in the page table tree are physical addresses */
 #define __pgtable_ptr_val(ptr)	__pa(ptr)
 
-#define pud_page_vaddr(pud)	__va(pud_val(pud) & ~PUD_MASKED_BITS)
 #define p4d_page_vaddr(p4d)	__va(p4d_val(p4d) & ~P4D_MASKED_BITS)
 
+static inline pmd_t *pud_pgtable(pud_t pud)
+{
+	return (pmd_t *)__va(pud_val(pud) & ~PUD_MASKED_BITS);
+}
+
 #define pte_ERROR(e) \
 	pr_err("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, pte_val(e))
 #define pmd_ERROR(e) \
--- a/arch/powerpc/include/asm/nohash/64/pgtable.h~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/arch/powerpc/include/asm/nohash/64/pgtable.h
@@ -162,7 +162,11 @@ static inline void pud_clear(pud_t *pudp
 #define	pud_bad(pud)		(!is_kernel_addr(pud_val(pud)) \
 				 || (pud_val(pud) & PUD_BAD_BITS))
 #define pud_present(pud)	(pud_val(pud) != 0)
-#define pud_page_vaddr(pud)	(pud_val(pud) & ~PUD_MASKED_BITS)
+
+static inline pmd_t *pud_pgtable(pud_t pud)
+{
+	return (pmd_t *)(pud_val(pud) & ~PUD_MASKED_BITS);
+}
 
 extern struct page *pud_page(pud_t pud);
 
--- a/arch/powerpc/mm/book3s64/radix_pgtable.c~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/arch/powerpc/mm/book3s64/radix_pgtable.c
@@ -826,7 +826,7 @@ static void __meminit remove_pud_table(p
 			continue;
 		}
 
-		pmd_base = (pmd_t *)pud_page_vaddr(*pud);
+		pmd_base = pud_pgtable(*pud);
 		remove_pmd_table(pmd_base, addr, next);
 		free_pmd_table(pmd_base, pud);
 	}
@@ -1111,7 +1111,7 @@ int pud_free_pmd_page(pud_t *pud, unsign
 	pmd_t *pmd;
 	int i;
 
-	pmd = (pmd_t *)pud_page_vaddr(*pud);
+	pmd = pud_pgtable(*pud);
 	pud_clear(pud);
 
 	flush_tlb_kernel_range(addr, addr + PUD_SIZE);
--- a/arch/powerpc/mm/pgtable_64.c~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/arch/powerpc/mm/pgtable_64.c
@@ -115,7 +115,7 @@ struct page *pud_page(pud_t pud)
 		VM_WARN_ON(!pud_huge(pud));
 		return pte_page(pud_pte(pud));
 	}
-	return virt_to_page(pud_page_vaddr(pud));
+	return virt_to_page(pud_pgtable(pud));
 }
 
 /*
--- a/arch/riscv/include/asm/pgtable-64.h~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/arch/riscv/include/asm/pgtable-64.h
@@ -59,9 +59,9 @@ static inline void pud_clear(pud_t *pudp
 	set_pud(pudp, __pud(0));
 }
 
-static inline unsigned long pud_page_vaddr(pud_t pud)
+static inline pmd_t *pud_pgtable(pud_t pud)
 {
-	return (unsigned long)pfn_to_virt(pud_val(pud) >> _PAGE_PFN_SHIFT);
+	return (pmd_t *)pfn_to_virt(pud_val(pud) >> _PAGE_PFN_SHIFT);
 }
 
 static inline struct page *pud_page(pud_t pud)
--- a/arch/sh/include/asm/pgtable-3level.h~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/arch/sh/include/asm/pgtable-3level.h
@@ -32,9 +32,9 @@ typedef struct { unsigned long long pmd;
 #define pmd_val(x)	((x).pmd)
 #define __pmd(x)	((pmd_t) { (x) } )
 
-static inline unsigned long pud_page_vaddr(pud_t pud)
+static inline pmd_t *pud_pgtable(pud_t pud)
 {
-	return pud_val(pud);
+	return (pmd_t *)pud_val(pud);
 }
 
 /* only used by the stubbed out hugetlb gup code, should never be called */
--- a/arch/sparc/include/asm/pgtable_32.h~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/arch/sparc/include/asm/pgtable_32.h
@@ -151,13 +151,13 @@ static inline unsigned long pmd_page_vad
 	return (unsigned long)__nocache_va(v << 4);
 }
 
-static inline unsigned long pud_page_vaddr(pud_t pud)
+static inline pmd_t *pud_pgtable(pud_t pud)
 {
 	if (srmmu_device_memory(pud_val(pud))) {
 		return ~0;
 	} else {
 		unsigned long v = pud_val(pud) & SRMMU_PTD_PMASK;
-		return (unsigned long)__nocache_va(v << 4);
+		return (pmd_t *)__nocache_va(v << 4);
 	}
 }
 
--- a/arch/sparc/include/asm/pgtable_64.h~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/arch/sparc/include/asm/pgtable_64.h
@@ -841,18 +841,18 @@ static inline unsigned long pmd_page_vad
 	return ((unsigned long) __va(pfn << PAGE_SHIFT));
 }
 
-static inline unsigned long pud_page_vaddr(pud_t pud)
+static inline pmd_t *pud_pgtable(pud_t pud)
 {
 	pte_t pte = __pte(pud_val(pud));
 	unsigned long pfn;
 
 	pfn = pte_pfn(pte);
 
-	return ((unsigned long) __va(pfn << PAGE_SHIFT));
+	return ((pmd_t *) __va(pfn << PAGE_SHIFT));
 }
 
 #define pmd_page(pmd) 			virt_to_page((void *)pmd_page_vaddr(pmd))
-#define pud_page(pud) 			virt_to_page((void *)pud_page_vaddr(pud))
+#define pud_page(pud)			virt_to_page((void *)pud_pgtable(pud))
 #define pmd_clear(pmdp)			(pmd_val(*(pmdp)) = 0UL)
 #define pud_present(pud)		(pud_val(pud) != 0U)
 #define pud_clear(pudp)			(pud_val(*(pudp)) = 0UL)
--- a/arch/um/include/asm/pgtable-3level.h~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/arch/um/include/asm/pgtable-3level.h
@@ -83,7 +83,7 @@ static inline void pud_clear (pud_t *pud
 }
 
 #define pud_page(pud) phys_to_page(pud_val(pud) & PAGE_MASK)
-#define pud_page_vaddr(pud) ((unsigned long) __va(pud_val(pud) & PAGE_MASK))
+#define pud_pgtable(pud) ((pmd_t *) __va(pud_val(pud) & PAGE_MASK))
 
 static inline unsigned long pte_pfn(pte_t pte)
 {
--- a/arch/x86/include/asm/pgtable.h~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/arch/x86/include/asm/pgtable.h
@@ -865,9 +865,9 @@ static inline int pud_present(pud_t pud)
 	return pud_flags(pud) & _PAGE_PRESENT;
 }
 
-static inline unsigned long pud_page_vaddr(pud_t pud)
+static inline pmd_t *pud_pgtable(pud_t pud)
 {
-	return (unsigned long)__va(pud_val(pud) & pud_pfn_mask(pud));
+	return (pmd_t *)__va(pud_val(pud) & pud_pfn_mask(pud));
 }
 
 /*
--- a/arch/x86/mm/pat/set_memory.c~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/arch/x86/mm/pat/set_memory.c
@@ -1134,7 +1134,7 @@ static void __unmap_pmd_range(pud_t *pud
 			      unsigned long start, unsigned long end)
 {
 	if (unmap_pte_range(pmd, start, end))
-		if (try_to_free_pmd_page((pmd_t *)pud_page_vaddr(*pud)))
+		if (try_to_free_pmd_page(pud_pgtable(*pud)))
 			pud_clear(pud);
 }
 
@@ -1178,7 +1178,7 @@ static void unmap_pmd_range(pud_t *pud,
 	 * Try again to free the PMD page if haven't succeeded above.
 	 */
 	if (!pud_none(*pud))
-		if (try_to_free_pmd_page((pmd_t *)pud_page_vaddr(*pud)))
+		if (try_to_free_pmd_page(pud_pgtable(*pud)))
 			pud_clear(pud);
 }
 
--- a/arch/x86/mm/pgtable.c~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/arch/x86/mm/pgtable.c
@@ -801,7 +801,7 @@ int pud_free_pmd_page(pud_t *pud, unsign
 	pte_t *pte;
 	int i;
 
-	pmd = (pmd_t *)pud_page_vaddr(*pud);
+	pmd = pud_pgtable(*pud);
 	pmd_sv = (pmd_t *)__get_free_page(GFP_KERNEL);
 	if (!pmd_sv)
 		return 0;
--- a/include/asm-generic/pgtable-nopmd.h~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/include/asm-generic/pgtable-nopmd.h
@@ -51,7 +51,7 @@ static inline pmd_t * pmd_offset(pud_t *
 #define __pmd(x)				((pmd_t) { __pud(x) } )
 
 #define pud_page(pud)				(pmd_page((pmd_t){ pud }))
-#define pud_page_vaddr(pud)			(pmd_page_vaddr((pmd_t){ pud }))
+#define pud_pgtable(pud)			((pmd_t *)(pmd_page_vaddr((pmd_t){ pud })))
 
 /*
  * allocating and freeing a pmd is trivial: the 1-entry pmd is
--- a/include/asm-generic/pgtable-nopud.h~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/include/asm-generic/pgtable-nopud.h
@@ -49,7 +49,7 @@ static inline pud_t *pud_offset(p4d_t *p
 #define __pud(x)				((pud_t) { __p4d(x) })
 
 #define p4d_page(p4d)				(pud_page((pud_t){ p4d }))
-#define p4d_page_vaddr(p4d)			(pud_page_vaddr((pud_t){ p4d }))
+#define p4d_page_vaddr(p4d)			(pud_pgtable((pud_t){ p4d }))
 
 /*
  * allocating and freeing a pud is trivial: the 1-entry pud is
--- a/include/linux/pgtable.h~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/include/linux/pgtable.h
@@ -106,7 +106,7 @@ static inline pte_t *pte_offset_kernel(p
 #ifndef pmd_offset
 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
 {
-	return (pmd_t *)pud_page_vaddr(*pud) + pmd_index(address);
+	return pud_pgtable(*pud) + pmd_index(address);
 }
 #define pmd_offset pmd_offset
 #endif
_

Patches currently in -mm which might be from aneesh.kumar at linux.ibm.com are

mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t.patch
mm-rename-p4d_page_vaddr-to-p4d_pgtable-and-make-it-return-pud_t.patch



From akpm at linux-foundation.org  Tue Jun 15 16:38:15 2021
From: akpm at linux-foundation.org (akpm at linux-foundation.org)
Date: Tue, 15 Jun 2021 16:38:15 -0700
Subject: +
 mm-rename-p4d_page_vaddr-to-p4d_pgtable-and-make-it-return-pud_t.patch
 added to -mm tree
Message-ID: <20210615233815.VObB7frXE%akpm@linux-foundation.org>


The patch titled
     Subject: mm: rename p4d_page_vaddr to p4d_pgtable and make it return pud_t *
has been added to the -mm tree.  Its filename is
     mm-rename-p4d_page_vaddr-to-p4d_pgtable-and-make-it-return-pud_t.patch

This patch should soon appear at
    https://ozlabs.org/~akpm/mmots/broken-out/mm-rename-p4d_page_vaddr-to-p4d_pgtable-and-make-it-return-pud_t.patch
and later at
    https://ozlabs.org/~akpm/mmotm/broken-out/mm-rename-p4d_page_vaddr-to-p4d_pgtable-and-make-it-return-pud_t.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: "Aneesh Kumar K.V" <aneesh.kumar at linux.ibm.com>
Subject: mm: rename p4d_page_vaddr to p4d_pgtable and make it return pud_t *

No functional change in this patch.

Link: https://lkml.kernel.org/r/20210615110859.320299-2-aneesh.kumar at linux.ibm.com
Link: https://lore.kernel.org/linuxppc-dev/CAHk-=wi+J+iodze9FtjM3Zi4j4OeS+qqbKxME9QN4roxPEXH9Q at mail.gmail.com/
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar at linux.ibm.com>
Cc: <linux-alpha at vger.kernel.org>
Cc: <linux-kernel at vger.kernel.org>
Cc: <linux-arm-kernel at lists.infradead.org>
Cc: <linux-ia64 at vger.kernel.org>
Cc: <linux-m68k at lists.linux-m68k.org>
Cc: <linux-mips at vger.kernel.org>
Cc: <linux-parisc at vger.kernel.org>
Cc: <linuxppc-dev at lists.ozlabs.org>
Cc: <linux-riscv at lists.infradead.org>
Cc: <linux-sh at vger.kernel.org>
Cc: <sparclinux at vger.kernel.org>
Cc: <linux-um at lists.infradead.org>
Cc: <linux-arch at vger.kernel.org>
Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
---

 arch/arm64/include/asm/pgtable.h                |    4 ++--
 arch/ia64/include/asm/pgtable.h                 |    2 +-
 arch/mips/include/asm/pgtable-64.h              |    4 ++--
 arch/powerpc/include/asm/book3s/64/pgtable.h    |    5 ++++-
 arch/powerpc/include/asm/nohash/64/pgtable-4k.h |    6 +++++-
 arch/powerpc/mm/book3s64/radix_pgtable.c        |    2 +-
 arch/powerpc/mm/pgtable_64.c                    |    2 +-
 arch/sparc/include/asm/pgtable_64.h             |    4 ++--
 arch/x86/include/asm/pgtable.h                  |    4 ++--
 arch/x86/mm/init_64.c                           |    4 ++--
 include/asm-generic/pgtable-nop4d.h             |    2 +-
 include/asm-generic/pgtable-nopud.h             |    2 +-
 include/linux/pgtable.h                         |    2 +-
 13 files changed, 25 insertions(+), 18 deletions(-)

--- a/arch/arm64/include/asm/pgtable.h~mm-rename-p4d_page_vaddr-to-p4d_pgtable-and-make-it-return-pud_t
+++ a/arch/arm64/include/asm/pgtable.h
@@ -694,9 +694,9 @@ static inline phys_addr_t p4d_page_paddr
 	return __p4d_to_phys(p4d);
 }
 
-static inline unsigned long p4d_page_vaddr(p4d_t p4d)
+static inline pud_t *p4d_pgtable(p4d_t p4d)
 {
-	return (unsigned long)__va(p4d_page_paddr(p4d));
+	return (pud_t *)__va(p4d_page_paddr(p4d));
 }
 
 /* Find an entry in the frst-level page table. */
--- a/arch/ia64/include/asm/pgtable.h~mm-rename-p4d_page_vaddr-to-p4d_pgtable-and-make-it-return-pud_t
+++ a/arch/ia64/include/asm/pgtable.h
@@ -281,7 +281,7 @@ ia64_phys_addr_valid (unsigned long addr
 #define p4d_bad(p4d)			(!ia64_phys_addr_valid(p4d_val(p4d)))
 #define p4d_present(p4d)		(p4d_val(p4d) != 0UL)
 #define p4d_clear(p4dp)			(p4d_val(*(p4dp)) = 0UL)
-#define p4d_page_vaddr(p4d)		((unsigned long) __va(p4d_val(p4d) & _PFN_MASK))
+#define p4d_pgtable(p4d)		((pud_t *) __va(p4d_val(p4d) & _PFN_MASK))
 #define p4d_page(p4d)			virt_to_page((p4d_val(p4d) + PAGE_OFFSET))
 #endif
 
--- a/arch/mips/include/asm/pgtable-64.h~mm-rename-p4d_page_vaddr-to-p4d_pgtable-and-make-it-return-pud_t
+++ a/arch/mips/include/asm/pgtable-64.h
@@ -209,9 +209,9 @@ static inline void p4d_clear(p4d_t *p4dp
 	p4d_val(*p4dp) = (unsigned long)invalid_pud_table;
 }
 
-static inline unsigned long p4d_page_vaddr(p4d_t p4d)
+static inline pud_t *p4d_pgtable(p4d_t p4d)
 {
-	return p4d_val(p4d);
+	return (pud_t *)p4d_val(p4d);
 }
 
 #define p4d_phys(p4d)		virt_to_phys((void *)p4d_val(p4d))
--- a/arch/powerpc/include/asm/book3s/64/pgtable.h~mm-rename-p4d_page_vaddr-to-p4d_pgtable-and-make-it-return-pud_t
+++ a/arch/powerpc/include/asm/book3s/64/pgtable.h
@@ -1048,7 +1048,10 @@ extern struct page *p4d_page(p4d_t p4d);
 /* Pointers in the page table tree are physical addresses */
 #define __pgtable_ptr_val(ptr)	__pa(ptr)
 
-#define p4d_page_vaddr(p4d)	__va(p4d_val(p4d) & ~P4D_MASKED_BITS)
+static inline pud_t *p4d_pgtable(p4d_t p4d)
+{
+	return (pud_t *)__va(p4d_val(p4d) & ~P4D_MASKED_BITS);
+}
 
 static inline pmd_t *pud_pgtable(pud_t pud)
 {
--- a/arch/powerpc/include/asm/nohash/64/pgtable-4k.h~mm-rename-p4d_page_vaddr-to-p4d_pgtable-and-make-it-return-pud_t
+++ a/arch/powerpc/include/asm/nohash/64/pgtable-4k.h
@@ -56,10 +56,14 @@
 #define p4d_none(p4d)		(!p4d_val(p4d))
 #define p4d_bad(p4d)		(p4d_val(p4d) == 0)
 #define p4d_present(p4d)	(p4d_val(p4d) != 0)
-#define p4d_page_vaddr(p4d)	(p4d_val(p4d) & ~P4D_MASKED_BITS)
 
 #ifndef __ASSEMBLY__
 
+static inline pud_t *p4d_pgtable(p4d_t p4d)
+{
+	return (pud_t *) (p4d_val(p4d) & ~P4D_MASKED_BITS);
+}
+
 static inline void p4d_clear(p4d_t *p4dp)
 {
 	*p4dp = __p4d(0);
--- a/arch/powerpc/mm/book3s64/radix_pgtable.c~mm-rename-p4d_page_vaddr-to-p4d_pgtable-and-make-it-return-pud_t
+++ a/arch/powerpc/mm/book3s64/radix_pgtable.c
@@ -860,7 +860,7 @@ static void __meminit remove_pagetable(u
 			continue;
 		}
 
-		pud_base = (pud_t *)p4d_page_vaddr(*p4d);
+		pud_base = p4d_pgtable(*p4d);
 		remove_pud_table(pud_base, addr, next);
 		free_pud_table(pud_base, p4d);
 	}
--- a/arch/powerpc/mm/pgtable_64.c~mm-rename-p4d_page_vaddr-to-p4d_pgtable-and-make-it-return-pud_t
+++ a/arch/powerpc/mm/pgtable_64.c
@@ -105,7 +105,7 @@ struct page *p4d_page(p4d_t p4d)
 		VM_WARN_ON(!p4d_huge(p4d));
 		return pte_page(p4d_pte(p4d));
 	}
-	return virt_to_page(p4d_page_vaddr(p4d));
+	return virt_to_page(p4d_pgtable(p4d));
 }
 #endif
 
--- a/arch/sparc/include/asm/pgtable_64.h~mm-rename-p4d_page_vaddr-to-p4d_pgtable-and-make-it-return-pud_t
+++ a/arch/sparc/include/asm/pgtable_64.h
@@ -856,8 +856,8 @@ static inline pmd_t *pud_pgtable(pud_t p
 #define pmd_clear(pmdp)			(pmd_val(*(pmdp)) = 0UL)
 #define pud_present(pud)		(pud_val(pud) != 0U)
 #define pud_clear(pudp)			(pud_val(*(pudp)) = 0UL)
-#define p4d_page_vaddr(p4d)		\
-	((unsigned long) __va(p4d_val(p4d)))
+#define p4d_pgtable(p4d)		\
+	((pud_t *) __va(p4d_val(p4d)))
 #define p4d_present(p4d)		(p4d_val(p4d) != 0U)
 #define p4d_clear(p4dp)			(p4d_val(*(p4dp)) = 0UL)
 
--- a/arch/x86/include/asm/pgtable.h~mm-rename-p4d_page_vaddr-to-p4d_pgtable-and-make-it-return-pud_t
+++ a/arch/x86/include/asm/pgtable.h
@@ -906,9 +906,9 @@ static inline int p4d_present(p4d_t p4d)
 	return p4d_flags(p4d) & _PAGE_PRESENT;
 }
 
-static inline unsigned long p4d_page_vaddr(p4d_t p4d)
+static inline pud_t *p4d_pgtable(p4d_t p4d)
 {
-	return (unsigned long)__va(p4d_val(p4d) & p4d_pfn_mask(p4d));
+	return (pud_t *)__va(p4d_val(p4d) & p4d_pfn_mask(p4d));
 }
 
 /*
--- a/arch/x86/mm/init_64.c~mm-rename-p4d_page_vaddr-to-p4d_pgtable-and-make-it-return-pud_t
+++ a/arch/x86/mm/init_64.c
@@ -195,8 +195,8 @@ static void sync_global_pgds_l4(unsigned
 			spin_lock(pgt_lock);
 
 			if (!p4d_none(*p4d_ref) && !p4d_none(*p4d))
-				BUG_ON(p4d_page_vaddr(*p4d)
-				       != p4d_page_vaddr(*p4d_ref));
+				BUG_ON(p4d_pgtable(*p4d)
+				       != p4d_pgtable(*p4d_ref));
 
 			if (p4d_none(*p4d))
 				set_p4d(p4d, *p4d_ref);
--- a/include/asm-generic/pgtable-nop4d.h~mm-rename-p4d_page_vaddr-to-p4d_pgtable-and-make-it-return-pud_t
+++ a/include/asm-generic/pgtable-nop4d.h
@@ -42,7 +42,7 @@ static inline p4d_t *p4d_offset(pgd_t *p
 #define __p4d(x)				((p4d_t) { __pgd(x) })
 
 #define pgd_page(pgd)				(p4d_page((p4d_t){ pgd }))
-#define pgd_page_vaddr(pgd)			(p4d_page_vaddr((p4d_t){ pgd }))
+#define pgd_page_vaddr(pgd)			(p4d_pgtable((p4d_t){ pgd }))
 
 /*
  * allocating and freeing a p4d is trivial: the 1-entry p4d is
--- a/include/asm-generic/pgtable-nopud.h~mm-rename-p4d_page_vaddr-to-p4d_pgtable-and-make-it-return-pud_t
+++ a/include/asm-generic/pgtable-nopud.h
@@ -49,7 +49,7 @@ static inline pud_t *pud_offset(p4d_t *p
 #define __pud(x)				((pud_t) { __p4d(x) })
 
 #define p4d_page(p4d)				(pud_page((pud_t){ p4d }))
-#define p4d_page_vaddr(p4d)			(pud_pgtable((pud_t){ p4d }))
+#define p4d_pgtable(p4d)			((pud_t *)(pud_pgtable((pud_t){ p4d })))
 
 /*
  * allocating and freeing a pud is trivial: the 1-entry pud is
--- a/include/linux/pgtable.h~mm-rename-p4d_page_vaddr-to-p4d_pgtable-and-make-it-return-pud_t
+++ a/include/linux/pgtable.h
@@ -114,7 +114,7 @@ static inline pmd_t *pmd_offset(pud_t *p
 #ifndef pud_offset
 static inline pud_t *pud_offset(p4d_t *p4d, unsigned long address)
 {
-	return (pud_t *)p4d_page_vaddr(*p4d) + pud_index(address);
+	return p4d_pgtable(*p4d) + pud_index(address);
 }
 #define pud_offset pud_offset
 #endif
_

Patches currently in -mm which might be from aneesh.kumar at linux.ibm.com are

mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t.patch
mm-rename-p4d_page_vaddr-to-p4d_pgtable-and-make-it-return-pud_t.patch



From brendanhiggins at google.com  Wed Jun 16 13:36:46 2021
From: brendanhiggins at google.com (Brendan Higgins)
Date: Wed, 16 Jun 2021 13:36:46 -0700
Subject: [PATCH v2 2/3] kunit: Move default config from arch/um ->
 tools/testing/kunit
In-Reply-To: <20210522044241.2763088-2-davidgow@google.com>
References: <20210522044241.2763088-1-davidgow@google.com>
 <20210522044241.2763088-2-davidgow@google.com>
Message-ID: <CAFd5g44-zP7VWwBMxSMv=PNPQWNHB-y90kQ4E8WVqs2mWCE2dQ@mail.gmail.com>

On Fri, May 21, 2021 at 9:43 PM David Gow <davidgow at google.com> wrote:
>
> The default .kunitconfig file is currently kept in
> arch/um/configs/kunit_defconfig, but -- with the impending QEMU patch
> -- will no-longer be exclusively used for UML-based kernels.
>
> Move it alongside the other KUnit configs in
> tools/testing/kunit/configs, and give it a name which matches the
> existing all_tests.config and broken_on_uml.config files.
>
> Also update the Getting Started documentation to point to the new file.
>
> Signed-off-by: David Gow <davidgow at google.com>

Reviewed-by: Brendan Higgins <brendanhiggins at google.com>


From brendanhiggins at google.com  Wed Jun 16 13:41:16 2021
From: brendanhiggins at google.com (Brendan Higgins)
Date: Wed, 16 Jun 2021 13:41:16 -0700
Subject: [PATCH v2 3/3] kunit: Remove the unused all_tests.config
In-Reply-To: <20210522044241.2763088-3-davidgow@google.com>
References: <20210522044241.2763088-1-davidgow@google.com>
 <20210522044241.2763088-3-davidgow@google.com>
Message-ID: <CAFd5g46jOwV5iZretZEHOuxTbSvNxan-VSiN7genAXkhgbksAg@mail.gmail.com>

On Fri, May 21, 2021 at 9:43 PM David Gow <davidgow at google.com> wrote:
>
> This isn't used anywhere. While it's possible that people were manually
> referencing it, the new default config (in default.config in the same
> path) provides equivalent functionality.
>
> Signed-off-by: David Gow <davidgow at google.com>

Reviewed-by: Brendan Higgins <brendanhiggins at google.com>


From akpm at linux-foundation.org  Wed Jun 16 16:08:04 2021
From: akpm at linux-foundation.org (akpm at linux-foundation.org)
Date: Wed, 16 Jun 2021 16:08:04 -0700
Subject: [to-be-updated]
 mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t.patch
 removed from -mm tree
Message-ID: <20210616230804.7nsBdkkF4%akpm@linux-foundation.org>


The patch titled
     Subject: mm: rename pud_page_vaddr to pud_pgtable and make it return pmd_t *
has been removed from the -mm tree.  Its filename was
     mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t.patch

This patch was dropped because an updated version will be merged

------------------------------------------------------
From: "Aneesh Kumar K.V" <aneesh.kumar at linux.ibm.com>
Subject: mm: rename pud_page_vaddr to pud_pgtable and make it return pmd_t *

No functional change in this patch.

Link: https://lkml.kernel.org/r/20210615110859.320299-1-aneesh.kumar at linux.ibm.com
Link: https://lore.kernel.org/linuxppc-dev/CAHk-=wi+J+iodze9FtjM3Zi4j4OeS+qqbKxME9QN4roxPEXH9Q at mail.gmail.com/
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar at linux.ibm.com>
Cc: <linux-alpha at vger.kernel.org>
Cc: <linux-kernel at vger.kernel.org>
Cc: <linux-arm-kernel at lists.infradead.org>
Cc: <linux-ia64 at vger.kernel.org>
Cc: <linux-m68k at lists.linux-m68k.org>
Cc: <linux-mips at vger.kernel.org>
Cc: <linux-parisc at vger.kernel.org>
Cc: <linuxppc-dev at lists.ozlabs.org>
Cc: <linux-riscv at lists.infradead.org>
Cc: <linux-sh at vger.kernel.org>
Cc: <sparclinux at vger.kernel.org>
Cc: <linux-um at lists.infradead.org>
Cc: <linux-arch at vger.kernel.org>
Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
---

 arch/alpha/include/asm/pgtable.h             |    8 +++++---
 arch/arm/include/asm/pgtable-3level.h        |    2 +-
 arch/arm64/include/asm/pgtable.h             |    4 ++--
 arch/ia64/include/asm/pgtable.h              |    2 +-
 arch/m68k/include/asm/motorola_pgtable.h     |    2 +-
 arch/mips/include/asm/pgtable-64.h           |    4 ++--
 arch/parisc/include/asm/pgtable.h            |    4 ++--
 arch/powerpc/include/asm/book3s/64/pgtable.h |    6 +++++-
 arch/powerpc/include/asm/nohash/64/pgtable.h |    6 +++++-
 arch/powerpc/mm/book3s64/radix_pgtable.c     |    4 ++--
 arch/powerpc/mm/pgtable_64.c                 |    2 +-
 arch/riscv/include/asm/pgtable-64.h          |    4 ++--
 arch/sh/include/asm/pgtable-3level.h         |    4 ++--
 arch/sparc/include/asm/pgtable_32.h          |    4 ++--
 arch/sparc/include/asm/pgtable_64.h          |    6 +++---
 arch/um/include/asm/pgtable-3level.h         |    2 +-
 arch/x86/include/asm/pgtable.h               |    4 ++--
 arch/x86/mm/pat/set_memory.c                 |    4 ++--
 arch/x86/mm/pgtable.c                        |    2 +-
 include/asm-generic/pgtable-nopmd.h          |    2 +-
 include/asm-generic/pgtable-nopud.h          |    2 +-
 include/linux/pgtable.h                      |    2 +-
 22 files changed, 45 insertions(+), 35 deletions(-)

--- a/arch/alpha/include/asm/pgtable.h~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/arch/alpha/include/asm/pgtable.h
@@ -236,8 +236,10 @@ pmd_page_vaddr(pmd_t pmd)
 #define pmd_page(pmd)	(pfn_to_page(pmd_val(pmd) >> 32))
 #define pud_page(pud)	(pfn_to_page(pud_val(pud) >> 32))
 
-extern inline unsigned long pud_page_vaddr(pud_t pgd)
-{ return PAGE_OFFSET + ((pud_val(pgd) & _PFN_MASK) >> (32-PAGE_SHIFT)); }
+static inline pmd_t *pud_pgtable(pud_t pgd)
+{
+	return (pmd_t *)(PAGE_OFFSET + ((pud_val(pgd) & _PFN_MASK) >> (32-PAGE_SHIFT)));
+}
 
 extern inline int pte_none(pte_t pte)		{ return !pte_val(pte); }
 extern inline int pte_present(pte_t pte)	{ return pte_val(pte) & _PAGE_VALID; }
@@ -287,7 +289,7 @@ extern inline pte_t pte_mkyoung(pte_t pt
 /* Find an entry in the second-level page table.. */
 extern inline pmd_t * pmd_offset(pud_t * dir, unsigned long address)
 {
-	pmd_t *ret = (pmd_t *) pud_page_vaddr(*dir) + ((address >> PMD_SHIFT) & (PTRS_PER_PAGE - 1));
+	pmd_t *ret = pud_pgtable(*dir) + ((address >> PMD_SHIFT) & (PTRS_PER_PAGE - 1));
 	smp_rmb(); /* see above */
 	return ret;
 }
--- a/arch/arm64/include/asm/pgtable.h~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/arch/arm64/include/asm/pgtable.h
@@ -633,9 +633,9 @@ static inline phys_addr_t pud_page_paddr
 	return __pud_to_phys(pud);
 }
 
-static inline unsigned long pud_page_vaddr(pud_t pud)
+static inline pmd_t *pud_pgtable(pud_t pud)
 {
-	return (unsigned long)__va(pud_page_paddr(pud));
+	return (pmd_t *)__va(pud_page_paddr(pud));
 }
 
 /* Find an entry in the second-level page table. */
--- a/arch/arm/include/asm/pgtable-3level.h~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/arch/arm/include/asm/pgtable-3level.h
@@ -130,7 +130,7 @@
 		flush_pmd_entry(pudp);	\
 	} while (0)
 
-static inline pmd_t *pud_page_vaddr(pud_t pud)
+static inline pmd_t *pud_pgtable(pud_t pud)
 {
 	return __va(pud_val(pud) & PHYS_MASK & (s32)PAGE_MASK);
 }
--- a/arch/ia64/include/asm/pgtable.h~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/arch/ia64/include/asm/pgtable.h
@@ -273,7 +273,7 @@ ia64_phys_addr_valid (unsigned long addr
 #define pud_bad(pud)			(!ia64_phys_addr_valid(pud_val(pud)))
 #define pud_present(pud)		(pud_val(pud) != 0UL)
 #define pud_clear(pudp)			(pud_val(*(pudp)) = 0UL)
-#define pud_page_vaddr(pud)		((unsigned long) __va(pud_val(pud) & _PFN_MASK))
+#define pud_pgtable(pud)		((pmd_t *) __va(pud_val(pud) & _PFN_MASK))
 #define pud_page(pud)			virt_to_page((pud_val(pud) + PAGE_OFFSET))
 
 #if CONFIG_PGTABLE_LEVELS == 4
--- a/arch/m68k/include/asm/motorola_pgtable.h~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/arch/m68k/include/asm/motorola_pgtable.h
@@ -131,7 +131,7 @@ static inline void pud_set(pud_t *pudp,
 
 #define __pte_page(pte) ((unsigned long)__va(pte_val(pte) & PAGE_MASK))
 #define pmd_page_vaddr(pmd) ((unsigned long)__va(pmd_val(pmd) & _TABLE_MASK))
-#define pud_page_vaddr(pud) ((unsigned long)__va(pud_val(pud) & _TABLE_MASK))
+#define pud_pgtable(pud) ((pmd_t *)__va(pud_val(pud) & _TABLE_MASK))
 
 
 #define pte_none(pte)		(!pte_val(pte))
--- a/arch/mips/include/asm/pgtable-64.h~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/arch/mips/include/asm/pgtable-64.h
@@ -313,9 +313,9 @@ static inline void pud_clear(pud_t *pudp
 #endif
 
 #ifndef __PAGETABLE_PMD_FOLDED
-static inline unsigned long pud_page_vaddr(pud_t pud)
+static inline pmd_t *pud_pgtable(pud_t pud)
 {
-	return pud_val(pud);
+	return (pmd_t *)pud_val(pud);
 }
 #define pud_phys(pud)		virt_to_phys((void *)pud_val(pud))
 #define pud_page(pud)		(pfn_to_page(pud_phys(pud) >> PAGE_SHIFT))
--- a/arch/parisc/include/asm/pgtable.h~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/arch/parisc/include/asm/pgtable.h
@@ -322,8 +322,8 @@ static inline void pmd_clear(pmd_t *pmd)
 
 
 #if CONFIG_PGTABLE_LEVELS == 3
-#define pud_page_vaddr(pud) ((unsigned long) __va(pud_address(pud)))
-#define pud_page(pud)	virt_to_page((void *)pud_page_vaddr(pud))
+#define pud_pgtable(pud) ((pmd_t *) __va(pud_address(pud)))
+#define pud_page(pud)	virt_to_page((void *)pud_pgtable(pud))
 
 /* For 64 bit we have three level tables */
 
--- a/arch/powerpc/include/asm/book3s/64/pgtable.h~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/arch/powerpc/include/asm/book3s/64/pgtable.h
@@ -1048,9 +1048,13 @@ extern struct page *p4d_page(p4d_t p4d);
 /* Pointers in the page table tree are physical addresses */
 #define __pgtable_ptr_val(ptr)	__pa(ptr)
 
-#define pud_page_vaddr(pud)	__va(pud_val(pud) & ~PUD_MASKED_BITS)
 #define p4d_page_vaddr(p4d)	__va(p4d_val(p4d) & ~P4D_MASKED_BITS)
 
+static inline pmd_t *pud_pgtable(pud_t pud)
+{
+	return (pmd_t *)__va(pud_val(pud) & ~PUD_MASKED_BITS);
+}
+
 #define pte_ERROR(e) \
 	pr_err("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, pte_val(e))
 #define pmd_ERROR(e) \
--- a/arch/powerpc/include/asm/nohash/64/pgtable.h~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/arch/powerpc/include/asm/nohash/64/pgtable.h
@@ -162,7 +162,11 @@ static inline void pud_clear(pud_t *pudp
 #define	pud_bad(pud)		(!is_kernel_addr(pud_val(pud)) \
 				 || (pud_val(pud) & PUD_BAD_BITS))
 #define pud_present(pud)	(pud_val(pud) != 0)
-#define pud_page_vaddr(pud)	(pud_val(pud) & ~PUD_MASKED_BITS)
+
+static inline pmd_t *pud_pgtable(pud_t pud)
+{
+	return (pmd_t *)(pud_val(pud) & ~PUD_MASKED_BITS);
+}
 
 extern struct page *pud_page(pud_t pud);
 
--- a/arch/powerpc/mm/book3s64/radix_pgtable.c~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/arch/powerpc/mm/book3s64/radix_pgtable.c
@@ -826,7 +826,7 @@ static void __meminit remove_pud_table(p
 			continue;
 		}
 
-		pmd_base = (pmd_t *)pud_page_vaddr(*pud);
+		pmd_base = pud_pgtable(*pud);
 		remove_pmd_table(pmd_base, addr, next);
 		free_pmd_table(pmd_base, pud);
 	}
@@ -1111,7 +1111,7 @@ int pud_free_pmd_page(pud_t *pud, unsign
 	pmd_t *pmd;
 	int i;
 
-	pmd = (pmd_t *)pud_page_vaddr(*pud);
+	pmd = pud_pgtable(*pud);
 	pud_clear(pud);
 
 	flush_tlb_kernel_range(addr, addr + PUD_SIZE);
--- a/arch/powerpc/mm/pgtable_64.c~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/arch/powerpc/mm/pgtable_64.c
@@ -115,7 +115,7 @@ struct page *pud_page(pud_t pud)
 		VM_WARN_ON(!pud_huge(pud));
 		return pte_page(pud_pte(pud));
 	}
-	return virt_to_page(pud_page_vaddr(pud));
+	return virt_to_page(pud_pgtable(pud));
 }
 
 /*
--- a/arch/riscv/include/asm/pgtable-64.h~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/arch/riscv/include/asm/pgtable-64.h
@@ -59,9 +59,9 @@ static inline void pud_clear(pud_t *pudp
 	set_pud(pudp, __pud(0));
 }
 
-static inline unsigned long pud_page_vaddr(pud_t pud)
+static inline pmd_t *pud_pgtable(pud_t pud)
 {
-	return (unsigned long)pfn_to_virt(pud_val(pud) >> _PAGE_PFN_SHIFT);
+	return (pmd_t *)pfn_to_virt(pud_val(pud) >> _PAGE_PFN_SHIFT);
 }
 
 static inline struct page *pud_page(pud_t pud)
--- a/arch/sh/include/asm/pgtable-3level.h~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/arch/sh/include/asm/pgtable-3level.h
@@ -32,9 +32,9 @@ typedef struct { unsigned long long pmd;
 #define pmd_val(x)	((x).pmd)
 #define __pmd(x)	((pmd_t) { (x) } )
 
-static inline unsigned long pud_page_vaddr(pud_t pud)
+static inline pmd_t *pud_pgtable(pud_t pud)
 {
-	return pud_val(pud);
+	return (pmd_t *)pud_val(pud);
 }
 
 /* only used by the stubbed out hugetlb gup code, should never be called */
--- a/arch/sparc/include/asm/pgtable_32.h~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/arch/sparc/include/asm/pgtable_32.h
@@ -151,13 +151,13 @@ static inline unsigned long pmd_page_vad
 	return (unsigned long)__nocache_va(v << 4);
 }
 
-static inline unsigned long pud_page_vaddr(pud_t pud)
+static inline pmd_t *pud_pgtable(pud_t pud)
 {
 	if (srmmu_device_memory(pud_val(pud))) {
 		return ~0;
 	} else {
 		unsigned long v = pud_val(pud) & SRMMU_PTD_PMASK;
-		return (unsigned long)__nocache_va(v << 4);
+		return (pmd_t *)__nocache_va(v << 4);
 	}
 }
 
--- a/arch/sparc/include/asm/pgtable_64.h~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/arch/sparc/include/asm/pgtable_64.h
@@ -841,18 +841,18 @@ static inline unsigned long pmd_page_vad
 	return ((unsigned long) __va(pfn << PAGE_SHIFT));
 }
 
-static inline unsigned long pud_page_vaddr(pud_t pud)
+static inline pmd_t *pud_pgtable(pud_t pud)
 {
 	pte_t pte = __pte(pud_val(pud));
 	unsigned long pfn;
 
 	pfn = pte_pfn(pte);
 
-	return ((unsigned long) __va(pfn << PAGE_SHIFT));
+	return ((pmd_t *) __va(pfn << PAGE_SHIFT));
 }
 
 #define pmd_page(pmd) 			virt_to_page((void *)pmd_page_vaddr(pmd))
-#define pud_page(pud) 			virt_to_page((void *)pud_page_vaddr(pud))
+#define pud_page(pud)			virt_to_page((void *)pud_pgtable(pud))
 #define pmd_clear(pmdp)			(pmd_val(*(pmdp)) = 0UL)
 #define pud_present(pud)		(pud_val(pud) != 0U)
 #define pud_clear(pudp)			(pud_val(*(pudp)) = 0UL)
--- a/arch/um/include/asm/pgtable-3level.h~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/arch/um/include/asm/pgtable-3level.h
@@ -83,7 +83,7 @@ static inline void pud_clear (pud_t *pud
 }
 
 #define pud_page(pud) phys_to_page(pud_val(pud) & PAGE_MASK)
-#define pud_page_vaddr(pud) ((unsigned long) __va(pud_val(pud) & PAGE_MASK))
+#define pud_pgtable(pud) ((pmd_t *) __va(pud_val(pud) & PAGE_MASK))
 
 static inline unsigned long pte_pfn(pte_t pte)
 {
--- a/arch/x86/include/asm/pgtable.h~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/arch/x86/include/asm/pgtable.h
@@ -865,9 +865,9 @@ static inline int pud_present(pud_t pud)
 	return pud_flags(pud) & _PAGE_PRESENT;
 }
 
-static inline unsigned long pud_page_vaddr(pud_t pud)
+static inline pmd_t *pud_pgtable(pud_t pud)
 {
-	return (unsigned long)__va(pud_val(pud) & pud_pfn_mask(pud));
+	return (pmd_t *)__va(pud_val(pud) & pud_pfn_mask(pud));
 }
 
 /*
--- a/arch/x86/mm/pat/set_memory.c~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/arch/x86/mm/pat/set_memory.c
@@ -1134,7 +1134,7 @@ static void __unmap_pmd_range(pud_t *pud
 			      unsigned long start, unsigned long end)
 {
 	if (unmap_pte_range(pmd, start, end))
-		if (try_to_free_pmd_page((pmd_t *)pud_page_vaddr(*pud)))
+		if (try_to_free_pmd_page(pud_pgtable(*pud)))
 			pud_clear(pud);
 }
 
@@ -1178,7 +1178,7 @@ static void unmap_pmd_range(pud_t *pud,
 	 * Try again to free the PMD page if haven't succeeded above.
 	 */
 	if (!pud_none(*pud))
-		if (try_to_free_pmd_page((pmd_t *)pud_page_vaddr(*pud)))
+		if (try_to_free_pmd_page(pud_pgtable(*pud)))
 			pud_clear(pud);
 }
 
--- a/arch/x86/mm/pgtable.c~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/arch/x86/mm/pgtable.c
@@ -801,7 +801,7 @@ int pud_free_pmd_page(pud_t *pud, unsign
 	pte_t *pte;
 	int i;
 
-	pmd = (pmd_t *)pud_page_vaddr(*pud);
+	pmd = pud_pgtable(*pud);
 	pmd_sv = (pmd_t *)__get_free_page(GFP_KERNEL);
 	if (!pmd_sv)
 		return 0;
--- a/include/asm-generic/pgtable-nopmd.h~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/include/asm-generic/pgtable-nopmd.h
@@ -51,7 +51,7 @@ static inline pmd_t * pmd_offset(pud_t *
 #define __pmd(x)				((pmd_t) { __pud(x) } )
 
 #define pud_page(pud)				(pmd_page((pmd_t){ pud }))
-#define pud_page_vaddr(pud)			(pmd_page_vaddr((pmd_t){ pud }))
+#define pud_pgtable(pud)			((pmd_t *)(pmd_page_vaddr((pmd_t){ pud })))
 
 /*
  * allocating and freeing a pmd is trivial: the 1-entry pmd is
--- a/include/asm-generic/pgtable-nopud.h~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/include/asm-generic/pgtable-nopud.h
@@ -49,7 +49,7 @@ static inline pud_t *pud_offset(p4d_t *p
 #define __pud(x)				((pud_t) { __p4d(x) })
 
 #define p4d_page(p4d)				(pud_page((pud_t){ p4d }))
-#define p4d_page_vaddr(p4d)			(pud_page_vaddr((pud_t){ p4d }))
+#define p4d_page_vaddr(p4d)			(pud_pgtable((pud_t){ p4d }))
 
 /*
  * allocating and freeing a pud is trivial: the 1-entry pud is
--- a/include/linux/pgtable.h~mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t
+++ a/include/linux/pgtable.h
@@ -106,7 +106,7 @@ static inline pte_t *pte_offset_kernel(p
 #ifndef pmd_offset
 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
 {
-	return (pmd_t *)pud_page_vaddr(*pud) + pmd_index(address);
+	return pud_pgtable(*pud) + pmd_index(address);
 }
 #define pmd_offset pmd_offset
 #endif
_

Patches currently in -mm which might be from aneesh.kumar at linux.ibm.com are

mm-rename-pud_page_vaddr-to-pud_pgtable-and-make-it-return-pmd_t-fix-2.patch
mm-rename-p4d_page_vaddr-to-p4d_pgtable-and-make-it-return-pud_t.patch
mm-rename-p4d_page_vaddr-to-p4d_pgtable-and-make-it-return-pud_t-fix.patch



From akpm at linux-foundation.org  Wed Jun 16 16:08:09 2021
From: akpm at linux-foundation.org (akpm at linux-foundation.org)
Date: Wed, 16 Jun 2021 16:08:09 -0700
Subject: [to-be-updated]
 mm-rename-p4d_page_vaddr-to-p4d_pgtable-and-make-it-return-pud_t.patch
 removed from -mm tree
Message-ID: <20210616230809.aAS-HuAzz%akpm@linux-foundation.org>


The patch titled
     Subject: mm: rename p4d_page_vaddr to p4d_pgtable and make it return pud_t *
has been removed from the -mm tree.  Its filename was
     mm-rename-p4d_page_vaddr-to-p4d_pgtable-and-make-it-return-pud_t.patch

This patch was dropped because an updated version will be merged

------------------------------------------------------
From: "Aneesh Kumar K.V" <aneesh.kumar at linux.ibm.com>
Subject: mm: rename p4d_page_vaddr to p4d_pgtable and make it return pud_t *

No functional change in this patch.

Link: https://lkml.kernel.org/r/20210615110859.320299-2-aneesh.kumar at linux.ibm.com
Link: https://lore.kernel.org/linuxppc-dev/CAHk-=wi+J+iodze9FtjM3Zi4j4OeS+qqbKxME9QN4roxPEXH9Q at mail.gmail.com/
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar at linux.ibm.com>
Cc: <linux-alpha at vger.kernel.org>
Cc: <linux-kernel at vger.kernel.org>
Cc: <linux-arm-kernel at lists.infradead.org>
Cc: <linux-ia64 at vger.kernel.org>
Cc: <linux-m68k at lists.linux-m68k.org>
Cc: <linux-mips at vger.kernel.org>
Cc: <linux-parisc at vger.kernel.org>
Cc: <linuxppc-dev at lists.ozlabs.org>
Cc: <linux-riscv at lists.infradead.org>
Cc: <linux-sh at vger.kernel.org>
Cc: <sparclinux at vger.kernel.org>
Cc: <linux-um at lists.infradead.org>
Cc: <linux-arch at vger.kernel.org>
Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
---

 arch/arm64/include/asm/pgtable.h                |    4 ++--
 arch/ia64/include/asm/pgtable.h                 |    2 +-
 arch/mips/include/asm/pgtable-64.h              |    4 ++--
 arch/powerpc/include/asm/book3s/64/pgtable.h    |    5 ++++-
 arch/powerpc/include/asm/nohash/64/pgtable-4k.h |    6 +++++-
 arch/powerpc/mm/book3s64/radix_pgtable.c        |    2 +-
 arch/powerpc/mm/pgtable_64.c                    |    2 +-
 arch/sparc/include/asm/pgtable_64.h             |    4 ++--
 arch/x86/include/asm/pgtable.h                  |    4 ++--
 arch/x86/mm/init_64.c                           |    4 ++--
 include/asm-generic/pgtable-nop4d.h             |    2 +-
 include/asm-generic/pgtable-nopud.h             |    2 +-
 include/linux/pgtable.h                         |    2 +-
 13 files changed, 25 insertions(+), 18 deletions(-)

--- a/arch/arm64/include/asm/pgtable.h~mm-rename-p4d_page_vaddr-to-p4d_pgtable-and-make-it-return-pud_t
+++ a/arch/arm64/include/asm/pgtable.h
@@ -694,9 +694,9 @@ static inline phys_addr_t p4d_page_paddr
 	return __p4d_to_phys(p4d);
 }
 
-static inline unsigned long p4d_page_vaddr(p4d_t p4d)
+static inline pud_t *p4d_pgtable(p4d_t p4d)
 {
-	return (unsigned long)__va(p4d_page_paddr(p4d));
+	return (pud_t *)__va(p4d_page_paddr(p4d));
 }
 
 /* Find an entry in the frst-level page table. */
--- a/arch/ia64/include/asm/pgtable.h~mm-rename-p4d_page_vaddr-to-p4d_pgtable-and-make-it-return-pud_t
+++ a/arch/ia64/include/asm/pgtable.h
@@ -281,7 +281,7 @@ ia64_phys_addr_valid (unsigned long addr
 #define p4d_bad(p4d)			(!ia64_phys_addr_valid(p4d_val(p4d)))
 #define p4d_present(p4d)		(p4d_val(p4d) != 0UL)
 #define p4d_clear(p4dp)			(p4d_val(*(p4dp)) = 0UL)
-#define p4d_page_vaddr(p4d)		((unsigned long) __va(p4d_val(p4d) & _PFN_MASK))
+#define p4d_pgtable(p4d)		((pud_t *) __va(p4d_val(p4d) & _PFN_MASK))
 #define p4d_page(p4d)			virt_to_page((p4d_val(p4d) + PAGE_OFFSET))
 #endif
 
--- a/arch/mips/include/asm/pgtable-64.h~mm-rename-p4d_page_vaddr-to-p4d_pgtable-and-make-it-return-pud_t
+++ a/arch/mips/include/asm/pgtable-64.h
@@ -209,9 +209,9 @@ static inline void p4d_clear(p4d_t *p4dp
 	p4d_val(*p4dp) = (unsigned long)invalid_pud_table;
 }
 
-static inline unsigned long p4d_page_vaddr(p4d_t p4d)
+static inline pud_t *p4d_pgtable(p4d_t p4d)
 {
-	return p4d_val(p4d);
+	return (pud_t *)p4d_val(p4d);
 }
 
 #define p4d_phys(p4d)		virt_to_phys((void *)p4d_val(p4d))
--- a/arch/powerpc/include/asm/book3s/64/pgtable.h~mm-rename-p4d_page_vaddr-to-p4d_pgtable-and-make-it-return-pud_t
+++ a/arch/powerpc/include/asm/book3s/64/pgtable.h
@@ -1048,7 +1048,10 @@ extern struct page *p4d_page(p4d_t p4d);
 /* Pointers in the page table tree are physical addresses */
 #define __pgtable_ptr_val(ptr)	__pa(ptr)
 
-#define p4d_page_vaddr(p4d)	__va(p4d_val(p4d) & ~P4D_MASKED_BITS)
+static inline pud_t *p4d_pgtable(p4d_t p4d)
+{
+	return (pud_t *)__va(p4d_val(p4d) & ~P4D_MASKED_BITS);
+}
 
 static inline pmd_t *pud_pgtable(pud_t pud)
 {
--- a/arch/powerpc/include/asm/nohash/64/pgtable-4k.h~mm-rename-p4d_page_vaddr-to-p4d_pgtable-and-make-it-return-pud_t
+++ a/arch/powerpc/include/asm/nohash/64/pgtable-4k.h
@@ -56,10 +56,14 @@
 #define p4d_none(p4d)		(!p4d_val(p4d))
 #define p4d_bad(p4d)		(p4d_val(p4d) == 0)
 #define p4d_present(p4d)	(p4d_val(p4d) != 0)
-#define p4d_page_vaddr(p4d)	(p4d_val(p4d) & ~P4D_MASKED_BITS)
 
 #ifndef __ASSEMBLY__
 
+static inline pud_t *p4d_pgtable(p4d_t p4d)
+{
+	return (pud_t *) (p4d_val(p4d) & ~P4D_MASKED_BITS);
+}
+
 static inline void p4d_clear(p4d_t *p4dp)
 {
 	*p4dp = __p4d(0);
--- a/arch/powerpc/mm/book3s64/radix_pgtable.c~mm-rename-p4d_page_vaddr-to-p4d_pgtable-and-make-it-return-pud_t
+++ a/arch/powerpc/mm/book3s64/radix_pgtable.c
@@ -860,7 +860,7 @@ static void __meminit remove_pagetable(u
 			continue;
 		}
 
-		pud_base = (pud_t *)p4d_page_vaddr(*p4d);
+		pud_base = p4d_pgtable(*p4d);
 		remove_pud_table(pud_base, addr, next);
 		free_pud_table(pud_base, p4d);
 	}
--- a/arch/powerpc/mm/pgtable_64.c~mm-rename-p4d_page_vaddr-to-p4d_pgtable-and-make-it-return-pud_t
+++ a/arch/powerpc/mm/pgtable_64.c
@@ -105,7 +105,7 @@ struct page *p4d_page(p4d_t p4d)
 		VM_WARN_ON(!p4d_huge(p4d));
 		return pte_page(p4d_pte(p4d));
 	}
-	return virt_to_page(p4d_page_vaddr(p4d));
+	return virt_to_page(p4d_pgtable(p4d));
 }
 #endif
 
--- a/arch/sparc/include/asm/pgtable_64.h~mm-rename-p4d_page_vaddr-to-p4d_pgtable-and-make-it-return-pud_t
+++ a/arch/sparc/include/asm/pgtable_64.h
@@ -856,8 +856,8 @@ static inline pmd_t *pud_pgtable(pud_t p
 #define pmd_clear(pmdp)			(pmd_val(*(pmdp)) = 0UL)
 #define pud_present(pud)		(pud_val(pud) != 0U)
 #define pud_clear(pudp)			(pud_val(*(pudp)) = 0UL)
-#define p4d_page_vaddr(p4d)		\
-	((unsigned long) __va(p4d_val(p4d)))
+#define p4d_pgtable(p4d)		\
+	((pud_t *) __va(p4d_val(p4d)))
 #define p4d_present(p4d)		(p4d_val(p4d) != 0U)
 #define p4d_clear(p4dp)			(p4d_val(*(p4dp)) = 0UL)
 
--- a/arch/x86/include/asm/pgtable.h~mm-rename-p4d_page_vaddr-to-p4d_pgtable-and-make-it-return-pud_t
+++ a/arch/x86/include/asm/pgtable.h
@@ -906,9 +906,9 @@ static inline int p4d_present(p4d_t p4d)
 	return p4d_flags(p4d) & _PAGE_PRESENT;
 }
 
-static inline unsigned long p4d_page_vaddr(p4d_t p4d)
+static inline pud_t *p4d_pgtable(p4d_t p4d)
 {
-	return (unsigned long)__va(p4d_val(p4d) & p4d_pfn_mask(p4d));
+	return (pud_t *)__va(p4d_val(p4d) & p4d_pfn_mask(p4d));
 }
 
 /*
--- a/arch/x86/mm/init_64.c~mm-rename-p4d_page_vaddr-to-p4d_pgtable-and-make-it-return-pud_t
+++ a/arch/x86/mm/init_64.c
@@ -195,8 +195,8 @@ static void sync_global_pgds_l4(unsigned
 			spin_lock(pgt_lock);
 
 			if (!p4d_none(*p4d_ref) && !p4d_none(*p4d))
-				BUG_ON(p4d_page_vaddr(*p4d)
-				       != p4d_page_vaddr(*p4d_ref));
+				BUG_ON(p4d_pgtable(*p4d)
+				       != p4d_pgtable(*p4d_ref));
 
 			if (p4d_none(*p4d))
 				set_p4d(p4d, *p4d_ref);
--- a/include/asm-generic/pgtable-nop4d.h~mm-rename-p4d_page_vaddr-to-p4d_pgtable-and-make-it-return-pud_t
+++ a/include/asm-generic/pgtable-nop4d.h
@@ -42,7 +42,7 @@ static inline p4d_t *p4d_offset(pgd_t *p
 #define __p4d(x)				((p4d_t) { __pgd(x) })
 
 #define pgd_page(pgd)				(p4d_page((p4d_t){ pgd }))
-#define pgd_page_vaddr(pgd)			(p4d_page_vaddr((p4d_t){ pgd }))
+#define pgd_page_vaddr(pgd)			(p4d_pgtable((p4d_t){ pgd }))
 
 /*
  * allocating and freeing a p4d is trivial: the 1-entry p4d is
--- a/include/asm-generic/pgtable-nopud.h~mm-rename-p4d_page_vaddr-to-p4d_pgtable-and-make-it-return-pud_t
+++ a/include/asm-generic/pgtable-nopud.h
@@ -49,7 +49,7 @@ static inline pud_t *pud_offset(p4d_t *p
 #define __pud(x)				((pud_t) { __p4d(x) })
 
 #define p4d_page(p4d)				(pud_page((pud_t){ p4d }))
-#define p4d_page_vaddr(p4d)			(pud_pgtable((pud_t){ p4d }))
+#define p4d_pgtable(p4d)			((pud_t *)(pud_pgtable((pud_t){ p4d })))
 
 /*
  * allocating and freeing a pud is trivial: the 1-entry pud is
--- a/include/linux/pgtable.h~mm-rename-p4d_page_vaddr-to-p4d_pgtable-and-make-it-return-pud_t
+++ a/include/linux/pgtable.h
@@ -114,7 +114,7 @@ static inline pmd_t *pmd_offset(pud_t *p
 #ifndef pud_offset
 static inline pud_t *pud_offset(p4d_t *p4d, unsigned long address)
 {
-	return (pud_t *)p4d_page_vaddr(*p4d) + pud_index(address);
+	return p4d_pgtable(*p4d) + pud_index(address);
 }
 #define pud_offset pud_offset
 #endif
_

Patches currently in -mm which might be from aneesh.kumar at linux.ibm.com are

mm-rename-p4d_page_vaddr-to-p4d_pgtable-and-make-it-return-pud_t-fix.patch



From richard.weinberger at gmail.com  Thu Jun 17 12:21:45 2021
From: richard.weinberger at gmail.com (Richard Weinberger)
Date: Thu, 17 Jun 2021 21:21:45 +0200
Subject: [PATCH v4 4/9] um: export signals_enabled directly
In-Reply-To: <20210305131934.b1cae3585b98.I2a08cbe698fc23f1731e33e4f2582475290b90dc@changeid>
References: <20210305122010.442577-1-johannes@sipsolutions.net>
 <20210305131934.b1cae3585b98.I2a08cbe698fc23f1731e33e4f2582475290b90dc@changeid>
Message-ID: <CAFLxGvy8aZq9OO+--bz7vxFa3s+NgaPqTFQO+DLBFivS+Fai-Q@mail.gmail.com>

On Fri, Mar 5, 2021 at 1:20 PM Johannes Berg <johannes at sipsolutions.net> wrote:
> +#define UML_SETJMP(buf) ({                             \
> +       int n, enable;                                  \
> +       enable = *(volatile int *)&signals_enabled;     \

Isn't this a case for READ_ONCE()?

-- 
Thanks,
//richard


From johannes at sipsolutions.net  Thu Jun 17 12:31:30 2021
From: johannes at sipsolutions.net (Johannes Berg)
Date: Thu, 17 Jun 2021 21:31:30 +0200
Subject: [PATCH v4 4/9] um: export signals_enabled directly
In-Reply-To: <CAFLxGvy8aZq9OO+--bz7vxFa3s+NgaPqTFQO+DLBFivS+Fai-Q@mail.gmail.com>
 (sfid-20210617_212157_642443_0F782CCF)
References: <20210305122010.442577-1-johannes@sipsolutions.net>
 <20210305131934.b1cae3585b98.I2a08cbe698fc23f1731e33e4f2582475290b90dc@changeid>
 <CAFLxGvy8aZq9OO+--bz7vxFa3s+NgaPqTFQO+DLBFivS+Fai-Q@mail.gmail.com>
 (sfid-20210617_212157_642443_0F782CCF)
Message-ID: <db83b3c4a2202c2591898c410f4980cf88fb1613.camel@sipsolutions.net>

On Thu, 2021-06-17 at 21:21 +0200, Richard Weinberger wrote:
> On Fri, Mar 5, 2021 at 1:20 PM Johannes Berg <johannes at sipsolutions.net> wrote:
> > +#define UML_SETJMP(buf) ({                             \
> > +       int n, enable;                                  \
> > +       enable = *(volatile int *)&signals_enabled;     \
> 
> Isn't this a case for READ_ONCE()?

I guess, but it's in shared code, so must compile without kernel-space
headers.

johannes



From wanjiabing at vivo.com  Fri Jun 18 19:02:59 2021
From: wanjiabing at vivo.com (Wan Jiabing)
Date: Sat, 19 Jun 2021 10:02:59 +0800
Subject: [PATCH] um: remove unneeded semicolon in um_arch.c
Message-ID: <20210619020301.77672-1-wanjiabing@vivo.com>

Fix following coccicheck warning:
./arch/um/kernel/um_arch.c:284:34-35: Unneeded semicolon

Signed-off-by: Wan Jiabing <wanjiabing at vivo.com>
---
 arch/um/kernel/um_arch.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c
index f9f1463f0521..a149a5e9a16a 100644
--- a/arch/um/kernel/um_arch.c
+++ b/arch/um/kernel/um_arch.c
@@ -281,7 +281,7 @@ static void parse_host_cpu_flags(char *line)
 	int i;
 	for (i = 0; i < 32*NCAPINTS; i++) {
 		if ((x86_cap_flags[i] != NULL) && strstr(line, x86_cap_flags[i]))
-			set_cpu_cap(&boot_cpu_data, i);;
+			set_cpu_cap(&boot_cpu_data, i);
 	}
 }
 static void parse_cache_line(char *line)
-- 
2.20.1



From anton.ivanov at cambridgegreys.com  Fri Jun 18 23:41:59 2021
From: anton.ivanov at cambridgegreys.com (Anton Ivanov)
Date: Sat, 19 Jun 2021 07:41:59 +0100
Subject: [PATCH] um: remove unneeded semicolon in um_arch.c
In-Reply-To: <20210619020301.77672-1-wanjiabing@vivo.com>
References: <20210619020301.77672-1-wanjiabing@vivo.com>
Message-ID: <4320e0ea-1339-e2c1-03c0-271dbcd6e22d@cambridgegreys.com>

On 19/06/2021 03:02, Wan Jiabing wrote:
> Fix following coccicheck warning:
> ./arch/um/kernel/um_arch.c:284:34-35: Unneeded semicolon
> 
> Signed-off-by: Wan Jiabing <wanjiabing at vivo.com>
> ---
>   arch/um/kernel/um_arch.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c
> index f9f1463f0521..a149a5e9a16a 100644
> --- a/arch/um/kernel/um_arch.c
> +++ b/arch/um/kernel/um_arch.c
> @@ -281,7 +281,7 @@ static void parse_host_cpu_flags(char *line)
>   	int i;
>   	for (i = 0; i < 32*NCAPINTS; i++) {
>   		if ((x86_cap_flags[i] != NULL) && strstr(line, x86_cap_flags[i]))
> -			set_cpu_cap(&boot_cpu_data, i);;
> +			set_cpu_cap(&boot_cpu_data, i);
>   	}
>   }
>   static void parse_cache_line(char *line)
> 

Thanks.

I do not think the patch which introduces this ([v7,1/3] um: Add support 
for host CPU flags and alignment) has been merged yet. I do not see it 
in the tree as of this morning.

I can see that it is already marked as done in patchwork so it is on its 
way.

Richard, what do you want me to do - reissue a fixed one or we should 
accept the fix once the original is merged?

-- 
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/


From richard at nod.at  Sat Jun 19 01:04:41 2021
From: richard at nod.at (Richard Weinberger)
Date: Sat, 19 Jun 2021 10:04:41 +0200 (CEST)
Subject: [PATCH] um: remove unneeded semicolon in um_arch.c
In-Reply-To: <4320e0ea-1339-e2c1-03c0-271dbcd6e22d@cambridgegreys.com>
References: <20210619020301.77672-1-wanjiabing@vivo.com>
 <4320e0ea-1339-e2c1-03c0-271dbcd6e22d@cambridgegreys.com>
Message-ID: <653435823.132192.1624089881861.JavaMail.zimbra@nod.at>

Anton,

----- Urspr?ngliche Mail -----
> Thanks.
> 
> I do not think the patch which introduces this ([v7,1/3] um: Add support
> for host CPU flags and alignment) has been merged yet. I do not see it
> in the tree as of this morning.
> 
> I can see that it is already marked as done in patchwork so it is on its
> way.
> 
> Richard, what do you want me to do - reissue a fixed one or we should
> accept the fix once the original is merged?

I have just applied the fix to UML's next tree. :-)

Thanks,
//richard


From richard.weinberger at gmail.com  Sat Jun 19 13:17:55 2021
From: richard.weinberger at gmail.com (Richard Weinberger)
Date: Sat, 19 Jun 2021 22:17:55 +0200
Subject: [PATCH 03/27] um: Drop support for hosts without
 SYSEMU_SINGLESTEP support
In-Reply-To: <20210303155523.124277-4-benjamin@sipsolutions.net>
References: <20210303155523.124277-1-benjamin@sipsolutions.net>
 <20210303155523.124277-4-benjamin@sipsolutions.net>
Message-ID: <CAFLxGvwvpz26-RGw_isFYQq4PzOzbMoQOcXb5gxTYq3+vMxHaQ@mail.gmail.com>

On Thu, Mar 4, 2021 at 12:03 AM Benjamin Berg <benjamin at sipsolutions.net> wrote:
>
> These features have existed since Linux 2.6.14 and can be considered
> widely available at this point.

[...]

> -#ifndef PTRACE_SYSEMU
> -#define PTRACE_SYSEMU 31
> -#endif
> -#ifndef PTRACE_SYSEMU_SINGLESTEP
> -#define PTRACE_SYSEMU_SINGLESTEP 32
> -#endif

Where did you test this? On my OpenSUSE 15.2 machine this change
causes a build failure.

arch/um/os-Linux/start_up.c: In function ?check_sysemu?:
arch/um/os-Linux/start_up.c:153:14: error: ?PTRACE_SYSEMU_SINGLESTEP?
undeclared (first use in this function); did you mean
?PTRACE_SINGLESTEP??
   if (ptrace(PTRACE_SYSEMU_SINGLESTEP, pid, 0, 0) < 0)
              ^~~~~~~~~~~~~~~~~~~~~~~~
              PTRACE_SINGLESTEP

I think we need to carefully include the right asm headers.

-- 
Thanks,
//richard


From benjamin at sipsolutions.net  Sun Jun 20 05:05:58 2021
From: benjamin at sipsolutions.net (Benjamin Berg)
Date: Sun, 20 Jun 2021 14:05:58 +0200
Subject: [PATCH 03/27] um: Drop support for hosts without
 SYSEMU_SINGLESTEP support
In-Reply-To: <CAFLxGvwvpz26-RGw_isFYQq4PzOzbMoQOcXb5gxTYq3+vMxHaQ@mail.gmail.com>
 (sfid-20210619_221807_950608_C9764135)
References: <20210303155523.124277-1-benjamin@sipsolutions.net>
 <20210303155523.124277-4-benjamin@sipsolutions.net>
 <CAFLxGvwvpz26-RGw_isFYQq4PzOzbMoQOcXb5gxTYq3+vMxHaQ@mail.gmail.com>
 (sfid-20210619_221807_950608_C9764135)
Message-ID: <84f937926c2341651927a8efbbe47ef56980feac.camel@sipsolutions.net>

On Sat, 2021-06-19 at 22:17 +0200, Richard Weinberger wrote:
> On Thu, Mar 4, 2021 at 12:03 AM Benjamin Berg
> <benjamin at sipsolutions.net> wrote:
> > 
> > These features have existed since Linux 2.6.14 and can be considered
> > widely available at this point.
> 
> [...]
> 
> > -#ifndef PTRACE_SYSEMU
> > -#define PTRACE_SYSEMU 31
> > -#endif
> > -#ifndef PTRACE_SYSEMU_SINGLESTEP
> > -#define PTRACE_SYSEMU_SINGLESTEP 32
> > -#endif
> 
> Where did you test this? On my OpenSUSE 15.2 machine this change
> causes a build failure.

I have been testing this on Fedora, currently F34 (x86_64).

> arch/um/os-Linux/start_up.c: In function ?check_sysemu?:
> arch/um/os-Linux/start_up.c:153:14: error: ?PTRACE_SYSEMU_SINGLESTEP?
> undeclared (first use in this function); did you mean
> ?PTRACE_SINGLESTEP??
> ?? if (ptrace(PTRACE_SYSEMU_SINGLESTEP, pid, 0, 0) < 0)
> ????????????? ^~~~~~~~~~~~~~~~~~~~~~~~
> ????????????? PTRACE_SINGLESTEP
> 
> I think we need to carefully include the right asm headers.

Hmm, possibly. For me the definition is coming from the glibc headers
right now:

# 26 "arch/um/os-Linux/start_up.c" 2
# 1 "./arch/um/include/shared/ptrace_user.h" 1
# 9 "./arch/um/include/shared/ptrace_user.h"
# 1 "/usr/include/sys/ptrace.h" 1 3 4
# 26 "/usr/include/sys/ptrace.h" 3 4

sys/ptrace.h is in turn is provided by glibc-headers-x86-2.33-
16.fc34.noarch.

Not sure what the right thing here is. One could include
"linux/ptrace.h", but those are #defines, while the glibc header uses
an enum. I think it'll work if one first includes the glibc header for
the function definition and only then the kernel header. But, that
seems odd to me right now, and I am not why 

Benjamin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/linux-um/attachments/20210620/1bb92ec0/attachment.sig>

From johannes at sipsolutions.net  Fri Jun 25 01:34:36 2021
From: johannes at sipsolutions.net (Johannes Berg)
Date: Fri, 25 Jun 2021 10:34:36 +0200
Subject: [PATCH 3/4] um: virtio_uml: include linux/virtio-uml.h
In-Reply-To: <20210625103436.900a9e962c32.Id45a0d2d0167dd9b6a067b42d791523896574064@changeid>
References: <20210625103436.900a9e962c32.Id45a0d2d0167dd9b6a067b42d791523896574064@changeid>
Message-ID: <20210625103437.d8dde80ec4c4.Icb63afa98dd3949f29f53325e9e1f2eb132749ae@changeid>

From: Johannes Berg <johannes.berg at intel.com>

This fixes a sparse warning, since the function defined
here should have a declaration (or be static).

Reported-by: kernel test robot <lkp at intel.com>
Fixes: 43c590cb8666 ("um: virtio/pci: enable suspend/resume")
Signed-off-by: Johannes Berg <johannes.berg at intel.com>
---
 arch/um/drivers/virtio_uml.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/um/drivers/virtio_uml.c b/arch/um/drivers/virtio_uml.c
index 4412d6febade..cb79fe33d84e 100644
--- a/arch/um/drivers/virtio_uml.c
+++ b/arch/um/drivers/virtio_uml.c
@@ -27,6 +27,7 @@
 #include <linux/virtio_config.h>
 #include <linux/virtio_ring.h>
 #include <linux/time-internal.h>
+#include <linux/virtio-uml.h>
 #include <shared/as-layout.h>
 #include <irq_kern.h>
 #include <init.h>
-- 
2.31.1



From johannes at sipsolutions.net  Fri Jun 25 01:34:37 2021
From: johannes at sipsolutions.net (Johannes Berg)
Date: Fri, 25 Jun 2021 10:34:37 +0200
Subject: [PATCH 4/4] um: virtio_uml: fix memory leak on init failures
In-Reply-To: <20210625103436.900a9e962c32.Id45a0d2d0167dd9b6a067b42d791523896574064@changeid>
References: <20210625103436.900a9e962c32.Id45a0d2d0167dd9b6a067b42d791523896574064@changeid>
Message-ID: <20210625103437.bb82b95035e4.I748b002f0650d0705e6ae6b4c4f4b63face436f7@changeid>

From: Johannes Berg <johannes.berg at intel.com>

If initialization fails, e.g. because the connection failed,
we leak the 'vu_dev'. Fix that. Reported by smatch.

Fixes: 5d38f324993f ("um: drivers: Add virtio vhost-user driver")
Signed-off-by: Johannes Berg <johannes.berg at intel.com>
---
 arch/um/drivers/virtio_uml.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/um/drivers/virtio_uml.c b/arch/um/drivers/virtio_uml.c
index cb79fe33d84e..d51e445df797 100644
--- a/arch/um/drivers/virtio_uml.c
+++ b/arch/um/drivers/virtio_uml.c
@@ -1140,7 +1140,7 @@ static int virtio_uml_probe(struct platform_device *pdev)
 		rc = os_connect_socket(pdata->socket_path);
 	} while (rc == -EINTR);
 	if (rc < 0)
-		return rc;
+		goto error_free;
 	vu_dev->sock = rc;
 
 	spin_lock_init(&vu_dev->sock_lock);
@@ -1161,6 +1161,8 @@ static int virtio_uml_probe(struct platform_device *pdev)
 
 error_init:
 	os_close_file(vu_dev->sock);
+error_free:
+	kfree(vu_dev);
 	return rc;
 }
 
-- 
2.31.1



From johannes at sipsolutions.net  Fri Jun 25 01:34:34 2021
From: johannes at sipsolutions.net (Johannes Berg)
Date: Fri, 25 Jun 2021 10:34:34 +0200
Subject: [PATCH 1/4] um: make PCI emulation driver init/exit static
Message-ID: <20210625103436.900a9e962c32.Id45a0d2d0167dd9b6a067b42d791523896574064@changeid>

From: Johannes Berg <johannes.berg at intel.com>

The functions aren't used elsewhere, so they can be static.

Reported-by: kernel test robot <lkp at intel.com>
Fixes: 68f5d3f3b654 ("um: add PCI over virtio emulation driver")
Signed-off-by: Johannes Berg <johannes.berg at intel.com>
---
 arch/um/drivers/virt-pci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/um/drivers/virt-pci.c b/arch/um/drivers/virt-pci.c
index 0b802834f40a..70c17de16662 100644
--- a/arch/um/drivers/virt-pci.c
+++ b/arch/um/drivers/virt-pci.c
@@ -810,7 +810,7 @@ void *pci_root_bus_fwnode(struct pci_bus *bus)
 	return um_pci_fwnode;
 }
 
-int um_pci_init(void)
+static int um_pci_init(void)
 {
 	int err, i;
 
@@ -884,7 +884,7 @@ int um_pci_init(void)
 }
 module_init(um_pci_init);
 
-void um_pci_exit(void)
+static void um_pci_exit(void)
 {
 	unregister_virtio_driver(&um_pci_virtio_driver);
 	irq_domain_remove(um_pci_msi_domain);
-- 
2.31.1



From johannes at sipsolutions.net  Fri Jun 25 01:34:35 2021
From: johannes at sipsolutions.net (Johannes Berg)
Date: Fri, 25 Jun 2021 10:34:35 +0200
Subject: [PATCH 2/4] lib/logic_iomem: fix sparse warnings
In-Reply-To: <20210625103436.900a9e962c32.Id45a0d2d0167dd9b6a067b42d791523896574064@changeid>
References: <20210625103436.900a9e962c32.Id45a0d2d0167dd9b6a067b42d791523896574064@changeid>
Message-ID: <20210625103437.8ab400c16323.Ic4ba1a600f837d01bf592fad52f55fe52c063388@changeid>

From: Johannes Berg <johannes.berg at intel.com>

A couple of sparse warnings happened here due to casts on
the prints, a missing static and a missing include. Fix
all of them.

Reported-by: kernel test robot <lkp at intel.com>
Fixes: ca2e334232b6 ("lib: add iomem emulation (logic_iomem)")
Signed-off-by: Johannes Berg <johannes.berg at intel.com>
---
 lib/logic_iomem.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/lib/logic_iomem.c b/lib/logic_iomem.c
index b76b92dd0f1f..9bdfde0c0f86 100644
--- a/lib/logic_iomem.c
+++ b/lib/logic_iomem.c
@@ -6,6 +6,7 @@
 #include <linux/types.h>
 #include <linux/slab.h>
 #include <linux/logic_iomem.h>
+#include <asm/io.h>
 
 struct logic_iomem_region {
 	const struct resource *res;
@@ -78,7 +79,7 @@ static void __iomem *real_ioremap(phys_addr_t offset, size_t size)
 static void real_iounmap(void __iomem *addr)
 {
 	WARN(1, "invalid iounmap for addr 0x%llx\n",
-	     (unsigned long long)addr);
+	     (unsigned long long __force)addr);
 }
 #endif /* CONFIG_LOGIC_IOMEM_FALLBACK */
 
@@ -172,14 +173,15 @@ EXPORT_SYMBOL(iounmap);
 static u##sz real_raw_read ## op(const volatile void __iomem *addr)	\
 {									\
 	WARN(1, "Invalid read" #op " at address %llx\n",		\
-	     (unsigned long long)addr);					\
+	     (unsigned long long __force)addr);				\
 	return (u ## sz)~0ULL;						\
 }									\
 									\
-void real_raw_write ## op(u ## sz val, volatile void __iomem *addr)	\
+static void real_raw_write ## op(u ## sz val,				\
+				 volatile void __iomem *addr)		\
 {									\
 	WARN(1, "Invalid writeq" #op " of 0x%llx at address %llx\n",	\
-	     (unsigned long long)val, (unsigned long long)addr);	\
+	     (unsigned long long)val, (unsigned long long __force)addr);\
 }									\
 
 MAKE_FALLBACK(b, 8);
@@ -192,14 +194,14 @@ MAKE_FALLBACK(q, 64);
 static void real_memset_io(volatile void __iomem *addr, int value, size_t size)
 {
 	WARN(1, "Invalid memset_io at address 0x%llx\n",
-	     (unsigned long long)addr);
+	     (unsigned long long __force)addr);
 }
 
 static void real_memcpy_fromio(void *buffer, const volatile void __iomem *addr,
 			       size_t size)
 {
 	WARN(1, "Invalid memcpy_fromio at address 0x%llx\n",
-	     (unsigned long long)addr);
+	     (unsigned long long __force)addr);
 
 	memset(buffer, 0xff, size);
 }
@@ -208,7 +210,7 @@ static void real_memcpy_toio(volatile void __iomem *addr, const void *buffer,
 			     size_t size)
 {
 	WARN(1, "Invalid memcpy_toio at address 0x%llx\n",
-	     (unsigned long long)addr);
+	     (unsigned long long __force)addr);
 }
 #endif /* CONFIG_LOGIC_IOMEM_FALLBACK */
 
-- 
2.31.1



From johannes at sipsolutions.net  Fri Jun 25 01:37:34 2021
From: johannes at sipsolutions.net (Johannes Berg)
Date: Fri, 25 Jun 2021 10:37:34 +0200
Subject: [PATCH] drivers: gpio: AMD8111 and TQMX86 require HAS_IOPORT_MAP
Message-ID: <20210625103734.2f29630be607.Ied890c9ca650517103410e399ef509796653f5d3@changeid>

From: Johannes Berg <johannes.berg at intel.com>

Both of these drivers use ioport_map(), so they need to
depend on HAS_IOPORT_MAP. Otherwise, they cannot be built
even with COMPILE_TEST on architectures without an ioport
implementation, such as ARCH=um.

Reported-by: kernel test robot <lkp at intel.com>
Signed-off-by: Johannes Berg <johannes.berg at intel.com>
---
 drivers/gpio/Kconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 1dd0ec6727fd..3c69b785cb79 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -1383,6 +1383,7 @@ config GPIO_TPS68470
 config GPIO_TQMX86
 	tristate "TQ-Systems QTMX86 GPIO"
 	depends on MFD_TQMX86 || COMPILE_TEST
+	depends on HAS_IOPORT_MAP
 	select GPIOLIB_IRQCHIP
 	help
 	  This driver supports GPIO on the TQMX86 IO controller.
@@ -1450,6 +1451,7 @@ menu "PCI GPIO expanders"
 config GPIO_AMD8111
 	tristate "AMD 8111 GPIO driver"
 	depends on X86 || COMPILE_TEST
+	depends on HAS_IOPORT_MAP
 	help
 	  The AMD 8111 south bridge contains 32 GPIO pins which can be used.
 
-- 
2.31.1



From johannes at sipsolutions.net  Fri Jun 25 01:38:10 2021
From: johannes at sipsolutions.net (Johannes Berg)
Date: Fri, 25 Jun 2021 10:38:10 +0200
Subject: [PATCH] dmaengine: idxd: depends on !UML
Message-ID: <20210625103810.fe877ae0aef4.If240438e3f50ae226f3f755fc46ea498c6858393@changeid>

From: Johannes Berg <johannes.berg at intel.com>

Now that UML has PCI support, this driver must depend also on
!UML since it pokes at X86_64 architecture internals that don't
exist on ARCH=um.

Reported-by: kernel test robot <lkp at intel.com>
Signed-off-by: Johannes Berg <johannes.berg at intel.com>
---
 drivers/dma/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index 6ab9d9a488a6..1f3c0e2ea4d9 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -278,7 +278,7 @@ config INTEL_IDMA64
 
 config INTEL_IDXD
 	tristate "Intel Data Accelerators support"
-	depends on PCI && X86_64
+	depends on PCI && X86_64 && !UML
 	depends on PCI_MSI
 	depends on SBITMAP
 	select DMA_ENGINE
-- 
2.31.1



From anton.ivanov at cambridgegreys.com  Fri Jun 25 02:14:05 2021
From: anton.ivanov at cambridgegreys.com (Anton Ivanov)
Date: Fri, 25 Jun 2021 10:14:05 +0100
Subject: [PATCH] dmaengine: idxd: depends on !UML
In-Reply-To: <20210625103810.fe877ae0aef4.If240438e3f50ae226f3f755fc46ea498c6858393@changeid>
References: <20210625103810.fe877ae0aef4.If240438e3f50ae226f3f755fc46ea498c6858393@changeid>
Message-ID: <4de7c73b-a064-2adc-b7ee-ce2df6b72e1b@cambridgegreys.com>



On 25/06/2021 09:38, Johannes Berg wrote:
> From: Johannes Berg <johannes.berg at intel.com>
> 
> Now that UML has PCI support, this driver must depend also on
> !UML since it pokes at X86_64 architecture internals that don't
> exist on ARCH=um.
> 
> Reported-by: kernel test robot <lkp at intel.com>
> Signed-off-by: Johannes Berg <johannes.berg at intel.com>
> ---
>   drivers/dma/Kconfig | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
> index 6ab9d9a488a6..1f3c0e2ea4d9 100644
> --- a/drivers/dma/Kconfig
> +++ b/drivers/dma/Kconfig
> @@ -278,7 +278,7 @@ config INTEL_IDMA64
>   
>   config INTEL_IDXD
>   	tristate "Intel Data Accelerators support"
> -	depends on PCI && X86_64
> +	depends on PCI && X86_64 && !UML
>   	depends on PCI_MSI
>   	depends on SBITMAP
>   	select DMA_ENGINE
> 

Acked-By: Anton Ivanov <anton.ivanov at cambridgegreys.com>

-- 
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/


From anton.ivanov at kot-begemot.co.uk  Fri Jun 25 02:15:19 2021
From: anton.ivanov at kot-begemot.co.uk (Anton Ivanov)
Date: Fri, 25 Jun 2021 10:15:19 +0100
Subject: [PATCH 4/4] um: virtio_uml: fix memory leak on init failures
In-Reply-To: <20210625103437.bb82b95035e4.I748b002f0650d0705e6ae6b4c4f4b63face436f7@changeid>
References: <20210625103436.900a9e962c32.Id45a0d2d0167dd9b6a067b42d791523896574064@changeid>
 <20210625103437.bb82b95035e4.I748b002f0650d0705e6ae6b4c4f4b63face436f7@changeid>
Message-ID: <ab85d80c-850b-90a7-1695-4b2120610c67@kot-begemot.co.uk>



On 25/06/2021 09:34, Johannes Berg wrote:
> From: Johannes Berg <johannes.berg at intel.com>
> 
> If initialization fails, e.g. because the connection failed,
> we leak the 'vu_dev'. Fix that. Reported by smatch.
> 
> Fixes: 5d38f324993f ("um: drivers: Add virtio vhost-user driver")
> Signed-off-by: Johannes Berg <johannes.berg at intel.com>
> ---
>   arch/um/drivers/virtio_uml.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/um/drivers/virtio_uml.c b/arch/um/drivers/virtio_uml.c
> index cb79fe33d84e..d51e445df797 100644
> --- a/arch/um/drivers/virtio_uml.c
> +++ b/arch/um/drivers/virtio_uml.c
> @@ -1140,7 +1140,7 @@ static int virtio_uml_probe(struct platform_device *pdev)
>   		rc = os_connect_socket(pdata->socket_path);
>   	} while (rc == -EINTR);
>   	if (rc < 0)
> -		return rc;
> +		goto error_free;
>   	vu_dev->sock = rc;
>   
>   	spin_lock_init(&vu_dev->sock_lock);
> @@ -1161,6 +1161,8 @@ static int virtio_uml_probe(struct platform_device *pdev)
>   
>   error_init:
>   	os_close_file(vu_dev->sock);
> +error_free:
> +	kfree(vu_dev);
>   	return rc;
>   }
>   
> 

Acked-By: Anton Ivanov <anton.ivanov at cambridgegreys.com>

-- 
Anton R. Ivanov
https://www.kot-begemot.co.uk/


From anton.ivanov at cambridgegreys.com  Fri Jun 25 02:16:09 2021
From: anton.ivanov at cambridgegreys.com (Anton Ivanov)
Date: Fri, 25 Jun 2021 10:16:09 +0100
Subject: [PATCH 3/4] um: virtio_uml: include linux/virtio-uml.h
In-Reply-To: <20210625103437.d8dde80ec4c4.Icb63afa98dd3949f29f53325e9e1f2eb132749ae@changeid>
References: <20210625103436.900a9e962c32.Id45a0d2d0167dd9b6a067b42d791523896574064@changeid>
 <20210625103437.d8dde80ec4c4.Icb63afa98dd3949f29f53325e9e1f2eb132749ae@changeid>
Message-ID: <7af91f5e-e19c-2cb2-4cac-f7bba22e8d1a@cambridgegreys.com>



On 25/06/2021 09:34, Johannes Berg wrote:
> From: Johannes Berg <johannes.berg at intel.com>
> 
> This fixes a sparse warning, since the function defined
> here should have a declaration (or be static).
> 
> Reported-by: kernel test robot <lkp at intel.com>
> Fixes: 43c590cb8666 ("um: virtio/pci: enable suspend/resume")
> Signed-off-by: Johannes Berg <johannes.berg at intel.com>
> ---
>   arch/um/drivers/virtio_uml.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/arch/um/drivers/virtio_uml.c b/arch/um/drivers/virtio_uml.c
> index 4412d6febade..cb79fe33d84e 100644
> --- a/arch/um/drivers/virtio_uml.c
> +++ b/arch/um/drivers/virtio_uml.c
> @@ -27,6 +27,7 @@
>   #include <linux/virtio_config.h>
>   #include <linux/virtio_ring.h>
>   #include <linux/time-internal.h>
> +#include <linux/virtio-uml.h>
>   #include <shared/as-layout.h>
>   #include <irq_kern.h>
>   #include <init.h>
> 
Acked-By: Anton Ivanov <anton.ivanov at cambridgegreys.com>

-- 
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/


From anton.ivanov at cambridgegreys.com  Fri Jun 25 02:16:27 2021
From: anton.ivanov at cambridgegreys.com (Anton Ivanov)
Date: Fri, 25 Jun 2021 10:16:27 +0100
Subject: [PATCH 2/4] lib/logic_iomem: fix sparse warnings
In-Reply-To: <20210625103437.8ab400c16323.Ic4ba1a600f837d01bf592fad52f55fe52c063388@changeid>
References: <20210625103436.900a9e962c32.Id45a0d2d0167dd9b6a067b42d791523896574064@changeid>
 <20210625103437.8ab400c16323.Ic4ba1a600f837d01bf592fad52f55fe52c063388@changeid>
Message-ID: <1ec68d06-eafa-cc49-2f49-43f0b6289540@cambridgegreys.com>



On 25/06/2021 09:34, Johannes Berg wrote:
> From: Johannes Berg <johannes.berg at intel.com>
> 
> A couple of sparse warnings happened here due to casts on
> the prints, a missing static and a missing include. Fix
> all of them.
> 
> Reported-by: kernel test robot <lkp at intel.com>
> Fixes: ca2e334232b6 ("lib: add iomem emulation (logic_iomem)")
> Signed-off-by: Johannes Berg <johannes.berg at intel.com>
> ---
>   lib/logic_iomem.c | 16 +++++++++-------
>   1 file changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/lib/logic_iomem.c b/lib/logic_iomem.c
> index b76b92dd0f1f..9bdfde0c0f86 100644
> --- a/lib/logic_iomem.c
> +++ b/lib/logic_iomem.c
> @@ -6,6 +6,7 @@
>   #include <linux/types.h>
>   #include <linux/slab.h>
>   #include <linux/logic_iomem.h>
> +#include <asm/io.h>
>   
>   struct logic_iomem_region {
>   	const struct resource *res;
> @@ -78,7 +79,7 @@ static void __iomem *real_ioremap(phys_addr_t offset, size_t size)
>   static void real_iounmap(void __iomem *addr)
>   {
>   	WARN(1, "invalid iounmap for addr 0x%llx\n",
> -	     (unsigned long long)addr);
> +	     (unsigned long long __force)addr);
>   }
>   #endif /* CONFIG_LOGIC_IOMEM_FALLBACK */
>   
> @@ -172,14 +173,15 @@ EXPORT_SYMBOL(iounmap);
>   static u##sz real_raw_read ## op(const volatile void __iomem *addr)	\
>   {									\
>   	WARN(1, "Invalid read" #op " at address %llx\n",		\
> -	     (unsigned long long)addr);					\
> +	     (unsigned long long __force)addr);				\
>   	return (u ## sz)~0ULL;						\
>   }									\
>   									\
> -void real_raw_write ## op(u ## sz val, volatile void __iomem *addr)	\
> +static void real_raw_write ## op(u ## sz val,				\
> +				 volatile void __iomem *addr)		\
>   {									\
>   	WARN(1, "Invalid writeq" #op " of 0x%llx at address %llx\n",	\
> -	     (unsigned long long)val, (unsigned long long)addr);	\
> +	     (unsigned long long)val, (unsigned long long __force)addr);\
>   }									\
>   
>   MAKE_FALLBACK(b, 8);
> @@ -192,14 +194,14 @@ MAKE_FALLBACK(q, 64);
>   static void real_memset_io(volatile void __iomem *addr, int value, size_t size)
>   {
>   	WARN(1, "Invalid memset_io at address 0x%llx\n",
> -	     (unsigned long long)addr);
> +	     (unsigned long long __force)addr);
>   }
>   
>   static void real_memcpy_fromio(void *buffer, const volatile void __iomem *addr,
>   			       size_t size)
>   {
>   	WARN(1, "Invalid memcpy_fromio at address 0x%llx\n",
> -	     (unsigned long long)addr);
> +	     (unsigned long long __force)addr);
>   
>   	memset(buffer, 0xff, size);
>   }
> @@ -208,7 +210,7 @@ static void real_memcpy_toio(volatile void __iomem *addr, const void *buffer,
>   			     size_t size)
>   {
>   	WARN(1, "Invalid memcpy_toio at address 0x%llx\n",
> -	     (unsigned long long)addr);
> +	     (unsigned long long __force)addr);
>   }
>   #endif /* CONFIG_LOGIC_IOMEM_FALLBACK */
>   
> 

Acked-By: Anton Ivanov <anton.ivanov at cambridgegreys.com>

-- 
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/


From anton.ivanov at cambridgegreys.com  Fri Jun 25 02:16:46 2021
From: anton.ivanov at cambridgegreys.com (Anton Ivanov)
Date: Fri, 25 Jun 2021 10:16:46 +0100
Subject: [PATCH 1/4] um: make PCI emulation driver init/exit static
In-Reply-To: <20210625103436.900a9e962c32.Id45a0d2d0167dd9b6a067b42d791523896574064@changeid>
References: <20210625103436.900a9e962c32.Id45a0d2d0167dd9b6a067b42d791523896574064@changeid>
Message-ID: <3fe0853b-2e47-11ca-2668-b2de2f4970ce@cambridgegreys.com>



On 25/06/2021 09:34, Johannes Berg wrote:
> From: Johannes Berg <johannes.berg at intel.com>
> 
> The functions aren't used elsewhere, so they can be static.
> 
> Reported-by: kernel test robot <lkp at intel.com>
> Fixes: 68f5d3f3b654 ("um: add PCI over virtio emulation driver")
> Signed-off-by: Johannes Berg <johannes.berg at intel.com>
> ---
>   arch/um/drivers/virt-pci.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/um/drivers/virt-pci.c b/arch/um/drivers/virt-pci.c
> index 0b802834f40a..70c17de16662 100644
> --- a/arch/um/drivers/virt-pci.c
> +++ b/arch/um/drivers/virt-pci.c
> @@ -810,7 +810,7 @@ void *pci_root_bus_fwnode(struct pci_bus *bus)
>   	return um_pci_fwnode;
>   }
>   
> -int um_pci_init(void)
> +static int um_pci_init(void)
>   {
>   	int err, i;
>   
> @@ -884,7 +884,7 @@ int um_pci_init(void)
>   }
>   module_init(um_pci_init);
>   
> -void um_pci_exit(void)
> +static void um_pci_exit(void)
>   {
>   	unregister_virtio_driver(&um_pci_virtio_driver);
>   	irq_domain_remove(um_pci_msi_domain);
> 

Acked-By: Anton Ivanov <anton.ivanov at cambridgegreys.com>

-- 
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/


From bgolaszewski at baylibre.com  Fri Jun 25 03:16:56 2021
From: bgolaszewski at baylibre.com (Bartosz Golaszewski)
Date: Fri, 25 Jun 2021 12:16:56 +0200
Subject: [PATCH] drivers: gpio: AMD8111 and TQMX86 require HAS_IOPORT_MAP
In-Reply-To: <20210625103734.2f29630be607.Ied890c9ca650517103410e399ef509796653f5d3@changeid>
References: <20210625103734.2f29630be607.Ied890c9ca650517103410e399ef509796653f5d3@changeid>
Message-ID: <CAMpxmJWnh6RB98H_z5U3_x7J05GNwN8TW5=eiTj7QzPJRnuKuQ@mail.gmail.com>

On Fri, Jun 25, 2021 at 10:37 AM Johannes Berg
<johannes at sipsolutions.net> wrote:
>
> From: Johannes Berg <johannes.berg at intel.com>
>
> Both of these drivers use ioport_map(), so they need to
> depend on HAS_IOPORT_MAP. Otherwise, they cannot be built
> even with COMPILE_TEST on architectures without an ioport
> implementation, such as ARCH=um.
>
> Reported-by: kernel test robot <lkp at intel.com>
> Signed-off-by: Johannes Berg <johannes.berg at intel.com>
> ---
>  drivers/gpio/Kconfig | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
> index 1dd0ec6727fd..3c69b785cb79 100644
> --- a/drivers/gpio/Kconfig
> +++ b/drivers/gpio/Kconfig
> @@ -1383,6 +1383,7 @@ config GPIO_TPS68470
>  config GPIO_TQMX86
>         tristate "TQ-Systems QTMX86 GPIO"
>         depends on MFD_TQMX86 || COMPILE_TEST
> +       depends on HAS_IOPORT_MAP
>         select GPIOLIB_IRQCHIP
>         help
>           This driver supports GPIO on the TQMX86 IO controller.
> @@ -1450,6 +1451,7 @@ menu "PCI GPIO expanders"
>  config GPIO_AMD8111
>         tristate "AMD 8111 GPIO driver"
>         depends on X86 || COMPILE_TEST
> +       depends on HAS_IOPORT_MAP
>         help
>           The AMD 8111 south bridge contains 32 GPIO pins which can be used.
>
> --
> 2.31.1
>

Applied, thanks!

Bart


From dave.jiang at intel.com  Fri Jun 25 07:34:12 2021
From: dave.jiang at intel.com (Dave Jiang)
Date: Fri, 25 Jun 2021 07:34:12 -0700
Subject: [PATCH] dmaengine: idxd: depends on !UML
In-Reply-To: <20210625103810.fe877ae0aef4.If240438e3f50ae226f3f755fc46ea498c6858393@changeid>
References: <20210625103810.fe877ae0aef4.If240438e3f50ae226f3f755fc46ea498c6858393@changeid>
Message-ID: <ff85e229-9605-7a25-08fa-4013df49b49c@intel.com>


On 6/25/2021 1:38 AM, Johannes Berg wrote:
> From: Johannes Berg <johannes.berg at intel.com>
>
> Now that UML has PCI support, this driver must depend also on
> !UML since it pokes at X86_64 architecture internals that don't
> exist on ARCH=um.
>
> Reported-by: kernel test robot <lkp at intel.com>
> Signed-off-by: Johannes Berg <johannes.berg at intel.com>

Acked-by: Dave Jiang <dave.jiang at intel.com>


> ---
>   drivers/dma/Kconfig | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
> index 6ab9d9a488a6..1f3c0e2ea4d9 100644
> --- a/drivers/dma/Kconfig
> +++ b/drivers/dma/Kconfig
> @@ -278,7 +278,7 @@ config INTEL_IDMA64
>   
>   config INTEL_IDXD
>   	tristate "Intel Data Accelerators support"
> -	depends on PCI && X86_64
> +	depends on PCI && X86_64 && !UML
>   	depends on PCI_MSI
>   	depends on SBITMAP
>   	select DMA_ENGINE


From hch at lst.de  Mon Jun 28 02:39:37 2021
From: hch at lst.de (Christoph Hellwig)
Date: Mon, 28 Jun 2021 11:39:37 +0200
Subject: [PATCH] ubd: remove dead code in ubd_setup_common
Message-ID: <20210628093937.1325608-1-hch@lst.de>

Remove some leftovers of the fake major number parsing that cause
complains from some compilers.

Fixes: aebbd9fdb0cc ("ubd: remove the code to register as the legacy IDE driver")
Signed-off-by: Christoph Hellwig <hch at lst.de>
---
 arch/um/drivers/ubd_kern.c | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index 0b86aa1b12f1..e3093071406d 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -243,22 +243,12 @@ static int ubd_setup_common(char *str, int *index_out, char **error_out)
 	if(index_out) *index_out = -1;
 	n = *str;
 	if(n == '='){
-		char *end;
-		int major;
-
 		str++;
 		if(!strcmp(str, "sync")){
 			global_openflags = of_sync(global_openflags);
 			return err;
 		}
 
-		err = -EINVAL;
-		major = simple_strtoul(str, &end, 0);
-		if((*end != '\0') || (end == str)){
-			*error_out = "Didn't parse major number";
-			return err;
-		}
-
 		pr_warn("fake major not supported any more\n");
 		return 0;
 	}
-- 
2.30.2



From jannh at google.com  Mon Jun 28 09:13:29 2021
From: jannh at google.com (Jann Horn)
Date: Mon, 28 Jun 2021 18:13:29 +0200
Subject: [PATCH 2/4] arch/x86: implement the process_vm_exec syscall
In-Reply-To: <20210414055217.543246-3-avagin@gmail.com>
References: <20210414055217.543246-1-avagin@gmail.com>
 <20210414055217.543246-3-avagin@gmail.com>
Message-ID: <CAG48ez3UrzPE8rkucTgCu8ggcTEjx_h3Gj2FES1qM-uv2KD8bQ@mail.gmail.com>

On Wed, Apr 14, 2021 at 7:59 AM Andrei Vagin <avagin at gmail.com> wrote:
> This change introduces the new system call:
> process_vm_exec(pid_t pid, struct sigcontext *uctx, unsigned long flags,
>                 siginfo_t * uinfo, sigset_t *sigmask, size_t sizemask)
>
> process_vm_exec allows to execute the current process in an address
> space of another process.
[...]

I still think that this whole API is fundamentally the wrong approach
because it tries to shoehorn multiple usecases with different
requirements into a single API. But that aside:

> +static void swap_mm(struct mm_struct *prev_mm, struct mm_struct *target_mm)
> +{
> +       struct task_struct *tsk = current;
> +       struct mm_struct *active_mm;
> +
> +       task_lock(tsk);
> +       /* Hold off tlb flush IPIs while switching mm's */
> +       local_irq_disable();
> +
> +       sync_mm_rss(prev_mm);
> +
> +       vmacache_flush(tsk);
> +
> +       active_mm = tsk->active_mm;
> +       if (active_mm != target_mm) {
> +               mmgrab(target_mm);
> +               tsk->active_mm = target_mm;
> +       }
> +       tsk->mm = target_mm;

I'm pretty sure you're not currently allowed to overwrite the ->mm
pointer of a userspace thread. For example, zap_threads() assumes that
all threads running under a process have the same ->mm. (And if you're
fiddling with ->mm stuff, you should probably CC linux-mm at .)

As far as I understand, only kthreads are allowed to do this (as
implemented in kthread_use_mm()).

> +       switch_mm_irqs_off(active_mm, target_mm, tsk);
> +       local_irq_enable();
> +       task_unlock(tsk);
> +#ifdef finish_arch_post_lock_switch
> +       finish_arch_post_lock_switch();
> +#endif
> +
> +       if (active_mm != target_mm)
> +               mmdrop(active_mm);
> +}


From luto at kernel.org  Mon Jun 28 09:30:31 2021
From: luto at kernel.org (Andy Lutomirski)
Date: Mon, 28 Jun 2021 09:30:31 -0700
Subject: [PATCH 2/4] arch/x86: implement the process_vm_exec syscall
In-Reply-To: <CAG48ez3UrzPE8rkucTgCu8ggcTEjx_h3Gj2FES1qM-uv2KD8bQ@mail.gmail.com>
References: <20210414055217.543246-1-avagin@gmail.com>
 <20210414055217.543246-3-avagin@gmail.com>
 <CAG48ez3UrzPE8rkucTgCu8ggcTEjx_h3Gj2FES1qM-uv2KD8bQ@mail.gmail.com>
Message-ID: <f64f960b-d978-4022-9e56-0d9d9a3c0ebc@www.fastmail.com>



On Mon, Jun 28, 2021, at 9:13 AM, Jann Horn wrote:
> On Wed, Apr 14, 2021 at 7:59 AM Andrei Vagin <avagin at gmail.com> wrote:
> > This change introduces the new system call:
> > process_vm_exec(pid_t pid, struct sigcontext *uctx, unsigned long flags,
> >                 siginfo_t * uinfo, sigset_t *sigmask, size_t sizemask)
> >
> > process_vm_exec allows to execute the current process in an address
> > space of another process.
> [...]
> 
> I still think that this whole API is fundamentally the wrong approach
> because it tries to shoehorn multiple usecases with different
> requirements into a single API. But that aside:
> 
> > +static void swap_mm(struct mm_struct *prev_mm, struct mm_struct *target_mm)
> > +{
> > +       struct task_struct *tsk = current;
> > +       struct mm_struct *active_mm;
> > +
> > +       task_lock(tsk);
> > +       /* Hold off tlb flush IPIs while switching mm's */
> > +       local_irq_disable();
> > +
> > +       sync_mm_rss(prev_mm);
> > +
> > +       vmacache_flush(tsk);
> > +
> > +       active_mm = tsk->active_mm;
> > +       if (active_mm != target_mm) {
> > +               mmgrab(target_mm);
> > +               tsk->active_mm = target_mm;
> > +       }
> > +       tsk->mm = target_mm;
> 
> I'm pretty sure you're not currently allowed to overwrite the ->mm
> pointer of a userspace thread. For example, zap_threads() assumes that
> all threads running under a process have the same ->mm. (And if you're
> fiddling with ->mm stuff, you should probably CC linux-mm at .)

exec_mmap() does it, so it can?t be entirely impossible.


From jannh at google.com  Mon Jun 28 10:14:31 2021
From: jannh at google.com (Jann Horn)
Date: Mon, 28 Jun 2021 19:14:31 +0200
Subject: [PATCH 2/4] arch/x86: implement the process_vm_exec syscall
In-Reply-To: <f64f960b-d978-4022-9e56-0d9d9a3c0ebc@www.fastmail.com>
References: <20210414055217.543246-1-avagin@gmail.com>
 <20210414055217.543246-3-avagin@gmail.com>
 <CAG48ez3UrzPE8rkucTgCu8ggcTEjx_h3Gj2FES1qM-uv2KD8bQ@mail.gmail.com>
 <f64f960b-d978-4022-9e56-0d9d9a3c0ebc@www.fastmail.com>
Message-ID: <CAG48ez1d3abHEekh_fYoXdAe85RG+c--G7sEyMYhiKEsns3uog@mail.gmail.com>

On Mon, Jun 28, 2021 at 6:30 PM Andy Lutomirski <luto at kernel.org> wrote:
> On Mon, Jun 28, 2021, at 9:13 AM, Jann Horn wrote:
> > On Wed, Apr 14, 2021 at 7:59 AM Andrei Vagin <avagin at gmail.com> wrote:
> > > This change introduces the new system call:
> > > process_vm_exec(pid_t pid, struct sigcontext *uctx, unsigned long flags,
> > >                 siginfo_t * uinfo, sigset_t *sigmask, size_t sizemask)
> > >
> > > process_vm_exec allows to execute the current process in an address
> > > space of another process.
> > [...]
> >
> > I still think that this whole API is fundamentally the wrong approach
> > because it tries to shoehorn multiple usecases with different
> > requirements into a single API. But that aside:
> >
> > > +static void swap_mm(struct mm_struct *prev_mm, struct mm_struct *target_mm)
> > > +{
> > > +       struct task_struct *tsk = current;
> > > +       struct mm_struct *active_mm;
> > > +
> > > +       task_lock(tsk);
> > > +       /* Hold off tlb flush IPIs while switching mm's */
> > > +       local_irq_disable();
> > > +
> > > +       sync_mm_rss(prev_mm);
> > > +
> > > +       vmacache_flush(tsk);
> > > +
> > > +       active_mm = tsk->active_mm;
> > > +       if (active_mm != target_mm) {
> > > +               mmgrab(target_mm);
> > > +               tsk->active_mm = target_mm;
> > > +       }
> > > +       tsk->mm = target_mm;
> >
> > I'm pretty sure you're not currently allowed to overwrite the ->mm
> > pointer of a userspace thread. For example, zap_threads() assumes that
> > all threads running under a process have the same ->mm. (And if you're
> > fiddling with ->mm stuff, you should probably CC linux-mm at .)
>
> exec_mmap() does it, so it can?t be entirely impossible.

Yeah, true, execve can do it - I guess the thing that makes that
special is that it's running after de_thread(), so it's guaranteed to
be single-threaded?


From ebiederm at xmission.com  Mon Jun 28 11:18:07 2021
From: ebiederm at xmission.com (Eric W. Biederman)
Date: Mon, 28 Jun 2021 13:18:07 -0500
Subject: [PATCH 2/4] arch/x86: implement the process_vm_exec syscall
In-Reply-To: <CAG48ez1d3abHEekh_fYoXdAe85RG+c--G7sEyMYhiKEsns3uog@mail.gmail.com>
 (Jann Horn's message of "Mon, 28 Jun 2021 19:14:31 +0200")
References: <20210414055217.543246-1-avagin@gmail.com>
 <20210414055217.543246-3-avagin@gmail.com>
 <CAG48ez3UrzPE8rkucTgCu8ggcTEjx_h3Gj2FES1qM-uv2KD8bQ@mail.gmail.com>
 <f64f960b-d978-4022-9e56-0d9d9a3c0ebc@www.fastmail.com>
 <CAG48ez1d3abHEekh_fYoXdAe85RG+c--G7sEyMYhiKEsns3uog@mail.gmail.com>
Message-ID: <87o8bpyhsw.fsf@disp2133>

Jann Horn <jannh at google.com> writes:

> On Mon, Jun 28, 2021 at 6:30 PM Andy Lutomirski <luto at kernel.org> wrote:
>> On Mon, Jun 28, 2021, at 9:13 AM, Jann Horn wrote:
>> > On Wed, Apr 14, 2021 at 7:59 AM Andrei Vagin <avagin at gmail.com> wrote:
>> > > This change introduces the new system call:
>> > > process_vm_exec(pid_t pid, struct sigcontext *uctx, unsigned long flags,
>> > >                 siginfo_t * uinfo, sigset_t *sigmask, size_t sizemask)
>> > >
>> > > process_vm_exec allows to execute the current process in an address
>> > > space of another process.
>> > [...]
>> >
>> > I still think that this whole API is fundamentally the wrong approach
>> > because it tries to shoehorn multiple usecases with different
>> > requirements into a single API. But that aside:
>> >
>> > > +static void swap_mm(struct mm_struct *prev_mm, struct mm_struct *target_mm)
>> > > +{
>> > > +       struct task_struct *tsk = current;
>> > > +       struct mm_struct *active_mm;
>> > > +
>> > > +       task_lock(tsk);
>> > > +       /* Hold off tlb flush IPIs while switching mm's */
>> > > +       local_irq_disable();
>> > > +
>> > > +       sync_mm_rss(prev_mm);
>> > > +
>> > > +       vmacache_flush(tsk);
>> > > +
>> > > +       active_mm = tsk->active_mm;
>> > > +       if (active_mm != target_mm) {
>> > > +               mmgrab(target_mm);
>> > > +               tsk->active_mm = target_mm;
>> > > +       }
>> > > +       tsk->mm = target_mm;
>> >
>> > I'm pretty sure you're not currently allowed to overwrite the ->mm
>> > pointer of a userspace thread. For example, zap_threads() assumes that
>> > all threads running under a process have the same ->mm. (And if you're
>> > fiddling with ->mm stuff, you should probably CC linux-mm at .)
>>
>> exec_mmap() does it, so it can?t be entirely impossible.
>
> Yeah, true, execve can do it - I guess the thing that makes that
> special is that it's running after de_thread(), so it's guaranteed to
> be single-threaded?

Even the implementation detail of swapping the mm aside.  Even the idea
of swaping the mm is completely broken, as an endless system calls
depend upon the state held in task_struct.  io_uring just tried running
system calls of a process in a different context and we ultimately had
to make the threads part of the original process to make enough things
work to keep the problem tractable.

System calls deeply and fundamentally depend on task_struct and
signal_struct.

I can think of two possibilities.
1) Hijack and existing process thread.
2) Inject a new thread into an existing process.

Anything else is just an exercise in trouble.  Of this I think Hijacking
an existing thread is the only one that won't require lots of tracking
down of special cases.  I seem to remember audit is still struggling
with how to properly audit io_uring threads.

Eric


From axboe at kernel.dk  Mon Jun 28 12:48:22 2021
From: axboe at kernel.dk (Jens Axboe)
Date: Mon, 28 Jun 2021 13:48:22 -0600
Subject: [PATCH] ubd: remove dead code in ubd_setup_common
In-Reply-To: <20210628093937.1325608-1-hch@lst.de>
References: <20210628093937.1325608-1-hch@lst.de>
Message-ID: <59dff238-e9aa-4de3-fa00-08d376f443a6@kernel.dk>

On 6/28/21 3:39 AM, Christoph Hellwig wrote:
> Remove some leftovers of the fake major number parsing that cause
> complains from some compilers.

Applied, thanks.

-- 
Jens Axboe



From avagin at gmail.com  Mon Jun 28 18:01:43 2021
From: avagin at gmail.com (Andrei Vagin)
Date: Mon, 28 Jun 2021 18:01:43 -0700
Subject: [PATCH 2/4] arch/x86: implement the process_vm_exec syscall
In-Reply-To: <87o8bpyhsw.fsf@disp2133>
References: <20210414055217.543246-1-avagin@gmail.com>
 <20210414055217.543246-3-avagin@gmail.com>
 <CAG48ez3UrzPE8rkucTgCu8ggcTEjx_h3Gj2FES1qM-uv2KD8bQ@mail.gmail.com>
 <f64f960b-d978-4022-9e56-0d9d9a3c0ebc@www.fastmail.com>
 <CAG48ez1d3abHEekh_fYoXdAe85RG+c--G7sEyMYhiKEsns3uog@mail.gmail.com>
 <87o8bpyhsw.fsf@disp2133>
Message-ID: <YNpw92ji12g9+W3D@gmail.com>

On Mon, Jun 28, 2021 at 01:18:07PM -0500, Eric W. Biederman wrote:
> Jann Horn <jannh at google.com> writes:
> 
> > On Mon, Jun 28, 2021 at 6:30 PM Andy Lutomirski <luto at kernel.org> wrote:
> >> On Mon, Jun 28, 2021, at 9:13 AM, Jann Horn wrote:
> >> > On Wed, Apr 14, 2021 at 7:59 AM Andrei Vagin <avagin at gmail.com> wrote:
> >> > > This change introduces the new system call:
> >> > > process_vm_exec(pid_t pid, struct sigcontext *uctx, unsigned long flags,
> >> > >                 siginfo_t * uinfo, sigset_t *sigmask, size_t sizemask)
> >> > >
> >> > > process_vm_exec allows to execute the current process in an address
> >> > > space of another process.
> >> > [...]
> >> >
> >> > I still think that this whole API is fundamentally the wrong approach
> >> > because it tries to shoehorn multiple usecases with different
> >> > requirements into a single API. But that aside:
> >> >
> >> > > +static void swap_mm(struct mm_struct *prev_mm, struct mm_struct *target_mm)
> >> > > +{
> >> > > +       struct task_struct *tsk = current;
> >> > > +       struct mm_struct *active_mm;
> >> > > +
> >> > > +       task_lock(tsk);
> >> > > +       /* Hold off tlb flush IPIs while switching mm's */
> >> > > +       local_irq_disable();
> >> > > +
> >> > > +       sync_mm_rss(prev_mm);
> >> > > +
> >> > > +       vmacache_flush(tsk);
> >> > > +
> >> > > +       active_mm = tsk->active_mm;
> >> > > +       if (active_mm != target_mm) {
> >> > > +               mmgrab(target_mm);
> >> > > +               tsk->active_mm = target_mm;
> >> > > +       }
> >> > > +       tsk->mm = target_mm;
> >> >
> >> > I'm pretty sure you're not currently allowed to overwrite the ->mm
> >> > pointer of a userspace thread. For example, zap_threads() assumes that
> >> > all threads running under a process have the same ->mm. (And if you're
> >> > fiddling with ->mm stuff, you should probably CC linux-mm at .)
> >>
> >> exec_mmap() does it, so it can?t be entirely impossible.
> >
> > Yeah, true, execve can do it - I guess the thing that makes that
> > special is that it's running after de_thread(), so it's guaranteed to
> > be single-threaded?
> 
> Even the implementation detail of swapping the mm aside.  Even the idea
> of swaping the mm is completely broken, as an endless system calls
> depend upon the state held in task_struct.  io_uring just tried running
> system calls of a process in a different context and we ultimately had
> to make the threads part of the original process to make enough things
> work to keep the problem tractable.
> 
> System calls deeply and fundamentally depend on task_struct and
> signal_struct.

In opposite to io_uring, process_vm_exec doesn't intend to run system
calls in the context of the target process. We initially declare that
system calls are executed in the context of the current process with
just another mm. If we are talking about user-mode kernels, they will
need just two system calls: mmap and munmap. In case of CRIU, vmsplice
will be used too.

> 
> I can think of two possibilities.
> 1) Hijack and existing process thread.
> 2) Inject a new thread into an existing process.

I am not sure that I understand what you mean here, but it sounds like
we will need to do a context switch to execute anything in a context
of a hijacked thread. If I am right, it kills the main idea of
process_vm_exec. If I misunderstand your idea, maybe you can describe it
with more details.

Thanks,
Andrei


