All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: sashiko-reviews@lists.linux.dev,
	Sean Christopherson <seanjc@google.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH 4/4] KVM: selftests: Check VMPTRLD with active eVMCS
Date: Mon, 17 Aug 2026 13:26:01 +0200	[thread overview]
Message-ID: <87lda5kmye.fsf@redhat.com> (raw)
In-Reply-To: <20260814163105.BDEC31F000E9@smtp.kernel.org>

sashiko-bot@kernel.org writes:

> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] The hardcoded `VMPTRLD_INSN_SIZE` of 5 bytes is brittle
> because `vmptrld` is executed using an inline assembly memory operand
> constraint (`"m"`), which results in a variable-sized instruction
> depending on compiler optimizations and register allocation.

True that, but afair we don't currently have an instruction decoder in
selftests. I see three ways to move forward:

- Calculate the size of the instruction with two labels, something like
  (untested):

    static inline int __vmptrld(u64 vmcs_pa, int *insn_size)
    {
            u8 ret;

            __asm__ __volatile__ ("movl $(2f-1f), %[size];"
                                  "1: vmptrld %[pa]; 2:"
                                  "setna %[ret]"
                    : [ret]"=rm"(ret), [size]"=m"(*insn_size)
                    : [pa]"m"(vmcs_pa)
                    : "cc", "memory");

            return ret;
    }

  and use insn_size in the tests.

- Stuf __vmptrld() with NOPs after vmptrld and keep the constant jump,
  just make it loner (e.g. 10 bytes should realistically be enough).

- Make peace with the fragility (it's just a selftest after all) and
  leave a comment in vmptrld() that changing the asm there make break
  the assumption.

Any preferences? Personally, I'm feeling adventurous and can go with the
first one - calculating the exact size with labels.

-- 
Vitaly


  reply	other threads:[~2026-08-17 11:26 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-14 16:22 [PATCH 0/4] KVM: nVMX: Adjust VMPTRLD/VMPTRST behavior with active eVMCS Vitaly Kuznetsov
2026-08-14 16:22 ` [PATCH 1/4] KVM: nVMX: Make VMPTRLD result in #UD when eVMCS is used Vitaly Kuznetsov
2026-08-14 16:31   ` sashiko-bot
2026-08-14 16:43     ` Sean Christopherson
2026-08-14 16:22 ` [PATCH 2/4] KVM: nVMX: Make VMPTRST return eVMCS GPA when it " Vitaly Kuznetsov
2026-08-14 16:32   ` sashiko-bot
2026-08-14 16:44     ` Sean Christopherson
2026-08-14 16:22 ` [PATCH 3/4] KVM: selftests: Adapt to the updated VMPTRST behavior when eVMCS " Vitaly Kuznetsov
2026-08-14 16:31   ` sashiko-bot
2026-08-14 16:22 ` [PATCH 4/4] KVM: selftests: Check VMPTRLD with active eVMCS Vitaly Kuznetsov
2026-08-14 16:31   ` sashiko-bot
2026-08-17 11:26     ` Vitaly Kuznetsov [this message]
2026-08-17 17:06       ` Sean Christopherson

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=87lda5kmye.fsf@redhat.com \
    --to=vkuznets@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=seanjc@google.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.