From patchwork Tue Jun 28 11:16:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 585567 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5036:0:0:0:0 with SMTP id e22csp662584mab; Tue, 28 Jun 2022 04:18:18 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uQ4sc1e4mXny0y3POuI834N2EF4Q4X+OdL1eRpFRj581wunnD0fmrUI74xBLLHelUVUA5c X-Received: by 2002:a05:6214:300f:b0:470:4e32:5463 with SMTP id ke15-20020a056214300f00b004704e325463mr1679213qvb.123.1656415098380; Tue, 28 Jun 2022 04:18:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656415098; cv=none; d=google.com; s=arc-20160816; b=VF1mX3rncGMfh8+s6ysN2YIVKV5uCzY6CY1YF7J9OCGgV3YgZ/hcp6Kqmc5YpiCh8B /uK3ifZWA4pKMcZWlc/pm7Hx+uoRklAfGtAAya95C0IFxm0I8zVLhLePmCVOjevqXwwf xmNyIwMFaCt4f4OaS4UTjTEZArFquP6RpOLQ7YvjKhe8S5pt5Kae5hBIgfjLLIwNw1BH TUKk7wkpCxnSgALaM0U4nzGSBBdy+CVuH9/cRYNhy32f9iErhaTQ6ULXrD1tVXSlm1WU Mz13JWP+KxBJEhopPi3pP/q/eIXOnkNR0oCLnem8YjTq4iWnw0hvSgurUYb3CaWl7oc3 gWbg== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zerCkHOdwKIBilTQCtBXa5Y3gI08+JACKBxg6I39kUQ=; b=X2tkll3CXpkEd+L1TM18jQKbalfZLvcQb7fCuWe+lfWdTn7xJ54ZX3XWinBP/LAU26 YgEz+GqRxEAhpEY9oF2eue84yMiYFpHCzju3RqCzsdvGa1/m+4eaCl7GxaTx0lUDhaDR bfs5I5BlU9jtcxx2rulHokjbo+AVcGN9Dlq8ovcthlFFIsUBeXz8psEUHIaLNQFjg5ue vvi8fC1zoGf+iI9RRIxMAubPwIBhGayKIpnd3XXNELluP80LVp80oXk27F8s3+2RR/vk QaHemcWxft+bw3buoY8b+//3uYg433yY5F3mZYdZovhH/T6Ixdb1QCtwPLMda8yNK6oq /tfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZlAM4Rw6; 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=pass (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 ay7-20020a05620a178700b006af3bc4ca93si1768792qkb.725.2022.06.28.04.18.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Jun 2022 04:18:18 -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=pass header.i=@linaro.org header.s=google header.b=ZlAM4Rw6; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:35540 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o69EX-0003dx-Uk for patch@linaro.org; Tue, 28 Jun 2022 07:18:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41200) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o69DW-0003bP-Sg for qemu-devel@nongnu.org; Tue, 28 Jun 2022 07:17:14 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]:34517) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o69DV-0003Au-9U for qemu-devel@nongnu.org; Tue, 28 Jun 2022 07:17:14 -0400 Received: by mail-pl1-x633.google.com with SMTP id jh14so10789696plb.1 for ; Tue, 28 Jun 2022 04:17:12 -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=zerCkHOdwKIBilTQCtBXa5Y3gI08+JACKBxg6I39kUQ=; b=ZlAM4Rw6H4MrIzKVS9yfMRhMGN1jqF4P5Y98hGgPfM0ntYCf7q2h4gHN70n6oWoBp9 V6Gzm5tfRsNy9ylnEWw28LqLytT9+yHYmNOKkkWY8b8+VxAN0mNqx51tgYSGVubWlZpS oVcDLB124aMITc46mHwCwYtVKyjAkmWNJFwS5314TVXthwKAQcJxJanl8kLbjbkY52ab 34D4TKx0nCw26Pi4Bw6nCUi+lhjF2qagmmGQd2ViMZnECdTg2UzJ5LmWxBOiu49p7Bml KV1T6s46Ls1Xro+jNjh3iPbJpYZFsDHTVQd+1JPBkeTFfPagS0460gM6kwiKBgAVdrzQ jYDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zerCkHOdwKIBilTQCtBXa5Y3gI08+JACKBxg6I39kUQ=; b=hCQM7NrPKxF3IcAI048vWH5XUuZxfdgiALXrn3R/HUG8BmNm1ICzBhbWivWF38Squt JSNhV9ZiW3uzGrG6QfCd4lnqKmDHwEW/oTR/UA0yCKzQqc1NFWyPciIkJr5SKWn4dyR9 hQbWuewEqiqQ+LoxpF4YNf3X/DWrVmtY7qUUjzOxaj9rIwwY1FxJNouyGx6ZzoNWAzMS /EBKgQnCjQLB+wbSxninjC0rYp3VjTi2NXYIm+1jeci5Jw+xfLVa3T3uzXp+02vxD2aV llJEnAIxv8+yCKOlL2O7yiwxJNMxYI+S648Qn79hP87EdVW0XtWHLTgHPN41yRy8kaWH iZCA== X-Gm-Message-State: AJIora9vVkp3HsMdVlrqocjDOspB7UfBd0u5NSt6fx37k8dSWGfogs5K PIR+trsyDyF08XiFsBbzxFrOImHqa8y2Ig== X-Received: by 2002:a17:902:d718:b0:168:d9df:4f1c with SMTP id w24-20020a170902d71800b00168d9df4f1cmr4306171ply.41.1656415031792; Tue, 28 Jun 2022 04:17:11 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id a8-20020a654188000000b003fd4831e6fesm9079283pgq.70.2022.06.28.04.17.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jun 2022 04:17:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: f4bug@amsat.org, alex.bennee@linaro.org, jiaxun.yang@flygoat.com, aleksandar.rikalo@syrmia.com Subject: [PATCH v5 1/8] target/mips: Create report_fault for semihosting Date: Tue, 28 Jun 2022 16:46:54 +0530 Message-Id: <20220628111701.677216-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220628111701.677216-1-richard.henderson@linaro.org> References: <20220628111701.677216-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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 UHI specification does not have an EFAULT value, and further specifies that "undefined UHI operations should not return control to the target". So, log the error and abort. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/mips/tcg/sysemu/mips-semi.c | 33 ++++++++++++++---------------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/target/mips/tcg/sysemu/mips-semi.c b/target/mips/tcg/sysemu/mips-semi.c index 67c35fe7f9..153df1fa15 100644 --- a/target/mips/tcg/sysemu/mips-semi.c +++ b/target/mips/tcg/sysemu/mips-semi.c @@ -114,6 +114,13 @@ enum UHIErrno { UHI_EXDEV = 18, }; +static void report_fault(CPUMIPSState *env) +{ + int op = env->active_tc.gpr[25]; + error_report("Fault during UHI operation %d", op); + abort(); +} + static int errno_mips(int host_errno) { /* Errno values taken from asm-mips/errno.h */ @@ -136,8 +143,7 @@ static int copy_stat_to_target(CPUMIPSState *env, const struct stat *src, hwaddr len = sizeof(struct UHIStat); UHIStat *dst = lock_user(VERIFY_WRITE, vaddr, len, 0); if (!dst) { - errno = EFAULT; - return -1; + report_fault(env); } dst->uhi_st_dev = tswap16(src->st_dev); @@ -188,8 +194,7 @@ static int write_to_file(CPUMIPSState *env, target_ulong fd, int num_of_bytes; void *dst = lock_user(VERIFY_READ, vaddr, len, 1); if (!dst) { - errno = EFAULT; - return -1; + report_fault(env); } num_of_bytes = write(fd, dst, len); @@ -204,8 +209,7 @@ static int read_from_file(CPUMIPSState *env, target_ulong fd, int num_of_bytes; void *dst = lock_user(VERIFY_WRITE, vaddr, len, 0); if (!dst) { - errno = EFAULT; - return -1; + report_fault(env); } num_of_bytes = read(fd, dst, len); @@ -220,7 +224,7 @@ static int copy_argn_to_target(CPUMIPSState *env, int arg_num, int strsize = strlen(semihosting_get_arg(arg_num)) + 1; char *dst = lock_user(VERIFY_WRITE, vaddr, strsize, 0); if (!dst) { - return -1; + report_fault(env); } strcpy(dst, semihosting_get_arg(arg_num)); @@ -233,9 +237,7 @@ static int copy_argn_to_target(CPUMIPSState *env, int arg_num, do { \ p = lock_user_string(addr); \ if (!p) { \ - gpr[2] = -1; \ - gpr[3] = EFAULT; \ - return; \ + report_fault(env); \ } \ } while (0) @@ -243,16 +245,11 @@ static int copy_argn_to_target(CPUMIPSState *env, int arg_num, do { \ p = lock_user_string(addr); \ if (!p) { \ - gpr[2] = -1; \ - gpr[3] = EFAULT; \ - return; \ + report_fault(env); \ } \ p2 = lock_user_string(addr2); \ if (!p2) { \ - unlock_user(p, addr, 0); \ - gpr[2] = -1; \ - gpr[3] = EFAULT; \ - return; \ + report_fault(env); \ } \ } while (0) @@ -375,7 +372,7 @@ void mips_semihosting(CPUMIPSState *env) break; #endif default: - fprintf(stderr, "Unknown UHI operation %d\n", op); + error_report("Unknown UHI operation %d", op); abort(); } return; From patchwork Tue Jun 28 11:16:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 585570 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5036:0:0:0:0 with SMTP id e22csp664552mab; Tue, 28 Jun 2022 04:21:37 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sk2/SugZjqejMqVL0TLzFz6dhN/1AMvpjxUTx80rgTTU2j53F40y0Gg6PO+AWbJwFWRKuG X-Received: by 2002:a05:620a:269a:b0:680:a5c5:954e with SMTP id c26-20020a05620a269a00b00680a5c5954emr10956817qkp.468.1656415297098; Tue, 28 Jun 2022 04:21:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656415297; cv=none; d=google.com; s=arc-20160816; b=l02iRbdGYRatV9E0AfGdQmJ8XUFRz8y6LvzJTerCBhROZkAle2T66hgp4vDmZZgEwX KSuzDem4xc55b2Tdwc9VH1fPTD8hYDPDOcQ5xV7u0bkvvEsg97ER4Ib6wriaulH43RIC bj7+fn0KwkR06aENE5AVIWTkzbp/q2IM71xWusQIrQ9euDl0UAGLfsR8ho+36KOQumpN shlv6DoVOwCG0+PFVrw6kQLfKEQA7971+GWxe8Ek/UZAsy1nF+plByN0UcVt6drnO06h j/+Ur3riA2+e9PQ+A2qW9xoFIodbdbFl3jH4vbwbz8ejReji/tznSPy5z0g/pMRB7eqr CsiA== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+UObdrhqrhV3XMbtzMZ8fVzyxK5zVU9oY2exQJ4RAHc=; b=a31Mwlsj1XZoV/RWjrsCoZZo/PVOIk0HgYiUwk6vElMFWeGc681phuKFyyVcrdejkb NtNC/7kjZWw6YGN2/gReh93pzNBp5A0c2daH9aqPEs6E/QG6Z3PDN46W67TXfQ/xhm9x LJXgTU3cPqTKD/5SqrEeaEfJ9QxvakhaJb8DfQ+QsBRJv510Dg3/fAN/R/jo3SYjGohl HBDwwDyLFol6tmbtxwiPBN23DZCmkkzpESnsfL+XOi/CDrxb4+Yz8+EE1mVCQvGyXeig 0nVamsze7uHavg9SAWv4Zyfjaa1/fIWSMXpBo46YPKwXX5f2o4ffzBMFLNRrjZkdJpiV I+3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EvSFEhQe; 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=pass (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 jp13-20020ad45f8d000000b004708ee85323si7188650qvb.475.2022.06.28.04.21.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Jun 2022 04:21:37 -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=pass header.i=@linaro.org header.s=google header.b=EvSFEhQe; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:42258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o69Hk-0008Dq-N4 for patch@linaro.org; Tue, 28 Jun 2022 07:21:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41216) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o69DZ-0003h3-Qw for qemu-devel@nongnu.org; Tue, 28 Jun 2022 07:17:17 -0400 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]:40799) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o69DY-0003B4-BY for qemu-devel@nongnu.org; Tue, 28 Jun 2022 07:17:17 -0400 Received: by mail-pg1-x535.google.com with SMTP id 9so11884901pgd.7 for ; Tue, 28 Jun 2022 04:17:15 -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=+UObdrhqrhV3XMbtzMZ8fVzyxK5zVU9oY2exQJ4RAHc=; b=EvSFEhQecEMcBjKHhmr6sk9mcjFsrq/lB/2scymTi9l6/lTpHM94olic4sE9PHQlwR Jrc49qnEiZuVZXvpetkwDbx1NuidM/tuPCdpivTtz/VTC1LX+lMaPnciVCuRb8hA9l1P W0PrPER7jvvFzsj7UQ+PANkz/JNhiXa/7ADggz8aCWZ0p/hAOkc6nUh6qsa1uUVKHO2a tCuSIGsoHEQ1k9PrF2rVREDwA1aRnWKf7mnpx8819YfJi0fZdb5pDYwQUYkZqtIFasqa r/PJ7D7+Aeaf3ZJvOHpwd5AZlyCSsjy8pyWu2HCHAiB9GACE/I3VGQXjXEd1g7M2BeFV g3wQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+UObdrhqrhV3XMbtzMZ8fVzyxK5zVU9oY2exQJ4RAHc=; b=1Y39TTffrbQYsDk7HlnQO5YoM3rRq4Pw2mk2ownLPkI/BUnfPjc0DOPuhmXmFgKhv4 r4P/pWe/jszyU0c+dcd55GQdv1Q5rrlAXfjo8Udd6rVj0DDxCf479rIK2hbkRWsHnxR3 /pYzq4htEmkD9UxP6/3boTj0bHhLbOMPRPa4K+ly2Xx/1Ue2iv95pwW/Uns2FrZPwoyy V+rUX5vtcukzNlcqMev3+sJeTLmt4aeVFk0ibeqYgfTsmcOtODgQgfgffHGYjSNXueOH 1XXdft2i4mFHzY/9YeZq2J4U8Js0QR4alF/BJEKHlPE1UrfQFpF7IsPWaWmsJ7pv7ngI MGbw== X-Gm-Message-State: AJIora/HjNaBxdnyntu4MwUW2rm47EInbMVniyGhEEKXeNURxQEfOj3J qqzt5rcBnTkaqnYUyeTT9me2r3BQWZiRng== X-Received: by 2002:aa7:81d4:0:b0:525:1ead:17af with SMTP id c20-20020aa781d4000000b005251ead17afmr3102526pfn.71.1656415034943; Tue, 28 Jun 2022 04:17:14 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id a8-20020a654188000000b003fd4831e6fesm9079283pgq.70.2022.06.28.04.17.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jun 2022 04:17:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: f4bug@amsat.org, alex.bennee@linaro.org, jiaxun.yang@flygoat.com, aleksandar.rikalo@syrmia.com Subject: [PATCH v5 2/8] target/mips: Drop link syscall from semihosting Date: Tue, 28 Jun 2022 16:46:55 +0530 Message-Id: <20220628111701.677216-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220628111701.677216-1-richard.henderson@linaro.org> References: <20220628111701.677216-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::535; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x535.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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" We don't implement it with _WIN32 hosts, and the syscall is missing from the gdb remote file i/o interface. Since we can't implement it universally, drop it. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/mips/tcg/sysemu/mips-semi.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/target/mips/tcg/sysemu/mips-semi.c b/target/mips/tcg/sysemu/mips-semi.c index 153df1fa15..93c9d3d0b3 100644 --- a/target/mips/tcg/sysemu/mips-semi.c +++ b/target/mips/tcg/sysemu/mips-semi.c @@ -362,15 +362,6 @@ void mips_semihosting(CPUMIPSState *env) FREE_TARGET_STRING(p, gpr[4]); abort(); break; -#ifndef _WIN32 - case UHI_link: - GET_TARGET_STRINGS_2(p, gpr[4], p2, gpr[5]); - gpr[2] = link(p, p2); - gpr[3] = errno_mips(errno); - FREE_TARGET_STRING(p2, gpr[5]); - FREE_TARGET_STRING(p, gpr[4]); - break; -#endif default: error_report("Unknown UHI operation %d", op); abort(); From patchwork Tue Jun 28 11:16:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 585574 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5036:0:0:0:0 with SMTP id e22csp667089mab; Tue, 28 Jun 2022 04:25:31 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ulgVJKY5cYEPe63us7bbmIkOihK4D4ipmj9fMlE/9ogXA3p8iTqIt4j2ZWs02LmzUlJL4+ X-Received: by 2002:a05:622a:1014:b0:319:7601:c22 with SMTP id d20-20020a05622a101400b0031976010c22mr8974770qte.509.1656415531439; Tue, 28 Jun 2022 04:25:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656415531; cv=none; d=google.com; s=arc-20160816; b=Td8LppqzKG6wT7QnsrtIdVxt+jSK+FMQAy8NisfusbEgTkwkIvzgydmFnnsSauMnhp oLHTzCXFt3N4ChpquKrvVvLgAV3iZ47tjUagOj8MW71plRSf/7u1ivRDuviPywfDzlXg 2+xH4QaNIM68HqrCtt/D3LUFSnCtNEEQT39EEsxGXpBNzBjHyXGcMHYKGj21J97ipnc8 hoNDjMhCUVLhC0l1vALQlote599HPKrjOT/4b+jvuqb4yjB776DUUpNutFeca9AjJy6Z snoPkuf1gXpfzCQirPr/1V6Ni5PFFfjNO/5UJpzjPKDC5UTUsEmkO+VqKqWaY6P83GVj tZDQ== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=w6sA15MForuaAbeYWpiX93UQp8+cxumrK25JuRIu/m4=; b=KSkMqLEie+S/q3JeSEIH8/JGoWSabfC80gso79w3er+/R+rVX9X7I2wcALO7ceCJM9 yRJtoA+OVp9b13AoLXZLT2FhRJp9O/OQkHq46bQgxPnZ29LeRFqO0KN8zffRkM6MJ9H+ CrcLhMaBLhT1eOejRsqMZ/33SNTIyYkNgTUPEJNf4V0mliy0isXJlU24lcmc3yG0Rxig nlPtuJ/9ew9EL2at88sOlcTQ1iRxjRyxBRwjoXYPASzhBNRCcp8Vc4iSMSg1k/agcPAo pVfEvOenGL146OZMK5f0MONPWaxQjDyTj+wxJBMH3lgeBJUAIkkBkLmnpZ5STAlZ24jd CSQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IOzbJ02n; 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=pass (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 c69-20020a379a48000000b006a6c58a5ae4si6386318qke.168.2022.06.28.04.25.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Jun 2022 04:25:31 -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=pass header.i=@linaro.org header.s=google header.b=IOzbJ02n; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:49464 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o69LT-0004rJ-Pb for patch@linaro.org; Tue, 28 Jun 2022 07:25:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41242) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o69Dc-0003lV-Tm for qemu-devel@nongnu.org; Tue, 28 Jun 2022 07:17:20 -0400 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]:46700) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o69Db-0003Ak-0I for qemu-devel@nongnu.org; Tue, 28 Jun 2022 07:17:20 -0400 Received: by mail-pj1-x1031.google.com with SMTP id h9-20020a17090a648900b001ecb8596e43so12286038pjj.5 for ; Tue, 28 Jun 2022 04:17:18 -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=w6sA15MForuaAbeYWpiX93UQp8+cxumrK25JuRIu/m4=; b=IOzbJ02nBmlOJihZ38QTs2VsuwRlAU4cIvO6kJbgEhrGNihV/CXIG4TqxWyJLu6fTn K23lC4ulbfSoazLAa6owD9CR5vrjKwBAgjVn4RsdImhAGNXmJDnagKtPH3o4Nw08JYrM QFN1zZYUQyjoxfzLybMYxHJJSQ6RFqVSXE1yImQozmR9NOpXpWUj/ijc+rEbdGh7yyBo JTj8FuMl464gJ8Hs1RXe52ESKg5dKEE1fJOYypi1NJ8+gViKLXIfPro9KPgQExgYcPk9 bEOrvECr7T3xRPtIoVQnw1KMmZ26yJkBYz5QUljb5Hfci31aEgxefXASphTUAJJo/zhJ Wx2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=w6sA15MForuaAbeYWpiX93UQp8+cxumrK25JuRIu/m4=; b=2udH4hius1EKkwjsfDHB1LJn/L9dMGROT0niaM8Lhyu5t+KslrxkATX/G7VM5j77jZ vG41kh4wbjryzYXo+By9I2IJXa7naOSG1xVLphb6SA1vleVXoKtE3QTD4TMkMSm3A1Jf 0d/NyakFZkyEYssJ7PNjBujsrmB7R4Nx4ve5dmcNhbHVPmv6ZpjaMfqU6bl8PDAb9S7J 4BtKjEUkEDpO9gn7amDg2fi5eVsFgzG6zYpRqF06rUo5ZCKsLZyKeCyhnE1SKHqgEB+G a14fk72Ylu3fqhg7DQ1ICAgmLl/JCZUtRr7+um3VuKxaxNJimNvsKMVxE5avQ2h9dL2y nooA== X-Gm-Message-State: AJIora+BLw1S/gLJmBgfNBihSz7K6pqH73xVt+FMTIccFj6GVHHnh/P4 NB/tk6b52BEggKWYD/wVZyrhU8wQa2yPdw== X-Received: by 2002:a17:90a:c782:b0:1ec:eea2:4236 with SMTP id gn2-20020a17090ac78200b001eceea24236mr21127996pjb.20.1656415038236; Tue, 28 Jun 2022 04:17:18 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id a8-20020a654188000000b003fd4831e6fesm9079283pgq.70.2022.06.28.04.17.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jun 2022 04:17:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: f4bug@amsat.org, alex.bennee@linaro.org, jiaxun.yang@flygoat.com, aleksandar.rikalo@syrmia.com Subject: [PATCH v5 3/8] target/mips: Use semihosting/syscalls.h Date: Tue, 28 Jun 2022 16:46:56 +0530 Message-Id: <20220628111701.677216-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220628111701.677216-1-richard.henderson@linaro.org> References: <20220628111701.677216-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1031.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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" This separates guest file descriptors from host file descriptors, and utilizes shared infrastructure for integration with gdbstub. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Philippe Mathieu-Daudé --- target/mips/tcg/sysemu/mips-semi.c | 219 +++++++++++++---------------- 1 file changed, 95 insertions(+), 124 deletions(-) diff --git a/target/mips/tcg/sysemu/mips-semi.c b/target/mips/tcg/sysemu/mips-semi.c index 93c9d3d0b3..5b78cf21a7 100644 --- a/target/mips/tcg/sysemu/mips-semi.c +++ b/target/mips/tcg/sysemu/mips-semi.c @@ -20,9 +20,11 @@ #include "qemu/osdep.h" #include "cpu.h" #include "qemu/log.h" +#include "exec/gdbstub.h" #include "semihosting/softmmu-uaccess.h" #include "semihosting/semihost.h" #include "semihosting/console.h" +#include "semihosting/syscalls.h" #include "internal.h" typedef enum UHIOp { @@ -121,101 +123,79 @@ static void report_fault(CPUMIPSState *env) abort(); } -static int errno_mips(int host_errno) +static void uhi_cb(CPUState *cs, uint64_t ret, int err) { - /* Errno values taken from asm-mips/errno.h */ - switch (host_errno) { - case 0: return 0; - case ENAMETOOLONG: return 78; -#ifdef EOVERFLOW - case EOVERFLOW: return 79; -#endif -#ifdef ELOOP - case ELOOP: return 90; -#endif - default: return EINVAL; - } -} + CPUMIPSState *env = cs->env_ptr; -static int copy_stat_to_target(CPUMIPSState *env, const struct stat *src, - target_ulong vaddr) -{ - hwaddr len = sizeof(struct UHIStat); - UHIStat *dst = lock_user(VERIFY_WRITE, vaddr, len, 0); - if (!dst) { +#define E(N) case E##N: err = UHI_E##N; break + + switch (err) { + case 0: + break; + E(PERM); + E(NOENT); + E(INTR); + E(BADF); + E(BUSY); + E(EXIST); + E(NOTDIR); + E(ISDIR); + E(INVAL); + E(NFILE); + E(MFILE); + E(FBIG); + E(NOSPC); + E(SPIPE); + E(ROFS); + E(NAMETOOLONG); + default: + err = UHI_EINVAL; + break; + case EFAULT: report_fault(env); } - dst->uhi_st_dev = tswap16(src->st_dev); - dst->uhi_st_ino = tswap16(src->st_ino); - dst->uhi_st_mode = tswap32(src->st_mode); - dst->uhi_st_nlink = tswap16(src->st_nlink); - dst->uhi_st_uid = tswap16(src->st_uid); - dst->uhi_st_gid = tswap16(src->st_gid); - dst->uhi_st_rdev = tswap16(src->st_rdev); - dst->uhi_st_size = tswap64(src->st_size); - dst->uhi_st_atime = tswap64(src->st_atime); - dst->uhi_st_mtime = tswap64(src->st_mtime); - dst->uhi_st_ctime = tswap64(src->st_ctime); -#ifdef _WIN32 - dst->uhi_st_blksize = 0; - dst->uhi_st_blocks = 0; -#else - dst->uhi_st_blksize = tswap64(src->st_blksize); - dst->uhi_st_blocks = tswap64(src->st_blocks); -#endif - unlock_user(dst, vaddr, len); - return 0; +#undef E + + env->active_tc.gpr[2] = ret; + env->active_tc.gpr[3] = err; } -static int get_open_flags(target_ulong target_flags) +static void uhi_fstat_cb(CPUState *cs, uint64_t ret, int err) { - int open_flags = 0; + QEMU_BUILD_BUG_ON(sizeof(UHIStat) < sizeof(struct gdb_stat)); - if (target_flags & UHIOpen_RDWR) { - open_flags |= O_RDWR; - } else if (target_flags & UHIOpen_WRONLY) { - open_flags |= O_WRONLY; - } else { - open_flags |= O_RDONLY; + if (!err) { + CPUMIPSState *env = cs->env_ptr; + target_ulong addr = env->active_tc.gpr[5]; + UHIStat *dst = lock_user(VERIFY_WRITE, addr, sizeof(UHIStat), 1); + struct gdb_stat s; + + if (!dst) { + report_fault(env); + } + + memcpy(&s, dst, sizeof(struct gdb_stat)); + memset(dst, 0, sizeof(UHIStat)); + + dst->uhi_st_dev = tswap16(be32_to_cpu(s.gdb_st_dev)); + dst->uhi_st_ino = tswap16(be32_to_cpu(s.gdb_st_ino)); + dst->uhi_st_mode = tswap32(be32_to_cpu(s.gdb_st_mode)); + dst->uhi_st_nlink = tswap16(be32_to_cpu(s.gdb_st_nlink)); + dst->uhi_st_uid = tswap16(be32_to_cpu(s.gdb_st_uid)); + dst->uhi_st_gid = tswap16(be32_to_cpu(s.gdb_st_gid)); + dst->uhi_st_rdev = tswap16(be32_to_cpu(s.gdb_st_rdev)); + dst->uhi_st_size = tswap64(be64_to_cpu(s.gdb_st_size)); + dst->uhi_st_atime = tswap64(be32_to_cpu(s.gdb_st_atime)); + dst->uhi_st_mtime = tswap64(be32_to_cpu(s.gdb_st_mtime)); + dst->uhi_st_ctime = tswap64(be32_to_cpu(s.gdb_st_ctime)); + dst->uhi_st_blksize = tswap64(be64_to_cpu(s.gdb_st_blksize)); + dst->uhi_st_blocks = tswap64(be64_to_cpu(s.gdb_st_blocks)); + + unlock_user(dst, addr, sizeof(UHIStat)); } - open_flags |= (target_flags & UHIOpen_APPEND) ? O_APPEND : 0; - open_flags |= (target_flags & UHIOpen_CREAT) ? O_CREAT : 0; - open_flags |= (target_flags & UHIOpen_TRUNC) ? O_TRUNC : 0; - open_flags |= (target_flags & UHIOpen_EXCL) ? O_EXCL : 0; - - return open_flags; -} - -static int write_to_file(CPUMIPSState *env, target_ulong fd, - target_ulong vaddr, target_ulong len) -{ - int num_of_bytes; - void *dst = lock_user(VERIFY_READ, vaddr, len, 1); - if (!dst) { - report_fault(env); - } - - num_of_bytes = write(fd, dst, len); - - unlock_user(dst, vaddr, 0); - return num_of_bytes; -} - -static int read_from_file(CPUMIPSState *env, target_ulong fd, - target_ulong vaddr, target_ulong len) -{ - int num_of_bytes; - void *dst = lock_user(VERIFY_WRITE, vaddr, len, 0); - if (!dst) { - report_fault(env); - } - - num_of_bytes = read(fd, dst, len); - - unlock_user(dst, vaddr, len); - return num_of_bytes; + uhi_cb(cs, ret, err); } static int copy_argn_to_target(CPUMIPSState *env, int arg_num, @@ -260,68 +240,59 @@ static int copy_argn_to_target(CPUMIPSState *env, int arg_num, void mips_semihosting(CPUMIPSState *env) { + CPUState *cs = env_cpu(env); target_ulong *gpr = env->active_tc.gpr; const UHIOp op = gpr[25]; char *p, *p2; switch (op) { case UHI_exit: - qemu_log("UHI(%d): exit(%d)\n", op, (int)gpr[4]); + gdb_exit(gpr[4]); exit(gpr[4]); + case UHI_open: - GET_TARGET_STRING(p, gpr[4]); - if (!strcmp("/dev/stdin", p)) { - gpr[2] = 0; - } else if (!strcmp("/dev/stdout", p)) { - gpr[2] = 1; - } else if (!strcmp("/dev/stderr", p)) { - gpr[2] = 2; - } else { - gpr[2] = open(p, get_open_flags(gpr[5]), gpr[6]); - gpr[3] = errno_mips(errno); + { + int ret = -1; + + GET_TARGET_STRING(p, gpr[4]); + if (!strcmp("/dev/stdin", p)) { + ret = 0; + } else if (!strcmp("/dev/stdout", p)) { + ret = 1; + } else if (!strcmp("/dev/stderr", p)) { + ret = 2; + } + FREE_TARGET_STRING(p, gpr[4]); + + /* FIXME: reusing a guest fd doesn't seem correct. */ + if (ret >= 0) { + gpr[2] = ret; + break; + } + + semihost_sys_open(cs, uhi_cb, gpr[4], 0, gpr[5], gpr[6]); } - FREE_TARGET_STRING(p, gpr[4]); break; + case UHI_close: - if (gpr[4] < 3) { - /* ignore closing stdin/stdout/stderr */ - gpr[2] = 0; - return; - } - gpr[2] = close(gpr[4]); - gpr[3] = errno_mips(errno); + semihost_sys_close(cs, uhi_cb, gpr[4]); break; case UHI_read: - gpr[2] = read_from_file(env, gpr[4], gpr[5], gpr[6]); - gpr[3] = errno_mips(errno); + semihost_sys_read(cs, uhi_cb, gpr[4], gpr[5], gpr[6]); break; case UHI_write: - gpr[2] = write_to_file(env, gpr[4], gpr[5], gpr[6]); - gpr[3] = errno_mips(errno); + semihost_sys_write(cs, uhi_cb, gpr[4], gpr[5], gpr[6]); break; case UHI_lseek: - gpr[2] = lseek(gpr[4], gpr[5], gpr[6]); - gpr[3] = errno_mips(errno); + semihost_sys_lseek(cs, uhi_cb, gpr[4], gpr[5], gpr[6]); break; case UHI_unlink: - GET_TARGET_STRING(p, gpr[4]); - gpr[2] = remove(p); - gpr[3] = errno_mips(errno); - FREE_TARGET_STRING(p, gpr[4]); + semihost_sys_remove(cs, uhi_cb, gpr[4], 0); break; case UHI_fstat: - { - struct stat sbuf; - memset(&sbuf, 0, sizeof(sbuf)); - gpr[2] = fstat(gpr[4], &sbuf); - gpr[3] = errno_mips(errno); - if (gpr[2]) { - return; - } - gpr[2] = copy_stat_to_target(env, &sbuf, gpr[5]); - gpr[3] = errno_mips(errno); - } + semihost_sys_fstat(cs, uhi_fstat_cb, gpr[4], gpr[5]); break; + case UHI_argc: gpr[2] = semihosting_get_argc(); break; From patchwork Tue Jun 28 11:16:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 585575 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5036:0:0:0:0 with SMTP id e22csp670163mab; Tue, 28 Jun 2022 04:29:17 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s2YKVCh0OuaO9i5bxCQnJnh2dJ+u3ANVRM6Z/EVNrV70mRCsLOvdxPkePNPywuYiBUQ/E8 X-Received: by 2002:a05:622a:178d:b0:317:7102:d046 with SMTP id s13-20020a05622a178d00b003177102d046mr12404986qtk.645.1656415757557; Tue, 28 Jun 2022 04:29:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656415757; cv=none; d=google.com; s=arc-20160816; b=jbVtHS0Tu4DTq7quKfcZahgZv0PDgLoiQFWAmgbDZPLJi/Vq/i4ewrMB3Vc2Bpp+nN 7ONNlKbNEszbhiPrnJcWJQpw0s5Ti6H1CuljJOmH0nDb+3yJUXjO8QJ0RK2CKlNcqe4L SulY87rUjsZM8751EkGkiJtCugd78twWgqLA5voiLqPLVDT8nc/ucTbzo+2If+1vK/ZG fFDhTW+XtyPL614moTStfnlN7MXzX8n1NJ+M1tV8EkwNP4ED2vsWm3dBX98/wIHJWsFh loJBX6Ylq7Sx6Z9AVjMCK0maHqTWidPaHEcHmC/Zrr9bJyzKxMkA1V4DB81bltLpfYna GDxA== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=rmf1h8nOdErU6TZ6hYcqWua8rMBnQ07/JNvdx/MscPs=; b=GvWx0aq4FQIAnktaksm+k3cenhbl/m+q7dBt2p1JdUDJGFpjpJ+SJfNvDxU34kFeVc Mmsv+QmC0frGEcQhiTYnGjikr6HzQIlzVHbmQE2V4EpDmVaUXQuQNqvcdTAhsa2GX2uy gZtiNMQnkK2Cgyk3GpvfbETPuD07eI/LmvdiW8hWExW2BHRuQoiexgEYlyWx9dpujQAW kB48fdl/eVYTgYM707FsOWLixV9Vnt26UFFkcKAg2IFXAbhoZNzdwHyoXovfjsizYn/t 6TbpqMsdhcmMmug6NDxKRooAqNt7DTP7MUCvuUZCCCGjD1eGfa2Hi6BZxgMTqXTZ2WNH Ptaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ouguid+t; 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=pass (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 j15-20020a05620a410f00b006a66f3d3a28si9330643qko.629.2022.06.28.04.29.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Jun 2022 04:29:17 -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=pass header.i=@linaro.org header.s=google header.b=ouguid+t; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:57314 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o69PB-0002Yx-2F for patch@linaro.org; Tue, 28 Jun 2022 07:29:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41268) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o69Dg-0003tR-Cc for qemu-devel@nongnu.org; Tue, 28 Jun 2022 07:17:24 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]:45803) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o69De-0003BX-J3 for qemu-devel@nongnu.org; Tue, 28 Jun 2022 07:17:23 -0400 Received: by mail-pl1-x631.google.com with SMTP id d5so10740968plo.12 for ; Tue, 28 Jun 2022 04:17:22 -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=rmf1h8nOdErU6TZ6hYcqWua8rMBnQ07/JNvdx/MscPs=; b=ouguid+tSAGHPRXsP+HGdII8hmXvBG6zDRb3HcrqFWZZ7pvORmmPGTOJ3lYpv6tIxT HsQpopfZBCy+FFpnPEAETELzUkukxtx3RGVksQtNbAhwIErgTdL50I6Ko6fECqZO4dsz CkagfonMYNwComw+mwt1vAUj5AqkOjeD6JFT/jJuHUp+rROO31uy1eVT2wHRRaOI0VGV p5hAfMFPTmTtNMML4PD30F4o151KkxUbf5CFhK9F7m4hiDchzEu3XWVx9JCLF/bPSjfc XDloV+huBJvWfIUzD/VYkxteIo/+jJUWBNeZ4/B3IwXvdU8kP1AFqsc8kK5Yan9YT3oc ZQaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rmf1h8nOdErU6TZ6hYcqWua8rMBnQ07/JNvdx/MscPs=; b=NMkGvOdmGDk4+11ma5zJevH1i6PSsPMCMleXTHxVqmAub+pjfwkZ/puz8Sh7yK+bIv jdcxO/mWPdYFrBgT6kUmKz5Ppyn78AqpK9Q6VKx3cF+BNPddCy93ph5tSk/X1yexBSBa kw6zhMqGVKsrHykdhTaNKE/KO/Xe4xNe1xCK6/3emo+AZjld2a5Hqesbc3a7W73m+2Zv Ah7gUsEJNLTcwMVOcy/PZM6rto8AZX80Pd9IyVRzvNW3uSOc63PF5z2o88CHbA29NOKw i823nE+DM5Zwb/ElcgWPLHOzMg0er31vNTXlrwmQnItIOBEJFFjZdVZEuYW9vVEpm+/w klXQ== X-Gm-Message-State: AJIora9s9A7zlMH82DFpDvis2wBnwmyc94ndr0Xvol6Tz9lHf5Wnfi4S +UzISfW3w7uTgkWfB9daJxVUqZJoyyyxdw== X-Received: by 2002:a17:90b:17cb:b0:1ec:9d52:46f7 with SMTP id me11-20020a17090b17cb00b001ec9d5246f7mr21206084pjb.221.1656415041229; Tue, 28 Jun 2022 04:17:21 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id a8-20020a654188000000b003fd4831e6fesm9079283pgq.70.2022.06.28.04.17.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jun 2022 04:17:20 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: f4bug@amsat.org, alex.bennee@linaro.org, jiaxun.yang@flygoat.com, aleksandar.rikalo@syrmia.com Subject: [PATCH v5 4/8] target/mips: Avoid qemu_semihosting_log_out for UHI_plog Date: Tue, 28 Jun 2022 16:46:57 +0530 Message-Id: <20220628111701.677216-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220628111701.677216-1-richard.henderson@linaro.org> References: <20220628111701.677216-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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" Use semihost_sys_write and/or qemu_semihosting_console_write for implementing plog. When using gdbstub, copy the temp string below the stack so that gdb has a guest address from which to perform the log. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/mips/tcg/sysemu/mips-semi.c | 52 +++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 11 deletions(-) diff --git a/target/mips/tcg/sysemu/mips-semi.c b/target/mips/tcg/sysemu/mips-semi.c index 5b78cf21a7..ad11a46820 100644 --- a/target/mips/tcg/sysemu/mips-semi.c +++ b/target/mips/tcg/sysemu/mips-semi.c @@ -310,20 +310,50 @@ void mips_semihosting(CPUMIPSState *env) } gpr[2] = copy_argn_to_target(env, gpr[4], gpr[5]); break; + case UHI_plog: - GET_TARGET_STRING(p, gpr[4]); - p2 = strstr(p, "%d"); - if (p2) { - int char_num = p2 - p; - GString *s = g_string_new_len(p, char_num); - g_string_append_printf(s, "%d%s", (int)gpr[5], p2 + 2); - gpr[2] = qemu_semihosting_log_out(s->str, s->len); - g_string_free(s, true); - } else { - gpr[2] = qemu_semihosting_log_out(p, strlen(p)); + { + target_ulong addr = gpr[4]; + ssize_t len = target_strlen(addr); + GString *str; + char *pct_d; + + if (len < 0) { + report_fault(env); + } + p = lock_user(VERIFY_READ, addr, len, 1); + if (!p) { + report_fault(env); + } + + pct_d = strstr(p, "%d"); + if (!pct_d) { + FREE_TARGET_STRING(p, addr); + semihost_sys_write(cs, uhi_cb, 2, addr, len); + break; + } + + str = g_string_new_len(p, pct_d - p); + g_string_append_printf(str, "%d%s", (int)gpr[5], pct_d + 2); + FREE_TARGET_STRING(p, addr); + + /* + * When we're using gdb, we need a guest address, so + * drop the string onto the stack below the stack pointer. + */ + if (use_gdb_syscalls()) { + addr = gpr[29] - str->len; + p = lock_user(VERIFY_WRITE, addr, str->len, 0); + memcpy(p, str->str, str->len); + unlock_user(p, addr, str->len); + semihost_sys_write(cs, uhi_cb, 2, addr, str->len); + } else { + gpr[2] = qemu_semihosting_console_write(str->str, str->len); + } + g_string_free(str, true); } - FREE_TARGET_STRING(p, gpr[4]); break; + case UHI_assert: GET_TARGET_STRINGS_2(p, gpr[4], p2, gpr[5]); printf("assertion '"); From patchwork Tue Jun 28 11:16:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 585569 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5036:0:0:0:0 with SMTP id e22csp664403mab; Tue, 28 Jun 2022 04:21:20 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tjPAJfWqwe2M95tcHlauiFVxE33F22zC6LP7ruI3oUwa6T31ecLFTJ1QMzK4i5oZC6PvKN X-Received: by 2002:a05:620a:190a:b0:69c:3ee7:7c8d with SMTP id bj10-20020a05620a190a00b0069c3ee77c8dmr11028884qkb.743.1656415280445; Tue, 28 Jun 2022 04:21:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656415280; cv=none; d=google.com; s=arc-20160816; b=Kp58JUvZuBRkW2e63Mw8rHPS43UzcvoCW2dWHHnonkQ/OL8ev7XRky4OwP8mEmakuc 3/s/Rb1XM5gWlsanYKQKz1SjbwBFq1bi4VO0xnALb09Bs/55ZFZl5SDNPJ8EQQI0k9wt ng7Xv4+62Vn862qhfzPg9QgdpfuTbj3kFkBilVP23zKd1MRuWQprN/QaOKAIF8E4yxhH uMKY9g8YCzWWp49Wwq+WECvD2cJTPdFmjZF/o2RYBoJ9BK4M6ZpEEPpOXdLabsDIGGk5 /TtoT5LFFjKqtxfq1VMoDeHkBy+nfEnKUC+6+mHK52vA/6/p0w6pjTp2wlnzXD4ZbKeH A4wg== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=RM42zMRkI421HiARyMb/O/C2Vq6+9jMrjOfzX4mv7Y0=; b=LFzaJNJXTIIe5c8uD3JaCb4KWvKWxqk5jcFyIIF3XfMwYfgB3IUC62Yt6y/m9f7GkT IYaw4teKuRSTRbD3UjFcl3lSl7Ie2OM4m1rxu9RTV/hhHkVITH7gCu4iRZ5nFtSDncQw 51rBqb6JZBqpcJtWJaohZZKI/d7B31UEV8+nCRaxXF2572cAq1MAQ5DJUqPB0AavbQCm x2Z215xyAQOeuDTNLG8kL5eyDzzmXQwAymTB5QJ/J9lDnnmEqstEY6TlZnzl326FAj/s p9A7KIDjwJxJ+wSTSv7jCcGGddq6FW6PIfcyFjAGVL6PkSQ1tLnuTloOpfXjLgWEH0J5 DQtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cU0PyAXU; 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=pass (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 e5-20020ac80105000000b003175be6b95csi5964133qtg.315.2022.06.28.04.21.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Jun 2022 04:21:20 -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=pass header.i=@linaro.org header.s=google header.b=cU0PyAXU; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:41420 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o69HU-0007e5-0v for patch@linaro.org; Tue, 28 Jun 2022 07:21:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41294) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o69Dj-0003y5-Ah for qemu-devel@nongnu.org; Tue, 28 Jun 2022 07:17:27 -0400 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]:37403) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o69Dh-0003Bm-NB for qemu-devel@nongnu.org; Tue, 28 Jun 2022 07:17:27 -0400 Received: by mail-pj1-x102e.google.com with SMTP id w19-20020a17090a8a1300b001ec79064d8dso15537511pjn.2 for ; Tue, 28 Jun 2022 04:17:25 -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=RM42zMRkI421HiARyMb/O/C2Vq6+9jMrjOfzX4mv7Y0=; b=cU0PyAXUIoTGSUk7MjTJZ4mp1Q4jyymWRtcVPJXvfmLXnSHpX4oId/WQUjM7C3sRUD W3OglN1oNE7/0EPIm+JRVOialsvm3myc3l9zD/bLT0X/NFW3uyN9tSCYpMNptZ/Jd+aP OV3HrzGjYSjbhxWbtqQpK9gTDLiNIp3OS2n9oUmlYEhVzCXdroTpzjCWvWIniwDUba4E 89So3XA1R6cYMkYKcWPYtEl6QuIWM/vWYNyA72qDYviHdgy/uQ+CSU7RivMD0f0nOWOE bjqDN/taODhyruZUMeZkbcvufeoKnJmajcyK6GKnvvcFGdP9lPeFuMN9cWrHTzQ0sGJV Tqew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RM42zMRkI421HiARyMb/O/C2Vq6+9jMrjOfzX4mv7Y0=; b=OdJ6Ixs/Y3iPQzgrkGUVg1s6S5sBTbRe8uNrJy2nOSW1wUfg5/5dAbEk2cmghnLzWj eQeULa2qPcu6Xs7w6Do4/30lc2bq+0IddvXlzA4LhyjGEmdFqNpTdr82Uu7HL4ldekTt IY/8GLFyWwp3siCx64ItWWvimMtueZLtt0/Ywat3kleC34TZbtjts8b5RTT1BE479R7v MKHsS0IQiygPEx0df0O7KUy/OcWrCzujVBph5puTe/Prwx0FUgYAE90A4pSVhKECV25q BvPnToK7p01+1xDsE5jmfAlzOyidKXOSc6BO/ADAi/vUPge3JVkSQfJH7ra4uUY2qi/m hf6A== X-Gm-Message-State: AJIora9PpdwJaUqS290X+p2stl6ng4IuR1WCg5CDJmNEfrWVbX48lnvk UbzIYA7Tz5vU+LlogMmammQtDi0j7t6MZQ== X-Received: by 2002:a17:902:f34a:b0:16a:e2d:3e9 with SMTP id q10-20020a170902f34a00b0016a0e2d03e9mr3251665ple.95.1656415044423; Tue, 28 Jun 2022 04:17:24 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id a8-20020a654188000000b003fd4831e6fesm9079283pgq.70.2022.06.28.04.17.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jun 2022 04:17:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: f4bug@amsat.org, alex.bennee@linaro.org, jiaxun.yang@flygoat.com, aleksandar.rikalo@syrmia.com Subject: [PATCH v5 5/8] target/mips: Use error_report for UHI_assert Date: Tue, 28 Jun 2022 16:46:58 +0530 Message-Id: <20220628111701.677216-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220628111701.677216-1-richard.henderson@linaro.org> References: <20220628111701.677216-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102e.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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" Always log the assert locally. Do not report_fault, but instead include the fact of the fault in the assertion. Don't bother freeing allocated strings before the abort(). Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/mips/tcg/sysemu/mips-semi.c | 39 ++++++++++++++---------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/target/mips/tcg/sysemu/mips-semi.c b/target/mips/tcg/sysemu/mips-semi.c index ad11a46820..ae4b8849b1 100644 --- a/target/mips/tcg/sysemu/mips-semi.c +++ b/target/mips/tcg/sysemu/mips-semi.c @@ -221,18 +221,6 @@ static int copy_argn_to_target(CPUMIPSState *env, int arg_num, } \ } while (0) -#define GET_TARGET_STRINGS_2(p, addr, p2, addr2) \ - do { \ - p = lock_user_string(addr); \ - if (!p) { \ - report_fault(env); \ - } \ - p2 = lock_user_string(addr2); \ - if (!p2) { \ - report_fault(env); \ - } \ - } while (0) - #define FREE_TARGET_STRING(p, gpr) \ do { \ unlock_user(p, gpr, 0); \ @@ -243,7 +231,7 @@ void mips_semihosting(CPUMIPSState *env) CPUState *cs = env_cpu(env); target_ulong *gpr = env->active_tc.gpr; const UHIOp op = gpr[25]; - char *p, *p2; + char *p; switch (op) { case UHI_exit: @@ -355,14 +343,23 @@ void mips_semihosting(CPUMIPSState *env) break; case UHI_assert: - GET_TARGET_STRINGS_2(p, gpr[4], p2, gpr[5]); - printf("assertion '"); - printf("\"%s\"", p); - printf("': file \"%s\", line %d\n", p2, (int)gpr[6]); - FREE_TARGET_STRING(p2, gpr[5]); - FREE_TARGET_STRING(p, gpr[4]); - abort(); - break; + { + const char *msg, *file; + + msg = lock_user_string(gpr[4]); + if (!msg) { + msg = ""; + } + file = lock_user_string(gpr[5]); + if (!file) { + file = ""; + } + + error_report("UHI assertion \"%s\": file \"%s\", line %d", + msg, file, (int)gpr[6]); + abort(); + } + default: error_report("Unknown UHI operation %d", op); abort(); From patchwork Tue Jun 28 11:16:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 585568 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5036:0:0:0:0 with SMTP id e22csp663165mab; Tue, 28 Jun 2022 04:19:20 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u65rtygd0DCN7uv7DQKyUy6u8Z/xDTaHPOE2w3p1NA+0TwieFAXBvjHLd7KEHNP8iP1kjR X-Received: by 2002:a0c:e74e:0:b0:46b:55e7:3152 with SMTP id g14-20020a0ce74e000000b0046b55e73152mr1902222qvn.41.1656415160249; Tue, 28 Jun 2022 04:19:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656415160; cv=none; d=google.com; s=arc-20160816; b=CEcUTsETXn2Cp5FqVRdk5kpCPllHZ5+ZjHW/JfLOgsH374PycOI2ePieBeS/D61oGr vpgnz9ANdS2P+B92H0Zm4LwCOjHeWN4hcOnnxvkqOvUPMj/hPQqOUfXr0XaKsXqGjcrd VTcrwETjGRF9sqjVSPLcdx5Pu4QZP/J9R/9RFOix8zI92y07Kxfuh1dCk8i2Imrzgjq7 CptXTLdrHwZwFCGZKWpYPosTUZ3VXzlab+sJKHXuKtu5YD3CEtyqO1KzOVy28gjz9qha LlVwtqav320BZHWcWUX1JvqMUmMvUkTYipc1IrO8S1mP8E9fS8hSeOZlNP35T6idNNAG JrAQ== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=BjePRvLodXee3nOF4Bnatx6neJkMsm/wRrhgMqaqYcE=; b=yJeOwHCX7FOyG220IkqZhsuz40Fx5VtZujNJgYulJue5YGbDIdxwZqybm75dmQRZsJ xcq0HfMhaaD1RlIuzJXRVk2jVRQErzePsA/yWLc5HVTvpUBbNtT8ZZpIHNHlU5eDKBLq M3+ZVydN2JMVINqV4vI3L9Dghu0ksf0Cg/qQRj9X3fUr+u2XHgeZBPp368cw7+W6Qy6q FcEICTo3QQ1pGVd/6RURPLx1wFTb7/CJ/b1v1cnv6AogqaRt4BQwCFDIfF4k5xnWkWXP It2TrzwrCcWupCAS+eK+uDSElmSAWdu9VGo1GgwrSwwGUeW3/bU/aXnbnyLG+eZRzL5G Bkmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qGiCAaYq; 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=pass (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 o10-20020a0562140e4a00b00459e17a3f8esi7300410qvc.205.2022.06.28.04.19.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Jun 2022 04:19:20 -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=pass header.i=@linaro.org header.s=google header.b=qGiCAaYq; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37644 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o69FX-00056p-Pr for patch@linaro.org; Tue, 28 Jun 2022 07:19:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41312) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o69Dm-000462-G3 for qemu-devel@nongnu.org; Tue, 28 Jun 2022 07:17:30 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]:38466) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o69Dk-0003CI-VT for qemu-devel@nongnu.org; Tue, 28 Jun 2022 07:17:30 -0400 Received: by mail-pf1-x429.google.com with SMTP id k9so2489430pfg.5 for ; Tue, 28 Jun 2022 04:17:28 -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=BjePRvLodXee3nOF4Bnatx6neJkMsm/wRrhgMqaqYcE=; b=qGiCAaYqmZlhGL+pdWEsGGrcRsBHK3DkSTiieoMvCuwPSeKIbSidxXL4s1LrUgQIDA P9Xui4o+oC7YwCe3rftARGubLgtZ70N7aWdMtj9BD8xDgq4msHwF/Wc2jUrPaSM9Fagf OH7pNbbcAguFaP96yddMe4gTxsJyFeiNKXdSct4TgFwTaRgyhbsV96iAeWfL18dkKhVn 0c9z/NiVNppNLpih03UNHu7Z125QITsFe6R2tp82ZMvuJv2RZmPA6wL1tW2HfX+aHy+M vnkgsaIP90gr/8D+ftnSsoAcq6wLb8zd662+mQDKHC0pjBrZ48WNJMlTbpzrdh/WWN6M fPqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BjePRvLodXee3nOF4Bnatx6neJkMsm/wRrhgMqaqYcE=; b=1NHWkdc6T2ejfTYn7lhkCpKD5yR9kUBEPLG5EOV7+yotrbWZGzKCOJy41c4OLvb1xI r6Cq4cX06nQCDkFgy4/TBCYdZD+nZ6livO8CZlnUI7uBCTjP2NeKRUgZO0XuqqTXE1+e cohxVfVAa0Hrg85bAAzX/hSsGuiO+sxTC1HnBdlu3ogMG96iNXrwZkslWt2MzgVhetpg Jt1B6Bi4+3macyUaCofZeDCYSapq3CzT7FbHnq/xip18xr0M2fg3tqEM0/XAbURfHe9y lMybcE1ot4Ju9VnLgQlDes9T7IeO01k1dgMZvMKbACH1tQiQrH4vO5K61GRpipLBya3w oQ7w== X-Gm-Message-State: AJIora8BVkCl53RR51aerlNK0mILH9DKowAGZBFaTCQZ3E8hQUf3UK3Q xbK/Y6Sevi7pR0kA2t6TXQM/B+etXUFEow== X-Received: by 2002:a63:9752:0:b0:3c6:5a7a:5bd6 with SMTP id d18-20020a639752000000b003c65a7a5bd6mr17377371pgo.390.1656415047635; Tue, 28 Jun 2022 04:17:27 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id a8-20020a654188000000b003fd4831e6fesm9079283pgq.70.2022.06.28.04.17.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jun 2022 04:17:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: f4bug@amsat.org, alex.bennee@linaro.org, jiaxun.yang@flygoat.com, aleksandar.rikalo@syrmia.com Subject: [PATCH v5 6/8] semihosting: Remove qemu_semihosting_log_out Date: Tue, 28 Jun 2022 16:46:59 +0530 Message-Id: <20220628111701.677216-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220628111701.677216-1-richard.henderson@linaro.org> References: <20220628111701.677216-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x429.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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 function is no longer used. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- include/semihosting/console.h | 13 ------------- semihosting/console.c | 9 --------- 2 files changed, 22 deletions(-) diff --git a/include/semihosting/console.h b/include/semihosting/console.h index 61b0cb3a94..bd78e5f03f 100644 --- a/include/semihosting/console.h +++ b/include/semihosting/console.h @@ -40,19 +40,6 @@ int qemu_semihosting_console_read(CPUState *cs, void *buf, int len); */ int qemu_semihosting_console_write(void *buf, int len); -/** - * qemu_semihosting_log_out: - * @s: pointer to string - * @len: length of string - * - * Send a string to the debug output. Unlike console_out these strings - * can't be sent to a remote gdb instance as they don't exist in guest - * memory. - * - * Returns: number of bytes written - */ -int qemu_semihosting_log_out(const char *s, int len); - /* * qemu_semihosting_console_block_until_ready: * @cs: CPUState diff --git a/semihosting/console.c b/semihosting/console.c index cda7cf1905..5b1ec0a1c3 100644 --- a/semihosting/console.c +++ b/semihosting/console.c @@ -38,15 +38,6 @@ typedef struct SemihostingConsole { static SemihostingConsole console; -int qemu_semihosting_log_out(const char *s, int len) -{ - if (console.chr) { - return qemu_chr_write_all(console.chr, (uint8_t *) s, len); - } else { - return write(STDERR_FILENO, s, len); - } -} - #define FIFO_SIZE 1024 static int console_can_read(void *opaque) From patchwork Tue Jun 28 11:17:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 585573 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5036:0:0:0:0 with SMTP id e22csp666817mab; Tue, 28 Jun 2022 04:25:01 -0700 (PDT) X-Google-Smtp-Source: AGRyM1upFCdz0tKF/dR9oMi7sX+C0ymP9jchFuo13LNFonevz7jQMK4W0nvl43ZTfFjoBhNV37oM X-Received: by 2002:ac8:7f48:0:b0:318:440e:802a with SMTP id g8-20020ac87f48000000b00318440e802amr12110683qtk.553.1656415501557; Tue, 28 Jun 2022 04:25:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656415501; cv=none; d=google.com; s=arc-20160816; b=ddTTeQCyrXioVGf+FNtBqAdCKn+K9IONV/ecMLei2i0FKDHR6BPqZBBUe+FUfGuqeo YwEZHusHFUgqzTlCwCvtayQq46bPu8l7EHQahgM0yod5JxDzB2YqgOsnMpoAeQ9sncaJ 3EfluaHQyjmzJH8yxidTx191Vsf+ujdzZ/WCa4AnjdOePxbNj52lUWYi06zdPhLx+8Sp C8k/YAS5f/aZrX1bw+ivhNrWaQRNbsTtPOJkHw7fLsc7Hxf4so6DtBK7coGjtP6PQThZ VU+mbUg4Ms33i5DUoyhGFqByda0/FPasbtWBk35MR8Wbu8pEd1L7B1+oMpjY7ThWCIzz Lp4Q== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qIoo0LzyvHSUbYXwQZj3nHuBOs19Duk2E4Vx8ekmqlk=; b=NnuSm9EO0X7yKxI5R4hjBxxyoxX+WaUvaOFCBDuGdcqcK/N8c9zQww82h7fZdE16Km vTZJxinyCLhcXngoEes4LXuxzphxiBlqSwyoUi/tdl7wL85ooUxtShl7z20Vfr/GRaDe aKxpV1Nhi7yIsd+Bq6beuTA4v7ayvzXiG6CDbZ5bsY6B56kQf/tGEH0QHr3xqehT6t37 k+ODXBX3/TVHuCc5/IMYh7g+wgyeMzlT3NvZsgNgl58Uwwls/cgvEDPdvwbgOOZ1erAd qB3rNkfxys2NGbZ+ujBk/ywjtEE/TiWxKn2p6vLlt1ok9ggA68xPHaYNX8R8sR+jKAcG ZBEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TLew3rlN; 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=pass (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 q13-20020ac8410d000000b0031befade048si930289qtl.690.2022.06.28.04.25.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Jun 2022 04:25:01 -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=pass header.i=@linaro.org header.s=google header.b=TLew3rlN; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48284 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o69L3-00042K-1t for patch@linaro.org; Tue, 28 Jun 2022 07:25:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41328) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o69Dp-0004Ex-Gs for qemu-devel@nongnu.org; Tue, 28 Jun 2022 07:17:33 -0400 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]:46011) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o69Dn-0003Cm-WB for qemu-devel@nongnu.org; Tue, 28 Jun 2022 07:17:33 -0400 Received: by mail-pg1-x52d.google.com with SMTP id 184so11863209pga.12 for ; Tue, 28 Jun 2022 04:17:31 -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=qIoo0LzyvHSUbYXwQZj3nHuBOs19Duk2E4Vx8ekmqlk=; b=TLew3rlNVvslip45PSkl6tIpvr8EWpPrzS2A/7URxjI9grS3zYZvC7ZmhwOgW/swvj 1r4rs1jBRzPKs6a2S0xUk4U3LGk+KKWmMtUkSQaqBZD039WVinmo4aQgTp05tMopVab5 b0NUwpZlsnv4XPdGz05CW4SosBvstrKd8bGjLHMsD6exNTxJxYIjCbRJpEdtrtLE/yo3 RXFfCS3q4aU7j9WBBBGdYffSWFR52mXAZvNev0pLgIlxKAdQv2wBPDtDK65sZ5pAazkK Jvo7AOl5UT9xgNxSg3dfNH/6v1fb/uSJl+zd75udlb/XpGPMHjUgAprPIukKRTAZRMv0 acYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qIoo0LzyvHSUbYXwQZj3nHuBOs19Duk2E4Vx8ekmqlk=; b=2wgwEUgsekrVFFPL04lWhY6ByEiFE4cdu/TOBMnyylswkNQMVdUiCsi+urK19SCvuH LYMnNnyAe1hwNvFAY8yN6xqT5w1ayNcqCd9D9gqRNPbO/bLldr9kGSmsJZIkti56ZxG7 5x0pb2gxQ90Izhrzx8CSjm+rbfFyfA2pNRtXMjUeK2qwpEatONJ0kdCKnL/AdHUxXLPh fE62UsN1KQdtRNncPtkez1LYKjIjy42TrMmsQ/snH0wnyqj3/lQWeU9pkKktKG5CLXxJ i1dJPmNHKg3RJLaSKaUWQAiKkb2/UMgimsm4P2odeCkBE7kZT5AwDq2pQHP2ztXWftBJ owVw== X-Gm-Message-State: AJIora80jMtSROZ99DrfDgWLL+3bR1a8Jo84LS/DgNgXKk/h0RGhCNrT Y/VpbInPuyav78k5bwEnr9TEa7Hb6QNTFw== X-Received: by 2002:a63:ee54:0:b0:3fe:30cc:899f with SMTP id n20-20020a63ee54000000b003fe30cc899fmr17762613pgk.234.1656415050695; Tue, 28 Jun 2022 04:17:30 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id a8-20020a654188000000b003fd4831e6fesm9079283pgq.70.2022.06.28.04.17.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jun 2022 04:17:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: f4bug@amsat.org, alex.bennee@linaro.org, jiaxun.yang@flygoat.com, aleksandar.rikalo@syrmia.com Subject: [PATCH v5 7/8] target/mips: Simplify UHI_argnlen and UHI_argn Date: Tue, 28 Jun 2022 16:47:00 +0530 Message-Id: <20220628111701.677216-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220628111701.677216-1-richard.henderson@linaro.org> References: <20220628111701.677216-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52d; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52d.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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" With semihosting_get_arg, we already have a check vs argc, so there's no point replicating it -- just check the result vs NULL. Merge copy_argn_to_target into its caller. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/mips/tcg/sysemu/mips-semi.c | 44 ++++++++++++++---------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/target/mips/tcg/sysemu/mips-semi.c b/target/mips/tcg/sysemu/mips-semi.c index ae4b8849b1..b54267681e 100644 --- a/target/mips/tcg/sysemu/mips-semi.c +++ b/target/mips/tcg/sysemu/mips-semi.c @@ -198,21 +198,6 @@ static void uhi_fstat_cb(CPUState *cs, uint64_t ret, int err) uhi_cb(cs, ret, err); } -static int copy_argn_to_target(CPUMIPSState *env, int arg_num, - target_ulong vaddr) -{ - int strsize = strlen(semihosting_get_arg(arg_num)) + 1; - char *dst = lock_user(VERIFY_WRITE, vaddr, strsize, 0); - if (!dst) { - report_fault(env); - } - - strcpy(dst, semihosting_get_arg(arg_num)); - - unlock_user(dst, vaddr, strsize); - return 0; -} - #define GET_TARGET_STRING(p, addr) \ do { \ p = lock_user_string(addr); \ @@ -285,18 +270,31 @@ void mips_semihosting(CPUMIPSState *env) gpr[2] = semihosting_get_argc(); break; case UHI_argnlen: - if (gpr[4] >= semihosting_get_argc()) { - gpr[2] = -1; - return; + { + const char *s = semihosting_get_arg(gpr[4]); + gpr[2] = s ? strlen(s) : -1; } - gpr[2] = strlen(semihosting_get_arg(gpr[4])); break; case UHI_argn: - if (gpr[4] >= semihosting_get_argc()) { - gpr[2] = -1; - return; + { + const char *s = semihosting_get_arg(gpr[4]); + target_ulong addr; + size_t len; + + if (!s) { + gpr[2] = -1; + break; + } + len = strlen(s) + 1; + addr = gpr[5]; + p = lock_user(VERIFY_WRITE, addr, len, 0); + if (!p) { + report_fault(env); + } + memcpy(p, s, len); + unlock_user(p, addr, len); + gpr[2] = 0; } - gpr[2] = copy_argn_to_target(env, gpr[4], gpr[5]); break; case UHI_plog: From patchwork Tue Jun 28 11:17:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 585576 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5036:0:0:0:0 with SMTP id e22csp673210mab; Tue, 28 Jun 2022 04:32:38 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sUSAYFNaYwRIrF+ZT6HCyMpEIe0v0PI8C9qfBI/ovsrPJm6DYYDhIc3Bl07KAu4KjhJ8VD X-Received: by 2002:a0c:e6a2:0:b0:470:45c8:6a84 with SMTP id j2-20020a0ce6a2000000b0047045c86a84mr3064226qvn.38.1656415958301; Tue, 28 Jun 2022 04:32:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656415958; cv=none; d=google.com; s=arc-20160816; b=iPCFJJMOf0Kez5yAubHUnP1G4IudKv101F7rsHjmHSw2oL1vizsgh8v74X7GT4xq+R LMnVtUGqOCbeVh7chj/c6GbcMem8b+o5GJUkX/hCMTT7a01DWyfotcnz76lRryzHNj7d 7YhXiny8a/CYtbOWNBsfBjyE+MsQ4N3BCt0PdKfNzWAojntqq8g8tkukZKrFymWW0L6c 7wfxLMkJNLf8PGvFJeFDS6dB4DiYrwDIkvdI4JSEqKeS3RK4uxU0WvM5dtlL5+tWRERG GkpzpRHLmo1PLAM7302QW73htohmT7b8K89NzdZVjXhw5Z2zqRQzwaynSwrv4frQ2M8s fxJw== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Uvve2F6bKnqA+jHkHDZA0DuOutle4LRsyC3luFc/kBA=; b=IbJwhMN6zlY2Gr6u5z5oL+aCtmxD9t7wh8A+q69GiaSLa5ta134BTCmJF2rrQB1tqj W7eUL4Bgx5UNIUXqnYam6QfPYRkW9nk0h1nf3DgIsdWgOMEzR2YwaJRxw7695jj9sTvN LCDRK8ER23BZ5Y+PJFA/krEccW8nj/oihitX0MndCvcySbRiWZNBnb2XK/IZmXgHEEu1 cG1MKADSHOV+nVRq1SxS5YykhbwtCTue91orLxG1zwLio7VkIvTQyCsuwo2vf+k8C3P0 zb3S9qrgs6yj1rb32xtnaZlfr7/CkzDuXj8MepxNIYwgZEz8YRnf9rDQw4pe/1PDRN0W fLiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=P4UKNWn+; 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=pass (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 5-20020ac84e85000000b003178dc1a9f8si8242005qtp.723.2022.06.28.04.32.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Jun 2022 04:32:38 -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=pass header.i=@linaro.org header.s=google header.b=P4UKNWn+; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34182 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o69SO-0006Ys-TU for patch@linaro.org; Tue, 28 Jun 2022 07:32:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41348) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o69Ds-0004Of-Uy for qemu-devel@nongnu.org; Tue, 28 Jun 2022 07:17:37 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]:40698) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o69Dr-0003D1-F5 for qemu-devel@nongnu.org; Tue, 28 Jun 2022 07:17:36 -0400 Received: by mail-pf1-x431.google.com with SMTP id c205so11703224pfc.7 for ; Tue, 28 Jun 2022 04:17:35 -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=Uvve2F6bKnqA+jHkHDZA0DuOutle4LRsyC3luFc/kBA=; b=P4UKNWn+foQwxmmqyiF/hUTaQZd79W/mFRqirhbsicN8ep9KEgX+ptKkawSHn0KLev 5C2r2EMm9zYh2yHyKKOzsSXZrNuyMlnCzIOaxNc7PXFlDH5YjnVh/CjO9nm9D90X6kTM Z4ToSst2ClxjLuQ+dBK8O52Hv7fb0i15CAiq199JFFIiApknI+peo23FZiPFOzEtNRKy MVJNl4FnAIn0qgwKEiYEzK88R+1FZuGis4VVqKMAU7745YlypzaXLIQ8k4bgwlBLfn1T iZOeUIXb135NcAECXmq/xOHpQrS8lhv461gi/VWs3nqe2djGfiI/GVRGY/0Dypio1uEf Jo7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Uvve2F6bKnqA+jHkHDZA0DuOutle4LRsyC3luFc/kBA=; b=TDw6KzeUBzZ9mXIaUnQmmFy20v0fMcoBMZ/N3RBvIfNy8XBQSuGgaKj8VwZaY7rUxC x2SnIETVIaR7EskPK73nZcW/flNI9gLYZvIxD3n1iO7dOYCK4RE5zIh2hSVoDOaO+WRG /b65rBl9n+VUojgdC/EEyyKpFu5Kfxj9B+F/xDRS7YjIDBfNhaiGuTnu45QGgtacnTD9 hXGxvn6K1N8hWYvDoRMP+8/UdNeex8PJAJ7gpZnbtnB2HCp1VXc1R8pc2hmJdRPXUMGe 1/w7KUOIdWyBC0PxHgtlAUjtliJ43JfrDgovlwjgycmzdKJIhRG3HUC2cwTxmd0B5fPw CHog== X-Gm-Message-State: AJIora+lyohA+YLF3FD0pjAoaBBLeRFzCrcJWuIqYZZe7tpQZkW/BnsI b38J8pL6lZW+w7rwfx3rK1BuBjD44Iz2dg== X-Received: by 2002:a05:6a00:15c1:b0:525:2db4:2a2c with SMTP id o1-20020a056a0015c100b005252db42a2cmr3104330pfu.30.1656415054050; Tue, 28 Jun 2022 04:17:34 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id a8-20020a654188000000b003fd4831e6fesm9079283pgq.70.2022.06.28.04.17.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jun 2022 04:17:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: f4bug@amsat.org, alex.bennee@linaro.org, jiaxun.yang@flygoat.com, aleksandar.rikalo@syrmia.com Subject: [PATCH v5 8/8] target/mips: Remove GET_TARGET_STRING and FREE_TARGET_STRING Date: Tue, 28 Jun 2022 16:47:01 +0530 Message-Id: <20220628111701.677216-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220628111701.677216-1-richard.henderson@linaro.org> References: <20220628111701.677216-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::431; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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" Inline these macros into the only two callers. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/mips/tcg/sysemu/mips-semi.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/target/mips/tcg/sysemu/mips-semi.c b/target/mips/tcg/sysemu/mips-semi.c index b54267681e..5fb1ad9092 100644 --- a/target/mips/tcg/sysemu/mips-semi.c +++ b/target/mips/tcg/sysemu/mips-semi.c @@ -198,19 +198,6 @@ static void uhi_fstat_cb(CPUState *cs, uint64_t ret, int err) uhi_cb(cs, ret, err); } -#define GET_TARGET_STRING(p, addr) \ - do { \ - p = lock_user_string(addr); \ - if (!p) { \ - report_fault(env); \ - } \ - } while (0) - -#define FREE_TARGET_STRING(p, gpr) \ - do { \ - unlock_user(p, gpr, 0); \ - } while (0) - void mips_semihosting(CPUMIPSState *env) { CPUState *cs = env_cpu(env); @@ -225,9 +212,13 @@ void mips_semihosting(CPUMIPSState *env) case UHI_open: { + target_ulong fname = gpr[4]; int ret = -1; - GET_TARGET_STRING(p, gpr[4]); + p = lock_user_string(fname); + if (!p) { + report_fault(env); + } if (!strcmp("/dev/stdin", p)) { ret = 0; } else if (!strcmp("/dev/stdout", p)) { @@ -235,7 +226,7 @@ void mips_semihosting(CPUMIPSState *env) } else if (!strcmp("/dev/stderr", p)) { ret = 2; } - FREE_TARGET_STRING(p, gpr[4]); + unlock_user(p, fname, 0); /* FIXME: reusing a guest fd doesn't seem correct. */ if (ret >= 0) { @@ -243,7 +234,7 @@ void mips_semihosting(CPUMIPSState *env) break; } - semihost_sys_open(cs, uhi_cb, gpr[4], 0, gpr[5], gpr[6]); + semihost_sys_open(cs, uhi_cb, fname, 0, gpr[5], gpr[6]); } break; @@ -314,14 +305,14 @@ void mips_semihosting(CPUMIPSState *env) pct_d = strstr(p, "%d"); if (!pct_d) { - FREE_TARGET_STRING(p, addr); + unlock_user(p, addr, 0); semihost_sys_write(cs, uhi_cb, 2, addr, len); break; } str = g_string_new_len(p, pct_d - p); g_string_append_printf(str, "%d%s", (int)gpr[5], pct_d + 2); - FREE_TARGET_STRING(p, addr); + unlock_user(p, addr, 0); /* * When we're using gdb, we need a guest address, so