Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3025925rwb; Mon, 15 Aug 2022 16:23:58 -0700 (PDT) X-Google-Smtp-Source: AA6agR5+jJujkl0mjNA9ZSnEQD8bzKbPWiCqXzS3Sn3eEsefJKc5vhLodAwJFzHVnSy/XfzTgiv9 X-Received: by 2002:a17:906:93f0:b0:730:6b07:102d with SMTP id yl16-20020a17090693f000b007306b07102dmr11833681ejb.237.1660605837966; Mon, 15 Aug 2022 16:23:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660605837; cv=none; d=google.com; s=arc-20160816; b=NkT1WNiCQ24MXLhTCswJD//PPsYFLzJe2+PFdehfehJF0GsAAYWSm0JL92tsZ83uZr jo3XuhlaJDThcs6m9LbWrkMpVYJLk45EMvxUKsLHCNXuBy2ko9MBZbksKhMD56QcvL1P so9XNoRReUAutWTUuzdYIX1auYHPTJ/AL/u0EaLkUaOBrWvyzT8cGy6YHlt0jttg3xpD oAU7wC9ehWWQfHFaai74ydr2xN3VN5VycZQI4fEiLOocebmbAwyOT9vEhfLcmG5AYrtv Vs6zNe/tMon6CO7ivjkpchtwOjwgPVKh7PNp+DvEIB1sav1OaMDlOGu2UnnHEc6MsVuP z9DQ== 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=ZVUXIe66G8JWQBeFjdXJEMg5ekAz/h4ShTvCth4JkZs=; b=JIMv5zpvwybHd1+gc+RwqdZHruUgXOkzdq/LtA0tiy2hSua/NCg7veITSEv6fG6nOq H8PMl2kgIcUwUMWZUsqT+Rm1J47mzqI53CnFFWqNS4ay8jdIcl0wpio7t9n0EZeYwV0g xOqAfGTxZVKJxjbmHVgfUAUbErMl0cMcfL+QeFNvgXEsmefJ60O0qGKw3AeDrsOP9osa GPZCbe+Se06zycrHJa9Nbo+4PYiBOei8c0KrBQcWjYZYCIj7Iq40YttejcnU+3Z0nzrf KlmsFme1Hijz/jpGFTtUX5Er97IC1yRK9wxQ+UcBpPWvLYdvMolQoQ7CwfVEbEwOlhb0 fxyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tyshf22h; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cs9-20020a170906dc8900b00730c36d50b3si9597435ejc.355.2022.08.15.16.23.32; Mon, 15 Aug 2022 16:23:57 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=tyshf22h; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352057AbiHOWwh (ORCPT + 99 others); Mon, 15 Aug 2022 18:52:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352131AbiHOWu5 (ORCPT ); Mon, 15 Aug 2022 18:50:57 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D1BD13790B; Mon, 15 Aug 2022 12:54:03 -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 AB00FB80EB1; Mon, 15 Aug 2022 19:54:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D60C7C433C1; Mon, 15 Aug 2022 19:53:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660593240; bh=+5i3Ku8ynmuTRvV2CSEcO5qjFU81rtcPqBZQ8aw0a6o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tyshf22hQDUt7az4ejbPceFhmkoTyCGb+ibG+er91cwT9qEorcX2gyimiD4SzVlLx NtjI6PzVQlpaqIYPZK6daVYfEMUThzmycwLHeByHiysSYRKkOc8jEryCo9Kbtml3Ej 6uyBp6ENqiN8ANXiUmP7Ryd2FMTrqPmLzAzUhUQI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Erhard Furtner , Christophe Leroy , Michael Ellerman , Sasha Levin Subject: [PATCH 5.18 0916/1095] powerpc/32s: Fix boot failure with KASAN + SMP + JUMP_LABEL_FEATURE_CHECK_DEBUG Date: Mon, 15 Aug 2022 20:05:15 +0200 Message-Id: <20220815180507.174163072@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Christophe Leroy [ Upstream commit 6042a1652d643d1d34fa89bb314cb102960c0800 ] Since commit 4291d085b0b0 ("powerpc/32s: Make pte_update() non atomic on 603 core"), pte_update() has been using mmu_has_feature(MMU_FTR_HPTE_TABLE) to avoid a useless atomic operation on 603 cores. When kasan_early_init() sets up the early zero shadow, it uses __set_pte_at(). On book3s/32, __set_pte_at() calls pte_update() when CONFIG_SMP is selected in order to ensure the preservation of _PAGE_HASHPTE in case of concurrent update of the PTE. But that's too early for mmu_has_feature(), so when CONFIG_JUMP_LABEL_FEATURE_CHECK_DEBUG is selected, mmu_has_feature() calls printk(). That's too early to call printk() because KASAN early zero shadow page is not set up yet. It leads to a deadlock. However, when kasan_early_init() is called, there is only one CPU running and no risk of concurrent PTE update. So __set_pte_at() can be called with the 'percpu' flag. With that flag set, the PTE is written directly instead of being written via pte_update(). Fixes: 4291d085b0b0 ("powerpc/32s: Make pte_update() non atomic on 603 core") Reported-by: Erhard Furtner Signed-off-by: Christophe Leroy Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/2ee707512b8b212b079b877f4ceb525a1606a3fb.1656655567.git.christophe.leroy@csgroup.eu Signed-off-by: Sasha Levin --- arch/powerpc/mm/kasan/kasan_init_32.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/mm/kasan/kasan_init_32.c b/arch/powerpc/mm/kasan/kasan_init_32.c index f3e4d069e0ba..a70828a6d935 100644 --- a/arch/powerpc/mm/kasan/kasan_init_32.c +++ b/arch/powerpc/mm/kasan/kasan_init_32.c @@ -25,7 +25,7 @@ static void __init kasan_populate_pte(pte_t *ptep, pgprot_t prot) int i; for (i = 0; i < PTRS_PER_PTE; i++, ptep++) - __set_pte_at(&init_mm, va, ptep, pfn_pte(PHYS_PFN(pa), prot), 0); + __set_pte_at(&init_mm, va, ptep, pfn_pte(PHYS_PFN(pa), prot), 1); } int __init kasan_init_shadow_page_tables(unsigned long k_start, unsigned long k_end) -- 2.35.1