Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3890949ybb; Mon, 23 Mar 2020 09:34:24 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuW79AB9geYnnSyCAZfhyWzg37gmw+KkxqMPkJsuzUEIMdhhh6Bi9EjfZD69eb+lOc2y6Sl X-Received: by 2002:aca:47c8:: with SMTP id u191mr133242oia.17.1584981263817; Mon, 23 Mar 2020 09:34:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584981263; cv=none; d=google.com; s=arc-20160816; b=q3HttbIGTkqgTGFdoP5D8fMd1dAWavxE3+7T3JmeDyCbxQkfQ6ZwLrpJ0YVhI/NvRD fy0CfMc3sPdjOH7KvQIcnftTPCYNZcakahqQoJ1Ec3WTRpruk9mH3yo34jFHgEwJ4bsw my9bOnWH+wJ/Mv2dDy8m19BJBUv0bNHZUVQM6LRcRlTT8ZmwRB4R7kAyo0kbZIw7+6ab 6TEFSor1g7OTahrBjuDdCqPW2r45gbtPxE8rOG5v0TmxEn6lRL5lGhzK67IyGWPX1q5Q sYh/qs2lRUibKdL9dC2JGx4C+JUWtTgJ5Wtaoh67Jhexx/DVWkwNwAO77oBdQf949RS1 VJfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=JhL/PNDb9udSz5kNxWWnk5wsW9f1jfulH4cBPkk1JaM=; b=OcjHl2XDjVBDJ2E9ps2+C5hjrKiJU9ZViN9DLOfE4Qf7FqWY7/uRqMyTDsdshgkMo+ eEsWGQvKFQ1OVqemfqGyDzWdVKSL/8oZpUGPthnuw3JoOEjHLY1wftdaE2bv9cJhZMX9 r3oNkGYSqt2GEQygvWJwPzHeA5RJ8bJkl5sSw3D5e+87MnDehXHnjOb0/tUIAVr778nS KzBJ3aXy6ymClLNAe/7NQfx5wCWCInagLfgxffskn9T/XMgId+Fj+vuok9dCDno6R15n vEhgI25eORU1cEZZ3KNN4mo778WAHFRie9GRF5PIidgdG4dkMSa3VVTj+NXbW9SO6bZM Le5g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s199si7482583oih.169.2020.03.23.09.34.10; Mon, 23 Mar 2020 09:34:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727560AbgCWQbk (ORCPT + 99 others); Mon, 23 Mar 2020 12:31:40 -0400 Received: from mga07.intel.com ([134.134.136.100]:48804 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727546AbgCWQbj (ORCPT ); Mon, 23 Mar 2020 12:31:39 -0400 IronPort-SDR: iFXscG6X/tylu1tKeCS7jZvcIQ6v4+/5LhyIrkhJqw1qGclb8KHTcuXn8p+4dVRCjoWCOtL6Vn kgKH8ptzLcUw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2020 09:31:38 -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 Cc: Paolo Bonzini , Paul Mackerras , Christian Borntraeger , Janosch Frank , David Hildenbrand , Cornelia Huck , Wanpeng Li , Jim Mattson , Joerg Roedel , Marc Zyngier , James Morse , Julien Thierry , Suzuki K Poulose , linux-mips@vger.kernel.org, kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87o8sn82ef.fsf@vitty.brq.redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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.