From patchwork Mon Oct 14 16:03:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 176285 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4732052ill; Mon, 14 Oct 2019 09:29:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqzXBlfEBOcDqz09/+Jv5w/44FdYAsbzJL/Ndgf53FNISP+kLQkcHNeXopF9hB9Xh96FR99D X-Received: by 2002:a17:906:48cf:: with SMTP id d15mr30028057ejt.59.1571070562120; Mon, 14 Oct 2019 09:29:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571070562; cv=none; d=google.com; s=arc-20160816; b=QWxYZMgbBw/pDmfAiqei6AQSZLO0y2dZw1u/9QtWxbqJDUlW8dg3W5J0EC88V09U5D 0u59eU3gPzd0/il++IpPbUcD86NwGjF4IsyF/RNWshFytOVHHvfMRxoSxcVTCXWPNom8 QNdt3bspD1W7bAXZOS7/1T8L5lGI7NGZmYPLd1rGPrBUJOSN1XtGceDVWuIp188zE0N4 qFNJZmRfsmXuCYYYKb2GlTEMVavLffY08eC7aBGOjk2nnhsXdnLwfCU2oynnTh/Mf5Tl Zljspc0QR2kQdjyPbLD9g8bfgQE9vZy3pZR9Lyk2qHYokMZEXr412pYn2xFzqcDGHQhW +ZZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=eSVt+eEc+RrJyKcS0K2MVccKihJyivwdaMosLyCjfLA=; b=WE/NuhyDhY3rTnHZyvSlP0c1KEgqoXHCQ0jw89TyHq+vrHj+ZM8mN9rAJz/DxNVi0x 2cjPVvbFrgpxNJ9aRIi0xDd+vo8LSlBzWx1aQesBVE6maYgblfXqldnFNw2zHPkkq3nR 4ehHLJe9lID3DJ+YdJDeIxjnlVdTli5ko0cBJut9MoCh26Tyxkpu8tSDJCE+idRFpsKK qsJ70iRlR8cnULVEl2tYVnzpos4pqPXavYL+OYNfvXCTh7wpIunZoE0nLqEQWCv04wlQ oWBt1ov7Q3FYBR6S9PItP6+96i00Mv25NCAhCl2mRMHlpwnznwLzP/Ax1kZgA1cFIeX5 TxJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pWNsaieJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id y22si11155452ejw.144.2019.10.14.09.29.21 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 09:29:22 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pWNsaieJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:53284 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iK3Dk-00028u-Kz for patch@linaro.org; Mon, 14 Oct 2019 12:29:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37002) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iK2q8-0004JO-HO for qemu-devel@nongnu.org; Mon, 14 Oct 2019 12:04:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iK2q7-0007VX-Bm for qemu-devel@nongnu.org; Mon, 14 Oct 2019 12:04:56 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:37686) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iK2q7-0007Un-5f for qemu-devel@nongnu.org; Mon, 14 Oct 2019 12:04:55 -0400 Received: by mail-wr1-x436.google.com with SMTP id p14so20380090wro.4 for ; Mon, 14 Oct 2019 09:04:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=eSVt+eEc+RrJyKcS0K2MVccKihJyivwdaMosLyCjfLA=; b=pWNsaieJHXzyY/1CJuNQ3JczuJQQdW/vbtSK+/km143Sy/vDQ489rMDbUOtg1jYLdM /ESCNA47BdZ22UGHYVMieQcGTZr354b6PDIs3SUcKiuVl1Vss22swytLCBCPtVmcSTrp g0rSKwY94Vx6eVGZmmlRjRStACwdr+2tYbycYHGCyOT5i0UDtS2EBa2Ow3tJkz+9ZwVe 951H4lHZ5czLIo1Q+cmsMEdINxHrcTq/3jLx0Cv/fUwSN5iUK7MaqV4xy4ftbiAno/r0 +KW5K+go8O6hHFfdehwSn/05iBpXamqvGE6K/5/0e20rHiYaylM+WZZr/hHoNxBnEj1L korQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eSVt+eEc+RrJyKcS0K2MVccKihJyivwdaMosLyCjfLA=; b=a2eNY596sm8oZocBEdh6NeN0zkWYR4A4W1+60KRUcuzcNHqA1lWMJ2pFdH7F+e0udM 0pwD0+uK2SNnPidnrM1LdhxwC2zVxclUuRQW/YV7pPZxjajDdBAdXJ+jHIiVj1Kw8AIJ TGVJrcllvfYPcYEJlMysw5V0ikDuPlVEK/7IL9DmWbrRhN8q1m6LdyA5FvebVo3atYKY 9yWqM3RNKlx/Swn00/Zb9q4YHmvrbb7OUFg6Ss8wEHAAoacovKHBN2GDXXeG3DF26Qq0 KQoAxh/k4SVpDUDWPmTAX2oyFZFbWr6/GX1k0HlrJ6ZgtM0QioIN+/goH+9XY4ZfA/KR WgMA== X-Gm-Message-State: APjAAAXABh/9Bna1eneYjxDBMWLlMyqgX+zu10kIC1e3AvN7IjGGqQpm 9AIRguxB1bd6dibydKzhTbaNHOWIyLEPMg== X-Received: by 2002:a5d:5052:: with SMTP id h18mr18759676wrt.143.1571069093935; Mon, 14 Oct 2019 09:04:53 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id 5sm18029779wrk.86.2019.10.14.09.04.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 09:04:52 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 25/68] target/arm/arm-semi: Capture errno in softmmu version of set_swi_errno() Date: Mon, 14 Oct 2019 17:03:21 +0100 Message-Id: <20191014160404.19553-26-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014160404.19553-1-peter.maydell@linaro.org> References: <20191014160404.19553-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::436 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The set_swi_errno() function is called to capture the errno from a host system call, so that we can return -1 from the semihosting function and later allow the guest to get a more specific error code with the SYS_ERRNO function. It comes in two versions, one for user-only and one for softmmu. We forgot to capture the errno in the softmmu version; fix the error. (Semihosting calls directed to gdb are unaffected because they go through a different code path that captures the error return from the gdbstub call in arm_semi_cb() or arm_semi_flen_cb().) Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-id: 20190916141544.17540-2-peter.maydell@linaro.org --- target/arm/arm-semi.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) -- 2.20.1 diff --git a/target/arm/arm-semi.c b/target/arm/arm-semi.c index 90423a35deb..03e60105c05 100644 --- a/target/arm/arm-semi.c +++ b/target/arm/arm-semi.c @@ -114,8 +114,13 @@ static inline uint32_t set_swi_errno(TaskState *ts, uint32_t code) return code; } #else +static target_ulong syscall_err; + static inline uint32_t set_swi_errno(CPUARMState *env, uint32_t code) { + if (code == (uint32_t)-1) { + syscall_err = errno; + } return code; } @@ -124,10 +129,6 @@ static inline uint32_t set_swi_errno(CPUARMState *env, uint32_t code) static target_ulong arm_semi_syscall_len; -#if !defined(CONFIG_USER_ONLY) -static target_ulong syscall_err; -#endif - static void arm_semi_cb(CPUState *cs, target_ulong ret, target_ulong err) { ARMCPU *cpu = ARM_CPU(cs);