public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Paraschiv, Andra-Irina" <andraprs@amazon.com>
To: Alexander Graf <graf@amazon.de>,
	linux-kernel <linux-kernel@vger.kernel.org>
Cc: Anthony Liguori <aliguori@amazon.com>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Colm MacCarthaigh <colmmacc@amazon.com>,
	"David Duncan" <davdunc@amazon.com>,
	Bjoern Doebel <doebel@amazon.de>,
	"David Woodhouse" <dwmw@amazon.co.uk>,
	Frank van der Linden <fllinden@amazon.com>,
	Greg KH <gregkh@linuxfoundation.org>,
	Karen Noel <knoel@redhat.com>,
	"Martin Pohlack" <mpohlack@amazon.de>,
	Matt Wilson <msw@amazon.com>, Paolo Bonzini <pbonzini@redhat.com>,
	Balbir Singh <sblbir@amazon.com>,
	Stefano Garzarella <sgarzare@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Stewart Smith <trawets@amazon.com>,
	Uwe Dannowski <uwed@amazon.de>,
	Vitaly Kuznetsov <vkuznets@redhat.com>, kvm <kvm@vger.kernel.org>,
	ne-devel-upstream <ne-devel-upstream@amazon.com>
Subject: Re: [PATCH v6 08/18] nitro_enclaves: Add logic for creating an enclave VM
Date: Tue, 11 Aug 2020 11:16:20 +0300	[thread overview]
Message-ID: <666a72eb-0170-ea53-d8f6-6fb71835cd4e@amazon.com> (raw)
In-Reply-To: <77f71395-d7ba-f198-56dc-3b0a954a98de@amazon.de>



