Message ID | 20231213233605.661251-28-iii@linux.ibm.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8165638dys; Wed, 13 Dec 2023 15:38:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IFNddW4WHlsUl5vqw1tHJtM6nanYKAB/JHXhkH+jE7MFsNNbf3G6MwfnKxs2CWS3Tq4o4nn X-Received: by 2002:a17:902:dacc:b0:1d2:f856:8576 with SMTP id q12-20020a170902dacc00b001d2f8568576mr4809856plx.24.1702510715546; Wed, 13 Dec 2023 15:38:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702510715; cv=none; d=google.com; s=arc-20160816; b=oehpYKnf4hkaOiL9J6wMQ6csCJDIBf0Rf/Wk08suZFOtXRf0s5oUw65CJtS8ZW6Gz+ 4u9Uh1c2/idzknQR0FziSopd1BFoINqMlzqZVGwna3L6HhYdH8BLn2JYssR9SLT8Apml edfki+W8+8aRtArFbWX39Yd5BUxJtpYLKt5DqkYYBCcCCZIqUSQByCogqoCg97veJt1N C0ZoTy8IT23OsAKYHetYfWF+CgRZt13h3/7/64dJybDFNKCk4+UVA8sGafpVnZ8VdNuE 9nJhJtwXUfIIXL4cWIqSzTeYvLsJPkaLK2ZwUVdzlCB7biki0HedFt4TWxsKsoE1La2E X7EA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KKQ+/x5aBUFVSHNTE5+u0C93kqAMHLy+4zXkcQqC2PY=; fh=TQATEbdDZNcnk8L2eDP6eFL9HlexFaHIexhR1TH2IlY=; b=TX2iAA5D+kOdGIP/hOFJPZDpPjasTQIZQDGlUiZ4EdL5WUmly8iZWy7qSYspsl7Xi+ RNLW4V0iuRTcqxTyyrsYij6SPggKa+NpdEQvhg32k81dD4AVoOphYmGh2lq9wuu3Uel5 4TlOE/+NdJZ2qYw3dYTgFdnX3MQYfo0ULKoihKT9os8kGJAGQWUuP2YtX6EGSM7nqL5Z 9Jvyg43hz780YDXdB8dSLgR4wRugdh4rYGVFH92RLnww0nWn2DwTI1VPELbu98vvf2Yj qokAx0+C0I2E1tFyWp6pmBpmwx7yxoEj808nTUbW1IsUbrjVhCuEt19d/2qv4XKxjHBU E7Ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=a+xMfSQN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id d16-20020a170902ced000b001d0d312bc13si10501725plg.401.2023.12.13.15.38.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 15:38:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=a+xMfSQN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id A0664802F560; Wed, 13 Dec 2023 15:38:31 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442862AbjLMXiN (ORCPT <rfc822;dexuan.linux@gmail.com> + 99 others); Wed, 13 Dec 2023 18:38:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442757AbjLMXhU (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 13 Dec 2023 18:37:20 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA5401BE; Wed, 13 Dec 2023 15:37:16 -0800 (PST) Received: from pps.filterd (m0353726.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3BDM7CtE015847; Wed, 13 Dec 2023 23:36:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=KKQ+/x5aBUFVSHNTE5+u0C93kqAMHLy+4zXkcQqC2PY=; b=a+xMfSQN60Zosn0PI81EMAF4iY520/iP3v9Go9PFZ6MMlXPomoueq2Ez2smx8b0GVB0h /Bj6t51LVnuCeIlcxLRdQLYnMmrLuXgt1/16Wg0BstV79h+ehRTfeOeByPkVLNlJfcj0 FZdPraGjUCULl+aHf7mZwssQpyMKKzPburxiGRZaG6X8tX27PiB9w9Tdeb1yE/HGWRVP 2nvtddCISxWAXZAQ1luQIjaGLqtlnLKyJEBVxSh2TJ+lbEJh4wyXU2NZsZr/Iqg6QoEV kpgM/0LiaDkcYoKUGn6fSQq2aOxqNEZt1vGUnMbqUXwtkRqq3negMXD7hUUCPiX8mdiQ Jw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uyn4d1q9y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Dec 2023 23:36:57 +0000 Received: from m0353726.ppops.net (m0353726.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3BDNQFao006872; Wed, 13 Dec 2023 23:36:56 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uyn4d1q98-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Dec 2023 23:36:56 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3BDLGUp7028201; Wed, 13 Dec 2023 23:36:55 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3uw2xyvrsa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Dec 2023 23:36:54 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3BDNap6R27263494 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Dec 2023 23:36:51 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BA37D20040; Wed, 13 Dec 2023 23:36:51 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 52BFE20043; Wed, 13 Dec 2023 23:36:50 +0000 (GMT) Received: from heavy.boeblingen.de.ibm.com (unknown [9.171.70.156]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 13 Dec 2023 23:36:50 +0000 (GMT) From: Ilya Leoshkevich <iii@linux.ibm.com> To: Alexander Gordeev <agordeev@linux.ibm.com>, Alexander Potapenko <glider@google.com>, Andrew Morton <akpm@linux-foundation.org>, Christoph Lameter <cl@linux.com>, David Rientjes <rientjes@google.com>, Heiko Carstens <hca@linux.ibm.com>, Joonsoo Kim <iamjoonsoo.kim@lge.com>, Marco Elver <elver@google.com>, Masami Hiramatsu <mhiramat@kernel.org>, Pekka Enberg <penberg@kernel.org>, Steven Rostedt <rostedt@goodmis.org>, Vasily Gorbik <gor@linux.ibm.com>, Vlastimil Babka <vbabka@suse.cz> Cc: Christian Borntraeger <borntraeger@linux.ibm.com>, Dmitry Vyukov <dvyukov@google.com>, Hyeonggon Yoo <42.hyeyoo@gmail.com>, kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-s390@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Mark Rutland <mark.rutland@arm.com>, Roman Gushchin <roman.gushchin@linux.dev>, Sven Schnelle <svens@linux.ibm.com>, Ilya Leoshkevich <iii@linux.ibm.com> Subject: [PATCH v3 27/34] s390/irqflags: Do not instrument arch_local_irq_*() with KMSAN Date: Thu, 14 Dec 2023 00:24:47 +0100 Message-ID: <20231213233605.661251-28-iii@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231213233605.661251-1-iii@linux.ibm.com> References: <20231213233605.661251-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: IYnxAzNVYRzPOrpd-XtDyC5bRWSG5SiX X-Proofpoint-GUID: xGq4qQaEqxkSC5s6qSjoXz9Vr7RdbrF2 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-13_14,2023-12-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 spamscore=0 mlxscore=0 malwarescore=0 phishscore=0 lowpriorityscore=0 mlxlogscore=999 impostorscore=0 clxscore=1015 priorityscore=1501 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312130167 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 13 Dec 2023 15:38:31 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785211876420219777 X-GMAIL-MSGID: 1785211876420219777 |
Series |
kmsan: Enable on s390
|
|
Commit Message
Ilya Leoshkevich
Dec. 13, 2023, 11:24 p.m. UTC
KMSAN generates the following false positives on s390x:
[ 6.063666] DEBUG_LOCKS_WARN_ON(lockdep_hardirqs_enabled())
[ ...]
[ 6.577050] Call Trace:
[ 6.619637] [<000000000690d2de>] check_flags+0x1fe/0x210
[ 6.665411] ([<000000000690d2da>] check_flags+0x1fa/0x210)
[ 6.707478] [<00000000006cec1a>] lock_acquire+0x2ca/0xce0
[ 6.749959] [<00000000069820ea>] _raw_spin_lock_irqsave+0xea/0x190
[ 6.794912] [<00000000041fc988>] __stack_depot_save+0x218/0x5b0
[ 6.838420] [<000000000197affe>] __msan_poison_alloca+0xfe/0x1a0
[ 6.882985] [<0000000007c5827c>] start_kernel+0x70c/0xd50
[ 6.927454] [<0000000000100036>] startup_continue+0x36/0x40
Between trace_hardirqs_on() and `stosm __mask, 3` lockdep thinks that
interrupts are on, but on the CPU they are still off. KMSAN
instrumentation takes spinlocks, giving lockdep a chance to see and
complain about this discrepancy.
KMSAN instrumentation is inserted in order to poison the __mask
variable. Disable instrumentation in the respective functions. They are
very small and it's easy to see that no important metadata updates are
lost because of this.
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
arch/s390/include/asm/irqflags.h | 18 +++++++++++++++---
drivers/s390/char/sclp.c | 2 +-
2 files changed, 16 insertions(+), 4 deletions(-)
Comments
On Thu, Dec 14, 2023 at 12:36 AM Ilya Leoshkevich <iii@linux.ibm.com> wrote: > > KMSAN generates the following false positives on s390x: > > [ 6.063666] DEBUG_LOCKS_WARN_ON(lockdep_hardirqs_enabled()) > [ ...] > [ 6.577050] Call Trace: > [ 6.619637] [<000000000690d2de>] check_flags+0x1fe/0x210 > [ 6.665411] ([<000000000690d2da>] check_flags+0x1fa/0x210) > [ 6.707478] [<00000000006cec1a>] lock_acquire+0x2ca/0xce0 > [ 6.749959] [<00000000069820ea>] _raw_spin_lock_irqsave+0xea/0x190 > [ 6.794912] [<00000000041fc988>] __stack_depot_save+0x218/0x5b0 > [ 6.838420] [<000000000197affe>] __msan_poison_alloca+0xfe/0x1a0 > [ 6.882985] [<0000000007c5827c>] start_kernel+0x70c/0xd50 > [ 6.927454] [<0000000000100036>] startup_continue+0x36/0x40 > > Between trace_hardirqs_on() and `stosm __mask, 3` lockdep thinks that > interrupts are on, but on the CPU they are still off. KMSAN > instrumentation takes spinlocks, giving lockdep a chance to see and > complain about this discrepancy. > > KMSAN instrumentation is inserted in order to poison the __mask > variable. Disable instrumentation in the respective functions. They are > very small and it's easy to see that no important metadata updates are > lost because of this. > > Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Reviewed-by: Alexander Potapenko <glider@google.com>
On Thu, Dec 14, 2023 at 12:24:47AM +0100, Ilya Leoshkevich wrote: > KMSAN generates the following false positives on s390x: > > [ 6.063666] DEBUG_LOCKS_WARN_ON(lockdep_hardirqs_enabled()) > [ ...] > [ 6.577050] Call Trace: > [ 6.619637] [<000000000690d2de>] check_flags+0x1fe/0x210 > [ 6.665411] ([<000000000690d2da>] check_flags+0x1fa/0x210) > [ 6.707478] [<00000000006cec1a>] lock_acquire+0x2ca/0xce0 > [ 6.749959] [<00000000069820ea>] _raw_spin_lock_irqsave+0xea/0x190 > [ 6.794912] [<00000000041fc988>] __stack_depot_save+0x218/0x5b0 > [ 6.838420] [<000000000197affe>] __msan_poison_alloca+0xfe/0x1a0 > [ 6.882985] [<0000000007c5827c>] start_kernel+0x70c/0xd50 > [ 6.927454] [<0000000000100036>] startup_continue+0x36/0x40 > > Between trace_hardirqs_on() and `stosm __mask, 3` lockdep thinks that > interrupts are on, but on the CPU they are still off. KMSAN > instrumentation takes spinlocks, giving lockdep a chance to see and > complain about this discrepancy. > > KMSAN instrumentation is inserted in order to poison the __mask > variable. Disable instrumentation in the respective functions. They are > very small and it's easy to see that no important metadata updates are > lost because of this. > > Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> > --- > arch/s390/include/asm/irqflags.h | 18 +++++++++++++++--- > drivers/s390/char/sclp.c | 2 +- > 2 files changed, 16 insertions(+), 4 deletions(-) > > diff --git a/arch/s390/include/asm/irqflags.h b/arch/s390/include/asm/irqflags.h > index 02427b205c11..7353a88b2ae2 100644 > --- a/arch/s390/include/asm/irqflags.h > +++ b/arch/s390/include/asm/irqflags.h > @@ -37,12 +37,19 @@ static __always_inline void __arch_local_irq_ssm(unsigned long flags) > asm volatile("ssm %0" : : "Q" (flags) : "memory"); > } > > -static __always_inline unsigned long arch_local_save_flags(void) > +#ifdef CONFIG_KMSAN > +#define ARCH_LOCAL_IRQ_ATTRIBUTES \ > + noinline notrace __no_sanitize_memory __maybe_unused > +#else > +#define ARCH_LOCAL_IRQ_ATTRIBUTES __always_inline > +#endif > + > +static ARCH_LOCAL_IRQ_ATTRIBUTES unsigned long arch_local_save_flags(void) > { Please change this to lower case and long single lines, so it matches the more common patterns: #ifdef CONFIG_KMSAN #define __arch_local_irq_attributes noinline notrace __no_sanitize_memory __maybe_unused #else #define __arch_local_irq_attributes __always_inline #endif static __arch_local_irq_attributes unsigned long arch_local_save_flags(void) ...
diff --git a/arch/s390/include/asm/irqflags.h b/arch/s390/include/asm/irqflags.h index 02427b205c11..7353a88b2ae2 100644 --- a/arch/s390/include/asm/irqflags.h +++ b/arch/s390/include/asm/irqflags.h @@ -37,12 +37,19 @@ static __always_inline void __arch_local_irq_ssm(unsigned long flags) asm volatile("ssm %0" : : "Q" (flags) : "memory"); } -static __always_inline unsigned long arch_local_save_flags(void) +#ifdef CONFIG_KMSAN +#define ARCH_LOCAL_IRQ_ATTRIBUTES \ + noinline notrace __no_sanitize_memory __maybe_unused +#else +#define ARCH_LOCAL_IRQ_ATTRIBUTES __always_inline +#endif + +static ARCH_LOCAL_IRQ_ATTRIBUTES unsigned long arch_local_save_flags(void) { return __arch_local_irq_stnsm(0xff); } -static __always_inline unsigned long arch_local_irq_save(void) +static ARCH_LOCAL_IRQ_ATTRIBUTES unsigned long arch_local_irq_save(void) { return __arch_local_irq_stnsm(0xfc); } @@ -52,7 +59,12 @@ static __always_inline void arch_local_irq_disable(void) arch_local_irq_save(); } -static __always_inline void arch_local_irq_enable(void) +static ARCH_LOCAL_IRQ_ATTRIBUTES void arch_local_irq_enable_external(void) +{ + __arch_local_irq_stosm(0x01); +} + +static ARCH_LOCAL_IRQ_ATTRIBUTES void arch_local_irq_enable(void) { __arch_local_irq_stosm(0x03); } diff --git a/drivers/s390/char/sclp.c b/drivers/s390/char/sclp.c index d53ee34d398f..fb1d9949adca 100644 --- a/drivers/s390/char/sclp.c +++ b/drivers/s390/char/sclp.c @@ -736,7 +736,7 @@ sclp_sync_wait(void) cr0_sync.val = cr0.val & ~CR0_IRQ_SUBCLASS_MASK; cr0_sync.val |= 1UL << (63 - 54); local_ctl_load(0, &cr0_sync); - __arch_local_irq_stosm(0x01); + arch_local_irq_enable_external(); /* Loop until driver state indicates finished request */ while (sclp_running_state != sclp_running_state_idle) { /* Check for expired request timer */