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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08CFEC433EF for ; Wed, 8 Dec 2021 18:17:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238760AbhLHSUw (ORCPT ); Wed, 8 Dec 2021 13:20:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231327AbhLHSUv (ORCPT ); Wed, 8 Dec 2021 13:20:51 -0500 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3F9EC061746 for ; Wed, 8 Dec 2021 10:17:19 -0800 (PST) Received: by mail-pj1-x102c.google.com with SMTP id cq22-20020a17090af99600b001a9550a17a5so4949402pjb.2 for ; Wed, 08 Dec 2021 10:17:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=3f166bKRHkMHhPvddU093J8vpeto2pmeKPfGPIYP+ag=; b=cL99TQ6qTeqBC/mnS0Sbgi4Lra35l+QPXJL+s5eSThP7qttO8f2pRKrpp9barCiLCG woTu8bBio6AH+TEKw8oTCflH3u3FIdd1A6Vej3Uk7l8vJ6m30fMfJ7o7E2aBa0n+Jojo GLybvYrDGZtX1i8uZyKy67wN0FN41BHrCDwGpvTtzDAS89TF++Wy1LA6HxvUda+2d1Fh LEQLhPilkaYqLfZsQJ3J6P7Dj9ZczaHkxbk5g5I6M71Iwv2PV52pcWlBkfnPR7lS1BPh eIIdkw/vQCJEQzYXH0XVhJIZNAMFCOhjaTML8TQbQ6k2NwLdSEKR0tRr3KqyJg/LN1Po 4Bpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=3f166bKRHkMHhPvddU093J8vpeto2pmeKPfGPIYP+ag=; b=zzKmeXo8gKzLe/LalFm7UJnSr8JncPht8u9UVENFgM7JXxcFecvw2totmWD5ThaR9/ j5w+v/WGQ4CufbwqiRFrxsXgoXwzA04cYg0j5rEfPdvtJcl920oGcB48BBjuCxJWYWPN DozDlyIO2mLppDoC/QmGoUkUnGmaz2VAPzOzE3//qQ6cmewfS75EBlF14t2oMOeGX0td KNG3pMdLiIOV+94AdfTVtXtBeSZln86jUqDnj7CerBLGGrvY9FmxipMK4ZTQC78K82LU Lss1H32mFuo608KpbqnnAvO/12Eo98IewlmyHvuUs9m0UTqb+jBeHfKRcWC2Hoq24bl7 JdFQ== X-Gm-Message-State: AOAM531ZolxE5OBYFXx/4Rv1xtp1w1bJRw76oo15Q1d52QSh5N5M56ac SLI9JE7+pzJpYU21+dOItit+HE8hMtuakw== X-Google-Smtp-Source: ABdhPJwmueStDqep48ij3iOz84X2oAXyKLxFMG73qqVpmizbC+ILabThfI8X1KTs/m00ikAT2XRW1w== X-Received: by 2002:a17:90a:8049:: with SMTP id e9mr8951250pjw.229.1638987439188; Wed, 08 Dec 2021 10:17:19 -0800 (PST) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id j17sm4020451pfe.174.2021.12.08.10.17.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Dec 2021 10:17:18 -0800 (PST) Date: Wed, 8 Dec 2021 18:17:15 +0000 From: Sean Christopherson To: Like Xu Cc: Paolo Bonzini , kvm@vger.kernel.org, Wanpeng Li , Jim Mattson , Vitaly Kuznetsov , Joerg Roedel , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 5/7] KVM: x86: Move .pmu_ops to kvm_x86_init_ops and tagged as __initdata Message-ID: References: <20211108111032.24457-1-likexu@tencent.com> <20211108111032.24457-6-likexu@tencent.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211108111032.24457-6-likexu@tencent.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org s/tagged/tag On Mon, Nov 08, 2021, Like Xu wrote: > From: Like Xu > > The pmu_ops should be moved to kvm_x86_init_ops and tagged as __initdata. State what the patch does, not what "should" be done. Now that pmu_ops is copied by value during kvm_arch_hardware_setup(), move the pointer to kvm_x86_init_ops and tag implementations as __initdata to make the implementations unreachable once KVM is loaded, e.g. to make it harder to sneak in post-init modification bugs. > That'll save those precious few bytes, and more importantly make > the original ops unreachable, i.e. make it harder to sneak in post-init > modification bugs. > > Suggested-by: Sean Christopherson > Signed-off-by: Like Xu > --- > arch/x86/include/asm/kvm_host.h | 4 ++-- > arch/x86/kvm/svm/pmu.c | 2 +- > arch/x86/kvm/svm/svm.c | 2 +- > arch/x86/kvm/vmx/pmu_intel.c | 2 +- > arch/x86/kvm/vmx/vmx.c | 2 +- > arch/x86/kvm/x86.c | 2 +- > 6 files changed, 7 insertions(+), 7 deletions(-) > > diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h > index c2d4ee2973c5..00760a3ac88c 100644 > --- a/arch/x86/include/asm/kvm_host.h > +++ b/arch/x86/include/asm/kvm_host.h > @@ -1436,8 +1436,7 @@ struct kvm_x86_ops { > int cpu_dirty_log_size; > void (*update_cpu_dirty_logging)(struct kvm_vcpu *vcpu); > > - /* pmu operations of sub-arch */ > - const struct kvm_pmu_ops *pmu_ops; > + /* nested operations of sub-arch */ No need for the new comment. > const struct kvm_x86_nested_ops *nested_ops; > > /* Nits aside, Reviewed-by: Sean Christopherson I'd also be a-ok squashing this with the copy-by-value patch.