Next Article in Journal
Energy Harvesting Backpacks for Human Load Carriage: Modelling and Performance Evaluation
Previous Article in Journal
Towards Efficient Neuromorphic Hardware: Unsupervised Adaptive Neuron Pruning
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Verification Method of Safety Properties of Embedded Assembly Program by Combining SMT-Based Bounded Model Checking and Reduction of Interrupt Handler Executions

Graduate School of Natural Science and Technology, Kanazawa University, Kanazawa 920-1192, Japan
*
Author to whom correspondence should be addressed.
Current address: Kakumamachi, Kanazawa City.
The author contributed to this work.
Electronics 2020, 9(7), 1060; https://doi.org/10.3390/electronics9071060
Submission received: 28 May 2020 / Revised: 15 June 2020 / Accepted: 16 June 2020 / Published: 27 June 2020
(This article belongs to the Section Computer Science & Engineering)

Abstract

:
Embedded software has properties dependent on hardware (direct operation of address spaces, memory mapped I/O, interruption, etc.). Therefore, demands about the established method of formal verifications corresponding to those properties are increasing from the point of view of shorter development and high reliability. Our study aims at enabling a formal verification with Satisfiability Modulo Theories-Based Bounded Model Checking (SMT-Based BMC) of safety for embedded assembly codes. Our proposed method generates models of assembly codes in detail with the fixed-sized bit-vectors theory. The models generated by our method include interrupts, and the size of the models is reduced using Interrupt Handler Execution Reduction (IHER) technique. In this paper, we have developed the verification method of safety properties of embedded assembly program by combining SMT-Based Bounded Model Checking and Reduction of Interrupt Handler Executions. Moreover, we show the evaluation of our method by experiments using prototype model checker.

1. Introduction

1.1. Background

Embedded systems are widely used, and the complexity of hardware and software advances with many functionalization. Also, embedded systems similar to those in Reference [1] based on microcontrollers, which are employed in airplanes, cars and mobile phones, have been targeted. The software of embedded systems has to be tested extensively because errors such as stack overflows and exception handlings may lead to severe or even fatal events as loss of reputation as in the case of the Toyota Prius bug [2]. The embedded software is mostly written in C or in assembly language. Removing errors in embedded software is difficult because deploying the updates is complicated and cost intensive. Testing of microcontroller software is often not possible because it is too time consuming for the desired time-to-market or too expensive. Also, testing is not sufficient for embedded systems as there are errors that are difficult to find by testing. There are standards such as IEC61508 [3] that recommend the application of formal methods such as formal verification methods. Formal verification methods, especially model checking [4] is very promising. In this paper, we focus on model checking.
Verifying C codes was not successful for embedded systems because the existing C code model checkers aim at the verification of hardware-independent ANSI C code [5]. In order to verify embedded systems, we must verify more features such as hardware-dependent constructs and interrupt handlers. All these features are not handled by the existing C code model checkers [5].
Verifying assembly codes is required. For example, we explain interruptions as follows. As one statement of C code supports plural instructions of assembly code, we can not verify interruptions because we cannot treat the timing when the interrupt enters well. When we verify assembly code with interruptions, the state space explosion problem occurs as each block of Control Flow Graph (CFG) [6,7] consists of one instruction. There is a possibility that an interrupt may be generated for each assembly instruction. Since there is a call to the interrupt processing routine for each instruction of the assembly, a state explosion occurs. In order to reduce the number of interruptions, B. Schlich et al. developed Interrupt Handler Execution Reduction (IHER) [8]. B. Schlich et al. have developed IHER, which reduces the number of Interrupt Handler (IH) executions by blocking IHs at program locations where there is no dependency between certain IHs and the program. There is a dependency if either one influences the other or the visible behavior of the program is changed. In order to reduce the number of blocks, we propose the method of making the block of codes, at which interruptions do not occur. We call the block Assembly Code Block (ACB).
Despite the high importance of assembly code verification, studies on verifying assembly codes, other than B. Schlich’s study, almost do not exist [1]. Also, we show the advantage of the verification of assembly program that B. Schlich pointed out as follows [1].
  • All errors (e.g., stack overflows, arithmetic overflows, interrupt handling errors, and writing reserved registers) introduced during the complete development process are consequently included in assembly program outcome, but by analyzing only the assembly program it is not possible to find and detect the roots of the assembly outcome.
  • Assembly language usually has a clean and well-documented semantics. Vendors of microcontrollers provide documentation describing the semantics of the provided assembly constructs.
  • Recently, bounded model checking of software using SMT solvers attracts attention [9]. SMT Solvers check the satisfiability of first-order formulas containing operations from various theories such as the Booleans, bit-vectors, arithmetic, arrays, and recursive datatypes. When model checking assembly program using SMT, the model checker does not have to exploit the compiler behavior, hardware-dependent constructs can be handled, and the source code (C code) of the software is not required. Hence, even programs that use libraries not available in source code can be analyzed. On the other hand, L.C. Cordeiro et al. have developed bounded model checking of C program using SMT [10], but bounded model checking of the assembly program using SMT has not existed.
  • Programs consisting of components written in different programming languages can be verified. When model checking the source code, only single components can be verified, and for each programming language used, a specific model checker has to be utilized.

1.2. Outline of This Paper

In this paper, we develop the verification method of safety properties by combining SMT-Based Bounded Model Checking [9] and Reduction of Interrupt Handler Executions [8].
We model registers and values of assembly codes using Fixed-Size Bit-Vector theory, and construct a transition system. Finally we verify the transition system using SMT-Based Bounded Model Checking. Also we construct the transition system including interrupts. We reduce state spaces using IHER [8]. IHER reduces the number of Interrupt Handler executions by blocking Interrupt Handlers at program locations where there is no dependency between certain Interrupt Handlers and the program [8]. We propose Assembly Code Block (ACB) by extending Basic Block of Control Flow Graph (CFG) [6,7] using IHER [8] in order to reduce state spaces. Moreover we show our proposed method effective by implementing the prototype. To the best of our knowledge, there have been no previous studies of SMT-Based Bounded Model Checking of embedded assembly program including interrupts. The outline of this research has been published at a domestic conference [11] and an international conference [12]. This paper is an extension of the previous work in References [11,12].

1.3. Related Work

Our paper is related to both SMT model checking of assembly program and reduction of interruption handlings. In particular, this paper is based on the model checking of assembly program [1,13], SMT-Based Bounded Model Checking [9] and Interrupt Handler Execution Reduction [8]. Therefore, this subsection presents related work regarding assembly program model checking first and then related work regarding SMT model checking and reduction of interruption handlings.
  • B. Schlich studied a new approach to model checking software for microcontrollers, which verifies the assembly code of the software [1]. The state space is built using a tailored simulator based on static analysis, which abstracts from time, handles nondeterminism, and creates an overapproximation of the behavior shown by the real microcontroller. On the other hand, we have developed model checker by both static analysis and dynamic program analysis such as undefined values [13].
    This paper and Reference [1] use different approaches as follows:
    (a)
    In Reference [1], if the model checker requests successors of a state which are not created yet, the state space uses the simulator to create the successors on-the-fly.
    (b)
    On the other hand, in this paper, the verification system completes the state transition system and passes it to the SMT solver. By using SMT’s background theory such as bit vector, bit-level assembly instructions can be easily expressed as functions of background theory and can be directly input to the SMT solver for verification.
  • B. Schlich et al. studied IHER in order to reduce the number of Interrupt Handler executions [8]. Also B. Schlich et al. studied various abstraction techniques based on static program analysis [14]. We propose Assembly Code Block (ACB) by extending Basic Block of CFG [6,7] using IHER [8].
  • L.C. Cordeiro et al. studied SMT-Based Bounded Model Checking of embedded ANSI-C program [10]. On the other hand, we study SMT-Based Bounded Model Checking of embedded assembly program. The background theory of the bit vector is effective for assembly program. Similar to model checking of C program, the background theory of the bit vector is expected to be effective in model checking of assembly program. In this study, we use the background theory of the bit vector for the assembly program, and construct the state space by representing register as a data type of a fixed length bit vector and representing the address space as a function of fixed bit vector mapping from address to value.
  • Recently, L. Lihao et al. proposed effective verification of low-level embedded C software with nested interrupts based on both partial-order encoding and symbolic execution [15]. On the other hand, in this paper, we merge basic blocks generated by interrupt processings based on reducing the number of interrupt handlers by IHER, and verify assembly program based on SMT Bounded model checking. If the method of Lihao Liang et al. is adopted, nested interrupts can be effectively handled in our paper as well.

