[REFACTOR] Re-index secondary VM names in unit tests to start at 1
VM ID 0 is used for the primary VM. Therefore, it can be ambiguous to refer to
secondary VMs starting at 0 (e.g., SERVICE_VM0).
Change-Id: I3c6454ce0fb5687ce865e2d8a21255c6ae0c46a2
diff --git a/.vscode/launch.json b/.vscode/launch.json
index 31b0247..1e0e217 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -21,7 +21,7 @@
},
{
// Update this with whatever VMs you want to debug.
- "text": "add-symbol-file ${workspaceRoot}/out/reference/qemu_aarch64_vm_clang/obj/test/vmapi/primary_with_secondaries/services/service_vm2.elf 0x43d00000+0xc4",
+ "text": "add-symbol-file ${workspaceRoot}/out/reference/qemu_aarch64_vm_clang/obj/test/vmapi/primary_with_secondaries/services/service_vm3.elf 0x43d00000+0xc4",
}
]
},
diff --git a/test/linux/BUILD.gn b/test/linux/BUILD.gn
index 527a4c3..a94af7f 100644
--- a/test/linux/BUILD.gn
+++ b/test/linux/BUILD.gn
@@ -31,7 +31,7 @@
output_name = "test_binary"
}
-vm_kernel("socket_vm0") {
+vm_kernel("socket_vm1") {
testonly = true
deps = [
@@ -63,7 +63,7 @@
primary_initrd = ":linux_test_initrd"
secondary_vms = [ [
"socket0",
- ":socket_vm0",
+ ":socket_vm1",
] ]
}
diff --git a/test/vmapi/arch/aarch64/gicv3/BUILD.gn b/test/vmapi/arch/aarch64/gicv3/BUILD.gn
index 83cb1d4..57ceb99 100644
--- a/test/vmapi/arch/aarch64/gicv3/BUILD.gn
+++ b/test/vmapi/arch/aarch64/gicv3/BUILD.gn
@@ -46,7 +46,7 @@
primary_name = "gicv3_test"
primary_vm = ":gicv3_test_vm"
secondary_vms = [ [
- "services0",
- "services:gicv3_service_vm0",
+ "services1",
+ "services:gicv3_service_vm1",
] ]
}
diff --git a/test/vmapi/arch/aarch64/gicv3/busy_secondary.c b/test/vmapi/arch/aarch64/gicv3/busy_secondary.c
index e04905a..db57638 100644
--- a/test/vmapi/arch/aarch64/gicv3/busy_secondary.c
+++ b/test/vmapi/arch/aarch64/gicv3/busy_secondary.c
@@ -40,7 +40,7 @@
system_setup();
EXPECT_EQ(spci_rxtx_map(send_page_addr, recv_page_addr).func,
SPCI_SUCCESS_32);
- SERVICE_SELECT(SERVICE_VM0, "busy", send_buffer);
+ SERVICE_SELECT(SERVICE_VM1, "busy", send_buffer);
}
TEST(busy_secondary, virtual_timer)
@@ -63,7 +63,7 @@
arch_irq_enable();
/* Let the secondary get started and wait for our message. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
@@ -82,10 +82,10 @@
dlog("Telling secondary to loop.\n");
memcpy_s(send_buffer, SPCI_MSG_PAYLOAD_MAX, message, sizeof(message));
EXPECT_EQ(
- spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, sizeof(message), 0)
+ spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(message), 0)
.func,
SPCI_SUCCESS_32);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_INTERRUPT_32);
dlog("Waiting for interrupt\n");
@@ -121,7 +121,7 @@
arch_irq_enable();
/* Let the secondary get started and wait for our message. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
@@ -140,10 +140,10 @@
dlog("Telling secondary to loop.\n");
memcpy_s(send_buffer, SPCI_MSG_PAYLOAD_MAX, message, sizeof(message));
EXPECT_EQ(
- spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, sizeof(message), 0)
+ spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(message), 0)
.func,
SPCI_SUCCESS_32);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_INTERRUPT_32);
dlog("Waiting for interrupt\n");
diff --git a/test/vmapi/arch/aarch64/gicv3/gicv3.c b/test/vmapi/arch/aarch64/gicv3/gicv3.c
index e2cc67e..f0f22f1 100644
--- a/test/vmapi/arch/aarch64/gicv3/gicv3.c
+++ b/test/vmapi/arch/aarch64/gicv3/gicv3.c
@@ -91,9 +91,9 @@
EXPECT_EQ(spci_rxtx_map(send_page_addr, recv_page_addr).func,
SPCI_SUCCESS_32);
- SERVICE_SELECT(SERVICE_VM0, "read_systemreg_ctlr", send_buffer);
+ SERVICE_SELECT(SERVICE_VM1, "read_systemreg_ctlr", send_buffer);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_ERROR_32);
EXPECT_EQ(run_res.arg2, SPCI_ABORTED);
}
@@ -108,9 +108,9 @@
EXPECT_EQ(spci_rxtx_map(send_page_addr, recv_page_addr).func,
SPCI_SUCCESS_32);
- SERVICE_SELECT(SERVICE_VM0, "write_systemreg_ctlr", send_buffer);
+ SERVICE_SELECT(SERVICE_VM1, "write_systemreg_ctlr", send_buffer);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_ERROR_32);
EXPECT_EQ(run_res.arg2, SPCI_ABORTED);
}
@@ -125,9 +125,9 @@
EXPECT_EQ(spci_rxtx_map(send_page_addr, recv_page_addr).func,
SPCI_SUCCESS_32);
- SERVICE_SELECT(SERVICE_VM0, "write_systemreg_sre", send_buffer);
+ SERVICE_SELECT(SERVICE_VM1, "write_systemreg_sre", send_buffer);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_TRUE((run_res.func == SPCI_ERROR_32 &&
run_res.arg2 == SPCI_ABORTED) ||
run_res.func == SPCI_YIELD_32);
diff --git a/test/vmapi/arch/aarch64/gicv3/inc/gicv3.h b/test/vmapi/arch/aarch64/gicv3/inc/gicv3.h
index 7308233..5fe9a52 100644
--- a/test/vmapi/arch/aarch64/gicv3/inc/gicv3.h
+++ b/test/vmapi/arch/aarch64/gicv3/inc/gicv3.h
@@ -25,7 +25,7 @@
#define NANOS_PER_UNIT 1000000000
-#define SERVICE_VM0 (HF_VM_ID_OFFSET + 1)
+#define SERVICE_VM1 (HF_VM_ID_OFFSET + 1)
extern alignas(PAGE_SIZE) uint8_t send_page[PAGE_SIZE];
extern alignas(PAGE_SIZE) uint8_t recv_page[PAGE_SIZE];
diff --git a/test/vmapi/arch/aarch64/gicv3/manifest.dts b/test/vmapi/arch/aarch64/gicv3/manifest.dts
index 9f3ea87..ad500e3 100644
--- a/test/vmapi/arch/aarch64/gicv3/manifest.dts
+++ b/test/vmapi/arch/aarch64/gicv3/manifest.dts
@@ -26,10 +26,10 @@
};
vm2 {
- debug_name = "services0";
+ debug_name = "services1";
vcpu_count = <1>;
mem_size = <0x100000>;
- kernel_filename = "services0";
+ kernel_filename = "services1";
};
};
};
diff --git a/test/vmapi/arch/aarch64/gicv3/services/BUILD.gn b/test/vmapi/arch/aarch64/gicv3/services/BUILD.gn
index 8ba8436..79858b5 100644
--- a/test/vmapi/arch/aarch64/gicv3/services/BUILD.gn
+++ b/test/vmapi/arch/aarch64/gicv3/services/BUILD.gn
@@ -70,7 +70,7 @@
# Group services together into VMs.
-vm_kernel("gicv3_service_vm0") {
+vm_kernel("gicv3_service_vm1") {
testonly = true
deps = [
diff --git a/test/vmapi/arch/aarch64/gicv3/timer_secondary.c b/test/vmapi/arch/aarch64/gicv3/timer_secondary.c
index 9996a2d..12ff038 100644
--- a/test/vmapi/arch/aarch64/gicv3/timer_secondary.c
+++ b/test/vmapi/arch/aarch64/gicv3/timer_secondary.c
@@ -30,7 +30,7 @@
EXPECT_EQ(spci_rxtx_map(send_page_addr, recv_page_addr).func,
SPCI_SUCCESS_32);
- SERVICE_SELECT(SERVICE_VM0, "timer", send_buffer);
+ SERVICE_SELECT(SERVICE_VM1, "timer", send_buffer);
interrupt_enable(VIRTUAL_TIMER_IRQ, true);
interrupt_set_edge_triggered(VIRTUAL_TIMER_IRQ, true);
@@ -45,14 +45,14 @@
struct spci_value run_res;
/* Let the secondary get started and wait for our message. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
/* Send the message for the secondary to set a timer. */
memcpy_s(send_buffer, SPCI_MSG_PAYLOAD_MAX, message, sizeof(message));
EXPECT_EQ(
- spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, sizeof(message), 0)
+ spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(message), 0)
.func,
SPCI_SUCCESS_32);
@@ -63,7 +63,7 @@
*/
dlog("running secondary after sending timer message.\n");
last_interrupt_id = 0;
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_INTERRUPT_32);
dlog("secondary yielded after receiving timer message\n");
EXPECT_EQ(last_interrupt_id, VIRTUAL_TIMER_IRQ);
@@ -73,7 +73,7 @@
* should inject a virtual timer interrupt into the secondary, which
* should get it and respond.
*/
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
EXPECT_EQ(spci_msg_send_size(run_res), sizeof(expected_response));
EXPECT_EQ(memcmp(recv_buffer, expected_response,
@@ -103,20 +103,20 @@
struct spci_value run_res;
/* Let the secondary get started and wait for our message. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
/* Send the message for the secondary to set a timer. */
memcpy_s(send_buffer, SPCI_MSG_PAYLOAD_MAX, message, message_length);
EXPECT_EQ(
- spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, message_length, 0)
+ spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, message_length, 0)
.func,
SPCI_SUCCESS_32);
/* Let the secondary handle the message and set the timer. */
last_interrupt_id = 0;
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
/*
* There's a race for whether the secondary manages to block and switch
@@ -150,7 +150,7 @@
EXPECT_NE(run_res.arg2, SPCI_SLEEP_INDEFINITE);
dlog("%d ns remaining\n", run_res.arg2);
}
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
}
dlog("Primary done looping\n");
@@ -166,7 +166,7 @@
*/
EXPECT_EQ(last_interrupt_id, VIRTUAL_TIMER_IRQ);
dlog("Preempted by timer interrupt, running again\n");
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
}
/* Once we wake it up it should get the timer interrupt and respond. */
@@ -255,14 +255,14 @@
struct spci_value run_res;
/* Let the secondary get started and wait for our message. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
/* Send the message for the secondary to set a timer. */
memcpy_s(send_buffer, SPCI_MSG_PAYLOAD_MAX, message, message_length);
EXPECT_EQ(
- spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, message_length, 0)
+ spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, message_length, 0)
.func,
SPCI_SUCCESS_32);
@@ -271,7 +271,7 @@
*/
last_interrupt_id = 0;
for (int i = 0; i < 20; ++i) {
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, HF_SPCI_RUN_WAIT_FOR_INTERRUPT);
dlog("Primary looping until timer fires; %d ns "
"remaining\n",
diff --git a/test/vmapi/primary_with_secondaries/BUILD.gn b/test/vmapi/primary_with_secondaries/BUILD.gn
index 86092cc..801d8b6 100644
--- a/test/vmapi/primary_with_secondaries/BUILD.gn
+++ b/test/vmapi/primary_with_secondaries/BUILD.gn
@@ -65,10 +65,6 @@
primary_vm = ":primary_with_secondaries_test_vm"
secondary_vms = [
[
- "services0",
- "services:service_vm0",
- ],
- [
"services1",
"services:service_vm1",
],
@@ -76,5 +72,9 @@
"services2",
"services:service_vm2",
],
+ [
+ "services3",
+ "services:service_vm3",
+ ],
]
}
diff --git a/test/vmapi/primary_with_secondaries/abort.c b/test/vmapi/primary_with_secondaries/abort.c
index 5337d18..e8559f8 100644
--- a/test/vmapi/primary_with_secondaries/abort.c
+++ b/test/vmapi/primary_with_secondaries/abort.c
@@ -28,9 +28,9 @@
struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
- SERVICE_SELECT(SERVICE_VM0, "data_abort", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "data_abort", mb.send);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
@@ -42,9 +42,9 @@
struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
- SERVICE_SELECT(SERVICE_VM0, "straddling_data_abort", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "straddling_data_abort", mb.send);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
@@ -56,9 +56,9 @@
struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
- SERVICE_SELECT(SERVICE_VM0, "instruction_abort", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "instruction_abort", mb.send);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
@@ -70,8 +70,8 @@
struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
- SERVICE_SELECT(SERVICE_VM0, "straddling_instruction_abort", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "straddling_instruction_abort", mb.send);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
diff --git a/test/vmapi/primary_with_secondaries/boot.c b/test/vmapi/primary_with_secondaries/boot.c
index a793d28..8df25f8 100644
--- a/test/vmapi/primary_with_secondaries/boot.c
+++ b/test/vmapi/primary_with_secondaries/boot.c
@@ -30,9 +30,9 @@
struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
- SERVICE_SELECT(SERVICE_VM0, "boot_memory", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "boot_memory", mb.send);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_YIELD_32);
}
@@ -44,9 +44,9 @@
struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
- SERVICE_SELECT(SERVICE_VM0, "boot_memory_overrun", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "boot_memory_overrun", mb.send);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
@@ -58,8 +58,8 @@
struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
- SERVICE_SELECT(SERVICE_VM0, "boot_memory_underrun", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "boot_memory_underrun", mb.send);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
diff --git a/test/vmapi/primary_with_secondaries/debug_el1.c b/test/vmapi/primary_with_secondaries/debug_el1.c
index 5f826c8..217b149 100644
--- a/test/vmapi/primary_with_secondaries/debug_el1.c
+++ b/test/vmapi/primary_with_secondaries/debug_el1.c
@@ -36,9 +36,9 @@
struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
- SERVICE_SELECT(SERVICE_VM0, "debug_el1_secondary_mdccint_el1", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "debug_el1_secondary_mdccint_el1", mb.send);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
@@ -47,9 +47,9 @@
struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
- SERVICE_SELECT(SERVICE_VM0, "debug_el1_secondary_dbgbcr0_el1", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "debug_el1_secondary_dbgbcr0_el1", mb.send);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
@@ -58,9 +58,9 @@
struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
- SERVICE_SELECT(SERVICE_VM0, "debug_el1_secondary_dbgbvr0_el1", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "debug_el1_secondary_dbgbvr0_el1", mb.send);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
@@ -69,9 +69,9 @@
struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
- SERVICE_SELECT(SERVICE_VM0, "debug_el1_secondary_dbgwcr0_el1", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "debug_el1_secondary_dbgwcr0_el1", mb.send);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
@@ -80,9 +80,9 @@
struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
- SERVICE_SELECT(SERVICE_VM0, "debug_el1_secondary_dbgwvr0_el1", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "debug_el1_secondary_dbgwvr0_el1", mb.send);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
diff --git a/test/vmapi/primary_with_secondaries/floating_point.c b/test/vmapi/primary_with_secondaries/floating_point.c
index 23660ce..88656e4 100644
--- a/test/vmapi/primary_with_secondaries/floating_point.c
+++ b/test/vmapi/primary_with_secondaries/floating_point.c
@@ -39,13 +39,13 @@
struct mailbox_buffers mb = set_up_mailbox();
fill_fp_registers(first);
- SERVICE_SELECT(SERVICE_VM0, "fp_fill", mb.send);
- run_res = spci_run(SERVICE_VM0, 0);
+ SERVICE_SELECT(SERVICE_VM1, "fp_fill", mb.send);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_YIELD_32);
EXPECT_EQ(check_fp_register(first), true);
fill_fp_registers(second);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_YIELD_32);
EXPECT_EQ(check_fp_register(second), true);
}
@@ -62,12 +62,12 @@
EXPECT_EQ(read_msr(fpcr), value);
- SERVICE_SELECT(SERVICE_VM0, "fp_fpcr", mb.send);
- run_res = spci_run(SERVICE_VM0, 0);
+ SERVICE_SELECT(SERVICE_VM1, "fp_fpcr", mb.send);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_YIELD_32);
EXPECT_EQ(read_msr(fpcr), value);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_YIELD_32);
EXPECT_EQ(read_msr(fpcr), value);
}
diff --git a/test/vmapi/primary_with_secondaries/inc/primary_with_secondary.h b/test/vmapi/primary_with_secondaries/inc/primary_with_secondary.h
index 9e20650..ad8dcc8 100644
--- a/test/vmapi/primary_with_secondaries/inc/primary_with_secondary.h
+++ b/test/vmapi/primary_with_secondaries/inc/primary_with_secondary.h
@@ -16,9 +16,9 @@
#pragma once
-#define SERVICE_VM0 (HF_VM_ID_OFFSET + 1)
-#define SERVICE_VM1 (HF_VM_ID_OFFSET + 2)
-#define SERVICE_VM2 (HF_VM_ID_OFFSET + 3)
+#define SERVICE_VM1 (HF_VM_ID_OFFSET + 1)
+#define SERVICE_VM2 (HF_VM_ID_OFFSET + 2)
+#define SERVICE_VM3 (HF_VM_ID_OFFSET + 3)
#define SELF_INTERRUPT_ID 5
#define EXTERNAL_INTERRUPT_ID_A 7
diff --git a/test/vmapi/primary_with_secondaries/interrupts.c b/test/vmapi/primary_with_secondaries/interrupts.c
index f295ef9..e315b9e 100644
--- a/test/vmapi/primary_with_secondaries/interrupts.c
+++ b/test/vmapi/primary_with_secondaries/interrupts.c
@@ -35,19 +35,19 @@
struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
- SERVICE_SELECT(SERVICE_VM0, "interruptible", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "interruptible", mb.send);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
/* Set the message, echo it and wait for a response. */
memcpy_s(mb.send, SPCI_MSG_PAYLOAD_MAX, message, sizeof(message));
EXPECT_EQ(
- spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, sizeof(message), 0)
+ spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(message), 0)
.func,
SPCI_SUCCESS_32);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
EXPECT_EQ(spci_msg_send_size(run_res), sizeof(expected_response));
EXPECT_EQ(memcmp(mb.recv, expected_response, sizeof(expected_response)),
@@ -66,15 +66,15 @@
struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
- SERVICE_SELECT(SERVICE_VM0, "interruptible", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "interruptible", mb.send);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
/* Inject the interrupt and wait for a message. */
- hf_interrupt_inject(SERVICE_VM0, 0, EXTERNAL_INTERRUPT_ID_A);
- run_res = spci_run(SERVICE_VM0, 0);
+ hf_interrupt_inject(SERVICE_VM1, 0, EXTERNAL_INTERRUPT_ID_A);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
EXPECT_EQ(spci_msg_send_size(run_res), sizeof(expected_response));
EXPECT_EQ(memcmp(mb.recv, expected_response, sizeof(expected_response)),
@@ -82,8 +82,8 @@
EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
/* Inject the interrupt again, and wait for the same message. */
- hf_interrupt_inject(SERVICE_VM0, 0, EXTERNAL_INTERRUPT_ID_A);
- run_res = spci_run(SERVICE_VM0, 0);
+ hf_interrupt_inject(SERVICE_VM1, 0, EXTERNAL_INTERRUPT_ID_A);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
EXPECT_EQ(spci_msg_send_size(run_res), sizeof(expected_response));
EXPECT_EQ(memcmp(mb.recv, expected_response, sizeof(expected_response)),
@@ -102,15 +102,15 @@
struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
- SERVICE_SELECT(SERVICE_VM0, "interruptible", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "interruptible", mb.send);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
/* Inject the interrupt and wait for a message. */
- hf_interrupt_inject(SERVICE_VM0, 0, EXTERNAL_INTERRUPT_ID_A);
- run_res = spci_run(SERVICE_VM0, 0);
+ hf_interrupt_inject(SERVICE_VM1, 0, EXTERNAL_INTERRUPT_ID_A);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
EXPECT_EQ(spci_msg_send_size(run_res), sizeof(expected_response));
EXPECT_EQ(memcmp(mb.recv, expected_response, sizeof(expected_response)),
@@ -118,8 +118,8 @@
EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
/* Inject a different interrupt and wait for a different message. */
- hf_interrupt_inject(SERVICE_VM0, 0, EXTERNAL_INTERRUPT_ID_B);
- run_res = spci_run(SERVICE_VM0, 0);
+ hf_interrupt_inject(SERVICE_VM1, 0, EXTERNAL_INTERRUPT_ID_B);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
EXPECT_EQ(spci_msg_send_size(run_res), sizeof(expected_response_2));
EXPECT_EQ(memcmp(mb.recv, expected_response_2,
@@ -141,32 +141,32 @@
struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
- SERVICE_SELECT(SERVICE_VM0, "interruptible", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "interruptible", mb.send);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
/* Inject the interrupt and wait for a message. */
- hf_interrupt_inject(SERVICE_VM0, 0, EXTERNAL_INTERRUPT_ID_A);
- run_res = spci_run(SERVICE_VM0, 0);
+ hf_interrupt_inject(SERVICE_VM1, 0, EXTERNAL_INTERRUPT_ID_A);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
EXPECT_EQ(spci_msg_send_size(run_res), sizeof(expected_response));
EXPECT_EQ(memcmp(mb.recv, expected_response, sizeof(expected_response)),
0);
EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
/* Now send a message to the secondary. */
memcpy_s(mb.send, SPCI_MSG_PAYLOAD_MAX, message, sizeof(message));
EXPECT_EQ(
- spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, sizeof(message), 0)
+ spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(message), 0)
.func,
SPCI_SUCCESS_32);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
EXPECT_EQ(spci_msg_send_size(run_res), sizeof(expected_response_2));
EXPECT_EQ(memcmp(mb.recv, expected_response_2,
@@ -187,11 +187,11 @@
struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
- SERVICE_SELECT(SERVICE_VM0, "interruptible", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "interruptible", mb.send);
/* Inject the interrupt and expect not to get a message. */
- hf_interrupt_inject(SERVICE_VM0, 0, EXTERNAL_INTERRUPT_ID_C);
- run_res = spci_run(SERVICE_VM0, 0);
+ hf_interrupt_inject(SERVICE_VM1, 0, EXTERNAL_INTERRUPT_ID_C);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
@@ -201,10 +201,10 @@
*/
memcpy_s(mb.send, SPCI_MSG_PAYLOAD_MAX, message, sizeof(message));
EXPECT_EQ(
- spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, sizeof(message), 0)
+ spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(message), 0)
.func,
SPCI_SUCCESS_32);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
EXPECT_EQ(spci_msg_send_size(run_res), sizeof(expected_response));
EXPECT_EQ(memcmp(mb.recv, expected_response, sizeof(expected_response)),
@@ -223,15 +223,15 @@
struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
- SERVICE_SELECT(SERVICE_VM0, "receive_block", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "receive_block", mb.send);
/*
* Inject the interrupt and run the VM. It should disable interrupts
* globally, enable the specific interrupt, and then send us a message
* back after failing to receive a message a few times.
*/
- hf_interrupt_inject(SERVICE_VM0, 0, EXTERNAL_INTERRUPT_ID_A);
- run_res = spci_run(SERVICE_VM0, 0);
+ hf_interrupt_inject(SERVICE_VM1, 0, EXTERNAL_INTERRUPT_ID_A);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
EXPECT_EQ(spci_msg_send_size(run_res), sizeof(expected_response));
EXPECT_EQ(memcmp(mb.recv, expected_response, sizeof(expected_response)),
@@ -250,15 +250,15 @@
struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
- SERVICE_SELECT(SERVICE_VM0, "wfi", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "wfi", mb.send);
/*
* Inject the interrupt and run the VM. It should disable interrupts
* globally, enable the specific interrupt, and then send us a message
* back after running WFI a few times.
*/
- hf_interrupt_inject(SERVICE_VM0, 0, EXTERNAL_INTERRUPT_ID_A);
- run_res = spci_run(SERVICE_VM0, 0);
+ hf_interrupt_inject(SERVICE_VM1, 0, EXTERNAL_INTERRUPT_ID_A);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
EXPECT_EQ(spci_msg_send_size(run_res), sizeof(expected_response));
EXPECT_EQ(memcmp(mb.recv, expected_response, sizeof(expected_response)),
@@ -276,19 +276,19 @@
struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
- SERVICE_SELECT(SERVICE_VM0, "interruptible_echo", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "interruptible_echo", mb.send);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
memcpy_s(mb.send, SPCI_MSG_PAYLOAD_MAX, message, sizeof(message));
EXPECT_EQ(
- spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, sizeof(message), 0)
+ spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(message), 0)
.func,
SPCI_SUCCESS_32);
- hf_interrupt_inject(SERVICE_VM0, 0, EXTERNAL_INTERRUPT_ID_A);
- run_res = spci_run(SERVICE_VM0, 0);
+ hf_interrupt_inject(SERVICE_VM1, 0, EXTERNAL_INTERRUPT_ID_A);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
EXPECT_EQ(spci_msg_send_size(run_res), sizeof(message));
EXPECT_EQ(memcmp(mb.recv, message, sizeof(message)), 0);
diff --git a/test/vmapi/primary_with_secondaries/mailbox.c b/test/vmapi/primary_with_secondaries/mailbox.c
index 92e64c3..0a880f7 100644
--- a/test/vmapi/primary_with_secondaries/mailbox.c
+++ b/test/vmapi/primary_with_secondaries/mailbox.c
@@ -82,19 +82,19 @@
struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
- SERVICE_SELECT(SERVICE_VM0, "echo", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "echo", mb.send);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
/* Set the message, echo it and check it didn't change. */
memcpy_s(mb.send, SPCI_MSG_PAYLOAD_MAX, message, sizeof(message));
EXPECT_EQ(
- spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, sizeof(message), 0)
+ spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(message), 0)
.func,
SPCI_SUCCESS_32);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
EXPECT_EQ(spci_msg_send_size(run_res), sizeof(message));
EXPECT_EQ(memcmp(mb.recv, message, sizeof(message)), 0);
@@ -111,11 +111,11 @@
uint8_t i;
struct mailbox_buffers mb = set_up_mailbox();
- SERVICE_SELECT(SERVICE_VM0, "echo", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "echo", mb.send);
for (i = 0; i < 100; i++) {
/* Run secondary until it reaches the wait for messages. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
@@ -123,11 +123,11 @@
next_permutation(message, sizeof(message) - 1);
memcpy_s(mb.send, SPCI_MSG_PAYLOAD_MAX, message,
sizeof(message));
- EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0,
+ EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1,
sizeof(message), 0)
.func,
SPCI_SUCCESS_32);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
EXPECT_EQ(spci_msg_send_size(run_res), sizeof(message));
EXPECT_EQ(memcmp(mb.recv, message, sizeof(message)), 0);
@@ -145,23 +145,23 @@
struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
- SERVICE_SELECT(SERVICE_VM0, "relay", mb.send);
SERVICE_SELECT(SERVICE_VM1, "relay", mb.send);
+ SERVICE_SELECT(SERVICE_VM2, "relay", mb.send);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
- run_res = spci_run(SERVICE_VM1, 0);
+ run_res = spci_run(SERVICE_VM2, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
/*
* Build the message chain so the message is sent from here to
- * SERVICE_VM0, then to SERVICE_VM1 and finally back to here.
+ * SERVICE_VM1, then to SERVICE_VM2 and finally back to here.
*/
{
spci_vm_id_t *chain = (spci_vm_id_t *)mb.send;
- *chain++ = htole32(SERVICE_VM1);
+ *chain++ = htole32(SERVICE_VM2);
*chain++ = htole32(HF_PRIMARY_VM_ID);
memcpy_s(chain,
SPCI_MSG_PAYLOAD_MAX - (2 * sizeof(spci_vm_id_t)),
@@ -169,21 +169,21 @@
EXPECT_EQ(
spci_msg_send(
- HF_PRIMARY_VM_ID, SERVICE_VM0,
+ HF_PRIMARY_VM_ID, SERVICE_VM1,
sizeof(message) + (2 * sizeof(spci_vm_id_t)), 0)
.func,
SPCI_SUCCESS_32);
}
- /* Let SERVICE_VM0 forward the message. */
- run_res = spci_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
- EXPECT_EQ(spci_msg_send_receiver(run_res), SERVICE_VM1);
- EXPECT_EQ(spci_msg_send_size(run_res), 0);
-
/* Let SERVICE_VM1 forward the message. */
run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
+ EXPECT_EQ(spci_msg_send_receiver(run_res), SERVICE_VM2);
+ EXPECT_EQ(spci_msg_send_size(run_res), 0);
+
+ /* Let SERVICE_VM2 forward the message. */
+ run_res = spci_run(SERVICE_VM2, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
/* Ensure the message is intact. */
EXPECT_EQ(spci_msg_send_receiver(run_res), HF_PRIMARY_VM_ID);
@@ -202,14 +202,14 @@
set_up_mailbox();
- EXPECT_SPCI_ERROR(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, 0, 0),
+ EXPECT_SPCI_ERROR(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, 0, 0),
SPCI_BUSY);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
- EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, 0, 0).func,
+ EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, 0, 0).func,
SPCI_SUCCESS_32);
}
@@ -223,7 +223,7 @@
set_up_mailbox();
- EXPECT_SPCI_ERROR(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, 0,
+ EXPECT_SPCI_ERROR(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, 0,
SPCI_MSG_SEND_NOTIFY),
SPCI_BUSY);
@@ -231,15 +231,15 @@
* Run first VM for it to configure itself. It should result in
* notifications having to be issued.
*/
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_RX_RELEASE_32);
/* A single waiter is returned. */
- EXPECT_EQ(hf_mailbox_waiter_get(SERVICE_VM0), HF_PRIMARY_VM_ID);
- EXPECT_EQ(hf_mailbox_waiter_get(SERVICE_VM0), -1);
+ EXPECT_EQ(hf_mailbox_waiter_get(SERVICE_VM1), HF_PRIMARY_VM_ID);
+ EXPECT_EQ(hf_mailbox_waiter_get(SERVICE_VM1), -1);
/* Send should now succeed. */
- EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, 0, 0).func,
+ EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, 0, 0).func,
SPCI_SUCCESS_32);
}
@@ -254,25 +254,25 @@
struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
- SERVICE_SELECT(SERVICE_VM0, "echo_with_notification", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "echo_with_notification", mb.send);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
/* Send a message to echo service, and get response back. */
memcpy_s(mb.send, SPCI_MSG_PAYLOAD_MAX, message, sizeof(message));
EXPECT_EQ(
- spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, sizeof(message), 0)
+ spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(message), 0)
.func,
SPCI_SUCCESS_32);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
EXPECT_EQ(spci_msg_send_size(run_res), sizeof(message));
EXPECT_EQ(memcmp(mb.recv, message, sizeof(message)), 0);
/* Let secondary VM continue running so that it will wait again. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
@@ -282,10 +282,10 @@
/* Message should be dropped since the mailbox was not cleared. */
EXPECT_EQ(
- spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, sizeof(message), 0)
+ spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(message), 0)
.func,
SPCI_SUCCESS_32);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, HF_SPCI_RUN_WAIT_FOR_INTERRUPT);
EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
@@ -293,7 +293,7 @@
EXPECT_EQ(spci_rx_release().func, SPCI_RX_RELEASE_32);
/* Retrieve a single waiter. */
- EXPECT_EQ(hf_mailbox_waiter_get(HF_PRIMARY_VM_ID), SERVICE_VM0);
+ EXPECT_EQ(hf_mailbox_waiter_get(HF_PRIMARY_VM_ID), SERVICE_VM1);
EXPECT_EQ(hf_mailbox_waiter_get(HF_PRIMARY_VM_ID), -1);
/*
@@ -301,9 +301,9 @@
* the echoed message.
*/
EXPECT_EQ(
- hf_interrupt_inject(SERVICE_VM0, 0, HF_MAILBOX_WRITABLE_INTID),
+ hf_interrupt_inject(SERVICE_VM1, 0, HF_MAILBOX_WRITABLE_INTID),
1);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
EXPECT_EQ(spci_msg_send_size(run_res), sizeof(message));
EXPECT_EQ(memcmp(mb.recv, message, sizeof(message)), 0);
@@ -320,39 +320,39 @@
struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
- SERVICE_SELECT(SERVICE_VM0, "echo_with_notification", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "echo_with_notification", mb.send);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
/* Send a message to echo service twice. The second should fail. */
memcpy_s(mb.send, SPCI_MSG_PAYLOAD_MAX, message, sizeof(message));
EXPECT_EQ(
- spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, sizeof(message), 0)
+ spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(message), 0)
.func,
SPCI_SUCCESS_32);
- EXPECT_SPCI_ERROR(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0,
+ EXPECT_SPCI_ERROR(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1,
sizeof(message), SPCI_MSG_SEND_NOTIFY),
SPCI_BUSY);
/* Receive a reply for the first message. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
EXPECT_EQ(spci_msg_send_size(run_res), sizeof(message));
EXPECT_EQ(memcmp(mb.recv, message, sizeof(message)), 0);
/* Run VM again so that it clears its mailbox. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_RX_RELEASE_32);
/* Retrieve a single waiter. */
- EXPECT_EQ(hf_mailbox_waiter_get(SERVICE_VM0), HF_PRIMARY_VM_ID);
- EXPECT_EQ(hf_mailbox_waiter_get(SERVICE_VM0), -1);
+ EXPECT_EQ(hf_mailbox_waiter_get(SERVICE_VM1), HF_PRIMARY_VM_ID);
+ EXPECT_EQ(hf_mailbox_waiter_get(SERVICE_VM1), -1);
/* Send should now succeed. */
EXPECT_EQ(
- spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, sizeof(message), 0)
+ spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(message), 0)
.func,
SPCI_SUCCESS_32);
}
diff --git a/test/vmapi/primary_with_secondaries/manifest.dts b/test/vmapi/primary_with_secondaries/manifest.dts
index 8cc5c00..3d9a73a 100644
--- a/test/vmapi/primary_with_secondaries/manifest.dts
+++ b/test/vmapi/primary_with_secondaries/manifest.dts
@@ -26,24 +26,24 @@
};
vm2 {
- debug_name = "services0";
- vcpu_count = <1>;
- mem_size = <0x100000>;
- kernel_filename = "services0";
- };
-
- vm3 {
debug_name = "services1";
vcpu_count = <1>;
mem_size = <0x100000>;
kernel_filename = "services1";
};
- vm4 {
+ vm3 {
debug_name = "services2";
- vcpu_count = <2>;
+ vcpu_count = <1>;
mem_size = <0x100000>;
kernel_filename = "services2";
};
+
+ vm4 {
+ debug_name = "services3";
+ vcpu_count = <2>;
+ mem_size = <0x100000>;
+ kernel_filename = "services3";
+ };
};
};
diff --git a/test/vmapi/primary_with_secondaries/memory_sharing.c b/test/vmapi/primary_with_secondaries/memory_sharing.c
index 745bd8b..e8dd6c5 100644
--- a/test/vmapi/primary_with_secondaries/memory_sharing.c
+++ b/test/vmapi/primary_with_secondaries/memory_sharing.c
@@ -33,7 +33,7 @@
*/
void check_cannot_share_memory(void *ptr, size_t size)
{
- uint32_t vms[] = {SERVICE_VM0, SERVICE_VM1};
+ uint32_t vms[] = {SERVICE_VM1, SERVICE_VM2};
enum hf_share modes[] = {HF_MEMORY_GIVE, HF_MEMORY_LEND,
HF_MEMORY_SHARE};
size_t i;
@@ -68,7 +68,7 @@
enum spci_memory_shareability lend_shareability[] = {
SPCI_MEMORY_SHARE_NON_SHAREABLE, SPCI_MEMORY_RESERVED,
SPCI_MEMORY_OUTER_SHAREABLE, SPCI_MEMORY_INNER_SHAREABLE};
- uint32_t vms[] = {HF_PRIMARY_VM_ID, SERVICE_VM0, SERVICE_VM1};
+ uint32_t vms[] = {HF_PRIMARY_VM_ID, SERVICE_VM1, SERVICE_VM2};
size_t i = 0;
size_t j = 0;
@@ -136,7 +136,7 @@
enum spci_memory_shareability lend_shareability[] = {
SPCI_MEMORY_SHARE_NON_SHAREABLE, SPCI_MEMORY_RESERVED,
SPCI_MEMORY_OUTER_SHAREABLE, SPCI_MEMORY_INNER_SHAREABLE};
- uint32_t vms[] = {HF_PRIMARY_VM_ID, SERVICE_VM0, SERVICE_VM1};
+ uint32_t vms[] = {HF_PRIMARY_VM_ID, SERVICE_VM1, SERVICE_VM2};
size_t i = 0;
size_t j = 0;
@@ -194,7 +194,7 @@
struct spci_memory_region_constituent constituents[], int num_elements,
int32_t avoid_vm)
{
- uint32_t vms[] = {HF_PRIMARY_VM_ID, SERVICE_VM0, SERVICE_VM1};
+ uint32_t vms[] = {HF_PRIMARY_VM_ID, SERVICE_VM1, SERVICE_VM2};
size_t i;
for (i = 0; i < ARRAY_SIZE(vms); ++i) {
@@ -223,7 +223,7 @@
struct mailbox_buffers mb,
struct spci_memory_region_constituent constituents[], int num_elements)
{
- uint32_t vms[] = {HF_PRIMARY_VM_ID, SERVICE_VM0, SERVICE_VM1};
+ uint32_t vms[] = {HF_PRIMARY_VM_ID, SERVICE_VM1, SERVICE_VM2};
size_t i;
size_t j;
@@ -252,7 +252,7 @@
*/
TEST(memory_sharing, cannot_share_concurrent_memory_twice)
{
- ASSERT_EQ(hf_share_memory(SERVICE_VM0, (hf_ipaddr_t)&page, PAGE_SIZE,
+ ASSERT_EQ(hf_share_memory(SERVICE_VM1, (hf_ipaddr_t)&page, PAGE_SIZE,
HF_MEMORY_SHARE),
0);
check_cannot_share_memory(page, PAGE_SIZE);
@@ -263,7 +263,7 @@
*/
TEST(memory_sharing, cannot_share_given_memory_twice)
{
- ASSERT_EQ(hf_share_memory(SERVICE_VM0, (hf_ipaddr_t)&page, PAGE_SIZE,
+ ASSERT_EQ(hf_share_memory(SERVICE_VM1, (hf_ipaddr_t)&page, PAGE_SIZE,
HF_MEMORY_GIVE),
0);
check_cannot_share_memory(page, PAGE_SIZE);
@@ -274,7 +274,7 @@
*/
TEST(memory_sharing, cannot_share_lent_memory_twice)
{
- ASSERT_EQ(hf_share_memory(SERVICE_VM0, (hf_ipaddr_t)&page, PAGE_SIZE,
+ ASSERT_EQ(hf_share_memory(SERVICE_VM1, (hf_ipaddr_t)&page, PAGE_SIZE,
HF_MEMORY_LEND),
0);
check_cannot_share_memory(page, PAGE_SIZE);
@@ -290,10 +290,10 @@
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = page;
- SERVICE_SELECT(SERVICE_VM0, "memory_increment", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "memory_increment", mb.send);
memset_s(ptr, sizeof(page), 'a', PAGE_SIZE);
- ASSERT_EQ(hf_share_memory(SERVICE_VM0, (hf_ipaddr_t)&page, PAGE_SIZE,
+ ASSERT_EQ(hf_share_memory(SERVICE_VM1, (hf_ipaddr_t)&page, PAGE_SIZE,
HF_MEMORY_SHARE),
0);
@@ -303,18 +303,18 @@
* explicitly to test the mechanism.
*/
memcpy_s(mb.send, SPCI_MSG_PAYLOAD_MAX, &ptr, sizeof(ptr));
- EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, sizeof(ptr), 0)
+ EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(ptr), 0)
.func,
SPCI_SUCCESS_32);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_YIELD_32);
for (int i = 0; i < PAGE_SIZE; ++i) {
page[i] = i;
}
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
for (int i = 0; i < PAGE_SIZE; ++i) {
@@ -333,11 +333,11 @@
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = page;
- SERVICE_SELECT(SERVICE_VM0, "memory_return", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "memory_return", mb.send);
/* Dirty the memory before sharing it. */
memset_s(ptr, sizeof(page), 'b', PAGE_SIZE);
- ASSERT_EQ(hf_share_memory(SERVICE_VM0, (hf_ipaddr_t)&page, PAGE_SIZE,
+ ASSERT_EQ(hf_share_memory(SERVICE_VM1, (hf_ipaddr_t)&page, PAGE_SIZE,
HF_MEMORY_SHARE),
0);
@@ -347,19 +347,19 @@
* explicitly to test the mechanism.
*/
memcpy_s(mb.send, SPCI_MSG_PAYLOAD_MAX, &ptr, sizeof(ptr));
- EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, sizeof(ptr), 0)
+ EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(ptr), 0)
.func,
SPCI_SUCCESS_32);
/* Let the memory be returned. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
for (int i = 0; i < PAGE_SIZE; ++i) {
ASSERT_EQ(ptr[i], 0);
}
/* Observe the service faulting when accessing the memory. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
@@ -373,8 +373,8 @@
{.address = PAGE_SIZE, .page_count = 1},
};
- SERVICE_SELECT(SERVICE_VM0, "spci_memory_return", mb.send);
SERVICE_SELECT(SERVICE_VM1, "spci_memory_return", mb.send);
+ SERVICE_SELECT(SERVICE_VM2, "spci_memory_return", mb.send);
spci_check_cannot_lend_memory(mb, constituents);
spci_check_cannot_share_memory(mb, constituents);
@@ -392,7 +392,7 @@
uint8_t *ptr = page;
uint32_t msg_size;
- SERVICE_SELECT(SERVICE_VM0, "spci_memory_return", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "spci_memory_return", mb.send);
/* Initialise the memory before giving it. */
memset_s(ptr, sizeof(page), 'b', PAGE_SIZE);
@@ -403,15 +403,15 @@
};
msg_size = spci_memory_donate_init(
- mb.send, SERVICE_VM0, constituents, 1, 0, SPCI_MEMORY_RW_X,
+ mb.send, SERVICE_VM1, constituents, 1, 0, SPCI_MEMORY_RW_X,
SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, msg_size,
+ EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, msg_size,
SPCI_MSG_SEND_LEGACY_MEMORY)
.func,
SPCI_SUCCESS_32);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
/* Let the memory be returned. */
EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
@@ -422,7 +422,7 @@
}
/* Observe the service faulting when accessing the memory. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
@@ -436,7 +436,7 @@
uint8_t *ptr = page;
uint32_t msg_size;
- SERVICE_SELECT(SERVICE_VM0, "spci_memory_lend_relinquish", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "spci_memory_lend_relinquish", mb.send);
/* Initialise the memory before giving it. */
memset_s(ptr, sizeof(page), 'b', PAGE_SIZE);
@@ -446,15 +446,15 @@
};
msg_size = spci_memory_lend_init(
- mb.send, SERVICE_VM0, constituents, 1, 0, SPCI_MEMORY_RW_X,
+ mb.send, SERVICE_VM1, constituents, 1, 0, SPCI_MEMORY_RW_X,
SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, msg_size,
+ EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, msg_size,
SPCI_MSG_SEND_LEGACY_MEMORY)
.func,
SPCI_SUCCESS_32);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
/* Let the memory be returned. */
EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
@@ -465,7 +465,7 @@
}
/* Observe the service faulting when accessing the memory. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
@@ -478,11 +478,11 @@
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = page;
- SERVICE_SELECT(SERVICE_VM0, "memory_return", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "memory_return", mb.send);
/* Dirty the memory before giving it. */
memset_s(ptr, sizeof(page), 'b', PAGE_SIZE);
- ASSERT_EQ(hf_share_memory(SERVICE_VM0, (hf_ipaddr_t)&page, PAGE_SIZE,
+ ASSERT_EQ(hf_share_memory(SERVICE_VM1, (hf_ipaddr_t)&page, PAGE_SIZE,
HF_MEMORY_GIVE),
0);
@@ -492,19 +492,19 @@
* explicitly to test the mechanism.
*/
memcpy_s(mb.send, SPCI_MSG_PAYLOAD_MAX, &ptr, sizeof(ptr));
- EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, sizeof(ptr), 0)
+ EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(ptr), 0)
.func,
SPCI_SUCCESS_32);
/* Let the memory be returned. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
for (int i = 0; i < PAGE_SIZE; ++i) {
ASSERT_EQ(ptr[i], 0);
}
/* Observe the service faulting when accessing the memory. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
@@ -517,11 +517,11 @@
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = page;
- SERVICE_SELECT(SERVICE_VM0, "memory_return", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "memory_return", mb.send);
/* Dirty the memory before lending it. */
memset_s(ptr, sizeof(page), 'c', PAGE_SIZE);
- ASSERT_EQ(hf_share_memory(SERVICE_VM0, (hf_ipaddr_t)&page, PAGE_SIZE,
+ ASSERT_EQ(hf_share_memory(SERVICE_VM1, (hf_ipaddr_t)&page, PAGE_SIZE,
HF_MEMORY_LEND),
0);
@@ -531,19 +531,19 @@
* explicitly to test the mechanism.
*/
memcpy_s(mb.send, SPCI_MSG_PAYLOAD_MAX, &ptr, sizeof(ptr));
- EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, sizeof(ptr), 0)
+ EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(ptr), 0)
.func,
SPCI_SUCCESS_32);
/* Let the memory be returned. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
for (int i = 0; i < PAGE_SIZE; ++i) {
ASSERT_EQ(ptr[i], 0);
}
/* Observe the service faulting when accessing the memory. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
@@ -556,10 +556,10 @@
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = page;
- SERVICE_SELECT(SERVICE_VM0, "memory_return", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "memory_return", mb.send);
/* Share the memory initially. */
- ASSERT_EQ(hf_share_memory(SERVICE_VM0, (hf_ipaddr_t)&page, PAGE_SIZE,
+ ASSERT_EQ(hf_share_memory(SERVICE_VM1, (hf_ipaddr_t)&page, PAGE_SIZE,
HF_MEMORY_LEND),
0);
@@ -569,21 +569,21 @@
* explicitly to test the mechanism.
*/
memcpy_s(mb.send, SPCI_MSG_PAYLOAD_MAX, &ptr, sizeof(ptr));
- EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, sizeof(ptr), 0)
+ EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(ptr), 0)
.func,
SPCI_SUCCESS_32);
/* Let the memory be returned. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
/* Share the memory again after it has been returned. */
- ASSERT_EQ(hf_share_memory(SERVICE_VM0, (hf_ipaddr_t)&page, PAGE_SIZE,
+ ASSERT_EQ(hf_share_memory(SERVICE_VM1, (hf_ipaddr_t)&page, PAGE_SIZE,
HF_MEMORY_LEND),
0);
/* Observe the service doesn't fault when accessing the memory. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
}
@@ -597,10 +597,10 @@
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = page;
- SERVICE_SELECT(SERVICE_VM0, "memory_return", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "memory_return", mb.send);
/* Share the memory initially. */
- ASSERT_EQ(hf_share_memory(SERVICE_VM0, (hf_ipaddr_t)&page, PAGE_SIZE,
+ ASSERT_EQ(hf_share_memory(SERVICE_VM1, (hf_ipaddr_t)&page, PAGE_SIZE,
HF_MEMORY_LEND),
0);
@@ -610,21 +610,21 @@
* explicitly to test the mechanism.
*/
memcpy_s(mb.send, SPCI_MSG_PAYLOAD_MAX, &ptr, sizeof(ptr));
- EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, sizeof(ptr), 0)
+ EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(ptr), 0)
.func,
SPCI_SUCCESS_32);
/* Let the memory be returned. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
/* Share the memory with a differnt VM after it has been returned. */
- ASSERT_EQ(hf_share_memory(SERVICE_VM1, (hf_ipaddr_t)&page, PAGE_SIZE,
+ ASSERT_EQ(hf_share_memory(SERVICE_VM2, (hf_ipaddr_t)&page, PAGE_SIZE,
HF_MEMORY_LEND),
0);
/* Observe the service faulting when accessing the memory. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
@@ -637,10 +637,10 @@
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr;
- SERVICE_SELECT(SERVICE_VM0, "give_memory_and_fault", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "give_memory_and_fault", mb.send);
/* Have the memory be given. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
/* Check the memory was cleared. */
@@ -650,7 +650,7 @@
}
/* Observe the service fault when it tries to access it. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
@@ -663,10 +663,10 @@
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr;
- SERVICE_SELECT(SERVICE_VM0, "lend_memory_and_fault", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "lend_memory_and_fault", mb.send);
/* Have the memory be lent. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
/* Check the memory was cleared. */
@@ -676,7 +676,7 @@
}
/* Observe the service fault when it tries to access it. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
@@ -690,7 +690,7 @@
uint8_t *ptr = page;
uint32_t msg_size;
- SERVICE_SELECT(SERVICE_VM0, "spci_donate_check_upper_bound", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "spci_donate_check_upper_bound", mb.send);
/* Initialise the memory before giving it. */
memset_s(ptr, sizeof(page), 'b', 1 * PAGE_SIZE);
@@ -700,16 +700,16 @@
};
msg_size = spci_memory_donate_init(
- mb.send, SERVICE_VM0, constituents, 1, 0, SPCI_MEMORY_RW_X,
+ mb.send, SERVICE_VM1, constituents, 1, 0, SPCI_MEMORY_RW_X,
SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, msg_size,
+ EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, msg_size,
SPCI_MSG_SEND_LEGACY_MEMORY)
.func,
SPCI_SUCCESS_32);
/* Observe the service faulting when accessing the memory. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
@@ -723,7 +723,7 @@
uint8_t *ptr = page;
uint32_t msg_size;
- SERVICE_SELECT(SERVICE_VM0, "spci_donate_check_lower_bound", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "spci_donate_check_lower_bound", mb.send);
/* Initialise the memory before giving it. */
memset_s(ptr, sizeof(page), 'b', 1 * PAGE_SIZE);
@@ -733,16 +733,16 @@
};
msg_size = spci_memory_donate_init(
- mb.send, SERVICE_VM0, constituents, 1, 0, SPCI_MEMORY_RW_X,
+ mb.send, SERVICE_VM1, constituents, 1, 0, SPCI_MEMORY_RW_X,
SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, msg_size,
+ EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, msg_size,
SPCI_MSG_SEND_LEGACY_MEMORY)
.func,
SPCI_SUCCESS_32);
/* Observe the service faulting when accessing the memory. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
@@ -757,8 +757,8 @@
uint8_t *ptr = page;
uint32_t msg_size;
- SERVICE_SELECT(SERVICE_VM0, "spci_memory_return", mb.send);
SERVICE_SELECT(SERVICE_VM1, "spci_memory_return", mb.send);
+ SERVICE_SELECT(SERVICE_VM2, "spci_memory_return", mb.send);
/* Initialise the memory before giving it. */
memset_s(ptr, sizeof(page), 'b', 1 * PAGE_SIZE);
@@ -768,31 +768,31 @@
};
msg_size = spci_memory_donate_init(
- mb.send, SERVICE_VM0, constituents, 1, 0, SPCI_MEMORY_RW_X,
+ mb.send, SERVICE_VM1, constituents, 1, 0, SPCI_MEMORY_RW_X,
SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, msg_size,
+ EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, msg_size,
SPCI_MSG_SEND_LEGACY_MEMORY)
.func,
SPCI_SUCCESS_32);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
/* Let the memory be returned. */
EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
/* Share the memory with another VM. */
msg_size = spci_memory_donate_init(
- mb.send, SERVICE_VM1, constituents, 1, 0, SPCI_MEMORY_RW_X,
+ mb.send, SERVICE_VM2, constituents, 1, 0, SPCI_MEMORY_RW_X,
SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, msg_size,
+ EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM2, msg_size,
SPCI_MSG_SEND_LEGACY_MEMORY)
.func,
SPCI_SUCCESS_32);
/* Observe the original service faulting when accessing the memory. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
@@ -807,8 +807,8 @@
uint8_t *ptr = page;
uint32_t msg_size;
- SERVICE_SELECT(SERVICE_VM0, "spci_donate_secondary_and_fault", mb.send);
- SERVICE_SELECT(SERVICE_VM1, "spci_memory_receive", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "spci_donate_secondary_and_fault", mb.send);
+ SERVICE_SELECT(SERVICE_VM2, "spci_memory_receive", mb.send);
/* Initialise the memory before giving it. */
memset_s(ptr, sizeof(page), 'b', 1 * PAGE_SIZE);
@@ -817,34 +817,34 @@
{.address = (uint64_t)page, .page_count = 1},
};
- /* Set up VM1 to wait for message. */
- run_res = spci_run(SERVICE_VM1, 0);
+ /* Set up VM2 to wait for message. */
+ run_res = spci_run(SERVICE_VM2, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
/* Donate memory. */
msg_size = spci_memory_donate_init(
- mb.send, SERVICE_VM0, constituents, 1, 0, SPCI_MEMORY_RW_X,
+ mb.send, SERVICE_VM1, constituents, 1, 0, SPCI_MEMORY_RW_X,
SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, msg_size,
+ EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, msg_size,
SPCI_MSG_SEND_LEGACY_MEMORY)
.func,
SPCI_SUCCESS_32);
- /* Let the memory be sent from VM0 to VM1. */
- run_res = spci_run(SERVICE_VM0, 0);
+ /* Let the memory be sent from VM1 to VM2. */
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
- /* Receive memory in VM1. */
- run_res = spci_run(SERVICE_VM1, 0);
+ /* Receive memory in VM2. */
+ run_res = spci_run(SERVICE_VM2, 0);
EXPECT_EQ(run_res.func, SPCI_YIELD_32);
- /* Try to access memory in VM0 and fail. */
- run_res = spci_run(SERVICE_VM0, 0);
+ /* Try to access memory in VM1 and fail. */
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
- /* Ensure that memory in VM1 remains the same. */
- run_res = spci_run(SERVICE_VM1, 0);
+ /* Ensure that memory in VM2 remains the same. */
+ run_res = spci_run(SERVICE_VM2, 0);
EXPECT_EQ(run_res.func, SPCI_YIELD_32);
}
@@ -858,8 +858,8 @@
uint8_t *ptr = page;
uint32_t msg_size;
- SERVICE_SELECT(SERVICE_VM0, "spci_donate_twice", mb.send);
- SERVICE_SELECT(SERVICE_VM1, "spci_memory_receive", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "spci_donate_twice", mb.send);
+ SERVICE_SELECT(SERVICE_VM2, "spci_memory_receive", mb.send);
/* Initialise the memory before giving it. */
memset_s(ptr, sizeof(page), 'b', 1 * PAGE_SIZE);
@@ -868,18 +868,18 @@
{.address = (uint64_t)page, .page_count = 1},
};
- /* Donate memory to VM0. */
+ /* Donate memory to VM1. */
msg_size = spci_memory_donate_init(
- mb.send, SERVICE_VM0, constituents, 1, 0, SPCI_MEMORY_RW_X,
+ mb.send, SERVICE_VM1, constituents, 1, 0, SPCI_MEMORY_RW_X,
SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, msg_size,
+ EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, msg_size,
SPCI_MSG_SEND_LEGACY_MEMORY)
.func,
SPCI_SUCCESS_32);
/* Let the memory be received. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_YIELD_32);
/* Fail to share memory again with any VM. */
@@ -887,15 +887,15 @@
/* Fail to relinquish memory from any VM. */
spci_check_cannot_relinquish_memory(mb, constituents, 1);
- /* Let the memory be sent from VM0 to PRIMARY (returned). */
- run_res = spci_run(SERVICE_VM0, 0);
+ /* Let the memory be sent from VM1 to PRIMARY (returned). */
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
/* Check we have access again. */
ptr[0] = 'f';
- /* Try and fail to donate memory from VM0 to VM1. */
- run_res = spci_run(SERVICE_VM0, 0);
+ /* Try and fail to donate memory from VM1 to VM2. */
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_YIELD_32);
}
@@ -982,8 +982,8 @@
uint8_t *ptr = page;
uint32_t msg_size;
- SERVICE_SELECT(SERVICE_VM0, "spci_donate_invalid_source", mb.send);
- SERVICE_SELECT(SERVICE_VM1, "spci_memory_receive", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "spci_donate_invalid_source", mb.send);
+ SERVICE_SELECT(SERVICE_VM2, "spci_memory_receive", mb.send);
/* Initialise the memory before giving it. */
memset_s(ptr, sizeof(page), 'b', PAGE_SIZE);
@@ -996,42 +996,42 @@
mb.send, HF_PRIMARY_VM_ID, constituents, 1, 0, SPCI_MEMORY_RW_X,
SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_SPCI_ERROR(spci_msg_send(SERVICE_VM0, HF_PRIMARY_VM_ID, msg_size,
+ EXPECT_SPCI_ERROR(spci_msg_send(SERVICE_VM1, HF_PRIMARY_VM_ID, msg_size,
SPCI_MSG_SEND_LEGACY_MEMORY),
SPCI_INVALID_PARAMETERS);
msg_size = spci_memory_donate_init(
- mb.send, SERVICE_VM0, constituents, 1, 0, SPCI_MEMORY_RW_X,
+ mb.send, SERVICE_VM1, constituents, 1, 0, SPCI_MEMORY_RW_X,
SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_SPCI_ERROR(spci_msg_send(SERVICE_VM0, SERVICE_VM0, msg_size,
+ EXPECT_SPCI_ERROR(spci_msg_send(SERVICE_VM1, SERVICE_VM1, msg_size,
SPCI_MSG_SEND_LEGACY_MEMORY),
SPCI_INVALID_PARAMETERS);
msg_size = spci_memory_donate_init(
- mb.send, SERVICE_VM0, constituents, 1, 0, SPCI_MEMORY_RW_X,
+ mb.send, SERVICE_VM1, constituents, 1, 0, SPCI_MEMORY_RW_X,
SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_SPCI_ERROR(spci_msg_send(SERVICE_VM1, SERVICE_VM0, msg_size,
+ EXPECT_SPCI_ERROR(spci_msg_send(SERVICE_VM2, SERVICE_VM1, msg_size,
SPCI_MSG_SEND_LEGACY_MEMORY),
SPCI_INVALID_PARAMETERS);
- /* Successfully donate to VM0. */
+ /* Successfully donate to VM1. */
msg_size = spci_memory_donate_init(
- mb.send, SERVICE_VM0, constituents, 1, 0, SPCI_MEMORY_RW_X,
+ mb.send, SERVICE_VM1, constituents, 1, 0, SPCI_MEMORY_RW_X,
SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, msg_size,
+ EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, msg_size,
SPCI_MSG_SEND_LEGACY_MEMORY)
.func,
SPCI_SUCCESS_32);
- /* Receive and return memory from VM0. */
- run_res = spci_run(SERVICE_VM0, 0);
+ /* Receive and return memory from VM1. */
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
- /* Use VM0 to fail to donate memory from the primary to VM1. */
- run_res = spci_run(SERVICE_VM0, 0);
+ /* Use VM1 to fail to donate memory from the primary to VM2. */
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_YIELD_32);
}
@@ -1042,28 +1042,28 @@
{
struct mailbox_buffers mb = set_up_mailbox();
- SERVICE_SELECT(SERVICE_VM0, "spci_memory_return", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "spci_memory_return", mb.send);
for (int i = 1; i < PAGE_SIZE; i++) {
struct spci_memory_region_constituent constituents[] = {
{.address = (uint64_t)page + i, .page_count = 1},
};
uint32_t msg_size = spci_memory_donate_init(
- mb.send, SERVICE_VM0, constituents, 1, 0,
+ mb.send, SERVICE_VM1, constituents, 1, 0,
SPCI_MEMORY_RW_X, SPCI_MEMORY_NORMAL_MEM,
SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
EXPECT_SPCI_ERROR(
- spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, msg_size,
+ spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, msg_size,
SPCI_MSG_SEND_LEGACY_MEMORY),
SPCI_INVALID_PARAMETERS);
msg_size = spci_memory_lend_init(
- mb.send, SERVICE_VM0, constituents, 1, 0,
+ mb.send, SERVICE_VM1, constituents, 1, 0,
SPCI_MEMORY_RW_X, SPCI_MEMORY_NORMAL_MEM,
SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
EXPECT_SPCI_ERROR(
- spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, msg_size,
+ spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, msg_size,
SPCI_MSG_SEND_LEGACY_MEMORY),
SPCI_INVALID_PARAMETERS);
}
@@ -1079,7 +1079,7 @@
uint8_t *ptr = page;
uint32_t msg_size;
- SERVICE_SELECT(SERVICE_VM0, "spci_lend_invalid_source", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "spci_lend_invalid_source", mb.send);
/* Initialise the memory before giving it. */
memset_s(ptr, sizeof(page), 'b', PAGE_SIZE);
@@ -1089,29 +1089,29 @@
/* Check cannot swap VM IDs. */
msg_size = spci_memory_lend_init(
- mb.send, SERVICE_VM0, constituents, 1, 0, SPCI_MEMORY_RW_X,
+ mb.send, SERVICE_VM1, constituents, 1, 0, SPCI_MEMORY_RW_X,
SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_SPCI_ERROR(spci_msg_send(SERVICE_VM0, HF_PRIMARY_VM_ID, msg_size,
+ EXPECT_SPCI_ERROR(spci_msg_send(SERVICE_VM1, HF_PRIMARY_VM_ID, msg_size,
SPCI_MSG_SEND_LEGACY_MEMORY),
SPCI_INVALID_PARAMETERS);
- /* Lend memory to VM0. */
+ /* Lend memory to VM1. */
msg_size = spci_memory_lend_init(
- mb.send, SERVICE_VM0, constituents, 1, 0, SPCI_MEMORY_RW_X,
+ mb.send, SERVICE_VM1, constituents, 1, 0, SPCI_MEMORY_RW_X,
SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, msg_size,
+ EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, msg_size,
SPCI_MSG_SEND_LEGACY_MEMORY)
.func,
SPCI_SUCCESS_32);
- /* Receive and return memory from VM0. */
- run_res = spci_run(SERVICE_VM0, 0);
+ /* Receive and return memory from VM1. */
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
- /* Try to lend memory from primary in VM0. */
- run_res = spci_run(SERVICE_VM0, 0);
+ /* Try to lend memory from primary in VM1. */
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_YIELD_32);
}
@@ -1126,7 +1126,7 @@
uint8_t *ptr = page;
uint32_t msg_size;
- SERVICE_SELECT(SERVICE_VM0, "spci_memory_lend_relinquish_RW", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "spci_memory_lend_relinquish_RW", mb.send);
/* Initialise the memory before giving it. */
memset_s(ptr, sizeof(page), 'b', PAGE_SIZE);
@@ -1136,42 +1136,42 @@
};
msg_size = spci_memory_lend_init(
- mb.send, SERVICE_VM0, constituents, 1, 0, SPCI_MEMORY_RW_X,
+ mb.send, SERVICE_VM1, constituents, 1, 0, SPCI_MEMORY_RW_X,
SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, msg_size,
+ EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, msg_size,
SPCI_MSG_SEND_LEGACY_MEMORY)
.func,
SPCI_SUCCESS_32);
/* Let the memory be accessed. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_YIELD_32);
/* Let service write to and return memory. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
/* Re-initialise the memory before giving it. */
memset_s(ptr, sizeof(page), 'b', PAGE_SIZE);
msg_size = spci_memory_lend_init(
- mb.send, SERVICE_VM0, constituents, 1, 0, SPCI_MEMORY_RO_X,
+ mb.send, SERVICE_VM1, constituents, 1, 0, SPCI_MEMORY_RO_X,
SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, msg_size,
+ EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, msg_size,
SPCI_MSG_SEND_LEGACY_MEMORY)
.func,
SPCI_SUCCESS_32);
/* Let the memory be accessed. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_YIELD_32);
/* Observe the service faulting when writing to the memory. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
@@ -1186,7 +1186,7 @@
uint8_t *ptr = page;
uint32_t msg_size;
- SERVICE_SELECT(SERVICE_VM0, "spci_memory_lend_relinquish_RW", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "spci_memory_lend_relinquish_RW", mb.send);
/* Initialise the memory before giving it. */
memset_s(ptr, sizeof(page), 'b', PAGE_SIZE);
@@ -1196,17 +1196,17 @@
};
msg_size = spci_memory_share_init(
- mb.send, SERVICE_VM0, constituents, 1, 0, SPCI_MEMORY_RW_X,
+ mb.send, SERVICE_VM1, constituents, 1, 0, SPCI_MEMORY_RW_X,
SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, msg_size,
+ EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, msg_size,
SPCI_MSG_SEND_LEGACY_MEMORY)
.func,
SPCI_SUCCESS_32);
/* Let the memory be accessed. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_YIELD_32);
/* Ensure we still have access. */
@@ -1216,24 +1216,24 @@
}
/* Let service write to and return memory. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
/* Re-initialise the memory before giving it. */
memset_s(ptr, sizeof(page), 'b', PAGE_SIZE);
msg_size = spci_memory_share_init(
- mb.send, SERVICE_VM0, constituents, 1, 0, SPCI_MEMORY_RO_X,
+ mb.send, SERVICE_VM1, constituents, 1, 0, SPCI_MEMORY_RO_X,
SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, msg_size,
+ EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, msg_size,
SPCI_MSG_SEND_LEGACY_MEMORY)
.func,
SPCI_SUCCESS_32);
/* Let the memory be accessed. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_YIELD_32);
/* Ensure we still have access. */
@@ -1243,7 +1243,7 @@
}
/* Observe the service faulting when writing to the memory. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
@@ -1258,7 +1258,7 @@
uint8_t *ptr = page;
uint32_t msg_size;
- SERVICE_SELECT(SERVICE_VM0, "spci_memory_lend_relinquish_RW", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "spci_memory_lend_relinquish_RW", mb.send);
/* Initialise the memory before giving it. */
memset_s(ptr, sizeof(page), 'b', PAGE_SIZE);
@@ -1268,17 +1268,17 @@
};
msg_size = spci_memory_share_init(
- mb.send, SERVICE_VM0, constituents, 1, 0, SPCI_MEMORY_RW_NX,
+ mb.send, SERVICE_VM1, constituents, 1, 0, SPCI_MEMORY_RW_NX,
SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, msg_size,
+ EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, msg_size,
SPCI_MSG_SEND_LEGACY_MEMORY)
.func,
SPCI_SUCCESS_32);
/* Let the memory be accessed. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_YIELD_32);
/* Ensure we still have access. */
@@ -1287,24 +1287,24 @@
}
/* Let service write to and return memory. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
/* Re-initialise the memory before giving it. */
memset_s(ptr, sizeof(page), 'b', PAGE_SIZE);
msg_size = spci_memory_share_init(
- mb.send, SERVICE_VM0, constituents, 1, 0, SPCI_MEMORY_RO_NX,
+ mb.send, SERVICE_VM1, constituents, 1, 0, SPCI_MEMORY_RO_NX,
SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, msg_size,
+ EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, msg_size,
SPCI_MSG_SEND_LEGACY_MEMORY)
.func,
SPCI_SUCCESS_32);
/* Let the memory be accessed. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_YIELD_32);
/* Ensure we still have access. */
@@ -1314,7 +1314,7 @@
}
/* Observe the service faulting when writing to the memory. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
@@ -1328,7 +1328,7 @@
uint8_t *ptr = page;
uint32_t msg_size;
- SERVICE_SELECT(SERVICE_VM0, "spci_memory_lend_relinquish_X", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "spci_memory_lend_relinquish_X", mb.send);
/* Initialise the memory before giving it. */
memset_s(ptr, sizeof(page), 0, PAGE_SIZE);
@@ -1342,29 +1342,29 @@
};
msg_size = spci_memory_lend_init(
- mb.send, SERVICE_VM0, constituents, 1, 0, SPCI_MEMORY_RW_X,
+ mb.send, SERVICE_VM1, constituents, 1, 0, SPCI_MEMORY_RW_X,
SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, msg_size,
+ EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, msg_size,
SPCI_MSG_SEND_LEGACY_MEMORY)
.func,
SPCI_SUCCESS_32);
/* Attempt to execute from memory. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
msg_size = spci_memory_lend_init(
- mb.send, SERVICE_VM0, constituents, 1, 0, SPCI_MEMORY_RW_NX,
+ mb.send, SERVICE_VM1, constituents, 1, 0, SPCI_MEMORY_RW_NX,
SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, msg_size,
+ EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, msg_size,
SPCI_MSG_SEND_LEGACY_MEMORY)
.func,
SPCI_SUCCESS_32);
/* Try and fail to execute from the memory region. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
@@ -1378,7 +1378,7 @@
uint8_t *ptr = page;
uint32_t msg_size;
- SERVICE_SELECT(SERVICE_VM0, "spci_memory_lend_relinquish_X", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "spci_memory_lend_relinquish_X", mb.send);
/* Initialise the memory before giving it. */
memset_s(ptr, sizeof(page), 0, PAGE_SIZE);
@@ -1392,29 +1392,29 @@
};
msg_size = spci_memory_lend_init(
- mb.send, SERVICE_VM0, constituents, 1, 0, SPCI_MEMORY_RO_X,
+ mb.send, SERVICE_VM1, constituents, 1, 0, SPCI_MEMORY_RO_X,
SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, msg_size,
+ EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, msg_size,
SPCI_MSG_SEND_LEGACY_MEMORY)
.func,
SPCI_SUCCESS_32);
/* Attempt to execute from memory. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
msg_size = spci_memory_lend_init(
- mb.send, SERVICE_VM0, constituents, 1, 0, SPCI_MEMORY_RO_NX,
+ mb.send, SERVICE_VM1, constituents, 1, 0, SPCI_MEMORY_RO_NX,
SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, msg_size,
+ EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, msg_size,
SPCI_MSG_SEND_LEGACY_MEMORY)
.func,
SPCI_SUCCESS_32);
/* Try and fail to execute from the memory region. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
@@ -1428,8 +1428,8 @@
uint8_t *ptr = page;
uint32_t msg_size;
- SERVICE_SELECT(SERVICE_VM0, "spci_memory_lend_relinquish_RW", mb.send);
SERVICE_SELECT(SERVICE_VM1, "spci_memory_lend_relinquish_RW", mb.send);
+ SERVICE_SELECT(SERVICE_VM2, "spci_memory_lend_relinquish_RW", mb.send);
/* Initialise the memory before giving it. */
memset_s(ptr, sizeof(page) * 2, 'b', PAGE_SIZE * 2);
@@ -1439,17 +1439,17 @@
};
msg_size = spci_memory_lend_init(
- mb.send, SERVICE_VM0, constituents, 1, 0, SPCI_MEMORY_RO_X,
+ mb.send, SERVICE_VM1, constituents, 1, 0, SPCI_MEMORY_RO_X,
SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, msg_size,
+ EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, msg_size,
SPCI_MSG_SEND_LEGACY_MEMORY)
.func,
SPCI_SUCCESS_32);
/* Let the memory be accessed. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_YIELD_32);
/* Ensure we can't donate any sub section of memory to another VM. */
@@ -1457,22 +1457,22 @@
for (int i = 1; i < PAGE_SIZE * 2; i++) {
constituents[0].address = (uint64_t)page + PAGE_SIZE;
msg_size = spci_memory_donate_init(
- mb.send, SERVICE_VM1, constituents, 1, 0,
+ mb.send, SERVICE_VM2, constituents, 1, 0,
SPCI_MEMORY_RW_X, SPCI_MEMORY_NORMAL_MEM,
SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
EXPECT_SPCI_ERROR(
- spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, msg_size,
+ spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM2, msg_size,
SPCI_MSG_SEND_LEGACY_MEMORY),
SPCI_INVALID_PARAMETERS);
}
/* Ensure we can donate to the only borrower. */
msg_size = spci_memory_donate_init(
- mb.send, SERVICE_VM0, constituents, 1, 0, SPCI_MEMORY_RW_X,
+ mb.send, SERVICE_VM1, constituents, 1, 0, SPCI_MEMORY_RW_X,
SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, msg_size,
+ EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, msg_size,
SPCI_MSG_SEND_LEGACY_MEMORY)
.func,
SPCI_SUCCESS_32);
@@ -1488,8 +1488,8 @@
uint8_t *ptr = page;
uint32_t msg_size;
- SERVICE_SELECT(SERVICE_VM0, "spci_memory_lend_relinquish_RW", mb.send);
SERVICE_SELECT(SERVICE_VM1, "spci_memory_lend_relinquish_RW", mb.send);
+ SERVICE_SELECT(SERVICE_VM2, "spci_memory_lend_relinquish_RW", mb.send);
/* Initialise the memory before giving it. */
memset_s(ptr, sizeof(page) * 2, 'b', PAGE_SIZE * 2);
@@ -1499,17 +1499,17 @@
};
msg_size = spci_memory_share_init(
- mb.send, SERVICE_VM0, constituents, 1, 0, SPCI_MEMORY_RO_X,
+ mb.send, SERVICE_VM1, constituents, 1, 0, SPCI_MEMORY_RO_X,
SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, msg_size,
+ EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, msg_size,
SPCI_MSG_SEND_LEGACY_MEMORY)
.func,
SPCI_SUCCESS_32);
/* Let the memory be accessed. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_YIELD_32);
/* Ensure we can't donate any sub section of memory to another VM. */
@@ -1517,22 +1517,22 @@
for (int i = 1; i < PAGE_SIZE * 2; i++) {
constituents[0].address = (uint64_t)page + PAGE_SIZE;
msg_size = spci_memory_donate_init(
- mb.send, SERVICE_VM1, constituents, 1, 0,
+ mb.send, SERVICE_VM2, constituents, 1, 0,
SPCI_MEMORY_RW_X, SPCI_MEMORY_NORMAL_MEM,
SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
EXPECT_SPCI_ERROR(
- spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, msg_size,
+ spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM2, msg_size,
SPCI_MSG_SEND_LEGACY_MEMORY),
SPCI_INVALID_PARAMETERS);
}
/* Ensure we can donate to the only borrower. */
msg_size = spci_memory_donate_init(
- mb.send, SERVICE_VM0, constituents, 1, 0, SPCI_MEMORY_RW_X,
+ mb.send, SERVICE_VM1, constituents, 1, 0, SPCI_MEMORY_RW_X,
SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, msg_size,
+ EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, msg_size,
SPCI_MSG_SEND_LEGACY_MEMORY)
.func,
SPCI_SUCCESS_32);
@@ -1548,8 +1548,8 @@
uint8_t *ptr = page;
uint32_t msg_size;
- SERVICE_SELECT(SERVICE_VM0, "spci_memory_lend_twice", mb.send);
SERVICE_SELECT(SERVICE_VM1, "spci_memory_lend_twice", mb.send);
+ SERVICE_SELECT(SERVICE_VM2, "spci_memory_lend_twice", mb.send);
/* Initialise the memory before giving it. */
memset_s(ptr, sizeof(page) * 2, 'b', PAGE_SIZE * 2);
@@ -1559,25 +1559,25 @@
};
msg_size = spci_memory_lend_init(
- mb.send, SERVICE_VM0, constituents, 1, 0, SPCI_MEMORY_RO_X,
+ mb.send, SERVICE_VM1, constituents, 1, 0, SPCI_MEMORY_RO_X,
SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, msg_size,
+ EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, msg_size,
SPCI_MSG_SEND_LEGACY_MEMORY)
.func,
SPCI_SUCCESS_32);
/* Let the memory be accessed. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_YIELD_32);
/* Attempt to lend the same area of memory. */
spci_check_cannot_lend_memory(mb, constituents);
/* Attempt to share the same area of memory. */
spci_check_cannot_share_memory(mb, constituents);
- /* Fail to donate to VM apart from VM0. */
- spci_check_cannot_donate_memory(mb, constituents, 1, SERVICE_VM0);
+ /* Fail to donate to VM apart from VM1. */
+ spci_check_cannot_donate_memory(mb, constituents, 1, SERVICE_VM1);
/* Fail to relinquish from any VM. */
spci_check_cannot_relinquish_memory(mb, constituents, 1);
@@ -1586,12 +1586,12 @@
for (int i = 1; i < PAGE_SIZE * 2; i++) {
constituents[0].address = (uint64_t)page + PAGE_SIZE;
msg_size = spci_memory_lend_init(
- mb.send, SERVICE_VM0, constituents, 1, 0,
+ mb.send, SERVICE_VM1, constituents, 1, 0,
SPCI_MEMORY_RO_X, SPCI_MEMORY_NORMAL_MEM,
SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
EXPECT_SPCI_ERROR(
- spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, msg_size,
+ spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM2, msg_size,
SPCI_MSG_SEND_LEGACY_MEMORY),
SPCI_INVALID_PARAMETERS);
}
@@ -1607,8 +1607,8 @@
uint8_t *ptr = page;
uint32_t msg_size;
- SERVICE_SELECT(SERVICE_VM0, "spci_memory_lend_twice", mb.send);
SERVICE_SELECT(SERVICE_VM1, "spci_memory_lend_twice", mb.send);
+ SERVICE_SELECT(SERVICE_VM2, "spci_memory_lend_twice", mb.send);
/* Initialise the memory before giving it. */
memset_s(ptr, sizeof(page) * 2, 'b', PAGE_SIZE * 2);
@@ -1618,25 +1618,25 @@
};
msg_size = spci_memory_share_init(
- mb.send, SERVICE_VM0, constituents, 1, 0, SPCI_MEMORY_RO_X,
+ mb.send, SERVICE_VM1, constituents, 1, 0, SPCI_MEMORY_RO_X,
SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, msg_size,
+ EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, msg_size,
SPCI_MSG_SEND_LEGACY_MEMORY)
.func,
SPCI_SUCCESS_32);
/* Let the memory be accessed. */
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_YIELD_32);
/* Attempt to share the same area of memory. */
spci_check_cannot_share_memory(mb, constituents);
/* Attempt to lend the same area of memory. */
spci_check_cannot_lend_memory(mb, constituents);
- /* Fail to donate to VM apart from VM0. */
- spci_check_cannot_donate_memory(mb, constituents, 1, SERVICE_VM0);
+ /* Fail to donate to VM apart from VM1. */
+ spci_check_cannot_donate_memory(mb, constituents, 1, SERVICE_VM1);
/* Fail to relinquish from any VM. */
spci_check_cannot_relinquish_memory(mb, constituents, 1);
@@ -1645,12 +1645,12 @@
for (int i = 1; i < PAGE_SIZE * 2; i++) {
constituents[0].address = (uint64_t)page + PAGE_SIZE;
msg_size = spci_memory_share_init(
- mb.send, SERVICE_VM0, constituents, 1, 0,
+ mb.send, SERVICE_VM1, constituents, 1, 0,
SPCI_MEMORY_RO_X, SPCI_MEMORY_NORMAL_MEM,
SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
EXPECT_SPCI_ERROR(
- spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, msg_size,
+ spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM2, msg_size,
SPCI_MSG_SEND_LEGACY_MEMORY),
SPCI_INVALID_PARAMETERS);
}
diff --git a/test/vmapi/primary_with_secondaries/no_services.c b/test/vmapi/primary_with_secondaries/no_services.c
index 33b83e0..e4dea80 100644
--- a/test/vmapi/primary_with_secondaries/no_services.c
+++ b/test/vmapi/primary_with_secondaries/no_services.c
@@ -56,7 +56,7 @@
*/
TEST(hf_vcpu_get_count, secondary_has_one_vcpu)
{
- EXPECT_EQ(hf_vcpu_get_count(SERVICE_VM0), 1);
+ EXPECT_EQ(hf_vcpu_get_count(SERVICE_VM1), 1);
}
/**
@@ -103,7 +103,7 @@
*/
TEST(spci_run, cannot_run_absent_vcpu)
{
- struct spci_value res = spci_run(SERVICE_VM0, 1234);
+ struct spci_value res = spci_run(SERVICE_VM1, 1234);
EXPECT_SPCI_ERROR(res, SPCI_INVALID_PARAMETERS);
}
diff --git a/test/vmapi/primary_with_secondaries/perfmon.c b/test/vmapi/primary_with_secondaries/perfmon.c
index 8fd0aba..64bf35c 100644
--- a/test/vmapi/primary_with_secondaries/perfmon.c
+++ b/test/vmapi/primary_with_secondaries/perfmon.c
@@ -33,9 +33,9 @@
struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
- SERVICE_SELECT(SERVICE_VM0, "perfmon_secondary_pmccfiltr_el0", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "perfmon_secondary_pmccfiltr_el0", mb.send);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
@@ -44,9 +44,9 @@
struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
- SERVICE_SELECT(SERVICE_VM0, "perfmon_secondary_pmcr_el0", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "perfmon_secondary_pmcr_el0", mb.send);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
@@ -55,10 +55,10 @@
struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
- SERVICE_SELECT(SERVICE_VM0, "perfmon_secondary_pmintenset_el1",
+ SERVICE_SELECT(SERVICE_VM1, "perfmon_secondary_pmintenset_el1",
mb.send);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
diff --git a/test/vmapi/primary_with_secondaries/run_race.c b/test/vmapi/primary_with_secondaries/run_race.c
index 3a27f71..28276e9 100644
--- a/test/vmapi/primary_with_secondaries/run_race.c
+++ b/test/vmapi/primary_with_secondaries/run_race.c
@@ -40,7 +40,7 @@
for (;;) {
/* Run until it manages to schedule vCPU on this CPU. */
do {
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
} while (run_res.func == HF_SPCI_RUN_WAIT_FOR_INTERRUPT &&
run_res.arg2 == HF_SLEEP_INDEFINITE);
@@ -88,7 +88,7 @@
mb = set_up_mailbox();
- SERVICE_SELECT(SERVICE_VM0, "check_state", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "check_state", mb.send);
/* Start second vCPU. */
ASSERT_TRUE(hftest_cpu_start(hftest_get_cpu_id(1), stack, sizeof(stack),
diff --git a/test/vmapi/primary_with_secondaries/services/BUILD.gn b/test/vmapi/primary_with_secondaries/services/BUILD.gn
index a735b81..732a655 100644
--- a/test/vmapi/primary_with_secondaries/services/BUILD.gn
+++ b/test/vmapi/primary_with_secondaries/services/BUILD.gn
@@ -213,7 +213,7 @@
# Group services together into VMs.
-vm_kernel("service_vm0") {
+vm_kernel("service_vm1") {
testonly = true
deps = [
@@ -235,7 +235,7 @@
]
}
-vm_kernel("service_vm1") {
+vm_kernel("service_vm2") {
testonly = true
deps = [
@@ -245,7 +245,7 @@
]
}
-vm_kernel("service_vm2") {
+vm_kernel("service_vm3") {
testonly = true
deps = [
diff --git a/test/vmapi/primary_with_secondaries/services/boot.c b/test/vmapi/primary_with_secondaries/services/boot.c
index 4ca4390..5cd7226 100644
--- a/test/vmapi/primary_with_secondaries/services/boot.c
+++ b/test/vmapi/primary_with_secondaries/services/boot.c
@@ -22,7 +22,7 @@
#include "hftest.h"
/*
- * This must match the size specified for services0 in
+ * This must match the size specified for services1 in
* //test/vmapi/primary_with_secondaries:primary_with_secondaries_test.
*/
#define SECONDARY_MEMORY_SIZE 1048576
diff --git a/test/vmapi/primary_with_secondaries/services/interruptible_echo.c b/test/vmapi/primary_with_secondaries/services/interruptible_echo.c
index 43212aa..d7b5506 100644
--- a/test/vmapi/primary_with_secondaries/services/interruptible_echo.c
+++ b/test/vmapi/primary_with_secondaries/services/interruptible_echo.c
@@ -54,7 +54,7 @@
spci_msg_send_size(res));
spci_rx_release();
- spci_msg_send(SERVICE_VM0, HF_PRIMARY_VM_ID,
+ spci_msg_send(SERVICE_VM1, HF_PRIMARY_VM_ID,
spci_msg_send_size(res), 0);
}
}
diff --git a/test/vmapi/primary_with_secondaries/services/memory.c b/test/vmapi/primary_with_secondaries/services/memory.c
index 4d3eec5..dc076c2 100644
--- a/test/vmapi/primary_with_secondaries/services/memory.c
+++ b/test/vmapi/primary_with_secondaries/services/memory.c
@@ -292,11 +292,11 @@
/* Donate memory to next VM. */
msg_size = spci_memory_donate_init(
- send_buf, SERVICE_VM1, constituents,
+ send_buf, SERVICE_VM2, constituents,
memory_region->constituent_count, 0, SPCI_MEMORY_RW_X,
SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_EQ(spci_msg_send(spci_msg_send_receiver(ret), SERVICE_VM1,
+ EXPECT_EQ(spci_msg_send(spci_msg_send_receiver(ret), SERVICE_VM2,
msg_size, SPCI_MSG_SEND_LEGACY_MEMORY)
.func,
SPCI_SUCCESS_32);
@@ -334,19 +334,19 @@
memory_region->constituent_count, 0, SPCI_MEMORY_RW_X,
SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_EQ(spci_msg_send(SERVICE_VM0, HF_PRIMARY_VM_ID, msg_size,
+ EXPECT_EQ(spci_msg_send(SERVICE_VM1, HF_PRIMARY_VM_ID, msg_size,
SPCI_MSG_SEND_LEGACY_MEMORY)
.func,
SPCI_SUCCESS_32);
/* Attempt to donate the memory to another VM. */
msg_size = spci_memory_donate_init(
- send_buf, SERVICE_VM1, &constituent,
+ send_buf, SERVICE_VM2, &constituent,
memory_region->constituent_count, 0, SPCI_MEMORY_RW_X,
SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
EXPECT_SPCI_ERROR(
- spci_msg_send(spci_msg_send_receiver(ret), SERVICE_VM1,
+ spci_msg_send(spci_msg_send_receiver(ret), SERVICE_VM2,
msg_size, SPCI_MSG_SEND_LEGACY_MEMORY),
SPCI_INVALID_PARAMETERS);
@@ -412,13 +412,13 @@
.func,
SPCI_SUCCESS_32);
- /* Fail to donate the memory from the primary to VM1. */
+ /* Fail to donate the memory from the primary to VM2. */
msg_size = spci_memory_donate_init(
- send_buf, SERVICE_VM1, constituents,
+ send_buf, SERVICE_VM2, constituents,
memory_region->constituent_count, 0, SPCI_MEMORY_RW_X,
SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_SPCI_ERROR(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, msg_size,
+ EXPECT_SPCI_ERROR(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM2, msg_size,
SPCI_MSG_SEND_LEGACY_MEMORY),
SPCI_INVALID_PARAMETERS);
spci_yield();
@@ -550,21 +550,21 @@
/* Ensure we cannot lend from the primary to another secondary. */
msg_size = spci_memory_lend_init(
- send_buf, SERVICE_VM1, constituents,
+ send_buf, SERVICE_VM2, constituents,
memory_region->constituent_count, 0, SPCI_MEMORY_RW_X,
SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_SPCI_ERROR(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, msg_size,
+ EXPECT_SPCI_ERROR(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM2, msg_size,
SPCI_MSG_SEND_LEGACY_MEMORY),
SPCI_INVALID_PARAMETERS);
/* Ensure we cannot share from the primary to another secondary. */
msg_size = spci_memory_share_init(
- send_buf, SERVICE_VM1, constituents,
+ send_buf, SERVICE_VM2, constituents,
memory_region->constituent_count, 0, SPCI_MEMORY_RW_X,
SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_SPCI_ERROR(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, msg_size,
+ EXPECT_SPCI_ERROR(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM2, msg_size,
SPCI_MSG_SEND_LEGACY_MEMORY),
SPCI_INVALID_PARAMETERS);
@@ -747,21 +747,21 @@
/* Fail to lend or share the memory back to the primary. */
msg_size = spci_memory_lend_init(
- send_buf, SERVICE_VM1, constituents,
+ send_buf, SERVICE_VM2, constituents,
memory_region->constituent_count, 0, SPCI_MEMORY_RW_X,
SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
EXPECT_SPCI_ERROR(
- spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, msg_size,
+ spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM2, msg_size,
SPCI_MSG_SEND_LEGACY_MEMORY),
SPCI_INVALID_PARAMETERS);
msg_size = spci_memory_share_init(
- send_buf, SERVICE_VM1, constituents,
+ send_buf, SERVICE_VM2, constituents,
memory_region->constituent_count, 0, SPCI_MEMORY_RW_X,
SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
EXPECT_SPCI_ERROR(
- spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, msg_size,
+ spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM2, msg_size,
SPCI_MSG_SEND_LEGACY_MEMORY),
SPCI_INVALID_PARAMETERS);
}
diff --git a/test/vmapi/primary_with_secondaries/smp.c b/test/vmapi/primary_with_secondaries/smp.c
index 4bedb72..4c20c66 100644
--- a/test/vmapi/primary_with_secondaries/smp.c
+++ b/test/vmapi/primary_with_secondaries/smp.c
@@ -35,17 +35,17 @@
struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
- SERVICE_SELECT(SERVICE_VM2, "smp", mb.send);
+ SERVICE_SELECT(SERVICE_VM3, "smp", mb.send);
/* Let the first vCPU start the second vCPU. */
- run_res = spci_run(SERVICE_VM2, 0);
+ run_res = spci_run(SERVICE_VM3, 0);
EXPECT_EQ(run_res.func, HF_SPCI_RUN_WAKE_UP);
- EXPECT_EQ(spci_vm_id(run_res), SERVICE_VM2);
+ EXPECT_EQ(spci_vm_id(run_res), SERVICE_VM3);
EXPECT_EQ(spci_vcpu_index(run_res), 1);
/* Run the second vCPU and wait for a message. */
dlog("Run second vCPU for message\n");
- run_res = spci_run(SERVICE_VM2, 1);
+ run_res = spci_run(SERVICE_VM3, 1);
EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
EXPECT_EQ(spci_msg_send_size(run_res), sizeof(expected_response_1));
EXPECT_EQ(memcmp(mb.recv, expected_response_1,
@@ -55,7 +55,7 @@
/* Run the first vCPU and wait for a different message. */
dlog("Run first vCPU for message\n");
- run_res = spci_run(SERVICE_VM2, 0);
+ run_res = spci_run(SERVICE_VM3, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
EXPECT_EQ(spci_msg_send_size(run_res), sizeof(expected_response_0));
EXPECT_EQ(memcmp(mb.recv, expected_response_0,
@@ -65,7 +65,7 @@
/* Run the second vCPU again, and expect it to turn itself off. */
dlog("Run second vCPU for poweroff.\n");
- run_res = spci_run(SERVICE_VM2, 1);
+ run_res = spci_run(SERVICE_VM3, 1);
EXPECT_EQ(run_res.func, HF_SPCI_RUN_WAIT_FOR_INTERRUPT);
EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
}
diff --git a/test/vmapi/primary_with_secondaries/spci.c b/test/vmapi/primary_with_secondaries/spci.c
index 017b080..c7c4581 100644
--- a/test/vmapi/primary_with_secondaries/spci.c
+++ b/test/vmapi/primary_with_secondaries/spci.c
@@ -36,16 +36,16 @@
struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
- SERVICE_SELECT(SERVICE_VM0, "spci_check", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "spci_check", mb.send);
/* Set the payload, init the message header and send the message. */
memcpy_s(mb.send, SPCI_MSG_PAYLOAD_MAX, message, sizeof(message));
EXPECT_EQ(
- spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, sizeof(message), 0)
+ spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(message), 0)
.func,
SPCI_SUCCESS_32);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_YIELD_32);
}
@@ -57,12 +57,12 @@
const char message[] = "spci_msg_send";
struct mailbox_buffers mb = set_up_mailbox();
- SERVICE_SELECT(SERVICE_VM0, "spci_check", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "spci_check", mb.send);
/* Set the payload, init the message header and send the message. */
memcpy_s(mb.send, SPCI_MSG_PAYLOAD_MAX, message, sizeof(message));
EXPECT_SPCI_ERROR(
- spci_msg_send(SERVICE_VM1, SERVICE_VM0, sizeof(message), 0),
+ spci_msg_send(SERVICE_VM2, SERVICE_VM1, sizeof(message), 0),
SPCI_INVALID_PARAMETERS);
}
@@ -74,7 +74,7 @@
const char message[] = "fail to send";
struct mailbox_buffers mb = set_up_mailbox();
- SERVICE_SELECT(SERVICE_VM0, "spci_check", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "spci_check", mb.send);
/* Set the payload, init the message header and send the message. */
memcpy_s(mb.send, SPCI_MSG_PAYLOAD_MAX, message, sizeof(message));
EXPECT_SPCI_ERROR(
@@ -91,14 +91,14 @@
struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
- SERVICE_SELECT(SERVICE_VM0, "spci_length", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "spci_length", mb.send);
/* Send the message and compare if truncated. */
memcpy_s(mb.send, SPCI_MSG_PAYLOAD_MAX, message, sizeof(message));
/* Hard code incorrect length. */
- EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, 16, 0).func,
+ EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, 16, 0).func,
SPCI_SUCCESS_32);
- run_res = spci_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_YIELD_32);
}
@@ -113,7 +113,7 @@
memcpy_s(mb.send, SPCI_MSG_PAYLOAD_MAX, message, sizeof(message));
/* Send a message that is larger than the mailbox supports (4KB). */
EXPECT_SPCI_ERROR(
- spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, 4 * 1024 + 1, 0),
+ spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, 4 * 1024 + 1, 0),
SPCI_INVALID_PARAMETERS);
}
@@ -126,7 +126,7 @@
struct spci_value run_res;
/* Check is performed in secondary vm. */
- SERVICE_SELECT(SERVICE_VM0, "spci_recv_non_blocking", mb.send);
- run_res = spci_run(SERVICE_VM0, 0);
+ SERVICE_SELECT(SERVICE_VM1, "spci_recv_non_blocking", mb.send);
+ run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_YIELD_32);
}