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=1796077515; b=Om6MCVSFfo6QUj8smiQkBOc84oWsJP+Ws33bJKDUde/4Uf+CmO5YQRW5eW8R3cNhs0Vf Lzd/uiXlgTbB9kVXzTGQw+eJOIo6uFJiDVvZXONnODCzC1Sp8fJqqAP9++NNfL7+elY7G WzMjshwbiT6zlZ77g6RRVsLLPWpAyTymdmJ7D870kkBuaUBI/wrJVGVHFqg1VQj2YPUJW 4kQKoDxWpwUqqd4XsfPOTgCcyIsqlUlsFPyxejO6PnouiLpBjCYS3efOIyM0gj+cqaeA0 5dNgI1dI/ZE4umjwdcCxLV9JbsaELeKEcjvTHyoblHxmbP+dWVO3a5FHizree1wKhQA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796077515; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=kS1os6F7YwqkbQguStOBgOjFfSZtwfysPhmt4fm6yWc=; b=XUcbt9H+1uqPQ6In9Agbepj8agjv5VdpBhv0Mzts8WGiAvVNJOdo28kwgabUXCQVhaR/ BKC50vcEh5XbvCQIdcAXCINu+/g7yIxCDdKto/zC3jL2VEyd8HPYKB1zNRuwihctUZM3j XiKwA9wwvYaZyZU1J1ln0HCOgoAsVjAC0JmM5tKfndrsYpbGCVu6MZKbwGextXqSwEmiX Z3FuFNJ2PPMNOGdAA7BH3h33mhuZl5hrLnVhFyGdDSjWQbneqzIVZbiobFI/ChptAdKlB nySaHHodfNztrz8SpKHMTdvWFV9kb5bV1qXU1Lkw6FeK/EoXQNVCrcAb52oUTPEzh8g== 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=mMk9WUNe; 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 BF6AB606A31A for ; Mon, 30 Nov 2026 22:25:15 +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=mMk9WUNe Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4AE591F00896; Mon, 30 Nov 2026 22:25:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796077515; bh=kS1os6F7YwqkbQguStOBgOjFfSZtwfysPhmt4fm6yWc=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=mMk9WUNeik+qsrCYKf7PikfSrQdeUq5STr0icDt8qQOKfr8M6FaW/gOzn7NYdPHrw WSHMMz7AnzN7dWKyFH3vzfXCLUanchBo7JVNA6N63sJndcW9IbB21gZs6L0DUA6MXb qYL6IO6GrH+0P4dnfxsgPW3ky2JIefFdt9Ej0mNroztTRkO8gyOteUsK3ThfOaG1ml 67uy2FsQJUfZKbG5gBz1tdZaZTT8K9SvCLCm0m00x1xd+UxBqrQEjAhnqjn+1mBAxl zVsOnALzbx9b7+bnlb4DekLPlM2CJP4Di4qcTGInDKW5librMRENpYBUhP/55UuDL8 cIQY7NM8OkG8Q== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v3] x86/sev: Handle DR7 accesses in the #VC handler after GHCB teardown Reply-To: sashiko-reviews@lists.linux.dev To: "Ashish Kalra" Cc: kvm@vger.kernel.org In-Reply-To: <55e961099c4169dc8b3853d4b05a330c572e8b21.1796075019.git.ashish.kalra@amd.com> References: <55e961099c4169dc8b3853d4b05a330c572e8b21.1796075019.git.ashish.kalra@amd.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Nov 2026 22:25:14 +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] x86/sev: missing opcode and DebugSwap checks in vc_handle_exception_no_ghcb() -- commit c27cd4c5ad513d845adab8b2a99525e2c33cc33d Author: Ashish Kalra x86/sev: Handle DR7 accesses in the #VC handler after GHCB teardown This commit handles DR7 read and write #VC exceptions locally after the per-CPU and boot GHCBs have been torn down during kexec, and terminates the guest with GHCB_TERM_NO_GHCB on any other #VC in that window. > diff --git a/arch/x86/coco/sev/vc-handle.c b/arch/x86/coco/sev/vc-handle.c > index 96b62b49b2b53..5b5da8efbf39e 100644 > --- a/arch/x86/coco/sev/vc-handle.c > +++ b/arch/x86/coco/sev/vc-handle.c > @@ -889,6 +889,32 @@ static __always_inline bool vc_from_invalid_context(= struct pt_regs *regs) > return is_vc2_stack(sp) && !is_vc2_stack(prev_sp); > } > =20 > +/* Without a GHCB, only DR7 accesses are currently handled */ > +static void vc_handle_exception_no_ghcb(struct pt_regs *regs, unsigned l= ong exit_code) > +{ > + struct es_em_ctxt ctxt; > + long *reg; > + > + if (exit_code !=3D SVM_EXIT_READ_DR7 && exit_code !=3D SVM_EXIT_WRITE_D= R7) > + goto fail; > + > + if (vc_init_em_ctxt(&ctxt, regs, exit_code) !=3D ES_OK) > + goto fail; > + > + reg =3D vc_insn_get_rm(&ctxt); > + if (!reg) > + goto fail; > + > + if (exit_code =3D=3D SVM_EXIT_READ_DR7) > + *reg =3D DR7_RESET_VALUE; > + > + vc_finish_insn(&ctxt); > + return; [Severity: Medium] Should vc_handle_exception_no_ghcb() also validate the instruction with vc_check_opcode_bytes(&ctxt, exit_code) and reject the #VC when (sev_status & MSR_AMD64_SNP_DEBUG_SWAP) is set, as vc_handle_exitcode(), vc_handle_dr7_read() and vc_handle_dr7_write() do? Without vc_check_opcode_bytes(), if the hypervisor injects a #VC with SVM_EXIT_WRITE_DR7 or SVM_EXIT_READ_DR7 at an arbitrary instruction after snp_kexec_finish(), vc_insn_get_rm() still resolves a register pointer from modrm.value (defaulting to ®s->ax when the instruction has no ModRM byte), so vc_handle_exception_no_ghcb() skips the instruction via vc_finish_insn() and, on SVM_EXIT_READ_DR7, overwrites a general-purpose register in regs with DR7_RESET_VALUE instead of terminating the guest. And if MSR_AMD64_SNP_DEBUG_SWAP is enabled, DR7 accesses are not intercepted, so a #VC on the DR7 write in hw_breakpoint_disable() would skip clearing the hardware DR7 register in the encrypted VMSA instead of terminating. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/55e961099c4169dc8b3= 853d4b05a330c572e8b21.1796075019.git.ashish.kalra@amd.com?part=3D1