Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4050939pxv; Tue, 13 Jul 2021 09:36:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyd7XqeXkgr9PhEhikLpWvMpB3ALCjxknM+RKddtBCPKtXrBNp5O5pNHRzFAyGuKNTH+QgM X-Received: by 2002:a5d:4d8c:: with SMTP id b12mr7006735wru.332.1626194182487; Tue, 13 Jul 2021 09:36:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626194182; cv=none; d=google.com; s=arc-20160816; b=XgLQy4ttotijMWheJsB/5TOBPhw+uOMxTaqVDHM+bY3RDR00pEcCEmkvzoWEPHMHGA xocmU0fYS8zCSvtL50KdUDkN/L2jCqHho0clbJg9vdZeVpBl9QGgPp1IY/k/4GipwVY1 bFQPYrr+SENDHJRJkhyv+fIr1wNBYIyfCoCAJTHrsVG81Ayg0XkJybn/zCYinBbQ7rSi 7/U874hs5QSx+MW8RSuDa0dzv6VJjZInBTyhjuZH3vQa6T3uaNJhBQdvXLhDExD/9LY5 c/z7wd8jMfuXP/nSEFZMv+dvdaUOBsPCLZrSNaGOEa9v/c5QYH8MBXTL5+dKtOljl2A/ 2zSA== 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=CzDDt8Xveb+AiWMJHUA0uSHyGS/Vcfc0iWePgVgIMys=; b=fyROoj5XNVd3IlSjbBD54NsM/CjslM8XTj1eOuONHO/3hEXhgGA7LipQ9HRyPeNbH9 RWFYvX72KVDQ1QANEXGy8/FBZfFtMUn4oag6HCPSUs2G5NRcHKN9t9zZP/BXcmMKCIsS Zbqq9bSMywoNIew7Kop5ysXKfdg99iqJbkDLfh3QXfTFSkOXpYIb9DFxzUvJfoNmw9xs as2FvW40Cj2QvZFf/roztwEcw0/Dk4c/m9Y+/siyQnOpFp5wMChsO+OGnxF8rwEU/YgC e2z6fvv5Ou61phWWPluITbLglvghqRKZaokfsGNQmiUt7UoSLobbIyoj+l+12s00pvsc Edew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="t/atGzTC"; 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 o21si21501697edc.577.2021.07.13.09.35.56; Tue, 13 Jul 2021 09:36: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=20161025 header.b="t/atGzTC"; 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 S234396AbhGMQhF (ORCPT + 99 others); Tue, 13 Jul 2021 12:37:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233930AbhGMQgw (ORCPT ); Tue, 13 Jul 2021 12:36:52 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9639C0613AA for ; Tue, 13 Jul 2021 09:33:59 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id j186-20020a25d2c30000b029055ed6ffbea6so20161094ybg.14 for ; Tue, 13 Jul 2021 09:33:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=CzDDt8Xveb+AiWMJHUA0uSHyGS/Vcfc0iWePgVgIMys=; b=t/atGzTCApK+WNx7wLzAjU9pLgb4MFOh9aA6d7dCtEFsCMWJxKXU1eUEIbWIQUlpJo t+GkqFwH31xp4VkQZZDtPm2SFWkIGwda8iaXl20eWtg+mQqecMO2J5NHpFfpbU8ye7xW k8HJEnbn/ILcp7nTdho08R1WmRHOkG1GJt6/o2suwvxDuEXFznyhpEDCNDHIN6+7cN5K er0Qt0MDzUOiVsthGvPQVsdzIF4mSdBl/UyLFvIVOBdncApEgqfzyxj/S6hBwUm+aP2E CrLITG0nS33ReX4zpN93eCjBWjLWtuu7uiP5lmxJhcYO4SNKsnVNlP9Gmo985EkY13nb mboQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=CzDDt8Xveb+AiWMJHUA0uSHyGS/Vcfc0iWePgVgIMys=; b=l2vLirDSJNLp2krS2nx4OUDsvZJjNKFJj6MoyvPf9m50BurkJecd09bTBHk26q7X/w G2rd1DO9UD0M4jhTKDpcfYbn9CQRxkgmGTQVW0GKFYqb7l9QKxY3jBamy8BJHRWRhYdv mKu3irE7jYQlE0DEGeTcnStbrFGeV0gfJQbcGaAHifRHefuF3wKDmrMDKeoqadaXO/SS 9Zqp3yK/15Yp1JXtho/lpP+35nVc99QMI93UObzoLkw61eHKVJqph7K6NmX7WlItwQud l5BaaEZ6HTxjaVQcgsjDpfDo9m5hWUvP9Y+Y3KnORRlPghVQH+bOSU/lyy8luxgxvtRq F8cw== X-Gm-Message-State: AOAM532G6GI5qoz2GqVwY9hF2uNviBwayPX0Upb+T0tLQuqQCMWj/u6l HyhV/Sv1YCP4r5BQ3GhySvLLE81bc5o= X-Received: from seanjc798194.pdx.corp.google.com ([2620:15c:90:200:825e:11a1:364b:8109]) (user=seanjc job=sendgmr) by 2002:a25:8482:: with SMTP id v2mr6838057ybk.214.1626194039015; Tue, 13 Jul 2021 09:33:59 -0700 (PDT) Reply-To: Sean Christopherson Date: Tue, 13 Jul 2021 09:32:51 -0700 In-Reply-To: <20210713163324.627647-1-seanjc@google.com> Message-Id: <20210713163324.627647-14-seanjc@google.com> Mime-Version: 1.0 References: <20210713163324.627647-1-seanjc@google.com> X-Mailer: git-send-email 2.32.0.93.g670b81a890-goog Subject: [PATCH v2 13/46] KVM: x86: Migrate the PIT only if vcpu0 is migrated, not any BSP From: Sean Christopherson To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Reiji Watanabe Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Make vcpu0 the arbitrary owner of the PIT, as was intended when PIT migration was added by commit 2f5997140f22 ("KVM: migrate PIT timer"). The PIT was unintentionally turned into being owned by the BSP by commit c5af89b68abb ("KVM: Introduce kvm_vcpu_is_bsp() function."), and was then unintentionally converted to a shared ownership model when kvm_vcpu_is_bsp() was modified to check the APIC base MSR instead of hardcoding vcpu0 as the BSP. Functionally, this just means the PIT's hrtimer is migrated less often. The real motivation is to remove the usage of kvm_vcpu_is_bsp(), so that more legacy/broken crud can be removed in a future patch. Fixes: 58d269d8cccc ("KVM: x86: BSP in MSR_IA32_APICBASE is writable") Signed-off-by: Sean Christopherson --- arch/x86/kvm/i8254.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c index a6e218c6140d..5a69cce4d72d 100644 --- a/arch/x86/kvm/i8254.c +++ b/arch/x86/kvm/i8254.c @@ -220,7 +220,8 @@ void __kvm_migrate_pit_timer(struct kvm_vcpu *vcpu) struct kvm_pit *pit = vcpu->kvm->arch.vpit; struct hrtimer *timer; - if (!kvm_vcpu_is_bsp(vcpu) || !pit) + /* Somewhat arbitrarily make vcpu0 the owner of the PIT. */ + if (vcpu->vcpu_id || !pit) return; timer = &pit->pit_state.timer; -- 2.32.0.93.g670b81a890-goog