From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42489) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WUxUq-0006rk-R8 for qemu-devel@nongnu.org; Tue, 01 Apr 2014 08:08:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WUxUm-00054h-Dx for qemu-devel@nongnu.org; Tue, 01 Apr 2014 08:08:52 -0400 Received: from static.88-198-71-155.clients.your-server.de ([88.198.71.155]:44199 helo=socrates.bennee.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WUxUm-00054Z-7Q for qemu-devel@nongnu.org; Tue, 01 Apr 2014 08:08:48 -0400 References: <1396052834-26834-1-git-send-email-rth@twiddle.net> <1396052834-26834-2-git-send-email-rth@twiddle.net> From: Alex =?utf-8?Q?Benn=C3=A9e?= In-reply-to: <1396052834-26834-2-git-send-email-rth@twiddle.net> Date: Tue, 01 Apr 2014 13:09:17 +0100 Message-ID: <87mwg5s13m.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH 1/8] exec-all.h: Use stl_p to avoid undefinedbehaviour patching x86 jumpss List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Richard Henderson Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org, aurelien@aurel32.net Richard Henderson writes: > From: Peter Maydell > > The code which patches x86 jump instructions assumes it can do an > unaligned write of a uint32_t. This is actually safe on x86, but it's > still undefined behaviour. We have infrastructure for doing efficient > unaligned accesses which doesn't engage in undefined behaviour, so > use it. > > This is technically fractionally less efficient, at least with gcc 4.6; > instead of one instruction: > 7b2: 89 3e mov %edi,(%rsi) > we get an extra spurious store to the stack slot: > 7b2: 89 7c 24 64 mov %edi,0x64(%rsp) > 7b6: 89 3e mov %edi,(%rsi) Ehh? Is that gcc just being silly and putting parameters for an inline on the stack frame? > > Signed-off-by: Peter Maydell > Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée -- Alex Bennée