From nobody Tue Dec 2 01:36:24 2025 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 3B0AC2FFDD9 for ; Fri, 21 Nov 2025 22:34:56 +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=1763764501; cv=none; b=NuCPTn6d7O0ou5UNyzQ4jWjzEQ/m3I5DuJRKM5ZpfYq2xUtVFDVX522/DJxXxx7RiabHm7ESMPAewFL0+0vooUtcDx0UHNKuw6/1PDcBeg4ZiKA98m/YJck82JJUWYz9pxbXDXmaSU0MMnJGRNbOrLRsFjXfQ/LCAbSkQVhj/Pc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763764501; c=relaxed/simple; bh=yz0/RGPQhgUuawce+VsL4GeCp7piSee5icPYDy8cV6c=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=lfZqxbl3h52o8uzKys/hmQjVVMPXhGYOBLa0ZrvzHECIsxOGivu/vTJu1h9CLmefVF15HXxgrNzuSekekv0cWubCu/Uk5h7lfXJ3Mz3/YeZo/ZIXRpREgAkt91s0fQFXV+QXfdeCNmFji+oBOaxEjjds/kySfsFvHw6vQ1nWxsg= 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=pSuv5mXO; 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="pSuv5mXO" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-3418ad76023so5536344a91.0 for ; Fri, 21 Nov 2025 14:34:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1763764494; x=1764369294; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=InBo93G5HI4PVLH9iAiwY8b0qujoTNU9yFW4BKVHb7c=; b=pSuv5mXOF9dHdZsdTevp90hvORKV5rqBdjKHc6BF0y9t2Ka/AEVrxzBjqIOIB0zppO XesYZxa0Hw/1wiz/QErAGtR3euTqw06fYINsuU6Sj1qXwSi/3lbTfSfKUZ3LaDF7g/7z EEZ+pWbAohf4E4QQL3ydd6qi6vCAgcbHeoyuTqu38cs5l5P8ta/NYEAs1O1ONzVkTx0L VkK/9xFpLIW7e7sYVZ2vP9q2D5ZVwh48yiJ241DkoFQ9iPg+5Ji5frUltyvwsU3I61kv IeiSGdM0n2X5KywZ5FfD1dXD4NfsHZfiTPa4+lSwWNT5dFhpzsEWZ+ATE10PJ6sr6cQm GquQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763764494; x=1764369294; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=InBo93G5HI4PVLH9iAiwY8b0qujoTNU9yFW4BKVHb7c=; b=m9NoyM8kCIKUZBojyRLO9PVCl0vX+e8hmHG0m1zxPGRAABrg+ZG7n/EH3BelmOwgBE 0tZ8SfRsWvuIFFCm/pI2tjKUtdonFa/bKPJSmAf584Y/y0N06XJPtCol5rCJdnOa+JtW DiY2XPKUi45qMTUV5Iywf4F1s5dFbc9imNuYPWN/N//O4S4MNK4/lup4yYs/7eyHxFp5 83Qsx49bcI/DgIgcf6UHkic4IYqyAyZPrTdPZQCC32Zh+NYZ0aupNZs7NYH8JidYAxQk h04nDnRzSP3q4aa72zwoAK1EQs+AUT37RgCvB4aoQG3/MFldK5mY4tKoOtmCBpj2N3sc MY3Q== X-Forwarded-Encrypted: i=1; AJvYcCVzr78n+NqHaahFiGnXJDzKs8Vz8KRXQMSpqePYKpXwSe3OS70ZNgLTi/Ln0T/2v0DgD4LahE0jkLxi/ok=@vger.kernel.org X-Gm-Message-State: AOJu0YwJ+lHdLaTETWf2hrGKWF6+hUNV5CfD+lLulS75dbH6y+gnwG6K IAQcz5KYB6Qhj9eiApgmhoW9w6x9U3y8R4kErONBw4ysDvpcd4zhIX3D3b6YRH49sZ5aka3SJNd bkFw1xw== X-Google-Smtp-Source: AGHT+IG/fkRkERFnKO9mGUfex1cS5KDldCvz0Sp1ylkSk1r8aqWB94jzs/m2QrXXVQ0EDvIltYU6m1G5OK0= X-Received: from pjbmi9.prod.google.com ([2002:a17:90b:4b49:b0:343:65be:4db2]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:1c85:b0:32e:38b0:15f4 with SMTP id 98e67ed59e1d1-34733e46dc6mr5204222a91.7.1763764493765; Fri, 21 Nov 2025 14:34:53 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 21 Nov 2025 14:34:43 -0800 In-Reply-To: <20251121223444.355422-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251121223444.355422-1-seanjc@google.com> X-Mailer: git-send-email 2.52.0.rc2.455.g230fcf2819-goog Message-ID: <20251121223444.355422-5-seanjc@google.com> Subject: [PATCH v3 4/5] KVM: VMX: Move nested_mark_vmcs12_pages_dirty() to vmx.c, and rename From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Fred Griffoul Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Move nested_mark_vmcs12_pages_dirty() to vmx.c now that it's only used in the VM-Exit path, and add "all" to its name to document that its purpose is to mark all (mapped-out-of-band) vmcs12 pages as dirty. No functional change intended. Signed-off-by: Sean Christopherson --- arch/x86/kvm/vmx/nested.c | 13 ------------- arch/x86/kvm/vmx/vmx.c | 14 +++++++++++++- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c index d0cf99903971..97554eda440c 100644 --- a/arch/x86/kvm/vmx/nested.c +++ b/arch/x86/kvm/vmx/nested.c @@ -3980,19 +3980,6 @@ static void vmcs12_save_pending_event(struct kvm_vcp= u *vcpu, } } =20 - -void nested_mark_vmcs12_pages_dirty(struct kvm_vcpu *vcpu) -{ - struct vcpu_vmx *vmx =3D to_vmx(vcpu); - - /* - * Don't need to mark the APIC access page dirty; it is never - * written to by the CPU during APIC virtualization. - */ - kvm_vcpu_map_mark_dirty(vcpu, &vmx->nested.virtual_apic_map); - kvm_vcpu_map_mark_dirty(vcpu, &vmx->nested.pi_desc_map); -} - static int vmx_complete_nested_posted_interrupt(struct kvm_vcpu *vcpu) { struct vcpu_vmx *vmx =3D to_vmx(vcpu); diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 4cbe8c84b636..cc38d08935e8 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -6378,6 +6378,18 @@ static void vmx_flush_pml_buffer(struct kvm_vcpu *vc= pu) vmcs_write16(GUEST_PML_INDEX, PML_HEAD_INDEX); } =20 +static void nested_vmx_mark_all_vmcs12_pages_dirty(struct kvm_vcpu *vcpu) +{ + struct vcpu_vmx *vmx =3D to_vmx(vcpu); + + /* + * Don't need to mark the APIC access page dirty; it is never + * written to by the CPU during APIC virtualization. + */ + kvm_vcpu_map_mark_dirty(vcpu, &vmx->nested.virtual_apic_map); + kvm_vcpu_map_mark_dirty(vcpu, &vmx->nested.pi_desc_map); +} + static void vmx_dump_sel(char *name, uint32_t sel) { pr_err("%s sel=3D0x%04x, attr=3D0x%05x, limit=3D0x%08x, base=3D0x%016lx\n= ", @@ -6655,7 +6667,7 @@ static int __vmx_handle_exit(struct kvm_vcpu *vcpu, f= astpath_t exit_fastpath) * Mark them dirty on every exit from L2 to prevent them from * getting out of sync with dirty tracking. */ - nested_mark_vmcs12_pages_dirty(vcpu); + nested_vmx_mark_all_vmcs12_pages_dirty(vcpu); =20 /* * Synthesize a triple fault if L2 state is invalid. In normal --=20 2.52.0.rc2.455.g230fcf2819-goog