Re: [PATCH v6 6/8] KVM: nSVM: Use emulator bytes for synthesized nested #NPF
From: Jim Mattson
Date: Mon Sep 14 2026 - 17:36:13 EST
On Sat, Sep 12, 2026 at 11:44 PM Tina Zhang <zhang_wei@xxxxxxxxxxxxxx> wrote:
>
> Preserve the bytes used by the emulator when synthesizing a data #NPF.
> Reuse the fetch cache only when the fault is the current emulator
> exception, identified by fault == &ctxt->exception.
>
> Add an emulator accessor to copy cached instruction bytes, checking
> the RIP and cache bounds. These checks alone do not establish that
> the cache belongs to the current emulation.
>
> Write the cached bytes directly to VMCB02 and fetch any missing tail
> through the instruction-fetch helper. If the tail cannot be read,
> report only the bytes already available. For SEV guests, retain only
> the cached bytes because KVM cannot fetch plaintext guest instructions.
>
> Signed-off-by: Tina Zhang <zhang_wei@xxxxxxxxxxxxxx>
Reviewed-by: Jim Mattson <jmattson@xxxxxxxxx>