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: 68567 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp1135985qge; Wed, 25 May 2016 03:47:37 -0700 (PDT) X-Received: by 10.141.44.4 with SMTP id v4mr2680338qhe.29.1464173257894; Wed, 25 May 2016 03:47:37 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 205si7200073qhs.73.2016.05.25.03.47.37 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 25 May 2016 03:47:37 -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]:58873 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5WLh-0005rw-Cf for patch@linaro.org; Wed, 25 May 2016 06:47:37 -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+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 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;