From patchwork Wed May 25 10:32:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 9135155 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3D5B86075C for ; Wed, 25 May 2016 11:00:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 31037252D5 for ; Wed, 25 May 2016 11:00:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 25DF2282A2; Wed, 25 May 2016 11:00:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, FSL_HELO_HOME, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 86B47252D5 for ; Wed, 25 May 2016 11:00:00 +0000 (UTC) Received: from localhost ([::1]:58930 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5WXf-0000xP-Jl for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 May 2016 06:59:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42021) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5W7T-0001XV-8F for qemu-devel@nongnu.org; Wed, 25 May 2016 06:33:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b5W7J-0003SB-C0 for qemu-devel@nongnu.org; Wed, 25 May 2016 06:32:54 -0400 Received: from mail-lb0-x235.google.com ([2a00:1450:4010:c04::235]:34562) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5W7J-0003RZ-4B for qemu-devel@nongnu.org; Wed, 25 May 2016 06:32:45 -0400 Received: by mail-lb0-x235.google.com with SMTP id sh2so14050848lbb.1 for ; Wed, 25 May 2016 03:32:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=B7nSv9UxVGDEqexeOlaZdMBfC46rznHmDolNtYmP+jw=; b=ZENsKl3ZI/33CPwZyS4zEA9ko/5FRMZLPaphGi8VDBzFRas8QdwFcxaWi3nOZs/l37 0QwdVvnQFnwczZRgX4vipzVUNBzOveroMGQfvcVBRsnfNf/mOGku3ym63ZbQXugoXkPE r8yJ4XcQTzVmNrl6hRLuJTtELaGQSxtGcKB68= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=B7nSv9UxVGDEqexeOlaZdMBfC46rznHmDolNtYmP+jw=; b=bkvKAUA6fPguhddb/ZPgysqnXvLE8sm9C5DlOP2oRc+JhCdcT2YdROJWKUr9SfCTP0 RSecJgVfzM0Q8avm61HTh1np4ITDSHDQbLtHwv4iPUeAhCG9zM+/ta5RshrCcUdHUUp4 3x+3ZR8X67NdiCMz/ECYnWcoogdzXd/h89B5/98jvF3hgbQRoJrNoeoF0DpxYCyYXJRe uKJ70+3RXvhzJiv3MVV15hzzRWbt50f06KcRtbPtmo8TZzbov+y8+oRPEaT8rAN6cgZT oEkzY/vlVIQOpSku9acQjpaqtABKu2HtMJ7WCc7oSFQbLXv9nO5xYCCH4lQGpH/VMCib MxxA== X-Gm-Message-State: ALyK8tK/Hyr6NbIFScQwr0Rir5fqyy9FkkhPts/T8SAQwv7gsQsvJkzkJRYJvVRW8TkCQ5zx X-Received: by 10.112.9.200 with SMTP id c8mr904981lbb.50.1464172364355; Wed, 25 May 2016 03:32:44 -0700 (PDT) Received: from beaming.home (91-157-168-132.elisa-laajakaista.fi. [91.157.168.132]) by smtp.gmail.com with ESMTPSA id o75sm1379610lfi.9.2016.05.25.03.32.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 May 2016 03:32:43 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Wed, 25 May 2016 13:32:06 +0300 Message-Id: <613965b61ee6b53b9fe038fa9549bc78323e79c4.1464153942.git.riku.voipio@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c04::235 Subject: [Qemu-devel] [PULL 34/38] linux-user: arm: Remove ARM_cpsr and similar #defines X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Peter Maydell The #defines of ARM_cpsr and friends in linux-user/arm/target-syscall.h can clash with versions in the system headers if building on an ARM or AArch64 build (though this seems to be dependent on the version of the system headers). The QEMU defines are not very useful (it's not clear that they're intended for use with the target_pt_regs struct rather than (say) the CPUARMState structure) and we only use them in one function in elfload.c anyway. So just remove the #defines and directly access regs->uregs[]. Reported-by: Christopher Covington Tested-by: Christopher Covington Signed-off-by: Peter Maydell Signed-off-by: Riku Voipio --- linux-user/arm/target_syscall.h | 20 +------------------- linux-user/elfload.c | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 28 deletions(-) diff --git a/linux-user/arm/target_syscall.h b/linux-user/arm/target_syscall.h index ea863db..11077b7 100644 --- a/linux-user/arm/target_syscall.h +++ b/linux-user/arm/target_syscall.h @@ -4,29 +4,11 @@ /* this struct defines the way the registers are stored on the stack during a system call. */ +/* uregs[0..15] are r0 to r15; uregs[16] is CPSR; uregs[17] is ORIG_r0 */ struct target_pt_regs { abi_long uregs[18]; }; -#define ARM_cpsr uregs[16] -#define ARM_pc uregs[15] -#define ARM_lr uregs[14] -#define ARM_sp uregs[13] -#define ARM_ip uregs[12] -#define ARM_fp uregs[11] -#define ARM_r10 uregs[10] -#define ARM_r9 uregs[9] -#define ARM_r8 uregs[8] -#define ARM_r7 uregs[7] -#define ARM_r6 uregs[6] -#define ARM_r5 uregs[5] -#define ARM_r4 uregs[4] -#define ARM_r3 uregs[3] -#define ARM_r2 uregs[2] -#define ARM_r1 uregs[1] -#define ARM_r0 uregs[0] -#define ARM_ORIG_r0 uregs[17] - #define ARM_SYSCALL_BASE 0x900000 #define ARM_THUMB_SYSCALL 0 diff --git a/linux-user/elfload.c b/linux-user/elfload.c index e47caff..bb2558f 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -274,19 +274,20 @@ static inline void init_thread(struct target_pt_regs *regs, abi_long stack = infop->start_stack; memset(regs, 0, sizeof(*regs)); - regs->ARM_cpsr = 0x10; - if (infop->entry & 1) - regs->ARM_cpsr |= CPSR_T; - regs->ARM_pc = infop->entry & 0xfffffffe; - regs->ARM_sp = infop->start_stack; + regs->uregs[16] = ARM_CPU_MODE_USR; + if (infop->entry & 1) { + regs->uregs[16] |= CPSR_T; + } + regs->uregs[15] = infop->entry & 0xfffffffe; + regs->uregs[13] = infop->start_stack; /* FIXME - what to for failure of get_user()? */ - get_user_ual(regs->ARM_r2, stack + 8); /* envp */ - get_user_ual(regs->ARM_r1, stack + 4); /* envp */ + get_user_ual(regs->uregs[2], stack + 8); /* envp */ + get_user_ual(regs->uregs[1], stack + 4); /* envp */ /* XXX: it seems that r0 is zeroed after ! */ - regs->ARM_r0 = 0; + regs->uregs[0] = 0; /* For uClinux PIC binaries. */ /* XXX: Linux does this only on ARM with no MMU (do we care ?) */ - regs->ARM_r10 = infop->start_data; + regs->uregs[10] = infop->start_data; } #define ELF_NREG 18