From nobody Tue Nov 18 04:28:31 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1607977371; cv=none; d=zohomail.com; s=zohoarc; b=nU8S3RB7JtMSbb/9onwhJMiva4aqUB6AA2hT6KC7sSMV1R8mvwXHXtZhrMa6oyJqkxpWRUzl3hABwiSZqnr5vrPmvIVdF46+MeKuMt+Fc8JfEqc64frvviXrcmyCefn8KwCS96K6y1pQbUiorQGrWdlz4U01Hc1hiqttA19Etrs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607977371; 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:Reply-To:References:Sender:Subject:To; bh=D7RyhcGqk00Azp53vjwcq+tBOBajGKUzjE+kCsGHKxo=; b=N2WMgxG3FQn2Ui1F382V951dQO8RPb35NQpHK59ci3Q979mlquBHhjGA4KMp4PQP1XRrf+wL758icVOf8Q01OuyvwmuXxjb5JMjYYEeCS+SxzkMHSnFVJ55JT0tmY+IFS6cxPR7vigUUaivgQqPkNLWSw5YJfLdGFXH8EiyuDx0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass 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 SMTP id 1607977371115457.5884657651088; Mon, 14 Dec 2020 12:22:51 -0800 (PST) Received: from localhost ([::1]:34784 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kouEO-0008A9-Pz for importer@patchew.org; Mon, 14 Dec 2020 15:14:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40694) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kou82-0001B1-9k; Mon, 14 Dec 2020 15:07:30 -0500 Received: from home.keithp.com ([63.227.221.253]:51870 helo=elaine.keithp.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kou7z-0004H3-GG; Mon, 14 Dec 2020 15:07:30 -0500 Received: from localhost (localhost [127.0.0.1]) by elaine.keithp.com (Postfix) with ESMTP id D965F3F2E37D; Mon, 14 Dec 2020 12:07:20 -0800 (PST) Received: from elaine.keithp.com ([127.0.0.1]) by localhost (elaine.keithp.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id EnWiC6NnVfvt; Mon, 14 Dec 2020 12:07:20 -0800 (PST) Received: from keithp.com (koto.keithp.com [10.0.0.2]) by elaine.keithp.com (Postfix) with ESMTPSA id C99493F2E391; Mon, 14 Dec 2020 12:07:17 -0800 (PST) Received: by keithp.com (Postfix, from userid 1000) id 5964F1582298; Mon, 14 Dec 2020 12:07:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=keithp.com; s=mail; t=1607976440; bh=AY23CfBi0c3vtSQCvpxnzKbVG3QpC88qHLH0dGoVpoI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F4DhU0zkZL89XzzLTcsmt+odzuBk4TMpQH0ZNS25zBVNqS4y/eQ0fjZ06k+wyufyb 9FlUvkf5JHzFZVZXI/gp3GTMMFRYiuqt1MA9PTbryEw2YaDCih+tLoz8eoI6CNygPO L0Bv8S+5Ps4cvuwsZ2AziOTlU5Kj51WGH4OS2lp59a4DWjBhYxegcF25/fgxhN+R2K XbhSYCzolyJih3+/V/scdIct3Tebe8xX4oZL36/1TftDUvDN3oj9nB98pILMLU1PYW +/7eM0FvFXknSZmJGueP4kVZjp4u4+q3XilvU4PNgKTLSJkBOkvyriFalZ/eFxio1i YztD4EnozOeGQ== X-Virus-Scanned: Debian amavisd-new at keithp.com DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=keithp.com; s=mail; t=1607976437; bh=AY23CfBi0c3vtSQCvpxnzKbVG3QpC88qHLH0dGoVpoI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=woPLroOD667jpLIvfckXEoyx0d1jgITfLVKizZm7SGP6zEAdSbsXLTKSD84Tac0cv Bp9p0qroqDceD0XI1ztXljgEARTqs3nhAfmPMpLyleXMMS89YqbXVtVZD/d0R7PrTV gH55FkFrhotquAHmejt2vJnw6nOCd0LrBToXZEWWulKQlWacCmRFkJxLSBaf/D4F1S jrAvrO1Vn+m4UWSR9XXJVk5De1XWsznlpXaqv36WnVGHL5D69tAlc8VfroTmOxFEuh 7LItHvaRvl/W/7nPUZ8YFNoarMlJbnyMLWhAuGVa040TXpgF0fjgIxMecQ7AR1+hij vCpt7pGLTpmww== To: qemu-devel@nongnu.org Subject: [PATCH 8/9] semihosting: Implement SYS_TMPNAM Date: Mon, 14 Dec 2020 12:07:12 -0800 Message-Id: <20201214200713.3886611-9-keithp@keithp.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201214200713.3886611-1-keithp@keithp.com> References: <87wnxktost.fsf@linaro.org> <20201214200713.3886611-1-keithp@keithp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=63.227.221.253; envelope-from=keithp@keithp.com; helo=elaine.keithp.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Peter Maydell , Keith Packard , qemu-riscv@nongnu.org, Sagar Karandikar , Bastian Koppelmann , Laurent Vivier , qemu-arm@nongnu.org, Alistair Francis , Palmer Dabbelt , =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Reply-to: Keith Packard From: Keith Packard via X-ZohoMail-DKIM: fail (found 2 invalid signatures) Content-Type: text/plain; charset="utf-8" Part of Semihosting for AArch32 and AArch64 Release 2.0 Signed-off-by: Keith Packard --- hw/semihosting/common-semi.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/hw/semihosting/common-semi.c b/hw/semihosting/common-semi.c index b1368d945c..b0648c3812 100644 --- a/hw/semihosting/common-semi.c +++ b/hw/semihosting/common-semi.c @@ -835,6 +835,7 @@ target_ulong do_common_semihosting(CPUState *cs) CPUArchState *env =3D cs->env_ptr; target_ulong args; target_ulong arg0, arg1, arg2, arg3; + target_ulong ul_ret; char * s; int nr; uint32_t ret; @@ -998,8 +999,24 @@ target_ulong do_common_semihosting(CPUState *cs) =20 return guestfd_fns[gf->type].flenfn(cs, gf); case TARGET_SYS_TMPNAM: - qemu_log_mask(LOG_UNIMP, "%s: SYS_TMPNAM not implemented", __func_= _); - return -1; + GET_ARG(0); + GET_ARG(1); + GET_ARG(2); + if (asprintf(&s, "/tmp/qemu-%x%02x", getpid(), + (int) (arg1 & 0xff)) < 0) { + return -1; + } + ul_ret =3D (target_ulong) -1; + + /* Make sure there's enough space in the buffer */ + if (strlen(s) < arg2) { + char *output =3D lock_user(VERIFY_WRITE, arg0, arg2, 0); + strcpy(output, s); + unlock_user(output, arg0, arg2); + ul_ret =3D 0; + } + free(s); + return ul_ret; case TARGET_SYS_REMOVE: GET_ARG(0); GET_ARG(1); --=20 2.29.2