Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6827047rwn; Tue, 13 Sep 2022 09:29:47 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4L4625u26mDQdUC/QdxZdyqwgfQbL/Yhc1j1XXjz0tZMO+ODYMquXVL6vTHtqguzBqo4uj X-Received: by 2002:a17:90b:4c0a:b0:202:54cc:6d5 with SMTP id na10-20020a17090b4c0a00b0020254cc06d5mr94361pjb.121.1663086586908; Tue, 13 Sep 2022 09:29:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663086586; cv=none; d=google.com; s=arc-20160816; b=zgmFA3D3E7ExJi/7k/JN5pbrdT7wj7nnEaRZAwBrqaqIAYEM9aEM00XskucBpX0ovY Zy2CfVmumBmPqmsqRhuolU6z9MO8Iqfs9Qif/0AzJcqOnSm3CepGhNmsiy7y4zGnWmbL la/ysQJFRyDl8QWS0XfWnFf2qHORPwY/31WFcQUfXgS1QgdcJesBMerX7aDJfzkueSNt 7p0NCfvYZG1r8vfSTeohSEbILht3mRBVeno7L6G3WAiwAsjvQVTFCKRQwxDKGD8ATYXb Mqxm+pHBMwa0+YHfwfIvqLVHWdeAqH9k1pqo4mWwiRD4XkcnOlLOuKmsTkL+mk/tY/kq C40A== 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=GDlr9QPoDbqcz2LKSQF8cuPZcq8vosAUWJJtxh+1W7A=; b=tPpp7B0pAwPDaHEglVacgTkJXqkMIQs2y9CzkKCQvnFmiLnu07nXJOIuXbZXFJ1kcH AwXgY4LIdS0ozFb65PPmSzbiI1/NlvDfJg45WvtTcmgcGCG9bX78gtiVUltA3K5fy4iu dqdZh24+E2DE3SFRkar8AgxZvgnX+61a3fTOfWtMsPZKMxUMiK5dFIh+t1ClqQSTzGe6 M9wkKU1TqQWfQ77KCqpeJ3dMc0GQWFAfxLR4z4bI27k6QsTUjKM5+gwcTJSCxYSN3hjP 82LKOVB8MmWaNbNBUfc0AnKzDBzU5DRCD94m+dwmAs5jgXcAZuRCoqbwFCvFAO0+8s1s NRDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mE3wksAZ; 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 n16-20020a170903111000b0016ece04936dsi13725540plh.504.2022.09.13.09.29.33; Tue, 13 Sep 2022 09:29:46 -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=mE3wksAZ; 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 S233697AbiIMOb3 (ORCPT + 99 others); Tue, 13 Sep 2022 10:31:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234050AbiIMO3D (ORCPT ); Tue, 13 Sep 2022 10:29:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1081513E11; Tue, 13 Sep 2022 07:18:28 -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 37477614CB; Tue, 13 Sep 2022 14:16:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50C71C433D6; Tue, 13 Sep 2022 14:16:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1663078615; bh=9BUB6F8qHCVRmkkXwqJ9eg/dFaiKKeYVazMEdqCcvko=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mE3wksAZ3B5ClQBmgaXooVp7CzAvP7xUOdbtZ/RQMyz7Jm1wccbabrfv4FhGcPuBz y1N2fwGXt4P34SqBzupbXFfdwA8RhNlmznOEaJYN0Ibbkt1I3oQsNg2xZsLaaAKi+2 qQU7aXunXiemLNo9HWQ1hc7rrg5iMBtYEN3OPBnU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Helge Deller , Sasha Levin Subject: [PATCH 5.15 017/121] parisc: Add runtime check to prevent PA2.0 kernels on PA1.x machines Date: Tue, 13 Sep 2022 16:03:28 +0200 Message-Id: <20220913140358.082052557@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220913140357.323297659@linuxfoundation.org> References: <20220913140357.323297659@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: Helge Deller [ Upstream commit 591d2108f3abc4db9f9073cae37cf3591fd250d6 ] If a 32-bit kernel was compiled for PA2.0 CPUs, it won't be able to run on machines with PA1.x CPUs. Add a check and bail out early if a PA1.x machine is detected. Signed-off-by: Helge Deller Signed-off-by: Sasha Levin --- arch/parisc/kernel/head.S | 43 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/arch/parisc/kernel/head.S b/arch/parisc/kernel/head.S index aa93d775c34db..598d0938449da 100644 --- a/arch/parisc/kernel/head.S +++ b/arch/parisc/kernel/head.S @@ -22,7 +22,7 @@ #include #include - .level PA_ASM_LEVEL + .level 1.1 __INITDATA ENTRY(boot_args) @@ -69,6 +69,47 @@ $bss_loop: stw,ma %arg2,4(%r1) stw,ma %arg3,4(%r1) +#if !defined(CONFIG_64BIT) && defined(CONFIG_PA20) + /* This 32-bit kernel was compiled for PA2.0 CPUs. Check current CPU + * and halt kernel if we detect a PA1.x CPU. */ + ldi 32,%r10 + mtctl %r10,%cr11 + .level 2.0 + mfctl,w %cr11,%r10 + .level 1.1 + comib,<>,n 0,%r10,$cpu_ok + + load32 PA(msg1),%arg0 + ldi msg1_end-msg1,%arg1 +$iodc_panic: + copy %arg0, %r10 + copy %arg1, %r11 + load32 PA(init_stack),%sp +#define MEM_CONS 0x3A0 + ldw MEM_CONS+32(%r0),%arg0 // HPA + ldi ENTRY_IO_COUT,%arg1 + ldw MEM_CONS+36(%r0),%arg2 // SPA + ldw MEM_CONS+8(%r0),%arg3 // layers + load32 PA(__bss_start),%r1 + stw %r1,-52(%sp) // arg4 + stw %r0,-56(%sp) // arg5 + stw %r10,-60(%sp) // arg6 = ptr to text + stw %r11,-64(%sp) // arg7 = len + stw %r0,-68(%sp) // arg8 + load32 PA(.iodc_panic_ret), %rp + ldw MEM_CONS+40(%r0),%r1 // ENTRY_IODC + bv,n (%r1) +.iodc_panic_ret: + b . /* wait endless with ... */ + or %r10,%r10,%r10 /* qemu idle sleep */ +msg1: .ascii "Can't boot kernel which was built for PA8x00 CPUs on this machine.\r\n" +msg1_end: + +$cpu_ok: +#endif + + .level PA_ASM_LEVEL + /* Initialize startup VM. Just map first 16/32 MB of memory */ load32 PA(swapper_pg_dir),%r4 mtctl %r4,%cr24 /* Initialize kernel root pointer */ -- 2.35.1