From patchwork Tue Jun 7 20:45:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 579417 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5806:0:0:0:0 with SMTP id j6csp5568326max; Tue, 7 Jun 2022 15:29:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxgjvnl8NeQjh6b9tnK0n8laol2ZeCpmsGSXpbd79LP8JKeFGa+eafa2rlRzHjT3z6EzX/J X-Received: by 2002:ac8:5dca:0:b0:304:e1e2:8a17 with SMTP id e10-20020ac85dca000000b00304e1e28a17mr18558256qtx.12.1654640977950; Tue, 07 Jun 2022 15:29:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654640977; cv=none; d=google.com; s=arc-20160816; b=H7wmg1VxZUTn27tN14Sk18LpQWZPDFlvBLZDF6TRCTK/toOrVIYWAX4gy9eCeAG+lu Ar7lGGcqGgKKCSkqgrHqKD0lX9xDNEeD/fLFasBtcnTgb66b3xIdZtGdsPILfcnSPshK cHuidIqBCsVsZYtZXgBZZUsghlhbySjAWk0oo/SJgqya1YF0cQyKfqV5Se3A2gbasOsH i8QwDXn2v50R42ZfFlSydn2bQntD86LrU8JD2SBLvI2Vzt7EyXrG+he/igrtGWJjByjd MdzYGidy0WCewf3cIW1I92+rO5j9lsIAvG/LKjiHCyD2QQWNkuEwXccjz+wAtW1K9vA5 Sc6w== 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=oxNDqSzg5Hw13giw27gxbf2VZjOoolDUxgjGkiB+OjI=; b=1D/MVvv5suS3Vv0rUVd1ai2OAiEDhsdA2OuQfGPu0dtLXvY7sbna18d/tL76zpePDu zJTlTPL7TSu3VQX+68QWDoXA8l7bLXu+BrKNlzTKhpSEhPI2j3VL6d1umlpHlIZ/06l8 Uhh2cy8XZpaSCl5QxahQJSxu9ePnjGIDpefFBRznWZoSzd8AZorLJTTtJjECz259rtjY E44JThoiM7gbIboiDGeFE8OkEyoZp8Afn2dsxzQAQa/2lzkXbvAxc1Rl3rZIOgK8sqUP +0NY6r20Axa4ARNSmtAGYA83w8Yr2ANmNVkcXU+PPgERKaL2EW7tSaFVgToTcmCf73n1 T3aA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=g7GI5eJj; 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 w17-20020a05622a191100b00304e2c56e8bsi7558738qtc.177.2022.06.07.15.29.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 15:29: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=g7GI5eJj; 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]:50306 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nyhhg-00078s-Qr for patch@linaro.org; Tue, 07 Jun 2022 18:29:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38966) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nyg5i-0007Gd-4o for qemu-devel@nongnu.org; Tue, 07 Jun 2022 16:46:21 -0400 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]:33404) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nyg5g-0001Mg-0s for qemu-devel@nongnu.org; Tue, 07 Jun 2022 16:46:17 -0400 Received: by mail-pg1-x533.google.com with SMTP id r71so17015993pgr.0 for ; Tue, 07 Jun 2022 13:46:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oxNDqSzg5Hw13giw27gxbf2VZjOoolDUxgjGkiB+OjI=; b=g7GI5eJj97SG063ZqeBvHi0ZQ1Fg4ZJa9fqxmZzolElaodj9My3CQg19R6wbsGHHHV MeBqcjDlnlQRlp46WQsb5FJEtaFGp8aoX7jsPuPcTOL49AU0fwNr9oJwZL8g22+ahPtZ OIfckUhDnDhghe7Q0A3pwyHYpjdgdsn+w6FAzJhGwmzXSj0AnbpPbx5oZ8hX77GDl74f i4JAJOKjFyG5nImS0NqkZeARvUpQumUZNDCJCUbShw4gJ2TUyRO4FtdZ8Nz7Yx6CIRMo ToR4F+2gcgV/Wsd5sYV7i23FVlqjGCVIq7p6zvkgHa7gnFgfFsIDTFLTgGe2ix8+r/5D bdHA== 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=oxNDqSzg5Hw13giw27gxbf2VZjOoolDUxgjGkiB+OjI=; b=Co5p3J8T0Pqj3tXJIIAwHKk3hSFTplEJr2Y/s14p2UjZVs3Horx3jQUJ8X128ZTutf h68XX+3rjnVnG6XUxwuiIOd81LxOVJ9cWKaBZayqQ+PNJQC5gGmrR59jHgpMfDWEX2r/ 2BxLwGiyw+98da/bJUUVXjT8Xyg0hcGBqHXuW+F13yajmEENQCWDGaR8WJKGNoK1TjsP SlNCj49+7miyuwccdE6tlZa/dJnGhQcivdDKzZh99Jm3KpiqktSkBkqNFi5VTBFpsFxh 5/gT3j/Gx5PAA2vST1kc7jYommkYaCV136JP0QXiADDGIIEuUYvPoXPg5221Bp6VtGrO Ow0w== X-Gm-Message-State: AOAM5308jCB9mIlIkiaVJ8QVLxvL9UgGiNQOqkSPLtQh+gJuFqKVArbv 4arFE90ss2AJ8CETusMGoFt7b4lE9NY++w== X-Received: by 2002:a05:6a00:148d:b0:51c:4b1e:9436 with SMTP id v13-20020a056a00148d00b0051c4b1e9436mr2407066pfu.38.1654634774659; Tue, 07 Jun 2022 13:46:14 -0700 (PDT) Received: from stoup.. ([2602:ae:1547:e101:3cf2:c634:5b19:25f6]) by smtp.gmail.com with ESMTPSA id r6-20020a170902be0600b00162037fbacdsm12971279pls.187.2022.06.07.13.46.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 13:46:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Maydell Subject: [PATCH v4 17/53] include/exec: Move gdb_stat and gdb_timeval to gdbstub.h Date: Tue, 7 Jun 2022 13:45:21 -0700 Message-Id: <20220607204557.658541-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220607204557.658541-1-richard.henderson@linaro.org> References: <20220607204557.658541-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::533; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x533.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 have two copies of these structures, and require them in semihosting/ going forward. Reviewed-by: Alex Bennée Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- include/exec/gdbstub.h | 25 +++++++++++++++++++++++++ target/m68k/m68k-semi.c | 32 +++++--------------------------- target/nios2/nios2-semi.c | 30 +++--------------------------- 3 files changed, 33 insertions(+), 54 deletions(-) diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index 603e22ae80..7413ffeba2 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -19,6 +19,31 @@ #define GDB_O_TRUNC 0x400 #define GDB_O_EXCL 0x800 +/* For gdb file i/o stat/fstat. */ +typedef uint32_t gdb_mode_t; +typedef uint32_t gdb_time_t; + +struct gdb_stat { + uint32_t gdb_st_dev; /* device */ + uint32_t gdb_st_ino; /* inode */ + gdb_mode_t gdb_st_mode; /* protection */ + uint32_t gdb_st_nlink; /* number of hard links */ + uint32_t gdb_st_uid; /* user ID of owner */ + uint32_t gdb_st_gid; /* group ID of owner */ + uint32_t gdb_st_rdev; /* device type (if inode device) */ + uint64_t gdb_st_size; /* total size, in bytes */ + uint64_t gdb_st_blksize; /* blocksize for filesystem I/O */ + uint64_t gdb_st_blocks; /* number of blocks allocated */ + gdb_time_t gdb_st_atime; /* time of last access */ + gdb_time_t gdb_st_mtime; /* time of last modification */ + gdb_time_t gdb_st_ctime; /* time of last change */ +} QEMU_PACKED; + +struct gdb_timeval { + gdb_time_t tv_sec; /* second */ + uint64_t tv_usec; /* microsecond */ +} QEMU_PACKED; + #ifdef NEED_CPU_H #include "cpu.h" diff --git a/target/m68k/m68k-semi.c b/target/m68k/m68k-semi.c index 475a6b13b7..b886ebf714 100644 --- a/target/m68k/m68k-semi.c +++ b/target/m68k/m68k-semi.c @@ -45,30 +45,6 @@ #define HOSTED_ISATTY 12 #define HOSTED_SYSTEM 13 -typedef uint32_t gdb_mode_t; -typedef uint32_t gdb_time_t; - -struct m68k_gdb_stat { - uint32_t gdb_st_dev; /* device */ - uint32_t gdb_st_ino; /* inode */ - gdb_mode_t gdb_st_mode; /* protection */ - uint32_t gdb_st_nlink; /* number of hard links */ - uint32_t gdb_st_uid; /* user ID of owner */ - uint32_t gdb_st_gid; /* group ID of owner */ - uint32_t gdb_st_rdev; /* device type (if inode device) */ - uint64_t gdb_st_size; /* total size, in bytes */ - uint64_t gdb_st_blksize; /* blocksize for filesystem I/O */ - uint64_t gdb_st_blocks; /* number of blocks allocated */ - gdb_time_t gdb_st_atime; /* time of last access */ - gdb_time_t gdb_st_mtime; /* time of last modification */ - gdb_time_t gdb_st_ctime; /* time of last change */ -} QEMU_PACKED; - -struct gdb_timeval { - gdb_time_t tv_sec; /* second */ - uint64_t tv_usec; /* microsecond */ -} QEMU_PACKED; - static int translate_openflags(int flags) { int hf; @@ -90,11 +66,13 @@ static int translate_openflags(int flags) static void translate_stat(CPUM68KState *env, target_ulong addr, struct stat *s) { - struct m68k_gdb_stat *p; + struct gdb_stat *p; - if (!(p = lock_user(VERIFY_WRITE, addr, sizeof(struct m68k_gdb_stat), 0))) + p = lock_user(VERIFY_WRITE, addr, sizeof(struct gdb_stat), 0); + if (!p) { /* FIXME - should this return an error code? */ return; + } p->gdb_st_dev = cpu_to_be32(s->st_dev); p->gdb_st_ino = cpu_to_be32(s->st_ino); p->gdb_st_mode = cpu_to_be32(s->st_mode); @@ -114,7 +92,7 @@ static void translate_stat(CPUM68KState *env, target_ulong addr, struct stat *s) p->gdb_st_atime = cpu_to_be32(s->st_atime); p->gdb_st_mtime = cpu_to_be32(s->st_mtime); p->gdb_st_ctime = cpu_to_be32(s->st_ctime); - unlock_user(p, addr, sizeof(struct m68k_gdb_stat)); + unlock_user(p, addr, sizeof(struct gdb_stat)); } static void m68k_semi_return_u32(CPUM68KState *env, uint32_t ret, uint32_t err) diff --git a/target/nios2/nios2-semi.c b/target/nios2/nios2-semi.c index 0eec1f9a1c..3e504a6c5f 100644 --- a/target/nios2/nios2-semi.c +++ b/target/nios2/nios2-semi.c @@ -47,30 +47,6 @@ #define HOSTED_ISATTY 12 #define HOSTED_SYSTEM 13 -typedef uint32_t gdb_mode_t; -typedef uint32_t gdb_time_t; - -struct nios2_gdb_stat { - uint32_t gdb_st_dev; /* device */ - uint32_t gdb_st_ino; /* inode */ - gdb_mode_t gdb_st_mode; /* protection */ - uint32_t gdb_st_nlink; /* number of hard links */ - uint32_t gdb_st_uid; /* user ID of owner */ - uint32_t gdb_st_gid; /* group ID of owner */ - uint32_t gdb_st_rdev; /* device type (if inode device) */ - uint64_t gdb_st_size; /* total size, in bytes */ - uint64_t gdb_st_blksize; /* blocksize for filesystem I/O */ - uint64_t gdb_st_blocks; /* number of blocks allocated */ - gdb_time_t gdb_st_atime; /* time of last access */ - gdb_time_t gdb_st_mtime; /* time of last modification */ - gdb_time_t gdb_st_ctime; /* time of last change */ -} QEMU_PACKED; - -struct gdb_timeval { - gdb_time_t tv_sec; /* second */ - uint64_t tv_usec; /* microsecond */ -} QEMU_PACKED; - static int translate_openflags(int flags) { int hf; @@ -102,9 +78,9 @@ static int translate_openflags(int flags) static bool translate_stat(CPUNios2State *env, target_ulong addr, struct stat *s) { - struct nios2_gdb_stat *p; + struct gdb_stat *p; - p = lock_user(VERIFY_WRITE, addr, sizeof(struct nios2_gdb_stat), 0); + p = lock_user(VERIFY_WRITE, addr, sizeof(struct gdb_stat), 0); if (!p) { return false; @@ -128,7 +104,7 @@ static bool translate_stat(CPUNios2State *env, target_ulong addr, p->gdb_st_atime = cpu_to_be32(s->st_atime); p->gdb_st_mtime = cpu_to_be32(s->st_mtime); p->gdb_st_ctime = cpu_to_be32(s->st_ctime); - unlock_user(p, addr, sizeof(struct nios2_gdb_stat)); + unlock_user(p, addr, sizeof(struct gdb_stat)); return true; }