Message ID | 20240110012705.506918-4-seanjc@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-21629-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp517322dyi; Tue, 9 Jan 2024 17:29:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IHGy1nDR2EaAEoRKsXsXEUgiyn8EINF79CHfRWpGHh80CsgZlqPSB4ophkw5L5rBVF6xYZX X-Received: by 2002:a05:6512:1092:b0:50e:3ca0:d695 with SMTP id j18-20020a056512109200b0050e3ca0d695mr123930lfg.89.1704850164151; Tue, 09 Jan 2024 17:29:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704850164; cv=none; d=google.com; s=arc-20160816; b=Znt7RaA4k2b+VKjk+9gF6I6AibQ9EEpqD2Ma3Bno/KAZZkykI3ohB3gYOsLvOm/opC i3yLPW9vJKTeJpnIkN/Kt5w/2umhj0R1Rd66dBjSEwAJxtqJ4BydyZZyM6f1bheQTzb6 pzFMlyRi5v/fOLq7y4h0tQJKXJpTv9AzLx1Kq5uBCtx6Dj3fEGWQTrsQQHnxBqM5nSj6 tDshe2NHc+ZqQwx70pPFK2H7OVIsc3KkGcJVNSom+6Qa/V3EDLaa6HGXGdspwKmQFWdy FIlSbbY19FIzge4o3VST7MB4WBIv0NbKrTWkFSO8aLNh9EGXD62ub9sfbmPbRG9R7jnb ba7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :reply-to:dkim-signature; bh=iBBhsVReFdkY5Qcu4g5Me7VWeVaRdBMAkHcGlOP8ClI=; fh=5gy8eLL9j0mBq5w7XH+Mzaa/H0RFuTaOFYvX0+V/1sM=; b=NCZ2k5xpMBzP+lQJ67LwB+tUbVtc/q2phneO/BVC/J++W/Sq1oTZhOezKMPTeL/fJK ORRya7frkmMW06hW8Rrz78Pc92/QCWxqgrzHxpZRdefEaxU6FODdIRHdXiLP04ZX0O87 TLNNOE4ycPXtrxEMqDY6Unx5eKXJobf4c/hsDLMA2pY6qQv6XVr+fynbrGA5UZVKd9y9 +4rOIqEMIkNPsFIGdyCKoCimDxcYi7JHDE617hhDs0d8NoDIyywyojY9Mc9ncnuW1eSw PjPSlZ+xGMnB9G+SV5K94cbAARrvmKYMko2pqGSZgMNqrp3YFlX+FRArvn2uxhKu1KEm oQ6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=usPyjKfz; spf=pass (google.com: domain of linux-kernel+bounces-21629-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-21629-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id f18-20020a17090624d200b00a2bd6e1a8eesi62250ejb.401.2024.01.09.17.29.23 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 17:29:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-21629-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=usPyjKfz; spf=pass (google.com: domain of linux-kernel+bounces-21629-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-21629-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 22C651F26B41 for <ouuuleilei@gmail.com>; Wed, 10 Jan 2024 01:29:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 825922A1DB; Wed, 10 Jan 2024 01:27:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="usPyjKfz" 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 AA08C8F5B for <linux-kernel@vger.kernel.org>; Wed, 10 Jan 2024 01:27:14 +0000 (UTC) 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 Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-5c17cff57f9so1553631a12.0 for <linux-kernel@vger.kernel.org>; Tue, 09 Jan 2024 17:27:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1704850034; x=1705454834; 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=iBBhsVReFdkY5Qcu4g5Me7VWeVaRdBMAkHcGlOP8ClI=; b=usPyjKfzpYYa6kyMLj88WwG3q5VDQRhqbd27V4H9+oZI0jM/4D6/lM8onS7JwQL+Ll 7+36bkBlEVwVjTzg7vI6E+eMKrMEACdJZUv26vN4heuFJh+F46ZGK93dU8oWMz1uxtQA Iq7ZP7AeYSBizmKZeDzwmWYI/WV9Yl7mYWWwY3JxRUGnj0taTY5Hbg40Zg/vNTT1f488 zUWwGvShCAaalkJmwFlSRW48Ftlp50cM9wmBgI5aaNwUzRKPewATgik+FzprBXI8Bpt+ 6kerwMsAJmRu5VVlriUUtrG+BGiE07I2tvVSvqOwalHVzb4F/TOQjwNoDIsmDzgSG4Hg Mj8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704850034; x=1705454834; 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=iBBhsVReFdkY5Qcu4g5Me7VWeVaRdBMAkHcGlOP8ClI=; b=pHDzKao5SLU+2hMQ3GqlxY7zzdRdOWc6VcRTcv5QXWeR1GWDEMPe8LyfH8c3ef+CXz TMSyfyt0Cq+uTKKiT9Mnof2DDlVfiDSYsUDnHC3MIOzBbRDFOtv2wS5dRO8lH8XxFatb t7o8bYukvNPEv+rygc8by/OrssfnwcwYws1FX5NdpjffAs3KTpuec9/kYLHkaTiDnyMa iNYqp5K8ojHS7wMXYGJkFXbGM8jyOLYoJPguLiOjwIKHuK08AtDO7+b+TLjiPMtle7DO 5WLg8kB+Xt7NSSRvopTUjkXWtzm8LZwi+rWOnh0p4wyU3eAUUfzXj78/5tduiTpvVU3o igMg== X-Gm-Message-State: AOJu0YwkBBanUS2GAZXFiseTc39It10LAvOgKuBbkIfW4YooFeuzN5xR Po+g/jOnY2gwdGs7ahaiF0VI7KZBoYkp65pXXQ== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a63:9554:0:b0:5ca:450e:25cb with SMTP id t20-20020a639554000000b005ca450e25cbmr849pgn.6.1704850033419; Tue, 09 Jan 2024 17:27:13 -0800 (PST) Reply-To: Sean Christopherson <seanjc@google.com> Date: Tue, 9 Jan 2024 17:27:02 -0800 In-Reply-To: <20240110012705.506918-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> Mime-Version: 1.0 References: <20240110012705.506918-1-seanjc@google.com> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog Message-ID: <20240110012705.506918-4-seanjc@google.com> Subject: [PATCH 3/6] KVM: VMX: Handle forced exit due to preemption timer in fastpath From: Sean Christopherson <seanjc@google.com> To: Sean Christopherson <seanjc@google.com>, Paolo Bonzini <pbonzini@redhat.com> Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Maxim Levitsky <mlevitsk@redhat.com> Content-Type: text/plain; charset="UTF-8" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787664965445549415 X-GMAIL-MSGID: 1787664965445549415 |
Series |
KVM: x86: Clean up "force immediate exit" code
|
|
Commit Message
Sean Christopherson
Jan. 10, 2024, 1:27 a.m. UTC
Handle VMX preemption timer VM-Exits due to KVM forcing an exit in the
exit fastpath, i.e. avoid calling back into handle_preemption_timer() for
the same exit. There is no work to be done for forced exits, as the name
suggests the goal is purely to get control back in KVM.
In addition to shaving a few cycles, this will allow cleanly separating
handle_fastpath_preemption_timer() from handle_preemption_timer(), e.g.
it's not immediately obvious why _apparently_ calling
handle_fastpath_preemption_timer() twice on a "slow" exit is necessary:
the "slow" call is necessary to handle exits from L2, which are excluded
from the fastpath by vmx_vcpu_run().
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
arch/x86/kvm/vmx/vmx.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 4caad881d9a0..c4a10d46d7a8 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -6003,12 +6003,15 @@ static fastpath_t handle_fastpath_preemption_timer(struct kvm_vcpu *vcpu) if (unlikely(vmx->loaded_vmcs->hv_timer_soft_disabled)) return EXIT_FASTPATH_REENTER_GUEST; - if (!vmx->req_immediate_exit) { - kvm_lapic_expired_hv_timer(vcpu); - return EXIT_FASTPATH_REENTER_GUEST; - } + /* + * If the timer expired because KVM used it to force an immediate exit, + * then mission accomplished. + */ + if (vmx->req_immediate_exit) + return EXIT_FASTPATH_EXIT_HANDLED; - return EXIT_FASTPATH_NONE; + kvm_lapic_expired_hv_timer(vcpu); + return EXIT_FASTPATH_REENTER_GUEST; } static int handle_preemption_timer(struct kvm_vcpu *vcpu)