From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.202]) (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 518533A0EA2 for ; Mon, 6 Apr 2026 22:54:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775516046; cv=none; b=LCWMqQLN8a04MQoBb4PatpcuuHYKg8ysbR1spib2y4lgmGKEMNVI8PKHVsoDhMwMKMa0ODAvmPrGsbh+WTsXn3oI5E6goP+OaLeGxHeR4G6dlH7ysGjU5TWUbh8NPNZ5mocvw4tmdzLw7APeo4r5+5KObpeqs7nvh0HYISJNkPI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775516046; c=relaxed/simple; bh=PrIzYzYDOqnyviPg7z9Bu0t4d4Y/A+WX2DYoDsRUdxI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=U9Yr4eYgOSKYuGhor/kTcXQFJ+W2v7besUX+lKJ5MU6Ci9hUYAT1s7gsf+2OsMrz10S+t9SJm7xaFKCpcZDdj7yjx22vBjHJzRwWgDaOJX1F+WQEZABSOgLbJ78SmDsfZ5vh9Y228XExA6+QS01uDoIS2mh7tGxaejDX/NA5oik= 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=gP4x6LPF; arc=none smtp.client-ip=209.85.210.202 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="gP4x6LPF" Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-82c675116f1so6366514b3a.2 for ; Mon, 06 Apr 2026 15:54:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775516044; x=1776120844; 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=FMKpziGML7Zg5ERXIPN3K5TAiZoQQ1DW1+IhEDhwfcA=; b=gP4x6LPFVZyvYtzbCCBY/WWbLJvoD2GaZYEqcDM7LUjJdE6dQaKg08F0EsVA4BMLTc WZYCO0AkUIzMbJ6/EdE+YdiAidX6X11vvboAhxVas8vjKZOxiYdqyPoA71TsHfkkIiq9 HvLGvNDQOZKUsNwca/SiTdVYljj4EpeZejqk+9pE4/X/3bOAly7qQOHhDVNfx38ESVqm pXKCMCObFSRdc/zjS851unIaciwnWGoSAvhsK7fX/gEESqFpAX9yBg/0+cezpRsgwPWc 1usj90k6uWvV5+PZSTRepj8lGWQNcu7sDyrVmqxcxHfz70RuxiRDvg87voZDWOQ6mR5o O2Zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775516044; x=1776120844; 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=FMKpziGML7Zg5ERXIPN3K5TAiZoQQ1DW1+IhEDhwfcA=; b=VGWyHIbmqgxYljmmzNAYbfemEPvaRoe4MjMCuuXJSgTmOBqJz6efIitbVjKh71v8od vjqvh7Qn29PRoifVdkzD17Ya5/6X9yBsp2jdxOLSZLRbrAv3Ky+IHIVYcX21rr0bt1Fv z8FX+JUVs4f3i0a//GWngkvQ0q7sIhfjOMmsmCwgcYtrxtIJsfibAgACngatH0Ao9nln Zd0b89uN4e4BuexA/EHy1seb32rQW1xdcW9/wn2xsHpZwVlkefA3qMz2PbImCZ/Sq440 e90DBx2m27qHw1DqmVU4Le67+m6Dtf65W/NZN9qnvMmIQzCqiHBSxS1He7dLzHB2hITr W4iA== X-Forwarded-Encrypted: i=1; AJvYcCW3JZBnWc8dOIbAqiKtYqI74OcTnBD4XsQuf49FEhEUTXexf9iMV6oyL+YoPcaIj2k0Z20UXf31xSLjcyQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxSf0TLx2NTBo3stMJ3LGcjkBVGEQPUwd/hZtI2eswf2Mqzn59i qI1awAmwXYdZu7yZfA4Ys882WKLP44MkIlvDxWJ6L4SfxoV+NCmE6j0D7h5wj8l64KZyrRxy/iY S+RKZfw== X-Received: from pfiu21.prod.google.com ([2002:a05:6a00:1255:b0:82c:d8bd:7e5b]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:3011:b0:82c:6f07:2dc4 with SMTP id d2e1a72fcca58-82d0daa006bmr13673224b3a.21.1775516044435; Mon, 06 Apr 2026 15:54:04 -0700 (PDT) Reply-To: Sean Christopherson Date: Mon, 6 Apr 2026 15:53:57 -0700 In-Reply-To: <20260406225359.1245490-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: <20260406225359.1245490-1-seanjc@google.com> X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260406225359.1245490-3-seanjc@google.com> Subject: [PATCH v3 2/3] KVM: x86: Drop superfluous caching of KVM_ASYNC_PF_DELIVERY_AS_PF_VMEXIT From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, syzbot+bc0e18379a290e5edfe4@syzkaller.appspotmail.com, Xiaoyao Li , Ethan Yang Content-Type: text/plain; charset="UTF-8" Drop kvm_vcpu_arch.delivery_as_pf_vmexit and instead use msr_en_val as the source of truth to reduce the probability of operating on stale data. This fixes flaws where KVM fails to update delivery_as_pf_vmexit when APF is explicitly disabled by the guest or implicitly disabled by KVM on INIT. Absent other bugs, the flaws are benign as KVM *shouldn't* consume delivery_as_pf_vmexit when PV APF support is disabled. Simply delete the field, as there's zero benefit to maintaining a separate "cache" of the state. Fixes: 52a5c155cf79 ("KVM: async_pf: Let guest support delivery of async_pf from guest mode") Signed-off-by: Sean Christopherson --- arch/x86/include/asm/kvm_host.h | 1 - arch/x86/kvm/x86.c | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index c470e40a00aa..fae1f4aeca5a 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1039,7 +1039,6 @@ struct kvm_vcpu_arch { u32 id; u32 host_apf_flags; bool send_always; - bool delivery_as_pf_vmexit; bool pageready_pending; } apf; diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index c35d359b56dd..4632222a5d1c 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -3666,7 +3666,6 @@ static int kvm_pv_enable_async_pf(struct kvm_vcpu *vcpu, u64 data) } vcpu->arch.apf.send_always = (data & KVM_ASYNC_PF_SEND_ALWAYS); - vcpu->arch.apf.delivery_as_pf_vmexit = data & KVM_ASYNC_PF_DELIVERY_AS_PF_VMEXIT; kvm_async_pf_wakeup_all(vcpu); @@ -14035,7 +14034,7 @@ static bool kvm_can_deliver_async_pf(struct kvm_vcpu *vcpu) * L1 needs to opt into the special #PF vmexits that are * used to deliver async page faults. */ - return vcpu->arch.apf.delivery_as_pf_vmexit; + return vcpu->arch.apf.msr_en_val & KVM_ASYNC_PF_DELIVERY_AS_PF_VMEXIT; } else { /* * Play it safe in case the guest temporarily disables paging. -- 2.53.0.1213.gd9a14994de-goog