Giter VIP home page Giter VIP logo

penglai-enclave / penglai-enclave-spmp Goto Github PK

View Code? Open in Web Editor NEW
121.0 8.0 35.0 173.77 MB

Penglai Enclave is an open-sourced, secure and scalable TEE system for RISC-V.

License: Other

Makefile 0.26% Shell 0.29% Roff 0.02% C 97.99% Assembly 1.07% Perl 0.13% C++ 0.03% Awk 0.01% Python 0.17% sed 0.01% Yacc 0.01% Lex 0.01% UnrealScript 0.01% SmPL 0.02% Gherkin 0.01% XS 0.01% Raku 0.01% Clojure 0.01% M4 0.01% GDB 0.01%
risc-v tee enclave

penglai-enclave-spmp's Introduction

Penglai is a set of security solutions based on Trusted Execution Environment.

This repo contains an overview of the whole project.

It currently supports RISC-V platforms, including both high-performant MMU RISC-V64 arch and MCU (RISC-V32, no MMU).

More informations can be found in our online document: Penglai-doc

Systems

Penglai contains a set of systems satisfying different scenarios.

  • Penglai-TVM: it is based on OpenSBI, supports fine-grained isolation (page-level isolation) between untrusted host and enclaves. The code is maintained in Penglai-TVM.
  • Penglai-sPMP: it utilizes PMP or sPMP (S-mode PMP) to provide basic enclave functionalities. A version based on OpenSBI for Nuclei devices is maintained in Nuclei SDK.
  • Penglai-Zone: PenglaiZone is a project that aims to support the privileged zone in Trusted Execution Environment (TEE), such as TEEOS, standaloneMM in Unified Extensible Firmware Interface (UEFI). The code is maintained in Penglai-Zone.
  • Penglai-MCU: it supports Global Platform, and PSA now. Not open-sourced. Refer Penglai-MCU for more info.

Monthly Report

Monthly update reports for Penglai TEE (include Penglai-sPMP, Penglai-TVM and Penglai-Zone) can be obtained here.

Features

We highlight several features on Penglai which are novel over other TEE systems.

Cross-enclave communication

Penglai supports the synchronous and asynchronous cross-enclave communication using the zero-copy memory transferring mechanism.

Synchronous IPC interface:
struct call_enclave_arg_t
{
  unsigned long req_arg;
  unsigned long resp_val;
  unsigned long req_vaddr;
  unsigned long req_size;
  unsigned long resp_vaddr;
  unsigned long resp_size;
};

unsigned long acquire_enclave(char* name);;
unsigned long call_enclave(unsigned long handle, struct call_enclave_arg_t* arg);
void SERVER_RETURN(struct call_enclave_arg_t *arg);

As for synchronous cross-enclave communication, Penglai sdk provides three IPC-related interfaces: acquire_enclave, call_enclave and SERVER_RETURN.

  • Acquire_enclave receives the callee enclave name and returns the corresponding enclave handler.

  • Call_enclave has two parameters, one is the enclave handler, and another is the argument's structure: struct call_enclave_arg_t. struct call_enclave_arg_t contains six variables: req_arg and resp_val are the calling and return value passing by the register. req_size and req_vaddr indicate a memory range that will map to the callee enclave using the zero-copy mechanism. resp_size and resp_vaddr are similar to the req_size and req_vaddr, which are ignored in the calling procedure, but will be filled by monitor in the return procedure.

    Call_enclave will be hanged until the calling procedure returns.

  • SERVER_RETURN also receives the struct call_enclave_arg_t, which indicates the resp_size and resp_vaddr.

Asynchronous IPC interface:

unsigned long asyn_enclave_call(char* name, struct call_enclave_arg_t *arg);

asyn_enclave_call receives two parameters, one is the callee enclave name and another is the pointer of the struct call_enclave_arg_t, but only the req_vaddr and req_size are effective. When an enclave invokes the asyn_enclave_call, Penglai monitor will unmap these memory pages, and re-map them to the callee enclave before it running. In addition, asyn_enclave_call will not suspend the caller enclave procedure.

Secure file system

Penglai adopts xv6fs and littlefs as its file system, serving enclaves. It utilizes the encryption libraries in SDK to encrypt/decrypt the data and provide integrity protections.

