From nobody Mon Feb 9 15:55:32 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1654665747; cv=none; d=zohomail.com; s=zohoarc; b=ZlYtYVMhxcedS/eWH44O/eBVsApBg7DR//5gEYuSNIepIHtTY21tj21hxdDLWv1c3zcR5fTCOSWPxCXevRSo/MJB8B1/RA8CLY0OIaMZqDRUuX40iknGkSuYl2gECrUMU8TKM5QxJVdO4Z1cnScQf0xikSYHguDqc3ntGZ0KHjQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654665747; 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:References:Sender:Subject:To; bh=w4FYTiyxhI0mE5fcTHb/1MDqV87uaAoIyMIlxrvf02Y=; b=ObyY+MrQHbKdceHt5dDrrCiunBHg7FLUvsJClWzsMf4DJFrQC56p/IfEQVAHWhSEEuZWiwz4Townh0I3ElN4pQhusWrXud2b/aq+Ug9WUPeWV0b+YcvX/TJPbY9PSgzyUif9yqIOqHkJ+ZafvJngW5UN9Z9hSghjuF7SI5xsgRA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1654665747155509.49415673639044; Tue, 7 Jun 2022 22:22:27 -0700 (PDT) Received: from localhost ([::1]:35614 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nyo9B-0000bn-Bf for importer@patchew.org; Wed, 08 Jun 2022 01:22:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33698) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nyo6j-0006qG-AM for qemu-devel@nongnu.org; Wed, 08 Jun 2022 01:19:53 -0400 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]:46651) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nyo6f-000226-LS for qemu-devel@nongnu.org; Wed, 08 Jun 2022 01:19:52 -0400 Received: by mail-pg1-x530.google.com with SMTP id c14so17866213pgu.13 for ; Tue, 07 Jun 2022 22:19:49 -0700 (PDT) Received: from stoup.. ([2602:ae:1547:e101:c626:2f70:ac99:7c97]) by smtp.gmail.com with ESMTPSA id k8-20020a170902d58800b001641244d051sm13378807plh.257.2022.06.07.22.19.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:19:47 -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=w4FYTiyxhI0mE5fcTHb/1MDqV87uaAoIyMIlxrvf02Y=; b=uSPQluXp+bqLxAzJsPx+cQUOrlPNwijh5Xx7LVIyLivApw/KFTRSut8SQ2tp0GLEe9 tPEa4T578KGHNb8aE9hoyI0Q4zOMoLeJAM6cYLQ/mB6jymPW50+blIsf4wsjrSOBTI8s Kn/Uw86bJCBIEXJuOPDrZdAzdvhfnfmYqPLihfmJdxXxVAfROP2Re6FoOusUtrI6yBAc P6ftvf/TGitxUJtF1EUSPH5ZtQWoUvqCjUIT05hZvi4I2HK+DZ8bA0TFcJnpkR0y4ZhX JCd0WJY2G3w++SqwrHXw+ElAyGlhEcCrEYHxOM7ReQJK7/Wc5kcENzZIW2XDy68H6/ia I5Bw== 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=w4FYTiyxhI0mE5fcTHb/1MDqV87uaAoIyMIlxrvf02Y=; b=sWkLsJc0QKdg3f/SLOu2cB4/uvrPRgsjYDeXjlXJxYmbd0MLR/F+U/LqZm5tqid0xg tpnydze/3MN3Ml3PqjSeptfxSdHaAoG4Z4PHgSePjIF9+PgTP4XLNxKPPIe30WqqH2Hk 2oSbWqP9fiUIovlXgtY3+AOMheSCsairGPE7L4KGkKHrw7rW1CmubfhhdXJwwW1ea8qN TWHn2v71hAL4vzCEZkad05uPOsnj2EeIk8lk0/zJwHy4Nf2GiSdG8+Bu13WRsSoiCLH+ CitAW5ACsvNepBDwYDKWhzRxaBJvXEc3ONFaFNuIbC0yl7QWW+ampZHFymgJF71M+7B9 I3Xw== X-Gm-Message-State: AOAM532ToHniMxvqyQTvzrj+EA+q2P75vbzSqD10t5UzrdaybiVnQYqE bdOjjw8xcEs6ebnU04RxQpa31KD92B7Akg== X-Google-Smtp-Source: ABdhPJy1IyKOetUInrg30H/U8yDHHgMbUnlUoQeANvmRithz6rW2C+uLUlz037Fxza3MU6HZ3JB3kQ== X-Received: by 2002:a63:91c2:0:b0:3fc:bcef:5681 with SMTP id l185-20020a6391c2000000b003fcbcef5681mr29306415pge.236.1654665587965; Tue, 07 Jun 2022 22:19:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: f4bug@amsat.org Subject: [PATCH v4 01/11] target/mips: Use an exception for semihosting Date: Tue, 7 Jun 2022 22:19:35 -0700 Message-Id: <20220608051945.802339-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220608051945.802339-1-richard.henderson@linaro.org> References: <20220608051945.802339-1-richard.henderson@linaro.org> 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=2607:f8b0:4864:20::530; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x530.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654665748646100001 Content-Type: text/plain; charset="utf-8" Within do_interrupt, we hold the iothread lock, which is required for Chardev access for the console, and for the round trip for use_gdb_syscalls(). Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/mips/cpu.h | 3 ++- target/mips/tcg/tcg-internal.h | 2 ++ target/mips/tcg/sysemu_helper.h.inc | 2 -- target/mips/tcg/exception.c | 1 + target/mips/tcg/sysemu/mips-semi.c | 4 ++-- target/mips/tcg/sysemu/tlb_helper.c | 4 ++++ target/mips/tcg/translate.c | 12 ++---------- target/mips/tcg/micromips_translate.c.inc | 6 +++--- target/mips/tcg/mips16e_translate.c.inc | 2 +- target/mips/tcg/nanomips_translate.c.inc | 4 ++-- 10 files changed, 19 insertions(+), 21 deletions(-) diff --git a/target/mips/cpu.h b/target/mips/cpu.h index 5335ac10a3..f56a5a95c4 100644 --- a/target/mips/cpu.h +++ b/target/mips/cpu.h @@ -1251,8 +1251,9 @@ enum { EXCP_MSAFPE, EXCP_TLBXI, EXCP_TLBRI, + EXCP_SEMIHOST, =20 - EXCP_LAST =3D EXCP_TLBRI, + EXCP_LAST =3D EXCP_SEMIHOST, }; =20 /* diff --git a/target/mips/tcg/tcg-internal.h b/target/mips/tcg/tcg-internal.h index 993720b00c..1d27fa2ff9 100644 --- a/target/mips/tcg/tcg-internal.h +++ b/target/mips/tcg/tcg-internal.h @@ -62,6 +62,8 @@ bool mips_cpu_tlb_fill(CPUState *cs, vaddr address, int s= ize, MMUAccessType access_type, int mmu_idx, bool probe, uintptr_t retaddr); =20 +void mips_semihosting(CPUMIPSState *env); + #endif /* !CONFIG_USER_ONLY */ =20 #endif diff --git a/target/mips/tcg/sysemu_helper.h.inc b/target/mips/tcg/sysemu_h= elper.h.inc index 4353a966f9..af585b5d9c 100644 --- a/target/mips/tcg/sysemu_helper.h.inc +++ b/target/mips/tcg/sysemu_helper.h.inc @@ -9,8 +9,6 @@ * SPDX-License-Identifier: LGPL-2.1-or-later */ =20 -DEF_HELPER_1(do_semihosting, void, env) - /* CP0 helpers */ DEF_HELPER_1(mfc0_mvpcontrol, tl, env) DEF_HELPER_1(mfc0_mvpconf0, tl, env) diff --git a/target/mips/tcg/exception.c b/target/mips/tcg/exception.c index 0b21e0872b..2bd77a61de 100644 --- a/target/mips/tcg/exception.c +++ b/target/mips/tcg/exception.c @@ -125,6 +125,7 @@ static const char * const excp_names[EXCP_LAST + 1] =3D= { [EXCP_TLBRI] =3D "TLB read-inhibit", [EXCP_MSADIS] =3D "MSA disabled", [EXCP_MSAFPE] =3D "MSA floating point", + [EXCP_SEMIHOST] =3D "Semihosting", }; =20 const char *mips_exception_name(int32_t exception) diff --git a/target/mips/tcg/sysemu/mips-semi.c b/target/mips/tcg/sysemu/mi= ps-semi.c index 6d6296e709..ac12c802a3 100644 --- a/target/mips/tcg/sysemu/mips-semi.c +++ b/target/mips/tcg/sysemu/mips-semi.c @@ -20,10 +20,10 @@ #include "qemu/osdep.h" #include "cpu.h" #include "qemu/log.h" -#include "exec/helper-proto.h" #include "semihosting/softmmu-uaccess.h" #include "semihosting/semihost.h" #include "semihosting/console.h" +#include "internal.h" =20 typedef enum UHIOp { UHI_exit =3D 1, @@ -238,7 +238,7 @@ static int copy_argn_to_target(CPUMIPSState *env, int a= rg_num, unlock_user(p, gpr, 0); \ } while (0) =20 -void helper_do_semihosting(CPUMIPSState *env) +void mips_semihosting(CPUMIPSState *env) { target_ulong *gpr =3D env->active_tc.gpr; const UHIOp op =3D gpr[25]; diff --git a/target/mips/tcg/sysemu/tlb_helper.c b/target/mips/tcg/sysemu/t= lb_helper.c index 73254d1929..57ffad2902 100644 --- a/target/mips/tcg/sysemu/tlb_helper.c +++ b/target/mips/tcg/sysemu/tlb_helper.c @@ -1053,6 +1053,10 @@ void mips_cpu_do_interrupt(CPUState *cs) } offset =3D 0x180; switch (cs->exception_index) { + case EXCP_SEMIHOST: + cs->exception_index =3D EXCP_NONE; + mips_semihosting(env); + return; case EXCP_DSS: env->CP0_Debug |=3D 1 << CP0DB_DSS; /* diff --git a/target/mips/tcg/translate.c b/target/mips/tcg/translate.c index 6de5b66650..e554b3adcc 100644 --- a/target/mips/tcg/translate.c +++ b/target/mips/tcg/translate.c @@ -12094,14 +12094,6 @@ static inline bool is_uhi(int sdbbp_code) #endif } =20 -#ifdef CONFIG_USER_ONLY -/* The above should dead-code away any calls to this..*/ -static inline void gen_helper_do_semihosting(void *env) -{ - g_assert_not_reached(); -} -#endif - void gen_ldxs(DisasContext *ctx, int base, int index, int rd) { TCGv t0 =3D tcg_temp_new(); @@ -13910,7 +13902,7 @@ static void decode_opc_special_r6(CPUMIPSState *env= , DisasContext *ctx) break; case R6_OPC_SDBBP: if (is_uhi(extract32(ctx->opcode, 6, 20))) { - gen_helper_do_semihosting(cpu_env); + generate_exception_end(ctx, EXCP_SEMIHOST); } else { if (ctx->hflags & MIPS_HFLAG_SBRI) { gen_reserved_instruction(ctx); @@ -14322,7 +14314,7 @@ static void decode_opc_special2_legacy(CPUMIPSState= *env, DisasContext *ctx) break; case OPC_SDBBP: if (is_uhi(extract32(ctx->opcode, 6, 20))) { - gen_helper_do_semihosting(cpu_env); + generate_exception_end(ctx, EXCP_SEMIHOST); } else { /* * XXX: not clear which exception should be raised diff --git a/target/mips/tcg/micromips_translate.c.inc b/target/mips/tcg/mi= cromips_translate.c.inc index fc6ede75b8..274caf2c3c 100644 --- a/target/mips/tcg/micromips_translate.c.inc +++ b/target/mips/tcg/micromips_translate.c.inc @@ -826,7 +826,7 @@ static void gen_pool16c_insn(DisasContext *ctx) break; case SDBBP16: if (is_uhi(extract32(ctx->opcode, 0, 4))) { - gen_helper_do_semihosting(cpu_env); + generate_exception_end(ctx, EXCP_SEMIHOST); } else { /* * XXX: not clear which exception should be raised @@ -942,7 +942,7 @@ static void gen_pool16c_r6_insn(DisasContext *ctx) case R6_SDBBP16: /* SDBBP16 */ if (is_uhi(extract32(ctx->opcode, 6, 4))) { - gen_helper_do_semihosting(cpu_env); + generate_exception_end(ctx, EXCP_SEMIHOST); } else { if (ctx->hflags & MIPS_HFLAG_SBRI) { generate_exception(ctx, EXCP_RI); @@ -1311,7 +1311,7 @@ static void gen_pool32axf(CPUMIPSState *env, DisasCon= text *ctx, int rt, int rs) break; case SDBBP: if (is_uhi(extract32(ctx->opcode, 16, 10))) { - gen_helper_do_semihosting(cpu_env); + generate_exception_end(ctx, EXCP_SEMIHOST); } else { check_insn(ctx, ISA_MIPS_R1); if (ctx->hflags & MIPS_HFLAG_SBRI) { diff --git a/target/mips/tcg/mips16e_translate.c.inc b/target/mips/tcg/mips= 16e_translate.c.inc index f57e0a5f2a..0a3ba252e4 100644 --- a/target/mips/tcg/mips16e_translate.c.inc +++ b/target/mips/tcg/mips16e_translate.c.inc @@ -952,7 +952,7 @@ static int decode_ase_mips16e(CPUMIPSState *env, DisasC= ontext *ctx) break; case RR_SDBBP: if (is_uhi(extract32(ctx->opcode, 5, 6))) { - gen_helper_do_semihosting(cpu_env); + generate_exception_end(ctx, EXCP_SEMIHOST); } else { /* * XXX: not clear which exception should be raised diff --git a/target/mips/tcg/nanomips_translate.c.inc b/target/mips/tcg/nan= omips_translate.c.inc index 916cece4d2..5b0e4683a7 100644 --- a/target/mips/tcg/nanomips_translate.c.inc +++ b/target/mips/tcg/nanomips_translate.c.inc @@ -3691,7 +3691,7 @@ static int decode_nanomips_32_48_opc(CPUMIPSState *en= v, DisasContext *ctx) break; case NM_SDBBP: if (is_uhi(extract32(ctx->opcode, 0, 19))) { - gen_helper_do_semihosting(cpu_env); + generate_exception_end(ctx, EXCP_SEMIHOST); } else { if (ctx->hflags & MIPS_HFLAG_SBRI) { gen_reserved_instruction(ctx); @@ -4609,7 +4609,7 @@ static int decode_isa_nanomips(CPUMIPSState *env, Dis= asContext *ctx) break; case NM_SDBBP16: if (is_uhi(extract32(ctx->opcode, 0, 3))) { - gen_helper_do_semihosting(cpu_env); + generate_exception_end(ctx, EXCP_SEMIHOST); } else { if (ctx->hflags & MIPS_HFLAG_SBRI) { gen_reserved_instruction(ctx); --=20 2.34.1 From nobody Mon Feb 9 15:55:32 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1654665920; cv=none; d=zohomail.com; s=zohoarc; b=hmysOeNoUhVon9NL6A5lPaMQ+Fn9u135SU4FNIIN7afDm/duXC2WEkGGOeklo5bnbVSqvFcplBbYVEMoi8oTrAOlNS5vP4nIYJMEVN/qvJs0RqSBO7Hj4HS20+MnPpURl+Hmk/RnC938dtX/rZjpD2/33eU9DtwqdmIfoIK4Geg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654665920; 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:References:Sender:Subject:To; bh=oYsK2DCkJDRZ/LkA4A11UkQEUx69l+6MA6r9SJofgvk=; b=YnKf1K8jgbi97sNs9xEYy6ykcaAfmsNprhGH7AR2fWfyUmatrUOfCwbZ/9ma8+HkWYAlFqOE1zRj2MiW4a18a7YBZ3Cx7NvUs5MmMqJ5C0yyQecAFq2C4WHikYMOYjnSLhs589FZZsdHacOXlQFlNg804oFAZ4+N5S+xsifcb8c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1654665920424382.7544241128463; Tue, 7 Jun 2022 22:25:20 -0700 (PDT) Received: from localhost ([::1]:41742 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nyoBy-0004ir-9o for importer@patchew.org; Wed, 08 Jun 2022 01:25:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33680) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nyo6h-0006q4-W3 for qemu-devel@nongnu.org; Wed, 08 Jun 2022 01:19:52 -0400 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]:41583) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nyo6g-000228-8d for qemu-devel@nongnu.org; Wed, 08 Jun 2022 01:19:51 -0400 Received: by mail-pg1-x534.google.com with SMTP id e66so17882269pgc.8 for ; Tue, 07 Jun 2022 22:19:49 -0700 (PDT) Received: from stoup.. ([2602:ae:1547:e101:c626:2f70:ac99:7c97]) by smtp.gmail.com with ESMTPSA id k8-20020a170902d58800b001641244d051sm13378807plh.257.2022.06.07.22.19.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:19:48 -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=oYsK2DCkJDRZ/LkA4A11UkQEUx69l+6MA6r9SJofgvk=; b=WlAIQPL8OiayRjLCifNs79QaDKpEifcUQx1z3uPK0G0t2ggLy2kCimAFrJ+iXzf1YO etta8vcg0eV+IhdsGEcZvz5dWwY64o7GfrH8lrnSXOvN+AuLKXX+l3UcJDc90IKlI7fN iUjOnCqPr4InW7iIS+JOm8AkvsJdMcAZnZ7I7YpZMc5HDB1LEw6zF6T9UoEFzYqnRVd5 1R8BDqK63kuA0uasFRaoQwaI/+YXuoVunEuitPbyh6Pb32F8+tN3THz4A+EXA0z32WQ0 detY71+Ut4RB5ITQk7d6IU7n0zbpyNVbJ5ND1gjA1BdhsVlh98Kizxe4s1IraOoAadkX uOjg== 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=oYsK2DCkJDRZ/LkA4A11UkQEUx69l+6MA6r9SJofgvk=; b=XydYEaFkswnUtqmlWjbZwHIfZ31kOFTaSmdfj9kjmAkpXU19MHpqhnwaPj4f+fJw/g 9B4YUBANCVya6G2gF3jZ/EBWEQoiHylf6nM+UKphhYuiWNk/b1WsFGuFKWhsPyROaxbe 45AW7QA2eigtUdzKxbqNQqObCBFEetS8XFLMqQPk/lJ8oQULxlGPtc6MyMgBBdhyHi9u tf5dLBR1lg0HdWQIDvgGIW2NTbe3oerCkQLPXSQhjl/SMdrshuom4fOJ47BJB3FCdSga F2iOkA2+Tt1LpofemzeQ1Q6Ce3r82VilHqiamnzDG4pz6MDC1B3wSvrwlZTU6dM453YN 3Odg== X-Gm-Message-State: AOAM5306XSEBIHrlzxXRQuwLEK+DNhntGYUVHdm0aONIGHvKURHez/QT zx49FuQj5/1cAOpF7PEKAbcfuft/KPXr0Q== X-Google-Smtp-Source: ABdhPJyc/ltR41BJbz8jfMpE+vHSZrLozXJc/cenkIZwu5SwnPmKw6QEIbUtH1ut6VSkl85YPFBfLw== X-Received: by 2002:a62:1784:0:b0:51b:bc40:28a7 with SMTP id 126-20020a621784000000b0051bbc4028a7mr32905577pfx.55.1654665588789; Tue, 07 Jun 2022 22:19:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: f4bug@amsat.org Subject: [PATCH v4 02/11] target/mips: Add UHI errno values Date: Tue, 7 Jun 2022 22:19:36 -0700 Message-Id: <20220608051945.802339-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220608051945.802339-1-richard.henderson@linaro.org> References: <20220608051945.802339-1-richard.henderson@linaro.org> 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=2607:f8b0:4864:20::534; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x534.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654665920902100001 Content-Type: text/plain; charset="utf-8" From the Unified Hosting Interface, MD01069 Reference Manual, version 1.1.6, 06 July 2015. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/mips/tcg/sysemu/mips-semi.c | 40 ++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/target/mips/tcg/sysemu/mips-semi.c b/target/mips/tcg/sysemu/mi= ps-semi.c index ac12c802a3..2a039baf4c 100644 --- a/target/mips/tcg/sysemu/mips-semi.c +++ b/target/mips/tcg/sysemu/mips-semi.c @@ -74,6 +74,46 @@ enum UHIOpenFlags { UHIOpen_EXCL =3D 0x800 }; =20 +enum UHIErrno { + UHI_EACCESS =3D 13, + UHI_EAGAIN =3D 11, + UHI_EBADF =3D 9, + UHI_EBADMSG =3D 77, + UHI_EBUSY =3D 16, + UHI_ECONNRESET =3D 104, + UHI_EEXIST =3D 17, + UHI_EFBIG =3D 27, + UHI_EINTR =3D 4, + UHI_EINVAL =3D 22, + UHI_EIO =3D 5, + UHI_EISDIR =3D 21, + UHI_ELOOP =3D 92, + UHI_EMFILE =3D 24, + UHI_EMLINK =3D 31, + UHI_ENAMETOOLONG =3D 91, + UHI_ENETDOWN =3D 115, + UHI_ENETUNREACH =3D 114, + UHI_ENFILE =3D 23, + UHI_ENOBUFS =3D 105, + UHI_ENOENT =3D 2, + UHI_ENOMEM =3D 12, + UHI_ENOSPC =3D 28, + UHI_ENOSR =3D 63, + UHI_ENOTCONN =3D 128, + UHI_ENOTDIR =3D 20, + UHI_ENXIO =3D 6, + UHI_EOVERFLOW =3D 139, + UHI_EPERM =3D 1, + UHI_EPIPE =3D 32, + UHI_ERANGE =3D 34, + UHI_EROFS =3D 30, + UHI_ESPIPE =3D 29, + UHI_ETIMEDOUT =3D 116, + UHI_ETXTBSY =3D 26, + UHI_EWOULDBLOCK =3D 11, + UHI_EXDEV =3D 18, +}; + static int errno_mips(int host_errno) { /* Errno values taken from asm-mips/errno.h */ --=20 2.34.1 From nobody Mon Feb 9 15:55:32 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1654666159; cv=none; d=zohomail.com; s=zohoarc; b=cEV7tqFCFqFvs7nf0ULuXF0CQLSmVVg4K30HO4K1hyHmxF3Tf5SqmPAnN/f9YKdUhscZSV+L72oPvYzzxLyj4MEoqKj8J7PYa0eO0X9lYh3/0SPSsTP2Th4HqxbA0Pkf/GcoENIZllCojasZkPiy+/A7wpO3oIFFwZ7PGgOVeKs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654666159; 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:References:Sender:Subject:To; bh=HeLbzu4J7HUJ/gIyU/6OdVT7zEVHegu20jhi9pPruCA=; b=GXFklFlJ80TzE2pQYBXQ+afTu6PhafsA/0dAAPua5PmTQasezeRiwTdxiMl1lWiLuaZKEKLUco0eUDBjWTEnXaxfG+0UYgq/fImwEoDgNJJw05KIh28dvOgP5xZ+5qO+rBZTIQvwJ8kVhVG3LeeDO4VZxniwuNGtOaIjvN5ZkrM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 165466615929293.47516609715137; Tue, 7 Jun 2022 22:29:19 -0700 (PDT) Received: from localhost ([::1]:48168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nyoFp-0000gR-DV for importer@patchew.org; Wed, 08 Jun 2022 01:29:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33726) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nyo6k-0006rU-7c for qemu-devel@nongnu.org; Wed, 08 Jun 2022 01:19:55 -0400 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]:43914) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nyo6h-00022O-3T for qemu-devel@nongnu.org; Wed, 08 Jun 2022 01:19:53 -0400 Received: by mail-pg1-x530.google.com with SMTP id s135so2265687pgs.10 for ; Tue, 07 Jun 2022 22:19:50 -0700 (PDT) Received: from stoup.. ([2602:ae:1547:e101:c626:2f70:ac99:7c97]) by smtp.gmail.com with ESMTPSA id k8-20020a170902d58800b001641244d051sm13378807plh.257.2022.06.07.22.19.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:19:49 -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=HeLbzu4J7HUJ/gIyU/6OdVT7zEVHegu20jhi9pPruCA=; b=bSETDgHEZ2Dmj+0hZNIu2hA5cwSLmDURwrqny9qYr0TiJ9EDSmUGT+t5kcM4Eendt+ +tPapgeSMxV9t+MH8qT8fbEQSDZWP0jqLf2Z/WJhnQyaA+8KCj0FQAGAqfPzwmmJO9C4 vhtB4HYOhcrrxRBi94csSpf8Hqto4LLjsxhUoMSNMZLLtt5ULNw/PaJ1TgWm7SVNYQzn G3LxIuJ4eUaM5Dmt8m4hJr1ZtJPOKoFnbV+k3pt3sXttAzTPKmeBixjah0MWO4rGKI9E d26BmT/LmoZK9qq1nxXqPHQQxtgLrDOxdbncsAdLzGnP49p83Q9xg7bFgY2Oxu/rDUup 9hNA== 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=HeLbzu4J7HUJ/gIyU/6OdVT7zEVHegu20jhi9pPruCA=; b=cu87zTLXI4l7pwotJb2wIjVK5z7c4LK+SRDuse3zW6G+f2FsY1/2yZlb1rIDVJNDzC VnAw0ubb8qKYv19q+/A2TraMjKHOjnItwB11W59AzK2XJedNMtHL3yFzXasGObHdEdEm CQVh4ocYukOr36QG3cX7vm3TzO1o1/hYeG74AqUKlNfI0KQGWjunp/8Opcgli8zZYGen e9OrVX3l4IkozVwBA2Z8x26syqThpr38hHufdZUErFAtDP4JEiSLrxdlC8U856P6cZS/ XgDYdlEjUPg85WNxJr91R8r2zkntGVZS1mAaIS35MhTC0SB8HeKWWdH1puVQJmWXiLG5 t+gQ== X-Gm-Message-State: AOAM53353pXTQlVA5AtcCGhsdN04Tx04vSLiLzvKi+jyc+CR8EHxgOWe i8FycDEKc0vbhQmxrgt5gAMeX47votvn1Q== X-Google-Smtp-Source: ABdhPJxntGRpbXirnys95Nz6FCgCMVmNYsV0H34a1NxTxAiR2X4mfOxk2F34+X48yYFGI0SJa92qTw== X-Received: by 2002:a05:6a00:4504:b0:51b:f04e:a130 with SMTP id cw4-20020a056a00450400b0051bf04ea130mr22409360pfb.52.1654665589830; Tue, 07 Jun 2022 22:19:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: f4bug@amsat.org Subject: [PATCH v4 03/11] target/mips: Create report_fault for semihosting Date: Tue, 7 Jun 2022 22:19:37 -0700 Message-Id: <20220608051945.802339-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220608051945.802339-1-richard.henderson@linaro.org> References: <20220608051945.802339-1-richard.henderson@linaro.org> 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=2607:f8b0:4864:20::530; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x530.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654666160627100001 Content-Type: text/plain; charset="utf-8" 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 --- 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/mi= ps-semi.c index 2a039baf4c..33221444e1 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 =3D 18, }; =20 +static void report_fault(CPUMIPSState *env) +{ + int op =3D 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 =3D sizeof(struct UHIStat); UHIStat *dst =3D lock_user(VERIFY_WRITE, vaddr, len, 0); if (!dst) { - errno =3D EFAULT; - return -1; + report_fault(env); } =20 dst->uhi_st_dev =3D tswap16(src->st_dev); @@ -188,8 +194,7 @@ static int write_to_file(CPUMIPSState *env, target_ulon= g fd, target_ulong vaddr, int num_of_bytes; void *dst =3D lock_user(VERIFY_READ, vaddr, len, 1); if (!dst) { - errno =3D EFAULT; - return -1; + report_fault(env); } =20 if (offset) { @@ -213,8 +218,7 @@ static int read_from_file(CPUMIPSState *env, target_ulo= ng fd, int num_of_bytes; void *dst =3D lock_user(VERIFY_WRITE, vaddr, len, 0); if (!dst) { - errno =3D EFAULT; - return -1; + report_fault(env); } =20 if (offset) { @@ -237,7 +241,7 @@ static int copy_argn_to_target(CPUMIPSState *env, int a= rg_num, int strsize =3D strlen(semihosting_get_arg(arg_num)) + 1; char *dst =3D lock_user(VERIFY_WRITE, vaddr, strsize, 0); if (!dst) { - return -1; + report_fault(env); } =20 strcpy(dst, semihosting_get_arg(arg_num)); @@ -250,9 +254,7 @@ static int copy_argn_to_target(CPUMIPSState *env, int a= rg_num, do { \ p =3D lock_user_string(addr); \ if (!p) { \ - gpr[2] =3D -1; \ - gpr[3] =3D EFAULT; \ - return; \ + report_fault(env); \ } \ } while (0) =20 @@ -260,16 +262,11 @@ static int copy_argn_to_target(CPUMIPSState *env, int= arg_num, do { \ p =3D lock_user_string(addr); \ if (!p) { \ - gpr[2] =3D -1; \ - gpr[3] =3D EFAULT; \ - return; \ + report_fault(env); \ } \ p2 =3D lock_user_string(addr2); \ if (!p2) { \ - unlock_user(p, addr, 0); \ - gpr[2] =3D -1; \ - gpr[3] =3D EFAULT; \ - return; \ + report_fault(env); \ } \ } while (0) =20 @@ -400,7 +397,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; --=20 2.34.1 From nobody Mon Feb 9 15:55:32 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1654666168; cv=none; d=zohomail.com; s=zohoarc; b=fYQ+77yy3cXHFjVNmfhEnMBdWCNPr/Ll3qdU/9qZ1lVq9J6FPYi98tKYxqbKJaG40DmVlSyxLE76+vDJYNldTTSPjiPlj0H69IiFIHeLKUIHb9lpRq6CtIzM7u2i8r+aWDmxwemqnSPDglvZJbii2NTDpAsp3E5MlUUS0ydZxGQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654666168; 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:References:Sender:Subject:To; bh=GB8QwFJfH3hlfZTD3yMvfbRrCq2bQTobhy4HeZnGERI=; b=gXKo1onHywnf/7EWO+vL6+r8RqITY5dlihbjzjsOea63XgU83euSOw9u+PxwfQbY6sVBCIVV4+V+zuodg1Zx+j5MNJsFXMs1yxfGLMJYaIW9CoBdD2vqEJTGceytgZ3v6zAPBp9F1fPRoNa9yF6s0ySqZu2VOOGRCb4OG3JiCU0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1654666168020411.84520064961043; Tue, 7 Jun 2022 22:29:28 -0700 (PDT) Received: from localhost ([::1]:48608 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nyoFz-0000zf-1F for importer@patchew.org; Wed, 08 Jun 2022 01:29:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33782) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nyo6m-0006tI-4t for qemu-devel@nongnu.org; Wed, 08 Jun 2022 01:19:56 -0400 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]:40747) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nyo6k-00022a-27 for qemu-devel@nongnu.org; Wed, 08 Jun 2022 01:19:55 -0400 Received: by mail-pj1-x102f.google.com with SMTP id w13-20020a17090a780d00b001e8961b355dso5605591pjk.5 for ; Tue, 07 Jun 2022 22:19:51 -0700 (PDT) Received: from stoup.. ([2602:ae:1547:e101:c626:2f70:ac99:7c97]) by smtp.gmail.com with ESMTPSA id k8-20020a170902d58800b001641244d051sm13378807plh.257.2022.06.07.22.19.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:19:50 -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=GB8QwFJfH3hlfZTD3yMvfbRrCq2bQTobhy4HeZnGERI=; b=E2+lQZu4gEeyLpetu/BjgozYH5ryNjR0Ihq6Vj9hx5x7XUPw/hxuP5G6gMJSm/TDXb N5xijYhvxA5/lxNHrjABgY1RKHHR8YMTD7q8YiRF6zGjeL4wlQfL/m/kyoSa+vmor1q1 KSiyYK8Y1E/SrmV07fBYc4mI32GqlqWp0ebrvv9LWZia3P29HsjcXXXHisPqiKhJt0Uo ObZDDfeWD1KylmfX2VoEBMoFTVHaKzUkxp4HtWmLehxetTfkgdqAfufcm/puFhif3N5g mgsvCZLfjl2UKYNCCoZK0tFqnPLfLDWIvqb59O3cPEjDmwR3Dt4kL+o1E5WHgKkv/wEx hZsw== 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=GB8QwFJfH3hlfZTD3yMvfbRrCq2bQTobhy4HeZnGERI=; b=QhWKKZZXKHe9q6VYJ91hT1bOvjDiLhaQCjmM1ZdaS+TZmvprC8Ittf/6MtmAwpUZFt 0tsv88/fRhb5aucIJ4gjJH92Yy7QrDPwWdJk+CN8vwSs+FBoozr9Yx1dbbNEQBxDUEj0 pRwPquNBIJ5xRd0sLkf1TQuYBBJBzFtismu4bKftOSDqfHruDT9oOL3e6kPvthQuDeFh F31Yu7g5TlPoWvq4Pkt0eXpouOQbNbbqSUstafORhHzLmsdM3PX7CiuNojkXQSc2oVwh JGaR+8I30Lpb3zxYIK6yUrKrk8k9EncCXgN0I4OpRkKwqNSM7JDjjZUUwBI+D0hX8CJT VFTw== X-Gm-Message-State: AOAM532S2wGJzyFvkuEBa4k9bJQoZjx4lKW7lqekfL1S+uvf8Q3saFSu lbFsC56Q9mJwjy7lvpwi8Fvcr3zz+z/+1w== X-Google-Smtp-Source: ABdhPJwhEvW1Otilw+qaJsowjLEdsuWYCz9YN505hGPOKC8RU5nmNi7Y2sAa1GzKnGwSEW16K9j2QA== X-Received: by 2002:a17:902:d50f:b0:166:41a8:abf5 with SMTP id b15-20020a170902d50f00b0016641a8abf5mr30945014plg.17.1654665590647; Tue, 07 Jun 2022 22:19:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: f4bug@amsat.org Subject: [PATCH v4 04/11] target/mips: Drop link syscall from semihosting Date: Tue, 7 Jun 2022 22:19:38 -0700 Message-Id: <20220608051945.802339-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220608051945.802339-1-richard.henderson@linaro.org> References: <20220608051945.802339-1-richard.henderson@linaro.org> 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=2607:f8b0:4864:20::102f; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102f.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654666168362100001 Content-Type: text/plain; charset="utf-8" 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 --- 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/mi= ps-semi.c index 33221444e1..254c7fad9a 100644 --- a/target/mips/tcg/sysemu/mips-semi.c +++ b/target/mips/tcg/sysemu/mips-semi.c @@ -387,15 +387,6 @@ void mips_semihosting(CPUMIPSState *env) gpr[2] =3D write_to_file(env, gpr[4], gpr[5], gpr[6], gpr[7]); gpr[3] =3D errno_mips(errno); break; -#ifndef _WIN32 - case UHI_link: - GET_TARGET_STRINGS_2(p, gpr[4], p2, gpr[5]); - gpr[2] =3D link(p, p2); - gpr[3] =3D 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(); --=20 2.34.1 From nobody Mon Feb 9 15:55:32 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1654666458; cv=none; d=zohomail.com; s=zohoarc; b=kCr+8cmD9EX/hzntxAYV0HjuPyUbuw4NvEUk2wNxkdgx0jZtHF2YM2SJ5NmBTbKYAVyindzKf/3SHwbxjWaMmVngMTFDjDFaeRNVhkDSXecLRy0X4EfDl+HV1rdZ2OllzP8TfvU1JKpBWV7kvJYV1l5A+sG9PibGHdpicQzbyTI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654666458; 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:References:Sender:Subject:To; bh=vchvWnQo4YVofH3IH1WWni/usGrLZ5KUM5YMsZGZNkI=; b=KjYtGE1rPIGFkU2hxV6f9wMK5SJQnmUQ4u+B3vVDmMIbIgoUxSn5A5CEw+Vif3AaEbDuV4UqngnkU3JQGalfKhq6/hQ/DjYkKaatTbwHjWVIslEeHOTGJDnvU1xoZWieKWPiXFl+dC1TWV246EbvoEeRcMo/bszIWskh3AP5BVI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1654666458441923.97199805079; Tue, 7 Jun 2022 22:34:18 -0700 (PDT) Received: from localhost ([::1]:56990 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nyoKe-0006pr-Po for importer@patchew.org; Wed, 08 Jun 2022 01:34:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33794) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nyo6m-0006u7-F3 for qemu-devel@nongnu.org; Wed, 08 Jun 2022 01:19:57 -0400 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]:51941) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nyo6k-00022n-2R for qemu-devel@nongnu.org; Wed, 08 Jun 2022 01:19:56 -0400 Received: by mail-pj1-x102d.google.com with SMTP id cx11so17604822pjb.1 for ; Tue, 07 Jun 2022 22:19:52 -0700 (PDT) Received: from stoup.. ([2602:ae:1547:e101:c626:2f70:ac99:7c97]) by smtp.gmail.com with ESMTPSA id k8-20020a170902d58800b001641244d051sm13378807plh.257.2022.06.07.22.19.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:19:51 -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=vchvWnQo4YVofH3IH1WWni/usGrLZ5KUM5YMsZGZNkI=; b=HO93Od8Vu9r1/7Kh/vDT8rMHYrZUCwZlEUwD7ybT0KMJJGpaehkDXxlBKXRotfBuvL rlsT3h/MR8tJHQ2EuMz9yZw3pCN7gDJDhAzboNaIilqpj+6WVhuXVtc/+B1BqPcu5jD2 i/sdaq04RFONOuKrsgoE+Go4Qn4VyfXOvkLgNO6nXrMcuNG+AR5uK3XC8cs0UoT3XgMz x8O4vba/txcRUZ1ap17I9dohaiXDS2l9/2z/EVk9of8onkkNfSSgUY5PLeF0F+N32rou AgfYb2+BATJy7gg/YrfJlBmS1ympWgSwNSm9nQloQU8xKqVgiVdFalG6d4SdIGoIuhX5 H28A== 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=vchvWnQo4YVofH3IH1WWni/usGrLZ5KUM5YMsZGZNkI=; b=o9zuqMWtHk52MeVvkt2kqFIvRmE0DZejINyYMWMXhMRg7wGWM9+duKD8ulKrxkI+Wo aQVATO8iiS8/hAflGaV0veYJVKvioIe93pxDnIxjKB7PC1x/gzlZAsKPWWc8xI7lyv5b 18px1Gi4hZ2Fw9a4bYiELQL06ZPVfwXGuCyVG9ofLeDyLF68x+AT8UN7QHcWIc+G3H+c HguPgQUK/jyQjr82q6vo98TTPo60slzUBU5CmQQvrVM0nH8m+WCLZQfAV+4WppazCNhP /JNiNX53fEWdWB7N3Fx9H4M/KnSaTZx9FVZIoGm66yrSB5hT9Met54Vm398J/+qmNYGP Agsw== X-Gm-Message-State: AOAM530/Tp11v63jYqK/KJmo+SAJInt9f4GX76saDCv7mjj39yKa8g2j twtzFWw8osC8as3lw1F2XNLMJaTUBnjc1g== X-Google-Smtp-Source: ABdhPJzQi3nSng+qOGH+9GvOxIVMIpl9+jcGP786BjSMmR2fAjhDNehq+0zd14UA306TqArTYlRJOA== X-Received: by 2002:a17:90b:4b90:b0:1e8:48bd:453 with SMTP id lr16-20020a17090b4b9000b001e848bd0453mr24626763pjb.86.1654665591427; Tue, 07 Jun 2022 22:19:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: f4bug@amsat.org Subject: [PATCH v4 05/11] target/mips: Drop pread and pwrite syscalls from semihosting Date: Tue, 7 Jun 2022 22:19:39 -0700 Message-Id: <20220608051945.802339-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220608051945.802339-1-richard.henderson@linaro.org> References: <20220608051945.802339-1-richard.henderson@linaro.org> 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=2607:f8b0:4864:20::102d; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102d.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654666459924100001 Content-Type: text/plain; charset="utf-8" We don't implement it with _WIN32 hosts, and the syscalls are missing from the gdb remote file i/o interface. Since we can't implement them universally, drop them. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/mips/tcg/sysemu/mips-semi.c | 39 ++++++------------------------ 1 file changed, 7 insertions(+), 32 deletions(-) diff --git a/target/mips/tcg/sysemu/mips-semi.c b/target/mips/tcg/sysemu/mi= ps-semi.c index 254c7fad9a..93c9d3d0b3 100644 --- a/target/mips/tcg/sysemu/mips-semi.c +++ b/target/mips/tcg/sysemu/mips-semi.c @@ -188,8 +188,8 @@ static int get_open_flags(target_ulong target_flags) return open_flags; } =20 -static int write_to_file(CPUMIPSState *env, target_ulong fd, target_ulong = vaddr, - target_ulong len, target_ulong offset) +static int write_to_file(CPUMIPSState *env, target_ulong fd, + target_ulong vaddr, target_ulong len) { int num_of_bytes; void *dst =3D lock_user(VERIFY_READ, vaddr, len, 1); @@ -197,23 +197,14 @@ static int write_to_file(CPUMIPSState *env, target_ul= ong fd, target_ulong vaddr, report_fault(env); } =20 - if (offset) { -#ifdef _WIN32 - num_of_bytes =3D 0; -#else - num_of_bytes =3D pwrite(fd, dst, len, offset); -#endif - } else { - num_of_bytes =3D write(fd, dst, len); - } + num_of_bytes =3D write(fd, dst, len); =20 unlock_user(dst, vaddr, 0); return num_of_bytes; } =20 static int read_from_file(CPUMIPSState *env, target_ulong fd, - target_ulong vaddr, target_ulong len, - target_ulong offset) + target_ulong vaddr, target_ulong len) { int num_of_bytes; void *dst =3D lock_user(VERIFY_WRITE, vaddr, len, 0); @@ -221,15 +212,7 @@ static int read_from_file(CPUMIPSState *env, target_ul= ong fd, report_fault(env); } =20 - if (offset) { -#ifdef _WIN32 - num_of_bytes =3D 0; -#else - num_of_bytes =3D pread(fd, dst, len, offset); -#endif - } else { - num_of_bytes =3D read(fd, dst, len); - } + num_of_bytes =3D read(fd, dst, len); =20 unlock_user(dst, vaddr, len); return num_of_bytes; @@ -309,11 +292,11 @@ void mips_semihosting(CPUMIPSState *env) gpr[3] =3D errno_mips(errno); break; case UHI_read: - gpr[2] =3D read_from_file(env, gpr[4], gpr[5], gpr[6], 0); + gpr[2] =3D read_from_file(env, gpr[4], gpr[5], gpr[6]); gpr[3] =3D errno_mips(errno); break; case UHI_write: - gpr[2] =3D write_to_file(env, gpr[4], gpr[5], gpr[6], 0); + gpr[2] =3D write_to_file(env, gpr[4], gpr[5], gpr[6]); gpr[3] =3D errno_mips(errno); break; case UHI_lseek: @@ -379,14 +362,6 @@ void mips_semihosting(CPUMIPSState *env) FREE_TARGET_STRING(p, gpr[4]); abort(); break; - case UHI_pread: - gpr[2] =3D read_from_file(env, gpr[4], gpr[5], gpr[6], gpr[7]); - gpr[3] =3D errno_mips(errno); - break; - case UHI_pwrite: - gpr[2] =3D write_to_file(env, gpr[4], gpr[5], gpr[6], gpr[7]); - gpr[3] =3D errno_mips(errno); - break; default: error_report("Unknown UHI operation %d", op); abort(); --=20 2.34.1 From nobody Mon Feb 9 15:55:32 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1654665925; cv=none; d=zohomail.com; s=zohoarc; b=Cq1QUj2LCGyZaTd8w0tLigfRYeWsmdXAhsV4uxgPRZ41GHbJ9TSz3+VKd6dpXNTu6blPf7Ywa+QHxv+GQ4wwpjNgY4kB2hr4sefSbN6gB7M2CLXoZjZqvuOf8akqqsVjCZ7SAr4C7uWfvnaATFkFd0IjYsSW1J0QcFfJWlFSsRk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654665925; 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:References:Sender:Subject:To; bh=w6sA15MForuaAbeYWpiX93UQp8+cxumrK25JuRIu/m4=; b=BGd4puvjvygTy1ykw9nEf2/QBfFvCWn5cruZAVedpsy2uWxX/E6LE0hgHk6vfgznFapbe+C3q5Q2R3NUU64FwUhM4Q7MAi3k+2I/GH1scBJL0tE2Xh/9DxYS+Eu2YsPf7wvpXLGwPpb/Bdt2IxMvJPCBo5PvD77B+NavjPAWNGQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 165466592561758.25923586627414; Tue, 7 Jun 2022 22:25:25 -0700 (PDT) Received: from localhost ([::1]:42140 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nyoC4-0004yc-Gn for importer@patchew.org; Wed, 08 Jun 2022 01:25:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33772) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nyo6l-0006sG-P3 for qemu-devel@nongnu.org; Wed, 08 Jun 2022 01:19:55 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]:42513) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nyo6j-00022t-IO for qemu-devel@nongnu.org; Wed, 08 Jun 2022 01:19:55 -0400 Received: by mail-pl1-x631.google.com with SMTP id d22so16654555plr.9 for ; Tue, 07 Jun 2022 22:19:53 -0700 (PDT) Received: from stoup.. ([2602:ae:1547:e101:c626:2f70:ac99:7c97]) by smtp.gmail.com with ESMTPSA id k8-20020a170902d58800b001641244d051sm13378807plh.257.2022.06.07.22.19.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:19:51 -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=wMp7LNDSTptFCOih4ohk+W2pqcN5C1jxxDYwep0oYeMrcruYis0XZ1kRVB4eOMUopO r6vLG1TfctTMqIBpxwJxJ7GC8uOiL7vDdeivpBU74/gfo4CJMWXzp3B44ACGf5J8mQ+A 12tU/mRQ2N0i26E15ti0lMVqeHAEYcZOGDwv0TuVt03Hd1ZpoYvDAFsFuQC5FUD7Qjq4 HY23Ju2l57Vg1sHXzqt7ygWbXncaRO6BvB+WWzXiexaez56w2UGVkgHTrVEfvIc27uFQ jDyCDQ0LSi6JWIHdT0NZx/8wNYVZ4YJ56vnhTsk0voZdMIR56g/Gon/ovQeY6unppfsV RZzg== 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=eKKpTJG/M7kJsfesAu8HdWVDs6DUgcCOrXMz9VwnFnVzPwweFdFcQkiU17lMVieI6T McgADVvNxBGhMV7nDQR6xQcgdGWquBUCC9fxoK6mPBuONE2NcbpXV17DGcD2bCgAlumx NrEbb9LvzQeAz53jsmx0qreT6xDP911bRjO12zkTR/UC7Kv1HeEh4Zaat4+49AyVujcg S45DlhdS5PUxlJ7tVDCzE06LwE9V9jlsB5bic8rvSmfT104tLOszHSF4zD8vC7BBNF3k y8LdEBibxKSBr3GNpXRWlQZMa+d8qkUe2sLaN08dOTlT3AY2fcmhhB/fDIOgbGeI9Fdl wNDw== X-Gm-Message-State: AOAM532jzRf8WXrxYgZ4CaAQZwrQyFEE3ZeG77ESdqVHe8Nn4u3qeRwF 6pwfjZWIw6pAwCD9aqb4BSBNuTTGc5uqfQ== X-Google-Smtp-Source: ABdhPJyuuRzBF1K7F6KaTbMxRRtTq2fSWZy1j+BiASfz941GymX0ybaicC0CpZxM1kWpv0QNl6780g== X-Received: by 2002:a17:902:b18e:b0:15e:c6ac:440a with SMTP id s14-20020a170902b18e00b0015ec6ac440amr32831778plr.152.1654665592146; Tue, 07 Jun 2022 22:19:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: f4bug@amsat.org Subject: [PATCH v4 06/11] target/mips: Use semihosting/syscalls.h Date: Tue, 7 Jun 2022 22:19:40 -0700 Message-Id: <20220608051945.802339-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220608051945.802339-1-richard.henderson@linaro.org> References: <20220608051945.802339-1-richard.henderson@linaro.org> 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=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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654665926954100002 Content-Type: text/plain; charset="utf-8" This separates guest file descriptors from host file descriptors, and utilizes shared infrastructure for integration with gdbstub. Signed-off-by: Richard Henderson --- 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/mi= ps-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" =20 typedef enum UHIOp { @@ -121,101 +123,79 @@ static void report_fault(CPUMIPSState *env) abort(); } =20 -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 =3D cs->env_ptr; =20 -static int copy_stat_to_target(CPUMIPSState *env, const struct stat *src, - target_ulong vaddr) -{ - hwaddr len =3D sizeof(struct UHIStat); - UHIStat *dst =3D lock_user(VERIFY_WRITE, vaddr, len, 0); - if (!dst) { +#define E(N) case E##N: err =3D 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 =3D UHI_EINVAL; + break; + case EFAULT: report_fault(env); } =20 - dst->uhi_st_dev =3D tswap16(src->st_dev); - dst->uhi_st_ino =3D tswap16(src->st_ino); - dst->uhi_st_mode =3D tswap32(src->st_mode); - dst->uhi_st_nlink =3D tswap16(src->st_nlink); - dst->uhi_st_uid =3D tswap16(src->st_uid); - dst->uhi_st_gid =3D tswap16(src->st_gid); - dst->uhi_st_rdev =3D tswap16(src->st_rdev); - dst->uhi_st_size =3D tswap64(src->st_size); - dst->uhi_st_atime =3D tswap64(src->st_atime); - dst->uhi_st_mtime =3D tswap64(src->st_mtime); - dst->uhi_st_ctime =3D tswap64(src->st_ctime); -#ifdef _WIN32 - dst->uhi_st_blksize =3D 0; - dst->uhi_st_blocks =3D 0; -#else - dst->uhi_st_blksize =3D tswap64(src->st_blksize); - dst->uhi_st_blocks =3D tswap64(src->st_blocks); -#endif - unlock_user(dst, vaddr, len); - return 0; +#undef E + + env->active_tc.gpr[2] =3D ret; + env->active_tc.gpr[3] =3D err; } =20 -static int get_open_flags(target_ulong target_flags) +static void uhi_fstat_cb(CPUState *cs, uint64_t ret, int err) { - int open_flags =3D 0; + QEMU_BUILD_BUG_ON(sizeof(UHIStat) < sizeof(struct gdb_stat)); =20 - if (target_flags & UHIOpen_RDWR) { - open_flags |=3D O_RDWR; - } else if (target_flags & UHIOpen_WRONLY) { - open_flags |=3D O_WRONLY; - } else { - open_flags |=3D O_RDONLY; + if (!err) { + CPUMIPSState *env =3D cs->env_ptr; + target_ulong addr =3D env->active_tc.gpr[5]; + UHIStat *dst =3D 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 =3D tswap16(be32_to_cpu(s.gdb_st_dev)); + dst->uhi_st_ino =3D tswap16(be32_to_cpu(s.gdb_st_ino)); + dst->uhi_st_mode =3D tswap32(be32_to_cpu(s.gdb_st_mode)); + dst->uhi_st_nlink =3D tswap16(be32_to_cpu(s.gdb_st_nlink)); + dst->uhi_st_uid =3D tswap16(be32_to_cpu(s.gdb_st_uid)); + dst->uhi_st_gid =3D tswap16(be32_to_cpu(s.gdb_st_gid)); + dst->uhi_st_rdev =3D tswap16(be32_to_cpu(s.gdb_st_rdev)); + dst->uhi_st_size =3D tswap64(be64_to_cpu(s.gdb_st_size)); + dst->uhi_st_atime =3D tswap64(be32_to_cpu(s.gdb_st_atime)); + dst->uhi_st_mtime =3D tswap64(be32_to_cpu(s.gdb_st_mtime)); + dst->uhi_st_ctime =3D tswap64(be32_to_cpu(s.gdb_st_ctime)); + dst->uhi_st_blksize =3D tswap64(be64_to_cpu(s.gdb_st_blksize)); + dst->uhi_st_blocks =3D tswap64(be64_to_cpu(s.gdb_st_blocks)); + + unlock_user(dst, addr, sizeof(UHIStat)); } =20 - open_flags |=3D (target_flags & UHIOpen_APPEND) ? O_APPEND : 0; - open_flags |=3D (target_flags & UHIOpen_CREAT) ? O_CREAT : 0; - open_flags |=3D (target_flags & UHIOpen_TRUNC) ? O_TRUNC : 0; - open_flags |=3D (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 =3D lock_user(VERIFY_READ, vaddr, len, 1); - if (!dst) { - report_fault(env); - } - - num_of_bytes =3D 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 =3D lock_user(VERIFY_WRITE, vaddr, len, 0); - if (!dst) { - report_fault(env); - } - - num_of_bytes =3D read(fd, dst, len); - - unlock_user(dst, vaddr, len); - return num_of_bytes; + uhi_cb(cs, ret, err); } =20 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, =20 void mips_semihosting(CPUMIPSState *env) { + CPUState *cs =3D env_cpu(env); target_ulong *gpr =3D env->active_tc.gpr; const UHIOp op =3D gpr[25]; char *p, *p2; =20 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] =3D 0; - } else if (!strcmp("/dev/stdout", p)) { - gpr[2] =3D 1; - } else if (!strcmp("/dev/stderr", p)) { - gpr[2] =3D 2; - } else { - gpr[2] =3D open(p, get_open_flags(gpr[5]), gpr[6]); - gpr[3] =3D errno_mips(errno); + { + int ret =3D -1; + + GET_TARGET_STRING(p, gpr[4]); + if (!strcmp("/dev/stdin", p)) { + ret =3D 0; + } else if (!strcmp("/dev/stdout", p)) { + ret =3D 1; + } else if (!strcmp("/dev/stderr", p)) { + ret =3D 2; + } + FREE_TARGET_STRING(p, gpr[4]); + + /* FIXME: reusing a guest fd doesn't seem correct. */ + if (ret >=3D 0) { + gpr[2] =3D 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] =3D 0; - return; - } - gpr[2] =3D close(gpr[4]); - gpr[3] =3D errno_mips(errno); + semihost_sys_close(cs, uhi_cb, gpr[4]); break; case UHI_read: - gpr[2] =3D read_from_file(env, gpr[4], gpr[5], gpr[6]); - gpr[3] =3D errno_mips(errno); + semihost_sys_read(cs, uhi_cb, gpr[4], gpr[5], gpr[6]); break; case UHI_write: - gpr[2] =3D write_to_file(env, gpr[4], gpr[5], gpr[6]); - gpr[3] =3D errno_mips(errno); + semihost_sys_write(cs, uhi_cb, gpr[4], gpr[5], gpr[6]); break; case UHI_lseek: - gpr[2] =3D lseek(gpr[4], gpr[5], gpr[6]); - gpr[3] =3D 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] =3D remove(p); - gpr[3] =3D 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] =3D fstat(gpr[4], &sbuf); - gpr[3] =3D errno_mips(errno); - if (gpr[2]) { - return; - } - gpr[2] =3D copy_stat_to_target(env, &sbuf, gpr[5]); - gpr[3] =3D errno_mips(errno); - } + semihost_sys_fstat(cs, uhi_fstat_cb, gpr[4], gpr[5]); break; + case UHI_argc: gpr[2] =3D semihosting_get_argc(); break; --=20 2.34.1 From nobody Mon Feb 9 15:55:32 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1654666364; cv=none; d=zohomail.com; s=zohoarc; b=M4sK+359J3FqY2vBb3i5PDSsLja5gYCJAnEwcBe/rXo5x7krV0TTr9jpZsZdygVYHl5tbkDvofhk5ppV4Q++klNaNKM6w10fL8FwruVFE1Nfon3l65VrSjZgYQ0UWwI9yCyaBuadWeTx456UGL2+hkYxNvDTnsFQTQBU/jxZtnY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654666364; 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:References:Sender:Subject:To; bh=rmf1h8nOdErU6TZ6hYcqWua8rMBnQ07/JNvdx/MscPs=; b=FlepwofZ+1WVdEqmkgjq6auO6UMP6Wh/q3mQoXU1Y1GXfiZJhLaT0PMQAfJBwnlf34g0oQCf6ZMeVU4DhoPQnNMGOR9/BGM8IajFRi/Jpv/uQNhXjWTQwRBuwryHuc5ubR6D1v48dK05wCK+v3w7RgDtyRXubTZrkgVkoJZyo04= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1654666364252694.3844156248082; Tue, 7 Jun 2022 22:32:44 -0700 (PDT) Received: from localhost ([::1]:53596 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nyoJ8-0004Uh-IJ for importer@patchew.org; Wed, 08 Jun 2022 01:32:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33818) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nyo6n-0006vM-6j for qemu-devel@nongnu.org; Wed, 08 Jun 2022 01:19:57 -0400 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]:34376) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nyo6l-000239-Fl for qemu-devel@nongnu.org; Wed, 08 Jun 2022 01:19:56 -0400 Received: by mail-pj1-x1035.google.com with SMTP id mh16-20020a17090b4ad000b001e8313301f1so9155722pjb.1 for ; Tue, 07 Jun 2022 22:19:54 -0700 (PDT) Received: from stoup.. ([2602:ae:1547:e101:c626:2f70:ac99:7c97]) by smtp.gmail.com with ESMTPSA id k8-20020a170902d58800b001641244d051sm13378807plh.257.2022.06.07.22.19.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:19:52 -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=YgNcAVgxteMAGOD9q04cE3zwRZoC+3IO4J2yIi2lh2iR7ey0Uj8ofdKU1uaZoQo4/L 1Ey9mc8qOslv2xyM5+F4X0Qrns+rmP6+9pftHrtUqvG133qDmbvh28iq3DaA8ATly5HC cKlEWkHpPI8qQZaZhBP9C5E46X6QRvuvFkbahYmKY1ob3mAuVnPDunlg2mZ5smXmWo/i fcfFuBQW619oS9YAYN/bn1bdGEzRdJPbeUznpI2JObDrzr2vNIaH7GH3ouOkeSUa95It OUOd6kV+tw5ywwZQ0Rxr+BaN6ifgbdlmJHoZKKr4UlU/+FB5YhLeJOHzdQvj89riV+9O mJmQ== 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=ava5xKm02WR2ZoivT8dj/2M+A8Ul0zqPgrQbaPqa5SMgG18dQnmReKP+fUXaN4vrFL QWFhlT95fKmClELdxpS06wKwSrX5rF8PGCfxdHBX6SCq20ahyjCJN71v/Nn+iFgkVD9A ND5ncUmiJJGnpfnvD1ONDJohksgaXvKF59Uj5gmNzV/Ebj3OzRIsGh+WUmiQpX5QnU7j kDj6Q6zJ022N4ovFgBLRvD8K4TPd0/1wovKLTMjdE0clIceS55e9cAfY7pO2dCyYf12I UQP3WHhaoN4Al7vUg+bvP1JNvrAkQ1DSv1MtFAGF6WHDX25twwa3JvYZT+bT+XfDYb9f GXOQ== X-Gm-Message-State: AOAM531qufn2F80sVYLZPI832ppYVd2r1Zj0Ay6H7hXt++g9NW/d1pZ+ wIN/m4d0PDhaNiBQ3dq3TuP/vfObUNeboA== X-Google-Smtp-Source: ABdhPJyJTZ0G9dsdM8QHKf8NDiO6r4tEgC7Pbf1U00o7g5odxxZy0h5t4yaT3L6YguCCWZFc6vZGKg== X-Received: by 2002:a17:90b:3907:b0:1e8:57f9:dadb with SMTP id ob7-20020a17090b390700b001e857f9dadbmr22214461pjb.137.1654665592967; Tue, 07 Jun 2022 22:19:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: f4bug@amsat.org Subject: [PATCH v4 07/11] target/mips: Avoid qemu_semihosting_log_out for UHI_plog Date: Tue, 7 Jun 2022 22:19:41 -0700 Message-Id: <20220608051945.802339-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220608051945.802339-1-richard.henderson@linaro.org> References: <20220608051945.802339-1-richard.henderson@linaro.org> 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=2607:f8b0:4864:20::1035; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1035.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654666365310100001 Content-Type: text/plain; charset="utf-8" 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 --- 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/mi= ps-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] =3D copy_argn_to_target(env, gpr[4], gpr[5]); break; + case UHI_plog: - GET_TARGET_STRING(p, gpr[4]); - p2 =3D strstr(p, "%d"); - if (p2) { - int char_num =3D p2 - p; - GString *s =3D g_string_new_len(p, char_num); - g_string_append_printf(s, "%d%s", (int)gpr[5], p2 + 2); - gpr[2] =3D qemu_semihosting_log_out(s->str, s->len); - g_string_free(s, true); - } else { - gpr[2] =3D qemu_semihosting_log_out(p, strlen(p)); + { + target_ulong addr =3D gpr[4]; + ssize_t len =3D target_strlen(addr); + GString *str; + char *pct_d; + + if (len < 0) { + report_fault(env); + } + p =3D lock_user(VERIFY_READ, addr, len, 1); + if (!p) { + report_fault(env); + } + + pct_d =3D strstr(p, "%d"); + if (!pct_d) { + FREE_TARGET_STRING(p, addr); + semihost_sys_write(cs, uhi_cb, 2, addr, len); + break; + } + + str =3D 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 =3D gpr[29] - str->len; + p =3D 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] =3D qemu_semihosting_console_write(str->str, str->l= en); + } + 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 '"); --=20 2.34.1 From nobody Mon Feb 9 15:55:32 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1654665925; cv=none; d=zohomail.com; s=zohoarc; b=h5SxlEoK7/7wTTAnhyKnGMGa2fqs4qc4wGVrtRXgQudPxIFi2KNR0200V3Ph29uN74gcJrSfYoT7D/GjjA3wCEwHoheS73QMzOs5U0kpr+VBktYP40YREvvuilaOd37Zc0qC9IK6fZRR5KB++dq/IEcqiVYM2xILkKm9AnAVs7A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654665925; 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:References:Sender:Subject:To; bh=RM42zMRkI421HiARyMb/O/C2Vq6+9jMrjOfzX4mv7Y0=; b=RLzbFlAJoXkSR1Adueao/3YsgrKuluDpOdYK0ZBhcXNZg35e3iVy6j5Hvjcz0TAfzMoyT7BJPhJG8YqKWhpz28ZFVl04dHSHvshieAKe79C+VvP/j1z0pn5gBPTtTF6D/XR4WR4kPsiWqqIu1mcych4acDz7u63ZGg/2ZySbC/c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1654665925423554.1788648740396; Tue, 7 Jun 2022 22:25:25 -0700 (PDT) Received: from localhost ([::1]:42076 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nyoC4-0004wO-EP for importer@patchew.org; Wed, 08 Jun 2022 01:25:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33834) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nyo6o-0006wc-8l for qemu-devel@nongnu.org; Wed, 08 Jun 2022 01:19:58 -0400 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]:34673) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nyo6l-00023M-Hq for qemu-devel@nongnu.org; Wed, 08 Jun 2022 01:19:57 -0400 Received: by mail-pg1-x535.google.com with SMTP id g186so9023917pgc.1 for ; Tue, 07 Jun 2022 22:19:54 -0700 (PDT) Received: from stoup.. ([2602:ae:1547:e101:c626:2f70:ac99:7c97]) by smtp.gmail.com with ESMTPSA id k8-20020a170902d58800b001641244d051sm13378807plh.257.2022.06.07.22.19.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:19:53 -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=dRsQuzcSmi2ALA61dgmw9YNkB/KU2DY3wZ+ycRfkqzaLNS52pMxxk4fkl4yMAKQu4C 76FMAJZGHYTmPkxa3l5s4FLFJk7//rDnuuR8KpXC1b4InpVP1gav1re1C0/gjE24EVt/ gb7aDmMhALtbOWI/2TUpKDMFwvjpflek2X9BhA/cxq28LjBptVUsSgu5qJqYAndh1u1U PF7pxRhyJ26tGgudtSA+XEKJbkukPm2MD41yJjs1byS/9Gq2l9LBq6PaM0jbdNzJFLiD Izb5MmRj87p0rYnVfsKd6K+mySJXj9YbBLdumFUfkMT0gTrk8Ry15EIevvzG0t4806b8 vVbQ== 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=owOL48bq5915nj5qClpOto2a71OWilPZINbBvvkNbTqAXKxCUoJ+dkzMuB8zpxV02R grMpfprzmfMh9ezEzoc4NbdlLsVjqgpPdJVBI0wYtKlShWXHmLabZScHG6FNh09I7POd bkaaSumuJ7QkupMZvseMgcUp/r3JT46JAdBufAjUfhn1Vh+CQk78FtsWJdIU1gXfLZdi FUMQ74AYrkqvaWHxV8HRrowx0cDN84wIIH2Y5PomaZU+Sr0BST0kKqADq8q6tx+Uukor 1kYOyTm2t4iTh68dVkL1Lxu44Q4H5wBByxNXsy/2RgylXxh2vpj3SJscc9iW8PGuzhRj vmBg== X-Gm-Message-State: AOAM5308AHqVSlgOu/+4/kWjqdANrQ2DlAHZP+Pvilr5bqMGG3sk2/mC xoazBXbMUYznMf2UsPsd3Ma7OPxH9YZ7ZA== X-Google-Smtp-Source: ABdhPJwSwasrgVOfl8arpPmVCujet79bJ+ZQnKoa/3dAA5X0jOB0QFOhvGHfQ2mQOfKdryRpE6A90Q== X-Received: by 2002:a62:8702:0:b0:51b:c452:33cf with SMTP id i2-20020a628702000000b0051bc45233cfmr25358364pfe.72.1654665593769; Tue, 07 Jun 2022 22:19:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: f4bug@amsat.org Subject: [PATCH v4 08/11] target/mips: Use error_report for UHI_assert Date: Tue, 7 Jun 2022 22:19:42 -0700 Message-Id: <20220608051945.802339-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220608051945.802339-1-richard.henderson@linaro.org> References: <20220608051945.802339-1-richard.henderson@linaro.org> 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=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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654665926927100001 Content-Type: text/plain; charset="utf-8" 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=C3=A9 --- 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/mi= ps-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) =20 -#define GET_TARGET_STRINGS_2(p, addr, p2, addr2) \ - do { \ - p =3D lock_user_string(addr); \ - if (!p) { \ - report_fault(env); \ - } \ - p2 =3D 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 =3D env_cpu(env); target_ulong *gpr =3D env->active_tc.gpr; const UHIOp op =3D gpr[25]; - char *p, *p2; + char *p; =20 switch (op) { case UHI_exit: @@ -355,14 +343,23 @@ void mips_semihosting(CPUMIPSState *env) break; =20 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 =3D lock_user_string(gpr[4]); + if (!msg) { + msg =3D ""; + } + file =3D lock_user_string(gpr[5]); + if (!file) { + file =3D ""; + } + + error_report("UHI assertion \"%s\": file \"%s\", line %d", + msg, file, (int)gpr[6]); + abort(); + } + default: error_report("Unknown UHI operation %d", op); abort(); --=20 2.34.1 From nobody Mon Feb 9 15:55:32 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1654665749; cv=none; d=zohomail.com; s=zohoarc; b=nOQzfMFM99XR9JRcAXraM2/TGWa9LzXHhqjBMtI7s9IOCJuC5e5GVKrVcl/c+KoKMnd9b19JaZ3LP9k+0ukvotOyDnChJBtuS58gjR6GLIHyboBu7AgV/62n/nXeFR92EBXh60Tl2n3foA/qZWKSYHug+s8k/kaefRc0GA1FqUw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654665749; 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:References:Sender:Subject:To; bh=7hrYGm6CB5wl83BARKhSg3dxjfTTX0HLuXW9+o58cZc=; b=OOjb0wKQwlLKUs36oV3SoioZjxoEqqdnfHXJwOeXWYugJDgDVUrgk3bR3ScZNByIpC+XKokS2OQvCiZd2QhaHtDVY9cRK7gqW6/0bK6m1W7Vd5XPojvIkjZoadeRXrM28RDlJ+M03dtlhFgnhq4cNrExoqs4iYiKWGQDt4XosJA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 165466574957128.429737436691994; Tue, 7 Jun 2022 22:22:29 -0700 (PDT) Received: from localhost ([::1]:35746 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nyo9E-0000gq-JW for importer@patchew.org; Wed, 08 Jun 2022 01:22:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33826) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nyo6n-0006vd-LH for qemu-devel@nongnu.org; Wed, 08 Jun 2022 01:19:57 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]:42506) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nyo6m-00023W-0C for qemu-devel@nongnu.org; Wed, 08 Jun 2022 01:19:57 -0400 Received: by mail-pl1-x629.google.com with SMTP id d22so16654615plr.9 for ; Tue, 07 Jun 2022 22:19:55 -0700 (PDT) Received: from stoup.. ([2602:ae:1547:e101:c626:2f70:ac99:7c97]) by smtp.gmail.com with ESMTPSA id k8-20020a170902d58800b001641244d051sm13378807plh.257.2022.06.07.22.19.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:19:54 -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=7hrYGm6CB5wl83BARKhSg3dxjfTTX0HLuXW9+o58cZc=; b=IuGF6ySv0370yKn52DUQm+78xcb46sg7ZJPS1Kz2moi07HrQnuVBliDqhWEq3rYU6M i8R0sXlieBGs2ovK90kIvVfcx+RVi3Y5Zk2taOIBNan0n1/umZ0PY7rjzEOE0HoIcOAZ OHM1tbyuhs1pf1BLmW5ZXRSdDRhQiWa3RSyCLb4oItpXHrmzpPvcz/1zSQoPse50KTCp 8et6k/7RSLPvKKYjOD2XFdK8qhB674hm7ly7JF30qN9/V5nn4mF+f3vKHR2u8OqTOkwU LHT8hBREJ1Wv8ytSUtgJH2eOHkLTDdhmiHAH+4LumNgI0w5cxHPAnRASks2oT1uGCdPu eNHg== 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=7hrYGm6CB5wl83BARKhSg3dxjfTTX0HLuXW9+o58cZc=; b=TsJ2BuvX8uTvUsvWVQ2vI+7C2Oz4oDSjRy02OAl3Bj4tWqCjsWyu2hAB/pPoywk3Os IITM8R5k5KI2w5m8bjwntInpFsIloiUEMSekQG2qp2eVPJP/poSZtt2cWBBOPObHwv6y 1GP/v0z0EaZiCn20fGoRv2WQ6Bo1q8Z2wdBv/XlNas5cEwoWy8PyrokZxKskH6M3Btoq WZV9kR3O1EzDpl7LYj/X/7nbkwQo/KAtTqa4+iPXXvvErP9KBmqODWR1t4mcu6OZ4Sr1 bmRyLaxo71JB0lowFXfd5aJ6mjtlVbCDmQfZn6InBITt38OkLp9RCxTUX0g0jHnSrakp DNAA== X-Gm-Message-State: AOAM530cbkex2jUMC/ccBfgNzKwW4bZbTq/3aDCBS/8sSxPDst8mBlCw XLJ6fBQpM2BgRjBuSztc14HgBanKNbDXng== X-Google-Smtp-Source: ABdhPJwsaSXvAkui0/Q5ZkW2MOjHfC2W/jqjAww4zLqR4ntqi11iN9lKAX8Tw80IyrI6cYbGvhX5Rg== X-Received: by 2002:a17:902:e888:b0:163:f3e5:b379 with SMTP id w8-20020a170902e88800b00163f3e5b379mr32680921plg.62.1654665594551; Tue, 07 Jun 2022 22:19:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: f4bug@amsat.org Subject: [PATCH v4 09/11] semihosting: Remove qemu_semihosting_log_out Date: Tue, 7 Jun 2022 22:19:43 -0700 Message-Id: <20220608051945.802339-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220608051945.802339-1-richard.henderson@linaro.org> References: <20220608051945.802339-1-richard.henderson@linaro.org> 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=2607:f8b0:4864:20::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654665750228100003 Content-Type: text/plain; charset="utf-8" The function is no longer used. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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 *bu= f, int len); */ int qemu_semihosting_console_write(void *buf, int len); =20 -/** - * 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 { =20 static SemihostingConsole console; =20 -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 =20 static int console_can_read(void *opaque) --=20 2.34.1 From nobody Mon Feb 9 15:55:32 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1654666372; cv=none; d=zohomail.com; s=zohoarc; b=PljviqMGJBsRQGNgeWvu+CxLDR0E36FEk4W0EdvEZsVjCBmDSj74XSJJfrHdadybKE6ZIcbUK0wHQRMkbnTK2S6nhlxh/okMLJTr4uhdiVYBSno2JcOlHEJhfPMH99RC6FYEwreAW2TZ75SqnV8GqZbdw4XKrA8ef0JosN9WMCA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654666372; 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:References:Sender:Subject:To; bh=qIoo0LzyvHSUbYXwQZj3nHuBOs19Duk2E4Vx8ekmqlk=; b=LfkRAz+zIqaEPo/cM/YB77wZ6Q3OH5xp3KtlPC9+BK61oTHRH5oFUdbUROrHIzicCO8de9FTfdf1+FyVWlj7Za4mDKJfDXk5/SXMAJyXp6zV3bSoF4rQr+iameadtDaJG6LqxSqGo9uD5HveeKVcTtrN1SqCFBrnm8BDM54T4SY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1654666372369594.7216751680595; Tue, 7 Jun 2022 22:32:52 -0700 (PDT) Received: from localhost ([::1]:53984 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nyoJG-0004kY-TA for importer@patchew.org; Wed, 08 Jun 2022 01:32:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33848) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nyo6p-0006zg-Nf for qemu-devel@nongnu.org; Wed, 08 Jun 2022 01:19:59 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]:34584) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nyo6n-00023x-5Y for qemu-devel@nongnu.org; Wed, 08 Jun 2022 01:19:59 -0400 Received: by mail-pf1-x436.google.com with SMTP id c196so17413536pfb.1 for ; Tue, 07 Jun 2022 22:19:56 -0700 (PDT) Received: from stoup.. ([2602:ae:1547:e101:c626:2f70:ac99:7c97]) by smtp.gmail.com with ESMTPSA id k8-20020a170902d58800b001641244d051sm13378807plh.257.2022.06.07.22.19.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:19:55 -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=q6r5wPFTvsqXnIBveexZxvp4k6gm/9xxQXvVVoMje8uveB2lxPwPsG49B9BexbOwbe 4yjy4sOopC+2wb+JYmzrXXMbYTwc1odjZWsV1McE6X0OPyg/oLOSHd/9ug3jgCS+Rkvz Srtp+XCA/QbqDRML/R+diJO242a9/eRWwTv/EshsHDM8cdCfofvLyvpTzLUPW4X04Pn+ E5rqktwNLSrAEOGdUmouiotxF5pC6BOxg5T9C20DbAkWMXeS8fIRkcM6TW9nKuTwXSBz 2XXdDvWi+9yPBt385RoXvxUX9OyQGU3N/sLX/WaWdh94Cv7pgSljWuCbNKy5EWAKHXXg gbQw== 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=xTQpgEk8Sa42TrBYYnLO0CAIzcNFT1A7tmEBqzZRekEubCYrozSQV55Fk/3yvSX2PV Bg05LOZaE4FJxXQNNcZTUDOV6WWGRKfbUFjgjk2pryvXdiPr4JTYUWg3RL/ZA2AhrPa1 EEcy4tZM/dMEEeO8QI6JH+sAYgdPgyBDns9VEpm1OL40xHWrCMJNvzBpDVa4/hRzIHlw FeE3L84gf7R0OcnhRGiVWhpxq1RUmpc5+7gPPYGFBlRkL+hrWUh4x+vQMbRxfoC2X3uV 39KbXKqpVwRFkLE3+A+822rAd7rGBPauyGZ580rXDNrGatLMvIxFpS95Ousn5X8Gf+Nl ETgg== X-Gm-Message-State: AOAM531P3dmokzNBBypVNIPGshOT61vBiO92xXV7X2bhLTP2/IkbhzYW bkIrJHywLFp5F4U/GOSq1MYauaX3DR48zQ== X-Google-Smtp-Source: ABdhPJzInboqWhAneSHUeg9CAylmFnAHeM0uqaLj35N62Y04XMwOg+0H24stJtE0fKRx25grKG0nUA== X-Received: by 2002:a63:210e:0:b0:3fd:9c07:7670 with SMTP id h14-20020a63210e000000b003fd9c077670mr14256096pgh.222.1654665595764; Tue, 07 Jun 2022 22:19:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: f4bug@amsat.org Subject: [PATCH v4 10/11] target/mips: Simplify UHI_argnlen and UHI_argn Date: Tue, 7 Jun 2022 22:19:44 -0700 Message-Id: <20220608051945.802339-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220608051945.802339-1-richard.henderson@linaro.org> References: <20220608051945.802339-1-richard.henderson@linaro.org> 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=2607:f8b0:4864:20::436; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x436.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654666373331100001 Content-Type: text/plain; charset="utf-8" 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 --- 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/mi= ps-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, i= nt err) uhi_cb(cs, ret, err); } =20 -static int copy_argn_to_target(CPUMIPSState *env, int arg_num, - target_ulong vaddr) -{ - int strsize =3D strlen(semihosting_get_arg(arg_num)) + 1; - char *dst =3D 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 =3D lock_user_string(addr); \ @@ -285,18 +270,31 @@ void mips_semihosting(CPUMIPSState *env) gpr[2] =3D semihosting_get_argc(); break; case UHI_argnlen: - if (gpr[4] >=3D semihosting_get_argc()) { - gpr[2] =3D -1; - return; + { + const char *s =3D semihosting_get_arg(gpr[4]); + gpr[2] =3D s ? strlen(s) : -1; } - gpr[2] =3D strlen(semihosting_get_arg(gpr[4])); break; case UHI_argn: - if (gpr[4] >=3D semihosting_get_argc()) { - gpr[2] =3D -1; - return; + { + const char *s =3D semihosting_get_arg(gpr[4]); + target_ulong addr; + size_t len; + + if (!s) { + gpr[2] =3D -1; + break; + } + len =3D strlen(s) + 1; + addr =3D gpr[5]; + p =3D lock_user(VERIFY_WRITE, addr, len, 0); + if (!p) { + report_fault(env); + } + memcpy(p, s, len); + unlock_user(p, addr, len); + gpr[2] =3D 0; } - gpr[2] =3D copy_argn_to_target(env, gpr[4], gpr[5]); break; =20 case UHI_plog: --=20 2.34.1 From nobody Mon Feb 9 15:55:32 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1654666678; cv=none; d=zohomail.com; s=zohoarc; b=lawgKbybEQsMh/Bh68cfN9dNKRXNZSwEQBYzhty701HregDnKuP1m6D4iITa4Sw/0tbZjT5lQicEPFv86xXxn6sVd9HW4p/upnfp//nk/lCl+8ekS77cYaDKIpZZx9CqPBXPSu+o33VqVhQ0CfwFSzKKG15zwMx5qbghnusKDv8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654666678; 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:References:Sender:Subject:To; bh=Lf36jiR6VUIV3UBN1JaIb1RW/v6kW3v6qxzzklReehI=; b=DG7VZ/27UBeT5Hw7xWIq0Z0hDuc77syRDg4qik8NpxhNix5kMEPc6chrJLBd35r3UuMhsp+RVJbSNY244Eq76lQS/GYbzowKlWO6HPE+7lR8dc6F6bH1NeaeDp0aQv2wPOzKjfy19e0fG4eumekOyA2MTDa8TMkRihH2mwhP/O8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 165466667808514.241965999476747; Tue, 7 Jun 2022 22:37:58 -0700 (PDT) Received: from localhost ([::1]:60214 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nyoOC-0000iv-TA for importer@patchew.org; Wed, 08 Jun 2022 01:37:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33864) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nyo6q-000725-Oy for qemu-devel@nongnu.org; Wed, 08 Jun 2022 01:20:00 -0400 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]:55988) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nyo6p-00024B-3U for qemu-devel@nongnu.org; Wed, 08 Jun 2022 01:20:00 -0400 Received: by mail-pj1-x1034.google.com with SMTP id e9so7052436pju.5 for ; Tue, 07 Jun 2022 22:19:57 -0700 (PDT) Received: from stoup.. ([2602:ae:1547:e101:c626:2f70:ac99:7c97]) by smtp.gmail.com with ESMTPSA id k8-20020a170902d58800b001641244d051sm13378807plh.257.2022.06.07.22.19.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:19:56 -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=Lf36jiR6VUIV3UBN1JaIb1RW/v6kW3v6qxzzklReehI=; b=fow0+1f9ayyYKmSkThePoL8Y3P73mC7rcuJXJkWsf7KoealjAQcaoBnEsTfq3PSJ55 3QJQ4boEC2CS346e0vbpTbQx+gJmKGsmASXWMEQW887/AtShwPXIF6EBSjk75NUUC3cz VZJLslrIgX+Fkqh9/77EFB29E8RXLrrLQZSH772463hfLxhRduXKhyvDtrIPCal1cbtl 9QJU7BgZgYxL4RLOPmLq5YtnMnlu5vDMKuZn6BqT+nkkeAfLi2uFumMM4bceH7o97QqL Q5Xd8RM8Um8Z9+3UEVjMtj84wYKEo9WjuKWl+Ijxu4+43zUwowOkfOCH+bSevGxCHD+N VgZA== 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=Lf36jiR6VUIV3UBN1JaIb1RW/v6kW3v6qxzzklReehI=; b=qUvo5T0BS6gsBxF1sah5BHQPznkFq/UKSfhOn12oQvM34c/iqZ8i9KW7qnYw0/bgrp FwdAv6wrCdV5Wx/7SIvekiGrdjrW9r8euhWRv6/Wzf+NEn/jsQ4uO8uCVoBQ9sRTO3QK ohFW94utZKzED4FO5ru4to7EjHXsjQwn/6d8f1I/IMzi8+/IMLl8lvY8W/z1VtzCu2sO MX1J+jItjcv22rzfU0LK/jA5PmOU1PodNi49BszacsR/hEYXl7aByOl/9m2caXp+Uqeu C2q+/OV3N+7CiE7uMRmlumz4/ccG2v0JnYJ9O7qjcxLv+L78gGaIDUuBLYPkDQa0iaNI 48Hw== X-Gm-Message-State: AOAM533n32+r8keN9Mdw2rzSFpCwA8o0sIZw7u/Kr6H9txmDsdQDoc1C Y9eGwR/DXNvcX7nybrygx0sHpCVOuHwAoQ== X-Google-Smtp-Source: ABdhPJxrme25t6It1RukM4lJiiAR1rGBOtvAOmzPYgP0rJ3btIuqPFEQAGrLAYs6XtOKA5q0QKRGIw== X-Received: by 2002:a17:902:d4cf:b0:167:735a:e7a1 with SMTP id o15-20020a170902d4cf00b00167735ae7a1mr16233082plg.161.1654665596774; Tue, 07 Jun 2022 22:19:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: f4bug@amsat.org Subject: [PATCH v4 11/11] target/mips: Remove GET_TARGET_STRING and FREE_TARGET_STRING Date: Tue, 7 Jun 2022 22:19:45 -0700 Message-Id: <20220608051945.802339-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220608051945.802339-1-richard.henderson@linaro.org> References: <20220608051945.802339-1-richard.henderson@linaro.org> 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=2607:f8b0:4864:20::1034; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1034.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654666679534100001 Content-Type: text/plain; charset="utf-8" Inline these macros into the only two callers. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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/mi= ps-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, i= nt err) uhi_cb(cs, ret, err); } =20 -#define GET_TARGET_STRING(p, addr) \ - do { \ - p =3D 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 =3D env_cpu(env); @@ -225,9 +212,13 @@ void mips_semihosting(CPUMIPSState *env) =20 case UHI_open: { + target_ulong fname =3D gpr[4]; int ret =3D -1; =20 - GET_TARGET_STRING(p, gpr[4]); + p =3D lock_user_string(fname); + if (!p) { + report_fault(env); + } if (!strcmp("/dev/stdin", p)) { ret =3D 0; } else if (!strcmp("/dev/stdout", p)) { @@ -235,7 +226,7 @@ void mips_semihosting(CPUMIPSState *env) } else if (!strcmp("/dev/stderr", p)) { ret =3D 2; } - FREE_TARGET_STRING(p, gpr[4]); + unlock_user(p, fname, 0); =20 /* FIXME: reusing a guest fd doesn't seem correct. */ if (ret >=3D 0) { @@ -243,7 +234,7 @@ void mips_semihosting(CPUMIPSState *env) break; } =20 - 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; =20 @@ -314,14 +305,14 @@ void mips_semihosting(CPUMIPSState *env) =20 pct_d =3D 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; } =20 str =3D 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); =20 /* * When we're using gdb, we need a guest address, so --=20 2.34.1