From patchwork Wed Jan 6 08:33:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: DD Aric li X-Patchwork-Id: 1422862 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4D9jnW0s4qz9sTv for ; Wed, 6 Jan 2021 19:53:19 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=tolEMrWQ; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4D9jnW01qpzDqZG for ; Wed, 6 Jan 2021 19:53:19 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::102e; helo=mail-pj1-x102e.google.com; envelope-from=lixgemail@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=tolEMrWQ; dkim-atps=neutral Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4D9jLd6tr9zDqXg for ; Wed, 6 Jan 2021 19:33:26 +1100 (AEDT) Received: by mail-pj1-x102e.google.com with SMTP id l23so1231470pjg.1 for ; Wed, 06 Jan 2021 00:33:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=VlZKO6YH4/m83mPb7JJ0qV3qiJd9IV6PB0U/6zqnWBk=; b=tolEMrWQDIONeLt9lh0cO2ZOUO7vUKl8A8wWAFsBulHZrv/3Cz1T8jyPK/R4HUgqUM oIc/eeeSdpilaKit/OgU9DTFvjkiti1rQCr7fBzNQimoMcc90Jb/gGHbufQZk3CczxZD 7Bg7HuJlXb4TokQgGJsp0pIddQxxaEm9cEcEGuGuDYmFhFDn8AKqL6R9dKcXBobHa2t1 mHdBv7IrCcQz589tv4B1UHcCDqeTeuBTTHjTIvaFuGkcaVRPZAWOF4hPdPX6ZxmtMHH9 zJ3LVZu9Khax7nW/6fbgcJWONSOybOYOoPU/FRSRn2OulGQweopwPJDGXMWRu0YGGqE6 1UQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=VlZKO6YH4/m83mPb7JJ0qV3qiJd9IV6PB0U/6zqnWBk=; b=ZSUCr8XsyWJtdBDZRGV+sSLdRwEUTIgl7L7Oe0A3hpgrlJqMERm4N0VQR76D8MdohF ByewthH4ppLwyxxF/GJ2cu9zr/AXtgN1BrbG0dMHitrCLv8nIVsCQEG7NNx7K7pdTFlY jvM6ylvRcNiOO3IFwt2vlLL/n9StBw//7opSJ+azwf643GwCQlY3XFnCp056XZx+Tbnd Fr5Qj1kimQE9Bvwq1IDMNaIR+ViZ4NxOB1M7JW2p4sKQJZObzKgpRnb/0AcDGw+Gac4D L37px6mco/KN/k1wJuGI2TTaZNUw6TLOoz1SjDMkqwz32/PfB576SYrXxW+6GIwkkhc4 byfA== X-Gm-Message-State: AOAM5336I6R0xpe8G2m5viHpaZXhVgEgKJepCRZPyh5AEtnIODyPTIgz jqj4170srgrIiUuGx5s3Z9FoTwTFcGLPRV6/8QU= X-Google-Smtp-Source: ABdhPJzO9YE3XufKwfB3lb6GszMR8pjQijmOUzKYPtfWh+kkvU/kzOua2p5z/uU3a4ELWP7dS4uaFg== X-Received: by 2002:a17:90a:e28a:: with SMTP id d10mr3166741pjz.77.1609922002676; Wed, 06 Jan 2021 00:33:22 -0800 (PST) Received: from localhost (95.169.4.245.16clouds.com. [95.169.4.245]) by smtp.gmail.com with ESMTPSA id 3sm1705109pfv.92.2021.01.06.00.33.21 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 06 Jan 2021 00:33:22 -0800 (PST) From: lixg X-Google-Original-From: lixg <867314078@qq.com> To: skiboot@lists.ozlabs.org Date: Wed, 6 Jan 2021 08:33:18 +0000 Message-Id: <20210106083318.39407-1-867314078@qq.com> X-Mailer: git-send-email 2.17.1 X-Mailman-Approved-At: Wed, 06 Jan 2021 19:53:16 +1100 Subject: [Skiboot] [PATCH] fix lock error when BT IRQ preempt BT timer X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: hegdevasant@in.ibm.com MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" BT IRQ may preempt BT timer if BMC response host when bt msg timeout. When BT IRQ preempt BT timer, the infight_bt_msg did not protected by bt.lock very well. And we will see the following log: [29006114.163785853,3] BT: seq 0x81 netfn 0x0a cmd 0x23: Timeout sending message [29006114.288029290,3] BT: seq 0x81 netfn 0x0b cmd 0x23: Timeout sending message [29006114.288917798,3] IPMI: Incorrect netfn 0x0b in response It may cause 'CPU Hardlock UP', 'memory refree', 'kernel crash' or something else... Signed-off-by: lixg <867314078@qq.com> --- hw/bt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/bt.c b/hw/bt.c index cf967f89..24e6ef7f 100644 --- a/hw/bt.c +++ b/hw/bt.c @@ -111,7 +111,7 @@ struct bt { }; static struct bt bt; -static struct bt_msg *inflight_bt_msg; /* Holds in flight message */ +static struct bt_msg * volatile inflight_bt_msg; /* Holds in flight message */ static int ipmi_seq; @@ -211,6 +211,11 @@ static void bt_msg_del(struct bt_msg *bt_msg) { list_del(&bt_msg->link); bt.queue_len--; + + /* once inflight_bt_msg out of list, it should be emptyed */ + if (bt_msg == inflight_bt_msg) + inflight_bt_msg = NULL; + unlock(&bt.lock); ipmi_cmd_done(bt_msg->ipmi_msg.cmd, IPMI_NETFN_RETURN_CODE(bt_msg->ipmi_msg.netfn), @@ -394,7 +399,7 @@ static void bt_expire_old_msg(uint64_t tb) bt_msg_del(bt_msg); /* Ready to send next message */ - inflight_bt_msg = NULL; + //inflight_bt_msg = NULL; /* * Timing out a message is inherently racy as the BMC