Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp5759115ioo; Wed, 1 Jun 2022 11:59:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxr/I+f7rBYy8xz9BauybclBowMzVCFaQqfpRviGUSvlzoLxgv45spC80bNJjw8mEExCGsW X-Received: by 2002:a17:903:22d0:b0:164:ec0:178c with SMTP id y16-20020a17090322d000b001640ec0178cmr845461plg.127.1654109974762; Wed, 01 Jun 2022 11:59:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654109974; cv=none; d=google.com; s=arc-20160816; b=SCreNykenKXnqxb94XsC8rCCB2S5PLGJxfMfFXn5x9lfkbUbf2HwfJQGcUzWkjoRlh pqeC0hjInjbbQpGU8eJlMHLhRDtfz0k8/UAazEMD4Q1/cMxAzOiqnb1c0KfVZYzrly0d ihU6cGHzx4E6PuMicO5MGmWI9uE9GHVoZpQlavRpcjTFpfQOmLIm9GNOYFEBrzNM9a/U zNe4e8PmioRD4Brcz6I7QwVMqWxDO+vrc6J8fixD/VWWpeZTRmPc8wq5JRM4WCOfiPTf ZRfmEc5dmDS18vTQMD+gp0qfWpqi+KTxQTqudwTs+CAc/CpsFgip7FdG5m1DsSy6XTal UUAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=YhC+hN49BuSzPA2eVA/U+rfjQum2PYL/Zemnrj3txh0=; b=XPbOnQDxVmEjOwff4N7am6LP5N2zxywrKV1sVWQm2vIhKs7JCUlvQxLD0d1PVR4X9q h7dqX1ep9EW49z19l/Bp6WRKwWb5wcZd0Ka3WaIoVbbVwOZ887P33qtrO0gZgzzltX/B rl5Fps4Ax8LYp1PTV3VDfmIEoUn22oTS6RI2bVbtvAD7dy6rRQrwm6mWu2mP4HD9DELT oOGZ1bx7eC1LeJhZkIvsL78Vh3y1Yx0ob7Bt6o384RwiI7iob4kCINsiJjSTGNVuIKw6 1/pg5EEaZj5NnSOsaSExpergU8lObQoClwvBNu0oS211M3MntZGzOei7TmcwO67PGbDy OAHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=FhMngP+h; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id i4-20020a170902c94400b00161a548df6fsi4055621pla.147.2022.06.01.11.59.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 11:59:34 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=FhMngP+h; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 19314ED8C8; Wed, 1 Jun 2022 11:45:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347441AbiEaTrz (ORCPT + 99 others); Tue, 31 May 2022 15:47:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347484AbiEaTrM (ORCPT ); Tue, 31 May 2022 15:47:12 -0400 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3D63DF93 for ; Tue, 31 May 2022 12:47:10 -0700 (PDT) Received: by mail-pf1-x42b.google.com with SMTP id bo5so14137140pfb.4 for ; Tue, 31 May 2022 12:47:10 -0700 (PDT) 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:content-transfer-encoding:in-reply-to; bh=YhC+hN49BuSzPA2eVA/U+rfjQum2PYL/Zemnrj3txh0=; b=FhMngP+h/QliKbg6XS8bp+cpEhNKyESg7EWr5+H4hY/gbY3FNqrhlm/dll7peYP7GT Uv3Tw3xiYKMIDT+AFnDYlkyG2udMgt/V71thYzb1cHkzIT1plDbOGQRmnFXHHEU4XTcg rRA/SS2DEXu8N1+QhdBn4DOnx6Adgx2dUSuA40QHDFEm3hTTJRF8/fhzs9WEHdxQdkU3 myIzXNU50STTaLKoMLjsDUqK6U4LhDzO9iwItNPCaqOqUrEYA4ShoqTWIu709HDdShfg GkgMIrS5lTvPeNjYEC/uksKmjVeQyy18mT7QATDjrSuRdIK1FdlsMzUkiaz1N0jnvAMV 8srw== 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:content-transfer-encoding :in-reply-to; bh=YhC+hN49BuSzPA2eVA/U+rfjQum2PYL/Zemnrj3txh0=; b=abKrsB1ZTwh0mO60AFof4woxc+Y78wTYE5XHl3uywBlWM2ykWJe3anZZjv3H0w+V6O Zsgd5gbd9Q3KYiVQpQCEun4khhjA4/olKzYwPOdk0jdjJvM1+u3rcq97c5I6HknsTIu7 q8AA/YEfo77wCBv+zcNjwIe9v2VvFRpN3iJZ92veX0B4lFu3aUqX4Z6otFjdJlhjZ/P6 L1nvgrPyhlbiSLRSxasa7+ml2qo3HjRBuP4PuWQQ4PHSlbvniP18VhUz2LfaodL+1x4r zIaZc3aiQQUgzql5PtYVTjGPlTXOdnf1MiKPF8dh2uFyiBqQepne0cdeqfEoxPOCYYsd XTqQ== X-Gm-Message-State: AOAM532JcgmCk2cVuqXua70Ls23fEQuABft9dfbmDEWv3Scu0sJjyCcs AaPNejfH5EXwY3VfywxRtgA6Yg== X-Received: by 2002:a63:1543:0:b0:3fa:8e73:d7a5 with SMTP id 3-20020a631543000000b003fa8e73d7a5mr34189956pgv.160.1654026430233; Tue, 31 May 2022 12:47:10 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id m6-20020a635806000000b003c67e472338sm10741774pgb.42.2022.05.31.12.47.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 May 2022 12:47:09 -0700 (PDT) Date: Tue, 31 May 2022 19:47:06 +0000 From: Sean Christopherson To: Xiang wangx Cc: pbonzini@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] KVM: Add const to file_operations Message-ID: References: <20220530020857.2565-1-wangxiang@cdjrlc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220530020857.2565-1-wangxiang@cdjrlc.com> X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL 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 Mon, May 30, 2022, Xiang wangx wrote: > Struct file_operations should normally be const. Operative word being "should". kvm_chardev_ops isn't constant because kvm_init() modifies the "owner". The same was true for kvm_vcpu_fops and kvm_vm_fops until commit 70375c2d8fa3 ("Revert "KVM: set owner of cpu and vm file operations""). So, this patch is both stale, and completely broken when applied against current KVM as well as whatever old version of KVM it was generated with. arch/x86/kvm/../../../virt/kvm/kvm_main.c:4873:37: error: conflicting type qualifiers for ‘kvm_chardev_ops’ 4873 | static const struct file_operations kvm_chardev_ops = { | ^~~~~~~~~~~~~~~ arch/x86/kvm/../../../virt/kvm/kvm_main.c:120:31: note: previous declaration of ‘kvm_chardev_ops’ with type ‘struct file_operations’ 120 | static struct file_operations kvm_chardev_ops; | ^~~~~~~~~~~~~~~ arch/x86/kvm/../../../virt/kvm/kvm_main.c: In function ‘kvm_init’: arch/x86/kvm/../../../virt/kvm/kvm_main.c:5777:31: error: assignment of member ‘owner’ in read-only object 5777 | kvm_chardev_ops.owner = module; | ^ CC arch/x86/events/intel/p6.o make[3]: *** [scripts/Makefile.build:288: arch/x86/kvm/../../../virt/kvm/kvm_main.o] Error 1 make[2]: *** [scripts/Makefile.build:550: arch/x86/kvm] Error 2 > Signed-off-by: Xiang wangx > --- > virt/kvm/kvm_main.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index 3f6d450355f0..7dc2433f1b01 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -3550,7 +3550,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp) > return 0; > } > > -static struct file_operations kvm_vcpu_fops = { > +static const struct file_operations kvm_vcpu_fops = { > .release = kvm_vcpu_release, > .unlocked_ioctl = kvm_vcpu_ioctl, > .mmap = kvm_vcpu_mmap, > @@ -4599,7 +4599,7 @@ static long kvm_vm_compat_ioctl(struct file *filp, > } > #endif > > -static struct file_operations kvm_vm_fops = { > +static const struct file_operations kvm_vm_fops = { > .release = kvm_vm_release, > .unlocked_ioctl = kvm_vm_ioctl, > .llseek = noop_llseek, > @@ -4701,7 +4701,7 @@ static long kvm_dev_ioctl(struct file *filp, > return r; > } > > -static struct file_operations kvm_chardev_ops = { > +static const struct file_operations kvm_chardev_ops = { > .unlocked_ioctl = kvm_dev_ioctl, > .llseek = noop_llseek, > KVM_COMPAT(kvm_dev_ioctl), > -- > 2.36.1 >