From patchwork Tue Sep 10 14:44:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 173524 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp5899929ilq; Tue, 10 Sep 2019 07:46:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqw3TwFfsmqiDj6Pev9SyeuZ5A/NM7jFt/dZ0P95J/b+1xq4hn7HoHS5ZQgHBGhZHbf2xIdc X-Received: by 2002:ac8:1c54:: with SMTP id j20mr29863069qtk.302.1568126792272; Tue, 10 Sep 2019 07:46:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568126792; cv=none; d=google.com; s=arc-20160816; b=IidGAWtiOGy4f2k88sSc/QEIT3Wd/VZijjSQsPjVgUFE84Y1vH3MXeWXQajHXm6yr2 C0zm2ZlbAosGsoYsW/dSsjCv9If7jgRWxRk/z/CbAQGP3kOmOBWVNji16jZwrvTiYuM4 ttD6jJTWK5DpQu+Irnon5Pet4kjspeO8VSL6I6XA7U/4SEAmytx8GW30OxRGI4/tIMUg Xd6moLZvdjionArHiJLKskGQUan4C0z7nonLlbw5U0Qctkce+kmDIsK9uVFHDOnid0YG rewg1zl8+3XmJke0N89EXoMoGi3sujEfufOXizBIFPklUKhj7H7fIK9MhfSbBLsEwK9J 4erg== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=+93zhnxV6y7awAg0ASSqV7pmnPcURr2F+yzvl9fZsA4=; b=enPywXzeQn7ydtPCLlfXnrBKEhQX7hDQH1X+QA8UtcxnjZwWL4lGglqOLxOgcyCQvQ 1w/o7VMQr53A5t4iuIol2myM/WQaSJ9hYEVb67/hUuw9Pok/iH0vXzXdQS3NyoIq26UZ As4ZCiVPS9Aayybip0Lkw2sCia+Exfbk4YjvEei2Hikttuz0GHgK0nqh7P6WA0w3YAee Wpavzj7onnx6M6wiwgUygJlwhjrbrW0EmPHJkYNSY2J8mR9IHhTnpZV6h2985CRxx6wa Z1yAzKSrAFWv3TWH6YdTfTIS7k8UBFJtnS8mqRrCVv/iCg9+pGuW+wyIXOMPCBnXzhAk sRLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=yjlgCfy9; 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=fail (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 b186si12656046qkf.220.2019.09.10.07.46.32 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Sep 2019 07:46:32 -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=fail header.i=@linaro.org header.s=google header.b=yjlgCfy9; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:40642 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i7hPb-0005Ne-2m for patch@linaro.org; Tue, 10 Sep 2019 10:46:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53877) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i7hNi-0005Kt-Bo for qemu-devel@nongnu.org; Tue, 10 Sep 2019 10:44:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i7hNh-0004xX-9k for qemu-devel@nongnu.org; Tue, 10 Sep 2019 10:44:34 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:46933) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i7hNh-0004x4-3S for qemu-devel@nongnu.org; Tue, 10 Sep 2019 10:44:33 -0400 Received: by mail-wr1-x441.google.com with SMTP id d17so8066013wrq.13 for ; Tue, 10 Sep 2019 07:44:33 -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=+93zhnxV6y7awAg0ASSqV7pmnPcURr2F+yzvl9fZsA4=; b=yjlgCfy9He+gTLDKlS4tw4uJ09J7Z4UDlHWsRjtbB+txmHoBkLZCVFMrmmsmTuh2NW rlmUYDsPDLwT6abct4DmFK3w9vnVVOmqK7dNdwZzduuRc7ceYZpHMpN6mYv2VPje1hX8 LUv8zHDO6H0C7IbQZ7lKKSWPisdiX9jbI1gx7JtgLDtDYbepW6gzfg8yifKqH7TlyaQn IDFNKgXt9L4uYdzZT3sBGEgSaoH91SkjAjOkSdzm7hUUnSw3fAQcW3V+xj4SBCvTBeaD uwFB2vzUsONxWrPeppaFOLM9bnBAhkckPPCYVh2W1XHxvqGJkv4It126hXq3BPWXRltt rSnw== 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=+93zhnxV6y7awAg0ASSqV7pmnPcURr2F+yzvl9fZsA4=; b=Um12oqQjEQuMMkNDLp34unzia1b5GtXgntf6MpBuG5KGHTvuiT4zH8IUs+Hj9McvXB Np/c4g+G6yJse547yl+JPL716KkJhixtzHDsUE9FOBGdf7UmG5FOxvYWxF4Be0HxtC3O UbwkYm8rWlxLfYDK8687zTTeoP/0/GuibqoDmUjC/wBrmD0Lu7hjF4mJRZFS0w4OQq5R 4AcBKeuf2lO2mpcBTikKn8X0MyF1lx/9wGWwMBWDDUGNc+ngsaTvuJVgvbJjLYZTndX9 Vabg8Yfjr/kKLoE+U9PisRt+spEnZBLdTRwbJZNSop9OW3Adi7IRGQSOwNaXnXJM1xFx MwtQ== X-Gm-Message-State: APjAAAWPlmpa5ztykVlOH5hCK13fr8daJ9fo3DygD8V1UJNSA60TrI0y nb/CBBoPOKIGheqZDaSHbv/oJQ== X-Received: by 2002:adf:f110:: with SMTP id r16mr4111003wro.152.1568126672093; Tue, 10 Sep 2019 07:44:32 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id a192sm5703814wma.1.2019.09.10.07.44.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2019 07:44:31 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Date: Tue, 10 Sep 2019 15:44:16 +0100 Message-Id: <20190910144428.32597-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190910144428.32597-1-peter.maydell@linaro.org> References: <20190910144428.32597-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::441 Subject: [Qemu-devel] [PATCH 01/13] 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: , 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 --- 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(-) -- 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);