1.4. The History of Model Checking

Model checking methods have been categorized into four categories such as (1) classical model checking, (2) Binary Decision Diagram (BDD) based symbolic model checking, (3) SATisfiability problem (SAT) based symbol model checking, and (4) SMT based model checking. Also, model checking methods have evolved from (1) to (4).
  • First, the evolution from (1) to (2) is in Reference [16]. The system is encoded in BDD without implementing the system directly in the adjacency list and so forth, realizing the verification of the large scale system.
  • Second, the evolution from (2) to (3) is in Reference [17]. We avoid the exponential state explosion of BDD, and encode the system into propositional logic rather than BDD to realize SAT verification with bounded model checking.
  • Finally, the evolution from (3) to (4) is in Reference [9]. SMT model checking is realized by expanding the scope of the verification by using the background theory by encoding the system into the predicate logic expression without the quantification symbol, not the propositional logic. Furthermore, SMT model checking can use a general-purpose SMT solver [18], and there is also future development. Our study is based on SMT model checking.
In this paper, in the scope of our survey, it is the first study on SMT based symbolic model checking with bounded model checking using the background theory of the bit vectors of assembly program.

1.5. Structure of This Paper

The rest of the paper is organized as follows. We first give a brief introduction to SMT-Based Bounded Model Checking, and in Section 3 we present SMT-Based Bounded Model Checking of assembly program. We next give a brief introduction to IHER, and in Section 5 we present ACB by extending Basic Block of CFG using IHER. Finally, we present the prototype model checker and the experiment.

2. Introduction to SMT-Based Bounded Model Checking

2.1. Overview

SMT generalizes boolean satisfiability (SAT) by adding equality reasoning, arithmetic, fixed-size bit-vectors, arrays, quantifiers, and other useful first-order theories [18]. A SMT solver is a tool for deciding the satisfiability of formulas in these theories.
On the other hand, model checking verifies whether a model M satisfies a property Φ or not. SMT solvers enable SMT-Based Bounded Model Checking over infinite domains. The idea of Bounded Model Checking is to check the negation of a given property at a given depth [19].

2.2. Program Verification by SMT-Based Bounded Model Checking

In BMC, the program to be analyzed is modelled as a state transition system, which is extracted from the control-flow graph (CFG) [6,7] as shown in Figure 1. In Figure 1, l 0 , l 1 and l 2 are a set of states, T 0 , T 1 and T 2 are a set of transition relations such as T 0 = { ( l 0 , l 1 ) } , T 1 = { ( l 1 , l 1 ) } and T 2 = { ( l 1 , l 2 ) } . This graph is built as part of a translation process from program text to single static assignment (SSA) form. A node in the CFG represents either a (non-) deterministic assignment or a conditional statement, while an edge in the CFG represents a possible change in the program’s control location.
A state transition system M = ( S , T , S 0 ) is a machine that consists of a set of states S of basic blocks, where S 0 S represents the set of initial states, and T S × S is the transition relation, that is, pairs of states specifying how the system can move from state to state. A state s S consists of the value of the program counter P C and the values of all program variables of a basic block. An initial state s 0 assigns the initial program location of the CFG to the P C . We identify each transition γ = ( s i , s i + 1 ) T between two states s i and s i + 1 with a logical formula γ ( s i , s i + 1 ) that captures the constraints on the corresponding values of the program counter and the program variables.
Given a transition system M, a property Φ , and a bound k, BMC unrolls the system k times and translates it into a VC (Verification Condition) ψ k such that ψ k can be satisfied if and only if for some i k there exists a reachable state at time step i in which Φ is violated. The VC is a quantifier-free formula in a decidable subset of first-order logic, which is then checked for satisfiability by an SMT solver. In this work, we are interested in checking safety properties of single-threaded programs. The associated model checking problem is formulated by constructing the following logical formula:
ψ k = I ( s 0 ) i = 0 k j = 0 i 1 γ ( s j , s j + 1 ) Φ ( s i ) .
Here, Φ is a safety property, I the set of initial states of M and γ ( s j , s j + 1 ) the transition relation of M between time steps j and j + 1 of basic blocks. Hence, I ( s 0 ) j = 0 i 1 γ ( s j , s j + 1 ) represents the executions of M of length i and Equation (1) can be satisfied if and only if for some i k there exists a reachable state at time step i in which Φ is violated. If Equation (1) is satisfiable, then the SMT solver provides a satisfying assignment, from which we can extract the values of the program variables to construct a counterexample. A counterexample for a property Φ is a sequence of states s 0 , s 1 , , s k with s 0 S 0 , s k S , and γ ( s i , s i + 1 ) for 0 i < k . If Equation (1) is unsatisfiable, we can conclude that no error state is reachable in k steps or less [10].

3. Proposal of Modeling Assembly Codes

We construct logical formulas by modeling assembly codes using SMT (Satisfiability Modulo Theories).

3.1. Defining States of Assembly Codes

A state is defined by values of registers and memory in microcontroller, and the values are represented as Bit-Vector.
In this paper, we model values of 16-bit registers and memory assigned address in the 16-bit by Fixed-Size Bit-Vector theory in SMT [18]. As some assembly instruction operates bits, Fixed-Size Bit-Vector theory is effective. We define registers by Fixed-Size Bit-Vector typed variables, and define memory by the function of Fixed-Size Bit-Vector mapping a 16-bit address to a 8-bit value. We construct states by Fixed-Size Bit-Vector typed variables and the function. Fixed-Size Bit-Vector theory consists of functions and predicates of Fixed-Size Bit-Vector. Functions consist of concat, extract, bvadd, bvsub, where function concat concatenates two bit vectors, function extract extracts bits, function bvadd adds two bits, function bvsub subtracts bits from bits. Fixed-Size Bit-Vector theory is defined by SMT-LIB 2.0, which is an international initiative aimed at facilitating research and development in Satisfiability Modulo Theories (SMT) [20,21], and is implemented by SMT solvers.

3.2. Defining State Transitions of Assembly Codes

