From patchwork Fri Jan 15 13:08:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 363638 Delivered-To: patch@linaro.org Received: by 2002:a02:ccad:0:0:0:0:0 with SMTP id t13csp307471jap; Fri, 15 Jan 2021 05:44:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJyPyYRhqRZ+Ls1D/juxj6GciMv7ECnwzZOwe1+DVfehbGc9U75eAc0qG+8lv46VzzAiPfkg X-Received: by 2002:a25:c614:: with SMTP id k20mr9759490ybf.371.1610718279008; Fri, 15 Jan 2021 05:44:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610718279; cv=none; d=google.com; s=arc-20160816; b=hRwbegQsOhgGyXuPWFOegKJNlgDuy1omVzozIOgDyDhxspEYH56m/KvVu/HNTi7PxW AQwgC6ATu0//p05vmXz614GGqtEUiZOwzWxoW9PI7kA26U0zpOZwNBATWK/uswVb2GPS emu3vzZ6R0vCNOSAOmlZFbmkzgq+Lu+4n6QUu+ISq4gYMsN2ayGNaJYOwbBzqukF4Sdk dSwboSduzzY3hpT/W+WsA4aZ2+OnamaWppmnrlA01OpD1K7Sdi8sVvVWR1xIBZGRLKNi S+3h2xIQ46gvNgkXgLseQR1bulD/UL42Bld0BiGHoXwLORhWObjL25xyoPhmxxlriuS1 ACDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=muCsYbQEcoe3YnIMkqZAOUWb9L93swjFn/KxNUvS9X4=; b=NnrktHpneUjP3RPz0maxUyO6GhF0KwmtSMH/PqPAj3QTJmomYAurCE6vAQNdrz9Yca RQJqtyofcbhQWjhlkYPVXiqQfsiSYjwHcZQhENt/Y3hwVEOHXYuEhplzrPlw6If2RXfg /4zVfb7R+68wX75zSmw0og94dagSvnuBSe6mxIFXgLXNQaysn5E294pw1MfEexLbQwgt /e6cQvn1FHU+CDoRW5g4LOAd76n7t+JY02VzvPNEJ5F37k/yL5t1UyUTO8nZFSFQTEGr xdWDgKG4vImkDah4mEGukx8JhVyxgPoKi2i4vnzv1z08JmcQTs5Xd9UUlSnil4Hzspku hDWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=cm8QpXwU; 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 s5si8181941ybq.464.2021.01.15.05.44.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Jan 2021 05:44:38 -0800 (PST) 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=cm8QpXwU; 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]:41970 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l0PP4-00052E-CG for patch@linaro.org; Fri, 15 Jan 2021 08:44:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39724) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l0P0A-0005GV-0K for qemu-devel@nongnu.org; Fri, 15 Jan 2021 08:18:54 -0500 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:39076) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l0P04-0002Lk-AA for qemu-devel@nongnu.org; Fri, 15 Jan 2021 08:18:53 -0500 Received: by mail-wr1-x431.google.com with SMTP id c5so9249525wrp.6 for ; Fri, 15 Jan 2021 05:18:45 -0800 (PST) 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=muCsYbQEcoe3YnIMkqZAOUWb9L93swjFn/KxNUvS9X4=; b=cm8QpXwUSuihR+6C1Lt4bH5gTT4ymKGuR4utKpSgrPJWxHtmewtUJWMvcprAHu19ab mGdKHYYvCPfTIngViG77DmRbcRl26YTCLots5v6pn8tefs/WtXhK5a6rVuET2e98PGi7 uEuBYDho8BCt6P5hvwO+vmH17MFU1ljKwT2wXUr3QKgRkMbItJEZHqv24ibmfWjHQG7L cGyv5eBkZVggVXANqQRJCphn64u+x4iipyYnvwllUahpM5IvL8U0MM3kERKOdPgH3Mw2 VY5NUtqRjwVYrpU384pq68yEJ8PuQFht0mkhXHCNFvkNGyvsMHrN5J+sGijIk7cPrtXH F+3w== 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=muCsYbQEcoe3YnIMkqZAOUWb9L93swjFn/KxNUvS9X4=; b=pmht1oxKpbGyy+OtDnRFPAn+ux6lxAKdmLw9xQWsOp8jxVj6GjpLOyJm/VcyR/4fAF fPHeruJcJJjAMofESHq47Sj783XpL75hWZ+lL7GeBptRW6MgRwTwQKvoe4orbacQqimg JPOYjHlmtBgnZSFac70NH/sMW5a3yTPB8nv+46SJn/ZiC7h4D5vLYQiBg1MDDaQf0pGw lS3O18Eo2Hlka5uKLEsvA+FXf8FACjnQUmxwdFVj67quDeNq4ZXRn7uxg69Hl7hjMdsT XuFS/98gz6suTbSmQuvtfVQ5Y4+Br30RnOJbeBG5lTGTkiBja+xo7kVArtTSlY5kA2Qu L/Kg== X-Gm-Message-State: AOAM532KnEs2yKf1kO0W+y+hvKdmpdfl9+l6f0z+pTwzyaKBFFutKQiX aYua8YsC/bX02vu9Ua7O4BloFw== X-Received: by 2002:a5d:5704:: with SMTP id a4mr13211102wrv.37.1610716724818; Fri, 15 Jan 2021 05:18:44 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id c190sm12346612wme.19.2021.01.15.05.18.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jan 2021 05:18:33 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 61B3C1FFB4; Fri, 15 Jan 2021 13:08:35 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 29/30] semihosting: Implement SYS_TMPNAM Date: Fri, 15 Jan 2021 13:08:27 +0000 Message-Id: <20210115130828.23968-30-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210115130828.23968-1-alex.bennee@linaro.org> References: <20210115130828.23968-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x431.google.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, RCVD_IN_DNSWL_NONE=-0.0001, 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: Keith Packard , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Keith Packard Part of Semihosting for AArch32 and AArch64 Release 2.0 Signed-off-by: Keith Packard Signed-off-by: Alex Bennée Message-Id: <20210107170717.2098982-9-keithp@keithp.com> Message-Id: <20210108224256.2321-20-alex.bennee@linaro.org> -- 2.20.1 diff --git a/hw/semihosting/arm-compat-semi.c b/hw/semihosting/arm-compat-semi.c index 3d6604dcdd..a631904fb0 100644 --- a/hw/semihosting/arm-compat-semi.c +++ b/hw/semihosting/arm-compat-semi.c @@ -835,6 +835,7 @@ target_ulong do_common_semihosting(CPUState *cs) CPUArchState *env = 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) 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 = (target_ulong) -1; + + /* Make sure there's enough space in the buffer */ + if (strlen(s) < arg2) { + char *output = lock_user(VERIFY_WRITE, arg0, arg2, 0); + strcpy(output, s); + unlock_user(output, arg0, arg2); + ul_ret = 0; + } + free(s); + return ul_ret; case TARGET_SYS_REMOVE: GET_ARG(0); GET_ARG(1);