From patchwork Fri May 27 13:00:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 9138369 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 2ED1A60467 for ; Fri, 27 May 2016 13:32:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E7AF27CB1 for ; Fri, 27 May 2016 13:32:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 101DA28159; Fri, 27 May 2016 13:32:44 +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 755A427CB1 for ; Fri, 27 May 2016 13:32:43 +0000 (UTC) Received: from localhost ([::1]:45843 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6HsY-0004Vx-Ha for patchwork-qemu-devel@patchwork.kernel.org; Fri, 27 May 2016 09:32:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37557) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6HOA-0007sr-KM for qemu-devel@nongnu.org; Fri, 27 May 2016 09:01:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b6HO8-0001MI-CG for qemu-devel@nongnu.org; Fri, 27 May 2016 09:01:17 -0400 Received: from mail-lb0-x22a.google.com ([2a00:1450:4010:c04::22a]:36563) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6HO8-0001M7-4R for qemu-devel@nongnu.org; Fri, 27 May 2016 09:01:16 -0400 Received: by mail-lb0-x22a.google.com with SMTP id h1so31610492lbj.3 for ; Fri, 27 May 2016 06:01:15 -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=YiwOaJx9KH/R7UWZstb/pS9WUuoJw+K7MUpXE/oNB3wBoLKYQnXQS+EF2b9JOPpjK5 waVUIE3kqFnhEODUcjgpfXM3iq0pR6jfCYEn5BxM7w30lNr+XyG661J0kA2L4S2t2LFT HrkJ5P6tzNgPgOripySum41Guj/i/7IQ348ks= 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=k9WRLNo6eQpGF+BHKW8AD5toZYHAZAIJ4Zkip5ZRgLeQ6ndRhMHC8ob93++FS+OHlI 6Ydi8T/eQ1p3CwI+GCPsmKCM1uoah2SBiN9KiF+wgyaI4G9flBRDEaJ9l9YfVdQ6YJYO gFzhEC2ipE7ssJiHO9sFYqaM9PhFOu7aOBEcybImHotbcKsk+f5c8wukgvHBcFesmzlz yIeNHde+sNEDqsKUQ+04Eo2JXylFf9Y/p9hifWDeyHRYWTJTwQW+mv1t6aA1E0TQecHh wVPQhgcMsxfobOS0Q3cfuDVDdTgIAOdJDU7/G2s8cZbd+266fZpuRPXlQEOm4sJALMe0 gWwg== X-Gm-Message-State: ALyK8tKcfDlpvh8CYqp4mpJZ9nIbcNA0ueyh94EpqtALeWg0blQZPxQAhDfJwG4vbTAOO8Lo X-Received: by 10.112.136.194 with SMTP id qc2mr4575149lbb.60.1464354075248; Fri, 27 May 2016 06:01:15 -0700 (PDT) Received: from beaming.home (91-157-168-132.elisa-laajakaista.fi. [91.157.168.132]) by smtp.gmail.com with ESMTPSA id n16sm2281066lfg.31.2016.05.27.06.01.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 27 May 2016 06:01:14 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Fri, 27 May 2016 16:00:25 +0300 Message-Id: <167e4cdc29985e69769452fade698c5b9df78b3d.1464353863.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::22a Subject: [Qemu-devel] [PULL v2 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