am 7f92fce4: (-s ours) am a0f5038c: resolved conflicts for merge of 02459827 to stage-aosp-master

* commit '7f92fce427043d9904c9e52d21bc548be1d78e3c':
  Add missing ioctls used by NFC.
diff --git a/main/Android.mk b/main/Android.mk
index 744b6ed..08db43c 100644
--- a/main/Android.mk
+++ b/main/Android.mk
@@ -14,6 +14,8 @@
 
 LOCAL_PATH:= $(call my-dir)
 
+ANDROID_HARDWARE := ANDROID_HARDWARE_generic
+
 ifneq ($(filter arm x86,$(TARGET_ARCH)),)
 
 common_cflags := \
@@ -26,8 +28,7 @@
 	-DVGPV_$(TARGET_ARCH)_linux_android=1 \
 	-DVG_PLATFORM=\"$(TARGET_ARCH)-linux\" \
 	-DVG_LIBDIR=\"/system/lib/valgrind\" \
-	-DANDROID_SYMBOLS_DIR=\"/data/local/symbols\" \
-	-DANDROID_HARDWARE_nexus_s
+	-DANDROID_SYMBOLS_DIR=\"/data/local/symbols\"
 
 common_includes := \
 	external/valgrind/main \
@@ -39,10 +40,20 @@
 
 ifeq ($(TARGET_ARCH),arm)
 tool_ldflags := -static -Wl,--build-id=none,-Ttext=0x38000000 -nodefaultlibs -nostartfiles -u _start -e_start
+
+# ioctl/syscall wrappers are device dependent
+ifeq ($(TARGET_BOOTLOADER_BOARD_NAME),manta)
+ANDROID_HARDWARE := ANDROID_HARDWARE_nexus_10
+else ifeq ($(TARGET_BOOTLOADER_BOARD_NAME),grouper)
+ANDROID_HARDWARE := ANDROID_HARDWARE_nexus_7
+endif
+
 else
 tool_ldflags := -static -Wl,-Ttext=0x38000000 -nodefaultlibs -nostartfiles -u _start -e_start
 endif
 
+common_cflags += -D$(ANDROID_HARDWARE)
+
 preload_ldflags := -nodefaultlibs -Wl,-z,interpose,-z,initfirst
 # Remove this when the all toolchains are GCC 4.4
 ifeq ($(TARGET_ARCH),arm)
@@ -245,7 +256,9 @@
 
 LOCAL_LDFLAGS := $(vex_ldflags)
 
+# TODO: split asflags out from cflags.
 LOCAL_CFLAGS := $(common_cflags)
+LOCAL_ASFLAGS := $(common_cflags)
 
 include $(BUILD_STATIC_LIBRARY)
 
diff --git a/main/VEX/priv/guest_arm_toIR.c b/main/VEX/priv/guest_arm_toIR.c
index 220c50f..3da677e 100644
--- a/main/VEX/priv/guest_arm_toIR.c
+++ b/main/VEX/priv/guest_arm_toIR.c
@@ -18802,6 +18802,30 @@
       }
    }
 
+   /* ------------------- (T1) SMMLA{R} ------------------ */
+   if (INSN0(15,7) == BITS9(1,1,1,1,1,0,1,1,0)
+       && INSN0(6,4) == BITS3(1,0,1)
+       && INSN1(7,5) == BITS3(0,0,0)) {
+      UInt bitR = INSN1(4,4);
+      UInt rA = INSN1(15,12);
+      UInt rD = INSN1(11,8);
+      UInt rM = INSN1(3,0);
+      UInt rN = INSN0(3,0);
+      if (!isBadRegT(rD) && !isBadRegT(rN) && !isBadRegT(rM) && (rA != 13)) {
+         IRExpr* res
+         = unop(Iop_64HIto32,
+                binop(Iop_Add64,
+                      binop(Iop_Add64,
+                            binop(Iop_32HLto64, getIRegT(rA), mkU32(0)),
+                            binop(Iop_MullS32, getIRegT(rN), getIRegT(rM))),
+                      mkU64(bitR ? 0x80000000ULL : 0ULL)));
+         putIRegT(rD, res, condT);
+         DIP("smmla%s r%u, r%u, r%u, r%u\n",
+             bitR ? "r" : "", rD, rN, rM, rA);
+         goto decode_success;
+      }
+   }
+
    /* ----------------------------------------------------------- */
    /* -- VFP (CP 10, CP 11) instructions (in Thumb mode)       -- */
    /* ----------------------------------------------------------- */
