Re: [PATCH 1/2] KVM: VMX: Drop obsolete branch hint prefixes from inline asm
From: David Laight
Date: Wed Feb 11 2026 - 08:44:41 EST
On Wed, 11 Feb 2026 10:57:31 +0000
Andrew Cooper <andrew.cooper3@xxxxxxxxxx> wrote:
> > Remove explicit branch hint prefixes (.byte 0x2e / 0x3e) from VMX
> > inline assembly sequences.
> >
> > These prefixes (CS/DS segment overrides used as branch hints on
> > very old x86 CPUs) have been ignored by modern processors for a
> > long time. Keeping them provides no measurable benefit and only
> > enlarges the generated code.
>
> It's actually worse than this.
>
> The branch-taken hint has new meaning in Lion Cove cores and later,
> along with a warning saying "performance penalty for misuse".
>
> i.e. "only insert this prefix after profiling".
Don't they really have much the same meaning as before?
Perhaps the branch prediction logic is ignored (which would make
getting then wrong very bad).
But here (and a few other places) the branch really is 'never taken',
so perhaps the branch hints should have been removed 20 years ago
and now is the time to add them back?
Of course, the branch-hint can only have an effect when the branch
prediction logic gets to see the branch.
The initial instruction prefetch (etc) is done without regard to
the contents of the memory being read - so initially all branches
are effectively predicted 'not-taken'.
(I got the impression that some AMD cpu 'attached' some of the branch
prediction info to the cache-line - and would use it when the cache
line was re-used for an entirely different address. Hence the issues
where non-branch instructions would be predicted as branches.)
David
>
> ~Andrew
>