From patchwork Sat Sep 25 00:55:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 12517183 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AEA7CC433EF for ; Sat, 25 Sep 2021 01:04:33 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 727356105A for ; Sat, 25 Sep 2021 01:04:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 727356105A Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:References :Mime-Version:Message-Id:In-Reply-To:Date:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=rTpDbY2dzFSkL57TmgoFxDOrWMjwTiQ3nky/4vZud+E=; b=ovVWi24qW8prh/ 6k/u0ZI2//joPql4acBEdT8GY4Vu9w9vt7LRIBAscGzDwH8mlCerOZKcP33ohywpxz9qRRt3WerAB HIDkLPTOXMEBaeyMRhs1DaL/mBfxyBj7QJWStYbfcHdyv6R22P4qNlQGcNjBqCq6CAsSAiqRowDYX ArkCpwm3tm6y1chpaPxLmDi/i/5B8bzHLP8rbjyIxGjtqOoDOH+UMSXXQaF/MBuUrTViPCjriQFV3 NZJ9ek3ivLwAP3u7G6rHfxdwKWC65bCgJRxPPz5me8vhPx+8GUZ7UYV/kT5DzFapDhU6VUmt6V+Oz GpGSybPAcL33qGODKBZA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mTw4i-00FsVJ-3e; Sat, 25 Sep 2021 01:01:56 +0000 Received: from mail-qv1-xf49.google.com ([2607:f8b0:4864:20::f49]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mTvyy-00Fq2K-Im for linux-arm-kernel@lists.infradead.org; Sat, 25 Sep 2021 00:56:01 +0000 Received: by mail-qv1-xf49.google.com with SMTP id l18-20020a056214039200b0037e4da8b408so43620988qvy.6 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=Dx0HbI4s/7LNslVaWHJjdvBPHr2xYCwnlJZdBpTWyW0yNDfTQYkTIceSxwaaInyGb5 yqZTuj3GRbPXWNLoydTodoug0Vv06qW4FJfWWl4zxEDHqZNdd3FRKLzJbo/Id2pKXcel dGv/0Zhlyr0TO1ygzZxdWMgC49kNcpUOB4cgRSYyrQP5xO25Q43kUX7d8zaJYCZCjHmG l/KS2xIPUpbHcCT2e5sUdfsADHdKJ49shsiv9lQ6X589NpEbCpmi1znbc+JF8k21NJo0 AHt+mgq+5rl+dhD0Td1XvIPCNH2Dfu4MmmHE9w2xWoduwAhcD1LbErIV1NfkVJRuI37S H85A== X-Gm-Message-State: AOAM5315RIpHNmQtVWdpkH5CwQrxG0b0QJM4SPdJy9cdr1tBakVcTAZd 02okTM/88Tziz85v8RjoYReAlJoeRQg= X-Google-Smtp-Source: ABdhPJxx8SkwYvYT9fuqd8J8/D25/GRV4ipTe+x7gxZbCgpsQNDucApI5+ArqZrudVFBp8cYqIvrEUF3+SY= 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) 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210924_175600_658476_9D3DCF81 X-CRM114-Status: GOOD ( 13.12 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Sean Christopherson Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 Reviewed-by: David Matlack --- 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;