© 2013 Carnegie Mellon University Static Analysis of Real-Time Embedded Systems with REK Arie...

36
© 2013 Carnegie Mellon University Static Analysis of Real-Time Embedded Systems with REK Arie Gurfinkel 1 joint work with Sagar Chaki 1 , Ofer Strichman 2 , and Soonho Kong 1 1 Software Engineering Institute, CMU 2 Technion, Israel Institute of Technology

Transcript of © 2013 Carnegie Mellon University Static Analysis of Real-Time Embedded Systems with REK Arie...

Page 1: © 2013 Carnegie Mellon University Static Analysis of Real-Time Embedded Systems with REK Arie Gurfinkel 1 joint work with Sagar Chaki 1, Ofer Strichman.

© 2013 Carnegie Mellon University

Static Analysis of Real-Time Embedded Systems with REK

Arie Gurfinkel1

joint work with Sagar Chaki1,Ofer Strichman2, and Soonho Kong1

1Software Engineering Institute, CMU2Technion, Israel Institute of Technology

Page 2: © 2013 Carnegie Mellon University Static Analysis of Real-Time Embedded Systems with REK Arie Gurfinkel 1 joint work with Sagar Chaki 1, Ofer Strichman.

2START-REKGurfinkel© 2013 Carnegie Mellon University

NO WARRANTY

THIS CARNEGIE MELLON UNIVERSITY AND SOFTWARE ENGINEERING INSTITUTE MATERIAL IS FURNISHED ON AN “AS-IS" BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY KIND, EITHER EXPRESSED OR IMPLIED, AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR PURPOSE OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT MAKE ANY WARRANTY OF ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT.

Use of any trademarks in this presentation is not intended in any way to infringe on the rights of the trademark holder.

This Presentation may be reproduced in its entirety, without modification, and freely distributed in written or electronic form without requesting formal permission.  Permission is required for any other use.  Requests for permission should be directed to the Software Engineering Institute at [email protected].

This work was created in the performance of Federal Government Contract Number FA8721-05-C-0003 with Carnegie Mellon University for the operation of the Software Engineering Institute, a federally funded research and development center. The Government of the United States has a royalty-free government-purpose license to use, duplicate, or disclose the work, in whole or in part and in any manner, and to have or permit others to do so, for government purposes pursuant to the copyright license under the clause at 252.227-7013.

Page 3: © 2013 Carnegie Mellon University Static Analysis of Real-Time Embedded Systems with REK Arie Gurfinkel 1 joint work with Sagar Chaki 1, Ofer Strichman.

3START-REKGurfinkel© 2013 Carnegie Mellon University

Automated

Analysis

Software Model Checking with Predicate Abstraction

e.g., Microsoft’s SDV

Automated Software Analysis

Correct + Proof

Incorrect + Counterexample

Abstract Interpretation with Numeric Abstraction

e.g., ASTREE, Polyspace

Program

Property

Page 4: © 2013 Carnegie Mellon University Static Analysis of Real-Time Embedded Systems with REK Arie Gurfinkel 1 joint work with Sagar Chaki 1, Ofer Strichman.

4START-REKGurfinkel© 2013 Carnegie Mellon University

Page 5: © 2013 Carnegie Mellon University Static Analysis of Real-Time Embedded Systems with REK Arie Gurfinkel 1 joint work with Sagar Chaki 1, Ofer Strichman.

5START-REKGurfinkel© 2013 Carnegie Mellon University

Motivation: Real-Time Embedded Systems

Avionics Mission System* Rate Monotonic Scheduling (RMS)

*Locke, Vogel, Lucas, and Goodenough. “Generic Avionics Software Specification”. SEI/CMU Technical Report CMU/SEI-90-TR-8-ESD-TR-90-209, December, 1990

Task Period

weapon release 10ms

radar tracking 40ms

target tracking 40ms

aircraft flight data 50ms

display 50ms

steering 80ms

Page 6: © 2013 Carnegie Mellon University Static Analysis of Real-Time Embedded Systems with REK Arie Gurfinkel 1 joint work with Sagar Chaki 1, Ofer Strichman.

6START-REKGurfinkel© 2013 Carnegie Mellon University

Periodic Program

An N-task periodic program PP is a set of tasks {1, …, N}

A task is a tuple I, T, P, C, A, where• I is a task identifier•T is a task body (i.e., code)•P is a period•C is the worst-case execution time•A is the release time: the time at which task becomes first enabled

Semantics of PP is given by an asynchronous concurrent program:

ki = 0;while (Wait(i, ki)) Ti (); ki = ki + 1;

parallel execution w/ priorities

blocks task iuntil next arrival

time

Page 7: © 2013 Carnegie Mellon University Static Analysis of Real-Time Embedded Systems with REK Arie Gurfinkel 1 joint work with Sagar Chaki 1, Ofer Strichman.

7START-REKGurfinkel© 2013 Carnegie Mellon University

Task

High Priority Task

Low Priority Task

Priority

Periodic Programs

Time

Page 8: © 2013 Carnegie Mellon University Static Analysis of Real-Time Embedded Systems with REK Arie Gurfinkel 1 joint work with Sagar Chaki 1, Ofer Strichman.

8START-REKGurfinkel© 2013 Carnegie Mellon University

Task

Task body

Loop-free code (C)

Periodic Programs

High Priority Task

Low Priority TaskTime

Page 9: © 2013 Carnegie Mellon University Static Analysis of Real-Time Embedded Systems with REK Arie Gurfinkel 1 joint work with Sagar Chaki 1, Ofer Strichman.

9START-REKGurfinkel© 2013 Carnegie Mellon University

Task

Period

Periodic Programs

High Priority Task

Low Priority TaskTime

Page 10: © 2013 Carnegie Mellon University Static Analysis of Real-Time Embedded Systems with REK Arie Gurfinkel 1 joint work with Sagar Chaki 1, Ofer Strichman.

10START-REKGurfinkel© 2013 Carnegie Mellon University

Task

WCET

Periodic Programs

High Priority Task

Low Priority TaskTime

Page 11: © 2013 Carnegie Mellon University Static Analysis of Real-Time Embedded Systems with REK Arie Gurfinkel 1 joint work with Sagar Chaki 1, Ofer Strichman.

11START-REKGurfinkel© 2013 Carnegie Mellon University

Task

Arrival Time

Periodic Programs

High Priority Task

Low Priority TaskTime

Page 12: © 2013 Carnegie Mellon University Static Analysis of Real-Time Embedded Systems with REK Arie Gurfinkel 1 joint work with Sagar Chaki 1, Ofer Strichman.

12START-REKGurfinkel© 2013 Carnegie Mellon University

Preemptive Fixed Priority Scheduling

High Priority Task

Low Priority TaskTime

Page 13: © 2013 Carnegie Mellon University Static Analysis of Real-Time Embedded Systems with REK Arie Gurfinkel 1 joint work with Sagar Chaki 1, Ofer Strichman.

13START-REKGurfinkel© 2013 Carnegie Mellon University

Preemptive Fixed Priority Scheduling

High Priority Task

Low Priority TaskTime

Page 14: © 2013 Carnegie Mellon University Static Analysis of Real-Time Embedded Systems with REK Arie Gurfinkel 1 joint work with Sagar Chaki 1, Ofer Strichman.

14START-REKGurfinkel© 2013 Carnegie Mellon University

High & low priority jobs arrived togetherHigh & low priority

jobs arrived together

Preemptive Fixed Priority Scheduling

High Priority Task

Low Priority TaskTime

Page 15: © 2013 Carnegie Mellon University Static Analysis of Real-Time Embedded Systems with REK Arie Gurfinkel 1 joint work with Sagar Chaki 1, Ofer Strichman.

15START-REKGurfinkel© 2013 Carnegie Mellon University

High priority job is executed first

Preemptive Fixed Priority Scheduling

High Priority Task

Low Priority TaskTime

Page 16: © 2013 Carnegie Mellon University Static Analysis of Real-Time Embedded Systems with REK Arie Gurfinkel 1 joint work with Sagar Chaki 1, Ofer Strichman.

16START-REKGurfinkel© 2013 Carnegie Mellon University

Low priority job is executed later

Preemptive Fixed Priority Scheduling

High Priority Task

Low Priority TaskTime

Page 17: © 2013 Carnegie Mellon University Static Analysis of Real-Time Embedded Systems with REK Arie Gurfinkel 1 joint work with Sagar Chaki 1, Ofer Strichman.

17START-REKGurfinkel© 2013 Carnegie Mellon University

High priority job arrived

Preemptive Fixed Priority Scheduling

High Priority Task

Low Priority TaskTime

Page 18: © 2013 Carnegie Mellon University Static Analysis of Real-Time Embedded Systems with REK Arie Gurfinkel 1 joint work with Sagar Chaki 1, Ofer Strichman.

18START-REKGurfinkel© 2013 Carnegie Mellon University

Preempts low priority job

Preemptive Fixed Priority Scheduling

High Priority Task

Low Priority TaskTime

Page 19: © 2013 Carnegie Mellon University Static Analysis of Real-Time Embedded Systems with REK Arie Gurfinkel 1 joint work with Sagar Chaki 1, Ofer Strichman.