First as IH might be invoked at every assembly instruction, we represent an assembly program by state transitions via Control Flow Automata (CFA) with the idea of Berkeley Lazy Abstraction Software verification Tool (BLAST) [22,23] instead of CFG. A CFA is a directed graph, with locations corresponding to control points of the assembly program, and edges corresponding to program operations. The transition relation γ ( s C F A j , s C F A j + 1 ) is defined by G ( s C F A j ) I S ( s C F A j , s C F A j + 1 ) as shown in Figure 2, where s C F A j ( j = 0 , 1 , 2 , ) ˙ is a state generated by one assembly instruction based on CFA. If there is a branch instruction in s C F A j , the state of the transition destination is s C F A j + 1 . In this case, the transition relation is defined by the same γ ( s C F A j , s C F A j + 1 ) . The case of ACB (in Section 5.3) can be defined similarly.
In this paper, we use standard Fixed-Size Bit-Vector theory [18]. In the description of CFGs, we use two kinds of equation symbols for clarity, = = for guard conditions and = for assignments. When passing formulas to the SMT solver, both symbols are translated as the equation symbol of the Bit-Vector theory.
By the way, the transition relation γ ( s j , s j + 1 ) in Equation (1) is generated from CFG. On the other hand, the transition relation γ ( s C F A j , s C F A j + 1 ) is generated from CFA. γ ( s C F A j , s C F A j + 1 ) is different from γ ( s j , s j + 1 ) .
  • First a transition condition G ( s C F A j ) is the equation using P C (Program Counter). For P C 0 = = 0 x 0000 , if the P C 0 is 0 x 0000 , this means that the instructions of the Static Single Assignment form (SSA) format are executed. P C 1 = 0 x 0001 means to assign 0 x 0001 to P C 1 .
  • Next after executing assembly codes at s C F A j , the transition from s C F A j to s C F A j + 1 occurs. The next state s C F A j + 1 is defined by a instruction constraint I S ( s C F A j , s C F A j + 1 ) . CFA is constructed from assembly codes. Each node consists of assembly code, and each edge is caused by a instruction constraint I S ( s C F A j , s C F A j + 1 ) . An instruction constraint I S ( s C F A j , s C F A j + 1 ) is represented by predicate formulas. There are instructions such as data transfer, arithmetic operation, extraction and concatenation [24]. The logical formula of state transition γ ( s C F A j , s C F A j + 1 ) is represented by a instruction constraint I S ( s C F A j , s C F A j + 1 ) . All instructions can be transformed into I S ( s C F A j , s C F A j + 1 ) .
Also, in Figure 2, for all registers that are not assigned in a state (for example, ER), a constraint such as E R p + 1 = E R p is set to I S ( s C F A j , s C F A j + 1 ) , where p { 0 , 1 , 2 , } . All variables that appear in the left-hand sides of SSA are distinguished by introducing a fresh variable for each assignment. We use the subscript p to represent these variables. p is used for variables with distinct names.
Here we show three I S ( s C F A j , s C F A j + 1 ) of M O V and A D D instructions as follows.
  • The instruction constraint I S ( s C F A j , s C F A j + 1 ) of data transfer instruction M O V E R s , E R d is represented by the equation between E R s and E R d as follows.
    E R d p + 1 = E R s p
    where E R s p represents the value of E R s at s C F A j , and E R d p + 1 represents the value of E R s at s C F A j + 1 .
  • The instruction constraint I S ( s C F A j , s C F A j + 1 ) of Fixed-Size Bit-Vector operation, for example A D D E R s , E R d is represented by the equation between an operation result and a destination register. The following Equation (3) represents adding E R s and E R d , and storing it in E R d using b v a d d .
    E R d p + 1 = b v a d d E R d p E R s p .
  • The instructions (a) M O V A R , E R d and (b) M O V E R s , A R are represented by functions _ e x t r a c t and c o n c a t of bits as follows. Here ⓐ denotes register indirect addressing. Access to address space is defined by a function AS and the argument of the function is indirect address.
    (a)
    The instruction constraint I S ( s C F A j , s C F A j + 1 ) of the instruction M O V a A R , E R d is represented by Equation (4) using c o n c a t as shown in Figure 3. The value of 16-bit register A R is interpreted as memory address, and the value that is stored at the address is stored into E R d .
    E R d p + 1 = ( c o n c a t A S p ( A R p ) A S p ( b v a d d A R p x 0001 ) ) .
    (b)
    The instruction constraint I S ( s C F A j , s C F A j + 1 ) of the instruction M O V E R s , A R is represented by Equation (5) using _ e x t r a c t as shown in Figure 4. The value of 16-bit register A R is interpreted as memory address, and the value of E R s is stored into the address A R .
    ( ( A S p + 1 ( A R p ) ) = ( ( _ e x t r a c t 15 8 ) E R s p ) ( ( A S p + 1 ( b v a d d A R p x 0001 ) ) = ( ( _ e x t r a c t 7 0 ) E R s p ) ) .
Because all including the update of P C and status registers may not be stated clearly for an operand, we add update of the P C and the status registers to the instruction constraint I S ( s C F A j , s C F A j + 1 ) in consideration of both the structure of the microcomputer and the syntax of assembly code.
Also in consideration of interrupts, we must compose program and Interrupt Handler (IH). Composing program and Interrupt Handler may cause the state space explosion. But in the case of a routine controlling permission and prohibition of interrupts, we need not add interrupts into the program location when interrupts are prohibited. Therefore we can reduce the state space of program using B. Schlich et al.’s method [8].

4. Introduction to Interrupt Handler Execution Reduction (IHER)

B. Schlich et al. have developed an abstraction technique called IHER, which reduces the number of IH executions by blocking IHs at program locations where there is no dependency between certain IHs and the program [8]. Here there is a dependency if either one influences the other or the visible behavior of the program is changed. An IH influences a program location if it writes a memory location that is accessed by the program location, and on the other hand, a program location influences an IH if it enables or disables interrupts.
In this paper, we reduce the number of IH executions using B. Schlich et al.’s IHER.
B. Schlich et al.’s IHER consists of four steps. According to B. Schlich et al.’s paper [8], we briefly explain the four steps as follows.
  • Detect Dependencies between IHs:
    i , j IH depend on each other, if one of the following conditions holds:
    • one enables or disables the other,
    • one writes a memory location accessed by the other, or
    • one writes a memory location. Writing a memory location or a register is an atomic proposition, where an atomic proposition is appeared in temporal logic formulas. In other words, writing a value to a variable is used as the atomic proposition in a temporal logic formula that describes a property to be verified.
  • Detect Dependencies between Program and IHs:
    To detect the dependencies between the program and the IHs, we mark specific program locations with the following two labels: e x e c u t i o n and b a r r i e r . The label e x e c u t i o n implies that there exists a dependency between the preceding program location and an IH, and thus, this IH needs to be executed eventually. The label b a r r i e r denotes that there exists a dependency between that program location and an IH, and therefore, this IH needs to be executed before the instruction at that location is executed.
    Let program location k be a direct predecessor of program location l.
    • Label e x e c u t i o n :
      For each i IH, l is labeled with e x e c u t i o n i if one of the following conditions is satisfied:
      k enables or disables i,
      k writes a memory location that is accessed by i, or
      k writes a memory location that is used in an atomic proposition.
    • Label b a r r i e r :
      For each i IH, a program location l is labeled with b a r r i e r i if one of the following conditions holds:
      i writes a memory location that is accessed by l,
      l enables or disables i,
      l writes a memory location that is accessed by i, or
      l writes a memory location that is used in an atomic proposition.
  • Refine Labelings:
    In the refinement step, we try to reduce state spaces further by moving e x e c u t i o n i labels until their execution is actually required. We move labels e x e c u t i o n i forward until one of the following conditions holds:
    • a program location labeled with b a r r i e r i is reached,
    • a loop entry is found, or
    • a loop exit is found.
  • Label Blocking Locations:
    In the last step, all program locations are labeled with IHs that can be blocked at the corresponding program location. An IH can be blocked at a program location if its execution is not required. Thus, a program location is labeled with b l o c k i n g i if it is not labeled with e x e c u t i o n i .
IHER reduces the number of program locations at which the possible execution of interrupt handlers (IHs) has to be considered. In this paper, we reduce state spaces using IHER. B. Schilich’s paper proves that model checking of C T L * X is valid, even if IHER reduces the number of program locations at which the possible execution of interrupt handlers (IHs) has to be considered. Here C T L * X is defined by disallowing the nexttime operator X in C T L * formulas [25]. In this paper, as we verify assembly codes using subclass of C T L * X such as safety properties, our verifications are valid even if IHER reduces the number of assembly program locations.

5. Proposal of Assembly Code Block (ACB) of CFG Using IHER (in Other Words, Combining SMT-Based Bounded Model Checking and Reduction of Interrupt Handler Executions)

5.1. Introduction to ACB

In this paper, we reduce the number of IH executions by blocking IHs at program locations using IHER, and make a set of basic blocks from assembly codes blocking IHs. We propose this set of blocks, what we call ACB. By the same method as partitioning program codes into basic blocks [6,7], we partition assembly codes into blocks. Therefore there are no jumps into the middle of the block. Also control will leave the block without halting or branching, except possibly at the last instruction in the block. The blocks become the nodes of CFG, whose edges indicate which blocks can follow which other blocks.
The start point satisfies one of the following conditions:
  • A start node of program
  • A branch destination node
  • An e x e c u t i o n node
Also the end point satisfies one of the following conditions:
  • An end node of program, which has return instruction
  • A node, which has branch instruction
The consecutive nodes from the start point of the block to the end point becomes one node.

5.2. ACB (Assembly Code Block)

We propose ACB by extending basic blocks [6,7]. In ACB, assembly codes, at which IHs are blocked, are collected, and one block is made. ACB is built as part of a translation process from assembly program text to SSA (static single assignment) form [6,7] as shown in Figure 5, where s j is generated by a basic block of CFG, and s A C B q is generated by ACB of CFG.
Basic blocks γ ( s j + m , s j + m + 1 ) = G ( s j + m ) I S ( s j + m , s j + m + 1 ) ( m = 0 , , L 1 ) is defined by transforming assembly program into SSA form and then into the quantifier-free formula, where L is the number of instructions merged from basic blocks to ACB in program including interrupt routines. ACB based on IHER reduces the number of logical formulas of a transition γ ( s A C B q , s A C B q + 1 ) , where γ ( s A C B q , s A C B q + 1 ) = G ( s A C B q ) I S ( s A C B q , s A C B q + 1 ) as shown in Figure 5, where q { 0 , 1 , 2 , } represents the order in which s A C B q is generated. s A C B q consists of the values of variables of the bit vector type representing the values of the program counter, program variables and registers. Each s A C B q is defined by the values of common state variables. If no assignment is made to a register, an expression is added to indicate that the value of E R 0 p + 1 = E R 0 p in state s j + 1 does not change. But we omit the expression in Figure 5 and all figures in this paper. In Figure 5, we denote variables such as P C p and E R 1 p + 1 by SSA notation. Figure 5 shows a method of constructing A C B ( s A C B q , s A C B q + 1 ) from the basic blocks γ ( s j , s j + 1 ) and γ ( s j + 1 , s j + 2 ) . Here P C p = = 0 x 0000 means that if P C p is equal to 0 x 0000 , the following instructions will be executed, and P C p + 1 = 0 x 0000 means to substitute 0 x 0000 into P C p + 1 . P C p and P C p + 1 are SSA forms of a single state variable P C , and P C p and P C p + 1 correspond to a state variable P C . In Figure 5, each set of variables used in s j , s j + 1 , s j + 2 and s A C B q , s A C B q + 1 is the following subset:
{ P C p , P C p + 1 , E R 0 p , P C p + 2 , E R 1 p , E R 1 p + 1 }
  • G ( s A C B q ) is the conditional statement using P C value of the first instruction.
  • I S ( s A C B q , s A C B q + 1 ) is the conjunction of logical formulas representing update of registers and locations by executing instructions. As shown in Figure 5, the number of logical formulas of ACB is smaller than the number of logical formulas of basic block.
The generation procedure of ACB formula such as γ ( s A C B q , s A C B q + 1 ) = G ( s A C B q ) I S ( s A C B q , s A C B q + 1 ) , is as follows.
Description 1.
(1) 
Since the first instruction of ACB is a guard instruction, a predicate logical expression G ( s A C B q ) with a conditional expression == is generated.
(2) 
Since the instruction after the first is an assignment statement to a register or a memory, a logical expression is generated in the usual SSA format [7].
(3) 
Repeat (2) to generate these logical products.
(4) 
Finally generate a logical product of (1) and (3).
Here we describe “the condition of a basic block” [6,7] as follows. A basic block is a sequence of instructions, satisfying “the condition of a basic block” such that the flow of control can enter the basic block through the first instruction and control will leave the basic block without halting or branching except at the last instruction in the basic block.
Finally we define Algorithm 1 to generate from basic blocks to ACB.
Algorithm 1: Algorithm to generate from CFA to ACB
1:
Input : CFA of assembly program
2:
Output : CFG of ACB
3:
Method : By the following procedures of (1), (2) and (3), ACB is generated from assembly program.
Description 2.
(1) 
First, as IH might be invoked at every instruction and IH is called for all instructions in CFA [22,23], we embed IH call in every instruction.
Next, as shown in Figure 6, for all instructions, by making both an edge from IH to an instruction and an edge from the instruction to IH, we generate CFG using commonly used techniques in compiler [6,7].
(2) 
First, as shown in Figure 7, we delete unnecessary IH calls using IHER [8].
Next, after deleting unnecessary IH calls, we reconfigure CFG for basic blocks.
(3) 
After IHER removes unnecessary IH calls, there are some basic blocks where IH branches are deleted.
The basic blocks where the branches are deleted can be merged, so we merge and configure a new basic block, what is called ACB as shown in Figure 8, as follows:
Generating from basic blocks to ACB is performed by depth-first search from the basic block of the CFG root as follows:
Description 3.
(a) 
The following processing is performed on the next basic block connected by an edge from the basic block:
Description 4.
(a)-1 
Merge basic blocks if “the condition of a basic block” is satisfied. However, we do not merge with basic blocks that have already been merged with other basic blocks. Two ACBs can meet the same block when merging and bifurcation exist in the CFG.
(a)-2 
Otherwise, do not merge, and the basic block becomes ACB.

5.3. Program Verification Based on ACB

In order to verify program using SMT-Based Bounded Model Checking based on ACB, first the assembly program is modeled as a state transition system, which is extracted from CFG consisting of ACBs, instead of CFG consisting of basic blocks [6,7]. Usual CFG is a graph with basic blocks as nodes [6,7], on the other hand, CFG here is a graph with ACBs as nodes. A node in the CFG consisting of ACBs represents either a (non-) deterministic assignment or a conditional statement, while an edge in the CFG represents a possible change in the assembly program’s control location. Given a transition system M, a property Φ , and a bound k, Bounded Model Checking unrolls the system k times and translates it into a verification condition ψ k such that ψ k is satisfiable if and only if Φ has a counterexample of depth k or less. The verification condition ψ k is constructed from the CFG consisting of ACBs, and given by Equation (6).
As A C B ( s A C B q , s A C B q + 1 ) is constructed by composing basic blocks such as γ ( s j , s j + 1 ) , γ ( s j + 1 , s j + 2 ) , , Equation (6). can compute the larger number of reachable states than Equation (1)
ψ k = I ( s A C B 0 ) i = 0 k ( q = 0 i 1 A C B ( s A C B q , s A C B q + 1 ) Φ ( s A C B i ) ) .
Verification property Φ is intended to be re-given (abstracted by block granularity) in the CFG after blocking with ACB.
An example of merging from two basic blocks to ACB is shown below. Sometimes it merges from two or more basic blocks to the ACB. When the number of instructions of ACB is L, A C B ( s A C B q , s A C B q + 1 ) is represented by Equation (7) as shown in Figure 5.
A C B ( s A C B q , s A C B q + 1 ) : = G ( s A C B q ) I S ( s A C B q , s A C B q + 1 ) .
A C B ( s A C B q , s A C B q + 1 ) is the conjunction of a transition condition G ( s A C B q ) and an instruction constraint I S ( s A C B q , s A C B q + 1 ) . An instruction constraint I S ( s A C B q , s A C B q + 1 ) is the logical formula representing effect by executing the instruction.
We suggest thefollowing:
  • When instructions included in one A C B are few, the effect of reducing state spaces is not provided enough.
  • As the length of logical formula A C B ( s A C B q , s A C B q + 1 ) is long, verification time is long by SMT solver.

5.4. Comparison of Usual CFG, CFG of IHER, CFG of ACB

In this subsection, we compare usual CFG, CFG of IHER, CFG of ACB. In Figure 6, Figure 7 and Figure 8, we show the correspondence between the assembly program and the CFG with dotted arrows. The CFGs shown in Figure 6, Figure 7 and Figure 8 are CFGs considering loops, and include arbitrary execution paths as shown in References [6,7,22,23]. Therefore, if this CFG is verified, it can be verified by model checking for an arbitrary execution path.
  • Usual CFG [6,7] is used in the optimization of compiler. Every assembly instruction, an interrupt occurs. Therefore as usual CFG with interruptions is shown in Figure 6, the state space explosion usually occurs.
  • CFG of IHER is developed by B. Schlich et al. [8]. IHER reduces the number of Interrupt Handler executions by blocking Interrupt Handlers at program locations where there is no dependency between certain Interrupt Handlers and the program [8]. Therefore CFG of IHER is shown in Figure 7.
    For example, in Figure 7, since the value of ER1 after executing SUB.L instruction is the same regardless of the presence or absence of the interrupt routine, the transition to the interrupt routine is decreasing because there is no dependency. As explained in Section 4, IHER and our proposed method analyze even such complex dependencies.
  • We propose CFG of ACB in this paper. We propose ACB by extending Basic block of CFG [6,7] using IHER [8] in order to reduce the state spaces. In order to reduce the number of blocks, we propose the method of making the block of codes, at which interruptions do not occur. Therefore CFG of ACB is shown in Figure 8. Here for example, we show s A C B q ( q = 0 , 1 , 2 , ) , P C p , E R p ( p = 0 , 1 , 2 , ) in Figure 8 as follows:
    (a)
    s A C B 0 : = P C 0 = = 0 x 0000 P C 1 = 0 x 0001 E R 0 0 = 0 x 0001 P C 2 = 0 x 0002 E R 1 1 = E R 1 0 + E R 1 0 P C 3 = 0 x 0003 E R 2 0 = 0 x 0001
    (b)
    The following is repeated with a loop count n = 0 , 1 , 2 , of lines 3–5 of the program:
    • s A C B 1 + n : = P C 3 + 5 n = = 0 x 0003 + 5 n P C 4 + 5 n = 0 x 0004 + 5 n E R 0 1 + n = E R 0 0 + n + E R 0 0 + n
    • s A C B 2 + n : = P C 4 + 5 n = = 0 x 0004 + 5 n P C 5 + 5 n = 0 x 0005 + 5 n E R 1 2 + n = 0 x 001
    • s A C B 3 + n : = P C 5 + 5 n = = 0 x 0005 + 5 n P C 6 + 5 n = 0 x 0006 + 5 n C C R 0 + n = 0 x 0
    • s A C B 4 + n : = P C 6 + 5 n = = 0 x 0006 + 5 n P C 7 + 5 n = 0 x 0007 + 5 n E R 1 3 + n = 0 x 001
    • s A C B 5 + n : = P C 7 + 5 n = = 0 x 0007 + 5 n P C 8 + 5 n = 0 x 0008 + 5 n
    (c)
    s A C B 6 + n : = P C 8 + 5 n = = 0 x 0008 + 5 n P C 9 + 5 n = 0 x 0009 + 5 n E R 2 1 = 0 x 0000 P C 10 + 5 n = 0 x 0010 + 5 n
    Here, the P C on the sixth line of the program is P C 9 + 5 n = 0 x 0009 + 5 n , and the P C on the seventh line is P C 10 + 5 n = 0 x 0010 + 5 n .
    However, n ( n = 0 , 1 , 2 , 3 , ) changes depending on k of bounded model check k-bound. The larger k is, the larger n is.
From comparison of usual CFG, CFG of IHER and CFG of ACB, our proposed ACB is effective for the number of blocks as shown in Figure 6, Figure 7 and Figure 8, where we omit the constraints that represent no change.

6. Prototype Model Checker

This prototype is a prototype in the sense that it realizes a subset of instructions of assembly program, but the functions of our proposed method are realized. Therefore, experimental evaluation is general.

6.1. Verification Example

In this paper, we demonstrate the effectiveness of our proposed method for robots which carried microcomputer H8/3687 [26,27] of Renesas company. In H8/3687 processor, all the general purpose registers are 16 bits wide. When a general register is used as a data register, it can be accessed as a 32-bit, 16-bit, or 8-bit register. On the other hand, Control registers consist of 24-bit P C , 8-bit C C R . When ER7 (SP) is used as an address register to access the stack area, the operand size should be word or longword.
In this paper, we model values of 16-bit registers and memory assigned address in the 16-bit by Fixed-Size Bit-Vector theory in SMT [18]. We define registers by Fixed-Size Bit-Vector typed variables, and define memory by the function of Fixed-Size Bit-Vector mapping a 16-bit address to a 8-bit value. We construct states by Fixed-Size Bit-Vector typed variables and the function. Fixed-Size Bit-Vector theory consists of functions and predicates of Fixed-Size Bit-Vector. Functions consist of concat, extract, bvadd, bvsub.

6.2. Example of Modeling Assembly Instructions

We transform instructions into instruction constraints as shown in Table 1. The notation of the expression follows input form SMT-LIB2lang [20] of SMT-LIB 2.0. In Table 1, we omit implicit behaviors about P C , and C C R , and we list only logical formulas indicating the behaviors for the operand.
  • The data transfer instruction M O V E R s , E R d is represented by the equation between source register E R s j and destination register E R d j + 1 .
  • A D D . W R s , R d is represented by the equation between an operation result and a destination register using _ e x t r a c t , c o n c a t and b v a d d .
  • ⓐ denotes register indirect addressing. M O V . B R s L E R d stores the low 8 bits of a source operand R s L into the address that the value in a destination register points. Access to address space (AS) is defined by a function, and the argument of the function is indirect address.

6.3. Configuration of Prototype Model Checker

We show the configuration of prototype model checker in Figure 9. Our prototype model checker consists of analysis of assembly codes, generation of CFG, VC (Verification Condition) builder, verification by SMT solver. Prototype Model Checker is written in Java 7 (7500 lines).
  • Lexer and Parser:
    Lexer performs lexical analysis, and parser performs syntax analysis of assembly codes of H8/3687 microcomputer. Lexer and Parser output analyzed codes (syntax tree) and memory map from assembly codes. We use JFlex [28] and BYACC/J [29] for Java in order to develop Lexer and Parser.
  • CFG generator:
    CFG generator constructs CFG from syntax tree. First CFG generator composes interrupts. After that it constructs CFG using IHER. CFG consists of both ACBs and the transitions between ACBs.
  • VC builder:
    VC builder generates verification conditions. VC builder generates logical formulas of an initial condition and transition relations from CFG. Given a property Φ and a bound k, the verification condition ψ k is gnerated such as Equation (6).
  • SMT solver: We verify the verification condition ψ k using SMT solver Z3 4.3 [30]. In this paper, we use Fixed-Size Bit-Vector theory in SMT [18,24].

7. Verification Experiments

7.1. Overview of Verification Experiments

Prototype model checker verifies assembly codes of H8/3687 microcomputer. We prepare two programs. Two programs satisfy each verification condition. We verify programs using only IHER and using both IHER and ACB. As SMT solver may not terminate in a realistic time, we stop verification in a time limit.
We verify whether the following property composed of the conjunction of three conditions ϕ 1 ( s A C B q ) , ϕ 2 ( s A C B q ) and ϕ 3 ( s A C B q ) is satisfied. Thought the property is a liveness property correctly if infinite k-bound, we verify whether there is a counterexample until finite k-bound. Namely we verify the following liveness property as a safety property.
  • ϕ 1 ( s A C B q ) : Program reaches RTS instruction.
  • ϕ 2 ( s A C B q ) : The value of stack pointer after reaching RTS is equal to the value of stack pointer before executing the routine.
  • ϕ 3 ( s A C B q ) : The value of P C after executing RTS is equal to return address.
For verifying the above property, the set of initial states is given by initial conditions as follows.
  • I 1 ( s A C B 0 ) : The initial value of P C is set.
  • I 2 ( s A C B 0 ) : The initial value of stack pointer is equal to the value of stack pointer before calling this routine.
  • I 3 ( s A C B 0 ) : The return address is stored in the stack at the time of the routine start.
In accordance with the above, we give the set of initial states I ( s A C B o ) and the verification property Φ ( s A C B i ) in the verification conditional Equation (6) verified in this experiment concretely in SSA form.
  • When the initial value of P C is set to x 0100 and the return destination address is set to x 0116 in program 1, the set of initial states I ( s A C B 0 ) is defined as follows:
    I ( s A C B 0 ) = I 1 ( s A C B 0 ) I 2 ( s A C B 0 ) I 3 ( s A C B 0 ) , where I 1 ( s A C B 0 ) = ( P C 0 = x 0100 ) , I 2 ( s A C B 0 ) = ( E R 7 0 = x F F 78 ) , I 3 ( s A C B 0 ) = ( A S 0 ( E R 7 0 ) = x 0001 ) A S 0 ( E R 7 0 + 1 ) = x 0016 ) .
    Here I 1 ( s A C B 0 ) is an expression defining the initial value of the program counter P C (corresponding to the initial condition 1), I 2 ( s A C B 0 ) is an expression defining that the initial value of stack pointer is equal to the value of stack pointer before calling this routine (corresponding to the initial condition 2), and I 3 ( s A C B 0 ) is an expression defining that the return address is stored in the stack at the time of the routine start.
  • When the address of ReTurn from Subroutine (RTS) instruction is x 010 E , the return destination address is x 0116 , and the stack pointer register E R 7 is x F F 78 in program 1, the verification property Φ ( s A C B q ) is defined, where q = 6 + n and p = 11 + 5 n as follows:
    Φ ( s A C B q ) = ϕ 1 ( s A C B q ) ϕ 2 ( s A C B q ) ϕ 3 ( s A C B q ) , where ϕ 1 ( s A C B q ) = ( P C 10 + 5 n = = x 010 E ) , ϕ 2 ( s A C B q ) = ( E R 7 0 = = x F F 78 ) , ϕ 3 ( s A C B q ) = ( P C 11 + 5 n = = x 0116 ) .
    As shown in Figure 8, a verifier specify Φ ( s A C B q ) including q = 6 + n and p = 11 + 5 n using the correspondence between the assembly program and the CFG with dotted arrows, where n is the number of loops of program.
    Here ϕ 1 ( s A C B q ) is an expression defining that Program reaches RTS instruction (corresponding to the property 1), ϕ 2 ( s A C B q ) is an expression defining that the value of stack pointer after reaching RTS is equal to the value of stack pointer before executing the routine (corresponding to the property 2), and ϕ 3 ( s A C B q ) is an expression defining that the value of P C after executing RTS is equal to return address (corresponding to the property 3).
