Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2184687pxb; Fri, 24 Sep 2021 23:47:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJze9gupYsLTjBcUyrHzmN3Jss0N1m1a/r+0TDPPJ9SbYe8q3fBjj/dm377paChaGTAjzQOJ X-Received: by 2002:aa7:da45:: with SMTP id w5mr9756881eds.266.1632552442346; Fri, 24 Sep 2021 23:47:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632552442; cv=none; d=google.com; s=arc-20160816; b=Q3jRjtnA/vmay935pJcGcJviPVDlOcD/svty2WAACE5BZkEqYppZyjz6BAjGnGWTO/ 9cdAb3uFNDa1xtnMpe35dltt9OvEHRJxqL2miMUgLXhpE468Ov133gFVCiJ0KFooVh1L 8+vM471/13M34xSnbDLgl9YJAo6oa4mxiKLhsTlY0w3dvBl/DxeS5bX5tgTAM+04ui49 qSRzBsDy0QYiX2AxMs6SHBlqt3AZG6TC3/hOnOCtOnKZs5XqbqxRDGSz0fAfbTJcWzZH 72fZcPtNqB3haiJaYH0j5ysStLNwMfRWYVrE/hMN7ZRp2soha6INiX4WvyK7TJJDm/0a 0BJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:reply-to:dkim-signature; bh=AVRxITHRgpiea0PQRu71hObIdpCCXd1tddFTuoKEd5M=; b=hqMkhLmB95Y9AqA92hrX+kyTNek1l2fB3O6nkNGbHrXddbNAbvyp6IPzyC7zVDXPjy 5JWSBXW3455F18jTz/WZnKWA5TCTNG5Tp4x5SXoKngb2aPVReoC5OdMKZcedE+YHVF32 a9inZvpOkmJfIDeeHq8pdV4hf8B44wk1ammg7viW+JQcZBDxhqa2D87jhkFPObUIJ7I2 0qoFScvWqnLfPbpL6zGH30vhLRAjnnXN5/NZA2Hu7l82lHXPhPGPOMOcvcvUKEzxn9J7 3gGskQ6JUnKcjMLDgwtgBKob8uaeyB02oKO+i1Pmob/6oyy2Cs7ORhgn4F/8t9gykrix sYNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="AmZZR6+/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bq14si2422923edb.57.2021.09.24.23.46.59; Fri, 24 Sep 2021 23:47:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="AmZZR6+/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347806AbhIYA67 (ORCPT + 99 others); Fri, 24 Sep 2021 20:58:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346958AbhIYA6V (ORCPT ); Fri, 24 Sep 2021 20:58:21 -0400 Received: from mail-qv1-xf4a.google.com (mail-qv1-xf4a.google.com [IPv6:2607:f8b0:4864:20::f4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C49B5C0617BF for ; Fri, 24 Sep 2021 17:55:59 -0700 (PDT) Received: by mail-qv1-xf4a.google.com with SMTP id z8-20020a056214040800b00380dea65c01so43938400qvx.4 for ; Fri, 24 Sep 2021 17:55:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=AVRxITHRgpiea0PQRu71hObIdpCCXd1tddFTuoKEd5M=; b=AmZZR6+/WobaV3d/KTMW3XEm+/mJU1HTP/alrco2LxeX8sPbzL7l8R5VIEq9wXYyp7 P31gfDlcRexYcYK12mPrGpQSHiwq1+7jjMKOfcgumO3thuYh7379U579a8VXzaHynz/c Q3KQVXVmXyM9LNzIQGRL46YsUVsNUTTA436JsJh3i+G14dKyyalUZ6UHTH5GdEZXjP9r IiNGv+ok9CwUCbLkrQ6KhkOVblpqSFVi+lqel510DljUqO6ykZ33BWRlVYKAV98E9Pb3 w2kY0mdXtU63LGRjV1zY+2LpQRo0iJs3knGrr124qdmj7QQ2lJ+zuHgXzPFrmiw1XkSd zSxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=AVRxITHRgpiea0PQRu71hObIdpCCXd1tddFTuoKEd5M=; b=xIBwxgvnW4LUyj2CaQPI5GZROGRKL2/2ahRiEwLhWKc0hKJi98JIUuFbdOLpd9UK8c BLnCZbTdd2g3oxpIi8IxzhUhBSjCBuU1+FtSLqw7A5eAuFjTChKl+Od/DtWC3h8onskN n61miPtdI1pwmhUMKJvCik8gmHETx3fWpLj8i3TxjcNJwKl3aKn5kf4AcjjrwYJHRs/6 ZBI1OsJaVilBABycqyv5eRYIQ6lY8QOYBz/FYDnNWVD5o7Ev6bOr5v+3ngqjrZFbgJw9 iWwONKoIl+vyLPia9/Og2mRSoUsGFcbOMtoKjOi5LuX4Kg9kXXawT6jx74SvUmJ0bj5h ytUg== X-Gm-Message-State: AOAM533pbfZ5AzWUc/30yFygq5tHbLGNx8AuyB1qUJft6lTZfRV+2dUB nwHJObhQu8gQwThk+gVXMGHj/lfa15o= X-Received: from seanjc798194.pdx.corp.google.com ([2620:15c:90:200:4c72:89be:dba3:2bcb]) (user=seanjc job=sendgmr) by 2002:a05:6214:4c9:: with SMTP id ck9mr13433509qvb.52.1632531359011; Fri, 24 Sep 2021 17:55:59 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 24 Sep 2021 17:55:27 -0700 In-Reply-To: <20210925005528.1145584-1-seanjc@google.com> Message-Id: <20210925005528.1145584-14-seanjc@google.com> Mime-Version: 1.0 References: <20210925005528.1145584-1-seanjc@google.com> X-Mailer: git-send-email 2.33.0.685.g46640cef36-goog Subject: [PATCH 13/14] KVM: x86: Directly block (instead of "halting") UNINITIALIZED vCPUs From: Sean Christopherson To: Marc Zyngier , Huacai Chen , Aleksandar Markovic , Paul Mackerras , Christian Borntraeger , Janosch Frank , Paolo Bonzini Cc: James Morse , Alexandru Elisei , Suzuki K Poulose , David Hildenbrand , Cornelia Huck , Claudio Imbrenda , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-mips@vger.kernel.org, kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, linux-kernel@vger.kernel.org, David Matlack , Jing Zhang Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Go directly to kvm_vcpu_block() when handling the case where userspace attempts to run an UNINITIALIZED vCPU. The vCPU isn't halted and its time spent in limbo arguably should not be factored into halt-polling as the behavior of the VM at this point is not at all indicative of the behavior of the VM once it is up and running, i.e. executing HLT in idle tasks. Note, because this case is encountered only on the first run of an AP vCPU, vcpu->halt_poll_ns is guaranteed to be '0', and so KVM will not attempt halt-polling, i.e. this really only affects the post-block bookkeeping. Signed-off-by: Sean Christopherson --- arch/x86/kvm/x86.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 0d71c73a61bb..b444f9315766 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -10127,7 +10127,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu) r = -EINTR; goto out; } - kvm_vcpu_halt(vcpu); + kvm_vcpu_block(vcpu); if (kvm_apic_accept_events(vcpu) < 0) { r = 0; goto out; -- 2.33.0.685.g46640cef36-goog