| fbf3443f | 07-Nov-2021 |
Longpeng <longpeng2@huawei.com> |
nitro_enclaves: Add KUnit tests for contiguous physical memory regions merging
Add KUnit tests for the contiguous physical memory regions merging functionality from the Nitro Enclaves misc device lo
nitro_enclaves: Add KUnit tests for contiguous physical memory regions merging
Add KUnit tests for the contiguous physical memory regions merging functionality from the Nitro Enclaves misc device logic.
We can build the test binary with the following configuration: CONFIG_KUNIT=y CONFIG_NITRO_ENCLAVES=m CONFIG_NITRO_ENCLAVES_MISC_DEV_TEST=y and install the nitro_enclaves module to run the testcases.
We'll see the following message using dmesg if everything goes well:
[...] # Subtest: ne_misc_dev_test [...] 1..1 [...] (NULL device *): Physical mem region address is not 2 MiB aligned [...] (NULL device *): Physical mem region size is not multiple of 2 MiB [...] (NULL device *): Physical mem region address is not 2 MiB aligned [...] ok 1 - ne_misc_dev_test_merge_phys_contig_memory_regions [...] ok 1 - ne_misc_dev_test
Reviewed-by: Andra Paraschiv <andraprs@amazon.com> Signed-off-by: Longpeng <longpeng2@huawei.com> Link: https://lore.kernel.org/r/20211107140918.2106-5-longpeng2@huawei.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
| 07503b3c | 07-Nov-2021 |
Longpeng <longpeng2@huawei.com> |
nitro_enclaves: Add KUnit tests setup for the misc device functionality
Add the initial setup for the KUnit tests that will target the Nitro Enclaves misc device functionality.
Reviewed-by: Andra P
nitro_enclaves: Add KUnit tests setup for the misc device functionality
Add the initial setup for the KUnit tests that will target the Nitro Enclaves misc device functionality.
Reviewed-by: Andra Paraschiv <andraprs@amazon.com> Signed-off-by: Longpeng <longpeng2@huawei.com> Link: https://lore.kernel.org/r/20211107140918.2106-4-longpeng2@huawei.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
| 090ce783 | 07-Nov-2021 |
Longpeng <longpeng2@huawei.com> |
nitro_enclaves: Sanity check physical memory regions during merging
Sanity check the physical memory regions during the merge of contiguous regions. Thus we can test the physical memory regions setu
nitro_enclaves: Sanity check physical memory regions during merging
Sanity check the physical memory regions during the merge of contiguous regions. Thus we can test the physical memory regions setup logic individually, including the error cases coming from the sanity checks.
Reviewed-by: Andra Paraschiv <andraprs@amazon.com> Signed-off-by: Longpeng <longpeng2@huawei.com> Link: https://lore.kernel.org/r/20211107140918.2106-3-longpeng2@huawei.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
| f6bdc0aa | 07-Nov-2021 |
Longpeng <longpeng2@huawei.com> |
nitro_enclaves: Merge contiguous physical memory regions
There can be cases when there are more memory regions that need to be set for an enclave than the maximum supported number of memory regions
nitro_enclaves: Merge contiguous physical memory regions
There can be cases when there are more memory regions that need to be set for an enclave than the maximum supported number of memory regions per enclave. One example can be when the memory regions are backed by 2 MiB hugepages (the minimum supported hugepage size).
Let's merge the adjacent regions if they are physically contiguous. This way the final number of memory regions is less than before merging and could potentially avoid reaching maximum.
Reviewed-by: Andra Paraschiv <andraprs@amazon.com> Signed-off-by: Longpeng <longpeng2@huawei.com> Link: https://lore.kernel.org/r/20211107140918.2106-2-longpeng2@huawei.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
| 02bba596 | 27-Aug-2021 |
Andra Paraschiv <andraprs@amazon.com> |
nitro_enclaves: Add fixes for checkpatch match open parenthesis reports
Update the codebase formatting to fix the reports from the checkpatch script, to match the open parenthesis.
Reviewed-by: Geo
nitro_enclaves: Add fixes for checkpatch match open parenthesis reports
Update the codebase formatting to fix the reports from the checkpatch script, to match the open parenthesis.
Reviewed-by: George-Aurelian Popescu <popegeo@amazon.com> Signed-off-by: Andra Paraschiv <andraprs@amazon.com> Link: https://lore.kernel.org/r/20210827154930.40608-6-andraprs@amazon.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
| e3cba4d2 | 27-Aug-2021 |
Andra Paraschiv <andraprs@amazon.com> |
nitro_enclaves: Update copyright statement to include 2021
Update the copyright statement to include 2021, as a change has been made over this year.
Check commit d874742f6a73 ("nitro_enclaves: Set
nitro_enclaves: Update copyright statement to include 2021
Update the copyright statement to include 2021, as a change has been made over this year.
Check commit d874742f6a73 ("nitro_enclaves: Set Bus Master for the NE PCI device") for the codebase update from this file (ne_pci_dev.c).
Reviewed-by: George-Aurelian Popescu <popegeo@amazon.com> Signed-off-by: Andra Paraschiv <andraprs@amazon.com> Link: https://lore.kernel.org/r/20210827154930.40608-5-andraprs@amazon.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
| e16a30a4 | 27-Aug-2021 |
Andra Paraschiv <andraprs@amazon.com> |
nitro_enclaves: Add fix for the kernel-doc report
Fix the reported issue from the kernel-doc script, to have a comment per identifier.
Reviewed-by: George-Aurelian Popescu <popegeo@amazon.com> Sign
nitro_enclaves: Add fix for the kernel-doc report
Fix the reported issue from the kernel-doc script, to have a comment per identifier.
Reviewed-by: George-Aurelian Popescu <popegeo@amazon.com> Signed-off-by: Andra Paraschiv <andraprs@amazon.com> Link: https://lore.kernel.org/r/20210827154930.40608-4-andraprs@amazon.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
| 0f5c7b74 | 21-Sep-2020 |
Andra Paraschiv <andraprs@amazon.com> |
nitro_enclaves: Add Makefile for the Nitro Enclaves driver
Add Makefile for the Nitro Enclaves driver, considering the option set in the kernel config.
Changelog
v9 -> v10
* Update commit message
nitro_enclaves: Add Makefile for the Nitro Enclaves driver
Add Makefile for the Nitro Enclaves driver, considering the option set in the kernel config.
Changelog
v9 -> v10
* Update commit message to include the changelog before the SoB tag(s).
v8 -> v9
* Remove -Wall flags, could use W=1 as an option for this.
v7 -> v8
* No changes.
v6 -> v7
* No changes.
v5 -> v6
* No changes.
v4 -> v5
* No changes.
v3 -> v4
* No changes.
v2 -> v3
* Remove the GPL additional wording as SPDX-License-Identifier is already in place.
v1 -> v2
* Update path to Makefile to match the drivers/virt/nitro_enclaves directory.
Reviewed-by: Alexander Graf <graf@amazon.com> Signed-off-by: Andra Paraschiv <andraprs@amazon.com> Link: https://lore.kernel.org/r/20200921121732.44291-16-andraprs@amazon.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
| 07499cc6 | 21-Sep-2020 |
Andra Paraschiv <andraprs@amazon.com> |
nitro_enclaves: Add Kconfig for the Nitro Enclaves driver
Add kernel config entry for Nitro Enclaves, including dependencies.
Changelog
v9 -> v10
* Update commit message to include the changelog
nitro_enclaves: Add Kconfig for the Nitro Enclaves driver
Add kernel config entry for Nitro Enclaves, including dependencies.
Changelog
v9 -> v10
* Update commit message to include the changelog before the SoB tag(s).
v8 -> v9
* No changes.
v7 -> v8
* No changes.
v6 -> v7
* Remove, for now, the dependency on ARM64 arch. x86 is currently supported, with Arm to come afterwards. The NE kernel driver can be built for aarch64 arch.
v5 -> v6
* No changes.
v4 -> v5
* Add arch dependency for Arm / x86.
v3 -> v4
* Add PCI and SMP dependencies.
v2 -> v3
* Remove the GPL additional wording as SPDX-License-Identifier is already in place.
v1 -> v2
* Update path to Kconfig to match the drivers/virt/nitro_enclaves directory. * Update help in Kconfig.
Reviewed-by: Alexander Graf <graf@amazon.com> Signed-off-by: Andra Paraschiv <andraprs@amazon.com> Link: https://lore.kernel.org/r/20200921121732.44291-15-andraprs@amazon.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
| 9c8eb50f | 21-Sep-2020 |
Andra Paraschiv <andraprs@amazon.com> |
nitro_enclaves: Add logic for terminating an enclave
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 encl
nitro_enclaves: Add logic for terminating an enclave
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: Alexander Graf <graf@amazon.com> Signed-off-by: Alexandru Vasile <lexnv@amazon.com> Signed-off-by: Andra Paraschiv <andraprs@amazon.com> Link: https://lore.kernel.org/r/20200921121732.44291-14-andraprs@amazon.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
| 111c775a | 21-Sep-2020 |
Andra Paraschiv <andraprs@amazon.com> |
nitro_enclaves: Add logic for starting an enclave
After all the enclave resources are set, the enclave is ready for beginning to run.
Add ioctl command logic for starting an enclave after all its r
nitro_enclaves: Add logic for starting an enclave
After all the enclave resources are set, the enclave is ready for beginning to run.
Add ioctl command logic for starting an enclave after all its resources, memory regions and CPUs, have been set.
The enclave start information includes the local channel addressing - vsock CID - and the flags associated with the enclave.
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
* Add check for invalid enclave CID value e.g. well-known CIDs and parent VM CID. * Add custom error code for incorrect flag in enclave start info and invalid enclave CID.
v6 -> v7
* 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
* Check for invalid enclave start flags. * Update documentation to kernel-doc format.
v4 -> v5
* Add early exit on enclave start ioctl function call error. * Move sanity checks in the enclave start ioctl function, outside of the switch-case block. * Remove log on copy_from_user() / copy_to_user() failure.
v3 -> v4
* Use dev_err instead of custom NE log pattern. * Update the naming for the ioctl command from metadata to info. * Check for minimum enclave memory size.
v2 -> v3
* Remove the WARN_ON calls. * Update static calls sanity checks.
v1 -> v2
* Add log pattern for NE. * Check if enclave state is init when starting an enclave. * Remove the BUG_ON calls.
Reviewed-by: Alexander Graf <graf@amazon.com> Signed-off-by: Alexandru Vasile <lexnv@amazon.com> Signed-off-by: Andra Paraschiv <andraprs@amazon.com> Link: https://lore.kernel.org/r/20200921121732.44291-13-andraprs@amazon.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
| 7dc9d430 | 21-Sep-2020 |
Andra Paraschiv <andraprs@amazon.com> |
nitro_enclaves: Add logic for setting an enclave memory region
Another resource that is being set for an enclave is memory. User space memory regions, that need to be backed by contiguous memory reg
nitro_enclaves: Add logic for setting an enclave memory region
Another resource that is being set for an enclave is memory. User space memory regions, that need to be backed by contiguous memory regions, are associated with the enclave.
One solution for allocating / reserving contiguous memory regions, that is used for integration, is hugetlbfs. The user space process that is associated with the enclave passes to the driver these memory regions.
The enclave memory regions need to be from the same NUMA node as the enclave CPUs.
Add ioctl command logic for setting user space memory region for an enclave.
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
* Add early check, while getting user pages, to be multiple of 2 MiB for the pages that back the user space memory region. * Add custom error code for incorrect user space memory region flag. * Include in a separate function the sanity checks for each page of the user space memory region.
v6 -> v7
* Update check for duplicate user space memory regions to cover additional possible scenarios.
v5 -> v6
* Check for max number of pages allocated for the internal data structure for pages. * Check for invalid memory region flags. * Check for aligned physical memory regions. * Update documentation to kernel-doc format. * Check for duplicate user space memory regions. * Use directly put_page() instead of unpin_user_pages(), to match the get_user_pages() calls.
v4 -> v5
* Add early exit on set memory region ioctl function call error. * Remove log on copy_from_user() failure. * Exit without unpinning the pages on NE PCI dev request failure as memory regions from the user space range may have already been added. * Add check for the memory region user space address to be 2 MiB aligned. * Update logic to not have a hardcoded check for 2 MiB memory regions.
v3 -> v4
* Check enclave memory regions are from the same NUMA node as the enclave CPUs. * Use dev_err instead of custom NE log pattern. * Update the NE ioctl call to match the decoupling from the KVM API.
v2 -> v3
* Remove the WARN_ON calls. * Update static calls sanity checks. * Update kzfree() calls to kfree().
v1 -> v2
* Add log pattern for NE. * Update goto labels to match their purpose. * Remove the BUG_ON calls. * Check if enclave max memory regions is reached when setting an enclave memory region. * Check if enclave state is init when setting an enclave memory region.
Reviewed-by: Alexander Graf <graf@amazon.com> Signed-off-by: Alexandru Vasile <lexnv@amazon.com> Signed-off-by: Andra Paraschiv <andraprs@amazon.com> Link: https://lore.kernel.org/r/20200921121732.44291-12-andraprs@amazon.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|