5.14.19-rc1 review
Subsystems (13)
Greg Kroah-Hartman
maintainerPATCH 724/849 net: dsa: tag_ocelot: break circular dependency with ocelot switch lib driver
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit deab6b1cd9789bb9bd466d5e76aecb8b336259b4 ]
As explained here:
https://lore.kernel.org/netdev/20210908220834.d7gmtnwrorhharna@skbuf/
DSA tagging protocol drivers cannot depend on symbols exported by switch drivers, because this creates a circular dependency that breaks module autoloading.
The tag_ocelot.c file depends on the ocelot_ptp_rew_op() function exported by the common ocelot switch lib. This function looks at OCELOT_SKB_CB(skb) and computes how to populate the REW_OP field of the DSA tag, for PTP timestamping (the command: one-step/two-step, and the TX timestamp identifier).
None of that requires deep insight into the driver, it is quite stateless, as it only depends upon the skb->cb. So let's make it a static inline function and put it in include/linux/dsa/ocelot.h, a file that despite its name is used by the ocelot switch driver for populating the injection header too - since commit 40d3f295b5fe ("net:
mscc: ocelot: use common tag parsing code with DSA").
With that function declared as static inline, its body is expanded inside each call site, so the dependency is broken and the DSA tagger can be built without the switch library, upon which the felix driver depends.
--- drivers/net/ethernet/mscc/ocelot.c | 17 ------------ drivers/net/ethernet/mscc/ocelot_net.c | 1 + include/linux/dsa/ocelot.h | 37 ++++++++++++++++++++++++++ include/soc/mscc/ocelot.h | 24 ----------------- net/dsa/Kconfig | 2 -- net/dsa/tag_ocelot.c | 1 - net/dsa/tag_ocelot_8021q.c | 1 + 7 files changed, 39 insertions(+), 44 deletions(-)
drivers/net/ethernet/mscc/ocelot.c +0 -17
@@ -568,23 +568,6 @@ static int ocelot_port_add_txtstamp_skb(struct ocelot *ocelot, int port,return 0 ; } -u32 ocelot_ptp_rew_op (struct sk_buff *skb) -{ -struct sk_buff *clone =OCELOT_SKB_CB (skb)->clone; -u8 ptp_cmd =OCELOT_SKB_CB (skb)->ptp_cmd; -u32 rew_op =0 ; - -if (ptp_cmd ==IFH_REW_OP_TWO_STEP_PTP && clone) { - rew_op = ptp_cmd; - rew_op |=OCELOT_SKB_CB (clone)->ts_id <<3 ; - }else if (ptp_cmd ==IFH_REW_OP_ORIGIN_PTP ) { - rew_op = ptp_cmd; - } - -return rew_op; -} -EXPORT_SYMBOL (ocelot_ptp_rew_op); -static bool ocelot_ptp_is_onestep_sync (struct sk_buff *skb,unsigned int ptp_class) {
drivers/net/ethernet/mscc/ocelot_net.c +1 -0
@@ -8,6 +8,7 @@* Copyright 2020-2021 NXP Semiconductors */ +#include <linux/dsa/ocelot.h> #include <linux/if_bridge.h> #include <net/pkt_cls.h> #include "ocelot.h"
include/linux/dsa/ocelot.h +37 -0
@@ -6,6 +6,26 @@#define _NET_DSA_TAG_OCELOT_H#include <linux/packing.h> +#include <linux/skbuff.h> + +struct ocelot_skb_cb { +struct sk_buff *clone; +unsigned int ptp_class;/* valid only for clones */ +u8 ptp_cmd; +u8 ts_id; +}; + +#define OCELOT_SKB_CB (skb) \ + ((struct ocelot_skb_cb *)((skb)->cb)) + +#define IFH_TAG_TYPE_C 0 +#define IFH_TAG_TYPE_S 1 + +#define IFH_REW_OP_NOOP 0x0 +#define IFH_REW_OP_DSCP 0x1 +#define IFH_REW_OP_ONE_STEP_PTP 0x2 +#define IFH_REW_OP_TWO_STEP_PTP 0x3 +#define IFH_REW_OP_ORIGIN_PTP 0x5#define OCELOT_TAG_LEN 16#define OCELOT_SHORT_PREFIX_LEN 4
@@ -215,4 +235,21 @@ static inline void ocelot_ifh_set_vid(void *injection, u64 vid) packing(injection, &vid, 11, 0, OCELOT_TAG_LEN, PACK, 0); } +/* Determine the PTP REW_OP to use for injecting the given skb */ +static inline u32 ocelot_ptp_rew_op (struct sk_buff *skb) +{ +struct sk_buff *clone =OCELOT_SKB_CB (skb)->clone; +u8 ptp_cmd =OCELOT_SKB_CB (skb)->ptp_cmd; +u32 rew_op =0 ; + +if (ptp_cmd ==IFH_REW_OP_TWO_STEP_PTP && clone) { + rew_op = ptp_cmd; + rew_op |=OCELOT_SKB_CB (clone)->ts_id <<3 ; + }else if (ptp_cmd ==IFH_REW_OP_ORIGIN_PTP ) { + rew_op = ptp_cmd; + } + +return rew_op; +} +#endif
include/soc/mscc/ocelot.h +0 -24
@@ -89,15 +89,6 @@/* Source PGIDs, one per physical port */ #define PGID_SRC 80 -#define IFH_TAG_TYPE_C 0 -#define IFH_TAG_TYPE_S 1 - -#define IFH_REW_OP_NOOP 0x0 -#define IFH_REW_OP_DSCP 0x1 -#define IFH_REW_OP_ONE_STEP_PTP 0x2 -#define IFH_REW_OP_TWO_STEP_PTP 0x3 -#define IFH_REW_OP_ORIGIN_PTP 0x5 -#define OCELOT_NUM_TC 8#define OCELOT_SPEED_2500 0
@@ -692,16 +683,6 @@ struct ocelot_policer {u32 burst;/* bytes */ }; -struct ocelot_skb_cb { -struct sk_buff *clone; -unsigned int ptp_class;/* valid only for clones */ -u8 ptp_cmd; -u8 ts_id; -}; - -#define OCELOT_SKB_CB (skb) \ - ((struct ocelot_skb_cb *)((skb)->cb)) -#define ocelot_read_ix (ocelot, reg, gi, ri) __ocelot_read_ix(ocelot, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri))#define ocelot_read_gix (ocelot, reg, gi) __ocelot_read_ix(ocelot, reg, reg##_GSZ * (gi))#define ocelot_read_rix (ocelot, reg, ri) __ocelot_read_ix(ocelot, reg, reg##_RSZ * (ri))
@@ -762,7 +743,6 @@ void ocelot_port_inject_frame(struct ocelot *ocelot, int port, int grp,int ocelot_xtr_poll_frame (struct ocelot *ocelot,int grp,struct sk_buff **skb);void ocelot_drain_cpu_queue (struct ocelot *ocelot,int grp); -u32 ocelot_ptp_rew_op (struct sk_buff *skb);#else static inline bool ocelot_can_inject (struct ocelot *ocelot,int grp)
@@ -786,10 +766,6 @@ static inline void ocelot_drain_cpu_queue(struct ocelot *ocelot, int grp) { } -static inline u32 ocelot_ptp_rew_op (struct sk_buff *skb) -{ -return 0 ; -}#endif /* Hardware initialization */
net/dsa/Kconfig +0 -2
@@ -101,8 +101,6 @@ config NET_DSA_TAG_RTL4_A config NET_DSA_TAG_OCELOT tristate "Tag driver for Ocelot family of switches, using NPI port" - depends on MSCC_OCELOT_SWITCH_LIB || \ - (MSCC_OCELOT_SWITCH_LIB=n && COMPILE_TEST) select PACKING help Say Y or M if you want to enable NPI tagging for the Ocelot switches
net/dsa/tag_ocelot.c +0 -1
@@ -2,7 +2,6 @@/* Copyright 2019 NXP Semiconductors */ #include <linux/dsa/ocelot.h> -#include <soc/mscc/ocelot.h> #include "dsa_priv.h" static void ocelot_xmit_common(struct sk_buff *skb, struct net_device *netdev,
net/dsa/tag_ocelot_8021q.c +1 -0
@@ -9,6 +9,7 @@* that on egress */ #include <linux/dsa/8021q.h> +#include <linux/dsa/ocelot.h> #include <soc/mscc/ocelot.h> #include <soc/mscc/ocelot_ptp.h> #include "dsa_priv.h"
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 725/849 net: dsa: felix: fix broken VLAN-tagged PTP under VLAN-aware bridge
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit 92f62485b3715882cd397b0cbd80a96d179b86d6 ]
Normally it is expected that the dsa_device_ops :: rcv() method finishes parsing the DSA tag and consumes it, then never looks at it again.
But commit c0bcf537667c ("net: dsa: ocelot: add hardware timestamping support for Felix") added support for RX timestamping in a very unconventional way. On this switch, a partial timestamp is available in the DSA header, but the driver got away with not parsing that timestamp right away, but instead delayed that parsing for a little longer:
dsa_switch_rcv():
nskb = cpu_dp->rcv(skb, dev); <------------- not here -> ocelot_rcv() ... skb = nskb; skb_push(skb, ETH_HLEN); skb->pkt_type = PACKET_HOST; skb->protocol = eth_type_trans(skb, skb->dev); ... if (dsa_skb_defer_rx_timestamp(p, skb)) <--- but here -> felix_rxtstamp() return 0;
When in felix_rxtstamp(), this driver accounted for the fact that eth_type_trans() happened in the meanwhile, so it got a hold of the extraction header again by subtracting (ETH_HLEN + OCELOT_TAG_LEN) bytes from the current skb->data.
This worked for quite some time but was quite fragile from the very beginning. Not to mention that having DSA tag parsing split in two different files, under different folders (net/dsa/tag_ocelot.c vs drivers/net/dsa/ocelot/felix.c) made it quite non-obvious for patches to come that they might break this.
Finally, the blamed commit does the following: at the end of ocelot_rcv(), it checks whether the skb payload contains a VLAN header. If it does, and this port is under a VLAN-aware bridge, that VLAN ID might not be correct in the sense that the packet might have suffered VLAN rewriting due to TCAM rules (VCAP IS1). So we consume the VLAN ID from the skb payload using __skb_vlan_pop(), and take the classified VLAN ID from the DSA tag, and construct a hwaccel VLAN tag with the classified VLAN, and the skb payload is VLAN-untagged.
The big problem is that __skb_vlan_pop() does:
memmove(skb->data + VLAN_HLEN, skb->data, 2 * ETH_ALEN); __skb_pull(skb, VLAN_HLEN);
aka it moves the Ethernet header 4 bytes to the right, and pulls 4 bytes from the skb headroom (effectively also moving skb->data, by definition). So for felix_rxtstamp()'s fragile logic, all bets are off now. Instead of having the "extraction" pointer point to the DSA header, it actually points to 4 bytes _inside_ the extraction header. Corollary, the last 4 bytes of the "extraction" header are in fact 4 stale bytes of the destination MAC address from the Ethernet header, from prior to the __skb_vlan_pop() movement.
So of course, RX timestamps are completely bogus when the system is configured in this way.
The fix is actually very simple: just don't structure the code like that. For better or worse, the DSA PTP timestamping API does not offer a straightforward way for drivers to present their RX timestamps, but other drivers (sja1105) have established a simple mechanism to carry their RX timestamp from dsa_device_ops :: rcv() all the way to dsa_switch_ops :: port_rxtstamp() and even later. That mechanism is to simply save the partial timestamp to the skb->cb, and complete it later.
Question: why don't we simply populate the skb's struct skb_shared_hwtstamps from ocelot_rcv(), and bother with this complication of propagating the timestamp to felix_rxtstamp()?
Answer: dsa_switch_ops :: port_rxtstamp() answers the question whether PTP packets need sleepable context to retrieve the full RX timestamp. Currently felix_rxtstamp() answers "no, thanks" to that question, and calls ocelot_ptp_gettime64() from softirq atomic context. This is understandable, since Felix VSC9959 is a PCIe memory-mapped switch, so hardware access does not require sleeping. But the felix driver is preparing for the introduction of other switches where hardware access is over a slow bus like SPI or MDIO:
https://lore.kernel.org/lkml/[email protected]/
So I would like to keep this code structure, so the rework needed when that driver will need PTP support will be minimal (answer "yes, I need deferred context for this skb's RX timestamp", then the partial timestamp will still be found in the skb->cb.
--- drivers/net/dsa/ocelot/felix.c | 9 +++------ include/linux/dsa/ocelot.h | 1 + net/dsa/tag_ocelot.c | 3 +++ 3 files changed, 7 insertions(+), 6 deletions(-)
drivers/net/dsa/ocelot/felix.c +3 -6
@@ -1367,12 +1367,12 @@ out:static bool felix_rxtstamp (struct dsa_switch *ds,int port,struct sk_buff *skb,unsigned int type) { -u8 *extraction = skb->data -ETH_HLEN -OCELOT_TAG_LEN ; +u32 tstamp_lo =OCELOT_SKB_CB (skb)->tstamp_lo;struct skb_shared_hwtstamps *shhwtstamps;struct ocelot *ocelot = ds->priv; -u32 tstamp_lo, tstamp_hi;struct timespec64 ts; -u64 tstamp, val; +u32 tstamp_hi; +u64 tstamp;/* If the "no XTR IRQ" workaround is in use, tell DSA to defer this skb * for RX timestamping. Then free it, and poll for its copy through
@@ -1387,9 +1387,6 @@ static bool felix_rxtstamp(struct dsa_switch *ds, int port,ocelot_ptp_gettime64 (&ocelot->ptp_info, &ts); tstamp =ktime_set (ts.tv_sec, ts.tv_nsec); -ocelot_xfh_get_rew_val (extraction, &val); - tstamp_lo = (u32 )val; - tstamp_hi = tstamp >>32 ;if ((tstamp &0xffffffff ) < tstamp_lo) tstamp_hi--;
include/linux/dsa/ocelot.h +1 -0
@@ -11,6 +11,7 @@struct ocelot_skb_cb {struct sk_buff *clone;unsigned int ptp_class;/* valid only for clones */ +u32 tstamp_lo;u8 ptp_cmd;u8 ts_id; };
net/dsa/tag_ocelot.c +3 -0
@@ -63,6 +63,7 @@ static struct sk_buff *ocelot_rcv(struct sk_buff *skb,struct dsa_port *dp;u8 *extraction;u16 vlan_tpid; +u64 rew_val;/* Revert skb->data by the amount consumed by the DSA master, * so it points to the beginning of the frame.
@@ -92,6 +93,7 @@ static struct sk_buff *ocelot_rcv(struct sk_buff *skb,ocelot_xfh_get_qos_class (extraction, &qos_class);ocelot_xfh_get_tag_type (extraction, &tag_type);ocelot_xfh_get_vlan_tci (extraction, &vlan_tci); +ocelot_xfh_get_rew_val (extraction, &rew_val); skb->dev =dsa_master_find_slave (netdev,0 , src_port);if (!skb->dev)
@@ -105,6 +107,7 @@ static struct sk_buff *ocelot_rcv(struct sk_buff *skb, skb->offload_fwd_mark =1 ; skb->priority = qos_class; +OCELOT_SKB_CB (skb)->tstamp_lo = rew_val;/* Ocelot switches copy frames unmodified to the CPU. However, it is * possible for the user to request a VLAN modification through
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 726/849 ice: Fix replacing VF hardware MAC to existing MAC filter
In reply to Greg Kroah-HartmanFrom: Sylwester Dziedziuch <[email protected]>
[ Upstream commit ce572a5b88d5ca6737b5e23da9892792fd708ad3 ]
VF was not able to change its hardware MAC address in case the new address was already present in the MAC filter list. Change the handling of VF add mac request to not return if requested MAC address is already present on the list and check if its hardware MAC needs to be updated in this case.
--- drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +9 -5
@@ -3762,6 +3762,7 @@ ice_vc_add_mac_addr(struct ice_vf *vf, struct ice_vsi *vsi,struct device *dev =ice_pf_to_dev (vf->pf);u8 *mac_addr = vc_ether_addr->addr;enum ice_status status; +int ret =0 ;/* device MAC already added */ if (ether_addr_equal (mac_addr, vf->dev_lan_addr.addr))
@@ -3774,20 +3775,23 @@ ice_vc_add_mac_addr(struct ice_vf *vf, struct ice_vsi *vsi, status =ice_fltr_add_mac (vsi, mac_addr,ICE_FWD_TO_VSI );if (status ==ICE_ERR_ALREADY_EXISTS ) { -dev_err (dev,"MAC %pM already exists for VF %d\n" , mac_addr, +dev_dbg (dev,"MAC %pM already exists for VF %d\n" , mac_addr, vf->vf_id); -return -EEXIST ; +/* don't return since we might need to update +* the primary MAC in ice_vfhw_mac_add() below +*/ + ret = -EEXIST ; }else if (status) {dev_err (dev,"Failed to add MAC %pM for VF %d\n, error %s\n" , mac_addr, vf->vf_id,ice_stat_str (status));return -EIO ; + }else { + vf->num_mac++; }ice_vfhw_mac_add (vf, vc_ether_addr); - vf->num_mac++; - -return 0 ; +return ret; }/**
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 727/849 ice: Fix not stopping Tx queues for VFs
In reply to Greg Kroah-HartmanFrom: Brett Creeley <[email protected]>
[ Upstream commit b385cca47363316c6d9a74ae9db407bbc281f815 ]
When a VF is removed and/or reset its Tx queues need to be stopped from the PF. This is done by calling the ice_dis_vf_qs() function, which calls ice_vsi_stop_lan_tx_rings(). Currently ice_dis_vf_qs() is protected by the VF state bit ICE_VF_STATE_QS_ENA. Unfortunately, this is causing the Tx queues to not be disabled in some cases and when the VF tries to re-enable/reconfigure its Tx queues over virtchnl the op is failing. This is because a VF can be reset and/or removed before the ICE_VF_STATE_QS_ENA bit is set, but the Tx queues were already configured via ice_vsi_cfg_single_txq() in the VIRTCHNL_OP_CONFIG_VSI_QUEUES op. However, the ICE_VF_STATE_QS_ENA bit is set on a successful VIRTCHNL_OP_ENABLE_QUEUES, which will always happen after the VIRTCHNL_OP_CONFIG_VSI_QUEUES op.
This was causing the following error message when loading the ice driver, creating VFs, and modifying VF trust in an endless loop:
[35274.192484] ice 0000:88:00.0: Failed to set LAN Tx queue context, error: ICE_ERR_PARAM [35274.193074] ice 0000:88:00.0: VF 0 failed opcode 6, retval: -5 [35274.193640] iavf 0000:88:01.0: PF returned error -5 (IAVF_ERR_PARAM) to our request 6
Fix this by always calling ice_dis_vf_qs() and silencing the error message in ice_vsi_stop_tx_ring() since the calling code ignores the return anyway. Also, all other places that call ice_vsi_stop_tx_ring() catch the error, so this doesn't affect those flows since there was no change to the values the function returns.
Other solutions were considered (i.e. tracking which VF queues had been "started/configured" in VIRTCHNL_OP_CONFIG_VSI_QUEUES, but it seemed more complicated than it was worth. This solution also brings in the chance for other unexpected conditions due to invalid state bit checks. So, the proposed solution seemed like the best option since there is no harm in failing to stop Tx queues that were never started.
This issue can be seen using the following commands:
for i in {0..50}; do
rmmod ice
modprobe ice
sleep 1
echo 1 > /sys/class/net/ens785f0/device/sriov_numvfs echo 1 > /sys/class/net/ens785f1/device/sriov_numvfs
ip link set ens785f1 vf 0 trust on
ip link set ens785f0 vf 0 trust on
sleep 2
echo 0 > /sys/class/net/ens785f0/device/sriov_numvfs echo 0 > /sys/class/net/ens785f1/device/sriov_numvfs sleep 1
echo 1 > /sys/class/net/ens785f0/device/sriov_numvfs echo 1 > /sys/class/net/ens785f1/device/sriov_numvfs
ip link set ens785f1 vf 0 trust on
ip link set ens785f0 vf 0 trust on
done
--- drivers/net/ethernet/intel/ice/ice_base.c | 2 +- drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/ice/ice_base.c +1 -1
@@ -909,7 +909,7 @@ ice_vsi_stop_tx_ring(struct ice_vsi *vsi, enum ice_disq_rst_src rst_src, }else if (status ==ICE_ERR_DOES_NOT_EXIST ) {dev_dbg (ice_pf_to_dev (vsi->back),"LAN Tx queues do not exist, nothing to disable\n" ); }else if (status) { -dev_err (ice_pf_to_dev (vsi->back),"Failed to disable LAN Tx queues, error: %s\n" , +dev_dbg (ice_pf_to_dev (vsi->back),"Failed to disable LAN Tx queues, error: %s\n" ,ice_stat_str (status));return -ENODEV ; }
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +2 -4
@@ -634,8 +634,7 @@ void ice_free_vfs(struct ice_pf *pf)/* Avoid wait time by stopping all VFs at the same time */ ice_for_each_vf (pf, i) -if (test_bit (ICE_VF_STATE_QS_ENA , pf->vf[i].vf_states)) -ice_dis_vf_qs (&pf->vf[i]); +ice_dis_vf_qs (&pf->vf[i]); tmp = pf->num_alloc_vfs; pf->num_qps_per_vf =0 ;
@@ -1645,8 +1644,7 @@ bool ice_reset_vf(struct ice_vf *vf, bool is_vflr) vsi =ice_get_vf_vsi (vf); -if (test_bit (ICE_VF_STATE_QS_ENA , vf->vf_states)) -ice_dis_vf_qs (vf); +ice_dis_vf_qs (vf);/* Call Disable LAN Tx queue AQ whether or not queues are * enabled. This is needed for successful completion of VFR.
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 728/849 ACPI: PMIC: Fix intel_pmic_regs_handler() read accesses
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
[ Upstream commit 009a789443fe4c8e6b1ecb7c16b4865c026184cd ]
The handling of PMIC register reads through writing 0 to address 4 of the OpRegion is wrong. Instead of returning the read value through the value64, which is a no-op for function == ACPI_WRITE calls, store the value and then on a subsequent function == ACPI_READ with address == 3 (the address for the value field of the OpRegion) return the stored value.
This has been tested on a Xiaomi Mi Pad 2 and makes the ACPI battery dev there mostly functional (unfortunately there are still other issues).
Here are the SET() / GET() functions of the PMIC ACPI device, which use this OpRegion, which clearly show the new behavior to be correct:
OperationRegion (REGS, 0x8F, Zero, 0x50)
Field (REGS, ByteAcc, NoLock, Preserve)
{
CLNT, 8,
SA, 8,
OFF, 8,
VAL, 8,
RWM, 8
}Method (GET, 3, Serialized)
{
If ((AVBE == One))
{
CLNT = Arg0
SA = Arg1
OFF = Arg2
RWM = Zero
If ((AVBG == One))
{
GPRW = Zero
}
}
Return (VAL) /* \_SB_.PCI0.I2C7.PMI5.VAL_ */
}Method (SET, 4, Serialized)
{
If ((AVBE == One))
{
CLNT = Arg0
SA = Arg1
OFF = Arg2
VAL = Arg3
RWM = One
If ((AVBG == One))
{
GPRW = One
}
}
}
--- drivers/acpi/pmic/intel_pmic.c | 51 +++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 23 deletions(-)
drivers/acpi/pmic/intel_pmic.c +28 -23
@@ -211,31 +211,36 @@ static acpi_status intel_pmic_regs_handler(u32 function, void *handler_context, void *region_context) { struct intel_pmic_opregion *opregion = region_context; -int result =0 ; +int result = -EINVAL ; + +if (function ==ACPI_WRITE ) { +switch (address) { +case 0 : +return AE_OK ; +case 1 : + opregion->ctx.addr |= (*value64 &0xff ) <<8 ; +return AE_OK ; +case 2 : + opregion->ctx.addr |= *value64 &0xff ; +return AE_OK ; +case 3 : + opregion->ctx.val = *value64 &0xff ; +return AE_OK ; +case 4 : +if (*value64) { + result =regmap_write (opregion->regmap, opregion->ctx.addr, + opregion->ctx.val); + }else { + result =regmap_read (opregion->regmap, opregion->ctx.addr, + &opregion->ctx.val); + } + opregion->ctx.addr =0 ; + } + } -switch (address) { -case 0 : -return AE_OK ; -case 1 : - opregion->ctx.addr |= (*value64 &0xff ) <<8 ; -return AE_OK ; -case 2 : - opregion->ctx.addr |= *value64 &0xff ; +if (function ==ACPI_READ && address ==3 ) { + *value64 = opregion->ctx.val;return AE_OK ; -case 3 : - opregion->ctx.val = *value64 &0xff ; -return AE_OK ; -case 4 : -if (*value64) { - result =regmap_write (opregion->regmap, opregion->ctx.addr, - opregion->ctx.val); - }else { - result =regmap_read (opregion->regmap, opregion->ctx.addr, - &opregion->ctx.val); -if (result ==0 ) - *value64 = opregion->ctx.val; - } -memset (&opregion->ctx,0x00 ,sizeof (opregion->ctx)); }if (result <0 ) {
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 729/849 PCI: j721e: Fix j721e_pcie_probe() error path
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 496bb18483cc0474913e81e18a6b313aaea4c120 ]
If an error occurs after a successful cdns_pcie_init_phy() call, it must be undone by a cdns_pcie_disable_phy() call, as already done above and below.
Update the goto to branch at the correct place of the error handling path.
--- drivers/pci/controller/cadence/pci-j721e.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/cadence/pci-j721e.c +1 -1
@@ -474,7 +474,7 @@ static int j721e_pcie_probe(struct platform_device *pdev) ret =clk_prepare_enable (clk);if (ret) {dev_err (dev,"failed to enable pcie_refclk\n" ); - goto err_get_sync; + goto err_pcie_setup; } pcie->refclk = clk;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 730/849 nvdimm/btt: do not call del_gendisk() if not needed
In reply to Greg Kroah-HartmanFrom: Luis Chamberlain <[email protected]>
[ Upstream commit 3aefb5ee843fbe4789d03bb181e190d462df95e4 ]
del_gendisk() should not called if the disk has not been added. Fix this.
--- drivers/nvdimm/btt.c | 1 - 1 file changed, 1 deletion(-)
drivers/nvdimm/btt.c +0 -1
@@ -1538,7 +1538,6 @@ static int btt_blk_init(struct btt *btt)int rc =nd_integrity_init (btt->btt_disk,btt_meta_size (btt));if (rc) { -del_gendisk (btt->btt_disk);blk_cleanup_disk (btt->btt_disk);return rc; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 731/849 drm/nouveau/svm: Fix refcount leak bug and missing check against null bug
In reply to Greg Kroah-HartmanFrom: Chenyuan Mi <[email protected]>
[ Upstream commit 6bb8c2d51811eb5e6504f49efe3b089d026009d2 ]
The reference counting issue happens in one exception handling path of nouveau_svmm_bind(). When cli->svm.svmm is null, the function forgets to decrease the refcount of mm increased by get_task_mm(), causing a refcount leak.
Fix this issue by using mmput() to decrease the refcount in the exception handling path.
Also, the function forgets to do check against null when get mm by get_task_mm().
Fix this issue by adding null check after get mm by get_task_mm().
--- drivers/gpu/drm/nouveau/nouveau_svm.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/nouveau/nouveau_svm.c +4 -0
@@ -162,10 +162,14 @@ nouveau_svmm_bind(struct drm_device *dev, void *data,*/ mm =get_task_mm (current); +if (!mm) { +return -EINVAL ; + }mmap_read_lock (mm);if (!cli->svm.svmm) {mmap_read_unlock (mm); +mmput (mm);return -EINVAL ; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 732/849 block/ataflop: use the blk_cleanup_disk() helper
In reply to Greg Kroah-HartmanFrom: Luis Chamberlain <[email protected]>
[ Upstream commit 44a469b6acae6ad05c4acca8429467d1d50a8b8d ]
Use the helper to replace two lines with one.
--- drivers/block/ataflop.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/block/ataflop.c +2 -4
@@ -2097,8 +2097,7 @@ static int __init atari_floppy_init (void) err:while (--i >=0 ) { -blk_cleanup_queue (unit[i].disk[0 ]->queue); -put_disk (unit[i].disk[0 ]); +blk_cleanup_disk (unit[i].disk[0 ]);blk_mq_free_tag_set (&unit[i].tag_set); }
@@ -2156,8 +2155,7 @@ static void __exit atari_floppy_exit(void)if (!unit[i].disk[type])continue ;del_gendisk (unit[i].disk[type]); -blk_cleanup_queue (unit[i].disk[type]->queue); -put_disk (unit[i].disk[type]); +blk_cleanup_disk (unit[i].disk[type]); }blk_mq_free_tag_set (&unit[i].tag_set); }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 733/849 block/ataflop: add registration bool before calling del_gendisk()
In reply to Greg Kroah-HartmanFrom: Luis Chamberlain <[email protected]>
[ Upstream commit 573effb298011d3fcabc9b12025cf637f8a07911 ]
The ataflop assumes del_gendisk() is safe to call, this is only true because add_disk() does not return a failure, but that will change soon. And so, before we get to adding error handling for that case, let's make sure we keep track of which disks actually get registered. Then we use this to only call del_gendisk for them.
--- drivers/block/ataflop.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/block/ataflop.c +7 -2
@@ -298,6 +298,7 @@ static struct atari_floppy_struct {disk change detection) */ int flags;/* flags */ struct gendisk *disk[NUM_DISK_MINORS ]; +bool registered[NUM_DISK_MINORS ];int ref;int type;struct blk_mq_tag_set tag_set;
@@ -2021,8 +2022,10 @@ static void ataflop_probe(dev_t dev)return ;mutex_lock (&ataflop_probe_lock);if (!unit[drive].disk[type]) { -if (ataflop_alloc_disk (drive, type) ==0 ) +if (ataflop_alloc_disk (drive, type) ==0 ) {add_disk (unit[drive].disk[type]); + unit[drive].registered[type] = true; + } }mutex_unlock (&ataflop_probe_lock); }
@@ -2086,6 +2089,7 @@ static int __init atari_floppy_init (void) unit[i].track =-1 ; unit[i].flags =0 ;add_disk (unit[i].disk[0 ]); + unit[i].registered[0 ] = true; } printk(KERN_INFO "Atari floppy driver: max. %cD, %strack buffering\n",
@@ -2154,7 +2158,8 @@ static void __exit atari_floppy_exit(void)for (type =0 ; type <NUM_DISK_MINORS ; type++) {if (!unit[i].disk[type])continue ; -del_gendisk (unit[i].disk[type]); +if (unit[i].registered[type]) +del_gendisk (unit[i].disk[type]);blk_cleanup_disk (unit[i].disk[type]); }blk_mq_free_tag_set (&unit[i].tag_set);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 734/849 block/ataflop: provide a helper for cleanup up an atari disk
In reply to Greg Kroah-HartmanFrom: Luis Chamberlain <[email protected]>
[ Upstream commit deae1138d04758c7f8939fcb8aee330bc37e3015 ]
Instead of using two separate code paths for cleaning up an atari disk, use one. We take the more careful approach to check for *all* disk types, as is done on exit. The init path didn't have that check as the alternative disk types are only probed for later, they are not initialized by default.
Yes, there is a shared tag for all disks.
--- drivers/block/ataflop.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-)
drivers/block/ataflop.c +19 -15
@@ -2030,6 +2030,20 @@ static void ataflop_probe(dev_t dev)mutex_unlock (&ataflop_probe_lock); } +static void atari_cleanup_floppy_disk (struct atari_floppy_struct *fs) +{ +int type; + +for (type =0 ; type <NUM_DISK_MINORS ; type++) { +if (!fs->disk[type]) +continue ; +if (fs->registered[type]) +del_gendisk (fs->disk[type]); +blk_cleanup_disk (fs->disk[type]); + } +blk_mq_free_tag_set (&fs->tag_set); +} +static int __init atari_floppy_init (void ) {int i;
@@ -2100,10 +2114,8 @@ static int __init atari_floppy_init (void)return 0 ; err: -while (--i >=0 ) { -blk_cleanup_disk (unit[i].disk[0 ]); -blk_mq_free_tag_set (&unit[i].tag_set); - } +while (--i >=0 ) +atari_cleanup_floppy_disk (&unit[i]);unregister_blkdev (FLOPPY_MAJOR ,"fd" ); out_unlock:
@@ -2152,18 +2164,10 @@ __setup("floppy=", atari_floppy_setup); static void __exit atari_floppy_exit(void) { -int i, type; +int i; -for (i =0 ; i <FD_MAX_UNITS ; i++) { -for (type =0 ; type <NUM_DISK_MINORS ; type++) { -if (!unit[i].disk[type]) -continue ; -if (unit[i].registered[type]) -del_gendisk (unit[i].disk[type]); -blk_cleanup_disk (unit[i].disk[type]); - } -blk_mq_free_tag_set (&unit[i].tag_set); - } +for (i =0 ; i <FD_MAX_UNITS ; i++) +atari_cleanup_floppy_disk (&unit[i]);unregister_blkdev (FLOPPY_MAJOR ,"fd" );del_timer_sync (&fd_timer);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 735/849 ataflop: remove ataflop_probe_lock mutex
In reply to Greg Kroah-HartmanFrom: Tetsuo Handa <[email protected]>
[ Upstream commit 4ddb85d36613c45bde00d368bf9f357bd0708a0c ]
Commit bf9c0538e485b591 ("ataflop: use a separate gendisk for each media format") introduced ataflop_probe_lock mutex, but forgot to unlock the mutex when atari_floppy_init() (i.e. module loading) succeeded. This will result in double lock deadlock if ataflop_probe() is called. Also, unregister_blkdev() must not be called from atari_floppy_init() with ataflop_probe_lock held when atari_floppy_init() failed, for ataflop_probe() waits for ataflop_probe_lock with major_names_lock held (i.e. AB-BA deadlock).
__register_blkdev() needs to be called last in order to avoid calling ataflop_probe() when atari_floppy_init() is about to fail, for memory for completing already-started ataflop_probe() safely will be released as soon as atari_floppy_init() released ataflop_probe_lock mutex.
As with commit 8b52d8be86d72308 ("loop: reorder loop_exit"), unregister_blkdev() needs to be called first in order to avoid calling ataflop_alloc_disk() from ataflop_probe() after del_gendisk() from atari_floppy_exit().
By relocating __register_blkdev() / unregister_blkdev() as explained above, we can remove ataflop_probe_lock mutex, for probe function and __exit function are serialized by major_names_lock mutex.
--- drivers/block/ataflop.c | 47 +++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 20 deletions(-)
drivers/block/ataflop.c +27 -20
@@ -2008,8 +2008,6 @@ static int ataflop_alloc_disk(unsigned int drive, unsigned int type)return 0 ; } -static DEFINE_MUTEX (ataflop_probe_lock); -static void ataflop_probe (dev_t dev) {int drive =MINOR (dev) &3 ;
@@ -2020,14 +2018,32 @@ static void ataflop_probe(dev_t dev)if (drive >=FD_MAX_UNITS || type >=NUM_DISK_MINORS )return ; -mutex_lock (&ataflop_probe_lock);if (!unit[drive].disk[type]) {if (ataflop_alloc_disk (drive, type) ==0 ) {add_disk (unit[drive].disk[type]); unit[drive].registered[type] = true; } } -mutex_unlock (&ataflop_probe_lock); +} + +static void atari_floppy_cleanup (void ) +{ +int i; +int type; + +for (i =0 ; i <FD_MAX_UNITS ; i++) { +for (type =0 ; type <NUM_DISK_MINORS ; type++) { +if (!unit[i].disk[type]) +continue ; +del_gendisk (unit[i].disk[type]); +blk_cleanup_queue (unit[i].disk[type]->queue); +put_disk (unit[i].disk[type]); + } +blk_mq_free_tag_set (&unit[i].tag_set); + } + +del_timer_sync (&fd_timer); +atari_stram_free (DMABuffer); }static void atari_cleanup_floppy_disk (struct atari_floppy_struct *fs)
@@ -2053,11 +2069,6 @@ static int __init atari_floppy_init (void)/* Amiga, Mac, ... don't have Atari-compatible floppy :-) */ return -ENODEV ; -mutex_lock (&ataflop_probe_lock); - ret =__register_blkdev (FLOPPY_MAJOR ,"fd" , ataflop_probe); -if (ret) - goto out_unlock; -for (i =0 ; i <FD_MAX_UNITS ; i++) {memset (&unit[i].tag_set,0 ,sizeof (unit[i].tag_set)); unit[i].tag_set.ops = &ataflop_mq_ops;
@@ -2111,15 +2122,17 @@ static int __init atari_floppy_init (void) UseTrackbuffer ? "" : "no ");config_types (); -return 0 ; + ret =__register_blkdev (FLOPPY_MAJOR ,"fd" , ataflop_probe); +if (ret) { +printk (KERN_ERR "atari_floppy_init: cannot register block device\n" ); +atari_floppy_cleanup (); + } +return ret; err:while (--i >=0 )atari_cleanup_floppy_disk (&unit[i]); -unregister_blkdev (FLOPPY_MAJOR ,"fd" ); -out_unlock: -mutex_unlock (&ataflop_probe_lock);return ret; }
@@ -2164,14 +2177,8 @@ __setup("floppy=", atari_floppy_setup); static void __exit atari_floppy_exit(void) { -int i; - -for (i =0 ; i <FD_MAX_UNITS ; i++) -atari_cleanup_floppy_disk (&unit[i]);unregister_blkdev (FLOPPY_MAJOR ,"fd" ); - -del_timer_sync (&fd_timer); -atari_stram_free ( DMABuffer ); +atari_floppy_cleanup (); }module_init (atari_floppy_init)
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 736/849 PCI: Do not enable AtomicOps on VFs
In reply to Greg Kroah-HartmanFrom: Selvin Xavier <[email protected]>
[ Upstream commit 5ec0a6fcb60ea430f8ee7e0bec22db9b22f856d3 ]
Host crashes when pci_enable_atomic_ops_to_root() is called for VFs with virtual buses. The virtual buses added to SR-IOV have bus->self set to NULL and host crashes due to this.
PID: 4481 TASK: ffff89c6941b0000 CPU: 53 COMMAND: "bash"
...
#3 [ffff9a9481713808] oops_end at ffffffffb9025cd6 #4 [ffff9a9481713828] page_fault_oops at ffffffffb906e417 #5 [ffff9a9481713888] exc_page_fault at ffffffffb9a0ad14 #6 [ffff9a94817138b0] asm_exc_page_fault at ffffffffb9c00ace
[exception RIP: pcie_capability_read_dword+28]
RIP: ffffffffb952fd5c RSP: ffff9a9481713960 RFLAGS: 00010246
RAX: 0000000000000001 RBX: ffff89c6b1096000 RCX: 0000000000000000
RDX: ffff9a9481713990 RSI: 0000000000000024 RDI: 0000000000000000
RBP: 0000000000000080 R8: 0000000000000008 R9: ffff89c64341a2f8
R10: 0000000000000002 R11: 0000000000000000 R12: ffff89c648bab000
R13: 0000000000000000 R14: 0000000000000000 R15: ffff89c648bab0c8
ORIG_RAX: ffffffffffffffff CS: 0010 SS: 0018 #7 [ffff9a9481713988] pci_enable_atomic_ops_to_root at ffffffffb95359a6 #8 [ffff9a94817139c0] bnxt_qplib_determine_atomics at ffffffffc08c1a33 [bnxt_re] #9 [ffff9a94817139d0] bnxt_re_dev_init at ffffffffc08ba2d1 [bnxt_re]
Per PCIe r5.0, sec 9.3.5.10, the AtomicOp Requester Enable bit in Device Control 2 is reserved for VFs. The PF value applies to all associated VFs.
Return -EINVAL if pci_enable_atomic_ops_to_root() is called for a VF.
--- drivers/pci/pci.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/pci/pci.c +8 -0
@@ -3709,6 +3709,14 @@ int pci_enable_atomic_ops_to_root(struct pci_dev *dev, u32 cap_mask)struct pci_dev *bridge;u32 cap, ctl2; +/* +* Per PCIe r5.0, sec 9.3.5.10, the AtomicOp Requester Enable bit +* in Device Control 2 is reserved in VFs and the PF value applies +* to all associated VFs. +*/ +if (dev->is_virtfn) +return -EINVAL ; +if (!pci_is_pcie (dev))return -EINVAL ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 737/849 cpufreq: intel_pstate: Clear HWP desired on suspend/shutdown and offline
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
[ Upstream commit dbea75fe18f60e364de6d994fc938a24ba249d81 ]
Commit a365ab6b9dfb ("cpufreq: intel_pstate: Implement the ->adjust_perf() callback") caused intel_pstate to use nonzero HWP desired values in certain usage scenarios, but it did not prevent them from being leaked into the confugirations in which HWP desired is expected to be 0.
The failing scenarios are switching the driver from the passive mode to the active mode and starting a new kernel via kexec() while intel_pstate is running in the passive mode.
To address this issue, ensure that HWP desired will be cleared on offline and suspend/shutdown.
--- drivers/cpufreq/intel_pstate.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-)
drivers/cpufreq/intel_pstate.c +30 -2
@@ -1076,9 +1076,16 @@ static void intel_pstate_hwp_offline(struct cpudata *cpu)*/ value &= ~GENMASK_ULL (31 ,24 ); value |=HWP_ENERGY_PERF_PREFERENCE (cpu->epp_cached); -WRITE_ONCE (cpu->hwp_req_cached, value); } +/* +* Clear the desired perf field in the cached HWP request value to +* prevent nonzero desired values from being leaked into the active +* mode. +*/ + value &= ~HWP_DESIRED_PERF (~0L ); +WRITE_ONCE (cpu->hwp_req_cached, value); + value &= ~GENMASK_ULL (31 ,0 ); min_perf =HWP_LOWEST_PERF (READ_ONCE (cpu->hwp_cap_cached));
@@ -2947,6 +2954,27 @@ static int intel_cpufreq_cpu_exit(struct cpufreq_policy *policy)return intel_pstate_cpu_exit (policy); } +static int intel_cpufreq_suspend (struct cpufreq_policy *policy) +{ +intel_pstate_suspend (policy); + +if (hwp_active) { +struct cpudata *cpu = all_cpu_data[policy->cpu]; +u64 value =READ_ONCE (cpu->hwp_req_cached); + +/* +* Clear the desired perf field in MSR_HWP_REQUEST in case +* intel_cpufreq_adjust_perf() is in use and the last value +* written by it may not be suitable. +*/ + value &= ~HWP_DESIRED_PERF (~0L ); +wrmsrl_on_cpu (cpu->cpu,MSR_HWP_REQUEST , value); +WRITE_ONCE (cpu->hwp_req_cached, value); + } + +return 0 ; +} +static struct cpufreq_driver intel_cpufreq = { .flags =CPUFREQ_CONST_LOOPS , .verify = intel_cpufreq_verify_policy,
@@ -2956,7 +2984,7 @@ static struct cpufreq_driver intel_cpufreq = { .exit = intel_cpufreq_cpu_exit, .offline = intel_cpufreq_cpu_offline, .online = intel_pstate_cpu_online, - .suspend = intel_pstate_suspend, + .suspend = intel_cpufreq_suspend, .resume = intel_pstate_resume, .update_limits = intel_pstate_update_limits, .name = "intel_cpufreq",
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 738/849 net: phy: fix duplex out of sync problem while changing settings
In reply to Greg Kroah-HartmanFrom: Heiner Kallweit <[email protected]>
[ Upstream commit a4db9055fdb9cf607775c66d39796caf6439ec92 ]
As reported by Zhang there's a small issue if in forced mode the duplex mode changes with the link staying up [0]. In this case the MAC isn't notified about the change.
The proposed patch relies on the phylib state machine and ignores the fact that there are drivers that uses phylib but not the phylib state machine. So let's don't change the behavior for such drivers and fix it w/o re-adding state PHY_FORCING for the case that phylib state machine is used.
[0] https://lore.kernel.org/netdev/[email protected]/T/
--- drivers/net/phy/phy.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/phy/phy.c +6 -1
@@ -815,7 +815,12 @@ int phy_ethtool_ksettings_set(struct phy_device *phydev, phydev->mdix_ctrl = cmd->base.eth_tp_mdix_ctrl;/* Restart the PHY */ -_phy_start_aneg (phydev); +if (phy_is_started (phydev)) { + phydev->state =PHY_UP ; +phy_trigger_machine (phydev); + }else { +_phy_start_aneg (phydev); + }mutex_unlock (&phydev->lock);return 0 ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 739/849 drm/ttm: remove ttm_bo_vm_insert_huge()
In reply to Greg Kroah-HartmanFrom: Jason Gunthorpe <[email protected]>
[ Upstream commit 0d979509539ed1df883a30d442177ca7be609565 ]
The huge page functionality in TTM does not work safely because PUD and PMD entries do not have a special bit.
get_user_pages_fast() considers any page that passed pmd_huge() as usable:
if (unlikely(pmd_trans_huge(pmd) || pmd_huge(pmd) ||
pmd_devmap(pmd))) {And vmf_insert_pfn_pmd_prot() unconditionally sets
entry = pmd_mkhuge(pfn_t_pmd(pfn, prot));
eg on x86 the page will be _PAGE_PRESENT | PAGE_PSE.
As such gup_huge_pmd() will try to deref a struct page:
head = try_grab_compound_head(pmd_page(orig), refs, flags);
and thus crash.
Thomas further notices that the drivers are not expecting the struct page to be used by anything - in particular the refcount incr above will cause them to malfunction.
Thus everything about this is not able to fully work correctly considering GUP_fast. Delete it entirely. It can return someday along with a proper PMD/PUD_SPECIAL bit in the page table itself to gate GUP_fast.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 2 +- drivers/gpu/drm/nouveau/nouveau_gem.c | 2 +- drivers/gpu/drm/radeon/radeon_gem.c | 2 +- drivers/gpu/drm/ttm/ttm_bo_vm.c | 94 +--------------------- drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 4 - drivers/gpu/drm/vmwgfx/vmwgfx_page_dirty.c | 72 +---------------- drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c | 3 - include/drm/ttm/ttm_bo_api.h | 3 +- 8 files changed, 7 insertions(+), 175 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +1 -1
@@ -61,7 +61,7 @@ static vm_fault_t amdgpu_gem_fault(struct vm_fault *vmf) } ret =ttm_bo_vm_fault_reserved (vmf, vmf->vma->vm_page_prot, -TTM_BO_VM_NUM_PREFAULT ,1 ); +TTM_BO_VM_NUM_PREFAULT );drm_dev_exit (idx); }else {
drivers/gpu/drm/nouveau/nouveau_gem.c +1 -1
@@ -56,7 +56,7 @@ static vm_fault_t nouveau_ttm_fault(struct vm_fault *vmf)nouveau_bo_del_io_reserve_lru (bo); prot =vm_get_page_prot (vma->vm_flags); - ret =ttm_bo_vm_fault_reserved (vmf, prot,TTM_BO_VM_NUM_PREFAULT ,1 ); + ret =ttm_bo_vm_fault_reserved (vmf, prot,TTM_BO_VM_NUM_PREFAULT );nouveau_bo_add_io_reserve_lru (bo);if (ret ==VM_FAULT_RETRY && !(vmf->flags &FAULT_FLAG_RETRY_NOWAIT ))return ret;
drivers/gpu/drm/radeon/radeon_gem.c +1 -1
@@ -61,7 +61,7 @@ static vm_fault_t radeon_gem_fault(struct vm_fault *vmf) goto unlock_resv; ret =ttm_bo_vm_fault_reserved (vmf, vmf->vma->vm_page_prot, -TTM_BO_VM_NUM_PREFAULT ,1 ); +TTM_BO_VM_NUM_PREFAULT );if (ret ==VM_FAULT_RETRY && !(vmf->flags &FAULT_FLAG_RETRY_NOWAIT )) goto unlock_mclk;
drivers/gpu/drm/ttm/ttm_bo_vm.c +2 -92
124 lines not on this page · raw message
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +0 -4
@@ -1526,10 +1526,6 @@ void vmw_bo_dirty_unmap(struct vmw_buffer_object *vbo, pgoff_t start, pgoff_t end);vm_fault_t vmw_bo_vm_fault (struct vm_fault *vmf);vm_fault_t vmw_bo_vm_mkwrite (struct vm_fault *vmf); -#ifdef CONFIG_TRANSPARENT_HUGEPAGE -vm_fault_t vmw_bo_vm_huge_fault (struct vm_fault *vmf, -enum page_entry_size pe_size); -#endif /* Transparent hugepage support - vmwgfx_thp.c */ #ifdef CONFIG_TRANSPARENT_HUGEPAGE
drivers/gpu/drm/vmwgfx/vmwgfx_page_dirty.c +1 -71
81 lines not on this page · raw message
drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c +0 -3
@@ -61,9 +61,6 @@ int vmw_mmap(struct file *filp, struct vm_area_struct *vma) .fault = vmw_bo_vm_fault, .open = ttm_bo_vm_open, .close = ttm_bo_vm_close, -#ifdef CONFIG_TRANSPARENT_HUGEPAGE - .huge_fault = vmw_bo_vm_huge_fault, -#endif };struct drm_file *file_priv = filp->private_data;struct vmw_private *dev_priv =vmw_priv (file_priv->minor->dev);
include/drm/ttm/ttm_bo_api.h +1 -2
@@ -594,8 +594,7 @@ vm_fault_t ttm_bo_vm_reserve(struct ttm_buffer_object *bo,vm_fault_t ttm_bo_vm_fault_reserved (struct vm_fault *vmf,pgprot_t prot, -pgoff_t num_prefault, -pgoff_t fault_page_size); +pgoff_t num_prefault);vm_fault_t ttm_bo_vm_fault (struct vm_fault *vmf);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 740/849 bonding: Fix a use-after-free problem when bond_sysfs_slave_add() failed
In reply to Greg Kroah-HartmanFrom: Huang Guobin <[email protected]>
[ Upstream commit b93c6a911a3fe926b00add28f3b932007827c4ca ]
When I do fuzz test for bonding device interface, I got the following use-after-free Calltrace:
==================================================================
BUG: KASAN: use-after-free in bond_enslave+0x1521/0x24f0
Read of size 8 at addr ffff88825bc11c00 by task ifenslave/7365
CPU: 5 PID: 7365 Comm: ifenslave Tainted: G E 5.15.0-rc1+ #13
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1 04/01/2014
Call Trace:
dump_stack_lvl+0x6c/0x8b
print_address_description.constprop.0+0x48/0x70
kasan_report.cold+0x82/0xdb
__asan_load8+0x69/0x90
bond_enslave+0x1521/0x24f0
bond_do_ioctl+0x3e0/0x450
dev_ifsioc+0x2ba/0x970
dev_ioctl+0x112/0x710
sock_do_ioctl+0x118/0x1b0
sock_ioctl+0x2e0/0x490
__x64_sys_ioctl+0x118/0x150
do_syscall_64+0x35/0xb0
entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x7f19159cf577
Code: b3 66 90 48 8b 05 11 89 2c 00 64 c7 00 26 00 00 00 48 c7 c0 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 b8 10 00 00 00 0f 05 <48> 3d 01 f0 ff ff 78
RSP: 002b:00007ffeb3083c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007ffeb3084bca RCX: 00007f19159cf577
RDX: 00007ffeb3083ce0 RSI: 0000000000008990 RDI: 0000000000000003
RBP: 00007ffeb3084bc4 R08: 0000000000000040 R09: 0000000000000000
R10: 00007ffeb3084bc0 R11: 0000000000000246 R12: 00007ffeb3083ce0
R13: 0000000000000000 R14: 0000000000000000 R15: 00007ffeb3083cb0
Allocated by task 7365:
kasan_save_stack+0x23/0x50
__kasan_kmalloc+0x83/0xa0
kmem_cache_alloc_trace+0x22e/0x470
bond_enslave+0x2e1/0x24f0
bond_do_ioctl+0x3e0/0x450
dev_ifsioc+0x2ba/0x970
dev_ioctl+0x112/0x710
sock_do_ioctl+0x118/0x1b0
sock_ioctl+0x2e0/0x490
__x64_sys_ioctl+0x118/0x150
do_syscall_64+0x35/0xb0
entry_SYSCALL_64_after_hwframe+0x44/0xae
Freed by task 7365:
kasan_save_stack+0x23/0x50
kasan_set_track+0x20/0x30
kasan_set_free_info+0x24/0x40
__kasan_slab_free+0xf2/0x130
kfree+0xd1/0x5c0
slave_kobj_release+0x61/0x90
kobject_put+0x102/0x180
bond_sysfs_slave_add+0x7a/0xa0
bond_enslave+0x11b6/0x24f0
bond_do_ioctl+0x3e0/0x450
dev_ifsioc+0x2ba/0x970
dev_ioctl+0x112/0x710
sock_do_ioctl+0x118/0x1b0
sock_ioctl+0x2e0/0x490
__x64_sys_ioctl+0x118/0x150
do_syscall_64+0x35/0xb0
entry_SYSCALL_64_after_hwframe+0x44/0xae
Last potentially related work creation:
kasan_save_stack+0x23/0x50
kasan_record_aux_stack+0xb7/0xd0
insert_work+0x43/0x190
__queue_work+0x2e3/0x970
delayed_work_timer_fn+0x3e/0x50
call_timer_fn+0x148/0x470
run_timer_softirq+0x8a8/0xc50
__do_softirq+0x107/0x55f
Second to last potentially related work creation:
kasan_save_stack+0x23/0x50
kasan_record_aux_stack+0xb7/0xd0
insert_work+0x43/0x190
__queue_work+0x2e3/0x970
__queue_delayed_work+0x130/0x180
queue_delayed_work_on+0xa7/0xb0
bond_enslave+0xe25/0x24f0
bond_do_ioctl+0x3e0/0x450
dev_ifsioc+0x2ba/0x970
dev_ioctl+0x112/0x710
sock_do_ioctl+0x118/0x1b0
sock_ioctl+0x2e0/0x490
__x64_sys_ioctl+0x118/0x150
do_syscall_64+0x35/0xb0
entry_SYSCALL_64_after_hwframe+0x44/0xae
The buggy address belongs to the object at ffff88825bc11c00
which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 0 bytes inside of
1024-byte region [ffff88825bc11c00, ffff88825bc12000)
The buggy address belongs to the page:
page:ffffea00096f0400 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x25bc10
head:ffffea00096f0400 order:3 compound_mapcount:0 compound_pincount:0
flags: 0x57ff00000010200(slab|head|node=1|zone=2|lastcpupid=0x7ff)
raw: 057ff00000010200 ffffea0009a71c08 ffff888240001968 ffff88810004dbc0
raw: 0000000000000000 00000000000a000a 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff88825bc11b00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88825bc11b80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88825bc11c00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88825bc11c80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88825bc11d00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================Put new_slave in bond_sysfs_slave_add() will cause use-after-free problems when new_slave is accessed in the subsequent error handling process. Since new_slave will be put in the subsequent error handling process, remove the unnecessary put to fix it.
In addition, when sysfs_create_file() fails, if some files have been crea- ted successfully, we need to call sysfs_remove_file() to remove them. Since there are sysfs_create_files() & sysfs_remove_files() can be used, use these two functions instead.
--- drivers/net/bonding/bond_sysfs_slave.c | 36 ++++++++------------------ 1 file changed, 11 insertions(+), 25 deletions(-)
drivers/net/bonding/bond_sysfs_slave.c +11 -25
@@ -108,15 +108,15 @@ static ssize_t ad_partner_oper_port_state_show(struct slave *slave, char *buf) }static SLAVE_ATTR_RO (ad_partner_oper_port_state); -static const struct slave_attribute *slave_attrs[] = { - &slave_attr_state, - &slave_attr_mii_status, - &slave_attr_link_failure_count, - &slave_attr_perm_hwaddr, - &slave_attr_queue_id, - &slave_attr_ad_aggregator_id, - &slave_attr_ad_actor_oper_port_state, - &slave_attr_ad_partner_oper_port_state, +static const struct attribute *slave_attrs[] = { + &slave_attr_state.attr, + &slave_attr_mii_status.attr, + &slave_attr_link_failure_count.attr, + &slave_attr_perm_hwaddr.attr, + &slave_attr_queue_id.attr, + &slave_attr_ad_aggregator_id.attr, + &slave_attr_ad_actor_oper_port_state.attr, + &slave_attr_ad_partner_oper_port_state.attr,NULL };
@@ -137,24 +137,10 @@ const struct sysfs_ops slave_sysfs_ops = {int bond_sysfs_slave_add (struct slave *slave) { -const struct slave_attribute **a; -int err; - -for (a = slave_attrs; *a; ++a) { - err =sysfs_create_file (&slave->kobj, &((*a)->attr)); -if (err) { -kobject_put (&slave->kobj); -return err; - } - } - -return 0 ; +return sysfs_create_files (&slave->kobj, slave_attrs); }void bond_sysfs_slave_del (struct slave *slave) { -const struct slave_attribute **a; - -for (a = slave_attrs; *a; ++a) -sysfs_remove_file (&slave->kobj, &((*a)->attr)); +sysfs_remove_files (&slave->kobj, slave_attrs); }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 741/849 ALSA: memalloc: Catch call with NULL snd_dma_buffer pointer
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
[ Upstream commit dce9446192439eaac81c21f517325fb473735e53 ]
Although we've covered all calls with NULL dma buffer pointer, so far, there may be still some else in the wild. For catching such a case more easily, add a WARN_ON_ONCE() in snd_dma_get_ops().
--- sound/core/memalloc.c | 2 ++ 1 file changed, 2 insertions(+)
sound/core/memalloc.c +2 -0
@@ -403,6 +403,8 @@ static const struct snd_malloc_ops *dma_ops[] = {static const struct snd_malloc_ops *snd_dma_get_ops (struct snd_dma_buffer *dmab) { +if (WARN_ON_ONCE (!dmab)) +return NULL ;if (WARN_ON_ONCE (dmab->dev.type <=SNDRV_DMA_TYPE_UNKNOWN || dmab->dev.type >=ARRAY_SIZE (dma_ops)))return NULL ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 742/849 mfd: core: Add missing of_node_put for loop iteration
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
[ Upstream commit 002be81140075e17a1ebd5c3c55e356fbab0ddad ]
Early exits from for_each_child_of_node() should decrement the node reference counter. Reported by Coccinelle:
drivers/mfd/mfd-core.c:197:2-24: WARNING:
Function "for_each_child_of_node" should have of_node_put() before goto around lines 209.
--- drivers/mfd/mfd-core.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/mfd/mfd-core.c +2 -0
@@ -198,6 +198,7 @@ static int mfd_add_device(struct device *parent, int id,if (of_device_is_compatible (np, cell->of_compatible)) {/* Ignore 'disabled' devices error free */ if (!of_device_is_available (np)) { +of_node_put (np); ret =0 ; goto fail_alias; }
@@ -205,6 +206,7 @@ static int mfd_add_device(struct device *parent, int id, ret =mfd_match_of_node_to_dev (pdev, np, cell);if (ret == -EAGAIN )continue ; +of_node_put (np);if (ret) goto fail_alias;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 743/849 mfd: cpcap: Add SPI device ID table
In reply to Greg Kroah-HartmanFrom: Mark Brown <[email protected]>
[ Upstream commit d5fa8592b773f4da2b04e7333cd37efec5e4ca43 ]
Currently autoloading for SPI devices does not use the DT ID table, it uses SPI modalises. Supporting OF modalises is going to be difficult if not impractical, an attempt was made but has been reverted, so ensure that module autoloading works for this driver by adding a SPI device ID table.
--- drivers/mfd/motorola-cpcap.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/mfd/motorola-cpcap.c +8 -0
@@ -202,6 +202,13 @@ static const struct of_device_id cpcap_of_match[] = { };MODULE_DEVICE_TABLE (of, cpcap_of_match); +static const struct spi_device_id cpcap_spi_ids[] = { + { .name ="cpcap" , }, + { .name ="6556002" , }, + {}, +}; +MODULE_DEVICE_TABLE (spi, cpcap_spi_ids); +static const struct regmap_config cpcap_regmap_config = { .reg_bits =16 , .reg_stride =4 ,
@@ -342,6 +349,7 @@ static struct spi_driver cpcap_driver = { .pm = &cpcap_pm, }, .probe = cpcap_probe, + .id_table = cpcap_spi_ids, };module_spi_driver (cpcap_driver);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 744/849 mfd: sprd: Add SPI device ID table
In reply to Greg Kroah-HartmanFrom: Mark Brown <[email protected]>
[ Upstream commit c5c7f0677107052060037583b9c8c15d818afb04 ]
Currently autoloading for SPI devices does not use the DT ID table, it uses SPI modalises. Supporting OF modalises is going to be difficult if not impractical, an attempt was made but has been reverted, so ensure that module autoloading works for this driver by adding a SPI device ID table.
--- drivers/mfd/sprd-sc27xx-spi.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/mfd/sprd-sc27xx-spi.c +7 -0
@@ -236,6 +236,12 @@ static const struct of_device_id sprd_pmic_match[] = { };MODULE_DEVICE_TABLE (of, sprd_pmic_match); +static const struct spi_device_id sprd_pmic_spi_ids[] = { + { .name ="sc2731" , .driver_data = (unsigned long )&sc2731_data }, + {}, +}; +MODULE_DEVICE_TABLE (spi, sprd_pmic_spi_ids); +static struct spi_driver sprd_pmic_driver = { .driver = { .name ="sc27xx-pmic" ,
@@ -243,6 +249,7 @@ static struct spi_driver sprd_pmic_driver = { .pm = &sprd_pmic_pm_ops, }, .probe = sprd_pmic_probe, + .id_table = sprd_pmic_spi_ids, };static int __init sprd_pmic_init (void )
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 745/849 mfd: altera-sysmgr: Fix a mistake caused by resource_size conversion
In reply to Greg Kroah-HartmanFrom: Kai Song <[email protected]>
[ Upstream commit fae2570d629cdd72f0611d015fc4ba705ae5422b ]
The resource_size defines that:
res->end - res->start + 1; The origin original code is: sysmgr_config.max_register = res->end - res->start - 3;
So, the correct fix is that:
sysmgr_config.max_register = resource_size(res) - 4;
--- drivers/mfd/altera-sysmgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/altera-sysmgr.c +1 -1
@@ -153,7 +153,7 @@ static int sysmgr_probe(struct platform_device *pdev)if (!base)return -ENOMEM ; - sysmgr_config.max_register =resource_size (res) -3 ; + sysmgr_config.max_register =resource_size (res) -4 ; regmap =devm_regmap_init_mmio (dev, base, &sysmgr_config); }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 746/849 ACPI: PM: Fix device wakeup power reference counting error
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
[ Upstream commit 452a3e723f75880757acf87b053935c43aa89f89 ]
Fix a device wakeup power reference counting error introduced by commit a2d7b2e004af ("ACPI: PM: Fix sharing of wakeup power resources") because of a coding mistake.
--- drivers/acpi/power.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/acpi/power.c +3 -5
@@ -746,13 +746,11 @@ int acpi_disable_wakeup_device_power(struct acpi_device *dev)mutex_lock (&acpi_device_lock); -if (dev->wakeup.prepare_count >1 ) { - dev->wakeup.prepare_count--; +/* Do nothing if wakeup power has not been enabled for this device. */ +if (dev->wakeup.prepare_count <=0 ) goto out; - } -/* Do nothing if wakeup power has not been enabled for this device. */ -if (!dev->wakeup.prepare_count) +if (--dev->wakeup.prepare_count >0 ) goto out; err =acpi_device_sleep_wake (dev,0 ,0 ,0 );
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 747/849 libbpf: Fix lookup_and_delete_elem_flags error reporting
In reply to Greg Kroah-HartmanFrom: Mehrdad Arshad Rad <[email protected]>
[ Upstream commit 64165ddf8ea184631c65e3bbc8d59f6d940590ca ]
Fix bpf_map_lookup_and_delete_elem_flags() to pass the return code through libbpf_err_errno() as we do similarly in bpf_map_lookup_and_delete_elem().
--- tools/lib/bpf/bpf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/lib/bpf/bpf.c +3 -1
@@ -480,6 +480,7 @@ int bpf_map_lookup_and_delete_elem(int fd, const void *key, void *value)int bpf_map_lookup_and_delete_elem_flags (int fd,const void *key,void *value,__u64 flags) {union bpf_attr attr; +int ret;memset (&attr,0 ,sizeof (attr)); attr.map_fd = fd;
@@ -487,7 +488,8 @@ int bpf_map_lookup_and_delete_elem_flags(int fd, const void *key, void *value, _ attr.value =ptr_to_u64 (value); attr.flags = flags; -return sys_bpf (BPF_MAP_LOOKUP_AND_DELETE_ELEM , &attr,sizeof (attr)); + ret =sys_bpf (BPF_MAP_LOOKUP_AND_DELETE_ELEM , &attr,sizeof (attr)); +return libbpf_err_errno (ret); }int bpf_map_delete_elem (int fd,const void *key)
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 748/849 selftests/bpf/xdp_redirect_multi: Put the logs to tmp folder
In reply to Greg Kroah-HartmanFrom: Hangbin Liu <[email protected]>
[ Upstream commit 8b4ac13abe7d82da0e0d22a9ba2e27301559a93e ]
The xdp_redirect_multi test logs are created in selftest folder and not cleaned after test. Let's creat a tmp dir and remove the logs after testing.
--- .../selftests/bpf/test_xdp_redirect_multi.sh | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-)
tools/testing/selftests/bpf/test_xdp_redirect_multi.sh +18 -17
@@ -31,6 +31,7 @@ IFACES="" DRV_MODE="xdpgeneric xdpdrv xdpegress" PASS=0 FAIL=0 +LOG_DIR=$(mktemp -d) test_pass() {
@@ -100,17 +101,17 @@ do_egress_tests() local mode=$1 # mac test - ip netns exec ns2 tcpdump -e -i veth0 -nn -l -e &> mac_ns1-2_${mode}.log & - ip netns exec ns3 tcpdump -e -i veth0 -nn -l -e &> mac_ns1-3_${mode}.log & + ip netns exec ns2 tcpdump -e -i veth0 -nn -l -e &> ${LOG_DIR}/mac_ns1-2_${mode}.log & + ip netns exec ns3 tcpdump -e -i veth0 -nn -l -e &> ${LOG_DIR}/mac_ns1-3_${mode}.log & sleep 0.5 ip netns exec ns1 ping 192.0.2.254 -i 0.1 -c 4 &> /dev/null sleep 0.5 pkill -9 tcpdump # mac check - grep -q "${veth_mac[2]} > ff:ff:ff:ff:ff:ff" mac_ns1-2_${mode}.log && \ + grep -q "${veth_mac[2]} > ff:ff:ff:ff:ff:ff" ${LOG_DIR}/mac_ns1-2_${mode}.log && \ test_pass "$mode mac ns1-2" || test_fail "$mode mac ns1-2" - grep -q "${veth_mac[3]} > ff:ff:ff:ff:ff:ff" mac_ns1-3_${mode}.log && \ + grep -q "${veth_mac[3]} > ff:ff:ff:ff:ff:ff" ${LOG_DIR}/mac_ns1-3_${mode}.log && \ test_pass "$mode mac ns1-3" || test_fail "$mode mac ns1-3" }
@@ -121,9 +122,9 @@ do_ping_tests() # ping6 test: echo request should be redirect back to itself, not others ip netns exec ns1 ip neigh add 2001:db8::2 dev veth0 lladdr 00:00:00:00:00:02 - ip netns exec ns1 tcpdump -i veth0 -nn -l -e &> ns1-1_${mode}.log & - ip netns exec ns2 tcpdump -i veth0 -nn -l -e &> ns1-2_${mode}.log & - ip netns exec ns3 tcpdump -i veth0 -nn -l -e &> ns1-3_${mode}.log & + ip netns exec ns1 tcpdump -i veth0 -nn -l -e &> ${LOG_DIR}/ns1-1_${mode}.log & + ip netns exec ns2 tcpdump -i veth0 -nn -l -e &> ${LOG_DIR}/ns1-2_${mode}.log & + ip netns exec ns3 tcpdump -i veth0 -nn -l -e &> ${LOG_DIR}/ns1-3_${mode}.log & sleep 0.5 # ARP test ip netns exec ns1 ping 192.0.2.254 -i 0.1 -c 4 &> /dev/null
@@ -135,32 +136,32 @@ do_ping_tests() pkill -9 tcpdump # All netns should receive the redirect arp requests - [ $(grep -c "who-has 192.0.2.254" ns1-1_${mode}.log) -gt 4 ] && \ + [ $(grep -c "who-has 192.0.2.254" ${LOG_DIR}/ns1-1_${mode}.log) -gt 4 ] && \ test_pass "$mode arp(F_BROADCAST) ns1-1" || \ test_fail "$mode arp(F_BROADCAST) ns1-1" - [ $(grep -c "who-has 192.0.2.254" ns1-2_${mode}.log) -le 4 ] && \ + [ $(grep -c "who-has 192.0.2.254" ${LOG_DIR}/ns1-2_${mode}.log) -le 4 ] && \ test_pass "$mode arp(F_BROADCAST) ns1-2" || \ test_fail "$mode arp(F_BROADCAST) ns1-2" - [ $(grep -c "who-has 192.0.2.254" ns1-3_${mode}.log) -le 4 ] && \ + [ $(grep -c "who-has 192.0.2.254" ${LOG_DIR}/ns1-3_${mode}.log) -le 4 ] && \ test_pass "$mode arp(F_BROADCAST) ns1-3" || \ test_fail "$mode arp(F_BROADCAST) ns1-3" # ns1 should not receive the redirect echo request, others should - [ $(grep -c "ICMP echo request" ns1-1_${mode}.log) -eq 4 ] && \ + [ $(grep -c "ICMP echo request" ${LOG_DIR}/ns1-1_${mode}.log) -eq 4 ] && \ test_pass "$mode IPv4 (F_BROADCAST|F_EXCLUDE_INGRESS) ns1-1" || \ test_fail "$mode IPv4 (F_BROADCAST|F_EXCLUDE_INGRESS) ns1-1" - [ $(grep -c "ICMP echo request" ns1-2_${mode}.log) -eq 4 ] && \ + [ $(grep -c "ICMP echo request" ${LOG_DIR}/ns1-2_${mode}.log) -eq 4 ] && \ test_pass "$mode IPv4 (F_BROADCAST|F_EXCLUDE_INGRESS) ns1-2" || \ test_fail "$mode IPv4 (F_BROADCAST|F_EXCLUDE_INGRESS) ns1-2" - [ $(grep -c "ICMP echo request" ns1-3_${mode}.log) -eq 4 ] && \ + [ $(grep -c "ICMP echo request" ${LOG_DIR}/ns1-3_${mode}.log) -eq 4 ] && \ test_pass "$mode IPv4 (F_BROADCAST|F_EXCLUDE_INGRESS) ns1-3" || \ test_fail "$mode IPv4 (F_BROADCAST|F_EXCLUDE_INGRESS) ns1-3" # ns1 should receive the echo request, ns2 should not - [ $(grep -c "ICMP6, echo request" ns1-1_${mode}.log) -eq 4 ] && \ + [ $(grep -c "ICMP6, echo request" ${LOG_DIR}/ns1-1_${mode}.log) -eq 4 ] && \ test_pass "$mode IPv6 (no flags) ns1-1" || \ test_fail "$mode IPv6 (no flags) ns1-1" - [ $(grep -c "ICMP6, echo request" ns1-2_${mode}.log) -eq 0 ] && \ + [ $(grep -c "ICMP6, echo request" ${LOG_DIR}/ns1-2_${mode}.log) -eq 0 ] && \ test_pass "$mode IPv6 (no flags) ns1-2" || \ test_fail "$mode IPv6 (no flags) ns1-2" }
@@ -176,7 +177,7 @@ do_tests() xdpgeneric) drv_p="-S";; esac - ./xdp_redirect_multi $drv_p $IFACES &> xdp_redirect_${mode}.log & + ./xdp_redirect_multi $drv_p $IFACES &> ${LOG_DIR}/xdp_redirect_${mode}.log & xdp_pid=$! sleep 1
@@ -192,13 +193,13 @@ do_tests() trap clean_up 0 2 3 6 9 check_env -rm -f xdp_redirect_*.log ns*.log mac_ns*.log for mode in ${DRV_MODE}; do setup_ns $mode do_tests $mode clean_up done +rm -rf ${LOG_DIR} echo "Summary: PASS $PASS, FAIL $FAIL" [ $FAIL -eq 0 ] && exit 0 || exit 1
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 749/849 selftests/bpf/xdp_redirect_multi: Use arping to accurate the arp number
In reply to Greg Kroah-HartmanFrom: Hangbin Liu <[email protected]>
[ Upstream commit f53ea9dbf78d42a10e2392b5c59362ccc224fd1d ]
The arp request number triggered by ping none exist address is not accurate, which may lead the test false negative/positive. Change to use arping to accurate the arp number. Also do not use grep pattern match for dot.
--- tools/testing/selftests/bpf/test_xdp_redirect_multi.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
tools/testing/selftests/bpf/test_xdp_redirect_multi.sh +4 -4
@@ -127,7 +127,7 @@ do_ping_tests() ip netns exec ns3 tcpdump -i veth0 -nn -l -e &> ${LOG_DIR}/ns1-3_${mode}.log & sleep 0.5 # ARP test - ip netns exec ns1 ping 192.0.2.254 -i 0.1 -c 4 &> /dev/null + ip netns exec ns1 arping -q -c 2 -I veth0 192.0.2.254 # IPv4 test ip netns exec ns1 ping 192.0.2.253 -i 0.1 -c 4 &> /dev/null # IPv6 test
@@ -136,13 +136,13 @@ do_ping_tests() pkill -9 tcpdump # All netns should receive the redirect arp requests - [ $(grep -c "who-has 192.0.2.254" ${LOG_DIR}/ns1-1_${mode}.log) -gt 4 ] && \ + [ $(grep -cF "who-has 192.0.2.254" ${LOG_DIR}/ns1-1_${mode}.log) -eq 4 ] && \ test_pass "$mode arp(F_BROADCAST) ns1-1" || \ test_fail "$mode arp(F_BROADCAST) ns1-1" - [ $(grep -c "who-has 192.0.2.254" ${LOG_DIR}/ns1-2_${mode}.log) -le 4 ] && \ + [ $(grep -cF "who-has 192.0.2.254" ${LOG_DIR}/ns1-2_${mode}.log) -eq 2 ] && \ test_pass "$mode arp(F_BROADCAST) ns1-2" || \ test_fail "$mode arp(F_BROADCAST) ns1-2" - [ $(grep -c "who-has 192.0.2.254" ${LOG_DIR}/ns1-3_${mode}.log) -le 4 ] && \ + [ $(grep -cF "who-has 192.0.2.254" ${LOG_DIR}/ns1-3_${mode}.log) -eq 2 ] && \ test_pass "$mode arp(F_BROADCAST) ns1-3" || \ test_fail "$mode arp(F_BROADCAST) ns1-3"
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 750/849 selftests/bpf/xdp_redirect_multi: Give tcpdump a chance to terminate cleanly
In reply to Greg Kroah-HartmanFrom: Hangbin Liu <[email protected]>
[ Upstream commit 648c3677062fbd14d754b853daebb295426771e8 ]
No need to kill tcpdump with -9.
--- tools/testing/selftests/bpf/test_xdp_redirect_multi.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/test_xdp_redirect_multi.sh +2 -2
@@ -106,7 +106,7 @@ do_egress_tests() sleep 0.5 ip netns exec ns1 ping 192.0.2.254 -i 0.1 -c 4 &> /dev/null sleep 0.5 - pkill -9 tcpdump + pkill tcpdump # mac check grep -q "${veth_mac[2]} > ff:ff:ff:ff:ff:ff" ${LOG_DIR}/mac_ns1-2_${mode}.log && \
@@ -133,7 +133,7 @@ do_ping_tests() # IPv6 test ip netns exec ns1 ping6 2001:db8::2 -i 0.1 -c 2 &> /dev/null sleep 0.5 - pkill -9 tcpdump + pkill tcpdump # All netns should receive the redirect arp requests [ $(grep -cF "who-has 192.0.2.254" ${LOG_DIR}/ns1-1_${mode}.log) -eq 4 ] && \
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 751/849 selftests/bpf/xdp_redirect_multi: Limit the tests in netns
In reply to Greg Kroah-HartmanFrom: Hangbin Liu <[email protected]>
[ Upstream commit 8955c1a329873385775081e029d9a7c6aa9037e1 ]
As I want to test both DEVMAP and DEVMAP_HASH in XDP multicast redirect, I limited DEVMAP max entries to a small value for performace. When the test runs after amount of interface creating/deleting tests. The interface index will exceed the map max entries and xdp_redirect_multi will error out with "Get interfacesInterface index to large".
Fix this issue by limit the tests in netns and specify the ifindex when creating interfaces.
--- .../selftests/bpf/test_xdp_redirect_multi.sh | 23 ++++++++++++------- .../selftests/bpf/xdp_redirect_multi.c | 4 ++-- 2 files changed, 17 insertions(+), 10 deletions(-)
tools/testing/selftests/bpf/test_xdp_redirect_multi.sh +15 -8
@@ -2,11 +2,11 @@ # SPDX-License-Identifier: GPL-2.0 # # Test topology: -# - - - - - - - - - - - - - - - - - - - - - - - - - -# | veth1 veth2 veth3 | ... init net +# - - - - - - - - - - - - - - - - - - - +# | veth1 veth2 veth3 | ns0 # - -| - - - - - - | - - - - - - | - - # --------- --------- --------- -# | veth0 | | veth0 | | veth0 | ... +# | veth0 | | veth0 | | veth0 | # --------- --------- --------- # ns1 ns2 ns3 #
@@ -51,6 +51,7 @@ clean_up() ip link del veth$i 2> /dev/null ip netns del ns$i 2> /dev/null done + ip netns del ns0 2> /dev/null } # Kselftest framework requirement - SKIP code is 4.
@@ -78,10 +79,12 @@ setup_ns() mode="xdpdrv" fi + ip netns add ns0 for i in $(seq $NUM); do ip netns add ns$i - ip link add veth$i type veth peer name veth0 netns ns$i - ip link set veth$i up + ip -n ns$i link add veth0 index 2 type veth \ + peer name veth$i netns ns0 index $((1 + $i)) + ip -n ns0 link set veth$i up ip -n ns$i link set veth0 up ip -n ns$i addr add 192.0.2.$i/24 dev veth0
@@ -92,7 +95,7 @@ setup_ns() xdp_dummy.o sec xdp_dummy &> /dev/null || \ { test_fail "Unable to load dummy xdp" && exit 1; } IFACES="$IFACES veth$i" - veth_mac[$i]=$(ip link show veth$i | awk '/link\/ether/ {print $2}') + veth_mac[$i]=$(ip -n ns0 link show veth$i | awk '/link\/ether/ {print $2}') done }
@@ -177,9 +180,13 @@ do_tests() xdpgeneric) drv_p="-S";; esac - ./xdp_redirect_multi $drv_p $IFACES &> ${LOG_DIR}/xdp_redirect_${mode}.log & + ip netns exec ns0 ./xdp_redirect_multi $drv_p $IFACES &> ${LOG_DIR}/xdp_redirect_${mode}.log & xdp_pid=$! sleep 1 + if ! ps -p $xdp_pid > /dev/null; then + test_fail "$mode xdp_redirect_multi start failed" + return 1 + fi if [ "$mode" = "xdpegress" ]; then do_egress_tests $mode
@@ -190,7 +197,7 @@ do_tests() kill $xdp_pid } -trap clean_up 0 2 3 6 9 +trap clean_up EXIT check_env
tools/testing/selftests/bpf/xdp_redirect_multi.c +2 -2
@@ -129,7 +129,7 @@ int main(int argc, char **argv) goto err_out; } -printf ("Get interfaces" ); +printf ("Get interfaces:" );for (i =0 ; i <MAX_IFACE_NUM && argv[optind + i]; i++) { ifaces[i] =if_nametoindex (argv[optind + i]);if (!ifaces[i])
@@ -139,7 +139,7 @@ int main(int argc, char **argv) goto err_out; }if (ifaces[i] >MAX_INDEX_NUM ) { -printf ("Interface index to large\n" ); +printf (" interface index too large\n" ); goto err_out; }printf (" %d" , ifaces[i]);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 752/849 drm: fb_helper: improve CONFIG_FB dependency
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 9d6366e743f37d36ef69347924ead7bcc596076e ]
My previous patch correctly addressed the possible link failure, but as Jani points out, the dependency is now stricter than it needs to be.
Change it again, to allow DRM_FBDEV_EMULATION to be used when DRM_KMS_HELPER and FB are both loadable modules and DRM is linked into the kernel.
As a side-effect, the option is now only visible when at least one DRM driver makes use of DRM_KMS_HELPER. This is better, because the option has no effect otherwise.
--- drivers/gpu/drm/Kconfig | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/Kconfig +2 -3
@@ -97,9 +97,8 @@ config DRM_DEBUG_DP_MST_TOPOLOGY_REFS config DRM_FBDEV_EMULATION bool "Enable legacy fbdev support for your modesetting driver" - depends on DRM - depends on FB=y || FB=DRM - select DRM_KMS_HELPER + depends on DRM_KMS_HELPER + depends on FB=y || FB=DRM_KMS_HELPER select FB_CFB_FILLRECT select FB_CFB_COPYAREA select FB_CFB_IMAGEBLIT
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 753/849 Revert "drm/imx: Annotate dma-fence critical section in commit path"
In reply to Greg Kroah-HartmanFrom: Fabio Estevam <[email protected]>
[ Upstream commit 14d9a37c952588930d7226953359fea3ab956d39 ]
This reverts commit f4b34faa08428d813fc3629f882c503487f94a12.
Since commit f4b34faa0842 ("drm/imx: Annotate dma-fence critical section in commit path") the following possible circular dependency is detected:
[ 5.001811] ======================================================
[ 5.001817] WARNING: possible circular locking dependency detected
[ 5.001824] 5.14.9-01225-g45da36cc6fcc-dirty #1 Tainted: G W
[ 5.001833] ------------------------------------------------------
[ 5.001838] kworker/u8:0/7 is trying to acquire lock:
[ 5.001848] c1752080 (regulator_list_mutex){+.+.}-{3:3}, at: regulator_lock_dependent+0x40/0x294
[ 5.001903]
[ 5.001903] but task is already holding lock:
[ 5.001909] c176df78 (dma_fence_map){++++}-{0:0}, at: imx_drm_atomic_commit_tail+0x10/0x160
[ 5.001957]
[ 5.001957] which lock already depends on the new lock....
Revert it for now.
Tested on a imx6q-sabresd.
--- drivers/gpu/drm/imx/imx-drm-core.c | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/imx/imx-drm-core.c +0 -2
@@ -81,7 +81,6 @@ static void imx_drm_atomic_commit_tail(struct drm_atomic_state *state)struct drm_plane_state *old_plane_state, *new_plane_state;bool plane_disabling = false;int i; -bool fence_cookie =dma_fence_begin_signalling ();drm_atomic_helper_commit_modeset_disables (dev, state);
@@ -112,7 +111,6 @@ static void imx_drm_atomic_commit_tail(struct drm_atomic_state *state) }drm_atomic_helper_commit_hw_done (state); -dma_fence_end_signalling (fence_cookie); }static const struct drm_mode_config_helper_funcs imx_drm_mode_config_helpers = {
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 754/849 can: etas_es58x: es58x_rx_err_msg(): fix memory leak in error path
In reply to Greg Kroah-HartmanFrom: Vincent Mailhol <[email protected]>
[ Upstream commit d9447f768bc8c60623e4bb3ce65b8f4654d33a50 ]
In es58x_rx_err_msg(), if can->do_set_mode() fails, the function directly returns without calling netif_rx(skb). This means that the skb previously allocated by alloc_can_err_skb() is not freed. In other terms, this is a memory leak.
This patch simply removes the return statement in the error branch and let the function continue.
Issue was found with GCC -fanalyzer, please follow the link below for details.
--- drivers/net/can/usb/etas_es58x/es58x_core.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/can/usb/etas_es58x/es58x_core.c +2 -4
@@ -664,7 +664,7 @@ int es58x_rx_err_msg(struct net_device *netdev, enum es58x_err error,struct can_device_stats *can_stats = &can->can_stats;struct can_frame *cf =NULL ;struct sk_buff *skb; -int ret; +int ret =0 ;if (!netif_running (netdev)) {if (net_ratelimit ())
@@ -823,8 +823,6 @@ int es58x_rx_err_msg(struct net_device *netdev, enum es58x_err error, can->state =CAN_STATE_BUS_OFF ;can_bus_off (netdev); ret = can->do_set_mode (netdev,CAN_MODE_STOP ); -if (ret) -return ret; }break ;
@@ -881,7 +879,7 @@ int es58x_rx_err_msg(struct net_device *netdev, enum es58x_err error, ES58X_EVENT_BUSOFF, timestamp); } -return 0 ; +return ret; }/**
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 755/849 can: mcp251xfd: mcp251xfd_chip_start(): fix error handling for mcp251xfd_chip_rx_int_enable()
In reply to Greg Kroah-HartmanFrom: Marc Kleine-Budde <[email protected]>
[ Upstream commit 69c55f6e7669d46bb40e41f6e2b218428178368a ]
This patch fixes the error handling for mcp251xfd_chip_rx_int_enable(). Instead just returning the error, properly shut down the chip.
--- drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c +1 -1
@@ -1092,7 +1092,7 @@ static int mcp251xfd_chip_start(struct mcp251xfd_priv *priv) err =mcp251xfd_chip_rx_int_enable (priv);if (err) -return err; + goto out_chip_stop; err =mcp251xfd_chip_ecc_init (priv);if (err)
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 756/849 mm/zsmalloc.c: close race window between zs_pool_dec_isolated() and zs_unregister_migration()
In reply to Greg Kroah-HartmanFrom: Miaohe Lin <[email protected]>
[ Upstream commit afe8605ca45424629fdddfd85984b442c763dc47 ]
There is one possible race window between zs_pool_dec_isolated() and zs_unregister_migration() because wait_for_isolated_drain() checks the isolated count without holding class->lock and there is no order inside zs_pool_dec_isolated(). Thus the below race window could be possible:
zs_pool_dec_isolated zs_unregister_migration
check pool->destroying != 0
pool->destroying = true;
smp_mb();
wait_for_isolated_drain()
wait for pool->isolated_pages == 0
atomic_long_dec(&pool->isolated_pages);
atomic_long_read(&pool->isolated_pages) == 0Since we observe the pool->destroying (false) before atomic_long_dec() for pool->isolated_pages, waking pool->migration_wait up is missed.
Fix this by ensure checking pool->destroying happens after the atomic_long_dec(&pool->isolated_pages).
--- mm/zsmalloc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
mm/zsmalloc.c +4 -3
@@ -1830,10 +1830,11 @@ static inline void zs_pool_dec_isolated(struct zs_pool *pool)VM_BUG_ON (atomic_long_read (&pool->isolated_pages) <=0 );atomic_long_dec (&pool->isolated_pages);/* -* There's no possibility of racing, since wait_for_isolated_drain() -* checks the isolated count under &class->lock after enqueuing -* on migration_wait. +* Checking pool->destroying must happen after atomic_long_dec() +* for pool->isolated_pages above. Paired with the smp_mb() in +* zs_unregister_migration(). */ +smp_mb__after_atomic ();if (atomic_long_read (&pool->isolated_pages) ==0 && pool->destroying)wake_up_all (&pool->migration_wait); }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 757/849 zram: off by one in read_block_state()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit a88e03cf3d190cf46bc4063a9b7efe87590de5f4 ]
snprintf() returns the number of bytes it would have printed if there were space. But it does not count the NUL terminator. So that means that if "count == copied" then this has already overflowed by one character.
This bug likely isn't super harmful in real life.
--- drivers/block/zram/zram_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/zram/zram_drv.c +1 -1
@@ -910,7 +910,7 @@ static ssize_t read_block_state(struct file *file, char __user *buf,zram_test_flag (zram, index,ZRAM_HUGE ) ?'h' :'.' , zram_test_flag(zram, index, ZRAM_IDLE) ? 'i' : '.'); -if (count < copied) { +if (count <= copied) {zram_slot_unlock (zram, index);break ; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 758/849 perf bpf: Add missing free to bpf_event__print_bpf_prog_info()
In reply to Greg Kroah-HartmanFrom: Ian Rogers <[email protected]>
[ Upstream commit 88c42f4d6cb249eb68524282f8d4cc32f9059984 ]
If btf__new() is called then there needs to be a corresponding btf__free().
--- tools/perf/util/bpf-event.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/perf/util/bpf-event.c +3 -1
@@ -564,7 +564,7 @@ void bpf_event__print_bpf_prog_info(struct bpf_prog_info *info,synthesize_bpf_prog_name (name,KSYM_NAME_LEN , info, btf,0 );fprintf (fp,"# bpf_prog_info %u: %s addr 0x%llx size %u\n" , info->id, name, prog_addrs[0 ], prog_lens[0 ]); -return ; + goto out; }fprintf (fp,"# bpf_prog_info %u:\n" , info->id);
@@ -574,4 +574,6 @@ void bpf_event__print_bpf_prog_info(struct bpf_prog_info *info,fprintf (fp,"# \tsub_prog %u: %s addr 0x%llx size %u\n" , i, name, prog_addrs[i], prog_lens[i]); } +out: +btf__free (btf); }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 759/849 llc: fix out-of-bound array index in llc_sk_dev_hash()
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 8ac9dfd58b138f7e82098a4e0a0d46858b12215b ]
Both ifindex and LLC_SK_DEV_HASH_ENTRIES are signed.
This means that (ifindex % LLC_SK_DEV_HASH_ENTRIES) is negative if @ifindex is negative.
We could simply make LLC_SK_DEV_HASH_ENTRIES unsigned.
In this patch I chose to use hash_32() to get more entropy from @ifindex, like llc_sk_laddr_hashfn().
UBSAN: array-index-out-of-bounds in ./include/net/llc.h:75:26 index -43 is out of range for type 'hlist_head [64]' CPU: 1 PID: 20999 Comm: syz-executor.3 Not tainted 5.15.0-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: <TASK> __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106 ubsan_epilogue+0xb/0x5a lib/ubsan.c:151 __ubsan_handle_out_of_bounds.cold+0x62/0x6c lib/ubsan.c:291 llc_sk_dev_hash include/net/llc.h:75 [inline] llc_sap_add_socket+0x49c/0x520 net/llc/llc_conn.c:697 llc_ui_bind+0x680/0xd70 net/llc/af_llc.c:404 __sys_bind+0x1e9/0x250 net/socket.c:1693 __do_sys_bind net/socket.c:1704 [inline] __se_sys_bind net/socket.c:1702 [inline] __x64_sys_bind+0x6f/0xb0 net/socket.c:1702 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae RIP: 0033:0x7fa503407ae9
--- include/net/llc.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
include/net/llc.h +3 -1
@@ -72,7 +72,9 @@ struct llc_sap {static inline struct hlist_head *llc_sk_dev_hash (struct llc_sap *sap,int ifindex) { -return &sap->sk_dev_hash[ifindex %LLC_SK_DEV_HASH_ENTRIES ]; +u32 bucket =hash_32 (ifindex,LLC_SK_DEV_HASH_BITS ); + +return &sap->sk_dev_hash[bucket]; } static inline
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 760/849 nfc: pn533: Fix double free when pn533_fill_fragment_skbs() fails
In reply to Greg Kroah-HartmanFrom: Chengfeng Ye <[email protected]>
[ Upstream commit 9fec40f850658e00a14a7dd9e06f7fbc7e59cc4a ]
skb is already freed by dev_kfree_skb in pn533_fill_fragment_skbs, but follow error handler branch when pn533_fill_fragment_skbs() fails, skb is freed again, results in double free issue. Fix this by not free skb in error path of pn533_fill_fragment_skbs.
--- drivers/nfc/pn533/pn533.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/nfc/pn533/pn533.c +3 -3
@@ -2218,7 +2218,7 @@ static int pn533_fill_fragment_skbs(struct pn533 *dev, struct sk_buff *skb) frag =pn533_alloc_skb (dev, frag_size);if (!frag) {skb_queue_purge (&dev->fragment_skb); -break ; +return -ENOMEM ; }if (!dev->tgt_mode) {
@@ -2287,7 +2287,7 @@ static int pn533_transceive(struct nfc_dev *nfc_dev,/* jumbo frame ? */ if (skb->len >PN533_CMD_DATAEXCH_DATA_MAXLEN ) { rc =pn533_fill_fragment_skbs (dev, skb); -if (rc <=0 ) +if (rc <0 ) goto error; skb =skb_dequeue (&dev->fragment_skb);
@@ -2355,7 +2355,7 @@ static int pn533_tm_send(struct nfc_dev *nfc_dev, struct sk_buff *skb)/* let's split in multiple chunks if size's too big */ if (skb->len >PN533_CMD_DATAEXCH_DATA_MAXLEN ) { rc =pn533_fill_fragment_skbs (dev, skb); -if (rc <=0 ) +if (rc <0 ) goto error;/* get the first skb */
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 761/849 arm64: arm64_ftr_reg->name may not be a human-readable string
In reply to Greg Kroah-HartmanFrom: Reiji Watanabe <[email protected]>
[ Upstream commit 9dc232a8ab18bb20f1dcb03c8e049e3607f3ed15 ]
The id argument of ARM64_FTR_REG_OVERRIDE() is used for two purposes:
one as the system register encoding (used for the sys_id field of __ftr_reg_entry), and the other as the register name (stringified and used for the name field of arm64_ftr_reg), which is debug information. The id argument is supposed to be a macro that indicates an encoding of the register (eg. SYS_ID_AA64PFR0_EL1, etc).
ARM64_FTR_REG(), which also has the same id argument, uses ARM64_FTR_REG_OVERRIDE() and passes the id to the macro. Since the id argument is completely macro-expanded before it is substituted into a macro body of ARM64_FTR_REG_OVERRIDE(), the stringified id in the body of ARM64_FTR_REG_OVERRIDE is not a human-readable register name, but a string of numeric bitwise operations.
Fix this so that human-readable register names are available as debug information.
--- arch/arm64/kernel/cpufeature.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
arch/arm64/kernel/cpufeature.c +7 -3
@@ -572,15 +572,19 @@ static const struct arm64_ftr_bits ftr_raz[] = { ARM64_FTR_END, }; -#define ARM64_FTR_REG_OVERRIDE (id, table, ovr) { \ +#define __ARM64_FTR_REG_OVERRIDE (id_str, id, table, ovr) { \ .sys_id = id, \ .reg = &(struct arm64_ftr_reg){ \ - .name = #id, \ + .name = id_str, \ .override = (ovr), \ .ftr_bits = &((table)[0]), \ }} -#define ARM64_FTR_REG (id, table) ARM64_FTR_REG_OVERRIDE(id, table, &no_override) +#define ARM64_FTR_REG_OVERRIDE (id, table, ovr) \ + __ARM64_FTR_REG_OVERRIDE(#id, id, table, ovr) + +#define ARM64_FTR_REG (id, table) \ + __ARM64_FTR_REG_OVERRIDE(#id, id, table, &no_override)struct arm64_ftr_override __ro_after_init id_aa64mmfr1_override;struct arm64_ftr_override __ro_after_init id_aa64pfr1_override;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 762/849 arm64: pgtable: make __pte_to_phys/__phys_to_pte_val inline functions
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit c7c386fbc20262c1d911c615c65db6a58667d92c ]
gcc warns about undefined behavior the vmalloc code when building with CONFIG_ARM64_PA_BITS_52, when the 'idx++' in the argument to __phys_to_pte_val() is evaluated twice:
mm/vmalloc.c: In function 'vmap_pfn_apply':mm/vmalloc.c:2800:58: error: operation on 'data->idx' may be undefined [-Werror=sequence-point]
2800 | *pte = pte_mkspecial(pfn_pte(data->pfns[data->idx++], data->prot));
| ~~~~~~~~~^~arch/arm64/include/asm/pgtable-types.h:25:37: note: in definition of macro '__pte'
25 | #define __pte(x) ((pte_t) { (x) } )
| ^arch/arm64/include/asm/pgtable.h:80:15: note: in expansion of macro '__phys_to_pte_val'
80 | __pte(__phys_to_pte_val((phys_addr_t)(pfn) << PAGE_SHIFT) | pgprot_val(prot))
| ^~~~~~~~~~~~~~~~~
mm/vmalloc.c:2800:30: note: in expansion of macro 'pfn_pte'
2800 | *pte = pte_mkspecial(pfn_pte(data->pfns[data->idx++], data->prot));
| ^~~~~~~
I have no idea why this never showed up earlier, but the safest workaround appears to be changing those macros into inline functions so the arguments get evaluated only once.
--- arch/arm64/include/asm/pgtable.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
arch/arm64/include/asm/pgtable.h +9 -3
@@ -67,9 +67,15 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];* page table entry, taking care of 52-bit addresses. */ #ifdef CONFIG_ARM64_PA_BITS_52 -#define __pte_to_phys (pte) \ - ((pte_val(pte) & PTE_ADDR_LOW) | ((pte_val(pte) & PTE_ADDR_HIGH) << 36)) -#define __phys_to_pte_val (phys) (((phys) | ((phys) >> 36)) & PTE_ADDR_MASK) +static inline phys_addr_t __pte_to_phys (pte_t pte) +{ +return (pte_val (pte) &PTE_ADDR_LOW ) | + ((pte_val (pte) &PTE_ADDR_HIGH ) <<36 ); +} +static inline pteval_t __phys_to_pte_val (phys_addr_t phys) +{ +return (phys | (phys >>36 )) &PTE_ADDR_MASK ; +}#else #define __pte_to_phys (pte) (pte_val(pte) & PTE_ADDR_MASK)#define __phys_to_pte_val (phys) (phys)
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 763/849 bpf, sockmap: Remove unhash handler for BPF sockmap usage
In reply to Greg Kroah-HartmanFrom: John Fastabend <[email protected]>
[ Upstream commit b8b8315e39ffaca82e79d86dde26e9144addf66b ]
We do not need to handle unhash from BPF side we can simply wait for the close to happen. The original concern was a socket could transition from ESTABLISHED state to a new state while the BPF hook was still attached. But, we convinced ourself this is no longer possible and we also improved BPF sockmap to handle listen sockets so this is no longer a problem.
More importantly though there are cases where unhash is called when data is in the receive queue. The BPF unhash logic will flush this data which is wrong. To be correct it should keep the data in the receive queue and allow a receiving application to continue reading the data. This may happen when tcp_abort() is received for example. Instead of complicating the logic in unhash simply moving all this to tcp_close() hook solves this.
--- net/ipv4/tcp_bpf.c | 1 - 1 file changed, 1 deletion(-)
net/ipv4/tcp_bpf.c +0 -1
@@ -488,7 +488,6 @@ static void tcp_bpf_rebuild_protos(struct proto prot[TCP_BPF_NUM_CFGS], struct proto *base) { prot[TCP_BPF_BASE ] = *base; - prot[TCP_BPF_BASE ].unhash = sock_map_unhash; prot[TCP_BPF_BASE ].close = sock_map_close; prot[TCP_BPF_BASE ].recvmsg = tcp_bpf_recvmsg; prot[TCP_BPF_BASE ].stream_memory_read = tcp_bpf_stream_read;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 764/849 bpf, sockmap: Fix race in ingress receive verdict with redirect to self
In reply to Greg Kroah-HartmanFrom: John Fastabend <[email protected]>
[ Upstream commit c5d2177a72a1659554922728fc407f59950aa929 ]
A socket in a sockmap may have different combinations of programs attached depending on configuration. There can be no programs in which case the socket acts as a sink only. There can be a TX program in this case a BPF program is attached to sending side, but no RX program is attached. There can be an RX program only where sends have no BPF program attached, but receives are hooked with BPF. And finally, both TX and RX programs may be attached. Giving us the permutations:
None, Tx, Rx, and TxRx
To date most of our use cases have been TX case being used as a fast datapath to directly copy between local application and a userspace proxy. Or Rx cases and TxRX applications that are operating an in kernel based proxy. The traffic in the first case where we hook applications into a userspace application looks like this:
AppA redirect AppB
Tx <-----------> Rx
| | + +
TCP <--> lo <--> TCP
In this case all traffic from AppA (after 3whs) is copied into the AppB ingress queue and no traffic is ever on the TCP recieive_queue.
In the second case the application never receives, except in some rare error cases, traffic on the actual user space socket. Instead the send happens in the kernel.
AppProxy socket pool
sk0 ------------->{sk1,sk2, skn}
^ |
| |
| v
ingress lb egress
TCP TCP
Here because traffic is never read off the socket with userspace recv() APIs there is only ever one reader on the sk receive_queue. Namely the BPF programs.
However, we've started to introduce a third configuration where the BPF program on receive should process the data, but then the normal case is to push the data into the receive queue of AppB.
AppB
recv() (userspace)
-----------------------
tcp_bpf_recvmsg() (kernel)
| |
| |
| |
ingress_msgQ |
| |
RX_BPF |
| |
v v
sk->receive_queueThis is different from the App{A,B} redirect because traffic is first received on the sk->receive_queue.
Now for the issue. The tcp_bpf_recvmsg() handler first checks the ingress_msg queue for any data handled by the BPF rx program and returned with PASS code so that it was enqueued on the ingress msg queue. Then if no data exists on that queue it checks the socket receive queue. Unfortunately, this is the same receive_queue the BPF program is reading data off of. So we get a race. Its possible for the recvmsg() hook to pull data off the receive_queue before the BPF hook has a chance to read it. It typically happens when an application is banging on recv() and getting EAGAINs. Until they manage to race with the RX BPF program.
To fix this we note that before this patch at attach time when the socket is loaded into the map we check if it needs a TX program or just the base set of proto bpf hooks. Then it uses the above general RX hook regardless of if we have a BPF program attached at rx or not. This patch now extends this check to handle all cases enumerated above, TX, RX, TXRX, and none. And to fix above race when an RX program is attached we use a new hook that is nearly identical to the old one except now we do not let the recv() call skip the RX BPF program. Now only the BPF program pulls data from sk->receive_queue and recv() only pulls data from the ingress msgQ post BPF program handling.
With this resolved our AppB from above has been up and running for many hours without detecting any errors. We do this by correlating counters in RX BPF events and the AppB to ensure data is never skipping the BPF program. Selftests, was not able to detect this because we only run them for a short period of time on well ordered send/recvs so we don't get any of the noise we see in real application environments.
--- net/ipv4/tcp_bpf.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+)
net/ipv4/tcp_bpf.c +47 -0
@@ -185,6 +185,41 @@ static int tcp_msg_wait_data(struct sock *sk, struct sk_psock *psock,return ret; } +static int tcp_bpf_recvmsg_parser (struct sock *sk, +struct msghdr *msg, +size_t len, +int nonblock, +int flags, +int *addr_len) +{ +struct sk_psock *psock; +int copied; + +if (unlikely (flags &MSG_ERRQUEUE )) +return inet_recv_error (sk, msg, len, addr_len); + + psock =sk_psock_get (sk); +if (unlikely (!psock)) +return tcp_recvmsg (sk, msg, len, nonblock, flags, addr_len); + +lock_sock (sk); +msg_bytes_ready: + copied =sk_msg_recvmsg (sk, psock, msg, len, flags); +if (!copied) { +long timeo; +int data; + + timeo =sock_rcvtimeo (sk, nonblock); + data =tcp_msg_wait_data (sk, psock, timeo); +if (data && !sk_psock_queue_empty (psock)) + goto msg_bytes_ready; + copied = -EAGAIN ; + } +release_sock (sk); +sk_psock_put (sk, psock); +return copied; +} +static int tcp_bpf_recvmsg (struct sock *sk,struct msghdr *msg,size_t len,int nonblock,int flags,int *addr_len) {
@@ -477,6 +512,8 @@ enum {enum {TCP_BPF_BASE ,TCP_BPF_TX , +TCP_BPF_RX , +TCP_BPF_TXRX ,TCP_BPF_NUM_CFGS , };
@@ -495,6 +532,12 @@ static void tcp_bpf_rebuild_protos(struct proto prot[TCP_BPF_NUM_CFGS], prot[TCP_BPF_TX ] = prot[TCP_BPF_BASE ]; prot[TCP_BPF_TX ].sendmsg = tcp_bpf_sendmsg; prot[TCP_BPF_TX ].sendpage = tcp_bpf_sendpage; + + prot[TCP_BPF_RX ] = prot[TCP_BPF_BASE ]; + prot[TCP_BPF_RX ].recvmsg = tcp_bpf_recvmsg_parser; + + prot[TCP_BPF_TXRX ] = prot[TCP_BPF_TX ]; + prot[TCP_BPF_TXRX ].recvmsg = tcp_bpf_recvmsg_parser; }static void tcp_bpf_check_v6_needs_rebuild (struct proto *ops)
@@ -532,6 +575,10 @@ int tcp_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool restore)int family = sk->sk_family ==AF_INET6 ?TCP_BPF_IPV6 :TCP_BPF_IPV4 ;int config = psock->progs.msg_parser ?TCP_BPF_TX :TCP_BPF_BASE ; +if (psock->progs.stream_verdict || psock->progs.skb_verdict) { + config = (config ==TCP_BPF_TX ) ?TCP_BPF_TXRX :TCP_BPF_RX ; + } +if (restore) {if (inet_csk_has_ulp (sk)) {/* TLS does not have an unhash proto in SW cases,
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 765/849 bpf: sockmap, strparser, and tls are reusing qdisc_skb_cb and colliding
In reply to Greg Kroah-HartmanFrom: John Fastabend <[email protected]>
[ Upstream commit e0dc3b93bd7bcff8c3813d1df43e0908499c7cf0 ]
Strparser is reusing the qdisc_skb_cb struct to stash the skb message handling progress, e.g. offset and length of the skb. First this is poorly named and inherits a struct from qdisc that doesn't reflect the actual usage of cb[] at this layer.
But, more importantly strparser is using the following to access its metadata.
(struct _strp_msg *)((void *)skb->cb + offsetof(struct qdisc_skb_cb, data))
Where _strp_msg is defined as:
struct _strp_msg {
struct strp_msg strp; /* 0 8 */
int accum_len; /* 8 4 */ /* size: 12, cachelines: 1, members: 2 */
/* last cacheline: 12 bytes */};
So we use 12 bytes of ->data[] in struct. However in BPF code running parser and verdict the user has read capabilities into the data[] array as well. Its not too problematic, but we should not be exposing internal state to BPF program. If its really needed then we can use the probe_read() APIs which allow reading kernel memory. And I don't believe cb[] layer poses any API breakage by moving this around because programs can't depend on cb[] across layers.
In order to fix another issue with a ctx rewrite we need to stash a temp variable somewhere. To make this work cleanly this patch builds a cb struct for sk_skb types called sk_skb_cb struct. Then we can use this consistently in the strparser, sockmap space. Additionally we can start allowing ->cb[] write access after this.
--- include/net/strparser.h | 16 +++++++++++++++- net/core/filter.c | 22 ++++++++++++++++++++++ net/strparser/strparser.c | 10 +--------- 3 files changed, 38 insertions(+), 10 deletions(-)
include/net/strparser.h +15 -1
@@ -54,10 +54,24 @@ struct strp_msg {int offset; }; +struct _strp_msg { +/* Internal cb structure. struct strp_msg must be first for passing +* to upper layer. +*/ +struct strp_msg strp; +int accum_len; +}; + +struct sk_skb_cb { +#define SK_SKB_CB_PRIV_LEN 20 +unsigned char data[SK_SKB_CB_PRIV_LEN ]; +struct _strp_msg strp; +}; +static inline struct strp_msg *strp_msg (struct sk_buff *skb) {return (struct strp_msg *)((void *)skb->cb + - offsetof(struct qdisc_skb_cb , data)); + offsetof(struct sk_skb_cb , strp)); }/* Structure for an attached lower socket */
net/core/filter.c +22 -0
@@ -9681,11 +9681,33 @@ static u32 sk_skb_convert_ctx_access(enum bpf_access_type type, struct bpf_prog *prog, u32 *target_size) { struct bpf_insn *insn = insn_buf; +int off;switch (si->off) {case offsetof(struct __sk_buff , data_end): insn =bpf_convert_data_end_access (si, insn);break ; + case offsetof(struct __sk_buff, cb[0]) ... + offsetofend(struct __sk_buff, cb[4]) - 1: + BUILD_BUG_ON(sizeof_field(struct sk_skb_cb, data) < 20); +BUILD_BUG_ON ((offsetof(struct sk_buff , cb) + + offsetof(struct sk_skb_cb , data)) % +sizeof (__u64)); + + prog->cb_access =1 ; + off = si->off; + off -= offsetof(struct __sk_buff, cb[0]); + off += offsetof(struct sk_buff , cb); + off += offsetof(struct sk_skb_cb , data); +if (type ==BPF_WRITE ) + *insn++ =BPF_STX_MEM (BPF_SIZE (si->code), si->dst_reg, + si->src_reg, off); +else + *insn++ =BPF_LDX_MEM (BPF_SIZE (si->code), si->dst_reg, + si->src_reg, off); +break ; + +default :return bpf_convert_ctx_access (type, si, insn_buf, prog, target_size);
net/strparser/strparser.c +1 -9
@@ -27,18 +27,10 @@static struct workqueue_struct *strp_wq; -struct _strp_msg { -/* Internal cb structure. struct strp_msg must be first for passing -* to upper layer. -*/ -struct strp_msg strp; -int accum_len; -}; -static inline struct _strp_msg *_strp_msg (struct sk_buff *skb) {return (struct _strp_msg *)((void *)skb->cb + - offsetof(struct qdisc_skb_cb , data)); + offsetof(struct sk_skb_cb , strp)); }/* Lower lock held */
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 766/849 bpf, sockmap: sk_skb data_end access incorrect when src_reg = dst_reg
In reply to Greg Kroah-HartmanFrom: Jussi Maki <[email protected]>
[ Upstream commit b2c4618162ec615a15883a804cce7e27afecfa58 ]
The current conversion of skb->data_end reads like this:
; data_end = (void*)(long)skb->data_end; 559: (79) r1 = *(u64 *)(r2 +200) ; r1 = skb->data 560: (61) r11 = *(u32 *)(r2 +112) ; r11 = skb->len 561: (0f) r1 += r11 562: (61) r11 = *(u32 *)(r2 +116) 563: (1f) r1 -= r11
But similar to the case in 84f44df664e9 ("bpf: sock_ops sk access may stomp registers when dst_reg = src_reg"), the code will read an incorrect skb->len when src == dst. In this case we end up generating this xlated code:
; data_end = (void*)(long)skb->data_end; 559: (79) r1 = *(u64 *)(r1 +200) ; r1 = skb->data 560: (61) r11 = *(u32 *)(r1 +112) ; r11 = (skb->data)->len 561: (0f) r1 += r11 562: (61) r11 = *(u32 *)(r1 +116) 563: (1f) r1 -= r11
... where line 560 is the reading 4B of (skb->data + 112) instead of the intended skb->len Here the skb pointer in r1 gets set to skb->data and the later deref for skb->len ends up following skb->data instead of skb.
This fixes the issue similarly to the patch mentioned above by creating an additional temporary variable and using to store the register when dst_reg = src_reg. We name the variable bpf_temp_reg and place it in the cb context for sk_skb. Then we restore from the temp to ensure nothing is lost.
--- include/net/strparser.h | 4 ++++ net/core/filter.c | 36 ++++++++++++++++++++++++++++++------ 2 files changed, 34 insertions(+), 6 deletions(-)
include/net/strparser.h +4 -0
@@ -66,6 +66,10 @@ struct sk_skb_cb {#define SK_SKB_CB_PRIV_LEN 20unsigned char data[SK_SKB_CB_PRIV_LEN ];struct _strp_msg strp; +/* temp_reg is a temporary register used for bpf_convert_data_end_access +* when dst_reg == src_reg. +*/ +u64 temp_reg; };static inline struct strp_msg *strp_msg (struct sk_buff *skb)
net/core/filter.c +30 -6
@@ -9655,22 +9655,46 @@ static u32 sock_ops_convert_ctx_access(enum bpf_access_type type,static struct bpf_insn *bpf_convert_data_end_access (const struct bpf_insn *si,struct bpf_insn *insn) { -/* si->dst_reg = skb->data */ +int reg; +int temp_reg_off = offsetof(struct sk_buff , cb) + + offsetof(struct sk_skb_cb , temp_reg); + +if (si->src_reg == si->dst_reg) { +/* We need an extra register, choose and save a register. */ + reg =BPF_REG_9 ; +if (si->src_reg == reg || si->dst_reg == reg) + reg--; +if (si->src_reg == reg || si->dst_reg == reg) + reg--; + *insn++ =BPF_STX_MEM (BPF_DW , si->src_reg, reg, temp_reg_off); + }else { + reg = si->dst_reg; + } + +/* reg = skb->data */ *insn++ = BPF_LDX_MEM(BPF_FIELD_SIZEOF(struct sk_buff, data), - si->dst_reg, si->src_reg, + reg, si->src_reg, offsetof(struct sk_buff , data));/* AX = skb->len */ *insn++ = BPF_LDX_MEM(BPF_FIELD_SIZEOF(struct sk_buff, len),BPF_REG_AX , si->src_reg, offsetof(struct sk_buff , len)); -/* si->dst_reg = skb->data + skb->len */ - *insn++ =BPF_ALU64_REG (BPF_ADD , si->dst_reg,BPF_REG_AX ); +/* reg = skb->data + skb->len */ + *insn++ =BPF_ALU64_REG (BPF_ADD , reg,BPF_REG_AX );/* AX = skb->data_len */ *insn++ = BPF_LDX_MEM(BPF_FIELD_SIZEOF(struct sk_buff, data_len),BPF_REG_AX , si->src_reg, offsetof(struct sk_buff , data_len)); -/* si->dst_reg = skb->data + skb->len - skb->data_len */ - *insn++ =BPF_ALU64_REG (BPF_SUB , si->dst_reg,BPF_REG_AX ); + +/* reg = skb->data + skb->len - skb->data_len */ + *insn++ =BPF_ALU64_REG (BPF_SUB , reg,BPF_REG_AX ); + +if (si->src_reg == si->dst_reg) { +/* Restore the saved register */ + *insn++ =BPF_MOV64_REG (BPF_REG_AX , si->src_reg); + *insn++ =BPF_MOV64_REG (si->dst_reg, reg); + *insn++ =BPF_LDX_MEM (BPF_DW , reg,BPF_REG_AX , temp_reg_off); + }return insn; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 767/849 dmaengine: stm32-dma: fix burst in case of unaligned memory address
In reply to Greg Kroah-HartmanFrom: Amelie Delaunay <[email protected]>
[ Upstream commit af229d2c2557b5cf2a3b1eb39847ec1de7446873 ]
Theorically, address pointers used by STM32 DMA must be chosen so as to ensure that all transfers within a burst block are aligned on the address boundary equal to the size of the transfer.
If this is always the case for peripheral addresses on STM32, it is not for memory addresses if the user doesn't respect this alignment constraint. To avoid a weird behavior of the DMA controller in this case (no error triggered but data are not transferred as expected), force no burst.
--- drivers/dma/stm32-dma.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
drivers/dma/stm32-dma.c +16 -4
@@ -750,8 +750,14 @@ static int stm32_dma_set_xfer_param(struct stm32_dma_chan *chan,if (src_bus_width <0 )return src_bus_width; -/* Set memory burst size */ - src_maxburst =STM32_DMA_MAX_BURST ; +/* +* Set memory burst size - burst not possible if address is not aligned on +* the address boundary equal to the size of the transfer +*/ +if (buf_addr % buf_len) + src_maxburst =1 ; +else + src_maxburst =STM32_DMA_MAX_BURST ; src_best_burst = stm32_dma_get_best_burst(buf_len, src_maxburst, fifoth,
@@ -800,8 +806,14 @@ static int stm32_dma_set_xfer_param(struct stm32_dma_chan *chan,if (dst_bus_width <0 )return dst_bus_width; -/* Set memory burst size */ - dst_maxburst =STM32_DMA_MAX_BURST ; +/* +* Set memory burst size - burst not possible if address is not aligned on +* the address boundary equal to the size of the transfer +*/ +if (buf_addr % buf_len) + dst_maxburst =1 ; +else + dst_maxburst =STM32_DMA_MAX_BURST ; dst_best_burst = stm32_dma_get_best_burst(buf_len, dst_maxburst, fifoth,
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 768/849 dmaengine: stm32-dma: avoid 64-bit division in stm32_dma_get_max_width
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 2498363310e9b5e5de0e104709adc35c9f3ff7d9 ]
Using the % operator on a 64-bit variable is expensive and can cause a link failure:
arm-linux-gnueabi-ld: drivers/dma/stm32-dma.o: in function `stm32_dma_get_max_width':
stm32-dma.c:(.text+0x170): undefined reference to `__aeabi_uldivmod'
arm-linux-gnueabi-ld: drivers/dma/stm32-dma.o: in function `stm32_dma_set_xfer_param':
stm32-dma.c:(.text+0x1cd4): undefined reference to `__aeabi_uldivmod'
As we know that we just want to check the alignment in stm32_dma_get_max_width(), there is no need for a full division, and using a simple mask is a faster replacement.
Same in stm32_dma_set_xfer_param(), change this to only allow burst transfers if the address is a multiple of the length. stm32_dma_get_best_burst just after will take buf_len into account to fix burst in case of misalignment.
--- drivers/dma/stm32-dma.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/dma/stm32-dma.c +3 -3
@@ -278,7 +278,7 @@ static enum dma_slave_buswidth stm32_dma_get_max_width(u32 buf_len, max_width > DMA_SLAVE_BUSWIDTH_1_BYTE) max_width = max_width >>1 ; -if (buf_addr % max_width) +if (buf_addr & (max_width -1 )) max_width =DMA_SLAVE_BUSWIDTH_1_BYTE ;return max_width;
@@ -754,7 +754,7 @@ static int stm32_dma_set_xfer_param(struct stm32_dma_chan *chan,* Set memory burst size - burst not possible if address is not aligned on * the address boundary equal to the size of the transfer */ -if (buf_addr % buf_len) +if (buf_addr & (buf_len -1 )) src_maxburst =1 ;else src_maxburst =STM32_DMA_MAX_BURST ;
@@ -810,7 +810,7 @@ static int stm32_dma_set_xfer_param(struct stm32_dma_chan *chan,* Set memory burst size - burst not possible if address is not aligned on * the address boundary equal to the size of the transfer */ -if (buf_addr % buf_len) +if (buf_addr & (buf_len -1 )) dst_maxburst =1 ;else dst_maxburst =STM32_DMA_MAX_BURST ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 769/849 gve: Fix off by one in gve_tx_timeout()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 1c360cc1cc883fbdf0a258b4df376571fbeac5ee ]
The priv->ntfy_blocks[] has "priv->num_ntfy_blks" elements so this > needs to be >= to prevent an off by one bug. The priv->ntfy_blocks[] array is allocated in gve_alloc_notify_blocks().
--- drivers/net/ethernet/google/gve/gve_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/google/gve/gve_main.c +1 -1
@@ -1132,7 +1132,7 @@ static void gve_tx_timeout(struct net_device *dev, unsigned int txqueue) goto reset; ntfy_idx =gve_tx_idx_to_ntfy (priv, txqueue); -if (ntfy_idx > priv->num_ntfy_blks) +if (ntfy_idx >= priv->num_ntfy_blks) goto reset; block = &priv->ntfy_blocks[ntfy_idx];
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 770/849 drm/i915/fb: Fix rounding error in subsampled plane size calculation
In reply to Greg Kroah-HartmanFrom: Imre Deak <[email protected]>
[ Upstream commit 90ab96f3872eae816f4e07deaa77322a91237960 ]
For NV12 FBs with odd main surface tile-row height the CCS surface height was incorrectly calculated 1 less than the actual value. Fix this by rounding up the result of divison. For consistency do the same for the CCS surface width calculation.
--- drivers/gpu/drm/i915/display/intel_fb.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/display/intel_fb.c +3 -2
@@ -172,8 +172,9 @@ static void intel_fb_plane_dims(const struct intel_framebuffer *fb, int color_plintel_fb_plane_get_subsampling (&main_hsub, &main_vsub, &fb->base, main_plane);intel_fb_plane_get_subsampling (&hsub, &vsub, &fb->base, color_plane); - *w = fb->base.width / main_hsub / hsub; - *h = fb->base.height / main_vsub / vsub; + + *w =DIV_ROUND_UP (fb->base.width, main_hsub * hsub); + *h =DIV_ROUND_UP (fb->base.height, main_vsub * vsub); } static u32 intel_adjust_tile_offset(int *x, int *y,
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 771/849 seq_file: fix passing wrong private data
In reply to Greg Kroah-HartmanFrom: Muchun Song <[email protected]>
[ Upstream commit 10a6de19cad6efb9b49883513afb810dc265fca2 ]
DEFINE_PROC_SHOW_ATTRIBUTE() is supposed to be used to define a series of functions and variables to register proc file easily. And the users can use proc_create_data() to pass their own private data and get it via seq->private in the callback. Unfortunately, the proc file system use PDE_DATA() to get private data instead of inode->i_private. So fix it. Fortunately, there only one user of it which does not pass any private data, so this bug does not break any in-tree codes.
--- include/linux/seq_file.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/seq_file.h +1 -1
@@ -194,7 +194,7 @@ static const struct file_operations __name ## _fops = { \#define DEFINE_PROC_SHOW_ATTRIBUTE (__name) \ static int __name ## _open(struct inode *inode, struct file *file) \ { \ - return single_open(file, __name ## _show, inode->i_private); \ + return single_open(file, __name ## _show, PDE_DATA(inode)); \ } \ \ static const struct proc_ops __name ## _proc_ops = { \
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 772/849 net: dsa: mv88e6xxx: Dont support >1G speeds on 6191X on ports other than 10
In reply to Greg Kroah-HartmanFrom: Marek Behún <[email protected]>
[ Upstream commit dc2fc9f03c5c410d8f01c2206b3d529f80b13733 ]
Model 88E6191X only supports >1G speeds on port 10. Port 0 and 9 are only 1G.
--- drivers/net/dsa/mv88e6xxx/chip.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/dsa/mv88e6xxx/chip.c +4 -1
@@ -639,7 +639,10 @@ static void mv88e6393x_phylink_validate(struct mv88e6xxx_chip *chip, int port,unsigned long *mask, struct phylink_link_state *state) { -if (port ==0 || port ==9 || port ==10 ) { + bool is_6191x = + chip->info->prod_num ==MV88E6XXX_PORT_SWITCH_ID_PROD_6191X ; + +if (((port ==0 || port ==9 ) && !is_6191x) || port ==10 ) { phylink_set(mask, 10000baseT_Full); phylink_set(mask, 10000baseKR_Full); phylink_set(mask, 10000baseCR_Full);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 773/849 net/sched: sch_taprio: fix undefined behavior in ktime_mono_to_any
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 6dc25401cba4d428328eade8ceae717633fdd702 ]
1) if q->tk_offset == TK_OFFS_MAX, then get_tcp_tstamp() calls ktime_mono_to_any() with out-of-bound value.
2) if q->tk_offset is changed in taprio_parse_clockid(), taprio_get_time() might also call ktime_mono_to_any() with out-of-bound value as sysbot found:
UBSAN: array-index-out-of-bounds in kernel/time/timekeeping.c:908:27 index 3 is out of range for type 'ktime_t *[3]' CPU: 1 PID: 25668 Comm: kworker/u4:0 Not tainted 5.15.0-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: bat_events batadv_iv_send_outstanding_bat_ogm_packet Call Trace: <TASK> __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106 ubsan_epilogue+0xb/0x5a lib/ubsan.c:151 __ubsan_handle_out_of_bounds.cold+0x62/0x6c lib/ubsan.c:291 ktime_mono_to_any+0x1d4/0x1e0 kernel/time/timekeeping.c:908 get_tcp_tstamp net/sched/sch_taprio.c:322 [inline] get_packet_txtime net/sched/sch_taprio.c:353 [inline] taprio_enqueue_one+0x5b0/0x1460 net/sched/sch_taprio.c:420 taprio_enqueue+0x3b1/0x730 net/sched/sch_taprio.c:485 dev_qdisc_enqueue+0x40/0x300 net/core/dev.c:3785 __dev_xmit_skb net/core/dev.c:3869 [inline] __dev_queue_xmit+0x1f6e/0x3630 net/core/dev.c:4194 batadv_send_skb_packet+0x4a9/0x5f0 net/batman-adv/send.c:108 batadv_iv_ogm_send_to_if net/batman-adv/bat_iv_ogm.c:393 [inline] batadv_iv_ogm_emit net/batman-adv/bat_iv_ogm.c:421 [inline] batadv_iv_send_outstanding_bat_ogm_packet+0x6d7/0x8e0 net/batman-adv/bat_iv_ogm.c:1701 process_one_work+0x9b2/0x1690 kernel/workqueue.c:2298 worker_thread+0x658/0x11f0 kernel/workqueue.c:2445 kthread+0x405/0x4f0 kernel/kthread.c:327 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
--- net/sched/sch_taprio.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-)
net/sched/sch_taprio.c +17 -10
@@ -95,18 +95,22 @@ static ktime_t sched_base_time(const struct sched_gate_list *sched)return ns_to_ktime (sched->base_time); } -static ktime_t taprio_get_time (struct taprio_sched *q) +static ktime_t taprio_mono_to_any (const struct taprio_sched *q,ktime_t mono) { -ktime_t mono =ktime_get (); +/* This pairs with WRITE_ONCE() in taprio_parse_clockid() */ +enum tk_offsets tk_offset =READ_ONCE (q->tk_offset); -switch (q->tk_offset) { +switch (tk_offset) {case TK_OFFS_MAX :return mono;default : -return ktime_mono_to_any (mono, q->tk_offset); +return ktime_mono_to_any (mono, tk_offset); } +} -return KTIME_MAX ; +static ktime_t taprio_get_time (const struct taprio_sched *q) +{ +return taprio_mono_to_any (q,ktime_get ()); }static void taprio_free_sched_cb (struct rcu_head *head)
@@ -319,7 +323,7 @@ static ktime_t get_tcp_tstamp(struct taprio_sched *q, struct sk_buff *skb)return 0 ; } -return ktime_mono_to_any (skb->skb_mstamp_ns, q->tk_offset); +return taprio_mono_to_any (q, skb->skb_mstamp_ns); }/* There are a few scenarios where we will have to modify the txtime from
@@ -1352,6 +1356,7 @@ static int taprio_parse_clockid(struct Qdisc *sch, struct nlattr **tb, } }else if (tb[TCA_TAPRIO_ATTR_SCHED_CLOCKID ]) {int clockid =nla_get_s32 (tb[TCA_TAPRIO_ATTR_SCHED_CLOCKID ]); +enum tk_offsets tk_offset;/* We only support static clockids and we don't allow * for it to be modified after the first init.
@@ -1366,22 +1371,24 @@ static int taprio_parse_clockid(struct Qdisc *sch, struct nlattr **tb,switch (clockid) {case CLOCK_REALTIME : - q->tk_offset =TK_OFFS_REAL ; + tk_offset =TK_OFFS_REAL ;break ;case CLOCK_MONOTONIC : - q->tk_offset =TK_OFFS_MAX ; + tk_offset =TK_OFFS_MAX ;break ;case CLOCK_BOOTTIME : - q->tk_offset =TK_OFFS_BOOT ; + tk_offset =TK_OFFS_BOOT ;break ;case CLOCK_TAI : - q->tk_offset =TK_OFFS_TAI ; + tk_offset =TK_OFFS_TAI ;break ;default :NL_SET_ERR_MSG (extack,"Invalid 'clockid'" ); err = -EINVAL ; goto out; } +/* This pairs with READ_ONCE() in taprio_mono_to_any */ +WRITE_ONCE (q->tk_offset, tk_offset); q->clockid = clockid; }else {
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 774/849 net: hns3: fix ROCE base interrupt vector initialization bug
In reply to Greg Kroah-HartmanFrom: Jie Wang <[email protected]>
[ Upstream commit beb27ca451a57a1c0e52b5268703f3c3173c1f8c ]
Currently, NIC init ROCE interrupt vector with MSIX interrupt. But ROCE use pci_irq_vector() to get interrupt vector, which adds the relative interrupt vector again and gets wrong interrupt vector.
So fixes it by assign relative interrupt vector to ROCE instead of MSIX interrupt vector and delete the unused struct member base_msi_vector declaration of hclgevf_dev.
--- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 6 +----- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 2 -- drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 5 +---- drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h | 2 -- 4 files changed, 2 insertions(+), 13 deletions(-)
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +1 -5
@@ -2497,7 +2497,7 @@ static int hclge_init_roce_base_info(struct hclge_vport *vport)if (hdev->num_msi < hdev->num_nic_msi + hdev->num_roce_msi)return -EINVAL ; - roce->rinfo.base_vector = hdev->roce_base_vector; + roce->rinfo.base_vector = hdev->num_nic_msi; roce->rinfo.netdev = nic->kinfo.netdev; roce->rinfo.roce_io_base = hdev->hw.io_base;
@@ -2533,10 +2533,6 @@ static int hclge_init_msi(struct hclge_dev *hdev) hdev->num_msi = vectors; hdev->num_msi_left = vectors; - hdev->base_msi_vector = pdev->irq; - hdev->roce_base_vector = hdev->base_msi_vector + - hdev->num_nic_msi; - hdev->vector_status =devm_kcalloc (&pdev->dev, hdev->num_msi,sizeof (u16),GFP_KERNEL );if (!hdev->vector_status) {
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +0 -2
@@ -874,12 +874,10 @@ struct hclge_dev {u16 num_msi;u16 num_msi_left;u16 num_msi_used; -u32 base_msi_vector;u16 *vector_status;int *vector_irq;u16 num_nic_msi;/* Num of nic vectors for this PF */ u16 num_roce_msi;/* Num of roce vectors for this PF */ -int roce_base_vector;unsigned long service_timer_period;unsigned long service_timer_previous;
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +1 -4
@@ -2555,7 +2555,7 @@ static int hclgevf_init_roce_base_info(struct hclgevf_dev *hdev) hdev->num_msi_left == 0)return -EINVAL ; - roce->rinfo.base_vector = hdev->roce_base_vector; + roce->rinfo.base_vector = hdev->roce_base_msix_offset; roce->rinfo.netdev = nic->kinfo.netdev; roce->rinfo.roce_io_base = hdev->hw.io_base;
@@ -2821,9 +2821,6 @@ static int hclgevf_init_msi(struct hclgevf_dev *hdev) hdev->num_msi = vectors; hdev->num_msi_left = vectors; - hdev->base_msi_vector = pdev->irq; - hdev->roce_base_vector = pdev->irq + hdev->roce_base_msix_offset; - hdev->vector_status =devm_kcalloc (&pdev->dev, hdev->num_msi,sizeof (u16),GFP_KERNEL );if (!hdev->vector_status) {
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h +0 -2
@@ -306,8 +306,6 @@ struct hclgevf_dev {u16 num_nic_msix;/* Num of nic vectors for this VF */ u16 num_roce_msix;/* Num of roce vectors for this VF */ u16 roce_base_msix_offset; -int roce_base_vector; -u32 base_msi_vector;u16 *vector_status;int *vector_irq;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 775/849 net: hns3: fix pfc packet number incorrect after querying pfc parameters
In reply to Greg Kroah-HartmanFrom: Jie Wang <[email protected]>
[ Upstream commit 0b653a81a26d66ffe526a54c2177e24fb1400301 ]
Currently, driver will send command to firmware to query pfc packet number when user uses dcb tool to get pfc parameters. However, the periodic service task will also periodically query and record MAC statistics, including pfc packet number.
As the hardware registers of statistics is cleared after reading, it will cause pfc packet number of MAC statistics are not correct after using dcb tool to get pfc parameters.
To fix this problem, when user uses dcb tool to get pfc parameters, driver updates MAC statistics firstly and then get pfc packet number from MAC statistics.
--- .../hisilicon/hns3/hns3pf/hclge_dcb.c | 18 ++--- .../hisilicon/hns3/hns3pf/hclge_main.c | 4 +- .../hisilicon/hns3/hns3pf/hclge_main.h | 4 ++ .../ethernet/hisilicon/hns3/hns3pf/hclge_tm.c | 68 +++++++++---------- .../ethernet/hisilicon/hns3/hns3pf/hclge_tm.h | 4 +- 5 files changed, 48 insertions(+), 50 deletions(-)
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c +7 -11
@@ -265,28 +265,24 @@ err_out:static int hclge_ieee_getpfc (struct hnae3_handle *h,struct ieee_pfc *pfc) { -u64 requests[HNAE3_MAX_TC ], indications[HNAE3_MAX_TC ];struct hclge_vport *vport =hclge_get_vport (h);struct hclge_dev *hdev = vport->back;int ret; -u8 i;memset (pfc,0 ,sizeof (*pfc)); pfc->pfc_cap = hdev->pfc_max; pfc->pfc_en = hdev->tm_info.pfc_en; - ret =hclge_pfc_tx_stats_get (hdev, requests); -if (ret) + ret =hclge_mac_update_stats (hdev); +if (ret) { +dev_err (&hdev->pdev->dev, +"failed to update MAC stats, ret = %d.\n" , ret);return ret; + } - ret =hclge_pfc_rx_stats_get (hdev, indications); -if (ret) -return ret; +hclge_pfc_tx_stats_get (hdev, pfc->requests); +hclge_pfc_rx_stats_get (hdev, pfc->indications); -for (i =0 ; i <HCLGE_MAX_TC_NUM ; i++) { - pfc->requests[i] = requests[i]; - pfc->indications[i] = indications[i]; - }return 0 ; }
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +1 -3
@@ -25,8 +25,6 @@#include "hnae3.h" #define HCLGE_NAME "hclge" -#define HCLGE_STATS_READ (p, offset) (*(u64 *)((u8 *)(p) + (offset))) -#define HCLGE_MAC_STATS_FIELD_OFF (f) (offsetof(struct hclge_mac_stats, f))#define HCLGE_BUF_SIZE_UNIT 256U#define HCLGE_BUF_MUL_BY 2
@@ -547,7 +545,7 @@ static int hclge_mac_query_reg_num(struct hclge_dev *hdev, u32 *desc_num)return 0 ; } -static int hclge_mac_update_stats (struct hclge_dev *hdev) +int hclge_mac_update_stats (struct hclge_dev *hdev) {u32 desc_num;int ret;
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +4 -0
@@ -822,6 +822,9 @@ struct hclge_vf_vlan_cfg { (y) = (_k_ ^ ~_v_) & (_k_); \ } while (0) +#define HCLGE_MAC_STATS_FIELD_OFF (f) (offsetof(struct hclge_mac_stats, f)) +#define HCLGE_STATS_READ (p, offset) (*(u64 *)((u8 *)(p) + (offset))) +#define HCLGE_MAC_TNL_LOG_SIZE 8#define HCLGE_VPORT_NUM 256struct hclge_dev {
@@ -1128,4 +1131,5 @@ void hclge_inform_vf_promisc_info(struct hclge_vport *vport);int hclge_dbg_dump_rst_info (struct hclge_dev *hdev,char *buf,int len);int hclge_push_vf_link_status (struct hclge_vport *vport);int hclge_enable_vport_vlan_filter (struct hclge_vport *vport,bool request_en); +int hclge_mac_update_stats (struct hclge_dev *hdev);#endif
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c +34 -34
84 lines not on this page · raw message
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h +2 -2
@@ -228,8 +228,8 @@ int hclge_tm_dwrr_cfg(struct hclge_dev *hdev);int hclge_tm_init_hw (struct hclge_dev *hdev,bool init);int hclge_mac_pause_en_cfg (struct hclge_dev *hdev,bool tx,bool rx);int hclge_pause_addr_cfg (struct hclge_dev *hdev,const u8 *mac_addr); -int hclge_pfc_rx_stats_get (struct hclge_dev *hdev,u64 *stats); -int hclge_pfc_tx_stats_get (struct hclge_dev *hdev,u64 *stats); +void hclge_pfc_rx_stats_get (struct hclge_dev *hdev,u64 *stats); +void hclge_pfc_tx_stats_get (struct hclge_dev *hdev,u64 *stats);int hclge_tm_qs_shaper_cfg (struct hclge_vport *vport,int max_tx_rate);int hclge_tm_get_qset_num (struct hclge_dev *hdev,u16 *qset_num);int hclge_tm_get_pri_num (struct hclge_dev *hdev,u8 *pri_num);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 776/849 net: hns3: fix kernel crash when unload VF while it is being reset
In reply to Greg Kroah-HartmanFrom: Yufeng Mo <[email protected]>
[ Upstream commit e140c7983e3054be0652bf914f4454f16c5520b0 ]
When fully configure VLANs for a VF, then unload the VF while triggering a reset to PF, will cause a kernel crash because the irq is already uninit.
[ 293.177579] ------------[ cut here ]------------ [ 293.183502] kernel BUG at drivers/pci/msi.c:352! [ 293.189547] Internal error: Oops - BUG: 0 [#1] SMP ...... [ 293.390124] Workqueue: hclgevf hclgevf_service_task [hclgevf] [ 293.402627] pstate: 80c00009 (Nzcv daif +PAN +UAO) [ 293.414324] pc : free_msi_irqs+0x19c/0x1b8 [ 293.425429] lr : free_msi_irqs+0x18c/0x1b8 [ 293.436545] sp : ffff00002716fbb0 [ 293.446950] x29: ffff00002716fbb0 x28: 0000000000000000 [ 293.459519] x27: 0000000000000000 x26: ffff45b91ea16b00 [ 293.472183] x25: 0000000000000000 x24: ffffa587b08f4700 [ 293.484717] x23: ffffc591ac30e000 x22: ffffa587b08f8428 [ 293.497190] x21: ffffc591ac30e300 x20: 0000000000000000 [ 293.509594] x19: ffffa58a062a8300 x18: 0000000000000000 [ 293.521949] x17: 0000000000000000 x16: ffff45b91dcc3f48 [ 293.534013] x15: 0000000000000000 x14: 0000000000000000 [ 293.545883] x13: 0000000000000040 x12: 0000000000000228 [ 293.557508] x11: 0000000000000020 x10: 0000000000000040 [ 293.568889] x9 : ffff45b91ea1e190 x8 : ffffc591802d0000 [ 293.580123] x7 : ffffc591802d0148 x6 : 0000000000000120 [ 293.591190] x5 : ffffc591802d0000 x4 : 0000000000000000 [ 293.602015] x3 : 0000000000000000 x2 : 0000000000000000 [ 293.612624] x1 : 00000000000004a4 x0 : ffffa58a1e0c6b80 [ 293.623028] Call trace: [ 293.630340] free_msi_irqs+0x19c/0x1b8 [ 293.638849] pci_disable_msix+0x118/0x140 [ 293.647452] pci_free_irq_vectors+0x20/0x38 [ 293.656081] hclgevf_uninit_msi+0x44/0x58 [hclgevf] [ 293.665309] hclgevf_reset_rebuild+0x1ac/0x2e0 [hclgevf] [ 293.674866] hclgevf_reset+0x358/0x400 [hclgevf] [ 293.683545] hclgevf_reset_service_task+0xd0/0x1b0 [hclgevf] [ 293.693325] hclgevf_service_task+0x4c/0x2e8 [hclgevf] [ 293.702307] process_one_work+0x1b0/0x448 [ 293.710034] worker_thread+0x54/0x468 [ 293.717331] kthread+0x134/0x138 [ 293.724114] ret_from_fork+0x10/0x18 [ 293.731324] Code: f940b000 b4ffff00 a903e7b8 f90017b6 (d4210000)
This patch fixes the problem by waiting for the VF reset done while unloading the VF.
--- drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 5 +++++ drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h | 2 ++ 2 files changed, 7 insertions(+)
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +5 -0
@@ -3008,7 +3008,10 @@ static void hclgevf_uninit_client_instance(struct hnae3_client *client,/* un-init roce, if it exists */ if (hdev->roce_client) { +while (test_bit (HCLGEVF_STATE_RST_HANDLING , &hdev->state)) +msleep (HCLGEVF_WAIT_RESET_DONE );clear_bit (HCLGEVF_STATE_ROCE_REGISTERED , &hdev->state); + hdev->roce_client->ops->uninit_instance (&hdev->roce,0 ); hdev->roce_client =NULL ; hdev->roce.client =NULL ;
@@ -3017,6 +3020,8 @@ static void hclgevf_uninit_client_instance(struct hnae3_client *client,/* un-init nic/unic, if this was not called by roce client */ if (client->ops->uninit_instance && hdev->nic_client && client->type !=HNAE3_CLIENT_ROCE ) { +while (test_bit (HCLGEVF_STATE_RST_HANDLING , &hdev->state)) +msleep (HCLGEVF_WAIT_RESET_DONE );clear_bit (HCLGEVF_STATE_NIC_REGISTERED , &hdev->state); client->ops->uninit_instance (&hdev->nic,0 );
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h +2 -0
@@ -107,6 +107,8 @@#define HCLGEVF_VF_RST_ING 0x07008#define HCLGEVF_VF_RST_ING_BIT BIT(16) +#define HCLGEVF_WAIT_RESET_DONE 100 +#define HCLGEVF_RSS_IND_TBL_SIZE 512#define HCLGEVF_RSS_SET_BITMAP_MSK 0xffff#define HCLGEVF_RSS_KEY_SIZE 40
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 777/849 net: hns3: allow configure ETS bandwidth of all TCs
In reply to Greg Kroah-HartmanFrom: Guangbin Huang <[email protected]>
[ Upstream commit 688db0c7a4a69ddc8b8143a1cac01eb20082a3aa ]
Currently, driver only allow configuring ETS bandwidth of TCs according to the max TC number queried from firmware. However, the hardware actually supports 8 TCs and users may need to configure ETS bandwidth of all TCs, so remove the restriction.
--- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-)
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c +1 -1
@@ -125,7 +125,7 @@ static int hclge_ets_validate(struct hclge_dev *hdev, struct ieee_ets *ets,if (ret)return ret; -for (i =0 ; i < hdev->tc_max; i++) { +for (i =0 ; i <HNAE3_MAX_TC ; i++) {switch (ets->tc_tsa[i]) {case IEEE_8021QAZ_TSA_STRICT : if (hdev->tm_info.tc_info[i].tc_sch_mode !=
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c +1 -8
@@ -1123,7 +1123,6 @@ static int hclge_tm_pri_tc_base_dwrr_cfg(struct hclge_dev *hdev)static int hclge_tm_ets_tc_dwrr_cfg (struct hclge_dev *hdev) { -#define DEFAULT_TC_WEIGHT 1#define DEFAULT_TC_OFFSET 14struct hclge_ets_tc_weight_cmd *ets_weight;
@@ -1136,13 +1135,7 @@ static int hclge_tm_ets_tc_dwrr_cfg(struct hclge_dev *hdev)for (i =0 ; i <HNAE3_MAX_TC ; i++) {struct hclge_pg_info *pg_info; - ets_weight->tc_weight[i] =DEFAULT_TC_WEIGHT ; - -if (!(hdev->hw_tc_map &BIT (i))) -continue ; - - pg_info = - &hdev->tm_info.pg_info[hdev->tm_info.tc_info[i].pgid]; + pg_info = &hdev->tm_info.pg_info[hdev->tm_info.tc_info[i].pgid]; ets_weight->tc_weight[i] = pg_info->tc_dwrr[i]; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 778/849 net: stmmac: allow a tc-taprio base-time of zero
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit f64ab8e4f368f48afb08ae91928e103d17b235e9 ]
Commit fe28c53ed71d ("net: stmmac: fix taprio configuration when base_time is in the past") allowed some base time values in the past, but apparently not all, the base-time value of 0 (Jan 1st 1970) is still explicitly denied by the driver.
Remove the bogus check.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +0 -2
@@ -786,8 +786,6 @@ static int tc_setup_taprio(struct stmmac_priv *priv, goto disable;if (qopt->num_entries >= dep)return -EINVAL ; -if (!qopt->base_time) -return -ERANGE ;if (!qopt->cycle_time)return -ERANGE ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 779/849 net: ethernet: ti: cpsw_ale: Fix access to un-initialized memory
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 7a166854b4e24c57d56b3eba9fe1594985ee0a2c ]
It is spurious to allocate a bitmap without initializing it. So, better safe than sorry, initialize it to 0 at least to have some known values.
While at it, switch to the devm_bitmap_ API which is less verbose.
--- drivers/net/ethernet/ti/cpsw_ale.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/ethernet/ti/cpsw_ale.c +2 -4
@@ -1299,10 +1299,8 @@ struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params *params)if (!ale)return ERR_PTR (-ENOMEM ); - ale->p0_untag_vid_mask = -devm_kmalloc_array (params->dev,BITS_TO_LONGS (VLAN_N_VID ), -sizeof (unsigned long ), -GFP_KERNEL ); + ale->p0_untag_vid_mask =devm_bitmap_zalloc (params->dev,VLAN_N_VID , +GFP_KERNEL );if (!ale->p0_untag_vid_mask)return ERR_PTR (-ENOMEM );
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 780/849 net: marvell: mvpp2: Fix wrong SerDes reconfiguration order
In reply to Greg Kroah-HartmanFrom: Marek Behún <[email protected]>
[ Upstream commit bb7bbb6e36474933540c24ae1f1ad651b843981f ]
Commit bfe301ebbc94 ("net: mvpp2: convert to use mac_prepare()/mac_finish()") introduced a bug wherein it leaves the MAC RESET register asserted after mac_finish(), due to wrong order of function calls.
Before it was:
.mac_config()
mvpp22_mode_reconfigure()
assert reset
mvpp2_xlg_config()
deassert resetNow it is:
.mac_prepare()
.mac_config()
mvpp2_xlg_config()
deassert reset
.mac_finish()
mvpp2_xlg_config()
assert resetObviously this is wrong.
This bug is triggered when phylink tries to change the PHY interface mode from a GMAC mode (sgmii, 1000base-x, 2500base-x) to XLG mode (10gbase-r, xaui). The XLG mode does not work since reset is left asserted. Only after
ifconfig down && ifconfig up
is called will the XLG mode work.
Move the call to mvpp22_mode_reconfigure() to .mac_prepare() implementation. Since some of the subsequent functions need to know whether the interface is being changed, we unfortunately also need to pass around the new interface mode before setting port->phy_interface.
--- .../net/ethernet/marvell/mvpp2/mvpp2_main.c | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-)
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +20 -18
@@ -1605,7 +1605,7 @@ static void mvpp22_gop_fca_set_periodic_timer(struct mvpp2_port *port)mvpp22_gop_fca_enable_periodic (port, true); } -static int mvpp22_gop_init (struct mvpp2_port *port) +static int mvpp22_gop_init (struct mvpp2_port *port,phy_interface_t interface) {struct mvpp2 *priv = port->priv;u32 val;
@@ -1613,7 +1613,7 @@ static int mvpp22_gop_init(struct mvpp2_port *port)if (!priv->sysctrl_base)return 0 ; -switch (port->phy_interface) { +switch (interface) {case PHY_INTERFACE_MODE_RGMII :case PHY_INTERFACE_MODE_RGMII_ID :case PHY_INTERFACE_MODE_RGMII_RXID :
@@ -1743,15 +1743,15 @@ static void mvpp22_gop_setup_irq(struct mvpp2_port *port)* lanes by the physical layer. This is why configurations like * "PPv2 (2500BaseX) - COMPHY (2500SGMII)" are valid. */ -static int mvpp22_comphy_init (struct mvpp2_port *port) +static int mvpp22_comphy_init (struct mvpp2_port *port, +phy_interface_t interface) {int ret;if (!port->comphy)return 0 ; - ret =phy_set_mode_ext (port->comphy,PHY_MODE_ETHERNET , - port->phy_interface); + ret =phy_set_mode_ext (port->comphy,PHY_MODE_ETHERNET , interface);if (ret)return ret;
@@ -2172,7 +2172,8 @@ static void mvpp22_pcs_reset_assert(struct mvpp2_port *port)writel (val & ~MVPP22_XPCS_CFG0_RESET_DIS , xpcs +MVPP22_XPCS_CFG0 ); } -static void mvpp22_pcs_reset_deassert (struct mvpp2_port *port) +static void mvpp22_pcs_reset_deassert (struct mvpp2_port *port, +phy_interface_t interface) {struct mvpp2 *priv = port->priv;void __iomem *mpcs, *xpcs;
@@ -2184,7 +2185,7 @@ static void mvpp22_pcs_reset_deassert(struct mvpp2_port *port) mpcs = priv->iface_base +MVPP22_MPCS_BASE (port->gop_id); xpcs = priv->iface_base +MVPP22_XPCS_BASE (port->gop_id); -switch (port->phy_interface) { +switch (interface) {case PHY_INTERFACE_MODE_10GBASER : val =readl (mpcs +MVPP22_MPCS_CLK_RESET ); val |= MAC_CLK_RESET_MAC | MAC_CLK_RESET_SD_RX |
@@ -4529,7 +4530,8 @@ static int mvpp2_poll(struct napi_struct *napi, int budget)return rx_done; } -static void mvpp22_mode_reconfigure (struct mvpp2_port *port) +static void mvpp22_mode_reconfigure (struct mvpp2_port *port, +phy_interface_t interface) {u32 ctrl3;
@@ -4540,18 +4542,18 @@ static void mvpp22_mode_reconfigure(struct mvpp2_port *port)mvpp22_pcs_reset_assert (port);/* comphy reconfiguration */ -mvpp22_comphy_init (port); +mvpp22_comphy_init (port, interface);/* gop reconfiguration */ -mvpp22_gop_init (port); +mvpp22_gop_init (port, interface); -mvpp22_pcs_reset_deassert (port); +mvpp22_pcs_reset_deassert (port, interface);if (mvpp2_port_supports_xlg (port)) { ctrl3 =readl (port->base +MVPP22_XLG_CTRL3_REG ); ctrl3 &= ~MVPP22_XLG_CTRL3_MACMODESELECT_MASK ; -if (mvpp2_is_xlg (port->phy_interface)) +if (mvpp2_is_xlg (interface)) ctrl3 |=MVPP22_XLG_CTRL3_MACMODESELECT_10G ;else ctrl3 |=MVPP22_XLG_CTRL3_MACMODESELECT_GMAC ;
@@ -4559,7 +4561,7 @@ static void mvpp22_mode_reconfigure(struct mvpp2_port *port)writel (ctrl3, port->base +MVPP22_XLG_CTRL3_REG ); } -if (mvpp2_port_supports_xlg (port) &&mvpp2_is_xlg (port->phy_interface)) +if (mvpp2_port_supports_xlg (port) &&mvpp2_is_xlg (interface))mvpp2_xlg_max_rx_size_set (port);else mvpp2_gmac_max_rx_size_set (port);
@@ -4579,7 +4581,7 @@ static void mvpp2_start_dev(struct mvpp2_port *port)mvpp2_interrupts_enable (port);if (port->priv->hw_version >=MVPP22 ) -mvpp22_mode_reconfigure (port); +mvpp22_mode_reconfigure (port, port->phy_interface);if (port->phylink) {phylink_start (port->phylink);
@@ -6462,6 +6464,9 @@ static int mvpp2__mac_prepare(struct phylink_config *config, unsigned int mode,mvpp22_gop_mask_irq (port);phy_power_off (port->comphy); + +/* Reconfigure the serdes lanes */ +mvpp22_mode_reconfigure (port, interface); } }
@@ -6516,9 +6521,6 @@ static int mvpp2_mac_finish(struct phylink_config *config, unsigned int mode, port->phy_interface != interface) { port->phy_interface = interface; -/* Reconfigure the serdes lanes */ -mvpp22_mode_reconfigure (port); -/* Unmask interrupts */ mvpp22_gop_unmask_irq (port); }
@@ -6945,7 +6947,7 @@ static int mvpp2_port_probe(struct platform_device *pdev,* driver does this, we can remove this code. */ if (port->comphy) { - err =mvpp22_comphy_init (port); + err =mvpp22_comphy_init (port, port->phy_interface);if (err ==0 )phy_power_off (port->comphy); }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 781/849 vsock: prevent unnecessary refcnt inc for nonblocking connect
In reply to Greg Kroah-HartmanFrom: Eiichi Tsukata <[email protected]>
[ Upstream commit c7cd82b90599fa10915f41e3dd9098a77d0aa7b6 ]
Currently vosck_connect() increments sock refcount for nonblocking socket each time it's called, which can lead to memory leak if it's called multiple times because connect timeout function decrements sock refcount only once.
Fixes it by making vsock_connect() return -EALREADY immediately when sock state is already SS_CONNECTING.
--- net/vmw_vsock/af_vsock.c | 2 ++ 1 file changed, 2 insertions(+)
net/vmw_vsock/af_vsock.c +2 -0
@@ -1322,6 +1322,8 @@ static int vsock_connect(struct socket *sock, struct sockaddr *addr,* non-blocking call. */ err = -EALREADY ; +if (flags &O_NONBLOCK ) + goto out;break ;default : if ((sk->sk_state == TCP_LISTEN) ||
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 782/849 net/smc: fix sk_refcnt underflow on linkdown and fallback
In reply to Greg Kroah-HartmanFrom: Dust Li <[email protected]>
[ Upstream commit e5d5aadcf3cd59949316df49c27cb21788d7efe4 ]
We got the following WARNING when running ab/nginx test with RDMA link flapping (up-down-up).
The reason is when smc_sock fallback and at linkdown happens simultaneously, we may got the following situation:
__smc_lgr_terminate()
--> smc_conn_kill()
--> smc_close_active_abort()
smc_sock->sk_state = SMC_CLOSED
sock_put(smc_sock)smc_sock was set to SMC_CLOSED and sock_put() been called when terminate the link group. But later application call close() on the socket, then we got:
__smc_release():
if (smc_sock->fallback)
smc_sock->sk_state = SMC_CLOSED
sock_put(smc_sock)Again we set the smc_sock to CLOSED through it's already in CLOSED state, and double put the refcnt, so the following warning happens:
refcount_t: underflow; use-after-free.
WARNING: CPU: 5 PID: 860 at lib/refcount.c:28 refcount_warn_saturate+0x8d/0xf0 Modules linked in: CPU: 5 PID: 860 Comm: nginx Not tainted 5.10.46+ #403 Hardware name: Alibaba Cloud Alibaba Cloud ECS, BIOS 8c24b4c 04/01/2014 RIP: 0010:refcount_warn_saturate+0x8d/0xf0 Code: 05 5c 1e b5 01 01 e8 52 25 bc ff 0f 0b c3 80 3d 4f 1e b5 01 00 75 ad 48
RSP: 0018:ffffc90000527e50 EFLAGS: 00010286 RAX: 0000000000000026 RBX: ffff8881300df2c0 RCX: 0000000000000027 RDX: 0000000000000000 RSI: ffff88813bd58040 RDI: ffff88813bd58048 RBP: 0000000000000000 R08: 0000000000000003 R09: 0000000000000001 R10: ffff8881300df2c0 R11: ffffc90000527c78 R12: ffff8881300df340 R13: ffff8881300df930 R14: ffff88810b3dad80 R15: ffff8881300df4f8 FS: 00007f739de8fb80(0000) GS:ffff88813bd40000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000000000a01b008 CR3: 0000000111b64003 CR4: 00000000003706e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: smc_release+0x353/0x3f0 __sock_release+0x3d/0xb0 sock_close+0x11/0x20 __fput+0x93/0x230 task_work_run+0x65/0xa0 exit_to_user_mode_prepare+0xf9/0x100 syscall_exit_to_user_mode+0x27/0x190 entry_SYSCALL_64_after_hwframe+0x44/0xa9
This patch adds check in __smc_release() to make sure we won't do an extra sock_put() and set the socket to CLOSED when its already in CLOSED state.
--- net/smc/af_smc.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
net/smc/af_smc.c +11 -7
@@ -148,14 +148,18 @@ static int __smc_release(struct smc_sock *smc)sock_set_flag (sk,SOCK_DEAD ); sk->sk_shutdown |=SHUTDOWN_MASK ; }else { -if (sk->sk_state !=SMC_LISTEN && sk->sk_state !=SMC_INIT ) -sock_put (sk);/* passive closing */ -if (sk->sk_state ==SMC_LISTEN ) { -/* wake up clcsock accept */ - rc =kernel_sock_shutdown (smc->clcsock,SHUT_RDWR ); +if (sk->sk_state !=SMC_CLOSED ) { +if (sk->sk_state !=SMC_LISTEN && + sk->sk_state !=SMC_INIT ) +sock_put (sk);/* passive closing */ +if (sk->sk_state ==SMC_LISTEN ) { +/* wake up clcsock accept */ + rc =kernel_sock_shutdown (smc->clcsock, +SHUT_RDWR ); + } + sk->sk_state =SMC_CLOSED ; + sk->sk_state_change (sk); } - sk->sk_state =SMC_CLOSED ; - sk->sk_state_change (sk);smc_restore_fallback_changes (smc); }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 783/849 cxgb4: fix eeprom len when diagnostics not implemented
In reply to Greg Kroah-HartmanFrom: Rahul Lakkireddy <[email protected]>
[ Upstream commit 4ca110bf8d9b31a60f8f8ff6706ea147d38ad97c ]
Ensure diagnostics monitoring support is implemented for the SFF 8472 compliant port module and set the correct length for ethtool port module eeprom read.
--- drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c | 7 +++++-- drivers/net/ethernet/chelsio/cxgb4/t4_hw.h | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c +5 -2
@@ -2011,12 +2011,15 @@ static int cxgb4_get_module_info(struct net_device *dev,if (ret)return ret; -if (!sff8472_comp || (sff_diag_type &4 )) { +if (!sff8472_comp || (sff_diag_type &SFP_DIAG_ADDRMODE )) { modinfo->type =ETH_MODULE_SFF_8079 ; modinfo->eeprom_len =ETH_MODULE_SFF_8079_LEN ; }else { modinfo->type =ETH_MODULE_SFF_8472 ; - modinfo->eeprom_len =ETH_MODULE_SFF_8472_LEN ; +if (sff_diag_type &SFP_DIAG_IMPLEMENTED ) + modinfo->eeprom_len =ETH_MODULE_SFF_8472_LEN ; +else + modinfo->eeprom_len =ETH_MODULE_SFF_8472_LEN /2 ; }break ;
drivers/net/ethernet/chelsio/cxgb4/t4_hw.h +2 -0
@@ -293,6 +293,8 @@ enum {#define I2C_PAGE_SIZE 0x100#define SFP_DIAG_TYPE_ADDR 0x5c#define SFP_DIAG_TYPE_LEN 0x1 +#define SFP_DIAG_ADDRMODE BIT(2) +#define SFP_DIAG_IMPLEMENTED BIT(6)#define SFF_8472_COMP_ADDR 0x5e#define SFF_8472_COMP_LEN 0x1#define SFF_REV_ADDR 0x1
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 784/849 selftests/net: udpgso_bench_rx: fix port argument
In reply to Greg Kroah-HartmanFrom: Willem de Bruijn <[email protected]>
[ Upstream commit d336509cb9d03970911878bb77f0497f64fda061 ]
The below commit added optional support for passing a bind address. It configures the sockaddr bind arguments before parsing options and reconfigures on options -b and -4.
This broke support for passing port (-p) on its own.
Configure sockaddr after parsing all arguments.
--- tools/testing/selftests/net/udpgso_bench_rx.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
tools/testing/selftests/net/udpgso_bench_rx.c +7 -4
@@ -293,19 +293,17 @@ static void usage(const char *filepath)static void parse_opts (int argc,char **argv) { +const char *bind_addr =NULL ;int c; -/* bind to any by default */ -setup_sockaddr (PF_INET6 ,"::" , &cfg_bind_addr);while ((c =getopt (argc, argv,"4b:C:Gl:n:p:rR:S:tv" )) !=-1 ) {switch (c) {case '4' : cfg_family =PF_INET ; cfg_alen =sizeof (struct sockaddr_in ); -setup_sockaddr (PF_INET ,"0.0.0.0" , &cfg_bind_addr);break ;case 'b' : -setup_sockaddr (cfg_family, optarg, &cfg_bind_addr); + bind_addr = optarg;break ;case 'C' : cfg_connect_timeout_ms =strtoul (optarg,NULL ,0 );
@@ -341,6 +339,11 @@ static void parse_opts(int argc, char **argv) } } +if (!bind_addr) + bind_addr = cfg_family ==PF_INET6 ?"::" :"0.0.0.0" ; + +setup_sockaddr (cfg_family, bind_addr, &cfg_bind_addr); +if (optind != argc)usage (argv[0 ]);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 785/849 smb3: do not error on fsync when readonly
In reply to Greg Kroah-HartmanFrom: Steve French <[email protected]>
commit 71e6864eacbef0b2645ca043cdfbac272cb6cea3 upstream.
Linux allows doing a flush/fsync on a file open for read-only, but the protocol does not allow that. If the file passed in on the flush is read-only try to find a writeable handle for the same inode, if that is not possible skip sending the fsync call to the server to avoid breaking the apps.
--- fs/cifs/file.c | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-)
fs/cifs/file.c +29 -6
@@ -2689,12 +2689,23 @@ int cifs_strict_fsync(struct file *file, tcon =tlink_tcon (smbfile->tlink);if (!(cifs_sb->mnt_cifs_flags &CIFS_MOUNT_NOSSYNC )) { server = tcon->ses->server; -if (server->ops->flush) - rc = server->ops->flush (xid, tcon, &smbfile->fid); -else +if (server->ops->flush ==NULL ) { rc = -ENOSYS ; + goto strict_fsync_exit; + } + +if ((OPEN_FMODE (smbfile->f_flags) &FMODE_WRITE ) ==0 ) { + smbfile =find_writable_file (CIFS_I (inode),FIND_WR_ANY ); +if (smbfile) { + rc = server->ops->flush (xid, tcon, &smbfile->fid); +cifsFileInfo_put (smbfile); + }else +cifs_dbg (FYI ,"ignore fsync for file not open for write\n" ); + }else + rc = server->ops->flush (xid, tcon, &smbfile->fid); } +strict_fsync_exit:free_xid (xid);return rc; }
@@ -2706,6 +2717,7 @@ int cifs_fsync(struct file *file, loff_tstruct cifs_tcon *tcon;struct TCP_Server_Info *server;struct cifsFileInfo *smbfile = file->private_data; +struct inode *inode =file_inode (file);struct cifs_sb_info *cifs_sb =CIFS_FILE_SB (file); rc =file_write_and_wait_range (file, start, end);
@@ -2722,12 +2734,23 @@ int cifs_fsync(struct file *file, loff_t tcon =tlink_tcon (smbfile->tlink);if (!(cifs_sb->mnt_cifs_flags &CIFS_MOUNT_NOSSYNC )) { server = tcon->ses->server; -if (server->ops->flush) - rc = server->ops->flush (xid, tcon, &smbfile->fid); -else +if (server->ops->flush ==NULL ) { rc = -ENOSYS ; + goto fsync_exit; + } + +if ((OPEN_FMODE (smbfile->f_flags) &FMODE_WRITE ) ==0 ) { + smbfile =find_writable_file (CIFS_I (inode),FIND_WR_ANY ); +if (smbfile) { + rc = server->ops->flush (xid, tcon, &smbfile->fid); +cifsFileInfo_put (smbfile); + }else +cifs_dbg (FYI ,"ignore fsync for file not open for write\n" ); + }else + rc = server->ops->flush (xid, tcon, &smbfile->fid); } +fsync_exit:free_xid (xid);return rc; }
Greg Kroah-Hartman
maintainerPATCH 786/849 ARM: 9155/1: fix early early_iounmap()
In reply to Greg Kroah-HartmanFrom: Michał Mirosław <[email protected]>
commit 0d08e7bf0d0d1a29aff7b16ef516f7415eb1aa05 upstream.
Currently __set_fixmap() bails out with a warning when called in early boot from early_iounmap(). Fix it, and while at it, make the comment a bit easier to understand.
--- arch/arm/mm/mmu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mm/mmu.c +2 -2
@@ -390,9 +390,9 @@ void __set_fixmap(enum fixed_addresses iBUILD_BUG_ON (__fix_to_virt (__end_of_fixed_addresses) <FIXADDR_START );BUG_ON (idx >= __end_of_fixed_addresses); -/* we only support device mappings until pgprot_kernel has been set */ +/* We support only device mappings before pgprot_kernel is set. */ if (WARN_ON (pgprot_val (prot) !=pgprot_val (FIXMAP_PAGE_IO ) && -pgprot_val (pgprot_kernel) ==0 )) +pgprot_val (prot) &&pgprot_val (pgprot_kernel) ==0 ))return ;if (pgprot_val (prot))
Greg Kroah-Hartman
maintainerPATCH 787/849 ARM: 9156/1: drop cc-option fallbacks for architecture selection
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
commit 418ace9992a7647c446ed3186df40cf165b67298 upstream.
Naresh and Antonio ran into a build failure with latest Debian armhf compilers, with lots of output like
tmp/ccY3nOAs.s:2215: Error: selected processor does not support `cpsid i' in ARM mode
As it turns out, $(cc-option) fails early here when the FPU is not selected before CPU architecture is selected, as the compiler option check runs before enabling -msoft-float, which causes a problem when testing a target architecture level without an FPU:
cc1: error: '-mfloat-abi=hard': selected architecture lacks an FPU
Passing e.g. -march=armv6k+fp in place of -march=armv6k would avoid this issue, but the fallback logic is already broken because all supported compilers (gcc-5 and higher) are much more recent than these options, and building with -march=armv5t as a fallback no longer works.
The best way forward that I see is to just remove all the checks, which also has the nice side-effect of slightly improving the startup time for 'make'.
The -mtune=marvell-f option was apparently never supported by any mainline compiler, and the custom Codesourcery gcc build that did support is now too old to build kernels, so just use -mtune=xscale unconditionally for those.
This should be safe to apply on all stable kernels, and will be required in order to keep building them with gcc-11 and higher.
--- arch/arm/Makefile | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
arch/arm/Makefile +11 -11
@@ -60,15 +60,15 @@ KBUILD_CFLAGS += $(call cc-option,-fno-i # Note that GCC does not numerically define an architecture version # macro, but instead defines a whole series of macros which makes # testing for a specific architecture or later rather impossible. -arch-$(CONFIG_CPU_32v7M) =-D__LINUX_ARM_ARCH__=7 -march=armv7-m -Wa,-march=armv7-m -arch-$(CONFIG_CPU_32v7) =-D__LINUX_ARM_ARCH__=7 $(call cc-option,-march=armv7-a,-march=armv5t -Wa$(comma)-march=armv7-a) -arch-$(CONFIG_CPU_32v6) =-D__LINUX_ARM_ARCH__=6 $(call cc-option,-march=armv6,-march=armv5t -Wa$(comma)-march=armv6) +arch-$(CONFIG_CPU_32v7M) =-D__LINUX_ARM_ARCH__=7 -march=armv7-m +arch-$(CONFIG_CPU_32v7) =-D__LINUX_ARM_ARCH__=7 -march=armv7-a +arch-$(CONFIG_CPU_32v6) =-D__LINUX_ARM_ARCH__=6 -march=armv6 # Only override the compiler option if ARMv6. The ARMv6K extensions are # always available in ARMv7 ifeq ($(CONFIG_CPU_32v6),y) -arch-$(CONFIG_CPU_32v6K) =-D__LINUX_ARM_ARCH__=6 $(call cc-option,-march=armv6k,-march=armv5t -Wa$(comma)-march=armv6k) +arch-$(CONFIG_CPU_32v6K) =-D__LINUX_ARM_ARCH__=6 -march=armv6k endif -arch-$(CONFIG_CPU_32v5) =-D__LINUX_ARM_ARCH__=5 $(call cc-option,-march=armv5te,-march=armv4t) +arch-$(CONFIG_CPU_32v5) =-D__LINUX_ARM_ARCH__=5 -march=armv5te arch-$(CONFIG_CPU_32v4T) =-D__LINUX_ARM_ARCH__=4 -march=armv4t arch-$(CONFIG_CPU_32v4) =-D__LINUX_ARM_ARCH__=4 -march=armv4 arch-$(CONFIG_CPU_32v3) =-D__LINUX_ARM_ARCH__=3 -march=armv3m
@@ -82,7 +82,7 @@ tune-$(CONFIG_CPU_ARM720T) =-mtune=arm7t tune-$(CONFIG_CPU_ARM740T) =-mtune=arm7tdmi tune-$(CONFIG_CPU_ARM9TDMI) =-mtune=arm9tdmi tune-$(CONFIG_CPU_ARM940T) =-mtune=arm9tdmi -tune-$(CONFIG_CPU_ARM946E) =$(call cc-option,-mtune=arm9e,-mtune=arm9tdmi) +tune-$(CONFIG_CPU_ARM946E) =-mtune=arm9e tune-$(CONFIG_CPU_ARM920T) =-mtune=arm9tdmi tune-$(CONFIG_CPU_ARM922T) =-mtune=arm9tdmi tune-$(CONFIG_CPU_ARM925T) =-mtune=arm9tdmi
@@ -90,11 +90,11 @@ tune-$(CONFIG_CPU_ARM926T) =-mtune=arm9t tune-$(CONFIG_CPU_FA526) =-mtune=arm9tdmi tune-$(CONFIG_CPU_SA110) =-mtune=strongarm110 tune-$(CONFIG_CPU_SA1100) =-mtune=strongarm1100 -tune-$(CONFIG_CPU_XSCALE) =$(call cc-option,-mtune=xscale,-mtune=strongarm110) -Wa,-mcpu=xscale -tune-$(CONFIG_CPU_XSC3) =$(call cc-option,-mtune=xscale,-mtune=strongarm110) -Wa,-mcpu=xscale -tune-$(CONFIG_CPU_FEROCEON) =$(call cc-option,-mtune=marvell-f,-mtune=xscale) -tune-$(CONFIG_CPU_V6) =$(call cc-option,-mtune=arm1136j-s,-mtune=strongarm) -tune-$(CONFIG_CPU_V6K) =$(call cc-option,-mtune=arm1136j-s,-mtune=strongarm) +tune-$(CONFIG_CPU_XSCALE) =-mtune=xscale +tune-$(CONFIG_CPU_XSC3) =-mtune=xscale +tune-$(CONFIG_CPU_FEROCEON) =-mtune=xscale +tune-$(CONFIG_CPU_V6) =-mtune=arm1136j-s +tune-$(CONFIG_CPU_V6K) =-mtune=arm1136j-s # Evaluate tune cc-option calls now tune-y := $(tune-y)
Greg Kroah-Hartman
maintainerPATCH 788/849 parisc: Fix backtrace to always include init funtion names
In reply to Greg Kroah-HartmanFrom: Helge Deller <[email protected]>
commit 279917e27edc293eb645a25428c6ab3f3bca3f86 upstream.
I noticed that sometimes at kernel startup the backtraces did not included the function names of init functions. Their address were not resolved to function names and instead only the address was printed.
Debugging shows that the culprit is is_ksym_addr() which is called by the backtrace functions to check if an address belongs to a function in the kernel. The problem occurs only for CONFIG_KALLSYMS_ALL=y.
When looking at is_ksym_addr() one can see that for CONFIG_KALLSYMS_ALL=y the function only tries to resolve the address via is_kernel() function, which checks like this:
if (addr >= _stext && addr <= _end)
return 1;On parisc the init functions are located before _stext, so this check fails. Other platforms seem to have all functions (including init functions) behind _stext.
The following patch moves the _stext symbol at the beginning of the kernel and thus includes the init section. This fixes the check and does not seem to have any negative side effects on where the kernel mapping happens in the map_pages() function in arch/parisc/mm/init.c.
--- arch/parisc/kernel/vmlinux.lds.S | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/parisc/kernel/vmlinux.lds.S +2 -1
@@ -57,6 +57,8 @@ SECTIONS { . = KERNEL_BINARY_TEXT_START; + _stext = .; /* start of kernel text, includes init code & data */ + __init_begin = .; HEAD_TEXT_SECTION MLONGCALL_DISCARD(INIT_TEXT_SECTION(8))
@@ -80,7 +82,6 @@ SECTIONS /* freed after init ends here */ _text = .; /* Text and read-only data */ - _stext = .; MLONGCALL_KEEP(INIT_TEXT_SECTION(8)) .text ALIGN(PAGE_SIZE) : { TEXT_TEXT
Greg Kroah-Hartman
maintainerPATCH 789/849 parisc: Flush kernel data mapping in set_pte_at() when installing pte for user page
In reply to Greg Kroah-HartmanFrom: John David Anglin <[email protected]>
commit 38860b2c8bb1b92f61396eb06a63adff916fc31d upstream.
For years, there have been random segmentation faults in userspace on SMP PA-RISC machines. It occurred to me that this might be a problem in set_pte_at(). MIPS and some other architectures do cache flushes when installing PTEs with the present bit set.
Here I have adapted the code in update_mmu_cache() to flush the kernel mapping when the kernel flush is deferred, or when the kernel mapping may alias with the user mapping. This simplifies calls to update_mmu_cache().
I also changed the barrier in set_pte() from a compiler barrier to a full memory barrier. I know this change is not sufficient to fix the problem. It might not be needed.
I have had a few days of operation with 5.14.16 to 5.15.1 and haven't seen any random segmentation faults on rp3440 or c8000 so far.
--- arch/parisc/include/asm/pgtable.h | 10 ++++++++-- arch/parisc/kernel/cache.c | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-)
arch/parisc/include/asm/pgtable.h +8 -2
@@ -76,6 +76,8 @@ static inline void purge_tlb_entries(strpurge_tlb_end (flags); } +extern void __update_cache (pte_t pte); +/* Certain architectures need to do special things when PTEs * within a page table are directly modified. Thus, the following * hook is made available.
@@ -83,11 +85,14 @@ static inline void purge_tlb_entries(str#define set_pte (pteptr, pteval) \ do { \ *(pteptr) = (pteval); \ - barrier(); \ + mb(); \ } while(0)#define set_pte_at (mm, addr, pteptr, pteval) \ do { \ + if (pte_present(pteval) && \ + pte_user(pteval)) \ + __update_cache(pteval); \ *(pteptr) = (pteval); \ purge_tlb_entries(mm, addr); \ } while (0)
@@ -303,6 +308,7 @@ extern unsigned long *empty_zero_page;#define pte_none (x) (pte_val(x) == 0)#define pte_present (x) (pte_val(x) & _PAGE_PRESENT) +#define pte_user (x) (pte_val(x) & _PAGE_USER)#define pte_clear (mm, addr, xp) set_pte_at(mm, addr, xp, __pte(0))#define pmd_flag (x) (pmd_val(x) & PxD_FLAG_MASK)
@@ -410,7 +416,7 @@ extern void paging_init (void);#define PG_dcache_dirty PG_arch_1 -extern void update_mmu_cache (struct vm_area_struct *,unsigned long ,pte_t *); +#define update_mmu_cache (vms,addr,ptep) __update_cache(*ptep)/* Encode and de-code a swap entry */
arch/parisc/kernel/cache.c +2 -2
@@ -83,9 +83,9 @@ EXPORT_SYMBOL(flush_cache_all_local);#define pfn_va (pfn) __va(PFN_PHYS(pfn))void -update_mmu_cache (struct vm_area_struct *vma,unsigned long address,pte_t *ptep) +__update_cache (pte_t pte) { -unsigned long pfn =pte_pfn (*ptep); +unsigned long pfn =pte_pfn (pte);struct page *page;/* We don't have pte special. As a result, we can be called with
Greg Kroah-Hartman
maintainerPATCH 790/849 MIPS: fix duplicated slashes for Platform file path
In reply to Greg Kroah-HartmanFrom: Masahiro Yamada <[email protected]>
commit cca2aac8acf470b01066f559acd7146fc4c32ae8 upstream.
platform-y accumulates platform names with a slash appended. The current $(patsubst ...) ends up with doubling slashes.
GNU Make still include Platform files, but in case of an error, a clumsy file path is displayed:
arch/mips/loongson2ef//Platform:36: *** only binutils >= 2.20.2 have needed option -mfix-loongson2f-nop. Stop.
--- arch/mips/Makefile | 2 ++ 1 file changed, 2 insertions(+)
arch/mips/Makefile +2 -0
@@ -254,7 +254,9 @@ endif # # Board-dependent options and extra files # +ifdef need-compiler include arch/mips/Kbuild.platforms +endif ifdef CONFIG_PHYSICAL_START load-y = $(CONFIG_PHYSICAL_START)
Greg Kroah-Hartman
maintainerPATCH 791/849 MIPS: Fix assembly error from MIPSr2 code used within MIPS_ISA_ARCH_LEVEL
In reply to Greg Kroah-HartmanFrom: Maciej W. Rozycki <[email protected]>
commit a923a2676e60683aee46aa4b93c30aff240ac20d upstream.
Fix assembly errors like:
{standard input}: Assembler messages:
{standard input}:287: Error: opcode not supported on this processor: mips3 (mips3) dins $10,$7,32,32' {standard input}:680: Error: opcode not supported on this processor: mips3 (mips3) dins $10,$7,32,32' {standard input}:1274: Error: opcode not supported on this processor: mips3 (mips3) dins $12,$9,32,32' {standard input}:2175: Error: opcode not supported on this processor: mips3 (mips3) dins $10,$7,32,32' make[1]: *** [scripts/Makefile.build:277: mm/highmem.o] Error 1
with code produced from `__cmpxchg64' for MIPS64r2 CPU configurations using CONFIG_32BIT and CONFIG_PHYS_ADDR_T_64BIT.
This is due to MIPS_ISA_ARCH_LEVEL downgrading the assembly architecture to `r4000' i.e. MIPS III for MIPS64r2 configurations, while there is a block of code containing a DINS MIPS64r2 instruction conditionalized on MIPS_ISA_REV >= 2 within the scope of the downgrade.
The assembly architecture override code pattern has been put there for LL/SC instructions, so that code compiles for configurations that select a processor to build for that does not support these instructions while still providing run-time support for processors that do, dynamically switched by non-constant `cpu_has_llsc'. It went in with linux-mips.org commit aac8aa7717a2 ("Enable a suitable ISA for the assembler around ll/sc so that code builds even for processors that don't support the instructions. Plus minor formatting fixes.") back in 2005.
Fix the problem by wrapping these instructions along with the adjacent SYNC instructions only, following the practice established with commit cfd54de3b0e4 ("MIPS: Avoid move psuedo-instruction whilst using MIPS_ISA_LEVEL") and commit 378ed6f0e3c5 ("MIPS: Avoid using .set mips0 to restore ISA"). Strictly speaking the SYNC instructions do not have to be wrapped as they are only used as a Loongson3 erratum workaround, so they will be enabled in the assembler by default, but do this so as to keep code consistent with other places.
--- arch/mips/include/asm/cmpxchg.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/mips/include/asm/cmpxchg.h +4 -1
@@ -249,6 +249,7 @@ static inline unsigned long __cmpxchg64(/* Load 64 bits from ptr */ " " __SYNC(full, loongson3_war) " \n""1: lld %L0, %3 # __cmpxchg64 \n" +" .set pop \n" /* * Split the 64 bit value we loaded into the 2 registers that hold the * ret variable.
@@ -276,12 +277,14 @@ static inline unsigned long __cmpxchg64(" or %L1, %L1, $at \n" " .set at \n"# endif +" .set push \n" +" .set " MIPS_ISA_ARCH_LEVEL " \n" /* Attempt to store new at ptr */ " scd %L1, %2 \n" /* If we failed, loop! */ "\t" __SC_BEQZ"%L1, 1b \n" -" .set pop \n" "2: " __SYNC(full, loongson3_war) " \n" + " .set pop \n" : "=&r"(ret),"=&r" (tmp),"=" GCC_OFF_SMALL_ASM () (*(unsigned long long *)ptr)
Greg Kroah-Hartman
maintainerPATCH 792/849 x86/mce: Add errata workaround for Skylake SKX37
In reply to Greg Kroah-HartmanFrom: Dave Jones <[email protected]>
commit e629fc1407a63dbb748f828f9814463ffc2a0af0 upstream.
Errata SKX37 is word-for-word identical to the other errata listed in
this workaround. I happened to notice this after investigating a CMCI
storm on a Skylake host. While I can't confirm this was the root cause, spurious corrected errors does sound like a likely suspect.
--- arch/x86/kernel/cpu/mce/intel.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/mce/intel.c +3 -2
@@ -547,12 +547,13 @@ bool intel_filter_mce(struct mce *m) {struct cpuinfo_x86 *c = &boot_cpu_data; -/* MCE errata HSD131, HSM142, HSW131, BDM48, and HSM142 */ +/* MCE errata HSD131, HSM142, HSW131, BDM48, HSM142 and SKX37 */ if ((c->x86 ==6 ) && ((c->x86_model ==INTEL_FAM6_HASWELL ) || (c->x86_model ==INTEL_FAM6_HASWELL_L ) || (c->x86_model ==INTEL_FAM6_BROADWELL ) || - (c->x86_model ==INTEL_FAM6_HASWELL_G )) && + (c->x86_model ==INTEL_FAM6_HASWELL_G ) || + (c->x86_model ==INTEL_FAM6_SKYLAKE_X )) && (m->bank ==0 ) && ((m->status &0xa0000000ffffffff ) ==0x80000000000f0005 ))return true;
Greg Kroah-Hartman
maintainerPATCH 793/849 KVM: x86: move guest_pv_has out of user_access section
In reply to Greg Kroah-HartmanFrom: Paolo Bonzini <[email protected]>
commit 3e067fd8503d6205aa0c1c8f48f6b209c592d19c upstream.
When UBSAN is enabled, the code emitted for the call to guest_pv_has includes a call to __ubsan_handle_load_invalid_value. objtool complains that this call happens with UACCESS enabled; to avoid the warning, pull the calls to user_access_begin into both arms of the "if" statement, after the check for guest_pv_has.
--- arch/x86/kvm/x86.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
arch/x86/kvm/x86.c +6 -3
@@ -3222,9 +3222,6 @@ static void record_steal_time(struct kvm } st = (struct kvm_steal_time __user *)ghc->hva; -if (!user_access_begin (st,sizeof (*st))) -return ; -/* * Doing a TLB flush here, on the guest's behalf, can avoid * expensive IPIs.
@@ -3233,6 +3230,9 @@ static void record_steal_time(struct kvmu8 st_preempted =0 ;int err = -EFAULT ; +if (!user_access_begin (st,sizeof (*st))) +return ; + asmvolatile ("1: xchgb %0, %2\n" "xor %1, %1\n" "2:\n"
@@ -3255,6 +3255,9 @@ static void record_steal_time(struct kvmif (!user_access_begin (st,sizeof (*st))) goto dirty; }else { +if (!user_access_begin (st,sizeof (*st))) +return ; +unsafe_put_user (0 , &st->preempted, out); vcpu->arch.st.preempted =0 ; }
Greg Kroah-Hartman
maintainerPATCH 794/849 posix-cpu-timers: Clear task::posix_cputimers_work in copy_process()
In reply to Greg Kroah-HartmanFrom: Michael Pratt <[email protected]>
commit ca7752caeaa70bd31d1714af566c9809688544af upstream.
copy_process currently copies task_struct.posix_cputimers_work as-is. If a timer interrupt arrives while handling clone and before dup_task_struct completes then the child task will have:
1. posix_cputimers_work.scheduled = true
2. posix_cputimers_work.work queued.
copy_process clears task_struct.task_works, so (2) will have no effect and posix_cpu_timers_work will never run (not to mention it doesn't make sense for two tasks to share a common linked list).
Since posix_cpu_timers_work never runs, posix_cputimers_work.scheduled is never cleared. Since scheduled is set, future timer interrupts will skip scheduling work, with the ultimate result that the task will never receive timer expirations.
Together, the complete flow is:
1. Task 1 calls clone(), enters kernel.
2. Timer interrupt fires, schedules task work on Task 1.
2a. task_struct.posix_cputimers_work.scheduled = true
2b. task_struct.posix_cputimers_work.work added to
task_struct.task_works.
3. dup_task_struct() copies Task 1 to Task 2.
4. copy_process() clears task_struct.task_works for Task 2.
5. Future timer interrupts on Task 2 see task_struct.posix_cputimers_work.scheduled = true and skip scheduling work.
Fix this by explicitly clearing contents of task_struct.posix_cputimers_work in copy_process(). This was never meant to be shared or inherited across tasks in the first place.
--- include/linux/posix-timers.h | 2 ++ kernel/fork.c | 1 + kernel/time/posix-cpu-timers.c | 19 +++++++++++++++++-- 3 files changed, 20 insertions(+), 2 deletions(-)
include/linux/posix-timers.h +2 -0
@@ -177,8 +177,10 @@ static inline void posix_cputimers_group#endif #ifdef CONFIG_POSIX_CPU_TIMERS_TASK_WORK +void clear_posix_cputimers_work (struct task_struct *p);void posix_cputimers_init_work (void );#else +static inline void clear_posix_cputimers_work (struct task_struct *p) { }static inline void posix_cputimers_init_work (void ) { }#endif
kernel/fork.c +1 -0
@@ -2206,6 +2206,7 @@ static __latent_entropy struct task_stru p->pdeath_signal =0 ;INIT_LIST_HEAD (&p->thread_group); p->task_works =NULL ; +clear_posix_cputimers_work (p);#ifdef CONFIG_KRETPROBES p->kretprobe_instances.first =NULL ;
kernel/time/posix-cpu-timers.c +17 -2
@@ -1101,13 +1101,28 @@ static void posix_cpu_timers_work(struct }/* +* Clear existing posix CPU timers task work. +*/ +void clear_posix_cputimers_work (struct task_struct *p) +{ +/* +* A copied work entry from the old task is not meaningful, clear it. +* N.B. init_task_work will not do this. +*/ +memset (&p->posix_cputimers_work.work,0 , +sizeof (p->posix_cputimers_work.work)); +init_task_work (&p->posix_cputimers_work.work, + posix_cpu_timers_work); + p->posix_cputimers_work.scheduled = false; +} + +/* * Initialize posix CPU timers task work in init task. Out of line to * keep the callback static and to avoid header recursion hell. */ void __init posix_cputimers_init_work (void ) { -init_task_work (¤t->posix_cputimers_work.work, - posix_cpu_timers_work); +clear_posix_cputimers_work (current); }/*
Greg Kroah-Hartman
maintainerPATCH 795/849 irqchip/sifive-plic: Fixup EOI failed when masked
In reply to Greg Kroah-HartmanFrom: Guo Ren <[email protected]>
commit 69ea463021be0d159ab30f96195fb0dd18ee2272 upstream.
When using "devm_request_threaded_irq(,,,,IRQF_ONESHOT,,)" in a driver, only the first interrupt is handled, and following interrupts are never delivered (initially reported in [1]).
That's because the RISC-V PLIC cannot EOI masked interrupts, as explained in the description of Interrupt Completion in the PLIC spec [2]:
<quote>
The PLIC signals it has completed executing an interrupt handler by writing the interrupt ID it received from the claim to the claim/complete register. The PLIC does not check whether the completion ID is the same as the last claim ID for that target. If the completion ID does not match an interrupt source that *is currently enabled* for the target, the completion is silently ignored.
</quote>
Re-enable the interrupt before completion if it has been masked during the handling, and remask it afterwards.
[1] http://lists.infradead.org/pipermail/linux-riscv/2021-July/007441.html
[2] https://github.com/riscv/riscv-plic-spec/blob/8bc15a35d07c9edf7b5d23fec9728302595ffc4d/riscv-plic.adoc
--- drivers/irqchip/irq-sifive-plic.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/irqchip/irq-sifive-plic.c +7 -1
@@ -163,7 +163,13 @@ static void plic_irq_eoi(struct irq_data {struct plic_handler *handler =this_cpu_ptr (&plic_handlers); -writel (d->hwirq, handler->hart_base +CONTEXT_CLAIM ); +if (irqd_irq_masked (d)) { +plic_irq_unmask (d); +writel (d->hwirq, handler->hart_base +CONTEXT_CLAIM ); +plic_irq_mask (d); + }else { +writel (d->hwirq, handler->hart_base +CONTEXT_CLAIM ); + } }static struct irq_chip plic_chip = {
Greg Kroah-Hartman
maintainerPATCH 796/849 f2fs: should use GFP_NOFS for directory inodes
In reply to Greg Kroah-HartmanFrom: Jaegeuk Kim <[email protected]>
commit 92d602bc7177325e7453189a22e0c8764ed3453e upstream.
We use inline_dentry which requires to allocate dentry page when adding a link. If we allow to reclaim memory from filesystem, we do down_read(&sbi->cp_rwsem) twice by f2fs_lock_op(). I think this should be okay, but how about stopping the lockdep complaint [1]?
f2fs_create()
- f2fs_lock_op()
- f2fs_do_add_link()
- __f2fs_find_entry
- f2fs_get_read_data_page()
-> kswapd
- shrink_node
- f2fs_evict_inode
- f2fs_lock_op()
[1]
fs_reclaim
){+.+.}-{0:0}
:
kswapd0: lock_acquire+0x114/0x394 kswapd0: __fs_reclaim_acquire+0x40/0x50 kswapd0: prepare_alloc_pages+0x94/0x1ec kswapd0: __alloc_pages_nodemask+0x78/0x1b0 kswapd0: pagecache_get_page+0x2e0/0x57c kswapd0: f2fs_get_read_data_page+0xc0/0x394 kswapd0: f2fs_find_data_page+0xa4/0x23c kswapd0: find_in_level+0x1a8/0x36c kswapd0: __f2fs_find_entry+0x70/0x100 kswapd0: f2fs_do_add_link+0x84/0x1ec kswapd0: f2fs_mkdir+0xe4/0x1e4 kswapd0: vfs_mkdir+0x110/0x1c0 kswapd0: do_mkdirat+0xa4/0x160 kswapd0: __arm64_sys_mkdirat+0x24/0x34 kswapd0: el0_svc_common.llvm.17258447499513131576+0xc4/0x1e8 kswapd0: do_el0_svc+0x28/0xa0 kswapd0: el0_svc+0x24/0x38 kswapd0: el0_sync_handler+0x88/0xec kswapd0: el0_sync+0x1c0/0x200
kswapd0:
-> #1
(&sbi->cp_rwsem
){++++}-{3:3}
:
kswapd0: lock_acquire+0x114/0x394 kswapd0: down_read+0x7c/0x98 kswapd0: f2fs_do_truncate_blocks+0x78/0x3dc kswapd0: f2fs_truncate+0xc8/0x128 kswapd0: f2fs_evict_inode+0x2b8/0x8b8 kswapd0: evict+0xd4/0x2f8 kswapd0: iput+0x1c0/0x258 kswapd0: do_unlinkat+0x170/0x2a0 kswapd0: __arm64_sys_unlinkat+0x4c/0x68 kswapd0: el0_svc_common.llvm.17258447499513131576+0xc4/0x1e8 kswapd0: do_el0_svc+0x28/0xa0 kswapd0: el0_svc+0x24/0x38 kswapd0: el0_sync_handler+0x88/0xec kswapd0: el0_sync+0x1c0/0x200
--- fs/f2fs/inode.c | 2 +- fs/f2fs/namei.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
fs/f2fs/inode.c +1 -1
@@ -527,7 +527,7 @@ make_now: inode->i_op = &f2fs_dir_inode_operations; inode->i_fop = &f2fs_dir_operations; inode->i_mapping->a_ops = &f2fs_dblock_aops; -inode_nohighmem (inode); +mapping_set_gfp_mask (inode->i_mapping,GFP_NOFS ); }else if (S_ISLNK (inode->i_mode)) {if (file_is_encrypt (inode)) inode->i_op = &f2fs_encrypted_symlink_inode_operations;
fs/f2fs/namei.c +1 -1
@@ -757,7 +757,7 @@ static int f2fs_mkdir(struct user_namesp inode->i_op = &f2fs_dir_inode_operations; inode->i_fop = &f2fs_dir_operations; inode->i_mapping->a_ops = &f2fs_dblock_aops; -inode_nohighmem (inode); +mapping_set_gfp_mask (inode->i_mapping,GFP_NOFS );set_inode_flag (inode,FI_INC_LINK );f2fs_lock_op (sbi);
Greg Kroah-Hartman
maintainerPATCH 797/849 f2fs: include non-compressed blocks in compr_written_block
In reply to Greg Kroah-HartmanFrom: Daeho Jeong <[email protected]>
commit 09631cf3234d32156e7cae32275f5a4144c683c5 upstream.
Need to include non-compressed blocks in compr_written_block to estimate average compression ratio more accurately.
--- fs/f2fs/compress.c | 1 + 1 file changed, 1 insertion(+)
fs/f2fs/compress.c +1 -0
@@ -1476,6 +1476,7 @@ int f2fs_write_multi_pages(struct compreif (cluster_may_compress (cc)) { err =f2fs_compress_pages (cc);if (err == -EAGAIN ) { +add_compr_block_stat (cc->inode, cc->cluster_size); goto write; }else if (err) {f2fs_put_rpages_wbc (cc, wbc, true,1 );
Greg Kroah-Hartman
maintainerPATCH 798/849 f2fs: fix UAF in f2fs_available_free_memory
In reply to Greg Kroah-HartmanFrom: Dongliang Mu <[email protected]>
commit 5429c9dbc9025f9a166f64e22e3a69c94fd5b29b upstream.
if2fs_fill_super
-> f2fs_build_segment_manager
-> create_discard_cmd_control
-> f2fs_start_discard_thread
It invokes kthread_run to create a thread and run issue_discard_thread.
However, if f2fs_build_node_manager fails, the control flow goes to free_nm and calls f2fs_destroy_node_manager. This function will free sbi->nm_info. However, if issue_discard_thread accesses sbi->nm_info after the deallocation, but before the f2fs_stop_discard_thread, it will cause UAF(Use-after-free).
-> f2fs_destroy_segment_manager
-> destroy_discard_cmd_control
-> f2fs_stop_discard_thread
Fix this by stopping discard thread before f2fs_destroy_node_manager.
Note that, the commit d6d2b491a82e1 introduces the call of f2fs_available_free_memory into issue_discard_thread.
--- fs/f2fs/super.c | 2 ++ 1 file changed, 2 insertions(+)
fs/f2fs/super.c +2 -0
@@ -4271,6 +4271,8 @@ free_node_inode: free_stats:f2fs_destroy_stats (sbi); free_nm: +/* stop discard thread before destroying node manager */ +f2fs_stop_discard_thread (sbi);f2fs_destroy_node_manager (sbi); free_sm:f2fs_destroy_segment_manager (sbi);
Greg Kroah-Hartman
maintainerPATCH 799/849 erofs: fix unsafe pagevec reuse of hooked pclusters
In reply to Greg Kroah-HartmanFrom: Gao Xiang <[email protected]>
commit 86432a6dca9bed79111990851df5756d3eb5f57c upstream.
There are pclusters in runtime marked with Z_EROFS_PCLUSTER_TAIL before actual I/O submission. Thus, the decompression chain can be extended if the following pcluster chain hooks such tail pcluster.
As the related comment mentioned, if some page is made of a hooked pcluster and another followed pcluster, it can be reused for in-place I/O (since I/O should be submitted anyway):
_______________________________________________________________
| tail (partial) page | head (partial) page | |_____PRIMARY_HOOKED___|____________PRIMARY_FOLLOWED____________|
However, it's by no means safe to reuse as pagevec since if such PRIMARY_HOOKED pclusters finally move into bypass chain without I/O submission. It's somewhat hard to reproduce with LZ4 and I just found it (general protection fault) by ro_fsstressing a LZMA image for long time.
I'm going to actively clean up related code together with multi-page folio adaption in the next few months. Let's address it directly for easier backporting for now.
Call trace for reference:
z_erofs_decompress_pcluster+0x10a/0x8a0 [erofs] z_erofs_decompress_queue.isra.36+0x3c/0x60 [erofs] z_erofs_runqueue+0x5f3/0x840 [erofs] z_erofs_readahead+0x1e8/0x320 [erofs] read_pages+0x91/0x270 page_cache_ra_unbounded+0x18b/0x240 filemap_get_pages+0x10a/0x5f0 filemap_read+0xa9/0x330 new_sync_read+0x11b/0x1a0 vfs_read+0xf1/0x190
--- fs/erofs/zdata.c | 13 +++++++------ fs/erofs/zpvec.h | 13 ++++++++++--- 2 files changed, 17 insertions(+), 9 deletions(-)
fs/erofs/zdata.c +7 -6
@@ -375,8 +375,8 @@ static bool z_erofs_try_inplace_io(struc/* callers must be with collection lock held */ static int z_erofs_attach_page (struct z_erofs_collector *clt, -struct page *page, -enum z_erofs_page_type type) +struct page *page,enum z_erofs_page_type type, +bool pvec_safereuse) {int ret;
@@ -386,9 +386,9 @@ static int z_erofs_attach_page(struct z_ z_erofs_try_inplace_io(clt, page))return 0 ; - ret =z_erofs_pagevec_enqueue (&clt->vector, page, type); + ret =z_erofs_pagevec_enqueue (&clt->vector, page, type, + pvec_safereuse); clt->cl->vcnt += (unsigned int )ret; -return ret ?0 : -EAGAIN ; }
@@ -731,7 +731,8 @@ hitted: tight &= (clt->mode >=COLLECT_PRIMARY_FOLLOWED ); retry: - err =z_erofs_attach_page (clt, page, page_type); + err =z_erofs_attach_page (clt, page, page_type, + clt->mode >=COLLECT_PRIMARY_FOLLOWED );/* should allocate an additional short-lived page for pagevec */ if (err == -EAGAIN ) { struct page *const newpage =
@@ -739,7 +740,7 @@ retry:set_page_private (newpage,Z_EROFS_SHORTLIVED_PAGE ); err =z_erofs_attach_page (clt, newpage, -Z_EROFS_PAGE_TYPE_EXCLUSIVE ); +Z_EROFS_PAGE_TYPE_EXCLUSIVE , true);if (!err) goto retry; }
fs/erofs/zpvec.h +10 -3
@@ -106,11 +106,18 @@ static inline void z_erofs_pagevec_ctor_static inline bool z_erofs_pagevec_enqueue (struct z_erofs_pagevec_ctor *ctor,struct page *page, -enum z_erofs_page_type type) +enum z_erofs_page_type type, +bool pvec_safereuse) { -if (!ctor->next && type) -if (ctor->index +1 == ctor->nr) +if (!ctor->next) { +/* some pages cannot be reused as pvec safely without I/O */ +if (type ==Z_EROFS_PAGE_TYPE_EXCLUSIVE && !pvec_safereuse) + type =Z_EROFS_VLE_PAGE_TYPE_TAIL_SHARED ; + +if (type !=Z_EROFS_PAGE_TYPE_EXCLUSIVE && + ctor->index +1 == ctor->nr)return false; + }if (ctor->index >= ctor->nr)z_erofs_pagevec_ctor_pagedown (ctor, false);
Greg Kroah-Hartman
maintainerPATCH 800/849 dmaengine: ti: k3-udma: Set bchan to NULL if a channel request fail
In reply to Greg Kroah-HartmanFrom: Kishon Vijay Abraham I <[email protected]>
commit 5c6c6d60e4b489308ae4da8424c869f7cc53cd12 upstream.
bcdma_get_*() checks if bchan is already allocated by checking if it has a NON NULL value. For the error cases, bchan will have error value and bcdma_get_*() considers this as already allocated (PASS) since the error values are NON NULL. This results in NULL pointer dereference error while de-referencing bchan.
Reset the value of bchan to NULL if a channel request fails.
--- drivers/dma/ti/k3-udma.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/dma/ti/k3-udma.c +6 -2
@@ -1348,6 +1348,7 @@ static int bcdma_get_bchan(struct udma_c {struct udma_dev *ud = uc->ud;enum udma_tp_level tpl; +int ret;if (uc->bchan) { dev_dbg(ud->dev, "chan%d: already have bchan%d allocated\n",
@@ -1365,8 +1366,11 @@ static int bcdma_get_bchan(struct udma_c tpl = ud->bchan_tpl.levels -1 ; uc->bchan =__udma_reserve_bchan (ud, tpl,-1 ); -if (IS_ERR (uc->bchan)) -return PTR_ERR (uc->bchan); +if (IS_ERR (uc->bchan)) { + ret =PTR_ERR (uc->bchan); + uc->bchan =NULL ; +return ret; + } uc->tchan = uc->bchan;
Greg Kroah-Hartman
maintainerPATCH 801/849 dmaengine: ti: k3-udma: Set r/tchan or rflow to NULL if request fail
In reply to Greg Kroah-HartmanFrom: Kishon Vijay Abraham I <[email protected]>
commit eb91224e47ec33a0a32c9be0ec0fcb3433e555fd upstream.
udma_get_*() checks if rchan/tchan/rflow is already allocated by checking if it has a NON NULL value. For the error cases, rchan/tchan/rflow will have error value and udma_get_*() considers this as already allocated (PASS) since the error values are NON NULL. This results in NULL pointer dereference error while de-referencing rchan/tchan/rflow.
Reset the value of rchan/tchan/rflow to NULL if a channel request fails.
--- drivers/dma/ti/k3-udma.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-)
drivers/dma/ti/k3-udma.c +20 -4
@@ -1380,6 +1380,7 @@ static int bcdma_get_bchan(struct udma_cstatic int udma_get_tchan (struct udma_chan *uc) {struct udma_dev *ud = uc->ud; +int ret;if (uc->tchan) { dev_dbg(ud->dev, "chan%d: already have tchan%d allocated\n",
@@ -1394,8 +1395,11 @@ static int udma_get_tchan(struct udma_ch*/ uc->tchan =__udma_reserve_tchan (ud, uc->config.channel_tpl, uc->config.mapped_channel_id); -if (IS_ERR (uc->tchan)) -return PTR_ERR (uc->tchan); +if (IS_ERR (uc->tchan)) { + ret =PTR_ERR (uc->tchan); + uc->tchan =NULL ; +return ret; + }if (ud->tflow_cnt) {int tflow_id;
@@ -1425,6 +1429,7 @@ static int udma_get_tchan(struct udma_chstatic int udma_get_rchan (struct udma_chan *uc) {struct udma_dev *ud = uc->ud; +int ret;if (uc->rchan) { dev_dbg(ud->dev, "chan%d: already have rchan%d allocated\n",
@@ -1439,8 +1444,13 @@ static int udma_get_rchan(struct udma_ch*/ uc->rchan =__udma_reserve_rchan (ud, uc->config.channel_tpl, uc->config.mapped_channel_id); +if (IS_ERR (uc->rchan)) { + ret =PTR_ERR (uc->rchan); + uc->rchan =NULL ; +return ret; + } -return PTR_ERR_OR_ZERO (uc->rchan); +return 0 ; }static int udma_get_chan_pair (struct udma_chan *uc)
@@ -1494,6 +1504,7 @@ static int udma_get_chan_pair(struct udmstatic int udma_get_rflow (struct udma_chan *uc,int flow_id) {struct udma_dev *ud = uc->ud; +int ret;if (!uc->rchan) {dev_err (ud->dev,"chan%d: does not have rchan??\n" , uc->id);
@@ -1507,8 +1518,13 @@ static int udma_get_rflow(struct udma_ch } uc->rflow =__udma_get_rflow (ud, flow_id); +if (IS_ERR (uc->rflow)) { + ret =PTR_ERR (uc->rflow); + uc->rflow =NULL ; +return ret; + } -return PTR_ERR_OR_ZERO (uc->rflow); +return 0 ; }static void bcdma_put_bchan (struct udma_chan *uc)
Greg Kroah-Hartman
maintainerPATCH 802/849 dmaengine: bestcomm: fix system boot lockups
In reply to Greg Kroah-HartmanFrom: Anatolij Gustschin <[email protected]>
commit adec566b05288f2787a1f88dbaf77ed8b0c644fa upstream.
memset() and memcpy() on an MMIO region like here results in a lockup at startup on mpc5200 platform (since this first happens during probing of the ATA and Ethernet drivers). Use memset_io() and memcpy_toio() instead.
--- drivers/dma/bestcomm/ata.c | 2 +- drivers/dma/bestcomm/bestcomm.c | 22 +++++++++++----------- drivers/dma/bestcomm/fec.c | 4 ++-- drivers/dma/bestcomm/gen_bd.c | 4 ++-- 4 files changed, 16 insertions(+), 16 deletions(-)
drivers/dma/bestcomm/ata.c +1 -1
@@ -133,7 +133,7 @@ void bcom_ata_reset_bd(struct bcom_taskstruct bcom_ata_var *var;/* Reset all BD */ -memset (tsk->bd,0x00 , tsk->num_bd * tsk->bd_size); +memset_io (tsk->bd,0x00 , tsk->num_bd * tsk->bd_size); tsk->index =0 ; tsk->outdex =0 ;
drivers/dma/bestcomm/bestcomm.c +11 -11
@@ -95,7 +95,7 @@ bcom_task_alloc(int bd_count, int bd_siz tsk->bd =bcom_sram_alloc (bd_count * bd_size,4 , &tsk->bd_pa);if (!tsk->bd) goto error; -memset (tsk->bd,0x00 , bd_count * bd_size); +memset_io (tsk->bd,0x00 , bd_count * bd_size); tsk->num_bd = bd_count; tsk->bd_size = bd_size;
@@ -186,16 +186,16 @@ bcom_load_image(int task, u32 *task_imag inc =bcom_task_inc (task);/* Clear & copy */ -memset (var,0x00 ,BCOM_VAR_SIZE ); -memset (inc,0x00 ,BCOM_INC_SIZE ); +memset_io (var,0x00 ,BCOM_VAR_SIZE ); +memset_io (inc,0x00 ,BCOM_INC_SIZE ); desc_src = (u32 *)(hdr +1 ); var_src = desc_src + hdr->desc_size; inc_src = var_src + hdr->var_size; -memcpy (desc, desc_src, hdr->desc_size *sizeof (u32)); -memcpy (var + hdr->first_var, var_src, hdr->var_size *sizeof (u32)); -memcpy (inc, inc_src, hdr->inc_size *sizeof (u32)); +memcpy_toio (desc, desc_src, hdr->desc_size *sizeof (u32)); +memcpy_toio (var + hdr->first_var, var_src, hdr->var_size *sizeof (u32)); +memcpy_toio (inc, inc_src, hdr->inc_size *sizeof (u32));return 0 ; }
@@ -302,13 +302,13 @@ static int bcom_engine_init(void)return -ENOMEM ; } -memset (bcom_eng->tdt,0x00 , tdt_size); -memset (bcom_eng->ctx,0x00 , ctx_size); -memset (bcom_eng->var,0x00 , var_size); -memset (bcom_eng->fdt,0x00 , fdt_size); +memset_io (bcom_eng->tdt,0x00 , tdt_size); +memset_io (bcom_eng->ctx,0x00 , ctx_size); +memset_io (bcom_eng->var,0x00 , var_size); +memset_io (bcom_eng->fdt,0x00 , fdt_size);/* Copy the FDT for the EU#3 */ -memcpy (&bcom_eng->fdt[48 ], fdt_ops,sizeof (fdt_ops)); +memcpy_toio (&bcom_eng->fdt[48 ], fdt_ops,sizeof (fdt_ops));/* Initialize Task base structure */ for (task=0 ; task<BCOM_MAX_TASKS ; task++)
drivers/dma/bestcomm/fec.c +2 -2
@@ -140,7 +140,7 @@ bcom_fec_rx_reset(struct bcom_task *tsk) tsk->index =0 ; tsk->outdex =0 ; -memset (tsk->bd,0x00 , tsk->num_bd * tsk->bd_size); +memset_io (tsk->bd,0x00 , tsk->num_bd * tsk->bd_size);/* Configure some stuff */ bcom_set_task_pragma (tsk->tasknum,BCOM_FEC_RX_BD_PRAGMA );
@@ -241,7 +241,7 @@ bcom_fec_tx_reset(struct bcom_task *tsk) tsk->index =0 ; tsk->outdex =0 ; -memset (tsk->bd,0x00 , tsk->num_bd * tsk->bd_size); +memset_io (tsk->bd,0x00 , tsk->num_bd * tsk->bd_size);/* Configure some stuff */ bcom_set_task_pragma (tsk->tasknum,BCOM_FEC_TX_BD_PRAGMA );
drivers/dma/bestcomm/gen_bd.c +2 -2
@@ -142,7 +142,7 @@ bcom_gen_bd_rx_reset(struct bcom_task *t tsk->index =0 ; tsk->outdex =0 ; -memset (tsk->bd,0x00 , tsk->num_bd * tsk->bd_size); +memset_io (tsk->bd,0x00 , tsk->num_bd * tsk->bd_size);/* Configure some stuff */ bcom_set_task_pragma (tsk->tasknum,BCOM_GEN_RX_BD_PRAGMA );
@@ -226,7 +226,7 @@ bcom_gen_bd_tx_reset(struct bcom_task *t tsk->index =0 ; tsk->outdex =0 ; -memset (tsk->bd,0x00 , tsk->num_bd * tsk->bd_size); +memset_io (tsk->bd,0x00 , tsk->num_bd * tsk->bd_size);/* Configure some stuff */ bcom_set_task_pragma (tsk->tasknum,BCOM_GEN_TX_BD_PRAGMA );
Greg Kroah-Hartman
maintainerPATCH 803/849 net, neigh: Enable state migration between NUD_PERMANENT and NTF_USE
In reply to Greg Kroah-HartmanFrom: Daniel Borkmann <[email protected]>
[ Upstream commit 3dc20f4762c62d3b3f0940644881ed818aa7b2f5 ]
Currently, it is not possible to migrate a neighbor entry between NUD_PERMANENT state and NTF_USE flag with a dynamic NUD state from a user space control plane. Similarly, it is not possible to add/remove NTF_EXT_LEARNED flag from an existing neighbor entry in combination with NTF_USE flag.
This is due to the latter directly calling into neigh_event_send() without any meta data updates as happening in __neigh_update(). Thus, to enable this use case, extend the latter with a NEIGH_UPDATE_F_USE flag where we break the NUD_PERMANENT state in particular so that a latter neigh_event_send() is able to re-resolve a neighbor entry.
Before fix, NUD_PERMANENT -> NUD_* & NTF_USE:
# ./ip/ip n replace 192.168.178.30 dev enp5s0 lladdr f4:8c:50:5e:71:9a # ./ip/ip n 192.168.178.30 dev enp5s0 lladdr f4:8c:50:5e:71:9a PERMANENT [...] # ./ip/ip n replace 192.168.178.30 dev enp5s0 use extern_learn # ./ip/ip n 192.168.178.30 dev enp5s0 lladdr f4:8c:50:5e:71:9a PERMANENT [...]
As can be seen, despite the admin-triggered replace, the entry remains in the NUD_PERMANENT state.
After fix, NUD_PERMANENT -> NUD_* & NTF_USE:
# ./ip/ip n replace 192.168.178.30 dev enp5s0 lladdr f4:8c:50:5e:71:9a # ./ip/ip n 192.168.178.30 dev enp5s0 lladdr f4:8c:50:5e:71:9a PERMANENT [...] # ./ip/ip n replace 192.168.178.30 dev enp5s0 use extern_learn # ./ip/ip n 192.168.178.30 dev enp5s0 lladdr f4:8c:50:5e:71:9a extern_learn REACHABLE [...] # ./ip/ip n 192.168.178.30 dev enp5s0 lladdr f4:8c:50:5e:71:9a extern_learn STALE [...] # ./ip/ip n replace 192.168.178.30 dev enp5s0 lladdr f4:8c:50:5e:71:9a # ./ip/ip n 192.168.178.30 dev enp5s0 lladdr f4:8c:50:5e:71:9a PERMANENT [...]
After the fix, the admin-triggered replace switches to a dynamic state from the NTF_USE flag which triggered a new neighbor resolution. Likewise, we can transition back from there, if needed, into NUD_PERMANENT.
Similar before/after behavior can be observed for below transitions:
Before fix, NTF_USE -> NTF_USE | NTF_EXT_LEARNED -> NTF_USE:
# ./ip/ip n replace 192.168.178.30 dev enp5s0 use # ./ip/ip n 192.168.178.30 dev enp5s0 lladdr f4:8c:50:5e:71:9a REACHABLE [...] # ./ip/ip n replace 192.168.178.30 dev enp5s0 use extern_learn # ./ip/ip n 192.168.178.30 dev enp5s0 lladdr f4:8c:50:5e:71:9a REACHABLE [...]
After fix, NTF_USE -> NTF_USE | NTF_EXT_LEARNED -> NTF_USE:
# ./ip/ip n replace 192.168.178.30 dev enp5s0 use # ./ip/ip n 192.168.178.30 dev enp5s0 lladdr f4:8c:50:5e:71:9a REACHABLE [...] # ./ip/ip n replace 192.168.178.30 dev enp5s0 use extern_learn # ./ip/ip n 192.168.178.30 dev enp5s0 lladdr f4:8c:50:5e:71:9a extern_learn REACHABLE [...] # ./ip/ip n replace 192.168.178.30 dev enp5s0 use # ./ip/ip n 192.168.178.30 dev enp5s0 lladdr f4:8c:50:5e:71:9a REACHABLE [..]
--- include/net/neighbour.h | 1 + net/core/neighbour.c | 22 +++++++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-)
include/net/neighbour.h +1 -0
@@ -253,6 +253,7 @@ static inline void *neighbour_priv(const struct neighbour *n)#define NEIGH_UPDATE_F_OVERRIDE 0x00000001#define NEIGH_UPDATE_F_WEAK_OVERRIDE 0x00000002#define NEIGH_UPDATE_F_OVERRIDE_ISROUTER 0x00000004 +#define NEIGH_UPDATE_F_USE 0x10000000#define NEIGH_UPDATE_F_EXT_LEARNED 0x20000000#define NEIGH_UPDATE_F_ISROUTER 0x40000000#define NEIGH_UPDATE_F_ADMIN 0x80000000
net/core/neighbour.c +13 -9
@@ -1221,7 +1221,7 @@ static void neigh_update_hhs(struct neighbour *neigh) lladdr instead of overriding it if it is different. NEIGH_UPDATE_F_ADMIN means that the change is administrative. - + NEIGH_UPDATE_F_USE means that the entry is user triggered. NEIGH_UPDATE_F_OVERRIDE_ISROUTER allows to override existing NTF_ROUTER flag. NEIGH_UPDATE_F_ISROUTER indicates if the neighbour is known as
@@ -1259,6 +1259,12 @@ static int __neigh_update(struct neighbour *neigh, const u8 *lladdr, goto out; ext_learn_change =neigh_update_ext_learned (neigh, flags, ¬ify); +if (flags &NEIGH_UPDATE_F_USE ) { + new = old & ~NUD_PERMANENT ; + neigh->nud_state = new; + err =0 ; + goto out; + }if (!(new &NUD_VALID )) {neigh_del_timer (neigh);
@@ -1968,22 +1974,20 @@ static int neigh_add(struct sk_buff *skb, struct nlmsghdr *nlh,if (protocol) neigh->protocol = protocol; -if (ndm->ndm_flags &NTF_EXT_LEARNED ) flags |=NEIGH_UPDATE_F_EXT_LEARNED ; -if (ndm->ndm_flags &NTF_ROUTER ) flags |=NEIGH_UPDATE_F_ISROUTER ; +if (ndm->ndm_flags &NTF_USE ) + flags |=NEIGH_UPDATE_F_USE ; -if (ndm->ndm_flags &NTF_USE ) { + err =__neigh_update (neigh, lladdr, ndm->ndm_state, flags, +NETLINK_CB (skb).portid, extack); +if (!err && ndm->ndm_flags &NTF_USE ) {neigh_event_send (neigh,NULL ); err =0 ; - }else - err =__neigh_update (neigh, lladdr, ndm->ndm_state, flags, -NETLINK_CB (skb).portid, extack); - + }neigh_release (neigh); - out:return err; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 804/849 bpf, cgroups: Fix cgroup v2 fallback on v1/v2 mixed mode
In reply to Greg Kroah-HartmanFrom: Daniel Borkmann <[email protected]>
[ Upstream commit 8520e224f547cd070c7c8f97b1fc6d58cff7ccaa ]
Fix cgroup v1 interference when non-root cgroup v2 BPF programs are used. Back in the days, commit bd1060a1d671 ("sock, cgroup: add sock->sk_cgroup") embedded per-socket cgroup information into sock->sk_cgrp_data and in order to save 8 bytes in struct sock made both mutually exclusive, that is, when cgroup v1 socket tagging (e.g. net_cls/net_prio) is used, then cgroup v2 falls back to the root cgroup in sock_cgroup_ptr() (&cgrp_dfl_root.cgrp).
The assumption made was "there is no reason to mix the two and this is in line with how legacy and v2 compatibility is handled" as stated in bd1060a1d671. However, with Kubernetes more widely supporting cgroups v2 as well nowadays, this assumption no longer holds, and the possibility of the v1/v2 mixed mode with the v2 root fallback being hit becomes a real security issue.
Many of the cgroup v2 BPF programs are also used for policy enforcement, just to pick _one_ example, that is, to programmatically deny socket related system calls like connect(2) or bind(2). A v2 root fallback would implicitly cause a policy bypass for the affected Pods.
In production environments, we have recently seen this case due to various
circumstances: i) a different 3rd party agent and/or ii) a container runtime such as [0] in the user's environment configuring legacy cgroup v1 net_cls tags, which triggered implicitly mentioned root fallback. Another case is Kubernetes projects like kind [1] which create Kubernetes nodes in a container and also add cgroup namespaces to the mix, meaning programs which are attached to the cgroup v2 root of the cgroup namespace get attached to a non-root cgroup v2 path from init namespace point of view. And the latter's root is out of reach for agents on a kind Kubernetes node to configure. Meaning, any entity on the node setting cgroup v1 net_cls tag will trigger the bypass despite cgroup v2 BPF programs attached to the namespace root.
Generally, this mutual exclusiveness does not hold anymore in today's user environments and makes cgroup v2 usage from BPF side fragile and unreliable. This fix adds proper struct cgroup pointer for the cgroup v2 case to struct sock_cgroup_data in order to address these issues; this implicitly also fixes the tradeoffs being made back then with regards to races and refcount leaks as stated in bd1060a1d671, and removes the fallback, so that cgroup v2 BPF programs always operate as expected.
[0] https://github.com/nestybox/sysbox/
[1] https://kind.sigs.k8s.io/
--- include/linux/cgroup-defs.h | 107 +++++++++-------------------------- include/linux/cgroup.h | 22 +------ kernel/cgroup/cgroup.c | 50 ++++------------ net/core/netclassid_cgroup.c | 7 +-- net/core/netprio_cgroup.c | 10 +--- 5 files changed, 41 insertions(+), 155 deletions(-)
include/linux/cgroup-defs.h +27 -80
@@ -752,107 +752,54 @@ static inline void cgroup_threadgroup_change_end(struct task_struct *tsk) {}* sock_cgroup_data is embedded at sock->sk_cgrp_data and contains * per-socket cgroup information except for memcg association. * -* On legacy hierarchies, net_prio and net_cls controllers directly set -* attributes on each sock which can then be tested by the network layer. -* On the default hierarchy, each sock is associated with the cgroup it was -* created in and the networking layer can match the cgroup directly. -* -* To avoid carrying all three cgroup related fields separately in sock, -* sock_cgroup_data overloads (prioidx, classid) and the cgroup pointer. -* On boot, sock_cgroup_data records the cgroup that the sock was created -* in so that cgroup2 matches can be made; however, once either net_prio or -* net_cls starts being used, the area is overridden to carry prioidx and/or -* classid. The two modes are distinguished by whether the lowest bit is -* set. Clear bit indicates cgroup pointer while set bit prioidx and -* classid. -* -* While userland may start using net_prio or net_cls at any time, once -* either is used, cgroup2 matching no longer works. There is no reason to -* mix the two and this is in line with how legacy and v2 compatibility is -* handled. On mode switch, cgroup references which are already being -* pointed to by socks may be leaked. While this can be remedied by adding -* synchronization around sock_cgroup_data, given that the number of leaked -* cgroups is bound and highly unlikely to be high, this seems to be the -* better trade-off. +* On legacy hierarchies, net_prio and net_cls controllers directly +* set attributes on each sock which can then be tested by the network +* layer. On the default hierarchy, each sock is associated with the +* cgroup it was created in and the networking layer can match the +* cgroup directly. */ struct sock_cgroup_data { -union { -#ifdef __LITTLE_ENDIAN -struct { -u8 is_data :1 ; -u8 no_refcnt :1 ; -u8 unused :6 ; -u8 padding; -u16 prioidx; -u32 classid; - } __packed; -#else -struct { -u32 classid; -u16 prioidx; -u8 padding; -u8 unused :6 ; -u8 no_refcnt :1 ; -u8 is_data :1 ; - } __packed; +struct cgroup *cgroup;/* v2 */ +#ifdef CONFIG_CGROUP_NET_CLASSID +u32 classid;/* v1 */ +#endif +#ifdef CONFIG_CGROUP_NET_PRIO +u16 prioidx;/* v1 */ #endif -u64 val; - }; }; -/* -* There's a theoretical window where the following accessors race with -* updaters and return part of the previous pointer as the prioidx or -* classid. Such races are short-lived and the result isn't critical. -*/ static inline u16 sock_cgroup_prioidx (const struct sock_cgroup_data *skcd) { -/* fallback to 1 which is always the ID of the root cgroup */ -return (skcd->is_data &1 ) ? skcd->prioidx :1 ; +#ifdef CONFIG_CGROUP_NET_PRIO +return READ_ONCE (skcd->prioidx); +#else +return 1 ; +#endif }static inline u32 sock_cgroup_classid (const struct sock_cgroup_data *skcd) { -/* fallback to 0 which is the unconfigured default classid */ -return (skcd->is_data &1 ) ? skcd->classid :0 ; +#ifdef CONFIG_CGROUP_NET_CLASSID +return READ_ONCE (skcd->classid); +#else +return 0 ; +#endif } -/* -* If invoked concurrently, the updaters may clobber each other. The -* caller is responsible for synchronization. -*/ static inline void sock_cgroup_set_prioidx (struct sock_cgroup_data *skcd,u16 prioidx) { -struct sock_cgroup_data skcd_buf = {{ .val =READ_ONCE (skcd->val) }}; - -if (sock_cgroup_prioidx (&skcd_buf) == prioidx) -return ; - -if (!(skcd_buf.is_data &1 )) { - skcd_buf.val =0 ; - skcd_buf.is_data =1 ; - } - - skcd_buf.prioidx = prioidx; -WRITE_ONCE (skcd->val, skcd_buf.val);/* see sock_cgroup_ptr() */ +#ifdef CONFIG_CGROUP_NET_PRIO +WRITE_ONCE (skcd->prioidx, prioidx); +#endif }static inline void sock_cgroup_set_classid (struct sock_cgroup_data *skcd,u32 classid) { -struct sock_cgroup_data skcd_buf = {{ .val =READ_ONCE (skcd->val) }}; - -if (sock_cgroup_classid (&skcd_buf) == classid) -return ; - -if (!(skcd_buf.is_data &1 )) { - skcd_buf.val =0 ; - skcd_buf.is_data =1 ; - } - - skcd_buf.classid = classid; -WRITE_ONCE (skcd->val, skcd_buf.val);/* see sock_cgroup_ptr() */ +#ifdef CONFIG_CGROUP_NET_CLASSID +WRITE_ONCE (skcd->classid, classid); +#endif }#else /* CONFIG_SOCK_CGROUP_DATA */
include/linux/cgroup.h +1 -21
@@ -829,33 +829,13 @@ static inline void cgroup_account_cputime_field(struct task_struct *task,*/ #ifdef CONFIG_SOCK_CGROUP_DATA -#if defined(CONFIG_CGROUP_NET_PRIO ) || defined(CONFIG_CGROUP_NET_CLASSID ) -extern spinlock_t cgroup_sk_update_lock; -#endif - -void cgroup_sk_alloc_disable (void );void cgroup_sk_alloc (struct sock_cgroup_data *skcd);void cgroup_sk_clone (struct sock_cgroup_data *skcd);void cgroup_sk_free (struct sock_cgroup_data *skcd);static inline struct cgroup *sock_cgroup_ptr (struct sock_cgroup_data *skcd) { -#if defined(CONFIG_CGROUP_NET_PRIO ) || defined(CONFIG_CGROUP_NET_CLASSID ) -unsigned long v; - -/* -* @skcd->val is 64bit but the following is safe on 32bit too as we -* just need the lower ulong to be written and read atomically. -*/ - v =READ_ONCE (skcd->val); - -if (v &3 ) -return &cgrp_dfl_root.cgrp; - -return (struct cgroup *)(unsigned long )v ?: &cgrp_dfl_root.cgrp; -#else -return (struct cgroup *)(unsigned long )skcd->val; -#endif +return skcd->cgroup; }#else /* CONFIG_CGROUP_DATA */
kernel/cgroup/cgroup.c +10 -40
84 lines not on this page · raw message
net/core/netclassid_cgroup.c +1 -6
@@ -71,11 +71,8 @@ static int update_classid_sock(const void *v, struct file *file, unsigned n)struct update_classid_context *ctx = (void *)v;struct socket *sock =sock_from_file (file); -if (sock) { -spin_lock (&cgroup_sk_update_lock); +if (sock)sock_cgroup_set_classid (&sock->sk->sk_cgrp_data, ctx->classid); -spin_unlock (&cgroup_sk_update_lock); - }if (--ctx->batch ==0 ) { ctx->batch =UPDATE_CLASSID_BATCH ;return n +1 ;
@@ -121,8 +118,6 @@ static int write_classid(struct cgroup_subsys_state *css, struct cftype *cft,struct css_task_iter it;struct task_struct *p; -cgroup_sk_alloc_disable (); - cs->classid = (u32 )value;css_task_iter_start (css,0 , &it);
net/core/netprio_cgroup.c +2 -8
@@ -207,8 +207,6 @@ static ssize_t write_priomap(struct kernfs_open_file *of,if (!dev)return -ENODEV ; -cgroup_sk_alloc_disable (); -rtnl_lock (); ret =netprio_set_prio (of_css (of), dev, prio);
@@ -221,12 +219,10 @@ static ssize_t write_priomap(struct kernfs_open_file *of,static int update_netprio (const void *v,struct file *file,unsigned n) {struct socket *sock =sock_from_file (file); -if (sock) { -spin_lock (&cgroup_sk_update_lock); + +if (sock)sock_cgroup_set_prioidx (&sock->sk->sk_cgrp_data, (unsigned long )v); -spin_unlock (&cgroup_sk_update_lock); - }return 0 ; }
@@ -235,8 +231,6 @@ static void net_prio_attach(struct cgroup_taskset *tset)struct task_struct *p;struct cgroup_subsys_state *css; -cgroup_sk_alloc_disable (); -cgroup_taskset_for_each (p, css, tset) {void *v = (void *)(unsigned long )css->id;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 805/849 bpf, cgroup: Assign cgroup in cgroup_sk_alloc when called from interrupt
In reply to Greg Kroah-HartmanFrom: Daniel Borkmann <[email protected]>
[ Upstream commit 78cc316e9583067884eb8bd154301dc1e9ee945c ]
If cgroup_sk_alloc() is called from interrupt context, then just assign the root cgroup to skcd->cgroup. Prior to commit 8520e224f547 ("bpf, cgroups:
Fix cgroup v2 fallback on v1/v2 mixed mode") we would just return, and later on in sock_cgroup_ptr(), we were NULL-testing the cgroup in fast-path, and iff indeed NULL returning the root cgroup (v ?: &cgrp_dfl_root.cgrp). Rather than re-adding the NULL-test to the fast-path we can just assign it once from cgroup_sk_alloc() given v1/v2 handling has been simplified. The migration from NULL test with returning &cgrp_dfl_root.cgrp to assigning &cgrp_dfl_root.cgrp directly does /not/ change behavior for callers of sock_cgroup_ptr().
syzkaller was able to trigger a splat in the legacy netrom code base, where the RX handler in nr_rx_frame() calls nr_make_new() which calls sk_alloc() and therefore cgroup_sk_alloc() with in_interrupt() condition. Thus the NULL skcd->cgroup, where it trips over on cgroup_sk_free() side given it expects a non-NULL object. There are a few other candidates aside from netrom which have similar pattern where in their accept-like implementation, they just call to sk_alloc() and thus cgroup_sk_alloc() instead of sk_clone_lock() with the corresponding cgroup_sk_clone() which then inherits the cgroup from the parent socket. None of them are related to core protocols where BPF cgroup programs are running from. However, in future, they should follow to implement a similar inheritance mechanism.
Additionally, with a !CONFIG_CGROUP_NET_PRIO and !CONFIG_CGROUP_NET_CLASSID configuration, the same issue was exposed also prior to 8520e224f547 due to commit e876ecc67db8 ("cgroup: memcg: net: do not associate sock with unrelated cgroup") which added the early in_interrupt() return back then.
--- kernel/cgroup/cgroup.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
kernel/cgroup/cgroup.c +12 -5
@@ -6586,22 +6586,29 @@ int cgroup_parse_float(const char *input, unsigned dec_shift, s64 *v)void cgroup_sk_alloc (struct sock_cgroup_data *skcd) { -/* Don't associate the sock with unrelated interrupted task's cgroup. */ -if (in_interrupt ()) -return ; +struct cgroup *cgroup;rcu_read_lock (); +/* Don't associate the sock with unrelated interrupted task's cgroup. */ +if (in_interrupt ()) { + cgroup = &cgrp_dfl_root.cgrp; +cgroup_get (cgroup); + goto out; + } +while (true) {struct css_set *cset; cset =task_css_set (current);if (likely (cgroup_tryget (cset->dfl_cgrp))) { - skcd->cgroup = cset->dfl_cgrp; -cgroup_bpf_get (cset->dfl_cgrp); + cgroup = cset->dfl_cgrp;break ; }cpu_relax (); } +out: + skcd->cgroup = cgroup; +cgroup_bpf_get (cgroup);rcu_read_unlock (); }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 806/849 9p/net: fix missing error check in p9_check_errors
In reply to Greg Kroah-HartmanFrom: Dominique Martinet <[email protected]>
commit 27eb4c3144f7a5ebef3c9a261d80cb3e1fa784dc upstream.
--- net/9p/client.c | 2 ++ 1 file changed, 2 insertions(+)
net/9p/client.c +2 -0
@@ -539,6 +539,8 @@ static int p9_check_errors(struct p9_clikfree (ename); }else { err =p9pdu_readf (&req->rc, c->proto_version,"d" , &ecode); +if (err) + goto out_err; err = -ecode;p9_debug (P9_DEBUG_9P ,"<<< RLERROR (%d)\n" , -ecode);
Greg Kroah-Hartman
maintainerPATCH 807/849 mm/filemap.c: remove bogus VM_BUG_ON
In reply to Greg Kroah-HartmanFrom: Matthew Wilcox (Oracle) <[email protected]>
commit d417b49fff3e2f21043c834841e8623a6098741d upstream.
It is not safe to check page->index without holding the page lock. It can be changed if the page is moved between the swap cache and the page cache for a shmem file, for example. There is a VM_BUG_ON below which checks page->index is correct after taking the page lock.
--- mm/filemap.c | 1 - 1 file changed, 1 deletion(-)
mm/filemap.c +0 -1
@@ -2038,7 +2038,6 @@ unsigned find_lock_entries(struct addresif (!xa_is_value (page)) {if (page->index < start) goto put; -VM_BUG_ON_PAGE (page->index != xas.xa_index, page);if (page->index +thp_nr_pages (page) -1 > end) goto put;if (!trylock_page (page))
Greg Kroah-Hartman
maintainerPATCH 808/849 memcg: prohibit unconditional exceeding the limit of dying tasks
In reply to Greg Kroah-HartmanFrom: Vasily Averin <[email protected]>
commit a4ebf1b6ca1e011289677239a2a361fde4a88076 upstream.
Memory cgroup charging allows killed or exiting tasks to exceed the hard limit. It is assumed that the amount of the memory charged by those tasks is bound and most of the memory will get released while the task is exiting. This is resembling a heuristic for the global OOM situation when tasks get access to memory reserves. There is no global memory shortage at the memcg level so the memcg heuristic is more relieved.
The above assumption is overly optimistic though. E.g. vmalloc can scale to really large requests and the heuristic would allow that. We used to have an early break in the vmalloc allocator for killed tasks but this has been reverted by commit b8c8a338f75e ("Revert "vmalloc:
back off when the current task is killed""). There are likely other similar code paths which do not check for fatal signals in an allocation&charge loop. Also there are some kernel objects charged to a memcg which are not bound to a process life time.
It has been observed that it is not really hard to trigger these bypasses and cause global OOM situation.
One potential way to address these runaways would be to limit the amount of excess (similar to the global OOM with limited oom reserves). This is certainly possible but it is not really clear how much of an excess is desirable and still protects from global OOMs as that would have to consider the overall memcg configuration.
This patch is addressing the problem by removing the heuristic altogether. Bypass is only allowed for requests which either cannot fail or where the failure is not desirable while excess should be still limited (e.g. atomic requests). Implementation wise a killed or dying task fails to charge if it has passed the OOM killer stage. That should give all forms of reclaim chance to restore the limit before the failure (ENOMEM) and tell the caller to back off.
In addition, this patch renames should_force_charge() helper to task_is_dying() because now its use is not associated witch forced charging.
This patch depends on pagefault_out_of_memory() to not trigger out_of_memory(), because then a memcg failure can unwind to VM_FAULT_OOM and cause a global OOM killer.
--- mm/memcontrol.c | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-)
mm/memcontrol.c +8 -19
@@ -234,7 +234,7 @@ enum res_type { iter !=NULL ; \ iter = mem_cgroup_iter(NULL, iter, NULL)) -static inline bool should_force_charge (void ) +static inline bool task_is_dying (void ) {return tsk_is_oom_victim (current) ||fatal_signal_pending (current) || (current->flags &PF_EXITING );
@@ -1607,7 +1607,7 @@ static bool mem_cgroup_out_of_memory(str* A few threads which were not waiting at mutex_lock_killable() can * fail to bail out. Therefore, check again after holding oom_lock. */ - ret =should_force_charge () ||out_of_memory (&oc); + ret =task_is_dying () ||out_of_memory (&oc); unlock:mutex_unlock (&oom_lock);
@@ -2588,6 +2588,7 @@ static int try_charge_memcg(struct mem_cstruct page_counter *counter;enum oom_status oom_status;unsigned long nr_reclaimed; +bool passed_oom = false;bool may_swap = true;bool drained = false;unsigned long pflags;
@@ -2623,15 +2624,6 @@ retry: goto force;/* -* Unlike in global OOM situations, memcg is not in a physical -* memory shortage. Allow dying and OOM-killed tasks to -* bypass the last charges so that they can exit quickly and -* free their memory. -*/ -if (unlikely (should_force_charge ())) - goto force; - -/* * Prevent unbounded recursion when reclaim operations need to * allocate memory. This might exceed the limits temporarily, * but we prefer facilitating memory reclaim and getting back
@@ -2688,8 +2680,9 @@ retry:if (gfp_mask & __GFP_RETRY_MAYFAIL) goto nomem; -if (fatal_signal_pending (current)) - goto force; +/* Avoid endless loop for tasks bypassed by the oom killer */ +if (passed_oom &&task_is_dying ()) + goto nomem;/* * keep retrying as long as the memcg oom killer is able to make
@@ -2698,14 +2691,10 @@ retry:*/ oom_status =mem_cgroup_oom (mem_over_limit, gfp_mask,get_order (nr_pages *PAGE_SIZE )); -switch (oom_status) { -case OOM_SUCCESS : +if (oom_status ==OOM_SUCCESS ) { + passed_oom = true; nr_retries =MAX_RECLAIM_RETRIES ; goto retry; -case OOM_FAILED : - goto force; -default : - goto nomem; } nomem:if (!(gfp_mask & __GFP_NOFAIL))
Greg Kroah-Hartman
maintainerPATCH 809/849 io-wq: ensure that hash wait lock is IRQ disabling
In reply to Greg Kroah-HartmanFrom: Jens Axboe <[email protected]>
commit 08bdbd39b58474d762242e1fadb7f2eb9ffcca71 upstream.
A previous commit removed the IRQ safety of the worker and wqe locks, but that left one spot of the hash wait lock now being done without already having IRQs disabled.
Ensure that we use the right locking variant for the hashed waitqueue lock.
--- fs/io-wq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/io-wq.c +2 -2
@@ -405,7 +405,7 @@ static void io_wait_on_hash(struct io_wq {struct io_wq *wq = wqe->wq; -spin_lock (&wq->hash->wait.lock); +spin_lock_irq (&wq->hash->wait.lock);if (list_empty (&wqe->wait.entry)) {__add_wait_queue (&wq->hash->wait, &wqe->wait);if (!test_bit (hash, &wq->hash->map)) {
@@ -413,7 +413,7 @@ static void io_wait_on_hash(struct io_wqlist_del_init (&wqe->wait.entry); } } -spin_unlock (&wq->hash->wait.lock); +spin_unlock_irq (&wq->hash->wait.lock); }/*
Greg Kroah-Hartman
maintainerPATCH 810/849 io-wq: fix queue stalling race
In reply to Greg Kroah-HartmanFrom: Jens Axboe <[email protected]>
commit 0242f6426ea78fbe3933b44f8c55ae93ec37f6cc upstream.
We need to set the stalled bit early, before we drop the lock for adding us to the stall hash queue. If not, then we can race with new work being queued between adding us to the stall hash and io_worker_handle_work() marking us stalled.
--- fs/io-wq.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
fs/io-wq.c +7 -8
@@ -436,8 +436,7 @@ static bool io_worker_can_run_work(struc }static struct io_wq_work *io_get_next_work (struct io_wqe *wqe, -struct io_worker *worker, -bool *stalled) +struct io_worker *worker) __must_hold(wqe->lock) {struct io_wq_work_node *node, *prev;
@@ -475,10 +474,14 @@ static struct io_wq_work *io_get_next_wo }if (stall_hash !=-1U ) { +/* +* Set this before dropping the lock to avoid racing with new +* work being added and clearing the stalled bit. +*/ + wqe->flags |=IO_WQE_FLAG_STALLED ;raw_spin_unlock (&wqe->lock);io_wait_on_hash (wqe, stall_hash);raw_spin_lock (&wqe->lock); - *stalled = true; }return NULL ;
@@ -518,7 +521,6 @@ static void io_worker_handle_work(struct do { struct io_wq_work *work; - bool stalled; get_next: /* * If we got some work, mark us as busy. If we didn't, but
@@ -527,12 +529,9 @@ get_next:* can't make progress, any work completion or insertion will * clear the stalled flag. */ - stalled = false; - work =io_get_next_work (wqe, worker, &stalled); + work =io_get_next_work (wqe, worker);if (work)__io_worker_busy (wqe, worker, work); -else if (stalled) - wqe->flags |=IO_WQE_FLAG_STALLED ;raw_spin_unlock_irq (&wqe->lock);if (!work)
Greg Kroah-Hartman
maintainerPATCH 811/849 io-wq: serialize hash clear with wakeup
In reply to Greg Kroah-HartmanFrom: Jens Axboe <[email protected]>
commit d3e3c102d107bb84251455a298cf475f24bab995 upstream.
We need to ensure that we serialize the stalled and hash bits with the wait_queue wait handler, or we could be racing with someone modifying the hashed state after we find it busy, but before we then give up and wait for it to be cleared. This can cause random delays or stalls when handling buffered writes for many files, where some of these files cause hash collisions between the worker threads.
--- fs/io-wq.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
fs/io-wq.c +16 -3
@@ -401,9 +401,10 @@ static inline unsigned int io_get_work_hreturn work->flags >>IO_WQ_HASH_SHIFT ; } -static void io_wait_on_hash (struct io_wqe *wqe,unsigned int hash) +static bool io_wait_on_hash (struct io_wqe *wqe,unsigned int hash) {struct io_wq *wq = wqe->wq; +bool ret = false;spin_lock_irq (&wq->hash->wait.lock);if (list_empty (&wqe->wait.entry)) {
@@ -411,9 +412,11 @@ static void io_wait_on_hash(struct io_wqif (!test_bit (hash, &wq->hash->map)) {__set_current_state (TASK_RUNNING );list_del_init (&wqe->wait.entry); + ret = true; } }spin_unlock_irq (&wq->hash->wait.lock); +return ret; }/*
@@ -474,14 +477,21 @@ static struct io_wq_work *io_get_next_wo }if (stall_hash !=-1U ) { +bool unstalled; +/* * Set this before dropping the lock to avoid racing with new * work being added and clearing the stalled bit. */ wqe->flags |=IO_WQE_FLAG_STALLED ;raw_spin_unlock (&wqe->lock); -io_wait_on_hash (wqe, stall_hash); + unstalled =io_wait_on_hash (wqe, stall_hash);raw_spin_lock (&wqe->lock); +if (unstalled) { + wqe->flags &= ~IO_WQE_FLAG_STALLED ; +if (wq_has_sleeper (&wqe->wq->hash->wait)) +wake_up (&wqe->wq->hash->wait); + } }return NULL ;
@@ -562,11 +572,14 @@ get_next:io_wqe_enqueue (wqe, linked);if (hash !=-1U && !next_hashed) { +/* serialize hash clear with wake_up() */ +spin_lock_irq (&wq->hash->wait.lock);clear_bit (hash, &wq->hash->map); + wqe->flags &= ~IO_WQE_FLAG_STALLED ; +spin_unlock_irq (&wq->hash->wait.lock);if (wq_has_sleeper (&wq->hash->wait))wake_up (&wq->hash->wait);raw_spin_lock_irq (&wqe->lock); - wqe->flags &= ~IO_WQE_FLAG_STALLED ;/* skip unnecessary unlock-lock wqe->lock */ if (!work) goto get_next;
Greg Kroah-Hartman
maintainerPATCH 812/849 mm, oom: pagefault_out_of_memory: dont force global OOM for dying tasks
In reply to Greg Kroah-HartmanFrom: Vasily Averin <[email protected]>
commit 0b28179a6138a5edd9d82ad2687c05b3773c387b upstream.
Patch series "memcg: prohibit unconditional exceeding the limit of dying tasks", v3.
Memory cgroup charging allows killed or exiting tasks to exceed the hard limit. It can be misused and allowed to trigger global OOM from inside a memcg-limited container. On the other hand if memcg fails allocation, called from inside #PF handler it triggers global OOM from inside pagefault_out_of_memory().
To prevent these problems this patchset:
(a) removes execution of out_of_memory() from pagefault_out_of_memory(), becasue nobody can explain why it is necessary.
(b) allow memcg to fail allocation of dying/killed tasks.
This patch (of 3):
Any allocation failure during the #PF path will return with VM_FAULT_OOM which in turn results in pagefault_out_of_memory which in turn executes out_out_memory() and can kill a random task.
An allocation might fail when the current task is the oom victim and there are no memory reserves left. The OOM killer is already handled at the page allocator level for the global OOM and at the charging level for the memcg one. Both have much more information about the scope of allocation/charge request. This means that either the OOM killer has been invoked properly and didn't lead to the allocation success or it has been skipped because it couldn't have been invoked. In both cases triggering it from here is pointless and even harmful.
It makes much more sense to let the killed task die rather than to wake up an eternally hungry oom-killer and send him to choose a fatter victim for breakfast.
--- mm/oom_kill.c | 3 +++ 1 file changed, 3 insertions(+)
mm/oom_kill.c +3 -0
@@ -1136,6 +1136,9 @@ void pagefault_out_of_memory(void)if (mem_cgroup_oom_synchronize (true))return ; +if (fatal_signal_pending (current)) +return ; +if (!mutex_trylock (&oom_lock))return ;out_of_memory (&oc);
Greg Kroah-Hartman
maintainerPATCH 813/849 mm, oom: do not trigger out_of_memory from the #PF
In reply to Greg Kroah-HartmanFrom: Michal Hocko <[email protected]>
commit 60e2793d440a3ec95abb5d6d4fc034a4b480472d upstream.
Any allocation failure during the #PF path will return with VM_FAULT_OOM which in turn results in pagefault_out_of_memory. This can happen for 2 different reasons. a) Memcg is out of memory and we rely on mem_cgroup_oom_synchronize to perform the memcg OOM handling or b) normal allocation fails.
The latter is quite problematic because allocation paths already trigger out_of_memory and the page allocator tries really hard to not fail allocations. Anyway, if the OOM killer has been already invoked there is no reason to invoke it again from the #PF path. Especially when the OOM condition might be gone by that time and we have no way to find out other than allocate.
Moreover if the allocation failed and the OOM killer hasn't been invoked then we are unlikely to do the right thing from the #PF context because we have already lost the allocation context and restictions and therefore might oom kill a task from a different NUMA domain.
This all suggests that there is no legitimate reason to trigger out_of_memory from pagefault_out_of_memory so drop it. Just to be sure that no #PF path returns with VM_FAULT_OOM without allocation print a warning that this is happening before we restart the #PF.
[VvS: #PF allocation can hit into limit of cgroup v1 kmem controller. This is a local problem related to memcg, however, it causes unnecessary global OOM kills that are repeated over and over again and escalate into a real disaster. This has been broken since kmem accounting has been introduced for cgroup v1 (3.8). There was no kmem specific reclaim for the separate limit so the only way to handle kmem hard limit was to return with ENOMEM. In upstream the problem will be fixed by removing the outdated kmem limit, however stable and LTS kernels cannot do it and are still affected. This patch fixes the problem and should be backported into stable/LTS.]
--- mm/oom_kill.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-)
mm/oom_kill.c +8 -14
@@ -1119,19 +1119,15 @@ bool out_of_memory(struct oom_control *o }/* -* The pagefault handler calls here because it is out of memory, so kill a -* memory-hogging task. If oom_lock is held by somebody else, a parallel oom -* killing is already in progress so do nothing. +* The pagefault handler calls here because some allocation has failed. We have +* to take care of the memcg OOM here because this is the only safe context without +* any locks held but let the oom killer triggered from the allocation context care +* about the global OOM. */ void pagefault_out_of_memory (void ) { -struct oom_control oc = { - .zonelist =NULL , - .nodemask =NULL , - .memcg =NULL , - .gfp_mask =0 , - .order =0 , - }; + static DEFINE_RATELIMIT_STATE(pfoom_rs, DEFAULT_RATELIMIT_INTERVAL, + DEFAULT_RATELIMIT_BURST);if (mem_cgroup_oom_synchronize (true))return ;
@@ -1139,8 +1135,6 @@ void pagefault_out_of_memory(void)if (fatal_signal_pending (current))return ; -if (!mutex_trylock (&oom_lock)) -return ; -out_of_memory (&oc); -mutex_unlock (&oom_lock); +if (__ratelimit (&pfoom_rs)) +pr_warn ("Huh VM_FAULT_OOM leaked out to the #PF handler. Retrying PF\n" ); }
Greg Kroah-Hartman
maintainerPATCH 814/849 mfd: dln2: Add cell for initializing DLN2 ADC
In reply to Greg Kroah-HartmanFrom: Jack Andersen <[email protected]>
commit 313c84b5ae4104e48c661d5d706f9f4c425fd50f upstream.
This patch extends the DLN2 driver; adding cell for adc_dln2 module.
The original patch[1] fell through the cracks when the driver was added so ADC has never actually been usable. That patch did not have ACPI support which was added in v5.9, so the oldest supported version this current patch can be backported to is 5.10.
[1] https://www.spinics.net/lists/linux-iio/msg33975.html
--- drivers/mfd/dln2.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/mfd/dln2.c +18 -0
@@ -50,6 +50,7 @@ enum dln2_handle {DLN2_HANDLE_GPIO ,DLN2_HANDLE_I2C ,DLN2_HANDLE_SPI , +DLN2_HANDLE_ADC , DLN2_HANDLES };
@@ -653,6 +654,7 @@ enum {DLN2_ACPI_MATCH_GPIO =0 ,DLN2_ACPI_MATCH_I2C =1 ,DLN2_ACPI_MATCH_SPI =2 , + DLN2_ACPI_MATCH_ADC = 3, }; static struct dln2_platform_data dln2_pdata_gpio = {
@@ -683,6 +685,16 @@ static struct mfd_cell_acpi_match dln2_a .adr = DLN2_ACPI_MATCH_SPI, }; +/* Only one ADC port supported */ +static struct dln2_platform_data dln2_pdata_adc = { + .handle =DLN2_HANDLE_ADC , + .port =0 , +}; + +static struct mfd_cell_acpi_match dln2_acpi_match_adc = { + .adr =DLN2_ACPI_MATCH_ADC , +}; +static const struct mfd_cell dln2_devs[] = { { .name ="dln2-gpio" ,
@@ -702,6 +714,12 @@ static const struct mfd_cell dln2_devs[] .platform_data = &dln2_pdata_spi, .pdata_size = sizeof(struct dln2_platform_data), }, + { + .name = "dln2-adc", + .acpi_match = &dln2_acpi_match_adc, + .platform_data = &dln2_pdata_adc, + .pdata_size = sizeof(struct dln2_platform_data), + }, };static void dln2_stop (struct dln2_dev *dln2)
Greg Kroah-Hartman
maintainerPATCH 815/849 video: backlight: Drop maximum brightness override for brightness zero
In reply to Greg Kroah-HartmanFrom: Marek Vasut <[email protected]>
commit 33a5471f8da976bf271a1ebbd6b9d163cb0cb6aa upstream.
The note in c2adda27d202f ("video: backlight: Add of_find_backlight helper in backlight.c") says that gpio-backlight uses brightness as power state. This has been fixed since in ec665b756e6f7 ("backlight: gpio-backlight:
Correct initial power state handling") and other backlight drivers do not require this workaround. Drop the workaround.
This fixes the case where e.g. pwm-backlight can perfectly well be set to brightness 0 on boot in DT, which without this patch leads to the display brightness to be max instead of off.
--- drivers/video/backlight/backlight.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/video/backlight/backlight.c +0 -6
@@ -688,12 +688,6 @@ static struct backlight_device *of_find_of_node_put (np);if (!bd)return ERR_PTR (-EPROBE_DEFER ); -/* -* Note: gpio_backlight uses brightness as -* power state during probe -*/ -if (!bd->props.brightness) - bd->props.brightness = bd->props.max_brightness; } }
Greg Kroah-Hartman
maintainerPATCH 816/849 PM: sleep: Avoid calling put_device() under dpm_list_mtx
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
commit 2aa36604e8243698ff22bd5fef0dd0c6bb07ba92 upstream.
It is generally unsafe to call put_device() with dpm_list_mtx held, because the given device's release routine may carry out an action depending on that lock which then may deadlock, so modify the system-wide suspend and resume of devices to always drop dpm_list_mtx before calling put_device() (and adjust white space somewhat while at it).
For instance, this prevents the following splat from showing up in the kernel log after a system resume in certain configurations:
[ 3290.969514] ======================================================
[ 3290.969517] WARNING: possible circular locking dependency detected
[ 3290.969519] 5.15.0+ #2420 Tainted: G S
[ 3290.969523] ------------------------------------------------------
[ 3290.969525] systemd-sleep/4553 is trying to acquire lock:
[ 3290.969529] ffff888117ab1138 ((wq_completion)hci0#2){+.+.}-{0:0}, at: flush_workqueue+0x87/0x4a0
[ 3290.969554]
but task is already holding lock:
[ 3290.969556] ffffffff8280fca8 (dpm_list_mtx){+.+.}-{3:3}, at: dpm_resume+0x12e/0x3e0
[ 3290.969571]
which lock already depends on the new lock.[ 3290.969573]
the existing dependency chain (in reverse order) is:
[ 3290.969575]
-> #3 (dpm_list_mtx){+.+.}-{3:3}:
[ 3290.969583] __mutex_lock+0x9d/0xa30
[ 3290.969591] device_pm_add+0x2e/0xe0
[ 3290.969597] device_add+0x4d5/0x8f0
[ 3290.969605] hci_conn_add_sysfs+0x43/0xb0 [bluetooth]
[ 3290.969689] hci_conn_complete_evt.isra.71+0x124/0x750 [bluetooth]
[ 3290.969747] hci_event_packet+0xd6c/0x28a0 [bluetooth]
[ 3290.969798] hci_rx_work+0x213/0x640 [bluetooth]
[ 3290.969842] process_one_work+0x2aa/0x650
[ 3290.969851] worker_thread+0x39/0x400
[ 3290.969859] kthread+0x142/0x170
[ 3290.969865] ret_from_fork+0x22/0x30
[ 3290.969872]
-> #2 (&hdev->lock){+.+.}-{3:3}:
[ 3290.969881] __mutex_lock+0x9d/0xa30
[ 3290.969887] hci_event_packet+0xba/0x28a0 [bluetooth]
[ 3290.969935] hci_rx_work+0x213/0x640 [bluetooth]
[ 3290.969978] process_one_work+0x2aa/0x650
[ 3290.969985] worker_thread+0x39/0x400
[ 3290.969993] kthread+0x142/0x170
[ 3290.969999] ret_from_fork+0x22/0x30
[ 3290.970004]
-> #1 ((work_completion)(&hdev->rx_work)){+.+.}-{0:0}:
[ 3290.970013] process_one_work+0x27d/0x650
[ 3290.970020] worker_thread+0x39/0x400
[ 3290.970028] kthread+0x142/0x170
[ 3290.970033] ret_from_fork+0x22/0x30
[ 3290.970038]
-> #0 ((wq_completion)hci0#2){+.+.}-{0:0}:
[ 3290.970047] __lock_acquire+0x15cb/0x1b50
[ 3290.970054] lock_acquire+0x26c/0x300
[ 3290.970059] flush_workqueue+0xae/0x4a0
[ 3290.970066] drain_workqueue+0xa1/0x130
[ 3290.970073] destroy_workqueue+0x34/0x1f0
[ 3290.970081] hci_release_dev+0x49/0x180 [bluetooth]
[ 3290.970130] bt_host_release+0x1d/0x30 [bluetooth]
[ 3290.970195] device_release+0x33/0x90
[ 3290.970201] kobject_release+0x63/0x160
[ 3290.970211] dpm_resume+0x164/0x3e0
[ 3290.970215] dpm_resume_end+0xd/0x20
[ 3290.970220] suspend_devices_and_enter+0x1a4/0xba0
[ 3290.970229] pm_suspend+0x26b/0x310
[ 3290.970236] state_store+0x42/0x90
[ 3290.970243] kernfs_fop_write_iter+0x135/0x1b0
[ 3290.970251] new_sync_write+0x125/0x1c0
[ 3290.970257] vfs_write+0x360/0x3c0
[ 3290.970263] ksys_write+0xa7/0xe0
[ 3290.970269] do_syscall_64+0x3a/0x80
[ 3290.970276] entry_SYSCALL_64_after_hwframe+0x44/0xae
[ 3290.970284]
other info that might help us debug this:[ 3290.970285] Chain exists of:
(wq_completion)hci0#2 --> &hdev->lock --> dpm_list_mtx[ 3290.970297] Possible unsafe locking scenario:
[ 3290.970299] CPU0 CPU1
[ 3290.970300] ---- ----
[ 3290.970302] lock(dpm_list_mtx);
[ 3290.970306] lock(&hdev->lock);
[ 3290.970310] lock(dpm_list_mtx);
[ 3290.970314] lock((wq_completion)hci0#2);
[ 3290.970319]
*** DEADLOCK ***[ 3290.970321] 7 locks held by systemd-sleep/4553:
[ 3290.970325] #0: ffff888103bcd448 (sb_writers#4){.+.+}-{0:0}, at: ksys_write+0xa7/0xe0
[ 3290.970341] #1: ffff888115a14488 (&of->mutex){+.+.}-{3:3}, at: kernfs_fop_write_iter+0x103/0x1b0
[ 3290.970355] #2: ffff888100f719e0 (kn->active#233){.+.+}-{0:0}, at: kernfs_fop_write_iter+0x10c/0x1b0
[ 3290.970369] #3: ffffffff82661048 (autosleep_lock){+.+.}-{3:3}, at: state_store+0x12/0x90
[ 3290.970384] #4: ffffffff82658ac8 (system_transition_mutex){+.+.}-{3:3}, at: pm_suspend+0x9f/0x310
[ 3290.970399] #5: ffffffff827f2a48 (acpi_scan_lock){+.+.}-{3:3}, at: acpi_suspend_begin+0x4c/0x80
[ 3290.970416] #6: ffffffff8280fca8 (dpm_list_mtx){+.+.}-{3:3}, at: dpm_resume+0x12e/0x3e0
[ 3290.970428]
stack backtrace:
[ 3290.970431] CPU: 3 PID: 4553 Comm: systemd-sleep Tainted: G S 5.15.0+ #2420
[ 3290.970438] Hardware name: Dell Inc. XPS 13 9380/0RYJWW, BIOS 1.5.0 06/03/2019
[ 3290.970441] Call Trace:
[ 3290.970446] dump_stack_lvl+0x44/0x57
[ 3290.970454] check_noncircular+0x105/0x120
[ 3290.970468] ? __lock_acquire+0x15cb/0x1b50
[ 3290.970474] __lock_acquire+0x15cb/0x1b50
[ 3290.970487] lock_acquire+0x26c/0x300
[ 3290.970493] ? flush_workqueue+0x87/0x4a0
[ 3290.970503] ? __raw_spin_lock_init+0x3b/0x60
[ 3290.970510] ? lockdep_init_map_type+0x58/0x240
[ 3290.970519] flush_workqueue+0xae/0x4a0
[ 3290.970526] ? flush_workqueue+0x87/0x4a0
[ 3290.970544] ? drain_workqueue+0xa1/0x130
[ 3290.970552] drain_workqueue+0xa1/0x130
[ 3290.970561] destroy_workqueue+0x34/0x1f0
[ 3290.970572] hci_release_dev+0x49/0x180 [bluetooth]
[ 3290.970624] bt_host_release+0x1d/0x30 [bluetooth]
[ 3290.970687] device_release+0x33/0x90
[ 3290.970695] kobject_release+0x63/0x160
[ 3290.970705] dpm_resume+0x164/0x3e0
[ 3290.970710] ? dpm_resume_early+0x251/0x3b0
[ 3290.970718] dpm_resume_end+0xd/0x20
[ 3290.970723] suspend_devices_and_enter+0x1a4/0xba0
[ 3290.970737] pm_suspend+0x26b/0x310
[ 3290.970746] state_store+0x42/0x90
[ 3290.970755] kernfs_fop_write_iter+0x135/0x1b0
[ 3290.970764] new_sync_write+0x125/0x1c0
[ 3290.970777] vfs_write+0x360/0x3c0
[ 3290.970785] ksys_write+0xa7/0xe0
[ 3290.970794] do_syscall_64+0x3a/0x80
[ 3290.970803] entry_SYSCALL_64_after_hwframe+0x44/0xae
[ 3290.970811] RIP: 0033:0x7f41b1328164
[ 3290.970819] Code: 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b7 0f 1f 80 00 00 00 00 8b 05 4a d2 2c 00 48 63 ff 85 c0 75 13 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 54 f3 c3 66 90 55 53 48 89 d5 48 89 f3 48 83
[ 3290.970824] RSP: 002b:00007ffe6ae21b28 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
[ 3290.970831] RAX: ffffffffffffffda RBX: 0000000000000004 RCX: 00007f41b1328164
[ 3290.970836] RDX: 0000000000000004 RSI: 000055965e651070 RDI: 0000000000000004
[ 3290.970839] RBP: 000055965e651070 R08: 000055965e64f390 R09: 00007f41b1e3d1c0
[ 3290.970843] R10: 000000000000000a R11: 0000000000000246 R12: 0000000000000004
[ 3290.970846] R13: 0000000000000001 R14: 000055965e64f2b0 R15: 0000000000000004--- drivers/base/power/main.c | 84 +++++++++++++++++++++++++++++++--------------- 1 file changed, 57 insertions(+), 27 deletions(-)
drivers/base/power/main.c +57 -27
@@ -711,6 +711,7 @@ static void dpm_noirq_resume_devices(pm_ dev =to_device (dpm_noirq_list.next);get_device (dev);list_move_tail (&dev->power.entry, &dpm_late_early_list); +mutex_unlock (&dpm_list_mtx);if (!is_async (dev)) {
@@ -725,8 +726,9 @@ static void dpm_noirq_resume_devices(pm_ } } -mutex_lock (&dpm_list_mtx);put_device (dev); + +mutex_lock (&dpm_list_mtx); }mutex_unlock (&dpm_list_mtx);async_synchronize_full ();
@@ -852,6 +854,7 @@ void dpm_resume_early(pm_message_t state dev =to_device (dpm_late_early_list.next);get_device (dev);list_move_tail (&dev->power.entry, &dpm_suspended_list); +mutex_unlock (&dpm_list_mtx);if (!is_async (dev)) {
@@ -865,8 +868,10 @@ void dpm_resume_early(pm_message_t statepm_dev_err (dev, state," early" , error); } } -mutex_lock (&dpm_list_mtx); +put_device (dev); + +mutex_lock (&dpm_list_mtx); }mutex_unlock (&dpm_list_mtx);async_synchronize_full ();
@@ -1029,7 +1034,12 @@ void dpm_resume(pm_message_t state) }if (!list_empty (&dev->power.entry))list_move_tail (&dev->power.entry, &dpm_prepared_list); + +mutex_unlock (&dpm_list_mtx); +put_device (dev); + +mutex_lock (&dpm_list_mtx); }mutex_unlock (&dpm_list_mtx);async_synchronize_full ();
@@ -1107,14 +1117,16 @@ void dpm_complete(pm_message_t state)get_device (dev); dev->power.is_prepared = false;list_move (&dev->power.entry, &list); +mutex_unlock (&dpm_list_mtx);trace_device_pm_callback_start (dev,"" , state.event);device_complete (dev, state);trace_device_pm_callback_end (dev,0 ); -mutex_lock (&dpm_list_mtx);put_device (dev); + +mutex_lock (&dpm_list_mtx); }list_splice (&list, &dpm_list);mutex_unlock (&dpm_list_mtx);
@@ -1299,17 +1311,21 @@ static int dpm_noirq_suspend_devices(pm_ error =device_suspend_noirq (dev);mutex_lock (&dpm_list_mtx); +if (error) {pm_dev_err (dev, state," noirq" , error);dpm_save_failed_dev (dev_name (dev)); -put_device (dev); -break ; - } -if (!list_empty (&dev->power.entry)) + }else if (!list_empty (&dev->power.entry)) {list_move (&dev->power.entry, &dpm_noirq_list); + } + +mutex_unlock (&dpm_list_mtx); +put_device (dev); -if (async_error) +mutex_lock (&dpm_list_mtx); + +if (error || async_error)break ; }mutex_unlock (&dpm_list_mtx);
@@ -1476,23 +1492,28 @@ int dpm_suspend_late(pm_message_t state)struct device *dev =to_device (dpm_suspended_list.prev);get_device (dev); +mutex_unlock (&dpm_list_mtx); error =device_suspend_late (dev);mutex_lock (&dpm_list_mtx); +if (!list_empty (&dev->power.entry))list_move (&dev->power.entry, &dpm_late_early_list);if (error) {pm_dev_err (dev, state," late" , error);dpm_save_failed_dev (dev_name (dev)); -put_device (dev); -break ; } + +mutex_unlock (&dpm_list_mtx); +put_device (dev); -if (async_error) +mutex_lock (&dpm_list_mtx); + +if (error || async_error)break ; }mutex_unlock (&dpm_list_mtx);
@@ -1752,21 +1773,27 @@ int dpm_suspend(pm_message_t state)struct device *dev =to_device (dpm_prepared_list.prev);get_device (dev); +mutex_unlock (&dpm_list_mtx); error =device_suspend (dev);mutex_lock (&dpm_list_mtx); +if (error) {pm_dev_err (dev, state,"" , error);dpm_save_failed_dev (dev_name (dev)); -put_device (dev); -break ; - } -if (!list_empty (&dev->power.entry)) + }else if (!list_empty (&dev->power.entry)) {list_move (&dev->power.entry, &dpm_suspended_list); + } + +mutex_unlock (&dpm_list_mtx); +put_device (dev); -if (async_error) + +mutex_lock (&dpm_list_mtx); + +if (error || async_error)break ; }mutex_unlock (&dpm_list_mtx);
@@ -1883,6 +1910,7 @@ int dpm_prepare(pm_message_t state)struct device *dev =to_device (dpm_list.next);get_device (dev); +mutex_unlock (&dpm_list_mtx);trace_device_pm_callback_start (dev,"" , state.event);
@@ -1890,21 +1918,23 @@ int dpm_prepare(pm_message_t state)trace_device_pm_callback_end (dev, error);mutex_lock (&dpm_list_mtx); -if (error) { -if (error == -EAGAIN ) { -put_device (dev); - error =0 ; -continue ; - } + +if (!error) { + dev->power.is_prepared = true; +if (!list_empty (&dev->power.entry)) +list_move_tail (&dev->power.entry, &dpm_prepared_list); + }else if (error == -EAGAIN ) { + error =0 ; + }else {dev_info (dev,"not prepared for power transition: code %d\n" , error); -put_device (dev); -break ; } - dev->power.is_prepared = true; -if (!list_empty (&dev->power.entry)) -list_move_tail (&dev->power.entry, &dpm_prepared_list); + +mutex_unlock (&dpm_list_mtx); +put_device (dev); + +mutex_lock (&dpm_list_mtx); }mutex_unlock (&dpm_list_mtx);trace_suspend_resume (TPS ("dpm_prepare" ), state.event, false);
Greg Kroah-Hartman
maintainerPATCH 817/849 s390/cpumf: cpum_cf PMU displays invalid value after hotplug remove
In reply to Greg Kroah-HartmanFrom: Thomas Richter <[email protected]>
commit 9d48c7afedf91a02d03295837ec76b2fb5e7d3fe upstream.
When a CPU is hotplugged while the perf stat -e cycles command is running, a wrong (very large) value is displayed immediately after the CPU removal:
Check the values, shouldn't be too high as in
time counts unit events
1.001101919 29261846 cycles
2.002454499 17523405 cycles
3.003659292 24361161 cycles
4.004816983 18446744073638406144 cycles
5.005671647 <not counted> cycles
...The CPU hotplug off took place after 3 seconds.
The issue is the read of the event count value after 4 seconds when the CPU is not available and the read of the counter returns an error. This is treated as a counter value of zero. This results in a very large value (0 - previous_value).
Fix this by detecting the hotplugged off CPU and report 0 instead of a very large number.
--- arch/s390/kernel/perf_cpum_cf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/s390/kernel/perf_cpum_cf.c +3 -1
@@ -679,8 +679,10 @@ static void cpumf_pmu_stop(struct perf_e false);if (cfdiag_diffctr (cpuhw, event->hw.config_base))cfdiag_push_sample (event, cpuhw); - }else + }else if (cpuhw->flags &PMU_F_RESERVED ) { +/* Only update when PMU not hotplugged off */ hw_perf_event_update (event); + } hwc->state |=PERF_HES_UPTODATE ; } }
Greg Kroah-Hartman
maintainerPATCH 818/849 s390/cio: check the subchannel validity for dev_busid
In reply to Greg Kroah-HartmanFrom: Vineeth Vijayan <[email protected]>
commit a4751f157c194431fae9e9c493f456df8272b871 upstream.
Check the validity of subchanel before reading other fields in the schib.
--- drivers/s390/cio/css.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/s390/cio/css.c +2 -2
@@ -437,8 +437,8 @@ static ssize_t dev_busid_show(struct devstruct subchannel *sch =to_subchannel (dev);struct pmcw *pmcw = &sch->schib.pmcw; -if ((pmcw->st ==SUBCHANNEL_TYPE_IO || - pmcw->st ==SUBCHANNEL_TYPE_MSG ) && pmcw->dnv) +if ((pmcw->st ==SUBCHANNEL_TYPE_IO && pmcw->dnv) || + (pmcw->st ==SUBCHANNEL_TYPE_MSG && pmcw->w))return sysfs_emit (buf,"0.%x.%04x\n" , sch->schid.ssid, pmcw->dev);else
Greg Kroah-Hartman
maintainerPATCH 819/849 s390/tape: fix timer initialization in tape_std_assign()
In reply to Greg Kroah-HartmanFrom: Sven Schnelle <[email protected]>
commit 213fca9e23b59581c573d558aa477556f00b8198 upstream.
commit 9c6c273aa424 ("timer: Remove init_timer_on_stack() in favor of timer_setup_on_stack()") changed the timer setup from init_timer_on_stack(() to timer_setup(), but missed to change the mod_timer() call. And while at it, use msecs_to_jiffies() instead of the open coded timeout calculation.
--- drivers/s390/char/tape_std.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/s390/char/tape_std.c +1 -2
@@ -53,7 +53,6 @@ int tape_std_assign(struct tape_device *device) {int rc; -struct timer_list timeout;struct tape_request *request; request =tape_alloc_request (2 ,11 );
@@ -70,7 +69,7 @@ tape_std_assign(struct tape_device *devi* So we set up a timeout for this call. */ timer_setup (&request->timer, tape_std_assign_timeout,0 ); -mod_timer (&timeout, jiffies +2 *HZ ); +mod_timer (&request->timer, jiffies +msecs_to_jiffies (2000 )); rc =tape_do_io_interruptible (device, request);
Greg Kroah-Hartman
maintainerPATCH 820/849 s390/ap: Fix hanging ioctl caused by orphaned replies
In reply to Greg Kroah-HartmanFrom: Harald Freudenberger <[email protected]>
commit 3826350e6dd435e244eb6e47abad5a47c169ebc2 upstream.
When a queue is switched to soft offline during heavy load and later switched to soft online again and now used, it may be that the caller is blocked forever in the ioctl call.
The failure occurs because there is a pending reply after the queue(s) have been switched to offline. This orphaned reply is received when the queue is switched to online and is accidentally counted for the outstanding replies. So when there was a valid outstanding reply and this orphaned reply is received it counts as the outstanding one thus dropping the outstanding counter to 0. Voila, with this counter the receive function is not called any more and the real outstanding reply is never received (until another request comes in...) and the ioctl blocks.
The fix is simple. However, instead of readjusting the counter when an orphaned reply is detected, I check the queue status for not empty and compare this to the outstanding counter. So if the queue is not empty then the counter must not drop to 0 but at least have a value of 1.
--- drivers/s390/crypto/ap_queue.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/s390/crypto/ap_queue.c +2 -0
@@ -157,6 +157,8 @@ static struct ap_queue_status ap_sm_recvswitch (status.response_code) {case AP_RESPONSE_NORMAL : aq->queue_count =max_t (int,0 , aq->queue_count -1 ); +if (!status.queue_empty && !aq->queue_count) + aq->queue_count++;if (aq->queue_count >0 )mod_timer (&aq->timeout, jiffies + aq->request_timeout);
Greg Kroah-Hartman
maintainerPATCH 821/849 s390/cio: make ccw_device_dma_* more robust
In reply to Greg Kroah-HartmanFrom: Halil Pasic <[email protected]>
commit ad9a14517263a16af040598c7920c09ca9670a31 upstream.
Since commit 48720ba56891 ("virtio/s390: use DMA memory for ccw I/O and classic notifiers") we were supposed to make sure that virtio_ccw_release_dev() completes before the ccw device and the attached dma pool are torn down, but unfortunately we did not. Before that commit it used to be OK to delay cleaning up the memory allocated by virtio-ccw indefinitely (which isn't really intuitive for guys used to destruction happens in reverse construction order), but now we trigger a BUG_ON if the genpool is destroyed before all memory allocated from it is deallocated. Which brings down the guest. We can observe this problem, when unregister_virtio_device() does not give up the last reference to the virtio_device (e.g. because a virtio-scsi attached scsi disk got removed without previously unmounting its previously mounted partition).
To make sure that the genpool is only destroyed after all the necessary freeing is done let us take a reference on the ccw device on each ccw_device_dma_zalloc() and give it up on each ccw_device_dma_free().
Actually there are multiple approaches to fixing the problem at hand that can work. The upside of this one is that it is the safest one while remaining simple. We don't crash the guest even if the driver does not pair allocations and frees. The downside is the reference counting overhead, that the reference counting for ccw devices becomes more complex, in a sense that we need to pair the calls to the aforementioned functions for it to be correct, and that if we happen to leak, we leak more than necessary (the whole ccw device instead of just the genpool).
Some alternatives to this approach are taking a reference in virtio_ccw_online() and giving it up in virtio_ccw_release_dev() or making sure virtio_ccw_release_dev() completes its work before virtio_ccw_remove() returns. The downside of these approaches is that these are less safe against programming errors.
--- drivers/s390/cio/device_ops.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/s390/cio/device_ops.c +11 -1
@@ -825,13 +825,23 @@ EXPORT_SYMBOL_GPL(ccw_device_get_chid);*/ void *ccw_device_dma_zalloc (struct ccw_device *cdev,size_t size) { -return cio_gp_dma_zalloc (cdev->private->dma_pool, &cdev->dev, size); +void *addr; + +if (!get_device (&cdev->dev)) +return NULL ; + addr =cio_gp_dma_zalloc (cdev->private->dma_pool, &cdev->dev, size); +if (IS_ERR_OR_NULL (addr)) +put_device (&cdev->dev); +return addr; }EXPORT_SYMBOL (ccw_device_dma_zalloc);void ccw_device_dma_free (struct ccw_device *cdev,void *cpu_addr,size_t size) { +if (!cpu_addr) +return ;cio_gp_dma_free (cdev->private->dma_pool, cpu_addr, size); +put_device (&cdev->dev); }EXPORT_SYMBOL (ccw_device_dma_free);
Greg Kroah-Hartman
maintainerPATCH 822/849 remoteproc: elf_loader: Fix loading segment when is_iomem true
In reply to Greg Kroah-HartmanFrom: Peng Fan <[email protected]>
commit 24acbd9dc934f5d9418a736c532d3970a272063e upstream.
It seems luckliy work on i.MX platform, but it is wrong. Need use memcpy_toio, not memcpy_fromio.
--- drivers/remoteproc/remoteproc_elf_loader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/remoteproc/remoteproc_elf_loader.c +1 -1
@@ -220,7 +220,7 @@ int rproc_elf_load_segments(struct rproc/* put the segment where the remote processor expects it */ if (filesz) {if (is_iomem) -memcpy_fromio (ptr, (void __iomem *)(elf_data + offset), filesz); +memcpy_toio ((void __iomem *)ptr, elf_data + offset, filesz);else memcpy (ptr, elf_data + offset, filesz); }
Greg Kroah-Hartman
maintainerPATCH 823/849 remoteproc: Fix the wrong default value of is_iomem
In reply to Greg Kroah-HartmanFrom: Dong Aisheng <[email protected]>
commit 970675f61bf5761d7e5326f6e4df995ecdba5e11 upstream.
Currently the is_iomem is a random value in the stack which may be default to true even on those platforms that not use iomem to store firmware.
--- drivers/remoteproc/remoteproc_coredump.c | 2 +- drivers/remoteproc/remoteproc_elf_loader.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/remoteproc/remoteproc_coredump.c +1 -1
@@ -152,8 +152,8 @@ static void rproc_copy_segment(struct rpstruct rproc_dump_segment *segment, size_t offset, size_t size) { + bool is_iomem = false;void *ptr; -bool is_iomem;if (segment->dump) { segment->dump (rproc, segment, dest, offset, size);
drivers/remoteproc/remoteproc_elf_loader.c +1 -1
@@ -178,8 +178,8 @@ int rproc_elf_load_segments(struct rprocu64 filesz =elf_phdr_get_p_filesz (class, phdr);u64 offset =elf_phdr_get_p_offset (class, phdr);u32 type =elf_phdr_get_p_type (class, phdr); +bool is_iomem = false;void *ptr; -bool is_iomem;if (type !=PT_LOAD )continue ;
Greg Kroah-Hartman
maintainerPATCH 824/849 remoteproc: imx_rproc: Fix ignoring mapping vdev regions
In reply to Greg Kroah-HartmanFrom: Dong Aisheng <[email protected]>
commit afe670e23af91d8a74a8d7049f6e0984bbf6ea11 upstream.
vdev regions are typically named vdev0buffer, vdev0ring0, vdev0ring1 and etc. Change to strncmp to cover them all.
--- drivers/remoteproc/imx_rproc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/remoteproc/imx_rproc.c +2 -2
@@ -582,8 +582,8 @@ static int imx_rproc_addr_init(struct imstruct resource res; node =of_parse_phandle (np,"memory-region" , a); -/* Not map vdev region */ -if (!strcmp (node->name,"vdev" )) +/* Not map vdevbuffer, vdevring region */ +if (!strncmp (node->name,"vdev" ,strlen ("vdev" )))continue ; err =of_address_to_resource (node,0 , &res);if (err) {
Greg Kroah-Hartman
maintainerPATCH 825/849 remoteproc: imx_rproc: Fix rsc-table name
In reply to Greg Kroah-HartmanFrom: Dong Aisheng <[email protected]>
commit e90547d59d4e29e269e22aa6ce590ed0b41207d2 upstream.
Usually the dash '-' is preferred in node name.
So far, not dts in upstream kernel, so we just update node name in driver.
--- drivers/remoteproc/imx_rproc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/remoteproc/imx_rproc.c +1 -1
@@ -604,7 +604,7 @@ static int imx_rproc_addr_init(struct im } priv->mem[b].sys_addr = res.start; priv->mem[b].size =resource_size (&res); -if (!strcmp (node->name,"rsc_table" )) +if (!strcmp (node->name,"rsc-table" )) priv->rsc_table = priv->mem[b].cpu_addr; b++; }
Greg Kroah-Hartman
maintainerPATCH 826/849 mtd: rawnand: fsmc: Fix use of SM ORDER
In reply to Greg Kroah-HartmanFrom: Miquel Raynal <[email protected]>
commit 9be1446ece291a1f08164bd056bed3d698681f8b upstream.
The introduction of the generic ECC engine API lead to a number of changes in various drivers which broke some of them. Here is a typical
example: I expected the SM_ORDER option to be handled by the Hamming ECC engine internals. Problem: the fsmc driver does not instantiate (yet) a real ECC engine object so we had to use a 'bare' ECC helper instead of the shiny rawnand functions. However, when not intializing this engine properly and using the bare helpers, we do not get the SM ORDER feature handled automatically. It looks like this was lost in the process so let's ensure we use the right SM ORDER now.
--- drivers/mtd/nand/raw/fsmc_nand.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mtd/nand/raw/fsmc_nand.c +3 -1
@@ -438,8 +438,10 @@ static int fsmc_correct_ecc1(struct nandunsigned char *read_ecc, unsigned char *calc_ecc) { + bool sm_order = chip->ecc.options & NAND_ECC_SOFT_HAMMING_SM_ORDER; +return ecc_sw_hamming_correct (buf, read_ecc, calc_ecc, - chip->ecc.size, false); + chip->ecc.size, sm_order); }/* Count the number of 0's in buff upto a max of max_bits */
Greg Kroah-Hartman
maintainerPATCH 827/849 mtd: rawnand: ams-delta: Keep the driver compatible with on-die ECC engines
In reply to Greg Kroah-HartmanFrom: Miquel Raynal <[email protected]>
commit d707bb74daae07879e0fc1b4b960f8f2d0a5fe5d upstream.
Following the introduction of the generic ECC engine infrastructure, it was necessary to reorganize the code and move the ECC configuration in the ->attach_chip() hook. Failing to do that properly lead to a first series of fixes supposed to stabilize the situation. Unfortunately, this only fixed the use of software ECC engines, preventing any other kind of engine to be used, including on-die ones.
It is now time to (finally) fix the situation by ensuring that we still provide a default (eg. software ECC) but will still support different ECC engines such as on-die ECC engines if properly described in the device tree.
There are no changes needed on the core side in order to do this, but we just need to leverage the logic there which allows:
1- a subsystem default (set to Host engines in the raw NAND world) 2- a driver specific default (here set to software ECC engines) 3- any type of engine requested by the user (ie. described in the DT)
As the raw NAND subsystem has not yet been fully converted to the ECC engine infrastructure, in order to provide a default ECC engine for this driver we need to set chip->ecc.engine_type *before* calling nand_scan(). During the initialization step, the core will consider this entry as the default engine for this driver. This value may of course be overloaded by the user if the usual DT properties are provided.
--- drivers/mtd/nand/raw/ams-delta.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/mtd/nand/raw/ams-delta.c +9 -3
@@ -217,9 +217,8 @@ static int gpio_nand_setup_interface(strstatic int gpio_nand_attach_chip (struct nand_chip *chip) { - chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; - -if (chip->ecc.algo ==NAND_ECC_ALGO_UNKNOWN ) +if (chip->ecc.engine_type ==NAND_ECC_ENGINE_TYPE_SOFT && + chip->ecc.algo ==NAND_ECC_ALGO_UNKNOWN ) chip->ecc.algo =NAND_ECC_ALGO_HAMMING ;return 0 ;
@@ -370,6 +369,13 @@ static int gpio_nand_probe(struct platfo/* Release write protection */ gpiod_set_value (priv->gpiod_nwp,0 ); +/* +* This driver assumes that the default ECC engine should be TYPE_SOFT. +* Set ->engine_type before registering the NAND devices in order to +* provide a driver specific default value. +*/ + this->ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; +/* Scan to find existence of the device */ err =nand_scan (this,1 );if (err)
Greg Kroah-Hartman
maintainerPATCH 828/849 mtd: rawnand: xway: Keep the driver compatible with on-die ECC engines
In reply to Greg Kroah-HartmanFrom: Miquel Raynal <[email protected]>
commit 6bcd2960af1b7bacb2f1e710ab0c0b802d900501 upstream.
Following the introduction of the generic ECC engine infrastructure, it was necessary to reorganize the code and move the ECC configuration in the ->attach_chip() hook. Failing to do that properly lead to a first series of fixes supposed to stabilize the situation. Unfortunately, this only fixed the use of software ECC engines, preventing any other kind of engine to be used, including on-die ones.
It is now time to (finally) fix the situation by ensuring that we still provide a default (eg. software ECC) but will still support different ECC engines such as on-die ECC engines if properly described in the device tree.
There are no changes needed on the core side in order to do this, but we just need to leverage the logic there which allows:
1- a subsystem default (set to Host engines in the raw NAND world) 2- a driver specific default (here set to software ECC engines) 3- any type of engine requested by the user (ie. described in the DT)
As the raw NAND subsystem has not yet been fully converted to the ECC engine infrastructure, in order to provide a default ECC engine for this driver we need to set chip->ecc.engine_type *before* calling nand_scan(). During the initialization step, the core will consider this entry as the default engine for this driver. This value may of course be overloaded by the user if the usual DT properties are provided.
--- drivers/mtd/nand/raw/xway_nand.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/mtd/nand/raw/xway_nand.c +9 -3
@@ -148,9 +148,8 @@ static void xway_write_buf(struct nand_cstatic int xway_attach_chip (struct nand_chip *chip) { - chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; - -if (chip->ecc.algo ==NAND_ECC_ALGO_UNKNOWN ) +if (chip->ecc.engine_type ==NAND_ECC_ENGINE_TYPE_SOFT && + chip->ecc.algo ==NAND_ECC_ALGO_UNKNOWN ) chip->ecc.algo =NAND_ECC_ALGO_HAMMING ;return 0 ;
@@ -219,6 +218,13 @@ static int xway_nand_probe(struct platfo | NAND_CON_SE_P | NAND_CON_WP_P | NAND_CON_PRE_P | cs_flag, EBU_NAND_CON); +/* +* This driver assumes that the default ECC engine should be TYPE_SOFT. +* Set ->engine_type before registering the NAND devices in order to +* provide a driver specific default value. +*/ + data->chip.ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; +/* Scan to find existence of the device */ err =nand_scan (&data->chip,1 );if (err)
Greg Kroah-Hartman
maintainerPATCH 829/849 mtd: rawnand: mpc5121: Keep the driver compatible with on-die ECC engines
In reply to Greg Kroah-HartmanFrom: Miquel Raynal <[email protected]>
commit f9d8570b7fd6f4f08528ce2f5e39787a8a260cd6 upstream.
Following the introduction of the generic ECC engine infrastructure, it was necessary to reorganize the code and move the ECC configuration in the ->attach_chip() hook. Failing to do that properly lead to a first series of fixes supposed to stabilize the situation. Unfortunately, this only fixed the use of software ECC engines, preventing any other kind of engine to be used, including on-die ones.
It is now time to (finally) fix the situation by ensuring that we still provide a default (eg. software ECC) but will still support different ECC engines such as on-die ECC engines if properly described in the device tree.
There are no changes needed on the core side in order to do this, but we just need to leverage the logic there which allows:
1- a subsystem default (set to Host engines in the raw NAND world) 2- a driver specific default (here set to software ECC engines) 3- any type of engine requested by the user (ie. described in the DT)
As the raw NAND subsystem has not yet been fully converted to the ECC engine infrastructure, in order to provide a default ECC engine for this driver we need to set chip->ecc.engine_type *before* calling nand_scan(). During the initialization step, the core will consider this entry as the default engine for this driver. This value may of course be overloaded by the user if the usual DT properties are provided.
--- drivers/mtd/nand/raw/mpc5121_nfc.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/mtd/nand/raw/mpc5121_nfc.c +9 -3
@@ -605,9 +605,8 @@ static void mpc5121_nfc_free(struct devistatic int mpc5121_nfc_attach_chip (struct nand_chip *chip) { - chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; - -if (chip->ecc.algo ==NAND_ECC_ALGO_UNKNOWN ) +if (chip->ecc.engine_type ==NAND_ECC_ENGINE_TYPE_SOFT && + chip->ecc.algo ==NAND_ECC_ALGO_UNKNOWN ) chip->ecc.algo =NAND_ECC_ALGO_HAMMING ;return 0 ;
@@ -772,6 +771,13 @@ static int mpc5121_nfc_probe(struct plat goto error; } +/* +* This driver assumes that the default ECC engine should be TYPE_SOFT. +* Set ->engine_type before registering the NAND devices in order to +* provide a driver specific default value. +*/ + chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; +/* Detect NAND chips */ retval =nand_scan (chip,be32_to_cpup (chips_no));if (retval) {
Greg Kroah-Hartman
maintainerPATCH 830/849 mtd: rawnand: gpio: Keep the driver compatible with on-die ECC engines
In reply to Greg Kroah-HartmanFrom: Miquel Raynal <[email protected]>
commit b5b5b4dc6fcd8194b9dd38c8acdc5ab71adf44f8 upstream.
Following the introduction of the generic ECC engine infrastructure, it was necessary to reorganize the code and move the ECC configuration in the ->attach_chip() hook. Failing to do that properly lead to a first series of fixes supposed to stabilize the situation. Unfortunately, this only fixed the use of software ECC engines, preventing any other kind of engine to be used, including on-die ones.
It is now time to (finally) fix the situation by ensuring that we still provide a default (eg. software ECC) but will still support different ECC engines such as on-die ECC engines if properly described in the device tree.
There are no changes needed on the core side in order to do this, but we just need to leverage the logic there which allows:
1- a subsystem default (set to Host engines in the raw NAND world) 2- a driver specific default (here set to software ECC engines) 3- any type of engine requested by the user (ie. described in the DT)
As the raw NAND subsystem has not yet been fully converted to the ECC engine infrastructure, in order to provide a default ECC engine for this driver we need to set chip->ecc.engine_type *before* calling nand_scan(). During the initialization step, the core will consider this entry as the default engine for this driver. This value may of course be overloaded by the user if the usual DT properties are provided.
--- drivers/mtd/nand/raw/gpio.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/mtd/nand/raw/gpio.c +9 -3
@@ -163,9 +163,8 @@ static int gpio_nand_exec_op(struct nandstatic int gpio_nand_attach_chip (struct nand_chip *chip) { - chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; - -if (chip->ecc.algo ==NAND_ECC_ALGO_UNKNOWN ) +if (chip->ecc.engine_type ==NAND_ECC_ENGINE_TYPE_SOFT && + chip->ecc.algo ==NAND_ECC_ALGO_UNKNOWN ) chip->ecc.algo =NAND_ECC_ALGO_HAMMING ;return 0 ;
@@ -365,6 +364,13 @@ static int gpio_nand_probe(struct platfoif (gpiomtd->nwp && !IS_ERR (gpiomtd->nwp))gpiod_direction_output (gpiomtd->nwp,1 ); +/* +* This driver assumes that the default ECC engine should be TYPE_SOFT. +* Set ->engine_type before registering the NAND devices in order to +* provide a driver specific default value. +*/ + chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; + ret =nand_scan (chip,1 );if (ret) goto err_wp;
Greg Kroah-Hartman
maintainerPATCH 831/849 mtd: rawnand: pasemi: Keep the driver compatible with on-die ECC engines
In reply to Greg Kroah-HartmanFrom: Miquel Raynal <[email protected]>
commit f16b7d2a5e810fcf4b15d096246d0d445da9cc88 upstream.
Following the introduction of the generic ECC engine infrastructure, it was necessary to reorganize the code and move the ECC configuration in the ->attach_chip() hook. Failing to do that properly lead to a first series of fixes supposed to stabilize the situation. Unfortunately, this only fixed the use of software ECC engines, preventing any other kind of engine to be used, including on-die ones.
It is now time to (finally) fix the situation by ensuring that we still provide a default (eg. software ECC) but will still support different ECC engines such as on-die ECC engines if properly described in the device tree.
There are no changes needed on the core side in order to do this, but we just need to leverage the logic there which allows:
1- a subsystem default (set to Host engines in the raw NAND world) 2- a driver specific default (here set to software ECC engines) 3- any type of engine requested by the user (ie. described in the DT)
As the raw NAND subsystem has not yet been fully converted to the ECC engine infrastructure, in order to provide a default ECC engine for this driver we need to set chip->ecc.engine_type *before* calling nand_scan(). During the initialization step, the core will consider this entry as the default engine for this driver. This value may of course be overloaded by the user if the usual DT properties are provided.
--- drivers/mtd/nand/raw/pasemi_nand.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/mtd/nand/raw/pasemi_nand.c +9 -3
@@ -75,9 +75,8 @@ static int pasemi_device_ready(struct nastatic int pasemi_attach_chip (struct nand_chip *chip) { - chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; - -if (chip->ecc.algo ==NAND_ECC_ALGO_UNKNOWN ) +if (chip->ecc.engine_type ==NAND_ECC_ENGINE_TYPE_SOFT && + chip->ecc.algo ==NAND_ECC_ALGO_UNKNOWN ) chip->ecc.algo =NAND_ECC_ALGO_HAMMING ;return 0 ;
@@ -154,6 +153,13 @@ static int pasemi_nand_probe(struct plat/* Enable the following for a flash based bad block table */ chip->bbt_options =NAND_BBT_USE_FLASH ; +/* +* This driver assumes that the default ECC engine should be TYPE_SOFT. +* Set ->engine_type before registering the NAND devices in order to +* provide a driver specific default value. +*/ + chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; +/* Scan to find existence of the device */ err =nand_scan (chip,1 );if (err)
Greg Kroah-Hartman
maintainerPATCH 832/849 mtd: rawnand: orion: Keep the driver compatible with on-die ECC engines
In reply to Greg Kroah-HartmanFrom: Miquel Raynal <[email protected]>
commit 194ac63de6ff56d30c48e3ac19c8a412f9c1408e upstream.
Following the introduction of the generic ECC engine infrastructure, it was necessary to reorganize the code and move the ECC configuration in the ->attach_chip() hook. Failing to do that properly lead to a first series of fixes supposed to stabilize the situation. Unfortunately, this only fixed the use of software ECC engines, preventing any other kind of engine to be used, including on-die ones.
It is now time to (finally) fix the situation by ensuring that we still provide a default (eg. software ECC) but will still support different ECC engines such as on-die ECC engines if properly described in the device tree.
There are no changes needed on the core side in order to do this, but we just need to leverage the logic there which allows:
1- a subsystem default (set to Host engines in the raw NAND world) 2- a driver specific default (here set to software ECC engines) 3- any type of engine requested by the user (ie. described in the DT)
As the raw NAND subsystem has not yet been fully converted to the ECC engine infrastructure, in order to provide a default ECC engine for this driver we need to set chip->ecc.engine_type *before* calling nand_scan(). During the initialization step, the core will consider this entry as the default engine for this driver. This value may of course be overloaded by the user if the usual DT properties are provided.
--- drivers/mtd/nand/raw/orion_nand.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/mtd/nand/raw/orion_nand.c +9 -3
@@ -85,9 +85,8 @@ static void orion_nand_read_buf(struct nstatic int orion_nand_attach_chip (struct nand_chip *chip) { - chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; - -if (chip->ecc.algo ==NAND_ECC_ALGO_UNKNOWN ) +if (chip->ecc.engine_type ==NAND_ECC_ENGINE_TYPE_SOFT && + chip->ecc.algo ==NAND_ECC_ALGO_UNKNOWN ) chip->ecc.algo =NAND_ECC_ALGO_HAMMING ;return 0 ;
@@ -190,6 +189,13 @@ static int __init orion_nand_probe(strucreturn ret; } +/* +* This driver assumes that the default ECC engine should be TYPE_SOFT. +* Set ->engine_type before registering the NAND devices in order to +* provide a driver specific default value. +*/ + nc->ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; + ret =nand_scan (nc,1 );if (ret) goto no_dev;
Greg Kroah-Hartman
maintainerPATCH 833/849 mtd: rawnand: plat_nand: Keep the driver compatible with on-die ECC engines
In reply to Greg Kroah-HartmanFrom: Miquel Raynal <[email protected]>
commit 325fd539fc84f0aaa0ceb9d7d3b8718582473dc5 upstream.
Following the introduction of the generic ECC engine infrastructure, it was necessary to reorganize the code and move the ECC configuration in the ->attach_chip() hook. Failing to do that properly lead to a first series of fixes supposed to stabilize the situation. Unfortunately, this only fixed the use of software ECC engines, preventing any other kind of engine to be used, including on-die ones.
It is now time to (finally) fix the situation by ensuring that we still provide a default (eg. software ECC) but will still support different ECC engines such as on-die ECC engines if properly described in the device tree.
There are no changes needed on the core side in order to do this, but we just need to leverage the logic there which allows:
1- a subsystem default (set to Host engines in the raw NAND world) 2- a driver specific default (here set to software ECC engines) 3- any type of engine requested by the user (ie. described in the DT)
As the raw NAND subsystem has not yet been fully converted to the ECC engine infrastructure, in order to provide a default ECC engine for this driver we need to set chip->ecc.engine_type *before* calling nand_scan(). During the initialization step, the core will consider this entry as the default engine for this driver. This value may of course be overloaded by the user if the usual DT properties are provided.
--- drivers/mtd/nand/raw/plat_nand.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/mtd/nand/raw/plat_nand.c +9 -3
@@ -21,9 +21,8 @@ struct plat_nand_data {static int plat_nand_attach_chip (struct nand_chip *chip) { - chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; - -if (chip->ecc.algo ==NAND_ECC_ALGO_UNKNOWN ) +if (chip->ecc.engine_type ==NAND_ECC_ENGINE_TYPE_SOFT && + chip->ecc.algo ==NAND_ECC_ALGO_UNKNOWN ) chip->ecc.algo =NAND_ECC_ALGO_HAMMING ;return 0 ;
@@ -94,6 +93,13 @@ static int plat_nand_probe(struct platfo goto out; } +/* +* This driver assumes that the default ECC engine should be TYPE_SOFT. +* Set ->engine_type before registering the NAND devices in order to +* provide a driver specific default value. +*/ + data->chip.ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; +/* Scan to find existence of the device */ err =nand_scan (&data->chip, pdata->chip.nr_chips);if (err)
Greg Kroah-Hartman
maintainerPATCH 834/849 mtd: rawnand: au1550nd: Keep the driver compatible with on-die ECC engines
In reply to Greg Kroah-HartmanFrom: Miquel Raynal <[email protected]>
commit 7e3cdba176ba59eaf4d463d273da0718e3626140 upstream.
Following the introduction of the generic ECC engine infrastructure, it was necessary to reorganize the code and move the ECC configuration in the ->attach_chip() hook. Failing to do that properly lead to a first series of fixes supposed to stabilize the situation. Unfortunately, this only fixed the use of software ECC engines, preventing any other kind of engine to be used, including on-die ones.
It is now time to (finally) fix the situation by ensuring that we still provide a default (eg. software ECC) but will still support different ECC engines such as on-die ECC engines if properly described in the device tree.
There are no changes needed on the core side in order to do this, but we just need to leverage the logic there which allows:
1- a subsystem default (set to Host engines in the raw NAND world) 2- a driver specific default (here set to software ECC engines) 3- any type of engine requested by the user (ie. described in the DT)
As the raw NAND subsystem has not yet been fully converted to the ECC engine infrastructure, in order to provide a default ECC engine for this driver we need to set chip->ecc.engine_type *before* calling nand_scan(). During the initialization step, the core will consider this entry as the default engine for this driver. This value may of course be overloaded by the user if the usual DT properties are provided.
--- drivers/mtd/nand/raw/au1550nd.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/mtd/nand/raw/au1550nd.c +9 -3
@@ -239,9 +239,8 @@ static int au1550nd_exec_op(struct nand_static int au1550nd_attach_chip (struct nand_chip *chip) { - chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; - -if (chip->ecc.algo ==NAND_ECC_ALGO_UNKNOWN ) +if (chip->ecc.engine_type ==NAND_ECC_ENGINE_TYPE_SOFT && + chip->ecc.algo ==NAND_ECC_ALGO_UNKNOWN ) chip->ecc.algo =NAND_ECC_ALGO_HAMMING ;return 0 ;
@@ -310,6 +309,13 @@ static int au1550nd_probe(struct platforif (pd->devwidth) this->options |=NAND_BUSWIDTH_16 ; +/* +* This driver assumes that the default ECC engine should be TYPE_SOFT. +* Set ->engine_type before registering the NAND devices in order to +* provide a driver specific default value. +*/ + this->ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; + ret =nand_scan (this,1 );if (ret) {dev_err (&pdev->dev,"NAND scan failed with %d\n" , ret);
Greg Kroah-Hartman
maintainerPATCH 835/849 powerpc/vas: Fix potential NULL pointer dereference
In reply to Greg Kroah-HartmanFrom: Gustavo A. R. Silva <[email protected]>
commit 61cb9ac66b30374c7fd8a8b2a3c4f8f432c72e36 upstream.
(!ptr && !ptr->foo) strikes again. :)
The expression (!ptr && !ptr->foo) is bogus and in case ptr is NULL, it leads to a NULL pointer dereference: ptr->foo.
Fix this by converting && to ||
This issue was detected with the help of Coccinelle, and audited and fixed manually.
--- arch/powerpc/platforms/book3s/vas-api.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/platforms/book3s/vas-api.c +2 -2
@@ -303,7 +303,7 @@ static int coproc_ioc_tx_win_open(structreturn -EINVAL ; } -if (!cp_inst->coproc->vops && !cp_inst->coproc->vops->open_win) { +if (!cp_inst->coproc->vops || !cp_inst->coproc->vops->open_win) {pr_err ("VAS API is not registered\n" );return -EACCES ; }
@@ -373,7 +373,7 @@ static int coproc_mmap(struct file *fp,return -EINVAL ; } -if (!cp_inst->coproc->vops && !cp_inst->coproc->vops->paste_addr) { +if (!cp_inst->coproc->vops || !cp_inst->coproc->vops->paste_addr) {pr_err ("%s(): VAS API is not registered\n" , __func__);return -EACCES ; }
Greg Kroah-Hartman
maintainerPATCH 836/849 powerpc/bpf: Fix write protecting JIT code
In reply to Greg Kroah-HartmanFrom: Hari Bathini <[email protected]>
commit 44a8214de96bafb5210e43bfa2c97c19bf75af3d upstream.
Running program with bpf-to-bpf function calls results in data access exception (0x300) with the below call trace:
bpf_int_jit_compile+0x238/0x750 (unreliable) bpf_check+0x2008/0x2710 bpf_prog_load+0xb00/0x13a0 __sys_bpf+0x6f4/0x27c0 sys_bpf+0x2c/0x40 system_call_exception+0x164/0x330 system_call_vectored_common+0xe8/0x278
as bpf_int_jit_compile() tries writing to write protected JIT code location during the extra pass.
Fix it by holding off write protection of JIT code until the extra pass, where branch target addresses fixup happens.
--- arch/powerpc/net/bpf_jit_comp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/net/bpf_jit_comp.c +1 -1
@@ -241,8 +241,8 @@ skip_codegen_passes: fp->jited_len = alloclen;bpf_flush_icache (bpf_hdr, (u8 *)bpf_hdr + (bpf_hdr->pages *PAGE_SIZE )); -bpf_jit_binary_lock_ro (bpf_hdr);if (!fp->is_func || extra_pass) { +bpf_jit_binary_lock_ro (bpf_hdr);bpf_prog_fill_jited_linfo (fp, addrs); out_addrs:kfree (addrs);
Greg Kroah-Hartman
maintainerPATCH 837/849 powerpc/32e: Ignore ESR in instruction storage interrupt handler
In reply to Greg Kroah-HartmanFrom: Nicholas Piggin <[email protected]>
commit 81291383ffde08b23bce75e7d6b2575ce9d3475c upstream.
A e5500 machine running a 32-bit kernel sometimes hangs at boot, seemingly going into an infinite loop of instruction storage interrupts.
The ESR (Exception Syndrome Register) has a value of 0x800000 (store) when this happens, which is likely set by a previous store. An instruction TLB miss interrupt would then leave ESR unchanged, and if no PTE exists it calls directly to the instruction storage interrupt handler without changing ESR.
access_error() does not cause a segfault due to a store to a read-only vma because is_exec is true. Most subsequent fault handling does not check for a write fault on a read-only vma, and might do strange things like create a writeable PTE or call page_mkwrite on a read only vma or file. It's not clear what happens here to cause the infinite faulting in this case, a fault handler failure or low level PTE or TLB handling.
In any case this can be fixed by having the instruction storage interrupt zero regs->dsisr rather than storing the ESR value to it.
--- arch/powerpc/kernel/head_booke.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
arch/powerpc/kernel/head_booke.h +12 -3
@@ -465,12 +465,21 @@ label:bl do_page_fault; \b interrupt_return +/* +* Instruction TLB Error interrupt handlers may call InstructionStorage +* directly without clearing ESR, so the ESR at this point may be left over +* from a prior interrupt. +* +* In any case, do_page_fault for BOOK3E does not use ESR and always expects +* dsisr to be 0. ESR_DST from a prior store in particular would confuse fault +* handling. + */#define INSTRUCTION_STORAGE_EXCEPTION \ START_EXCEPTION(InstructionStorage) \ - NORMAL_EXCEPTION_PROLOG(0x400, INST_STORAGE); \ - mfspr r5,SPRN_ESR;/* Grab the ESR and save it */ \ + NORMAL_EXCEPTION_PROLOG(0x400, INST_STORAGE); \ + li r5,0;/* Store 0 in regs->esr (dsisr) */ \stw r5,_ESR (r11 ); \ -stw r12,_DEAR (r11 );/* Pass SRR0 as arg2 */ \ +stw r12,_DEAR (r11 );/* Set regs->dear (dar) to SRR0 */ \ prepare_transfer_to_handler; \bl do_page_fault; \b interrupt_return
Greg Kroah-Hartman
maintainerPATCH 838/849 powerpc/powernv/prd: Unregister OPAL_MSG_PRD2 notifier during module unload
In reply to Greg Kroah-HartmanFrom: Vasant Hegde <[email protected]>
commit 52862ab33c5d97490f3fa345d6529829e6d6637b upstream.
Commit 587164cd, introduced new opal message type (OPAL_MSG_PRD2) and added opal notifier. But I missed to unregister the notifier during module unload path. This results in below call trace if you try to unload and load opal_prd module.
Also add new notifier_block for OPAL_MSG_PRD2 message.
Sample calltrace (modprobe -r opal_prd; modprobe opal_prd)
BUG: Unable to handle kernel data access on read at 0xc0080000192200e0
Faulting instruction address: 0xc00000000018d1cc
Oops: Kernel access of bad area, sig: 11 [#1]
LE PAGE_SIZE=64K MMU=Radix SMP NR_CPUS=2048 NUMA PowerNV
CPU: 66 PID: 7446 Comm: modprobe Kdump: loaded Tainted: G E 5.14.0prd #759
NIP: c00000000018d1cc LR: c00000000018d2a8 CTR: c0000000000cde10
REGS: c0000003c4c0f0a0 TRAP: 0300 Tainted: G E (5.14.0prd)
MSR: 9000000002009033 <SF,HV,VEC,EE,ME,IR,DR,RI,LE> CR: 24224824 XER: 20040000
CFAR: c00000000018d2a4 DAR: c0080000192200e0 DSISR: 40000000 IRQMASK: 1
...
NIP notifier_chain_register+0x2c/0xc0
LR atomic_notifier_chain_register+0x48/0x80
Call Trace:
0xc000000002090610 (unreliable)
atomic_notifier_chain_register+0x58/0x80
opal_message_notifier_register+0x7c/0x1e0
opal_prd_probe+0x84/0x150 [opal_prd]
platform_probe+0x78/0x130
really_probe+0x110/0x5d0
__driver_probe_device+0x17c/0x230
driver_probe_device+0x60/0x130
__driver_attach+0xfc/0x220
bus_for_each_dev+0xa8/0x130
driver_attach+0x34/0x50
bus_add_driver+0x1b0/0x300
driver_register+0x98/0x1a0
__platform_driver_register+0x38/0x50
opal_prd_driver_init+0x34/0x50 [opal_prd]
do_one_initcall+0x60/0x2d0
do_init_module+0x7c/0x320
load_module+0x3394/0x3650
__do_sys_finit_module+0xd4/0x160
system_call_exception+0x140/0x290
system_call_common+0xf4/0x258--- arch/powerpc/platforms/powernv/opal-prd.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
arch/powerpc/platforms/powernv/opal-prd.c +11 -1
@@ -369,6 +369,12 @@ static struct notifier_block opal_prd_ev .priority = 0, }; +static struct notifier_block opal_prd_event_nb2 = { + .notifier_call = opal_prd_msg_notifier, + .next =NULL , + .priority =0 , +}; +static int opal_prd_probe (struct platform_device *pdev) {int rc;
@@ -390,9 +396,10 @@ static int opal_prd_probe(struct platforreturn rc; } - rc =opal_message_notifier_register (OPAL_MSG_PRD2 , &opal_prd_event_nb); + rc =opal_message_notifier_register (OPAL_MSG_PRD2 , &opal_prd_event_nb2);if (rc) {pr_err ("Couldn't register PRD2 event notifier\n" ); +opal_message_notifier_unregister (OPAL_MSG_PRD , &opal_prd_event_nb);return rc; }
@@ -401,6 +408,8 @@ static int opal_prd_probe(struct platforpr_err ("failed to register miscdev\n" );opal_message_notifier_unregister (OPAL_MSG_PRD , &opal_prd_event_nb); +opal_message_notifier_unregister (OPAL_MSG_PRD2 , + &opal_prd_event_nb2);return rc; }
@@ -411,6 +420,7 @@ static int opal_prd_remove(struct platfo {misc_deregister (&opal_prd_dev);opal_message_notifier_unregister (OPAL_MSG_PRD , &opal_prd_event_nb); +opal_message_notifier_unregister (OPAL_MSG_PRD2 , &opal_prd_event_nb2);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 839/849 powerpc/security: Use a mutex for interrupt exit code patching
In reply to Greg Kroah-HartmanFrom: Russell Currey <[email protected]>
commit 3c12b4df8d5e026345a19886ae375b3ebc33c0b6 upstream.
The mitigation-patching.sh script in the powerpc selftests toggles all mitigations on and off simultaneously, revealing that rfi_flush and stf_barrier cannot safely operate at the same time due to races in updating the static key.
On some systems, the static key code throws a warning and the kernel remains functional. On others, the kernel will hang or crash.
Fix this by slapping on a mutex.
--- arch/powerpc/lib/feature-fixups.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
arch/powerpc/lib/feature-fixups.c +11 -0
@@ -228,6 +228,7 @@ static void do_stf_exit_barrier_fixups(estatic bool stf_exit_reentrant = false;static bool rfi_exit_reentrant = false; +static DEFINE_MUTEX (exit_flush_lock);static int __do_stf_barrier_fixups (void *data) {
@@ -253,6 +254,9 @@ void do_stf_barrier_fixups(enum stf_barr* low level interrupt exit code before patching. After the patching, * if allowed, then flip the branch to allow fast exits. */ + +// Prevent static key update races with do_rfi_flush_fixups() +mutex_lock (&exit_flush_lock);static_branch_enable (&interrupt_exit_not_reentrant);stop_machine (__do_stf_barrier_fixups, &types,NULL );
@@ -264,6 +268,8 @@ void do_stf_barrier_fixups(enum stf_barrif (stf_exit_reentrant && rfi_exit_reentrant)static_branch_disable (&interrupt_exit_not_reentrant); + +mutex_unlock (&exit_flush_lock); }void do_uaccess_flush_fixups (enum l1d_flush_type types)
@@ -486,6 +492,9 @@ void do_rfi_flush_fixups(enum l1d_flush_* without stop_machine, so this could be achieved with a broadcast * IPI instead, but this matches the stf sequence. */ + +// Prevent static key update races with do_stf_barrier_fixups() +mutex_lock (&exit_flush_lock);static_branch_enable (&interrupt_exit_not_reentrant);stop_machine (__do_rfi_flush_fixups, &types,NULL );
@@ -497,6 +506,8 @@ void do_rfi_flush_fixups(enum l1d_flush_if (stf_exit_reentrant && rfi_exit_reentrant)static_branch_disable (&interrupt_exit_not_reentrant); + +mutex_unlock (&exit_flush_lock); }void do_barrier_nospec_fixups_range (bool enable,void *fixup_start,void *fixup_end)
Greg Kroah-Hartman
maintainerPATCH 840/849 powerpc/64s/interrupt: Fix check_return_regs_valid() false positive
In reply to Greg Kroah-HartmanFrom: Nicholas Piggin <[email protected]>
commit 4a5cb51f3db4be547225a4bce7a43d41b231382b upstream.
The check_return_regs_valid() can cause a false positive if the return regs are marked as norestart and they are an HSRR type interrupt, because the low bit in the bottom of regs->trap causes interrupt type matching to fail.
This can occcur for example on bare metal with a HV privileged doorbell interrupt that causes a signal, but do_signal returns early because get_signal() fails, and takes the "No signal to deliver" path. In this case no signal was delivered so the return location is not changed so return SRRs are not invalidated, yet set_trap_norestart is called, which messes up the match. Building go-1.16.6 is known to reproduce this.
Fix it by using the TRAP() accessor which masks out the low bit.
--- arch/powerpc/kernel/interrupt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kernel/interrupt.c +1 -1
@@ -268,7 +268,7 @@ static void check_return_regs_valid(struif (trap_is_scv (regs))return ; - trap = regs->trap; + trap =TRAP (regs);// EE in HV mode sets HSRRs like 0xea0 if (cpu_has_feature (CPU_FTR_HVMODE ) && trap ==INTERRUPT_EXTERNAL ) trap =0xea0 ;
Greg Kroah-Hartman
maintainerPATCH 841/849 powerpc/pseries/mobility: ignore ibm, platform-facilities updates
In reply to Greg Kroah-HartmanFrom: Nathan Lynch <[email protected]>
commit 319fa1a52e438a6e028329187783a25ad498c4e6 upstream.
On VMs with NX encryption, compression, and/or RNG offload, these capabilities are described by nodes in the ibm,platform-facilities device tree hierarchy:
$ tree -d /sys/firmware/devicetree/base/ibm,platform-facilities/ /sys/firmware/devicetree/base/ibm,platform-facilities/ ├── ibm,compression-v1 ├── ibm,random-v1 └── ibm,sym-encryption-v1
3 directories
The acceleration functions that these nodes describe are not disrupted by live migration, not even temporarily.
But the post-migration ibm,update-nodes sequence firmware always sends "delete" messages for this hierarchy, followed by an "add" directive to reconstruct it via ibm,configure-connector (log with debugging statements enabled in mobility.c):
mobility: removing node /ibm,platform-facilities/ibm,random-v1:4294967285
mobility: removing node /ibm,platform-facilities/ibm,compression-v1:4294967284
mobility: removing node /ibm,platform-facilities/ibm,sym-encryption-v1:4294967283
mobility: removing node /ibm,platform-facilities:4294967286
...
mobility: added node /ibm,platform-facilities:4294967286
Note we receive a single "add" message for the entire hierarchy, and what we receive from the ibm,configure-connector sequence is the top-level platform-facilities node along with its three children. The debug message simply reports the parent node and not the whole subtree.
Also, significantly, the nodes added are almost completely equivalent to the ones removed; even phandles are unchanged. ibm,shared-interrupt-pool in the leaf nodes is the only property I've observed to differ, and Linux does not use that. So in practice, the sum of update messages Linux receives for this hierarchy is equivalent to minor property updates.
We succeed in removing the original hierarchy from the device tree. But the vio bus code is ignorant of this, and does not unbind or relinquish its references. The leaf nodes, still reachable through sysfs, of course still refer to the now-freed ibm,platform-facilities parent node, which makes use-after-free possible:
refcount_t: addition on 0; use-after-free.
WARNING: CPU: 3 PID: 1706 at lib/refcount.c:25 refcount_warn_saturate+0x164/0x1f0 refcount_warn_saturate+0x160/0x1f0 (unreliable) kobject_get+0xf0/0x100 of_node_get+0x30/0x50 of_get_parent+0x50/0xb0 of_fwnode_get_parent+0x54/0x90 fwnode_count_parents+0x50/0x150 fwnode_full_name_string+0x30/0x110 device_node_string+0x49c/0x790 vsnprintf+0x1c0/0x4c0 sprintf+0x44/0x60 devspec_show+0x34/0x50 dev_attr_show+0x40/0xa0 sysfs_kf_seq_show+0xbc/0x200 kernfs_seq_show+0x44/0x60 seq_read_iter+0x2a4/0x740 kernfs_fop_read_iter+0x254/0x2e0 new_sync_read+0x120/0x190 vfs_read+0x1d0/0x240
Moreover, the "new" replacement subtree is not correctly added to the device tree, resulting in ibm,platform-facilities parent node without the appropriate leaf nodes, and broken symlinks in the sysfs device hierarchy:
$ tree -d /sys/firmware/devicetree/base/ibm,platform-facilities/ /sys/firmware/devicetree/base/ibm,platform-facilities/
0 directories
$ cd /sys/devices/vio ; find . -xtype l -exec file {} +
./ibm,sym-encryption-v1/of_node: broken symbolic link to
../../../firmware/devicetree/base/ibm,platform-facilities/ibm,sym-encryption-v1
./ibm,random-v1/of_node: broken symbolic link to
../../../firmware/devicetree/base/ibm,platform-facilities/ibm,random-v1
./ibm,compression-v1/of_node: broken symbolic link to
../../../firmware/devicetree/base/ibm,platform-facilities/ibm,compression-v1This is because add_dt_node() -> dlpar_attach_node() attaches only the parent node returned from configure-connector, ignoring any children. This should be corrected for the general case, but fixing that won't help with the stale OF node references, which is the more urgent problem.
One way to address that would be to make the drivers respond to node removal notifications, so that node references can be dropped appropriately. But this would likely force the drivers to disrupt active clients for no useful purpose: equivalent nodes are immediately re-added. And recall that the acceleration capabilities described by the nodes remain available throughout the whole process.
The solution I believe to be robust for this situation is to convert remove+add of a node with an unchanged phandle to an update of the node's properties in the Linux device tree structure. That would involve changing and adding a fair amount of code, and may take several iterations to land.
Until that can be realized we have a confirmed use-after-free and the possibility of memory corruption. So add a limited workaround that discriminates on the node type, ignoring adds and removes. This should be amenable to backporting in the meantime.
--- arch/powerpc/platforms/pseries/mobility.c | 34 ++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
arch/powerpc/platforms/pseries/mobility.c +34 -0
@@ -63,6 +63,27 @@ static int mobility_rtas_call(int token,static int delete_dt_node (struct device_node *dn) { +struct device_node *pdn; +bool is_platfac; + + pdn =of_get_parent (dn); + is_platfac =of_node_is_type (dn,"ibm,platform-facilities" ) || +of_node_is_type (pdn,"ibm,platform-facilities" ); +of_node_put (pdn); + +/* +* The drivers that bind to nodes in the platform-facilities +* hierarchy don't support node removal, and the removal directive +* from firmware is always followed by an add of an equivalent +* node. The capability (e.g. RNG, encryption, compression) +* represented by the node is never interrupted by the migration. +* So ignore changes to this part of the tree. +*/ +if (is_platfac) { +pr_notice ("ignoring remove operation for %pOFfp\n" , dn); +return 0 ; + } +pr_debug ("removing node %pOFfp\n" , dn);dlpar_detach_node (dn);return 0 ;
@@ -222,6 +243,19 @@ static int add_dt_node(struct device_nodif (!dn)return -ENOENT ; +/* +* Since delete_dt_node() ignores this node type, this is the +* necessary counterpart. We also know that a platform-facilities +* node returned from dlpar_configure_connector() has children +* attached, and dlpar_attach_node() only adds the parent, leaking +* the children. So ignore these on the add side for now. +*/ +if (of_node_is_type (dn,"ibm,platform-facilities" )) { +pr_notice ("ignoring add operation for %pOF\n" , dn); +dlpar_free_cc_nodes (dn); +return 0 ; + } + rc =dlpar_attach_node (dn, parent_dn);if (rc)dlpar_free_cc_nodes (dn);
Greg Kroah-Hartman
maintainerPATCH 842/849 powerpc/85xx: fix timebase sync issue when CONFIG_HOTPLUG_CPU=n
In reply to Greg Kroah-HartmanFrom: Xiaoming Ni <[email protected]>
commit c45361abb9185b1e172bd75eff51ad5f601ccae4 upstream.
When CONFIG_SMP=y, timebase synchronization is required when the second kernel is started.
arch/powerpc/kernel/smp.c:
int __cpu_up(unsigned int cpu, struct task_struct *tidle) {
...
if (smp_ops->give_timebase)
smp_ops->give_timebase();
...
}
void start_secondary(void *unused)
{
...
if (smp_ops->take_timebase)
smp_ops->take_timebase();
...
}When CONFIG_HOTPLUG_CPU=n and CONFIG_KEXEC_CORE=n,
smp_85xx_ops.give_timebase is NULL, smp_85xx_ops.take_timebase is NULL,
As a result, the timebase is not synchronized.
Timebase synchronization does not depend on CONFIG_HOTPLUG_CPU.
--- arch/powerpc/platforms/85xx/Makefile | 4 +++- arch/powerpc/platforms/85xx/mpc85xx_pm_ops.c | 4 ++++ arch/powerpc/platforms/85xx/smp.c | 12 ++++++------ 3 files changed, 13 insertions(+), 7 deletions(-)
arch/powerpc/platforms/85xx/Makefile +3 -1
@@ -3,7 +3,9 @@ # Makefile for the PowerPC 85xx linux kernel. # obj-$(CONFIG_SMP) += smp.o -obj-$(CONFIG_FSL_PMC) += mpc85xx_pm_ops.o +ifneq ($(CONFIG_FSL_CORENET_RCPM),y) +obj-$(CONFIG_SMP) += mpc85xx_pm_ops.o +endif obj-y += common.o
arch/powerpc/platforms/85xx/mpc85xx_pm_ops.c +4 -0
@@ -17,6 +17,7 @@static struct ccsr_guts __iomem *guts; +#ifdef CONFIG_FSL_PMC static void mpc85xx_irq_mask (int cpu) {
@@ -49,6 +50,7 @@ static void mpc85xx_cpu_up_prepare(int c { } +#endif static void mpc85xx_freeze_time_base (bool freeze) {
@@ -76,10 +78,12 @@ static const struct of_device_id mpc85xxstatic const struct fsl_pm_ops mpc85xx_pm_ops = { .freeze_time_base = mpc85xx_freeze_time_base, +#ifdef CONFIG_FSL_PMC .irq_mask = mpc85xx_irq_mask, .irq_unmask = mpc85xx_irq_unmask, .cpu_die = mpc85xx_cpu_die, .cpu_up_prepare = mpc85xx_cpu_up_prepare, +#endif };int __init mpc85xx_setup_pmc (void )
arch/powerpc/platforms/85xx/smp.c +6 -6
@@ -40,7 +40,6 @@ struct epapr_spin_table {u32 pir; }; -#ifdef CONFIG_HOTPLUG_CPU static u64 timebase;static int tb_req;static int tb_valid;
@@ -112,6 +111,7 @@ static void mpc85xx_take_timebase(void)local_irq_restore (flags); } +#ifdef CONFIG_HOTPLUG_CPU static void smp_85xx_cpu_offline_self (void ) {unsigned int cpu =smp_processor_id ();
@@ -495,21 +495,21 @@ void __init mpc85xx_smp_init(void) smp_85xx_ops.probe =NULL ; } -#ifdef CONFIG_HOTPLUG_CPU #ifdef CONFIG_FSL_CORENET_RCPM +/* Assign a value to qoriq_pm_ops on PPC_E500MC */ fsl_rcpm_init (); -#endif - -#ifdef CONFIG_FSL_PMC +#else +/* Assign a value to qoriq_pm_ops on !PPC_E500MC */ mpc85xx_setup_pmc ();#endif if (qoriq_pm_ops) { smp_85xx_ops.give_timebase = mpc85xx_give_timebase; smp_85xx_ops.take_timebase = mpc85xx_take_timebase; +#ifdef CONFIG_HOTPLUG_CPU smp_85xx_ops.cpu_offline_self = smp_85xx_cpu_offline_self; smp_85xx_ops.cpu_die = qoriq_cpu_kill; - }#endif + } smp_ops = &smp_85xx_ops;#ifdef CONFIG_KEXEC_CORE
Greg Kroah-Hartman
maintainerPATCH 843/849 drm/sun4i: Fix macros in sun8i_csc.h
In reply to Greg Kroah-HartmanFrom: Jernej Skrabec <[email protected]>
commit c302c98da646409d657a473da202f10f417f3ff1 upstream.
Macros SUN8I_CSC_CTRL() and SUN8I_CSC_COEFF() don't follow usual recommendation of having arguments enclosed in parenthesis. While that didn't change anything for quite sometime, it actually become important after CSC code rework with commit ea067aee45a8 ("drm/sun4i: de2/de3:
Remove redundant CSC matrices").
Without this fix, colours are completely off for supported YVU formats on SoCs with DE2 (A64, H3, R40, etc.).
Fix the issue by enclosing macro arguments in parenthesis.
--- drivers/gpu/drm/sun4i/sun8i_csc.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/sun4i/sun8i_csc.h +2 -2
@@ -16,8 +16,8 @@ struct sun8i_mixer;#define CCSC10_OFFSET 0xA0000#define CCSC11_OFFSET 0xF0000 -#define SUN8I_CSC_CTRL (base) (base + 0x0) -#define SUN8I_CSC_COEFF (base, i) (base + 0x10 + 4 * i) +#define SUN8I_CSC_CTRL (base) ((base) + 0x0) +#define SUN8I_CSC_COEFF (base, i) ((base) + 0x10 + 4 * (i))#define SUN8I_CSC_CTRL_EN BIT(0)
Greg Kroah-Hartman
maintainerPATCH 844/849 PCI: Add PCI_EXP_DEVCTL_PAYLOAD_* macros
In reply to Greg Kroah-HartmanFrom: Pali Rohár <[email protected]>
commit 460275f124fb072dca218a6b43b6370eebbab20d upstream.
Define a macro PCI_EXP_DEVCTL_PAYLOAD_* for every possible Max Payload Size in linux/pci_regs.h, in the same style as PCI_EXP_DEVCTL_READRQ_*.
--- include/uapi/linux/pci_regs.h | 6 ++++++ 1 file changed, 6 insertions(+)
include/uapi/linux/pci_regs.h +6 -0
@@ -504,6 +504,12 @@#define PCI_EXP_DEVCTL_URRE 0x0008/* Unsupported Request Reporting En. */ #define PCI_EXP_DEVCTL_RELAX_EN 0x0010/* Enable relaxed ordering */ #define PCI_EXP_DEVCTL_PAYLOAD 0x00e0/* Max_Payload_Size */ +#define PCI_EXP_DEVCTL_PAYLOAD_128B 0x0000/* 128 Bytes */ +#define PCI_EXP_DEVCTL_PAYLOAD_256B 0x0020/* 256 Bytes */ +#define PCI_EXP_DEVCTL_PAYLOAD_512B 0x0040/* 512 Bytes */ +#define PCI_EXP_DEVCTL_PAYLOAD_1024B 0x0060/* 1024 Bytes */ +#define PCI_EXP_DEVCTL_PAYLOAD_2048B 0x0080/* 2048 Bytes */ +#define PCI_EXP_DEVCTL_PAYLOAD_4096B 0x00a0/* 4096 Bytes */ #define PCI_EXP_DEVCTL_EXT_TAG 0x0100/* Extended Tag Field Enable */ #define PCI_EXP_DEVCTL_PHANTOM 0x0200/* Phantom Functions Enable */ #define PCI_EXP_DEVCTL_AUX_PME 0x0400/* Auxiliary Power PM Enable */
Greg Kroah-Hartman
maintainerPATCH 845/849 PCI: aardvark: Fix PCIe Max Payload Size setting
In reply to Greg Kroah-HartmanFrom: Pali Rohár <[email protected]>
commit a4e17d65dafdd3513042d8f00404c9b6068a825c upstream.
Change PCIe Max Payload Size setting in PCIe Device Control register to 512 bytes to align with PCIe Link Initialization sequence as defined in Marvell Armada 3700 Functional Specification. According to the specification, maximal Max Payload Size supported by this device is 512 bytes.
Without this kernel prints suspicious line:
pci 0000:01:00.0: Upstream bridge's Max Payload Size set to 256 (was 16384, max 512)
With this change it changes to:
pci 0000:01:00.0: Upstream bridge's Max Payload Size set to 256 (was 512, max 512)
--- drivers/pci/controller/pci-aardvark.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pci/controller/pci-aardvark.c +2 -1
@@ -597,8 +597,9 @@ static void advk_pcie_setup_hw(struct ad reg =advk_readl (pcie,PCIE_CORE_PCIEXP_CAP +PCI_EXP_DEVCTL ); reg &= ~PCI_EXP_DEVCTL_RELAX_EN ; reg &= ~PCI_EXP_DEVCTL_NOSNOOP_EN ; + reg &= ~PCI_EXP_DEVCTL_PAYLOAD ; reg &= ~PCI_EXP_DEVCTL_READRQ ; - reg |=PCI_EXP_DEVCTL_PAYLOAD ;/* Set max payload size */ + reg |=PCI_EXP_DEVCTL_PAYLOAD_512B ; reg |=PCI_EXP_DEVCTL_READRQ_512B ;advk_writel (pcie, reg,PCIE_CORE_PCIEXP_CAP +PCI_EXP_DEVCTL );
Greg Kroah-Hartman
maintainerPATCH 846/849 SUNRPC: Partial revert of commit 6f9f17287e78
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
commit ea7a1019d8baf8503ecd6e3ec8436dec283569e6 upstream.
The premise of commit 6f9f17287e78 ("SUNRPC: Mitigate cond_resched() in xprt_transmit()") was that cond_resched() is expensive and unnecessary when there has been just a single send.
The point of cond_resched() is to ensure that tasks that should pre-empt this one get a chance to do so when it is safe to do so. The code prior to commit 6f9f17287e78 failed to take into account that it was keeping a rpc_task pinned for longer than it needed to, and so rather than doing a full revert, let's just move the cond_resched.
--- net/sunrpc/xprt.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-)
net/sunrpc/xprt.c +15 -13
@@ -1585,15 +1585,14 @@ xprt_transmit(struct rpc_task *task) {struct rpc_rqst *next, *req = task->tk_rqstp;struct rpc_xprt *xprt = req->rq_xprt; -int counter, status; +int status;spin_lock (&xprt->queue_lock); - counter =0 ; -while (!list_empty (&xprt->xmit_queue)) { -if (++counter ==20 ) +for (;;) { + next =list_first_entry_or_null (&xprt->xmit_queue, + struct rpc_rqst, rq_xmit); +if (!next)break ; - next =list_first_entry (&xprt->xmit_queue, - struct rpc_rqst, rq_xmit);xprt_pin_rqst (next);spin_unlock (&xprt->queue_lock); status =xprt_request_transmit (next, task);
@@ -1601,13 +1600,16 @@ xprt_transmit(struct rpc_task *task) status =0 ;spin_lock (&xprt->queue_lock);xprt_unpin_rqst (next); -if (status ==0 ) { -if (!xprt_request_data_received (task) || -test_bit (RPC_TASK_NEED_XMIT , &task->tk_runstate)) -continue ; - }else if (test_bit (RPC_TASK_NEED_XMIT , &task->tk_runstate)) - task->tk_status = status; -break ; +if (status <0 ) { +if (test_bit (RPC_TASK_NEED_XMIT , &task->tk_runstate)) + task->tk_status = status; +break ; + } +/* Was @task transmitted, and has it received a reply? */ +if (xprt_request_data_received (task) && + !test_bit (RPC_TASK_NEED_XMIT , &task->tk_runstate)) +break ; +cond_resched_lock (&xprt->queue_lock); }spin_unlock (&xprt->queue_lock); }
Greg Kroah-Hartman
maintainerPATCH 847/849 pinctrl: amd: Add irq field data
In reply to Greg Kroah-HartmanFrom: Basavaraj Natikar <[email protected]>
commit 7e6f8d6f4a42ef9b693ff1b49267c546931d4619 upstream.
pinctrl_amd use gpiochip_get_data() to get their local state containers back from the gpiochip passed as amd_gpio chip data.
Hence added irq field data to get directly using amd_gpio chip data.
--- drivers/pinctrl/pinctrl-amd.c | 9 ++++----- drivers/pinctrl/pinctrl-amd.h | 1 + 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/pinctrl/pinctrl-amd.c +4 -5
@@ -932,7 +932,6 @@ static struct pinctrl_desc amd_pinctrl_dstatic int amd_gpio_probe (struct platform_device *pdev) {int ret =0 ; -int irq_base;struct resource *res;struct amd_gpio *gpio_dev;struct gpio_irq_chip *girq;
@@ -955,9 +954,9 @@ static int amd_gpio_probe(struct platforif (!gpio_dev->base)return -ENOMEM ; - irq_base =platform_get_irq (pdev,0 ); -if (irq_base <0 ) -return irq_base; + gpio_dev->irq =platform_get_irq (pdev,0 ); +if (gpio_dev->irq <0 ) +return gpio_dev->irq;#ifdef CONFIG_PM_SLEEP gpio_dev->saved_regs = devm_kcalloc(&pdev->dev, amd_pinctrl_desc.npins,
@@ -1020,7 +1019,7 @@ static int amd_gpio_probe(struct platfor goto out2; } - ret =devm_request_irq (&pdev->dev, irq_base, amd_gpio_irq_handler, + ret =devm_request_irq (&pdev->dev, gpio_dev->irq, amd_gpio_irq_handler,IRQF_SHARED ,KBUILD_MODNAME , gpio_dev);if (ret) goto out2;
drivers/pinctrl/pinctrl-amd.h +1 -0
@@ -98,6 +98,7 @@ struct amd_gpio {struct resource *res;struct platform_device *pdev;u32 *saved_regs; +int irq; };/* KERNCZ configuration*/
Greg Kroah-Hartman
maintainerPATCH 848/849 pinctrl: amd: Handle wake-up interrupt
In reply to Greg Kroah-HartmanFrom: Basavaraj Natikar <[email protected]>
commit acd47b9f28e55b505aedb842131b40904e151d7c upstream.
Enable/disable power management wakeup mode, which is disabled by default. enable_irq_wake enables wakes the system from sleep.
Hence added enable/disable irq_wake to handle wake-up interrupt.
--- drivers/pinctrl/pinctrl-amd.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/pinctrl/pinctrl-amd.c +10 -0
@@ -445,6 +445,7 @@ static int amd_gpio_irq_set_wake(structstruct gpio_chip *gc =irq_data_get_irq_chip_data (d);struct amd_gpio *gpio_dev =gpiochip_get_data (gc);u32 wake_mask =BIT (WAKE_CNTRL_OFF_S0I3 ) |BIT (WAKE_CNTRL_OFF_S3 ); +int err;raw_spin_lock_irqsave (&gpio_dev->lock, flags); pin_reg =readl (gpio_dev->base + (d->hwirq)*4 );
@@ -457,6 +458,15 @@ static int amd_gpio_irq_set_wake(structwritel (pin_reg, gpio_dev->base + (d->hwirq)*4 );raw_spin_unlock_irqrestore (&gpio_dev->lock, flags); +if (on) + err =enable_irq_wake (gpio_dev->irq); +else + err =disable_irq_wake (gpio_dev->irq); + +if (err) +dev_err (&gpio_dev->pdev->dev,"failed to %s wake-up interrupt\n" , + on ?"enable" :"disable" ); +return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 849/849 drm/amd/display: Look at firmware version to determine using dmub on dcn21
In reply to Greg Kroah-HartmanFrom: Mario Limonciello <[email protected]>
commit 91adec9e07097e538691daed5d934e7886dd1dc3 upstream.
commit 652de07addd2 ("drm/amd/display: Fully switch to dmub for all dcn21 asics") switched over to using dmub on Renoir to fix Gitlab 1735, but this implied a new dependency on newer firmware which might not be met on older kernel versions.
Since sw_init runs before hw_init, there is an opportunity to determine whether or not the firmware version is new to adjust the behavior.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +8 -1
@@ -1143,8 +1143,15 @@ static int amdgpu_dm_init(struct amdgpu_case CHIP_RAVEN :case CHIP_RENOIR : init_data.flags.gpu_vm_support = true; -if (ASICREV_IS_GREEN_SARDINE (adev->external_rev_id)) +switch (adev->dm.dmcub_fw_version) { +case 0 :/* development */ +case 0x1 :/* linux-firmware.git hash 6d9f399 */ +case 0x01000000 :/* linux-firmware.git hash 9a0b0f4 */ + init_data.flags.disable_dmcu = false; +break ; +default : init_data.flags.disable_dmcu = true; + }break ;case CHIP_VANGOGH :case CHIP_YELLOW_CARP :
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.14.19 release. There are 849 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 17 Nov 2021 16:52:23 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 9 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.14.19-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.14.y
and the diffstat can be found below.thanks,
greg k-h
Compiled and booted on my test system. No dmesg regressions.
thanks,
-- Shuah
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.14.19 release. There are 849 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 17 Nov 2021 16:52:23 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 9 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.14.19-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.14.y
and the diffstat can be found below.thanks,
greg k-h
5.14.19-rc1 Successfully Compiled and booted on my Raspberry PI 4b (8g) (bcm2711)
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.14.19 release. There are 849 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 17 Nov 2021 16:52:23 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.14.19-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.14.y
and the diffstat can be found below.thanks,
greg k-h
Results from Linaro’s test farm.
No regressions on arm64, arm, x86_64, and i386.
## Build
* kernel: 5.14.19-rc1
* git: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
* git branch: linux-5.14.y
* git commit: f9bb48b60e5a17952d2ad5b43826ffc2ce4b2255
* git describe: v5.14.18-850-gf9bb48b60e5a
* test details:
https://qa-reports.linaro.org/lkft/linux-stable-rc-linux-5.14.y/build/v5.14.18-850-gf9bb48b60e5a
## No regressions (compared to v5.14.18-154-g052582294dec)
## No fixes (compared to v5.14.18-154-g052582294dec)
## Test result summary
total: 95749, pass: 80866, fail: 1066, skip: 12961, xfail: 856
## Build Summary
* arc: 10 total, 10 passed, 0 failed
* arm: 290 total, 290 passed, 0 failed
* arm64: 40 total, 40 passed, 0 failed
* dragonboard-410c: 1 total, 1 passed, 0 failed
* hi6220-hikey: 1 total, 1 passed, 0 failed
* i386: 39 total, 39 passed, 0 failed
* juno-r2: 1 total, 1 passed, 0 failed
* mips: 37 total, 37 passed, 0 failed
* parisc: 12 total, 12 passed, 0 failed
* powerpc: 54 total, 48 passed, 6 failed
* riscv: 24 total, 24 passed, 0 failed
* s390: 18 total, 18 passed, 0 failed
* sh: 24 total, 24 passed, 0 failed
* sparc: 12 total, 12 passed, 0 failed
* x15: 1 total, 1 passed, 0 failed
* x86: 1 total, 1 passed, 0 failed
* x86_64: 40 total, 40 passed, 0 failed
## Test suites summary
* fwts
* igt-gpu-tools
* kselftest-
* kselftest-android
* kselftest-arm64
* kselftest-arm64/arm64.btitest.bti_c_func
* kselftest-arm64/arm64.btitest.bti_j_func
* kselftest-arm64/arm64.btitest.bti_jc_func
* kselftest-arm64/arm64.btitest.bti_none_func
* kselftest-arm64/arm64.btitest.nohint_func
* kselftest-arm64/arm64.btitest.paciasp_func
* kselftest-arm64/arm64.nobtitest.bti_c_func
* kselftest-arm64/arm64.nobtitest.bti_j_func
* kselftest-arm64/arm64.nobtitest.bti_jc_func
* kselftest-arm64/arm64.nobtitest.bti_none_func
* kselftest-arm64/arm64.nobtitest.nohint_func
* kselftest-arm64/arm64.nobtitest.paciasp_func
* kselftest-bpf
* kselftest-breakpoints
* kselftest-capabilities
* kselftest-cgroup
* kselftest-clone3
* kselftest-core
* kselftest-cpu-hotplug
* kselftest-cpufreq
* kselftest-drivers
* kselftest-efivarfs
* kselftest-filesystems
* kselftest-firmware
* kselftest-fpu
* kselftest-futex
* kselftest-gpio
* kselftest-intel_pstate
* kselftest-ipc
* kselftest-ir
* kselftest-kcmp
* kselftest-kexec
* kselftest-kvm
* kselftest-lib
* kselftest-livepatch
* kselftest-lkdtm
* kselftest-membarrier
* kselftest-memfd
* kselftest-memory-hotplug
* kselftest-mincore
* kselftest-mount
* kselftest-mqueue
* kselftest-net
* kselftest-netfilter
* kselftest-nsfs
* kselftest-openat2
* kselftest-pid_namespace
* kselftest-pidfd
* kselftest-proc
* kselftest-pstore
* kselftest-ptrace
* kselftest-rseq
* kselftest-rtc
* kselftest-seccomp
* kselftest-sigaltsta[
* kselftest-sigaltstack
* kselftest-size
* kselftest-splice
* kselftest-static_keys
* kselftest-sync
* kselftest-sysctl
* kselftest-tc-testing
* kselftest-timens
* kselftest-timers
* kselftest-tmpfs
* kselftest-tpm2
* kselftest-user
* kselftest-vm
* kselftest-x86
* kselftest-zram
* kunit
* kvm-unit-tests
* libgpiod
* libhugetlbfs
* linux-log-parser
* ltp-cap_bounds-tests
* ltp-commands-tests
* ltp-containers-tests
* ltp-controllers-tests
* ltp-cpuhotplug-tests
* ltp-crypto-tests
* ltp-cve-tests
* ltp-dio-tests
* ltp-fcntl-locktests-tests
* ltp-filecaps-tests
* ltp-fs-tests
* ltp-fs_bind-tests
* ltp-fs_perms_simple-tests
* ltp-fsx-tests
* ltp-hugetlb-tests
* ltp-io-tests
* ltp-ipc-tests
* ltp-math-tests
* ltp-mm-tests
* ltp-nptl-tests
* ltp-open-posix-tests
* ltp-pty-tests
* ltp-sched-tests
* ltp-securebits-tests
* ltp-syscalls-tests
* ltp-tracing-tests
* network-basic-tests
* packetdrill
* perf
* perf/Zstd-perf.data-compression
* rcutorture
* ssuite
* v4l2-compliance
--
Linaro LKFT
https://lkft.linaro.org
Jon Hunter
maintainerHi Greg,
Quoted 20 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.14.19 release. There are 849 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 17 Nov 2021 16:52:23 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.14.19-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.14.y
and the diffstat can be found below.thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
...
Quoted 2 lines
Mikko Perttunen <[email protected]>
reset: tegra-bpmp: Handle errors in BPMP response
The above is causing a regression for HDA audio on Tegra. Please can you drop this from stable for now until we get this sorted out.
Thanks
Jon
Signature · 1 line
nvpublic
Greg Kroah-Hartman
maintainerQuoted 24 lines · Jon Hunter
Hi Greg,
Quoted 14 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.14.19 release. There are 849 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 17 Nov 2021 16:52:23 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.14.19-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.14.y
and the diffstat can be found below.Quoted 6 lines
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Quoted 8 lines
...
Quoted 2 lines
Mikko Perttunen <[email protected]>
reset: tegra-bpmp: Handle errors in BPMP responseThe above is causing a regression for HDA audio on Tegra. Please can you drop this from stable for now until we get this sorted out.
Already dropped. I'll be pushing out some -rc2 releases soon as there's been a number of changes for all of these trees.
thanks,
greg k-h