diff --git a/main/coregrind/m_syswrap/syswrap-linux.c b/main/coregrind/m_syswrap/syswrap-linux.c
index fbee4f8..526ff0c 100644
--- a/main/coregrind/m_syswrap/syswrap-linux.c
+++ b/main/coregrind/m_syswrap/syswrap-linux.c
@@ -4299,14 +4299,11 @@
    /* undocumented ioctl ids noted on the device */
    case 0x4d07:
    case 0x6101:
-   case 0xfa01: /* used by NFC */
-   case 0xfa05: /* used by NFC */
       return;
 #  elif defined(ANDROID_HARDWARE_nexus_7)
    /* undocumented ioctl ids noted on the device */
    case 0x4e04:
    case 0x7231:
-   case 0x4004e901: /* used by NFC */
       return;
 #  endif
 
@@ -4317,6 +4314,18 @@
       break;
    }
 
+
+#  if defined(ANDROID_HARDWARE_nexus_10)
+
+   /* undocumented ioctl ids noted on the device */
+   if (ARG2 >= 0xc0108000 && ARG2 <= 0xc1e8820b && ARG3 != 0) {
+       int size = (ARG2 >> 16) & 0x3fff;
+       PRE_MEM_WRITE("ioctl(GL_UNDOCUMENTED)", (Addr)ARG3,  size);
+       return;
+   }
+
+#  endif
+
    // We now handle those that do look at ARG3 (and unknown ones fall into
    // this category).  Nb: some of these may well belong in the
    // doesn't-use-ARG3 switch above.
@@ -5520,6 +5529,7 @@
            PRE_FIELD_WRITE("ioctl(BINDER_VERSION)", bv->protocol_version);
        }
        break;
+
 #  endif /* defined(VGPV_*_linux_android) */
 
    case VKI_HCIINQUIRY:
@@ -5542,6 +5552,9 @@
    case VKI_KVM_RUN:
       break;
 
+   case VKI_EVIOCSSUSPENDBLOCK:
+      break;
+
    default:
       /* EVIOC* are variable length and return size written on success */
       switch (ARG2 & ~(_VKI_IOC_SIZEMASK << _VKI_IOC_SIZESHIFT)) {
@@ -5649,6 +5662,16 @@
    /* END generic/emulator specific ioctls */
 
 
+#  elif defined(ANDROID_HARDWARE_nexus_10)
+
+   /* undocumented ioctl ids noted on the device */
+   if (ARG2 >= 0xc0108000 && ARG2 <= 0xc1e8820b && ARG3 != 0) {
+      int size = (ARG2 >> 16) & 0x3fff;
+      POST_MEM_WRITE(ARG3, size);
+   }
+
+#  elif defined(ANDROID_HARDWARE_nexus_7)
+
 #  else /* no ANDROID_HARDWARE_anything defined */
 
 #   warning ""
@@ -5657,6 +5680,8 @@
 #   warning "building for.  Currently known values are"
 #   warning ""
 #   warning "   ANDROID_HARDWARE_nexus_s       Samsung Nexus S"
+#   warning "   ANDROID_HARDWARE_nexus_10      Samsung Nexus 10"
+#   warning "   ANDROID_HARDWARE_nexus_7       ASUS Nexus 7"
 #   warning "   ANDROID_HARDWARE_generic       Generic device (eg, Pandaboard)"
 #   warning "   ANDROID_HARDWARE_emulator      x86 or arm emulator"
 #   warning ""
@@ -6539,6 +6564,10 @@
    case VKI_KVM_S390_INITIAL_RESET:
       break;
 
+   case VKI_EVIOCSSUSPENDBLOCK:
+      POST_MEM_WRITE( ARG3, sizeof(int) );
+      break;
+
    default:
       /* EVIOC* are variable length and return size written on success */
       switch (ARG2 & ~(_VKI_IOC_SIZEMASK << _VKI_IOC_SIZESHIFT)) {
diff --git a/main/include/vki/vki-linux.h b/main/include/vki/vki-linux.h
index c18195e..8cefd8f 100644
--- a/main/include/vki/vki-linux.h
+++ b/main/include/vki/vki-linux.h
@@ -2813,6 +2813,8 @@
 
 #define VKI_EVIOCGBIT(ev,len)	_VKI_IOC(_VKI_IOC_READ, 'E', 0x20 + ev, len)	/* get event bits */
 
+#define VKI_EVIOCSSUSPENDBLOCK	_VKI_IOW('E', 0x91, int)	/* set suspend block enable */
+
 /*
  * Event types
  */