Add minimal Hexagon target - First in a series of patches - linux-user changes + linux-user/hexagon + skeleton of target/hexagon - Files in target/hexagon/imported are from another project and therefore do not conform to qemu coding standards
PATCH 1/1 Add minimal Hexagon target - First in a series of patches - linux-user changes + linux-user/hexagon + skeleton of target/hexagon - Files in target/hexagon/imported are from another project and therefore do not conform to qemu coding standards
--- configure | 9 + default-configs/hexagon-linux-user.mak | 1 + include/elf.h | 2 + linux-user/elfload.c | 16 ++ linux-user/hexagon/cpu_loop.c | 103 +++++++++ linux-user/hexagon/signal.c | 276 +++++++++++++++++++++++ linux-user/hexagon/sockbits.h | 3 + linux-user/hexagon/syscall_nr.h | 331 ++++++++++++++++++++++++++++ linux-user/hexagon/target_cpu.h | 35 +++ linux-user/hexagon/target_elf.h | 24 ++ linux-user/hexagon/target_fcntl.h | 3 + linux-user/hexagon/target_signal.h | 19 ++ linux-user/hexagon/target_structs.h | 31 +++ linux-user/hexagon/target_syscall.h | 17 ++ linux-user/hexagon/termbits.h | 231 +++++++++++++++++++ linux-user/signal.c | 8 + linux-user/syscall.c | 2 + linux-user/syscall_defs.h | 33 +++ target/hexagon/Makefile.objs | 6 + target/hexagon/cpu-param.h | 11 + target/hexagon/cpu.c | 283 ++++++++++++++++++++++++ target/hexagon/cpu.h | 146 ++++++++++++ target/hexagon/cpu_bits.h | 15 ++ target/hexagon/helper.h | 3 + target/hexagon/imported/global_types.h | 25 +++ target/hexagon/imported/iss_ver_registers.h | 183 +++++++++++++++ target/hexagon/imported/max.h | 78 +++++++ target/hexagon/imported/regs.h | 19 ++ target/hexagon/op_helper.c | 29 +++ target/hexagon/translate.c | 220 ++++++++++++++++++ target/hexagon/translate.h | 22 ++ 31 files changed, 2184 insertions(+) create mode 100644 default-configs/hexagon-linux-user.mak create mode 100644 linux-user/hexagon/cpu_loop.c create mode 100644 linux-user/hexagon/signal.c create mode 100644 linux-user/hexagon/sockbits.h create mode 100644 linux-user/hexagon/syscall_nr.h create mode 100644 linux-user/hexagon/target_cpu.h create mode 100644 linux-user/hexagon/target_elf.h create mode 100644 linux-user/hexagon/target_fcntl.h create mode 100644 linux-user/hexagon/target_signal.h create mode 100644 linux-user/hexagon/target_structs.h create mode 100644 linux-user/hexagon/target_syscall.h create mode 100644 linux-user/hexagon/termbits.h create mode 100644 target/hexagon/Makefile.objs create mode 100644 target/hexagon/cpu-param.h create mode 100644 target/hexagon/cpu.c create mode 100644 target/hexagon/cpu.h create mode 100644 target/hexagon/cpu_bits.h create mode 100644 target/hexagon/helper.h create mode 100644 target/hexagon/imported/global_types.h create mode 100644 target/hexagon/imported/iss_ver_registers.h create mode 100644 target/hexagon/imported/max.h create mode 100644 target/hexagon/imported/regs.h create mode 100644 target/hexagon/op_helper.c create mode 100644 target/hexagon/translate.c create mode 100644 target/hexagon/translate.h
configure +9 -0
@@ -7739,6 +7739,12 @@ case "$target_name" in bflt="yes" mttcg="yes" ;; + hexagon) + TARGET_BASE_ARCH=hexagon + TARGET_ABI_DIR=hexagon + mttcg=yes + target_compiler=$cross_cc_hexagon + ;; *) error_exit "Unsupported target CPU" ;;
@@ -7902,6 +7908,9 @@ for i in $ARCH $TARGET_BASE_ARCH ; do xtensa*) disas_config "XTENSA" ;; + hexagon) + disas_config "HEXAGON" + ;; esac done if test "$tcg_interpreter" = "yes" ; then
default-configs/hexagon-linux-user.mak new file +1 -0
@@ -0,0 +1 @@ +# Default configuration for hexagon-linux-user
include/elf.h +2 -0
@@ -170,6 +170,8 @@ typedef struct mips_elf_abiflags_v0 {#define EM_UNICORE32 110/* UniCore32 */ +#define EM_HEXAGON 164/* Qualcomm Hexagon */ +#define EM_RISCV 243/* RISC-V */ #define EM_NANOMIPS 249/* Wave Computing nanoMIPS */
linux-user/elfload.c +16 -0
@@ -1504,6 +1504,22 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs,#endif /* TARGET_XTENSA */ +#ifdef TARGET_HEXAGON + +#define ELF_START_MMAP 0x20000000 + +#define ELF_CLASS ELFCLASS32 +#define ELF_ARCH EM_HEXAGON + +static inline void init_thread (struct target_pt_regs *regs, +struct image_info *infop) +{ + regs->sepc = infop->entry; + regs->sp = infop->start_stack; +} + +#endif /* TARGET_HEXAGON */ +#ifndef ELF_PLATFORM #define ELF_PLATFORM (NULL)#endif
linux-user/hexagon/cpu_loop.c new file +103 -0
103 lines not on this page · raw message
linux-user/hexagon/signal.c new file +276 -0
276 lines not on this page · raw message
linux-user/hexagon/sockbits.h new file +3 -0
@@ -0,0 +1,3 @@ +/* Copyright (c) 2019 Qualcomm Innovation Center, Inc. All Rights Reserved. */ + +#include "../generic/sockbits.h"
linux-user/hexagon/syscall_nr.h new file +331 -0
331 lines not on this page · raw message
linux-user/hexagon/target_cpu.h new file +35 -0
@@ -0,0 +1,35 @@ +/* Copyright (c) 2019 Qualcomm Innovation Center, Inc. All Rights Reserved. */ + +#ifndef TARGET_CPU_H +#define TARGET_CPU_H + +static inline void cpu_clone_regs_child (CPUHexagonState *env, +target_ulong newsp,unsigned flags) +{ +#ifdef DEBUG_HEX +printf ("cpu_clone_regs 0x%x\n" , newsp); +#endif +if (newsp) { + env->gpr[HEX_REG_SP ] = newsp; + } + env->gpr[0 ] =0 ; +} + +static inline void cpu_clone_regs_parent (CPUHexagonState *env,unsigned flags) +{ +} + +static inline void cpu_set_tls (CPUHexagonState *env,target_ulong newtls) +{ +#ifdef DEBUG_HEX +printf ("cpu_set_tls 0x%x\n" , newtls); +#endif + env->gpr[HEX_REG_UGP ] = newtls; +} + +static inline abi_ulong get_sp_from_cpustate (CPUHexagonState *state) +{ +return state->gpr[HEX_REG_SP ]; +} + +#endif
linux-user/hexagon/target_elf.h new file +24 -0
@@ -0,0 +1,24 @@ +/* Copyright (c) 2019 Qualcomm Innovation Center, Inc. All Rights Reserved. */ + +#ifndef HEXAGON_TARGET_ELF_H +#define HEXAGON_TARGET_ELF_H + +static inline const char *cpu_get_model (uint32_t eflags) +{ +/* For now, treat anything newer than v60 as a v67 */ +/* FIXME - Disable instructions that are newer than the specified arch */ +if (eflags ==0x04 ||/* v5 */ + eflags ==0x05 ||/* v55 */ + eflags ==0x60 ||/* v60 */ + eflags ==0x61 ||/* v61 */ + eflags ==0x62 ||/* v62 */ + eflags ==0x65 ||/* v65 */ + eflags ==0x66 ||/* v66 */ + eflags ==0x67 ) {/* v67 */ +return "v67" ; + } +printf ("eflags = 0x%x\n" , eflags); +return "unknown" ; +} + +#endif
linux-user/hexagon/target_fcntl.h new file +3 -0
@@ -0,0 +1,3 @@ +/* Copyright (c) 2019 Qualcomm Innovation Center, Inc. All Rights Reserved. */ + +#include "../generic/fcntl.h"
linux-user/hexagon/target_signal.h new file +19 -0
@@ -0,0 +1,19 @@ +/* Copyright (c) 2019 Qualcomm Innovation Center, Inc. All Rights Reserved. */ + +#ifndef TARGET_SIGNAL_H +#define TARGET_SIGNAL_H + +typedef struct target_sigaltstack { +abi_ulong ss_sp; +abi_int ss_flags; +abi_ulong ss_size; +}target_stack_t ; + +#define TARGET_SS_ONSTACK 1 +#define TARGET_SS_DISABLE 2 + +#define TARGET_MINSIGSTKSZ 2048 + +#include "../generic/signal.h" + +#endif /* TARGET_SIGNAL_H */
linux-user/hexagon/target_structs.h new file +31 -0
@@ -0,0 +1,31 @@ +/* Copyright (c) 2019 Qualcomm Innovation Center, Inc. All Rights Reserved. */ + +/* +* Hexagon specific structures for linux-user +*/ +#ifndef TARGET_STRUCTS_H +#define TARGET_STRUCTS_H + +struct target_ipc_perm { +abi_int __key; +abi_int uid; +abi_int gid; +abi_int cuid; +abi_int cgid; +abi_ushort mode; +abi_ushort __pad1; +abi_ushort __seq; +}; + +struct target_shmid_ds { +struct target_ipc_perm shm_perm; +abi_long shm_segsz; +abi_ulong shm_atime; +abi_ulong shm_dtime; +abi_ulong shm_ctime; +abi_int shm_cpid; +abi_int shm_lpid; +abi_ulong shm_nattch; +}; + +#endif
linux-user/hexagon/target_syscall.h new file +17 -0
@@ -0,0 +1,17 @@ +/* Copyright (c) 2019 Qualcomm Innovation Center, Inc. All Rights Reserved. */ + +#ifndef TARGET_SYSCALL_H +#define TARGET_SYSCALL_H + +struct target_pt_regs { +abi_long sepc; +abi_long sp; +}; + +#define UNAME_MACHINE "hexagon" +#define UNAME_MINIMUM_RELEASE "4.15.0" + +#define TARGET_MLOCKALL_MCL_CURRENT 1 +#define TARGET_MLOCKALL_MCL_FUTURE 2 + +#endif
linux-user/hexagon/termbits.h new file +231 -0
231 lines not on this page · raw message
linux-user/signal.c +8 -0
@@ -72,6 +72,14 @@ static uint8_t host_to_target_signal_table[_NSIG] = {over a single host signal. */ [__SIGRTMIN] = __SIGRTMAX, [__SIGRTMAX] = __SIGRTMIN, +#ifdef TARGET_HEXAGON +/* +* Hexagon uses the same signal for pthread cancel as the host pthreads, +* so cannot be overridden. +* Therefore, we map Hexagon signal to a different host signal. +*/ + [__SIGRTMAX - 1] = __SIGRTMIN + 1, +#endif };static uint8_t target_to_host_signal_table[_NSIG];
linux-user/syscall.c +2 -0
@@ -507,6 +507,8 @@ static inline int regpairs_aligned(void *cpu_env, int num) }#elif defined(TARGET_XTENSA)static inline int regpairs_aligned (void *cpu_env,int num) {return 1 ; } +#elif defined(TARGET_HEXAGON) +static inline int regpairs_aligned (void *cpu_env,int num) {return 1 ; }#else static inline int regpairs_aligned (void *cpu_env,int num) {return 0 ; }#endif
linux-user/syscall_defs.h +33 -0
@@ -102,6 +102,14 @@#define TARGET_IOC_WRITE 2U#define TARGET_IOC_READ 1U +#elif defined(TARGET_HEXAGON ) + +#define TARGET_IOC_SIZEBITS 14 + +#define TARGET_IOC_NONE 0U +#define TARGET_IOC_WRITE 1U +#define TARGET_IOC_READ 2U +#else #error unsupported CPU#endif
@@ -2085,6 +2093,31 @@ struct target_stat64 { uint64_t st_ino; }; +#elif defined(TARGET_HEXAGON) + +struct target_stat { +unsigned long long st_dev; +unsigned long long st_ino; +unsigned int st_mode; +unsigned int st_nlink; +unsigned int st_uid; +unsigned int st_gid; +unsigned long long st_rdev; +target_ulong __pad1; +long long st_size; +target_long st_blksize; +int __pad2; +long long st_blocks; + +target_long target_st_atime; +target_long target_st_atime_nsec; +target_long target_st_mtime; +target_long target_st_mtime_nsec; +target_long target_st_ctime; +target_long target_st_ctime_nsec; +int __unused[2 ]; +}; +#else #error unsupported CPU#endif
target/hexagon/Makefile.objs new file +6 -0
@@ -0,0 +1,6 @@ +obj-y += \ + cpu.o \ + translate.o \ + op_helper.o + +CFLAGS += -I$(SRC_PATH)/target/hexagon/imported
target/hexagon/cpu-param.h new file +11 -0
@@ -0,0 +1,11 @@ +/* Copyright (c) 2019 Qualcomm Innovation Center, Inc. All Rights Reserved. */ + + +#ifndef HEXAGON_CPU_PARAM_H +#define HEXAGON_CPU_PARAM_H + +# define TARGET_PHYS_ADDR_SPACE_BITS 36 + +#define NB_MMU_MODES 1 + +#endif
target/hexagon/cpu.c new file +283 -0
283 lines not on this page · raw message
target/hexagon/cpu.h new file +146 -0
146 lines not on this page · raw message
target/hexagon/cpu_bits.h new file +15 -0
@@ -0,0 +1,15 @@ +/* Copyright (c) 2019 Qualcomm Innovation Center, Inc. All Rights Reserved. */ + +#ifndef HEXAGON_CPU_BITS_H +#define HEXAGON_CPU_BITS_H + +#define HEX_EXCP_FETCH_NO_UPAGE 0x012 +#define HEX_EXCP_PRIV_NO_UREAD 0x024 +#define HEX_EXCP_PRIV_NO_UWRITE 0x025 + +#define HEX_EXCP_TRAP0 0x172 +#define HEX_EXCP_TRAP1 0x173 +#define HEX_EXCP_SC4 0x100 +#define HEX_EXCP_SC8 0x200 + +#endif
target/hexagon/helper.h new file +3 -0
@@ -0,0 +1,3 @@ +/* Copyright (c) 2019 Qualcomm Innovation Center, Inc. All Rights Reserved. */ + +DEF_HELPER_2 (raise_exception, noreturn, env, i32)
target/hexagon/imported/global_types.h new file +25 -0
@@ -0,0 +1,25 @@ +/* Copyright (c) 2019 Qualcomm Innovation Center, Inc. All Rights Reserved. */ + + +#ifndef _GLOBAL_TYPES_H_ +#define _GLOBAL_TYPES_H_ 1 + + +typedef unsigned char size1u_t ; +typedef char size1s_t ; +typedef unsigned short int size2u_t ; +typedef short size2s_t ; +typedef unsigned int size4u_t ; +typedef int size4s_t ; +typedef unsigned long long int size8u_t ; +typedef long long int size8s_t ; +typedef size8u_t paddr_t ; +typedef size4u_t vaddr_t ; +typedef size8u_t pcycles_t ; + +typedef struct size16s { +size8s_t hi; +size8u_t lo; +}size16s_t ; + +#endif /* _GLOBAL_TYPES_H_ */
target/hexagon/imported/iss_ver_registers.h new file +183 -0
183 lines not on this page · raw message
target/hexagon/imported/max.h new file +78 -0
78 lines not on this page · raw message
target/hexagon/imported/regs.h new file +19 -0
@@ -0,0 +1,19 @@ +/* Copyright (c) 2019 Qualcomm Innovation Center, Inc. All Rights Reserved. */ + + +/* +* There are 32 general user regs and up to 32 user control regs. +*/ + + +#ifndef _REGS_H +#define _REGS_H + +#define NUM_GEN_REGS 32 +#define NUM_PREGS 4 +/* user + guest + per-thread supervisor + A regs */ +#define NUM_PER_THREAD_CR (32 + 32 + 16 + 48) +#define TOTAL_PER_THREAD_REGS 64 +#define NUM_GLOBAL_REGS (128 + 32)/* + A regs */ + +#endif
target/hexagon/op_helper.c new file +29 -0
@@ -0,0 +1,29 @@ +/* Copyright (c) 2019 Qualcomm Innovation Center, Inc. All Rights Reserved. */ + +/* +* Hexagon helpers +*/ + +#include "qemu/osdep.h" +#include "qemu/log.h" +#include "tcg-op.h" +#include "cpu.h" +#include "qemu/main-loop.h" +#include "exec/exec-all.h" +#include "exec/helper-proto.h" + +/* Exceptions processing helpers */ +void QEMU_NORETURN do_raise_exception_err(CPUHexagonState *env, +uint32_t exception,uintptr_t pc) +{ +CPUState *cs =CPU (hexagon_env_get_cpu (env)); +qemu_log_mask (CPU_LOG_INT ,"%s: %d\n" , __func__, exception); + cs->exception_index = exception; +cpu_loop_exit_restore (cs, pc); +} + +void helper_raise_exception (CPUHexagonState *env,uint32_t exception) +{ +do_raise_exception_err (env, exception,0 ); +} +
target/hexagon/translate.c new file +220 -0
220 lines not on this page · raw message
target/hexagon/translate.h new file +22 -0
@@ -0,0 +1,22 @@ +/* Copyright (c) 2019 Qualcomm Innovation Center, Inc. All Rights Reserved. */ + +#ifndef TRANSLATE_H +#define TRANSLATE_H + +#include "cpu.h" +#include "exec/translator.h" +#include "exec/helper-proto.h" +#include "exec/helper-gen.h" + +typedef struct DisasContext { +DisasContextBase base; +uint32_t mem_idx; +}DisasContext ; + +extern TCGv hex_gpr[TOTAL_PER_THREAD_REGS ]; +extern TCGv hex_pred[NUM_PREGS ]; + +extern void gen_exception (int excp); +extern void gen_exception_debug (void ); + +#endif
Signature · 1 line
2.7.4
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Subject: [PATCH] Add minimal Hexagon target - First in a series of patches - linux-user changes + linux-user/hexagon + skeleton of target/hexagon - Files in target/hexagon/imported are from another project and therefore do not conform to qemu coding standards
Type: series
Message-id: [email protected]
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
Switched to a new branch 'test'
7744509 Add minimal Hexagon target - First in a series of patches - linux-user changes + linux-user/hexagon + skeleton of target/hexagon - Files in target/hexagon/imported are from another project and therefore do not conform to qemu coding standards
=== OUTPUT BEGIN ===
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #38:
new file mode 100644
ERROR: do not use C99 // comments
#1922: FILE: target/hexagon/imported/iss_ver_registers.h:80:
+// New interrupts, keep old defines for the time being
ERROR: trailing whitespace
#1924: FILE: target/hexagon/imported/iss_ver_registers.h:82:
+#define HEX_REG_GSR 81 $
ERROR: do not use C99 // comments
#2003: FILE: target/hexagon/imported/iss_ver_registers.h:161:
+// GREG_AVS renamed to GREG_RGDR2 in v67
ERROR: trailing whitespace
#2038: FILE: target/hexagon/imported/max.h:7:
+ * $
ERROR: code indent should never use tabs #2046: FILE: target/hexagon/imported/max.h:15:
+#define INSTRUCTIONS_MAX 7^I^I/* 2 pairs + loopend */$
ERROR: code indent should never use tabs #2051: FILE: target/hexagon/imported/max.h:20:
+#define MAX_CORES 4^I^I^I^I/* Cores per shared L2 */$
ERROR: line over 90 characters
#2054: FILE: target/hexagon/imported/max.h:23:
+#define THREADS_PER_CORE (MAX_CLUSTERS * MAX_THREADS_PER_CLUSTER) /* HW threads in a core */
ERROR: code indent should never use tabs
#2054: FILE: target/hexagon/imported/max.h:23:
+#define THREADS_PER_CORE (MAX_CLUSTERS * MAX_THREADS_PER_CLUSTER)^I^I/* HW threads in a core */$
ERROR: do not use C99 // comments
#2056: FILE: target/hexagon/imported/max.h:25:
+#define DMA_MAX THREADS_MAX // DMA: make this independent
ERROR: code indent should never use tabs
#2064: FILE: target/hexagon/imported/max.h:33:
+#define REG_WRITES_MAX 32^I^I/*?? */$
ERROR: code indent should never use tabs #2065: FILE: target/hexagon/imported/max.h:34:
+#define PRED_WRITES_MAX 5^I^I/* 4 insns + endloop */$
WARNING: line over 80 characters
#2074: FILE: target/hexagon/imported/max.h:43:
+#define MAX_N_GRANULES 4 /* Max of number of granules of all caches */
ERROR: code indent should never use tabs
#2074: FILE: target/hexagon/imported/max.h:43:
+#define MAX_N_GRANULES 4^I^I/* Max of number of granules of all caches */$
ERROR: code indent should never use tabs
#2080: FILE: target/hexagon/imported/max.h:49:
+#define IIC_TAGS_MAX (1024*128)^I/* 1MB = 2^20 bytes */$
ERROR: spaces required around that '*' (ctx:VxV)
#2080: FILE: target/hexagon/imported/max.h:49:
+#define IIC_TAGS_MAX (1024*128) /* 1MB = 2^20 bytes */
^
ERROR: spaces required around that '*' (ctx:VxV)
#2081: FILE: target/hexagon/imported/max.h:50:
+#define IIC_DATA_IN_BYTES_MAX (1024*1024*4)
^
ERROR: spaces required around that '*' (ctx:VxV)
#2081: FILE: target/hexagon/imported/max.h:50:
+#define IIC_DATA_IN_BYTES_MAX (1024*1024*4)
^
ERROR: code indent should never use tabs #2083: FILE: target/hexagon/imported/max.h:52:
+#define MAX_TLB_GUESS_ENTRIES (1024)^I// power of 2$
ERROR: do not use C99 // comments
#2083: FILE: target/hexagon/imported/max.h:52:
+#define MAX_TLB_GUESS_ENTRIES (1024) // power of 2
ERROR: spaces required around that '*' (ctx:VxV)
#2088: FILE: target/hexagon/imported/max.h:57:
+#define IICTLB_PAGE_SIZE (1024*4)
^
ERROR: spaces required around that '*' (ctx:VxV)
#2091: FILE: target/hexagon/imported/max.h:60:
+#define MAX_L1S_SIZE (1024*1024)
^
WARNING: line over 80 characters
#2094: FILE: target/hexagon/imported/max.h:63:
+#define SUB_IMMEDS_MAX 4 /* number of immediate fragments within insn */
ERROR: code indent should never use tabs
#2094: FILE: target/hexagon/imported/max.h:63:
+#define SUB_IMMEDS_MAX 4^I^I/* number of immediate fragments within insn */$
ERROR: do not use C99 // comments
#2101: FILE: target/hexagon/imported/max.h:70:
+//#define QTRACE_HEADER_SIZE_MAX 50 /* at most 50 chars in header */
ERROR: code indent should never use tabs
#2109: FILE: target/hexagon/imported/max.h:78:
+#endif^I^I^I^I^I^I^I/* _MAX_H */$
total: 23 errors, 3 warnings, 2232 lines checked
Commit 7744509714d7 (Add minimal Hexagon target - First in a series of patches - linux-user changes + linux-user/hexagon + skeleton of target/hexagon - Files in target/hexagon/imported are from another project and therefore do not conform to qemu coding standards) has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===
Test command exited with code: 1
The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]
Exclude paths from checkpatch (was: Re: [PATCH] Add minimal Hexagon target)
Quoted 25 lines · On 11/19/19 2:31 AM, [email protected] wrote:
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Subject: [PATCH] Add minimal Hexagon target - First in a series of patches - linux-user changes + linux-user/hexagon + skeleton of target/hexagon - Files in target/hexagon/imported are from another project and therefore do not conform to qemu coding standards
Type: series
Message-id: [email protected]=== TEST SCRIPT BEGIN === #!/bin/bash
git rev-parse base >/dev/null|| exit 0 git config --local diff.renamelimit 0 git config --local diff.renames True git config --local diff.algorithm histogram./scripts/checkpatch.pl--mailback base.. === TEST SCRIPT END ===Switched to a new branch 'test'
7744509 Add minimal Hexagon target - First in a series of patches - linux-user changes + linux-user/hexagon + skeleton of target/hexagon - Files in target/hexagon/imported are from another project and therefore do not conform to qemu coding standards
Quoted 8 lines
=== OUTPUT BEGIN ===
WARNING: added, moved or deleted file(s), doesMAINTAINERSneed updating? #38:
new file mode 100644ERROR: do not use C99 // comments
#1922: FILE:target/hexagon/imported/iss_ver_registers.h:80:
+// New interrupts, keep old defines for the time being
I tried this quick way to filter some file/directory out of checkpatch.pl, and it works nicely:
$ cat .git/hooks/pre-commit #!/bin/bash exec git diff --cached -- ':(top)' $(test -e .checkpatchignore && sed -ne '/^\(#.*\|$\)/ ! s/.*/:(exclude)\0/p' < .checkpatchignore) | scripts/checkpatch.pl --no-signoff -q -
$ cat .checkpatchignore # A line starting with # serves as a comment. # A blank line matches no files, so it can serve as a separator for readability. include/standard-headers target/xtensa/core-* target/hexagon/imported
Would this be acceptable to reduce patchew false positives?
git exclude pathspec trick from:
https://stackoverflow.com/questions/39931781/git-diff-stat-exclude-certain-files/39937070#39937070
Re: Exclude paths from checkpatch (was: Re: [PATCH] Add minimal Hexagon target)
Quoted 16 lines · Philippe Mathieu-Daudé
I tried this quick way to filter some file/directory out of checkpatch.pl, and it works nicely:
$ cat .git/hooks/pre-commit #!/bin/bash exec git diff --cached -- ':(top)' $(test -e .checkpatchignore && sed -ne '/^\(#.*\|$\)/ ! s/.*/:(exclude)\0/p' < .checkpatchignore) | scripts/checkpatch.pl --no-signoff -q -$ cat .checkpatchignore # A line starting with # serves as a comment. # A blank line matches no files, so it can serve as a separator for readability. include/standard-headers target/xtensa/core-* target/hexagon/imported
Quoted 4 lines
Would this be acceptable to reduce patchew false positives?
git exclude pathspec trick from:
https://stackoverflow.com/questions/39931781/git-diff-stat-exclude-certain-files/39937070#39937070
Looks like a good solution to me.
r~
Re: Exclude paths from checkpatch (was: Re: [PATCH] Add minimal Hexagon target)
In reply to Philippe Mathieu-DaudéQuoted 15 lines · Philippe Mathieu-Daudé
$ cat .git/hooks/pre-commit #!/bin/bash exec git diff --cached -- ':(top)' $(test -e .checkpatchignore && sed -ne '/^\(#.*\|$\)/ ! s/.*/:(exclude)\0/p' < .checkpatchignore) | scripts/checkpatch.pl --no-signoff -q -$ cat .checkpatchignore # A line starting with # serves as a comment. # A blank line matches no files, so it can serve as a separator for readability. include/standard-headers target/xtensa/core-* target/hexagon/imported
Quoted 5 lines
Would this be acceptable to reduce patchew false positives?
git exclude pathspec trick from:
https://stackoverflow.com/questions/39931781/git-diff-stat-exclude-certain-files/39937070#39937070
Could support for this be added directly to checkpatch, instead?
Paolo
Re: Exclude paths from checkpatch (was: Re: [PATCH] Add minimal Hexagon target)
In reply to Philippe Mathieu-DaudéQuoted 52 lines · Philippe Mathieu-Daudé
Quoted 25 lines · On 11/19/19 2:31 AM, [email protected] wrote:
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Subject: [PATCH] Add minimal Hexagon target - First in a series of patches - linux-user changes + linux-user/hexagon + skeleton of target/hexagon - Files in target/hexagon/imported are from another project and therefore do not conform to qemu coding standards
Type: series
Message-id: [email protected]=== TEST SCRIPT BEGIN === #!/bin/bash
git rev-parse base >/dev/null|| exit 0 git config --local diff.renamelimit 0 git config --local diff.renames True git config --local diff.algorithm histogram./scripts/checkpatch.pl--mailback base.. === TEST SCRIPT END ===Switched to a new branch 'test'
7744509 Add minimal Hexagon target - First in a series of patches - linux-user changes + linux-user/hexagon + skeleton of target/hexagon - Files in target/hexagon/imported are from another project and therefore do not conform to qemu coding standardsQuoted 8 lines
=== OUTPUT BEGIN ===
WARNING: added, moved or deleted file(s), doesMAINTAINERSneed updating? #38:
new file mode 100644ERROR: do not use C99 // comments
#1922: FILE:target/hexagon/imported/iss_ver_registers.h:80:
+// New interrupts, keep old defines for the time beingI tried this quick way to filter some file/directory out of checkpatch.pl, and it works nicely:
$ cat .git/hooks/pre-commit #!/bin/bash exec git diff --cached -- ':(top)' $(test -e .checkpatchignore && sed -ne '/^\(#.*\|$\)/ ! s/.*/:(exclude)\0/p' < .checkpatchignore) | scripts/checkpatch.pl --no-signoff -q -$ cat .checkpatchignore # A line starting with # serves as a comment. # A blank line matches no files, so it can serve as a separator for readability. include/standard-headers target/xtensa/core-* target/hexagon/imported
Quoted 4 lines
Would this be acceptable to reduce patchew false positives?
git exclude pathspec trick from:
https://stackoverflow.com/questions/39931781/git-diff-stat-exclude-certain-files/39937070#39937070
Seems useful so that patchew/checkpatch output remains high-quality.
An alternative to the git exclude pathspec trick is to build .checkpatchignore into the checkpatch.pl script so that regular invocations also use .checkpatchignore.
Stefan
Hi,
thank you for your contribution.
I think we need some little changes:
- fix the errors reported by patchew (you can check your patch with scripts/checkpatch.pl)
- split the patch in two parts: one to add the target, one to add the linux-user part,
- add the license header in files where it is missing. (you can use the SPDX tag)
- I think you can remove the "DEBUG_HEX" in cpu_loop() as most of the information can be displayed by QEMU_STRACE env variable. The one in hexagon_tr_translate_packet() can be done using QEMU_SINGLESTEP (if I understand the purpose),
- The "[__SIGRTMAX - 1] = __SIGRTMIN + 1" part must be in a separate patch. As I said at KVM Forum, I agree with this change if it doesn't break anything else but it can be controversial.
Thanks,
Laurent
Le 19/11/2019 à 00:58, Taylor Simpson a écrit :
Quoted 60 lines
Signed-off-by Taylor Simpson <[email protected]>--- configure | 9 + default-configs/hexagon-linux-user.mak | 1 + include/elf.h | 2 + linux-user/elfload.c | 16 ++ linux-user/hexagon/cpu_loop.c | 103 +++++++++ linux-user/hexagon/signal.c | 276 +++++++++++++++++++++++ linux-user/hexagon/sockbits.h | 3 + linux-user/hexagon/syscall_nr.h | 331 ++++++++++++++++++++++++++++ linux-user/hexagon/target_cpu.h | 35 +++ linux-user/hexagon/target_elf.h | 24 ++ linux-user/hexagon/target_fcntl.h | 3 + linux-user/hexagon/target_signal.h | 19 ++ linux-user/hexagon/target_structs.h | 31 +++ linux-user/hexagon/target_syscall.h | 17 ++ linux-user/hexagon/termbits.h | 231 +++++++++++++++++++ linux-user/signal.c | 8 + linux-user/syscall.c | 2 + linux-user/syscall_defs.h | 33 +++ target/hexagon/Makefile.objs | 6 + target/hexagon/cpu-param.h | 11 + target/hexagon/cpu.c | 283 ++++++++++++++++++++++++ target/hexagon/cpu.h | 146 ++++++++++++ target/hexagon/cpu_bits.h | 15 ++ target/hexagon/helper.h | 3 + target/hexagon/imported/global_types.h | 25 +++ target/hexagon/imported/iss_ver_registers.h | 183 +++++++++++++++ target/hexagon/imported/max.h | 78 +++++++ target/hexagon/imported/regs.h | 19 ++ target/hexagon/op_helper.c | 29 +++ target/hexagon/translate.c | 220 ++++++++++++++++++ target/hexagon/translate.h | 22 ++ 31 files changed, 2184 insertions(+) create mode 100644 default-configs/hexagon-linux-user.mak create mode 100644 linux-user/hexagon/cpu_loop.c create mode 100644 linux-user/hexagon/signal.c create mode 100644 linux-user/hexagon/sockbits.h create mode 100644 linux-user/hexagon/syscall_nr.h create mode 100644 linux-user/hexagon/target_cpu.h create mode 100644 linux-user/hexagon/target_elf.h create mode 100644 linux-user/hexagon/target_fcntl.h create mode 100644 linux-user/hexagon/target_signal.h create mode 100644 linux-user/hexagon/target_structs.h create mode 100644 linux-user/hexagon/target_syscall.h create mode 100644 linux-user/hexagon/termbits.h create mode 100644 target/hexagon/Makefile.objs create mode 100644 target/hexagon/cpu-param.h create mode 100644 target/hexagon/cpu.c create mode 100644 target/hexagon/cpu.h create mode 100644 target/hexagon/cpu_bits.h create mode 100644 target/hexagon/helper.h create mode 100644 target/hexagon/imported/global_types.h create mode 100644 target/hexagon/imported/iss_ver_registers.h create mode 100644 target/hexagon/imported/max.h create mode 100644 target/hexagon/imported/regs.h create mode 100644 target/hexagon/op_helper.c create mode 100644 target/hexagon/translate.c create mode 100644 target/hexagon/translate.h
Le 19/11/2019 à 09:39, Laurent Vivier a écrit :
Quoted 8 lines
Hi,
thank you for your contribution.
I think we need some little changes:
- fix the errors reported by patchew (you can check your patch with
scripts/checkpatch.pl)
of course we can ignore the errors for the imported files if you want to copy them as-is from your reference implementation.
Thanks,
Laurent
On 11/18/19 5:58 PM, Taylor Simpson wrote:
In addition to what others have said, you have an atypical and long subject line. You'll want to rewrite it to match more typical subject lines (around 65 characters) then a blank line then the additional details. 'git shortlog -30' might give you some ideas on how to do it; you'll probably want to use 'hexagon:' as your prefix.
Quoted 4 lines
Signed-off-by Taylor Simpson <[email protected]>---
31 files changed, 2184 insertions(+)
That's a big patch. How much of it is copied verbatim from elsewhere and how much is new code? Splitting the patch along those lines makes review of the non-copied portion easier.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Quoted 10 lines · Eric Blake
On 11/18/19 5:58 PM, Taylor Simpson wrote:
In addition to what others have said, you have an atypical and long subject line. You'll want to rewrite it to match more typical subject lines (around 65 characters) then a blank line then the additional details. 'git shortlog -30' might give you some ideas on how to do it; you'll probably want to use 'hexagon:' as your prefix.
Quoted 4 lines
Signed-off-by Taylor Simpson <[email protected]>---
31 files changed, 2184 insertions(+)That's a big patch. How much of it is copied verbatim from elsewhere and how much is new code? Splitting the patch along those lines makes review of the non-copied portion easier.
This is WAY less than the 132114 additions in 2 patches from the first round (see https://lists.gnu.org/archive/html/qemu-devel/2019-10/msg07188.html)
:)))
Quoted 2 lines · Taylor Simpson
Signed-off-by Taylor Simpson <[email protected]>---
[...]
Quoted 4 lines
target/hexagon/imported/global_types.h | 25 +++ target/hexagon/imported/iss_ver_registers.h | 183 +++++++++++++++ target/hexagon/imported/max.h | 78 +++++++ target/hexagon/imported/regs.h | 19 ++
Maybe you can rename this directory as:
target/hexagon/dsp-sdk/
and add a README "Files under this directory are imported from the SDK available once registered on developer.qualcomm.com ..."
Thanks for all the feedback on the patch. I'll summarize my TODO list here. Please let me know if there's anything I missed.
- Add a README file in the imported directory to make it clear that the code comes from another project. Personally, I prefer keeping the name as "imported". It was suggested by Richard at the meeting. Also as a heads-up, that is a small subset of the files that will be in that directory eventually. Right now, it is the minimum needed to build the skeleton target.
- Work on the .checkpatchignore as Philippe suggested.
- Split out the "[__SIGRTMAX - 1] = __SIGRTMIN + 1" into a separate patch.
- Clean up the long subject line.
- Add license text to the new files.
- Remove the DEBUG_HEX blocks. In general the DEBUG_HEX macro controls a bunch of debugging output as you'll see in later patches. In the long run, I think it should be replaces with a macro that is defined when configured with --enable-debug and then an additional command-line argument. I haven't looked into this, so any pointers would be appreciated.
- Laurent suggested I split the patch into two parts: linux-user and target/hexagon. If I do that, which one should contain the changes to common files (e.g., configure)? Also, note that we won't be able to build until both patches are merged. Is that OK?
Thanks,
Taylor
-----Original Message-----
From: Philippe Mathieu-Daudé <[email protected]>
Sent: Tuesday, November 19, 2019 9:19 AM
To: Taylor Simpson <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] Add minimal Hexagon target - First in a series of patches - linux-user changes + linux-user/hexagon + skeleton of target/hexagon - Files in target/hexagon/imported are from another project and therefore do not conform to qemu coding standards
-------------------------------------------------------------------------
CAUTION: This email originated from outside of the organization.
-------------------------------------------------------------------------
Quoted 2 lines · Taylor Simpson
Signed-off-by Taylor Simpson <[email protected]>---
[...]
Quoted 4 lines
target/hexagon/imported/global_types.h | 25 +++ target/hexagon/imported/iss_ver_registers.h | 183 +++++++++++++++ target/hexagon/imported/max.h | 78 +++++++ target/hexagon/imported/regs.h | 19 ++
Maybe you can rename this directory as:
target/hexagon/dsp-sdk/
and add a README "Files under this directory are imported from the SDK available once registered on developer.qualcomm.com ..."
Quoted 1 line · Taylor Simpson
- Laurent suggested I split the patch into two parts: linux-user and target/hexagon. If I do that, which one should contain the changes to common files (e.g., configure)? Also, note that we won't be able to build until both patches are merged. Is that OK?
Rule of thumb -- patches should generally be 200 lines or less (less is good!), with exceptions where something is very mechanical/repetitive and there's no point splitting it up (eg there's no need to have the new syscall_nr.h additions split into multiple patches). Judging purely by the "2184 insertions" summary you should probably be looking to split this into somewhere between 5 and 10 patches, where each patch is a coherent chunk with a commit message describing it.
Typically a new port is a complete patchset consisting of multiple patches which are intended to be applied in sequence. (They should be sent to the mailing list so they appear as a cover letter plus a set of patch emails each of which is a follow-up/reply to the cover letter. git-send-email can do this kind of thing for you.)
The requirement for a patch series like that is that at each intermediate point QEMU should still build and pass 'make check'; but the new port will obviously not be completely functional until all the parts are present. You can probably look at how the initial commits for various other recent ports were structured to see the general idea.
thanks
-- PMM
Le 19/11/2019 à 18:22, Taylor Simpson a écrit :
Quoted 7 lines
Thanks for all the feedback on the patch. I'll summarize my TODO list here. Please let me know if there's anything I missed.
- Add a README file in the imported directory to make it clear that the code comes from another project. Personally, I prefer keeping the name as "imported". It was suggested by Richard at the meeting. Also as a heads-up, that is a small subset of the files that will be in that directory eventually. Right now, it is the minimum needed to build the skeleton target.
- Work on the .checkpatchignore as Philippe suggested.
- Split out the "[__SIGRTMAX- 1] =__SIGRTMIN+ 1" into a separate patch.
- Clean up the long subject line.
- Add license text to the new files.
- Remove theDEBUG_HEXblocks. In general theDEBUG_HEXmacro controls a bunch of debugging output as you'll see in later patches. In the long run, I think it should be replaces with a macro that is defined when configured with --enable-debug and then an additional command-line argument. I haven't looked into this, so any pointers would be appreciated.
You can have a look to the trace infrastructure (docs/devel/tracing.txt). We have also some qemu_log() macros for low level debugging.
Quoted 1 line
- Laurent suggested I split the patch into two parts: linux-user and target/hexagon. If I do that, which one should contain the changes to common files (e.g., configure)? Also, note that we won't be able to build until both patches are merged. Is that OK?
You should add target/hexagon first, and it should not be build as we don't have any target (hexagon-linux-user or hexagon-softmmu), then you can add linux-user part that will be built and use the target/hexagone CPU. I think the configure part should go to the linux-user part as it enables the build.
I asked to split the patch for review purpose, but this should not break anything (to allow bisect).
Thanks,
Laurent
Quoted 31 lines
Thanks,
Taylor-----Original Message-----
From: Philippe Mathieu-Daudé <[email protected]>
Sent: Tuesday, November 19, 2019 9:19 AM
To: Taylor Simpson <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] Add minimal Hexagon target - First in a series of patches - linux-user changes + linux-user/hexagon + skeleton of target/hexagon - Files in target/hexagon/imported are from another project and therefore do not conform to qemu coding standards-------------------------------------------------------------------------
CAUTION: This email originated from outside of the organization.
-------------------------------------------------------------------------Quoted 2 lines · Taylor Simpson
Signed-off-by Taylor Simpson <[email protected]>---
[...]
Quoted 4 lines
target/hexagon/imported/global_types.h | 25 +++ target/hexagon/imported/iss_ver_registers.h | 183 +++++++++++++++ target/hexagon/imported/max.h | 78 +++++++ target/hexagon/imported/regs.h | 19 ++Maybe you can rename this directory as:
target/hexagon/dsp-sdk/
and add a README "Files under this directory are imported from the SDK available once registered on developer.qualcomm.com ..."
For the general DEBUG_HEX messages, I think the trace infrastructure isn't quite what I'm looking for.
Here's a sample of what it prints
Start packet: pc = 0x4002f0
Packet committed: pc = 0x4002f0
Regs written
r18 = -69420 (0xfffef0d4)
r19 = -69412 (0xfffef0dc)
Stores
memd[0xfffef0b0] = 0 (0x0000000000000000)Next PC = 0x4002f8
Exec counters: pkt = 17, insn = 24, hvx = 0
For performance, I'd like a way to disable them completely when --enable-debug isn't passed to configure. It looks like #ifdef CONFIG_DEBUG_TCG will work for this. Then, I'd like a command-line option to turn them on. The "-d exec" seems like a reasonable place. So, the code will look like this
#ifdef CONFIG_DEBUG_TCG
if (qemu_loglevel_maks(CPU_LOG_EXEC)) {
qemu_log(...);
}#endif
Please let me know if I'm on the right track here.
Thanks,
Taylor
-----Original Message-----
From: Laurent Vivier <[email protected]>
Sent: Tuesday, November 19, 2019 12:13 PM
To: Taylor Simpson <[email protected]>; Philippe Mathieu-Daudé <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH] Add minimal Hexagon target - First in a series of patches - linux-user changes + linux-user/hexagon + skeleton of target/hexagon - Files in target/hexagon/imported are from another project and therefore do not conform to qemu coding standards
Quoted 7 lines · Taylor Simpson
Thanks for all the feedback on the patch. I'll summarize my TODO list here. Please let me know if there's anything I missed.
- Add a README file in the imported directory to make it clear that the code comes from another project. Personally, I prefer keeping the name as "imported". It was suggested by Richard at the meeting. Also as a heads-up, that is a small subset of the files that will be in that directory eventually. Right now, it is the minimum needed to build the skeleton target.
- Work on the .checkpatchignore as Philippe suggested.
- Split out the "[__SIGRTMAX- 1] =__SIGRTMIN+ 1" into a separate patch.
- Clean up the long subject line.
- Add license text to the new files.
- Remove theDEBUG_HEXblocks. In general theDEBUG_HEXmacro controls a bunch of debugging output as you'll see in later patches. In the long run, I think it should be replaces with a macro that is defined when configured with --enable-debug and then an additional command-line argument. I haven't looked into this, so any pointers would be appreciated.
You can have a look to the trace infrastructure (docs/devel/tracing.txt). We have also some qemu_log() macros for low level debugging.
Quoted 1 line
- Laurent suggested I split the patch into two parts: linux-user and target/hexagon. If I do that, which one should contain the changes to common files (e.g., configure)? Also, note that we won't be able to build until both patches are merged. Is that OK?
You should add target/hexagon first, and it should not be build as we don't have any target (hexagon-linux-user or hexagon-softmmu), then you can add linux-user part that will be built and use the target/hexagone CPU. I think the configure part should go to the linux-user part as it enables the build.
I asked to split the patch for review purpose, but this should not break anything (to allow bisect).
Thanks,
Laurent
Quoted 37 lines
Thanks,
Taylor-----Original Message-----
From: Philippe Mathieu-Daudé <[email protected]>
Sent: Tuesday, November 19, 2019 9:19 AM
To: Taylor Simpson <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] Add minimal Hexagon target - First in a series of patches - linux-user changes + linux-user/hexagon + skeleton of target/hexagon - Files in target/hexagon/imported are from another project and therefore do not conform to qemu coding standards----------------------------------------------------------------------
---
CAUTION: This email originated from outside of the organization.
----------------------------------------------------------------------
---Quoted 2 lines · Taylor Simpson
Signed-off-by Taylor Simpson <[email protected]>---
[...]
Quoted 4 lines
target/hexagon/imported/global_types.h | 25 +++ target/hexagon/imported/iss_ver_registers.h | 183 +++++++++++++++ target/hexagon/imported/max.h | 78 +++++++ target/hexagon/imported/regs.h | 19 ++Maybe you can rename this directory as:
target/hexagon/dsp-sdk/
and add a README "Files under this directory are imported from the SDK available once registered on developer.qualcomm.com ..."
Le 20/11/2019 à 05:48, Taylor Simpson a écrit :
Quoted 15 lines
For the general
DEBUG_HEXmessages, I think the trace infrastructure isn't quite what I'm looking for.Here's a sample of what it prints Start packet: pc =
0x4002f0Packet committed: pc =0x4002f0Regs writtenr18 = -69420 (0xfffef0d4) r19 = -69412 (0xfffef0dc) Stores memd[0xfffef0b0] = 0 (0x0000000000000000)Next PC =
0x4002f8
Exec counters: pkt = 17, insn = 24, hvx = 0For performance, I'd like a way to disable them completely when --enable-debug isn't passed to configure. It looks like #ifdef
CONFIG_DEBUG_TCGwill work for this. Then, I'd like a command-line option to turn them on. The "-d exec" seems like a reasonable place. So, the code will look like this
Quoted 8 lines
#ifdef CONFIG_DEBUG_TCG if (qemu_loglevel_maks(CPU_LOG_EXEC)) { qemu_log(...); }#endif
Please let me know if I'm on the right track here.
I'm not sure CONFIG_DEBUG_TCG is the good choice (Richard should know...), you should keep your DEBUG_HEX in this case.
But the performance impact should not be big without the #ifdef as qemu_loglevel_maks() is a simple test and the rest of the code is not executed (Perhaps an "unlikely(qemu_loglevel_maks(CPU_LOG_EXEC))" could help).
Thanks,
Laurent
Quoted 13 lines · Laurent Vivier
Le 20/11/2019 à 05:48, Taylor Simpson a écrit :
Quoted 12 lines
For the general
DEBUG_HEXmessages, I think the trace infrastructure isn't quite what I'm looking for.Here's a sample of what it prints Start packet: pc =
0x4002f0Packet committed: pc =0x4002f0Regs writtenr18 = -69420 (0xfffef0d4) r19 = -69412 (0xfffef0dc) Stores memd[0xfffef0b0] = 0 (0x0000000000000000)Next PC =
0x4002f8
Exec counters: pkt = 17, insn = 24, hvx = 0
For something like this, I'd keep DEBUG_HEX.
Quoted 1 line
Quoted 1 line
if (qemu_loglevel_maks(CPU_LOG_EXEC)) {
CPU_LOG_EXEC already has a specific structure, listing the TranslationBlocks that are executed. It shouldn't be hijacked for something else.
If you really want a runtime flag for this, we should add a new CPU_LOG_* flag.
r~
Is there a precedent for this? I'm OK with DEBUG_HEX, but I assumed reviewers wouldn't approve #ifdef FIXME
#define DEBUG_HEX
#endif
Taylor
-----Original Message-----
From: Richard Henderson <[email protected]>
Sent: Wednesday, November 20, 2019 3:02 AM
To: Laurent Vivier <[email protected]>; Taylor Simpson <[email protected]>; Philippe Mathieu-Daudé <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH] Add minimal Hexagon target - First in a series of patches - linux-user changes + linux-user/hexagon + skeleton of target/hexagon - Files in target/hexagon/imported are from another project and therefore do not conform to qemu coding standards
Quoted 12 lines · Laurent Vivier
Quoted 11 lines · Taylor Simpson
For the general
DEBUG_HEXmessages, I think the trace infrastructure isn't quite what I'm looking for.Here's a sample of what it prints
Start packet: pc =0x4002f0
Packet committed: pc =0x4002f0
Regs writtenr18 = -69420 (0xfffef0d4) r19 = -69412 (0xfffef0dc) Stores memd[0xfffef0b0] = 0 (0x0000000000000000) Next PC = 0x4002f8Exec counters: pkt = 17, insn = 24, hvx = 0
For something like this, I'd keep DEBUG_HEX.
Quoted 1 line
Quoted 1 line
if (qemu_loglevel_maks(CPU_LOG_EXEC)) {
CPU_LOG_EXEC already has a specific structure, listing the TranslationBlocks that are executed. It shouldn't be hijacked for something else.
If you really want a runtime flag for this, we should add a new CPU_LOG_* flag.
r~
Le 20/11/2019 à 13:58, Taylor Simpson a écrit :
Quoted 4 lines
Is there a precedent for this? I'm OK with
DEBUG_HEX, but I assumed reviewers wouldn't approve #ifdef FIXME
#defineDEBUG_HEX
#endif
For instance, in target/mips/translate.c you have:
42
43 #define MIPS_DEBUG_DISAS 0
44...
2603 #define LOG_DISAS(...) \
2604 do { \
2605 if (MIPS_DEBUG_DISAS) { \
2606 qemu_log_mask(CPU_LOG_TB_IN_ASM, ## __VA_ARGS__);\
2607 } \
2608 } while (0)
2609
...
10121 LOG_DISAS("mftr (reg %d u %d sel %d h %d)\n", rt, u, sel,
h);
...
For the linux-user part, I don't think you need the DEBUG_HEX traces.
Thanks,
Laurent
Quoted 33 lines
-----Original Message-----
From: Richard Henderson <[email protected]>
Sent: Wednesday, November 20, 2019 3:02 AM
To: Laurent Vivier <[email protected]>; Taylor Simpson <[email protected]>; Philippe Mathieu-Daudé <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH] Add minimal Hexagon target - First in a series of patches - linux-user changes + linux-user/hexagon + skeleton of target/hexagon - Files in target/hexagon/imported are from another project and therefore do not conform to qemu coding standardsQuoted 12 lines · Laurent Vivier
Quoted 11 lines · Taylor Simpson
For the general
DEBUG_HEXmessages, I think the trace infrastructure isn't quite what I'm looking for.Here's a sample of what it prints
Start packet: pc =0x4002f0
Packet committed: pc =0x4002f0
Regs writtenr18 = -69420 (0xfffef0d4) r19 = -69412 (0xfffef0dc) Stores memd[0xfffef0b0] = 0 (0x0000000000000000) Next PC = 0x4002f8Exec counters: pkt = 17, insn = 24, hvx = 0
For something like this, I'd keep
DEBUG_HEX.Quoted 1 line
Quoted 1 line
if (qemu_loglevel_maks(CPU_LOG_EXEC)) {
CPU_LOG_EXECalready has a specific structure, listing the TranslationBlocks that are executed. It shouldn't be hijacked for something else.If you really want a runtime flag for this, we should add a new CPU_LOG_* flag.
r~
OK, I'll modify to follow the mips approach.
Taylor
-----Original Message-----
From: Laurent Vivier <[email protected]>
Sent: Wednesday, November 20, 2019 8:15 AM
To: Taylor Simpson <[email protected]>; Richard Henderson <[email protected]>; Philippe Mathieu-Daudé <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH] Add minimal Hexagon target - First in a series of patches - linux-user changes + linux-user/hexagon + skeleton of target/hexagon - Files in target/hexagon/imported are from another project and therefore do not conform to qemu coding standards
-------------------------------------------------------------------------
CAUTION: This email originated from outside of the organization.
-------------------------------------------------------------------------
Quoted 2 lines · Taylor Simpson
Is there a precedent for this? I'm OK with
DEBUG_HEX, but I assumed reviewers wouldn't approve #ifdef FIXME #defineDEBUG_HEX#endif
For instance, in target/mips/translate.c you have:
42
43 #define MIPS_DEBUG_DISAS 0
44...
2603 #define LOG_DISAS(...) \
2604 do { \
2605 if (MIPS_DEBUG_DISAS) { \
2606 qemu_log_mask(CPU_LOG_TB_IN_ASM, ## __VA_ARGS__);\
2607 } \
2608 } while (0)
2609
...
10121 LOG_DISAS("mftr (reg %d u %d sel %d h %d)\n", rt, u, sel,
h);
...
For the linux-user part, I don't think you need the DEBUG_HEX traces.
Thanks,
Laurent
Quoted 38 lines
-----Original Message-----
From: Richard Henderson <[email protected]>
Sent: Wednesday, November 20, 2019 3:02 AM
To: Laurent Vivier <[email protected]>; Taylor Simpson <[email protected]>; Philippe Mathieu-Daudé <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH] Add minimal Hexagon target - First in a series of patches - linux-user changes + linux-user/hexagon + skeleton of target/hexagon - Files in target/hexagon/imported are from another project and therefore do not conform to qemu coding standardsQuoted 12 lines · Laurent Vivier
Quoted 11 lines · Taylor Simpson
For the general
DEBUG_HEXmessages, I think the trace infrastructure isn't quite what I'm looking for.Here's a sample of what it prints
Start packet: pc =0x4002f0
Packet committed: pc =0x4002f0
Regs writtenr18 = -69420 (0xfffef0d4) r19 = -69412 (0xfffef0dc) Stores memd[0xfffef0b0] = 0 (0x0000000000000000) Next PC = 0x4002f8Exec counters: pkt = 17, insn = 24, hvx = 0
For something like this, I'd keep
DEBUG_HEX.Quoted 1 line
Quoted 1 line
if (qemu_loglevel_maks(CPU_LOG_EXEC)) {
CPU_LOG_EXECalready has a specific structure, listing the TranslationBlocks that are executed. It shouldn't be hijacked for something else.If you really want a runtime flag for this, we should add a new CPU_LOG_* flag.
r~
Quoted 4 lines · Taylor Simpson
Is there a precedent for this? I'm OK with
DEBUG_HEX, but I assumed reviewers wouldn't approve #ifdef FIXME
#defineDEBUG_HEX
#endif
We are trying to phase out this style of #define as it's prone to bitrot. What you can do if define a debug helper like:
#define D(fmt, ..) \
if (DEBUG_HEXAGON) { \
qemu_log(fmt, ## __VA_ARGS__); \}
So the debug will still be built (and format strings checked etc) but with DEBUG_HEXAGON as 0 things get dead coded away.
Quoted 27 lines
Taylor
-----Original Message-----
From: Richard Henderson <[email protected]>
Sent: Wednesday, November 20, 2019 3:02 AM
To: Laurent Vivier <[email protected]>; Taylor Simpson <[email protected]>; Philippe Mathieu-Daudé <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH] Add minimal Hexagon target - First in a series of patches - linux-user changes + linux-user/hexagon + skeleton of target/hexagon - Files in target/hexagon/imported are from another project and therefore do not conform to qemu coding standardsQuoted 12 lines · Laurent Vivier
Quoted 11 lines · Taylor Simpson
For the general
DEBUG_HEXmessages, I think the trace infrastructure isn't quite what I'm looking for.Here's a sample of what it prints
Start packet: pc =0x4002f0
Packet committed: pc =0x4002f0
Regs writtenr18 = -69420 (0xfffef0d4) r19 = -69412 (0xfffef0dc) Stores memd[0xfffef0b0] = 0 (0x0000000000000000) Next PC = 0x4002f8Exec counters: pkt = 17, insn = 24, hvx = 0
For something like this, I'd keep
DEBUG_HEX.
Quoted 8 lines
Quoted 1 line
Quoted 1 line
if (qemu_loglevel_maks(CPU_LOG_EXEC)) {
CPU_LOG_EXECalready has a specific structure, listing the TranslationBlocks that are executed. It shouldn't be hijacked for something else.If you really want a runtime flag for this, we should add a new CPU_LOG_* flag.
r~
--
Alex Bennée
Quoted 13 lines · Laurent Vivier
Le 19/11/2019 à 18:22, Taylor Simpson a écrit :
Quoted 7 lines
Thanks for all the feedback on the patch. I'll summarize my TODO list here. Please let me know if there's anything I missed.
- Add a README file in the imported directory to make it clear that the code comes from another project. Personally, I prefer keeping the name as "imported". It was suggested by Richard at the meeting. Also as a heads-up, that is a small subset of the files that will be in that directory eventually. Right now, it is the minimum needed to build the skeleton target.
- Work on the .checkpatchignore as Philippe suggested.
- Split out the "[__SIGRTMAX- 1] =__SIGRTMIN+ 1" into a separate patch.
- Clean up the long subject line.
- Add license text to the new files.
- Remove theDEBUG_HEXblocks. In general theDEBUG_HEXmacro controls a bunch of debugging output as you'll see in later patches. In the long run, I think it should be replaces with a macro that is defined when configured with --enable-debug and then an additional command-line argument. I haven't looked into this, so any pointers would be appreciated.You can have a look to the trace infrastructure (
docs/devel/tracing.txt). We have also someqemu_log()macros for low level debugging.
Quoted 7 lines
Quoted 1 line
- Laurent suggested I split the patch into two parts: linux-user and target/hexagon. If I do that, which one should contain the changes to common files (e.g., configure)? Also, note that we won't be able to build until both patches are merged. Is that OK?
You should add target/hexagon first, and it should not be build as we don't have any target (hexagon-linux-user or hexagon-softmmu), then you can add linux-user part that will be built and use the target/hexagone CPU. I think the configure part should go to the linux-user part as it enables the build.
If you have a CPU in target/hexagone, you should be able to link hexagon-softmmu and run 'hexagon-softmmu -M none -m $SIZE -S -s', this starts a CPU with $SIZE MiB of ram mapped at 0, and wait for gdb on port 1234. From here you can use 'load binary' to load some code in memory, set breakpoints, and test your CPU (and TCG).
Then I'd continue with linux-user. If you already have it, that's easier.
Quoted 6 lines
I asked to split the patch for review purpose, but this should not break anything (to allow bisect).
Thanks,
Laurent
Quoted 1 line · Taylor Simpson
- Laurent suggested I split the patch into two parts: linux-user and target/hexagon. If I do that, which one should contain the changes to common files (e.g., configure)? Also, note that we won't be able to build until both patches are merged. Is that OK?
The configure parts should be a third, last, patch.
The series is bisectable, because before the configure patch, none of the hexagon code is compiled at all.
r~
Quoted 12 lines · Richard Henderson
Quoted 1 line · Taylor Simpson
- Laurent suggested I split the patch into two parts: linux-user and
target/hexagon. If I do that, which one should contain the changes to common files (e.g., configure)? Also, note that we won't be able to build until both patches are merged. Is that OK?
The configure parts should be a third, last, patch.
The series is bisectable, because before the configure patch, none of the hexagon code is compiled at all.
I don't think this is a good advice. Yes, at first glance, that would make the submitter's job easier - since he could divide the whole code into parts practicaly arbitrarily - but the resulting series will be of suboptimal quality. If the submitter was forced from the outset to add segments of his solution so that each step actually (not only ostensibly) compiles, he would also be forced to organize patches in much more coherent way, organize his code in much more modular way, possibly improve initial organization, additionally making reviews much easier.
Aleksandar
Quoted 4 lines
r~
Quoted 13 lines · Aleksandar Markovic
On Tuesday, November 19, 2019, Richard Henderson <[email protected] <mailto:[email protected]>> wrote:
On 11/19/19 6:22 PM, Taylor Simpson wrote:
> - Laurent suggested I split the patch into two parts: linux-user and target/hexagon. If I do that, which one should contain the changes to common files (e.g., configure)? Also, note that we won't be able to build until both patches are merged. Is that OK?The configure parts should be a third, last, patch.
Quoted 8 lines
The series is bisectable, because before the configure patch, none of the hexagon code is compiled at all.
I don't think this is a good advice. Yes, at first glance, that would make the submitter's job easier - since he could divide the whole code into parts practicaly arbitrarily - but the resulting series will be of suboptimal quality.
How's that? He has been asked to split the linux-user stuff from the target skeleton stuff. Neither of these will compile independently. You could merge the configure bits artificially into the second of the two patches, or you could leave it separate.
Quoted 5 lines
If the submitter was forced from the outset to add segments of his solution so that each step actually (not only ostensibly) compiles, he would also be forced to organize patches in much more coherent way, organize his code in much more modular way, possibly improve initial organization, additionally making reviews much easier.
This argument would make more sense if there were more present here than a skeleton. The vast majority of the work is yet to be submitted, and *will* have to compile, be coherent, etc, just as you suggest.
r~
Quoted 4 lines · Richard Henderson
How's that? He has been asked to split the linux-user stuff from the target skeleton stuff.
...
Quoted 2 lines
This argument would make more sense if there were more present here than a skeleton.
Speaking about anatomy, I am opposed to upstreaming any "skeletons". The other month, another community was dead serious wanting to upstream code based on "proposal of the draft" (or was it "draft of the proposal"), and now we want to upstream "skeletons"??
And even that "skeleton" can't be regularly built stage by stage, but must resort to "enable configure at the end" cheap tricks?
What happened to QEMU upstream?
If this is really just a skeleton that can't be organized in a decent patch series that actually builds, my recommendation to Taylor is simply to postpone upstreaming until the skeleton is made stronger, all bones are in their right place, and the full body is ready - what is the point/purpose of having such a skeleton in QEMU upstream?
I am slightly disappointed that after a slick presentation on KVM Forum, we now talk about a "skeleton".
Yours,
Aleksandar
Quoted 17 lines · Aleksandar Markovic
Quoted 4 lines · Richard Henderson
How's that? He has been asked to split the linux-user stuff from the target skeleton stuff.
...
Quoted 2 lines
This argument would make more sense if there were more present here than a skeleton.
Speaking about anatomy, I am opposed to upstreaming any "skeletons". The other month, another community was dead serious wanting to upstream code based on "proposal of the draft" (or was it "draft of the proposal"), and now we want to upstream "skeletons"??
Quoted 4 lines
And even that "skeleton" can't be regularly built stage by stage, but must resort to "enable configure at the end" cheap tricks?
What happened to QEMU upstream?
You are over reacting.
We're also talking about *2* patches before the "cheap trick" of enable at the end. The only alternative to the "cheap trick" is *1* patch, which no one wants. There really is a minimum amount of code that is required before *anything* will compile.
We're not talking about applying anything at this stage. We're talking about patch review, and making the pieces small enough to actually review.
I assume that Taylor and the revng guys are coordinating the actual meat of the port. I assume those will be presented in reviewable chunks, each of which will compile. Only when we see all of those will the whole thing be applied.
r~
Le 20/11/2019 à 03:26, Aleksandar Markovic a écrit :
Quoted 17 lines
On Tuesday, November 19, 2019, Richard Henderson <[email protected] <mailto:[email protected]>> wrote:
On 11/19/19 6:22 PM, Taylor Simpson wrote:
> - Laurent suggested I split the patch into two parts: linux-user and target/hexagon. If I do that, which one should contain the changes to common files (e.g., configure)? Also, note that we won't be able to build until both patches are merged. Is that OK?The configure parts should be a third, last, patch.
The series is bisectable, because before the configure patch, none of the hexagon code is compiled at all.
Quoted 9 lines
I don't think this is a good advice. Yes, at first glance, that would make the submitter's job easier - since he could divide the whole code into parts practicaly arbitrarily - but the resulting series will be of suboptimal quality. If the submitter was forced from the outset to add segments of his solution so that each step actually (not only ostensibly) compiles, he would also be forced to organize patches in much more coherent way, organize his code in much more modular way, possibly improve initial organization, additionally making reviews much easier.
I totally agree with you but in this case I don't see a simple solution to be able to compile each part separately.
If there will be problems in the way the code is divided in patches, we can point out the problem during review.
Thanks,
Laurent
Quoted 15 lines · Aleksandar Markovic
Quoted 12 lines · Richard Henderson
Quoted 1 line · Taylor Simpson
- Laurent suggested I split the patch into two parts: linux-user and
target/hexagon. If I do that, which one should contain the changes to common files (e.g., configure)? Also, note that we won't be able to build until both patches are merged. Is that OK?
The configure parts should be a third, last, patch.
The series is bisectable, because before the configure patch, none of the hexagon code is compiled at all.
Quoted 8 lines
I don't think this is a good advice. Yes, at first glance, that would make the submitter's job easier - since he could divide the whole code into parts practicaly arbitrarily - but the resulting series will be of suboptimal quality. If the submitter was forced from the outset to add segments of his solution so that each step actually (not only ostensibly) compiles, he would also be forced to organize patches in much more coherent way, organize his code in much more modular way, possibly improve initial organization, additionally making reviews much easier.
You can do what I did for the TCG plugins which is put the machinery patches at the start (or near the start) while developing but move it to the end when it comes to the final series and PR.
It's fairly easy to move patches around.
Quoted 8 lines
Aleksandar
Quoted 4 lines
r~
--
Alex Bennée
linux-user/hexagon/signal.c line 74
Quoted 9 lines · Taylor Simpson
linux-user/hexagon/signal.c new file +9
-0+static abi_ulong get_sigframe (struct target_sigaction *ka, +CPUHexagonState *regs,size_t framesize) +{ +abi_ulong sp =get_sp_from_cpustate (regs); + +/* This is the X/Open sanctioned signal stack switching. */ + sp =target_sigsp (sp, ka) - framesize; + + sp &= ~7UL ;/* align sp on 8-byte boundary */
QEMU_ALIGN_DOWN.
linux-user/hexagon/sockbits.h line 3
Quoted 9 lines
linux-user/hexagon/sockbits.h new file +3
-0@@ -0,0 +1,3 @@ +/* Copyright (c) 2019 Qualcomm Innovation Center, Inc. All Rights Reserved. */ + +#include "../generic/sockbits.h"
All new files should have denote their license.
Quoted 5 lines
linux-user/hexagon/sockbits.h new file +5
-0+static inline const char *cpu_get_model (uint32_t eflags) +{ +/* For now, treat anything newer than v60 as a v67 */ +/* FIXME - Disable instructions that are newer than the specified arch */ + if (eflags == 0x04 || /* v5 */
linux-user/hexagon/sockbits.h
Quoted 10 lines
linux-user/hexagon/sockbits.h new file +10
-0+ eflags == 0x05 || /* v55 */ + eflags == 0x60 || /* v60 */ + eflags == 0x61 || /* v61 */ + eflags == 0x62 || /* v62 */ + eflags == 0x65 || /* v65 */ + eflags == 0x66 || /* v66 */ + eflags == 0x67) { /* v67 */ +return "v67" ; + } +printf ("eflags = 0x%x\n" , eflags);
Left over debug.
target/hexagon/Makefile.objs line 6
Quoted 12 lines
target/hexagon/Makefile.objs new file +6
-0@@ -0,0 +1,6 @@ +obj-y += \ + cpu.o \ + translate.o \ + op_helper.o + +CFLAGS += -I$(SRC_PATH)/target/hexagon/imported
Is this really better than
#include "imported/global_types.h"
etc?
target/hexagon/Makefile.objs line 7
Quoted 9 lines
+++
b/target/hexagon/cpu-param.htarget/hexagon/Makefile.objs new file +7
-0@@ -0,0 +1,11 @@ +/* Copyright (c) 2019 Qualcomm Innovation Center, Inc. All Rights Reserved. */ + + +#ifndef HEXAGON_CPU_PARAM_H +#define HEXAGON_CPU_PARAM_H + +# define TARGET_PHYS_ADDR_SPACE_BITS 36
Watch your spacing.
Does this really compile without TARGET_VIRT_ADDR_SPACE_BITS?
It's used in linux-user/main.c, but I suppose in a way that the preprocessor interprets it as 0.
target/hexagon/Makefile.objs line 10
Quoted 3 lines
target/hexagon/Makefile.objs new file +3
-0+const char * const hexagon_prednames[] = { + "p0 ", "p1 ", "p2 ", "p3 " +};
Inter-string spacing probably belongs to the format not the name.
target/hexagon/Makefile.objs
Quoted 12 lines
target/hexagon/Makefile.objs new file +12
-0+static inline target_ulong hack_stack_ptrs(CPUHexagonState *env, + target_ulong addr) +{ + target_ulong stack_start = env->stack_start; + target_ulong stack_size = 0x10000; + target_ulong stack_adjust = env->stack_adjust; + + if (stack_start + 0x1000 >= addr && addr >= (stack_start - stack_size)) { + return addr - stack_adjust; + } + return addr; +}
An explanation would be welcome here.
target/hexagon/Makefile.objs
Quoted 12 lines
target/hexagon/Makefile.objs new file +12
-0+static void hexagon_dump(CPUHexagonState *env, FILE *f) +{ + static target_ulong last_pc; + int i; + + /* + * When comparing with LLDB, it doesn't step through single-cycle + * hardware loops the same way. So, we just skip them here + */ + if (env->gpr[HEX_REG_PC] == last_pc) { + return; + }
This seems mis-placed.
Quoted 21 lines
target/hexagon/Makefile.objs new file +21
-0+#ifdef FIXME + /* + * LLDB bug swaps gp and ugp + * FIXME when the LLDB bug is fixed + */ + print_reg(f, env, HEX_REG_GP); + print_reg(f, env, HEX_REG_UGP); +#else + fprintf(f, " %s = 0x" TARGET_FMT_lx "\n", + hexagon_regnames[HEX_REG_GP], + hack_stack_ptrs(env, env->gpr[HEX_REG_UGP])); + fprintf(f, " %s = 0x" TARGET_FMT_lx "\n", + hexagon_regnames[HEX_REG_UGP], + hack_stack_ptrs(env, env->gpr[HEX_REG_GP])); +#endif + print_reg(f, env, HEX_REG_PC); +#ifdef FIXME + /* + * Not modelled in qemu, print junk to minimize the diff's + * with LLDB output + */
target/hexagon/Makefile.objs
Quoted 10 lines
target/hexagon/Makefile.objs new file +10
-0+ print_reg(f, env, HEX_REG_CAUSE); + print_reg(f, env, HEX_REG_BADVA); + print_reg(f, env, HEX_REG_CS0); + print_reg(f, env, HEX_REG_CS1); +#else + fprintf(f, " cause = 0x000000db\n"); + fprintf(f, " badva = 0x00000000\n"); + fprintf(f, " cs0 = 0x00000000\n"); + fprintf(f, " cs1 = 0x00000000\n"); +#endif
Need we retain the fixme?
target/hexagon/Makefile.objs
Quoted 4 lines
target/hexagon/Makefile.objs new file +4
-0+void hexagon_debug(CPUHexagonState *env) +{ + hexagon_dump(env, stdout); +}
Is this to be called from the debugger? From what location did you find it useful? There are only certain locations in tcg that are self-consistent...
Quoted 1 line
+
DEFINE_CPU(TYPE_HEXAGON_CPU_V67, hexagon_v67_cpu_init),
Spacing?
target/hexagon/Makefile.objs
Quoted 10 lines
target/hexagon/Makefile.objs new file +10
-0+#ifndef HEXAGON_CPU_H +#define HEXAGON_CPU_H + +/* FIXME - Change this to a command-line option */ +#ifdef FIXME +#define DEBUG_HEX +#endif +#ifdef FIXME +#define COUNT_HEX_HELPERS +#endif
Eh?
target/hexagon/Makefile.objs
Quoted 6 lines
target/hexagon/Makefile.objs new file +6
-0+ +/* Forward declaration needed by some of the header files */ +typedef struct CPUHexagonState CPUHexagonState; + +#include <fenv.h> +#include "qemu/osdep.h"
osdep.h should already have been included.
Indeed, it must be first for *.c files.
Why do you need fenv.h?
target/hexagon/Makefile.objs
Quoted 11 lines
target/hexagon/Makefile.objs new file +11
-0+#include "global_types.h" +#include "max.h" +#include "iss_ver_registers.h" + +#define TARGET_PAGE_BITS 16 /* 64K pages */ +/* + * For experimenting with oslib (4K pages) + * #define TARGET_PAGE_BITS 12 + */ +#define TARGET_LONG_BITS 32 +#define TARGET_VIRT_ADDR_SPACE_BITS 32
Ah, to answer my earlier question, these belong to cpu-param.h. Drop the "experimenting" comment.
target/hexagon/Makefile.objs
Quoted 2 lines
target/hexagon/Makefile.objs new file +2
-0+ +#include <time.h>
time.h is included by osdep.h.
Quoted 7 lines
target/hexagon/Makefile.objs new file +7
-0+#include "qemu/compiler.h" +#include "qemu-common.h" +#include "exec/cpu-defs.h" +#include "regs.h" + +#define TYPE_HEXAGON_CPU "hexagon-cpu" +
target/hexagon/Makefile.objs
Quoted 10 lines
target/hexagon/Makefile.objs new file +10
-0+#define HEXAGON_CPU_TYPE_SUFFIX "-" TYPE_HEXAGON_CPU +#define HEXAGON_CPU_TYPE_NAME(name) (name HEXAGON_CPU_TYPE_SUFFIX) +#define CPU_RESOLVING_TYPE TYPE_HEXAGON_CPU + +#define TYPE_HEXAGON_CPU_V67 HEXAGON_CPU_TYPE_NAME("v67") + +#define MMU_USER_IDX 0 + +#define TRANSLATE_FAIL 1 +#define TRANSLATE_SUCCESS 0
What's this for? This looks like it's cribbed from riscv, which oddly doesn't match the actual tlb_fill interface, which uses bool true for success.
target/hexagon/Makefile.objs
Quoted 7 lines
target/hexagon/Makefile.objs new file +7
-0+ +struct MemLog { + vaddr_t va; + size1u_t width; + size4u_t data32; + size8u_t data64; +};
Is this part of translation? Maybe save this til you actually use it, and probably place in translate.h.
target/hexagon/Makefile.objs
Quoted 3 lines
target/hexagon/Makefile.objs new file +3
-0+ /* For comparing with LLDB on target - see hack_stack_ptrs function */ + target_ulong stack_start; + target_ulong stack_adjust;
Which, as you recall, doesn't actually have any commentary.
target/hexagon/Makefile.objs
Quoted 2 lines
target/hexagon/Makefile.objs new file +2
-0+extern const char * const hexagon_regnames[]; +extern const char * const hexagon_prednames[];
Do these actually need declaring here?
Let's keep them private to cpu.c otherwise.
target/hexagon/Makefile.objs
Quoted 2 lines
target/hexagon/Makefile.objs new file +2
-0+#define ENV_GET_CPU(e) CPU(hexagon_env_get_cpu(e)) +#define ENV_OFFSET offsetof(HexagonCPU, env)
Obsolete. Remove.
target/hexagon/Makefile.objs
Quoted 2 lines
target/hexagon/Makefile.objs new file +2
-0+int hexagon_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); +int hexagon_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
Move these decls to e.g. internal.h?
They're not relevant to generic users of cpu.h
target/hexagon/Makefile.objs
Quoted 2 lines
target/hexagon/Makefile.objs new file +2
-0+void QEMU_NORETURN do_raise_exception_err(CPUHexagonState *env, + uint32_t exception, uintptr_t pc);
Likewise.
target/hexagon/Makefile.objs
Quoted 4 lines
target/hexagon/Makefile.objs new file +4
-0+void hexagon_translate_init(void); +void hexagon_debug(CPUHexagonState *env); +void hexagon_debug_vreg(CPUHexagonState *env, int regnum); +void hexagon_debug_qreg(CPUHexagonState *env, int regnum);
Likewise.
target/hexagon/Makefile.objs
Quoted 3 lines
target/hexagon/Makefile.objs new file +3
-0+#ifdef COUNT_HEX_HELPERS +extern void print_helper_counts(void); +#endif
Likewise.
target/hexagon/Makefile.objs
Quoted 6 lines
target/hexagon/Makefile.objs new file +6
-0+static void decode_packet(CPUHexagonState *env, DisasContext *ctx) +{ + size4u_t words[4]; + int i; + /* Brute force way to make sure current PC is set */ + tcg_gen_movi_tl(hex_gpr[HEX_REG_PC], ctx->base.pc_next);
What's this for?
target/hexagon/Makefile.objs
Quoted 4 lines
target/hexagon/Makefile.objs new file +4
-0+ + for (i = 0; i < 4; i++) { + words[i] = cpu_ldl_code(env, ctx->base.pc_next + i * sizeof(size4u_t)); + }
And this?
Quoted 39 lines
target/hexagon/Makefile.objs new file +39
-0+ /* + * Brute force just enough to get the first program to execute. + */ + switch (words[0]) { + case 0x7800c806: /* r6 = #64 */ + tcg_gen_movi_tl(hex_gpr[6], 64); + ctx->base.pc_next += 4; + break; + case 0x7800c020: /* r0 = #1 */ + tcg_gen_movi_tl(hex_gpr[0], 1); + ctx->base.pc_next += 4; + break; + case 0x00044002: + if (words[1] == 0x7800c001) { /* r1 = ##0x400080 */ + tcg_gen_movi_tl(hex_gpr[1], 0x400080); + ctx->base.pc_next += 8; + } else { + printf("ERROR: Unknown instruction 0x%x\n", words[1]); + g_assert_not_reached(); + } + break; + case 0x7800c0e2: /* r2 = #7 */ + tcg_gen_movi_tl(hex_gpr[2], 7); + ctx->base.pc_next += 4; + break; + case 0x5400c004: /* trap0(#1) */ + { + TCGv excp_trap0 = tcg_const_tl(HEX_EXCP_TRAP0); + gen_helper_raise_exception(cpu_env, excp_trap0); + tcg_temp_free(excp_trap0); + ctx->base.pc_next += 4; + break; + } + case 0x7800cbc6: /* r6 = #94 */ + tcg_gen_movi_tl(hex_gpr[6], 94); + ctx->base.pc_next += 4; + break; + case 0x7800cba6: /* r6 = #93 */ + tcg_gen_movi_tl(hex_gpr[6], 93);
target/hexagon/Makefile.objs
Quoted 10 lines
target/hexagon/Makefile.objs new file +10
-0+ ctx->base.pc_next += 4; + break; + case 0x7800c000: /* r0 = #0 */ + tcg_gen_movi_tl(hex_gpr[0], 0); + ctx->base.pc_next += 4; + break; + default: + ctx->base.is_jmp = DISAS_TOO_MANY; + ctx->base.pc_next += 4; + }
I'm not especially keen on this, since it will just be removed in subsequent patches. The initial patch must compile, but it need not do *anything* interesting.
C.f. 61766fe9e2d3 which is the initial commit for target/hppa, wherein the decoder is
Quoted 11 lines
target/hexagon/Makefile.objs new file +10
-0+static ExitStatus translate_one(DisasContext *ctx, uint32_t insn) +{ + uint32_t opc = extract32(insn, 26, 6); + + switch (opc) { + default: + break; + } + return gen_illegal(ctx); +}
target/hexagon/Makefile.objs
Quoted 10 lines
target/hexagon/Makefile.objs new file +8
-0+} + +static void hexagon_tr_init_disas_context(DisasContextBase *dcbase, + CPUState *cs) +{ + DisasContext *ctx = container_of(dcbase, DisasContext, base); + + ctx->mem_idx = ctx->base.tb->flags & TB_FLAGS_MMU_MASK;
Since you're not initializing this in cpu_get_tb_cpu_state, you might as well just use
ctx->mem_idx = MMU_USER_IDX;
Quoted 12 lines
target/hexagon/Makefile.objs new file +12
-0+static void hexagon_tr_translate_packet(DisasContextBase *dcbase, CPUState *cpu) +{ + DisasContext *ctx = container_of(dcbase, DisasContext, base); + CPUHexagonState *env = cpu->env_ptr; + + decode_packet(env, ctx); + + if (ctx->base.is_jmp == DISAS_NEXT) { + target_ulong page_start; + + page_start = ctx->base.pc_first & TARGET_PAGE_MASK; + if (ctx->base.pc_next - page_start >= TARGET_PAGE_SIZE) {
target/hexagon/Makefile.objs
Quoted 10 lines
target/hexagon/Makefile.objs new file +10
-0+ ctx->base.is_jmp = DISAS_TOO_MANY; + } + +#ifdef DEBUG_HEX + /* When debugging, force the end of the TB after each packet */ + if (ctx->base.pc_next - ctx->base.pc_first >= 0x04) { + ctx->base.is_jmp = DISAS_TOO_MANY; + } +#endif + }
As mentioned elsewhere, this latter should be handled by -singlestep. The generic translator loop will have set max_insns to 1.
r~
Thanks for the feedback Richard.
Responses below ...
Thanks,
Taylor
-----Original Message-----
From: Richard Henderson <[email protected]>
Sent: Tuesday, November 19, 2019 1:34 PM
To: Taylor Simpson <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] Add minimal Hexagon target - First in a series of patches - linux-user changes + linux-user/hexagon + skeleton of target/hexagon - Files in target/hexagon/imported are from another project and therefore do not conform to qemu coding standards
-------------------------------------------------------------------------
CAUTION: This email originated from outside of the organization.
-------------------------------------------------------------------------
linux-user/hexagon/signal.c line 74
Quoted 9 lines · Taylor Simpson
linux-user/hexagon/signal.c new file +9
-0+static abi_ulong get_sigframe (struct target_sigaction *ka, +CPUHexagonState *regs,size_t +framesize) { +abi_ulong sp =get_sp_from_cpustate (regs); + +/* This is the X/Open sanctioned signal stack switching. */ + sp =target_sigsp (sp, ka) - framesize; + + sp &= ~7UL ;/* align sp on 8-byte boundary */
QEMU_ALIGN_DOWN.
linux-user/hexagon/sockbits.h line 3
Quoted 10 lines
(quoted diff) +0
-0
b/linux-user/hexagon/sockbits.hnew file mode 100644 index 0000000..85bd64alinux-user/hexagon/sockbits.h new file +4
-0@@ -0,0 +1,3 @@ +/* Copyright (c) 2019 Qualcomm Innovation Center, Inc. All Rights +Reserved. */ + +#include "../generic/sockbits.h"
All new files should have denote their license.
Quoted 4 lines
linux-user/hexagon/sockbits.h new file +4
-0+static inline const char *cpu_get_model (uint32_t eflags) { +/* For now, treat anything newer than v60 as a v67 */ +/* FIXME - Disable instructions that are newer than the specified arch */ + if (eflags == 0x04 || /* v5 */
linux-user/hexagon/sockbits.h
Quoted 10 lines
linux-user/hexagon/sockbits.h new file +10
-0+ eflags == 0x05 || /* v55 */ + eflags == 0x60 || /* v60 */ + eflags == 0x61 || /* v61 */ + eflags == 0x62 || /* v62 */ + eflags == 0x65 || /* v65 */ + eflags == 0x66 || /* v66 */ + eflags == 0x67) { /* v67 */ +return "v67" ; + } +printf ("eflags = 0x%x\n" , eflags);
Left over debug.
target/hexagon/Makefile.objs line 6
Quoted 12 lines
(quoted diff) +0
-0b/target/hexagon/Makefile.objs new file mode 100644 index 0000000..dfab6ee
target/hexagon/Makefile.objs new file +6
-0@@ -0,0 +1,6 @@ +obj-y += \ + cpu.o \ + translate.o \ + op_helper.o + +CFLAGS += -I$(SRC_PATH)/target/hexagon/imported
Is this really better than
#include "imported/global_types.h"
etc?
target/hexagon/Makefile.objs line 8
Quoted 10 lines
+++
b/target/hexagon/cpu-param.htarget/hexagon/Makefile.objs new file +8
-0@@ -0,0 +1,11 @@ +/* Copyright (c) 2019 Qualcomm Innovation Center, Inc. All Rights +Reserved. */ + + +#ifndef HEXAGON_CPU_PARAM_H +#define HEXAGON_CPU_PARAM_H + +# define TARGET_PHYS_ADDR_SPACE_BITS 36
Watch your spacing.
Does this really compile without TARGET_VIRT_ADDR_SPACE_BITS?
It's used in linux-user/main.c, but I suppose in a way that the preprocessor interprets it as 0.
target/hexagon/Makefile.objs line 11
Quoted 3 lines
target/hexagon/Makefile.objs new file +3
-0+const char * const hexagon_prednames[] = { + "p0 ", "p1 ", "p2 ", "p3 " +};
Inter-string spacing probably belongs to the format not the name. [Taylor] Could you elaborate? Should I put spacing after the commas?
target/hexagon/Makefile.objs
Quoted 11 lines
target/hexagon/Makefile.objs new file +11
-0+static inline target_ulong hack_stack_ptrs(CPUHexagonState *env, + target_ulong addr) { + target_ulong stack_start = env->stack_start; + target_ulong stack_size = 0x10000; + target_ulong stack_adjust = env->stack_adjust; + + if (stack_start + 0x1000 >= addr && addr >= (stack_start - stack_size)) { + return addr - stack_adjust; + } + return addr; +}
An explanation would be welcome here.
[Taylor] I will add a comment. One of the main debugging techniques is to use "-d cpu" and compare against LLDB output when single stepping. However, the target and qemu put the stacks in different locations. This is used to compensate so the diff is cleaner.
target/hexagon/Makefile.objs
Quoted 11 lines
target/hexagon/Makefile.objs new file +11
-0+static void hexagon_dump(CPUHexagonState *env, FILE *f) { + static target_ulong last_pc; + int i; + + /* + * When comparing with LLDB, it doesn't step through single-cycle + * hardware loops the same way. So, we just skip them here + */ + if (env->gpr[HEX_REG_PC] == last_pc) { + return; + }
This seems mis-placed.
[Taylor] Hexagon has hardware controlled loops, so we can have a single packet that executes multiple times. We don't want the dump to print every time.
Quoted 19 lines
target/hexagon/Makefile.objs new file +19
-0+#ifdef FIXME + /* + * LLDB bug swaps gp and ugp + * FIXME when the LLDB bug is fixed + */ + print_reg(f, env, HEX_REG_GP); + print_reg(f, env, HEX_REG_UGP); +#else + fprintf(f, " %s = 0x" TARGET_FMT_lx "\n", + hexagon_regnames[HEX_REG_GP], + hack_stack_ptrs(env, env->gpr[HEX_REG_UGP])); + fprintf(f, " %s = 0x" TARGET_FMT_lx "\n", + hexagon_regnames[HEX_REG_UGP], + hack_stack_ptrs(env, env->gpr[HEX_REG_GP])); #endif + print_reg(f, env, HEX_REG_PC); +#ifdef FIXME + /* + * Not modelled in qemu, print junk to minimize the diff's + * with LLDB output
target/hexagon/Makefile.objs
Quoted 10 lines
target/hexagon/Makefile.objs new file +10
-0+ */ + print_reg(f, env, HEX_REG_CAUSE); + print_reg(f, env, HEX_REG_BADVA); + print_reg(f, env, HEX_REG_CS0); + print_reg(f, env, HEX_REG_CS1); +#else + fprintf(f, " cause = 0x000000db\n"); + fprintf(f, " badva = 0x00000000\n"); + fprintf(f, " cs0 = 0x00000000\n"); + fprintf(f, " cs1 = 0x00000000\n"); #endif
Need we retain the fixme?
[Taylor] Those will be needed when we implement system mode. So, I'll change the macro to CONFIG_USER_ONLY.
target/hexagon/Makefile.objs
Quoted 3 lines
target/hexagon/Makefile.objs new file +3
-0+void hexagon_debug(CPUHexagonState *env) { + hexagon_dump(env, stdout); +}
Is this to be called from the debugger? From what location did you find it useful? There are only certain locations in tcg that are self-consistent... [Taylor] Yes, these are useful from the debugger. I call it from a helper that takes CPUHexagonState as an argument.
Quoted 1 line
+
DEFINE_CPU(TYPE_HEXAGON_CPU_V67, hexagon_v67_cpu_init),
Spacing?
target/hexagon/Makefile.objs
Quoted 6 lines
target/hexagon/Makefile.objs new file +6
-0+#ifndef HEXAGON_CPU_H +#define HEXAGON_CPU_H + +/* FIXME - Change this to a command-line option */ #ifdef FIXME +#define DEBUG_HEX #endif #ifdef FIXME #define COUNT_HEX_HELPERS +#endif
Eh?
target/hexagon/Makefile.objs
Quoted 6 lines
target/hexagon/Makefile.objs new file +6
-0+ +/* Forward declaration needed by some of the header files */ typedef +struct CPUHexagonState CPUHexagonState; + +#include <fenv.h> +#include "qemu/osdep.h"
osdep.h should already have been included.
Indeed, it must be first for *.c files.
Why do you need fenv.h?
target/hexagon/Makefile.objs
Quoted 11 lines
target/hexagon/Makefile.objs new file +11
-0+#include "global_types.h" +#include "max.h" +#include "iss_ver_registers.h" + +#define TARGET_PAGE_BITS 16 /* 64K pages */ +/* + * For experimenting with oslib (4K pages) + * #define TARGET_PAGE_BITS 12 + */ +#define TARGET_LONG_BITS 32 +#define TARGET_VIRT_ADDR_SPACE_BITS 32
Ah, to answer my earlier question, these belong to cpu-param.h. Drop the "experimenting" comment.
target/hexagon/Makefile.objs
Quoted 2 lines
target/hexagon/Makefile.objs new file +2
-0+ +#include <time.h>
time.h is included by osdep.h.
Quoted 7 lines
target/hexagon/Makefile.objs new file +7
-0+#include "qemu/compiler.h" +#include "qemu-common.h" +#include "exec/cpu-defs.h" +#include "regs.h" + +#define TYPE_HEXAGON_CPU "hexagon-cpu" +
target/hexagon/Makefile.objs
Quoted 10 lines
target/hexagon/Makefile.objs new file +10
-0+#define HEXAGON_CPU_TYPE_SUFFIX "-" TYPE_HEXAGON_CPU #define +HEXAGON_CPU_TYPE_NAME(name) (name HEXAGON_CPU_TYPE_SUFFIX) #define +CPU_RESOLVING_TYPE TYPE_HEXAGON_CPU + +#define TYPE_HEXAGON_CPU_V67 HEXAGON_CPU_TYPE_NAME("v67") + +#define MMU_USER_IDX 0 + +#define TRANSLATE_FAIL 1 +#define TRANSLATE_SUCCESS 0
What's this for? This looks like it's cribbed from riscv, which oddly doesn't match the actual tlb_fill interface, which uses bool true for success.
target/hexagon/Makefile.objs
Quoted 7 lines
target/hexagon/Makefile.objs new file +7
-0+ +struct MemLog { + vaddr_t va; + size1u_t width; + size4u_t data32; + size8u_t data64; +};
Is this part of translation? Maybe save this til you actually use it, and probably place in translate.h.
[Taylor] Good catch. I can save them until they are actually used. They are part of the execution state, so need to be in cpu.h though.
target/hexagon/Makefile.objs
Quoted 3 lines
target/hexagon/Makefile.objs new file +3
-0+ /* For comparing with LLDB on target - see hack_stack_ptrs function */ + target_ulong stack_start; + target_ulong stack_adjust;
Which, as you recall, doesn't actually have any commentary.
target/hexagon/Makefile.objs
Quoted 2 lines
target/hexagon/Makefile.objs new file +2
-0+extern const char * const hexagon_regnames[]; extern const char * +const hexagon_prednames[];
Do these actually need declaring here?
Let's keep them private to cpu.c otherwise.
target/hexagon/Makefile.objs
Quoted 2 lines
target/hexagon/Makefile.objs new file +2
-0+#define ENV_GET_CPU(e) CPU(hexagon_env_get_cpu(e)) +#define ENV_OFFSET offsetof(HexagonCPU, env)
Obsolete. Remove.
target/hexagon/Makefile.objs
Quoted 2 lines
target/hexagon/Makefile.objs new file +2
-0+int hexagon_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); +int hexagon_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
Move these decls to e.g. internal.h?
They're not relevant to generic users of cpu.h
target/hexagon/Makefile.objs
Quoted 3 lines
target/hexagon/Makefile.objs new file +3
-0+void QEMU_NORETURN do_raise_exception_err(CPUHexagonState *env, + uint32_t exception, +uintptr_t pc);
Likewise.
target/hexagon/Makefile.objs
Quoted 4 lines
target/hexagon/Makefile.objs new file +4
-0+void hexagon_translate_init(void); +void hexagon_debug(CPUHexagonState *env); void +hexagon_debug_vreg(CPUHexagonState *env, int regnum); void +hexagon_debug_qreg(CPUHexagonState *env, int regnum);
Likewise.
target/hexagon/Makefile.objs
Quoted 2 lines
target/hexagon/Makefile.objs new file +2
-0+#ifdef COUNT_HEX_HELPERS +extern void print_helper_counts(void); #endif
Likewise.
target/hexagon/Makefile.objs
Quoted 5 lines
target/hexagon/Makefile.objs new file +5
-0+static void decode_packet(CPUHexagonState *env, DisasContext *ctx) { + size4u_t words[4]; + int i; + /* Brute force way to make sure current PC is set */ + tcg_gen_movi_tl(hex_gpr[HEX_REG_PC], ctx->base.pc_next);
What's this for?
[Taylor] Honestly, I'm not sure. If I remove it, nothing works - not even "hello world".
target/hexagon/Makefile.objs
Quoted 4 lines
target/hexagon/Makefile.objs new file +4
-0+ + for (i = 0; i < 4; i++) { + words[i] = cpu_ldl_code(env, ctx->base.pc_next + i * sizeof(size4u_t)); + }
And this?
[Taylor] It's reading from the instruction memory. The switch statement below uses it.
Quoted 39 lines
target/hexagon/Makefile.objs new file +39
-0+ /* + * Brute force just enough to get the first program to execute. + */ + switch (words[0]) { + case 0x7800c806: /* r6 = #64 */ + tcg_gen_movi_tl(hex_gpr[6], 64); + ctx->base.pc_next += 4; + break; + case 0x7800c020: /* r0 = #1 */ + tcg_gen_movi_tl(hex_gpr[0], 1); + ctx->base.pc_next += 4; + break; + case 0x00044002: + if (words[1] == 0x7800c001) { /* r1 = ##0x400080 */ + tcg_gen_movi_tl(hex_gpr[1], 0x400080); + ctx->base.pc_next += 8; + } else { + printf("ERROR: Unknown instruction 0x%x\n", words[1]); + g_assert_not_reached(); + } + break; + case 0x7800c0e2: /* r2 = #7 */ + tcg_gen_movi_tl(hex_gpr[2], 7); + ctx->base.pc_next += 4; + break; + case 0x5400c004: /* trap0(#1) */ + { + TCGv excp_trap0 = tcg_const_tl(HEX_EXCP_TRAP0); + gen_helper_raise_exception(cpu_env, excp_trap0); + tcg_temp_free(excp_trap0); + ctx->base.pc_next += 4; + break; + } + case 0x7800cbc6: /* r6 = #94 */ + tcg_gen_movi_tl(hex_gpr[6], 94); + ctx->base.pc_next += 4; + break; + case 0x7800cba6: /* r6 = #93 */ + tcg_gen_movi_tl(hex_gpr[6], 93);
target/hexagon/Makefile.objs
Quoted 10 lines
target/hexagon/Makefile.objs new file +10
-0+ ctx->base.pc_next += 4; + break; + case 0x7800c000: /* r0 = #0 */ + tcg_gen_movi_tl(hex_gpr[0], 0); + ctx->base.pc_next += 4; + break; + default: + ctx->base.is_jmp = DISAS_TOO_MANY; + ctx->base.pc_next += 4; + }
I'm not especially keen on this, since it will just be removed in subsequent patches. The initial patch must compile, but it need not do *anything* interesting.
C.f. 61766fe9e2d3 which is the initial commit for target/hppa, wherein the decoder is
Quoted 9 lines
target/hexagon/Makefile.objs new file +9
-0+static ExitStatus translate_one(DisasContext *ctx, uint32_t insn) { + uint32_t opc = extract32(insn, 26, 6); + + switch (opc) { + default: + break; + } + return gen_illegal(ctx); +}
target/hexagon/Makefile.objs
Quoted 10 lines
target/hexagon/Makefile.objs new file +7
-0+} + +static void hexagon_tr_init_disas_context(DisasContextBase *dcbase, + CPUState *cs) { + DisasContext *ctx = container_of(dcbase, DisasContext, base); + + ctx->mem_idx = ctx->base.tb->flags & TB_FLAGS_MMU_MASK;
Since you're not initializing this in cpu_get_tb_cpu_state, you might as well just use
ctx->mem_idx = MMU_USER_IDX;
[Taylor] Should I be initialize this in cpu_get_bt_cpu_state?
Quoted 12 lines
target/hexagon/Makefile.objs new file +12
-0+static void hexagon_tr_translate_packet(DisasContextBase *dcbase, +CPUState *cpu) { + DisasContext *ctx = container_of(dcbase, DisasContext, base); + CPUHexagonState *env = cpu->env_ptr; + + decode_packet(env, ctx); + + if (ctx->base.is_jmp == DISAS_NEXT) { + target_ulong page_start; + + page_start = ctx->base.pc_first & TARGET_PAGE_MASK; + if (ctx->base.pc_next - page_start >= TARGET_PAGE_SIZE) {
target/hexagon/Makefile.objs
Quoted 10 lines
target/hexagon/Makefile.objs new file +10
-0+ ctx->base.is_jmp = DISAS_TOO_MANY; + } + +#ifdef DEBUG_HEX + /* When debugging, force the end of the TB after each packet */ + if (ctx->base.pc_next - ctx->base.pc_first >= 0x04) { + ctx->base.is_jmp = DISAS_TOO_MANY; + } +#endif + }
As mentioned elsewhere, this latter should be handled by -singlestep. The generic translator loop will have set max_insns to 1.
r~
Quoted 6 lines · Taylor Simpson
target/hexagon/cpu.c line 49
Quoted 3 lines
target/hexagon/cpu.c new file +3
-0+const char *const hexagon_prednames[] = { +"p0 " ,"p1 " ,"p2 " ,"p3 " +};Inter-string spacing probably belongs to the format not the name. [Taylor] Could you elaborate? Should I put spacing after the commas?
"p0" not "p0 ". Typo on my part for "inter-"; sorry for the confusion.
Quoted 6 lines
Quoted 6 lines
target/hexagon/cpu.c new file +6
-0+static inline target_ulong hack_stack_ptrs (CPUHexagonState *env, +target_ulong addr) { +target_ulong stack_start = env->stack_start; +target_ulong stack_size =0x10000 ; +target_ulong stack_adjust = env->stack_adjust; +
Quoted 8 lines
target/hexagon/cpu.c line 62
Quoted 5 lines
target/hexagon/cpu.c new file +5
-0+if (stack_start +0x1000 >= addr && addr >= (stack_start - stack_size)) { +return addr - stack_adjust; + } +return addr; +}An explanation would be welcome here.
[Taylor] I will add a comment. One of the main debugging techniques is to use "-d cpu" and compare against LLDB output when single stepping. However, the target and qemu put the stacks in different locations. This is used to compensate so the diff is cleaner.
Ug. I understand why you want this, but... ug.
Quoted 6 lines
Quoted 6 lines
target/hexagon/cpu.c new file +6
-0+static void hexagon_dump (CPUHexagonState *env,FILE *f) { +static target_ulong last_pc; +int i; + +/* +* When comparing with LLDB, it doesn't step through single-cycle
Quoted 8 lines
target/hexagon/cpu.c line 83
Quoted 5 lines
target/hexagon/cpu.c new file +5
-0+* hardware loops the same way. So, we just skip them here +*/ +if (env->gpr[HEX_REG_PC ] == last_pc) { +return ; + }This seems mis-placed.
[Taylor] Hexagon has hardware controlled loops, so we can have a single packet that executes multiple times. We don't want the dump to print every time.
Certainly I do. If I'm single-stepping, I want every packet present. Just as if this were written as a traditional loop, with a branch back to the single packet in the loop body.
Also, you cannot expect a static variable to work in multi-threaded mode, and you cannot expect a __thread variable to work in single-threaded round-robin mode.
Quoted 8 lines
target/hexagon/translate.c line 45
Quoted 5 lines
target/hexagon/translate.c new file +5
-0+static void decode_packet (CPUHexagonState *env,DisasContext *ctx) { +size4u_t words[4 ]; +int i; +/* Brute force way to make sure current PC is set */ +tcg_gen_movi_tl (hex_gpr[HEX_REG_PC ], ctx->base.pc_next);What's this for?
[Taylor] Honestly, I'm not sure. If I remove it, nothing works - not even "hello world".
Weird. I would have expected that the update you do within hexagon_tr_tb_stop would be sufficient. I guess I'll have to peek at it.
I presume your minimal test case is a bit of hand-crafted assembly that issues a write syscall and exit?
Quoted 7 lines
target/hexagon/translate.c line 49
Quoted 4 lines
target/hexagon/translate.c new file +4
-0+ +for (i =0 ; i <4 ; i++) { + words[i] =cpu_ldl_code (env, ctx->base.pc_next + i *sizeof (size4u_t)); + }And this?
[Taylor] It's reading from the instruction memory. The switch statement below uses it.
I thought packets are variable length and ended by a bit set. Therefore why the fixed iteration to 4? Also...
Quoted 5 lines
target/hexagon/translate.c line 53
Quoted 5 lines
target/hexagon/translate.c new file +4
-0+/* +* Brute force just enough to get the first program to execute. +*/ +switch (words[0 ]) {
... you only use 1 word, but you read 4.
Quoted 10 lines
target/hexagon/translate.c line 106
Quoted 5 lines
target/hexagon/translate.c new file +5
-0+static void hexagon_tr_init_disas_context (DisasContextBase *dcbase, +CPUState *cs) { +DisasContext *ctx =container_of (dcbase, DisasContext, base); + + ctx->mem_idx = ctx->base.tb->flags &TB_FLAGS_MMU_MASK ;Since you're not initializing this in
cpu_get_tb_cpu_state, you might as well just usectx->mem_idx = MMU_USER_IDX;[Taylor] Should I be initialize this in
cpu_get_bt_cpu_state?
Not until there's something more interesting to put there, when you implement system state. The constant initialization should be fine.
r~
Responses inline ...
Thanks,
Taylor
-----Original Message-----
From: Richard Henderson <[email protected]>
Sent: Wednesday, November 20, 2019 2:07 AM
To: Taylor Simpson <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] Add minimal Hexagon target - First in a series of patches - linux-user changes + linux-user/hexagon + skeleton of target/hexagon - Files in target/hexagon/imported are from another project and therefore do not conform to qemu coding standards
-------------------------------------------------------------------------
CAUTION: This email originated from outside of the organization.
-------------------------------------------------------------------------
Quoted 6 lines · Taylor Simpson
target/hexagon/cpu.c line 49
Quoted 3 lines
target/hexagon/cpu.c new file +3
-0+const char *const hexagon_prednames[] = { +"p0 " ,"p1 " ,"p2 " ,"p3 " +};Inter-string spacing probably belongs to the format not the name. [Taylor] Could you elaborate? Should I put spacing after the commas?
"p0" not "p0 ". Typo on my part for "inter-"; sorry for the confusion.
Quoted 6 lines
Quoted 6 lines
target/hexagon/cpu.c new file +6
-0+static inline target_ulong hack_stack_ptrs (CPUHexagonState *env, +target_ulong addr) { +target_ulong stack_start = env->stack_start; +target_ulong stack_size =0x10000 ; +target_ulong stack_adjust = env->stack_adjust; +
Quoted 8 lines
target/hexagon/cpu.c line 62
Quoted 5 lines
target/hexagon/cpu.c new file +5
-0+if (stack_start +0x1000 >= addr && addr >= (stack_start - stack_size)) { +return addr - stack_adjust; + } +return addr; +}An explanation would be welcome here.
[Taylor] I will add a comment. One of the main debugging techniques is to use "-d cpu" and compare against LLDB output when single stepping. However, the target and qemu put the stacks in different locations. This is used to compensate so the diff is cleaner.
Ug. I understand why you want this, but... ug.
[Taylor] Not sure what to say - I guess there's a fine line between elegance and mayhem.
Quoted 6 lines
Quoted 6 lines
target/hexagon/cpu.c new file +6
-0+static void hexagon_dump (CPUHexagonState *env,FILE *f) { +static target_ulong last_pc; +int i; + +/* +* When comparing with LLDB, it doesn't step through single-cycle
Quoted 8 lines
target/hexagon/cpu.c line 83
Quoted 5 lines
target/hexagon/cpu.c new file +5
-0+* hardware loops the same way. So, we just skip them here +*/ +if (env->gpr[HEX_REG_PC ] == last_pc) { +return ; + }This seems mis-placed.
[Taylor] Hexagon has hardware controlled loops, so we can have a single packet that executes multiple times. We don't want the dump to print every time.
Certainly I do. If I'm single-stepping, I want every packet present. Just as if this were written as a traditional loop, with a branch back to the single packet in the loop body.
Also, you cannot expect a static variable to work in multi-threaded mode, and you cannot expect a __thread variable to work in single-threaded round-robin mode.
[Taylor] This is another place where it's important to match the output of LLDB for a clean diff. In fact, LLDB uses hardware single step, and that will step to the end of a single-cycle hardware loop. Also, the technique of comparing with LLDB only works for single threaded examples, so I'm not worried about the thread-safety of this code.
[Taylor] To clarify, this is for a rare case when a hardware loop body is a single packet. Here's an example. It's the portion of memset that gets called when the number of bytes is small
400404: 10 40 02 60 60024010 { loop0(0x40040c,r2)
400408: 08 c0 02 10 1002c008 p0 = cmp.eq(r2,#0); if (p0.new) jump:nt 0x400414 <memset+0x34> }
40040c: 01 81 03 a1 a1038101 { memb(r3+#1) = r1
400410: 10 c1 03 ab ab03c110 memb(r3++#2) = r1 } :endloop0The loop0 instruction sets the start address and the iteration count. The :endloop0 marks the end of the loop and tells the hardware to decrement the counter and go back to the start if it's not zero. So, the loop at 0x40040c-0x400410 is a single packet. In this case the hardware single step will execute the entire loop. Finally, if the loop has more than one packet, the single stepping will go through each iteration as you describe.
Quoted 8 lines
target/hexagon/translate.c line 45
Quoted 5 lines
target/hexagon/translate.c new file +5
-0+static void decode_packet (CPUHexagonState *env,DisasContext *ctx) { +size4u_t words[4 ]; +int i; +/* Brute force way to make sure current PC is set */ +tcg_gen_movi_tl (hex_gpr[HEX_REG_PC ], ctx->base.pc_next);What's this for?
[Taylor] Honestly, I'm not sure. If I remove it, nothing works - not even "hello world".
Weird. I would have expected that the update you do within hexagon_tr_tb_stop would be sufficient. I guess I'll have to peek at it.
I presume your minimal test case is a bit of hand-crafted assembly that issues a write syscall and exit?
[Taylor] The minimal test case is
#define SYS_write 64
#define SYS_exit_group 94
#define SYS_exit 93
#define FD_STDOUT 1
.typestr,@object
.section.rodata
str:
.string"Hello!\n"
.sizestr, 8
.text
.global _start_start:
r6 = #SYS_write
r0 = #FD_STDOUT
r1 = ##str
r2 = #7
trap0(#1)
r6 = #SYS_exit_group
trap0(#1)
r6 = #SYS_exit
r0 = #0
trap0(#1)
Without that code, it prints "Hello!" twice. With the full set of patches, I get segfaults ☹
Quoted 7 lines
target/hexagon/translate.c line 49
Quoted 4 lines
target/hexagon/translate.c new file +4
-0+ +for (i =0 ; i <4 ; i++) { + words[i] =cpu_ldl_code (env, ctx->base.pc_next + i *sizeof (size4u_t)); + }And this?
[Taylor] It's reading from the instruction memory. The switch statement below uses it.
I thought packets are variable length and ended by a bit set. Therefore why the fixed iteration to 4? Also...
[Taylor] The maximum size of a packet is 4 words, so I go ahead and read that much. Once the packet is decoded, I set ctx->base.pc_next appropriately. Note that most of the instructions in the switch add 4, but one of them adds 8.
Quoted 5 lines
target/hexagon/translate.c line 53
Quoted 5 lines
target/hexagon/translate.c new file +4
-0+/* +* Brute force just enough to get the first program to execute. +*/ +switch (words[0 ]) {
... you only use 1 word, but you read 4.
Quoted 11 lines
target/hexagon/translate.c line 106
Quoted 5 lines
target/hexagon/translate.c new file +5
-0+static void hexagon_tr_init_disas_context (DisasContextBase *dcbase, +CPUState *cs) { +DisasContext *ctx =container_of (dcbase, DisasContext, base); + + ctx->mem_idx = ctx->base.tb->flags &TB_FLAGS_MMU_MASK ;Since you're not initializing this in
cpu_get_tb_cpu_state, you might as well just usectx->mem_idx = MMU_USER_IDX;[Taylor] Should I be initialize this in
cpu_get_bt_cpu_state?
Not until there's something more interesting to put there, when you implement system state. The constant initialization should be fine.
r~
Quoted 15 lines · Taylor Simpson
Quoted 6 lines
Quoted 6 lines
target/hexagon/cpu.c new file +6
-0+static inline target_ulong hack_stack_ptrs (CPUHexagonState *env, +target_ulong addr) { +target_ulong stack_start = env->stack_start; +target_ulong stack_size =0x10000 ; +target_ulong stack_adjust = env->stack_adjust; +Quoted 8 lines
target/hexagon/cpu.c line 62
Quoted 5 lines
target/hexagon/cpu.c new file +5
-0+if (stack_start +0x1000 >= addr && addr >= (stack_start - stack_size)) { +return addr - stack_adjust; + } +return addr; +}An explanation would be welcome here.
[Taylor] I will add a comment. One of the main debugging techniques is to use "-d cpu" and compare against LLDB output when single stepping. However, the target and qemu put the stacks in different locations. This is used to compensate so the diff is cleaner.
Quoted 3 lines
Ug. I understand why you want this, but... ug.
[Taylor] Not sure what to say - I guess there's a fine line between elegance and mayhem.
The hack may work for now, but I would certainly expect this code to go away eventually. Sooner rather than later.
If you want dumps between LLDB and QEMU to match, then just put the stack at the same spot. Messing about with the pointers after the fact is insane.
Quoted 6 lines
[Taylor] To clarify, this is for a rare case when a hardware loop body is a single packet. Here's an example. It's the portion of memset that gets called when the number of bytes is small
400404: 10 40 02 60 60024010 { loop0(0x40040c,r2) 400408: 08 c0 02 10 1002c008 p0 = cmp.eq(r2,#0); if (p0.new) jump:nt 0x400414 <memset+0x34> } 40040c: 01 81 03 a1 a1038101 { memb(r3+#1) = r1 400410: 10 c1 03 ab ab03c110 memb(r3++#2) = r1 } :endloop0The loop0 instruction sets the start address and the iteration count. The :endloop0 marks the end of the loop and tells the hardware to decrement the counter and go back to the start if it's not zero. So, the loop at 0x40040c-0x400410 is a single packet. In this case the hardware single step will execute the entire loop. Finally, if the loop has more than one packet, the single stepping will go through each iteration as you describe.
The behaviour inconsistency between a single packet loop and a two packet loop sounds to me like a HW bug. Perhaps of the WONTFIX variety, but still...
Quoted 8 lines
Quoted 8 lines
target/hexagon/translate.c line 45
Quoted 5 lines
target/hexagon/translate.c new file +5
-0+static void decode_packet (CPUHexagonState *env,DisasContext *ctx) { +size4u_t words[4 ]; +int i; +/* Brute force way to make sure current PC is set */ +tcg_gen_movi_tl (hex_gpr[HEX_REG_PC ], ctx->base.pc_next);What's this for?
[Taylor] Honestly, I'm not sure. If I remove it, nothing works - not even "hello world".
It's because you forgot to update PC before raising the exception for trap #0. Which also ought to set DISAS_NORETURN to end the TB, since it longjmp's out.
Quoted 11 lines
Quoted 6 lines
target/hexagon/translate.c line 49
Quoted 3 lines
target/hexagon/translate.c new file +3
-0+for (i =0 ; i <4 ; i++) { + words[i] =cpu_ldl_code (env, ctx->base.pc_next + i *sizeof (size4u_t)); + }And this?
[Taylor] It's reading from the instruction memory. The switch statement below uses it.I thought packets are variable length and ended by a bit set. Therefore why the fixed iteration to 4? Also...
[Taylor] The maximum size of a packet is 4 words, so I go ahead and read that much. Once the packet is decoded, I set
ctx->base.pc_nextappropriately. Note that most of the instructions in the switch add 4, but one of them adds 8.
This is where you will need to take more care wrt the end of the packet and the end of the page. I would expect something like
max = -(dc->base.pc_next | TARGET_PAGE_MASK) / 4;
if (max < 4) {
/* this packet *might* cross a page boundary */
if (dc->base.num_insns == 1) {
/* this is the first packet in the TB -- allow it */
max = 4;
}
} else {
max = 4;
}
found_end = false;
for (i = 0; i < 4; i++) {
words[i] = load(...);
if (end_of_packet(words[i])) {
max = i + 1;
found_end = true;
break;
}
}
if (!found_end) {
if (i == 4) {
/* illegal packet -- read all 4 without an end */
gen_illegal_insn_or_whatever();
dc->base.is_jmp = DISAS_NORETURN;
return;
}
/* the packet crosses a page boundary -- defer to next tb */
dc->base.is_jmp = DISAS_TOO_MANY;
return;
}
...
case insn that needs two words:
assert(i + 2 <= max);
...r~
Are you saying there's a way to tell qemu to put the stack at a certain location? Or are you suggesting we do something on the hardware side?
Taylor
-----Original Message-----
From: Richard Henderson <[email protected]>
Sent: Wednesday, November 20, 2019 8:43 AM
To: Taylor Simpson <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] Add minimal Hexagon target - First in a series of patches - linux-user changes + linux-user/hexagon + skeleton of target/hexagon - Files in target/hexagon/imported are from another project and therefore do not conform to qemu coding standards
-------------------------------------------------------------------------
CAUTION: This email originated from outside of the organization.
-------------------------------------------------------------------------
Quoted 15 lines · Taylor Simpson
Quoted 6 lines
Quoted 6 lines
target/hexagon/cpu.c new file +6
-0+static inline target_ulong hack_stack_ptrs (CPUHexagonState *env, +target_ulong addr) { +target_ulong stack_start = env->stack_start; +target_ulong stack_size =0x10000 ; +target_ulong stack_adjust = env->stack_adjust; +Quoted 8 lines
target/hexagon/cpu.c line 62
Quoted 5 lines
target/hexagon/cpu.c new file +5
-0+if (stack_start +0x1000 >= addr && addr >= (stack_start - stack_size)) { +return addr - stack_adjust; + } +return addr; +}An explanation would be welcome here.
[Taylor] I will add a comment. One of the main debugging techniques is to use "-d cpu" and compare against LLDB output when single stepping. However, the target and qemu put the stacks in different locations. This is used to compensate so the diff is cleaner.
Quoted 3 lines
Ug. I understand why you want this, but... ug.
[Taylor] Not sure what to say - I guess there's a fine line between elegance and mayhem.
The hack may work for now, but I would certainly expect this code to go away eventually. Sooner rather than later.
If you want dumps between LLDB and QEMU to match, then just put the stack at the same spot. Messing about with the pointers after the fact is insane.
Quoted 6 lines
[Taylor] To clarify, this is for a rare case when a hardware loop body is a single packet. Here's an example. It's the portion of memset that gets called when the number of bytes is small
400404: 10 40 02 60 60024010 { loop0(0x40040c,r2) 400408: 08 c0 02 10 1002c008 p0 = cmp.eq(r2,#0); if (p0.new) jump:nt 0x400414 <memset+0x34> } 40040c: 01 81 03 a1 a1038101 { memb(r3+#1) = r1 400410: 10 c1 03 ab ab03c110 memb(r3++#2) = r1 } :endloop0The loop0 instruction sets the start address and the iteration count. The :endloop0 marks the end of the loop and tells the hardware to decrement the counter and go back to the start if it's not zero. So, the loop at 0x40040c-0x400410 is a single packet. In this case the hardware single step will execute the entire loop. Finally, if the loop has more than one packet, the single stepping will go through each iteration as you describe.
The behaviour inconsistency between a single packet loop and a two packet loop sounds to me like a HW bug. Perhaps of the WONTFIX variety, but still...
Quoted 8 lines
Quoted 8 lines
target/hexagon/translate.c line 45
Quoted 5 lines
target/hexagon/translate.c new file +5
-0+static void decode_packet (CPUHexagonState *env,DisasContext *ctx) { +size4u_t words[4 ]; +int i; +/* Brute force way to make sure current PC is set */ +tcg_gen_movi_tl (hex_gpr[HEX_REG_PC ], ctx->base.pc_next);What's this for?
[Taylor] Honestly, I'm not sure. If I remove it, nothing works - not even "hello world".
It's because you forgot to update PC before raising the exception for trap #0. Which also ought to set DISAS_NORETURN to end the TB, since it longjmp's out.
Quoted 11 lines
Quoted 6 lines
target/hexagon/translate.c line 49
Quoted 3 lines
target/hexagon/translate.c new file +3
-0+for (i =0 ; i <4 ; i++) { + words[i] =cpu_ldl_code (env, ctx->base.pc_next + i *sizeof (size4u_t)); + }And this?
[Taylor] It's reading from the instruction memory. The switch statement below uses it.I thought packets are variable length and ended by a bit set. Therefore why the fixed iteration to 4? Also...
[Taylor] The maximum size of a packet is 4 words, so I go ahead and read that much. Once the packet is decoded, I set
ctx->base.pc_nextappropriately. Note that most of the instructions in the switch add 4, but one of them adds 8.
This is where you will need to take more care wrt the end of the packet and the end of the page. I would expect something like
max = -(dc->base.pc_next | TARGET_PAGE_MASK) / 4;
if (max < 4) {
/* this packet *might* cross a page boundary */
if (dc->base.num_insns == 1) {
/* this is the first packet in the TB -- allow it */
max = 4;
}
} else {
max = 4;
}
found_end = false;
for (i = 0; i < 4; i++) {
words[i] = load(...);
if (end_of_packet(words[i])) {
max = i + 1;
found_end = true;
break;
}
}
if (!found_end) {
if (i == 4) {
/* illegal packet -- read all 4 without an end */
gen_illegal_insn_or_whatever();
dc->base.is_jmp = DISAS_NORETURN;
return;
}
/* the packet crosses a page boundary -- defer to next tb */
dc->base.is_jmp = DISAS_TOO_MANY;
return;
}
...
case insn that needs two words:
assert(i + 2 <= max);
...r~
Quoted 1 line · Taylor Simpson
Are you saying there's a way to tell qemu to put the stack at a certain location? Or are you suggesting we do something on the hardware side?
There's obviously nothing to be done on the hardware side. Presumably this is all about the kernel, running on the hardware, and the default memory map that it creates for the application.
There's certainly a way to influence where the stack gets put, via ELF_START_MMAP. We could even add another define to force the stack to a given location if required. I don't know enough about the kernel's default memory map, and what's different here, to answer that question.
r~
Quoted 4 lines
create mode 100644 target/hexagon/imported/global_types.h create mode 100644 target/hexagon/imported/iss_ver_registers.h create mode 100644 target/hexagon/imported/max.h create mode 100644 target/hexagon/imported/regs.h
Taylor, if I understood you well, these files don't confirm to QEMU coding standard, because they are imported. But, from where? And what is the reason they need to be imported (and not created independently by you or somebody else, but within QEMU code style guidelines) ? Their content looks fairly simple to me.
Thanks,
Aleksandar
They are imported from the existing Hexagon simulator. Please understand that this patch is the first in a series. Later patches will contain more elaborate contents in that directory. The reason I don't want to reformat them is to stay in sync with the other simulator in the future. When the other team makes changes to the code (either to fix bugs or add features), it will be easier to identify the changes and bring them into qemu.
Taylor
-----Original Message-----
From: Aleksandar Markovic <[email protected]>
Sent: Thursday, November 21, 2019 1:20 PM
To: Taylor Simpson <[email protected]>
Cc: Laurent Vivier <[email protected]>; Riku Voipio <[email protected]>; QEMU Developers <[email protected]>
Subject: Re: [PATCH] Add minimal Hexagon target - First in a series of patches - linux-user changes + linux-user/hexagon + skeleton of target/hexagon - Files in target/hexagon/imported are from another project and therefore do not conform to qemu coding standards
Quoted 4 lines
create mode 100644 target/hexagon/imported/global_types.h create mode 100644 target/hexagon/imported/iss_ver_registers.h create mode 100644 target/hexagon/imported/max.h create mode 100644
target/hexagon/imported/regs.h
Taylor, if I understood you well, these files don't confirm to QEMU coding standard, because they are imported. But, from where? And what is the reason they need to be imported (and not created independently by you or somebody else, but within QEMU code style guidelines) ? Their content looks fairly simple to me.
Thanks,
Aleksandar
Quoted 5 lines · Taylor Simpson
They are imported from the existing Hexagon simulator. Please understand that this patch is the first in a series. Later patches will contain more elaborate contents in that directory. The reason I don't want to reformat them is to stay in sync with the other simulator in the future. When the other team makes changes to the code (either to fix bugs or add features), it will be easier to identify the changes and bring them into qemu.
Taylor
Taylor,
Please understand that this patch can't remain a single patch. It can't remain even a set of 2 or 3 patches as others suggested. A patch is a logically connected unit of code whose typical size is less than 200 lines. There are lots of such logical units in this single path that you sent, and you should not have sent it in its present form, even if you wanted just comments to it. You should have submitted a series rather than a single patch. And you should have said this is v1 of my series that I will expand later on. Guidelines for submissions are here:
https://wiki.qemu.org/Contribute/SubmitAPatch
As far as "imported" files, frankly, I dislike the fact that you are willing to sacrifice our coding style guidelines in favor to your convenience. But, more than this, I also find very problematic that you practically create a dependency between QEMU and another simulator. QEMU implementation should rely on specifications, and only on specifications, and certainly should not depend on another simulator. Currently, in QEMU, there are some cases of imported disassemblers or similar relatively unimportant tools, but those imports change very rarely, and are modified to comply to QEMU coding style. I am not aware on dependency of QEMU on another simulator in the form you want to do for Hexagon. My strong impression is that you will create more problems than benefits with such dependency, both for you and for QEMU in general.
Once a CPU or any other device is specified though documentation, these specs don't change. Consequently, their emulation does not change too, in functional sense. The fact that you anticipate changes in these files imported from another simulator, leaves me with a (possibly wrong) perception that neither Hexagon internal simulator nor QEMU implementation you are trying to integrate are complete. If that is not true, can you explain what exactly you expect to be changing in imported files?
Yours,
Aleksandar
Quoted 18 lines
-----Original Message-----
From: Aleksandar Markovic <[email protected]>
Sent: Thursday, November 21, 2019 1:20 PM
To: Taylor Simpson <[email protected]>
Cc: Laurent Vivier <[email protected]>; Riku Voipio <[email protected]>; QEMU Developers <[email protected]>
Subject: Re: [PATCH] Add minimal Hexagon target - First in a series of patches - linux-user changes + linux-user/hexagon + skeleton of target/hexagon - Files in target/hexagon/imported are from another project and therefore do not conform to qemu coding standardsQuoted 4 lines
create mode 100644 target/hexagon/imported/global_types.h create mode 100644 target/hexagon/imported/iss_ver_registers.h create mode 100644 target/hexagon/imported/max.h create mode 100644
target/hexagon/imported/regs.hTaylor, if I understood you well, these files don't confirm to QEMU coding standard, because they are imported. But, from where? And what is the reason they need to be imported (and not created independently by you or somebody else, but within QEMU code style guidelines) ? Their content looks fairly simple to me.
Thanks,
Aleksandar
Hi Aleksandar,
The complete qemu-hexagon implementation can be found here
https://github.com/quic/qemu
From the beginning, I knew I would have to divide it up into smaller patches for review. The discussion on how divide it was here
https://lists.gnu.org/archive/html/qemu-devel/2019-11/msg01971.html
I'll summarize the proposal
1) linux-user changes + linux-user/hexagon + skeleton of target/hexagon
2) Add the code this imported from the Hexagon simulator and the qemu helper generator
3) Add support for packet semantics
4) Add support for wide vector extensions
5) Add the helper overrides for performance optimization
My assumption in the proposal was that each phase of the submission should compile and execute, and each phase should expand the capabilities of the Hexagon target. I apologize that it wasn't clear how large each of the patches would be.
I greatly appreciate all of the feedback on the proposal and the patch, and I am making the revisions. In several cases, the feedback also applies to the remainder of the code. So, I am making the changes there as well. From that perspective, I think it will reduce the overall burden on the reviewers.
As far as what might change in the imported files goes, the current simulator (hexagon-sim) has been used in production as part of the toolchain for over a decade and has been used to verify every version of the core that we have shipped. Since it is used in verification, it is considered the gold standard - more so than the PDF manual. Any changes to that code, including reformatting, would put qemu at risk of not accurately emulating the processor.
Taylor
-----Original Message-----
From: Aleksandar Markovic <[email protected]>
Sent: Thursday, November 21, 2019 2:45 PM
To: Taylor Simpson <[email protected]>
Cc: Laurent Vivier <[email protected]>; Riku Voipio <[email protected]>; QEMU Developers <[email protected]>
Subject: Re: [PATCH] Add minimal Hexagon target - First in a series of patches - linux-user changes + linux-user/hexagon + skeleton of target/hexagon - Files in target/hexagon/imported are from another project and therefore do not conform to qemu coding standards
Quoted 5 lines · Taylor Simpson
They are imported from the existing Hexagon simulator. Please understand that this patch is the first in a series. Later patches will contain more elaborate contents in that directory. The reason I don't want to reformat them is to stay in sync with the other simulator in the future. When the other team makes changes to the code (either to fix bugs or add features), it will be easier to identify the changes and bring them into qemu.
Taylor
Taylor,
Please understand that this patch can't remain a single patch. It can't remain even a set of 2 or 3 patches as others suggested. A patch is a logically connected unit of code whose typical size is less than
200 lines. There are lots of such logical units in this single path that you sent, and you should not have sent it in its present form, even if you wanted just comments to it. You should have submitted a series rather than a single patch. And you should have said this is v1 of my series that I will expand later on. Guidelines for submissions are here:
https://wiki.qemu.org/Contribute/SubmitAPatch
As far as "imported" files, frankly, I dislike the fact that you are willing to sacrifice our coding style guidelines in favor to your convenience. But, more than this, I also find very problematic that you practically create a dependency between QEMU and another simulator. QEMU implementation should rely on specifications, and only on specifications, and certainly should not depend on another simulator. Currently, in QEMU, there are some cases of imported disassemblers or similar relatively unimportant tools, but those imports change very rarely, and are modified to comply to QEMU coding style. I am not aware on dependency of QEMU on another simulator in the form you want to do for Hexagon. My strong impression is that you will create more problems than benefits with such dependency, both for you and for QEMU in general.
Once a CPU or any other device is specified though documentation, these specs don't change. Consequently, their emulation does not change too, in functional sense. The fact that you anticipate changes in these files imported from another simulator, leaves me with a (possibly wrong) perception that neither Hexagon internal simulator nor QEMU implementation you are trying to integrate are complete. If that is not true, can you explain what exactly you expect to be changing in imported files?
Yours,
Aleksandar
Quoted 22 lines
-----Original Message-----
From: Aleksandar Markovic <[email protected]>
Sent: Thursday, November 21, 2019 1:20 PM
To: Taylor Simpson <[email protected]>
Cc: Laurent Vivier <[email protected]>; Riku Voipio <[email protected]>; QEMU Developers <[email protected]>
Subject: Re: [PATCH] Add minimal Hexagon target - First in a series of patches - linux-user changes + linux-user/hexagon + skeleton of target/hexagon - Files in target/hexagon/imported are from another project and therefore do not conform to qemu coding standardsQuoted 4 lines
create mode 100644 target/hexagon/imported/global_types.h create mode 100644 target/hexagon/imported/iss_ver_registers.h create mode 100644 target/hexagon/imported/max.h create mode100644
target/hexagon/imported/regs.hTaylor, if I understood you well, these files don't confirm to QEMU coding standard, because they are imported. But, from where? And what is the reason they need to be imported (and not created independently by you or somebody else, but within QEMU code style guidelines) ? Their content looks fairly simple to me.
Thanks,
Aleksandar
Quoted 9 lines · Taylor Simpson
Hi Aleksandar,
The complete qemu-hexagon implementation can be found here
https://github.com/quic/qemuFrom the beginning, I knew I would have to divide it up into smaller patches for review. The discussion on how divide it was here
https://lists.gnu.org/archive/html/qemu-devel/2019-11/msg01971.html
I'll summarize the proposal
Quoted 8 lines
1) linux-user changes + linux-user/hexagon + skeleton of target/hexagon
2) Add the code this imported from the Hexagon simulator and the qemu
helper generator
3) Add support for packet semantics
4) Add support for wide vector extensions
5) Add the helper overrides for performance optimization
I think you, for some reason, mix and keep mixing two really different things:
- outline of your changes (as seen as points 1-5 above)
- a patch
None of points 1-5 could be a patch. All of them should be patch series, or part of patch series.
I am surprised that it seems as if you did not take a look at the previous cases of platform introductions to QEMU. Or you did, but decided you don't need to bother creating patch series, you don't need to follow QEMU submission guidelines - you apparently think you can simply send the changes as several huge patches.
Quoted 11 lines
My assumption in the proposal was that each phase of the submission should compile and execute, and each phase should expand the capabilities of the Hexagon target. I apologize that it wasn't clear how large each of the patches would be.
I greatly appreciate all of the feedback on the proposal and the patch, and I am making the revisions. In several cases, the feedback also applies to the remainder of the code. So, I am making the changes there as well. From that perspective, I think it will reduce the overall burden on the reviewers.
Quoted 9 lines
As far as what might change in the imported files goes, the current simulator (hexagon-sim) has been used in production as part of the toolchain for over a decade and has been used to verify every version of the core that we have shipped. Since it is used in verification, it is considered the gold standard - more so than the PDF manual. Any changes to that code, including reformatting, would put qemu at risk of not accurately emulating the processor.
We in MIPS also have ISA verification software that can be viewed as "gold standard", but we don't burden QEMU with any imported files - and we certainly could, using the same rationale as you do.
I am opposed to considering the output (or a part) of an internally developed simulator more important than (or on the same level as) documentation, and calling it a "gold standard".
A gold-standard-related question arises here:
If something is called a "gold standard", should it be a constant, by its very definition?
Also, you did not answer my question from my previous resoonse, which was:
What do you expect to be changing in imported-from-another-simulator code?
And I add another one:
What exactly components of QEMU for Hexagon are contained in imported-from-another-simulator code?
Thanks,
Aleksandar
Quoted 92 lines
Taylor
-----Original Message-----
From: Aleksandar Markovic <[email protected]>
Sent: Thursday, November 21, 2019 2:45 PM
To: Taylor Simpson <[email protected]>
Cc: Laurent Vivier <[email protected]>; Riku Voipio <[email protected]>; QEMU Developers <[email protected]>
Subject: Re: [PATCH] Add minimal Hexagon target - First in a series of patches - linux-user changes + linux-user/hexagon + skeleton of target/hexagon - Files in target/hexagon/imported are from another project and therefore do not conform to qemu coding standardsQuoted 2 lines · Taylor Simpson
They are imported from the existing Hexagon simulator. Please
understand that this patch is the first in a series. Later patches will contain more elaborate contents in that directory. The reason I don't want to reformat them is to stay in sync with the other simulator in the future. When the other team makes changes to the code (either to fix bugs or add features), it will be easier to identify the changes and bring them into qemu.
Quoted 3 lines
Taylor
Taylor,
Please understand that this patch can't remain a single patch. It can't remain even a set of 2 or 3 patches as others suggested. A patch is a logically connected unit of code whose typical size is less than 200 lines. There are lots of such logical units in this single path that you sent, and you should not have sent it in its present form, even if you wanted just comments to it. You should have submitted a series rather than a single patch. And you should have said this is v1 of my series that I will expand later on. Guidelines for submissions are here:
https://wiki.qemu.org/Contribute/SubmitAPatch
As far as "imported" files, frankly, I dislike the fact that you are willing to sacrifice our coding style guidelines in favor to your convenience. But, more than this, I also find very problematic that you practically create a dependency between QEMU and another simulator. QEMU implementation should rely on specifications, and only on specifications, and certainly should not depend on another simulator. Currently, in QEMU, there are some cases of imported disassemblers or similar relatively unimportant tools, but those imports change very rarely, and are modified to comply to QEMU coding style. I am not aware on dependency of QEMU on another simulator in the form you want to do for Hexagon. My strong impression is that you will create more problems than benefits with such dependency, both for you and for QEMU in general.
Once a CPU or any other device is specified though documentation, these specs don't change. Consequently, their emulation does not change too, in functional sense. The fact that you anticipate changes in these files imported from another simulator, leaves me with a (possibly wrong) perception that neither Hexagon internal simulator nor QEMU implementation you are trying to integrate are complete. If that is not true, can you explain what exactly you expect to be changing in imported files?
Yours,
AleksandarQuoted 12 lines
-----Original Message-----
From: Aleksandar Markovic <[email protected]>
Sent: Thursday, November 21, 2019 1:20 PM
To: Taylor Simpson <[email protected]>
Cc: Laurent Vivier <[email protected]>; Riku Voipio <[email protected]>; QEMU Developers <[email protected]>
Subject: Re: [PATCH] Add minimal Hexagon target - First in a series of patches - linux-user changes + linux-user/hexagon + skeleton of target/hexagon - Files in target/hexagon/imported are from another project and therefore do not conform to qemu coding standardsQuoted 6 lines
Quoted 4 lines
create mode 100644 target/hexagon/imported/global_types.h create mode 100644 target/hexagon/imported/iss_ver_registers.h create mode 100644 target/hexagon/imported/max.h create mode100644
target/hexagon/imported/regs.hTaylor, if I understood you well, these files don't confirm to QEMU
coding standard, because they are imported. But, from where? And what is the reason they need to be imported (and not created independently by you or somebody else, but within QEMU code style guidelines) ?
Quoted 4 lines
Their content looks fairly simple to me.
Thanks,
Aleksandar