On 10/08/2020 09:11, Alexander Graf wrote:
>
>
> On 05.08.20 11:10, Andra Paraschiv wrote:
>> Add ioctl command logic for enclave VM creation. It triggers a slot
>> allocation. The enclave resources will be associated with this slot and
>> it will be used as an identifier for triggering enclave run.
>>
>> Return a file descriptor, namely enclave fd. This is further used by the
>> associated user space enclave process to set enclave resources and
>> trigger enclave termination.
>>
>> The poll function is implemented in order to notify the enclave process
>> when an enclave exits without a specific enclave termination command
>> trigger e.g. when an enclave crashes.
>>
>> Signed-off-by: Alexandru Vasile <lexnv@amazon.com>
>> Signed-off-by: Andra Paraschiv <andraprs@amazon.com>
>> Reviewed-by: Alexander Graf <graf@amazon.com>
>> ---
>> Changelog
>>
>> v5 -> v6
>>
>> * Update the code base to init the ioctl function in this patch.
>> * Update documentation to kernel-doc format.
>>
>> v4 -> v5
>>
>> * Release the reference to the NE PCI device on create VM error.
>> * Close enclave fd on copy_to_user() failure; rename fd to enclave fd
>>    while at it.
>> * Remove sanity checks for situations that shouldn't happen, only if
>>    buggy system or broken logic at all.
>> * Remove log on copy_to_user() failure.
>>
>> v3 -> v4
>>
>> * Use dev_err instead of custom NE log pattern.
>> * Update the NE ioctl call to match the decoupling from the KVM API.
>> * Add metadata for the NUMA node for the enclave memory and CPUs.
>>
>> v2 -> v3
>>
>> * Remove the WARN_ON calls.
>> * Update static calls sanity checks.
>> * Update kzfree() calls to kfree().
>> * Remove file ops that do nothing for now - open.
>>
>> v1 -> v2
>>
>> * Add log pattern for NE.
>> * Update goto labels to match their purpose.
>> * Remove the BUG_ON calls.
>> ---
>>   drivers/virt/nitro_enclaves/ne_misc_dev.c | 229 ++++++++++++++++++++++
>>   1 file changed, 229 insertions(+)
>>
>> diff --git a/drivers/virt/nitro_enclaves/ne_misc_dev.c 
>> b/drivers/virt/nitro_enclaves/ne_misc_dev.c
>> index 472850250220..6c8c12f65666 100644
>> --- a/drivers/virt/nitro_enclaves/ne_misc_dev.c
>> +++ b/drivers/virt/nitro_enclaves/ne_misc_dev.c
>
> [...]
>
>> +/**
>> + * ne_ioctl() - Ioctl function provided by the NE misc device.
>> + * @file:    File associated with this ioctl function.
>> + * @cmd:    The command that is set for the ioctl call.
>> + * @arg:    The argument that is provided for the ioctl call.
>> + *
>> + * Context: Process context.
>> + * Return:
>> + * * Ioctl result (e.g. enclave file descriptor) on success.
>> + * * Negative return value on failure.
>> + */
>> +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;
>> +        /* TODO: Find another way to get the NE PCI device 
>> reference. */
>> +        struct pci_dev *pdev = pci_get_device(PCI_VENDOR_ID_AMAZON,
>> +                              PCI_DEVICE_ID_NE, NULL);
>
> This should go away if you set misc_dev.parent.
>
>> +        int rc = -EINVAL;
>> +        u64 slot_uid = 0;
>> +
>> +        ne_pci_dev = pci_get_drvdata(pdev);
>> +
>> +        mutex_lock(&ne_pci_dev->enclaves_list_mutex);
>> +
>> +        enclave_fd = ne_create_vm_ioctl(pdev, ne_pci_dev, &slot_uid);
>> +        if (enclave_fd < 0) {
>> +            rc = enclave_fd;
>> +
>> + mutex_unlock(&ne_pci_dev->enclaves_list_mutex);
>> +
>> +            pci_dev_put(pdev);
>
> This should also disappear.

Correct. I'll follow the misc dev parent approach to get the PCI device 
and include all the necessary code base updates in v7.

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.


  reply	other threads:[~2020-08-11  8:17 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-05  9:09 [PATCH v6 00/18] Add support for Nitro Enclaves Andra Paraschiv
2020-08-05  9:10 ` [PATCH v6 01/18] nitro_enclaves: Add ioctl interface definition Andra Paraschiv
2020-08-05  9:10 ` [PATCH v6 02/18] nitro_enclaves: Define the PCI device interface Andra Paraschiv
2020-08-05  9:10 ` [PATCH v6 03/18] nitro_enclaves: Define enclave info for internal bookkeeping Andra Paraschiv
2020-08-05  9:10 ` [PATCH v6 04/18] nitro_enclaves: Init PCI device driver Andra Paraschiv
2020-08-05  9:10 ` [PATCH v6 05/18] nitro_enclaves: Handle PCI device command requests Andra Paraschiv
2020-08-05  9:10 ` [PATCH v6 06/18] nitro_enclaves: Handle out-of-band PCI device events Andra Paraschiv
2020-08-05  9:10 ` [PATCH v6 07/18] nitro_enclaves: Init misc device providing the ioctl interface Andra Paraschiv
2020-08-10  5:22   ` Alexander Graf
2020-08-11  7:58     ` Paraschiv, Andra-Irina
2020-08-05  9:10 ` [PATCH v6 08/18] nitro_enclaves: Add logic for creating an enclave VM Andra Paraschiv
2020-08-10  6:11   ` Alexander Graf
2020-08-11  8:16     ` Paraschiv, Andra-Irina [this message]
2020-08-05  9:10 ` [PATCH v6 09/18] nitro_enclaves: Add logic for setting an enclave vCPU Andra Paraschiv
2020-08-10  7:33   ` Alexander Graf
2020-08-11  8:52     ` Paraschiv, Andra-Irina
2020-08-05  9:10 ` [PATCH v6 10/18] nitro_enclaves: Add logic for getting the enclave image load info Andra Paraschiv
2020-08-10  9:57   ` Alexander Graf
2020-08-11 10:17     ` Paraschiv, Andra-Irina
2020-08-05  9:10 ` [PATCH v6 11/18] nitro_enclaves: Add logic for setting an enclave memory region Andra Paraschiv
2020-08-10  9:54   ` Alexander Graf
2020-08-05  9:10 ` [PATCH v6 12/18] nitro_enclaves: Add logic for starting an enclave Andra Paraschiv
2020-08-10 10:33   ` Alexander Graf
2020-08-05  9:10 ` [PATCH v6 13/18] nitro_enclaves: Add logic for terminating " Andra Paraschiv
2020-08-05  9:10 ` [PATCH v6 14/18] nitro_enclaves: Add Kconfig for the Nitro Enclaves driver Andra Paraschiv
2020-08-05  9:10 ` [PATCH v6 15/18] nitro_enclaves: Add Makefile " Andra Paraschiv
2020-08-05 14:23   ` kernel test robot
2020-08-06  5:22     ` Paraschiv, Andra-Irina
2020-08-05  9:10 ` [PATCH v6 16/18] nitro_enclaves: Add sample for ioctl interface usage Andra Paraschiv
2020-08-05  9:10 ` [PATCH v6 17/18] nitro_enclaves: Add overview documentation Andra Paraschiv
2020-08-05  9:10 ` [PATCH v6 18/18] MAINTAINERS: Add entry for the Nitro Enclaves driver Andra Paraschiv

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=666a72eb-0170-ea53-d8f6-6fb71835cd4e@amazon.com \
    --to=andraprs@amazon.com \
    --cc=aliguori@amazon.com \
    --cc=benh@kernel.crashing.org \
    --cc=colmmacc@amazon.com \
    --cc=davdunc@amazon.com \
    --cc=doebel@amazon.de \
    --cc=dwmw@amazon.co.uk \
    --cc=fllinden@amazon.com \
    --cc=graf@amazon.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=knoel@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpohlack@amazon.de \
    --cc=msw@amazon.com \
    --cc=ne-devel-upstream@amazon.com \
    --cc=pbonzini@redhat.com \
    --cc=sblbir@amazon.com \
    --cc=sgarzare@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=trawets@amazon.com \
    --cc=uwed@amazon.de \
    --cc=vkuznets@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox