Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1250720pxj; Wed, 19 May 2021 01:34:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8AhjxPFTpkmPqfzcGGfvTojrOjTSac8SIqBJhD8WqUv8yOBW6mwBfgM9kjTpoTgljlp5z X-Received: by 2002:a05:6402:128f:: with SMTP id w15mr13165616edv.354.1621413270211; Wed, 19 May 2021 01:34:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621413270; cv=none; d=google.com; s=arc-20160816; b=OCAYYh9mxyVi99Onr5VWJkglPjEs/pLLNaoDjIwYYpIg0M8KPDUvugOKnDW7GHovWg FMPcwDg9A1aHEOR5ap7n1tstN4+O8e324ug6702aUIwHlGIz49B/tz7X3RkgVUNOwXdo M2Qq7cwHT26pamtVCqQrQliWAV1DWL5IUYwTfGx7eVJHX4zy4p2cP2IXIa5UF/4rprmy sBScJwTbYfBU0J+7k4iPelA6+W9WnK9ei6vFgPxhSQc9wsQEx5qADPkLfUJ79JHMQpxv eXIcCSi7C4SMl3WvGZb/jOXsj/99y+i41iyBeSLzw733JptJ2gNdH1zhEZ5DVekkP/ho Hhhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=javM02b4/WyQxR7G/IZDk0+ZM0MvdenmOr8WXepdWxM=; b=Egej7c01gNBNzjaz8VrfVnTx2GFyU2JErEsiBMwOq/N/3gN07l83dyazdZlD/XNksN aWSU8u22cLUKp/65lFW25lA/bScW9HFTDGXVG+wjJRa2TN+1DJ3uWAT6TeUqCjHTshSx vst/f5LEcGjOxAZvvQy49y4y7Hu9aNwxZrYZZGHCP9YgPVdhh3/vAfGbcSzS22whVtBp IhgedHG9ma7Vt7xu7cmvflIL2ZncBGFqCqIAiGUcJdwlo0zRPEONv43Ic/cgBerT4mJv SgIkouOnbJCEbNOuwm7SGa3jGW9sYpRGwt/ayQjLUJcWTWUZw/UKonBBc9267R1x0elj z58w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=I8sLUCn4; 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 g16si13682595edr.585.2021.05.19.01.34.06; Wed, 19 May 2021 01:34:30 -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=I8sLUCn4; 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 S245737AbhEQV6M (ORCPT + 99 others); Mon, 17 May 2021 17:58:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235014AbhEQV6L (ORCPT ); Mon, 17 May 2021 17:58:11 -0400 Received: from mail-oi1-x22d.google.com (mail-oi1-x22d.google.com [IPv6:2607:f8b0:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 052EFC061756 for ; Mon, 17 May 2021 14:56:55 -0700 (PDT) Received: by mail-oi1-x22d.google.com with SMTP id v22so7876591oic.2 for ; Mon, 17 May 2021 14:56:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=javM02b4/WyQxR7G/IZDk0+ZM0MvdenmOr8WXepdWxM=; b=I8sLUCn4ThTDhZTcCefu7YoeKN5+ReQGR7FONXUgZ6bljED4gnkCO2Gr2XHJWg2/Ej HyIDWveaB6jZgD9q1cWJYpyxkRZibRg2cc/oWbzczvsg6CP35npBbkAdC6iY0OHtG33g Nb3f3pbnohEhnNH/B8SDLTMZN/TDxDT+zRPMKXXhsWbzUYABziLnXcorj5vFbbC5b4iL rxiGXDGwGupVkGtpUuOMc2G1VzLT8vclHGci0Z69/S7rK/igWgNavg/XdOGyDA/HpRkT SFl0gqrua00z+WosbSRwfA7O1koHamJcvPprhj0XAaac0GXbLhRj5/aFFLAyYiDv0ni/ XPnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=javM02b4/WyQxR7G/IZDk0+ZM0MvdenmOr8WXepdWxM=; b=iaRawXyT6dPmIs+6Zx/+LJW+ElxV10kttkmaZb4Jd/gSUVSBN19lqvBO93rRPh6Fbz c56FkqWXOjJngJtQIzztwqq6YUXW88Ot/EatOapfG6rwjO2h+50+nBLWEbQeAB/iZ7Mj F8zlgddUhNlNOAO2bgN9hksP6jY/h/g8vWbfMk6NNlxQT1kEHxR423++/ge5zkwf/dOU 6JqeNXucbNeTEeIkfdJBdPU8muSwa8UqrcuzBvqMLYfO8OtVq/KIrFegmvIaqXLS0ZpN ZeGkyBHl67fiZplnc4Ew7fkqMOZbeRNJ0fvn8hcSGJL+EVFp79/Y8axZmyM2q1Tsh4Ip QfCA== X-Gm-Message-State: AOAM533/GoLcN9s6JhmqzNndoZYCpabYSGqhXeq84PQFhgVS7fG/65sZ Laf4TIw+ccZxzco76e8dpq1lz72BX5QMuiJBQy5NWg== X-Received: by 2002:aca:5358:: with SMTP id h85mr955353oib.6.1621288614176; Mon, 17 May 2021 14:56:54 -0700 (PDT) MIME-Version: 1.0 References: <20210513113710.1740398-1-vkuznets@redhat.com> <20210513113710.1740398-2-vkuznets@redhat.com> In-Reply-To: From: Jim Mattson Date: Mon, 17 May 2021 14:56:43 -0700 Message-ID: Subject: Re: [PATCH 1/2] KVM: x86: Invert APICv/AVIC enablement check To: Sean Christopherson Cc: Vitaly Kuznetsov , kvm list , Paolo Bonzini , Wanpeng Li , Kechen Lu , Maxim Levitsky , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 17, 2021 at 2:26 PM Sean Christopherson wrote: > > On Mon, May 17, 2021, Jim Mattson wrote: > > On Mon, May 17, 2021 at 2:03 PM Sean Christopherson wrote: > > > > > > On Thu, May 13, 2021, Vitaly Kuznetsov wrote: > > > > Currently, APICv/AVIC enablement is global ('enable_apicv' module parameter > > > > for Intel, 'avic' module parameter for AMD) but there's no way to check > > > > it from vendor-neutral code. Add 'apicv_supported()' to kvm_x86_ops and > > > > invert kvm_apicv_init() (which now doesn't need to be called from arch- > > > > specific code). > > > > > > Rather than add a new hook, just move the variable to x86.c, and export it so > > > that VMX and SVM can give it different module names. The only hiccup is that > > > avic is off by default, but I don't see why that can't be changed. > > > > See https://www.spinics.net/lists/kvm/msg208722.html. > > Boo. A common enable_apicv can still work, SVM just needs an intermediary > between the module param and enable_apicv. > > --- a/arch/x86/kvm/svm/svm.c > +++ b/arch/x86/kvm/svm/svm.c > @@ -185,6 +185,10 @@ module_param(vls, int, 0444); > static int vgif = true; > module_param(vgif, int, 0444); > > +/* enable / disable AVIC */ > +static bool avic; > +module_param(avic, bool, S_IRUGO); > + > bool __read_mostly dump_invalid_vmcb; > module_param(dump_invalid_vmcb, bool, 0644); > > @@ -1009,16 +1013,19 @@ static __init int svm_hardware_setup(void) > nrips = false; > } > > - if (avic) { > - if (!npt_enabled || > - !boot_cpu_has(X86_FEATURE_AVIC) || > - !IS_ENABLED(CONFIG_X86_LOCAL_APIC)) { > - avic = false; > - } else { > - pr_info("AVIC enabled\n"); > + if (!npt_enabled || !boot_cpu_has(X86_FEATURE_AVIC)) > + avic = false; > > - amd_iommu_register_ga_log_notifier(&avic_ga_log_notifier); > - } > + /* > + * Override the common enable_apicv. AVIC is disabled by default > + * because Jim said so. > + */ Hey! I'm just the messenger. Wei Huang said so. > + enable_apicv = avic; > + > + if (enable_apicv) { > + pr_info("AVIC enabled\n"); > + > + amd_iommu_register_ga_log_notifier(&avic_ga_log_notifier); > } > > if (vls) {