diff --git a/.travis.yml b/.travis.yml index 36ef6ac7d..58686b89c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -65,3 +65,6 @@ jobs: - source ./source.sh - travis_wait 120 make - travis_wait 10 ./scripts/travis.sh + after_failure: + - cat screenlog.0 + - cat output.log \ No newline at end of file diff --git a/linux-keystone-driver b/linux-keystone-driver index 4f8e0ea15..9c6b89010 160000 --- a/linux-keystone-driver +++ b/linux-keystone-driver @@ -1 +1 @@ -Subproject commit 4f8e0ea159b8e76a33c53b72b2921d592bb93076 +Subproject commit 9c6b89010f4a6e60d097d0f606f55fce816c44d8 diff --git a/patches/linux-cma.patch b/patches/linux-cma.patch new file mode 100644 index 000000000..7c8a5328f --- /dev/null +++ b/patches/linux-cma.patch @@ -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 + #include + #include ++#include + #include + #include + +@@ -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 + #include + #include ++#include + + #include + #include +@@ -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) diff --git a/scripts/apply-patch.sh b/scripts/apply-patch.sh index 7e8c3f192..529d396ef 100755 --- a/scripts/apply-patch.sh +++ b/scripts/apply-patch.sh @@ -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 .. + diff --git a/scripts/travis.sh b/scripts/travis.sh index 07aee8480..5175a4650 100755 --- a/scripts/travis.sh +++ b/scripts/travis.sh @@ -1,7 +1,7 @@ #!/bin/bash # Launch QEMU test -screen -dmS qemu ./scripts/run-qemu.sh +screen -L -dmS qemu ./scripts/run-qemu.sh sleep 10 ./scripts/test-qemu.sh diff --git a/sdk b/sdk index c7a0a6e7c..f73d3772c 160000 --- a/sdk +++ b/sdk @@ -1 +1 @@ -Subproject commit c7a0a6e7c1fb9f24c725acd1766244f80ee87487 +Subproject commit f73d3772cd2bbb48fa44434bbfc26ed4e9fe63cb diff --git a/tests/test-qemu.expected.log b/tests/test-qemu.expected.log index db11dd75e..151618c8f 100644 --- a/tests/test-qemu.expected.log +++ b/tests/test-qemu.expected.log @@ -20,7 +20,6 @@ Enclave said: 2nd hello world! Enclave said value: 13 Enclave said value: 20 testing attestation -{"device_pubkey": "0faad4ff01178583baa588966f7c1ff32564dd17d7dc2b46cb50a84a69270b4c", "enclave": {"data": "6e6f6e6365", "datalen": 5, "hash": "d57055329653d90d51d1cccb27aebdddbb7fb57ec233bb0e6fa252442c890578dc870b470ff2ef8b566bb2d8e426686635c5e887962e90b07e5ecfd1ce544a96", "signature": "715eb432d5a135ff99db5ebf36c879a2256ac30c748da53f4686582be8bc7350734ecfd0d546052e954b6982033412bcc5ad1ac31c6b0880072c2cb34725bd0f"}, "security_monitor": {"hash": "eae0226b42eaf3614ecf3fb1e6d3ce8854788457cacd018d9ef04de7c8d0d62504c040dc6a86b02380e459936e0ea96a4c721a0bec60351977b697ca46e7b05e", "pubkey": "40efc082defde02e3559d79b4536b602c3def2bf20515c59f189551a5c3481be", "signature": "f2acf168316d121005fc8dd3278b9740a17426a39ce6a95272ec9797a8710aa14f2cf700443b7aeddfd17f441f74f20a2d33827a4b4a04f3b6fde9ad6aa38c05"}} Attestation report SIGNATURE is valid root@ucbvax:~# poweroff root@ucbvax:~# Connection to localhost closed by remote host.