From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52074) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCM6B-00081A-Ko for qemu-devel@nongnu.org; Wed, 08 Nov 2017 03:52:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eCM66-00018n-UQ for qemu-devel@nongnu.org; Wed, 08 Nov 2017 03:52:35 -0500 Sender: Richard Henderson References: <20171107165226.22546-1-alex.bennee@linaro.org> <87r2taq66h.fsf@linaro.org> From: Richard Henderson Message-ID: Date: Wed, 8 Nov 2017 09:52:22 +0100 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] accel/tcg/translate-all: expand cpu_restore_state retaddr check List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell , =?UTF-8?Q?Alex_Benn=c3=a9e?= Cc: QEMU Developers , qemu-arm , Paolo Bonzini , Peter Crosthwaite On 11/07/2017 07:53 PM, Peter Maydell wrote: >> Then why call cpu_restore_state at all? We should be consistent as there >> are plenty of places that do things like: >> >> if (pc) { >> /* now we have a real cpu fault */ >> cpu_restore_state(cs, pc); >> } >> >> I'm happy to make a 0 retaddr officially valid and actually document it >> in exec-all.h. It's not like most callers even bother checking the >> return code. This is exactly the discussion that we had last time, and we did just that. > Hmm, there's more places than I expected that do that "don't call > if 0" check than I thought. Overall it seems better to me to officially > allow the zero, rather than having lots of callsites that all have > to remember to check. ... what we didn't do is go through and change all of the call sites to remove the check for zero. > Incidentally if retaddr is zero then > (retaddr < (uintptr_t) tcg_init_ctx.code_gen_buffer) > is always true and you don't need to explicitly check for zero, though > it might be clearer to do so if we think we might change the rest > of the condition in future. Indeed, I was thinking retaddr - code_gen_buffer < code_gen_buffer_size which works well with unsigned arithmetic. And a large comment re zero. r~