Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Tina Zhang" <zhang_wei@open-hieco.net>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v4 1/9] KVM: x86: Add helper to provide intercept linear addresses
Date: Wed, 19 Aug 2026 06:10:45 +0000	[thread overview]
Message-ID: <20260819061045.D47861F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <3e4406c2c7507e6a34433438271decd47dca22e6.1787116250.git.zhang_wei@open-hieco.net>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] The newly added `intercept_linear_addr` field is calculated but never consumed by architecture-specific intercept handlers, rendering the logic dead code.
- [Medium] The calculated linear address in `get_intercept_linear_addr()` is not untagged, violating architectural specifications when LAM/UAI is active.
--

--- Patch [1]: [PATCH v4 1/9] KVM: x86: Add helper to provide intercept linear addresses ---
commit bde7560cfe988f666acaf2bb0b4fbe6285414375
Author: Tina Zhang <zhang_wei@open-hieco.net>

KVM: x86: Add helper to provide intercept linear addresses

This commit adds a helper get_intercept_linear_addr() to compute the linear
address for intercepts like INVLPG, and passes this address through
x86_instruction_info so intercept handlers can use it directly.

> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
> index 8071b372d233e..a0e57b64cadd4 100644
> --- a/arch/x86/kvm/emulate.c
> +++ b/arch/x86/kvm/emulate.c
[ ... ]
> @@ -410,6 +410,26 @@ static int em_salc(struct x86_emulate_ctxt *ctxt)
[ ... ]
> +static u64 get_intercept_linear_addr(struct x86_emulate_ctxt *ctxt,
> +				     enum x86_intercept intercept)
> +{
> +	u64 la;
> +
> +	if (intercept != x86_intercept_invlpg)
> +		return 0;
> +
> +	la = seg_base(ctxt, ctxt->src.addr.mem.seg) + ctxt->src.addr.mem.ea;
> +	return ctxt->mode == X86EMUL_MODE_PROT64 ? la : (u32)la;

[Severity: Medium]
Should this address be untagged before being returned in 64-bit mode?

According to the Intel SDM and AMD APM, VM exits reporting a linear address
like INVLPG must report the address after masking tag bits if Linear Address
Masking (LAM) or Upper Address Ignore (UAI) is active.

Would it be necessary to pass this through ctxt->ops->get_untagged_addr()
here to ensure the resulting address is architecturally compliant?

> +}
> +
>  static int emulator_check_intercept(struct x86_emulate_ctxt *ctxt,
>  				    enum x86_intercept intercept,
>  				    enum x86_intercept_stage stage)
> @@ -427,6 +447,7 @@ static int emulator_check_intercept(struct x86_emulate_ctxt *ctxt,
>  		.src_type   = ctxt->src.type,
>  		.dst_type   = ctxt->dst.type,
>  		.ad_bytes   = ctxt->ad_bytes,
> +		.intercept_linear_addr = get_intercept_linear_addr(ctxt, intercept),

[Severity: Medium]
Is this new field actually consumed by the architecture-specific handlers?

Looking at svm_check_intercept() and vmx_check_intercept(), it doesn't
appear that either handler reads the intercept_linear_addr field from
x86_instruction_info.

If this field remains unused, does the original issue with nested
hypervisors receiving an incorrect INVLPG address remain unfixed?

>  		.rip	    = ctxt->eip,
>  		.next_rip   = ctxt->_eip,
>  	};

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1787116250.git.zhang_wei@open-hieco.net?part=1

  reply	other threads:[~2026-08-19  6:10 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-19  5:51 [PATCH v4 0/9] KVM: nSVM: Enable DecodeAssists for nested guests Tina Zhang
2026-08-19  5:51 ` [PATCH v4 1/9] KVM: x86: Add helper to provide intercept linear addresses Tina Zhang
2026-08-19  6:10   ` sashiko-bot [this message]
2026-08-19  5:51 ` [PATCH v4 2/9] KVM: nSVM: Synthesize DecodeAssists EXITINFO for emulated intercepts Tina Zhang
2026-08-19  6:05   ` sashiko-bot
2026-08-19  5:51 ` [PATCH v4 3/9] KVM: nSVM: Track hardware-provided instruction bytes Tina Zhang
2026-08-19  6:05   ` sashiko-bot
2026-08-19  5:51 ` [PATCH v4 4/9] KVM: nSVM: Propagate hardware DecodeAssist bytes to VMCB12 Tina Zhang
2026-08-19  6:11   ` sashiko-bot
2026-08-19  5:51 ` [PATCH v4 5/9] KVM: x86: Track emulator-originated nested #PF VM-Exits Tina Zhang
2026-08-19  6:11   ` sashiko-bot
2026-08-19  5:51 ` [PATCH v4 6/9] KVM: nSVM: Use emulator bytes for synthesized nested #NPF/#PF Tina Zhang
2026-08-19  5:51 ` [PATCH v4 7/9] KVM: nSVM: Fetch missing DecodeAssist bytes for synthesized #NPF/#PF Tina Zhang
2026-08-19  5:51 ` [PATCH v4 8/9] KVM: nSVM: Advertise DecodeAssists to L1 Tina Zhang
2026-08-19  5:51 ` [PATCH v4 9/9] KVM: selftests: Add nested SVM DecodeAssists test Tina Zhang
2026-08-19  6:10   ` sashiko-bot

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=20260819061045.D47861F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=zhang_wei@open-hieco.net \
    /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