From patchwork Wed Aug 14 07:08:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: vkamensky X-Patchwork-Id: 19096 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qe0-f72.google.com (mail-qe0-f72.google.com [209.85.128.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E2D0C2390D for ; Wed, 14 Aug 2013 07:09:44 +0000 (UTC) Received: by mail-qe0-f72.google.com with SMTP id a11sf9602313qen.7 for ; Wed, 14 Aug 2013 00:09:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=bBKdiiX8n/WRy8tBtRFd5SAfmAzYOEVRsblzjZ5mr+k=; b=pmBq9DGiWhBIopmVxcKjAtgQ5nYyjoZVoaBVHFm/QyDV7GbDFo/X7FqkFmT+MPUS5y lrjAFUUVjEvbHd31cHI9V6F30/gaYoOzgUelHB/R/FLHRE7a4Mv3NI/J/pIEtY2wUzJl H6HPZSwr8alAvNx7xhKj7O4r0lejltaET9yGmrjHI1wteN5qzwDJ0D7UY9RP6sWY14T3 aePIPn9uHS1fmxIaHcqNwRA48nlxnzYzlcB2J8oVJ5tAx+FaeShTl0aWaZYpk89c0/DW OU8iFUndwJcCALTV6vT704h44leAB6Brm+Z0g2dlEAlrv0ys1JxYhTNqfh6rz8j3MS7T Hnuw== X-Received: by 10.58.144.134 with SMTP id sm6mr1782492veb.27.1376464184387; Wed, 14 Aug 2013 00:09:44 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.97.197 with SMTP id ec5ls3020552qeb.26.gmail; Wed, 14 Aug 2013 00:09:44 -0700 (PDT) X-Received: by 10.58.237.105 with SMTP id vb9mr8219239vec.2.1376464184285; Wed, 14 Aug 2013 00:09:44 -0700 (PDT) Received: from mail-ve0-f174.google.com (mail-ve0-f174.google.com [209.85.128.174]) by mx.google.com with ESMTPS id fa1si10716639ved.13.2013.08.14.00.09.44 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 14 Aug 2013 00:09:44 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.174; Received: by mail-ve0-f174.google.com with SMTP id d10so7408395vea.19 for ; Wed, 14 Aug 2013 00:09:44 -0700 (PDT) X-Gm-Message-State: ALoCoQkygDgmmZQ4IJAb0FLIQyp0msRnVxKbb6CHB6wOtHF0RSMN0xcAMCz13TD0P0Fh63486zjx X-Received: by 10.52.180.229 with SMTP id dr5mr6883346vdc.20.1376464184118; Wed, 14 Aug 2013 00:09:44 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp197079vcz; Wed, 14 Aug 2013 00:09:43 -0700 (PDT) X-Received: by 10.66.196.168 with SMTP id in8mr8242032pac.18.1376464183135; Wed, 14 Aug 2013 00:09:43 -0700 (PDT) Received: from mail-pb0-f41.google.com (mail-pb0-f41.google.com [209.85.160.41]) by mx.google.com with ESMTPS id c10si28360512pav.287.2013.08.14.00.09.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 14 Aug 2013 00:09:43 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.41 is neither permitted nor denied by best guess record for domain of victor.kamensky@linaro.org) client-ip=209.85.160.41; Received: by mail-pb0-f41.google.com with SMTP id rp2so9045909pbb.28 for ; Wed, 14 Aug 2013 00:09:42 -0700 (PDT) X-Received: by 10.66.150.138 with SMTP id ui10mr8253338pab.19.1376464182716; Wed, 14 Aug 2013 00:09:42 -0700 (PDT) Received: from kamensky-w530.cisco.com.com (128-107-239-233.cisco.com. [128.107.239.233]) by mx.google.com with ESMTPSA id 7sm51315419paf.22.2013.08.14.00.09.40 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 14 Aug 2013 00:09:42 -0700 (PDT) From: Victor Kamensky To: linux-arm-kernel@lists.infradead.org, linux@arm.linux.org.uk, Dave.Martin@arm.com Cc: ben.dooks@codethink.co.uk, steve.mcintyre@linaro.org, patches@linaro.org, linaro-kernel@lists.linaro.org, Victor Kamensky Subject: [PATCH v2 1/1] ARM: signal: sigreturn_codes should be endian neutral to work in BE8 Date: Wed, 14 Aug 2013 00:08:54 -0700 Message-Id: <1376464134-23029-2-git-send-email-victor.kamensky@linaro.org> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1376464134-23029-1-git-send-email-victor.kamensky@linaro.org> References: <1376464134-23029-1-git-send-email-victor.kamensky@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: victor.kamensky@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 --- arch/arm/kernel/Makefile | 3 +- arch/arm/kernel/signal.c | 29 +++--------------- arch/arm/kernel/sigreturn_codes.S | 64 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 26 deletions(-) create mode 100644 arch/arm/kernel/sigreturn_codes.S diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile index 86d10dd..0722155 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-common.o irq.o opcodes.o \ process.o ptrace.o return_address.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 ab33042..cdcbf04 100644 --- a/arch/arm/kernel/signal.c +++ b/arch/arm/kernel/signal.c @@ -21,29 +21,8 @@ #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[]; +extern const int sigreturn_codes_size; static unsigned long signal_return_offset; @@ -639,10 +618,10 @@ struct page *get_signal_page(void) * Copy signal return handlers into the vector page, and * set sigreturn to be a pointer to these. */ - memcpy(addr + offset, sigreturn_codes, sizeof(sigreturn_codes)); + memcpy(addr + offset, sigreturn_codes, sigreturn_codes_size); ptr = (unsigned long)addr + offset; - flush_icache_range(ptr, ptr + sizeof(sigreturn_codes)); + flush_icache_range(ptr, ptr + sigreturn_codes_size); return page; } diff --git a/arch/arm/kernel/sigreturn_codes.S b/arch/arm/kernel/sigreturn_codes.S new file mode 100644 index 0000000..3ac1540 --- /dev/null +++ b/arch/arm/kernel/sigreturn_codes.S @@ -0,0 +1,64 @@ +/* + * 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 + */ + + .text + .global sigreturn_codes + .type sigreturn_codes, #object + +sigreturn_codes: + /* ARM sigreturn syscall code snippet */ + .arm + mov r7, #(__NR_sigreturn - __NR_SYSCALL_BASE) + svc #(__NR_sigreturn)|(__NR_OABI_SYSCALL_BASE) + + /* Thumb sigreturn syscall code snippet */ + .thumb + movs r7, #(__NR_sigreturn - __NR_SYSCALL_BASE) + svc #0 + + /* ARM sigreturn_rt syscall code snippet */ + .arm + mov r7, #(__NR_rt_sigreturn - __NR_SYSCALL_BASE) + svc #(__NR_rt_sigreturn)|(__NR_OABI_SYSCALL_BASE) + + /* Thumb sigreturn_rt syscall code snippet */ + .thumb + movs r7, #(__NR_rt_sigreturn - __NR_SYSCALL_BASE) + svc #0 + + .arm + .space 4 +__sigreturn_codes_end: + .size sigreturn_codes, . - sigreturn_codes + + .section .rodata + .global sigreturn_codes_size + .type sigreturn_codes_size, #object + .size sigreturn_codes_size, 4 + +sigreturn_codes_size: + .long __sigreturn_codes_end - sigreturn_codes