From patchwork Wed Dec 17 06:22:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sheng Yong X-Patchwork-Id: 42373 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f70.google.com (mail-wg0-f70.google.com [74.125.82.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6519326C90 for ; Wed, 17 Dec 2014 06:33:46 +0000 (UTC) Received: by mail-wg0-f70.google.com with SMTP id b13sf9534057wgh.9 for ; Tue, 16 Dec 2014 22:33:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-type:sender:precedence :list-id:x-original-sender:x-original-authentication-results :mailing-list:list-post:list-help:list-archive:list-unsubscribe; bh=xZCs7rCxSAxX5az7oC2PL6IIcuMmOHEX2AfNabXO3Hc=; b=S1B5B/QFPDo6Il70jvBzcMuhHHXL02sIRKYp91OXtWJrcq+4jixqfdH/B+Xwcy4zYy bdAeDQFL5ZJMWdOZ+LE2Mb56laeNvdznUPof8Jahd0KLznatrLWkdNIvIsuwd20kZqfY p/LPGov5zmMj5NEHqvl7H93ZSDf/BJa8icQPm4RweWgwPdN7X99xEx4eMnoN39aWFToq 2UDBc8KmZ0Q0XdkPVE0yDLwyzpJOQsGMxQux/h28L+0c4aZ9eOkZrB4sFzhnGfVIov/d 0KxL3u4iye5Ud8z49THZmsob7GHbPH3+aZ4i9H5YhQIQQz5jlKGzFgEiTUjjNs1Oziqa 5sJg== X-Gm-Message-State: ALoCoQnMgentqB21yf6bbI1SuQQjD6akWDCn5H1Pl2Q4a/QqPVWoMsm3fbQ/ODmbn6gCDyWnuRM2 X-Received: by 10.152.5.2 with SMTP id o2mr6197991lao.1.1418798025679; Tue, 16 Dec 2014 22:33:45 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.19.98 with SMTP id d2ls985094lae.19.gmail; Tue, 16 Dec 2014 22:33:45 -0800 (PST) X-Received: by 10.112.161.35 with SMTP id xp3mr11909544lbb.70.1418798025241; Tue, 16 Dec 2014 22:33:45 -0800 (PST) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com. [209.85.217.179]) by mx.google.com with ESMTPS id cr10si2887218lad.33.2014.12.16.22.33.45 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 16 Dec 2014 22:33:45 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) client-ip=209.85.217.179; Received: by mail-lb0-f179.google.com with SMTP id z11so12090995lbi.10 for ; Tue, 16 Dec 2014 22:33:45 -0800 (PST) X-Received: by 10.152.37.7 with SMTP id u7mr15621526laj.74.1418798024953; Tue, 16 Dec 2014 22:33:44 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.142.69 with SMTP id ru5csp1263309lbb; Tue, 16 Dec 2014 22:33:42 -0800 (PST) X-Received: by 10.68.195.41 with SMTP id ib9mr1999259pbc.15.1418797590503; Tue, 16 Dec 2014 22:26:30 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id jv1si4011312pbc.205.2014.12.16.22.26.29; Tue, 16 Dec 2014 22:26:30 -0800 (PST) Received-SPF: none (google.com: stable-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751585AbaLQG0X (ORCPT + 1 other); Wed, 17 Dec 2014 01:26:23 -0500 Received: from szxga03-in.huawei.com ([119.145.14.66]:1279 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751786AbaLQG0T (ORCPT ); Wed, 17 Dec 2014 01:26:19 -0500 Received: from 172.24.2.119 (EHLO szxeml421-hub.china.huawei.com) ([172.24.2.119]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id AYU15662; Wed, 17 Dec 2014 14:26:16 +0800 (CST) Received: from linux-4hy3.site (10.107.197.200) by szxeml421-hub.china.huawei.com (10.82.67.160) with Microsoft SMTP Server id 14.3.158.1; Wed, 17 Dec 2014 14:26:04 +0800 From: Sheng Yong To: CC: , Subject: [PATCH 11/16] ARM: signal: sigreturn_codes should be endian neutral to work in BE8 Date: Wed, 17 Dec 2014 06:22:54 +0000 Message-ID: <1418797379-107848-12-git-send-email-shengyong1@huawei.com> X-Mailer: git-send-email 1.8.3.4 In-Reply-To: <1418797379-107848-1-git-send-email-shengyong1@huawei.com> References: <1418797379-107848-1-git-send-email-shengyong1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.107.197.200] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020201.54912220.022F, ss=1, re=0.001, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 6a5009b5adcd4aaf02514f8f57afbef7 Sender: stable-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: stable@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: patch@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Victor Kamensky commit 574e2b5111e13827da501771b27d92e6e3f2e3d7 upstream In case of BE8 kernel data is in BE order whereas code stays in LE order. Move sigreturn_codes to separate .S file and use proper assembler mnemonics for these code snippets. In this case compiler will take care of proper instructions byteswaps for BE8 case. Change assumes that sufficiently Thumb-capable tools are used to build kernel. Problem was discovered during ltp testing of BE system: all rt_sig* tests failed. Tested against the same tests in both BE and LE modes. Signed-off-by: Victor Kamensky Reviewed-by: Dave Martin Signed-off-by: Ben Dooks [shengyong: backport to 3.10: - adjust context - since we don't have 38ff87f77af0b5a93fc8581cff1d6e5692ab8970, which makes sched_clock generic and does not impact on BE8, arch/arm/kernel/Makefile is adjusted. - After the above adjustments, becomes same to the original patch: https://github.com/torvalds/linux/commit/574e2b5111e13827da501771b27d92e6e3f2e3d7 ] Signed-off-by: Sheng Yong --- arch/arm/kernel/Makefile | 3 +- arch/arm/kernel/signal.c | 24 +----------- arch/arm/kernel/sigreturn_codes.S | 80 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 24 deletions(-) create mode 100644 arch/arm/kernel/sigreturn_codes.S diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile index 5f3338e..667345e 100644 --- a/arch/arm/kernel/Makefile +++ b/arch/arm/kernel/Makefile @@ -17,7 +17,8 @@ CFLAGS_REMOVE_return_address.o = -pg obj-y := elf.o entry-armv.o entry-common.o irq.o opcodes.o \ process.o ptrace.o return_address.o sched_clock.o \ - setup.o signal.o stacktrace.o sys_arm.o time.o traps.o + setup.o signal.o sigreturn_codes.o \ + stacktrace.o sys_arm.o time.o traps.o obj-$(CONFIG_ATAGS) += atags_parse.o obj-$(CONFIG_ATAGS_PROC) += atags_proc.o diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c index 5a42c12..3c23086 100644 --- a/arch/arm/kernel/signal.c +++ b/arch/arm/kernel/signal.c @@ -21,29 +21,7 @@ #include #include -/* - * For ARM syscalls, we encode the syscall number into the instruction. - */ -#define SWI_SYS_SIGRETURN (0xef000000|(__NR_sigreturn)|(__NR_OABI_SYSCALL_BASE)) -#define SWI_SYS_RT_SIGRETURN (0xef000000|(__NR_rt_sigreturn)|(__NR_OABI_SYSCALL_BASE)) - -/* - * With EABI, the syscall number has to be loaded into r7. - */ -#define MOV_R7_NR_SIGRETURN (0xe3a07000 | (__NR_sigreturn - __NR_SYSCALL_BASE)) -#define MOV_R7_NR_RT_SIGRETURN (0xe3a07000 | (__NR_rt_sigreturn - __NR_SYSCALL_BASE)) - -/* - * For Thumb syscalls, we pass the syscall number via r7. We therefore - * need two 16-bit instructions. - */ -#define SWI_THUMB_SIGRETURN (0xdf00 << 16 | 0x2700 | (__NR_sigreturn - __NR_SYSCALL_BASE)) -#define SWI_THUMB_RT_SIGRETURN (0xdf00 << 16 | 0x2700 | (__NR_rt_sigreturn - __NR_SYSCALL_BASE)) - -static const unsigned long sigreturn_codes[7] = { - MOV_R7_NR_SIGRETURN, SWI_SYS_SIGRETURN, SWI_THUMB_SIGRETURN, - MOV_R7_NR_RT_SIGRETURN, SWI_SYS_RT_SIGRETURN, SWI_THUMB_RT_SIGRETURN, -}; +extern const unsigned long sigreturn_codes[7]; static unsigned long signal_return_offset; diff --git a/arch/arm/kernel/sigreturn_codes.S b/arch/arm/kernel/sigreturn_codes.S new file mode 100644 index 0000000..3c5d0f2 --- /dev/null +++ b/arch/arm/kernel/sigreturn_codes.S @@ -0,0 +1,80 @@ +/* + * sigreturn_codes.S - code sinpets for sigreturn syscalls + * + * Created by: Victor Kamensky, 2013-08-13 + * Copyright: (C) 2013 Linaro Limited + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include + +/* + * For ARM syscalls, we encode the syscall number into the instruction. + * With EABI, the syscall number has to be loaded into r7. As result + * ARM syscall sequence snippet will have move and svc in .arm encoding + * + * For Thumb syscalls, we pass the syscall number via r7. We therefore + * need two 16-bit instructions in .thumb encoding + * + * Please note sigreturn_codes code are not executed in place. Instead + * they just copied by kernel into appropriate places. Code inside of + * arch/arm/kernel/signal.c is very sensitive to layout of these code + * snippets. + */ + +#if __LINUX_ARM_ARCH__ <= 4 + /* + * Note we manually set minimally required arch that supports + * required thumb opcodes for early arch versions. It is OK + * for this file to be used in combination with other + * lower arch variants, since these code snippets are only + * used as input data. + */ + .arch armv4t +#endif + + .section .rodata + .global sigreturn_codes + .type sigreturn_codes, #object + + .arm + +sigreturn_codes: + + /* ARM sigreturn syscall code snippet */ + mov r7, #(__NR_sigreturn - __NR_SYSCALL_BASE) + swi #(__NR_sigreturn)|(__NR_OABI_SYSCALL_BASE) + + /* Thumb sigreturn syscall code snippet */ + .thumb + movs r7, #(__NR_sigreturn - __NR_SYSCALL_BASE) + swi #0 + + /* ARM sigreturn_rt syscall code snippet */ + .arm + mov r7, #(__NR_rt_sigreturn - __NR_SYSCALL_BASE) + swi #(__NR_rt_sigreturn)|(__NR_OABI_SYSCALL_BASE) + + /* Thumb sigreturn_rt syscall code snippet */ + .thumb + movs r7, #(__NR_rt_sigreturn - __NR_SYSCALL_BASE) + swi #0 + + /* + * Note on addtional space: setup_return in signal.c + * algorithm uses two words copy regardless whether + * it is thumb case or not, so we need additional + * word after real last entry. + */ + .arm + .space 4 + + .size sigreturn_codes, . - sigreturn_codes