From mboxrd@z Thu Jan 1 00:00:00 1970 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 F1A2BC7618D for ; Mon, 20 Mar 2023 13:20:42 +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=7ed8rY7wtJcodwTo0COTJWivCCdHZsr1KRkxQienkXc=; b=0j5sFHFotUXOvD H3RusoDpb8SbRyNxPshR2QogIFIT9VXklYQurYuLBj+XZ2oH4NtjFt7GWM2w/365XGM+QTxqNx0k4 13W/qcbTXgkdY64mRq/11GjYcd5qQW15ncVQm5VqIsNpQoGtgMBcIxKYR3DuNfD0nwt59Y7v0a+FO HdVxkmrdoXrwmHMBTG306yWeWwXyhLH4q9MS8QeLVl5QplFrTqpCckArU0Kcw4/K/7OovePE6qI8K ix+mdtKxIdolCISkAL62JZWwDkc8q7cC2/gaMIxzXFuOrke0nmRYKfDthEZGaBE10FFNWe+7YK3FI xN0XRtEIgfIO2snft5XA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1peFQT-0096IO-06; Mon, 20 Mar 2023 13:19:49 +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 1peFPw-0095yk-1a for linux-arm-kernel@lists.infradead.org; Mon, 20 Mar 2023 13:19:19 +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 0281D61243; Mon, 20 Mar 2023 13:19:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BEF78C433EF; Mon, 20 Mar 2023 13:19:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679318355; bh=k4dFUg3r+KbkZHUNtCveFJ8cU6yD7O/BaCovCN/GtGs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TrvCHEcEoCLbv7zboxtYTifC32Y73WzYCn/aKaL6QFxylfUCXWVKqb/kWfFc8+QNS hHFTmHMXm8gXt36WF65E0HWTV4nZyGGqVY2MUDBvL537TzcAELyY27yvEwlOi+lhbn i9MulJzh7PwG/1+xeQqwAonkzENde6KbVGL5AXkZykKpWM0bK2lDTdZ69WvH6tJ6pR JFH7z5c9DMuMnI+VtS7Ck8isCU+KSNmeS8n1RhOpnD2eMa0seKYm8tbyW+n5M6FokL v8R1aem7ZNEZkn2TGzyeOQ5cokIYcwJQZN1/nCj/3kg5y4bCoIFh1ImCHBLy/QJnVm RsoadJ6zLRBpQ== 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 Subject: [PATCH v4 11/12] ARM: iwmmxt: Use undef hook to enable coprocessor for task Date: Mon, 20 Mar 2023 14:18:44 +0100 Message-Id: <20230320131845.3138015-12-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=3100; i=ardb@kernel.org; h=from:subject; bh=k4dFUg3r+KbkZHUNtCveFJ8cU6yD7O/BaCovCN/GtGs=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JIUUi1li+9KjSAr2C+gmvf0oaBv39tX/KrKdq36atP5hjk tH21Wt9RykLgxgHg6yYIovA7L/vdp6eKFXrPEsWZg4rE8gQBi5OAZjIWQeG/+lpizNrg8TzHb+t O24s9mrV5FOLn14McfjPtzvlCJf7TClGhnt7HF3V5m1vXS1540+k6xP7lbMvzyhS/HWiycLyGmN wHQcA 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_061916_615128_92A52FAE X-CRM114-Status: GOOD ( 16.04 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Define a undef hook to deal with undef exceptions triggered by iwmmxt instructions that were issued with the coprocessor disabled. This removes the dependency on the coprocessor dispatch code in entry-armv.S, which will be made NWFPE-only in a subsequent patch. Signed-off-by: Ard Biesheuvel --- arch/arm/include/asm/thread_info.h | 16 ++++++++++++++++ arch/arm/kernel/iwmmxt.S | 9 +++++++++ arch/arm/kernel/pj4-cp0.c | 1 + arch/arm/kernel/xscale-cp0.c | 1 + 4 files changed, 27 insertions(+) diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h index 85c5f1e02ebf83ca..943ffcf069d29cf4 100644 --- a/arch/arm/include/asm/thread_info.h +++ b/arch/arm/include/asm/thread_info.h @@ -40,6 +40,7 @@ struct task_struct; DECLARE_PER_CPU(struct task_struct *, __entry_task); #include +#include struct cpu_context_save { __u32 r4; @@ -104,6 +105,21 @@ extern void iwmmxt_task_restore(struct thread_info *, void *); extern void iwmmxt_task_release(struct thread_info *); extern void iwmmxt_task_switch(struct thread_info *); +extern int iwmmxt_undef_handler(struct pt_regs *, u32); + +static inline void register_iwmmxt_undef_handler(void) +{ + static struct undef_hook iwmmxt_undef_hook = { + .instr_mask = 0x0c000e00, + .instr_val = 0x0c000000, + .cpsr_mask = MODE_MASK | PSR_T_BIT, + .cpsr_val = USR_MODE, + .fn = iwmmxt_undef_handler, + }; + + register_undef_hook(&iwmmxt_undef_hook); +} + extern void vfp_sync_hwstate(struct thread_info *); extern void vfp_flush_hwstate(struct thread_info *); diff --git a/arch/arm/kernel/iwmmxt.S b/arch/arm/kernel/iwmmxt.S index d2b4ac06e4ed8c67..f8ea2c0ee19bd3d7 100644 --- a/arch/arm/kernel/iwmmxt.S +++ b/arch/arm/kernel/iwmmxt.S @@ -58,6 +58,15 @@ .text .arm +ENTRY(iwmmxt_undef_handler) + push {r9, r10, lr} + get_thread_info r10 + mov r9, pc + b iwmmxt_task_enable + mov r0, #0 + pop {r9, r10, pc} +ENDPROC(iwmmxt_undef_handler) + /* * Lazy switching of Concan coprocessor context * diff --git a/arch/arm/kernel/pj4-cp0.c b/arch/arm/kernel/pj4-cp0.c index 1d1fb22f44f37e3b..4bca8098c4ff5583 100644 --- a/arch/arm/kernel/pj4-cp0.c +++ b/arch/arm/kernel/pj4-cp0.c @@ -126,6 +126,7 @@ static int __init pj4_cp0_init(void) pr_info("PJ4 iWMMXt v%d coprocessor enabled.\n", vers); elf_hwcap |= HWCAP_IWMMXT; thread_register_notifier(&iwmmxt_notifier_block); + register_iwmmxt_undef_handler(); #endif return 0; diff --git a/arch/arm/kernel/xscale-cp0.c b/arch/arm/kernel/xscale-cp0.c index ed4f6e77616da1c2..00d00d3aae972d1e 100644 --- a/arch/arm/kernel/xscale-cp0.c +++ b/arch/arm/kernel/xscale-cp0.c @@ -166,6 +166,7 @@ static int __init xscale_cp0_init(void) pr_info("XScale iWMMXt coprocessor detected.\n"); elf_hwcap |= HWCAP_IWMMXT; thread_register_notifier(&iwmmxt_notifier_block); + register_iwmmxt_undef_handler(); #endif } else { pr_info("XScale DSP coprocessor detected.\n"); -- 2.39.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel