From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.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 25B9A1DE3B1 for ; Thu, 17 Oct 2024 16:05:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729181111; cv=none; b=he8Rp4NNdcxwvHFrj6RpVqpu/Sfuv0UWj1hTLky2VvJEM2cGAFUS0Sf78V33d0lichtZP0iYRZLbV5A+Ef5lGwX0AFEcsTC6xDxQdO/aIV3PuYvkhyk1rpkirFOrEm7ivtR0K7bnSslacYw3zx2FXmHGkPelJuoBkl53uU2Cd7g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729181111; c=relaxed/simple; bh=7iSCUy4hsd7mlFixKAw5QSrayk3PCs1zC5I7vexFMBk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=k0xpsX1U4VAd46GWA2rvyyG1LOZKPOX1Z64LfXczzl8/euzffTxlQJQs6PIieDXqvxqRHmrt+4QLJ0vDiohd2+Za/po4YyCbxtLwXEQBG6KXuu2nj66YSFX7BORjEVdtxA+gqNkMlLPbYZ56YecRULAVk9Zidbm3MGOXZ53xFs8= 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=NgHglzpn; arc=none smtp.client-ip=209.85.215.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="NgHglzpn" Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-7ea6efcd658so975884a12.3 for ; Thu, 17 Oct 2024 09:05:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729181109; x=1729785909; 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=uPGvpskT3qQS7A2X2wMCHyl1PllSmHhCFZoJsQqYtGE=; b=NgHglzpnPcgECbl64vItt0Ii+BbdB8ehHUTYLafIp3KvKJQMbRBfVIUIQJCHh6AXjj MH3ZvdVnxe3QcF0LuE3kc25fcN/ypKnF6SkXvJHaOsrEUyDYywj9WpXlHuRqi/mFPa/g mRmNHmHdtFjleFKiSKamxBrLu7P5IHSbh3Tby35p8LS/y2zdMQoUk1BUu+jR9XJsGddw SBxgSA9wcQ4NXz+tDT08dmJAxkZbrR/0KzGqzJy4PAzl6t8zdgTIAUyBJEHdbgyQ+unG LUtUUX979FhHYfIKLUysmLrgqpjAMmP6PKsNaKyAD/vF3hu7yMClVL4Hdz+zs/0ib1+M 9Y+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729181109; x=1729785909; 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=uPGvpskT3qQS7A2X2wMCHyl1PllSmHhCFZoJsQqYtGE=; b=r5TGKVNwaP42YQ5qqfpCK8aCIGUGnu1pmbGyFk1034kjSWjoFajx3R5UfBpzgLh1gl n1gBCSFlYcEVSgN8SRFKgFVmLFDGFq5NGDDwx2NVqZxtGffMGNVNYuX62mIb8awPyPN1 na2NWIfcrN1MU4Y+KdXczj4yolpm9Zw81HZXLnoKEY3exS/7F9XaUAekSiGZ53wj/Wh3 Y40q+DonCnJsFzfY5WBC5GlTRb46mQem8ZxAj0dFZuyq/JxTO4gFGlbaaw9281ksGJK/ e1K7h3MHFY0nimC05v1CkkQ7uYoR2a7X30kmTcfLXDoW8+70w2CG/M1sFOOBQyBLJdMx Z1GA== X-Forwarded-Encrypted: i=1; AJvYcCUOuEm9BdVU5exFDcWAp2fohvq1PIGw4EoK8R0uRbGNPYSdSK/MF3lJaMmAWVUJeVyiJDoaWhohXvtrVDw=@vger.kernel.org X-Gm-Message-State: AOJu0YyCeugOiwtEaey/TZ4JLXaFKxTc6LhLrPURs0Y5mZszI0bKsRaw OAxhRkXpE3LDwLG6fT7n40KeHQMH+FWYO3o1jORwPEREQjxDyXeGKborCh7KvIeN4D5gDfzflSp K9g== X-Google-Smtp-Source: AGHT+IEquI/dcGuvHtAD+d8/HkmmYalvr5Dpl8EjyXsUW0Mn0a/8F/NJjbLqp6zWRl9i1E0sX+PTajVAI8c= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:9d:3983:ac13:c240]) (user=seanjc job=sendgmr) by 2002:a63:f706:0:b0:7e6:c3f2:24d1 with SMTP id 41be03b00d2f7-7eaa6c6493bmr8214a12.4.1729181109079; Thu, 17 Oct 2024 09:05:09 -0700 (PDT) Date: Thu, 17 Oct 2024 09:05:07 -0700 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241002124324.14360-1-mankku@gmail.com> Message-ID: Subject: Re: [PATCH 1/1] KVM: nVMX: update VPPR on vmlaunch/vmresume From: Sean Christopherson To: Chao Gao Cc: "Markku =?utf-8?Q?Ahvenj=C3=A4rvi?=" , bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, janne.karhunen@gmail.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, mingo@redhat.com, pbonzini@redhat.com, tglx@linutronix.de, x86@kernel.org Content-Type: text/plain; charset="us-ascii" On Thu, Oct 17, 2024, Chao Gao wrote: > >> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c > >> index 5bb481aefcbc..d6a03c30f085 100644 > >> --- a/arch/x86/kvm/lapic.c > >> +++ b/arch/x86/kvm/lapic.c > >> @@ -800,6 +800,9 @@ static inline void apic_clear_isr(int vec, struct kvm_lapic *apic) > >> if (!__apic_test_and_clear_vector(vec, apic->regs + APIC_ISR)) > >> return; > >> > >> + if (is_guest_mode(apic->vcpu)) > > > >As above, I think this needs to be > > > > if (is_guest_mode(apic->vcpu) && !nested_cpu_has_vid(get_vmcs12(vcpu))) > > > >because if virtual interrupt delivery is enabled, then EOIs are virtualized. > >Which means that this needs to be handled in vmx_hwapic_isr_update(). > > I'm not sure if nested_cpu_has_vid() is necessary. My understanding is that > when a bit in the vCPU's vISR is cleared, the vCPU's SVI (i.e., SVI in vmcs01) > may be stale and so needs an update if vmcs01 isn't the active VMCS (i.e., the > vCPU is in guest mode). > > If L1 enables VID and EOIs from L2 are virtualized by KVM (L0), KVM shouldn't > call this function in the first place. Because KVM should update the > 'virt-APIC' page in VMCS12, rather than updating the vISR of the vCPU. Ah, right. And KVM handles that in nested_vmx_l1_wants_exit(), by forwarding all APICv exits to L1: case EXIT_REASON_APIC_ACCESS: case EXIT_REASON_APIC_WRITE: case EXIT_REASON_EOI_INDUCED: /* * The controls for "virtualize APIC accesses," "APIC- * register virtualization," and "virtual-interrupt * delivery" only come from vmcs12. */ return true;