From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1A772C3F2CD for ; Mon, 23 Mar 2020 16:31:46 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E23AB20735 for ; Mon, 23 Mar 2020 16:31:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="BAaQL4U/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E23AB20735 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=z3OXGLoyFscEXPtDRf0FdTi9rFSxqtbfrZDB+0URV4o=; b=BAaQL4U/nK98CH SqAWK9VxAN/iEZO0F7wDK4RSW5JN7g/M3BodN+WgXn4ChZ9RueA4CTm2EjWHgBGDbdz3VldrUVJTe TYY7ZvgdOII1+8fGHAFyKvo+iDog8METKh5SIl1B4MabKhxGcKPr7+U0opzwjL/lu9EW9EXmAIJvW n+Z/7ynzKy+vmB+hrRIy8kV+I6Xx0e+ZdBKW61hTQkZJs9jt+fWTcpgKPrdXg+H5nLMy4X1PHWF0F EU0D+5WVLT2ESgx/EyXU8ZtISWRdZe29KhxlEseg0r3bFNyaXIv9fIp/hmj58+U0Vr1Y63TFSiGk+ 1yq0ZAZhBdLNU+3CVFmA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jGPzM-0002BH-LM; Mon, 23 Mar 2020 16:31:44 +0000 Received: from mga05.intel.com ([192.55.52.43]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jGPzI-0002AF-Im for linux-arm-kernel@lists.infradead.org; Mon, 23 Mar 2020 16:31:42 +0000 IronPort-SDR: G9p34znk9fhvKkDQOYTArAEjtYHfPP5POfKY/21Rwog7i2464SWNSuiz9FTnQDkdZcJ5qtOtWi CFprOm/aATRg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2020 09:31:37 -0700 IronPort-SDR: szHRtSFDap8tPDDbCZjY8IsJB86JbCOaVx3NCNFM02k1aZo2cLfAgzLVZG93EZD2pGO8Xl0/T8 x/vNCF1+MuCQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,297,1580803200"; d="scan'208";a="357141639" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.202]) by fmsmga001.fm.intel.com with ESMTP; 23 Mar 2020 09:31:37 -0700 Date: Mon, 23 Mar 2020 09:31:36 -0700 From: Sean Christopherson To: Vitaly Kuznetsov Subject: Re: [PATCH v3 2/9] KVM: x86: Move init-only kvm_x86_ops to separate struct Message-ID: <20200323163136.GO28711@linux.intel.com> References: <20200321202603.19355-1-sean.j.christopherson@intel.com> <20200321202603.19355-3-sean.j.christopherson@intel.com> <87lfnr9sqn.fsf@vitty.brq.redhat.com> <20200323152909.GE28711@linux.intel.com> <87o8sn82ef.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <87o8sn82ef.fsf@vitty.brq.redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200323_093140_633109_A1922983 X-CRM114-Status: GOOD ( 20.01 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Wanpeng Li , Janosch Frank , kvm@vger.kernel.org, David Hildenbrand , Marc Zyngier , Joerg Roedel , Cornelia Huck , linux-mips@vger.kernel.org, kvm-ppc@vger.kernel.org, linux-kernel@vger.kernel.org, Paul Mackerras , Christian Borntraeger , James Morse , linux-arm-kernel@lists.infradead.org, Paolo Bonzini , Suzuki K Poulose , kvmarm@lists.cs.columbia.edu, Julien Thierry , Jim Mattson Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Mar 23, 2020 at 05:24:56PM +0100, Vitaly Kuznetsov wrote: > Sean Christopherson writes: > > > On Mon, Mar 23, 2020 at 01:10:40PM +0100, Vitaly Kuznetsov wrote: > >> Sean Christopherson writes: > >> > >> > + > >> > + .runtime_ops = &svm_x86_ops, > >> > +}; > >> > >> Unrelated to your patch but I think we can make the naming of some of > >> these functions more consistend on SVM/VMX, in particular I'd suggest > >> > >> has_svm() -> cpu_has_svm_support() > >> is_disabled -> svm_disabled_by_bios() > >> ... > >> (see below for VMX) > >> > >> > + > >> > static int __init svm_init(void) > >> > { > >> > - return kvm_init(&svm_x86_ops, sizeof(struct vcpu_svm), > >> > + return kvm_init(&svm_init_ops, sizeof(struct vcpu_svm), > >> > __alignof__(struct vcpu_svm), THIS_MODULE); > >> > } > >> > > >> > diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c > >> > index 07299a957d4a..ffcdcc86f5b7 100644 > >> > --- a/arch/x86/kvm/vmx/vmx.c > >> > +++ b/arch/x86/kvm/vmx/vmx.c > >> > @@ -7842,11 +7842,8 @@ static bool vmx_check_apicv_inhibit_reasons(ulong bit) > >> > } > >> > > >> > static struct kvm_x86_ops vmx_x86_ops __ro_after_init = { > >> > - .cpu_has_kvm_support = cpu_has_kvm_support, > >> > - .disabled_by_bios = vmx_disabled_by_bios, > >> > - .hardware_setup = hardware_setup, > >> > .hardware_unsetup = hardware_unsetup, > >> > - .check_processor_compatibility = vmx_check_processor_compat, > >> > + > >> > .hardware_enable = hardware_enable, > >> > .hardware_disable = hardware_disable, > >> > .cpu_has_accelerated_tpr = report_flexpriority, > >> > @@ -7981,6 +7978,15 @@ static struct kvm_x86_ops vmx_x86_ops __ro_after_init = { > >> > .apic_init_signal_blocked = vmx_apic_init_signal_blocked, > >> > }; > >> > > >> > +static struct kvm_x86_init_ops vmx_init_ops __initdata = { > >> > + .cpu_has_kvm_support = cpu_has_kvm_support, > >> > + .disabled_by_bios = vmx_disabled_by_bios, > >> > + .check_processor_compatibility = vmx_check_processor_compat, > >> > + .hardware_setup = hardware_setup, > >> > >> cpu_has_kvm_support() -> cpu_has_vmx_support() > >> hardware_setup() -> vmx_hardware_setup() > > > > Preaching to the choir on this one. The VMX functions without prefixes in > > in particular annoy me to no end, e.g. hardware_setup(). Though the worst > > is probably ".vcpu_create = vmx_create_vcpu", if I had a nickel for every > > time I've tried to find vmx_vcpu_create()... > > > > What if we added a macro to auto-generate the common/required hooks? E.g.: > > > > static struct kvm_x86_ops vmx_x86_ops __ro_after_init = { > > MANDATORY_KVM_X86_OPS(vmx), > > > > .pmu_ops = &intel_pmu_ops, > > > > ... > > }; > > > > That'd enforce consistent naming, and would provide a bit of documentation > > as to which hooks are optional, e.g. many of the nested hooks, and which > > must be defined for KVM to function. > > Sounds cool! (not sure that with only two implementations people won't > call it 'over-engineered' but cool). My personal wish would just be that > function names in function implementations are not auto-generated so > e.g. a simple 'git grep vmx_hardware_setup' works but the way how we > fill vmx_x86_ops in can be macroed I guess. Ya, I was thinking of just the macro. Even that has downsides though, e.g. chasing kvm_x86_ops.hardware_setup() to find VMX's hardware_setup() becomes a bit kludgy. On the other hand, _if_ you know how the fill macro works, getting to the implementation should be easier. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel