Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp4485181rwe; Tue, 30 Aug 2022 10:55:44 -0700 (PDT) X-Google-Smtp-Source: AA6agR42F+mRRlLXfFK02BnW2VZFuhTk9d/+lBhElkU2FvrVbEHlbHqURyFruBfHDJCGt4bb4Th6 X-Received: by 2002:a05:6402:2949:b0:445:dc8d:44d with SMTP id ed9-20020a056402294900b00445dc8d044dmr21595981edb.60.1661882143959; Tue, 30 Aug 2022 10:55:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661882143; cv=none; d=google.com; s=arc-20160816; b=r0VFor+5PTBhbcRyj8+DFYqDRz9sEKyM1mzVb9AcgK2UGlOABaplCiqxyrgh7Ozo6+ 9QdrpPardZfvtwTvVJ133dw4HjjiJ1LLl+DWR1ilkFISbdYUqlt96MfiINYsLJyhxqlK vVfBUO4uCKBnAr+O2krpz7sMZdwOtoaOKzp4Fl2K5wax5g/EZQmK0oc6D+g+2aWmOQrX gYBKidUlX9DJBazZXWNgN8ZjBQHD6VqHBWRge5+EAgoCZs+KZC9ilixJFjCCST9pYvfs FjLm7M5QRmlrGmne1pMfsL5r7jZEkPQCemXi87VBGM1hBuarAOfJ+73G5fUB9u7thIlS Ssmg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZlBZvhJHiIFd1lYyaJ19fXO9hXSj0gq/xzHduj+CSEs=; b=lTsauB+xI2glQvJCLH5Za6Y3nvvKBnRpUvzC0VR/wcqNJbI7/0PFNGg3CRRxNTmpJ3 RjIn8EDrCefwKrHpf2lA2gt5FlcA+yoTFEPXsd+CrN6JLmtnebV660AGsYb99YOhdKAZ Kx3dMSe9U4R0b3hOSA3RAFoXZspTH3SWT+VtZXjt1X3e+tPab90MIsdmg+SpEfeFrSJf TThqBX3qob6K2Z6U/mx2cWeUd/7+83IhIwF4VkjsUfkICg3SC2jzA01UOyuy3w9ydxOS fSkTSwCrKXdnHX5SBYgvl1PqPYbhycTOeMrxn6GOhqz/bzpTOXTytqZSeYpobRi9mpIb /jOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RfqsWsMZ; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xc6-20020a170907074600b0072b13473584si8453346ejb.918.2022.08.30.10.55.18; Tue, 30 Aug 2022 10:55:43 -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=@kernel.org header.s=k20201202 header.b=RfqsWsMZ; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231312AbiH3RVS (ORCPT + 99 others); Tue, 30 Aug 2022 13:21:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231279AbiH3RUj (ORCPT ); Tue, 30 Aug 2022 13:20:39 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D13E24BF0; Tue, 30 Aug 2022 10:19:56 -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 EA6216178B; Tue, 30 Aug 2022 17:19:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 89F08C433B5; Tue, 30 Aug 2022 17:19:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661879994; bh=y3Y5g5RO47iod1MXAA3F9GaMjTHJamxs9vmHWmTV2mc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RfqsWsMZ1MkWHTzcfo/zTbcFaYV7B3BjqJM/xvpPczCj6RXo4VmfxfZa8SnhkcN70 fOMjZ6V5p3aOn3ApQGBGgCIzt9n6CsTjkDAYYVbeKY2c2Wt97roN+Bd36tLy13GcEO LDb5XWAYqT8yxocVbjpi1xTDOs6nxxOt3xBfztIxGSgrAO8X7fXCO/U5S51fMLHFrT +mvzI5xaSVSFcIxlX3HIRpNCaVcKjwdWU/yvbazJPex7zUEp3khKmFi46//4BxPbcw 6MkM/lnxfA6Y4hT7sXJALiqo3ugRrl36uCqzQSIAvdr3oZGc1kfFtOv3vbBEgE8z2x ORVRE5kYfcDXA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Helge Deller , Sasha Levin , James.Bottomley@HansenPartnership.com, svens@stackframe.org, linux-parisc@vger.kernel.org Subject: [PATCH AUTOSEL 5.19 17/33] parisc: Add runtime check to prevent PA2.0 kernels on PA1.x machines Date: Tue, 30 Aug 2022 13:18:08 -0400 Message-Id: <20220830171825.580603-17-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220830171825.580603-1-sashal@kernel.org> References: <20220830171825.580603-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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 e0a9e96576221..fd15fd4bbb61b 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) @@ -70,6 +70,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