Penglai add an interface layer on top of file system to support unified interface abstraction to client enclave. In the implementation of this layer, these file system related interfaces are the functions supported to client. Clients call the functions in the way of IPC between enclave.

On the client side, we hide the details of IPC in the musl libc we offered in penglai SDK. So if a client want to interact with file system, they can just use the standard libc file system interfaces.

At this moment, the following file system related interfaces are supported.

FILE* fopen(const char* pathname, const char* mode);
FILE* fclose(FILE* stream);
size_t fread(void* ptr, size_t size, size_t nmemb, FILE* stream);
size_t fwrite(const void* ptr, size_t size, size_t nmemb, FILE* stream);
char* fgets(char* s, int size, FILE* stream);
int fputs(const char* s, FILE* stream);
int fseek(FILE* stream, long offset, int whence);
int mkdir(const char* pathname, mode_t mode);
int stat(const char* path, struct stat *buf);
int truncate(const char* path, off_t length);

Here is a easy example to show how to use file system.

int EAPP_ENTRY main(){
    unsigned long* args;
    EAPP_RESERVE_REG;
    FILE *f;
    int status;
    char buf[52] = {0};
    eapp_print("before fopen\n");
    f = fopen("/create.txt","w");
    char str[] = "just for create and write\ntest fgets";
    fputs(str,f);
    eapp_print("after fwrite\n");
    struct stat st;
    fclose(f);
    status = stat("/create.txt", &st);
    if(!status){
        eapp_print("stat succeed: file length: %d\n",st.st_size);
    }
    f = fopen("/create.txt","r");
    memset(buf,0,52);
    eapp_print("fopen /create.txt for read\n");
    char* res = fgets(buf,52,f);
    if(res == NULL){
        eapp_print("fgets failed\n");
    }
    eapp_print("read writed content: %s\n",buf);
    fseek(f,0,SEEK_SET);
    memset(buf,0,53);
    fgets(buf,52,f);
    eapp_print("read after seek: %s\n",buf);
    fclose(f);
    f = fopen("/sub/empty.txt","w");
    if(!f){
        eapp_print("open file failed, directory does not exist\n");
        if(mkdir("/sub", 0) != 0){
            eapp_print("mkdir failed\n");
            EAPP_RETURN(0);
        }
    }
    f = fopen("/sub/empty.txt","w");
    if(!f){
        eapp_print("open after mkdir failed\n");
        EAPP_RETURN(0);
    }
    fputs(str, f);
    fclose(f);
    eapp_print("write to empty file\n");
    f = fopen("/sub/empty.txt","r");
    fgets(buf,52,f);
    eapp_print("read from empty file, %s\n",buf);
    fclose(f);
    int fd;
    if ((fd = open("/sub/empty2.txt", O_RDWR| O_CREAT)) < 0) {
        eapp_print("open error\n");
     }
    struct stat stat_buf;
    eapp_print("stat begin\n");
    stat("/sub/empty.txt", &stat_buf);
    printf("/sub/empty.txt file size = %d/n", stat_buf.st_size);
    EAPP_RETURN(0);
}

Encryption library in SDK

Penglai supports national secret algorithm like SM4.

Besides, Penglai utilizes the mbedtls to provide other crypto algorithm support.

Mbed TLS is a C library that implements cryptographic primitives, X.509 certificate manipulation and the SSL/TLS and DTLS protocols. Its small code footprint makes it suitable for embedded systems. And Mbed TLS includes a reference implementation of the PSA Cryptography API.

You can find the basic doc tutorial in mbedtls/docs. And if you want to get more specific API documents, you can use doxygen engine to generate the API documents. The doxygen file is located at mbedtls/doxygen.

The implementation of mbedtls is very flexible and very easy to port to different platforms. You can modify the configurations in mbedtls/include/mbedtls/config.h to adapt to the library to your platform.

Support existing frameworks

  • PSA: description TODO
  • GP: description TODO

License Details

Mulan Permissive Software License,Version 1 (Mulan PSL v1)

Collaborators

We thank all of our collaborators (companies, organizations, and communities).

