Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp126462rdb; Thu, 21 Dec 2023 04:59:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IHRu45b0i8O26BbReZWsACWnV5Uu3Oea1bMm3reypw7CDtYcy+7ILXn6EqWmBJY/Mr9s0qG X-Received: by 2002:a17:90b:603:b0:28b:ce4a:324a with SMTP id gb3-20020a17090b060300b0028bce4a324amr1685828pjb.36.1703163573359; Thu, 21 Dec 2023 04:59:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703163573; cv=none; d=google.com; s=arc-20160816; b=P7HzDra2Q7uWg420oc7N2EAWW07f/0cVpgQA+cWbMYQEx/ohB/L4gjZiv3BtBD6NYY F/FL1LlDTmXZcp7NroNk0EPy/35q1lfetMSBScpmo9jNmSqffbCYhJM4S9EyB2JCSZBi CPoGHqGqqehYvCHwy8QR7dtTv/I5EJFNj+4Zp4ajXgFVIIOQqvWsWzMrEosjrjL/NATo CCkblz4NTNs1lPlu0KydQSq5hN3b+ZTK0V82wp8DU2/FnxEwjeNknjn2+Z2V52jaDrOv o4f21gvZVyQ1fLn0SMUJP/Lt7/5aUPOLrREdrCYpGurwtYfSJFpfUKOemwi3zNPLLoY7 dsAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:to:from; bh=mO0KKZJi6E11aVYU7qdXBu7ja7AJGLAfs1oA1+6FMLo=; fh=lyTQ3mSccWAGqVy84hZ+9QHSygd0HcRn5/BYt4nJ6Xg=; b=nQdFrsl/1uqEeAR7Bio2hrTBi5Wy9A7kFlICnb3XDC33hnwBZR5EjrSDtdqPKWCoDV qtXDstwcOrx7A2jO6+sbMqztvshBdd0bDnk/oA1GL4Q5FdDcSFeoTLz8+IN+MauidaTK L3lk0m0AGf8QPcbyuxZU6xcD2sMyhoOHmDkbarJ9eUIP+bnNZkjpIK5wmS2Li+iA8biD kg96vUqTy75uzs4mmhKjmQfzmyA4eodLgkGZN9zaAbQkQJCd4e7qtFJeX9NODAthpwAc BswBz6mWgLELALtc9QZnTwJfEzVHdS7cnvfBt+eIj/n8yhS1tV9aGETFGStUL4sQs7pK ZRQg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-8406-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8406-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id gl19-20020a17090b121300b0028a30507ff6si1651567pjb.150.2023.12.21.04.59.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 04:59:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8406-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-8406-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8406-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 2C59028320F for ; Thu, 21 Dec 2023 12:59:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1F66878E75; Thu, 21 Dec 2023 12:54:12 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E80F078E69; Thu, 21 Dec 2023 12:54:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=alpha.franken.de Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=alpha.franken.de Received: from hutton.arch.nue2.suse.org (unknown [10.168.144.140]) by smtp-out1.suse.de (Postfix) with ESMTP id F40F421E19; Thu, 21 Dec 2023 12:54:04 +0000 (UTC) From: Thomas Bogendoerfer To: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] MIPS: Allow vectored interrupt handler to reside everywhere for 64bit Date: Thu, 21 Dec 2023 13:54:03 +0100 Message-Id: <20231221125405.229100-1-tsbogend@alpha.franken.de> X-Mailer: git-send-email 2.35.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 4.90 X-Spamd-Result: default: False [4.90 / 50.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; BROKEN_CONTENT_TYPE(1.50)[]; RCPT_COUNT_TWO(0.00)[2]; MID_CONTAINS_FROM(1.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_ZERO(0.00)[0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+] Authentication-Results: smtp-out1.suse.de; none X-Spam-Level: **** X-Spam-Flag: NO Setting up vector interrupts worked only with handlers, which resided in CKSEG0 space. This limits the kernel placement for 64bit platforms. By patching in the offset into vi_handlers[] instead of the full handler address, the vectored exception handler can load the address by itself and jump to it. Signed-off-by: Thomas Bogendoerfer --- arch/mips/kernel/genex.S | 8 ++++---- arch/mips/kernel/traps.c | 9 +++------ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/arch/mips/kernel/genex.S b/arch/mips/kernel/genex.S index b6de8e88c1bd..a572ce36a24f 100644 --- a/arch/mips/kernel/genex.S +++ b/arch/mips/kernel/genex.S @@ -272,18 +272,17 @@ NESTED(except_vec_vi, 0, sp) .set push .set noreorder PTR_LA v1, except_vec_vi_handler -FEXPORT(except_vec_vi_lui) - lui v0, 0 /* Patched */ jr v1 FEXPORT(except_vec_vi_ori) - ori v0, 0 /* Patched */ + ori v0, zero, 0 /* Offset in vi_handlers[] */ .set pop END(except_vec_vi) EXPORT(except_vec_vi_end) /* * Common Vectored Interrupt code - * Complete the register saves and invoke the handler which is passed in $v0 + * Complete the register saves and invoke the handler, $v0 holds + * offset into vi_handlers[] */ NESTED(except_vec_vi_handler, 0, sp) SAVE_TEMP @@ -331,6 +330,7 @@ NESTED(except_vec_vi_handler, 0, sp) /* Save task's sp on IRQ stack so that unwinding can follow it */ LONG_S s1, 0(sp) 2: + PTR_L v0, vi_handlers(v0) jalr v0 /* Restore sp */ diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c index 246c6a6b0261..d90b18908692 100644 --- a/arch/mips/kernel/traps.c +++ b/arch/mips/kernel/traps.c @@ -2091,16 +2091,14 @@ static void *set_vi_srs_handler(int n, vi_handler_t addr, int srs) * If no shadow set is selected then use the default handler * that does normal register saving and standard interrupt exit */ - extern const u8 except_vec_vi[], except_vec_vi_lui[]; + extern const u8 except_vec_vi[]; extern const u8 except_vec_vi_ori[], except_vec_vi_end[]; extern const u8 rollback_except_vec_vi[]; const u8 *vec_start = using_rollback_handler() ? rollback_except_vec_vi : except_vec_vi; #if defined(CONFIG_CPU_MICROMIPS) || defined(CONFIG_CPU_BIG_ENDIAN) - const int lui_offset = except_vec_vi_lui - vec_start + 2; const int ori_offset = except_vec_vi_ori - vec_start + 2; #else - const int lui_offset = except_vec_vi_lui - vec_start; const int ori_offset = except_vec_vi_ori - vec_start; #endif const int handler_len = except_vec_vi_end - vec_start; @@ -2119,10 +2117,9 @@ static void *set_vi_srs_handler(int n, vi_handler_t addr, int srs) #else handler_len); #endif - h = (u16 *)(b + lui_offset); - *h = (handler >> 16) & 0xffff; + /* insert offset into vi_handlers[] */ h = (u16 *)(b + ori_offset); - *h = (handler & 0xffff); + *h = n * sizeof(handler); local_flush_icache_range((unsigned long)b, (unsigned long)(b+handler_len)); } -- 2.35.3