Skip to content

Commit

Permalink
assert fix in kernel and user level (assert()s in vm.c all fail - don't
Browse files Browse the repository at this point in the history
use this code yet.)
  • Loading branch information
phanikishoreg committed Nov 5, 2015
1 parent 952d64d commit 9f4753a
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src/components/implementation/no_interface/blk/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ C_OBJS=blk.o
ASM_OBJS=
COMPONENT=b.o
INTERFACES=
DEPENDENCIES=timed_blk sched
DEPENDENCIES=timed_blk sched printc
IF_LIB=

include ../../Makefile.subsubdir
Expand Down
7 changes: 1 addition & 6 deletions src/components/include/cos_debug.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#ifndef COS_DEBUG_H
#define COS_DEBUG_H

#include <cos_component.h>
#include <cos_config.h>
Expand All @@ -19,18 +20,12 @@
#define BUG() do { debug_print("BUG @ "); *((int *)0) = 0; } while (0);

#ifdef DEBUG
#ifndef assert
/*
* Tell the compiler that we will not return, thus it can make the
* static assertion that the condition is true past the assertion.
*/
__attribute__ ((noreturn)) static inline void __cos_noret(void) { while (1) ; }
#ifdef COS_PLATFORM == LINUX
#define assert(node) do { if (unlikely(!(node))) { debug_print("FIXME: assert error in @ "); /* *((int *)0) = 0 ; */ call_cap(0,0,0,0,0); /* FIXME: remove the return when we have fault handling. */ __cos_noret(); } } while(0)
#else
#define assert(node) do { if (unlikely(!(node))) { debug_print("FIXME: assert error in @ "); *((int *)0) = 0; __cos_noret(); } } while(0)
#endif
#endif
#ifndef BUG_ON
#define BUG_ON(c) assert(!(c))
#endif
Expand Down
26 changes: 12 additions & 14 deletions src/kernel/include/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,21 @@
#define likely(x) __builtin_expect(!!(x), 1)
#endif

#ifdef __KERNEL__
#ifndef die
__attribute__ ((noreturn)) static inline void __kern_noret(void) { while (1) ; }
#define die(fmt, ...) do { \
printk(fmt, ##__VA_ARGS__); \
(*(int *)0) = 0; \
__kern_noret(); \
} while (0)
#endif

#ifdef COS_DEBUG
#define assert(node) \
do { \
if(likely((node))) break; \
WARN_ON(unlikely(!(node))); \
BUG(); \
} while(0);
#define printd(str,args...) printk(str, ## args)
/*#else
#define printd(str,args...) printf(str, ## args)*/
#define assert(node) do { \
if(unlikely(!(node))) die("%s:%s:%d - Assertion '%s' failed\n", __FILE__, __func__, __LINE__, #node); \
} while (0)
#else
#define assert(a) (void)0
#define printd(str,args...)
#endif
#endif

#ifndef assert
#define assert(a)
#endif
1 change: 0 additions & 1 deletion src/kernel/include/shared/cos_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#include "./consts.h"
#include "./cos_config.h"
#include "../debug.h"

#ifndef COS_BASE_TYPES
#define COS_BASE_TYPES
Expand Down
1 change: 0 additions & 1 deletion src/kernel/tcap.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ static int
tcap_delete(struct tcap *s, struct tcap *tcap)
{
assert(s && tcap);
assert(tcap < &s->tcaps[TCAP_MAX] && tcap >= &s->tcaps[0]);
/* Can't delete your persistent tcap! */
if (s == tcap) return -1;
/* tcap still holds a reference to a child */
Expand Down
11 changes: 0 additions & 11 deletions src/platform/i386/assert.h

This file was deleted.

1 change: 0 additions & 1 deletion src/platform/i386/boot_comp.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include "assert.h"
#include "kernel.h"
#include "boot_comp.h"
#include "chal_cpu.h"
Expand Down
1 change: 0 additions & 1 deletion src/platform/i386/kernel.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include "assert.h"
#include "kernel.h"
#include "multiboot.h"
#include "string.h"
Expand Down
1 change: 1 addition & 0 deletions src/platform/i386/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <thd.h>

/* A not so nice way of oopsing */
#undef die
#define die(fmt, ...) do { \
printk(fmt,##__VA_ARGS__); \
khalt(); \
Expand Down
4 changes: 2 additions & 2 deletions src/platform/i386/vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ kern_retype_initial(void)
{
u8_t *k;

assert(mem_bootc_start() % RETYPE_MEM_NPAGES == 0);
assert(mem_bootc_end() % RETYPE_MEM_NPAGES == 0);
assert((int)mem_bootc_start() % RETYPE_MEM_NPAGES == 0);
assert((int)mem_bootc_end() % RETYPE_MEM_NPAGES == 0);
for (k = mem_bootc_start() ; k < mem_bootc_end() ; k += PAGE_SIZE * RETYPE_MEM_NPAGES) {
if (retypetbl_retype2user((void*)(chal_va2pa(k)))) assert(0);
}
Expand Down

1 comment on commit 9f4753a

@phanikishoreg
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Composite doesn't start with this: because vm.c asserts need to be re-looked.

Execution results:

phani@phani-thinkpad:~/transfer$ ./qemu.sh micro_boot.sh
vm.c:kern_paging_map_init:135 - Assertion 'j != KERN_INIT_PGD_IDX || (boot_comp_pgd[j] | PGTBL_GLOBAL) == (i | PGTBL_PRESENT | PGTBL_WRITABLE | PGTBL_SUPER | PGTBL_GLOBAL)' failed
Shutting down...

Please sign in to comment.