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: 68741 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp89629qge; Fri, 27 May 2016 06:28:17 -0700 (PDT) X-Received: by 10.55.181.67 with SMTP id e64mr14271310qkf.112.1464355697595; Fri, 27 May 2016 06:28:17 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id e7si17517836qte.114.2016.05.27.06.28.17 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 27 May 2016 06:28:17 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:45823 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6HoH-00080F-2W for patch@linaro.org; Fri, 27 May 2016 09:28:17 -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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(+) -- 2.1.4 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;