Huawei nuclei StarFive ISCAS
Huawei (华为) Nuclei (芯来科技) StarFive (赛昉科技) ISCAS(中科院软件所)
openEuler OpenHarmony secGear
openEuler community OpenHarmony community secGear framework

penglai-enclave-spmp's People

Contributors

ddnirvana avatar fengerhu1 avatar fly0307 avatar iku-iku-iku avatar liangliang-ll avatar moonquakes avatar pengxuanyao avatar shang-qy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

penglai-enclave-spmp's Issues

How to use Penglai Tee-TVM for development?

Hello, I am very interested in Penglai Tee and would like to conduct research and development on it. But I can only use it to run demo, how should I use it to run my own code? Is there a tutorial available for reference?

Facing kernel panic for openEuler 23.09

Hi Dong Du,

Facing kernel panic for openEuler 23.09

Workstation details:
Ubuntu 22.04
RISC-V cross compilier 13.2.0
qemu version 8.1.50

Steps to reproduce:
Cross compilied u-boot, opensbi-1.2 as per the steps for openEuler >23.
when cross compiling sdk it was unsuccessful.
used the https://ipads.se.sjtu.edu.cn:1313/d/6a464e02cd3d4c1bafb0/ sdk source and cross compilation was successful.

Booted the openEuler 23.09 with below command

qemu-system-riscv64 -nographic -machine virt \
			-smp 4 -m 2G \
			-bios  ./opensbi-1.2/build-oe/qemu-virt/platform/generic/firmware/fw_payload.bin  \
			-drive file=openEuler-23.09-qemu-riscv64.qcow2,format=qcow2,id=hd0 \
			-object rng-random,filename=/dev/urandom,id=rng0 \
			-device virtio-rng-device,rng=rng0 \
			-device virtio-blk-device,drive=hd0  \
			-device virtio-net-device,netdev=usernet \
			-netdev user,id=usernet,hostfwd=tcp::12055-:22 \
			-device qemu-xhci -usb -device usb-kbd -device usb-tablet

copied files from host to openEuler qemu as follows:

scp -P 12055 penglai-enclave-driver/penglai.ko root@localhost:~/
scp -P 12055 sdk/demo/host/host root@localhost:~/
scp -P 12055 sdk/demo/prime/prime root@localhost:~/

cross compiled penglai-kernel-driver generated penglai.ko
insert the enclave driver module
insmod penglai.ko

