From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A425EE573 for ; Thu, 12 Feb 2026 18:14:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770920051; cv=none; b=lrGt5/41cVUGgRH1sSVbUi8UymOX83an3F4uDrcQo6Zr6KjGrKfQ5UhZm24WSRKW9D0gQpefjahpIKn08W9neNWAtGZbIhN/u8rchju1S6f06TDxAxaJaE/dxTmqJOLWsOOUUmqQ3Yqg3+iB98dWWqEcKnKBBMM9xdmU8qduVZE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770920051; c=relaxed/simple; bh=p3D+1fyw54DSjvEXexOhGpduACheKFJGeLIf3VuSRNo=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=kmD4wkLID4qqywcjbIRdjstJlC7FwxvmbRu2kBGgOELIgJo2603zEkaUH30xWQ59V+CXhXEIOkvS+q4a+2CwOOlL+4/0QrNcdHM1J+KRqgOU2sEtdnDb6ZVHFaTopvE4C5aKEAXU4wPxl4NOhsp0Bp4RtjCO7Y89y+ODl0rmyq8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=sZYQzb/c; arc=none smtp.client-ip=209.85.216.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="sZYQzb/c" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-3545cc84ab1so447434a91.0 for ; Thu, 12 Feb 2026 10:14:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1770920049; x=1771524849; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=V3+cTICnHkot+sIoHqjaaAOCONP2u3fpl0bvZ8vKDTY=; b=sZYQzb/c0vtlj+Fbi5leXahfaO0U+Fn5NuzNXgiik2mJ7TUGoHHjOR8eQSkaqz37iL xU4WK0GcSUbnkTjOysi0V3iLcR4/VmvdKNfMIYEiKpBSIiqQL+8v/PIzOuDdpibCbdmw fwq26hKiFiNHKPYAekt1OmH41EGb1oBW1OUfT2gB4RX/5fyW3ACSGaoydZJPhoJBiq1m eixvhiUEsPJWRUL2+HBwxdbZ6oqFq1DEoPCWyQ6mkuofq87AHGFwuJ6I54aH92IpXolR qNw7VidD34+hTzgeMK1Fm706m5Yy+FSaIZMEHJ6Tu/a7VeYIVJ7j2UKdhMan1g51UL1X ADVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770920049; x=1771524849; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=V3+cTICnHkot+sIoHqjaaAOCONP2u3fpl0bvZ8vKDTY=; b=Nvxxc1j2Sxl42kvcpuoVhuDx/U9imhAP5tjYfI/Kz+knzWFCFnjSN4RbOIZUOZyFGe GOBlxuDO7bnGvot2/pQTVu8qJKL6G8DAiX9BBuYu0EhDDR36v8OeoaMvTvKgvOFabwOW nsrfGoDDCeaZbdvFUg/HuBjd18968/cohuMXzzYk04dIRR/UiCuSWzRG5+tijR7aLhIF 5Tqyzd/97qx2Nwjm5A3+NNWqcA4zx5SEMw5z1AoCA0LhY2k4yU1rOo3SOrlNmhNxLHD1 yyDuKS7JAjs1dxtuRqmUdVtEl6iwXQjtVVQNPFuZVh/cNJHSIk3G7t0yYenT8EE+UwIN 3YKg== X-Forwarded-Encrypted: i=1; AJvYcCUdCsS1O/t7rZ372JGHvTMPfGNTEnWVJUZX21YEAzsrgtsB7PHCEamxOF0niOFoKrXsocMpaqimDNRreHo=@vger.kernel.org X-Gm-Message-State: AOJu0YzIDudnCyYlaaeJG2Wguaeye97TqzTLH9ST2MD/fMmLcbXX9EDK Pfwz5Fj3YKMqz2CbZ8oC9SI2hsEzoaO/9t1alUbtPW8q04zz8oajETqakztPwxWYQ9xAq/o0H1q MKvzlUw== X-Received: from pjbsv15.prod.google.com ([2002:a17:90b:538f:b0:34c:2f02:7f5d]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:33cc:b0:340:776d:f4ca with SMTP id 98e67ed59e1d1-3568f403e39mr3361724a91.26.1770920048905; Thu, 12 Feb 2026 10:14:08 -0800 (PST) Date: Thu, 12 Feb 2026 10:14:07 -0800 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260203011320.1314791-1-yosry.ahmed@linux.dev> Message-ID: Subject: Re: [PATCH] KVM: nSVM: Use vcpu->arch.cr2 when updating vmcb12 on nested #VMEXIT From: Sean Christopherson To: Yosry Ahmed Cc: Paolo Bonzini , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="us-ascii" On Wed, Feb 11, 2026, Yosry Ahmed wrote: > > > So, with all of that in mind, I believe the best we can do is fully defer delivery > > of the exception until it's actually injected, and then apply the quirk to the > > relevant GET APIs. > > @@ -5747,6 +5759,8 @@ static int kvm_vcpu_ioctl_x86_get_debugregs(struct kvm_vcpu *vcpu, > > vcpu->arch.guest_state_protected) > > return -EINVAL; > > > > + kvm_handle_exception_payload_quirk(vcpu); > > + > > memset(dbgregs, 0, sizeof(*dbgregs)); > > > > BUILD_BUG_ON(ARRAY_SIZE(vcpu->arch.db) != ARRAY_SIZE(dbgregs->db)); > > @@ -12123,6 +12137,8 @@ static void __get_sregs_common(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs) > > if (vcpu->arch.guest_state_protected) > > goto skip_protected_regs; > > > > + kvm_handle_exception_payload_quirk(vcpu); > > + > > Hmm looking at this again, I realized it also affects the code path from > store_regs(), I think we don't want to prematurely deliver exception > payloads in that path. Hrm, I actually think delivering the payload in store_regs() is the least awful option. E.g. a VMM that saves sregs on exit to userspace could elide KVM_GET_SREGS when doing a save/restore. In practice, it's all moot, because AFAICT nothing uses KVM_SYNC_X86_SREGS. > So maybe it's best to move this to > kvm_arch_vcpu_ioctl_get_sregs() and kvm_arch_vcpu_ioctl()? > > The other option is to plumb a boolean that is only set to true in the > ioctl code path. > > > kvm_get_segment(vcpu, &sregs->cs, VCPU_SREG_CS); > > kvm_get_segment(vcpu, &sregs->ds, VCPU_SREG_DS); > > kvm_get_segment(vcpu, &sregs->es, VCPU_SREG_ES); > > > > base-commit: 55671237401edd1ec59276b852b9361cc170915b > > --