Signed-off-by: Andrea Bastoni <[email protected]>
---
hypervisor/arch/arm64/coloring.c | 17 ++++++-----------
hypervisor/arch/arm64/include/asm/coloring.h | 16 ++++++----------
2 files changed, 12 insertions(+), 21 deletions(-)
diff --git a/hypervisor/arch/arm64/coloring.c b/hypervisor/arch/arm64/coloring.c
index 3748c3f0..ea59e292 100644
--- a/hypervisor/arch/arm64/coloring.c
+++ b/hypervisor/arch/arm64/coloring.c
@@ -20,6 +20,7 @@
#include <jailhouse/unit.h>
#include <jailhouse/cell.h>
#include <jailhouse/mmio.h>
+#include <jailhouse/assert.h>
#include <asm/control.h>
#include <asm/coloring.h>
@@ -37,9 +38,7 @@ static inline int coloring_mem_destroy(struct cell *cell,
int err = 0;
/* Coloring was not created for subpages */
- if (JAILHOUSE_MEMORY_IS_SUBPAGE(mr)) {
- BUG();
- }
+ assert(!JAILHOUSE_MEMORY_IS_SUBPAGE(mr));
err = arch_unmap_memory_region(cell, mr);
if (err)
@@ -55,9 +54,7 @@ static inline int coloring_mem_destroy(struct cell *cell,
static inline int coloring_mem_start(struct jailhouse_memory *mr)
{
- if (!(mr->flags & JAILHOUSE_MEM_LOADABLE)) {
- BUG();
- }
+ assert(mr->flags & JAILHOUSE_MEM_LOADABLE);
/* Match the address specified during load */
mr->virt_start += coloring_root_map_offset;
@@ -67,9 +64,7 @@ static inline int coloring_mem_start(struct jailhouse_memory
*mr)
static inline int coloring_mem_load(struct jailhouse_memory *mr)
{
- if (!(mr->flags & JAILHOUSE_MEM_LOADABLE)) {
- BUG();
- }
+ assert(mr->flags & JAILHOUSE_MEM_LOADABLE);
/* Fix addr to match the driver's IPA ioremap */
mr->virt_start += coloring_root_map_offset;
@@ -102,8 +97,8 @@ static int dispatch_op(struct cell *cell, struct
jailhouse_memory *mr,
return 0;
}
- /* shouldn't get here */
- BUG();
+ /* Shouldn't get here */
+ assert(0);
/* keep compiler happy */
return 0;
diff --git a/hypervisor/arch/arm64/include/asm/coloring.h
b/hypervisor/arch/arm64/include/asm/coloring.h
index 7d0ebaa9..b01f605e 100644
--- a/hypervisor/arch/arm64/include/asm/coloring.h
+++ b/hypervisor/arch/arm64/include/asm/coloring.h
@@ -20,6 +20,7 @@
#include <jailhouse/cell-config.h>
#include <jailhouse/utils.h>
#include <jailhouse/control.h>
+#include <jailhouse/assert.h>
#include <asm/cache_layout.h>
#define col_print(fmt, ...) \
@@ -83,18 +84,13 @@ static inline void arch_color_unmap_memory_region(
struct cell *cell,
const struct jailhouse_memory *mr)
{
- int err;
+ int err __attribute__((unused));
- if (coloring_way_size == 0) {
- /* TODO: add assert() for debugging jailhouse? */
- /* must have mapped before */
- BUG();
- }
+ /* must have mapped before */
+ assert(coloring_way_size != 0);
err = color_cell_op(cell, mr, COL_OP_DESTROY, 0);
- if (err) {
- BUG();
- }
+ assert(err == 0);
}
static inline int arch_color_map_memory_region(
@@ -105,7 +101,7 @@ static inline int arch_color_map_memory_region(
return -ENODEV;
}
- // assert(!JAILHOUSE_MEMORY_IS_SUBPAGE(mr));
+ assert(!JAILHOUSE_MEMORY_IS_SUBPAGE(mr));
return color_cell_op(cell, mr, COL_OP_CREATE, 0);
}
--
2.29.2
--
You received this message because you are subscribed to the Google Groups
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jailhouse-dev/20210125120044.56794-13-andrea.bastoni%40tum.de.