Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1012496pxb; Wed, 6 Apr 2022 06:42:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzNbUPcSEbaN/mLHkdWS07paIkd1/JnwMj2pJZPTHVetERBwLLI/ddnIrPkTl4ltUxzyM6 X-Received: by 2002:a17:902:d48b:b0:156:bddf:f06 with SMTP id c11-20020a170902d48b00b00156bddf0f06mr8745512plg.141.1649252555573; Wed, 06 Apr 2022 06:42:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649252555; cv=none; d=google.com; s=arc-20160816; b=Oa/42tYOjKQAUzsyQjef2uHcx6c5TzIn2oArxFMwanDOYDxx7ESqLrRQGXvA+jyDbB AYVFcjmTTO9Hxdn7ThYeB65lErtczaWBDBC8sgDVDB9Z1MA2ufTiN1EElGwJBk5aklqy vIAqhg7jXp6FYolvL6YeK7QVHaUKw7zJpHSwsmv50TWwH7RD+PPYuy4T8kl7bPo0YfYi iW8dhQblsuDm4ARLxJw2AFC/otqYOgSJI/PaoXwsWTRiJleZt1/j33uxsvgCCaYHEpX5 rI8XDeL5nrbJkKwHwnw1Ki8kNlnnpwOKNPEmepIIYUtj3jcktuGAnSZnO/gHtz22+MlI lNPA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8qijnUZr2L//xzYe1Kc/wIhDZyhQAQv5/7YVJ/HEbMs=; b=AXXX0kIWMR73aTb2cX++hemJsxxWYdqpllXkKv0LN+iAU1NpV2+r8/wuJBGzPPqhV8 MZb3msjRWBkfnLF4HF9EYVlInv6HOKFUvXES4YcgpKA30VFbIAOZ9ncUd1oQCzEnaw4t ahvZmjiRK77L1HkxNOe0JEjL1YvYB6E1fSjZ5a8Wn3UZXx22s0grX0u1klsV3tbRkh3B hX+jmril4JTfb/BjYbR4MDxZKdWpCmJJE5HyXwFzHJpAE0Qa9UgqX3F0ejf4EQF11/5x LU3RLKQbpyhZNEMFUoNpry2lcOad6ucNtrqoQkTRPBgvdn/eZyI2rN2MnDDy86RiASS8 NWaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jWcw+k9H; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id z1-20020a170903018100b00156a2cedc79si9293551plg.529.2022.04.06.06.42.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 06:42:35 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jWcw+k9H; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 619734E4D70; Wed, 6 Apr 2022 04:30:04 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1843411AbiDFBkz (ORCPT + 99 others); Tue, 5 Apr 2022 21:40:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349235AbiDEJt2 (ORCPT ); Tue, 5 Apr 2022 05:49:28 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9AD31FA68; Tue, 5 Apr 2022 02:42:21 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 6EAA9B81C14; Tue, 5 Apr 2022 09:42:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B66EEC385A2; Tue, 5 Apr 2022 09:42:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649151739; bh=dDEgLEE+d+dNNd5zKLzfFJYE/4qo9BE4nxHk/OiZzKA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jWcw+k9HsX5NlDbXQ0LBbVSm+1G/OePaROxN9msb21I52a0RN9ck+4HkezQOuDpYF PQSk+X0M0YTMn8bmKqnseEiOnAc4YjYL6NRY+bknkrS7r4Pt3iEUuW2lqtV4OMFXXu qqw8gRjhuB/ep5GBj3YlYj+bwO2ZzzQ6+B4Aw7AQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nageswara R Sastry , Michael Ellerman , Nicholas Piggin , Sasha Levin Subject: [PATCH 5.15 523/913] powerpc/64s: Dont use DSISR for SLB faults Date: Tue, 5 Apr 2022 09:26:25 +0200 Message-Id: <20220405070355.529656117@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michael Ellerman [ Upstream commit d4679ac8ea2e5078704aa1c026db36580cc1bf9a ] Since commit 46ddcb3950a2 ("powerpc/mm: Show if a bad page fault on data is read or write.") we use page_fault_is_write(regs->dsisr) in __bad_page_fault() to determine if the fault is for a read or write, and change the message printed accordingly. But SLB faults, aka Data Segment Interrupts, don't set DSISR (Data Storage Interrupt Status Register) to a useful value. All ISA versions from v2.03 through v3.1 specify that the Data Segment Interrupt sets DSISR "to an undefined value". As far as I can see there's no mention of SLB faults setting DSISR in any BookIV content either. This manifests as accesses that should be a read being incorrectly reported as writes, for example, using the xmon "dump" command: 0:mon> d 0x5deadbeef0000000 5deadbeef0000000 [359526.415354][ C6] BUG: Unable to handle kernel data access on write at 0x5deadbeef0000000 [359526.415611][ C6] Faulting instruction address: 0xc00000000010a300 cpu 0x6: Vector: 380 (Data SLB Access) at [c00000000ffbf400] pc: c00000000010a300: mread+0x90/0x190 If we disassemble the PC, we see a load instruction: 0:mon> di c00000000010a300 c00000000010a300 89490000 lbz r10,0(r9) We can also see in exceptions-64s.S that the data_access_slb block doesn't set IDSISR=1, which means it doesn't load DSISR into pt_regs. So the value we're using to determine if the fault is a read/write is some stale value in pt_regs from a previous page fault. Rework the printing logic to separate the SLB fault case out, and only print read/write in the cases where we can determine it. The result looks like eg: 0:mon> d 0x5deadbeef0000000 5deadbeef0000000 [ 721.779525][ C6] BUG: Unable to handle kernel data access at 0x5deadbeef0000000 [ 721.779697][ C6] Faulting instruction address: 0xc00000000014cbe0 cpu 0x6: Vector: 380 (Data SLB Access) at [c00000000ffbf390] 0:mon> d 0 0000000000000000 [ 742.793242][ C6] BUG: Kernel NULL pointer dereference at 0x00000000 [ 742.793316][ C6] Faulting instruction address: 0xc00000000014cbe0 cpu 0x6: Vector: 380 (Data SLB Access) at [c00000000ffbf390] Fixes: 46ddcb3950a2 ("powerpc/mm: Show if a bad page fault on data is read or write.") Reported-by: Nageswara R Sastry Signed-off-by: Michael Ellerman Reviewed-by: Nicholas Piggin Link: https://lore.kernel.org/r/20220222113449.319193-1-mpe@ellerman.id.au Signed-off-by: Sasha Levin --- arch/powerpc/mm/fault.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c index a8d0ce85d39a..4a15172dfef2 100644 --- a/arch/powerpc/mm/fault.c +++ b/arch/powerpc/mm/fault.c @@ -568,18 +568,24 @@ NOKPROBE_SYMBOL(hash__do_page_fault); static void __bad_page_fault(struct pt_regs *regs, int sig) { int is_write = page_fault_is_write(regs->dsisr); + const char *msg; /* kernel has accessed a bad area */ + if (regs->dar < PAGE_SIZE) + msg = "Kernel NULL pointer dereference"; + else + msg = "Unable to handle kernel data access"; + switch (TRAP(regs)) { case INTERRUPT_DATA_STORAGE: - case INTERRUPT_DATA_SEGMENT: case INTERRUPT_H_DATA_STORAGE: - pr_alert("BUG: %s on %s at 0x%08lx\n", - regs->dar < PAGE_SIZE ? "Kernel NULL pointer dereference" : - "Unable to handle kernel data access", + pr_alert("BUG: %s on %s at 0x%08lx\n", msg, is_write ? "write" : "read", regs->dar); break; + case INTERRUPT_DATA_SEGMENT: + pr_alert("BUG: %s at 0x%08lx\n", msg, regs->dar); + break; case INTERRUPT_INST_STORAGE: case INTERRUPT_INST_SEGMENT: pr_alert("BUG: Unable to handle kernel instruction fetch%s", -- 2.34.1