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)
committerLuca Boccassi <luca.boccassi@gmail.com>
Tue, 22 Feb 2022 21:47:38 +0000 (21:47 +0000)
commit160eeab224e1f37acaf5b65bc97227c2d15cb4d2
treebf5b7fe669c3c9572dc2aa955c312814b6b8b54d
parente69b2a3a69d472e887633162111ed2a45f317eb9
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

(cherry picked from commit ea583ed5a366cf51b80bd363db95e828a25ec27e)
src/basic/virt.c