From patchwork Wed Nov 2 23:18:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 14526 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp199753wru; Wed, 2 Nov 2022 16:22:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7ABvg06h25Qwby/f1AP4cvJMnQ1sYHAAVSIrRhtv+XRK5skdutYDStFs/GCmpeE9O6wM+i X-Received: by 2002:a17:90b:3b43:b0:213:fa1a:5326 with SMTP id ot3-20020a17090b3b4300b00213fa1a5326mr14611871pjb.20.1667431333722; Wed, 02 Nov 2022 16:22:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667431333; cv=none; d=google.com; s=arc-20160816; b=ioG/BSbwh//25rwDvO4qyKLqJyYkcmaTp4O/v3t6DNEimxLub8qHNvtrWgJCK3L13L AXwwrukxKAhsuNPC52KLQiT4IJJ4XsTHEzYwXLLfKw0Z1PURsttcd2Jtr0sA5nqroUk/ LfoXLek67As8Px1JywPtq0frx2WCqg65plMWBF5C0H9yc4PUJXkNDEMG4ZyIpuLSpncu FxCBdPtWrJdnFl5JpGORQGjBAWyrlHIKz8V8DpNwJdaK/PM4ZR66ehKJqD1sC5zgVK92 qAnZ3wuz6dddzKr/0h//ryakJxXyOtfY3bP2c1EJXtjRIZGQqK5sn6q7mI8dY8/bQF4e rWvw== 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:message-id:references :mime-version:in-reply-to:date:reply-to:dkim-signature; bh=2jZZfFf52GmkjzF4UkJBFUQx8TRwCaNEoxRzKdccz/c=; b=T6ybW6PfvXES3pVo3Wh3V5/l2hGt+0/bOFjfI/KDkNjhrT72iDhFB6N/kD6uELM+Y9 1CnhjhNOYcBRwe2y5KuTzKs3oO0rs1Bs103CI7dVvJiXHKujbzgIUW9oS173hSuxsIWm ZEDuqFmnWFZaU5g12qkzPAGCI+kfeeUjZabW4nxadLp1VbhSOGtrOYiR+PrWI8H35v2P CMSnmbhzSqo6cHXmGY5QlPeJczmej2fS9z4EX6Ksv+2/B+nCZlDNgXVuBIosjEXcmBUR J7fogITkjsb9ZM1E8HyxkW9P7iuAr36445Vhgz58/lqndJZHlyl0fajtvORzjh0BxCJR rfdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=eS+ADSAU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u3-20020a654c03000000b0046f33e40222si16430268pgq.669.2022.11.02.16.22.01; Wed, 02 Nov 2022 16:22:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=eS+ADSAU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S231258AbiKBXU1 (ORCPT + 99 others); Wed, 2 Nov 2022 19:20:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230387AbiKBXT7 (ORCPT ); Wed, 2 Nov 2022 19:19:59 -0400 Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1995425EA for ; Wed, 2 Nov 2022 16:19:26 -0700 (PDT) Received: by mail-pg1-x549.google.com with SMTP id 125-20020a630283000000b0046e9babe7b3so90198pgc.11 for ; Wed, 02 Nov 2022 16:19:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; 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=2jZZfFf52GmkjzF4UkJBFUQx8TRwCaNEoxRzKdccz/c=; b=eS+ADSAUDBr+3HDHnDb3Fr9sF+Jb8/UT2oH309j3Rm/86ObG6TRCn9IyhpjUkKBdpE kcCNHyv3vwGiHYQRvOqDpsz+Ka9M2XEJCdBD1BDMQE+yHelvK5eIZBtBOFMFVOay6VLL HRD1UaccDMN8QRmrJzaFGA2kakGK5P4xJGBM94BuLtDJAAqDK7hBLTZ7oOdfic4lXqK4 Fr39ZfZInLrcHKiM8fxmsZrdE64FtenP1A0FKcDrTDJZkpQ1QUJo1/Y5EttLt8eZYz9U +9QTVq6+Q+Y4pZ8EkuhDPhDFtAlj3OJomhnuiK5WjSAlU9kpBh9BdzMjPScyheuXuiwK D0tA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=2jZZfFf52GmkjzF4UkJBFUQx8TRwCaNEoxRzKdccz/c=; b=xK0JZJQohatZx8jas7WLet5Ejx1HmBBDU5hHYxr82eaYFqIrl72703OZMPUGyumdGw UxlVG0tRVUUSokQVIVwO4+Mbf2SVxA0cd9BYCHZ3Hgb2l4eejfeQdgGMO0TLH8LwNfPh GGKVXdQPYg3fPJt159s9VFRitmuPmfnbkCqagDUMe2ve+R70+gBo7bRkrWGheD9wszwj 8Z5oD2sfYDWi5J0fyoyzy077RqxpQe6/in3od5IigiSCFM9dHNIbyvdw8Vdb93sTBejD fTV8yThNH/szZu9gfZXUOZOUGs8BAZ4F7hC16B1oiaVGBZM5v/ja/C5S5wW5OcacGgi8 GqNw== X-Gm-Message-State: ACrzQf08Uku4kMEvKByKRAU1mZf4ChCpZxvFEF0ZRKSthJMBkFqFPB+U pk6WPCT/ZCBJ5dmttCKkcnNerGss+V8= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:90a:e7c5:b0:213:b7d8:1c4c with SMTP id kb5-20020a17090ae7c500b00213b7d81c4cmr25473196pjb.114.1667431166266; Wed, 02 Nov 2022 16:19:26 -0700 (PDT) Reply-To: Sean Christopherson Date: Wed, 2 Nov 2022 23:18:34 +0000 In-Reply-To: <20221102231911.3107438-1-seanjc@google.com> Mime-Version: 1.0 References: <20221102231911.3107438-1-seanjc@google.com> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog Message-ID: <20221102231911.3107438-8-seanjc@google.com> Subject: [PATCH 07/44] KVM: x86: Do timer initialization after XCR0 configuration From: Sean Christopherson To: Paolo Bonzini , Marc Zyngier , Huacai Chen , Aleksandar Markovic , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Matthew Rosato , Eric Farman , Sean Christopherson , Vitaly Kuznetsov Cc: James Morse , Alexandru Elisei , Suzuki K Poulose , Oliver Upton , Atish Patra , David Hildenbrand , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, Isaku Yamahata , Fabiano Rosas , Michael Ellerman , Chao Gao , Thomas Gleixner , Yuan Yao X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748428477857465530?= X-GMAIL-MSGID: =?utf-8?q?1748428477857465530?= Move kvm_arch_init()'s call to kvm_timer_init() down a few lines below the XCR0 configuration code. A future patch will move hardware setup into kvm_arch_init() and slot in vendor hardware setup before the call to kvm_timer_init() so that timer initialization (among other stuff) doesn't need to be unwound if vendor setup fails. XCR0 setup on the other hand needs to happen before vendor hardware setup. Signed-off-by: Sean Christopherson --- arch/x86/kvm/x86.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index cd9eb13e2ed7..9a7702b1c563 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -9320,13 +9320,13 @@ int kvm_arch_init(void *opaque) if (r) goto out_free_percpu; - kvm_timer_init(); - if (boot_cpu_has(X86_FEATURE_XSAVE)) { host_xcr0 = xgetbv(XCR_XFEATURE_ENABLED_MASK); kvm_caps.supported_xcr0 = host_xcr0 & KVM_SUPPORTED_XCR0; } + kvm_timer_init(); + if (pi_inject_timer == -1) pi_inject_timer = housekeeping_enabled(HK_TYPE_TIMER); #ifdef CONFIG_X86_64