virt: Fix Xen Dom0 detection logic to no longer report as VM
authorRichard Neill <richard.neill@arm.com>
Wed, 2 Feb 2022 18:18:46 +0000 (18:18 +0000)
committerLennart Poettering <lennart@poettering.net>
Wed, 16 Feb 2022 17:05:28 +0000 (18:05 +0100)
commitea583ed5a366cf51b80bd363db95e828a25ec27e
treefdfc07f7b198a45daa413fa9d570ef2dcabb4977
parentbde335f21fc547163647513f4658d9a3fde1b8f9
virt: Fix Xen Dom0 detection logic to no longer report as VM

Fixes regression introduced in 599be274c13c503806c85073d7beb1a155ac27bd

Moving the Xen check before the CPUID check, in order to handle the case where
a Xen domain is nested within a hypervisor which can be detected by via the
CPUID check, had an unintended consequence of causing Dom0 to report as a Xen
VM when it is not nested.

This patch stops further checks once it has been determined that Dom0 is not
nested within another hypervisor, meaning that the non-nested case matches its
previous logic (where it does not report as a VM).

Also, tidy the conditionals for the Xen and UML checks by removing handling of
a VIRTUALIZATION_VM_OTHER result, which has no code path.

Fixes #22511
src/basic/virt.c