As a general theory, in embedded software, assembly language description is included in the interface part with hardware, so programming with C program alone is impossible. Therefore, in embedded software, verification of the assembly program is necessary. Also, since one line of the C program is compiled into the assembly program 2–3 lines, it can not be verified accurately by C program verification for interrupt processing occurring for each assembly program line. Also, it can not be verified that it is not an assembly program that the stack is not destroyed. The points concerning the evaluation experiment are as follows.
  • The verification property that the stack pointer before the function call is equal to the stack pointer immediately after returning from the called function can be verified only by the assembly program. By this verification property we verify whether the stack is not destroyed.
  • The verification property that the return address saved before the function call is equal to the address after execution of the RTS instruction of the called function can be verified only by the assembly program. By this verification property we verify whether the stack is not destroyed, too.

7.2. Which Programs Are Verified ?

We prepare two programs consisting of main routine and interrupt routines. They are the essential part of typical embedded programs implemented in e-nuvo WHEEL [31].
Program 1 consists of routine _ t e s t C o d e and interrupt _ t e s t I n t r as shown in Figure 10. _ t e s t C o d e repeats the addition of register E R 0 until the value of register E R 1 except 0 is stored. _ t e s t I n t r renews contents of the stack while storing a value in register E R 1 . That is, this program is a program that continues adding until an interrupt occurs and does not stop. Also, assuming that an interrupt is disabled in program 1 in the initial state, the interrupt is enabled by setting a value to the 6th bit in the address indicated by the interrupt status register Inputbuffer Control Register (ICR). As the above verification property is satisfied, model checker outputs UNSATisfiable (UNSAT).We stop verification in a time limit.
Program 2 consists of routine _ s c i _ t x b u f _ s e t and interrupt _ i n t _ s c i , which are implemented in e-nuvo WHEEL [31] as shown in Figure 11. _ s c i _ t x b u f _ s e t sets a value in a transfer buffer of serial communication interface (SCI3). This _ s c i _ t x b u f _ s e t controls an interrupt at the time of the transfer by SCI3, and the transfer processing in interrupt routine _ i n t _ s c i is prohibited during executing this routine. We stop verification in a time limit.

