Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp37256pxj; Wed, 26 May 2021 15:26:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5M2FkAIBJrxj1M9nLUgtYCmss0r796F9L+lccv53flDSgxIjHyW8heCK2lkhw/5PkyYAB X-Received: by 2002:a05:6638:118c:: with SMTP id f12mr382901jas.143.1622068003935; Wed, 26 May 2021 15:26:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622068003; cv=none; d=google.com; s=arc-20160816; b=zwXYhIKxEDcs/FMuzWUQdfz3+lOSKf7YNnCFUWUh/5MOf52QfrJIvkt9U21PZxBIdP u7rjv+JAmLHENHqs0uj+qLR8Zbn82un4/mxvKtvixEb0O6av8rObZNmHYGpdXtDVX5vx fwmjsdnpof0hZoJfI+qI/pHVSz2fOBx6dnP6i3QOlbHfBEin3uTS9WrCZxGBB0ioZUXV HMoqqektbl9EdnY4Qa+JDfe0JS4hrsEQij7YLIVhY6h5HpqyCd9LE34DUZBILh4p7NXk v9xKfELvxxVb3xnzdLrbB8mIgR7LbKED8qodmrwmE86b5xKikMy6mRHKgPPO/yhn5wEl v7HA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=gyPqMlWx0UGmus8UTSY9WUsK8ZBsk5nqFBqX0s/G7yY=; b=ex7wG61HGOviNa04frhrmbuVC5Zt54ocSaJm1C2dNZVuhNe+0nvD4Vy26gONVEFYW9 YaoRnpCvEeFFKx3cx3d+XbHpmbGninMl57evlHPsDtumvaq10mDD+Z5aGQ6kJWr8vI52 x5/GcJH7tmHspdrmLCpmCdUZcloLyXElAnHo1wOMG8PAbF1ZLhIc0ob6RIGSkHA96zH3 cO4iMHhbX1P5kI7ux+tJ2Upj3G89hGrxTRLMdanjI0tedOiVk4VPkonp2uM33IPQF5/6 bXrUnRzNCXh4vm6mNyK8ODQbLE2CAlUuE2GB8EzZTeMk+633eE6d4t+2m8calOtmm+qs PhPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="p/Ou/fdm"; 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 h6si305114ili.157.2021.05.26.15.26.28; Wed, 26 May 2021 15:26:43 -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="p/Ou/fdm"; 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 S235376AbhEZPQl (ORCPT + 99 others); Wed, 26 May 2021 11:16:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235335AbhEZPQk (ORCPT ); Wed, 26 May 2021 11:16:40 -0400 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82323C061756 for ; Wed, 26 May 2021 08:15:08 -0700 (PDT) Received: by mail-pg1-x52f.google.com with SMTP id m190so1226084pga.2 for ; Wed, 26 May 2021 08:15:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=gyPqMlWx0UGmus8UTSY9WUsK8ZBsk5nqFBqX0s/G7yY=; b=p/Ou/fdmAh55byEwBF8c18CI5ZSzs8YfUQ6WzubkB1roSNmpO8jAtO0ruzU2WRzTZb OTPta8JD+/cVxf1qamokAXWgTI6siNRm3yG706F4Ba9GBdDI+dtUZgeb7P92tW/+arGh OlIsi9Ir/+WIeXYP/th89Jf8VfoNsY5trO+Q2Z6njeDAHeWdNhiNBNEg+rWcjE2Q1aFi PCWZj7FdC94BdPguA+h3UmiUk0/gCNBoc7yhftUXDjrNZJTq0S5avzbwYyGPzvEmuQFS i6TlRmDo72KHfPLNA0bfq7AyEB1YP+U0XHK8SQtK5XPBGdihpoHSoAYKhNa20YnLVRa0 Qm+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=gyPqMlWx0UGmus8UTSY9WUsK8ZBsk5nqFBqX0s/G7yY=; b=Vf6Olpu1R/Q281NF7JEBL9kLQl13ZUegjhlOms85CAe2WrF17Ey/rL+hg4hEFazH4m afcsJlKesBtJ0uhh7CAP9EARpvtUVkPETFSsHZozFdlIlggnOAqChYBNIZPAUBz5RYQQ aXbeWNcOQieeoiFJLyEPc9vjGOKwbokIRKzPIPFOUL92SKD2cqbknPZoWwjhv2VIO5ls a+3NqE/vrkpH6VETd2MLpCnW4MFFvt4FbYfERalC1NAh5amhN9XgKPqwo7H9Y4bF8Fcu cbHlPKhBGzsRAk7RF5mXpdp2uanmC6rq39bBI76v2LCZHaM+JfhGQfiucfgMj8Fe1vmY WaRg== X-Gm-Message-State: AOAM533nCtEPOKOqtJw0vwTawK9+EV0k0MjlsirjXHw19t1IkmbsCqAu kWawHUECG0frEk3bL4zfsn9BRQ== X-Received: by 2002:a63:e14:: with SMTP id d20mr26047737pgl.35.1622042107988; Wed, 26 May 2021 08:15:07 -0700 (PDT) Received: from google.com (240.111.247.35.bc.googleusercontent.com. [35.247.111.240]) by smtp.gmail.com with ESMTPSA id 184sm15445516pfv.38.2021.05.26.08.15.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 May 2021 08:15:07 -0700 (PDT) Date: Wed, 26 May 2021 15:15:03 +0000 From: Sean Christopherson To: Reiji Watanabe Cc: Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 17/43] KVM: x86: Open code necessary bits of kvm_lapic_set_base() at vCPU RESET Message-ID: References: <20210424004645.3950558-1-seanjc@google.com> <20210424004645.3950558-18-seanjc@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 26, 2021, Reiji Watanabe wrote: > On Fri, Apr 23, 2021 at 5:51 PM Sean Christopherson wrote: > > > > 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; > > I think you wanted to make the code above set apic->base_address > to APIC_DEFAULT_PHYS_BASE (not MSR_IA32_APICBASE_ENABLE). Indeed! It also means I need to double check that I'm testing a guest without x2apic enabled. Thanks much!