From patchwork Fri Jun 21 00:25:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 13706588 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A3C1C2BA18 for ; Fri, 21 Jun 2024 00:28:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3C9598D0109; Thu, 20 Jun 2024 20:27:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 306208D0108; Thu, 20 Jun 2024 20:27:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0DF708D0109; Thu, 20 Jun 2024 20:27:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id D5D7F8D0108 for ; Thu, 20 Jun 2024 20:27:13 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 93A7EC06AA for ; Fri, 21 Jun 2024 00:27:13 +0000 (UTC) X-FDA: 82253006346.23.92052F4 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf08.hostedemail.com (Postfix) with ESMTP id 4B07016000F for ; Fri, 21 Jun 2024 00:27:11 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=IQLYQcBZ; spf=pass (imf08.hostedemail.com: domain of iii@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=iii@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718929621; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=+zoFJVlk37wQaOMfwbNCgteXo249s6T95ikp3xQJB1k=; b=qiJSXsCqqhNhqkeB4DbxmciVqvkkNhhyrXyjl/2nna20aIyQOzvPEEgJVS6PPRdRMF27CZ PwjpXx8kom4Zm/mUKadZvJ/nIt1aL/gnYuB+EPxUK5gJNhejBpoIsjM65S2hpQXZgo3yxp 39aXTEXMX29p5H1j4WX+V+1M+NoakwE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718929621; a=rsa-sha256; cv=none; b=E1CUae3eg7QslDisOvWkBUIOkdPic837r9OAhmBeiI61Hzh8g7LFPf3OugDfEalHmEt/NR Vj9wkHD+dl6Jot2QD8s0em9wDZd/cTwtngb3p72DER3EDljuulNFYYl1lzJC/LFC2QLc4I 7uLVzxq2VMmKzSJPt98fkINUQ9ihTjY= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=IQLYQcBZ; spf=pass (imf08.hostedemail.com: domain of iii@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=iii@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com Received: from pps.filterd (m0353728.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45L0Qnua007904; Fri, 21 Jun 2024 00:27:05 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=+zoFJVlk37wQa OMfwbNCgteXo249s6T95ikp3xQJB1k=; b=IQLYQcBZjqnXY46jTEf3T1rXGEJOD JzsTAECzL2BtnJ+puhZwIO9klXa1OfyYh34KfRBM7kET849OfcIlmefdWL08DuAy MfXzFprdqGipnoBIm8XVByjbhMgUbhcDL4heEi14JHpWfFLT+/At/L5oR9McdDv4 JvZMNdCnw2JBNPwY1qGOWvsbxFWhKYebqbJCxrZlzKsClEcoNTX8SXK7jdL/1onF bj3cnBI2f5oXGR7QkG4Tt2vD41TG+JsZ7r3P8vM77ydNqy1BCBjwpSl8AMI5PaLu jIQlyzi/yrCUHomasc12Mu0MErpWipBmRJuIOPZ3KQHT0aFBehYj6kokQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yvw8c876m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jun 2024 00:27:04 +0000 (GMT) Received: from m0353728.ppops.net (m0353728.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 45L0R3AH008332; Fri, 21 Jun 2024 00:27:04 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yvw8c876g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jun 2024 00:27:03 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 45L0PCOr019980; Fri, 21 Jun 2024 00:27:02 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3yvrqujp01-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jun 2024 00:27:02 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 45L0QuN328836416 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Jun 2024 00:26:58 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B1C8D2004D; Fri, 21 Jun 2024 00:26:56 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 91A1120043; Fri, 21 Jun 2024 00:26:55 +0000 (GMT) Received: from heavy.ibm.com (unknown [9.171.10.44]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 21 Jun 2024 00:26:55 +0000 (GMT) From: Ilya Leoshkevich To: Alexander Gordeev , Alexander Potapenko , Andrew Morton , Christoph Lameter , David Rientjes , Heiko Carstens , Joonsoo Kim , Marco Elver , Masami Hiramatsu , Pekka Enberg , Steven Rostedt , Vasily Gorbik , Vlastimil Babka Cc: Christian Borntraeger , Dmitry Vyukov , 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 , Roman Gushchin , Sven Schnelle , Ilya Leoshkevich Subject: [PATCH v6 30/39] s390/irqflags: Do not instrument arch_local_irq_*() with KMSAN Date: Fri, 21 Jun 2024 02:25:04 +0200 Message-ID: <20240621002616.40684-31-iii@linux.ibm.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240621002616.40684-1-iii@linux.ibm.com> References: <20240621002616.40684-1-iii@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: mJfVanZcD3aql1zd3WEmKagMvpX0kn1c X-Proofpoint-ORIG-GUID: NFgq7-uLXQwiRiHtpJGf6Y1zeU6AIr_p X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-20_11,2024-06-20_04,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 phishscore=0 mlxscore=0 impostorscore=0 lowpriorityscore=0 priorityscore=1501 bulkscore=0 suspectscore=0 mlxlogscore=999 malwarescore=0 clxscore=1015 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2406210001 X-Stat-Signature: tuktoumsipatsdrzuzg4jn3aypyrizmc X-Rspamd-Queue-Id: 4B07016000F X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1718929631-844410 X-HE-Meta: U2FsdGVkX1+Q2FqOvk+Fi3aWpK8b+RlZ64DOMke/uC8SDAWseph9CFU4ZXtNaWlWSeX8FjVuEimul3qJKMAhLXDhyWqCFFmgEfUcaFBx8zdAovjzWia55Fdbe8b+S9q2VglzHS5MI+3oZk/YhDDmPWYiDawECN9gWob2yP8y5WOel2l4QjKgIRdhmxRdal5fF/dAmyn4FKp0q5DYrl7+KQa8ochgUsLSIH/Ixh0NZRrbMuJG5zuelE4I6hJqJJRjCUbMBWeiOcD2DH1EIZpTsgHyYCkdcvhn0VAn08h6cY7YOHUt/cHAn+OtvTBcVvENvs4a8/KkteY7eODaz8mhsTIt3/E7mjPYdeXcUB17BSH2sVmSCMZNmojBG3ibhZQR5EWl0eVw/M5NhgSYvaRTwM/8m60UNa+zoVE+Jh4W/ZMw1wjqrdYHw6LuhBk39JDkavOAXSQlmig7CpcX3Mu4qYp5NIgr3velX9V9Zpg0xE8CtOhN8tuAuNg0dAH6azGkRg9RCrj5drwYEJ7CchPoRvLDifk+S9hlCrJ2alp2JPa7vgZJqAsltnyURpBrbavzBOQi6wPxDiX8jeHfb2+nnJ1GCRzEp3KYF28HGs+kAYu2VYxvRYJHUqsyeDpS+IU7W38PkYEC+rPJ9uheixqbw89Kb2SpgiT/gxEVFTXBOpcJY4qmXFhM+jWaJCDMAGUA42iTpbjlZJnUNkRzXnLYBdA1S9ZSDYrz3aFbh0yhAmxv+IEdaeH/9cpGtxZBEyPXM0m2E4iAZFRWDtiuVVE9QcFSloUNRSSJrd740ucFu4fF5CRztcv0egGbKIjgEzJy1uTYpbs0ouwIwMkPnvW43cgVFXz9jvB0SkFvg7+aeusG450TklLGw3r+kktMPIih/7VU75gdwhQ22Gfr6/+uOWxwJUXM7s0iPmI6LixW4z++veLOKg+SWMl08idBI2M/mho+cAt/1CYc4U7SDAP +8KQXoB4 HyfBO0nu6pX1QPISA0z0LfJO4T7PKUgvAOdNJQYWmeHlsEfu3hDhyJPfWWW+0eCqhrrZJichk0VAK07qS9QL/e+HP5YqzzB59K94CGhrv/qSkjA3T2pKyTC9ZNhMJxC8o7m2PcYzTglZo697QKp/OvdoIDNrUYMxiFmfaI+GlL9Y2EXM690A8zrRhJBQTcz0Gw/QXP8zrK/2psMm9SPMDr8c0jF7TkA2CSYsRaiR8WoVZ0vij5kTT+K1kkjlkh6f5ogrk65XbXV/wvD0o/RrUVp5dmk18Gu0ic6I+7ePq2dG/kwSZGXRNzVjaGnOEhviXDA/qYuFvpyNpvx0= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000010, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Lockdep generates the following false positives with KMSAN 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. Reviewed-by: Alexander Potapenko Signed-off-by: Ilya Leoshkevich --- arch/s390/include/asm/irqflags.h | 17 ++++++++++++++--- drivers/s390/char/sclp.c | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/arch/s390/include/asm/irqflags.h b/arch/s390/include/asm/irqflags.h index 02427b205c11..bcab456dfb80 100644 --- a/arch/s390/include/asm/irqflags.h +++ b/arch/s390/include/asm/irqflags.h @@ -37,12 +37,18 @@ 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 +58,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 */