From 681cf91c258821c10adb276f6e477bc83d9c9cbb Mon Sep 17 00:00:00 2001 From: Yonglong Liu Date: Wed, 7 Dec 2022 11:47:10 +0800 Subject: [PATCH] net: hns3: add barrier in vf mailbox reply process driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I7OQCS CVE: NA ---------------------------- In hclgevf_mbx_handler() and hclgevf_get_mbx_resp() functions, there is a typical store-store and load-load scenario between received_resp and additional_info. This patch adds barrier to fix the problem. Signed-off-by: Yonglong Liu --- drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c index 484e1a6fe3cc..ec2b4e653893 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c @@ -82,6 +82,9 @@ static int hclgevf_get_mbx_resp(struct hclgevf_dev *hdev, u16 code0, u16 code1, i++; } + /* ensure additional_info will be seen after received_resp */ + smp_rmb(); + if (i >= HCLGEVF_MAX_TRY_TIMES) { dev_err(&hdev->pdev->dev, "VF could not get mbx(%u,%u) resp(=%d) from PF in %d tries\n", @@ -240,6 +243,11 @@ void hclgevf_mbx_handler(struct hclgevf_dev *hdev) temp++; } + /* ensure additional_info will be seen before setting + * received_resp + */ + smp_wmb(); + if (req->match_id) { /* If match_id is not zero, it means PF support * match_id. If the match_id is right, VF get -- GitLab