Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5654663rdb; Wed, 13 Dec 2023 15:38:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IE8xXIFD+tocvislcU8ncQe+VZyAzNIZVT+szdzz7HJHqvq5wnf9wpIGjYmNlYpXsjlrwNK X-Received: by 2002:a05:6808:f12:b0:3b9:ffae:abfd with SMTP id m18-20020a0568080f1200b003b9ffaeabfdmr9406535oiw.61.1702510724309; Wed, 13 Dec 2023 15:38:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702510724; cv=none; d=google.com; s=arc-20160816; b=PgWuvEB2nz3Ipz/mXpEvKfpN1eCqJDJzzJCbyEJRSXezobvTLDY1ETParrofLzH6X6 OOPF8s0D7Wp+GMdcqS2XrbAYV+CN7rZYBPVNeQ6dzT3hWth1DF17IaiYE0NUq46uZHrO y9+pzgWq0T9B/Nl71553EdveZJctI0qA3Xav3Tv+Jol8R50ko3kmRI08la5qr+z3fKXz srlX1O7qnS86yZPPyEjrEopFRUUylJRXDmIstf1S861gqAQ5XG3x2kJ0a3oZs5AN3QA4 70rx5noODo0FKVbFjQIKmq40VEhAU1NCB3COnJ02JV1A9+YYDHUg8Xq0gxMnoIU1r8ry CZ7w== 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 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id f4-20020a635544000000b005c70983efc3si7775392pgm.205.2023.12.13.15.38.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 15:38:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; 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 23.128.96.33 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 6012480CD71A; Wed, 13 Dec 2023 15:38:39 -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 + 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 ); 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 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 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: 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:39 -0800 (PST) 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 --- 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) { 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 */ -- 2.43.0