Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp2028191rwe; Fri, 2 Sep 2022 07:33:10 -0700 (PDT) X-Google-Smtp-Source: AA6agR6bh35TTgP53Hn0fU7ik4xVGpYoQrjwUhMd0dmGsEWzvB1RnDrydMQCPzjE5GUrir0zmA18 X-Received: by 2002:a17:902:ea10:b0:175:c76:1a1 with SMTP id s16-20020a170902ea1000b001750c7601a1mr19570085plg.65.1662129190537; Fri, 02 Sep 2022 07:33:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662129190; cv=none; d=google.com; s=arc-20160816; b=pLwglEEmyBGVm0jCZk4WVu+1MsVlP32nwEKkMc6KlJb5jT8PJpKrL/BaXLuKLnksEQ UYaAJTjFRvLASgE/81UO5arbaZfzc7B5LHEQJHpc5A43mxu4Kys9a7owd++RWGpaP/PX mCsJphCVnzMrrbn+qvwa3XcJKvqhfdxypexQd8xmVWf64DWFkQZNNLowO88U1+0GP0LC Va2KIImua0UUzUur+PVIQhoLxQ/PATkdsTkPqVS/abaFFU+mVNSWsm3KRIMlDXowwBqJ 6Nv7g+WKnUwIVrYgl1ZfSMI2bkfceed9D/ZhNRDd4qRBJPrlj4hlCZQuKrjxZMKdkcLa bKjQ== 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=cTULr32/3TyHhYybWbshtYbDHPWlgwA2niUKYZg3y5c=; b=NpSgU7b9Mm+7ahqzRCOO3rB1KjJuTF6mYZ2Yr2gMXQKy3BBYYyr69rQJLqHY06n8Jp rlJLg2kY84sEycYOAHO2EWjnUsi/Yrv6FzS/lREy6kC2+w7F7VKHv1+f3f6j5dRgLyEP 3A6y46rzdYEtjnQhw2LkiUVFoEoSQP4jZni0Fn4dECBfmFqOnyopcn7ZPBhLPR1UrJAA 8gRsMBu9XegIEfYPsIkwY9h+Zq6TLwCAISGbY3LtwdAjYEE5YVqhI7beYcVd7ikUxw+j mvoWfNxMZLDraBX68LHQU2XgJi/EgbM6LFxJuv792vkGEZ0Eo0tj/j6pUkwCZTrZEzf/ zKXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lhY4v3CO; 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 a71-20020a63904a000000b0042b8d806ec7si1919402pge.694.2022.09.02.07.32.56; Fri, 02 Sep 2022 07:33:10 -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=lhY4v3CO; 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 S236166AbiIBMZI (ORCPT + 99 others); Fri, 2 Sep 2022 08:25:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236318AbiIBMYW (ORCPT ); Fri, 2 Sep 2022 08:24:22 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58C00D3E44; Fri, 2 Sep 2022 05:22:33 -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 1C253620F0; Fri, 2 Sep 2022 12:21:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 10AEFC433D6; Fri, 2 Sep 2022 12:21:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662121315; bh=GRY44WcHqY/SgymLIc9wHIjeXiuJ7rxdOZn+fozOfg8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lhY4v3COGunXWzIwt+UHFFBsy/NnCEEtLKubgObivEfEm76kvjemDxKVjW08RuP2C KVvSBe7X4h3Co3WFaLa1fKJ+l5nI5EkEWaAsxF3QRPXMvNthv8PLNVkqFR2+CNjkIL H5muqMnlYANnVAKMQUke/Vl6btq8g75lEgUfUwp4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Helge Deller Subject: [PATCH 4.14 02/42] parisc: Fix exception handler for fldw and fstw instructions Date: Fri, 2 Sep 2022 14:18:26 +0200 Message-Id: <20220902121358.861391702@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220902121358.773776406@linuxfoundation.org> References: <20220902121358.773776406@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 commit 7ae1f5508d9a33fd58ed3059bd2d569961e3b8bd upstream. The exception handler is broken for unaligned memory acceses with fldw and fstw instructions, because it trashes or uses randomly some other floating point register than the one specified in the instruction word on loads and stores. The instruction "fldw 0(addr),%fr22L" (and the other fldw/fstw instructions) encode the target register (%fr22) in the rightmost 5 bits of the instruction word. The 7th rightmost bit of the instruction word defines if the left or right half of %fr22 should be used. While processing unaligned address accesses, the FR3() define is used to extract the offset into the local floating-point register set. But the calculation in FR3() was buggy, so that for example instead of %fr22, register %fr12 [((22 * 2) & 0x1f) = 12] was used. This bug has been since forever in the parisc kernel and I wonder why it wasn't detected earlier. Interestingly I noticed this bug just because the libime debian package failed to build on *native* hardware, while it successfully built in qemu. This patch corrects the bitshift and masking calculation in FR3(). Signed-off-by: Helge Deller Cc: Signed-off-by: Greg Kroah-Hartman --- arch/parisc/kernel/unaligned.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/parisc/kernel/unaligned.c +++ b/arch/parisc/kernel/unaligned.c @@ -121,7 +121,7 @@ #define R1(i) (((i)>>21)&0x1f) #define R2(i) (((i)>>16)&0x1f) #define R3(i) ((i)&0x1f) -#define FR3(i) ((((i)<<1)&0x1f)|(((i)>>6)&1)) +#define FR3(i) ((((i)&0x1f)<<1)|(((i)>>6)&1)) #define IM(i,n) (((i)>>1&((1<<(n-1))-1))|((i)&1?((0-1L)<<(n-1)):0)) #define IM5_2(i) IM((i)>>16,5) #define IM5_3(i) IM((i),5)