cpus: Proper range-checking for -icount shift=N
commit9ec374a781c34daa6e70fcd885ef30e090cc2384
authorMarkus Armbruster <armbru@redhat.com>
Wed, 22 Apr 2020 13:07:09 +0000 (22 15:07 +0200)
committerMarkus Armbruster <armbru@redhat.com>
Wed, 29 Apr 2020 06:01:52 +0000 (29 08:01 +0200)
treeab9586712a191596b64f3dbdc07816cd7e1b3f4b
parentabc9bf69a66a11499a801ff545b8fe7adbb3a04c
cpus: Proper range-checking for -icount shift=N

timers_state.icount_time_shift must be in [0,63] to avoid undefined
behavior when shifting by it, e.g. in cpu_icount_to_ns().
icount_adjust() clamps it to [0,MAX_ICOUNT_SHIFT], with
MAX_ICOUNT_SHIFT = 10.  configure_icount() doesn't.  Fix that.

Fixes: a8bfac37085c3372366d722f131a7e18d664ee4d
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20200422130719.28225-5-armbru@redhat.com>
cpus.c