From patchwork Wed May 25 10:31:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 9135123 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 02ED360221 for ; Wed, 25 May 2016 10:45:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ECC50281E3 for ; Wed, 25 May 2016 10:45:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E1B6F282A2; Wed, 25 May 2016 10:45: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 9237B281E3 for ; Wed, 25 May 2016 10:45:44 +0000 (UTC) Received: from localhost ([::1]:58868 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5WJr-0004jN-Jt for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 May 2016 06:45:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41422) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5W76-0001Bi-TX for qemu-devel@nongnu.org; Wed, 25 May 2016 06:32:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b5W6z-0003A7-Ry for qemu-devel@nongnu.org; Wed, 25 May 2016 06:32:32 -0400 Received: from mail-lb0-x230.google.com ([2a00:1450:4010:c04::230]:34533) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5W6z-00039x-Ki for qemu-devel@nongnu.org; Wed, 25 May 2016 06:32:25 -0400 Received: by mail-lb0-x230.google.com with SMTP id sh2so14048600lbb.1 for ; Wed, 25 May 2016 03:32:25 -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=XDQZkO2BP8xwqaEmhgoGNPD9+KLvuQ27TcRKGJRaLVY=; b=MuFL1mGApOKToOGed3Cn32Xip6BwwgFKGvBth7qJ5cew5kCMTOF6SkyAePaafVOjC7 DFv1k7UjoVNjuv9syCXnHERpJcyz1e60MSh9xgtrfd/28taKcpMqXLZhJ8zQ8lLfaTld 0llP3XaJd4EC5ZK7FOJjvxsApE5mzJMXyY5q0= 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=XDQZkO2BP8xwqaEmhgoGNPD9+KLvuQ27TcRKGJRaLVY=; b=nD+HgjNMzkg7kFLm4GGwI9fNQh1FQx/8cjQJ9YMZKJJqgOJ7Sf2/xu/+8/wHDZuE8o cAu305ojATrmt49Liykntzm6KNGx9+pDrhxHZPrGZUJn6rIBzGNGq9ztoz/sW9wJ/jku 52FkT5A+k86LlZW4zbuOe85G7va2pSgZ87z8WEsdaNMgEebAULSJ5lzkvmvhPCAYHUxw tFhYEa4Rzfhp1OAYVFn6PrRKMnO8Ys+9glRYUNah4X5sydPBX9oZ8Zc2HIxEWK+U2Jr1 aPF25jtqsF5C3MVdeS+DQCgEyWfJhO/u1lpTb/xSMV+LkLq8TPQBNPgbi8ZGCClfYQ+S uq7A== X-Gm-Message-State: ALyK8tIZuijOjiI1nZ5ZzpbB/jNpE8oKHgHTTThY4yeJ69YJJQWES70Et6SifTefc7tQGLe6 X-Received: by 10.112.167.225 with SMTP id zr1mr948018lbb.96.1464172344866; Wed, 25 May 2016 03:32:24 -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.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 May 2016 03:32:24 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Wed, 25 May 2016 13:31:51 +0300 Message-Id: <7f73b830a03e6aa603d044c8642972e9eefcd3b2.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::230 Subject: [Qemu-devel] [PULL 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 1f604a7..aa6b414 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;