7.3. Results of Experiments

We verify programs in the following experiment environment as shown in Table 2. We stop verification in ten minutes of SMT solver. If verification time is longer than 3600 s after verification, verification is aborted.
By the introduction of ACB, both the number of interruption codes and the number of blocks are reduced, but the number of codes in a block is increased. The cost of verification is determined by the multiplication of the number of blocks and the size of blocks. Therefore in ACB, the verification cost of each block has a bigger cost. But the overall verification cost decreases because there is little number of blocks. At first, we verify the program with k = 1, then we increase k one by one and repeat program verification.

7.3.1. Verification Results of Program 1

We show verification results of program 1 using existing IHER and using our proposed ACB as shown in Table 3. When comparing with the same verification time, it is better to use ACB rather than IHER to include more assembly code lines (number of instructions) as shown in Table 3. In Table 3, the column name nodes of IHER is the number of basic blocks and the column name nodes of ACB is the number of ACB blocks. The number of nodes of ACB in the Table 3 was calculated by generating CFG. As ψ k is unsatisfiable using SMT solver, Φ is satisfied, and does not have a counterexample of depth k.
Also we show verification lines of program 1 for verification time in Figure 12. The vertical axis “Lines” in Figure 12 is the number of lines of the verified assembly code, and it was measured with our verification tool. For all state transition sequences obtained with the number of state transitions less than the given bound, the sum of the number of code lines executed by the program corresponding to each state transition sequence is assembly [lines] in Table 3 and Table 4. When we use ACB, the number of lines which we can verify in 3600 s increases from 3500 lines to 4500 lines. Therefore from the viewpoint of a bound k, our proposed ACB is superior to existing IHER. In the verification results of Program 1, both IHER and ACB output UNSAT. As the tool answers UNSAT, the behavior shown by the real microcontroller is safe under general conditions such as initial conditions.

7.3.2. Verification Results of Program 2

