Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp1794226pxy; Fri, 23 Apr 2021 17:52:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwHzv141qlj1UGpGJWyTLtYm5qRaqWdoUuvy9ExAQqLi1KgbfQoKtI9hE3MZx6alPnVcSry X-Received: by 2002:a17:906:c9d8:: with SMTP id hk24mr7016750ejb.480.1619225549761; Fri, 23 Apr 2021 17:52:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619225549; cv=none; d=google.com; s=arc-20160816; b=p8DbfbGiN0o+JNFWonQnnJrf0EGDTL1ck+6VmMKBQreByZUuYqqcoIX0P5O+TSt16V RLdE0zjFJ3ZqMJO4qsrDwPsiX11IBrIbWNhusGcIn0xNHZZnAuQCxQE8ZtJ/tOCnEbFM Y5sZalbdVq6pj5qK9Lx4bgT1s/ZZ6KHnxfALZi+pDOJ43M5csmQ0fGLrYd8MvO449Nzw jAROGNBYJUzOUAA4/8DHHJPYH7rCRiBxzvgPEvrQC1eA6E33k8rd3S5r4Ia2suTjr7+r pooswZG+GGJGEjW9mM5goY8ieIgZs9gqlwSKzo4UpduYqPO8413eKBB9dBPGkiLihq1W pFTQ== 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=DJN/sqIDywz/2FMtb4bxhM2j3upE+B1Quag3pNmQ3Oo=; b=rBSnl/U6FAZ3XB21Hqvm8YmIYQj5MckU9X0wdZfsNk2xfNiVAsrzbuukSoY7UYVLI5 58qRLRaNKvOgai2E76JKzAlnjE3AIwo30t21sSx3FwoMpgZU18XHtKdjTOIr5g1Coklz z631ra1NbtB96Ma8kevEOVkFyar/ClDAdSeyfyDwvmqMdgDXC9VIItFgFP8dtXbUxWaY An0YBJZ+gHI75NDI6iHyJbri+ohldnkxp9lZkTsSd+FE3YDB/76DjVbtw+aHagQJwqIP HhaYGjHSlP/onqeGkaB7IiVp877c48YyQX34Gz4toqzAnOQ47+mNIgHDpzlwFDkJ+hFk 47ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=sZAszlVU; 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 f7si6294321edu.503.2021.04.23.17.52.06; Fri, 23 Apr 2021 17:52:29 -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=sZAszlVU; 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 S229957AbhDXAvX (ORCPT + 99 others); Fri, 23 Apr 2021 20:51:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244185AbhDXAtR (ORCPT ); Fri, 23 Apr 2021 20:49:17 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4A13C061361 for ; Fri, 23 Apr 2021 17:47:37 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id a7-20020a5b00070000b02904ed415d9d84so4616155ybp.0 for ; Fri, 23 Apr 2021 17:47:37 -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=DJN/sqIDywz/2FMtb4bxhM2j3upE+B1Quag3pNmQ3Oo=; b=sZAszlVUTvzyfXu+nPT1sSpYj6JD1dvWEsBo7Fa8ZOaVrztp8j1FjXhNAEl4UsxQ4v G/v6zCJjgHHEdEBvvS+vhX8kL6jFFT07f8xMpxv76fFAXUdyPYTzD6nOltl/cvLoRAOr JUW3K2I9ThxLa4WbtspdveKg8Gi7Ieiddv+pYVuaIXGh8GGSGjMmAan01ASS5CYd58xP zG3NGAxWnobFVYq6Kny++rrHoILQoqRVbhLTi+WY1v3NRLFU2/jNF3HLsbc2Kc6kYlhn cU2HcA9iXhu/gjXtmgoSZsgSV7fz6XGFe1wuMMyH984RXLdSOKKAl/O4X3A59SPATJgC hEiA== 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=DJN/sqIDywz/2FMtb4bxhM2j3upE+B1Quag3pNmQ3Oo=; b=hbAnQ8sZxlO0eRbXavg2iQVkhHxFT3ulKCyAr+W6lcRQjqZaCTDKflVAVHg22udcUB gR/8i6BoCH2eLTkmEm/rnsPONio0u2uy5PQBsPmh0WqNGAD0wbedwlpSvXc66jmZdlL8 joIb0qaxjLZDowT8HfY4qFhIxauCtgwEu8KR+WybnEGiNo75aG2r/YyA3+SWAGATQ3lw fxD7gyBxm12Glufohp4ApL2hJ2OjoK0ZjPuwlK2Va2B3mDg6wAzHFlFTo0q0wh3DoTfh 88aLyqvkp+OPsOF+xtdwO5KqqZ3Vt3M7VYXFfr0+e8O2b1zEQxbQM+AF8ysMhoz4qpkH uUQw== X-Gm-Message-State: AOAM530RM4vDY0b/Rh/LNZtcriBkDjcNz/GFdtYlWl6r56RYqwunO96T TkW3wZ2exXHk8IUoAweoHbQuZyZK8Qw= X-Received: from seanjc798194.pdx.corp.google.com ([2620:15c:f:10:ad52:3246:e190:f070]) (user=seanjc job=sendgmr) by 2002:a25:4946:: with SMTP id w67mr9609876yba.141.1619225257191; Fri, 23 Apr 2021 17:47:37 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 23 Apr 2021 17:46:19 -0700 In-Reply-To: <20210424004645.3950558-1-seanjc@google.com> Message-Id: <20210424004645.3950558-18-seanjc@google.com> Mime-Version: 1.0 References: <20210424004645.3950558-1-seanjc@google.com> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog Subject: [PATCH 17/43] KVM: x86: Open code necessary bits of kvm_lapic_set_base() at vCPU RESET 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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Stuff vcpu->arch.apic_base and apic->base_address directly during APIC reset, as opposed to bouncing through kvm_set_apic_base() while fudging the ENABLE bit during creation to avoid the other, unwanted side effects. This is a step towards consolidating the APIC RESET logic across x86, VMX, and SVM. Signed-off-by: Sean Christopherson --- arch/x86/kvm/lapic.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index b088f6984b37..b1366df46d1d 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -2305,7 +2305,6 @@ EXPORT_SYMBOL_GPL(kvm_apic_update_apicv); void kvm_lapic_reset(struct kvm_vcpu *vcpu, bool init_event) { struct kvm_lapic *apic = vcpu->arch.apic; - u64 msr_val; int i; if (!apic) @@ -2315,10 +2314,13 @@ void kvm_lapic_reset(struct kvm_vcpu *vcpu, bool init_event) hrtimer_cancel(&apic->lapic_timer.timer); if (!init_event) { - msr_val = APIC_DEFAULT_PHYS_BASE | MSR_IA32_APICBASE_ENABLE; + vcpu->arch.apic_base = APIC_DEFAULT_PHYS_BASE | + MSR_IA32_APICBASE_ENABLE; if (kvm_vcpu_is_reset_bsp(vcpu)) - msr_val |= MSR_IA32_APICBASE_BSP; - kvm_lapic_set_base(vcpu, msr_val); + vcpu->arch.apic_base |= MSR_IA32_APICBASE_BSP; + + apic->base_address = MSR_IA32_APICBASE_ENABLE; + kvm_apic_set_xapic_id(apic, vcpu->vcpu_id); } kvm_apic_set_version(apic->vcpu); @@ -2461,11 +2463,6 @@ int kvm_create_lapic(struct kvm_vcpu *vcpu, int timer_advance_ns) lapic_timer_advance_dynamic = false; } - /* - * APIC is created enabled. This will prevent kvm_lapic_set_base from - * thinking that APIC state has changed. - */ - vcpu->arch.apic_base = MSR_IA32_APICBASE_ENABLE; static_branch_inc(&apic_sw_disabled.key); /* sw disabled at reset */ kvm_iodevice_init(&apic->dev, &apic_mmio_ops); -- 2.31.1.498.g6c1eba8ee3d-goog