From e50352257c83de5ee4cfc0bb0970c362b1e32f17 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Fri, 4 Feb 2022 10:44:55 +0100 Subject: [PATCH] Synchronize kernel patches with upstream This change updates the kernel patches with the patches used by Proxmox. Furthermore, we split the patches from Proxmox and Ubuntu, so that we don't have to re-order them. --- ...sce-host-bridge-contiguous-apertures.patch | 104 +++++++++++++ ...I-Coalesce-host-bridge-contiguous-ap.patch | 112 +++++++++++++ ...ate-split-BTF-type-info-per-default.patch} | 0 ...group-always-terminate-io.stat-lines.patch | 147 ++++++++++++++++++ debian/patches/series.linux | 14 +- ...parmor-compatibility-v2.x-net-rules.patch} | 0 .../0002-apparmor-af_unix-mediation.patch} | 0 ...diating-locking-non-fs-unix-sockets.patch} | 0 ...fix-use-after-free-in-sk_peer_label.patch} | 0 9 files changed, 372 insertions(+), 5 deletions(-) create mode 100644 debian/patches/pve/0006-Revert-PCI-Coalesce-host-bridge-contiguous-apertures.patch create mode 100644 debian/patches/pve/0007-PCI-Reinstate-PCI-Coalesce-host-bridge-contiguous-ap.patch rename debian/patches/pve/{0006-disable-split-btf.patch => 0008-do-not-generate-split-BTF-type-info-per-default.patch} (100%) create mode 100644 debian/patches/pve/0009-blk-cgroup-always-terminate-io.stat-lines.patch rename debian/patches/{pve/0007-apparmor-compatibility-v2.x-net-rules.patch => ubuntu/0001-apparmor-compatibility-v2.x-net-rules.patch} (100%) rename debian/patches/{pve/0008-apparmor-af_unix-mediation.patch => ubuntu/0002-apparmor-af_unix-mediation.patch} (100%) rename debian/patches/{pve/0009-apparmor-fix-apparmor-mediating-locking-non-fs-unix-sockets.patch => ubuntu/0003-apparmor-fix-apparmor-mediating-locking-non-fs-unix-sockets.patch} (100%) rename debian/patches/{pve/0010-apparmor-fix-use-after-free-in-sk_peer_label.patch => ubuntu/0004-apparmor-fix-use-after-free-in-sk_peer_label.patch} (100%) diff --git a/debian/patches/pve/0006-Revert-PCI-Coalesce-host-bridge-contiguous-apertures.patch b/debian/patches/pve/0006-Revert-PCI-Coalesce-host-bridge-contiguous-apertures.patch new file mode 100644 index 0000000..d38d1a9 --- /dev/null +++ b/debian/patches/pve/0006-Revert-PCI-Coalesce-host-bridge-contiguous-apertures.patch @@ -0,0 +1,104 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Thomas Lamprecht +Date: Mon, 27 Sep 2021 11:28:39 +0200 +Subject: [PATCH] Revert "PCI: Coalesce host bridge contiguous apertures" +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This reverts commit ab20e43b20b60f5cc8e2ea3763ffa388158469ac. + +was reverted upstream because of reports similar to + +Link: https://bugzilla.proxmox.com/show_bug.cgi?id=3552 +Link: https://lore.kernel.org/r/20210709231529.GA3270116@roeck-us.net +Signed-off-by: Fabian Grünbichler +Signed-off-by: Thomas Lamprecht +--- + drivers/pci/probe.c | 50 ++++----------------------------------------- + 1 file changed, 4 insertions(+), 46 deletions(-) + +diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c +index cb70d2605e97..258350f80f6c 100644 +--- a/drivers/pci/probe.c ++++ b/drivers/pci/probe.c +@@ -20,7 +20,6 @@ + #include + #include + #include +-#include + #include "pci.h" + + #define CARDBUS_LATENCY_TIMER 176 /* secondary latency timer */ +@@ -881,31 +880,14 @@ static void pci_set_bus_msi_domain(struct pci_bus *bus) + dev_set_msi_domain(&bus->dev, d); + } + +-static int res_cmp(void *priv, const struct list_head *a, +- const struct list_head *b) +-{ +- struct resource_entry *entry1, *entry2; +- +- entry1 = container_of(a, struct resource_entry, node); +- entry2 = container_of(b, struct resource_entry, node); +- +- if (entry1->res->flags != entry2->res->flags) +- return entry1->res->flags > entry2->res->flags; +- +- if (entry1->offset != entry2->offset) +- return entry1->offset > entry2->offset; +- +- return entry1->res->start > entry2->res->start; +-} +- + static int pci_register_host_bridge(struct pci_host_bridge *bridge) + { + struct device *parent = bridge->dev.parent; +- struct resource_entry *window, *next, *n; ++ struct resource_entry *window, *n; + struct pci_bus *bus, *b; +- resource_size_t offset, next_offset; ++ resource_size_t offset; + LIST_HEAD(resources); +- struct resource *res, *next_res; ++ struct resource *res; + char addr[64], *fmt; + const char *name; + int err; +@@ -988,35 +970,11 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge) + if (nr_node_ids > 1 && pcibus_to_node(bus) == NUMA_NO_NODE) + dev_warn(&bus->dev, "Unknown NUMA node; performance will be reduced\n"); + +- /* Sort and coalesce contiguous windows */ +- list_sort(NULL, &resources, res_cmp); +- resource_list_for_each_entry_safe(window, n, &resources) { +- if (list_is_last(&window->node, &resources)) +- break; +- +- next = list_next_entry(window, node); +- offset = window->offset; +- res = window->res; +- next_offset = next->offset; +- next_res = next->res; +- +- if (res->flags != next_res->flags || offset != next_offset) +- continue; +- +- if (res->end + 1 == next_res->start) { +- next_res->start = res->start; +- res->flags = res->start = res->end = 0; +- } +- } +- + /* Add initial resources to the bus */ + resource_list_for_each_entry_safe(window, n, &resources) { ++ list_move_tail(&window->node, &bridge->windows); + offset = window->offset; + res = window->res; +- if (!res->end) +- continue; +- +- list_move_tail(&window->node, &bridge->windows); + + if (res->flags & IORESOURCE_BUS) + pci_bus_insert_busn_res(bus, bus->number, res->end); \ No newline at end of file diff --git a/debian/patches/pve/0007-PCI-Reinstate-PCI-Coalesce-host-bridge-contiguous-ap.patch b/debian/patches/pve/0007-PCI-Reinstate-PCI-Coalesce-host-bridge-contiguous-ap.patch new file mode 100644 index 0000000..c46b719 --- /dev/null +++ b/debian/patches/pve/0007-PCI-Reinstate-PCI-Coalesce-host-bridge-contiguous-ap.patch @@ -0,0 +1,112 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Kai-Heng Feng +Date: Tue, 13 Jul 2021 20:50:07 +0800 +Subject: [PATCH] PCI: Reinstate "PCI: Coalesce host bridge contiguous + apertures" +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Built-in graphics on HP EliteDesk 805 G6 doesn't work because graphics +can't get the BAR it needs: + pci_bus 0000:00: root bus resource [mem 0x10020200000-0x100303fffff window] + pci_bus 0000:00: root bus resource [mem 0x10030400000-0x100401fffff window] + + pci 0000:00:08.1: bridge window [mem 0xd2000000-0xd23fffff] + pci 0000:00:08.1: bridge window [mem 0x10030000000-0x100401fffff 64bit pref] + pci 0000:00:08.1: can't claim BAR 15 [mem 0x10030000000-0x100401fffff 64bit pref]: no compatible bridge window + pci 0000:00:08.1: [mem 0x10030000000-0x100401fffff 64bit pref] clipped to [mem 0x10030000000-0x100303fffff 64bit pref] + pci 0000:00:08.1: bridge window [mem 0x10030000000-0x100303fffff 64bit pref] + pci 0000:07:00.0: can't claim BAR 0 [mem 0x10030000000-0x1003fffffff 64bit pref]: no compatible bridge window + pci 0000:07:00.0: can't claim BAR 2 [mem 0x10040000000-0x100401fffff 64bit pref]: no compatible bridge window + +However, the root bus has two contiguous apertures that can contain the +child resource requested. + +Coalesce contiguous apertures so we can allocate from the entire contiguous +region. + +This is the second take of commit 65db04053efe ("PCI: Coalesce host +bridge contiguous apertures"). The original approach sorts the apertures +by address, but that makes NVMe stop working on QEMU ppc:sam460ex: + PCI host bridge to bus 0002:00 + pci_bus 0002:00: root bus resource [io 0x0000-0xffff] + pci_bus 0002:00: root bus resource [mem 0xd80000000-0xdffffffff] (bus address [0x80000000-0xffffffff]) + pci_bus 0002:00: root bus resource [mem 0xc0ee00000-0xc0eefffff] (bus address [0x00000000-0x000fffff]) + +After the offending commit: + PCI host bridge to bus 0002:00 + pci_bus 0002:00: root bus resource [io 0x0000-0xffff] + pci_bus 0002:00: root bus resource [mem 0xc0ee00000-0xc0eefffff] (bus address [0x00000000-0x000fffff]) + pci_bus 0002:00: root bus resource [mem 0xd80000000-0xdffffffff] (bus address [0x80000000-0xffffffff]) + +Since the apertures on HP EliteDesk 805 G6 are already in ascending +order, doing a precautious sorting is not necessary. + +Remove the sorting part to avoid the regression on ppc:sam460ex. + +Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=212013 +Cc: Guenter Roeck +Suggested-by: Bjorn Helgaas +Signed-off-by: Kai-Heng Feng +Signed-off-by: Fabian Grünbichler +Signed-off-by: Thomas Lamprecht +--- + drivers/pci/probe.c | 31 +++++++++++++++++++++++++++---- + 1 file changed, 27 insertions(+), 4 deletions(-) + +diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c +index 258350f80f6c..7ff9fcec365b 100644 +--- a/drivers/pci/probe.c ++++ b/drivers/pci/probe.c +@@ -883,11 +883,11 @@ static void pci_set_bus_msi_domain(struct pci_bus *bus) + static int pci_register_host_bridge(struct pci_host_bridge *bridge) + { + struct device *parent = bridge->dev.parent; +- struct resource_entry *window, *n; ++ struct resource_entry *window, *next, *n; + struct pci_bus *bus, *b; +- resource_size_t offset; ++ resource_size_t offset, next_offset; + LIST_HEAD(resources); +- struct resource *res; ++ struct resource *res, *next_res; + char addr[64], *fmt; + const char *name; + int err; +@@ -970,11 +970,34 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge) + if (nr_node_ids > 1 && pcibus_to_node(bus) == NUMA_NO_NODE) + dev_warn(&bus->dev, "Unknown NUMA node; performance will be reduced\n"); + ++ /* Coalesce contiguous windows */ ++ resource_list_for_each_entry_safe(window, n, &resources) { ++ if (list_is_last(&window->node, &resources)) ++ break; ++ ++ next = list_next_entry(window, node); ++ offset = window->offset; ++ res = window->res; ++ next_offset = next->offset; ++ next_res = next->res; ++ ++ if (res->flags != next_res->flags || offset != next_offset) ++ continue; ++ ++ if (res->end + 1 == next_res->start) { ++ next_res->start = res->start; ++ res->flags = res->start = res->end = 0; ++ } ++ } ++ + /* Add initial resources to the bus */ + resource_list_for_each_entry_safe(window, n, &resources) { +- list_move_tail(&window->node, &bridge->windows); + offset = window->offset; + res = window->res; ++ if (!res->end) ++ continue; ++ ++ list_move_tail(&window->node, &bridge->windows); + + if (res->flags & IORESOURCE_BUS) + pci_bus_insert_busn_res(bus, bus->number, res->end); \ No newline at end of file diff --git a/debian/patches/pve/0006-disable-split-btf.patch b/debian/patches/pve/0008-do-not-generate-split-BTF-type-info-per-default.patch similarity index 100% rename from debian/patches/pve/0006-disable-split-btf.patch rename to debian/patches/pve/0008-do-not-generate-split-BTF-type-info-per-default.patch diff --git a/debian/patches/pve/0009-blk-cgroup-always-terminate-io.stat-lines.patch b/debian/patches/pve/0009-blk-cgroup-always-terminate-io.stat-lines.patch new file mode 100644 index 0000000..c4221f7 --- /dev/null +++ b/debian/patches/pve/0009-blk-cgroup-always-terminate-io.stat-lines.patch @@ -0,0 +1,147 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Wolfgang Bumiller +Date: Tue, 11 Jan 2022 09:31:59 +0100 +Subject: [PATCH] blk-cgroup: always terminate io.stat lines + +With the removal of seq_get_buf in blkcg_print_one_stat, we +cannot make adding the newline conditional on there being +relevant stats because the name was already written out +unconditionally. +Otherwise we may end up with multiple device names in one +line which is confusing and doesn't follow the nested-keyed +file format. + +Signed-off-by: Wolfgang Bumiller +Fixes: 252c651a4c85 ("blk-cgroup: stop using seq_get_buf") +Signed-off-by: Thomas Lamprecht +--- + block/blk-cgroup.c | 9 ++------- + block/blk-iocost.c | 5 ++--- + block/blk-iolatency.c | 8 +++----- + include/linux/blk-cgroup.h | 2 +- + 4 files changed, 8 insertions(+), 16 deletions(-) + +diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c +index 0eec59e4df65..38c62a44905a 100644 +--- a/block/blk-cgroup.c ++++ b/block/blk-cgroup.c +@@ -887,7 +887,6 @@ static void blkcg_print_one_stat(struct blkcg_gq *blkg, struct seq_file *s) + { + struct blkg_iostat_set *bis = &blkg->iostat; + u64 rbytes, wbytes, rios, wios, dbytes, dios; +- bool has_stats = false; + const char *dname; + unsigned seq; + int i; +@@ -913,14 +912,12 @@ static void blkcg_print_one_stat(struct blkcg_gq *blkg, struct seq_file *s) + } while (u64_stats_fetch_retry(&bis->sync, seq)); + + if (rbytes || wbytes || rios || wios) { +- has_stats = true; + seq_printf(s, "rbytes=%llu wbytes=%llu rios=%llu wios=%llu dbytes=%llu dios=%llu", + rbytes, wbytes, rios, wios, + dbytes, dios); + } + + if (blkcg_debug_stats && atomic_read(&blkg->use_delay)) { +- has_stats = true; + seq_printf(s, " use_delay=%d delay_nsec=%llu", + atomic_read(&blkg->use_delay), + atomic64_read(&blkg->delay_nsec)); +@@ -932,12 +929,10 @@ static void blkcg_print_one_stat(struct blkcg_gq *blkg, struct seq_file *s) + if (!blkg->pd[i] || !pol->pd_stat_fn) + continue; + +- if (pol->pd_stat_fn(blkg->pd[i], s)) +- has_stats = true; ++ pol->pd_stat_fn(blkg->pd[i], s); + } + +- if (has_stats) +- seq_printf(s, "\n"); ++ seq_puts(s, "\n"); + } + + static int blkcg_print_stat(struct seq_file *sf, void *v) +diff --git a/block/blk-iocost.c b/block/blk-iocost.c +index eb7b0d6bd11f..381c28f9561e 100644 +--- a/block/blk-iocost.c ++++ b/block/blk-iocost.c +@@ -2995,13 +2995,13 @@ static void ioc_pd_free(struct blkg_policy_data *pd) + kfree(iocg); + } + +-static bool ioc_pd_stat(struct blkg_policy_data *pd, struct seq_file *s) ++static void ioc_pd_stat(struct blkg_policy_data *pd, struct seq_file *s) + { + struct ioc_gq *iocg = pd_to_iocg(pd); + struct ioc *ioc = iocg->ioc; + + if (!ioc->enabled) +- return false; ++ return; + + if (iocg->level == 0) { + unsigned vp10k = DIV64_U64_ROUND_CLOSEST( +@@ -3017,7 +3017,6 @@ static bool ioc_pd_stat(struct blkg_policy_data *pd, struct seq_file *s) + iocg->last_stat.wait_us, + iocg->last_stat.indebt_us, + iocg->last_stat.indelay_us); +- return true; + } + + static u64 ioc_weight_prfill(struct seq_file *sf, struct blkg_policy_data *pd, +diff --git a/block/blk-iolatency.c b/block/blk-iolatency.c +index c0545f9da549..d33460f3d43d 100644 +--- a/block/blk-iolatency.c ++++ b/block/blk-iolatency.c +@@ -890,7 +890,7 @@ static int iolatency_print_limit(struct seq_file *sf, void *v) + return 0; + } + +-static bool iolatency_ssd_stat(struct iolatency_grp *iolat, struct seq_file *s) ++static void iolatency_ssd_stat(struct iolatency_grp *iolat, struct seq_file *s) + { + struct latency_stat stat; + int cpu; +@@ -913,17 +913,16 @@ static bool iolatency_ssd_stat(struct iolatency_grp *iolat, struct seq_file *s) + (unsigned long long)stat.ps.missed, + (unsigned long long)stat.ps.total, + iolat->rq_depth.max_depth); +- return true; + } + +-static bool iolatency_pd_stat(struct blkg_policy_data *pd, struct seq_file *s) ++static void iolatency_pd_stat(struct blkg_policy_data *pd, struct seq_file *s) + { + struct iolatency_grp *iolat = pd_to_lat(pd); + unsigned long long avg_lat; + unsigned long long cur_win; + + if (!blkcg_debug_stats) +- return false; ++ return; + + if (iolat->ssd) + return iolatency_ssd_stat(iolat, s); +@@ -936,7 +935,6 @@ static bool iolatency_pd_stat(struct blkg_policy_data *pd, struct seq_file *s) + else + seq_printf(s, " depth=%u avg_lat=%llu win=%llu", + iolat->rq_depth.max_depth, avg_lat, cur_win); +- return true; + } + + static struct blkg_policy_data *iolatency_pd_alloc(gfp_t gfp, +diff --git a/include/linux/blk-cgroup.h b/include/linux/blk-cgroup.h +index b4de2010fba5..132e05ed6935 100644 +--- a/include/linux/blk-cgroup.h ++++ b/include/linux/blk-cgroup.h +@@ -152,7 +152,7 @@ typedef void (blkcg_pol_online_pd_fn)(struct blkg_policy_data *pd); + typedef void (blkcg_pol_offline_pd_fn)(struct blkg_policy_data *pd); + typedef void (blkcg_pol_free_pd_fn)(struct blkg_policy_data *pd); + typedef void (blkcg_pol_reset_pd_stats_fn)(struct blkg_policy_data *pd); +-typedef bool (blkcg_pol_stat_pd_fn)(struct blkg_policy_data *pd, ++typedef void (blkcg_pol_stat_pd_fn)(struct blkg_policy_data *pd, + struct seq_file *s); + + struct blkcg_policy { \ No newline at end of file diff --git a/debian/patches/series.linux b/debian/patches/series.linux index 64f0feb..9d565a6 100644 --- a/debian/patches/series.linux +++ b/debian/patches/series.linux @@ -1,10 +1,14 @@ +ubuntu/0001-apparmor-compatibility-v2.x-net-rules.patch +ubuntu/0002-apparmor-af_unix-mediation.patch +ubuntu/0003-apparmor-fix-apparmor-mediating-locking-non-fs-unix-sockets.patch +ubuntu/0004-apparmor-fix-use-after-free-in-sk_peer_label.patch + pve/0001-Make-mkcompile_h-accept-an-alternate-timestamp-strin.patch pve/0002-bridge-keep-MAC-of-first-assigned-port.patch pve/0003-pci-Enable-overrides-for-missing-ACS-capabilities-4..patch pve/0004-kvm-disable-default-dynamic-halt-polling-growth.patch pve/0005-net-core-downgrade-unregister_netdevice-refcount-lea.patch -pve/0006-disable-split-btf.patch -pve/0007-apparmor-compatibility-v2.x-net-rules.patch -pve/0008-apparmor-af_unix-mediation.patch -pve/0009-apparmor-fix-apparmor-mediating-locking-non-fs-unix-sockets.patch -pve/0010-apparmor-fix-use-after-free-in-sk_peer_label.patch +# pve/0006-Revert-PCI-Coalesce-host-bridge-contiguous-apertures.patch +# pve/0007-PCI-Reinstate-PCI-Coalesce-host-bridge-contiguous-ap.patch +pve/0008-do-not-generate-split-BTF-type-info-per-default.patch +pve/0009-blk-cgroup-always-terminate-io.stat-lines.patch \ No newline at end of file diff --git a/debian/patches/pve/0007-apparmor-compatibility-v2.x-net-rules.patch b/debian/patches/ubuntu/0001-apparmor-compatibility-v2.x-net-rules.patch similarity index 100% rename from debian/patches/pve/0007-apparmor-compatibility-v2.x-net-rules.patch rename to debian/patches/ubuntu/0001-apparmor-compatibility-v2.x-net-rules.patch diff --git a/debian/patches/pve/0008-apparmor-af_unix-mediation.patch b/debian/patches/ubuntu/0002-apparmor-af_unix-mediation.patch similarity index 100% rename from debian/patches/pve/0008-apparmor-af_unix-mediation.patch rename to debian/patches/ubuntu/0002-apparmor-af_unix-mediation.patch diff --git a/debian/patches/pve/0009-apparmor-fix-apparmor-mediating-locking-non-fs-unix-sockets.patch b/debian/patches/ubuntu/0003-apparmor-fix-apparmor-mediating-locking-non-fs-unix-sockets.patch similarity index 100% rename from debian/patches/pve/0009-apparmor-fix-apparmor-mediating-locking-non-fs-unix-sockets.patch rename to debian/patches/ubuntu/0003-apparmor-fix-apparmor-mediating-locking-non-fs-unix-sockets.patch diff --git a/debian/patches/pve/0010-apparmor-fix-use-after-free-in-sk_peer_label.patch b/debian/patches/ubuntu/0004-apparmor-fix-use-after-free-in-sk_peer_label.patch similarity index 100% rename from debian/patches/pve/0010-apparmor-fix-use-after-free-in-sk_peer_label.patch rename to debian/patches/ubuntu/0004-apparmor-fix-use-after-free-in-sk_peer_label.patch