Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp3116673pxm; Mon, 28 Feb 2022 12:22:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJw/ev2eT9R6l5g+dF17i9OqZivPNfWihp4bXKO/sca5qZT1ig1zxmjI1zX+q17x2MMHr/HW X-Received: by 2002:a05:6a00:14ce:b0:4ec:aa7a:53c7 with SMTP id w14-20020a056a0014ce00b004ecaa7a53c7mr23413330pfu.62.1646079733513; Mon, 28 Feb 2022 12:22:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646079733; cv=none; d=google.com; s=arc-20160816; b=RLcmPqr/RHThE/ODrkV5o3ID/Gg1ElDacPuUNahrndxSpq9WmuQZO9VxeimEWPFRQ/ AMoqm00+mUi29i6XDkq42cqPqvJxbdF3ORqBjANfxVc0spKH7tn0sEyACsKiozNr8C7R xlISP7EpmrtkhAhhAXW6FYEixPX5zA+npsZLhn3GouyrGt8FqodytCYuXf1I7GzuUo1k tWJ0fu81sSvlHcWKGV9isFT0p35utqIns6vuqWmMGjXjmvYIdXuZmbdMfVxExgaDbpma jc71qsw1BWf4/j4YdfjWQqwwwedUICL6dPbqfRAzQdzQKhNOseLamx5F+LIW14d7IAVx OkRg== 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=KWG9+btmIuoycEqjpPvKEhLNZiSnNeYdzxZkPcfYeS0=; b=ARZFkHlebvp4KK+VLD7+KWJxWzVeLPuoECl5aQ5o5sBTdn1rQmhz3DdgNXoFsJpR85 8ZHy2bh8wprLdq5+oj1RjLwDUiNOlwlm8SIe/UOssZTi3G91U/IvtjqzzEXDK0URyRZv NhbS7nGGZezg0e1C9SneIuG1kUgqE5nUFghtBisxuAsjfibAr5KNOj5gGH8vhxsfaRUQ 9ZL/CfUeM1FD03icu4CZtcqhRVNRg6mfLDLVCRhcgHhxtehzpAxMN59r71pFV8PKUWVm BEBtPGe+l0xFOZZLUVzUnFZS1OMQBPxb4M4zGBrKW/91CFt3vmYn/GYavap146StzHQ2 qIbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ERqK8+92; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id a190-20020a6390c7000000b0037434235a5bsi10177993pge.331.2022.02.28.12.22.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 12:22:13 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ERqK8+92; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 550341C2F4C; Mon, 28 Feb 2022 11:41:39 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237031AbiB1RbH (ORCPT + 99 others); Mon, 28 Feb 2022 12:31:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236622AbiB1R26 (ORCPT ); Mon, 28 Feb 2022 12:28:58 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DC36710F4; Mon, 28 Feb 2022 09:28:08 -0800 (PST) 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 01CCAB815B1; Mon, 28 Feb 2022 17:28:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 535B9C340F0; Mon, 28 Feb 2022 17:28:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069285; bh=6D/k4W2XyKIc8/OLA2hacXN7jTCNa6Cnryitd6XkD18=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ERqK8+92x4h3YC3OhFgPVuCM4wP4RoZcbLp6h6M6EIn/DaCX6WC4ly/TUvBQOOKvP n6HQVhNAgHyfo+wRWQHG/hsvOu8y1Ti7Htt/vfpkr/anKWLkb+gVMIszBMImKzPeKp zXMwdJbpTOkMjAxbdm8JJ809A0cIGhWhcmsr9Lwk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Helge Deller Subject: [PATCH 4.14 03/31] parisc/unaligned: Fix fldd and fstd unaligned handlers on 32-bit kernel Date: Mon, 28 Feb 2022 18:23:59 +0100 Message-Id: <20220228172200.189589587@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172159.515152296@linuxfoundation.org> References: <20220228172159.515152296@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 dd2288f4a020d693360e3e8d72f8b9d9c25f5ef6 upstream. Usually the kernel provides fixup routines to emulate the fldd and fstd floating-point instructions if they load or store 8-byte from/to a not natuarally aligned memory location. On a 32-bit kernel I noticed that those unaligned handlers didn't worked and instead the application got a SEGV. While checking the code I found two problems: First, the OPCODE_FLDD_L and OPCODE_FSTD_L cases were ifdef'ed out by the CONFIG_PA20 option, and as such those weren't built on a pure 32-bit kernel. This is now fixed by moving the CONFIG_PA20 #ifdef to prevent the compilation of OPCODE_LDD_L and OPCODE_FSTD_L only, and handling the fldd and fstd instructions. The second problem are two bugs in the 32-bit inline assembly code, where the wrong registers where used. The calculation of the natural alignment used %2 (vall) instead of %3 (ior), and the first word was stored back to address %1 (valh) instead of %3 (ior). Signed-off-by: Helge Deller Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- arch/parisc/kernel/unaligned.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/arch/parisc/kernel/unaligned.c +++ b/arch/parisc/kernel/unaligned.c @@ -411,7 +411,7 @@ static int emulate_std(struct pt_regs *r __asm__ __volatile__ ( " mtsp %4, %%sr1\n" " zdep %2, 29, 2, %%r19\n" -" dep %%r0, 31, 2, %2\n" +" dep %%r0, 31, 2, %3\n" " mtsar %%r19\n" " zvdepi -2, 32, %%r19\n" "1: ldw 0(%%sr1,%3),%%r20\n" @@ -423,7 +423,7 @@ static int emulate_std(struct pt_regs *r " andcm %%r21, %%r19, %%r21\n" " or %1, %%r20, %1\n" " or %2, %%r21, %2\n" -"3: stw %1,0(%%sr1,%1)\n" +"3: stw %1,0(%%sr1,%3)\n" "4: stw %%r1,4(%%sr1,%3)\n" "5: stw %2,8(%%sr1,%3)\n" " copy %%r0, %0\n" @@ -611,7 +611,6 @@ void handle_unaligned(struct pt_regs *re ret = ERR_NOTHANDLED; /* "undefined", but lets kill them. */ break; } -#ifdef CONFIG_PA20 switch (regs->iir & OPCODE2_MASK) { case OPCODE_FLDD_L: @@ -622,14 +621,15 @@ void handle_unaligned(struct pt_regs *re flop=1; ret = emulate_std(regs, R2(regs->iir),1); break; +#ifdef CONFIG_PA20 case OPCODE_LDD_L: ret = emulate_ldd(regs, R2(regs->iir),0); break; case OPCODE_STD_L: ret = emulate_std(regs, R2(regs->iir),0); break; - } #endif + } switch (regs->iir & OPCODE3_MASK) { case OPCODE_FLDW_L: