From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796200550; b=1vWS71d6P+OUuX4Ch9aFM1DI/IPtJdw07e6CFVNheou3a90EC8RMvU10AmP3BU1ZFVdV D3gwUbMbRTeNwWQ+K81a662yrdu6CVV7iOTyVjtoemYZhbrtsm6iD92hZmsIp7lkwS/FK 6mRtuHQFDi2Xb3bdSztT+AgPVMTpOzShZL9VMhPs/FpgUn6UK1DlKeSujiJDXcPbJUHfa nbphxIw3XnQPokq9e2APnOiSs/c1OskzCkfL0m+u6n5qLo1jHNKTX9pMrx8I4TeEKv0qp tKacZZg0axAZc2FmSnEZ/8ydCV8CkY75cCPhnGDcYbWueo7NI0rEfY2os6hAt5X7SAA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796200550; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=Cp+JNkFKLLbIwkyMQWBmnFaB3QTnathOh4bvlWmFXxs=; b=FkF13N768uxZp0KoY/J3elLwHQZCDFrpneuE2QaZlG5vHv6GJ38cem6Ozh/1YpA72G9W J9Aj5r+hrvXx5+2iSp6DLtIvDIg7Y7luf53aKO4qGbB8n5XSSrMNmd6yHji9c36zldHk5 bV4eYaEkcpe6yNmJ/K1iDjgmHplgL/4aXzgTl2FPtdxzvJ3JuOFqXx9I8UOOTzoR6UW0t 9LuYYrTdPeuCrNpXZOwuFPrw+i1tyekJ+xBdN7Pow1HZBMXgo9I1M1DNggdkwIShxkLR/ IfkD4uEbibNTNtksT1G3l+d28BOC3+hEOP+JrtSqFwjjLTA9CI355g9x6KiQTfCvAwg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=HyLWe623; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5E7A8606A323 for ; Wed, 2 Dec 2026 08:35:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=HyLWe623 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 405481F00896; Wed, 2 Dec 2026 08:35:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796200549; bh=Cp+JNkFKLLbIwkyMQWBmnFaB3QTnathOh4bvlWmFXxs=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=HyLWe623BDI7n+GYq2W1u/TygjoTikw0K4Un2Og4C9MUP63pD2wO0kdwdJhIEA7fw mMcZwWRA76dqPYj4WGMOjfMup38yCrXVrwwyysCQO5/C2cDo04AEw/hunIywRD6oTr dZnR0frBqiq1PSVaLTMyDddRkll4PRgDTi2MAhuWzNupUnmmk02Rozc9VMsPeI+8gj Lb10ZZvpywbpyc9yh8GXbJIPxmBk7ITM6G2k571Irc4IS0dXdbFNeFJ+HU/UGLNMax IsN5N+at5Y6+Q7kVt/RWrXHbEWmjyJSZ5ITJi7gki2xSXFBLpuoV5YqTvisJDYeWGm daSazXr5mrFBQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 3/4] KVM: VMX: Re-inject an ICEBP #DB as a privileged software exception Reply-To: sashiko-reviews@lists.linux.dev To: "Sohil Mehta" , kvm@vger.kernel.org In-Reply-To: <20261202080224.4165883-4-sohil.mehta@intel.com> References: <20261202080224.4165883-1-sohil.mehta@intel.com> <20261202080224.4165883-4-sohil.mehta@intel.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 08:35:47 +0000 X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] KVM: x86: unhandled ICEBP payload in kvm_vcpu_ioctl_x86_get_vcpu_events() -- commit 52a98c13d9a8d8b249575bef58fd19c330f0a0f1 Author: Sohil Mehta KVM: VMX: Re-inject an ICEBP #DB as a privileged software exception This commit re-injects an intercepted ICEBP #DB on VMX as a privileged software exception with the VM-exit instruction length instead of skipping the instruction and queueing a hardware exception. > diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c > index fdc531a61fd30..72d16282b5598 100644 > --- a/arch/x86/kvm/vmx/vmx.c > +++ b/arch/x86/kvm/vmx/vmx.c [ ... ] > @@ -5533,17 +5532,24 @@ static int handle_exception_nmi(struct kvm_vcpu *= vcpu) > if (!(vcpu->guest_debug & > (KVM_GUESTDBG_SINGLESTEP | KVM_GUESTDBG_USE_HW_BP))) { > /* > - * If the #DB was due to ICEBP, a.k.a. INT1, skip the > - * instruction. ICEBP generates a trap-like #DB, but > + * ICEBP, a.k.a. INT1, generates a trap-like #DB, but > * despite its interception control being tied to #DB, > * is an instruction intercept, i.e. the VM-Exit occurs > - * on the ICEBP itself. Use the inner "skip" helper to > - * avoid single-step #DB and MTF updates, as ICEBP is > - * higher priority. Note, skipping ICEBP still clears > - * STI and MOVSS blocking. > + * on the ICEBP itself. Re-inject the #DB as what it > + * is, a privileged software exception, so that VM-Entry > + * advances RIP past the ICEBP using its length. Clear > + * STI and MOVSS blocking, as retiring the ICEBP would. > + * Note, an ICEBP in enclave mode exits as a hardware > + * exception, so it never gets here. > */ > - if (is_icebp(intr_info)) > - WARN_ON_ONCE(!skip_emulated_instruction(vcpu)); > + if (is_icebp(intr_info)) { > + vcpu->arch.event_exit_inst_len =3D > + vmcs_read32(VM_EXIT_INSTRUCTION_LEN); > + vmx_set_interrupt_shadow(vcpu, 0); > + kvm_queue_exception_p_type(vcpu, DB_VECTOR, dr6, > + EVENT_TYPE_PRIV_SWEXC); > + return 1; > + } [Severity: Medium] Can queueing an ICEBP #DB with a payload and EVENT_TYPE_PRIV_SWEXC corrupt guest state if KVM exits to userspace (for example on a pending signal) before injecting the exception? Previously, exceptions omitted from KVM_GET_VCPU_EVENTS never had both ex->pending and ex->has_payload set. Now an intercepted ICEBP queues a pending EVENT_TYPE_PRIV_SWEXC with ex->has_payload =3D true while leaving GUEST_RIP at the ICEBP instruction: arch/x86/kvm/x86.c:kvm_handle_exception_payload_quirk() { ... if (!vcpu->kvm->arch.exception_payload_enabled && ex->pending && ex->has_payload) kvm_deliver_exception_payload(vcpu, ex); } arch/x86/kvm/x86.c:kvm_vcpu_ioctl_x86_get_vcpu_events() { ... if (!kvm_exception_is_soft(ex->vector) && ex->event_type !=3D EVENT_TYPE_PRIV_SWEXC) { events->exception.injected =3D ex->injected; events->exception.pending =3D ex->pending; ... } events->exception.nr =3D ex->vector; events->exception.has_error_code =3D ex->has_error_code; events->exception.error_code =3D ex->error_code; events->exception_has_payload =3D ex->has_payload; events->exception_payload =3D ex->payload; ... } When KVM_CAP_EXCEPTION_PAYLOAD is disabled, kvm_handle_exception_payload_quirk() delivers the DR6 payload into vcpu->arch.dr6 (clearing B0..B3 and updating DR6_RTM) even though KVM_GET_VCPU_EVENTS drops the exception so the guest will re-execute ICEBP. When KVM_CAP_EXCEPTION_PAYLOAD is enabled, KVM_GET_VCPU_EVENTS reports events->exception_has_payload =3D 1 with pending =3D 0 and injected =3D 0. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202080224.4165= 883-1-sohil.mehta@intel.com?part=3D3