Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp1798059pxa; Sat, 29 Aug 2020 03:47:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzkSnna9F77om8mnffgP4v2LsoU9WrEhp02tXd/MsQgnI49rNEGUpODQvVO+SSc7WJyRjJi X-Received: by 2002:a50:d545:: with SMTP id f5mr2838797edj.322.1598698032668; Sat, 29 Aug 2020 03:47:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598698032; cv=none; d=google.com; s=arc-20160816; b=J0NRHMtkqNO7SOSz77KO9MIFqXLR0SeJlCRyaPrUmmPJVh2fwp3ed1RjDD50LUxz5Y dNaWI/8puqZCpT0Y6Qxct+H2fm785MrHDvN9ohVxFcFWPcwjvrCo0ugMSZeqlq3Xkzw0 vkIPNy17VuHB0oux33TUhL3eIHFsgJaqygFFVBH2Xb0LmnNaGOvWE2SzQj6gLntOHrq8 KLN9dsAYBA1BqnmyQkeTacKVAjW1vcdrvcg6KSOMb0+pPrKnbN7TjHiEPT+35xUq2qx6 2pEhpqK2b6Lph/FUHnsf2WUeN2H+MIsGm7mq+b89xUv7UdFKJNJYsBwm21txvlHQPq2v zqGw== 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=LIA/SqTtUhbfKwVLtAc4Ag4+1U/OqvhBOZFoSfPEHuc=; b=VvcOWZbu+CI7QsOwoeaWJ6PVA7nS8j01bAdcxFoO2ghDhv0EAafCB4wX98z8lpIRND nNyU7E2hgcs+7LR93ql9axCkZ2w9gllIV0Wvc1XUajzGHwHyMFsDs7jB0rM0vLEZwjQY 8iDeAq6kiJfD18UhA8+SCtwGKrxmvngNm7O4rBK3mkAoEAgqSKCH30YxXTM5bBgsMI6C XAR57ep9mBJGzTJsnunr0t//HPK0fOBfjQECqvAivKnDduMBPitU4D0SiQ4gbIwXWtC8 G6J7Cv0iArr0BV7eL+xykK+v0BEoFXpEUmFWSgdIKZNDrqH6z/xtfP6AlNfriTg8D1Vn E3QA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 23si1203070edv.203.2020.08.29.03.46.48; Sat, 29 Aug 2020 03:47:12 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727783AbgH2KqR (ORCPT + 99 others); Sat, 29 Aug 2020 06:46:17 -0400 Received: from mga09.intel.com ([134.134.136.24]:59580 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727022AbgH2KqQ (ORCPT ); Sat, 29 Aug 2020 06:46:16 -0400 IronPort-SDR: yh1bja9Zk3L9JuBaGgcPlrnE8b6xCUtUUC0qzJDtwjA2QTJXuFPdJX2bTeUMAARYaN0/vu789P szWw51/UT7Ww== X-IronPort-AV: E=McAfee;i="6000,8403,9727"; a="157806884" X-IronPort-AV: E=Sophos;i="5.76,367,1592895600"; d="scan'208";a="157806884" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Aug 2020 03:46:16 -0700 IronPort-SDR: T6xmkOoupvAZ9Yrhtai1YScQgfB10+J3wVSer2lE/p1UifbW5DV3S664Hwz8sLEDiUCjYjxyr+ UVcVzcqM0qdQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,367,1592895600"; d="scan'208";a="501313399" Received: from shuo-intel.sh.intel.com (HELO localhost) ([10.239.154.30]) by fmsmga005.fm.intel.com with ESMTP; 29 Aug 2020 03:46:13 -0700 Date: Sat, 29 Aug 2020 18:46:12 +0800 From: Shuo A Liu To: Greg Kroah-Hartman Cc: , "H . Peter Anvin" , "Thomas Gleixner" , Ingo Molnar , "Borislav Petkov" , Sean Christopherson , Yu Wang , Reinette Chatre , , Dave Hansen , Zhi Wang , Zhenyu Wang Subject: Re: [PATCH 05/17] virt: acrn: Introduce ACRN HSM basic driver Message-ID: <20200829104612.GD13723@shuo-intel.sh.intel.com> References: <20200825024516.16766-1-shuo.a.liu@intel.com> <20200825024516.16766-6-shuo.a.liu@intel.com> <20200828102559.GA1470435@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20200828102559.GA1470435@kroah.com> User-Agent: Mutt/1.8.3 (2017-05-23) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Greg, On Fri 28.Aug'20 at 12:25:59 +0200, Greg Kroah-Hartman wrote: >On Tue, Aug 25, 2020 at 10:45:05AM +0800, shuo.a.liu@intel.com wrote: >> +static long acrn_dev_ioctl(struct file *filp, unsigned int cmd, >> + unsigned long ioctl_param) >> +{ >> + if (cmd == ACRN_IOCTL_GET_API_VERSION) { >> + if (copy_to_user((void __user *)ioctl_param, >> + &api_version, sizeof(api_version))) >> + return -EFAULT; > >Why are you versioning your api? Shouldn't that not be a thing and you >either support an ioctl or you do not? The API version here is more for the hypercalls. The hypercalls might evolve later and the version indicates which set of interfaces (include the paramters' format) should be used by user space tools. Currently, it's used rarely. > > >> + } >> + >> + return 0; >> +} >> + >> +static int acrn_dev_release(struct inode *inode, struct file *filp) >> +{ >> + struct acrn_vm *vm = filp->private_data; >> + >> + kfree(vm); >> + return 0; >> +} >> + >> +static const struct file_operations acrn_fops = { >> + .owner = THIS_MODULE, >> + .open = acrn_dev_open, >> + .release = acrn_dev_release, >> + .unlocked_ioctl = acrn_dev_ioctl, >> +}; >> + >> +static struct miscdevice acrn_dev = { >> + .minor = MISC_DYNAMIC_MINOR, >> + .name = "acrn_hsm", >> + .fops = &acrn_fops, >> +}; >> + >> +static int __init hsm_init(void) >> +{ >> + int ret; >> + >> + if (x86_hyper_type != X86_HYPER_ACRN) >> + return -ENODEV; >> + >> + if (!acrn_is_privileged_vm()) >> + return -EPERM; >> + >> + ret = hcall_get_api_version(slow_virt_to_phys(&api_version)); >> + if (ret < 0) { >> + pr_err("Failed to get API version from hypervisor!\n"); >> + return ret; >> + } >> + >> + pr_info("API version is %u.%u\n", >> + api_version.major_version, api_version.minor_version); > >Shouldn't drivers be quiet when they load and all goes well? pr_dbg()? > >And can't you defer the "read the version" call until open happens? >Does it have to happen at module load time, increasing boot time for no >good reason if there is not a user? OK. I can defer the version fetch and pr_dbg() until open. Thanks shuo