From nobody Mon Feb 9 22:38:18 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=1568644059; cv=none; d=zoho.com; s=zohoarc; b=YQfHBl/Deie4dMGt0Gc1HIzT4KAF+d1I2GhQ7sQAjOkTOKjpqF2jhdqr07iWu6uwob4Rk2MtXqbUxhEIHT1t3wY9zNPeLPMVOKV+Rqtq+cWOuo/igw7C3Asp9uVwEFavwkHT04pxv7mtZMNVdW/Q90MZIXaPXI+TiMBc7CHsDRQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568644059; h=Content-Type: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=sbzqVgoyn7pJBiy5hHnuS48Tb76x8key349lTXeYMNs=; b=T6QNq0QCLXcDYxrlfuT1YpX5uLx/g6nmfqXdM0UcPMpKN/gNdiYe8wKZHExzs/3xbxloazUFH9RMerZTubvZ+nzNMRSnZk5955Sz3YUSv8NUIPYGRaEjWAiqNbHyWRQYf7z0IuSEiZ3EaghY9vilnCFlPaLC4xbetkzMoW0bmzE= 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 15686440597961018.9450910278122; Mon, 16 Sep 2019 07:27:39 -0700 (PDT) Received: from localhost ([::1]:35118 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9ryb-0007DW-Pg for importer@patchew.org; Mon, 16 Sep 2019 10:27:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49883) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9rnT-0004cW-JM for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:16:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i9rnR-00072I-EC for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:16:07 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:36376) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i9rnR-00070z-2w for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:16:05 -0400 Received: by mail-wr1-x443.google.com with SMTP id y19so39087520wrd.3 for ; Mon, 16 Sep 2019 07:16:04 -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.16.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2019 07:16:03 -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=sbzqVgoyn7pJBiy5hHnuS48Tb76x8key349lTXeYMNs=; b=d3FUYGeg3cqVj9C1S9arYoSDEpD5y9oaeHUyB4LHN+eP+aQeE7wPsQdXQCWHFIl2IW bCxqisg7w+7xxrmXglSgz96bjs8IB6X3MLABMgniAHgWzo0cmAY6+iNbm6+d7ix4VXJH pWovFPiHofeAHLTGED1nyagAPB/Mh1WsBhP1b7KI6u4udpsG0qirNMQnDMgx4PwgKSoN 1uImJ22ebqQBIS8WD2VmxWNArhS9gr4hHGXmoSEdgY/He4WMMBldspnX26/OPPMM0TP1 jBNsrcdjLO8siKpFK7BK7sWZ7UkYKNPOb1na0kiCLNw8JCFPxAKIDkRqa0DBcSBO8E01 NcGQ== 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=sbzqVgoyn7pJBiy5hHnuS48Tb76x8key349lTXeYMNs=; b=QHaWPWDkU9XDl9w8vmMcSB1x1jVoJFUrWGICHv2/Zbf2WUMX0wJU+T/NmhdR6Anqeu KIpvR3mYu29LOUOcUeVeBO6GorJwxGFEuY8ldiiGmudRIgIyUs1VCochjZZFw78jOWV8 CdaENrk+Q9kVx9oizJrQjKabr7A28shdWGZjOW9unINdtzPNvL32wBK9CmJuNe/WhnEn hNzpAWKwDvOSMsViDWliyTAGXwP6vGZavRSOrVv6hRUM/nTrQhVUJEpAkliqCfC5gj31 /YNzCZDCFMr/FHEijChtF2gFsLtlT7QNapCuilbu4maCUzEposYEG5Cq0hBXv4/MYEke /vag== X-Gm-Message-State: APjAAAVUfqjogAVFC3uJ0mauvjymU2kTlDRHAGmSaqftrgqWdOYwH7jW z+/yX+7YpGoJn1NzRV+QrKaZFg== X-Google-Smtp-Source: APXvYqypC/XW0HUi9u6xCUFphh2T+ilAYc+6fWlfpFBtC0WpVsqmNHtu6LUfKCQ1YVkhvCVKCSAK7A== X-Received: by 2002:a5d:6043:: with SMTP id j3mr9974595wrt.337.1568643363989; Mon, 16 Sep 2019 07:16:03 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Date: Mon, 16 Sep 2019 15:15:43 +0100 Message-Id: <20190916141544.17540-15-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-Type: text/plain; charset="utf-8" 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::443 Subject: [Qemu-devel] [PATCH v2 14/15] target/arm/arm-semi: Implement SH_EXT_EXIT_EXTENDED extension 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) SH_EXT_EXIT_EXTENDED is a v2.0 semihosting extension: it indicates that the implementation supports the SYS_EXIT_EXTENDED function. This function allows both A64 and A32/T32 guests to exit with a specified exit status, unlike the older SYS_EXIT function which only allowed this for A64 guests. Implement this extension. Signed-off-by: Peter Maydell Reviewed-by: Alex Benn=C3=A9e --- target/arm/arm-semi.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/target/arm/arm-semi.c b/target/arm/arm-semi.c index 57491740d73..f65d8c907e8 100644 --- a/target/arm/arm-semi.c +++ b/target/arm/arm-semi.c @@ -59,6 +59,7 @@ #define TARGET_SYS_HEAPINFO 0x16 #define TARGET_SYS_EXIT 0x18 #define TARGET_SYS_SYNCCACHE 0x19 +#define TARGET_SYS_EXIT_EXTENDED 0x20 =20 /* ADP_Stopped_ApplicationExit is used for exit(0), * anything else is implemented as exit(1) */ @@ -513,12 +514,15 @@ static uint32_t gdb_flenfn(ARMCPU *cpu, GuestFD *gf) #define SHFB_MAGIC_2 0x46 #define SHFB_MAGIC_3 0x42 =20 +/* Feature bits reportable in feature byte 0 */ +#define SH_EXT_EXIT_EXTENDED (1 << 0) + static const uint8_t featurefile_data[] =3D { SHFB_MAGIC_0, SHFB_MAGIC_1, SHFB_MAGIC_2, SHFB_MAGIC_3, - 0, /* Feature byte 0 */ + SH_EXT_EXIT_EXTENDED, /* Feature byte 0 */ }; =20 static void init_featurefile_guestfd(int guestfd) @@ -1042,11 +1046,14 @@ target_ulong do_arm_semihosting(CPUARMState *env) return 0; } case TARGET_SYS_EXIT: - if (is_a64(env)) { + case TARGET_SYS_EXIT_EXTENDED: + if (nr =3D=3D TARGET_SYS_EXIT_EXTENDED || is_a64(env)) { /* - * The A64 version of this call takes a parameter block, + * The A64 version of SYS_EXIT takes a parameter block, * so the application-exit type can return a subcode which * is the exit status code from the application. + * SYS_EXIT_EXTENDED is an a new-in-v2.0 optional function + * which allows A32/T32 guests to also provide a status code. */ GET_ARG(0); GET_ARG(1); @@ -1058,8 +1065,10 @@ target_ulong do_arm_semihosting(CPUARMState *env) } } else { /* - * ARM specifies only Stopped_ApplicationExit as normal - * exit, everything else is considered an error + * The A32/T32 version of SYS_EXIT specifies only + * Stopped_ApplicationExit as normal exit, but does not + * allow the guest to specify the exit status code. + * Everything else is considered an error. */ ret =3D (args =3D=3D ADP_Stopped_ApplicationExit) ? 0 : 1; } --=20 2.20.1