[root@openeuler-riscv64 penglai-enclave-driver]# insmod penglai.ko 
[ 1000.778139] penglai: loading out-of-tree module taints kernel.
[ 1000.780758] enclave_ioctl_init...
[Penglai KModule] sbi_ecall_penglai_host_handler invoked,funcid=100d
[Penglai Monitor] sm_mm_init invoked
[Penglai Monitor] sm_mm_init paddr:0xa3c00000, size:0x400000
[Debug:SM@dump_pmps] pmp_0: mode(0x18) perm(0x0) paddr(0x80028000) size(0x2000)
[Debug:SM@dump_pmps] pmp_1: mode(0x0) perm(0x0) paddr(0x0) size(0x0)
[Debug:SM@dump_pmps] pmp_2: mode(0x18) perm(0x7) paddr(0x0) size(0x8)
[Debug:SM@dump_pmps] pmp_3: mode(0x0) perm(0x0) paddr(0x0) size(0x0)
[Debug:SM@dump_pmps] pmp_4: mode(0x0) perm(0x0) paddr(0x0) size(0x0)
[Debug:SM@dump_pmps] pmp_5: mode(0x0) perm(0x0) paddr(0x0) size(0x0)
[Debug:SM@dump_pmps] pmp_6: mode(0x0) perm(0x0) paddr(0x0) size(0x0)
[Debug:SM@dump_pmps] pmp_7: mode(0x0) perm(0x0) paddr(0x0) size(0x0)
[Debug:SM@dump_pmps] pmp_8: mode(0x0) perm(0x0) paddr(0x0) size(0x0)
[Debug:SM@dump_pmps] pmp_9: mode(0x0) perm(0x0) paddr(0x0) size(0x0)
[Debug:SM@dump_pmps] pmp_10: mode(0x0) perm(0x0) paddr(0x0) size(0x0)
[Debug:SM@dump_pmps] pmp_11: mode(0x0) perm(0x0) paddr(0x0) size(0x0)
[Debug:SM@dump_pmps] pmp_12: mode(0x0) perm(0x0) paddr(0x0) size(0x0)
[Debug:SM@dump_pmps] pmp_13: mode(0x0) perm(0x0) paddr(0x0) size(0x0)
[Debug:SM@dump_pmps] pmp_14: mode(0x0) perm(0x0) paddr(0x0) size(0x0)
[Debug:SM@dump_pmps] pmp_15: mode(0x18) perm(0x7) paddr(0x0) size(0x8)
[Debug:SM@dump_pmps] pmp_0: mode(0x18) perm(0x0) paddr(0x80028000) size(0x2000)
[Debug:SM@dump_pmps] pmp_1: mode(0x0) perm(0x0) paddr(0x0) size(0x0)
[Debug:SM@dump_pmps] pmp_2: mode(0x18) perm(0x0) paddr(0xa3c00000) size(0x400000)
[Debug:SM@dump_pmps] pmp_3: mode(0x0) perm(0x0) paddr(0x0) size(0x0)
[Debug:SM@dump_pmps] pmp_4: mode(0x0) perm(0x0) paddr(0x0) size(0x0)
[Debug:SM@dump_pmps] pmp_5: mode(0x0) perm(0x0) paddr(0x0) size(0x0)
[Debug:SM@dump_pmps] pmp_6: mode(0x0) perm(0x0) paddr(0x0) size(0x0)
[Debug:SM@dump_pmps] pmp_7: mode(0x0) perm(0x0) paddr(0x0) size(0x0)
[Debug:SM@dump_pmps] pmp_8: mode(0x0) perm(0x0) paddr(0x0) size(0x0)
[Debug:SM@dump_pmps] pmp_9: mode(0x0) perm(0x0) paddr(0x0) size(0x0)
[Debug:SM@dump_pmps] pmp_10: mode(0x0) perm(0x0) paddr(0x0) size(0x0)
[Debug:SM@dump_pmps] pmp_11: mode(0x0) perm(0x0) paddr(0x0) size(0x0)
[Debug:SM@dump_pmps] pmp_12: mode(0x0) perm(0x0) paddr(0x0) size(0x0)
[Debug:SM@dump_pmps] pmp_13: mode(0x0) perm(0x0) paddr(0x0) size(0x0)
[Debug:SM@dump_pmps] pmp_14: mode(0x0) perm(0x0) paddr(0x0) size(0x0)
[Debug:SM@dump_pmps] pmp_15: mode(0x18) perm(0x7) paddr(0x0) size(0x8)
[Penglai Monitor] sm_mm_init ret:0d 
[ 1000.794471] [Penglai KModule] register_chrdev succeeded!

prime enclave execution was successful
./host prime
there is kernel call trace after enclave execution and kernel panic after some seconds

