diff --git a/auto_zvm.sh b/auto_zvm.sh index 577bf9785ec10dc51192428b9dd797b9848a4ad4..b31fcc70d6a904dbc7c5ea51e32222a9a83227cd 100755 --- a/auto_zvm.sh +++ b/auto_zvm.sh @@ -6,6 +6,11 @@ PLAT=$2 ops_array=("build" "debugserver") plat_array=("qemu_max_smp" "fvp_cortex_a55x4_a75x2_smp" "roc_rk3568_pc_smp") +# 只有在用户没手动设时才设置path,避免覆盖外部配置 +REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)" +export ZEPHYR_BASE="${ZEPHYR_BASE:-${REPO_ROOT}}" +export CMAKE_PREFIX_PATH="${ZEPHYR_BASE}:${CMAKE_PREFIX_PATH:-}" + ops_found=false for i in "${ops_array[@]}" do @@ -77,7 +82,7 @@ elif [ "$OPS" = "${ops_array[1]}" ]; then -device loader,file=$(pwd)/zvm_config/qemu_platform/hub/linux_qemu_c3_m1024.dtb,addr=0x64600000,force-raw=on \ -device loader,file=$(pwd)/zvm_config/qemu_platform/hub/linux_qemu_c4_m1024.dtb,addr=0x64700000,force-raw=on \ -device loader,file=$(pwd)/zvm_config/qemu_platform/hub/rootfs.cpio.gz,addr=0x67000000,force-raw=on \ - -device loader,file=$(pwd)/zvm_config/qemu_platform/hub/freertos_qemu_c1_m128.bin,addr=0x66000000,force-raw=on \ + -device loader,file=$(pwd)/zvm_config/qemu_platform/hub/qemu_a53_aarch64_demo_coremark_qemu.bin,addr=0x66000000,force-raw=on \ -kernel $(pwd)/build/zephyr/zvm_host.elf ### using gdb to connect it: # gdb-multiarch -q -ex 'file ./build/zephyr/zvm_host.elf' -ex 'target remote localhost:1234' diff --git a/subsys/zvm/vdev/zshm.c b/subsys/zvm/vdev/zshm.c index e52ef2bf92f85448e771e2e35c9f26bd9ec87db4..c75d0f00358916c39867f4c9d63db14fd1223d4b 100644 --- a/subsys/zvm/vdev/zshm.c +++ b/subsys/zvm/vdev/zshm.c @@ -239,7 +239,7 @@ int zshm_alloc_vm_shm(const struct device *dev, struct z_vm *vm, struct z_virt_d zshm_message *message_slots = (zshm_message *)mapped_addr; for (int slot = 0; slot < ZSHM_MESSAGE_SLOT_COUNT; slot++) { - zshm_message *msg = &message_slots[slot]; + zshm_message *msg = &message_slots[slot]; cache_sync_before_read(msg, sizeof(zshm_message)); msg->priority = 0; atomic_set(&msg->receivers, 0); @@ -373,7 +373,7 @@ int zshm_func_notify(struct z_virt_dev *vdev, uint64_t addr, uint64_t *notify_fl return 0; } - if (*notify_flag < 0 || *notify_flag > (ZSHM_SEND_SLOT_LIMIT-1)) { + if (*notify_flag < 0 || *notify_flag > (ZSHM_SEND_SLOT_LIMIT - 1)) { ZVM_LOG_WARN("VM %d: Invalid notify_flag value: %llu\n", vdev->vm->vmid, *notify_flag); return 0; } @@ -389,7 +389,7 @@ int zshm_func_notify(struct z_virt_dev *vdev, uint64_t addr, uint64_t *notify_fl while (mask) { int vm_id = __builtin_ctzll(mask); mask &= (mask - 1); - + bool should_decrease_refcount = false; if (vm_id >= ZSHM_UNIT_MAX_NUMS) { @@ -402,7 +402,7 @@ int zshm_func_notify(struct z_virt_dev *vdev, uint64_t addr, uint64_t *notify_fl goto handle_missing_vm; } - if (!zvm_overall_info->vms[vm_id] || + if (!zvm_overall_info->vms[vm_id] || !(zvm_overall_info->vms[vm_id]->vm_status & VM_STATE_RUNNING)) { should_decrease_refcount = true; goto handle_missing_vm; @@ -414,7 +414,7 @@ int zshm_func_notify(struct z_virt_dev *vdev, uint64_t addr, uint64_t *notify_fl handle_missing_vm: if (should_decrease_refcount) { dsb(); - atomic_and(&msg->receivers, ~(1ULL << vm_id)); + atomic_and(&msg->receivers, ~(1ULL << vm_id)); dsb(); continue; @@ -428,7 +428,7 @@ int zshm_func_notify(struct z_virt_dev *vdev, uint64_t addr, uint64_t *notify_fl dsb(); ring->entries[ring->prod_tail].sender_addr = vdev->vm->vmid; - ring->entries[ring->prod_tail].msg_slot = *notify_flag; + ring->entries[ring->prod_tail].msg_slot = *notify_flag; dsb(); @@ -444,7 +444,6 @@ int zshm_func_notify(struct z_virt_dev *vdev, uint64_t addr, uint64_t *notify_fl ZVM_LOG_ERR("Failed to get VM structure for VM %d\n", vm_id); } - } return 0; @@ -570,4 +569,4 @@ static const struct virt_device_api zshm_api = { ZVM_VIRTUAL_DEVICE_DEFINE(zshm_device_init, POST_KERNEL, CONFIG_ZSHM_INIT_PRIORITY, ZSHMEM_NAME, - zshmem_data_port, zshmem_cfg, zshm_api); \ No newline at end of file + zshmem_data_port, zshmem_cfg, zshm_api); diff --git a/zvm_config/qemu_platform/hub/qemu-system-aarch64 b/zvm_config/qemu_platform/hub/qemu-system-aarch64 index 30024f6701308cb9cae87b77a83d6a120fe732c3..d9e101632ba77b3c5407782f7d0f925d03f369a2 100755 Binary files a/zvm_config/qemu_platform/hub/qemu-system-aarch64 and b/zvm_config/qemu_platform/hub/qemu-system-aarch64 differ