-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementation of fault handler #366
Conversation
…t, get rid of a branch in the fast path by make sinv cap to fault handler another type.
…the component which starts the invocation.
…hether it is a sinv started by a fault_handler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're missing one major piece of functionality: I believe we need to make sure that sinv_activate
cannot be used on the range of capability addresses used for the fault handlers. Do you agree?
void | ||
fault_div_by_zero(unsigned long sp, unsigned long ip, unsigned long fault_addr, unsigned long fault_type) | ||
{ | ||
PRINTLOG(PRINT_DEBUG, "in div by zero error fault handler, fault happens in component:%u\n\n", cos_inv_token()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@phanikishoreg Why did the PRINTLOG start getting pervasively used? What functionality does it provide? This isn't an API we ever discussed. Not necessarily a problem here, but I'm curious.
@@ -67,8 +67,8 @@ hypercall_comp_initaep_get(spdid_t spdid, int is_sched, struct cos_aep_info *aep | |||
} | |||
|
|||
/* capid_t though is unsigned long, only assuming it occupies 16bits for packing */ | |||
ret = cos_sinv(BOOT_CAPTBL_SINV_CAP, 0, HYPERCALL_COMP_INITAEP_GET, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this old code doing!!!! Is this just as broken as it looks?
#ifndef FAULT_HANDLER_H | ||
#define FAULT_HANDLER_H | ||
|
||
#include <cos_kernal_api.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this compile?
Is this tested?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, just checked. This isn't part of any DEPENDENCIES, so is essentially untested.
The complexity here is that this is in some way a "virtual" API. In some sense every component should depend on this, so we shouldn't have to list it in DEPENDENCIES. It should be the build system that adds the dependency automatically. However, that dependency doesn't do much at build time...only when the system is composed together via sinvs. So this interface is in a strange place. However, it might be nice to have, if only to document the shape of the API. That said, the code should compile....
|
||
.text | ||
|
||
cos_asm_server_stub(fault_div_by_zero) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oddly, these don't make much sense as they can never be used...
@@ -969,8 +970,7 @@ composite_syscall_handler(struct pt_regs *regs) | |||
/* fast path: invocation return (avoiding captbl accesses) */ | |||
if (cap == COS_DEFAULT_RET_CAP) { | |||
/* No need to lookup captbl */ | |||
sret_ret(thd, regs, cos_info); | |||
return 0; | |||
return sret_ret(thd, regs, cos_info); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are the semantics around this correct? This is a functional change. Is it fixing a bug? What behavior is it changing?
return thd_invstk_current(thd, ip, sp, cos_info); | ||
/* | ||
* This is the only time we might use the in_fault flag. | ||
* We can reset the captbl after we get the in_fault flag. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again, I'm not sure how useful this comment is without broader context. Perhaps add that broader context into the data-structure (struct) location so that people can understand? I don't see how it is relevant here as this is "outside" of the abstraction.
@@ -584,6 +637,57 @@ thd_introspect(struct thread *t, unsigned long op, unsigned long *retval) | |||
case THD_GET_TID: | |||
*retval = t->tid; | |||
break; | |||
case THD_GET_FAULT_REG1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make a macro to do this.
cos_info = thd_invstk_current(curr_thd, &ip, &sp, ci); | ||
fh = captbl_lkup(cos_info->captbl, cap); | ||
__userregs_sinvargset(regs, regs->sp, regs->ip, fault_addr, cap); | ||
/* This is a software fault and should be fixed in the future. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add FIXME
in the comment.
unsigned long ip, sp; | ||
u32_t fault_addr = 0, errcode, eip; | ||
|
||
fault_regs_save (regs, curr_thd); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no space
int | ||
div_by_zero_err_fault_handler(struct pt_regs *regs) | ||
{ | ||
print_regs_state(regs); | ||
die("FAULT: Divide by Zero Error\n\n"); | ||
fault_handler_sinv(regs, FAULT_CAPTBL_DIVZERO); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe a macro to generate all of these as well?
@WenyuanShao this is a REALLY strong first PR. Some minor issues to clear up, but this is almost ready! |
Summary of this Pull Request (PR)
This PR is the implementation of user_level fault handlers. When a fault happens, it will make a sinv call to the user_level fault handler to handle the fault.
Intent for your PR
Choose one (Mandatory):
Reviewers (Mandatory):
@gparmer , @hungry-foolish , @phanikishoreg
Code Quality
As part of this pull request, I've considered the following:
Style:
Code Craftsmanship:
Testing
I've tested the code using the following test programs (provide list here):
-I have run llbooter_pong.sh, llbooter_test.sh, microboot.sh, unit_schedcomp.sh and unit_schedtest.sh tests.