From patchwork Mon Mar 20 13:18:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 13181222 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0DE8FC7618D for ; Mon, 20 Mar 2023 13:20:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=m4SFx+2pJHJz9eSDPIZZ7MM8MLdAWFiCInKn5PdcdII=; b=TgpR0sankh3/zU 1p98y82QNH4M2v3ETmTAEtnYxN8d6sLMdT3i+Oyayb5UMhMdDpMtKiXUWfcGu0qlMjA0MH2qEf4Li WHs0sP/Vbqt9eD/yaYv9eAPxm0f1LY5lqSjx7v+NBNywKX/sZDwesEVchdIJx/B48xb2zXHAcJR5Y 4SxY5FOEq77lyvLY//bu0fzV0NQbcy6uFEZkogd9fiUkIxMg5CrSPPJ+/LPiC4yZP+8jVc+edlr4r Bv/F9U74B61x6BbZA2+jzDZKkGNsRYkA7sSxqJs6KDWB+Wj9bWN7DUQ5T0c8DtQfNkpXQBJ/33kKI Ne/+1NgbzqIRxeEIiTIg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1peFPq-0095uZ-0Q; Mon, 20 Mar 2023 13:19:10 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1peFPh-0095pG-2A for linux-arm-kernel@lists.infradead.org; Mon, 20 Mar 2023 13:19:04 +0000 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 4203061245; Mon, 20 Mar 2023 13:19:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 48E26C433EF; Mon, 20 Mar 2023 13:18:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679318341; bh=fUhDyZHeBOcSwPnfZyfTu4hHOdwBeWOtcvESWQvwi/o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WwqD1Ph4rkX6rrIQGT9vQu5nhRh1dRMi73Vccu6thbWqJOjS2u1ECK7IAJ5FpglDL 1OeIEjLEJXwK+Gj2P1/o2ZaQw1FH1hmrH7liwQ/+qB5/0z9evf9LrZGJBQThoq+tw/ KdP3A/hDvxUb1hIdzVMAVmHzodYRrr1VafOQOTAWqNeiSLQ4dMzolhxKJZlUjimiCd fosR8QMY2z0i+zhQySQMU+XwkV+84ndniUY8bREARh5toTvDsawbUaGXyRSJ5wY+j7 ya8p0Yf15IwvL7ACCFHpwWOlX5Jw5IZfHJuAYuPpek1Q+drgH9xvmF0VUHXpeCnB80 mOdZXHCqtFTag== From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux@armlinux.org.uk Cc: Ard Biesheuvel , Frederic Weisbecker , Guenter Roeck , Peter Zijlstra , Linus Walleij , Arnd Bergmann , stable@vger.kernel.org Subject: [PATCH v4 04/12] ARM: entry: Fix iWMMXT TIF flag handling Date: Mon, 20 Mar 2023 14:18:37 +0100 Message-Id: <20230320131845.3138015-5-ardb@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230320131845.3138015-1-ardb@kernel.org> References: <20230320131845.3138015-1-ardb@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1993; i=ardb@kernel.org; h=from:subject; bh=fUhDyZHeBOcSwPnfZyfTu4hHOdwBeWOtcvESWQvwi/o=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JIUUiVvN8tNzp6vicP0G/r6z68jNt3w2vCTOk34XF5l2I9 5DysNLoKGVhEONgkBVTZBGY/ffdztMTpWqdZ8nCzGFlAhnCwMUpABMp4mL4H7Ld8NTUzsoFOxI6 qkIm5Cw90xq8vFZa61cyo9DtD5V76xn+KcTrrjMUeM2595d1Yqf4bZv363Z3ebLb7PLnX2Azfe8 dDgA= X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230320_061901_799431_1F03426E X-CRM114-Status: GOOD ( 16.78 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The conditional MOVS instruction that appears to have been added to test for the TIF_USING_IWMMXT thread_info flag only sets the N and Z condition flags and register R7, none of which are referenced in the subsequent code. This means that the instruction does nothing, which means that we might misidentify faulting FPE instructions as iWMMXT instructions on kernels that were built to support both. This seems to have been part of the original submission of the code, and so this has never worked as intended, and nobody ever noticed, and so we might decide to just leave this as-is. However, with the ongoing move towards multiplatform kernels, the issue becomes more likely to manifest, and so it is better to fix it. So check whether we are dealing with an undef exception regarding coprocessor index #0 or #1, and if so, load the thread_info flag and only dispatch it as a iWMMXT trap if the flag is set. Cc: # v2.6.9+ Signed-off-by: Ard Biesheuvel Reviewed-by: Linus Walleij --- arch/arm/kernel/entry-armv.S | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S index c39303e5c23470e6..c5d2f07994fb0d87 100644 --- a/arch/arm/kernel/entry-armv.S +++ b/arch/arm/kernel/entry-armv.S @@ -606,10 +606,11 @@ call_fpe: strb r7, [r6, #TI_USED_CP] @ set appropriate used_cp[] #ifdef CONFIG_IWMMXT @ Test if we need to give access to iWMMXt coprocessors - ldr r5, [r10, #TI_FLAGS] - rsbs r7, r8, #(1 << 8) @ CP 0 or 1 only - movscs r7, r5, lsr #(TIF_USING_IWMMXT + 1) - bcs iwmmxt_task_enable + tst r8, #0xe << 8 @ CP 0 or 1? + ldreq r5, [r10, #TI_FLAGS] @ if so, load thread_info flags + andeq r5, r5, #1 << TIF_USING_IWMMXT @ isolate TIF_USING_IWMMXT flag + teqeq r5, #1 << TIF_USING_IWMMXT @ check whether it is set + beq iwmmxt_task_enable @ branch if set #endif ARM( add pc, pc, r8, lsr #6 ) THUMB( lsr r8, r8, #6 )