From patchwork Thu May 12 17:47:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 9085151 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 20B0A9F372 for ; Thu, 12 May 2016 17:57:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 826D320253 for ; Thu, 12 May 2016 17:57:32 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id C529B20251 for ; Thu, 12 May 2016 17:57:31 +0000 (UTC) Received: from localhost ([::1]:59141 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0ura-0008Q4-Lh for patchwork-qemu-devel@patchwork.kernel.org; Thu, 12 May 2016 13:57:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50638) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0urM-00089w-IV for qemu-devel@nongnu.org; Thu, 12 May 2016 13:57:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b0urL-0005Gc-BH for qemu-devel@nongnu.org; Thu, 12 May 2016 13:57:16 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:56970) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0urL-0005GR-5e for qemu-devel@nongnu.org; Thu, 12 May 2016 13:57:15 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.84_2) (envelope-from ) id 1b0uiS-0004Qu-18; Thu, 12 May 2016 18:48:04 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 12 May 2016 18:47:43 +0100 Message-Id: <1463075272-9933-20-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1463075272-9933-1-git-send-email-peter.maydell@linaro.org> References: <1463075272-9933-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PATCH v2 19/28] 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: Riku Voipio , Timothy Edward Baldwin , Richard Henderson , patches@linaro.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- I think this is clearer, anyway, but the counterargument is that the guest can't reliably examine r14 anyway and so setting it is unnecessary. --- linux-user/main.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/linux-user/main.c b/linux-user/main.c index 59b8fd5..54db9bb 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -2982,6 +2982,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;