From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58496) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YuypZ-00027O-Hd for qemu-devel@nongnu.org; Wed, 20 May 2015 03:54:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YuypY-0000b4-MY for qemu-devel@nongnu.org; Wed, 20 May 2015 03:54:21 -0400 Date: Wed, 20 May 2015 09:54:10 +0200 From: Kevin Wolf Message-ID: <20150520075410.GA4917@noname.redhat.com> References: <1432049762-2184-1-git-send-email-kwolf@redhat.com> <1432049762-2184-4-git-send-email-kwolf@redhat.com> <555BA2A6.5090602@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] [PATCH 3/8] fdc: Introduce fdctrl->phase List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: John Snow , QEMU Developers , qemu-block@nongnu.org Am 19.05.2015 um 22:57 hat Peter Maydell geschrieben: > On 19 May 2015 at 21:52, John Snow wrote: > > Hmm, I think this is not purely derived state because the flags are not > > necessarily sufficient for regenerating that state. > > Yeah, if there's genuinely an underlying state machine that's > not completely visible in registers you need to actually model it. > You should probably then model the register bits by calculating > them from the state rather than by changing them as you go along > in parallel with moving the state machine around. I think the combination of registers is actually enough to reconstruct what state we're in, so it is derived (otherwise I would have fixed a bug that I'm not aware of). Adding logic to derive it in a post-load handler should be good enough. The reason why I want to have it explicit anyway is that having the information spread across multiple registers is non-obvious and error-prone. Before this eries, most places only check some bits instead of the full combination. And they are correct in the sense that some states are never expected to happen in that specific place - but if it happens anyway (i.e. there is a bug) without the patches something undefined happens, whereas with the patches we catch it. And then there's the readability of the code, too, of course. Kevin