[REFACTOR] Hafnium style fixes and other minor fixes.
Change-Id: I8f10a1d82f0de9efc43894a3a7cdd09bbbcfc6ec
diff --git a/test/inc/test/vmapi/exception_handler.h b/test/inc/test/vmapi/exception_handler.h
index 1703af6..07ef312 100644
--- a/test/inc/test/vmapi/exception_handler.h
+++ b/test/inc/test/vmapi/exception_handler.h
@@ -26,8 +26,8 @@
void exception_handler_reset(void);
-void exception_handler_send_num_exceptions(void);
+void exception_handler_send_exception_count(void);
-int exception_handler_receive_num_exceptions(
+int exception_handler_receive_exception_count(
const struct spci_value *send_res,
const struct spci_memory_region *recv_buf);
diff --git a/test/vmapi/common/exception_handler.c b/test/vmapi/common/exception_handler.c
index 87e61ec..c58a5b8 100644
--- a/test/vmapi/common/exception_handler.c
+++ b/test/vmapi/common/exception_handler.c
@@ -24,22 +24,22 @@
/**
* Tracks the number of times the exception handler has been invoked.
*/
-static int exception_handler_num_exceptions = 0;
+static int exception_handler_exception_count = 0;
/**
* Sends the number of exceptions handled to the Primary VM.
*/
-void exception_handler_send_num_exceptions(void)
+void exception_handler_send_exception_count(void)
{
void *send_buf = SERVICE_SEND_BUFFER();
- dlog("Sending num_exceptions %d to primary VM\n",
- exception_handler_num_exceptions);
+ dlog("Sending exception_count %d to primary VM\n",
+ exception_handler_exception_count);
memcpy_s(send_buf, SPCI_MSG_PAYLOAD_MAX,
- (const void *)&exception_handler_num_exceptions,
- sizeof(exception_handler_num_exceptions));
+ (const void *)&exception_handler_exception_count,
+ sizeof(exception_handler_exception_count));
EXPECT_EQ(spci_msg_send(hf_vm_get_id(), HF_PRIMARY_VM_ID,
- sizeof(exception_handler_num_exceptions), 0)
+ sizeof(exception_handler_exception_count), 0)
.func,
SPCI_SUCCESS_32);
}
@@ -47,16 +47,16 @@
/**
* Receives the number of exceptions handled.
*/
-int exception_handler_receive_num_exceptions(
+int exception_handler_receive_exception_count(
const struct spci_value *send_res,
const struct spci_memory_region *recv_buf)
{
- int num_exceptions = *((const int *)recv_buf);
+ int exception_count = *((const int *)recv_buf);
EXPECT_EQ(send_res->func, SPCI_MSG_SEND_32);
- EXPECT_EQ(spci_msg_send_size(*send_res), sizeof(num_exceptions));
+ EXPECT_EQ(spci_msg_send_size(*send_res), sizeof(exception_count));
EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
- return num_exceptions;
+ return exception_count;
}
/**
@@ -66,7 +66,7 @@
bool exception_handler_skip_instruction(void)
{
dlog("%s function is triggered!\n", __func__);
- ++exception_handler_num_exceptions;
+ ++exception_handler_exception_count;
/* Skip instruction that triggered the exception. */
uint64_t next_pc = read_msr(elr_el1);
@@ -84,9 +84,9 @@
bool exception_handler_yield(void)
{
dlog("%s function is triggered!\n", __func__);
- ++exception_handler_num_exceptions;
+ ++exception_handler_exception_count;
- exception_handler_send_num_exceptions();
+ exception_handler_send_exception_count();
/* Indicate that elr_el1 should not be restored. */
return true;
@@ -97,7 +97,7 @@
*/
int exception_handler_get_num(void)
{
- return exception_handler_num_exceptions;
+ return exception_handler_exception_count;
}
/**
@@ -105,5 +105,5 @@
*/
void exception_handler_reset(void)
{
- exception_handler_num_exceptions = 0;
+ exception_handler_exception_count = 0;
}
diff --git a/test/vmapi/primary_only/faults.c b/test/vmapi/primary_only/faults.c
index d9c1b46..34b7e15 100644
--- a/test/vmapi/primary_only/faults.c
+++ b/test/vmapi/primary_only/faults.c
@@ -59,7 +59,7 @@
sl_init(&s.lock);
s.done = false;
- /* Start secondary cpu while holding lock. */
+ /* Start secondary CPU while holding lock. */
sl_lock(&s.lock);
EXPECT_EQ(
hftest_cpu_start(hftest_get_cpu_id(1), other_stack,
diff --git a/test/vmapi/primary_only/primary_only.c b/test/vmapi/primary_only/primary_only.c
index 7b4bba1..ab26f1d 100644
--- a/test/vmapi/primary_only/primary_only.c
+++ b/test/vmapi/primary_only/primary_only.c
@@ -48,7 +48,7 @@
}
/**
- * Confirm the primary has at least one vcpu.
+ * Confirm the primary has at least one vCPU.
*/
TEST(hf_vcpu_get_count, primary_has_at_least_one)
{
@@ -56,7 +56,7 @@
}
/**
- * Confirm an error is returned when getting the vcpu count of a non-existant
+ * Confirm an error is returned when getting the vCPU count of a non-existent
* VM.
*/
TEST(hf_vcpu_get_count, no_secondary_vms)
@@ -65,7 +65,7 @@
}
/**
- * Confirm an error is returned when getting the vcpu count for a reserved ID.
+ * Confirm an error is returned when getting the vCPU count for a reserved ID.
*/
TEST(hf_vcpu_get_count, reserved_vm_id)
{
@@ -77,7 +77,7 @@
}
/**
- * Confirm an error is returned when getting the vcpu count of a VM with an ID
+ * Confirm an error is returned when getting the vCPU count of a VM with an ID
* that is likely to be far outside the resource limit.
*/
TEST(hf_vcpu_get_count, large_invalid_vm_id)
@@ -86,7 +86,7 @@
}
/**
- * Confirm it is an error when running a vcpu from the primary VM.
+ * Confirm it is an error when running a vCPU from the primary VM.
*/
TEST(spci_run, cannot_run_primary)
{
@@ -95,7 +95,7 @@
}
/**
- * Confirm it is an error when running a vcpu from a non-existant secondary VM.
+ * Confirm it is an error when running a vCPU from a non-existent secondary VM.
*/
TEST(spci_run, cannot_run_absent_secondary)
{
@@ -123,7 +123,7 @@
}
/**
- * Confirm a new cpu can be started to execute in parallel.
+ * Confirm a new CPU can be started to execute in parallel.
*/
TEST(cpus, start)
{
diff --git a/test/vmapi/primary_with_secondaries/boot.c b/test/vmapi/primary_with_secondaries/boot.c
index 7236b34..e098538 100644
--- a/test/vmapi/primary_with_secondaries/boot.c
+++ b/test/vmapi/primary_with_secondaries/boot.c
@@ -48,7 +48,7 @@
SERVICE_SELECT(SERVICE_VM1, "boot_memory_overrun", mb.send);
run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(exception_handler_receive_num_exceptions(&run_res, mb.recv),
+ EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}
@@ -63,6 +63,6 @@
SERVICE_SELECT(SERVICE_VM1, "boot_memory_underrun", mb.send);
run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(exception_handler_receive_num_exceptions(&run_res, mb.recv),
+ EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}
diff --git a/test/vmapi/primary_with_secondaries/memory_sharing.c b/test/vmapi/primary_with_secondaries/memory_sharing.c
index 08a8f25..a697e06 100644
--- a/test/vmapi/primary_with_secondaries/memory_sharing.c
+++ b/test/vmapi/primary_with_secondaries/memory_sharing.c
@@ -34,7 +34,7 @@
static void check_cannot_send_memory(
struct mailbox_buffers mb, uint32_t mode,
struct spci_memory_region_constituent constituents[],
- int num_constituents, int32_t avoid_vm)
+ int constituent_count, int32_t avoid_vm)
{
enum spci_memory_access access[] = {SPCI_MEMORY_RO_NX, SPCI_MEMORY_RO_X,
@@ -68,7 +68,7 @@
spci_memory_region_init(
mb.send, vms[i],
constituents,
- num_constituents, 0, 0,
+ constituent_count, 0, 0,
access[j],
SPCI_MEMORY_NORMAL_MEM,
cacheability[l],
@@ -84,7 +84,7 @@
spci_memory_region_init(
mb.send, vms[i],
constituents,
- num_constituents, 0, 0,
+ constituent_count, 0, 0,
access[j],
SPCI_MEMORY_DEVICE_MEM,
device[l],
@@ -106,11 +106,11 @@
static void check_cannot_lend_memory(
struct mailbox_buffers mb,
struct spci_memory_region_constituent constituents[],
- int num_constituents, int32_t avoid_vm)
+ int constituent_count, int32_t avoid_vm)
{
check_cannot_send_memory(mb, SPCI_MSG_SEND_LEGACY_MEMORY_LEND,
- constituents, num_constituents, avoid_vm);
+ constituents, constituent_count, avoid_vm);
}
/**
@@ -119,11 +119,11 @@
static void check_cannot_share_memory(
struct mailbox_buffers mb,
struct spci_memory_region_constituent constituents[],
- int num_constituents, int32_t avoid_vm)
+ int constituent_count, int32_t avoid_vm)
{
check_cannot_send_memory(mb, SPCI_MSG_SEND_LEGACY_MEMORY_SHARE,
- constituents, num_constituents, avoid_vm);
+ constituents, constituent_count, avoid_vm);
}
/**
@@ -134,7 +134,7 @@
static void check_cannot_donate_memory(
struct mailbox_buffers mb,
struct spci_memory_region_constituent constituents[],
- int num_constituents, int32_t avoid_vm)
+ int constituent_count, int32_t avoid_vm)
{
uint32_t vms[] = {HF_PRIMARY_VM_ID, SERVICE_VM1, SERVICE_VM2};
@@ -146,7 +146,7 @@
continue;
}
msg_size = spci_memory_region_init(
- mb.send, vms[i], constituents, num_constituents, 0, 0,
+ mb.send, vms[i], constituents, constituent_count, 0, 0,
SPCI_MEMORY_RW_X, SPCI_MEMORY_NORMAL_MEM,
SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
@@ -164,7 +164,7 @@
static void check_cannot_relinquish_memory(
struct mailbox_buffers mb,
struct spci_memory_region_constituent constituents[],
- int num_constituents)
+ int constituent_count)
{
uint32_t vms[] = {HF_PRIMARY_VM_ID, SERVICE_VM1, SERVICE_VM2};
@@ -173,8 +173,9 @@
for (i = 0; i < ARRAY_SIZE(vms); ++i) {
for (j = 0; j < ARRAY_SIZE(vms); ++j) {
uint32_t msg_size = spci_memory_region_init(
- mb.send, vms[i], constituents, num_constituents,
- 0, 0, SPCI_MEMORY_RW_X, SPCI_MEMORY_NORMAL_MEM,
+ mb.send, vms[i], constituents,
+ constituent_count, 0, 0, SPCI_MEMORY_RW_X,
+ SPCI_MEMORY_NORMAL_MEM,
SPCI_MEMORY_CACHE_WRITE_BACK,
SPCI_MEMORY_OUTER_SHAREABLE);
EXPECT_SPCI_ERROR(
@@ -274,7 +275,7 @@
EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(exception_handler_receive_num_exceptions(&run_res, mb.recv),
+ EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}
@@ -340,7 +341,7 @@
}
run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(exception_handler_receive_num_exceptions(&run_res, mb.recv),
+ EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}
@@ -417,7 +418,7 @@
EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(exception_handler_receive_num_exceptions(&run_res, mb.recv),
+ EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}
@@ -457,7 +458,7 @@
EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(exception_handler_receive_num_exceptions(&run_res, mb.recv),
+ EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}
@@ -547,7 +548,7 @@
SPCI_SUCCESS_32);
run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(exception_handler_receive_num_exceptions(&run_res, mb.recv),
+ EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}
@@ -580,7 +581,7 @@
EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(exception_handler_receive_num_exceptions(&run_res, mb.recv),
+ EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}
@@ -613,7 +614,7 @@
EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(exception_handler_receive_num_exceptions(&run_res, mb.recv),
+ EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}
@@ -654,7 +655,7 @@
SPCI_SUCCESS_32);
run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(exception_handler_receive_num_exceptions(&run_res, mb.recv),
+ EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
/* Use different memory regions for verifying the second constituent. */
@@ -677,7 +678,7 @@
SPCI_SUCCESS_32);
run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(exception_handler_receive_num_exceptions(&run_res, mb.recv),
+ EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}
@@ -718,7 +719,7 @@
SPCI_SUCCESS_32);
run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(exception_handler_receive_num_exceptions(&run_res, mb.recv),
+ EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
/* Use different memory regions for verifying the second constituent. */
@@ -745,7 +746,7 @@
* NOTE: This generates two exceptions, one for the page fault, and one
* for accessing a region past the lower bound.
*/
- EXPECT_EQ(exception_handler_receive_num_exceptions(&run_res, mb.recv),
+ EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
2);
}
@@ -796,7 +797,7 @@
SPCI_SUCCESS_32);
run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(exception_handler_receive_num_exceptions(&run_res, mb.recv),
+ EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}
@@ -846,7 +847,7 @@
/* Try to access memory in VM1. */
run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(exception_handler_receive_num_exceptions(&run_res, mb.recv),
+ EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
/* Ensure that memory in VM2 remains the same. */
@@ -1208,7 +1209,7 @@
EXPECT_EQ(run_res.func, SPCI_YIELD_32);
run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(exception_handler_receive_num_exceptions(&run_res, mb.recv),
+ EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}
@@ -1281,7 +1282,7 @@
}
run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(exception_handler_receive_num_exceptions(&run_res, mb.recv),
+ EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}
@@ -1353,7 +1354,7 @@
}
run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(exception_handler_receive_num_exceptions(&run_res, mb.recv),
+ EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}
@@ -1404,7 +1405,7 @@
SPCI_SUCCESS_32);
run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(exception_handler_receive_num_exceptions(&run_res, mb.recv),
+ EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}
@@ -1455,7 +1456,7 @@
SPCI_SUCCESS_32);
run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(exception_handler_receive_num_exceptions(&run_res, mb.recv),
+ EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}
@@ -1798,7 +1799,7 @@
SPCI_SUCCESS_32);
run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(exception_handler_receive_num_exceptions(&run_res, mb.recv),
+ EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
/* Use different memory regions for verifying the second constituent. */
@@ -1822,7 +1823,7 @@
SPCI_SUCCESS_32);
run_res = spci_run(SERVICE_VM2, 0);
- EXPECT_EQ(exception_handler_receive_num_exceptions(&run_res, mb.recv),
+ EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}
@@ -1864,7 +1865,7 @@
SPCI_SUCCESS_32);
run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(exception_handler_receive_num_exceptions(&run_res, mb.recv),
+ EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
/* Use different memory regions for verifying the second constituent. */
@@ -1888,6 +1889,6 @@
SPCI_SUCCESS_32);
run_res = spci_run(SERVICE_VM2, 0);
- EXPECT_EQ(exception_handler_receive_num_exceptions(&run_res, mb.recv),
+ EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}
diff --git a/test/vmapi/primary_with_secondaries/no_services.c b/test/vmapi/primary_with_secondaries/no_services.c
index 2e06c78..2757df2 100644
--- a/test/vmapi/primary_with_secondaries/no_services.c
+++ b/test/vmapi/primary_with_secondaries/no_services.c
@@ -52,7 +52,7 @@
}
/**
- * Confirm that secondary VM has 1 VCPU.
+ * Confirm that secondary VM has 1 vCPU.
*/
TEST(hf_vcpu_get_count, secondary_has_one_vcpu)
{
@@ -60,7 +60,7 @@
}
/**
- * Confirm an error is returned when getting the vcpu count for a reserved ID.
+ * Confirm an error is returned when getting the vCPU count for a reserved ID.
*/
TEST(hf_vcpu_get_count, reserved_vm_id)
{
@@ -72,7 +72,7 @@
}
/**
- * Confirm it is an error to query how many VCPUs are assigned to a nonexistent
+ * Confirm it is an error to query how many vCPUs are assigned to a nonexistent
* secondary VM.
*/
TEST(hf_vcpu_get_count, large_invalid_vm_id)
@@ -99,7 +99,7 @@
}
/**
- * Can only run a vcpu that exists.
+ * Can only run a vCPU that exists.
*/
TEST(spci_run, cannot_run_absent_vcpu)
{
@@ -124,7 +124,7 @@
hf_ipaddr_t unaligned_addr = (hf_ipaddr_t)&maybe_aligned[1];
hf_ipaddr_t aligned_addr = (hf_ipaddr_t)send_page;
- /* Check the the address is unaligned. */
+ /* Check that the address is unaligned. */
ASSERT_EQ(unaligned_addr & 1, 1);
EXPECT_SPCI_ERROR(spci_rxtx_map(aligned_addr, unaligned_addr),
diff --git a/test/vmapi/primary_with_secondaries/services/BUILD.gn b/test/vmapi/primary_with_secondaries/services/BUILD.gn
index 71235d1..d4a78c2 100644
--- a/test/vmapi/primary_with_secondaries/services/BUILD.gn
+++ b/test/vmapi/primary_with_secondaries/services/BUILD.gn
@@ -14,7 +14,7 @@
import("//build/image/image.gni")
-# Service to expose race conditions when running a vcpu.
+# Service to expose race conditions when running a vCPU.
source_set("check_state") {
testonly = true
public_configs = [ "//test/hftest:hftest_config" ]
diff --git a/test/vmapi/primary_with_secondaries/services/check_state.c b/test/vmapi/primary_with_secondaries/services/check_state.c
index 1b8db1f..da27cc6 100644
--- a/test/vmapi/primary_with_secondaries/services/check_state.c
+++ b/test/vmapi/primary_with_secondaries/services/check_state.c
@@ -33,7 +33,7 @@
}
/**
- * This service repeatedly takes the following steps: sets the per-cpu pointer
+ * This service repeatedly takes the following steps: sets the per-CPU pointer
* to some value, makes a hypervisor call, check that the value is still what it
* was set to.
*
diff --git a/test/vmapi/primary_with_secondaries/unmapped.c b/test/vmapi/primary_with_secondaries/unmapped.c
index 8b5af23..0b9c116 100644
--- a/test/vmapi/primary_with_secondaries/unmapped.c
+++ b/test/vmapi/primary_with_secondaries/unmapped.c
@@ -32,7 +32,7 @@
SERVICE_SELECT(SERVICE_VM1, "data_unmapped", mb.send);
run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(exception_handler_receive_num_exceptions(&run_res, mb.recv),
+ EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}
@@ -55,7 +55,7 @@
EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(exception_handler_receive_num_exceptions(&run_res, mb.recv),
+ EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}
@@ -70,7 +70,7 @@
SERVICE_SELECT(SERVICE_VM1, "instruction_unmapped", mb.send);
run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(exception_handler_receive_num_exceptions(&run_res, mb.recv),
+ EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}
@@ -93,6 +93,6 @@
EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(exception_handler_receive_num_exceptions(&run_res, mb.recv),
+ EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}