From nobody Mon Feb 9 19:07:19 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1568643813; cv=none; d=zoho.com; s=zohoarc; b=BoaHFU52szSUn/WUPNl5cnGQseTp/uznNvrftG2FnyYZ0D9UVG4MND1o/Ry9GuTRbwt4hyQB+KUpLoxSkpwqYIye5i8dUz7X4QtlVEt4lLdc99sK/8WwQVlhQpikZAfzXsejhTnPkVuIikEVIVDDvLW1TQ+RQ5Zbg/hzfXZlCPo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568643813; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=+93zhnxV6y7awAg0ASSqV7pmnPcURr2F+yzvl9fZsA4=; b=Y5j6P95vT9/5ujz9IBH7AtcqWd6pyxESdejzw7Dqctd+ovPV1qPHK58J+5RhjIVEdO6p+CWpj2K7ttrysyZoTOzXjMy9NA/v+3tVvvaqePsDwW9pW3YInbHyxRRTmZwZBISzVH7dGTGcfpX615typILtkyr4xqBL/l9F8U9hGUY= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1568643813341735.8403844186765; Mon, 16 Sep 2019 07:23:33 -0700 (PDT) Received: from localhost ([::1]:34990 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9rud-0002Yb-EV for importer@patchew.org; Mon, 16 Sep 2019 10:23:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49557) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9rnC-0004J0-SK for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:15:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i9rnB-0006s5-Ap for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:15:50 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:37663) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i9rnB-0006rf-3R for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:15:49 -0400 Received: by mail-wm1-x343.google.com with SMTP id r195so10615284wme.2 for ; Mon, 16 Sep 2019 07:15:49 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id s9sm15185884wme.36.2019.09.16.07.15.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2019 07:15:47 -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 :mime-version:content-transfer-encoding; bh=+93zhnxV6y7awAg0ASSqV7pmnPcURr2F+yzvl9fZsA4=; b=i/3gfIPtv+A1F40fA1vF7JhDCKPvqU19HuYbWuNBIq3rsJkVqGKmG4pBVer/iaH57j jHccakeMDBkHC23mM6t3xT2eEPloplRUXzLFCAPsoA1HEaydbmROJ1VCBQ3byxpEFkk9 7t8I1asM58+Bmb3gKSH5bG0xY2NCmowbCIqCdetFDbStt+8a69mLik+lD6vAd65axGoV 8WExTs3XNS3KnyZSUNUzxzts3O32SN/rXk7GkyAnW6VbT3vFWoYWI14/q+1VLIvNMV2/ 9DvFxU34JTRnYpcvR0OrsGE1E7z9tLIX0gjOztThsH06y8bzGA1OR1wOUiIkpnsT6wud +fAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+93zhnxV6y7awAg0ASSqV7pmnPcURr2F+yzvl9fZsA4=; b=AGDy2iOTUWRc593iy2PG0eKGhpT7EKaGzyiJpx3pUfBRyhEAyS28XOOtdq+C5swR3F K/QX6ul63r9VNzjLlurUai/meQ5A2hPs61rHfu2aLuNKWI604uzIif08gJ1NCbsdeYvR Wicx71L9QsHcNDvMcjAWRky/QVCrlAvgcJcKN/yRv2ri+cSW+w0ZemjBq5y9l8jN8eiQ ThU6nLLkp647t66D6i6uKnxsCnlaWX0YbJu1tuGf6+BCltdM13sN8EQc2p9MtPRugiqP YVwDVZegRUlxVpjIqo2loDTX4+42BdUYgSYy9USh2m4lKf3mD7TAmJ6xqCUiA7ViYL5n 4xfw== X-Gm-Message-State: APjAAAUYwsuU3doANn0qcPsFGkCwtkA4I0pW5a/lISH+HNZLmwJpfEXk JdFIUo0XweY2MRbw8o1N2w2Bgw== X-Google-Smtp-Source: APXvYqz6WZG8Uy1Q5GZEl16gZ7AQ138w+KdgGuAFTrtt92KeTjrl70jDCH01ooeHtXppfk2KCQUmWA== X-Received: by 2002:a1c:1d85:: with SMTP id d127mr15179087wmd.14.1568643348049; Mon, 16 Sep 2019 07:15:48 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Date: Mon, 16 Sep 2019 15:15:30 +0100 Message-Id: <20190916141544.17540-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190916141544.17540-1-peter.maydell@linaro.org> References: <20190916141544.17540-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 Subject: [Qemu-devel] [PATCH v2 01/15] target/arm/arm-semi: Capture errno in softmmu version of set_swi_errno() 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: , Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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=C3=A9 Reviewed-by: Richard Henderson --- NB that a later commit will put in some cleanup of TaskState that will let us reduce the duplication between the two implementations of this function. --- target/arm/arm-semi.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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, ui= nt32_t code) return code; } #else +static target_ulong syscall_err; + static inline uint32_t set_swi_errno(CPUARMState *env, uint32_t code) { + if (code =3D=3D (uint32_t)-1) { + syscall_err =3D errno; + } return code; } =20 @@ -124,10 +129,6 @@ static inline uint32_t set_swi_errno(CPUARMState *env,= uint32_t code) =20 static target_ulong arm_semi_syscall_len; =20 -#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 =3D ARM_CPU(cs); --=20 2.20.1