[root@openeuler ~]# rmo[  157.717647][  T730] kmemleak: Cannot insert 0xffffffd808391d80 into the object search tree (overlaps existing)
[  157.718217][  T730] CPU: 1 PID: 730 Comm: bash Tainted: G           OE      6.4.0-10.1.0.20.oe2309.riscv64 #1
[  157.718620][  T730] Hardware name: riscv-virtio,qemu (DT)
[  157.718938][  T730] Call Trace:
[  157.719111][  T730] [<ffffffff80006202>] dump_backtrace+0x28/0x30
[  157.719465][  T730] [<ffffffff80b96734>] show_stack+0x38/0x44
[  157.719699][  T730] [<ffffffff80ba9fe4>] dump_stack_lvl+0x44/0x5c
[  157.719946][  T730] [<ffffffff80baa014>] dump_stack+0x18/0x20
[  157.720172][  T730] [<ffffffff802a7ca8>] __create_object+0x374/0x398
[  157.720425][  T730] [<ffffffff80bacbbc>] kmemleak_alloc+0x48/0x80
[  157.720664][  T730] [<ffffffff80282e16>] __kmem_cache_alloc_node+0x1ca/0x2f8
[  157.720938][  T730] [<ffffffff802131e8>] __kmalloc+0x48/0x1b8
[  157.721162][  T730] [<ffffffff8036e65c>] ext4_htree_store_dirent+0x4c/0x16e
[  157.721432][  T730] [<ffffffff803a19c4>] htree_dirblock_to_tree+0x15c/0x27a
[  157.721694][  T730] [<ffffffff803a2836>] ext4_htree_fill_tree+0x172/0x2e6
[  157.721968][  T730] [<ffffffff8036dd08>] ext4_dx_readdir+0xd2/0x2be
[  157.722240][  T730] [<ffffffff8036e556>] ext4_readdir+0x43e/0x4c8
[  157.722505][  T730] [<ffffffff802d30a6>] iterate_dir+0x124/0x150
[  157.722772][  T730] [<ffffffff802d3330>] __do_sys_getdents64+0x64/0x150
[  157.723059][  T730] [<ffffffff802d3438>] sys_getdents64+0x1c/0x24
[  157.723342][  T730] [<ffffffff80baab12>] do_trap_ecall_u+0xf0/0x104
[  157.723653][  T730] [<ffffffff80003e70>] ret_from_exception+0x0/0x64
[  157.724090][  T730] kmemleak: Kernel memory leak detector disabled
[  157.724386][  T730] kmemleak: Object 0xffffffd808391d80 (size 64):
[  157.724653][  T730] kmemleak:   comm "bash", pid 730, jiffies 4294931765
[  157.724938][  T730] kmemleak:   min_count = 1
[  157.725136][  T730] kmemleak:   count = 0
[  157.725314][  T730] kmemleak:   flags = 0x1
[  157.725482][  T730] kmemleak:   checksum = 0
[  157.725654][  T730] kmemleak:   backtrace:
[  157.725902][  T730]  kmemleak_alloc+0x48/0x80
[  157.726108][  T730]  __kmem_cache_alloc_node+0x1ca/0x2f8
[  157.726322][  T730]  __kmalloc+0x48/0x1b8
[  157.726487][  T730]  ext4_htree_store_dirent+0x4c/0x16e
[  157.726693][  T730]  htree_dirblock_to_tree+0x15c/0x27a
[  157.726898][  T730]  ext4_htree_fill_tree+0x172/0x2e6
[  157.727098][  T730]  ext4_dx_readdir+0xd2/0x2be
[  157.727279][  T730]  ext4_readdir+0x43e/0x4c8
[  157.727455][  T730]  iterate_dir+0x124/0x150
[  157.727630][  T730]  __do_sys_getdents64+0x64/0x150
[  157.727826][  T730]  sys_getdents64+0x1c/0x24
[  157.728004][  T730]  do_trap_ecall_u+0xf0/0x104
[  157.728187][  T730]  ret_from_exception+0x0/0x64
[  157.738800][   T78] kmemleak: Automatic memory scanning thread ended

Similarly for 23.03 followed same steps with replacing openeuler 23.09 with 23.03 and was facing kernel panic as follows:

