From: Sasha Levin Date: Mon, 7 Oct 2024 03:41:36 +0000 (-0400) Subject: Fixes for 5.15 X-Git-Tag: v6.6.55~124 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d6661e5548db419482c47a5a0ce1b815581ce2c9;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 5.15 Signed-off-by: Sasha Levin --- diff --git a/queue-5.15/blk-integrity-convert-to-struct-device_attribute.patch b/queue-5.15/blk-integrity-convert-to-struct-device_attribute.patch new file mode 100644 index 00000000000..113f1b84309 --- /dev/null +++ b/queue-5.15/blk-integrity-convert-to-struct-device_attribute.patch @@ -0,0 +1,231 @@ +From 9ff6a3b2c3062c4ae2dcf8bee6b9b2e5548f7a52 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 2 Oct 2024 11:01:21 -0300 +Subject: blk-integrity: convert to struct device_attribute +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Thomas Weißschuh + +Upstream commit 76b8c319f02715e14abdbbbdd6508e83a1059bcc. + +An upcoming patch will register the integrity attributes directly with +the struct device kobject. +For this the attributes have to be implemented in terms of +struct device_attribute. + +Signed-off-by: Thomas Weißschuh +Reviewed-by: Christoph Hellwig +Reviewed-by: Martin K. Petersen +Link: https://lore.kernel.org/r/20230309-kobj_release-gendisk_integrity-v3-2-ceccb4493c46@weissschuh.net +Signed-off-by: Jens Axboe +Signed-off-by: Thadeu Lima de Souza Cascardo +Signed-off-by: Sasha Levin +--- + block/blk-integrity.c | 127 +++++++++++++++++++++--------------------- + 1 file changed, 62 insertions(+), 65 deletions(-) + +diff --git a/block/blk-integrity.c b/block/blk-integrity.c +index cbc77a2de0376..8868b1e01d58b 100644 +--- a/block/blk-integrity.c ++++ b/block/blk-integrity.c +@@ -212,21 +212,15 @@ bool blk_integrity_merge_bio(struct request_queue *q, struct request *req, + return true; + } + +-struct integrity_sysfs_entry { +- struct attribute attr; +- ssize_t (*show)(struct blk_integrity *, char *); +- ssize_t (*store)(struct blk_integrity *, const char *, size_t); +-}; +- + static ssize_t integrity_attr_show(struct kobject *kobj, struct attribute *attr, + char *page) + { + struct gendisk *disk = container_of(kobj, struct gendisk, integrity_kobj); +- struct blk_integrity *bi = &disk->queue->integrity; +- struct integrity_sysfs_entry *entry = +- container_of(attr, struct integrity_sysfs_entry, attr); ++ struct device *dev = disk_to_dev(disk); ++ struct device_attribute *dev_attr = ++ container_of(attr, struct device_attribute, attr); + +- return entry->show(bi, page); ++ return dev_attr->show(dev, dev_attr, page); + } + + static ssize_t integrity_attr_store(struct kobject *kobj, +@@ -234,38 +228,53 @@ static ssize_t integrity_attr_store(struct kobject *kobj, + size_t count) + { + struct gendisk *disk = container_of(kobj, struct gendisk, integrity_kobj); +- struct blk_integrity *bi = &disk->queue->integrity; +- struct integrity_sysfs_entry *entry = +- container_of(attr, struct integrity_sysfs_entry, attr); +- ssize_t ret = 0; ++ struct device *dev = disk_to_dev(disk); ++ struct device_attribute *dev_attr = ++ container_of(attr, struct device_attribute, attr); + +- if (entry->store) +- ret = entry->store(bi, page, count); ++ if (!dev_attr->store) ++ return 0; ++ return dev_attr->store(dev, dev_attr, page, count); ++} + +- return ret; ++static inline struct blk_integrity *dev_to_bi(struct device *dev) ++{ ++ return &dev_to_disk(dev)->queue->integrity; + } + +-static ssize_t integrity_format_show(struct blk_integrity *bi, char *page) ++static ssize_t format_show(struct device *dev, struct device_attribute *attr, ++ char *page) + { ++ struct blk_integrity *bi = dev_to_bi(dev); ++ + if (bi->profile && bi->profile->name) + return sysfs_emit(page, "%s\n", bi->profile->name); + return sysfs_emit(page, "none\n"); + } + +-static ssize_t integrity_tag_size_show(struct blk_integrity *bi, char *page) ++static ssize_t tag_size_show(struct device *dev, struct device_attribute *attr, ++ char *page) + { ++ struct blk_integrity *bi = dev_to_bi(dev); ++ + return sysfs_emit(page, "%u\n", bi->tag_size); + } + +-static ssize_t integrity_interval_show(struct blk_integrity *bi, char *page) ++static ssize_t protection_interval_bytes_show(struct device *dev, ++ struct device_attribute *attr, ++ char *page) + { ++ struct blk_integrity *bi = dev_to_bi(dev); ++ + return sysfs_emit(page, "%u\n", + bi->interval_exp ? 1 << bi->interval_exp : 0); + } + +-static ssize_t integrity_verify_store(struct blk_integrity *bi, +- const char *page, size_t count) ++static ssize_t read_verify_store(struct device *dev, ++ struct device_attribute *attr, ++ const char *page, size_t count) + { ++ struct blk_integrity *bi = dev_to_bi(dev); + char *p = (char *) page; + unsigned long val = simple_strtoul(p, &p, 10); + +@@ -277,14 +286,20 @@ static ssize_t integrity_verify_store(struct blk_integrity *bi, + return count; + } + +-static ssize_t integrity_verify_show(struct blk_integrity *bi, char *page) ++static ssize_t read_verify_show(struct device *dev, ++ struct device_attribute *attr, char *page) + { ++ struct blk_integrity *bi = dev_to_bi(dev); ++ + return sysfs_emit(page, "%d\n", !!(bi->flags & BLK_INTEGRITY_VERIFY)); + } + +-static ssize_t integrity_generate_store(struct blk_integrity *bi, +- const char *page, size_t count) ++static ssize_t write_generate_store(struct device *dev, ++ struct device_attribute *attr, ++ const char *page, size_t count) + { ++ struct blk_integrity *bi = dev_to_bi(dev); ++ + char *p = (char *) page; + unsigned long val = simple_strtoul(p, &p, 10); + +@@ -296,57 +311,39 @@ static ssize_t integrity_generate_store(struct blk_integrity *bi, + return count; + } + +-static ssize_t integrity_generate_show(struct blk_integrity *bi, char *page) ++static ssize_t write_generate_show(struct device *dev, ++ struct device_attribute *attr, char *page) + { ++ struct blk_integrity *bi = dev_to_bi(dev); ++ + return sysfs_emit(page, "%d\n", !!(bi->flags & BLK_INTEGRITY_GENERATE)); + } + +-static ssize_t integrity_device_show(struct blk_integrity *bi, char *page) ++static ssize_t device_is_integrity_capable_show(struct device *dev, ++ struct device_attribute *attr, ++ char *page) + { ++ struct blk_integrity *bi = dev_to_bi(dev); ++ + return sysfs_emit(page, "%u\n", + !!(bi->flags & BLK_INTEGRITY_DEVICE_CAPABLE)); + } + +-static struct integrity_sysfs_entry integrity_format_entry = { +- .attr = { .name = "format", .mode = 0444 }, +- .show = integrity_format_show, +-}; +- +-static struct integrity_sysfs_entry integrity_tag_size_entry = { +- .attr = { .name = "tag_size", .mode = 0444 }, +- .show = integrity_tag_size_show, +-}; +- +-static struct integrity_sysfs_entry integrity_interval_entry = { +- .attr = { .name = "protection_interval_bytes", .mode = 0444 }, +- .show = integrity_interval_show, +-}; +- +-static struct integrity_sysfs_entry integrity_verify_entry = { +- .attr = { .name = "read_verify", .mode = 0644 }, +- .show = integrity_verify_show, +- .store = integrity_verify_store, +-}; +- +-static struct integrity_sysfs_entry integrity_generate_entry = { +- .attr = { .name = "write_generate", .mode = 0644 }, +- .show = integrity_generate_show, +- .store = integrity_generate_store, +-}; +- +-static struct integrity_sysfs_entry integrity_device_entry = { +- .attr = { .name = "device_is_integrity_capable", .mode = 0444 }, +- .show = integrity_device_show, +-}; ++static DEVICE_ATTR_RO(format); ++static DEVICE_ATTR_RO(tag_size); ++static DEVICE_ATTR_RO(protection_interval_bytes); ++static DEVICE_ATTR_RW(read_verify); ++static DEVICE_ATTR_RW(write_generate); ++static DEVICE_ATTR_RO(device_is_integrity_capable); + + static struct attribute *integrity_attrs[] = { +- &integrity_format_entry.attr, +- &integrity_tag_size_entry.attr, +- &integrity_interval_entry.attr, +- &integrity_verify_entry.attr, +- &integrity_generate_entry.attr, +- &integrity_device_entry.attr, +- NULL, ++ &dev_attr_format.attr, ++ &dev_attr_tag_size.attr, ++ &dev_attr_protection_interval_bytes.attr, ++ &dev_attr_read_verify.attr, ++ &dev_attr_write_generate.attr, ++ &dev_attr_device_is_integrity_capable.attr, ++ NULL + }; + ATTRIBUTE_GROUPS(integrity); + +-- +2.43.0 + diff --git a/queue-5.15/blk-integrity-register-sysfs-attributes-on-struct-de.patch b/queue-5.15/blk-integrity-register-sysfs-attributes-on-struct-de.patch new file mode 100644 index 00000000000..1e97ae70a78 --- /dev/null +++ b/queue-5.15/blk-integrity-register-sysfs-attributes-on-struct-de.patch @@ -0,0 +1,209 @@ +From d6e7b9b931307d6628c7e7f6436d563412c24157 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 2 Oct 2024 11:01:22 -0300 +Subject: blk-integrity: register sysfs attributes on struct device +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Thomas Weißschuh + +Upstream commit ff53cd52d9bdbf4074d2bbe9b591729997780bd3. + +The "integrity" kobject only acted as a holder for static sysfs entries. +It also was embedded into struct gendisk without managing it, violating +assumptions of the driver core. + +Instead register the sysfs entries directly onto the struct device. + +Also drop the now unused member integrity_kobj from struct gendisk. + +Suggested-by: Christoph Hellwig +Signed-off-by: Thomas Weißschuh +Reviewed-by: Christoph Hellwig +Reviewed-by: Martin K. Petersen +Link: https://lore.kernel.org/r/20230309-kobj_release-gendisk_integrity-v3-3-ceccb4493c46@weissschuh.net +Signed-off-by: Jens Axboe +[cascardo: conflict because of constification of integrity_ktype] +[cascardo: struct gendisk is defined at include/linux/genhd.h] +[cascardo: there is no blk_trace_attr_group] +Signed-off-by: Thadeu Lima de Souza Cascardo +Signed-off-by: Sasha Levin +--- + block/blk-integrity.c | 55 +++---------------------------------------- + block/blk.h | 10 +------- + block/genhd.c | 12 ++++------ + include/linux/genhd.h | 3 --- + 4 files changed, 8 insertions(+), 72 deletions(-) + +diff --git a/block/blk-integrity.c b/block/blk-integrity.c +index 8868b1e01d58b..fbbb38cc9e8aa 100644 +--- a/block/blk-integrity.c ++++ b/block/blk-integrity.c +@@ -212,31 +212,6 @@ bool blk_integrity_merge_bio(struct request_queue *q, struct request *req, + return true; + } + +-static ssize_t integrity_attr_show(struct kobject *kobj, struct attribute *attr, +- char *page) +-{ +- struct gendisk *disk = container_of(kobj, struct gendisk, integrity_kobj); +- struct device *dev = disk_to_dev(disk); +- struct device_attribute *dev_attr = +- container_of(attr, struct device_attribute, attr); +- +- return dev_attr->show(dev, dev_attr, page); +-} +- +-static ssize_t integrity_attr_store(struct kobject *kobj, +- struct attribute *attr, const char *page, +- size_t count) +-{ +- struct gendisk *disk = container_of(kobj, struct gendisk, integrity_kobj); +- struct device *dev = disk_to_dev(disk); +- struct device_attribute *dev_attr = +- container_of(attr, struct device_attribute, attr); +- +- if (!dev_attr->store) +- return 0; +- return dev_attr->store(dev, dev_attr, page, count); +-} +- + static inline struct blk_integrity *dev_to_bi(struct device *dev) + { + return &dev_to_disk(dev)->queue->integrity; +@@ -345,16 +320,10 @@ static struct attribute *integrity_attrs[] = { + &dev_attr_device_is_integrity_capable.attr, + NULL + }; +-ATTRIBUTE_GROUPS(integrity); + +-static const struct sysfs_ops integrity_ops = { +- .show = &integrity_attr_show, +- .store = &integrity_attr_store, +-}; +- +-static struct kobj_type integrity_ktype = { +- .default_groups = integrity_groups, +- .sysfs_ops = &integrity_ops, ++const struct attribute_group blk_integrity_attr_group = { ++ .name = "integrity", ++ .attrs = integrity_attrs, + }; + + static blk_status_t blk_integrity_nop_fn(struct blk_integrity_iter *iter) +@@ -431,21 +400,3 @@ void blk_integrity_unregister(struct gendisk *disk) + memset(bi, 0, sizeof(*bi)); + } + EXPORT_SYMBOL(blk_integrity_unregister); +- +-int blk_integrity_add(struct gendisk *disk) +-{ +- int ret; +- +- ret = kobject_init_and_add(&disk->integrity_kobj, &integrity_ktype, +- &disk_to_dev(disk)->kobj, "%s", "integrity"); +- if (!ret) +- kobject_uevent(&disk->integrity_kobj, KOBJ_ADD); +- return ret; +-} +- +-void blk_integrity_del(struct gendisk *disk) +-{ +- kobject_uevent(&disk->integrity_kobj, KOBJ_REMOVE); +- kobject_del(&disk->integrity_kobj); +- kobject_put(&disk->integrity_kobj); +-} +diff --git a/block/blk.h b/block/blk.h +index aab72194d2266..e90a5e3485128 100644 +--- a/block/blk.h ++++ b/block/blk.h +@@ -130,8 +130,7 @@ static inline bool integrity_req_gap_front_merge(struct request *req, + bip_next->bip_vec[0].bv_offset); + } + +-int blk_integrity_add(struct gendisk *disk); +-void blk_integrity_del(struct gendisk *); ++extern const struct attribute_group blk_integrity_attr_group; + #else /* CONFIG_BLK_DEV_INTEGRITY */ + static inline bool blk_integrity_merge_rq(struct request_queue *rq, + struct request *r1, struct request *r2) +@@ -164,13 +163,6 @@ static inline bool bio_integrity_endio(struct bio *bio) + static inline void bio_integrity_free(struct bio *bio) + { + } +-static inline int blk_integrity_add(struct gendisk *disk) +-{ +- return 0; +-} +-static inline void blk_integrity_del(struct gendisk *disk) +-{ +-} + #endif /* CONFIG_BLK_DEV_INTEGRITY */ + + unsigned long blk_rq_timeout(unsigned long timeout); +diff --git a/block/genhd.c b/block/genhd.c +index 4d28f1d5f9b0e..88d1a6385a242 100644 +--- a/block/genhd.c ++++ b/block/genhd.c +@@ -467,15 +467,11 @@ int device_add_disk(struct device *parent, struct gendisk *disk, + */ + pm_runtime_set_memalloc_noio(ddev, true); + +- ret = blk_integrity_add(disk); +- if (ret) +- goto out_del_block_link; +- + disk->part0->bd_holder_dir = + kobject_create_and_add("holders", &ddev->kobj); + if (!disk->part0->bd_holder_dir) { + ret = -ENOMEM; +- goto out_del_integrity; ++ goto out_del_block_link; + } + disk->slave_dir = kobject_create_and_add("slaves", &ddev->kobj); + if (!disk->slave_dir) { +@@ -535,8 +531,6 @@ int device_add_disk(struct device *parent, struct gendisk *disk, + disk->slave_dir = NULL; + out_put_holder_dir: + kobject_put(disk->part0->bd_holder_dir); +-out_del_integrity: +- blk_integrity_del(disk); + out_del_block_link: + if (!sysfs_deprecated) + sysfs_remove_link(block_depr, dev_name(ddev)); +@@ -592,7 +586,6 @@ void del_gendisk(struct gendisk *disk) + if (WARN_ON_ONCE(!disk_live(disk) && !(disk->flags & GENHD_FL_HIDDEN))) + return; + +- blk_integrity_del(disk); + disk_del_events(disk); + + mutex_lock(&disk->open_mutex); +@@ -1084,6 +1077,9 @@ static struct attribute_group disk_attr_group = { + + static const struct attribute_group *disk_attr_groups[] = { + &disk_attr_group, ++#ifdef CONFIG_BLK_DEV_INTEGRITY ++ &blk_integrity_attr_group, ++#endif + NULL + }; + +diff --git a/include/linux/genhd.h b/include/linux/genhd.h +index 690b7f7996d15..3f49a3a30e9bc 100644 +--- a/include/linux/genhd.h ++++ b/include/linux/genhd.h +@@ -144,9 +144,6 @@ struct gendisk { + struct timer_rand_state *random; + atomic_t sync_io; /* RAID */ + struct disk_events *ev; +-#ifdef CONFIG_BLK_DEV_INTEGRITY +- struct kobject integrity_kobj; +-#endif /* CONFIG_BLK_DEV_INTEGRITY */ + #if IS_ENABLED(CONFIG_CDROM) + struct cdrom_device_info *cdi; + #endif +-- +2.43.0 + diff --git a/queue-5.15/blk-integrity-use-sysfs_emit.patch b/queue-5.15/blk-integrity-use-sysfs_emit.patch new file mode 100644 index 00000000000..46b7ef61458 --- /dev/null +++ b/queue-5.15/blk-integrity-use-sysfs_emit.patch @@ -0,0 +1,86 @@ +From 3cd299f155c478858a6554943fda495fc01e70c2 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 2 Oct 2024 11:01:20 -0300 +Subject: blk-integrity: use sysfs_emit +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Thomas Weißschuh + +Upstream commit 3315e169b446249c1b61ff988d157238f4b2c5a0. + +The correct way to emit data into sysfs is via sysfs_emit(), use it. + +Also perform some trivial syntactic cleanups. + +Signed-off-by: Thomas Weißschuh +Reviewed-by: Christoph Hellwig +Reviewed-by: Martin K. Petersen +Link: https://lore.kernel.org/r/20230309-kobj_release-gendisk_integrity-v3-1-ceccb4493c46@weissschuh.net +Signed-off-by: Jens Axboe +Signed-off-by: Thadeu Lima de Souza Cascardo +Signed-off-by: Sasha Levin +--- + block/blk-integrity.c | 19 +++++++++---------- + 1 file changed, 9 insertions(+), 10 deletions(-) + +diff --git a/block/blk-integrity.c b/block/blk-integrity.c +index 85edf6614b977..cbc77a2de0376 100644 +--- a/block/blk-integrity.c ++++ b/block/blk-integrity.c +@@ -248,20 +248,19 @@ static ssize_t integrity_attr_store(struct kobject *kobj, + static ssize_t integrity_format_show(struct blk_integrity *bi, char *page) + { + if (bi->profile && bi->profile->name) +- return sprintf(page, "%s\n", bi->profile->name); +- else +- return sprintf(page, "none\n"); ++ return sysfs_emit(page, "%s\n", bi->profile->name); ++ return sysfs_emit(page, "none\n"); + } + + static ssize_t integrity_tag_size_show(struct blk_integrity *bi, char *page) + { +- return sprintf(page, "%u\n", bi->tag_size); ++ return sysfs_emit(page, "%u\n", bi->tag_size); + } + + static ssize_t integrity_interval_show(struct blk_integrity *bi, char *page) + { +- return sprintf(page, "%u\n", +- bi->interval_exp ? 1 << bi->interval_exp : 0); ++ return sysfs_emit(page, "%u\n", ++ bi->interval_exp ? 1 << bi->interval_exp : 0); + } + + static ssize_t integrity_verify_store(struct blk_integrity *bi, +@@ -280,7 +279,7 @@ static ssize_t integrity_verify_store(struct blk_integrity *bi, + + static ssize_t integrity_verify_show(struct blk_integrity *bi, char *page) + { +- return sprintf(page, "%d\n", (bi->flags & BLK_INTEGRITY_VERIFY) != 0); ++ return sysfs_emit(page, "%d\n", !!(bi->flags & BLK_INTEGRITY_VERIFY)); + } + + static ssize_t integrity_generate_store(struct blk_integrity *bi, +@@ -299,13 +298,13 @@ static ssize_t integrity_generate_store(struct blk_integrity *bi, + + static ssize_t integrity_generate_show(struct blk_integrity *bi, char *page) + { +- return sprintf(page, "%d\n", (bi->flags & BLK_INTEGRITY_GENERATE) != 0); ++ return sysfs_emit(page, "%d\n", !!(bi->flags & BLK_INTEGRITY_GENERATE)); + } + + static ssize_t integrity_device_show(struct blk_integrity *bi, char *page) + { +- return sprintf(page, "%u\n", +- (bi->flags & BLK_INTEGRITY_DEVICE_CAPABLE) != 0); ++ return sysfs_emit(page, "%u\n", ++ !!(bi->flags & BLK_INTEGRITY_DEVICE_CAPABLE)); + } + + static struct integrity_sysfs_entry integrity_format_entry = { +-- +2.43.0 + diff --git a/queue-5.15/selftests-breakpoints-use-remaining-time-to-check-if.patch b/queue-5.15/selftests-breakpoints-use-remaining-time-to-check-if.patch new file mode 100644 index 00000000000..0a77fd4b827 --- /dev/null +++ b/queue-5.15/selftests-breakpoints-use-remaining-time-to-check-if.patch @@ -0,0 +1,87 @@ +From e318dbacbfe06bb904db3d9ee51595f31a07b3a6 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 30 Sep 2024 15:40:25 -0700 +Subject: selftests: breakpoints: use remaining time to check if suspend + succeed + +From: Yifei Liu + +[ Upstream commit c66be905cda24fb782b91053b196bd2e966f95b7 ] + +step_after_suspend_test fails with device busy error while +writing to /sys/power/state to start suspend. The test believes +it failed to enter suspend state with + +$ sudo ./step_after_suspend_test +TAP version 13 +Bail out! Failed to enter Suspend state + +However, in the kernel message, I indeed see the system get +suspended and then wake up later. + +[611172.033108] PM: suspend entry (s2idle) +[611172.044940] Filesystems sync: 0.006 seconds +[611172.052254] Freezing user space processes +[611172.059319] Freezing user space processes completed (elapsed 0.001 seconds) +[611172.067920] OOM killer disabled. +[611172.072465] Freezing remaining freezable tasks +[611172.080332] Freezing remaining freezable tasks completed (elapsed 0.001 seconds) +[611172.089724] printk: Suspending console(s) (use no_console_suspend to debug) +[611172.117126] serial 00:03: disabled +some other hardware get reconnected +[611203.136277] OOM killer enabled. +[611203.140637] Restarting tasks ... +[611203.141135] usb 1-8.1: USB disconnect, device number 7 +[611203.141755] done. +[611203.155268] random: crng reseeded on system resumption +[611203.162059] PM: suspend exit + +After investigation, I noticed that for the code block +if (write(power_state_fd, "mem", strlen("mem")) != strlen("mem")) + ksft_exit_fail_msg("Failed to enter Suspend state\n"); + +The write will return -1 and errno is set to 16 (device busy). +It should be caused by the write function is not successfully returned +before the system suspend and the return value get messed when waking up. +As a result, It may be better to check the time passed of those few +instructions to determine whether the suspend is executed correctly for +it is pretty hard to execute those few lines for 5 seconds. + +The timer to wake up the system is set to expire after 5 seconds and +no re-arm. If the timer remaining time is 0 second and 0 nano secomd, +it means the timer expired and wake the system up. Otherwise, the system +could be considered to enter the suspend state failed if there is any +remaining time. + +After appling this patch, the test would not fail for it believes the +system does not go to suspend by mistake. It now could continue to the +rest part of the test after suspend. + +Fixes: bfd092b8c272 ("selftests: breakpoint: add step_after_suspend_test") +Reported-by: Sinadin Shan +Signed-off-by: Yifei Liu +Signed-off-by: Shuah Khan +Signed-off-by: Sasha Levin +--- + .../testing/selftests/breakpoints/step_after_suspend_test.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/tools/testing/selftests/breakpoints/step_after_suspend_test.c b/tools/testing/selftests/breakpoints/step_after_suspend_test.c +index 2cf6f10ab7c4a..fc02918962c75 100644 +--- a/tools/testing/selftests/breakpoints/step_after_suspend_test.c ++++ b/tools/testing/selftests/breakpoints/step_after_suspend_test.c +@@ -153,7 +153,10 @@ void suspend(void) + if (err < 0) + ksft_exit_fail_msg("timerfd_settime() failed\n"); + +- if (write(power_state_fd, "mem", strlen("mem")) != strlen("mem")) ++ system("(echo mem > /sys/power/state) 2> /dev/null"); ++ ++ timerfd_gettime(timerfd, &spec); ++ if (spec.it_value.tv_sec != 0 || spec.it_value.tv_nsec != 0) + ksft_exit_fail_msg("Failed to enter Suspend state\n"); + + close(timerfd); +-- +2.43.0 + diff --git a/queue-5.15/selftests-mm-fix-charge_reserved_hugetlb.sh-test.patch b/queue-5.15/selftests-mm-fix-charge_reserved_hugetlb.sh-test.patch new file mode 100644 index 00000000000..90d0c25e017 --- /dev/null +++ b/queue-5.15/selftests-mm-fix-charge_reserved_hugetlb.sh-test.patch @@ -0,0 +1,123 @@ +From 83c37f3e46848701a3989fe73d1bcabe3c56ba2e Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 21 Aug 2024 14:31:15 +0200 +Subject: selftests/mm: fix charge_reserved_hugetlb.sh test + +From: David Hildenbrand + +[ Upstream commit c41a701d18efe6b8aa402efab16edbaba50c9548 ] + +Currently, running the charge_reserved_hugetlb.sh selftest we can +sometimes observe something like: + + $ ./charge_reserved_hugetlb.sh -cgroup-v2 + ... + write_result is 0 + After write: + hugetlb_usage=0 + reserved_usage=10485760 + killing write_to_hugetlbfs + Received 2. + Deleting the memory + Detach failure: Invalid argument + umount: /mnt/huge: target is busy. + +Both cases are issues in the test. + +While the unmount error seems to be racy, it will make the test fail: + $ ./run_vmtests.sh -t hugetlb + ... + # [FAIL] + not ok 10 charge_reserved_hugetlb.sh -cgroup-v2 # exit=32 + +The issue is that we are not waiting for the write_to_hugetlbfs process to +quit. So it might still have a hugetlbfs file open, about which umount is +not happy. Fix that by making "killall" wait for the process to quit. + +The other error ("Detach failure: Invalid argument") does not seem to +result in a test error, but is misleading. Turns out write_to_hugetlbfs.c +unconditionally tries to cleanup using shmdt(), even when we only +mmap()'ed a hugetlb file. Even worse, shmaddr is never even set for the +SHM case. Fix that as well. + +With this change it seems to work as expected. + +Link: https://lkml.kernel.org/r/20240821123115.2068812-1-david@redhat.com +Fixes: 29750f71a9b4 ("hugetlb_cgroup: add hugetlb_cgroup reservation tests") +Signed-off-by: David Hildenbrand +Reported-by: Mario Casquero +Reviewed-by: Mina Almasry +Tested-by: Mario Casquero +Cc: Shuah Khan +Cc: Muchun Song +Signed-off-by: Andrew Morton +Signed-off-by: Sasha Levin +--- + .../selftests/vm/charge_reserved_hugetlb.sh | 2 +- + .../testing/selftests/vm/write_to_hugetlbfs.c | 21 +++++++++++-------- + 2 files changed, 13 insertions(+), 10 deletions(-) + +diff --git a/tools/testing/selftests/vm/charge_reserved_hugetlb.sh b/tools/testing/selftests/vm/charge_reserved_hugetlb.sh +index e14bdd4455f2d..8e00276b4e69b 100644 +--- a/tools/testing/selftests/vm/charge_reserved_hugetlb.sh ++++ b/tools/testing/selftests/vm/charge_reserved_hugetlb.sh +@@ -252,7 +252,7 @@ function cleanup_hugetlb_memory() { + local cgroup="$1" + if [[ "$(pgrep -f write_to_hugetlbfs)" != "" ]]; then + echo killing write_to_hugetlbfs +- killall -2 write_to_hugetlbfs ++ killall -2 --wait write_to_hugetlbfs + wait_for_hugetlb_memory_to_get_depleted $cgroup + fi + set -e +diff --git a/tools/testing/selftests/vm/write_to_hugetlbfs.c b/tools/testing/selftests/vm/write_to_hugetlbfs.c +index 6a2caba19ee1d..1289d311efd70 100644 +--- a/tools/testing/selftests/vm/write_to_hugetlbfs.c ++++ b/tools/testing/selftests/vm/write_to_hugetlbfs.c +@@ -28,7 +28,7 @@ enum method { + + /* Global variables. */ + static const char *self; +-static char *shmaddr; ++static int *shmaddr; + static int shmid; + + /* +@@ -47,15 +47,17 @@ void sig_handler(int signo) + { + printf("Received %d.\n", signo); + if (signo == SIGINT) { +- printf("Deleting the memory\n"); +- if (shmdt((const void *)shmaddr) != 0) { +- perror("Detach failure"); ++ if (shmaddr) { ++ printf("Deleting the memory\n"); ++ if (shmdt((const void *)shmaddr) != 0) { ++ perror("Detach failure"); ++ shmctl(shmid, IPC_RMID, NULL); ++ exit(4); ++ } ++ + shmctl(shmid, IPC_RMID, NULL); +- exit(4); ++ printf("Done deleting the memory\n"); + } +- +- shmctl(shmid, IPC_RMID, NULL); +- printf("Done deleting the memory\n"); + } + exit(2); + } +@@ -211,7 +213,8 @@ int main(int argc, char **argv) + shmctl(shmid, IPC_RMID, NULL); + exit(2); + } +- printf("shmaddr: %p\n", ptr); ++ shmaddr = ptr; ++ printf("shmaddr: %p\n", shmaddr); + + break; + default: +-- +2.43.0 + diff --git a/queue-5.15/selftests-vdso-fix-elf-hash-table-entry-size-for-s39.patch b/queue-5.15/selftests-vdso-fix-elf-hash-table-entry-size-for-s39.patch new file mode 100644 index 00000000000..5f4691d831f --- /dev/null +++ b/queue-5.15/selftests-vdso-fix-elf-hash-table-entry-size-for-s39.patch @@ -0,0 +1,78 @@ +From 0009406cd64b5ac4a7172a7296510fe37e50fdf0 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 11 Sep 2024 10:50:14 +0200 +Subject: selftests: vDSO: fix ELF hash table entry size for s390x + +From: Jens Remus + +[ Upstream commit 14be4e6f35221c4731b004553ecf7cbc6dc1d2d8 ] + +The vDSO self tests fail on s390x for a vDSO linked with the GNU linker +ld as follows: + + # ./vdso_test_gettimeofday + Floating point exception (core dumped) + +On s390x the ELF hash table entries are 64 bits instead of 32 bits in +size (see Glibc sysdeps/unix/sysv/linux/s390/bits/elfclass.h). + +Fixes: 40723419f407 ("kselftest: Enable vDSO test on non x86 platforms") +Reported-by: Heiko Carstens +Tested-by: Heiko Carstens +Signed-off-by: Jens Remus +Signed-off-by: Heiko Carstens +Signed-off-by: Jason A. Donenfeld +Signed-off-by: Sasha Levin +--- + tools/testing/selftests/vDSO/parse_vdso.c | 14 ++++++++++---- + 1 file changed, 10 insertions(+), 4 deletions(-) + +diff --git a/tools/testing/selftests/vDSO/parse_vdso.c b/tools/testing/selftests/vDSO/parse_vdso.c +index d9ccc5acac182..7dd5668ea8a6e 100644 +--- a/tools/testing/selftests/vDSO/parse_vdso.c ++++ b/tools/testing/selftests/vDSO/parse_vdso.c +@@ -36,6 +36,12 @@ + #define ELF_BITS_XFORM(bits, x) ELF_BITS_XFORM2(bits, x) + #define ELF(x) ELF_BITS_XFORM(ELF_BITS, x) + ++#ifdef __s390x__ ++#define ELF_HASH_ENTRY ELF(Xword) ++#else ++#define ELF_HASH_ENTRY ELF(Word) ++#endif ++ + static struct vdso_info + { + bool valid; +@@ -47,8 +53,8 @@ static struct vdso_info + /* Symbol table */ + ELF(Sym) *symtab; + const char *symstrings; +- ELF(Word) *bucket, *chain; +- ELF(Word) nbucket, nchain; ++ ELF_HASH_ENTRY *bucket, *chain; ++ ELF_HASH_ENTRY nbucket, nchain; + + /* Version table */ + ELF(Versym) *versym; +@@ -115,7 +121,7 @@ void vdso_init_from_sysinfo_ehdr(uintptr_t base) + /* + * Fish out the useful bits of the dynamic table. + */ +- ELF(Word) *hash = 0; ++ ELF_HASH_ENTRY *hash = 0; + vdso_info.symstrings = 0; + vdso_info.symtab = 0; + vdso_info.versym = 0; +@@ -133,7 +139,7 @@ void vdso_init_from_sysinfo_ehdr(uintptr_t base) + + vdso_info.load_offset); + break; + case DT_HASH: +- hash = (ELF(Word) *) ++ hash = (ELF_HASH_ENTRY *) + ((uintptr_t)dyn[i].d_un.d_ptr + + vdso_info.load_offset); + break; +-- +2.43.0 + diff --git a/queue-5.15/selftests-vdso-fix-vdso-name-for-powerpc.patch b/queue-5.15/selftests-vdso-fix-vdso-name-for-powerpc.patch new file mode 100644 index 00000000000..f3d2528e796 --- /dev/null +++ b/queue-5.15/selftests-vdso-fix-vdso-name-for-powerpc.patch @@ -0,0 +1,52 @@ +From 31111d59079dc8538867465d96f6dc60dd732c2b Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 30 Aug 2024 14:28:35 +0200 +Subject: selftests: vDSO: fix vDSO name for powerpc + +From: Christophe Leroy + +[ Upstream commit 59eb856c3ed9b3552befd240c0c339f22eed3fa1 ] + +Following error occurs when running vdso_test_correctness on powerpc: + +~ # ./vdso_test_correctness +[WARN] failed to find vDSO +[SKIP] No vDSO, so skipping clock_gettime() tests +[SKIP] No vDSO, so skipping clock_gettime64() tests +[RUN] Testing getcpu... +[OK] CPU 0: syscall: cpu 0, node 0 + +On powerpc, vDSO is neither called linux-vdso.so.1 nor linux-gate.so.1 +but linux-vdso32.so.1 or linux-vdso64.so.1. + +Also search those two names before giving up. + +Fixes: c7e5789b24d3 ("kselftest: Move test_vdso to the vDSO test suite") +Signed-off-by: Christophe Leroy +Acked-by: Shuah Khan +Signed-off-by: Jason A. Donenfeld +Signed-off-by: Sasha Levin +--- + tools/testing/selftests/vDSO/vdso_test_correctness.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/tools/testing/selftests/vDSO/vdso_test_correctness.c b/tools/testing/selftests/vDSO/vdso_test_correctness.c +index c4aea794725a7..739cd83f3dfb7 100644 +--- a/tools/testing/selftests/vDSO/vdso_test_correctness.c ++++ b/tools/testing/selftests/vDSO/vdso_test_correctness.c +@@ -113,6 +113,12 @@ static void fill_function_pointers() + if (!vdso) + vdso = dlopen("linux-gate.so.1", + RTLD_LAZY | RTLD_LOCAL | RTLD_NOLOAD); ++ if (!vdso) ++ vdso = dlopen("linux-vdso32.so.1", ++ RTLD_LAZY | RTLD_LOCAL | RTLD_NOLOAD); ++ if (!vdso) ++ vdso = dlopen("linux-vdso64.so.1", ++ RTLD_LAZY | RTLD_LOCAL | RTLD_NOLOAD); + if (!vdso) { + printf("[WARN]\tfailed to find vDSO\n"); + return; +-- +2.43.0 + diff --git a/queue-5.15/selftests-vdso-fix-vdso-symbols-lookup-for-powerpc64.patch b/queue-5.15/selftests-vdso-fix-vdso-symbols-lookup-for-powerpc64.patch new file mode 100644 index 00000000000..8396456a345 --- /dev/null +++ b/queue-5.15/selftests-vdso-fix-vdso-symbols-lookup-for-powerpc64.patch @@ -0,0 +1,108 @@ +From 58d6db7e85603f18c3465a73402bddbf97987428 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 30 Aug 2024 14:28:37 +0200 +Subject: selftests: vDSO: fix vDSO symbols lookup for powerpc64 + +From: Christophe Leroy + +[ Upstream commit ba83b3239e657469709d15dcea5f9b65bf9dbf34 ] + +On powerpc64, following tests fail locating vDSO functions: + + ~ # ./vdso_test_abi + TAP version 13 + 1..16 + # [vDSO kselftest] VDSO_VERSION: LINUX_2.6.15 + # Couldn't find __kernel_gettimeofday + ok 1 # SKIP __kernel_gettimeofday + # clock_id: CLOCK_REALTIME + # Couldn't find __kernel_clock_gettime + ok 2 # SKIP __kernel_clock_gettime CLOCK_REALTIME + # Couldn't find __kernel_clock_getres + ok 3 # SKIP __kernel_clock_getres CLOCK_REALTIME + ... + # Couldn't find __kernel_time + ok 16 # SKIP __kernel_time + # Totals: pass:0 fail:0 xfail:0 xpass:0 skip:16 error:0 + + ~ # ./vdso_test_getrandom + __kernel_getrandom is missing! + + ~ # ./vdso_test_gettimeofday + Could not find __kernel_gettimeofday + + ~ # ./vdso_test_getcpu + Could not find __kernel_getcpu + +On powerpc64, as shown below by readelf, vDSO functions symbols have +type NOTYPE, so also accept that type when looking for symbols. + +$ powerpc64-linux-gnu-readelf -a arch/powerpc/kernel/vdso/vdso64.so.dbg +ELF Header: + Magic: 7f 45 4c 46 02 02 01 00 00 00 00 00 00 00 00 00 + Class: ELF64 + Data: 2's complement, big endian + Version: 1 (current) + OS/ABI: UNIX - System V + ABI Version: 0 + Type: DYN (Shared object file) + Machine: PowerPC64 + Version: 0x1 +... + +Symbol table '.dynsym' contains 12 entries: + Num: Value Size Type Bind Vis Ndx Name + 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND + 1: 0000000000000524 84 NOTYPE GLOBAL DEFAULT 8 __[...]@@LINUX_2.6.15 + 2: 00000000000005f0 36 NOTYPE GLOBAL DEFAULT 8 __[...]@@LINUX_2.6.15 + 3: 0000000000000578 68 NOTYPE GLOBAL DEFAULT 8 __[...]@@LINUX_2.6.15 + 4: 0000000000000000 0 OBJECT GLOBAL DEFAULT ABS LINUX_2.6.15 + 5: 00000000000006c0 48 NOTYPE GLOBAL DEFAULT 8 __[...]@@LINUX_2.6.15 + 6: 0000000000000614 172 NOTYPE GLOBAL DEFAULT 8 __[...]@@LINUX_2.6.15 + 7: 00000000000006f0 84 NOTYPE GLOBAL DEFAULT 8 __[...]@@LINUX_2.6.15 + 8: 000000000000047c 84 NOTYPE GLOBAL DEFAULT 8 __[...]@@LINUX_2.6.15 + 9: 0000000000000454 12 NOTYPE GLOBAL DEFAULT 8 __[...]@@LINUX_2.6.15 + 10: 00000000000004d0 84 NOTYPE GLOBAL DEFAULT 8 __[...]@@LINUX_2.6.15 + 11: 00000000000005bc 52 NOTYPE GLOBAL DEFAULT 8 __[...]@@LINUX_2.6.15 + +Symbol table '.symtab' contains 56 entries: + Num: Value Size Type Bind Vis Ndx Name +... + 45: 0000000000000000 0 OBJECT GLOBAL DEFAULT ABS LINUX_2.6.15 + 46: 00000000000006c0 48 NOTYPE GLOBAL DEFAULT 8 __kernel_getcpu + 47: 0000000000000524 84 NOTYPE GLOBAL DEFAULT 8 __kernel_clock_getres + 48: 00000000000005f0 36 NOTYPE GLOBAL DEFAULT 8 __kernel_get_tbfreq + 49: 000000000000047c 84 NOTYPE GLOBAL DEFAULT 8 __kernel_gettimeofday + 50: 0000000000000614 172 NOTYPE GLOBAL DEFAULT 8 __kernel_sync_dicache + 51: 00000000000006f0 84 NOTYPE GLOBAL DEFAULT 8 __kernel_getrandom + 52: 0000000000000454 12 NOTYPE GLOBAL DEFAULT 8 __kernel_sigtram[...] + 53: 0000000000000578 68 NOTYPE GLOBAL DEFAULT 8 __kernel_time + 54: 00000000000004d0 84 NOTYPE GLOBAL DEFAULT 8 __kernel_clock_g[...] + 55: 00000000000005bc 52 NOTYPE GLOBAL DEFAULT 8 __kernel_get_sys[...] + +Fixes: 98eedc3a9dbf ("Document the vDSO and add a reference parser") +Signed-off-by: Christophe Leroy +Acked-by: Shuah Khan +Signed-off-by: Jason A. Donenfeld +Signed-off-by: Sasha Levin +--- + tools/testing/selftests/vDSO/parse_vdso.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/tools/testing/selftests/vDSO/parse_vdso.c b/tools/testing/selftests/vDSO/parse_vdso.c +index 4ae417372e9eb..d9ccc5acac182 100644 +--- a/tools/testing/selftests/vDSO/parse_vdso.c ++++ b/tools/testing/selftests/vDSO/parse_vdso.c +@@ -216,7 +216,8 @@ void *vdso_sym(const char *version, const char *name) + ELF(Sym) *sym = &vdso_info.symtab[chain]; + + /* Check for a defined global or weak function w/ right name. */ +- if (ELF64_ST_TYPE(sym->st_info) != STT_FUNC) ++ if (ELF64_ST_TYPE(sym->st_info) != STT_FUNC && ++ ELF64_ST_TYPE(sym->st_info) != STT_NOTYPE) + continue; + if (ELF64_ST_BIND(sym->st_info) != STB_GLOBAL && + ELF64_ST_BIND(sym->st_info) != STB_WEAK) +-- +2.43.0 + diff --git a/queue-5.15/selftests-vdso-fix-vdso_config-for-powerpc.patch b/queue-5.15/selftests-vdso-fix-vdso_config-for-powerpc.patch new file mode 100644 index 00000000000..97552c87d0d --- /dev/null +++ b/queue-5.15/selftests-vdso-fix-vdso_config-for-powerpc.patch @@ -0,0 +1,52 @@ +From 86f576c25b7de1fc51d5db0695a960b7c6705801 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 30 Aug 2024 14:28:36 +0200 +Subject: selftests: vDSO: fix vdso_config for powerpc + +From: Christophe Leroy + +[ Upstream commit 7d297c419b08eafa69ce27243ee9bbecab4fcaa4 ] + +Running vdso_test_correctness on powerpc64 gives the following warning: + + ~ # ./vdso_test_correctness + Warning: failed to find clock_gettime64 in vDSO + +This is because vdso_test_correctness was built with VDSO_32BIT defined. + +__powerpc__ macro is defined on both powerpc32 and powerpc64 so +__powerpc64__ needs to be checked first in vdso_config.h + +Fixes: 693f5ca08ca0 ("kselftest: Extend vDSO selftest") +Signed-off-by: Christophe Leroy +Acked-by: Shuah Khan +Signed-off-by: Jason A. Donenfeld +Signed-off-by: Sasha Levin +--- + tools/testing/selftests/vDSO/vdso_config.h | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/tools/testing/selftests/vDSO/vdso_config.h b/tools/testing/selftests/vDSO/vdso_config.h +index 6188b16827d1d..446eb9737273b 100644 +--- a/tools/testing/selftests/vDSO/vdso_config.h ++++ b/tools/testing/selftests/vDSO/vdso_config.h +@@ -18,13 +18,13 @@ + #elif defined(__aarch64__) + #define VDSO_VERSION 3 + #define VDSO_NAMES 0 +-#elif defined(__powerpc__) ++#elif defined(__powerpc64__) + #define VDSO_VERSION 1 + #define VDSO_NAMES 0 +-#define VDSO_32BIT 1 +-#elif defined(__powerpc64__) ++#elif defined(__powerpc__) + #define VDSO_VERSION 1 + #define VDSO_NAMES 0 ++#define VDSO_32BIT 1 + #elif defined (__s390__) + #define VDSO_VERSION 2 + #define VDSO_NAMES 0 +-- +2.43.0 + diff --git a/queue-5.15/selftests-vdso-fix-vdso_config-for-s390.patch b/queue-5.15/selftests-vdso-fix-vdso_config-for-s390.patch new file mode 100644 index 00000000000..643191213c1 --- /dev/null +++ b/queue-5.15/selftests-vdso-fix-vdso_config-for-s390.patch @@ -0,0 +1,51 @@ +From 14d4d9fa4f7ff3e654c0fb22aee69d7f0066fe07 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 11 Sep 2024 10:50:15 +0200 +Subject: selftests: vDSO: fix vdso_config for s390 + +From: Heiko Carstens + +[ Upstream commit a6e23fb8d3c0e3904da70beaf5d7e840a983c97f ] + +Running vdso_test_correctness on s390x (aka s390 64 bit) emits a warning: + +Warning: failed to find clock_gettime64 in vDSO + +This is caused by the "#elif defined (__s390__)" check in vdso_config.h +which the defines VDSO_32BIT. + +If __s390x__ is defined also __s390__ is defined. Therefore the correct +check must make sure that only __s390__ is defined. + +Therefore add the missing !defined(__s390x__). Also use common +__s390x__ define instead of __s390X__. + +Signed-off-by: Heiko Carstens +Fixes: 693f5ca08ca0 ("kselftest: Extend vDSO selftest") +Signed-off-by: Jason A. Donenfeld +Signed-off-by: Sasha Levin +--- + tools/testing/selftests/vDSO/vdso_config.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/tools/testing/selftests/vDSO/vdso_config.h b/tools/testing/selftests/vDSO/vdso_config.h +index 446eb9737273b..a6868ca0e4f89 100644 +--- a/tools/testing/selftests/vDSO/vdso_config.h ++++ b/tools/testing/selftests/vDSO/vdso_config.h +@@ -25,11 +25,11 @@ + #define VDSO_VERSION 1 + #define VDSO_NAMES 0 + #define VDSO_32BIT 1 +-#elif defined (__s390__) ++#elif defined (__s390__) && !defined(__s390x__) + #define VDSO_VERSION 2 + #define VDSO_NAMES 0 + #define VDSO_32BIT 1 +-#elif defined (__s390X__) ++#elif defined (__s390x__) + #define VDSO_VERSION 2 + #define VDSO_NAMES 0 + #elif defined(__mips__) +-- +2.43.0 + diff --git a/queue-5.15/series b/queue-5.15/series index 502bd6859e1..6182103d531 100644 --- a/queue-5.15/series +++ b/queue-5.15/series @@ -462,3 +462,16 @@ ext4-don-t-set-sb_rdonly-after-filesystem-errors.patch ext4-ext4_search_dir-should-return-a-proper-error.patch ext4-avoid-use-after-free-in-ext4_ext_show_leaf.patch ext4-fix-i_data_sem-unlock-order-in-ext4_ind_migrate.patch +blk-integrity-use-sysfs_emit.patch +blk-integrity-convert-to-struct-device_attribute.patch +blk-integrity-register-sysfs-attributes-on-struct-de.patch +usb-typec-tcpm-check-for-port-partner-validity-befor.patch +spi-spi-imx-fix-pm_runtime_set_suspended-with-runtim.patch +spi-s3c64xx-fix-timeout-counters-in-flush_fifo.patch +selftests-breakpoints-use-remaining-time-to-check-if.patch +selftests-vdso-fix-vdso-name-for-powerpc.patch +selftests-vdso-fix-vdso_config-for-powerpc.patch +selftests-vdso-fix-vdso-symbols-lookup-for-powerpc64.patch +selftests-mm-fix-charge_reserved_hugetlb.sh-test.patch +selftests-vdso-fix-elf-hash-table-entry-size-for-s39.patch +selftests-vdso-fix-vdso_config-for-s390.patch diff --git a/queue-5.15/spi-s3c64xx-fix-timeout-counters-in-flush_fifo.patch b/queue-5.15/spi-s3c64xx-fix-timeout-counters-in-flush_fifo.patch new file mode 100644 index 00000000000..1c12dd45edf --- /dev/null +++ b/queue-5.15/spi-s3c64xx-fix-timeout-counters-in-flush_fifo.patch @@ -0,0 +1,49 @@ +From 5aa371e0ce18f8b20d8cbb020bff5c036bc2c990 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 24 Sep 2024 14:40:08 +0100 +Subject: spi: s3c64xx: fix timeout counters in flush_fifo + +From: Ben Dooks + +[ Upstream commit 68a16708d2503b6303d67abd43801e2ca40c208d ] + +In the s3c64xx_flush_fifo() code, the loops counter is post-decremented +in the do { } while(test && loops--) condition. This means the loops is +left at the unsigned equivalent of -1 if the loop times out. The test +after will never pass as if tests for loops == 0. + +Signed-off-by: Ben Dooks +Fixes: 230d42d422e7 ("spi: Add s3c64xx SPI Controller driver") +Reviewed-by: Andi Shyti +Link: https://patch.msgid.link/20240924134009.116247-2-ben.dooks@codethink.co.uk +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +--- + drivers/spi/spi-s3c64xx.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c +index 90c70d53e85e2..246a40b492757 100644 +--- a/drivers/spi/spi-s3c64xx.c ++++ b/drivers/spi/spi-s3c64xx.c +@@ -216,7 +216,7 @@ static void s3c64xx_flush_fifo(struct s3c64xx_spi_driver_data *sdd) + loops = msecs_to_loops(1); + do { + val = readl(regs + S3C64XX_SPI_STATUS); +- } while (TX_FIFO_LVL(val, sdd) && loops--); ++ } while (TX_FIFO_LVL(val, sdd) && --loops); + + if (loops == 0) + dev_warn(&sdd->pdev->dev, "Timed out flushing TX FIFO\n"); +@@ -229,7 +229,7 @@ static void s3c64xx_flush_fifo(struct s3c64xx_spi_driver_data *sdd) + readl(regs + S3C64XX_SPI_RX_DATA); + else + break; +- } while (loops--); ++ } while (--loops); + + if (loops == 0) + dev_warn(&sdd->pdev->dev, "Timed out flushing RX FIFO\n"); +-- +2.43.0 + diff --git a/queue-5.15/spi-spi-imx-fix-pm_runtime_set_suspended-with-runtim.patch b/queue-5.15/spi-spi-imx-fix-pm_runtime_set_suspended-with-runtim.patch new file mode 100644 index 00000000000..02fd4e5eb46 --- /dev/null +++ b/queue-5.15/spi-spi-imx-fix-pm_runtime_set_suspended-with-runtim.patch @@ -0,0 +1,39 @@ +From 8a6f4338fb61b91dc82d0bf5b64c488412baf08f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 23 Sep 2024 12:00:13 +0800 +Subject: spi: spi-imx: Fix pm_runtime_set_suspended() with runtime pm enabled + +From: Jinjie Ruan + +[ Upstream commit b6e05ba0844139dde138625906015c974c86aa93 ] + +It is not valid to call pm_runtime_set_suspended() for devices +with runtime PM enabled because it returns -EAGAIN if it is enabled +already and working. So, call pm_runtime_disable() before to fix it. + +Fixes: 43b6bf406cd0 ("spi: imx: fix runtime pm support for !CONFIG_PM") +Signed-off-by: Jinjie Ruan +Link: https://patch.msgid.link/20240923040015.3009329-2-ruanjinjie@huawei.com +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +--- + drivers/spi/spi-imx.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c +index c806ee8070e5a..f22b867b8c8a9 100644 +--- a/drivers/spi/spi-imx.c ++++ b/drivers/spi/spi-imx.c +@@ -1761,8 +1761,8 @@ static int spi_imx_probe(struct platform_device *pdev) + spi_imx_sdma_exit(spi_imx); + out_runtime_pm_put: + pm_runtime_dont_use_autosuspend(spi_imx->dev); +- pm_runtime_set_suspended(&pdev->dev); + pm_runtime_disable(spi_imx->dev); ++ pm_runtime_set_suspended(&pdev->dev); + + clk_disable_unprepare(spi_imx->clk_ipg); + out_put_per: +-- +2.43.0 + diff --git a/queue-5.15/usb-typec-tcpm-check-for-port-partner-validity-befor.patch b/queue-5.15/usb-typec-tcpm-check-for-port-partner-validity-befor.patch new file mode 100644 index 00000000000..bf3198b4be4 --- /dev/null +++ b/queue-5.15/usb-typec-tcpm-check-for-port-partner-validity-befor.patch @@ -0,0 +1,123 @@ +From 5bb75c403def5c2f4334d941ee793ec90458adfa Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 3 Oct 2024 09:43:39 -0700 +Subject: usb: typec: tcpm: Check for port partner validity before consuming it + +From: Badhri Jagan Sridharan + +commit ae11f04b452b5205536e1c02d31f8045eba249dd upstream. + +typec_register_partner() does not guarantee partner registration +to always succeed. In the event of failure, port->partner is set +to the error value or NULL. Given that port->partner validity is +not checked, this results in the following crash: + +Unable to handle kernel NULL pointer dereference at virtual address xx + pc : run_state_machine+0x1bc8/0x1c08 + lr : run_state_machine+0x1b90/0x1c08 +.. + Call trace: + run_state_machine+0x1bc8/0x1c08 + tcpm_state_machine_work+0x94/0xe4 + kthread_worker_fn+0x118/0x328 + kthread+0x1d0/0x23c + ret_from_fork+0x10/0x20 + +To prevent the crash, check for port->partner validity before +derefencing it in all the call sites. + +Cc: stable@vger.kernel.org +Fixes: c97cd0b4b54e ("usb: typec: tcpm: set initial svdm version based on pd revision") +Signed-off-by: Badhri Jagan Sridharan +Reviewed-by: Heikki Krogerus +Reviewed-by: Dmitry Baryshkov +Link: https://lore.kernel.org/r/20240427202812.3435268-1-badhri@google.com +Signed-off-by: Greg Kroah-Hartman +[Sherry: bp to 5.15.y, minor conflicts due to missing commit: + 8203d26905ee ("usb: typec: tcpm: Register USB Power Delivery +Capabilities"). Ignore the the part +typec_partner_set_usb_power_delivery() which is not in 5.15.y.] +Signed-off-by: Sherry Yang +Signed-off-by: Sasha Levin +--- + drivers/usb/typec/tcpm/tcpm.c | 28 ++++++++++++++++++++++------ + 1 file changed, 22 insertions(+), 6 deletions(-) + +diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c +index 5a5886cb0c002..2104bb6e61f59 100644 +--- a/drivers/usb/typec/tcpm/tcpm.c ++++ b/drivers/usb/typec/tcpm/tcpm.c +@@ -1471,7 +1471,8 @@ static void svdm_consume_identity(struct tcpm_port *port, const u32 *p, int cnt) + port->partner_ident.cert_stat = p[VDO_INDEX_CSTAT]; + port->partner_ident.product = product; + +- typec_partner_set_identity(port->partner); ++ if (port->partner) ++ typec_partner_set_identity(port->partner); + + tcpm_log(port, "Identity: %04x:%04x.%04x", + PD_IDH_VID(vdo), +@@ -1559,6 +1560,9 @@ static void tcpm_register_partner_altmodes(struct tcpm_port *port) + struct typec_altmode *altmode; + int i; + ++ if (!port->partner) ++ return; ++ + for (i = 0; i < modep->altmodes; i++) { + altmode = typec_partner_register_altmode(port->partner, + &modep->altmode_desc[i]); +@@ -3577,7 +3581,10 @@ static int tcpm_init_vconn(struct tcpm_port *port) + + static void tcpm_typec_connect(struct tcpm_port *port) + { ++ struct typec_partner *partner; ++ + if (!port->connected) { ++ port->connected = true; + /* Make sure we don't report stale identity information */ + memset(&port->partner_ident, 0, sizeof(port->partner_ident)); + port->partner_desc.usb_pd = port->pd_capable; +@@ -3587,9 +3594,13 @@ static void tcpm_typec_connect(struct tcpm_port *port) + port->partner_desc.accessory = TYPEC_ACCESSORY_AUDIO; + else + port->partner_desc.accessory = TYPEC_ACCESSORY_NONE; +- port->partner = typec_register_partner(port->typec_port, +- &port->partner_desc); +- port->connected = true; ++ partner = typec_register_partner(port->typec_port, &port->partner_desc); ++ if (IS_ERR(partner)) { ++ dev_err(port->dev, "Failed to register partner (%ld)\n", PTR_ERR(partner)); ++ return; ++ } ++ ++ port->partner = partner; + } + } + +@@ -3658,8 +3669,10 @@ static int tcpm_src_attach(struct tcpm_port *port) + static void tcpm_typec_disconnect(struct tcpm_port *port) + { + if (port->connected) { +- typec_unregister_partner(port->partner); +- port->partner = NULL; ++ if (port->partner) { ++ typec_unregister_partner(port->partner); ++ port->partner = NULL; ++ } + port->connected = false; + } + } +@@ -3868,6 +3881,9 @@ static enum typec_cc_status tcpm_pwr_opmode_to_rp(enum typec_pwr_opmode opmode) + + static void tcpm_set_initial_svdm_version(struct tcpm_port *port) + { ++ if (!port->partner) ++ return; ++ + switch (port->negotiated_rev) { + case PD_REV30: + break; +-- +2.43.0 +