All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
From: no-reply@sashiko.virtuozzo.com
To: andrey.zhadchenko@virtuozzo.com, "Denis V. Lunev" <den@openvz.org>
Cc: khorenko@virtuozzo.com, den@openvz.org, svt-core@virtuozzo.com
Subject: Re: [PATCH v2 hci-8.0/hci-8.1 2/6] i386: keep hle and rtm on Virtuozzo machine types up to vz9.2.0 #PSBM-149402
Date: Thu, 29 Oct 2026 11:39:01 +0000	[thread overview]
Message-ID: <010701a18774cf0a-bfb67a8e-8e72-416d-90c0-aea0e3ba023b-000000@eu-central-1.amazonses.com> (raw)
In-Reply-To: <20261029113436.93521-3-den@openvz.org>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] i386: x-tsx-compat advertises HLE/RTM on cold boot even when host TSX is off
- [Low] i386: x-tsx-compat keeps HLE/RTM on Haswell hosts without checking microcode
--

commit dbdfc9450553c67e1ff2b80314cb5e7632457006
Author: Denis V. Lunev <den@openvz.org>

i386: keep hle and rtm on Virtuozzo machine types up to vz9.2.0 #PSBM-149402

This commit adds an x-tsx-compat CPU property. When it is on, hle and rtm
requested by an Intel CPU model are not filtered against host support under
KVM. The property is enabled through pc_vz_9_2_compat for vz9.2.0 and older
vz machine types, so that a guest that booted with TSX can still be migrated
to a host where TSX is disabled.

> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c

[ ... ]

> +GlobalProperty pc_vz_9_2_compat[] = {
> +    { TYPE_X86_CPU, "x-tsx-compat", "on" },
> +};
> +const size_t pc_vz_9_2_compat_len = G_N_ELEMENTS(pc_vz_9_2_compat);

[Severity: Medium]
Because this is a machine type default, it applies to cold boot as well as
to incoming migration. Can this make a freshly started guest see hle and
rtm in CPUID on a host where TSX is off?

Where the host disables TSX through TSX_CTRL (tsx=off or the TAA default),
XBEGIN raises #UD, as the commit message says. A guest that trusts CPUID,
for example through lock elision or a TSX-aware library, could then take
SIGILL or a guest kernel fault.

Previously a fresh guest on such a host booted with these bits filtered.
For a cold boot this looks like new exposure. The statement that "the cold
boot adds no new failure mode" only seems to hold for guests that already
ran with the bits on another node.

Would it be possible to limit the behaviour to incoming migration? Or could
the code check how the host disabled TSX?

> diff --git a/target/i386/cpu.c b/target/i386/cpu.c
> --- a/target/i386/cpu.c
> +++ b/target/i386/cpu.c

[ ... ]

> +static uint64_t x86_cpu_compat_kept_features(X86CPU *cpu, FeatureWord w)
> +{

[ ... ]

> +    switch (w) {
> +    case FEAT_7_0_EBX:
> +        if (cpu->tsx_compat && IS_INTEL_CPU(env)) {
> +            kept = CPUID_7_0_EBX_HLE | CPUID_7_0_EBX_RTM;
> +        }
> +        break;

[Severity: Medium]
The only conditions here are kvm_enabled(), tsx_compat and IS_INTEL_CPU().
Nothing checks for incoming migration or for the way the host disabled TSX.

x86_cpu_filter_features() subtracts this result from unavailable_features,
so hle and rtm stay in env->features[FEAT_7_0_EBX]. They are not recorded
through mark_unavailable_features(), so check and enforce stay silent.

The existing masking in kvm_arch_get_supported_cpuid() only runs when host
TSX is broken (the host_tsx_broken() branch that clears RTM and HLE). It
affects the supported-CPUID query and not the guest CPUID. Is anything in
kvm.c expected to mask these bits again before they reach KVM_SET_CPUID2?

I could not confirm how the kernel handles these bits in KVM_SET_CPUID2.

[Severity: Low]
There is a second question about Haswell hosts with the TSX erratum. In
kvm_arch_get_supported_cpuid(), host_tsx_broken() hides RTM and HLE. It
looks only at family, model and stepping, and it reads no microcode
revision.

With x-tsx-compat on, x86_cpu_compat_kept_features() returns HLE and RTM
for any Intel guest, regardless of host state. How does the code tell
"erratum microcode has disabled TSX" apart from "erratum part with TSX still
active"?

The commit message says the "erratum microcode disables TSX" on these parts.
Is there code or documentation that backs up that assumption? Without it, a
guest could see TSX enabled on silicon with the known erratum, and no
check/enforce warning would be printed.

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261029113436.93521-1-den@openvz.org?part=2

  reply	other threads:[~2026-10-29 11:39 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-29 11:34 [PATCH v2 hci-8.0/hci-8.1 0/6] i386: keep CPU features of guests from older nodes on vz machine types #VSTOR-152264 Denis V. Lunev
2026-10-29 11:34 ` [PATCH v2 hci-8.0/hci-8.1 1/6] i386/pc: raise the limit of compat arrays per Virtuozzo machine type to four #VSTOR-152264 Denis V. Lunev
2026-10-29 11:36   ` no-reply
2026-10-29 11:53   ` Andrey Drobyshev
2026-10-29 11:34 ` [PATCH v2 hci-8.0/hci-8.1 2/6] i386: keep hle and rtm on Virtuozzo machine types up to vz9.2.0 #PSBM-149402 Denis V. Lunev
2026-10-29 11:39   ` no-reply [this message]
2026-10-29 11:53   ` Andrey Drobyshev
2026-10-29 11:34 ` [PATCH v2 hci-8.0/hci-8.1 3/6] i386: keep spec-ctrl for AMD guests on vz machine types up to vz9.2.0 #VSTOR-151770 Denis V. Lunev
2026-10-29 11:39   ` no-reply
2026-10-29 11:53   ` Andrey Drobyshev
2026-10-29 11:34 ` [PATCH v2 hci-8.0/hci-8.1 4/6] i386: keep bus-lock-detect for AMD guests on vz machine types up to vz9.2.0 #VSTOR-152291 Denis V. Lunev
2026-10-29 11:39   ` no-reply
2026-10-29 11:53   ` Andrey Drobyshev
2026-10-29 11:34 ` [PATCH v2 hci-8.0/hci-8.1 5/6] i386: keep v-vmsave-vmload for nested AMD guests on vz types up to vz9.2.0 #VSTOR-152264 Denis V. Lunev
2026-10-29 11:39   ` no-reply
2026-10-29 11:53   ` Andrey Drobyshev
2026-10-29 11:34 ` [PATCH v2 hci-8.0/hci-8.1 6/6] i386: keep SVM leaf features without svm on vz types up to vz9.2.0 #PSBM-144630 Denis V. Lunev
2026-10-29 11:41   ` no-reply
2026-10-29 11:53   ` Andrey Drobyshev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=010701a18774cf0a-bfb67a8e-8e72-416d-90c0-aea0e3ba023b-000000@eu-central-1.amazonses.com \
    --to=no-reply@sashiko.virtuozzo.com \
    --cc=andrey.zhadchenko@virtuozzo.com \
    --cc=den@openvz.org \
    --cc=khorenko@virtuozzo.com \
    --cc=svt-core@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.