From patchwork Fri May 27 13:00:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 9138355 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 89F3A60467 for ; Fri, 27 May 2016 13:26:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C2C526FC9 for ; Fri, 27 May 2016 13:26:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 70D9F27E3D; Fri, 27 May 2016 13:26:35 +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 ECC4726FC9 for ; Fri, 27 May 2016 13:26:34 +0000 (UTC) Received: from localhost ([::1]:45812 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6Hmb-0006to-M0 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 27 May 2016 09:26:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37415) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6HNx-0007d1-Dr for qemu-devel@nongnu.org; Fri, 27 May 2016 09:01:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b6HNp-0001Dv-0k for qemu-devel@nongnu.org; Fri, 27 May 2016 09:01:04 -0400 Received: from mail-lb0-x232.google.com ([2a00:1450:4010:c04::232]:35824) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6HNo-0001DK-Ow for qemu-devel@nongnu.org; Fri, 27 May 2016 09:00:56 -0400 Received: by mail-lb0-x232.google.com with SMTP id ww9so31534894lbc.2 for ; Fri, 27 May 2016 06:00:56 -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=cceNe3wFIjKLLgli5/cyCDolAcvbuoa6gNercJFilF8=; b=Y2XP6ipG/mNpkRnQmJNRkp2OdE1FX0S6HiW29GlpwZtGD8bydtj1uDg9IGi3VG+u4B MTqEu8JL4mXeYDc9DPeL+3yGQFs3ZHdNjYKhwGaxndxYRg131aFpgTbVXU9so6Mmw2tj XIZFjRNpp/dSznU+EbjIprtmKVktpXNTi0fUs= 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=cceNe3wFIjKLLgli5/cyCDolAcvbuoa6gNercJFilF8=; b=X1fJamdg3zg8cGmQYMBd6qOQEA5fO5mmkJIHkmZiexwdANzPEaG9xN2TxMYtp6K2hT NY9OYpuQ6khtSJCghr6cDhQoAoWdkgQYm7aEJWzNk/nFNgC8xnh4opVIkYhXxW4or120 ArkpIEn0YopKUbAJ1jfUZn2W9piPUq62bLO4d2R+fKqjOAxXW7nZPmIwAZZYIHmdjaFK seig46x3sX7Oso1hkWJfMWb3aM1Q/PJqd7j1HoiURzwfv+04SDqt5Gdu86qaCL0twcsX doC4Kl1izNHY/x9DlAeZCY6kPTHa2qmu30aIyRon4O10VDWOrmWxseIiE4XTBj30/jom OPSg== X-Gm-Message-State: ALyK8tLAG3u5S4GytrYdWEUtIv/3glscSP72NVaTjel98OxknegFgzWML0pozsXNHmSSy7iZ X-Received: by 10.112.17.71 with SMTP id m7mr3572403lbd.129.1464354055854; Fri, 27 May 2016 06:00:55 -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.00.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 27 May 2016 06:00:55 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Fri, 27 May 2016 16:00:10 +0300 Message-Id: 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::232 Subject: [Qemu-devel] [PULL v2 19/38] linux-user: Set r14 on exit from microblaze syscall 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 All syscall exits on microblaze result in r14 being equal to the PC we return to, because the kernel syscall exit instruction "rtbd" does this. (This is true even for sigreturn(); note that r14 is not a userspace-usable register as the kernel may clobber it at any point.) Emulate the setting of r14 on exit; this isn't really a guest visible change for valid guest code because r14 isn't reliably observable anyway. However having the code and the comment helps to explain why it's ok for the ERESTARTSYS handling not to undo the changes to r14 that happen on syscall entry. Signed-off-by: Peter Maydell Signed-off-by: Riku Voipio --- linux-user/main.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/linux-user/main.c b/linux-user/main.c index 4607e48..c5da418 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -2983,6 +2983,13 @@ void cpu_loop(CPUMBState *env) env->regs[10], 0, 0); env->regs[3] = ret; + /* All syscall exits result in guest r14 being equal to the + * PC we return to, because the kernel syscall exit "rtbd" does + * this. (This is true even for sigreturn(); note that r14 is + * not a userspace-usable register, as the kernel may clobber it + * at any point.) + */ + env->regs[14] = env->sregs[SR_PC]; break; case EXCP_HW_EXCP: env->regs[17] = env->sregs[SR_PC] + 4;