19START-REKGurfinkel© 2013 Carnegie Mellon University

Lower priority job resumes later

Preemptive Fixed Priority Scheduling

High Priority Task

Low Priority TaskTime

Page 20: © 2013 Carnegie Mellon University Static Analysis of Real-Time Embedded Systems with REK Arie Gurfinkel 1 joint work with Sagar Chaki 1, Ofer Strichman.

20START-REKGurfinkel© 2013 Carnegie Mellon University

Preemptive Fixed Priority Scheduling

High Priority Task

Low Priority TaskTime

Page 21: © 2013 Carnegie Mellon University Static Analysis of Real-Time Embedded Systems with REK Arie Gurfinkel 1 joint work with Sagar Chaki 1, Ofer Strichman.

21START-REKGurfinkel© 2013 Carnegie Mellon University

Preemptive Fixed Priority Scheduling

High Priority Task

Low Priority TaskTime

Page 22: © 2013 Carnegie Mellon University Static Analysis of Real-Time Embedded Systems with REK Arie Gurfinkel 1 joint work with Sagar Chaki 1, Ofer Strichman.

22START-REKGurfinkel© 2013 Carnegie Mellon University

1 Hyper-Period

Preemptive Fixed Priority Scheduling

High Priority Task

Low Priority TaskTime

Page 23: © 2013 Carnegie Mellon University Static Analysis of Real-Time Embedded Systems with REK Arie Gurfinkel 1 joint work with Sagar Chaki 1, Ofer Strichman.

23START-REKGurfinkel© 2013 Carnegie Mellon University

Case Study: A Metal Stamping Robot

a.k.a. LEGO Turing MachineImage courtesy of Taras Kowaliw

Page 24: © 2013 Carnegie Mellon University Static Analysis of Real-Time Embedded Systems with REK Arie Gurfinkel 1 joint work with Sagar Chaki 1, Ofer Strichman.

24START-REKGurfinkel© 2013 Carnegie Mellon University

LEGO Turing Machine

by Soonho Kong. See http://www.cs.cmu.edu/~soonhok for building instructions.

BEGIN: READ CJUMP0 CASE_0CASE_1: WRITE 0 MOVE R JUMP BEGINCASE_0: WRITE 1 MOVE R JUMP BEGIN

Page 25: © 2013 Carnegie Mellon University Static Analysis of Real-Time Embedded Systems with REK Arie Gurfinkel 1 joint work with Sagar Chaki 1, Ofer Strichman.

25START-REKGurfinkel© 2013 Carnegie Mellon University

OSEK/VDX RTOS

