From patchwork Sat Jul 7 04:02:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Yandong.Zhao" X-Patchwork-Id: 940746 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="b2qGSvWt"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Qav3xfao"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41Mydd5N6jz9s0w for ; Sat, 7 Jul 2018 14:04:05 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=+JQlg4892vkeYzxxftESclY51XxwVM/WJQLXjxX3hss=; b=b2qGSvWtonv726 XKIL6486Cda3//TzLA1dmCSzwkKWysCKz19CoZspzpj0wskPB29YKJvmjkSoQXm44gFgcb0b0FTY0 pzFrADhlIvyiRRTS61yjDojz7KNyKbt7ACY6jvY5yy626RZAYws3GJT6tOaMJ/7MLI4djUOQu7Hk0 JreqixinxdYM06qNxGjoz9dYwIEnn1amlz5NwqlawLrZtAdCobBKMToouFuqbUjkuYh9ydwHegkbs YS3GDqsFxvPYYffnwauAFjfBor+pUFkcS62mGNXM4ZTmTb/ndMdU2DodoqsFr5HXdpgi/YRnlx+rt laNIDoeeegT8nM0+/3oA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fbeRy-0005qa-O8; Sat, 07 Jul 2018 04:03:58 +0000 Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fbeRv-0005mu-Le for linux-arm-kernel@lists.infradead.org; Sat, 07 Jul 2018 04:03:57 +0000 Received: by mail-pl0-x243.google.com with SMTP id b1-v6so3678963pls.5 for ; Fri, 06 Jul 2018 21:03:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=q9OpqjMdCVIPatVbjpDctS5ACt4NpRns+klLBRlYHR0=; b=Qav3xfaoDYXFhNah5YBQ+gZIDGJ59CZ57Zx/eZbXEkjSk83cqCmvzGhWS2tmLgPiVh h+Sxl0FrMj608xdXrhHeZzJog6hnNrDKPSxjFS99saFhLzhISWfaQByczlCyzrwFDRPz z1VFJzt/VtIKAkxXqXgvVa4uj2nZ6QR5zW9mZvUIDtKZe28aNY2CF07n/QyMIrd8eI+0 EXIL+GvaGF/AnxRWs/na3x2RAsC7to956fI1cpVEP1nNZuPGRfaAYMr353867v19RnQ2 aD31LxwrDCYnEDNUctApa77Tn2gJqSj4WpFJFIUogi9no2BxkIvGq11OXANeLbhszCHS xOOw== 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:mime-version :content-transfer-encoding; bh=q9OpqjMdCVIPatVbjpDctS5ACt4NpRns+klLBRlYHR0=; b=S9gJrdAP3ic5mRNa+i2qVOx9ionHrtHbVyAnHUDwTp7Pfamd6vQz6CVNgu6Ezjpwc7 IZ44N84aZoE3bHl/Pj1hkMsUeczvzApFbYGxR6m4CZwtT9XNFWW2L3IoQvT/xJXKN0Re ag543oXQgB6TeslxlKlsiJ7f63GqdCZJvnVpV1uqpDyKfccosaOSpW2zurPwarD0IHIB fMEdJ5KvM7ZtFmuFAKW6bxV5F3oWnJFTCw/7miA78xRUGpprDcuFEhsQIacEIHb3GTRO cAnHBc5Mrf4+lsDpOHs3hxLyFVHqFjEH6EKg01RXJg+Tu7AS/4aKdgDC8TCgHEy/5IDv vTUQ== X-Gm-Message-State: APt69E1waNCF7x2AIvlGfHnQBJlsrUQYigyFw5Q4o5FW0YEbCA8l3U+9 ifQ6IRWHTWWmtvy/m+YPi+Q= X-Google-Smtp-Source: AAOMgpen6hpMvku2zZoPc4/+2V/C6ACsr7Y3I2QtK3LhnrRWnMgOQLbzzbo3kRPDL5426gGoWPnkFA== X-Received: by 2002:a17:902:5a1:: with SMTP id f30-v6mr12647953plf.167.1530936224796; Fri, 06 Jul 2018 21:03:44 -0700 (PDT) Received: from bj03003pcul8.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id f24-v6sm16665637pfe.39.2018.07.06.21.03.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 06 Jul 2018 21:03:44 -0700 (PDT) From: "Yandong.Zhao" To: Dave.Martin@arm.com Subject: [PATCH] arm64: neon: Do not access kernel_neon_busy with preemption enabled Date: Sat, 7 Jul 2018 12:02:51 +0800 Message-Id: <1530936171-16169-1-git-send-email-yandong77520@gmail.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180706_210355_708609_8BADBFE0 X-CRM114-Status: GOOD ( 16.75 ) X-Spam-Score: 0.1 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2607:f8b0:400e:c01:0:0:0:243 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (yandong77520[at]gmail.com) 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (yandong77520[at]gmail.com) -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yandong Zhao , zhaoyd@thundersoft.com, zhaoxb@thundersoft.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org From: Yandong Zhao Dear, Dave Thank you very much for reading my email. I have a question and I hope toget your reply. It is a bug to not close the preemption when executing raw_cpu_read(kernel_neon_busy) in the function may_use_simd()! We encountered a ‘sysdump’ problem on Kernel 4.14 code because the program entered BUG_ON() in the function kernel_neon_begin(). Our analysis concludes that the process is migrating while executing raw_cpu_read(kernel_neon_busy). Signed-off-by: Yandong Zhao --- arch/arm64/include/asm/simd.h | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/arch/arm64/include/asm/simd.h b/arch/arm64/include/asm/simd.h index fa8b3fe..0d91084 100644 --- a/arch/arm64/include/asm/simd.h +++ b/arch/arm64/include/asm/simd.h @@ -29,20 +29,13 @@ static __must_check inline bool may_use_simd(void) { /* - * The raw_cpu_read() is racy if called with preemption enabled. - * This is not a bug: kernel_neon_busy is only set when - * preemption is disabled, so we cannot migrate to another CPU - * while it is set, nor can we migrate to a CPU where it is set. - * So, if we find it clear on some CPU then we're guaranteed to - * find it clear on any CPU we could migrate to. - * - * If we are in between kernel_neon_begin()...kernel_neon_end(), - * the flag will be set, but preemption is also disabled, so we - * can't migrate to another CPU and spuriously see it become - * false. + * Operations for contexts where we do not want to do any checks for + * preemptions. Unless strictly necessary, always use this_cpu_*() + * instead. Because of the kernel_neon_busy here we have to make sure + * that it is the current cpu. */ return !in_irq() && !irqs_disabled() && !in_nmi() && - !raw_cpu_read(kernel_neon_busy); + !this_cpu_read(kernel_neon_busy); } #else /* ! CONFIG_KERNEL_MODE_NEON */