-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from keystone-enclave/dev
Merging Dev
- Loading branch information
Showing
7 changed files
with
90 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule linux-keystone-driver
updated
6 files
+14 −2 | keystone-enclave.c | |
+26 −3 | keystone-ioctl.c | |
+10 −0 | keystone-page.c | |
+68 −7 | keystone-rtld.c | |
+7 −1 | keystone.c | |
+4 −0 | keystone.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
diff --git arch/riscv/mm/dma.c arch/riscv/mm/dma.c | ||
index 0689bb2..9fa9f11 100644 | ||
--- arch/riscv/mm/dma.c | ||
+++ arch/riscv/mm/dma.c | ||
@@ -20,6 +20,7 @@ | ||
#include <linux/gfp.h> | ||
#include <linux/mm.h> | ||
#include <linux/dma-mapping.h> | ||
+#include <linux/dma-contiguous.h> | ||
#include <linux/scatterlist.h> | ||
#include <linux/swiotlb.h> | ||
|
||
@@ -35,14 +36,41 @@ static void *dma_riscv_alloc(struct device *dev, size_t size, | ||
gfp |= __GFP_DMA32; | ||
} | ||
|
||
- return swiotlb_alloc_coherent(dev, size, dma_handle, gfp); | ||
+ if (dev_get_cma_area(dev) && gfpflags_allow_blocking(gfp)) { | ||
+ void* addr; | ||
+ struct page *page; | ||
+ page = dma_alloc_from_contiguous(dev, size >> PAGE_SHIFT, | ||
+ get_order(size), gfp); | ||
+ if (!page) | ||
+ { | ||
+ pr_err("Unabled to allocated from contiguous memory\n"); | ||
+ return NULL; | ||
+ } | ||
+ | ||
+ *dma_handle = phys_to_dma(dev, page_to_phys(page)); | ||
+ addr = page_address(page); | ||
+ memset(addr, 0, size); | ||
+ return addr; | ||
+ } else { | ||
+ return swiotlb_alloc_coherent(dev, size, dma_handle, gfp); | ||
+ } | ||
} | ||
|
||
static void dma_riscv_free(struct device *dev, size_t size, | ||
void *cpu_addr, dma_addr_t dma_addr, | ||
unsigned long attrs) | ||
{ | ||
- return swiotlb_free_coherent(dev, size, cpu_addr, dma_addr); | ||
+ bool freed; | ||
+ phys_addr_t paddr = dma_to_phys(dev, dma_addr); | ||
+ | ||
+ freed = dma_release_from_contiguous(dev, | ||
+ phys_to_page(paddr), | ||
+ size >> PAGE_SHIFT); | ||
+ if(!freed) { | ||
+ swiotlb_free_coherent(dev, size, cpu_addr, dma_addr); | ||
+ } | ||
+ | ||
+ return; | ||
} | ||
|
||
static int dma_riscv_supported(struct device *dev, u64 mask) | ||
diff --git arch/riscv/mm/init.c arch/riscv/mm/init.c | ||
index c77df81..312c84d 100644 | ||
--- arch/riscv/mm/init.c | ||
+++ arch/riscv/mm/init.c | ||
@@ -18,6 +18,7 @@ | ||
#include <linux/memblock.h> | ||
#include <linux/swap.h> | ||
#include <linux/sizes.h> | ||
+#include <linux/dma-contiguous.h> | ||
|
||
#include <asm/tlbflush.h> | ||
#include <asm/sections.h> | ||
@@ -44,6 +45,7 @@ void __init paging_init(void) | ||
setup_zero_page(); | ||
local_flush_tlb_all(); | ||
zone_sizes_init(); | ||
+ dma_contiguous_reserve(memblock_end_of_DRAM()); | ||
} | ||
|
||
void __init mem_init(void) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
#!/usr/bin/env bash | ||
cd riscv-qemu | ||
patch -p0 --forward hw/riscv/boot.c < ../patches/qemu-kernel-reloc.patch || true | ||
patch --forward hw/riscv/boot.c < ../patches/qemu-kernel-reloc.patch || true | ||
cd .. | ||
|
||
# linux patch | ||
cd riscv-linux | ||
patch -p0 --forward < ../patches/linux-cma.patch || true | ||
cd .. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule sdk
updated
7 files
+7 −1 | lib/app/src/tiny-malloc.c | |
+1 −1 | lib/host/include/params.h | |
+15 −0 | lib/verifier/report.cpp | |
+1 −0 | lib/verifier/report.h | |
+1 −1 | runtime | |
+7 −3 | tests/app.lds | |
+0 −1 | tests/test-runner.cpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters