From patchwork Fri Dec 8 16:12:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregory CLEMENT X-Patchwork-Id: 175896 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp5558331vqy; Fri, 8 Dec 2023 08:13:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IED6vB3QMIY6tuwltDGDb48PkQEcg/AC5KkG93nV9oruUOe7JSZzLN6t9AdysDXLSX/q+2V X-Received: by 2002:a17:90b:4ac7:b0:286:6cc1:5fd1 with SMTP id mh7-20020a17090b4ac700b002866cc15fd1mr294078pjb.84.1702052002058; Fri, 08 Dec 2023 08:13:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702052002; cv=none; d=google.com; s=arc-20160816; b=HBFiEz5pX9EQVf2yrlPD8t7vlQdL5AahYhbzxA0V29bf2jS/07pZGky2hpriMlCC1P OhfXABznnjXoOnVC9u23r5qugQ6t5cZ3skqKBZz4dIu+YdFwbDozl09yw7FxFRaERYYS Omn7uHxqOfFDQHFAIUA5GqGs5GJuQ6hYBD1h1va8Ga2TgSbXY8w14VHChwVbIsWtK55g lTt/G2q8uYKNFjBljiDw9v8HTJizPveC5fe/T2Z2MTMhlJLCPNyyLV2H77eyH0G5su1T UEd9vw/Ghg9gUxerkOOd9RFalW64cEMUUHnsCn8qK+Y9anybf0sQdaFCFEDYRz2IVlKq t4kg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=AagYqurduAd05kHY0ow9kHcvI+mUo3FUEEyQW1aeXWI=; fh=MwmhOnPCNEKQUh9CETmL1NjqsCe+66NMqSNy76XJ1mw=; b=W9fT7yJjSDIq+X0LUfCEA9scIP28hfLNCHWemFS87Yxa0l0GkN8od3NFxxc/ElTyeX FUyA320PKH8OAS8gtOfjVYvMdYE7tzBVo9L1f6IA55VUPj22Mn4pRT4BIDvhTnYfEwaJ TSZUhzmH2FLB8+KImC26Dp5PR+u2MhoJbdg3WbGjU0otsQMOLH8IBPM+KlNHlDWlj1Xs eCFaaziEg5yIa1noAGd0wMZzTKsk/VGh9tCrdOiBzHQO/aDCJEpwR3ycsQxcLGJ8ZPb+ ZwMm0gPk8aTgiXEmaABpCgShy7qLWLLpeKvj/CSH3KKcUsXK+Hv62vspmvu89g5dtvSx 34tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=e1DVOJMb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id h14-20020a17090a604e00b0028679c85a9dsi3036262pjm.87.2023.12.08.08.13.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 08:13:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=e1DVOJMb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id AA00781BE82E; Fri, 8 Dec 2023 08:13:17 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1574124AbjLHQNE (ORCPT + 99 others); Fri, 8 Dec 2023 11:13:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1573867AbjLHQMx (ORCPT ); Fri, 8 Dec 2023 11:12:53 -0500 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE6B51995; Fri, 8 Dec 2023 08:12:58 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 92239C0004; Fri, 8 Dec 2023 16:12:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1702051977; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AagYqurduAd05kHY0ow9kHcvI+mUo3FUEEyQW1aeXWI=; b=e1DVOJMbQHAws2a4sJYGD+cU8txY0fD0/bnYzlRUqTuAocj9D/GDKqV13DlDIdi8cP7TX/ RqoQg9b65l0xcSt71ElN/z3aURY5EDE9wjcX4XXvb/FzyUigMrz18aCqowHugUJWYbDdKe Cj8KrRZ5GPgpe3ynTZGxw1lFTT4lbVHMhczeIGs3+rhViw5paJ1zNfBCUiRHKcTPLxt5vY +zHK+470tVAGMqc92Ei7tpb1ktcwaytCbV03usp5+78wopLnHTo83p06jJtfBQ5b83uU4N +DPFD7qgzdNTnuFRn+p9UFZxBASmApB0bOZ8t9HcXSsqhaGntCrkUoxXshbjag== From: Gregory CLEMENT To: Paul Burton , Thomas Bogendoerfer , linux-mips@vger.kernel.org, Jiaxun Yang , Rob Herring , Krzysztof Kozlowski , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Vladimir Kondratiev , Tawfik Bayouk , Alexandre Belloni , =?utf-8?q?Th=C3=A9o_Lebr?= =?utf-8?q?un?= , Thomas Petazzoni , Vladimir Kondratiev , Gregory CLEMENT Subject: [PATCH v4 04/22] MIPS: genex: Fix except_vec_vi for kernel in XKPHYS Date: Fri, 8 Dec 2023 17:12:20 +0100 Message-ID: <20231208161249.1827174-5-gregory.clement@bootlin.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231208161249.1827174-1-gregory.clement@bootlin.com> References: <20231208161249.1827174-1-gregory.clement@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: gregory.clement@bootlin.com X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,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 fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 08 Dec 2023 08:13:17 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784730879833424052 X-GMAIL-MSGID: 1784730879833424052 From: Jiaxun Yang Use {highest, higher, hi, lo} immediate loading sequence to load 64 bit jump address for handler when kernel is loaded to XKPHYS. Co-developed-by: Vladimir Kondratiev Signed-off-by: Vladimir Kondratiev Co-developed-by: Gregory CLEMENT Signed-off-by: Jiaxun Yang Signed-off-by: Gregory CLEMENT --- arch/mips/kernel/genex.S | 19 +++++++++++++++---- arch/mips/kernel/traps.c | 34 ++++++++++++++++++++++++---------- 2 files changed, 39 insertions(+), 14 deletions(-) diff --git a/arch/mips/kernel/genex.S b/arch/mips/kernel/genex.S index b6de8e88c1bd4..fd765ad9ecac0 100644 --- a/arch/mips/kernel/genex.S +++ b/arch/mips/kernel/genex.S @@ -272,11 +272,22 @@ 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 */ +#if defined(CONFIG_32BIT) || defined(KBUILD_64BIT_SYM32) +FEXPORT(except_vec_vi_hi) + lui v0, 0 /* Patched */ +#else +FEXPORT(except_vec_vi_highest) + lui v0, 0 /* Patched */ +FEXPORT(except_vec_vi_higher) + daddiu v0, 0 /* Patched */ + dsll v0, 16 +FEXPORT(except_vec_vi_hi) + daddiu v0, 0 /* Patched */ + dsll v0, 16 +#endif jr v1 -FEXPORT(except_vec_vi_ori) - ori v0, 0 /* Patched */ +FEXPORT(except_vec_vi_lo) + PTR_ADDIU v0, 0 /* Patched */ .set pop END(except_vec_vi) EXPORT(except_vec_vi_end) diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c index 246c6a6b02614..60c513c51684f 100644 --- a/arch/mips/kernel/traps.c +++ b/arch/mips/kernel/traps.c @@ -2091,18 +2091,26 @@ 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_ori[], except_vec_vi_end[]; + extern const u8 except_vec_vi[], except_vec_vi_hi[]; + extern const u8 except_vec_vi_lo[], except_vec_vi_end[]; +#if defined(CONFIG_64BIT) && !defined(KBUILD_64BIT_SYM32) + extern const u8 except_vec_vi_highest[], except_vec_vi_higher[]; +#endif 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; + const int imm_offset = 2; #else - const int lui_offset = except_vec_vi_lui - vec_start; - const int ori_offset = except_vec_vi_ori - vec_start; + const int imm_offset = 0; +#endif +#if defined(CONFIG_64BIT) && !defined(KBUILD_64BIT_SYM32) + const int highest_offset = except_vec_vi_highest - vec_start + imm_offset; + const int higher_offset = except_vec_vi_higher - vec_start + imm_offset; #endif + const int hi_offset = except_vec_vi_hi - vec_start + imm_offset; + const int lo_offset = except_vec_vi_lo - vec_start + imm_offset; + const int handler_len = except_vec_vi_end - vec_start; if (handler_len > VECTORSPACING) { @@ -2119,10 +2127,16 @@ 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; - h = (u16 *)(b + ori_offset); - *h = (handler & 0xffff); +#if defined(CONFIG_64BIT) && !defined(KBUILD_64BIT_SYM32) + h = (u16 *)(b + highest_offset); + *h = uasm_rel_highest(handler); + h = (u16 *)(b + higher_offset); + *h = uasm_rel_higher(handler); +#endif + h = (u16 *)(b + hi_offset); + *h = uasm_rel_hi(handler); + h = (u16 *)(b + lo_offset); + *h = uasm_rel_lo(handler); local_flush_icache_range((unsigned long)b, (unsigned long)(b+handler_len)); }