Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1150764pxb; Thu, 16 Sep 2021 00:25:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydhfUsQnUuQYlykakQ74V4RS6YyvF9JFfGfcRjInVr9/0mjuq5VG8XY8czw+HwtMJ0Z8RL X-Received: by 2002:a5d:9c53:: with SMTP id 19mr3137283iof.192.1631777157967; Thu, 16 Sep 2021 00:25:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631777157; cv=none; d=google.com; s=arc-20160816; b=CxN2wpj+dpU5ga+BaZ62aGRiQD+knVqfDC5QznqyX1X3QVlF/6PKDJPV11T46qLbD1 Sk82pMCCCuU/WKOvLhzqeVSf8Ywg/3Y6RFprzVNagMdVhaT3J5vR1mRDFxnRqn2/vge0 Xw5QHADbPUVSbDF2D5COQsMTSL+k8HhFRqAUAbXmJ+WDQKHoImwN/BjzADCoawPVUc6y obvnrXgrmH8RG4w2DlnJPq0qNEJ9nIdpeVZodr3Agu5UBuAwqAd5Dt4dtMyjF7cvXCRj PLflmljjzYFJLlkPGXEnED1d2y3buO+hGLq4bVUrffK9HISIRj2n3wNJ2WzEmXoFNa/Y l4ZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=dkriD1Jgx6RpTtD2zyOKP1Jy5d+PuIx2B+7qnxZDis0=; b=N7gPl/6b72KNT+CDOHx1dqRGILDKcN4HgYSgYRnNzGWUhABZwrb8BcYw88Mhzcvfa2 KLz8T0Vm2IZdaZ8TchlrvCyH0KdYXCW8giLgFyVMLxNYG47buKHMM5VPZeqvK14li+8d 42JAcoF37bD7Zl2c2MjMdy4jJuDVEswoLNA6Yyosj08HQchFfk1K6aMaWaCgG3e9rgcW /VcAGo/axeE4XfWbtdxpewutFOUIzfrHOVZennPf8eyFHkoY2B1lYfJafX2iJnZVSH5t Fnblxmdwg8kaQxu+28JapJ4Axsj3wde/RVKBj5doZf81DYyHn5ORhI9U+nwzC4jvxM7m TlgA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l39si2008939jac.108.2021.09.16.00.25.46; Thu, 16 Sep 2021 00:25:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234735AbhIPHZY (ORCPT + 99 others); Thu, 16 Sep 2021 03:25:24 -0400 Received: from pegase2.c-s.fr ([93.17.235.10]:46403 "EHLO pegase2.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234671AbhIPHZW (ORCPT ); Thu, 16 Sep 2021 03:25:22 -0400 Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4H97qh40qXz9sVF; Thu, 16 Sep 2021 09:24:00 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase2.c-s.fr ([172.26.127.65]) by localhost (pegase2.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wKKfxh6TCdGx; Thu, 16 Sep 2021 09:24:00 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase2.c-s.fr (Postfix) with ESMTP id 4H97qf313Xz9sVD; Thu, 16 Sep 2021 09:23:58 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 521AF8B763; Thu, 16 Sep 2021 09:23:58 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id pa4JKxB2Kswe; Thu, 16 Sep 2021 09:23:58 +0200 (CEST) Received: from PO20335.IDSI0.si.c-s.fr (unknown [192.168.202.5]) by messagerie.si.c-s.fr (Postfix) with ESMTP id A6F368B77E; Thu, 16 Sep 2021 09:23:57 +0200 (CEST) Subject: Re: [PATCH] powerpc: warn on emulation of dcbz instruction To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Stan Johnson , Finn Thain References: <62b33ca839f3d1d7d4b64b6f56af0bbe4d2c9057.1631716292.git.christophe.leroy@csgroup.eu> <2c0fd775625c76c4dd09b3e923da4405a003f3bd.camel@kernel.crashing.org> From: Christophe Leroy Message-ID: <43f736d4-8625-2848-786f-79b902d5c753@csgroup.eu> Date: Thu, 16 Sep 2021 09:23:57 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr-FR Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 16/09/2021 à 09:16, Benjamin Herrenschmidt a écrit : > On Thu, 2021-09-16 at 17:15 +1000, Benjamin Herrenschmidt wrote: >> On Wed, 2021-09-15 at 16:31 +0200, Christophe Leroy wrote: >>> dcbz instruction shouldn't be used on non-cached memory. Using >>> it on non-cached memory can result in alignment exception and >>> implies a heavy handling. >>> >>> Instead of silentely emulating the instruction and resulting in >>> high >>> performance degradation, warn whenever an alignment exception is >>> taken due to dcbz, so that the user is made aware that dcbz >>> instruction has been used unexpectedly. >>> >>> Reported-by: Stan Johnson >>> Cc: Finn Thain >>> Signed-off-by: Christophe Leroy >>> --- >>> arch/powerpc/kernel/align.c | 1 + >>> 1 file changed, 1 insertion(+) >>> >>> diff --git a/arch/powerpc/kernel/align.c >>> b/arch/powerpc/kernel/align.c >>> index bbb4181621dd..adc3a4a9c6e4 100644 >>> --- a/arch/powerpc/kernel/align.c >>> +++ b/arch/powerpc/kernel/align.c >>> @@ -349,6 +349,7 @@ int fix_alignment(struct pt_regs *regs) >>> if (op.type != CACHEOP + DCBZ) >>> return -EINVAL; >>> PPC_WARN_ALIGNMENT(dcbz, regs); >>> + WARN_ON_ONCE(1); >> >> This is heavy handed ... It will be treated as an oops by various >> things uselessly spit out a kernel backtrace. Isn't >> PPC_WARN_ALIGNMENT >> enough ? PPC_WARN_ALIGNMENT() only warns if explicitely activated, I want to catch uses on 'dcbz' on non-cached memory all the time as they are most often the result of using memset() instead of memset_io(). > > Ah I saw your other one about fbdev... Ok what about you do that in a > if (!user_mode(regs)) ? Yes I can do WARN_ON_ONCE(!user_mode(regs)); instead. > > Indeed the kernel should not do that. Does userspace accesses non-cached memory directly ? Christophe