Please find submitted a patch for ARM memory barriers.  This patch is
against qemu-2.12-rc2 but I do believe it should apply for anything from
2.11.x to current.

I found with qemu 2.11.x or newer that I would get an illegal instruction
error running some Intel binaries on my ARM chromebook.  On investigation,
I found it was quitting on memory barriers.
qemu instruction:
mb $0x31
was translating as:
0x604050cc:  5bf07ff5  blpl     #0x600250a8

After patch it gives:
0x604050cc:  f57ff05b  dmb      ish

In short, I found INSN_DMB_ISH (memory barrier for ARMv7) appeared to be
correct based on online docs, but due to some endian-related shenanigans it
had to be byte-swapped to suit qemu; it appears INSN_DMB_MCR (memory
barrier for ARMv6) also should be byte swapped  (and this patch does so).
I have not checked for correctness of aarch64's barrier instruction.
-------------------------------
Please find submitted a patch for getdents (this system call stands for
"get directory entries", it is passed a file descriptor pointing to a
directory and returns a struct with info on the entries in that
directory.)  This patch is against qemu-2.10 series but continues to apply
cleanly on current as of April 15 2018.  If you are running a 32-bit binary
on 64-bit target current qemu will convert he getdents struct, but it will
NOT in the case of 64-bit binary on 32-bit host.  (In my case, I had
android SDK's "aapt" for x86-64 error out on 32-bit ARM without this patch,
and run fine with it.)  This patch simply replaces a "#if TARGET_ABI_BITS
== 32 && HOST_LONG_BITS == 64" with "#if TARGET_ABI_BITS != HOST_LONG_BITS".

Thanks!
*** tcg/arm/tcg-target.inc.c.orig	2018-04-04 15:28:50.000000000 -0500
--- tcg/arm/tcg-target.inc.c	2018-04-16 12:55:04.917518898 -0500
***************
*** 158,167 ****
      INSN_LDRD_REG  = 0x000000d0,
      INSN_STRD_IMM  = 0x004000f0,
      INSN_STRD_REG  = 0x000000f0,
  
!     INSN_DMB_ISH   = 0x5bf07ff5,
!     INSN_DMB_MCR   = 0xba0f07ee,
  
      /* Architected nop introduced in v6k.  */
      /* ??? This is an MSR (imm) 0,0,0 insn.  Anyone know if this
         also Just So Happened to do nothing on pre-v6k so that we
--- 158,167 ----
      INSN_LDRD_REG  = 0x000000d0,
      INSN_STRD_IMM  = 0x004000f0,
      INSN_STRD_REG  = 0x000000f0,
  
!     INSN_DMB_ISH   = 0xf57ff05b,
!     INSN_DMB_MCR   = 0xee070fba,
  
      /* Architected nop introduced in v6k.  */
      /* ??? This is an MSR (imm) 0,0,0 insn.  Anyone know if this
         also Just So Happened to do nothing on pre-v6k so that we
*** linux-user/syscall.c~	2017-03-04 10:31:14.000000000 -0600
--- linux-user/syscall.c	2017-03-07 17:08:24.615399116 -0600
***************
*** 9913,9921 ****
  #endif
  #ifdef TARGET_NR_getdents
      case TARGET_NR_getdents:
  #ifdef __NR_getdents
! #if TARGET_ABI_BITS == 32 && HOST_LONG_BITS == 64
          {
              struct target_dirent *target_dirp;
              struct linux_dirent *dirp;
              abi_long count = arg3;
--- 9913,9921 ----
  #endif
  #ifdef TARGET_NR_getdents
      case TARGET_NR_getdents:
  #ifdef __NR_getdents
! #if TARGET_ABI_BITS != HOST_LONG_BITS
          {
              struct target_dirent *target_dirp;
              struct linux_dirent *dirp;
              abi_long count = arg3;

Reply via email to