khypervisor  v1
Functions | Variables
trap.c File Reference
#include <hvmm_trace.h>
#include <armv7_p15.h>
#include "trap.h"
#include "context.h"
#include "gic.h"
#include "sched_policy.h"
#include "trap_dabort.h"
#include <log/print.h>
Include dependency graph for trap.c:

Go to the source code of this file.

Functions

hvmm_status_t _hyp_trap_dabort (struct arch_regs *regs)
hvmm_status_t _hyp_trap_irq (struct arch_regs *regs)
hvmm_status_t _hyp_trap_unhandled (struct arch_regs *regs)
static void _trap_dump_bregs (void)
hyp_hvc_result_t _hyp_hvc_service (struct arch_regs *regs)
struct arch_regstrap_saved_regs (void)

Variables

static struct arch_regs_trap_hyp_saved_regs = 0

Function Documentation

Definition at line 80 of file trap.c.

{
        unsigned int hsr = read_hsr();
        unsigned int iss = hsr & 0x1FFFFFF;
        unsigned int ec = (hsr >> 26);

        _trap_hyp_saved_regs = regs;

        printh("[hvc] _hyp_hvc_service: enter\n\r");

    if ( ec == 0x12 && ((iss & 0xFFFF) == 0xFFFF) ) {
        /* Internal request to stay in hyp mode */
        printh("[hvc] enter hyp\n\r");
        context_dump_regs( regs );
        return HYP_RESULT_STAY;
    }

    if ( ec == 0x24) {
        /* Handle data abort at the priority */
        printh("[hyp] data abort handler: hsr.iss=%x\n", iss);
        _trap_dump_bregs();

        if ( trap_hvc_dabort(iss, regs) != HVMM_STATUS_SUCCESS ) {
            printh( "[hyp] === Unhandled dabort ===\n" );
            printh( "[hyp] current guest vmid:%d\n", context_current_vmid() );
            context_dump_regs( regs );

            _trap_dump_bregs();

            hyp_abort_infinite();
        }
        _trap_dump_bregs();
    } else {
        /* Handle the other cases */
        switch( iss ) {
            case 0xFFFE:
                /* hyp_ping */
                printh("[hyp] _hyp_hvc_service:ping\n\r");
                context_dump_regs( regs );
                break;
            case 0xFFFD:
                {
                    /* hsvc_yield() */
                    printh("[hyp] _hyp_hvc_service:yield\n\r");
                    context_dump_regs( regs );
                    context_switchto(sched_policy_determ_next());
                }
                break;
            default:
                if ( ec == 0x20 ) {
                    // Prefetch Abort routed to Hyp mode
                    printh( "[hyp]: prefetch abort routed to Hyp mode\n");
                }
    
                printh("[hyp] _hyp_hvc_service:unknown hsr.iss= %x\n", iss);
                printh("[hyp] hsr.ec= %x\n", ec);
                printh("[hyp] hsr= %x\n", hsr);
                context_dump_regs( regs );
                _trap_dump_bregs();
                hyp_abort_infinite();
                break;
        }
    }
    printh("[hyp] _hyp_hvc_service: done\n\r");

    context_perform_switch();
    return HYP_RESULT_ERET;
}

Here is the call graph for this function:

Definition at line 20 of file trap.c.

Here is the call graph for this function:

Definition at line 31 of file trap.c.

Here is the call graph for this function:

Definition at line 42 of file trap.c.

Here is the call graph for this function:

static void _trap_dump_bregs ( void  ) [static]

Definition at line 52 of file trap.c.

{
    uint32_t spsr, lr, sp;
    printh( " - banked regs\n" );
    asm volatile (" mrs     %0, sp_usr\n\t" :"=r" (sp)::"memory", "cc");
    asm volatile (" mrs     %0, lr_usr\n\t" :"=r" (lr)::"memory", "cc");
    printh( " - usr: sp:%x lr:%x\n", sp, lr );

    asm volatile (" mrs     %0, spsr_svc\n\t" :"=r" (spsr)::"memory", "cc");
    asm volatile (" mrs     %0, sp_svc\n\t" :"=r" (sp)::"memory", "cc");
    asm volatile (" mrs     %0, lr_svc\n\t" :"=r" (lr)::"memory", "cc");
    printh( " - svc: spsr:%x sp:%x lr:%x\n", spsr, sp, lr );

    asm volatile (" mrs     %0, spsr_irq\n\t" :"=r" (spsr)::"memory", "cc");
    asm volatile (" mrs     %0, sp_irq\n\t" :"=r" (sp)::"memory", "cc");
    asm volatile (" mrs     %0, lr_irq\n\t" :"=r" (lr)::"memory", "cc");
    printh( " - irq: spsr:%x sp:%x lr:%x\n", spsr, sp, lr );
}
struct arch_regs* trap_saved_regs ( void  ) [read]

Definition at line 151 of file trap.c.


Variable Documentation

struct arch_regs* _trap_hyp_saved_regs = 0 [static]

Definition at line 18 of file trap.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines