Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp11788836rwb; Fri, 25 Nov 2022 22:35:21 -0800 (PST) X-Google-Smtp-Source: AA0mqf7Ws97wLy+9BKOlbjyUXO39+FqtT3jo9YLiwE3INKoCWaRf7/I557rPeELYorWwT9aXczp+ X-Received: by 2002:a17:906:cec7:b0:7ad:b599:2b8e with SMTP id si7-20020a170906cec700b007adb5992b8emr35034270ejb.52.1669444520872; Fri, 25 Nov 2022 22:35:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669444520; cv=none; d=google.com; s=arc-20160816; b=PfY+v6m8EFS9AOPH31xRCbLbQASUqonTZpL+konKVYsjxbNFmQLqcSCx27JieK207n bvEY1n14xe/OrOG0AbIv76LFNRGDGTxxyDVpQWgEnfdgNzPWjQ/gGWxqW2hKw+GL4i/n N7nH2qLGj1SSZxLF/FRbMYeU3LN7aB9NcBGnrjunIR7RJugSXpjZ9lzq6C6lZHeXa7VD VMJZ6vTQQBcP+WGLsw5kMKRkEEq2ILHDS0GpehPLDogrC0H6cGwuCSJ6ljtxFUOUoGVI SovXnKvHP3EeI/rYiox4HtND5Dm44CgUePW6ILI/tTXC3EtR3MvP+TFKnxjfKWXjkpRR ZI0Q== 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 :message-id:date:subject:cc:to:from:feedback-id:dkim-signature :dkim-signature; bh=/r/5FKS1ZSeQJNg4RdB06WEIq+RLEgzS3SohRH6vLA0=; b=bIDTpxRmFgaHpRmOjNpQDVEkjk/EfFG9R5gLRsIayUNLg2TcHuuYl2FvTmzsrhbeVo fMF5FRr/UOfZh3Mb3waZxCuu8EAApTkd4J88i5E8AVePQtp3EwqCYqptQzRDMMkVOl6D vDO+gsCT70LIcKfDsG4zN38uOkTYIApmoFjjd45eXzFudowAqzN8IgeOzy+DHTvo0ThL nHdEjjGcyZUDYtP3M9OzuHCN3myg77j+KZB3pJpRpQ+dri8gyyyV5Ttav7/maczhvl04 +m0p9CVzJVqeg8GYNFXgZPbwM6rIQCwsKwH55ld6jY5qMmAtYn5iDOT8gQzPB0RxGIY3 9ntg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sholland.org header.s=fm2 header.b=wk+gLi+s; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=AGKRuj4Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sholland.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b10-20020a056402084a00b0046721c5b7e0si5840605edz.511.2022.11.25.22.35.00; Fri, 25 Nov 2022 22:35:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@sholland.org header.s=fm2 header.b=wk+gLi+s; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=AGKRuj4Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sholland.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229841AbiKZGJ1 (ORCPT + 85 others); Sat, 26 Nov 2022 01:09:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229464AbiKZGJZ (ORCPT ); Sat, 26 Nov 2022 01:09:25 -0500 Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 107CC1F9EA for ; Fri, 25 Nov 2022 22:09:24 -0800 (PST) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 9C38B5C00DB; Sat, 26 Nov 2022 01:09:22 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Sat, 26 Nov 2022 01:09:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :message-id:mime-version:reply-to:sender:subject:subject:to:to; s=fm2; t=1669442962; x=1669529362; bh=/r/5FKS1ZSeQJNg4RdB06WEIq +RLEgzS3SohRH6vLA0=; b=wk+gLi+sYjzoWtgoSLf0h9Rpl984GO8qgZR47uvCm drPMur6+dkSFLIjCcoyzpr4Ut+afuKw46R4VbU72TsdkV+1ZyKH3kl8jOSmivzYE C6sRaJpQFsv8Ftci3d6qhwkFrDYe10lIfPet2nimg9MS/7OQmlUDOVXMxcByf2ZU e5D6TxrMBkb+gFAJ3SFmUgo8y9S/LMkLuAm8D5x/3TWQZAtGJkoGTAXgN6qSQCnp yLOHMzumRfAVf0xw5s92WoUoB6prjeH/FBk/G7NrFMGE/F4DBO833YsqsmfqWgks lTV8PXIlwBQ6D+yxaHvXsBuHV+yRuXnef0bn1OCje0omg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:message-id :mime-version:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1669442962; x=1669529362; bh=/r/5FKS1ZSeQJNg4RdB06WEIq+RLEgzS3So hRH6vLA0=; b=AGKRuj4YdIaqoDo9ZkVNaUCyAYqxFHYm1X3Ny79NuQ1fNwFiUg9 RL1n8NqQzeoULAnJcuwzwF8+egi5nA5ZK5ioWyiOfHj/w1byYs7wG45RsnfQ2KIz Vw3y5c2jjHav3KfQN/psvMg+nGTC70NiwxJRH4O6I15+IKhlufiX4a+f3WqlPoo/ 8h/F28LC2cWc4gXTsKl6vaxAv4OHFRuyWkJCqvS/piXJjyU22MpNd9biLAocg8vs 3IeLA/vwL9ae8iTC2chQFS+4DcMwNubRLoBMSugXs4gC67IG/qHa0sYAl+9x4E5n CtI/+HgVec2n6lrQu0oyJAY9zYjVZu7pLyQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrieeigdeklecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffoggfgsedtkeertdertddtnecuhfhrohhmpefurghmuhgvlhcu jfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenucggtffrrg htthgvrhhnpeekveelhfejueelleetvdejvdeffeetgeelheeujeffhefgffefkeehhffh keekgeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hsrghmuhgvlhesshhhohhllhgrnhgurdhorhhg X-ME-Proxy: Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 26 Nov 2022 01:09:21 -0500 (EST) From: Samuel Holland To: Palmer Dabbelt , linux-riscv@lists.infradead.org Cc: Samuel Holland , Heiko Stuebner , Albert Ou , Alexandre Ghiti , Paul Walmsley , linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] riscv: Fix crash during early errata patching Date: Sat, 26 Nov 2022 00:09:19 -0600 Message-Id: <20221126060920.65009-1-samuel@sholland.org> X-Mailer: git-send-email 2.37.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS autolearn=ham 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 The patch function for the T-Head PBMT errata calls __pa_symbol() before relocation. This crashes when CONFIG_DEBUG_VIRTUAL is enabled, because __pa_symbol() forwards to __phys_addr_symbol(), and __phys_addr_symbol() checks against the absolute kernel start/end address. Fix this by checking against the kernel map instead of a symbol address. Fixes: a35707c3d850 ("riscv: add memory-type errata for T-Head") Reviewed-by: Heiko Stuebner Tested-by: Heiko Stuebner Signed-off-by: Samuel Holland --- Changes in v2: - Fix __phys_addr_symbol instead of avoiding it in the errata code arch/riscv/mm/physaddr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/riscv/mm/physaddr.c b/arch/riscv/mm/physaddr.c index 19cf25a74ee2..9b18bda74154 100644 --- a/arch/riscv/mm/physaddr.c +++ b/arch/riscv/mm/physaddr.c @@ -22,7 +22,7 @@ EXPORT_SYMBOL(__virt_to_phys); phys_addr_t __phys_addr_symbol(unsigned long x) { unsigned long kernel_start = kernel_map.virt_addr; - unsigned long kernel_end = (unsigned long)_end; + unsigned long kernel_end = kernel_start + kernel_map.size; /* * Boundary checking aginst the kernel image mapping. -- 2.37.4