svn commit: r283034 - head/sys/arm/include

Andrew Turner andrew at FreeBSD.org
Sun May 17 18:35:59 UTC 2015


Author: andrew
Date: Sun May 17 18:35:58 2015
New Revision: 283034
URL: https://svnweb.freebsd.org/changeset/base/283034

Log:
  Clean up struct syscall_args:
   1. Align to a 64-bit address so 64-bit data will be correctly aligned.
   2. Add a comment explaining why.
   3. Remove an unneeded value from the struct.
  
  This fixes an issue where the struct may not be correctly aligned on the
  stack in the syscall function. This may lead to accesing a 64-bit value
  at a non 64-bit. This will raise an exception and panic the kernel.
  
  We have been lucky where on arm and armv6 both clang and gcc correctly
  align the data, even without us asking to, however, on armeb with clang to
  not be the case. This tells the compiler we really do need this to be
  aligned.
  
  Reported and tested by:	jmg (on armeb with clang)
  MFC after:	1 Week [1, 2]

Modified:
  head/sys/arm/include/proc.h

Modified: head/sys/arm/include/proc.h
==============================================================================
--- head/sys/arm/include/proc.h	Sun May 17 17:03:37 2015	(r283033)
+++ head/sys/arm/include/proc.h	Sun May 17 18:35:58 2015	(r283034)
@@ -68,15 +68,20 @@ struct mdproc {
 #endif
 
 #define MAXARGS	8
+/*
+ * This holds the syscall state for a single system call.
+ * As some syscall arguments may be 64-bit aligned we need to ensure the
+ * args value is 64-bit aligned. The ABI will then ensure any 64-bit
+ * arguments are already correctly aligned, even if they were passed in
+ * via registers, we just need to make sure we copy them to an algned
+ * buffer.
+ */
 struct syscall_args {
 	u_int code;
 	struct sysent *callp;
 	register_t args[MAXARGS];
 	int narg;
 	u_int nap;
-#ifndef __ARM_EABI__
-	u_int32_t insn;
-#endif
-};
+} __aligned(8);
 
 #endif /* !_MACHINE_PROC_H_ */


More information about the svn-src-head mailing list