From patchwork Wed Jun 8 05:19:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 579807 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5806:0:0:0:0 with SMTP id j6csp5794453max; Tue, 7 Jun 2022 22:21:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYIqIRL/s7+uht9hC6iIJBxYZYjW7ym974wgUgh9HH6VN131YTZ80sy3Tz+/EwuoE9UH8x X-Received: by 2002:ac8:5d49:0:b0:304:eb9d:4c49 with SMTP id g9-20020ac85d49000000b00304eb9d4c49mr12004884qtx.153.1654665679752; Tue, 07 Jun 2022 22:21:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654665679; cv=none; d=google.com; s=arc-20160816; b=xrTBYkP7ciFh/0N7ehL2m7VFhDlat5+rwyL0bDNpV3u06rrPlQz6lyI61J5P8RbBbI ClkOU31uQN7T09q6mZwYi7p4yy3q8Xc79jOSNNqI6fvWtxZDfou/JpIhBv3CwS21yyDe Zf0WIf8FJXxlt7icHTxBRoW87OmbVqQ3ghFxSb3W3AFQkwk8oFtpM0eEKOHFy8DBEdGt pTKH40qT+17oG1g1HM2v5Z6TeCpisa52xmHwhA8pRj/0fYkn+i+Q+WfGQU1TlWhdcUqz t4S/H9DoP9FPbY3ruplATN+lhcIdV3o2FRwtE4/lE7gsmp5lImfDXzcy7muNwXAarhVp rAPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=w4FYTiyxhI0mE5fcTHb/1MDqV87uaAoIyMIlxrvf02Y=; b=gHNgF4nQT1Fn8sbK9rKaD9tgoO6jP0CN79xr6B1LG86n61Y+DHtvJqGzYj4+ZT9r5A SQMpeNWh8SIGDubTtwFWRE/sIBwtCDhjoh4pqcAw5n3uibLQ1XPlXcqMWpkDGZDvemeF Bb3C1qtO1VTOiR0XAx5vlen/jjxnLDd13yE1C3LdBz3F6clp5Ha0dBA8FkfyXvrInglU feBTHiQ3qBB6htM88cwAgcQc2iJiOngmO+XebJwsbQLQuPFZrFZIn7iWGtfC3K0ZcnAp oYHPmx0fGhtBT3Hnj3hy+oBshD7amPV2zvsY8u39PTppZDEItGBsj6btG2hk391yUaIk 6q6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uSPQluXp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id gf1-20020a056214250100b00461f3e2dbb5si12864183qvb.198.2022.06.07.22.21.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 22:21:19 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uSPQluXp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:60766 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nyo87-0006rb-25 for patch@linaro.org; Wed, 08 Jun 2022 01:21:19 -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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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é --- 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, - EXCP_LAST = EXCP_TLBRI, + EXCP_LAST = EXCP_SEMIHOST, }; /* 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 size, MMUAccessType access_type, int mmu_idx, bool probe, uintptr_t retaddr); +void mips_semihosting(CPUMIPSState *env); + #endif /* !CONFIG_USER_ONLY */ #endif diff --git a/target/mips/tcg/sysemu_helper.h.inc b/target/mips/tcg/sysemu_helper.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 */ -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] = { [EXCP_TLBRI] = "TLB read-inhibit", [EXCP_MSADIS] = "MSA disabled", [EXCP_MSAFPE] = "MSA floating point", + [EXCP_SEMIHOST] = "Semihosting", }; const char *mips_exception_name(int32_t exception) diff --git a/target/mips/tcg/sysemu/mips-semi.c b/target/mips/tcg/sysemu/mips-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" typedef enum UHIOp { UHI_exit = 1, @@ -238,7 +238,7 @@ static int copy_argn_to_target(CPUMIPSState *env, int arg_num, unlock_user(p, gpr, 0); \ } while (0) -void helper_do_semihosting(CPUMIPSState *env) +void mips_semihosting(CPUMIPSState *env) { target_ulong *gpr = env->active_tc.gpr; const UHIOp op = gpr[25]; diff --git a/target/mips/tcg/sysemu/tlb_helper.c b/target/mips/tcg/sysemu/tlb_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 = 0x180; switch (cs->exception_index) { + case EXCP_SEMIHOST: + cs->exception_index = EXCP_NONE; + mips_semihosting(env); + return; case EXCP_DSS: env->CP0_Debug |= 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 } -#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 = 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/micromips_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, DisasContext *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/mips16e_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, DisasContext *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/nanomips_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 *env, 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, DisasContext *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); From patchwork Wed Jun 8 05:19:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 579809 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5806:0:0:0:0 with SMTP id j6csp5796022max; Tue, 7 Jun 2022 22:24:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypG1Ayx0KNsrnN7Zs/ZyXXZDHAA9S7z7EM6Tb4shR4dzfd05qPSMM2zt48bBhTvQxJSEOv X-Received: by 2002:a05:622a:11ca:b0:304:c340:c37f with SMTP id n10-20020a05622a11ca00b00304c340c37fmr25778963qtk.336.1654665894914; Tue, 07 Jun 2022 22:24:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654665894; cv=none; d=google.com; s=arc-20160816; b=OCsmzCTHzgQA7Bpl088RCNoGmdBD2aOnvoDJ3kLu0cP4pqHMPfbzYuK8BD9tt6Xhms r/weyE7hlQgkY1/NUigvkSp5+SiRkFcrPGckEjNNvgQI5cmvBXYdn6gR3z9KZjv+Vxbp n5tZPXBZ9IkyiemNHt5lMo/0KtIIi2a34FvEsGyiYf1Z6DJN9hNRr4mo7PgUgOVqyNW5 5ztdr3LkQZNXzIdLHXLEfb6czSKNcY3D292C3J31TW6ZZsSog49gi3V6I++nrwAQcMiF vtD+mP6wtjV/+DIFTD38TT7uCbsz2XUVlb/4LQPGDauYpW1rVbmhe/pGvYDWAIz1M9QE k9aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=oYsK2DCkJDRZ/LkA4A11UkQEUx69l+6MA6r9SJofgvk=; b=LiUDSAPnwTKyBLOGIszVyWhlvCGKR0XnM13HIwq8aQmVlm7ImVWesxl9FRnBaR7bio TtjvlYxbIJzYYM1sTAyX4VG/ieYJG9g7b4dwdPASY1dGPS0AUL0diS3jf3b81/7jYfOd izWxlD+QRIbcECWCOzZCA832d1SC+bnj9yCd9O/E4FIFuVjLSdGhFHzVz9nFTG5onv0N zJ/ffxYqHe/DiPJKWx0ZQMCFVRZZW3joV9Y6QeDFmbflqywVf6tAYPti9f7nNka3R5jt gzc5WDTLDAfhhlPli1cWOP5PyKhvnO+fKazB24hbe3YHe8DwYeV5JpytQCnIwUnUY9cv 28cQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WlAIQPL8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v6-20020a379306000000b006a59f8a799bsi10057315qkd.748.2022.06.07.22.24.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 22:24:54 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WlAIQPL8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:38706 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nyoBa-0002fm-Fw for patch@linaro.org; Wed, 08 Jun 2022 01:24:54 -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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" >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é --- 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/mips-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 = 0x800 }; +enum UHIErrno { + UHI_EACCESS = 13, + UHI_EAGAIN = 11, + UHI_EBADF = 9, + UHI_EBADMSG = 77, + UHI_EBUSY = 16, + UHI_ECONNRESET = 104, + UHI_EEXIST = 17, + UHI_EFBIG = 27, + UHI_EINTR = 4, + UHI_EINVAL = 22, + UHI_EIO = 5, + UHI_EISDIR = 21, + UHI_ELOOP = 92, + UHI_EMFILE = 24, + UHI_EMLINK = 31, + UHI_ENAMETOOLONG = 91, + UHI_ENETDOWN = 115, + UHI_ENETUNREACH = 114, + UHI_ENFILE = 23, + UHI_ENOBUFS = 105, + UHI_ENOENT = 2, + UHI_ENOMEM = 12, + UHI_ENOSPC = 28, + UHI_ENOSR = 63, + UHI_ENOTCONN = 128, + UHI_ENOTDIR = 20, + UHI_ENXIO = 6, + UHI_EOVERFLOW = 139, + UHI_EPERM = 1, + UHI_EPIPE = 32, + UHI_ERANGE = 34, + UHI_EROFS = 30, + UHI_ESPIPE = 29, + UHI_ETIMEDOUT = 116, + UHI_ETXTBSY = 26, + UHI_EWOULDBLOCK = 11, + UHI_EXDEV = 18, +}; + static int errno_mips(int host_errno) { /* Errno values taken from asm-mips/errno.h */ From patchwork Wed Jun 8 05:19:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 579812 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5806:0:0:0:0 with SMTP id j6csp5797588max; Tue, 7 Jun 2022 22:28:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmPpPSh6/OEvzIzJ6jSlyVAdTTtkBq1oVxPYU18g3RJd2ytI/QQnJ3i+kQbwkgORgZmQ3C X-Received: by 2002:a05:622a:1051:b0:305:457:6ca1 with SMTP id f17-20020a05622a105100b0030504576ca1mr173839qte.315.1654666117049; Tue, 07 Jun 2022 22:28:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654666117; cv=none; d=google.com; s=arc-20160816; b=i5puppgUBqnzXLd2oOiAR+dFrfgUYx8JbggqWLSPcPwGZeF/y84xx9Lbwlx9DCdlb7 cn156QmeQ9ZKBaDTIWKlnRqI8bGW4Z3iiWa/BtfTZP/aMEfusOeVXOmCNqwWToAgJJjs u5xkeioa3OAbIOG8gB6x1JqRGVNGhQzBArGLpTBEpx4zj3QgmK6XXCliLtf6vK0jiU+8 38cFIGv2LdWmgaXWvc9rAaJKfW6iJhnK3JOK2tiWHQAfXkKpEJaDq3dHc8MJ1qqhUOPI bMDWEii3Fw7nSP8DFOuVJPb3mDanD/J/PixaC0cwqk89IOXp+tBwZoCN0GjkS1nshjSt YXkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=HeLbzu4J7HUJ/gIyU/6OdVT7zEVHegu20jhi9pPruCA=; b=FYDu6WDggwVckluZqFJJLHPv4CRUGCTdUC8FGu8eZVBLXyNcLqkAWcXwZ59g32KFfy 4175+WWtfYGrlBrrZVardo3uouFuLqY436dSJH8uUh7estCKZf7z2ctj8efwCa7Ty2PJ fu6AFPhd8BJkeLdZMoGZWO4xeqy8PuItYO71138hFZKmvWc1Q/m+3qcZTcv4XM6pEsuC pA9i4QAVKbUO2JGTIfSNXiYFogDYt+OSmBseRkbrXOAtnOsk5dhCWf/5xeSlKIXW1O18 EQCFIK23wAeme93VVEw594lliswfhPRJZC47Z1nOravxueC6XbY/ZJ8QxJSDlnUQ6IiG 2JOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bSETDgHE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v2-20020a05620a0f0200b006a39d0deb7esi12398788qkl.546.2022.06.07.22.28.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 22:28:37 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bSETDgHE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:45142 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nyoFA-0006yW-JQ for patch@linaro.org; Wed, 08 Jun 2022 01:28:36 -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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The UHI specification does not have an EFAULT value, and further specifies that "undefined UHI operations should not return control to the target". So, log the error and abort. Signed-off-by: Richard Henderson --- target/mips/tcg/sysemu/mips-semi.c | 33 ++++++++++++++---------------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/target/mips/tcg/sysemu/mips-semi.c b/target/mips/tcg/sysemu/mips-semi.c index 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 = 18, }; +static void report_fault(CPUMIPSState *env) +{ + int op = env->active_tc.gpr[25]; + error_report("Fault during UHI operation %d", op); + abort(); +} + static int errno_mips(int host_errno) { /* Errno values taken from asm-mips/errno.h */ @@ -136,8 +143,7 @@ static int copy_stat_to_target(CPUMIPSState *env, const struct stat *src, hwaddr len = sizeof(struct UHIStat); UHIStat *dst = lock_user(VERIFY_WRITE, vaddr, len, 0); if (!dst) { - errno = EFAULT; - return -1; + report_fault(env); } dst->uhi_st_dev = tswap16(src->st_dev); @@ -188,8 +194,7 @@ static int write_to_file(CPUMIPSState *env, target_ulong fd, target_ulong vaddr, int num_of_bytes; void *dst = lock_user(VERIFY_READ, vaddr, len, 1); if (!dst) { - errno = EFAULT; - return -1; + report_fault(env); } if (offset) { @@ -213,8 +218,7 @@ static int read_from_file(CPUMIPSState *env, target_ulong fd, int num_of_bytes; void *dst = lock_user(VERIFY_WRITE, vaddr, len, 0); if (!dst) { - errno = EFAULT; - return -1; + report_fault(env); } if (offset) { @@ -237,7 +241,7 @@ static int copy_argn_to_target(CPUMIPSState *env, int arg_num, int strsize = strlen(semihosting_get_arg(arg_num)) + 1; char *dst = lock_user(VERIFY_WRITE, vaddr, strsize, 0); if (!dst) { - return -1; + report_fault(env); } strcpy(dst, semihosting_get_arg(arg_num)); @@ -250,9 +254,7 @@ static int copy_argn_to_target(CPUMIPSState *env, int arg_num, do { \ p = lock_user_string(addr); \ if (!p) { \ - gpr[2] = -1; \ - gpr[3] = EFAULT; \ - return; \ + report_fault(env); \ } \ } while (0) @@ -260,16 +262,11 @@ static int copy_argn_to_target(CPUMIPSState *env, int arg_num, do { \ p = lock_user_string(addr); \ if (!p) { \ - gpr[2] = -1; \ - gpr[3] = EFAULT; \ - return; \ + report_fault(env); \ } \ p2 = lock_user_string(addr2); \ if (!p2) { \ - unlock_user(p, addr, 0); \ - gpr[2] = -1; \ - gpr[3] = EFAULT; \ - return; \ + report_fault(env); \ } \ } while (0) @@ -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; From patchwork Wed Jun 8 05:19:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 579813 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5806:0:0:0:0 with SMTP id j6csp5797677max; Tue, 7 Jun 2022 22:28:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJznHdJ+NlzhK/A+Afgk1ANCDGjStitcrjxgdDqM+BJvMYGCengae7a7RR5k9tBOwK8N2f0m X-Received: by 2002:a05:622a:178c:b0:304:bd84:3a93 with SMTP id s12-20020a05622a178c00b00304bd843a93mr25675541qtk.612.1654666127493; Tue, 07 Jun 2022 22:28:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654666127; cv=none; d=google.com; s=arc-20160816; b=1B2vF2BwegVGCN0MeXes26oUJtenLIxBOkZFntOBt6HIyPV4tkkWzL6Pi2PMwYh+5g dSzEsOIGtoiajZeS9WSZobTpahHqx6GBJ0vMUpW/zOGiqtLlB95TCDtbiSYqnLUCbdzr 5pRXVpX+aA51jwuLH2VqCBQajbZziHTIZdp41IeO7+OSaGH+6mlFgX214kyA7OVZpcpX UnIt7DfkpoLoQ1tlTPSXt1tZiMBxem/c00tHIbFEupYVPLpx+mmSj8nRiTayABqi6hMe 6qTTl1rkbXxQp3lL7il1xAQDWR+jiNFdbhPcXAtUuyQOIkrxnnPn+D9WNjHMSqj/ypr7 wIxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=GB8QwFJfH3hlfZTD3yMvfbRrCq2bQTobhy4HeZnGERI=; b=bRyTm09hmqo9MSx48wn0jv4ZQyvKqFf1gm9zUqbw6fUlhoedbhjeprbVBiA4ZFy7Ob R3HPclZIb2x7Ttjpwn4V6eVX8KoRujfqRJmOwCQXskRa+UL3hRY4CQSsZcWjzKDX5QV3 iox6w6YbvA9XHw/w3XySWUOa1IUOlgv0HUisxwmqB1VQmz79rjtG081S7umpBzyLErmE GkUmNgl+lQu4Z7JvaDhQdsYbfQhi9lTovMmQRVgmsH7XgDMIaX16FAuNubrRcXdn7dEP 04QjnGz4xy+VwLsny2uzOrhm+Rcs0mcijbERNybinlcXpukad2q4EdFWz5UZZ406qu6i 7ulA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=E2+lQZu4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id y22-20020a05622a005600b00304e67e8191si6746176qtw.354.2022.06.07.22.28.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 22:28:47 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=E2+lQZu4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:45634 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nyoFL-0007N4-3S for patch@linaro.org; Wed, 08 Jun 2022 01:28:47 -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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We don't implement it with _WIN32 hosts, and the syscall is missing from the gdb remote file i/o interface. Since we can't implement it universally, drop it. Signed-off-by: Richard Henderson --- target/mips/tcg/sysemu/mips-semi.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/target/mips/tcg/sysemu/mips-semi.c b/target/mips/tcg/sysemu/mips-semi.c index 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] = write_to_file(env, gpr[4], gpr[5], gpr[6], gpr[7]); gpr[3] = errno_mips(errno); break; -#ifndef _WIN32 - case UHI_link: - GET_TARGET_STRINGS_2(p, gpr[4], p2, gpr[5]); - gpr[2] = link(p, p2); - gpr[3] = errno_mips(errno); - FREE_TARGET_STRING(p2, gpr[5]); - FREE_TARGET_STRING(p, gpr[4]); - break; -#endif default: error_report("Unknown UHI operation %d", op); abort(); From patchwork Wed Jun 8 05:19:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 579816 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5806:0:0:0:0 with SMTP id j6csp5800431max; Tue, 7 Jun 2022 22:33:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJq4Ts2CmuMkA4JQHS2JdZgkDyZnnY6L+9fXkmJSNqlzqTERaU8JxREyJsbuZRjtA1GR21 X-Received: by 2002:a05:622a:2c3:b0:304:f1ac:cffe with SMTP id a3-20020a05622a02c300b00304f1accffemr9109543qtx.163.1654666435348; Tue, 07 Jun 2022 22:33:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654666435; cv=none; d=google.com; s=arc-20160816; b=rMiS3UdwSelT9AMVy8y3VgHmE+cGZVtP2cZaJxiNWtOZfvlK5hcbQoIagvxyusjNVb t8abDiZChU74qAEuJJpS4oVSGeUCWD0ld7c4F49oIX6ldqZEtg0+VCahApQdtYGHB9TE l/4itJM1M6mB8QWZOARCUxY4rhTFwxoSmhw+n4gYmb9tGHCi9pu8n+TOGAvLsgunQWPN j6QY33dIDsGpl72Sd6AI4SvOgq63asPfhAWJAkGYn9AgOJjYRnf4+SiBsX4VHd7gh88G CPmRLPOlRqwT0ftf/Lj2tivaBWFOMSCc8p9mG3IOsyu1c/peWiKIyQ+bVWASEbSOkbdR l8Rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vchvWnQo4YVofH3IH1WWni/usGrLZ5KUM5YMsZGZNkI=; b=gAbvOCwRB8hrD47BKrew/OEr8M/twTkzP9pFWuf9CuHycazc/E2dujlM+ZEo0jQhJs XzpN7luekg7iPkwTwturK0UDtZpGZaMYGJEijjp7t4AVGLTg4TFZ2nAZngEjlaaaFhMX 04bDvwjXOQwIvL/z9iTL8Up7pB/yHqdmT36ZcSensFJgy4/2PrIzBZxwwBxE6XoAWSRy jsbwkLBEZyXW1SMOjEGAPaSfwSmfX1R5piVTQPK1JCMs6y/K52MD10nMmCogK4GCmV+u 33cyDhaJ5I9h1rZkbTeJUzGoezPT7JrYPKfN7OoIDCQJfkNGlvTSbahHtWZijXCMzdVT dUXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HO93Od8V; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h15-20020ac8584f000000b00304e38edda4si7870226qth.631.2022.06.07.22.33.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 22:33:55 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HO93Od8V; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:55822 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nyoKI-00061D-VH for patch@linaro.org; Wed, 08 Jun 2022 01:33:54 -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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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é --- 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/mips-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; } -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 = lock_user(VERIFY_READ, vaddr, len, 1); @@ -197,23 +197,14 @@ static int write_to_file(CPUMIPSState *env, target_ulong fd, target_ulong vaddr, report_fault(env); } - if (offset) { -#ifdef _WIN32 - num_of_bytes = 0; -#else - num_of_bytes = pwrite(fd, dst, len, offset); -#endif - } else { - num_of_bytes = write(fd, dst, len); - } + num_of_bytes = write(fd, dst, len); unlock_user(dst, vaddr, 0); return num_of_bytes; } static int read_from_file(CPUMIPSState *env, target_ulong fd, - target_ulong vaddr, target_ulong len, - target_ulong offset) + target_ulong vaddr, target_ulong len) { int num_of_bytes; void *dst = lock_user(VERIFY_WRITE, vaddr, len, 0); @@ -221,15 +212,7 @@ static int read_from_file(CPUMIPSState *env, target_ulong fd, report_fault(env); } - if (offset) { -#ifdef _WIN32 - num_of_bytes = 0; -#else - num_of_bytes = pread(fd, dst, len, offset); -#endif - } else { - num_of_bytes = read(fd, dst, len); - } + num_of_bytes = read(fd, dst, len); unlock_user(dst, vaddr, len); return num_of_bytes; @@ -309,11 +292,11 @@ void mips_semihosting(CPUMIPSState *env) gpr[3] = errno_mips(errno); break; case UHI_read: - gpr[2] = read_from_file(env, gpr[4], gpr[5], gpr[6], 0); + gpr[2] = read_from_file(env, gpr[4], gpr[5], gpr[6]); gpr[3] = errno_mips(errno); break; case UHI_write: - gpr[2] = write_to_file(env, gpr[4], gpr[5], gpr[6], 0); + gpr[2] = write_to_file(env, gpr[4], gpr[5], gpr[6]); gpr[3] = 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] = read_from_file(env, gpr[4], gpr[5], gpr[6], gpr[7]); - gpr[3] = errno_mips(errno); - break; - case UHI_pwrite: - gpr[2] = write_to_file(env, gpr[4], gpr[5], gpr[6], gpr[7]); - gpr[3] = errno_mips(errno); - break; default: error_report("Unknown UHI operation %d", op); abort(); From patchwork Wed Jun 8 05:19:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 579810 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5806:0:0:0:0 with SMTP id j6csp5796050max; Tue, 7 Jun 2022 22:24:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyL6P4pwUl0BKsMmIllBEUkODJE8KkffcwM/ht1tX1N/9mNNZ6E4WkNaCS1FugMoRO0Nvsx X-Received: by 2002:ac8:5755:0:b0:304:edc9:c430 with SMTP id 21-20020ac85755000000b00304edc9c430mr10834927qtx.451.1654665899105; Tue, 07 Jun 2022 22:24:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654665899; cv=none; d=google.com; s=arc-20160816; b=CQ337BwkqkWkbPbRyvDSsElT1FIBxUkLBt2vnLy+RnzUIca+Ez/2pq77Nx6EDiW67b zRI9Be8XZWzYYiELjkEuf/0BYWK5BfXBdvDTLQCGRWSMblmeuNjpMqWP8oijJZ5Q7DVW +b2qKnnaaEORBfWyeZZ3F2d57E6Agonvhrs0P51OyNIo1Dzr+1UNlBKJXIO+FnwhZyGb nAHwqM4a5LjnD4ZVBrhPWkLhe2/ttR9PIgZ5lbo7OSUYOZ72DCZLnaNuyzqQgnPFKNPc /Im/GnE7rbNtmuzuqb8azyFXZ+6PK+Ivmkyb9GHE9FeU1EK0suJgFjxjKxtl7BHjC/wv mRyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=w6sA15MForuaAbeYWpiX93UQp8+cxumrK25JuRIu/m4=; b=aaDmbcvDr/yGmf98fRpuQVdWWmpBKB58GHyWW3Y78jRPTd2tE+9sPDKcXS+/x6hfwA Sm99orcbgyH9V3tKtxeAlqukG04CJxfbH//f47a7Y7zkrWwiyzy1D9DHcBGie5w6IVuU b5C3XFYnrYKIX7rlAXwKeKNtiqGw0QfjIVXatOSCr+BXXAZD/6+sAoG9F0xRNyiEXQJW ANC6xfC2GzEURejBSTehfv6XFsXqPZWDzMQo8f7PgkR0kkSj1Bu99TOmYnnTdPZ8te6A yfsO5iWDaVWFgmsYAXK1Qq1YR9+gIN4LZM8pv4fFyNsg5UOeXn64HJFS2zWOKNmJFwpI P60Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wMp7LNDS; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id r72-20020a37444b000000b006a3367f7e61si9411746qka.446.2022.06.07.22.24.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 22:24:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wMp7LNDS; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39028 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nyoBe-0002sz-N6 for patch@linaro.org; Wed, 08 Jun 2022 01:24:58 -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) 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-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) 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) 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 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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/mips-semi.c index 93c9d3d0b3..5b78cf21a7 100644 --- a/target/mips/tcg/sysemu/mips-semi.c +++ b/target/mips/tcg/sysemu/mips-semi.c @@ -20,9 +20,11 @@ #include "qemu/osdep.h" #include "cpu.h" #include "qemu/log.h" +#include "exec/gdbstub.h" #include "semihosting/softmmu-uaccess.h" #include "semihosting/semihost.h" #include "semihosting/console.h" +#include "semihosting/syscalls.h" #include "internal.h" typedef enum UHIOp { @@ -121,101 +123,79 @@ static void report_fault(CPUMIPSState *env) abort(); } -static int errno_mips(int host_errno) +static void uhi_cb(CPUState *cs, uint64_t ret, int err) { - /* Errno values taken from asm-mips/errno.h */ - switch (host_errno) { - case 0: return 0; - case ENAMETOOLONG: return 78; -#ifdef EOVERFLOW - case EOVERFLOW: return 79; -#endif -#ifdef ELOOP - case ELOOP: return 90; -#endif - default: return EINVAL; - } -} + CPUMIPSState *env = cs->env_ptr; -static int copy_stat_to_target(CPUMIPSState *env, const struct stat *src, - target_ulong vaddr) -{ - hwaddr len = sizeof(struct UHIStat); - UHIStat *dst = lock_user(VERIFY_WRITE, vaddr, len, 0); - if (!dst) { +#define E(N) case E##N: err = UHI_E##N; break + + switch (err) { + case 0: + break; + E(PERM); + E(NOENT); + E(INTR); + E(BADF); + E(BUSY); + E(EXIST); + E(NOTDIR); + E(ISDIR); + E(INVAL); + E(NFILE); + E(MFILE); + E(FBIG); + E(NOSPC); + E(SPIPE); + E(ROFS); + E(NAMETOOLONG); + default: + err = UHI_EINVAL; + break; + case EFAULT: report_fault(env); } - dst->uhi_st_dev = tswap16(src->st_dev); - dst->uhi_st_ino = tswap16(src->st_ino); - dst->uhi_st_mode = tswap32(src->st_mode); - dst->uhi_st_nlink = tswap16(src->st_nlink); - dst->uhi_st_uid = tswap16(src->st_uid); - dst->uhi_st_gid = tswap16(src->st_gid); - dst->uhi_st_rdev = tswap16(src->st_rdev); - dst->uhi_st_size = tswap64(src->st_size); - dst->uhi_st_atime = tswap64(src->st_atime); - dst->uhi_st_mtime = tswap64(src->st_mtime); - dst->uhi_st_ctime = tswap64(src->st_ctime); -#ifdef _WIN32 - dst->uhi_st_blksize = 0; - dst->uhi_st_blocks = 0; -#else - dst->uhi_st_blksize = tswap64(src->st_blksize); - dst->uhi_st_blocks = tswap64(src->st_blocks); -#endif - unlock_user(dst, vaddr, len); - return 0; +#undef E + + env->active_tc.gpr[2] = ret; + env->active_tc.gpr[3] = err; } -static int get_open_flags(target_ulong target_flags) +static void uhi_fstat_cb(CPUState *cs, uint64_t ret, int err) { - int open_flags = 0; + QEMU_BUILD_BUG_ON(sizeof(UHIStat) < sizeof(struct gdb_stat)); - if (target_flags & UHIOpen_RDWR) { - open_flags |= O_RDWR; - } else if (target_flags & UHIOpen_WRONLY) { - open_flags |= O_WRONLY; - } else { - open_flags |= O_RDONLY; + if (!err) { + CPUMIPSState *env = cs->env_ptr; + target_ulong addr = env->active_tc.gpr[5]; + UHIStat *dst = lock_user(VERIFY_WRITE, addr, sizeof(UHIStat), 1); + struct gdb_stat s; + + if (!dst) { + report_fault(env); + } + + memcpy(&s, dst, sizeof(struct gdb_stat)); + memset(dst, 0, sizeof(UHIStat)); + + dst->uhi_st_dev = tswap16(be32_to_cpu(s.gdb_st_dev)); + dst->uhi_st_ino = tswap16(be32_to_cpu(s.gdb_st_ino)); + dst->uhi_st_mode = tswap32(be32_to_cpu(s.gdb_st_mode)); + dst->uhi_st_nlink = tswap16(be32_to_cpu(s.gdb_st_nlink)); + dst->uhi_st_uid = tswap16(be32_to_cpu(s.gdb_st_uid)); + dst->uhi_st_gid = tswap16(be32_to_cpu(s.gdb_st_gid)); + dst->uhi_st_rdev = tswap16(be32_to_cpu(s.gdb_st_rdev)); + dst->uhi_st_size = tswap64(be64_to_cpu(s.gdb_st_size)); + dst->uhi_st_atime = tswap64(be32_to_cpu(s.gdb_st_atime)); + dst->uhi_st_mtime = tswap64(be32_to_cpu(s.gdb_st_mtime)); + dst->uhi_st_ctime = tswap64(be32_to_cpu(s.gdb_st_ctime)); + dst->uhi_st_blksize = tswap64(be64_to_cpu(s.gdb_st_blksize)); + dst->uhi_st_blocks = tswap64(be64_to_cpu(s.gdb_st_blocks)); + + unlock_user(dst, addr, sizeof(UHIStat)); } - open_flags |= (target_flags & UHIOpen_APPEND) ? O_APPEND : 0; - open_flags |= (target_flags & UHIOpen_CREAT) ? O_CREAT : 0; - open_flags |= (target_flags & UHIOpen_TRUNC) ? O_TRUNC : 0; - open_flags |= (target_flags & UHIOpen_EXCL) ? O_EXCL : 0; - - return open_flags; -} - -static int write_to_file(CPUMIPSState *env, target_ulong fd, - target_ulong vaddr, target_ulong len) -{ - int num_of_bytes; - void *dst = lock_user(VERIFY_READ, vaddr, len, 1); - if (!dst) { - report_fault(env); - } - - num_of_bytes = write(fd, dst, len); - - unlock_user(dst, vaddr, 0); - return num_of_bytes; -} - -static int read_from_file(CPUMIPSState *env, target_ulong fd, - target_ulong vaddr, target_ulong len) -{ - int num_of_bytes; - void *dst = lock_user(VERIFY_WRITE, vaddr, len, 0); - if (!dst) { - report_fault(env); - } - - num_of_bytes = read(fd, dst, len); - - unlock_user(dst, vaddr, len); - return num_of_bytes; + uhi_cb(cs, ret, err); } static int copy_argn_to_target(CPUMIPSState *env, int arg_num, @@ -260,68 +240,59 @@ static int copy_argn_to_target(CPUMIPSState *env, int arg_num, void mips_semihosting(CPUMIPSState *env) { + CPUState *cs = env_cpu(env); target_ulong *gpr = env->active_tc.gpr; const UHIOp op = gpr[25]; char *p, *p2; switch (op) { case UHI_exit: - qemu_log("UHI(%d): exit(%d)\n", op, (int)gpr[4]); + gdb_exit(gpr[4]); exit(gpr[4]); + case UHI_open: - GET_TARGET_STRING(p, gpr[4]); - if (!strcmp("/dev/stdin", p)) { - gpr[2] = 0; - } else if (!strcmp("/dev/stdout", p)) { - gpr[2] = 1; - } else if (!strcmp("/dev/stderr", p)) { - gpr[2] = 2; - } else { - gpr[2] = open(p, get_open_flags(gpr[5]), gpr[6]); - gpr[3] = errno_mips(errno); + { + int ret = -1; + + GET_TARGET_STRING(p, gpr[4]); + if (!strcmp("/dev/stdin", p)) { + ret = 0; + } else if (!strcmp("/dev/stdout", p)) { + ret = 1; + } else if (!strcmp("/dev/stderr", p)) { + ret = 2; + } + FREE_TARGET_STRING(p, gpr[4]); + + /* FIXME: reusing a guest fd doesn't seem correct. */ + if (ret >= 0) { + gpr[2] = ret; + break; + } + + semihost_sys_open(cs, uhi_cb, gpr[4], 0, gpr[5], gpr[6]); } - FREE_TARGET_STRING(p, gpr[4]); break; + case UHI_close: - if (gpr[4] < 3) { - /* ignore closing stdin/stdout/stderr */ - gpr[2] = 0; - return; - } - gpr[2] = close(gpr[4]); - gpr[3] = errno_mips(errno); + semihost_sys_close(cs, uhi_cb, gpr[4]); break; case UHI_read: - gpr[2] = read_from_file(env, gpr[4], gpr[5], gpr[6]); - gpr[3] = errno_mips(errno); + semihost_sys_read(cs, uhi_cb, gpr[4], gpr[5], gpr[6]); break; case UHI_write: - gpr[2] = write_to_file(env, gpr[4], gpr[5], gpr[6]); - gpr[3] = errno_mips(errno); + semihost_sys_write(cs, uhi_cb, gpr[4], gpr[5], gpr[6]); break; case UHI_lseek: - gpr[2] = lseek(gpr[4], gpr[5], gpr[6]); - gpr[3] = errno_mips(errno); + semihost_sys_lseek(cs, uhi_cb, gpr[4], gpr[5], gpr[6]); break; case UHI_unlink: - GET_TARGET_STRING(p, gpr[4]); - gpr[2] = remove(p); - gpr[3] = errno_mips(errno); - FREE_TARGET_STRING(p, gpr[4]); + semihost_sys_remove(cs, uhi_cb, gpr[4], 0); break; case UHI_fstat: - { - struct stat sbuf; - memset(&sbuf, 0, sizeof(sbuf)); - gpr[2] = fstat(gpr[4], &sbuf); - gpr[3] = errno_mips(errno); - if (gpr[2]) { - return; - } - gpr[2] = copy_stat_to_target(env, &sbuf, gpr[5]); - gpr[3] = errno_mips(errno); - } + semihost_sys_fstat(cs, uhi_fstat_cb, gpr[4], gpr[5]); break; + case UHI_argc: gpr[2] = semihosting_get_argc(); break; From patchwork Wed Jun 8 05:19:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 579814 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5806:0:0:0:0 with SMTP id j6csp5799413max; Tue, 7 Jun 2022 22:32:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLHUgb4i9oYIe+GE6aVZ5Z1s+hn0+u2h0+MjXnAfNg11toDKAJXQNWHeieRs/aKUPENjGF X-Received: by 2002:a05:6214:508a:b0:46b:97e7:e62c with SMTP id kk10-20020a056214508a00b0046b97e7e62cmr11221040qvb.26.1654666328095; Tue, 07 Jun 2022 22:32:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654666328; cv=none; d=google.com; s=arc-20160816; b=S2yGZwBzsFgBKIBAAxIXfWGeW0wkT73dcZ7pYtg7vjbm/J284INA6S/Q8RN3szXdEG 2czJUZIq0ff3cQDFDlRsZuIi+t9O2EEK2mIyvJ9/ae2fpSPYL2i0r/AEtpW1KjTbZfGn 5rB1iy/9uot2JV2d221ucTiQU5U9JS0WulwRzdKrj4s7q5ICBV5V+A31PtH0gsHNAmJx XoJOqWOdorQyV3Hw/tlopvLU/0iVxwwOWxOtMh21I9f6i7lVAcNrNUcqFhaGf7+xtwIP bejguL7HKt4RdgtQHJ3rQs8nmugeTtYTrHUjpo/fY9153gkc+nVKESqYNCWiUWOIC1Re QCxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=rmf1h8nOdErU6TZ6hYcqWua8rMBnQ07/JNvdx/MscPs=; b=IceZG7ncELRwT7oVtFph8yCXkX0hPiVsSL6FPr+umb8dC5MuIjvDzCJEUixVX4BB+K zKgtOB1atBeSs2wuw6IseHY+Rc+R0Zs9UPv2AhkJirBSrL3k/PZ/p0d3nnHxCvkzAVvT e1eOZ3QloKk3s8v0gI5q9y0lGJiN3TWu+0cQSe2GTnOX6mslfjVfi6kX8xuKhszPvzKK EkiBwxr3eZAVf+kx1WmcfDBnKj7pJxrbmJbkTSn2uenuth9Wl0QNBv8WzZHszx5FIvKg 8OETx5wkChxjdAcm6GmrjGCqwivpzoIh/0t6SWF06MAfEj3TlKjy44+FF4D21BUHRPA/ 8wkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YgNcAVgx; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a18-20020a05620a02f200b006a6aebdb9d2si5769589qko.44.2022.06.07.22.32.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 22:32:08 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YgNcAVgx; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:51540 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nyoIZ-00033W-NQ for patch@linaro.org; Wed, 08 Jun 2022 01:32:07 -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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Use semihost_sys_write and/or qemu_semihosting_console_write for implementing plog. When using gdbstub, copy the temp string below the stack so that gdb has a guest address from which to perform the log. Signed-off-by: Richard Henderson --- target/mips/tcg/sysemu/mips-semi.c | 52 +++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 11 deletions(-) diff --git a/target/mips/tcg/sysemu/mips-semi.c b/target/mips/tcg/sysemu/mips-semi.c index 5b78cf21a7..ad11a46820 100644 --- a/target/mips/tcg/sysemu/mips-semi.c +++ b/target/mips/tcg/sysemu/mips-semi.c @@ -310,20 +310,50 @@ void mips_semihosting(CPUMIPSState *env) } gpr[2] = copy_argn_to_target(env, gpr[4], gpr[5]); break; + case UHI_plog: - GET_TARGET_STRING(p, gpr[4]); - p2 = strstr(p, "%d"); - if (p2) { - int char_num = p2 - p; - GString *s = g_string_new_len(p, char_num); - g_string_append_printf(s, "%d%s", (int)gpr[5], p2 + 2); - gpr[2] = qemu_semihosting_log_out(s->str, s->len); - g_string_free(s, true); - } else { - gpr[2] = qemu_semihosting_log_out(p, strlen(p)); + { + target_ulong addr = gpr[4]; + ssize_t len = target_strlen(addr); + GString *str; + char *pct_d; + + if (len < 0) { + report_fault(env); + } + p = lock_user(VERIFY_READ, addr, len, 1); + if (!p) { + report_fault(env); + } + + pct_d = strstr(p, "%d"); + if (!pct_d) { + FREE_TARGET_STRING(p, addr); + semihost_sys_write(cs, uhi_cb, 2, addr, len); + break; + } + + str = g_string_new_len(p, pct_d - p); + g_string_append_printf(str, "%d%s", (int)gpr[5], pct_d + 2); + FREE_TARGET_STRING(p, addr); + + /* + * When we're using gdb, we need a guest address, so + * drop the string onto the stack below the stack pointer. + */ + if (use_gdb_syscalls()) { + addr = gpr[29] - str->len; + p = lock_user(VERIFY_WRITE, addr, str->len, 0); + memcpy(p, str->str, str->len); + unlock_user(p, addr, str->len); + semihost_sys_write(cs, uhi_cb, 2, addr, str->len); + } else { + gpr[2] = qemu_semihosting_console_write(str->str, str->len); + } + g_string_free(str, true); } - FREE_TARGET_STRING(p, gpr[4]); break; + case UHI_assert: GET_TARGET_STRINGS_2(p, gpr[4], p2, gpr[5]); printf("assertion '"); From patchwork Wed Jun 8 05:19:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 579811 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5806:0:0:0:0 with SMTP id j6csp5796061max; Tue, 7 Jun 2022 22:25:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKt24qbq5FeotfIamk+4Qnq1Fz7xx1yLMITyuXGs2/oahneevOQ8vqHDirEX8X6Kng2JdX X-Received: by 2002:ad4:5fcd:0:b0:46a:a0f8:db51 with SMTP id jq13-20020ad45fcd000000b0046aa0f8db51mr15237472qvb.11.1654665900172; Tue, 07 Jun 2022 22:25:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654665900; cv=none; d=google.com; s=arc-20160816; b=pLYg+HODn8PP9hHEF0/OhnEWhCOCfLuDfLSrKddD6suW+NifKt1M5GvZqk2WJndAuK qCYWO3DcuLuu1Ne1rX1GexzdaZXW7KANk5zZyEd0i0tfrX07u48A2LV0Osg+QJFDk8v4 DwyBDz9IFTpdHTW/SjNTPJEtZyYZmOLm5CUiFcLnhGAEo99CRzIPlBnrZyNAr/meYPJH Ls7SvLwra0Ju9DlHUYcC9lBEC53T4ES6ifxFlbEIImS2vkPzFvSpAkLwaCFChpu3gp60 I16dt2m+EPOHOfKlvPNmlgwQvM2d3pTGXVd21XZ1r3XUIgFMq5YWOgIMuBbngK4E2GP9 tdGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=RM42zMRkI421HiARyMb/O/C2Vq6+9jMrjOfzX4mv7Y0=; b=snMin+Ep7/5LPe8TvWggacov1u+bV2I7wwYniTN2Z4lKUxJi3DkxCAwYIFkWvr/KIu Hd2Ju7hdEOIF/HLFY+wxsBgOfbM/rpfVuCTW3ox3TP69509Jx2qM/ZifWavJTxripAqW 43RBAAXbzn5AgCZZ7VvkmX9c7jp3SSPN2cAJ1VJx7Pq1JF+PRY8EnveOaTcKEq3uPuuy n5EyJ6uSpA1XTN6UD7WVXxfB08Q40An701WpHl8jsLkb3u0jvqMUNecLWMHtg8Yl6pJg HQj+2DaXXsXk0mViOiwr74f0GCxtXX/AYf27oNxY5hl9sn3KQqC7W296sDsOEDWTBKsf g6QA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dRsQuzcS; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u17-20020ac858d1000000b002fc26474292si11467272qta.244.2022.06.07.22.25.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 22:25:00 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dRsQuzcS; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39186 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nyoBf-00030M-OE for patch@linaro.org; Wed, 08 Jun 2022 01:24:59 -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) 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-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) 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) 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 Received-SPF: pass client-ip=2607:f8b0:4864:20::535; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x535.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Always log the assert locally. Do not report_fault, but instead include the fact of the fault in the assertion. Don't bother freeing allocated strings before the abort(). Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/mips/tcg/sysemu/mips-semi.c | 39 ++++++++++++++---------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/target/mips/tcg/sysemu/mips-semi.c b/target/mips/tcg/sysemu/mips-semi.c index ad11a46820..ae4b8849b1 100644 --- a/target/mips/tcg/sysemu/mips-semi.c +++ b/target/mips/tcg/sysemu/mips-semi.c @@ -221,18 +221,6 @@ static int copy_argn_to_target(CPUMIPSState *env, int arg_num, } \ } while (0) -#define GET_TARGET_STRINGS_2(p, addr, p2, addr2) \ - do { \ - p = lock_user_string(addr); \ - if (!p) { \ - report_fault(env); \ - } \ - p2 = lock_user_string(addr2); \ - if (!p2) { \ - report_fault(env); \ - } \ - } while (0) - #define FREE_TARGET_STRING(p, gpr) \ do { \ unlock_user(p, gpr, 0); \ @@ -243,7 +231,7 @@ void mips_semihosting(CPUMIPSState *env) CPUState *cs = env_cpu(env); target_ulong *gpr = env->active_tc.gpr; const UHIOp op = gpr[25]; - char *p, *p2; + char *p; switch (op) { case UHI_exit: @@ -355,14 +343,23 @@ void mips_semihosting(CPUMIPSState *env) break; case UHI_assert: - GET_TARGET_STRINGS_2(p, gpr[4], p2, gpr[5]); - printf("assertion '"); - printf("\"%s\"", p); - printf("': file \"%s\", line %d\n", p2, (int)gpr[6]); - FREE_TARGET_STRING(p2, gpr[5]); - FREE_TARGET_STRING(p, gpr[4]); - abort(); - break; + { + const char *msg, *file; + + msg = lock_user_string(gpr[4]); + if (!msg) { + msg = ""; + } + file = lock_user_string(gpr[5]); + if (!file) { + file = ""; + } + + error_report("UHI assertion \"%s\": file \"%s\", line %d", + msg, file, (int)gpr[6]); + abort(); + } + default: error_report("Unknown UHI operation %d", op); abort(); From patchwork Wed Jun 8 05:19:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 579808 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5806:0:0:0:0 with SMTP id j6csp5794479max; Tue, 7 Jun 2022 22:21:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwCoPwpF99YgKI8qOqu56VPTN2sDUohY7V0G9nI9HlzExuCMRzVKDOyrzn/6JTrbmxdd+8w X-Received: by 2002:a37:9e12:0:b0:6a6:9643:4bb9 with SMTP id h18-20020a379e12000000b006a696434bb9mr17485353qke.2.1654665682982; Tue, 07 Jun 2022 22:21:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654665682; cv=none; d=google.com; s=arc-20160816; b=YXPBoRPMoPU15nu+vgajkXvw1kN15OYHucOrq/sHqDDsDDV7MRfsTTBaMIIMFDkWjy heQGnz2KuP3IPnekyrG/dcnoUPCQo8wcmDmodHXm1AfJAweZIVWCrxyoKgHDhyPJDYPq U6fiyaNUoZwe8xml21na0RambC1nl3Ztz+TBQDecObuW+Ueps1+7f+CpANxYI9ig1skw Txv6WEUP0mqZmsmT9tk1iMQv7Cpee0XcWcAWGRMvQ/NZSUgJckk4bHIwM99cCuqBtW0i yvjIbK6wSXen1YckitYHxBWldjzIVi0eC8RkPidv2zrhg8iqtKLcSXp/43yVVInIJCVN mDvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7hrYGm6CB5wl83BARKhSg3dxjfTTX0HLuXW9+o58cZc=; b=kZhl4EFGnxB/uKcoY1M8Fc+Z/sq8Ey5+MPOWvWqJFaYZOp/ZBhPnNS/gPjRZCGhCaD dgGyn4BCJRTgVuoL2blOd3wsJ6mH8UmlDNY3wBe6gLx1DDGQA/47+HdZqhvDBBVG1BLs jnsXQnZc+RGnThV2YoNLCpkvDTdWeKFVzIxxyU+qQy1pax8ZEHDbcDYrZbbWDlcDqof0 cNNmIIkEDrbp6MZm06FiHjT+YzbyXFJ/4zW3Nr1NzD5hPAjGCWkZFhsVOXfct1gcb5nX /Y32ttF54gcyZ6m7me16ASo7saPYWymrXj/VvIDlvdxtxg2FSChVEI5DiVDByYbjvl00 bKZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IuGF6ySv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id s6-20020a0562140ca600b0045d50fefe73si10395502qvs.375.2022.06.07.22.21.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 22:21:22 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IuGF6ySv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:60936 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nyo8A-0006z0-J0 for patch@linaro.org; Wed, 08 Jun 2022 01:21:22 -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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The function is no longer used. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- include/semihosting/console.h | 13 ------------- semihosting/console.c | 9 --------- 2 files changed, 22 deletions(-) diff --git a/include/semihosting/console.h b/include/semihosting/console.h index 61b0cb3a94..bd78e5f03f 100644 --- a/include/semihosting/console.h +++ b/include/semihosting/console.h @@ -40,19 +40,6 @@ int qemu_semihosting_console_read(CPUState *cs, void *buf, int len); */ int qemu_semihosting_console_write(void *buf, int len); -/** - * qemu_semihosting_log_out: - * @s: pointer to string - * @len: length of string - * - * Send a string to the debug output. Unlike console_out these strings - * can't be sent to a remote gdb instance as they don't exist in guest - * memory. - * - * Returns: number of bytes written - */ -int qemu_semihosting_log_out(const char *s, int len); - /* * qemu_semihosting_console_block_until_ready: * @cs: CPUState diff --git a/semihosting/console.c b/semihosting/console.c index cda7cf1905..5b1ec0a1c3 100644 --- a/semihosting/console.c +++ b/semihosting/console.c @@ -38,15 +38,6 @@ typedef struct SemihostingConsole { static SemihostingConsole console; -int qemu_semihosting_log_out(const char *s, int len) -{ - if (console.chr) { - return qemu_chr_write_all(console.chr, (uint8_t *) s, len); - } else { - return write(STDERR_FILENO, s, len); - } -} - #define FIFO_SIZE 1024 static int console_can_read(void *opaque) From patchwork Wed Jun 8 05:19:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 579815 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5806:0:0:0:0 with SMTP id j6csp5799592max; Tue, 7 Jun 2022 22:32:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFQSw4KdDLUv4vizIuQ5kmAQMKANsNpt847xQaX0kD1LCJ2xiZsP5QTrCY9Lqh1UOgsZQh X-Received: by 2002:a05:620a:404d:b0:6a7:d3d:df9b with SMTP id i13-20020a05620a404d00b006a70d3ddf9bmr158514qko.530.1654666350546; Tue, 07 Jun 2022 22:32:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654666350; cv=none; d=google.com; s=arc-20160816; b=JkoAHc+IYIEyKbD4r9RRoEZj0F+1pKKCeMQfKNV5UHrhDHd3rgyDRwiu/X5YhdwEPQ c1LOuEPhosqbHYC/ULwYyyUECy3deUZahckqtwfCqlz/3YWl6+1t9Nkr5t7vCGu+4F2I nWL6aeOGKGSTWo5kDLMkwyzCzIOWnxDwmM/bZFBPKRxOc8cpYcz5IkpOD0MYSTDDY9qH HV0urD1W6tMOYrCze7ozWEx9apN1Pz7mTTHe2cHVf4rtsMuee6Y08Kyuv4dWB4UA0XUk 1T4UulFBEjrYX6sJIhuT6ngc4QB1yjcRoVE/XbZ17pfwJ5ADuKfVGv4LrXI60h8rvn0i r/2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qIoo0LzyvHSUbYXwQZj3nHuBOs19Duk2E4Vx8ekmqlk=; b=lSk2AQKxIvYHWCE2nsf8deLXZr/e4L6kNDrU4JD65oSX5aAm4lOt/SgfqRtfC+6zZI UCOgjJyrd5kMJJKFX01xU4HRYmj4HHu1XA5x4GkrXwxdYieZp+9tXARRq95KA1Ba6TB+ lPD9EmqTQ4/Zs+aUMWJCVk3N3tfY6mviGG+SQkh60k+JsqbSEiFbmKjlYXzboW2bSMt0 RzNGfSBxCjAcOM7TceBXhB5qNREqwc2mJKxz4pasH8FR0VxxDfUEBrq3RyyMRbsWL8Bh dph0weV4FFh28EolLXJCEMQFjV0B8X/Oq2gd0dWv/LRh05Idkj5U04nwb1Gz5Z2mLSoW JZ+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=q6r5wPFT; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id b123-20020a379981000000b006a701dd36d9si524474qke.649.2022.06.07.22.32.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 22:32:30 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=q6r5wPFT; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:52008 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nyoIw-0003Np-5Z for patch@linaro.org; Wed, 08 Jun 2022 01:32:30 -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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" With semihosting_get_arg, we already have a check vs argc, so there's no point replicating it -- just check the result vs NULL. Merge copy_argn_to_target into its caller. Signed-off-by: Richard Henderson --- target/mips/tcg/sysemu/mips-semi.c | 44 ++++++++++++++---------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/target/mips/tcg/sysemu/mips-semi.c b/target/mips/tcg/sysemu/mips-semi.c index ae4b8849b1..b54267681e 100644 --- a/target/mips/tcg/sysemu/mips-semi.c +++ b/target/mips/tcg/sysemu/mips-semi.c @@ -198,21 +198,6 @@ static void uhi_fstat_cb(CPUState *cs, uint64_t ret, int err) uhi_cb(cs, ret, err); } -static int copy_argn_to_target(CPUMIPSState *env, int arg_num, - target_ulong vaddr) -{ - int strsize = strlen(semihosting_get_arg(arg_num)) + 1; - char *dst = lock_user(VERIFY_WRITE, vaddr, strsize, 0); - if (!dst) { - report_fault(env); - } - - strcpy(dst, semihosting_get_arg(arg_num)); - - unlock_user(dst, vaddr, strsize); - return 0; -} - #define GET_TARGET_STRING(p, addr) \ do { \ p = lock_user_string(addr); \ @@ -285,18 +270,31 @@ void mips_semihosting(CPUMIPSState *env) gpr[2] = semihosting_get_argc(); break; case UHI_argnlen: - if (gpr[4] >= semihosting_get_argc()) { - gpr[2] = -1; - return; + { + const char *s = semihosting_get_arg(gpr[4]); + gpr[2] = s ? strlen(s) : -1; } - gpr[2] = strlen(semihosting_get_arg(gpr[4])); break; case UHI_argn: - if (gpr[4] >= semihosting_get_argc()) { - gpr[2] = -1; - return; + { + const char *s = semihosting_get_arg(gpr[4]); + target_ulong addr; + size_t len; + + if (!s) { + gpr[2] = -1; + break; + } + len = strlen(s) + 1; + addr = gpr[5]; + p = lock_user(VERIFY_WRITE, addr, len, 0); + if (!p) { + report_fault(env); + } + memcpy(p, s, len); + unlock_user(p, addr, len); + gpr[2] = 0; } - gpr[2] = copy_argn_to_target(env, gpr[4], gpr[5]); break; case UHI_plog: From patchwork Wed Jun 8 05:19:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 579817 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5806:0:0:0:0 with SMTP id j6csp5801938max; Tue, 7 Jun 2022 22:37:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/zjRsXvG0z1UgG4exy7wyrE4TZlxGI19no1VJqUtjnm8GNtaDlQXncjOX6PTxWP6PQDPG X-Received: by 2002:a05:620a:c52:b0:6a6:6b8f:eac2 with SMTP id u18-20020a05620a0c5200b006a66b8feac2mr22327550qki.643.1654666625248; Tue, 07 Jun 2022 22:37:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654666625; cv=none; d=google.com; s=arc-20160816; b=JKzHi1pvaKyOavQkzCy2vMk8JH1OPQBevFp2vwQPsouxq2fnTJmNgutE+ZhH5QUxfX R6XTKiir3gBzzhuuJ/u7OxWbS6XK+vDblRMU+Xy6gA6oIM7oKSGc/HY/6xSUaSQB7aBR uRp2EKCby3wXLQfpWtXJxXl3Kkq/9Jk3LjLtnFeHfMiWtMGZnvr+jqcGHEF1hgwG1qKo 5qouYuH+r473nfRjF6ceKX3Dwtp8tB6yiJdQnL1unv0bTZNbb/72lqNIyKsn6/1d5pQr jnPCXvRcMei7Sy2X6/iUowK6TucLNSlepu7wE+ibYu+ozQu/+rQmYxLWlj1N3HFEEQTy q1AQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Lf36jiR6VUIV3UBN1JaIb1RW/v6kW3v6qxzzklReehI=; b=EilHE82RGmPtQUNYD4VzHJN2unptahhvo94qF7TWmRgO0K0mhw0dKPqg5SdA58SwvT +MknW9h6e9RRHWerhlCPCRs1n7TB1O/+3T8jPjNPj5qjnEozJc68PxwSybeZuDL81Hvn je5qZz6X72wDJf3tpVKmzoHUUrBDiTSwcOLv6tfQ7nTpwCEpZpj0be7/OR0z2GsZNreL eA+BR1kVTQP9av7Iz9ZVifMSMEf4MgnxxfTXSOJnFbpPuamhwsAqItarsIdt/Jdf8bBx nRGcmk8ukpo+7XnWNvbpgC5DoK8D4mOBVziAdqX/MVm5iehyZrP5tV3tu8sABWu+GsjU ilsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fow0+1f9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id y15-20020ac85f4f000000b002f3743e363fsi10293159qta.752.2022.06.07.22.37.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 22:37:05 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fow0+1f9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:58828 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nyoNM-00089c-RZ for patch@linaro.org; Wed, 08 Jun 2022 01:37:04 -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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Inline these macros into the only two callers. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/mips/tcg/sysemu/mips-semi.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/target/mips/tcg/sysemu/mips-semi.c b/target/mips/tcg/sysemu/mips-semi.c index b54267681e..5fb1ad9092 100644 --- a/target/mips/tcg/sysemu/mips-semi.c +++ b/target/mips/tcg/sysemu/mips-semi.c @@ -198,19 +198,6 @@ static void uhi_fstat_cb(CPUState *cs, uint64_t ret, int err) uhi_cb(cs, ret, err); } -#define GET_TARGET_STRING(p, addr) \ - do { \ - p = lock_user_string(addr); \ - if (!p) { \ - report_fault(env); \ - } \ - } while (0) - -#define FREE_TARGET_STRING(p, gpr) \ - do { \ - unlock_user(p, gpr, 0); \ - } while (0) - void mips_semihosting(CPUMIPSState *env) { CPUState *cs = env_cpu(env); @@ -225,9 +212,13 @@ void mips_semihosting(CPUMIPSState *env) case UHI_open: { + target_ulong fname = gpr[4]; int ret = -1; - GET_TARGET_STRING(p, gpr[4]); + p = lock_user_string(fname); + if (!p) { + report_fault(env); + } if (!strcmp("/dev/stdin", p)) { ret = 0; } else if (!strcmp("/dev/stdout", p)) { @@ -235,7 +226,7 @@ void mips_semihosting(CPUMIPSState *env) } else if (!strcmp("/dev/stderr", p)) { ret = 2; } - FREE_TARGET_STRING(p, gpr[4]); + unlock_user(p, fname, 0); /* FIXME: reusing a guest fd doesn't seem correct. */ if (ret >= 0) { @@ -243,7 +234,7 @@ void mips_semihosting(CPUMIPSState *env) break; } - semihost_sys_open(cs, uhi_cb, gpr[4], 0, gpr[5], gpr[6]); + semihost_sys_open(cs, uhi_cb, fname, 0, gpr[5], gpr[6]); } break; @@ -314,14 +305,14 @@ void mips_semihosting(CPUMIPSState *env) pct_d = strstr(p, "%d"); if (!pct_d) { - FREE_TARGET_STRING(p, addr); + unlock_user(p, addr, 0); semihost_sys_write(cs, uhi_cb, 2, addr, len); break; } str = g_string_new_len(p, pct_d - p); g_string_append_printf(str, "%d%s", (int)gpr[5], pct_d + 2); - FREE_TARGET_STRING(p, addr); + unlock_user(p, addr, 0); /* * When we're using gdb, we need a guest address, so