GithubHelp home page GithubHelp logo

sancus-tee / sancus-support Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 8.0 175 KB

Untrusted support software and device drivers

License: GNU Lesser General Public License v2.1

CMake 10.09% C 84.79% Python 5.09% Vim Script 0.03%

sancus-support's People

Contributors

jovanbulck avatar martonbognar avatar mtvec avatar sven-c avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

sancus-support's Issues

9 sancus-step runs in succession cause a memory violation

If __ss_start() is called 9 times in a program, it causes a memory violation on the last run.

A minimal program to reproduce the issue:

#include <msp430.h>
#include <sancus/sm_support.h>
#include <sancus_support/sm_io.h>
#include <sancus_support/sancus_step.h>

DECLARE_SM(foo, 0x1234);

void SM_ENTRY(foo) dummy(void) {
    __asm__ __volatile__("nop\n\t":::);
}

void checkCounter(void)
{
    __asm__ __volatile__("nop\n\tnop\n\t":::);
}

int main()
{
    msp430_io_init();
    asm("eint\n\t");
    sancus_enable(&foo);

    for (int i = 0; i <= 11; ++i) {
        __ss_start();
        dummy();
    }

    EXIT();
}

/* ======== TIMER A ISR ======== */
SANCUS_STEP_ISR_ENTRY2(checkCounter, __ss_end)

Some observations I made:

  • The instruction that causes the violation is MOV @r1+, r7 (pop r7) called from __unprotected_stub_dummy. The value of r1 at this point is 6f5c.

  • At the end of the previous cycle, this same instruction is executed with r1 being 41F6. One cycle before, the value is again 41F6. (It seems like for every cycle but the last, this is consistent.)

  • The instruction that restores the value of r1 prior to this instruction is in __unprotected_stub_dummy. For some reason, when this instruction executes in the 9th cycle, it does not restore the value that was previously stored in it. The value loaded in the last cycle is 6F60, this value never occurs in r1 before this point (as far as I can tell). Maybe this load gets corrupted by the IRQ? Or something overflows this memory location? I'm not sure why else this value would be loaded.

  • I also tracked the value of the stack pointer in the protected module for each cycle. For each cycle, it looks like the following:

    Cycle Start End
    1 08c4 08c4
    2 08a8 08a8
    8 0800 0800
    9 07e4 07e4

I uploaded both the object dump and the waveform of the simulation here.

Include Protected Device Drivers

We should provide protected MMIO driver variants for some of the devices under src/dev (e.g., keypad). Driver logic should probably best be split up into a minimal asm MMIO SM and higher-level C functions that are to be included in the client protection domain.

Ideally, client SMs should be able to securely use protected I/O devices by including an <sm_support/sm_devname.h> header file, and providing some configuration variables at link time.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.