From nobody Sun Feb 8 03:57:52 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; 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 ARC-Seal: i=1; a=rsa-sha256; t=1566413205; cv=none; d=zoho.com; s=zohoarc; b=K8CLyvl8rW8t1zdapqNRaq+iZuiymKdtiMr8OPA9/uSzIWhsJQeTFFO3bcePqiXk3CCwHSsbf8DORmNPG5UoI45HtdXb8kPgR0HZW9o/mvMB3tZi/2fw7x656O7k23S4DG+ffxYI/Sj6Mv/rozWzQlBudYhUq0YR/6UTiLtRmXs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566413205; h=Content-Type: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=NqtTJ15ZMFJHyk8WE1su8/i9mXXHwKCrtX+U+fegatk=; b=RDvZnZ0jzwAPuTYI+whYdwvrfRGNwxDVqwbluiCok4xhKZTxvZ3Ent5/Lwdq0JnnaPC1JKKybjlI8UlHtehng7d/12NTTIOfO2DaFjKR2IEwA1ZpqcylTrHUz8z35l+CKU5bu6YAmvK4p1ovcKhwBRpgVjSnORxLsyyb66bKr0k= ARC-Authentication-Results: i=1; mx.zoho.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1566413205666953.9275121773092; Wed, 21 Aug 2019 11:46:45 -0700 (PDT) Received: from localhost ([::1]:52372 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i0Vd6-0000q4-FS for importer@patchew.org; Wed, 21 Aug 2019 14:46:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44670) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i0Ul0-0003Ng-3e for qemu-devel@nongnu.org; Wed, 21 Aug 2019 13:50:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i0Uky-0005Q8-D5 for qemu-devel@nongnu.org; Wed, 21 Aug 2019 13:50:49 -0400 Received: from esa4.mentor.iphmx.com ([68.232.137.252]:13357) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i0Uky-0005KR-4X for qemu-devel@nongnu.org; Wed, 21 Aug 2019 13:50:48 -0400 Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa4.mentor.iphmx.com with ESMTP; 21 Aug 2019 09:50:47 -0800 IronPort-SDR: mMk/178bEhjfPxnXcVEpDQFhPQDF25KQIduSBTapHiQ9KJyUGueNW39tuizfPew/RUmOX1qrsk F/JumlHbYxD3Ffli/peWqL5FMM6p8+cPif8nghFt11lnsvp6qA3nSqN1l2n3pNzzyiU3RMMMYU J9LKLLs/6LlwBSPVxHhIEPNQ8VOag4roIEp5CfNuA1s6jPJoYz5CdQ8YdVNrzSZ0hiH4uHzvqJ cMsKssJfEYuKQJp0oXPUTyu4SYkIcYqmLtzunrOW3g05SDVmh0OSG1KQ03s/+F3gmrUuSQOD1X EPE= X-IronPort-AV: E=Sophos;i="5.64,412,1559548800"; d="scan'208";a="40657528" IronPort-SDR: fR6Nskbae+WoPyVgvYJTlkBPQsF5qFiXcNSd+Rk0bN4EahWXa8lZSiNmgNXWNVcUpx7XnkQT0d QJoS7mVEmBJ2kPWDG9K93KbaRp/rfKbD9q2psIv73RIglGt3VY6yd3z7T8s+mADMeNYHcGbb5b wN039HxVcQg4HHveigD75k2C5QWzwQP88bwaa4RV/EFXGvTpYKH1UmzMYCDTjfkK9m4kLnNm3w cF0NpQiWeAAigrvsDGFR8K/7TcJBY+QN0lfbq4682JZcdJZFIk1nmWaxzGcF97lQ96/VWVNi1J m3Y= From: Sandra Loosemore To: Date: Wed, 21 Aug 2019 11:50:28 -0600 Message-ID: <20190821175029.21868-2-sandra@codesourcery.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190821175029.21868-1-sandra@codesourcery.com> References: <20190821175029.21868-1-sandra@codesourcery.com> MIME-Version: 1.0 X-ClientProxiedBy: SVR-ORW-MBX-07.mgc.mentorg.com (147.34.90.207) To svr-orw-mbx-03.mgc.mentorg.com (147.34.90.203) X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x X-Received-From: 68.232.137.252 Subject: [Qemu-devel] [PATCH V2 1/2] target/nios2: Fix bug in semihosted exit handling 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: Marek Vasut , Chris Wulff , Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This patch fixes a bug that caused semihosted exit to always return status 0; it was incorrectly using the value of register R_ARG0 (which contains the HOSTED_EXIT request number) instead of register R_ARG1. Note that per the newlib documentation for the nios2 semihosting protocol https://www.sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;a=3Dblob;f= =3Dlibgloss/nios2/nios2-semi.txt;h=3Dded3a093c03dbae84cb95b4cd45bc3e0d751ed= a2;hb=3DHEAD for the HOSTED_EXIT syscall the parameter is passed directly in the register instead of in a parameter block pointed to by the register. Signed-off-by: Sandra Loosemore Reviewed-by: Laurent Vivier --- target/nios2/nios2-semi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/nios2/nios2-semi.c b/target/nios2/nios2-semi.c index d7a80dd..06c0861 100644 --- a/target/nios2/nios2-semi.c +++ b/target/nios2/nios2-semi.c @@ -215,8 +215,8 @@ void do_nios2_semihosting(CPUNios2State *env) args =3D env->regs[R_ARG1]; switch (nr) { case HOSTED_EXIT: - gdb_exit(env, env->regs[R_ARG0]); - exit(env->regs[R_ARG0]); + gdb_exit(env, env->regs[R_ARG1]); + exit(env->regs[R_ARG1]); case HOSTED_OPEN: GET_ARG(0); GET_ARG(1); --=20 2.8.1