Virtuozzo QEMU development (svt-core@virtuozzo.com)
 help / color / mirror / Atom feed
From: no-reply@sashiko.virtuozzo.com
To: andrey.zhadchenko@virtuozzo.com, "Denis V. Lunev" <den@openvz.org>
Cc: den@openvz.org, svt-core@virtuozzo.com
Subject: Re: [PATCH v3 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
Date: Thu, 29 Oct 2026 12:33:34 +0000	[thread overview]
Message-ID: <010701a187a6be34-2223c9d8-df88-40c5-b4b6-e74f4769315e-000000@eu-central-1.amazonses.com> (raw)
In-Reply-To: <20261029122527.365104-7-den@openvz.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] i386: x86_cpu_compat_kept_features() keeps SVM leaf bits after svm is host-filtered
--

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

i386: keep SVM leaf features without svm on vz types up to vz9.2.0 #PSBM-144630

This adds an x-svm-features-compat CPU property and enables it in
pc_vz_9_2_compat. Under KVM, requested SVM leaf features are kept when svm
is off, both against the feature dependency on svm and against the host
feature filter.

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

[ ... ]

> @@ -9138,6 +9145,10 @@ static uint64_t x86_cpu_compat_kept_features(X86CPU *cpu, FeatureWord w)
>          if (cpu->v_vmsave_vmload_compat && IS_AMD_CPU(env)) {
>              kept = CPUID_SVM_V_VMSAVE_VMLOAD;
>          }
> +        if (cpu->svm_features_compat &&
> +            !(env->features[FEAT_8000_0001_ECX] & CPUID_EXT3_SVM)) {
> +            kept = ~0ULL;
> +        }
>          break;
>      default:
>          break;

[Severity: Low]
Can this condition tell "svm=off was requested" apart from "svm=on was
requested but the host filtered it"?

x86_cpu_compat_kept_features() reads env->features[FEAT_8000_0001_ECX] when
it is called from x86_cpu_filter_features():

    uint64_t unavailable_features = requested_features & ~host_feat &
        ~x86_cpu_compat_kept_features(cpu, w);
    mark_unavailable_features(cpu, w, unavailable_features, prefix);

In the FeatureWord enum, FEAT_8000_0001_ECX comes before FEAT_SVM, so the
loop filters FEAT_8000_0001_ECX first. If the user requested svm=on, for
example through a host-model CPU, and the host lacks nested SVM, for
example kvm_amd nested=0, mark_unavailable_features() clears
CPUID_EXT3_SVM first.

When the loop then reaches FEAT_SVM, the check above sees the svm bit
already cleared and sets kept = ~0ULL. Every requested FEAT_SVM bit that
the host doesn't support is then neither cleared nor reported. This goes
beyond the stated "svm off" scope in the commit message.

The guest-visible CPUID looks unchanged, because cpu_x86_cpuid() returns
zeros for leaf 0x8000000a without svm. The svm bit is still reported as
unavailable, so enforce still fails. The xlevel adjustment happens in
x86_cpu_expand_features() before filtering. What does change is that npt,
nrip-save and the other SVM leaf features are no longer listed as filtered,
and env->features[FEAT_SVM] keeps unsupported bits.

Would it be better to record whether svm was requested off before
x86_cpu_filter_features() runs, or to check env->user_features, instead of
reading the already-filtered env->features value?

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

  reply	other threads:[~2026-10-29 12:33 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-29 12:25 [PATCH v3 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 12:25 ` [PATCH v3 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 12:27   ` no-reply
2026-10-29 12:25 ` [PATCH v3 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 12:29   ` no-reply
2026-10-29 12:25 ` [PATCH v3 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 12:29   ` no-reply
2026-10-29 12:25 ` [PATCH v3 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 12:30   ` no-reply
2026-10-29 12:25 ` [PATCH v3 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 12:30   ` no-reply
2026-10-29 12:25 ` [PATCH v3 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 12:33   ` no-reply [this message]
2026-10-29 13:30 ` [PATCH v3 hci-8.0/hci-8.1 0/6] i386: keep CPU features of guests from older nodes on vz machine types #VSTOR-152264 Andrey Drobyshev
2026-10-29 13:47   ` 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=010701a187a6be34-2223c9d8-df88-40c5-b4b6-e74f4769315e-000000@eu-central-1.amazonses.com \
    --to=no-reply@sashiko.virtuozzo.com \
    --cc=andrey.zhadchenko@virtuozzo.com \
    --cc=den@openvz.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox