Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp670575iob; Wed, 18 May 2022 10:15:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5SD1zyQgt/jj1k24dTM5khYdKwnSJx51yH2RdhpRbMFdwcWC7aDjgueKeA0YjVruWJ/f+ X-Received: by 2002:a17:90b:3e8a:b0:1dc:9d7e:1e12 with SMTP id rj10-20020a17090b3e8a00b001dc9d7e1e12mr468145pjb.58.1652894141168; Wed, 18 May 2022 10:15:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652894141; cv=none; d=google.com; s=arc-20160816; b=CQQIg13+bot1qr5ICZSeUGLHTfsTeZsmqUBUHrXro2mLp2WZi87ZTEogdYtptPeW9j rYVhU6w8qD/QBxfuixAwTGQQoyXuzFjE9PF+3eiMS8eO850wAVH7xWYPX/gMEhGYQe3X fL8pkcA0tkWX3tdQKYDITKRuFawG5VWbVN1xB7W7StZF8lZLAAddax9xRjeYQFgyn6/4 e7pjF/NvhnmKdbWwPgIh6hnQvxuz37gDyTDC+C+HCxRbk9XEbMvEn5tX2i0P5ImYgyQS qhW+r8Et8xM4U5i92gk+ZMTvNOtpfjZXA60Wa648g7jsYQikPKxx/+bU8JoHL73dZ12V dBCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=FxD9P4XnF1NnW2znaHobWArEduFPf/Vy60CUDQ3Fi/M=; b=JK2xRUelr649qEJ3IKSe++lZWr0oz4JuxU4tb8sQkuGREFE6ZwrX2LxtjQjO1OrHdH HJNPrG7jM9Rs4OyAEhOAwblV5cYKDHJ1IZB2Fu+iLY+OxvKmFtBIBDrruBnvttxEtFUj h5raclxDmjp+/oM+8e0YKvr5DSSxESndJRxSDT0jeiEdbFS7/1ZGaNdqDxVjJ3eD+3wT DViJHPEtdfWjva+tyvp9AnKPv/6zow5GkVaBZsZRjIXp1/dOX8xGTaus3fQ6G7f1bk4f n6U7PG0c61dcWqlVa0lAg4pNYVeS6W8a4YokkQZKpZaFFMHXlgiP4tSsFRoxpefLt+I3 Njkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WsDl4bOP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id b15-20020a63d80f000000b003ab2425a22esi2689293pgh.583.2022.05.18.10.15.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 10:15:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WsDl4bOP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2889720D4DC; Wed, 18 May 2022 10:15:39 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240777AbiERRPY (ORCPT + 99 others); Wed, 18 May 2022 13:15:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240720AbiERRPX (ORCPT ); Wed, 18 May 2022 13:15:23 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1E2D220D27A for ; Wed, 18 May 2022 10:15:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652894121; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FxD9P4XnF1NnW2znaHobWArEduFPf/Vy60CUDQ3Fi/M=; b=WsDl4bOPbbzn9o4sMZ2lu1ajsyOL5GWjQ1EjoZ8h43gvidJGLiPlMVNYa5pQHB3LeuI4cw 9RzMX5BURRxg6O1obASiSGd7XnhuKEgeoSs67ynVsBy/ZnTo6IapKBeaI+pIdNcA9Mw4t6 dvk/EBSq+Fmhwgji9exjafP96RXejO8= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-399-UGKIbxl-PHS4oIRfLhl59Q-1; Wed, 18 May 2022 13:15:14 -0400 X-MC-Unique: UGKIbxl-PHS4oIRfLhl59Q-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 639851801388; Wed, 18 May 2022 17:15:13 +0000 (UTC) Received: from starship (unknown [10.40.192.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id CDFC1C202D1; Wed, 18 May 2022 17:15:07 +0000 (UTC) Message-ID: Subject: Re: [RFC PATCH v3 02/19] KVM: x86: inhibit APICv/AVIC when the guest and/or host changes apic id/base from the defaults. From: Maxim Levitsky To: Sean Christopherson Cc: Chao Gao , kvm@vger.kernel.org, Wanpeng Li , Vitaly Kuznetsov , Jani Nikula , Paolo Bonzini , Tvrtko Ursulin , Rodrigo Vivi , Zhenyu Wang , Joonas Lahtinen , Tom Lendacky , Ingo Molnar , David Airlie , Thomas Gleixner , Dave Hansen , x86@kernel.org, intel-gfx@lists.freedesktop.org, Daniel Vetter , Borislav Petkov , Joerg Roedel , linux-kernel@vger.kernel.org, Jim Mattson , Zhi Wang , Brijesh Singh , "H. Peter Anvin" , intel-gvt-dev@lists.freedesktop.org, dri-devel@lists.freedesktop.org Date: Wed, 18 May 2022 20:15:06 +0300 In-Reply-To: References: <20220427200314.276673-1-mlevitsk@redhat.com> <20220427200314.276673-3-mlevitsk@redhat.com> <20220518082811.GA8765@gao-cwp> <8c78939bf01a98554696add10e17b07631d97a28.camel@redhat.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 On Wed, 2022-05-18 at 15:39 +0000, Sean Christopherson wrote: > On Wed, May 18, 2022, Maxim Levitsky wrote: > > On Wed, 2022-05-18 at 16:28 +0800, Chao Gao wrote: > > > > struct kvm_arch { > > > > @@ -1258,6 +1260,7 @@ struct kvm_arch { > > > > hpa_t hv_root_tdp; > > > > spinlock_t hv_root_tdp_lock; > > > > #endif > > > > + bool apic_id_changed; > > > > > > What's the value of this boolean? No one reads it. > > > > I use it in later patches to kill the guest during nested VM entry > > if it attempts to use nested AVIC after any vCPU changed APIC ID. > > Then the flag should be introduced in the later patch, because (a) it's dead code > if that patch is never merged and (b) it's impossible to review this patch for > correctness without seeing the usage, e.g. setting apic_id_changed isn't guarded > with a lock and so the usage may or may not be susceptible to races. I can't disagree with you on this, this was just somewhat a hack I wasn't sure (and not yet 100% sure I will move forward with) so I cut this corner. Thanks for the review! Best regards, Maxim Levitsky > > > > > + apic->vcpu->kvm->arch.apic_id_changed = true; > > > > +} > > > > +