[ 5190.432458] ------------[ cut here ]------------
[ 5190.432866] WARNING: CPU: 3 PID: 1 at mm/slab_common.c:923 free_large_kmalloc+0x5a/0x90
[ 5190.433355] Modules linked in: drm fuse i2c_core drm_panel_orientation_quirks backlight [last unloaded: penglai(O)]
[ 5190.434170] CPU: 3 PID: 1 Comm: systemd Tainted: G           O       6.1.19-2.oe2303.riscv64 #1
[ 5190.434824] Hardware name: riscv-virtio,qemu (DT)
[ 5190.435223] epc : free_large_kmalloc+0x5a/0x90
[ 5190.435513]  ra : free_large_kmalloc+0x16/0x90
[ 5190.435762] epc : ffffffff8018e6fe ra : ffffffff8018e6ba sp : ff2000000060bb30
[ 5190.436112]  gp : ffffffff815db148 tp : ff60000001b10000 t0 : 0000000000000002
[ 5190.436451]  t1 : 0000000000000001 t2 : 0000000000000040 s0 : ff2000000060bb70
[ 5190.436808]  s1 : ff6000007ea00080 a0 : ff6000007ea00080 a1 : ff60000073636f72
[ 5190.437150]  a2 : ffffffffffffffff a3 : 0080000000000000 a4 : 0000000000000000
[ 5190.437540]  a5 : 0000000000000000 a6 : 0000000000000000 a7 : 0000000000000002
[ 5190.437904]  s2 : ff60000073636f72 s3 : ffffffff801830f4 s4 : 0000000000000800
[ 5190.438249]  s5 : ffffffff814c3d40 s6 : ffffffff815de228 s7 : 00000000ffffffff
[ 5190.438629]  s8 : ffffffff80000001 s9 : ff60000003a52410 s10: 0000000000000004
[ 5190.439059]  s11: ffffffff815df1d0 t3 : 0000000000000002 t4 : 0000000000000402
[ 5190.439450]  t5 : ff60000003a52430 t6 : ff6000000276afea
[ 5190.439740] status: 0000000200000120 badaddr: 0000000000000000 cause: 0000000000000003
[ 5190.440272] [<ffffffff8018e6fe>] free_large_kmalloc+0x5a/0x90
[ 5190.440694] [<ffffffff8018e844>] kfree+0x110/0x116
[ 5190.440965] [<ffffffff801830f4>] kfree_const+0x18/0x2e
[ 5190.441260] [<ffffffff80270336>] kernfs_put.part.0+0x6e/0x196
[ 5190.441550] [<ffffffff8027047c>] kernfs_put+0x1e/0x26
[ 5190.441820] [<ffffffff8026f694>] kernfs_evict_inode+0x2a/0x36
[ 5190.442126] [<ffffffff80217afa>] evict+0x94/0x160
[ 5190.442392] [<ffffffff80217f20>] iput+0x142/0x1bc
[ 5190.442687] [<ffffffff80212dfe>] dentry_unlink_inode+0xbe/0x108
[ 5190.442975] [<ffffffff802139fa>] __dentry_kill+0xb6/0x174
[ 5190.443176] [<ffffffff80215150>] shrink_dentry_list+0x4c/0xd6
[ 5190.443379] [<ffffffff8021533e>] shrink_dcache_parent+0xdc/0x12a
[ 5190.443634] [<ffffffff802068d0>] vfs_rmdir.part.0+0xc6/0x160
[ 5190.443954] [<ffffffff8020c564>] do_rmdir+0x170/0x180
[ 5190.444281] [<ffffffff8020c834>] sys_unlinkat+0x48/0x56
[ 5190.444528] [<ffffffff80003a7a>] ret_from_syscall+0x0/0x2
[ 5190.444904] ---[ end trace 0000000000000000 ]---
[ 5190.445400] object pointer: 0x000000003c5e4edc
[ 5190.445905] page:00000000c8b1a57b refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0xf3836
[ 5190.446401] flags: 0x0(zone=0)
[ 5190.447400] raw: 0000000000000000 ff6000007ea00088 ff6000007ea00088 0000000000000000
[ 5190.447880] raw: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000
[ 5190.448619] page dumped because: VM_BUG_ON_PAGE(page_ref_count(page) == 0)
[ 5190.449097] ------------[ cut here ]------------
[ 5190.449359] kernel BUG at include/linux/mm.h:763!
[ 5190.449881] Kernel BUG [#1]
[ 5190.450119] Modules linked in: drm fuse i2c_core drm_panel_orientation_quirks backlight [last unloaded: penglai(O)]
[ 5190.450936] CPU: 3 PID: 1 Comm: systemd Tainted: G        W  O       6.1.19-2.oe2303.riscv64 #1
[ 5190.451455] Hardware name: riscv-virtio,qemu (DT)
[ 5190.451763] epc : __free_pages+0xcc/0xce
[ 5190.452049]  ra : __free_pages+0xcc/0xce
[ 5190.452296] epc : ffffffff801bb74a ra : ffffffff801bb74a sp : ff2000000060baf0
[ 5190.452699]  gp : ffffffff815db148 tp : ff60000001b10000 t0 : 6d75642065676170
[ 5190.453047]  t1 : 0000000000000070 t2 : 706d756420656761 s0 : ff2000000060bb30
[ 5190.453400]  s1 : ff6000007ea00080 a0 : 000000000000003e a1 : 0000000000000001
[ 5190.453824]  a2 : 0000000000000010 a3 : 0000000000000018 a4 : a811eb175061e400
[ 5190.454223]  a5 : a811eb175061e400 a6 : 0000000000000008 a7 : 0000000000000038
[ 5190.454649]  s2 : ff6000007ea00080 s3 : 0000000000000000 s4 : 0000000000000800
[ 5190.455058]  s5 : ffffffff814c3d40 s6 : ffffffff815de228 s7 : 00000000ffffffff
[ 5190.455471]  s8 : ffffffff80000001 s9 : ff60000003a52410 s10: 0000000000000004
[ 5190.455859]  s11: ffffffff815df1d0 t3 : ffffffff815f0717 t4 : ffffffff815f0717
[ 5190.456273]  t5 : ffffffff815f0718 t6 : ff2000000060b8c8
[ 5190.456541] status: 0000000200000120 badaddr: 0000000000000000 cause: 0000000000000003
[ 5190.456932] [<ffffffff801bb74a>] __free_pages+0xcc/0xce
[ 5190.457226] [<ffffffff8018e6f0>] free_large_kmalloc+0x4c/0x90
[ 5190.457581] [<ffffffff8018e844>] kfree+0x110/0x116
[ 5190.457871] [<ffffffff801830f4>] kfree_const+0x18/0x2e
[ 5190.458166] [<ffffffff80270336>] kernfs_put.part.0+0x6e/0x196
[ 5190.458502] [<ffffffff8027047c>] kernfs_put+0x1e/0x26
[ 5190.458838] [<ffffffff8026f694>] kernfs_evict_inode+0x2a/0x36
[ 5190.459132] [<ffffffff80217afa>] evict+0x94/0x160
[ 5190.459419] [<ffffffff80217f20>] iput+0x142/0x1bc
[ 5190.459708] [<ffffffff80212dfe>] dentry_unlink_inode+0xbe/0x108
[ 5190.460052] [<ffffffff802139fa>] __dentry_kill+0xb6/0x174
[ 5190.460358] [<ffffffff80215150>] shrink_dentry_list+0x4c/0xd6
[ 5190.460683] [<ffffffff8021533e>] shrink_dcache_parent+0xdc/0x12a
[ 5190.461019] [<ffffffff802068d0>] vfs_rmdir.part.0+0xc6/0x160
[ 5190.461345] [<ffffffff8020c564>] do_rmdir+0x170/0x180
[ 5190.461631] [<ffffffff8020c834>] sys_unlinkat+0x48/0x56
[ 5190.461927] [<ffffffff80003a7a>] ret_from_syscall+0x0/0x2
[ 5190.462686] ---[ end trace 0000000000000000 ]---
[ 5190.463124] note: systemd[1] exited with irqs disabled
[ 5190.463794] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
[ 5190.464295] SMP: stopping secondary CPUs
[ 5190.465087] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b ]---

