From patchwork Tue Jun 28 11:00:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 585565 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5036:0:0:0:0 with SMTP id e22csp655246mab; Tue, 28 Jun 2022 04:08:41 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s18aS/FkYuhYC+oL3kHVQdhvJYsCWB+XK1lH60L/ixsYj6if4mYvC+gF+4/9YZDSl5xpP/ X-Received: by 2002:a05:622a:178d:b0:317:7102:d046 with SMTP id s13-20020a05622a178d00b003177102d046mr12339021qtk.645.1656414521202; Tue, 28 Jun 2022 04:08:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656414521; cv=none; d=google.com; s=arc-20160816; b=mKY5MsL1yJe1k+RBhJfzviy3pJM7r31yqePUXHoRZXknBW5rYpBp3UKDFg5qqLnqZM TpdZBI1ay9ku+m1ilKusIyoLBx2hRIdQV29mduktfs5fChwp799gf90hWHl2aMURf9Mp Q1PjDvLAzbUP/3MR/Gz9Xwk2jS46b+cdLUdW/kkbLPWZYSPuABEDNaDRQQcLt2JAnGb/ DcYETButdpeLmqF7TxdZvJiB0D3Plw1uC+1ofFw9MVDlKae3PRxWrc/q76JStmbOE+FN z2lhjO9KQDOmMruxtAhRpX9r2e9LOsIiEFZ+FEdowYwtQb0C6udRhDh+u+KvBsBIubOU Ij7g== 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=xcxh7ubUhJGco7vRyAEMpV91NTEHoXb+MMYx1sQcaR0=; b=F92Lk02mDtWADIZhUfQ5RkvqeYJ3Sh0fMT7xk0RJWjAX5beP5+wdTlvvndoLL3Z8kl Kjo2MwQv5QMxiVlWiuyM+btkC21tBvK0CdCph2w+xNpMF69yFyT14JLu6cJ9KOJAmPsk 8mbDKjtXyHV0Htb+z96HhLr+AOKoas4vOuCuLA5ev9EQTLlqyjFQ4PQJ6M0u6IYeio7I ThPDM7n9S72bVvqmVgQ2b9Ngv4PfMOR7wgIZAaf8qYoq7q7sJ+u50qbDwSZDFaaZQCHT h/mw26lqzXeRAPVEWvfTon78G6tc+ESwSMxK6m9UHt0oHQeyoaZcMJBElrz2AyyIVKZD Ephg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="MRu/k47Z"; 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 f11-20020ac859cb000000b0031a9083fa80si2701781qtf.635.2022.06.28.04.08.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Jun 2022 04:08:41 -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="MRu/k47Z"; 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]:52238 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o695E-0003IE-Ox for patch@linaro.org; Tue, 28 Jun 2022 07:08:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36890) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o68xv-0002mY-U6 for qemu-devel@nongnu.org; Tue, 28 Jun 2022 07:01:10 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]:38853) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o68xp-0007kf-Q4 for qemu-devel@nongnu.org; Tue, 28 Jun 2022 07:01:03 -0400 Received: by mail-pl1-x630.google.com with SMTP id m14so10748996plg.5 for ; Tue, 28 Jun 2022 04:01:00 -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=xcxh7ubUhJGco7vRyAEMpV91NTEHoXb+MMYx1sQcaR0=; b=MRu/k47ZEKJvpXEdUMOfIu91OEloqcp01Iq8v6Go0z4H0o+qgblYjliQlm/kP6KZI+ XEluw1nBMt/ib6oOQGIwe2HKuLq5uGLP79djq532WPyUFyyUhk5iDpeBhY4Rz7udUdJm myq9C1XxY8P0bsI+AESQvzQZ4HgN0ThwUlU5G7oo6o7sRRvBgpteBRD8ahhXyb2p5BYk 8gJQwV17s3mLwFHPgPGGr7ZhBzCIatVMli3D48Z5HYqTcT/V4ark27rLw0yKemMGMwPD 7f8nTUwyqzADNXQWjXJds0DIakesDELN0CZejHPpF75O+6Ga/JAa4rqAL9avjMRRB1vg VHYw== 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=xcxh7ubUhJGco7vRyAEMpV91NTEHoXb+MMYx1sQcaR0=; b=7NnhooUulO58qvaUrxr1zy61Gj9GGHhYzspDWe+ttiRw5X39B/aNYxz8sisVaqjd9e HptF9IQSK9bacYNm0KsHlzx8845jpkQd7cMrJpvBfVAYE0KlkxAkKCfGFxmmT/MFdS6a zHQY7Sd6twLTnae90OgMgLM+EsMmOPP0OA0y7djk/9P5YXBSSW9GIR1TBW8Amuk2f2SL L7OwLQDbfNIne35O6Lkd5uVdPQ219Pm71H9V8Vsza/6lwe1IGXV2Gl9wmlom64NBjbEn U1Wj9tKaQKkt7wCm0RXwEP+I6PBrlZSSzuDo7LCbFoC0VeMhQy4k7l4lT4RBwzJ9RL+l CGXQ== X-Gm-Message-State: AJIora83q0WB3PnY9Eg5ebA/WFzNu4Fmh7/D3o4pK+TIxZlz6r0GrGOY Rtkj5i9xfeyhX0wy4DW5dJp9Jqc3sbFTCg== X-Received: by 2002:a17:902:ea02:b0:16a:57bb:d344 with SMTP id s2-20020a170902ea0200b0016a57bbd344mr3064626plg.150.1656414059967; Tue, 28 Jun 2022 04:00:59 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id p22-20020a1709027ed600b0016a0fe1a1fbsm9044501plb.220.2022.06.28.04.00.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jun 2022 04:00:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu Subject: [PATCH v5 2/2] target/m68k: Convert semihosting errno to gdb remote errno Date: Tue, 28 Jun 2022 16:30:47 +0530 Message-Id: <20220628110047.666612-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220628110047.666612-1-richard.henderson@linaro.org> References: <20220628110047.666612-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.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 semihosting abi used by m68k uses the gdb remote protocol filesys errnos. Signed-off-by: Richard Henderson Acked-by: Laurent Vivier --- target/m68k/m68k-semi.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/target/m68k/m68k-semi.c b/target/m68k/m68k-semi.c index 586a801034..87b1314925 100644 --- a/target/m68k/m68k-semi.c +++ b/target/m68k/m68k-semi.c @@ -41,6 +41,35 @@ #define HOSTED_ISATTY 12 #define HOSTED_SYSTEM 13 +static int host_to_gdb_errno(int err) +{ +#define E(X) case E##X: return GDB_E##X + switch (err) { + E(PERM); + E(NOENT); + E(INTR); + E(BADF); + E(ACCES); + E(FAULT); + E(BUSY); + E(EXIST); + E(NODEV); + E(NOTDIR); + E(ISDIR); + E(INVAL); + E(NFILE); + E(MFILE); + E(FBIG); + E(NOSPC); + E(SPIPE); + E(ROFS); + E(NAMETOOLONG); + default: + return GDB_EUNKNOWN; + } +#undef E +} + static void m68k_semi_u32_cb(CPUState *cs, uint64_t ret, int err) { M68kCPU *cpu = M68K_CPU(cs); @@ -48,7 +77,7 @@ static void m68k_semi_u32_cb(CPUState *cs, uint64_t ret, int err) target_ulong args = env->dregs[1]; if (put_user_u32(ret, args) || - put_user_u32(err, args + 4)) { + put_user_u32(host_to_gdb_errno(err), args + 4)) { /* * The m68k semihosting ABI does not provide any way to report this * error to the guest, so the best we can do is log it in qemu. @@ -67,7 +96,7 @@ static void m68k_semi_u64_cb(CPUState *cs, uint64_t ret, int err) target_ulong args = env->dregs[1]; if (put_user_u32(ret >> 32, args) || put_user_u32(ret, args + 4) || - put_user_u32(err, args + 8)) { + put_user_u32(host_to_gdb_errno(err), args + 8)) { /* No way to report this via m68k semihosting ABI; just log it */ qemu_log_mask(LOG_GUEST_ERROR, "m68k-semihosting: return value " "discarded because argument block not writable\n");