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]
This commit is contained in:
Andrew Turner 2015-05-17 18:35:58 +00:00
parent afd1f4a7e3
commit b7112ead32
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=283034

View File

@ -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_ */