openEuler 23.03 uses 6.1.x Linux kernel and openEuler 23.09 uses 6.4.x Linux kernel.

observations:
when booted with openEuler 23.03 it is observed mmu was sv57 and with openEuler 23.09 it was sv39.
Any issue with OpenSBI?

Please let me know your suggestions or comments.

Thanks,
MD Sadiq

compile error when Build OpenSBI (with Penglai supports)

I was using the branch opensbi-v0.9. I followed the instructions, but when I arrived at Build OpenSBI (with Penglai supports), I was encountered with the following problem:

/home/penglai/toolchain/bin/../lib/gcc/riscv64-unknown-linux-gnu/7.2.0/../../../../riscv64-unknown-linux-gnu/bin/as: out of memory allocating 9223372036854841443 bytes after a total of 466944 bytes
Makefile:392: recipe for target '/home/penglai/penglai-enclave/opensbi-0.9/build-oe/qemu-virt/platform/generic/firmware/fw_payload.o' failed
make: *** [/home/penglai/penglai-enclave/opensbi-0.9/build-oe/qemu-virt/platform/generic/firmware/fw_payload.o] Error 1

image

Default qemu version is out of date

I build the qemu binaries from the "riscv-qemu" path, which generate qemu 4.1.1. when I use this qemu to load the image, it hang up at the output as following
[Penglai] Penglai Enclave Preparing

