From: Yan Zhao <yan.y.zhao@intel.com>
To: Xiaoyao Li <xiaoyao.li@intel.com>
Cc: Sean Christopherson <seanjc@google.com>,
Marc Zyngier <maz@kernel.org>,
Oliver Upton <oliver.upton@linux.dev>,
Paolo Bonzini <pbonzini@redhat.com>,
<linux-arm-kernel@lists.infradead.org>, <kvmarm@lists.linux.dev>,
<kvm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Vishal Annapurve <vannapurve@google.com>,
"Rick Edgecombe" <rick.p.edgecombe@intel.com>,
Nikolay Borisov <nik.borisov@suse.com>
Subject: Re: [PATCH 2/5] KVM: TDX: Exit with MEMORY_FAULT on unexpected pending S-EPT Violation
Date: Wed, 30 Jul 2025 14:04:13 +0800 [thread overview]
Message-ID: <aIm13dDJf4/jGxKv@yzhao56-desk.sh.intel.com> (raw)
In-Reply-To: <1b0ea352-c645-461b-9e19-5202791f8e2d@intel.com>
On Wed, Jul 30, 2025 at 10:07:36AM +0800, Xiaoyao Li wrote:
> On 7/30/2025 3:33 AM, Sean Christopherson wrote:
> > Exit to userspace with -EFAULT and a valid MEMORY_FAULT exit if a vCPU
> > hits an unexpected pending S-EPT Violation instead of marking the VM dead.
> > While it's unlikely the VM can continue on, whether or not to terminate
> > the VM is not KVM's decision to make.
> >
> > Set memory_fault.size to zero to communicate to userspace that reported
> > fault is "bad", and to effectively terminate the VM if userspace blindly
> > treats the exit as a conversion attempt (KVM_SET_MEMORY_ATTRIBUTES will
> > fail with -EINVAL if the size is zero).
>
> This sets a special contract on size zero.
+1.
Or would it be good to use pr_warn_once() to indicate that the VM termination
reason is "Guest access before accepting" if a new exit type is not specified?
This info is straightforward and helpful in cases when a TD is accidentally
killed.
> I had a patch internally, which introduce a new exit type:
>
> + /* KVM_EXIT_GUEST_ERROR */
> + struct {
> + #define KVM_GUEST_ERROR_TDX_ACCESS_PENDING_PAGE 0
> + __u32 error_type;
> + __u32 ndata;
> + __u64 data[16];
> + } guest_error;
>
> how about it?
>
> > Opportunistically delete the pr_warn(), which could be abused to spam the
> > kernel log, and is largely useless outside of interact debug as it doesn't
> > specify which VM encountered a failure.
> >
> > Signed-off-by: Sean Christopherson <seanjc@google.com>
> > ---
> > arch/x86/kvm/vmx/tdx.c | 6 ++----
> > 1 file changed, 2 insertions(+), 4 deletions(-)
> >
> > diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c
> > index 3e0d4edee849..c2ef03f39c32 100644
> > --- a/arch/x86/kvm/vmx/tdx.c
> > +++ b/arch/x86/kvm/vmx/tdx.c
> > @@ -1937,10 +1937,8 @@ static int tdx_handle_ept_violation(struct kvm_vcpu *vcpu)
> > if (vt_is_tdx_private_gpa(vcpu->kvm, gpa)) {
> > if (tdx_is_sept_violation_unexpected_pending(vcpu)) {
> > - pr_warn("Guest access before accepting 0x%llx on vCPU %d\n",
> > - gpa, vcpu->vcpu_id);
> > - kvm_vm_dead(vcpu->kvm);
> > - return -EIO;
> > + kvm_prepare_memory_fault_exit(vcpu, gpa, 0, true, false, true);
> > + return -EFAULT;
> > }
> > /*
> > * Always treat SEPT violations as write faults. Ignore the
>
>
next prev parent reply other threads:[~2025-07-30 6:05 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-29 19:33 [PATCH 0/5] KVM: Drop vm_dead, pivot on vm_bugged for -EIO Sean Christopherson
2025-07-29 19:33 ` [PATCH 1/5] KVM: Never clear KVM_REQ_VM_DEAD from a vCPU's requests Sean Christopherson
2025-07-29 19:33 ` [PATCH 2/5] KVM: TDX: Exit with MEMORY_FAULT on unexpected pending S-EPT Violation Sean Christopherson
2025-07-29 22:27 ` Edgecombe, Rick P
2025-07-29 22:54 ` Sean Christopherson
2025-07-29 22:58 ` Edgecombe, Rick P
2025-07-29 23:08 ` Sean Christopherson
2025-07-29 23:13 ` Edgecombe, Rick P
2025-07-30 5:45 ` Yan Zhao
2025-07-30 5:55 ` Yan Zhao
2025-07-30 12:59 ` Edgecombe, Rick P
2025-07-30 2:07 ` Xiaoyao Li
2025-07-30 6:04 ` Yan Zhao [this message]
2025-07-29 19:33 ` [PATCH 3/5] KVM: Reject ioctls only if the VM is bugged, not simply marked dead Sean Christopherson
2025-07-30 1:20 ` Chao Gao
2025-07-29 19:33 ` [PATCH 4/5] KVM: selftests: Use for-loop to handle all successful SEV migrations Sean Christopherson
2025-07-29 19:33 ` [PATCH 5/5] KVM: TDX: Add sub-ioctl KVM_TDX_TERMINATE_VM Sean Christopherson
2025-08-01 13:56 ` Adrian Hunter
2025-08-01 16:44 ` Sean Christopherson
2025-08-03 17:41 ` Adrian Hunter
2025-08-06 6:06 ` Chao Gao
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=aIm13dDJf4/jGxKv@yzhao56-desk.sh.intel.com \
--to=yan.y.zhao@intel.com \
--cc=adrian.hunter@intel.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maz@kernel.org \
--cc=nik.borisov@suse.com \
--cc=oliver.upton@linux.dev \
--cc=pbonzini@redhat.com \
--cc=rick.p.edgecombe@intel.com \
--cc=seanjc@google.com \
--cc=vannapurve@google.com \
--cc=xiaoyao.li@intel.com \
/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
all inboxes | Powered by JetHome®