lkml.org 
[lkml]   [2020]   [Sep]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v8 08/18] nitro_enclaves: Add logic for creating an enclave VM
From
Date


On 07/09/2020 11:57, Greg KH wrote:
>
> On Fri, Sep 04, 2020 at 08:37:08PM +0300, Andra Paraschiv wrote:
>> +static long ne_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
>> +{
>> + switch (cmd) {
>> + case NE_CREATE_VM: {
>> + int enclave_fd = -1;
>> + struct file *enclave_file = NULL;
>> + struct ne_pci_dev *ne_pci_dev = NULL;
>> + struct pci_dev *pdev = to_pci_dev(ne_misc_dev.parent);
> That call is really "risky". You "know" that the misc device's parent
> is a specific PCI device, that just happens to be your pci device,
> right?

Correct, that's how it's assigned the misc device's parent, to point to
a particular PCI device that's the NE PCI device.

>
> But why not just have your misc device hold the pointer to the structure
> you really want, so you don't have to mess with the device tree in any
> way, and you always "know" you have the correct pointer? It should save
> you this two-step lookup all the time, right?
>

That would help, yes, to keep the pointer directly to the ne_pci_dev
data structure. Just that the misc device's parent data structure is a
struct device pointer. I can create a new internal data structure to
keep the miscdevice data structure and a pointer to the ne_pci_dev.

Thanks,
Andra



Amazon Development Center (Romania) S.R.L. registered office: 27A Sf. Lazar Street, UBC5, floor 2, Iasi, Iasi County, 700045, Romania. Registered in Romania. Registration number J22/2621/2005.
\
 
 \ /
  Last update: 2020-09-07 14:57    [W:0.059 / U:1.120 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site