• Andra Paraschiv's avatar
    nitro_enclaves: Add logic for terminating an enclave · 9c8eb50f
    Andra Paraschiv authored
    An enclave is associated with an fd that is returned after the enclave
    creation logic is completed. This enclave fd is further used to setup
    enclave resources. Once the enclave needs to be terminated, the enclave
    fd is closed.
    
    Add logic for enclave termination, that is mapped to the enclave fd
    release callback. Free the internal enclave info used for bookkeeping.
    
    Changelog
    
    v9 -> v10
    
    * Update commit message to include the changelog before the SoB tag(s).
    
    v8 -> v9
    
    * Use the ne_devs data structure to get the refs for the NE PCI device.
    
    v7 -> v8
    
    * No changes.
    
    v6 -> v7
    
    * Remove the pci_dev_put() call as the NE misc device parent field is
      used now to get the NE PCI device.
    * Update the naming and add more comments to make more clear the logic
      of handling full CPU cores and dedicating them to the enclave.
    
    v5 -> v6
    
    * Update documentation to kernel-doc format.
    * Use directly put_page() instead of unpin_user_pages(), to match the
      get_user_pages() calls.
    
    v4 -> v5
    
    * Release the reference to the NE PCI device on enclave fd release.
    * Adapt the logic to cpumask enclave vCPU ids and CPU cores.
    * Remove sanity checks for situations that shouldn't happen, only if
      buggy system or broken logic at all.
    
    v3 -> v4
    
    * Use dev_err instead of custom NE log pattern.
    
    v2 -> v3
    
    * Remove the WARN_ON calls.
    * Update static calls sanity checks.
    * Update kzfree() calls to kfree().
    
    v1 -> v2
    
    * Add log pattern for NE.
    * Remove the BUG_ON calls.
    * Update goto labels to match their purpose.
    * Add early exit in release() if there was a slot alloc error in the fd
      creation path.
    Reviewed-by: default avatarAlexander Graf <graf@amazon.com>
    Signed-off-by: default avatarAlexandru Vasile <lexnv@amazon.com>
    Signed-off-by: default avatarAndra Paraschiv <andraprs@amazon.com>
    Link: https://lore.kernel.org/r/20200921121732.44291-14-andraprs@amazon.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    9c8eb50f
ne_misc_dev.c 45.3 KB