Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp926536imj; Sat, 9 Feb 2019 10:58:57 -0800 (PST) X-Google-Smtp-Source: AHgI3Iby/PvGMlZpOIVv6mx+woPQFGOxbVfonW4u81fCXrQhj2aTs2hASkE+Z4daIW/oEoYeUS1e X-Received: by 2002:a62:5bc6:: with SMTP id p189mr15611827pfb.140.1549738737803; Sat, 09 Feb 2019 10:58:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549738737; cv=none; d=google.com; s=arc-20160816; b=Z4Kw2kcHDzPjpJu1sunTFpDlab23VD08hqpVQLPF+5epzLFPMWKx/pE22oCotmZHw1 fza0qaUQp2JQpMbXRp0Zzojxfp9G6Y4lS1wxBbHyqqYA8lCvHzjSSdies/4wou8e0MXk FIO+6yx4BusZ55FtT2iMRwI3jDgXIbdPqWOheLFNBmVCK7I7SK+BDEwxf47J1qz8b/6S RgWI7p5Wy7E0xoSn1YXjSnPedFy4WslvGyg9yLg5Cy9qLQugJ/EeQksmo43n5vQYimx0 NEJPEF8VkoklRX8UR81svBMFLsX+xxKXCHJtQ6pFO+TJfzsd0dEPHUckG6NX3aSt041m 2VgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8LjoA332fA9D27arqne0TynKHBzM6LQaSTHKUN+GcrQ=; b=warp6+q/L7j0/0smzsDT+KhGZbvc7aQpcr9yZ4/PCndQbU+64zN9JFaeKVCybTIunA QkyoPIBf6BJ/ZJI8hnRlspFTSRlHWk/3YVDXl+dCKkSGWAZ6MG5yhcMyk5yp5ZGpP2HD LzlxdOywmeT33zKTiTIXefZ7+9ljlbx8pQkfd2SPAKV98Rgz8S1SrqATyDGRMDRWiaFv mK2rnST7oWIp0tDiTt2ufzskoTrl8xpmFb1z6V4JqCURpxUQ+3BSnZM/tM97KqF7/ThG hcCJbs66sMin/PiRmphw7YN/6IhHd5rG/zRMQ5p01TaX+s4S+BmDKBJG54rcJaX6lBun NLVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oYmhmsw9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b5si5289235pgw.377.2019.02.09.10.58.42; Sat, 09 Feb 2019 10:58:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oYmhmsw9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728024AbfBIS50 (ORCPT + 99 others); Sat, 9 Feb 2019 13:57:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:60370 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727375AbfBISrq (ORCPT ); Sat, 9 Feb 2019 13:47:46 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 697E921919; Sat, 9 Feb 2019 18:47:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549738066; bh=gcET8lgoXkRG/uBMnL6wtuieGKpVKv8Z3yBvaczgZ/Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oYmhmsw9PY0+GBBqIO5mpVQInCQJsQXwe7OeVFU1Z1I3sSPxpUmZJLdUVHVQTvDyQ VpjH3W1cAuEUttopK45a4JrOcdnz8HQ0HsuTK29KC+ngKR9+mDTAHzZrec+izIIRK5 svGM3UPCibvwfwGg7q0qzRs2IQY2HStpG+PBPEnU= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Guo Ren , Hui Kai , Sasha Levin Subject: [PATCH AUTOSEL 4.20 10/42] csky: fixup relocation error with 807 & 860 Date: Sat, 9 Feb 2019 13:47:02 -0500 Message-Id: <20190209184734.125935-10-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190209184734.125935-1-sashal@kernel.org> References: <20190209184734.125935-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Guo Ren [ Upstream commit f553aa1c13cbc29aaf420349a28fc33ca98440e5 ] 810 doesn't support jsri instruction and csky-as will leave jsri + nop for relocation. Module-probe need replace them with lrw + jsr. Signed-off-by: Guo Ren Cc: Hui Kai Signed-off-by: Sasha Levin --- arch/csky/kernel/module.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/arch/csky/kernel/module.c b/arch/csky/kernel/module.c index 65abab0c7a47..0b028ee3c764 100644 --- a/arch/csky/kernel/module.c +++ b/arch/csky/kernel/module.c @@ -12,7 +12,7 @@ #include #include -#if defined(__CSKYABIV2__) +#ifdef CONFIG_CPU_CK810 #define IS_BSR32(hi16, lo16) (((hi16) & 0xFC00) == 0xE000) #define IS_JSRI32(hi16, lo16) ((hi16) == 0xEAE0) @@ -25,6 +25,26 @@ *(uint16_t *)(addr) = 0xE8Fa; \ *((uint16_t *)(addr) + 1) = 0x0000; \ } while (0) + +static void jsri_2_lrw_jsr(uint32_t *location) +{ + uint16_t location_tmp = (uint16_t *)location; + + if (IS_BSR32(*location_tmp, *(location_tmp + 1))) + return; + + if (IS_JSRI32(*location_tmp, *(location_tmp + 1))) { + /* jsri 0x... --> lrw r26, 0x... */ + CHANGE_JSRI_TO_LRW(location); + /* lsli r0, r0 --> jsr r26 */ + SET_JSR32_R26(location + 1); + } +} +#else +static void inline jsri_2_lrw_jsr(uint32_t *location) +{ + return; +} #endif int apply_relocate_add(Elf32_Shdr *sechdrs, const char *strtab, @@ -35,9 +55,6 @@ int apply_relocate_add(Elf32_Shdr *sechdrs, const char *strtab, Elf32_Sym *sym; uint32_t *location; short *temp; -#if defined(__CSKYABIV2__) - uint16_t *location_tmp; -#endif for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) { /* This is where to make the change */ @@ -59,18 +76,7 @@ int apply_relocate_add(Elf32_Shdr *sechdrs, const char *strtab, case R_CSKY_PCRELJSR_IMM11BY2: break; case R_CSKY_PCRELJSR_IMM26BY2: -#if defined(__CSKYABIV2__) - location_tmp = (uint16_t *)location; - if (IS_BSR32(*location_tmp, *(location_tmp + 1))) - break; - - if (IS_JSRI32(*location_tmp, *(location_tmp + 1))) { - /* jsri 0x... --> lrw r26, 0x... */ - CHANGE_JSRI_TO_LRW(location); - /* lsli r0, r0 --> jsr r26 */ - SET_JSR32_R26(location + 1); - } -#endif + jsri_2_lrw_jsr(location); break; case R_CSKY_ADDR_HI16: temp = ((short *)location) + 1; -- 2.19.1