We can figure out whether SMT is enabled or not, by checking the
topology of the CPUs, as it is exposed in /sys.
This means the information is available also when we are running
in `--sysfs-only` mode.
Info about 2nd mitigation to L1TF are gathered in various ways.
Some are available under /sys, and hence should be checked when
we're invoked without parameters, and with `--sysfs-only`, while
they should be ignored when we are invoked with `--no-sysfs`.
Some others use other sources, and hence should be ignored if
we are invoked with `--sysfs-only`.
Checking whether or not EPT is enabled, happens via /sys.
We should therefore also make sure that we do that when being
invoked with no options, and with `--sysfs-only`, and that we
don't when invoked with `--no-sysfs`.
We are now able to figure out whether or not we are running an hypervisor
(at least potentially) via /sys, so let's actually use that information.
This commit makes sure that, both when running with no options and with
`--sysfs-only`, finding 'VMX' inside the L1TF sysfs vulnerability file
is enough for calling the system a virtualization host.
If we can look in `/sys/devices/system/cpu/vulnerabilities/l1tf`, and
we find 'VMX' in it, it means we can run KVM guests, and hence we are
running as an hypervisor.
Right now, on a system with VMX enabled, with KVM guests running, and
booted with "l1tf=off", I see this:
`
CVE-2018-3646 aka 'Foreshadow-NG (VMM), L1 terminal fault'
* Information from the /sys interface: VMX: vulnerable
* This system is a host running a hypervisor: NO
... ... ...
* L1D flush enabled: NO
> STATUS: NOT VULNERABLE (this system is not running a hypervisor)
`
Which is wrong.
In fact, as said, guests are running, so we are an hypervisor,
and with "l1tf=off" (and hence L1D flush disabled) we are vulnerable.
We don't use $msg and $status.
Also, by always initializing l1d_mode, we fix the following "crash",
when running with `--sysfs-only`:
`
CVE-2018-3646 aka 'Foreshadow-NG (VMM), L1 terminal fault'
* Information from the /sys interface: VMX: vulnerable
./spectre-meltdown-checker.sh: line 3945: [: : integer expression expected
`