Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3261693rwb; Mon, 15 Aug 2022 22:37:03 -0700 (PDT) X-Google-Smtp-Source: AA6agR6QMz9CnWAHMbx08/3l3+RFbrB1d//NBXSRb0dCoRM/mV4j1VgErEcZGYR7sIlPcedY/Rn5 X-Received: by 2002:a17:906:8441:b0:730:7bd1:17ca with SMTP id e1-20020a170906844100b007307bd117camr12700359ejy.229.1660628223271; Mon, 15 Aug 2022 22:37:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660628223; cv=none; d=google.com; s=arc-20160816; b=Uzb3/MpKuQo7Z4hQihrUqChPbYaWpMeDRvA3qxfYqOKPePJpcuIM8sZqSDIWln+16p LuJdqY2TIakwWyceqbnwsEe1vmbHJgHmGTy3ex1IJOBW6uVHf6vPaoP7uIGTy4ZqV4fP ewFXtRt5/JzhnAoYpsI/NxoeGA5PP9kUvYbIxMroOP4X6Fq0rE/9hRTqIY5QpVBTQ3ji UTR3rXB3Mk13nbGdJHDEWa/2KRftSLtWzd+fN7jcm9UQmNS5YHfza6zfb6VudZUOV4AY 5KHGHf7gUPs2lGVv4kMqgFdRPeSZKW4LO4Q+tnLE5KvQEuR4btEoo1o4cgfNOJfcENw3 lOxg== 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=dXTns3N1qopIvZ6fUIOXZcj6ydn2LDQ2ZedWuoCLTcI=; b=MgzGwVBCDxXkyWCsMNdDLxTaKpUdSENeAaVKlFz/5y0drwJwnco3zFMHM/4yMY5U6L 0LiMiFGq2W/ISY5euZ4B/rqqtjAh+EGbSG0tAuAVHkFiyRco3jPgVn/5YVB3kd6nMG1i e89FA0ZjXKvAfJD+cSW4Oq23/Ssn2fWakr0BWRdJD0efB0HMoo2S4SbTYTkNXkbZnfQC 8H//x8BNDWWJ655Xw2SUsGPJVRn4RPwUdWB4VfH21oEiLkblkDzYex7UtSNSH5LBxv1B WLdgcfK/b9ELkvxV8oWpPmFBZBlzBQLqGwMofdd/IifT9QgpAAzrZRN3nkaxBDE5UKik xNZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=J8toRwwj; 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 dz10-20020a0564021d4a00b0043be95ef714si10719839edb.437.2022.08.15.22.36.37; Mon, 15 Aug 2022 22:37:03 -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=J8toRwwj; 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 S231574AbiHPEtt (ORCPT + 99 others); Tue, 16 Aug 2022 00:49:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232971AbiHPEqR (ORCPT ); Tue, 16 Aug 2022 00:46:17 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 850B82FE; Mon, 15 Aug 2022 13:42:49 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 20FA261234; Mon, 15 Aug 2022 20:42:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 078AFC433C1; Mon, 15 Aug 2022 20:42:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660596168; bh=yUfDoCYRdDXgi8Xlcc0Uym4eRpGA9rhbv20ep51oHow=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J8toRwwjOqAA+kixmaZtr03OrIhEh3iDn3lecNvRFtqr1IL1c3WVVL9dyJQjRFEjY mop8kFYuXm9Z4LBOWvfO6iQsjzfkeNYeRsNmNpCa4IYRuPLOL/ega9SCGxD52Lavmn tZaY6YFJBGPaahLRITgCQAdc95Pof1agBipD1aE0= 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.19 0994/1157] powerpc/32s: Fix boot failure with KASAN + SMP + JUMP_LABEL_FEATURE_CHECK_DEBUG Date: Mon, 15 Aug 2022 20:05:50 +0200 Message-Id: <20220815180519.482001214@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@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/init_32.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/mm/kasan/init_32.c b/arch/powerpc/mm/kasan/init_32.c index f3e4d069e0ba..a70828a6d935 100644 --- a/arch/powerpc/mm/kasan/init_32.c +++ b/arch/powerpc/mm/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