Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2947460rdh; Wed, 27 Sep 2023 19:24:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEVedYVRyIk251cP7hy5pQ0ZCSoXSpn8D/rNFpO0sL7hwBLMIeDNrZ+hRlEoPTXTklYnec3 X-Received: by 2002:a05:6a00:c96:b0:692:7527:c2d0 with SMTP id a22-20020a056a000c9600b006927527c2d0mr4682528pfv.32.1695867851559; Wed, 27 Sep 2023 19:24:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695867851; cv=none; d=google.com; s=arc-20160816; b=ByhH7ahHRaC1hO1R6lL0bWUyA6b7R+NTaVtIl/tTt7b4LUlHQGvlOSzbS52lCwrhEs 6VEMgSLPRf7j8fGcQzFr8r4iOiAkNKoPESNmmjDYj3BxUYSNlzjGUea1i6zpInMvwpuq FXDvkjOLuQ4Fy7QxuZ5BpNKhU0wMUj5s3Z3mxUQ//ADWG4NsryeWXWYXTRUwU2Gww4U8 ikNeSrX6vpZqKW6lc5yZCxjQVIqP0e51szDiIjZKztd8SM3Li/pCpbjV54XMoxS6BGOr NRZxhoMtcy8e8FiFall41tPZkembtom3pVEihALOmecXEpS7jfLtD3VKP5z0Ldh4Dqv4 izPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-filter; bh=apiqyVomDl3eH58Vs8mK0hqcp1k7lISOy2zAU3jCyNU=; fh=4IeBZmlOVToLc/pN4Fsijk40AHTc2siBePJ4bkaQO4M=; b=OIQLFn0JDXKlW5hl2EnVA7TXFnZMm+cOC7QOSd54EFcUlXS6Ayqk1+HBM4I142xOpa S1cNJi/UeEuyPCrBL6oEZvqTtvMTPv7kB2z09hS6nSjUk48LUATG9rRYNxAxRH54cSj/ HBFot0qY/sdGT9iSkIu7XbvoskmjnqjCXx+zgz3UYnCFeWBPrB25FEA3n6gNEE11aC9v oSQe5GeGoOt11kfztT5NXreB6hL2imFBxDekpyPwuz+eU+PryU+irfqyjM5kfHU016sz 9t42ZXKKaoWTTE1yvNQvxp03kFVEURmYUocfTwPZ7t6qyZZfkuvkS56WmdVYAb3iXytu vXXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=V8yNq7va; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id bk13-20020a056a02028d00b00563e25c07c0si14071533pgb.270.2023.09.27.19.24.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 19:24:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=V8yNq7va; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 67FCF8025836; Wed, 27 Sep 2023 17:18:14 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229780AbjI1ASA (ORCPT + 99 others); Wed, 27 Sep 2023 20:18:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229472AbjI1AR6 (ORCPT ); Wed, 27 Sep 2023 20:17:58 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D4C41114; Wed, 27 Sep 2023 17:17:56 -0700 (PDT) Received: from [10.0.0.178] (c-76-135-56-23.hsd1.wa.comcast.net [76.135.56.23]) by linux.microsoft.com (Postfix) with ESMTPSA id C798520B74C0; Wed, 27 Sep 2023 17:17:55 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com C798520B74C0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1695860276; bh=apiqyVomDl3eH58Vs8mK0hqcp1k7lISOy2zAU3jCyNU=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=V8yNq7vak/Kr3K00IoP6fpQzGDvLsvy4Ezk9uAHfe4/mS3eMbtM8AOjTFUAcUd+m8 Uy7bPwEC59miyqW9bO1K2C0BHSiD0UJAdT4igjnaL80svRDmpqu5ZuDj+DfThLWX/d EzQskjEpeqCkesXIudWToBYAWfoOBMOwhSz/l9+M= Message-ID: Date: Wed, 27 Sep 2023 17:17:54 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 15/15] Drivers: hv: Add modules to expose /dev/mshv to VMMs running on Hyper-V Content-Language: en-US To: Greg KH , Wei Liu Cc: linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-arch@vger.kernel.org, patches@lists.linux.dev, mikelley@microsoft.com, kys@microsoft.com, haiyangz@microsoft.com, decui@microsoft.com, apais@linux.microsoft.com, Tianyu.Lan@microsoft.com, ssengar@linux.microsoft.com, mukeshrathor@microsoft.com, stanislav.kinsburskiy@gmail.com, jinankjain@linux.microsoft.com, vkuznets@redhat.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, will@kernel.org, catalin.marinas@arm.com References: <2023092342-staunch-chafe-1598@gregkh> <2023092630-masculine-clinic-19b6@gregkh> <2023092614-tummy-dwelling-7063@gregkh> <2023092646-version-series-a7b5@gregkh> <05119cbc-155d-47c5-ab21-e6a08eba5dc4@linux.microsoft.com> <2023092737-daily-humility-f01c@gregkh> <2023092757-cupbearer-cancel-b314@gregkh> From: Nuno Das Neves In-Reply-To: <2023092757-cupbearer-cancel-b314@gregkh> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-17.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,ENV_AND_HDR_SPF_MATCH,SPF_HELO_PASS,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 27 Sep 2023 17:18:14 -0700 (PDT) On 9/27/2023 1:33 AM, Greg KH wrote: > On Wed, Sep 27, 2023 at 08:04:42AM +0000, Wei Liu wrote: >> So, the driver is supposed to stash a pointer to struct device in >> private_data. That's what I alluded to in my previous reply. The core >> driver framework or the VFS doesn't give us a reference to struct >> device. We have to do it ourselves. > > Please read Linux Device Drivers, 3rd edition, chapter 3, for how to do > this properly. The book is free online. > Thanks, the issue that confused us was how to get the miscdevice. I eventually found the answer in the misc_register() documentation: "By default, an open() syscall to the device sets file->private_data to point to the structure." That's good - when we create a guest, we will have the miscdevice in private_data already. Then we can just put it in our per-guest data structure. That will let us retrieve the device in the other ioctls so we can call dev_*(). Thanks, Nuno