Then I found in the document that the qemu version should >= 5.2.0. Then I installed the required qemu and it worked ok.

In that case why not removing this "riscv-qemu" from the repo to avoid confusion? Or you can upgrade the qemu into the required one.

sdk make error

demo/gm_test_enclaves、demo/seal_data、demo/evm make error:

make[2]: *** No rule to make target '/home/penglai/penglai-enclave/sdk/lib/gm/libpenglai-enclave-gm.a', needed by 'test_sm2'.  Stop.
make[2]: Leaving directory '/home/penglai/penglai-enclave/sdk/demo/gm_test_enclaves'
make[1]: *** [Makefile:9: all] Error 2
make[1]: Leaving directory '/home/penglai/penglai-enclave/sdk/demo'
make: *** [Makefile:4: all] Error 2

For Penglai with OpenSBI-v1.0, pmp0 config for monitor protection.

For Penglai with OpenSBI-v1.0(under directory opensbi-1.0), pmp0 configuration for monitor protection is inaccurate.
It now uses _fw_start and _fw_end to decide pmp0 configuration, which facilitates the migration on dev boards. Although they are set correctly(include the hole firmware) during build time, it seems _fw_start and _fw_end will be changed at boot time, which make this protection method incomplete.

Update to OpenSBI-v1.0

OpenSBI has released its 1.0 version.
We should bump up Penglai to support 1.0 openSBI.

Unable to run sealdata demo and others of secgear except helloworld

os-openEuler 23.09
kernal-6.4.0
reference document links for demo run
https://github.com/Penglai-Enclave/Penglai-secGear/blob/riscv-penglai-zx-dev/docs/riscv_tee.md
Error which I got during compilation of demos
[root@openeuler-riscv64 debug]# cmake -DENABLE_ENC_KEY=1 -DCMAKE_BUILD_TYPE=Debug -DENCLAVE=PL -DSDK_PATH=/root/dev/sdk -DSSL_PATH=/root/dev/sdk/penglai_sdk_ssl -DPL_SSLLIB_PATH=/opt/penglai/openssl ..
=============cmake help info=======================
Example default cmd: cmake ..
same with default: cmake -DENCLAVE=SGX -DSDK_PATH=/opt/intel/sgxsdk -DSSL_PATH=/opt/intel/sgxssl ..
cmake [-DCMAKE_BUILD_TYPE=val] [-DENCLAVE=val] [-DCC_SIM=ON] [-DSDK_PATH=path] [-DSSL_PATH=path] ..
CMAKE_BUILD_TYPE:[optional] pass Debug if you need file line info in log, default log without file line
ENCLAVE:[optional] valid val: SGX --default, GP --trustzone, PL --Penglai
CC_SIM:[optional] only support by SGX
SDK_PATH:[optional] default SGX:/opt/intel/sgxsdk, GP:/opt/itrustee_sdk, PL:/root/dev/sdk;
pass SDK_PATH if you installed sdk in custom path
SSL_PATH:[optional] pass security ssl installed path when your application use ssl
=============cmake help info=======================
Current Platform: RISC-V, Penglai SDK PATH:/root/dev/sdk
CMake Error at examples/seal_data/enclave/CMakeLists.txt:155 (set_target_properties):
set_target_properties Can not find target to add properties to: seal_data

CMake Error at examples/seal_data/host/CMakeLists.txt:69 (target_link_libraries):
Cannot specify link libraries for target "secgear_seal_data" which is not
built by this project.

-- Configuring incomplete, errors occurred!
See also "/root/dev/secGear/debug/CMakeFiles/CMakeOutput.log".

thanks
shreekant
secgeardemoissue

The need to dynamically detect PMP numbers

Currently Penglai's SM (statically) assumes 16 PMPs.
However, there are some platforms support less (e.g., 8 PMPs) or more (e.g., in the future with ePMP we will have upto 64).

We should dynamically detect PMP numbers to satisfy the diverse platforms.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.