ice/i40e: stop disabling VFs due to PF error responses
Subsystems (2)
cover ice/i40e: stop disabling VFs due to PF error responses
The ice and i40e drivers have similar logic to detect PF error responses to the VFs over the Virtchnl interface. This logic counts the number of sequential error responses sent to a VF and logs each error response as a dev_info to the kernel log. If more than 10 error responses are sent in a row, the PF driver disables the VF in question.
This logic has existed since the early days of i40e VF implementation, and was carried forward into ice. The logic appears to be some form of malicious VF detection. However, it doesn't actually fit in with the hardware based malicious VF detection available in the device hardware.
In fact, the logic has had some adjustments in the i40e driver to reduce the messaging from dev_err to dev_info, and to allow specific messages to skip the check.
These changes clearly highlight the problematic nature of the check. Additionally, there is no requirement for this behavior in our product design. Other driver implementations such as the FreeBSD drivers do not implement this behavior.
Disabling VFs is typically not what system administrators what to happen, and this behavior is non-intuitive and not documented. Since it clearly causes issues and isn't connected to the proper malicious driver detection, remove this check from both ice and i40e.
Jacob Keller (2):
i40e: stop disabling VFs due to PF error responses
ice: stop disabling VFs due to PF error responses
.../net/ethernet/intel/i40e/i40e_debugfs.c | 6 +- .../ethernet/intel/i40e/i40e_virtchnl_pf.c | 57 +++---------------- .../ethernet/intel/i40e/i40e_virtchnl_pf.h | 5 -- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 18 ------ .../net/ethernet/intel/ice/ice_virtchnl_pf.h | 3 - 5 files changed, 9 insertions(+), 80 deletions(-)
base-commit: 35410c10918a84c9685cd644686ca637bb3c046b
Signature · 1 line
2.35.1.129.gb80121027d12
PATCH 1/2 i40e: stop disabling VFs due to PF error responses
The i40e_vc_send_msg_to_vf_ex (and its wrapper i40e_vc_send_msg_to_vf) function has logic to detect "failure" responses sent to the VF. If a VF is sent more than I40E_DEFAULT_NUM_INVALID_MSGS_ALLOWED, then the VF is marked as disabled. In either case, a dev_info message is printed stating that a VF opcode failed.
This logic originates from the early implementation of VF support in commit 5c3c48ac6bf5 ("i40e: implement virtual device interface").
That commit did not go far enough. The "logic" for this behavior seems to be that error responses somehow indicate a malicious VF. This is not really true. The PF might be sending an error for any number of reasons such as lacking resources, an unsupported operation, etc. This does not indicate a malicious VF. We already have a separate robust malicious VF detection which relies on hardware logic to detect and prevent a variety of behaviors.
There is no justification for this behavior in the original implementation. In fact, a later commit 18b7af57d9c1 ("i40e: Lower some message levels") reduced the opcode failure message from a dev_err to a dev_info. In addition, recent commit 01cbf50877e6 ("i40e: Fix to not show opcode msg on unsuccessful VF MAC change") changed the logic to allow quieting it for expected failures.
That commit prevented this logic from kicking in for specific circumstances. This change did not go far enough. The behavior is not documented nor is it part of any requirement for our products. Other operating systems such as the FreeBSD implementation of our driver do not include this logic.
It is clear this check does not make sense, and causes problems which led to ugly workarounds.
Fix this by just removing the entire logic and the need for the i40e_vc_send_msg_to_vf_ex function.
--- .../net/ethernet/intel/i40e/i40e_debugfs.c | 6 +- .../ethernet/intel/i40e/i40e_virtchnl_pf.c | 57 +++---------------- .../ethernet/intel/i40e/i40e_virtchnl_pf.h | 5 -- 3 files changed, 9 insertions(+), 59 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_debugfs.c +2 -4
@@ -742,10 +742,8 @@ static void i40e_dbg_dump_vf(struct i40e_pf *pf, int vf_id) vsi = pf->vsi[vf->lan_vsi_idx];dev_info (&pf->pdev->dev,"vf %2d: VSI id=%d, seid=%d, qps=%d\n" , vf_id, vf->lan_vsi_id, vsi->seid, vf->num_queue_pairs); -dev_info (&pf->pdev->dev," num MDD=%lld, invalid msg=%lld, valid msg=%lld\n" , - vf->num_mdd_events, - vf->num_invalid_msgs, - vf->num_valid_msgs); +dev_info (&pf->pdev->dev," num MDD=%lld\n" , + vf->num_mdd_events); }else {dev_info (&pf->pdev->dev,"invalid VF id %d\n" , vf_id); }
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +7 -50
125 lines not on this page · raw message
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h +0 -5
@@ -10,8 +10,6 @@#define I40E_VIRTCHNL_SUPPORTED_QTYPES 2 -#define I40E_DEFAULT_NUM_INVALID_MSGS_ALLOWED 10 -#define I40E_VLAN_PRIORITY_SHIFT 13#define I40E_VLAN_MASK 0xFFF#define I40E_PRIORITY_MASK 0xE000
@@ -92,9 +90,6 @@ struct i40e_vf {u8 num_queue_pairs;/* num of qps assigned to VF vsis */ u8 num_req_queues;/* num of requested qps */ u64 num_mdd_events;/* num of mdd events detected */ -/* num of continuous malformed or invalid msgs detected */ -u64 num_invalid_msgs; -u64 num_valid_msgs;/* num of valid msgs detected */ unsigned long vf_caps;/* vf's adv. capabilities */ unsigned long vf_states;/* vf's runtime states */
base-commit: 35410c10918a84c9685cd644686ca637bb3c046b
Signature · 1 line
2.35.1.129.gb80121027d12
Jankowski
PATCH 1/2 i40e: stop disabling VFs due to PF error responses
Quoted 61 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Thursday, February 17, 2022 1:52 AM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [net PATCH 1/2] i40e: stop disabling VFs due to PF error responsesThe
i40e_vc_send_msg_to_vf_ex(and its wrapperi40e_vc_send_msg_to_vf) function has logic to detect "failure" responses sent to the VF. If a VF is sent more thanI40E_DEFAULT_NUM_INVALID_MSGS_ALLOWED, then the VF is marked as disabled. In either case, adev_infomessage is printed stating that a VF opcode failed.This logic originates from the early implementation of VF support in commit
5c3c48ac6bf5("i40e: implement virtual device interface").That commit did not go far enough. The "logic" for this behavior seems to be that error responses somehow indicate a malicious VF. This is not really true. The PF might be sending an error for any number of reasons such as lacking resources, an unsupported operation, etc. This does not indicate a malicious VF. We already have a separate robust malicious VF detection which relies on hardware logic to detect and prevent a variety of behaviors.
There is no justification for this behavior in the original implementation. In fact, a later commit
18b7af57d9c1("i40e: Lower some message levels") reduced the opcode failure message from adev_errto adev_info. In addition, recent commit01cbf50877e6("i40e: Fix to not show opcode msg on unsuccessful VF MAC change") changed the logic to allow quieting it for expected failures.That commit prevented this logic from kicking in for specific circumstances. This change did not go far enough. The behavior is not documented nor is it part of any requirement for our products. Other operating systems such as the FreeBSD implementation of our driver do not include this logic.
It is clear this check does not make sense, and causes problems which led to ugly workarounds.
Fix this by just removing the entire logic and the need for the
i40e_vc_send_msg_to_vf_exfunction.Fixes 01cbf50877e6 ("i40e: Fix to not show opcode msg on unsuccessful VFMAC change")
Fixes 5c3c48ac6bf5 ("i40e: implement virtual device interface")Signed-off-by Jacob Keller <[email protected]>--- .../net/ethernet/intel/i40e/i40e_debugfs.c | 6 +- .../ethernet/intel/i40e/i40e_virtchnl_pf.c | 57 +++---------------- .../ethernet/intel/i40e/i40e_virtchnl_pf.h | 5 -- 3 files changed, 9 insertions(+), 59 deletions(-)drivers/net/ethernet/intel/i40e/i40e_debugfs.c +0
-0
drivers/net/ethernet/intel/i40e/i40e_debugfs.c static void i40e_dbg_dump_vf(struct i40e_pf *pf, int · line 742
Quoted 1 line
drivers/net/ethernet/intel/i40e/i40e_debugfs.c +0
-0@@ -742,10 +742,8 @@ static void i40e_dbg_dump_vf(struct i40e_pf *pf, int vf_id)
PATCH 2/2 ice: stop disabling VFs due to PF error responses
In reply to Jacob KellerThe ice_vc_send_msg_to_vf function has logic to detect "failure" responses being sent to a VF. If a VF is sent more than ICE_DFLT_NUM_INVAL_MSGS_ALLOWED then the VF is marked as disabled. Almost identical logic also existed in the i40e driver.
This logic was added to the ice driver in commit 1071a8358a28 ("ice:
Implement virtchnl commands for AVF support") which itself copied from the i40e implementation in commit 5c3c48ac6bf5 ("i40e: implement virtual device interface").
Neither commit provides a proper explanation or justification of the check. In fact, later commits to i40e changed the logic to allow bypassing the check in some specific instances.
The "logic" for this seems to be that error responses somehow indicate a malicious VF. This is not really true. The PF might be sending an error for any number of reasons such as lack of resources, etc.
Additionally, this causes the PF to log an info message for every failed VF response which may confuse users, and can spam the kernel log.
This behavior is not documented as part of any requirement for our products and other operating system drivers such as the FreeBSD implementation of our drivers do not include this type of check.
In fact, the change from dev_err to dev_info in i40e commit 18b7af57d9c1 ("i40e: Lower some message levels") explains that these messages typically don't actually indicate a real issue. It is quite likely that a user who hits this in practice will be very confused as the VF will be disabled without an obvious way to recover.
We already have robust malicious driver detection logic using actual hardware detection mechanisms that detect and prevent invalid device usage. Remove the logic since its not a documented requirement and the behavior is not intuitive.
--- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 18 ------------------ .../net/ethernet/intel/ice/ice_virtchnl_pf.h | 3 --- 2 files changed, 21 deletions(-)
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +0 -18
@@ -2180,24 +2180,6 @@ ice_vc_send_msg_to_vf(struct ice_vf *vf, u32 v_opcode, dev =ice_pf_to_dev (pf); -/* single place to detect unsuccessful return values */ -if (v_retval) { - vf->num_inval_msgs++; -dev_info (dev,"VF %d failed opcode %d, retval: %d\n" , vf->vf_id, - v_opcode, v_retval); -if (vf->num_inval_msgs >ICE_DFLT_NUM_INVAL_MSGS_ALLOWED ) { -dev_err (dev,"Number of invalid messages exceeded for VF %d\n" , - vf->vf_id); -dev_err (dev,"Use PF Control I/F to enable the VF\n" ); -set_bit (ICE_VF_STATE_DIS , vf->vf_states); -return -EIO ; - } - }else { - vf->num_valid_msgs++; -/* reset the invalid counter, if a valid message is received. */ - vf->num_inval_msgs =0 ; - } - aq_ret =ice_aq_send_msg_to_vf (&pf->hw, vf->vf_id, v_opcode, v_retval, msg, msglen,NULL );if (aq_ret && pf->hw.mailboxq.sq_last_status !=ICE_AQ_RC_ENOSYS ) {
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h +0 -3
@@ -14,7 +14,6 @@#define ICE_MAX_MACADDR_PER_VF 18/* Malicious Driver Detection */ -#define ICE_DFLT_NUM_INVAL_MSGS_ALLOWED 10#define ICE_MDD_EVENTS_THRESHOLD 30/* Static VF transaction/status register def */
@@ -134,8 +133,6 @@ struct ice_vf {unsigned int max_tx_rate;/* Maximum Tx bandwidth limit in Mbps */ DECLARE_BITMAP (vf_states,ICE_VF_STATES_NBITS );/* VF runtime states */ -u64 num_inval_msgs;/* number of continuous invalid msgs */ -u64 num_valid_msgs;/* number of valid msgs detected */ unsigned long vf_caps;/* VF's adv. capabilities */ u8 num_req_qs;/* num of queue pairs requested by VF */ u16 num_mac;
Signature · 1 line
2.35.1.129.gb80121027d12
Nguyen
PATCH 2/2 ice: stop disabling VFs due to PF error responses
Quoted 39 lines · Jacob Keller
The
ice_vc_send_msg_to_vffunction has logic to detect "failure" responses being sent to a VF. If a VF is sent more thanICE_DFLT_NUM_INVAL_MSGS_ALLOWEDthen the VF is marked as disabled. Almost identical logic also existed in the i40e driver.This logic was added to the ice driver in commit
1071a8358a28("ice:
Implement virtchnl commands for AVF support") which itself copied from
the i40e implementation in commit5c3c48ac6bf5("i40e: implement virtual
device interface").Neither commit provides a proper explanation or justification of the check. In fact, later commits to i40e changed the logic to allow bypassing the check in some specific instances.
The "logic" for this seems to be that error responses somehow indicate a
malicious VF. This is not really true. The PF might be sending an error
for any number of reasons such as lack of resources, etc.Additionally, this causes the PF to log an info message for every failed
VF response which may confuse users, and can spam the kernel log.This behavior is not documented as part of any requirement for our products and other operating system drivers such as the FreeBSD implementation of our drivers do not include this type of check.
In fact, the change from
dev_errtodev_infoin i40e commit18b7af57d9c1
("i40e: Lower some message levels") explains that these messages typically don't actually indicate a real issue. It is quite likely that
a user who hits this in practice will be very confused as the VF will be
disabled without an obvious way to recover.
Quoted 7 lines
We already have robust malicious driver detection logic using actual hardware detection mechanisms that detect and prevent invalid device usage. Remove the logic since its not a documented requirement and the
behavior is not intuitive.Signed-off-by Jacob Keller <[email protected]>
If this is for net, it should have a Fixes: as well.
Thanks,
Tony
Keller
PATCH 2/2 ice: stop disabling VFs due to PF error responses
Quoted 55 lines
-----Original Message-----
From: Nguyen, Anthony L <[email protected]>
Sent: Thursday, February 17, 2022 9:25 AM
To: Keller, Jacob E <[email protected]>; intel-wired-lan at lists.osuosl.org
Subject: Re: [Intel-wired-lan] [net PATCH 2/2] ice: stop disabling VFs due to PF error responsesQuoted 45 lines · Jacob Keller
The
ice_vc_send_msg_to_vffunction has logic to detect "failure" responses being sent to a VF. If a VF is sent more thanICE_DFLT_NUM_INVAL_MSGS_ALLOWEDthen the VF is marked as disabled. Almost identical logic also existed in the i40e driver.This logic was added to the ice driver in commit
1071a8358a28("ice:
Implement virtchnl commands for AVF support") which itself copied from
the i40e implementation in commit5c3c48ac6bf5("i40e: implement virtual
device interface").Neither commit provides a proper explanation or justification of the check. In fact, later commits to i40e changed the logic to allow bypassing the check in some specific instances.
The "logic" for this seems to be that error responses somehow indicate a
malicious VF. This is not really true. The PF might be sending an error
for any number of reasons such as lack of resources, etc.Additionally, this causes the PF to log an info message for every failed
VF response which may confuse users, and can spam the kernel log.This behavior is not documented as part of any requirement for our products and other operating system drivers such as the FreeBSD implementation of our drivers do not include this type of check.
In fact, the change from
dev_errtodev_infoin i40e commit18b7af57d9c1
("i40e: Lower some message levels") explains that these messages typically don't actually indicate a real issue. It is quite likely that
a user who hits this in practice will be very confused as the VF will be
disabled without an obvious way to recover.We already have robust malicious driver detection logic using actual hardware detection mechanisms that detect and prevent invalid device usage. Remove the logic since its not a documented requirement and the
behavior is not intuitive.
Quoted 6 lines
Quoted 1 line
Signed-off-by Jacob Keller <[email protected]>If this is for net, it should have a Fixes: as well.
Thanks,
Tony
Jankowski
PATCH 2/2 ice: stop disabling VFs due to PF error responses
In reply to Jacob Kellerdrivers/net/ethernet/intel/ice/ice_virtchnl_pf.c ice_vc_send_msg_to_vf(struct ice_vf *vf, u32
Quoted 58 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Thursday, February 17, 2022 1:52 AM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [net PATCH 2/2] ice: stop disabling VFs due to PF error responsesThe
ice_vc_send_msg_to_vffunction has logic to detect "failure" responses being sent to a VF. If a VF is sent more thanICE_DFLT_NUM_INVAL_MSGS_ALLOWEDthen the VF is marked as disabled. Almost identical logic also existed in the i40e driver.This logic was added to the ice driver in commit
1071a8358a28("ice:
Implement virtchnl commands for AVF support") which itself copied from the i40e implementation in commit5c3c48ac6bf5("i40e: implement virtual device interface").Neither commit provides a proper explanation or justification of the check. In fact, later commits to i40e changed the logic to allow bypassing the check in some specific instances.
The "logic" for this seems to be that error responses somehow indicate a malicious VF. This is not really true. The PF might be sending an error for any number of reasons such as lack of resources, etc.
Additionally, this causes the PF to log an info message for every failed VF response which may confuse users, and can spam the kernel log.
This behavior is not documented as part of any requirement for our products and other operating system drivers such as the FreeBSD implementation of our drivers do not include this type of check.
In fact, the change from
dev_errtodev_infoin i40e commit18b7af57d9c1("i40e: Lower some message levels") explains that these messages typically don't actually indicate a real issue. It is quite likely that a user who hits this in practice will be very confused as the VF will be disabled without an obvious way to recover.We already have robust malicious driver detection logic using actual hardware detection mechanisms that detect and prevent invalid device usage. Remove the logic since its not a documented requirement and the behavior is not intuitive.
Signed-off-by Jacob Keller <[email protected]>--- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 18 ------------------ .../net/ethernet/intel/ice/ice_virtchnl_pf.h | 3 --- 2 files changed, 21 deletions(-)drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +0
-0@@ -2180,24 +2180,6 @@ ice_vc_send_msg_to_vf(struct ice_vf *vf, u32