libxc/restore: Fix data auditing in handle_x86_pv_info()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 18 Dec 2019 20:17:42 +0000 (20:17 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 20 Dec 2019 12:11:29 +0000 (12:11 +0000)
commitaafae0e800e9936b9eb6566e5fcdbe823625a7d1
tree87aa09e203a9f8a5a313ad48b7562ed5ee33f76f
parent1430c5a8cad45d689b035255f3d7ca6a07ae02e4
libxc/restore: Fix data auditing in handle_x86_pv_info()

handle_x86_pv_info() has a subtle bug.  It uses an 'else if' chain with a
clause in the middle which doesn't exit unconditionally.  In practice, this
means that when restoring a 32bit PV guest, later sanity checks are skipped.

Rework the logic a little to be simpler.  There are exactly two valid
combinations of fields in X86_PV_INFO, so factor this out and check them all
in one go, before making adjustments to the current domain.

Once adjustments have been completed successfully, sanity check the result
against the X86_PV_INFO settings in one go, rather than piece-wise.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/libxc/xc_sr_restore_x86_pv.c