Offene Systeme und deren Schnittstellen für die Elektronik in Kraftfahrzeugen; ("Open Systems and their Interfaces for the Electronics in Motor Vehicles“)

standard software architecture for the electronic control units (ECUs) in a car

Page 26: © 2013 Carnegie Mellon University Static Analysis of Real-Time Embedded Systems with REK Arie Gurfinkel 1 joint work with Sagar Chaki 1, Ofer Strichman.

26START-REKGurfinkel© 2013 Carnegie Mellon University

Turing Machine: Task Structure

Page 27: © 2013 Carnegie Mellon University Static Analysis of Real-Time Embedded Systems with REK Arie Gurfinkel 1 joint work with Sagar Chaki 1, Ofer Strichman.

27START-REKGurfinkel© 2013 Carnegie Mellon University

Turing Machine (Video)

http://www.youtube.com/watch?v=teDyd0d5M4o

Page 28: © 2013 Carnegie Mellon University Static Analysis of Real-Time Embedded Systems with REK Arie Gurfinkel 1 joint work with Sagar Chaki 1, Ofer Strichman.

28START-REKGurfinkel© 2013 Carnegie Mellon University

Turing Machine: Properties

Tape does not move when a bit is read or written

Read sensor and Write arm can move concurrently but must not interfere with one another

Read sensor’s light is off when not in use

Read task WCET is less than 25ms• reduced to checking API usage rules

No log messages are lost during USB communication•each message is delivered to the server before a new one is produced

Page 29: © 2013 Carnegie Mellon University Static Analysis of Real-Time Embedded Systems with REK Arie Gurfinkel 1 joint work with Sagar Chaki 1, Ofer Strichman.

29START-REKGurfinkel© 2013 Carnegie Mellon University

When writer flips a bit, the tape motor and read motor should stop.

Controller Task

Writer Task

An Example Property

Page 30: © 2013 Carnegie Mellon University Static Analysis of Real-Time Embedded Systems with REK Arie Gurfinkel 1 joint work with Sagar Chaki 1, Ofer Strichman.

30START-REKGurfinkel© 2013 Carnegie Mellon University

Time-Bounded Verification of Periodic Programs

Time-Bounded Verification• Is an assertion A violated within X milliseconds of a system’s execution from

initial state I• A, X , I are user specified

Periodic Program• Collection of periodic tasks

• Execute concurrently with fixed-priority scheduling• Priorities respect RMS • Communicate through shared memory• Synchronize through preemption and priority ceiling locks

Assumptions• System is schedulable• WCET of each task is given

Time-Bounded Analysis of Real-Time Systems, Proc. of FMCAD 2011

Page 31: © 2013 Carnegie Mellon University Static Analysis of Real-Time Embedded Systems with REK Arie Gurfinkel 1 joint work with Sagar Chaki 1, Ofer Strichman.

31START-REKGurfinkel© 2013 Carnegie Mellon University

Overall Approach

Supports C programs w/ tasks, priorities, priority ceiling protocol, shared variablesWorks in two stages:1. Sequentialization – reduction to sequential program w/ prophecy variables2. Bounded program analysis: bounded C model checker (CBMC, HAVOC, …)

Sequentialization Analysis

Periodic Program in CSequential Program OK

BUG + CEX

Periods, WCETs, Initial Condition, Time bound

Page 32: © 2013 Carnegie Mellon University Static Analysis of Real-Time Embedded Systems with REK Arie Gurfinkel 1 joint work with Sagar Chaki 1, Ofer Strichman.

32

START-REKGurfinkel© 2013 Carnegie Mellon University

START Family

REK (2011)•OSEK-based programs with Priority Ceiling locks•small robotics case study

REK-H (2012)•compositional sequentialization for harmonic tasks•Turing Machine case study

REK-PIP (2013)•Working on this now•Support for Priority-Inheritance-Locks (difficult )

REK-INF (Future)•Extend to complete verification by finding inductive invariants

http://www.andrew.cmu.edu/~arieg/Rek

Page 33: © 2013 Carnegie Mellon University Static Analysis of Real-Time Embedded Systems with REK Arie Gurfinkel 1 joint work with Sagar Chaki 1, Ofer Strichman.

33

START-REKGurfinkel© 2013 Carnegie Mellon University

Intellectually Defensible Base for Qualification

How should automatic verifiers be qualified for certification?

What is the base for automatic program analysis (or other automatic formal methods) to replace testing?

Verify the verifier• (too) expensive•verifiers are often very complex tools•difficult to continuously adapt tools to project-specific needs

Proof-producing (or certifying) verifier•Only the proof is important – not the tool that produced it•Only the proof-checker needs to be verified/qualified•Single proof-checker can be re-used in many projects

Page 34: © 2013 Carnegie Mellon University Static Analysis of Real-Time Embedded Systems with REK Arie Gurfinkel 1 joint work with Sagar Chaki 1, Ofer Strichman.

34START-REKGurfinkel© 2013 Carnegie Mellon University

Proof-Producing Verifier

Program+

PropertyVerifier No + Counterexample

Yes + Proof

Proof Checker

no need to qualify

“easy” to qualify / verify

Good

Bad

But things are not that simple in practice !!!

Page 35: © 2013 Carnegie Mellon University Static Analysis of Real-Time Embedded Systems with REK Arie Gurfinkel 1 joint work with Sagar Chaki 1, Ofer Strichman.

35START-REKGurfinkel© 2013 Carnegie Mellon University

Proof Producing Verifier

Low level propertyProgram = (Text, Semantics)

Verifier

Proof Checker

Front-End

Environment model

VC

No + Counterexample

Yes + Proof

Good Bad

Compiler

Executable

Real Env HardwareGood

Bad

?=?

Hard to verify

Hard to get right

Diff sem used by diff tools

Hard to get right

Page 36: © 2013 Carnegie Mellon University Static Analysis of Real-Time Embedded Systems with REK Arie Gurfinkel 1 joint work with Sagar Chaki 1, Ofer Strichman.

36START-REKGurfinkel© 2013 Carnegie Mellon University

Contact Information

PresenterArie GurfinkelRTSSTelephone: +1 412-268-5800Email: [email protected]

U.S. mail:Software Engineering InstituteCustomer Relations4500 Fifth AvenuePittsburgh, PA 15213-2612USA

Web:www.sei.cmu.eduhttp://www.sei.cmu.edu/contact.cfm

Customer RelationsEmail: [email protected]: +1 412-268-5800SEI Phone: +1 412-268-5800SEI Fax: +1 412-268-6257