We show verification results of program 2 using existing IHER and using our proposed ACB as shown in Table 4. In Table 4, the column name nodes of IHER is the number of basic blocks and the column name nodes of ACB is the number of ACB blocks. When ψ k is satisfiable using SMT solver, Φ has a counterexample of depth k.
In the verification results of Program 2, both IHER and ACB output UNSAT. Therefore it was confirmed that the stack was used correctly in the execution path that was verified up to each maximum step. Since interrupts are prohibited from line 6 to line 29 of _ s c i _ t x b u f _ s e t , the reduction of nodes due to blocking was remarkable. Figure 13 is a graph showing the change in the number of verified code lines per verification time. The number of verification lines per second is always higher than that of our ACB model, and the effect of blocking was confirmed, and the efficiency of verification time is considered to be higher for our ACB model.

7.4. Comparison with Classical Model Checking

7.4.1. Comparison with the Classical Model Checker SPIN

We compare SPIN [32] with our proposed method by program 1. We can verify Program 1 using SPIN in less time than using our proposed method as shown in Figure 14.
We can verify a system in polynomial time for the size of the system using SPIN. Also, SPIN has the following several optimisation algorithms to make verification runs more effective:
  • partial order reduction
  • bitstate hashing
  • minimised automaton encoding of states (not in a hashtable)
  • state vector compression
  • dataflow analysis
  • slicing algorithm
On the other hand, SMT-based model checking is convenient because it can use a general purpose theorem provers, but deciding the satisfiability of formulas with respect to decidable background theories is usually in NP-complete [18].

7.4.2. Examples That Can Not Be Verified by Classical Model Checking

Here we consider Program 3 in Figure 15. As function _ f is not defined in Program 3, we can not verify Program 3 by SPIN [32]. On the other hand, we can verify Program 3 using the following SMT theory of undefined function [18] by our proposed method.
( x 1 = y 1 ) ( x 2 = y 2 ) implies F ( x 1 , x 2 ) = F ( y 1 , y 2 ) .
This is one of advantages of SMT-based model checker.

8. Conclusions and Future Works

In this paper, we proposed the verification method of safety properties using ACB (Assembly Code Block) by combining SMT-Based Bounded Model Checking [9] and Reduction of Interrupt Handler Executions [8]. Also we implemented prototype model checker by Java 7500 lines, and show effective our proposed method. We model registers and values of assembly codes using Fixed-Size Bit-Vector theory, and construct a transition system. Also we construct the transition system including interrupts. We reduce state spaces using ACB.
In this paper, we developed a prototype model checker for demonstrating our proposed methods. We cannot specify verification properties without looking at generated CFG of ACBs. But if we extend our prototype model checker, we can specify verification properties with looking only at assembly program.
We are now extending our prototype model checker for specifying verification properties with looking only at assembly program. We are currently verifying other examples and properties using our proposed method. Also we develop verifying liveness properties.

Author Contributions

Conceptualization, S.Y.; Funding acquisition, S.Y.; Methodology, S.Y.; Project administration, S.Y.; Resources, S.Y.; Software, J.K. and K.U.; Supervision, S.Y.; Writing—original draft, S.Y. All authors have read and agreed to the published version of the manuscript.

Funding

This work was supported in part by JSPS/MEXT Grant-in-Aid for Scientific Research Numbers 15K00093.

Conflicts of Interest

The authors declare no conflict of interest.

References

  1. Schlich, B. Model Checking of Software for Microcontrollers. ACM Trans. Embed. Comput. Syst. 2010, 9, 1–27. [Google Scholar] [CrossRef] [Green Version]
  2. Kanellos, M. Software Glitch Stalls Some Toyota Hybrids. Available online: https://www.cnet.com/roadshow/news/software-glitch-stalls-some-toyota-hybrids/ (accessed on 28 May 2020).
  3. International Electrotechnical Commission. Functional Safety for Electrical/Electronic/Programmable Electronic Safety-Related Systems; IEC: Geneva, Switzerland, 2010. [Google Scholar]
  4. Clarke, E.M., Jr.; Grumberg, O.; Kroening, D.; Peled, D.; Veith, H. Model Checking; Cyber Physical Systems Series; MIT Press: Cambridge, MA, USA, 2018. [Google Scholar]
  5. Schlich, B.; Kowalewski, S. Model checking C source code for embedded systems. Int. J. Softw. Tools Technol. Transf. 2009, 11, 187–202. [Google Scholar] [CrossRef]
  6. Muchnick, S. Advanced Compiler Design and Implementation; Morgan Kaufmann Publishers Inc.: Burlington, MA, USA, 1997. [Google Scholar]
  7. Aho, A.V.; Sethi, R.; Ullman, J.D. Compilers: Principles, Techniques and Tools, 2 Revised ed of International ed.; Pearson: London, UK, 2006. [Google Scholar]
  8. Schlich, B.; Noll, T.; Brauer, J.; Brutschy, L. Reduction of interrupt handler executions for model checking embedded software. In HVC 2009: Hardware and Software: Verification and Testing; Springer: Berlin/Heidelberg, Germany, 2011; pp. 5–20. [Google Scholar]
  9. Armando, A.; Mantovani, J.; Platania, L. Bounded model checking of software using SMT solvers instead of SAT solvers. Int. J. Softw. Tools Technol. Transf. 2009, 11, 69–83. [Google Scholar] [CrossRef]
  10. Cordeiro, L.; Fischer, B.; Marques-Silva, J. SMT-Based Bounded Model Checking for Embedded ANSI-C Software. IEEE Trans. Softw. Eng. 2012, 38, 957–974. [Google Scholar] [CrossRef] [Green Version]
  11. Takeshita, A.; Kobashi, J.; Yamane, S. Verification of embedded software in assembly code by SMT Solver. In ESS2012; Information Processing Society of Japan: Tokyo, Japan, 2012; pp. 197–202. [Google Scholar]
  12. Kobashi, J.; Yamane, S.; Takeshita, A. Development of SMT-Based Bounded Model Checker for embedded assembly program. In Proceedings of the 2014 IEEE 3rd Global Conference on Consumer Electronics (GCCE), Tokyo, Japan, 7–10 October 2014. [Google Scholar]
  13. Yamane, S.; Konoshita, R.; Kato, T. Model checking of embedded assembly program based on simulation. IEICE Trans. Inf. Syst. 2017, 100, 1819–1826. [Google Scholar] [CrossRef]
  14. Schlich, B.; Brauer, J.; Kowalewski, S. Application of static analyses for state-space reduction to the microcontroller binary code. Sci. Comput. Program 2011, 76, 100–118. [Google Scholar] [CrossRef] [Green Version]
  15. Liang, L.; Melham, T.; Kroening, D.; Schrammel, P.; Tautschnig, M. Effective Verification for Low-Level Software with Competing Interrupts. ACM Trans. Embed. Comput. Syst. 2018, 17, 36:1–36:26. [Google Scholar] [CrossRef] [Green Version]
  16. Burch, J.R.; Clarke, E.M.; McMillan, K.L.; Dill, D.L.; Hwang, L.J. Symbolic Model Checking: 1020 States and Beyond. Inf. Comput. 1992, 98, 142–170. [Google Scholar] [CrossRef] [Green Version]
  17. Biere, A.; Cimatti, A.; Clarke, E.M.; Fujita, M.; Zhu, Y. Symbolic Model Checking Using SAT Procedures instead of BDDs. In Proceedings of the 36th Annual ACM/IEEE Design Automation Conference, New Orleans, LA, USA, 21–25 June 1999; pp. 317–320. [Google Scholar]
  18. Barrett, C.; Sebastiani, R.; Seshia, S.A.; Tinelli, C. Satisfability Modulo Theories. In Handbook of Satisfability; Springer: Cham, Switzerland, 2018; pp. 305–343. [Google Scholar]
  19. Biere, A.; Cimatti, A.; Clarke, E.; Zhu, Y. Symbolic model checking without BDDs. In International Conference on Tools and Algorithms for the Construction and Analysis of Systems; Springer: Berlin/Heidelberg, Germany, 1999; pp. 193–207. [Google Scholar]
  20. Barrett, C.; Stump, A.; Tinelli, C. The SMT-LIB Standard: Version 2.0; SMT-LIB.org; Department of Computer Science, The University of Iowa: Iowa City, IA, USA, 2010. [Google Scholar]
  21. Cok, D.R. The SMT-LIB v2 Language and Tools: A Tutorial. Available online: https://smtlib.github.io/jSMTLIB/SMTLIBTutorial.pdf (accessed on 28 May 2020).
  22. Henzinger, T.A.; Jhala, R.; Majumdar, R.; Sutre, G. Lazy abstraction. In Proceedings of the 29th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, Portland, OR, USA, 16–18 January 2002; pp. 58–70. [Google Scholar]
  23. Beyer, D.; Henzinger, T.A.; Jhala, R.; Majumdar, R. The software model checker Blast. Int. J. Softw. Tools Technol. Transf. 2007, 9, 505–525. [Google Scholar] [CrossRef]
  24. Nadel, A. Handling Bit-Propagating Operations in Bit-Vector Reasoning. In Proceedings of the Workshop on Satisfiability Modulo Theories, Helsinki, Finland, 8–9 July 2013. [Google Scholar]
  25. Browne, M.C.; Clarke, E.M.; Grumberg, O. Characterizing Finite Kripke Structures in Propositional Temporal Logic. Theor. Comput. Sci. 1988, 59, 115–131. [Google Scholar] [CrossRef] [Green Version]
  26. H8/3687 Group Hardware Manual—RS Components International, Renesas. 2005. Available online: https://docs-emea.rs-online.com/webdocs/0862/0900766b80862532.pdf (accessed on 28 May 2020).
  27. H8S, H8/300 Series C/C++ Compiler Package, Renesas. 2010. Available online: https://www.renesas.com/en-us/doc/products/tool/apn/rej05b0464_h8s.pdf (accessed on 28 May 2020).
  28. JFlex—The Fast Scanner Generator for Java. 2015. Available online: http://jflex.de/ (accessed on 28 May 2020).
  29. BYACC/J Java Extension. 2013. Available online: http://byaccj.sourceforge.net/ (accessed on 28 May 2020).
  30. De Moura, L.; Bjørner, N. Z3: An Efficient SMT Solver. In International Conference on Tools and Algorithms for the Construction and Analysis of Systems; Springer: Berlin/Heidelberg, Germany, 2008; pp. 337–340. [Google Scholar]
  31. ZMP Inc. Nuvo R WHEEL. 2010. Available online: https://robot.watch.impress.co.jp/cda/news/2006/07/12/81.html (accessed on 12 October 2019).
  32. Holzmann, G.J. The model checker SPIN. IEEE Trans. Softw. Eng. 1997, 23, 279–295. [Google Scholar] [CrossRef] [Green Version]
