Author: pfg
Date: Tue Mar 26 20:17:08 2013
New Revision: 248752
URL: http://svnweb.freebsd.org/changeset/base/248752

Log:
  Dtrace: dtrace.c erroneously checks for memory alignment on amd64.
  
  Merge change from illumos:
  
  3511 dtrace.c erroneously checks for memory alignment on amd64
  
  Illumos Revision:     c93cc65
  
  Reference:
  https://www.illumos.org/issues/3511
  
  Obtained from:        Illumos
  MFC after:    3 weeks

Modified:
  
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress5.d
  head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c

Modified: 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress5.d
==============================================================================
--- 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress5.d
     Tue Mar 26 20:11:09 2013        (r248751)
+++ 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress5.d
     Tue Mar 26 20:17:08 2013        (r248752)
@@ -24,7 +24,9 @@
  * Use is subject to license terms.
  */
 
-#pragma ident  "%Z%%M% %I%     %E% SMI"
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
 
 /*
  * ASSERTION:
@@ -32,44 +34,51 @@
  * a runtime error.
  *
  * SECTION: Pointers and Arrays/Generic Pointers
- *
- * NOTES:
- * This test doesn't apply to x86; for the time being, we're working
- * around this with the preprocessor.
  */
 
 #pragma D option quiet
 
-int array[3];
-uintptr_t uptr;
+#if defined(__i386) || defined(__amd64)
+#define __x86 1
+#endif
+
+int array[2];
+char *ptr;
 int *p;
 int *q;
 int *r;
 
 BEGIN
 {
-#ifdef __i386
+       array[0] = 0x12345678;
+       array[1] = 0xabcdefff;
+
+       ptr = (char *) &array[0];
+
+       p = (int *) (ptr);
+       q = (int *) (ptr + 2);
+       r = (int *) (ptr + 3);
+
+       printf("*p: 0x%x\n", *p);
+       printf("*q: 0x%x\n", *q);
+       printf("*r: 0x%x\n", *r);
+
+       /*
+        * On x86, the above unaligned memory accesses are allowed and should
+        * not result in the ERROR probe firing.
+        */
+#ifdef __x86
        exit(1);
 #else
-       array[0] = 20;
-       array[1] = 40;
-       array[2] = 80;
-
-       uptr = (uintptr_t) &array[0];
-
-       p = (int *) (uptr);
-       q = (int *) (uptr + 2);
-       r = (int *) (uptr + 3);
-
-       printf("array[0]: %d\t*p: %d\n", array[0], *p);
-       printf("array[1]: %d\t*q: %d\n", array[1], *q);
-       printf("array[2]: %d\t*r: %d\n", array[2], *r);
-
        exit(0);
 #endif
 }
 
 ERROR
 {
+#ifdef __x86
+       exit(0);
+#else
        exit(1);
+#endif
 }

Modified: head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c        Tue Mar 
26 20:11:09 2013        (r248751)
+++ head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c        Tue Mar 
26 20:17:08 2013        (r248752)
@@ -443,7 +443,7 @@ static kmutex_t dtrace_errlock;
 #define        DTRACE_STORE(type, tomax, offset, what) \
        *((type *)((uintptr_t)(tomax) + (uintptr_t)offset)) = (type)(what);
 
-#ifndef __i386
+#ifndef __x86
 #define        DTRACE_ALIGNCHECK(addr, size, flags)                            
\
        if (addr & (size - 1)) {                                        \
                *flags |= CPU_DTRACE_BADALIGN;                          \
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to