CROSS REFERENCE TO RELATED APPLICATION 
       [0001]    This application claims priority under 35 U.S.C. Section 119 to European Patent Application No: EP10157014.1 entitled “Method for checking data consistency in a system on chip” filed Mar. 19, 2010, the contents of which are hereby incorporated by reference herein. 
       FIELD OF THE INVENTION 
       [0002]    The present invention relates to the domain of software protection and security, and more particularly to a system on chip having means for at once rendering software tamper-proof and allowing high secure as well as high performance processing. 
       TECHNICAL BACKGROUND 
       [0003]    In the domain of secure data processing, it is necessary to provide a tamper-resistant environment within which the processing can occur in a secure manner without lowering too much the performance in terms of reliability and efficiency. 
         [0004]    A well known solution used to solve security problems was focused on protecting in a secure manner the hardware device containing the software necessary for the device functioning. The notion of tamper-proof was limited to such hardware which was difficult to open or once opened would destroy the processor and memory chip on which the secure software resided. However, it is generally recognized that software techniques for achieving application security offer more flexibility and lower cost particularly when hardware and software protection are combined. 
         [0005]    A typical system on which application programs run generally comprises processing units, a plurality of peripherals and memories. In most cases where security is required, data is encrypted to be kept secure, i.e. working data or executable processing instructions or code, is encrypted. Encryption is usually done within a security module associated to a user unit such as a pay television set top box, a mobile equipment, a personal computer or any other device requiring security for functioning with payload or sensitive services. The security module can be implemented in a variety of manners such as on a microprocessor card, on a smartcard or any electronic module in the form of a badge or key. These modules are generally portable and detachable from the host user unit and are designed to be tamper-proof. The most commonly used form has electrical contacts, but contactless versions of type ISO 14443 also exist. Another implementation of the security module consists either of a directly soldered integrated circuit inside the user unit or a circuit on a socket or connector such as a SIM (Subscriber Identity Module) module. The security module may also be integrated on a chip which has another function e.g. on a descrambling module or on a microprocessor module of a pay television set top box. The security module can also be implemented as software. 
         [0006]    In spite of the use of security modules and advanced encryption techniques, secure processing systems still represent a significant attraction for attempts at breaching security. Techniques used to bypass security of such systems include, for example, the reverse engineering of the hardware involved or the dynamic or static analysis of software used therein and the subsequent tampering with such software. By static analysis it is meant some form of disassembly or decompilation of non-executing code. By dynamic analysis it is meant analyzing during running of the program, i.e. by observing signals at certain contacts of the chip. Such analysis may lead to tampering whereby the software is modified by, for example, performing a branch-jamming attack wherein an unconditional jump is introduced in place of a conditional jump thus forcing a branch to execute when the current conditions do not prescribe such execution. Typically, such an attack would force a program to bypass an authentication step like serial number or password checking for example. 
         [0007]    High reliability applications provide arrangements where a pair of processors are executing the same program instructions and verify each other conformity of results. If an error is detected, a module for correcting the software error is activated. Some examples are disclosed in following documents: 
         [0008]    U.S. Pat. No. 5,915,082A1 describes a lockstep processor system which has error isolation built into the system and provides, in a large number of instances of detected error, high speed recovery with only small changes to current lockstep processor systems. The lockstep processor system adds error detection, isolation, and recovery logic to one or more lockstep processor system functions; namely, control outputs, processor inputs, busses, memory address busses, and memory data busses. Each processor notifies the other processor if it has detected an error, isolates the failure, and initiates recovery actions. To ensure that the processors are synchronized from a cycle perspective, a common clock source is used to drive both processors. 
         [0009]    U.S. Pat. No. 6,604,177B1 discloses a processing system including a pair of processor coupled in a lockstep arrangement. The pair of processors is coupled to a storage element that is external to the both of them. Each processor executes an instruction stream that is identical to that executed by the other. Dissimilar information can be exchanged between the processors by each writing the information they wish to exchange to a first storage location with identical instructions. Although both processors execute the write with the same address, the information written by one of the processors is redirected to a second storage location. Each processor then reads the first and second storage locations to retrieve information supplied by the other processor. Now each processor has a copy of the other&#39;s data while staying in lockstep. 
         [0010]    WO2004/061666 describes a processor having first and second execution cores that operate in a redundant (FRC) mode, an FRC check unit to compare results from the first and second execution cores, and an error check unit to detect recoverable errors in the first and second cores. The error detector disables the FRC checker, responsive to detection of a recoverable error. If an error reaches error detector from either core, recovery module is activated to implement a recovery routine. Recovery can be implemented with relatively low latency by hardware, software, firmware or some combination of these. 
         [0011]    US2004/0186979A1, discloses a processor, having a first calculating unit, a second calculating unit and a control means for controlling the two calculating units such that they operate selectively in a high-security mode of operation processing complementary data or in a parallel mode of operation processing independent data or in a security mode of operation processing the same data, or that they are in a power-saving mode of operation, wherein one of the calculating units is switched off. 
         [0012]    U.S. Pat. No. 6,615,366B1 describes a processor having dual execution cores that may be switched dynamically between operating in a high reliability mode and a high Performance mode. The execution cores process identical instructions in lock step, when the processor is operated in a high reliability mode. The execution cores may process different instructions when the processor is operated in a high performance mode. The processor may be switched dynamically between the high performance (HP) and high reliability (HR) modes. For one embodiment, the processor is switched between HP and HR modes under software control. Each execution core enters a ready state when it executes an HP-to-HR mode switch Instruction (S HR), and the processor switches from HP to HR mode when both execution cores have entered the ready state. For another embodiment, the processor includes a check unit that is activated in HR mode and deactivated in HP mode. The check unit compares the execution results generated by the first and second execution cores when it is activated, and signals an error when the execution results do not match. When an error is signaled, the processor may replay only the instructions that triggered the error and the issued operations that depend on it. 
         [0013]    U.S. Pat. No. 6,199,171 B1 discloses a method and implementing system for handling detected faults in a processor to improve reliability of a computer system. An exemplary fault-tolerant on-line transactional computer system includes first and second on-line transactional processors connected to an input/output processor through a system bus. Transaction results are stored in local processor buffers and at predetermined batch intervals, the stored transactions are compared. The matched transaction results are flushed to data store while unmatched transactions are re-executed. If the same errors do not occur during a re-execution, the errors are determined to be transient and the transaction results are flushed to storage. 
         [0014]    U.S. Pat. No. 6,839,849B1 discloses a smart integrated circuit characterized by a main processor and an operating system executing a main program for constituting a main task-performing process, at least one secondary processor capable of concurrently executing at least one secondary program for constituting at least one task-performing process, power supply circuits common to the processors and means for ensuring that the secondary processor or processors with similar power and different operating signatures are executed concurrently with the main process by continuously or intermittently inducing, in the power supply circuits, power disturbances that are superimposed on those of the main process so as to produce a continuous or intermittent scrambling. 
         [0015]    The above mentioned systems and methods are rather focused on high reliability and high performances than on high security involving software tamper proof features. 
       SUMMARY OF THE INVENTION 
       [0016]    The invention aims to provide a method and a system on chip able to detect at once hardware and software errors to prevent manipulations for retrieving cryptographic keys, inserting, suppressing or modifying instructions to bypass security processes, modifying memory content etc. The system on chip ensures thus high performance and high security data processing. If an error is detected, the process is preferably stopped or interrupted rather than the error is corrected and the current process continues. 
         [0017]    These aims are achieved by a method for checking data consistency in a system on chip comprising a core including at least two processors, registers, and a data consistency check module linking the two processors, the core being connected to at least one set of memories containing zones for instructions of a first program and zones for instructions of a second program, each program accessing to data, said instructions being to be executed respectively by the first and second processor, which respectively produce and store result data into the registers and the memories, the method comprising steps of:
       executing at least one instruction of the first program by the first processor, producing first result data,   executing at least one instruction of the second program by the second processor, producing second result data distinct from the first result data,   applying, by the data consistency check module, a predetermined function either over the first result data or the second result data to obtain a test result,   comparing by the data consistency check module, the test result previously obtained either with the corresponding second result data or first result data,   continuing execution of instructions of each program by respectively the first and second processor when the comparison between a test result and the corresponding result data is successful,   stopping execution of instructions of each program by respectively the first and second processor when the comparison shows an error.       
 
         [0024]    A further object of the invention is a system on chip comprising a core including at least two processors, registers, and a data consistency check module linking the two processors, the core being connected to at least one set of memories containing zones for instructions of a first program and zones for instructions of a second program, each program accessing to data, said instructions being to be executed respectively by the first and second processor, which respectively produce and store result data into the registers and the memories, the system on chip is characterized in that:
       the first processor is configured to execute at least one instruction of the first program and to produce first result data,   the second processor is configured to execute at least one instruction of the second program and to produce second result data distinct from the first result data,   the data consistency check module is configured to obtain a test result by applying a predetermined function either over the first result data or the second result data, to compare said test result either with the corresponding second result data or first result data,   the data consistency check module comprises means for continuing execution of instructions of each program by respectively the first and second processor when the comparison is successful, and stopping execution of instructions of each program by respectively the first and second processor when the comparison shows an error.       
 
         [0029]    According to the method and the features of the system on chip of the invention, the data consistency check module preferably stops the execution of the program by the processors when the result of the comparison between the result data shows an error. In this case, the first result data is different from the second result data i.e. the result data are not related by the predetermined function and therefore not usable by the programs of either the first or second processor. The errors are preferably logged in a register of either the first processor or the second processor which may generate an interrupt signal stopping the current process or resetting the processors. In an embodiment, a minimum number of errors could be tolerated by the system before program execution is stopped. 
     
    
     
       BRIEF DESCRIPTION OF THE FIGURES 
         [0030]    The invention will be better understood with the following detailed description, which refers to the attached figures given as non-limitative examples. 
           [0031]      FIG. 1  shows a general block diagram of a core of a system on chip comprising two processors with a data consistency check module linking the two processors. The core is connected to memories containing a first and a second program executed respectively by the first and second processor. 
           [0032]      FIG. 2  shows a block diagram showing instructions of a first program and instructions of a second program respectively executed by the first and second processor, and producing result data related by a predetermined function. 
           [0033]      FIG. 3  shows a block diagram of an embodiment where the memory or registers addresses of the second result data are related to the first result data by a function carried out by a mapping module. 
       
    
    
     DETAILED DESCRIPTION OF THE INVENTION 
       [0034]    The block diagram of  FIG. 1  illustrates a core (CO) of an example of a system on chip SoC connected to a set of memories (M) generally integrated in the system on chip SoC. The core (CO) comprises at least two processors (CPU 1 , CPU 2 ) each associated to a cache memory (C 1 , C 2 ) and registers (RG 1 , RG 2 ) which stores result or status data of the processor (CPU 1 , CPU 2 ). A consistency check module (CCM) links together the two processors (CPU 1 , CPU 2 ) and their associated registers (RG 1 , RG 2 ) and cache memories (C 1 , C 2 ). This module (CCM) checks consistency of various data and parameters produced during execution of program (P 1 , P 2 ) instructions by the processors (CPU 1 , CPU 2 ). 
         [0035]    The memories (M) which may form separated sets (M 1 , M 2 ) connected to each processor (CPU 1 , CPU 2 ) or a common set connected to both processors (CPU 1 , CPU 2 ) according to the implementation of the system on chip in a device include zones for program (P 1 , P 2 ) instructions and zones for data (D 1 , D 2 ). The data (D 1 , D 2 ) may be either common to both programs (P 1 , P 2 ) or each program (P 1 , P 2 ) accesses to its own data set D 1  or D 2 . 
         [0036]    The term instruction designates the most rudimentary commands executable by a processor. A program or set of instructions is the list of all the basic commands written in machine language. An instruction usually comprises a statement and variables or parameters used to carry out calculations, move or jump from a memory or register address to another, query data from a database, store data at an address of memory or register, test on variables values, declare and set values intervening in various operations executed by the statement, etc. The variables may take values retrieved from program data set D 1  or D 2 , or from results obtained by operations carried out with preceding instructions. They may also consist of status variables taken from registers, values provided by external devices or peripherals via a bus connected to the system on chip SoC, as well as addresses of memories or registers where to store or retrieve data. 
         [0037]    The data consistency check module (CCM) performs tests to determine if the data submitted by the processors (CPU 1 , CPU 2 ) are correct i.e. data produced at execution of the program instructions satisfy predefined comparison criteria or pass tests such as CRC (Cyclic Redundancy Check), parity bit check or other error detecting processes. 
         [0038]    In an exemplary secure functioning mode, the first processor (CPU 1 ) runs a first program P 1  including instructions (IN 11  . . . IN 1   n ) retrieved from the memory M 1 . It accesses also to data D 1  and produces first result data (R 11  . . . R 1   n ) all stored in further memory zones of the memory set M 1  or in the registers (RG 1 , RG 2 ). 
         [0039]    As the first processor (CPU 1 ), the second processor (CPU 2 ) runs a second program P 2  including instructions (IN 21  . . . IN 2   n ) by accessing data D 2  and produces second result data (R 21  . . . R 2   n ). The execution of the program instructions is preferably carried out in a synchronous mode i.e. when the first processor CPU 1  executes an instruction of the program P 1 , the second processor CPU 2  executes in parallel an instruction of the program P 2  as illustrated by arrows in  FIG. 2 . 
         [0040]    In a preferred embodiment, the data consistency check module CCM calculates a test result F(R 1   n ) or F(R 2   n ) by applying the function F either over the first result data R 1   n  produced by the execution of the first program instructions IN 1   n  or over the second result data R 2   n  produced by the execution of the second program instructions IN 2   n . This test result F(R 1   n ) or F(R 2   n ) thus obtained is compared with the corresponding second or first result data R 2   n  or R 1   n . If a match is found i.e. the comparison is successful, the programs instructions execution continues. Otherwise, if an error is detected by a difference between the calculated test result F(R 1   n ) or F(R 2   n ) and the corresponding result data R 2   n  or R 1   n , the first or the second program P 1 , P 2  execution is stopped. 
         [0041]    This error is preferably recorded in a register (RG 1 , RG 2 ) either of the first processor (CPU 1 ) or the second processor (CPU 2 ) for accounting and/or status history purposes. In case of an error, the processors may also be reset and the registers emptied. 
         [0042]    According to an embodiment, a certain number of errors can be cumulated until a predefined threshold of a maximum number of errors beyond which either the first processor (CPU 1 ) or the second processor (CPU 2 ) stops program execution. This threshold may be stored in a register (RG 1 , RG 2 ) and depends on the severity of the security attributed to the programs (P 1 , P 2 ) and to their result data (R 11  . . . R 1   n ), (R 21  . . . R 2   n ). 
         [0043]    In an example, the first and the second program P 1 , P 2  include instructions which statements and variables are specific to the type of processor, but producing result data R 1   n , R 2   n  so that the first and second result data are related by a function F such as for example R 2   n =F(R 1   n ) or R 1   n =F(R 2   n ). The function F may represent an XOR operation, a logical inversion operation or any other logical operation made on a result data to obtain the corresponding result data. Any other mathematical function or cryptographic function can also be envisaged as relation between the result data R 1   n , R 2   n.    
         [0044]    The result data thus produced and stored in registers or memories of the system on chip are systematically verified by the data consistency check module CCM. The verified result data consist as well of intermediate results obtained when an instruction is executed as of status or signaling data indicating how further instructions have to be executed. 
         [0045]    Several further configurations may be possible for the structure of the respective instructions IN 1   n  or IN 2   n  of the program P 1  or P 2  executed by the processors (CPU 1 , CPU 2 ), namely:
       The first and the second program P 1 , P 2  include instructions IN 1   n , IN 2   n  with the same statements but using different variables. The data consistency check module (CCM) verifies the result data by referring to the relations between the variables used by the first and second program instructions IN 1   n , IN 2   n.      The first and the second program include instructions which statements are specific to the type of processor, but using the same variables. The data consistency check module (CCM) verifies the result data by referring to the relations between the statements and variables used by the first and second program instructions.       
 
         [0048]    For example the first program P 1  includes instructions IN 1   n  with opposite statements relative to the statements of the instructions IN 2   n  of the second program P 2 . Statements as additions in the first program instructions IN 1   n  become subtractions in the instructions IN 2   n  of the second program P 2 , the corresponding variables having an opposite signs. The result data R 1   n , R 2   n  thus obtained by execution of program P 1  respectively P 2  are similar except for the sign. The verification made by the data consistency check module (CCM) may then be based on the equivalency of the absolute value alone or on the conformity of the value with sign of the result data R 1   n , R 2   n  obtained by each program instructions IN 1   n , IN 2   n.    
         [0049]    In another example, the binary code of the instructions IN 1   n  of first program P 1  may be inverted relatively to the binary code of the instructions IN 2   n  of the second program P 2 . The binary code of the result data R 1   n , R 2   n  produced by each instruction IN 1   n , IN 2   n  will be also inverted and checked, according to this criterion, by the data consistency check module (CCM). 
         [0050]    The data consistency check module (CCM) is preferably activated or deactivated thanks to specific instructions included in the first or second program (P 1 , P 2 ) executed by the first respectively the second processor (CPU 1 , CPU 2 ). When activated, the data consistency check module (CCM) determines a mode of synchronized functioning of the first and second processors (CPU 1 , CPU 2 ) or secure mode while the deactivated data consistency check module (CCM) determines a mode of independent functioning of said first and second processors (CPU 1 , CPU 2 ) or high performance mode. 
         [0051]    According to an embodiment, an automatic verification procedure may be performed at each result data R 1   n , R 2   n  produced by the program instructions IN 1   n , IN 2   n  either one by one as shown in  FIG. 2  or by batches. In this case a set of instructions (batch) is executed by each processor (CPU 1 , CPU 2 ) and the result data R 1   n , R 2   n  produced by the set of instructions is verified by the data consistency check module (CCM). 
         [0052]    According to an embodiment illustrated by  FIG. 3 , the result data (R 11  . . . R 1   n ) and (R 21  . . . R 2   n ) produced by the instructions of either the first program P 1  or second program P 2  are stored in memory and registers M 2  at addresses defined by a mapping module Mmap linking respectively memory and registers M 1 , RG 1 , M 2 , RG 2  used by the first and second processor (CPU 1 , CPU 2 ). This module Mmap may be a software and/or hardware memory management module including a correspondence table or a function G relating the addresses (A 1 , . . . An) of the first result data (R 11 , . . . R 1   n ) to the addresses (G(A 1 ), . . . , G(An)) of the second result data (R 21 , . . . R 2   n ). 
         [0053]    For example, the result data R 2   n  produced by the instructions IN 2   n  of the second program P 2  executed by the second processor CPU 2  are stored at memory or register addresses defined by a predetermined mapping applied on each memory or register address where are stored the corresponding result data R 1   n  produced by the instructions IN 1   n  of the first program P 1  executed by the first processor CPU 1 . 
         [0054]    The mapping may define a predetermined shift SH between the memory or registers addresses where are stored the result data R 1   n  and R 2   n . R 1   n  is stored at address An while R 2   n  is stored at address An+SH, the shift SH being for example constant for all addresses storing result data (R 11  . . . R 1   n ) and (R 21  . . . R 2   n ). In a further embodiment the shift may be different for the registers addresses and the memory addresses. 
         [0055]    The mapping could also consist of a predetermined function G carried out on each address (A 1  . . . An) where are stored the result data (R 11  . . . R 1   n ) produced by the instructions (IN 1 , . . . , IN 1   n ) of the first program P 1  to obtain the addresses (G(A 1 ) . . . G(An)) where are stored the result data (R 21  . . . R 2   n ) produced by the instructions (IN 2 , . . . , IN 2   n ) of the second program P 2 . As in the previous example of a shift SH between the addresses, the function G could be different for the registers addresses and the memory addresses.  FIG. 3  illustrates an implementation where the memory or registers addresses of the second result data are related to the first result data by a function G carried out by the mapping module Mmap. 
         [0056]    In a similar way than the function F relating the result data, the function G may represent XOR operation, an inversion operation or any other logical operation made on a memory or register address to obtain the corresponding address. Any other mathematical function or cryptographic function can also be envisaged as relation between the memory addresses. 
         [0057]    In the embodiments including the mapping of the result data (R 11  . . . R 1   n ) and (R 21  . . . R 2   n ) memory or registers addresses (A 1 , . . . An), (G(A 1 ), . . . G(An)), the data consistency check module CCM determines the address of the result data with the memory mapping module Mmap in order to localize the suitable result data to verify. These steps are thus carried out before obtaining by the data consistency check module (CCM), a test result F(R 1   n ) or F(R 2   n ) by applying the predetermined function F either over the first result data R 1   n  or the second result data R 2   n.    
         [0058]    The invention also concerns a system on chip (SoC) comprising a core (CO) including at least two processors (CPU 1 , CPU 2 ), registers (RG 1 , RG 2 ), and a data consistency check module (CCM) linking the two processors (CPU 1 , CPU 2 ), the core (CO) being connected to at least one set of memories (M) containing zones for instructions of a first program (P 1 ) and data (D 1 ) and zones for instructions of a second program (P 2 ) and data (D 2 ), said instructions being to be executed respectively by the first and second processor (CPU 1 , CPU 2 ), which respectively produce and store result data (R 1   n , R 2   n ) into the registers (RG 1 , RG 2 ) and the memories (M). The system on chip foreseen to operate in a high security and/or in a high performance mode is configured in such a way to be able to carry out the above described steps of the method including all or parts of the different embodiments or options.
The invention aims to provide a method and a system on chip able to detect at once hardware and software errors to prevent manipulations for retrieving cryptographic keys, inserting or suppressing instructions to bypass security processes, modifying programs or memory content etc. The system on chip comprises a core including at least two processors, registers, and a data consistency check module. The core is connected to at least one set of memories containing zones for instructions of a first program and of a second program, said instructions being to be executed respectively by the first and second processor, which respectively produce and store result data into the registers and the memories. The data consistency check module is configured to verify conformity of the produced result data by comparing a test result obtained by carrying out a predetermined function F over one of the first or second result data with the corresponding second or first result data and to continue execution of instructions of each program when the comparison is successful, or stop execution when the comparison shows an error.