Figure 1. Unrolling the system from Control Flow Graph (CFG).
Figure 1. Unrolling the system from Control Flow Graph (CFG).
Electronics 09 01060 g001
Figure 2. State transition of assembly code.
Figure 2. State transition of assembly code.
Electronics 09 01060 g002
Figure 3. M O V A R , E R d .
Figure 3. M O V A R , E R d .
Electronics 09 01060 g003
Figure 4. M O V E R s , A R .
Figure 4. M O V E R s , A R .
Electronics 09 01060 g004
Figure 5. Transition of Assembly Code Block (ACB).
Figure 5. Transition of Assembly Code Block (ACB).
Electronics 09 01060 g005
Figure 6. Usual CFG.
Figure 6. Usual CFG.
Electronics 09 01060 g006
Figure 7. CFG of IHER.
Figure 7. CFG of IHER.
Electronics 09 01060 g007
Figure 8. CFG of ACB.
Figure 8. CFG of ACB.
Electronics 09 01060 g008
Figure 9. Configuration of prototype model checker.
Figure 9. Configuration of prototype model checker.
Electronics 09 01060 g009
Figure 10. Program 1.
Figure 10. Program 1.
Electronics 09 01060 g010
Figure 11. Program 2.
Figure 11. Program 2.
Electronics 09 01060 g011
Figure 12. Verification lines of program 1 for verification time.
Figure 12. Verification lines of program 1 for verification time.
Electronics 09 01060 g012
Figure 13. Verification lines of program 2 for verification time.
Figure 13. Verification lines of program 2 for verification time.
Electronics 09 01060 g013
Figure 14. Comparison of SPIN and proposed Tool.
Figure 14. Comparison of SPIN and proposed Tool.
Electronics 09 01060 g014
Figure 15. Program 3.
Figure 15. Program 3.
Electronics 09 01060 g015
Table 1. Logical formulas of H8/3687 asembly instruction(SMT-LIB2 notation).
Table 1. Logical formulas of H8/3687 asembly instruction(SMT-LIB2 notation).
ItemInstructionOperationFormula
1.MOV.L ERs, ERdERs32 → ERd32 ( E R d p + 1 = E R s p )
2.ADD.W Rs, RdRd16 + Rs16 → Rd16 ( E R d p + 1 = ( c o n c a t ( ( _ e x t r a c t 31 16 ) E R d p )
( b v a d d ( ( _ e x t r a c t 15 0 ) E R d p ) ( ( _ e x t r a c t 15 0 ) E R s p ) ) ) )
3.MOV.B RsL, @ERdRs8 → @ERd ( ( A S p + 1 ( _ e x t r a c t 15 0 ) E R d p ) ) = ( ( _ e x t r a c t 15 0 ) E R s p )
and ( f o r a l l ( ( x ( _ B i t V e c 16 ) ) ) ( ( x = ( _ e x t r a c t 15 0 ) E R d p )
o r ( ( A S p + 1 ) = ( A S p ) ) ) )
Table 2. Environment of verification.
Table 2. Environment of verification.
CPUWindows 7 Professional 64 bit
OSCore i7-3770 CPU @3.40 GHz
Memory16 GB
SMT solverMicrosoft Z3 v4.3.0 [30]
JavaVer. 1.7.0_45
Prototype8400 lines
Table 3. Verification result of program 1.
Table 3. Verification result of program 1.
ModelNodesResultTime (s)k-BoundAssembly [Lines]
IHER10UNSAT3673573536
ACB5UNSAT4075524682
Table 4. Verification result of program 2.
Table 4. Verification result of program 2.
ModelNodesResultTime (s)k-BoundAssembly [Lines]
IHER73UNSAT43,656334485
ACB43UNSAT43,789229704

Share and Cite

MDPI and ACS Style

Yamane, S.; Kobashi, J.; Uemura, K. Verification Method of Safety Properties of Embedded Assembly Program by Combining SMT-Based Bounded Model Checking and Reduction of Interrupt Handler Executions. Electronics 2020, 9, 1060. https://doi.org/10.3390/electronics9071060

AMA Style

Yamane S, Kobashi J, Uemura K. Verification Method of Safety Properties of Embedded Assembly Program by Combining SMT-Based Bounded Model Checking and Reduction of Interrupt Handler Executions. Electronics. 2020; 9(7):1060. https://doi.org/10.3390/electronics9071060

Chicago/Turabian Style

Yamane, Satoshi, Junpei Kobashi, and Kosuke Uemura. 2020. "Verification Method of Safety Properties of Embedded Assembly Program by Combining SMT-Based Bounded Model Checking and Reduction of Interrupt Handler Executions" Electronics 9, no. 7: 1060. https://doi.org/10.3390/electronics9071060

APA Style

Yamane, S., Kobashi, J., & Uemura, K. (2020). Verification Method of Safety Properties of Embedded Assembly Program by Combining SMT-Based Bounded Model Checking and Reduction of Interrupt Handler Executions. Electronics, 9(7), 1060. https://doi.org/10.3390/electronics9071060

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop