From patchwork Tue Oct 13 09:49:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paoloni, Gabriele" X-Patchwork-Id: 11835267 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E001992C for ; Tue, 13 Oct 2020 09:50:15 +0000 (UTC) Received: from web01.groups.io (web01.groups.io [66.175.222.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 702792072D for ; Tue, 13 Oct 2020 09:50:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=lists.elisa.tech header.i=@lists.elisa.tech header.b="OSwM8qbn" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 702792072D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=bounce+72012+92+4688437+8417402@lists.elisa.tech X-Received: by 127.0.0.2 with SMTP id 1JeUYY4689772xqaZmBB7INa; Tue, 13 Oct 2020 02:50:15 -0700 X-Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web10.8229.1602582614818797112 for ; Tue, 13 Oct 2020 02:50:14 -0700 IronPort-SDR: hc5jZzK9bRo2mCqhtKNDmOgrTTDrmJRbhW0a5zMrRA/Kf3Vtyr/Tt5MST4iAwyZhqQcdcIsDBo igMkZRvxAGdA== X-IronPort-AV: E=McAfee;i="6000,8403,9772"; a="165093417" X-IronPort-AV: E=Sophos;i="5.77,369,1596524400"; d="scan'208";a="165093417" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2020 02:50:00 -0700 IronPort-SDR: /jCbjjDSsDRSjyGfB1MqqRNntspMoj2Yl5HqvxpZDGdEaiyb0U+s4dgGNFugVtb2N6HEDwpF9j 6us67uzDkxrQ== X-IronPort-AV: E=Sophos;i="5.77,369,1596524400"; d="scan'208";a="463427609" X-Received: from paolonig001.ir.intel.com ([163.33.183.93]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2020 02:49:59 -0700 From: "Paoloni, Gabriele" To: linux-safety@lists.elisa.tech Cc: gabriele.paoloni@intel.com Subject: [linux-safety] [RFC PATCH 1/2] bust_spinlocks: add kernel-doc format doc Date: Tue, 13 Oct 2020 10:49:37 +0100 Message-Id: <20201013094938.356837-2-gabriele.paoloni@intel.com> In-Reply-To: <20201013094938.356837-1-gabriele.paoloni@intel.com> References: <20201013094938.356837-1-gabriele.paoloni@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: linux-safety@lists.elisa.tech List-Id: Mailing-List: list linux-safety@lists.elisa.tech; contact linux-safety+owner@lists.elisa.tech Delivered-To: mailing list linux-safety@lists.elisa.tech List-Post: X-Gm-Message-State: cgtWqKJqhbtoS3g24DlllnRvx4688437AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.elisa.tech; q=dns/txt; s=20140610; t=1602582615; bh=EmXT2OxfWdkM7OykqJp40z4wfWLHnR9CMUMxGwc7hLw=; h=Cc:Content-Type:Date:From:Subject:To; b=OSwM8qbnwKuO6C6LxOlD9hlph7qY8BRrzL8yghEqgOdIs0nBvkawnngem7GgLFJYYo+ gDLSYfZA2hmKDdGypAvuGQGC3TCRJAXbcPLOUt87IDIfjOOm1OcHC/0Bxia1+AoenrZ9w JJ3NJzbpecAk3c2zortMXagvKA9WDZyIPGU= In the ELISA Linux Foundation project we are trying to improve the functions' documentation to make it more suitable to derive functions' specs and write unit tests. This is needed to make Linux more usable in functional safety systems. So I am adding a proper kernel-doc format for bust_spinlocks. Signed-off-by: Gabriele Paoloni --- With respect to this patch I have a question on how to set the function context; i.e. I don't know if it can be executed in any context or if it has limitations. --- lib/bust_spinlocks.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/bust_spinlocks.c b/lib/bust_spinlocks.c index 8be59f84eaea..594b270161d9 100644 --- a/lib/bust_spinlocks.c +++ b/lib/bust_spinlocks.c @@ -5,8 +5,6 @@ * Provides a minimal bust_spinlocks for architectures which don't * have one of their own. * - * bust_spinlocks() clears any spinlocks which would prevent oops, die(), BUG() - * and panic() information from reaching the user. */ #include @@ -17,6 +15,15 @@ #include #include +/** + * bust_spinlocks - increases or decreases oops_in_progress. + * if oops_in_progress != 0 spinlocks which would prevent + * oops, die(), BUG() and panic() information from reaching + * the user are busted. + * @yes: input flag; if zero decreases oops_in_progress, + * otherwise increases it. + * + */ void bust_spinlocks(int yes) { if (yes) { From patchwork Tue Oct 13 09:49:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paoloni, Gabriele" X-Patchwork-Id: 11835269 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4D5D014D5 for ; Tue, 13 Oct 2020 09:50:16 +0000 (UTC) Received: from web01.groups.io (web01.groups.io [66.175.222.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BA5B32078A for ; Tue, 13 Oct 2020 09:50:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=lists.elisa.tech header.i=@lists.elisa.tech header.b="cu/BJQy2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BA5B32078A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=bounce+72012+93+4688437+8417402@lists.elisa.tech X-Received: by 127.0.0.2 with SMTP id XPrsYY4689772xtUktBq9Xcm; Tue, 13 Oct 2020 02:50:15 -0700 X-Received: from mga14.intel.com (mga14.intel.com []) by mx.groups.io with SMTP id smtpd.web10.8229.1602582614818797112 for ; Tue, 13 Oct 2020 02:50:15 -0700 IronPort-SDR: 7YE3OhZH19cHbHKaIg6ceyeq5wJRDhx8I6Bl1Y9cSvJLUjBk7jnUCRamjmtX0aBanRU3pA8sIh WkUh9w43figg== X-IronPort-AV: E=McAfee;i="6000,8403,9772"; a="165093423" X-IronPort-AV: E=Sophos;i="5.77,369,1596524400"; d="scan'208";a="165093423" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2020 02:50:02 -0700 IronPort-SDR: /ztbp2kr8ZOHXgrgY4G413bnBkrCkuvat5Z3qDqmuNfs8d+CFfrNnVr9lyzRooGb2unzhwkuHx qs/zWpIq6MfQ== X-IronPort-AV: E=Sophos;i="5.77,369,1596524400"; d="scan'208";a="463427624" X-Received: from paolonig001.ir.intel.com ([163.33.183.93]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2020 02:50:02 -0700 From: "Paoloni, Gabriele" To: linux-safety@lists.elisa.tech Cc: gabriele.paoloni@intel.com Subject: [linux-safety] [RFC PATCH 2/2] bust_spinlocks: do not decrement oops_in_progress unconditionally Date: Tue, 13 Oct 2020 10:49:38 +0100 Message-Id: <20201013094938.356837-3-gabriele.paoloni@intel.com> In-Reply-To: <20201013094938.356837-1-gabriele.paoloni@intel.com> References: <20201013094938.356837-1-gabriele.paoloni@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: linux-safety@lists.elisa.tech List-Id: Mailing-List: list linux-safety@lists.elisa.tech; contact linux-safety+owner@lists.elisa.tech Delivered-To: mailing list linux-safety@lists.elisa.tech List-Post: X-Gm-Message-State: zIjr8b0sFiJdTrW9dy2MZ1Yox4688437AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.elisa.tech; q=dns/txt; s=20140610; t=1602582615; bh=rLmj388HL5yGq9HhZXeEjOkdmz8kYZgud1h156lYFIY=; h=Cc:Content-Type:Date:From:Subject:To; b=cu/BJQy2/4CouEkhNXy4TS5C5QqAbCF2TEOeI5CkhXISAU+zMxVB/ffGmBpBKTEpAZv 5y2e30iy9Wxp1p0ULIZbcjWuQgrN/J7SWG1EWTje1Vm4/zWlNvYhKyG3JuzsQiRZ56b4O 2ChMqP3VIYpttVaeRQStV1s+1DVb273fHYk= In the current implementation if the input flag is 0 oops_in_progress is unconditionally decremented, thus allowing to become a negative number. Since right now oops_in_progress is a global variable used in the kernel as a conditional flag to check if oops, panic(), BUG() or die() is in progress the current unconditional decrement may lead to unexpected behavior in the Kernel paths conditionally executing over this flag. This patch only decrement oops_in_progress if it is non zero Signed-off-by: Gabriele Paoloni --- lib/bust_spinlocks.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/bust_spinlocks.c b/lib/bust_spinlocks.c index 594b270161d9..842633ac9130 100644 --- a/lib/bust_spinlocks.c +++ b/lib/bust_spinlocks.c @@ -23,6 +23,9 @@ * @yes: input flag; if zero decreases oops_in_progress, * otherwise increases it. * + * Note: if oops_in_progress is already 0 it will not + * be decreased + * */ void bust_spinlocks(int yes) { @@ -33,7 +36,9 @@ void bust_spinlocks(int yes) unblank_screen(); #endif console_unblank(); - if (--oops_in_progress == 0) + if (oops_in_progress) + oops_in_progress--; + if (!oops_in_progress) wake_up_klogd(); } }