From: sashiko-bot@kernel.org
To: "David Woodhouse" <dwmw2@infradead.org>, kvm@vger.kernel.org
Cc: linux-hyperv@vger.kernel.org
Subject: Re: [PATCH v3 13/15] KVM: x86: Add descriptor-table registers to the write filter
Date: Fri, 27 Nov 2026 15:52:55 +0000 [thread overview]
Message-ID: <sashiko-outbox-237790@kernel.org> (raw)
In-Reply-To: <20261127152730.99319-14-dwmw2@infradead.org>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] KVM: x86: em_lgdt_lidt() validates canonical base before
filter_dt_write()
--
commit a776c4d770743069de4432de278b52d34d58dbce
Author: David Woodhouse <dwmw@amazon.co.uk>
KVM: x86: Add descriptor-table registers to the write filter
This commit extends KVM_X86_SET_REG_WRITE_FILTER to support filtering guest
writes to GDTR, IDTR, LDTR, and TR via LGDT, LIDT, LLDT, and LTR across VMX
and SVM.
> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
> index 9a4aebcccc958..b40e347c498f4 100644
> --- a/arch/x86/kvm/emulate.c
> +++ b/arch/x86/kvm/emulate.c
[ ... ]
> @@ -3489,6 +3512,11 @@ static int em_lgdt_lidt(struct x86_emulate_ctxt *ctxt, bool lgdt)
> emul_is_noncanonical_address(desc_ptr.address, ctxt,
> X86EMUL_F_DT_LOAD))
> return emulate_gp(ctxt, 0);
> + rc = ctxt->ops->filter_dt_write(ctxt, lgdt ? KVM_X86_REG_FILTER_GDTR :
> + KVM_X86_REG_FILTER_IDTR,
> + desc_ptr.address, desc_ptr.size);
> + if (rc != X86EMUL_CONTINUE)
> + return rc;
> if (lgdt)
> ctxt->ops->set_gdt(ctxt, &desc_ptr);
> else
[Severity: Medium]
Should em_lgdt_lidt() call filter_dt_write() before checking whether
desc_ptr.address is canonical?
The KVM_EXIT_X86_REG_WRITE documentation states that the exit is taken
before KVM validates the write, so new_value may be one for which the
instruction would have faulted (matching em_lldt(), em_ltr(), CR writes,
and XSETBV). Calling emul_is_noncanonical_address() first injects #GP(0)
into a 64-bit guest that loads a non-canonical GDTR or IDTR base instead
of exiting to userspace when a filter is armed.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261127152730.99319-1-dwmw2@infradead.org?part=13
next prev parent reply other threads:[~2026-11-27 15:52 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 15:27 [PATCH v3 00/15] KVM: x86: Exit handling for Hyper-V hcalls, register intercept David Woodhouse
2026-11-27 15:27 ` [PATCH v3 01/15] KVM: selftests: Make the x86 SSE register helpers volatile David Woodhouse
2026-11-27 15:27 ` [PATCH v3 02/15] KVM: Define what completing an exit does with its instruction David Woodhouse
2026-11-27 15:55 ` sashiko-bot
2026-11-30 17:23 ` Zack Rusin
2026-11-30 18:42 ` David Woodhouse
2026-11-30 19:51 ` Zack Rusin
2026-11-30 19:51 ` Zack Rusin
2026-11-30 21:37 ` David Woodhouse
2026-11-27 15:27 ` [PATCH v3 03/15] KVM: x86: Let userspace leave an MSR access alone David Woodhouse
2026-11-27 15:27 ` [PATCH v3 04/15] KVM: selftests: Test MSR accesses which userspace leaves alone David Woodhouse
2026-11-27 15:27 ` [PATCH v3 05/15] KVM: x86: hyper-v: Add KVM_CAP_HYPERV_FORWARD_HCALL David Woodhouse
2026-11-27 15:27 ` [PATCH v3 06/15] KVM: x86: hyper-v: Let userspace leave a hypercall uncompleted David Woodhouse
2026-11-27 15:27 ` [PATCH v3 07/15] KVM: x86: hyper-v: Advertise XMM fast hypercall output David Woodhouse
2026-11-27 15:27 ` [PATCH v3 08/15] KVM: selftests: Add Hyper-V hypercall forwarding test David Woodhouse
2026-11-27 15:27 ` [PATCH v3 09/15] KVM: x86: Add a per-vCPU register write filter David Woodhouse
2026-11-27 15:27 ` [PATCH v3 10/15] KVM: x86: Filter emulated CR0 and CR4 writes David Woodhouse
2026-11-27 15:48 ` sashiko-bot
2026-11-27 15:27 ` [PATCH v3 11/15] KVM: VMX: Support CR0 and CR4 write filters David Woodhouse
2026-11-27 15:27 ` [PATCH v3 12/15] KVM: SVM: " David Woodhouse
2026-11-27 15:49 ` sashiko-bot
2026-11-27 15:27 ` [PATCH v3 13/15] KVM: x86: Add descriptor-table registers to the write filter David Woodhouse
2026-11-27 15:52 ` sashiko-bot [this message]
2026-11-27 15:27 ` [PATCH v3 14/15] KVM: selftests: Add x86 register write filter test David Woodhouse
2026-11-27 15:27 ` [PATCH v3 15/15] KVM: selftests: Test the register write filter with a nested guest David Woodhouse
2026-11-27 15:47 ` sashiko-bot
2026-11-30 14:55 ` [PATCH v3 00/15] KVM: x86: Exit handling for Hyper-V hcalls, register intercept David Woodhouse
2026-11-30 17:19 ` Zack Rusin
2026-11-30 18:07 ` David Woodhouse
2026-11-30 20:00 ` Zack Rusin
2026-11-30 20:00 ` Zack Rusin
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=sashiko-outbox-237790@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dwmw2@infradead.org \
--cc=kvm@vger.kernel.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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.