JP2004280801A - Processor and compiler apparatus for generating program for the processor - Google Patents

Processor and compiler apparatus for generating program for the processor Download PDF

Info

Publication number
JP2004280801A
JP2004280801A JP2004048531A JP2004048531A JP2004280801A JP 2004280801 A JP2004280801 A JP 2004280801A JP 2004048531 A JP2004048531 A JP 2004048531A JP 2004048531 A JP2004048531 A JP 2004048531A JP 2004280801 A JP2004280801 A JP 2004280801A
Authority
JP
Japan
Prior art keywords
branch
instruction
operation mode
program
illegal
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Withdrawn
Application number
JP2004048531A
Other languages
Japanese (ja)
Inventor
Shinichiro Fukai
慎一郎 深井
Toshiya Kai
俊也 甲斐
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Panasonic Holdings Corp
Original Assignee
Matsushita Electric Industrial Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Matsushita Electric Industrial Co Ltd filed Critical Matsushita Electric Industrial Co Ltd
Priority to JP2004048531A priority Critical patent/JP2004280801A/en
Publication of JP2004280801A publication Critical patent/JP2004280801A/en
Withdrawn legal-status Critical Current

Links

Images

Landscapes

  • Storage Device Security (AREA)
  • Executing Machine-Instructions (AREA)

Abstract

<P>PROBLEM TO BE SOLVED: To provide a processor for preventing unauthorized execution of an authorized program by a user program to secure security and improving the realtime property in the case of authorized branching from the user program to the authorized program. <P>SOLUTION: In a processor provided with a CPU 401 and a flash memory 404 for storing a program, when a branch instruction for changing an operation mode to a different operation mode is executed by the program stored in the flash memory 404, an unauthorized branching detection circuit 409 judges whether a branch permission instruction exists in a branch destination address, and when the branch permission instruction does not exist, an unauthorized branching detection signal is output to prevent unauthorized execution of the authorized program by the user program. <P>COPYRIGHT: (C)2005,JPO&NCIPI

Description

本発明は、命令メモリに対して外部からプログラムを追加できるプロセッサにおける命令実行保護に関するものである。   The present invention relates to instruction execution protection in a processor that can externally add a program to an instruction memory.

通常、プロセッサは、命令メモリに格納されたプログラムに従って、データ処理、演算処理などの各種処理を実行する。   Generally, a processor executes various processes such as data processing and arithmetic processing in accordance with a program stored in an instruction memory.

以上のような従来のプロセッサについて、図面を参考にしながら以下に説明する。   The conventional processor as described above will be described below with reference to the drawings.

図6は、従来の技術によって開発されたプロセッサを用いたICカードシステムを表すブロック図である。   FIG. 6 is a block diagram showing an IC card system using a processor developed by a conventional technique.

従来の技術によって開発されたプロセッサを用いたICカードシステムは、図6に示すように、CPU101と、命令ROM102と、RAM103と、フラッシュメモリ104と、外部I/F105と、アンテナコイル106と、アドレスバス107aと、データバス107dと、割り込み制御回路108と、分岐許可アドレス判定回路109によって構成される。   As shown in FIG. 6, an IC card system using a processor developed by a conventional technique includes a CPU 101, an instruction ROM 102, a RAM 103, a flash memory 104, an external I / F 105, an antenna coil 106, an address It comprises a bus 107a, a data bus 107d, an interrupt control circuit 108, and a branch permission address determination circuit 109.

CPU101は、命令フェッチ部1011と、命令解読部1012と、命令実行部1013と、プログラムカウンタ1014と、メモリアクセス制御回路1015とによって構成される。   The CPU 101 includes an instruction fetch unit 1011, an instruction decoding unit 1012, an instruction execution unit 1013, a program counter 1014, and a memory access control circuit 1015.

CPU101は、命令ROM102またはフラッシュメモリ104に格納された命令を読み出し実行していく。フラッシュメモリ104に対しては、アンテナコイル106および外部I/F105を介して、外部からプログラムデータを追加することが可能である。   The CPU 101 reads and executes the instructions stored in the instruction ROM 102 or the flash memory 104. Program data can be externally added to the flash memory 104 via the antenna coil 106 and the external I / F 105.

図7は、従来の技術によって開発されたプロセッサを用いたメモリ空間の領域区分の概念図である。   FIG. 7 is a conceptual diagram of an area division of a memory space using a processor developed by a conventional technique.

図7において、200は全論理アドレス空間を表す。全論理アドレス空間200は、外部I/F105、命令ROM102、RAM103、および、フラッシュメモリ104に割り当てられている。全論理アドレス空間200のうち、命令ROM空間は特権領域211とAPI領域212に、RAM領域は特権領域221とAPI領域222とユーザ領域223に、フラッシュメモリはユーザ領域231に、外部I/Fはユーザ領域241に、それぞれ区分されている。   In FIG. 7, reference numeral 200 denotes the entire logical address space. The entire logical address space 200 is allocated to the external I / F 105, the instruction ROM 102, the RAM 103, and the flash memory 104. Of the total logical address space 200, the instruction ROM space is in the privileged area 211 and the API area 212, the RAM area is in the privileged area 221 and the API area 222 and the user area 223, the flash memory is in the user area 231, and the external I / F is Each is divided into a user area 241.

図8は、従来の技術によって開発されたプロセッサ用のプログラム概念図である。図8において、ユーザプログラム302における命令群3021は、ユーザプログラム302から特権プログラム301(命令群3011)への実行の移行を行うための処理を記述したものであり、ユーザプログラム302における命令群3022は、ユーザプログラム302から特権プログラム301(命令群3012)への実行の移行を行うための処理を記述したものである。特権プログラム301における命令群3011は、その処理内容の詳細な図示は省略してあるが、ユーザプログラム302から命令群3012または命令群3013への実行の移行を行うための処理を記述したものである。   FIG. 8 is a conceptual diagram of a program for a processor developed by a conventional technique. In FIG. 8, an instruction group 3021 in the user program 302 describes a process for shifting execution from the user program 302 to the privileged program 301 (instruction group 3011). Describes a process for shifting execution from the user program 302 to the privileged program 301 (instruction group 3012). The instruction group 3011 in the privileged program 301, which is not illustrated in detail, describes processing for shifting execution from the user program 302 to the instruction group 3012 or the instruction group 3013. .

従来の技術によって開発された上記ICカードシステムにおいては、ユーザプログラムによって特権プログラムおよびAPIプログラムが不正に実行されることを防ぎ、セキュリティを確保するために、動作モードの移行を伴う分岐が発生した場合は、以下に示す方法がとられる(例えば特許文献1を参照。)。   In the above-described IC card system developed by the conventional technology, in order to prevent a privileged program and an API program from being illegally executed by a user program and to ensure security, when a branch accompanied by an operation mode transition occurs. The following method is used (see, for example, Patent Document 1).

第一に、ユーザプログラム上で実行を希望する特権プログラムまたはAPIプログラムが格納されているアドレスを、演算用レジスタに設定する。第二に、分岐許可アドレス判定回路109によって定められた特定の分岐許可アドレスに対して分岐命令を実行する。第三に、分岐許可アドレス上に格納されている条件判定プログラムによって、演算用レジスタに設定されたアドレスの正当性が判定され、正当であれば、ユーザプログラムが実行を希望する特権プログラムまたはAPIプログラムが格納されているアドレスに対し、再度分岐命令が実行される。   First, an address at which a privileged program or an API program desired to be executed on a user program is stored is set in an arithmetic register. Second, a branch instruction is executed for a specific branch permission address determined by the branch permission address determination circuit 109. Third, the validity of the address set in the operation register is determined by the condition determination program stored on the branch permission address. If the address is valid, the privileged program or API program that the user program desires to execute is determined. Is executed again at the address where is stored.

また、ユーザプログラムから、分岐許可アドレス判定回路109に定められていない特権プログラムまたはAPIプログラム中のアドレスに対して分岐命令を実行した場合は、分岐許可アドレス判定回路109によって割り込み要求が出力されるため、セキュリティが確保される。
特開2002−182931号公報
Further, when a branch instruction is executed from a user program to an address in a privileged program or an API program not defined in the branch permission address determination circuit 109, an interrupt request is output by the branch permission address determination circuit 109. , Security is ensured.
JP-A-2002-182931

しかしながら、上記のようなプロセッサを用いたICカードシステムにおいては、ユーザプログラムから特権プログラムに実行が移行する際に条件判定プログラムの実行が発生するため、リアルタイム性が低下するという問題がある。   However, in the IC card system using the processor as described above, the execution of the condition determination program occurs when the execution shifts from the user program to the privileged program.

本発明は、上記従来の問題点を解決するためのものであり、例えばユーザプログラムから特権プログラムへ実行が移行する際のセキュリティを確保しつつ、リアルタイム性向上が可能なプロセッサを提供することを目的とする。   An object of the present invention is to solve the above-mentioned conventional problems, and an object of the present invention is to provide a processor capable of improving real-time performance while ensuring security when execution shifts from a user program to a privileged program. And

上記の目的を達成するために、本発明のプロセッサは、CPUと、プログラムを格納するための命令メモリと、前記命令メモリに格納されているプログラムによって、動作モードを異なる動作モードへ変更する分岐命令が実行された際、分岐先アドレスに分岐許可命令が存在するか否かを判断し、前記分岐許可命令が存在する場合は動作モードの変更を許可する一方、前記分岐許可命令が存在しない場合は不正分岐検出信号を出力する不正分岐検出部とを備えたことを特徴とする。   In order to achieve the above object, a processor according to the present invention comprises a CPU, an instruction memory for storing a program, and a branch instruction for changing an operation mode to a different operation mode depending on a program stored in the instruction memory. Is executed, it is determined whether or not a branch permission instruction is present at the branch destination address.If the branch permission instruction is present, the operation mode change is permitted. An illegal branch detection unit that outputs an illegal branch detection signal.

上述の構成にかかる本発明のプロセッサに関して、動作モードの変更とは、例えば、ある動作モードから、当該動作モードよりも高い権限を必要とする動作モードへの変更を言う。   In the processor according to the present invention having the above-described configuration, the change in the operation mode refers to, for example, a change from a certain operation mode to an operation mode requiring higher authority than the operation mode.

上記の構成を備えたことにより、本発明のプロセッサは、ユーザプログラムから例えば特権プログラムまたはAPIプログラム中のアドレスに対して分岐命令が実行された際、分岐先アドレス上に分岐許可命令が格納されていない場合は不正分岐検出部が不正分岐検出信号を出力するため、ユーザプログラムによって特権プログラム等が不正に実行されることを防ぎ、セキュリティを確保できる。またユーザプログラム上から、特権プログラムまたはAPIプログラムを正当に実行する際、ユーザプログラム上で実行を希望する特権プログラムまたはAPIプログラムが格納されているアドレスに対して、分岐命令を直接実行することができるため、動作モードの移行に伴う処理時間が削減され、リアルタイム性が向上する。   With the above configuration, when the processor of the present invention executes the branch instruction from the user program to, for example, the address in the privileged program or the API program, the branch permission instruction is stored on the branch destination address. If not, the illegal branch detection unit outputs an illegal branch detection signal, so that a privileged program or the like can be prevented from being illegally executed by the user program, and security can be ensured. When a privileged program or an API program is properly executed from a user program, a branch instruction can be directly executed at an address where the privileged program or the API program desired to be executed on the user program is stored. Therefore, the processing time associated with the transition of the operation mode is reduced, and the real-time property is improved.

本発明のプロセッサは、前記CPUが実行している命令のプログラムカウンタの値によって実行領域を判定する実行領域判定部と、前記実行領域判定部の判定結果によって、実行中の動作モードを決定する実行動作モード決定部と、前記命令メモリに格納されているプログラムによって分岐命令が実行された際、分岐先アドレスの値によって分岐先領域を判定する分岐先領域判定部と、前記分岐先領域判定部の判定結果によって、前記分岐命令による移行先の動作モードを決定する分岐先動作モード決定部と、前記実行動作モード決定部によって決定された実行動作モードと、前記分岐先動作モードによって決定された移行先動作モードとを比較することによって動作モードが変更されたか否かを検出する動作モード変更検出部とをさらに備え、前記不正分岐検出部が、前記命令メモリに格納されているプログラムによって分岐命令が実行された際、分岐先アドレスに分岐許可命令が存在しない場合は、前記動作モード変更検出部によって動作モードの変更が検出されたことを条件として前記不正分岐検出信号を出力することが好ましい。   The processor according to the present invention includes: an execution region determining unit that determines an execution region based on a value of a program counter of an instruction executed by the CPU; and an execution unit that determines an operation mode being executed based on a determination result of the execution region determination unit. An operation mode determining unit, a branch destination region determining unit that determines a branch destination region based on a value of a branch destination address when a branch instruction is executed by a program stored in the instruction memory, and a branch destination region determining unit. A branch destination operation mode determining unit that determines an operation mode of a transfer destination by the branch instruction according to the determination result; an execution operation mode determined by the execution operation mode determination unit; and a transfer destination determined by the branch destination operation mode An operation mode change detection unit that detects whether the operation mode has been changed by comparing the operation mode with the operation mode; When the illegal branch detection unit executes the branch instruction by the program stored in the instruction memory, and there is no branch enable instruction at the branch destination address, the operation mode change detection unit changes the operation mode. It is preferable to output the illegal branch detection signal on the condition that the signal is detected.

前記の構成において、分岐許可命令には、他の命令と重複しない特定の命令コードを割り当てることが好ましい。これにより、他の命令を処理するための資源に影響を与えることがなく、リアルタイム性を向上させることができる。   In the above configuration, it is preferable that a specific instruction code that does not overlap with other instructions is assigned to the branch permission instruction. Thereby, the real-time property can be improved without affecting resources for processing other instructions.

また、本発明のプロセッサは、前記不正分岐検出部が、前記命令メモリに格納されているプログラムによって分岐命令が実行された際、分岐先アドレスに分岐許可命令が存在しない場合は、前記動作モード変更検出部によって動作モードの変更が検出され、かつ、前記動作モード変更検出部によって検出された動作モードの変更と分岐許可命令が指定する動作モードの変更とが一致しないことを条件として、不正分岐検出信号を出力することがさらに好ましい。また、この構成において、前記分岐許可命令には、1つまたは複数の他の命令に対応する命令コードを重複して割り当てることが好ましい。あるいは、分岐許可命令が検出された際、当該命令コードを他の命令に対応する命令コードに変換する分岐許可命令コード変換部をさらに備えた構成とすることも好ましい。   Further, in the processor according to the present invention, when the illegal branch detection unit executes a branch instruction according to a program stored in the instruction memory, if there is no branch enable instruction at a branch destination address, the operation mode change is performed. Illegal branch detection is performed on condition that a change in the operation mode is detected by the detection unit and that the change in the operation mode detected by the operation mode change detection unit does not match the change in the operation mode specified by the branch permission instruction. More preferably, a signal is output. In this configuration, it is preferable that an instruction code corresponding to one or a plurality of other instructions is assigned to the branch permission instruction in an overlapping manner. Alternatively, it is preferable that the apparatus further includes a branch permission instruction code conversion unit that converts the instruction code into an instruction code corresponding to another instruction when the branch permission instruction is detected.

また、本発明のプロセッサは、前記不正分岐検出部より前記不正分岐検出信号が出力されたことを検知すると、前記CPUに対して割り込み要求を出力する割り込み出力部をさらに備えた構成とすることが好ましい。   The processor of the present invention may further include an interrupt output unit that outputs an interrupt request to the CPU when detecting that the illegal branch detection signal is output from the illegal branch detection unit. preferable.

あるいは、本発明のプロセッサは、前記不正分岐検出部より前記不正分岐検出信号が出力されたことを検知すると、前記CPUに対してリセット信号を出力するリセット出力部をさらに備えた構成としても良い。   Alternatively, the processor of the present invention may further include a reset output unit that outputs a reset signal to the CPU when detecting that the illegal branch detection signal is output from the illegal branch detection unit.

また、本発明のプロセッサは、前記不正分岐検出部より前記不正分岐検出信号が出力されたことを検知すると、分岐先アドレスの命令を未定義命令に置き換える命令変換部をさらに備えた構成としても良い。   Further, the processor of the present invention may further include an instruction conversion unit that replaces an instruction at a branch destination address with an undefined instruction when detecting that the illegal branch detection signal is output from the illegal branch detection unit. .

また、上記の目的を達成するために、本発明にかかるコンパイラ装置は、上述のいずれかの構成にかかるプロセッサ用のプログラムを生成するコンパイラ装置であって、ソースプログラムをコンパイルしアセンブラに変換する際に、ソースプログラム内の関数構造と動作モードとを判定することにより、特権領域のプログラムの所定位置に前記分岐許可命令を挿入することを特徴とする。   In order to achieve the above object, a compiler device according to the present invention is a compiler device that generates a program for a processor according to any one of the configurations described above, and is used when compiling a source program and converting it into an assembler. The branch permission instruction is inserted at a predetermined position of the program in the privileged area by determining a function structure and an operation mode in the source program.

以下、本発明のプロセッサおよびコンパイラ装置の具体例について、図面を参照しながら説明する。   Hereinafter, specific examples of the processor and the compiler device of the present invention will be described with reference to the drawings.

(実施の形態1)
本発明のプロセッサの一実施形態について、図1を参照しながら説明する。
(Embodiment 1)
One embodiment of the processor of the present invention will be described with reference to FIG.

図1は、本実施形態のプロセッサ400を用いたICカードシステムを表すブロック図である。   FIG. 1 is a block diagram illustrating an IC card system using the processor 400 of the present embodiment.

本実施形態のプロセッサ400を用いたICカードシステムは、図1に示すように、CPU401と、命令ROM402と、RAM403と、フラッシュメモリ404と、外部I/F405と、アンテナコイル406と、アドレスバス407aと、データバス407dと、割り込み制御回路408と、不正分岐検出回路409と、実行領域判定回路410と、実行動作モード決定回路411と、分岐先領域判定回路412と、分岐先動作モード決定回路413と、動作モード変更検出回路414とによって構成される。   As shown in FIG. 1, the IC card system using the processor 400 according to the present embodiment includes a CPU 401, a command ROM 402, a RAM 403, a flash memory 404, an external I / F 405, an antenna coil 406, an address bus 407a. , A data bus 407d, an interrupt control circuit 408, an illegal branch detection circuit 409, an execution region determination circuit 410, an execution operation mode determination circuit 411, a branch destination region determination circuit 412, and a branch destination operation mode determination circuit 413. And an operation mode change detection circuit 414.

更に、CPU401は、命令フェッチ部4011と、命令解読部4012と、命令実行部4013と、プログラムカウンタ4014と、メモリアクセス制御回路4015とによって構成される。   Further, the CPU 401 includes an instruction fetch unit 4011, an instruction decoding unit 4012, an instruction execution unit 4013, a program counter 4014, and a memory access control circuit 4015.

CPU401は、命令ROM402またはフラッシュメモリ404に格納された命令を読み出し実行していく。フラッシュメモリ404に対しては、アンテナコイル406および外部I/F405を介して、外部からプログラムデータを追加することが可能である。   The CPU 401 reads and executes instructions stored in the instruction ROM 402 or the flash memory 404. Program data can be externally added to the flash memory 404 via the antenna coil 406 and the external I / F 405.

図7は、本実施形態のプロセッサ400を用いたメモリ空間の領域区分の概念図である。   FIG. 7 is a conceptual diagram of an area division of a memory space using the processor 400 of the present embodiment.

図7において、200は全論理アドレス空間を表し、命令ROM空間は特権領域211とAPI領域212に、RAM領域は特権領域221とAPI領域222とユーザ領域223に、フラッシュメモリはユーザ領域231に、外部I/Fはユーザ領域241に、それぞれ区分されている。   In FIG. 7, reference numeral 200 denotes the entire logical address space, the instruction ROM space is in the privileged area 211 and the API area 212, the RAM area is in the privileged area 221 and the API area 222 and the user area 223, the flash memory is in the user area 231. The external I / F is divided into user areas 241 respectively.

図2は、本実施形態のプロセッサ400用のプログラム概念図である。   FIG. 2 is a conceptual diagram of a program for the processor 400 of the present embodiment.

図2に示すように、特権領域中の特権プログラム501およびAPI領域中のAPIプログラム502のそれぞれには、ユーザ領域中のユーザプログラム503から、分岐命令(jmp)によって、特権領域中の特権プログラム501またはAPI領域中のAPIプログラム502に実行が移行する際に、分岐先アドレスが正当なアドレスかどうかを指定するための分岐許可命令(accept)を記述する。ここで、分岐許可命令(accept)は、既存命令の命令コードと一致しない特別の命令コードを持つ。   As shown in FIG. 2, the privileged program 501 in the privileged area and the API program 502 in the API area are respectively supplied from the user program 503 in the user area by the branch instruction (jmp). Alternatively, when execution shifts to the API program 502 in the API area, a branch permission instruction (accept) for designating whether the branch destination address is a valid address is described. Here, the branch permission instruction (accept) has a special instruction code that does not match the instruction code of the existing instruction.

実行領域判定回路410は、実行プログラムカウンタ値s4018から、図7に示したメモリ空間の領域区分に従い、現在実行されている命令の領域が特権領域、API領域、ユーザ領域のいずれであるかを判定する。判定結果は、実行領域判定信号s410として実行動作モード決定回路411へ出力される。実行動作モード決定回路411は、実行領域判定信号s410の値に従い、実行動作モードを、特権モード、APIモード、ユーザモードのいずれかに決定する。決定結果は、実行動作モード決定信号s411として出力される。   The execution area determination circuit 410 determines from the execution program counter value s4018 whether the area of the instruction currently being executed is a privileged area, an API area, or a user area according to the area division of the memory space shown in FIG. I do. The determination result is output to the execution operation mode determination circuit 411 as an execution region determination signal s410. The execution operation mode determination circuit 411 determines the execution operation mode to be one of the privilege mode, the API mode, and the user mode according to the value of the execution region determination signal s410. The determination result is output as the execution operation mode determination signal s411.

CPU401は、命令フェッチプログラムカウンタ値s4015または分岐先アドレス値s4014のいずれかをメモリアクセス制御回路4015によって選択して、メモリアクセスアドレス信号s4016として出力する。   The CPU 401 selects one of the instruction fetch program counter value s4015 and the branch destination address value s4014 by the memory access control circuit 4015, and outputs it as a memory access address signal s4016.

分岐先領域判定回路412は、メモリアクセスアドレス信号s4016から、図7に示したメモリ空間の領域区分に従い、分岐先命令の領域が特権領域、API領域、ユーザ領域のいずれであるかを判定し、判定結果として分岐先領域判定信号s412を出力する。分岐先動作モード決定回路413は、分岐先領域判定信号s412の値に従い、動作モードを特権モード、APIモード、ユーザモードのいずれかに決定し、決定結果として分岐先動作モード決定信号s413を出力する。   The branch destination area determination circuit 412 determines from the memory access address signal s4016 whether the area of the branch destination instruction is a privileged area, an API area, or a user area in accordance with the area division of the memory space shown in FIG. A branch destination area determination signal s412 is output as the determination result. The branch destination operation mode determination circuit 413 determines the operation mode to be one of the privilege mode, the API mode, and the user mode according to the value of the branch destination region determination signal s412, and outputs a branch destination operation mode determination signal s413 as a determination result. .

動作モード変更検出回路414は、実行動作モード決定信号s411と分岐先動作モード決定信号s413から動作モードの変化を検出し、動作モード変更検出信号s414を出力する。   The operation mode change detection circuit 414 detects a change in the operation mode from the execution operation mode determination signal s411 and the branch destination operation mode determination signal s413, and outputs an operation mode change detection signal s414.

不正分岐検出回路409は、動作モード変更検出信号s414と命令フェッチデータs407dとに従い、以下の処理を行う。   The illegal branch detection circuit 409 performs the following processing according to the operation mode change detection signal s414 and the instruction fetch data s407d.

不正分岐検出回路409は、動作モード変更検出信号s414によって、ユーザプログラムからAPIプログラム、または、ユーザプログラムから特権プログラムへの実行の移行を伴う分岐命令が発生したと判定した場合は、分岐先アドレスに格納されている命令コードを解読し、ユーザプログラムからの分岐を許可する分岐許可命令(accept)でない場合は、不正分岐検出信号s409をアクティブとする。   If the illegal branch detection circuit 409 determines from the operation mode change detection signal s414 that a branch instruction accompanied by a transition of execution from the user program to the API program or from the user program to the privileged program has occurred, the branch destination address is The stored instruction code is decoded, and if the instruction is not a branch permission instruction (accept) for permitting a branch from the user program, the illegal branch detection signal s409 is activated.

なお、不正分岐検出回路409は、動作モード変更検出信号s414によって動作モードが変更しないと判定した場合、あるいは、動作モードが変更する場合であっても、その動作モードの変更が、ユーザプログラムからAPIプログラムへの変更、または、ユーザプログラムから特権プログラムへの変更のいずれでもないと判定した場合は、不正分岐検出信号s409を非アクティブとする。   Note that the illegal branch detection circuit 409 determines that the operation mode is not changed by the operation mode change detection signal s414, or even when the operation mode is changed, the change of the operation mode is performed by the API from the user program. If it is determined that the change is neither a change to a program nor a change from a user program to a privileged program, the illegal branch detection signal s409 is made inactive.

CPU401内部での分岐許可命令(accept)に対する処理は、命令解読部4012を機能拡張し、命令実行部4013の制御をノーオペレーション命令と同一とすることで、CPU401内部のデータ・演算処理用の資源に影響を与えることなく、最短実行処理サイクルで実行される。   The processing for the branch permission instruction (accept) in the CPU 401 is performed by extending the function of the instruction decoding unit 4012 and making the control of the instruction execution unit 4013 the same as that of the no-operation instruction. And is executed in the shortest execution processing cycle without affecting.

以上により、動作モードの移行を伴う分岐命令が実行された際、分岐先アドレス上にその分岐命令の実行を許可する分岐許可命令が格納されていない場合は、不正分岐検出回路409が不正分岐検出信号s409を出力する。不正分岐検出信号s409は、OR回路415へ与えられる。OR回路415には、割り込み制御回路408から割り込み信号s4081も与えられており、不正分岐検出信号s409がアクティブである場合に、割り込み要求s40812がCPU401へ出力される。   As described above, when a branch instruction with an operation mode transition is executed, if the branch enable instruction that permits the execution of the branch instruction is not stored in the branch destination address, the illegal branch detection circuit 409 detects the illegal branch. The signal s409 is output. The illegal branch detection signal s409 is provided to the OR circuit 415. The OR circuit 415 is also provided with an interrupt signal s4081 from the interrupt control circuit 408, and outputs an interrupt request s40812 to the CPU 401 when the illegal branch detection signal s409 is active.

これにより、例えばフラッシュメモリ404に外部から追加されたユーザプログラム等によって命令ROM402に格納された特権プログラムが不正に実行されることを防ぎ、セキュリティを確保できる。また、正当な処理の場合、実行を希望するプログラムが格納されているアドレスに対して直接分岐命令を実行できるので、動作モードの移行を最短実行処理サイクルで処理でき、リアルタイム性が向上する。   This prevents unauthorized execution of the privileged program stored in the instruction ROM 402 by, for example, a user program externally added to the flash memory 404, thereby ensuring security. Further, in the case of legitimate processing, since a branch instruction can be directly executed at the address where the program desired to be executed is stored, the transition of the operation mode can be processed in the shortest execution processing cycle, and the real-time property is improved.

なお、本実施形態では、不正分岐検出信号s409がアクティブである場合にCPU401へ割り込み要求を出力する構成を例示したが、図1に示す割り込み制御回路408の代わりに、CPU401に対するリセット信号を出力するリセット制御回路を備えた構成としても良い。この場合、不正分岐検出信号s409がアクティブである場合に、CPU401へリセット信号s40812が出力されることとなり、上述の構成と同様に、特権プログラムが不正に実行されることを防ぐという効果が得られる。   In the present embodiment, an example has been described in which an interrupt request is output to the CPU 401 when the illegal branch detection signal s409 is active, but a reset signal is output to the CPU 401 instead of the interrupt control circuit 408 shown in FIG. A configuration including a reset control circuit may be employed. In this case, when the illegal branch detection signal s409 is active, the reset signal s40812 is output to the CPU 401, and the effect of preventing the privileged program from being illegally executed is obtained as in the above-described configuration. .

(実施の形態2)
本発明の実施の形態2にかかるプロセッサ400を用いたICカードシステムについて、以下に説明する。
(Embodiment 2)
An IC card system using the processor 400 according to the second embodiment of the present invention will be described below.

本実施形態のプロセッサ400を用いたICカードシステムのハードウェア構成は、実施の形態1のICカードシステムと同様である(図1参照)。また、本実施形態のプロセッサ400を用いたメモリ空間の領域区分も、実施の形態1と同様である(図7参照)。   The hardware configuration of an IC card system using the processor 400 of the present embodiment is the same as that of the IC card system of the first embodiment (see FIG. 1). The area division of the memory space using the processor 400 of the present embodiment is also the same as that of the first embodiment (see FIG. 7).

図3は、本実施形態のプロセッサ400用のプログラム概念図である。   FIG. 3 is a conceptual diagram of a program for the processor 400 of the present embodiment.

API領域中のAPIプログラム602には、ユーザ領域中のユーザプログラム603から分岐命令(jmp)によってAPI領域中のAPIプログラム602に実行が移行する際に、API領域中の分岐先アドレスが正当なアドレスかどうかを指定するための分岐許可命令(accept usr)を記述する。   When the execution shifts from the user program 603 in the user area to the API program 602 in the API area by a branch instruction (jmp), the branch destination address in the API area is a valid address. A branch permission instruction (accept usr) for specifying whether or not the instruction is described.

特権領域中の特権プログラム601には、ユーザ領域中のユーザプログラム603から分岐命令(jmp)によって特権領域中の特権プログラム601に実行が移行する際に、特権領域中の分岐先アドレスが正当なアドレスかどうかを指定するための分岐許可命令(accept usr)を記述する。   When execution shifts from the user program 603 in the user area to the privileged program 601 in the privileged area by the branch instruction (jmp), the privileged program 601 in the privileged area has a valid branch destination address in the privileged area. A branch permission instruction (accept usr) for specifying whether or not the instruction is described.

また、特権領域中の特権プログラム601には、API領域中のAPIプログラム602から分岐命令(jmp)によって特権領域中の特権プログラム601に実行が移行する際に、特権領域中の分岐先アドレスが正当なアドレスかどうかを指定するための分岐許可命令(accept api)を記述する。   Also, when execution shifts from the API program 602 in the API area to the privileged program 601 in the privileged area by a branch instruction (jmp), the privileged program 601 in the privileged area has a valid branch destination address in the privileged area. A branch permit instruction (accept api) for designating whether or not the address is a proper address is described.

ここで、分岐許可命令(accept)は既存命令の命令コードと一致しない特別の命令コードを持つ。   Here, the branch permission instruction (accept) has a special instruction code that does not match the instruction code of the existing instruction.

実行領域判定回路410は、実行プログラムカウンタ値s4018から、図7に示したメモリ空間の領域区分に従い、現在実行されている命令の領域が特権領域、API領域、ユーザ領域のいずれであるかを判定し、判定結果として実行領域判定信号s410を出力する。実行動作モード決定回路411は、実行領域判定信号s410の値に従い、実行動作モードを特権モード、APIモード、ユーザモードのいずれかに決定する。決定結果は、実行動作モード決定信号s411として出力される。   The execution area determination circuit 410 determines from the execution program counter value s4018 whether the area of the instruction currently being executed is a privileged area, an API area, or a user area according to the area division of the memory space shown in FIG. Then, an execution region determination signal s410 is output as a determination result. The execution operation mode determination circuit 411 determines the execution operation mode to be one of the privilege mode, the API mode, and the user mode according to the value of the execution region determination signal s410. The determination result is output as the execution operation mode determination signal s411.

CPU401は、命令フェッチプログラムカウンタ値s4015または分岐先アドレス値s4014いずれかをメモリアクセス制御回路4015によって選択し、メモリアクセスアドレス信号s4016として出力する。   The CPU 401 selects either the instruction fetch program counter value s4015 or the branch destination address value s4014 by the memory access control circuit 4015, and outputs it as a memory access address signal s4016.

分岐先領域判定回路412は、メモリアクセスアドレス信号s4016から、図7に示したメモリ空間の領域区分に従い、分岐先の領域が特権領域、API領域、ユーザ領域のいずれであるかを判定し、判定結果として分岐先領域判定信号s412を出力する。分岐先動作モード決定回路413は分岐先領域判定信号s412の値に従い動作モードを特権モード、APIモード、ユーザモードのいずれかに決定する。決定結果は、分岐先動作モード決定信号s413として出力される。   The branch destination area determination circuit 412 determines from the memory access address signal s4016 whether the branch destination area is a privileged area, an API area, or a user area in accordance with the area division of the memory space shown in FIG. As a result, a branch destination area determination signal s412 is output. The branch destination operation mode determination circuit 413 determines the operation mode to be one of the privilege mode, the API mode, and the user mode according to the value of the branch destination area determination signal s412. The decision result is output as the branch destination operation mode decision signal s413.

動作モード変更検出回路414は、実行動作モード決定信号s411と分岐先動作モード決定信号s413から動作モードの変化を検出し、動作モード変更検出信号s414を出力する。   The operation mode change detection circuit 414 detects a change in the operation mode from the execution operation mode determination signal s411 and the branch destination operation mode determination signal s413, and outputs an operation mode change detection signal s414.

不正分岐検出回路409は、動作モード変更検出信号s414と、命令フェッチデータs407dに従い、以下の処理を行う。   The illegal branch detection circuit 409 performs the following processing according to the operation mode change detection signal s414 and the instruction fetch data s407d.

不正分岐検出回路409は、動作モード変更検出信号s414によってユーザプログラムからAPIプログラムまたはユーザプログラムから特権プログラムへの実行の移行を伴う分岐命令が発生したことを判定した場合は、分岐先アドレスに格納されている命令コードを解読し、ユーザプログラムからの分岐を許可する分岐許可命令(accept usr)でない場合は、不正分岐検出信号s409をアクティブとする。   If the illegal branch detection circuit 409 determines that the operation mode change detection signal s414 has caused the branch instruction accompanied by the transition from the user program to the API program or the execution from the user program to the privileged program, it is stored in the branch destination address. If the instruction code is not a branch permission instruction (accept usr) for permitting a branch from the user program, the illegal branch detection signal s409 is activated.

不正分岐検出回路409は、動作モード変更検出信号s414によってAPIプログラムから特権プログラムへの実行の移行を伴う分岐命令が発生したことを判定した場合は、分岐先アドレスに格納されている命令コードを解読し、ユーザプログラムからの分岐を許可する分岐許可命令(accept usr)またはAPIプログラムからの分岐を許可する分岐許可命令(accept api)でない場合は、不正分岐検出信号s409をアクティブとする。   If the illegal branch detection circuit 409 determines that the branch instruction accompanied by the transition from the API program to the privileged program has occurred by the operation mode change detection signal s414, it decodes the instruction code stored in the branch destination address. If the instruction is not a branch permission instruction (accept usr) that permits branching from the user program or a branch permission instruction (accept api) that permits branching from the API program, the illegal branch detection signal s409 is activated.

不正分岐検出回路409は、動作モード変更検出信号s414によって、動作モードが変更しないと判定した場合、あるいは、動作モードが変更する場合であっても、その動作モードの変更が、ユーザプログラムからAPIプログラムへの変更、ユーザプログラムから特権プログラム、または、APIプログラムから特権プログラムへの変更のいずれでもないと判定した場合は、不正分岐検出信号s409を非アクティブとする。   If the operation mode change detection signal s414 determines that the operation mode is not changed, or if the operation mode is changed, the illegal branch detection circuit 409 changes the operation mode from the user program to the API program. If it is determined that the change is neither the change from the user program to the privileged program nor from the API program to the privileged program, the illegal branch detection signal s409 is made inactive.

CPU401内部の分岐許可命令(accept)に対する処理は、命令解読部4012を機能拡張し、命令実行部4013の制御をノーオペレーション命令と同一にすることで、CPU401内部のデータ・演算処理用の資源に影響を与えることなく、最短実行処理サイクルで実行される。   The processing for the branch permission instruction (accept) inside the CPU 401 is performed by expanding the function of the instruction decoding unit 4012 and making the control of the instruction execution unit 4013 the same as that of the no operation instruction, so that the resources for data and arithmetic processing inside the CPU 401 can be used. It is executed in the shortest execution processing cycle without affecting.

以上により、動作モードの移行を伴う分岐命令が実行された際、分岐先アドレス上にその分岐命令の実行を許可する分岐許可命令が格納されていない場合は、不正分岐検出回路409が不正分岐検出信号s409を出力する。   As described above, when a branch instruction with an operation mode transition is executed, if the branch enable instruction that permits the execution of the branch instruction is not stored in the branch destination address, the illegal branch detection circuit 409 detects the illegal branch. The signal s409 is output.

不正分岐検出信号s409は、OR回路415へ与えられる。OR回路415には、割り込み制御回路408から割り込み信号s4081も与えられており、不正分岐検出信号s409がアクティブである場合に、割り込み要求s40812がCPU401へ出力される。これにより、フラッシュメモリ404に外部から追加されたユーザプログラム等によって命令ROM402に格納された特権プログラムが不正に実行されることを防ぎ、セキュリティを確保できる。正当な処理の場合、実行を希望するプログラムが格納されているアドレスに対して直接分岐命令を実行できるので、動作モードの移行を最短実行処理サイクルで処理でき、リアルタイム性が向上する。   The illegal branch detection signal s409 is provided to the OR circuit 415. The OR circuit 415 is also provided with an interrupt signal s4081 from the interrupt control circuit 408, and outputs an interrupt request s40812 to the CPU 401 when the illegal branch detection signal s409 is active. This prevents unauthorized execution of the privileged program stored in the instruction ROM 402 by a user program or the like externally added to the flash memory 404, thereby ensuring security. In the case of legitimate processing, a branch instruction can be directly executed at the address where the program desired to be executed is stored, so that the transition of the operation mode can be processed in the shortest execution processing cycle, and the real-time property is improved.

なお、本実施形態では、不正分岐検出信号s409がアクティブである場合にCPU401へ割り込み要求を出力する構成を例示したが、図1に示す割り込み制御回路408の代わりに、CPU401に対するリセット信号を出力するリセット制御回路を備えた構成としても良い。この場合、不正分岐検出信号s409がアクティブである場合に、CPU401へリセット信号s40812が出力されることとなり、上述の構成と同様に、特権プログラムが不正に実行されることを防ぐという効果が得られる。   In the present embodiment, an example has been described in which an interrupt request is output to the CPU 401 when the illegal branch detection signal s409 is active, but a reset signal is output to the CPU 401 instead of the interrupt control circuit 408 shown in FIG. A configuration including a reset control circuit may be employed. In this case, when the illegal branch detection signal s409 is active, the reset signal s40812 is output to the CPU 401, and the effect of preventing the privileged program from being illegally executed is obtained as in the above-described configuration. .

(実施の形態3)
本発明の実施の形態3にかかるプロセッサ400を用いたICカードシステムについて、以下に説明する。
(Embodiment 3)
An IC card system using the processor 400 according to the third embodiment of the present invention will be described below.

本実施形態のプロセッサ400を用いたICカードシステムのハードウェア構成は、実施の形態1のICカードシステムと同様である(図1参照)。また、本実施形態のプロセッサ400を用いたメモリ空間の領域区分も、実施の形態1と同様である(図7参照)。   The hardware configuration of an IC card system using the processor 400 of the present embodiment is the same as that of the IC card system of the first embodiment (see FIG. 1). The area division of the memory space using the processor 400 of the present embodiment is also the same as that of the first embodiment (see FIG. 7).

図3は、本実施形態のプロセッサ400用のプログラム概念図である。   FIG. 3 is a conceptual diagram of a program for the processor 400 of the present embodiment.

API領域中のAPIプログラム602には、ユーザ領域中のユーザプログラム603から分岐命令(jmp)によってAPI領域中のAPIプログラム602に実行が移行する際に、API領域中の分岐先アドレスが正当なアドレスかどうかを指定するための分岐許可命令(accept usr)を記述する。   When the execution shifts from the user program 603 in the user area to the API program 602 in the API area by a branch instruction (jmp), the branch destination address in the API area is a valid address. A branch permission instruction (accept usr) for specifying whether or not the instruction is described.

特権領域中の特権プログラム601には、ユーザ領域中のユーザプログラム603から分岐命令(jmp)によって特権領域中の特権プログラム601に実行が移行する際に、特権領域中の分岐先アドレスが正当なアドレスかどうかを指定するための分岐許可命令(accept usr)を記述する。   When execution shifts from the user program 603 in the user area to the privileged program 601 in the privileged area by the branch instruction (jmp), the privileged program 601 in the privileged area has a valid branch destination address in the privileged area. A branch permission instruction (accept usr) for specifying whether or not the instruction is described.

また特権領域中の特権プログラム601には、API領域中のAPIプログラム602から分岐命令(jmp)によって特権領域中の特権プログラム601に実行が移行する際に、特権領域中の分岐先アドレスが正当なアドレスかどうかを指定するための分岐許可命令(accept api)を記述する。   When execution shifts from the API program 602 in the API area to the privileged program 601 in the privileged area by the branch instruction (jmp), the privileged program 601 in the privileged area has a valid branch destination address in the privileged area. A branch permission instruction (accept api) for designating an address is described.

上述のように、本実施形態のプロセッサ400用のプログラム記述方法は、実施の形態2と同じである。しかし、本実施形態のプロセッサ400は、ユーザプログラムからの分岐を許可する分岐許可命令(accept usr)およびAPIプログラムからの分岐を許可する分岐許可命令(accept api)に、それぞれ特殊な命令コードを割り当てず、実プログラム上での使用頻度が低く、かつ、CPU401のデータ・演算処理用の資源に影響を与えることのない、既存命令のいずれかと同じ命令コードを重複して割り当てる点において、実施の形態2と異なっている。   As described above, the program description method for the processor 400 of the present embodiment is the same as that of the second embodiment. However, the processor 400 of the present embodiment assigns special instruction codes to a branch permission instruction (accept usr) that permits branching from a user program and a branch permission instruction (accept api) that permits branching from an API program. The embodiment is different from the first embodiment in that the same instruction code as any one of the existing instructions is allocated infrequently in the actual program and does not affect the data / arithmetic processing resources of the CPU 401. Different from 2.

実行領域判定回路410は、実行プログラムカウンタ値s4018から、図7に示したメモリ空間の領域区分に従い、現在実行されている命令の領域が特権領域、API領域、ユーザ領域のいずれであるかを判定し、判定結果として実行領域判定信号s410を出力する。実行動作モード決定回路411は、実行領域判定信号s410の値に従い、実行動作モードを特権モード、APIモード、ユーザモードのいずれかに決定する。決定結果は、実行動作モード決定信号s411として出力される。   The execution area determination circuit 410 determines from the execution program counter value s4018 whether the area of the instruction currently being executed is a privileged area, an API area, or a user area according to the area division of the memory space shown in FIG. Then, an execution region determination signal s410 is output as a determination result. The execution operation mode determination circuit 411 determines the execution operation mode to be one of the privilege mode, the API mode, and the user mode according to the value of the execution region determination signal s410. The determination result is output as the execution operation mode determination signal s411.

CPU401は、命令フェッチプログラムカウンタ値s4015または分岐先アドレス値s4014いずれかをメモリアクセス制御回路4015によって選択し、メモリアクセスアドレス信号s4016として出力する。   The CPU 401 selects either the instruction fetch program counter value s4015 or the branch destination address value s4014 by the memory access control circuit 4015, and outputs it as a memory access address signal s4016.

分岐先領域判定回路412は、メモリアクセスアドレス信号s4016から、図7に示したメモリ空間の領域区分に従い、分岐先命令の領域が特権領域、API領域、ユーザ領域のいずれであるかを判定し、判定結果として分岐先領域判定信号s412を出力する。分岐先動作モード決定回路413は、分岐先領域判定信号s412の値に従い、動作モードを特権モード、APIモード、ユーザモードのいずれかに決定する。決定結果は、分岐先動作モード決定信号s413として出力される。   The branch destination area determination circuit 412 determines from the memory access address signal s4016 whether the area of the branch destination instruction is a privileged area, an API area, or a user area in accordance with the area division of the memory space shown in FIG. A branch destination area determination signal s412 is output as the determination result. The branch destination operation mode determination circuit 413 determines the operation mode to be one of the privilege mode, the API mode, and the user mode according to the value of the branch destination region determination signal s412. The decision result is output as the branch destination operation mode decision signal s413.

動作モード変更検出回路414は、実行動作モード決定信号s411と分岐先動作モード決定信号s413から動作モードの変化を検出し、動作モード変更検出信号s414を出力する。   The operation mode change detection circuit 414 detects a change in the operation mode from the execution operation mode determination signal s411 and the branch destination operation mode determination signal s413, and outputs an operation mode change detection signal s414.

不正分岐検出回路409は、動作モード変更検出信号s414と、命令フェッチデータs407dに従い、以下の処理を行う。   The illegal branch detection circuit 409 performs the following processing according to the operation mode change detection signal s414 and the instruction fetch data s407d.

不正分岐検出回路409は、動作モード変更検出信号s414によって、ユーザプログラムからAPIプログラムへ、または、ユーザプログラムから特権プログラムへの実行の移行を伴う分岐命令が発生したことを判定した場合は、分岐先アドレスに格納されている命令コードを解読し、ユーザプログラムからの分岐を許可する分岐許可命令(accept usr)でない場合は、不正分岐検出信号s409をアクティブとする。   If the illegal branch detection circuit 409 determines from the operation mode change detection signal s414 that a branch instruction accompanied by a transition of execution from the user program to the API program or from the user program to the privileged program occurs, the branch destination The instruction code stored in the address is decoded, and if the instruction is not a branch permission instruction (accept usr) for permitting a branch from the user program, the illegal branch detection signal s409 is activated.

不正分岐検出回路409は、動作モード変更検出信号s414によって、APIプログラムから特権プログラムへの実行の移行を伴う分岐命令が発生したことを判定した場合は、分岐先アドレスに格納されている命令コードを解読し、ユーザプログラムからの分岐を許可する分岐許可命令(accept usr)またはAPIプログラムからの分岐を許可する分岐許可命令(accept api)でない場合は、不正分岐検出信号s409をアクティブとする。   If the illegal branch detection circuit 409 determines from the operation mode change detection signal s414 that a branch instruction accompanied by a transition of execution from the API program to the privileged program has occurred, the illegal branch detection circuit 409 detects the instruction code stored in the branch destination address. If the decryption is not a branch permission instruction (accept usr) for permitting a branch from the user program or a branch permission instruction (accept api) for permitting a branch from the API program, the illegal branch detection signal s409 is activated.

不正分岐検出回路409は、動作モード変更検出信号s414によって、動作モードが変更しないと判定した場合、あるいは、動作モードが変更する場合であっても、その動作モードの変更が、ユーザプログラムからAPIプログラムへの変更、ユーザプログラムから特権プログラム、またはAPIプログラムから特権プログラムへの変更のいずれでもないと判定した場合は、不正分岐検出信号s409を非アクティブとする。   If the operation mode change detection signal s414 determines that the operation mode is not changed, or if the operation mode is changed, the illegal branch detection circuit 409 changes the operation mode from the user program to the API program. If it is determined that the change is neither a change from a user program to a privileged program nor from an API program to a privileged program, the illegal branch detection signal s409 is deactivated.

分岐許可命令(accept)は既存命令と同一の命令コードに割り当てられているため、命令解読部4012は既存のものを使用できる。また、CPU401内部の分岐許可命令(accept)に対する処理は、割り当てられた既存命令と同一の実行処理内容、実行処理サイクルで実行される。   Since the branch permission instruction (accept) is assigned to the same instruction code as the existing instruction, the instruction decoding unit 4012 can use an existing instruction. The processing for the branch permission instruction (accept) in the CPU 401 is executed in the same execution processing content and execution processing cycle as the assigned existing instruction.

以上により、動作モードの移行を伴う分岐命令が実行された際、分岐先アドレス上にその分岐命令の実行を許可する分岐許可命令が格納されていない場合は、不正分岐検出回路409が不正分岐検出信号s409を出力する。   As described above, when a branch instruction with an operation mode transition is executed, if the branch enable instruction that permits the execution of the branch instruction is not stored in the branch destination address, the illegal branch detection circuit 409 detects the illegal branch. The signal s409 is output.

不正分岐検出信号s409は、OR回路415へ与えられる。OR回路415には、割り込み制御回路408から割り込み信号s4081も与えられており、不正分岐検出信号s409がアクティブである場合に、割り込み要求s40812がCPU401へ出力される。例えばフラッシュメモリ404に外部から追加されたユーザプログラム等によって命令ROM402に格納された特権プログラムが不正に実行されることを防ぎ、セキュリティを確保できる。   The illegal branch detection signal s409 is provided to the OR circuit 415. The OR circuit 415 is also provided with an interrupt signal s4081 from the interrupt control circuit 408, and outputs an interrupt request s40812 to the CPU 401 when the illegal branch detection signal s409 is active. For example, the privilege program stored in the instruction ROM 402 can be prevented from being illegally executed by a user program or the like externally added to the flash memory 404, and security can be ensured.

正当な処理の場合、実行を希望するプログラムが格納されているアドレスに対して直接分岐命令を実行できるので、動作モードの移行を分岐許可命令に割り当てられた既存命令1命令分と同一の実行処理サイクルで処理でき、リアルタイム性が向上する。また、CPU401に関しては既存のものを流用できるため設計容易性が高い。   In the case of legitimate processing, a branch instruction can be directly executed at the address where the program desired to be executed is stored, so that the operation mode shifts to the same execution processing as one existing instruction assigned to the branch enable instruction. Can be processed in cycles, improving real-time performance. In addition, since the existing CPU can be used, the design is easy.

なお、本実施形態では、不正分岐検出信号s409がアクティブである場合にCPU401へ割り込み要求を出力する構成を例示したが、図1に示す割り込み制御回路408の代わりに、CPU401に対するリセット信号を出力するリセット制御回路を備えた構成としても良い。この場合、不正分岐検出信号s409がアクティブである場合に、CPU401へリセット信号s40812が出力されることとなり、上述の構成と同様に、特権プログラムが不正に実行されることを防ぐという効果が得られる。   In the present embodiment, an example has been described in which an interrupt request is output to the CPU 401 when the illegal branch detection signal s409 is active, but a reset signal is output to the CPU 401 instead of the interrupt control circuit 408 shown in FIG. A configuration including a reset control circuit may be employed. In this case, when the illegal branch detection signal s409 is active, the reset signal s40812 is output to the CPU 401, and the effect of preventing the privileged program from being illegally executed is obtained as in the above-described configuration. .

(実施の形態4)
図4は、実施の形態4にかかるプロセッサ700を用いたICカードシステムを表すブロック図である。
(Embodiment 4)
FIG. 4 is a block diagram illustrating an IC card system using the processor 700 according to the fourth embodiment.

本実施形態のプロセッサ700を用いたICカードシステムは、図4に示すように、CPU701と、命令ROM702と、RAM703と、フラッシュメモリ704と、外部I/F705と、アンテナコイル706と、アドレスバス707aと、データバス707dと、割り込み制御回路708と、不正分岐検出回路709と、実行領域判定回路710と、実行動作モード決定回路711と、分岐先領域判定回路712と、分岐先動作モード決定回路713と、動作モード変更検出回路714と、分岐許可命令コード変換回路715とによって構成される。   As shown in FIG. 4, the IC card system using the processor 700 according to the present embodiment includes a CPU 701, an instruction ROM 702, a RAM 703, a flash memory 704, an external I / F 705, an antenna coil 706, an address bus 707a. , A data bus 707d, an interrupt control circuit 708, an illegal branch detection circuit 709, an execution region determination circuit 710, an execution operation mode determination circuit 711, a branch destination region determination circuit 712, and a branch destination operation mode determination circuit 713. And an operation mode change detection circuit 714 and a branch permission instruction code conversion circuit 715.

更に、CPU701は、命令フェッチ部7011と、命令解読部7012と、命令実行部7013と、プログラムカウンタ7014と、メモリアクセス制御回路7015とによって構成される。   Further, the CPU 701 includes an instruction fetch unit 7011, an instruction decoding unit 7012, an instruction execution unit 7013, a program counter 7014, and a memory access control circuit 7015.

CPU701は、命令ROM702またはフラッシュメモリ704に格納された命令を読み出し実行していく。フラッシュメモリ704に対しては、アンテナコイル706および外部I/F705を介して、外部からプログラムデータを追加することが可能である。   The CPU 701 reads and executes instructions stored in the instruction ROM 702 or the flash memory 704. Program data can be externally added to the flash memory 704 via the antenna coil 706 and the external I / F 705.

本実施形態のプロセッサ700を用いたメモリ空間の領域区分の概念図は、実施の形態1で説明した図7のとおりである。   The conceptual diagram of the area division of the memory space using the processor 700 of the present embodiment is as shown in FIG. 7 described in the first embodiment.

図3は、実施の形態4のプロセッサ700用のプログラム概念図である。   FIG. 3 is a conceptual diagram of a program for a processor 700 according to the fourth embodiment.

API領域中のAPIプログラム602には、ユーザ領域中のユーザプログラム603から分岐命令(jmp)によってAPI領域中のAPIプログラム602に実行が移行する際に、API領域中の分岐先アドレスが正当なアドレスかどうかを指定するための分岐許可命令(accept usr)を記述する。   When the execution shifts from the user program 603 in the user area to the API program 602 in the API area by a branch instruction (jmp), the branch destination address in the API area is a valid address. A branch permission instruction (accept usr) for specifying whether or not the instruction is described.

特権領域中の特権プログラム601には、ユーザ領域中のユーザプログラム603から分岐命令(jmp)によって特権領域中の特権プログラム601に実行が移行する際に、特権領域中の分岐先アドレスが正当なアドレスかどうかを指定するための分岐許可命令(accept usr)を記述する。   When execution shifts from the user program 603 in the user area to the privileged program 601 in the privileged area by the branch instruction (jmp), the privileged program 601 in the privileged area has a valid branch destination address in the privileged area. A branch permission instruction (accept usr) for specifying whether or not the instruction is described.

また特権領域中の特権プログラム601には、API領域中のAPIプログラム602から分岐命令(jmp)によって特権領域中の特権プログラム601に実行が移行する際に、特権領域中の分岐先アドレスが正当なアドレスかどうかを指定するための分岐許可命令(accept api)を記述する。   When execution shifts from the API program 602 in the API area to the privileged program 601 in the privileged area by the branch instruction (jmp), the privileged program 601 in the privileged area has a valid branch destination address in the privileged area. A branch permission instruction (accept api) for designating an address is described.

すなわち、本実施形態のプロセッサ700用のプログラム記述は、前述の実施の形態3と同様である。ただし、本実施形態では、分岐許可命令(accept)は、既存命令の命令コードと一致しない特別の命令コードを持つ。   That is, the program description for the processor 700 of the present embodiment is the same as that of the third embodiment. However, in this embodiment, the branch permission instruction (accept) has a special instruction code that does not match the instruction code of the existing instruction.

実行領域判定回路710は、実行プログラムカウンタ値s7018から、図7に示したメモリ空間の領域区分に従い、現在実行されている命令の領域が特権領域、API領域、ユーザ領域のいずれであるかを判定し、判定結果として実行領域判定信号s710を出力する。実行動作モード決定回路711は、実行領域判定信号s710の値に従い、実行動作モードを特権モード、APIモード、ユーザモードのいずれかに決定する。決定結果は、実行動作モード決定信号s711として出力される。   The execution area determination circuit 710 determines from the execution program counter value s7018 whether the area of the currently executed instruction is a privileged area, an API area, or a user area according to the area division of the memory space shown in FIG. Then, an execution region determination signal s710 is output as the determination result. The execution operation mode determination circuit 711 determines the execution operation mode to be one of the privilege mode, the API mode, and the user mode according to the value of the execution region determination signal s710. The determination result is output as the execution operation mode determination signal s711.

CPU701は、命令フェッチプログラムカウンタ値s7015または分岐先アドレス値s7014いずれかをメモリアクセス制御回路7015によって選択し、メモリアクセスアドレス信号s7016として出力する。   The CPU 701 selects either the instruction fetch program counter value s7015 or the branch destination address value s7014 by the memory access control circuit 7015, and outputs it as a memory access address signal s7016.

分岐先領域判定回路712は、メモリアクセスアドレス信号s7016から、図7に示したメモリ空間の領域区分に従い、分岐先命令の領域が特権領域、API領域、ユーザ領域のいずれであるかを判定し、判定結果として分岐先領域判定信号s712を出力する。分岐先動作モード決定回路713は、分岐先領域判定信号s712の値に従い、動作モードを特権モード、APIモード、ユーザモードのいずれかに決定する。決定結果は、分岐先動作モード決定信号s713として出力される。   The branch destination area determination circuit 712 determines from the memory access address signal s7016 whether the area of the branch destination instruction is a privileged area, an API area, or a user area in accordance with the area division of the memory space shown in FIG. A branch destination area determination signal s712 is output as the determination result. The branch destination operation mode determination circuit 713 determines the operation mode to be any of the privilege mode, the API mode, and the user mode according to the value of the branch destination region determination signal s712. The determination result is output as a branch destination operation mode determination signal s713.

動作モード変更検出回路714は、実行動作モード決定信号s711と分岐先動作モード決定信号s713から動作モードの変化を検出し、動作モード変更検出信号s714を出力する。   The operation mode change detection circuit 714 detects a change in the operation mode from the execution operation mode determination signal s711 and the branch destination operation mode determination signal s713, and outputs an operation mode change detection signal s714.

不正分岐検出回路709は、動作モード変更検出信号s714と、命令フェッチデータs707dに従い、以下の処理を行う。   The illegal branch detection circuit 709 performs the following processing according to the operation mode change detection signal s714 and the instruction fetch data s707d.

不正分岐検出回路709は、動作モード変更検出信号s714によって、ユーザプログラムからAPIプログラム、または、ユーザプログラムから特権プログラムへの実行の移行を伴う分岐命令が発生したことを判定した場合は、分岐先アドレスに格納されている命令コードを解読し、ユーザプログラムからの分岐を許可する分岐許可命令(accept usr)でない場合は、不正分岐検出信号s709をアクティブとする。   If the illegal branch detection circuit 709 determines from the operation mode change detection signal s714 that a branch instruction accompanied by a transition of execution from the user program to the API program or from the user program to the privileged program has occurred, the branch destination address is determined. If the instruction code is not a branch permission instruction (accept usr) for permitting a branch from the user program, the illegal branch detection signal s709 is activated.

不正分岐検出回路709は、動作モード変更検出信号s714によって、APIプログラムから特権プログラムへの実行の移行を伴う分岐命令が発生したことを判定した場合は、分岐先アドレスに格納されている命令コードを解読し、ユーザプログラムからの分岐を許可する分岐許可命令(accept usr)またはAPIプログラムからの分岐を許可する分岐許可命令(accept api)でない場合は、不正分岐検出信号s709をアクティブとする。   If the illegal branch detection circuit 709 determines from the operation mode change detection signal s714 that a branch instruction accompanied by a transition of execution from the API program to the privileged program has occurred, the illegal branch detection circuit 709 detects the instruction code stored in the branch destination address. If the decryption is not a branch permission instruction (accept usr) for permitting a branch from the user program or a branch permission instruction (accept api) for permitting a branch from the API program, the illegal branch detection signal s709 is activated.

不正分岐検出回路709は、動作モード変更検出信号s714によって、動作モードが変更しないと判定した場合、あるいは、動作モードが変更する場合であっても、その動作モードの変更が、ユーザプログラムからAPIプログラムへの変更、ユーザプログラムから特権プログラム、またはAPIプログラムから特権プログラムへの変更のいずれでもないと判定した場合は、不正分岐検出信号s709を非アクティブとする。   When the operation mode change detection signal s714 determines that the operation mode is not changed, or even when the operation mode is changed, the illegal branch detection circuit 709 changes the operation mode from the user program to the API program. If it is determined that the change is not a change from the user program to the privileged program or from the API program to the privileged program, the illegal branch detection signal s709 is made inactive.

分岐許可命令コード変換回路715は、不正分岐検出信号s709が非アクティブな場合は、ユーザプログラムからの分岐を許可する分岐許可命令(accept usr)の命令コードまたはAPIプログラムからの分岐を許可する分岐許可命令(accept api)からノーオペレーション命令へ、不正分岐検出信号s709がアクティブな場合は、すべての命令コードから未定義命令へ、命令フェッチデータs707dのデータ変換を行い、CPU701に対し、命令フェッチデータ信号s7011を出力する。   When the illegal branch detection signal s709 is inactive, the branch permission instruction code conversion circuit 715 converts the instruction code of a branch permission instruction (accept usr) that permits branching from the user program or the branch permission that permits branching from the API program. When the instruction (accept api) is changed to a no-operation instruction and the illegal branch detection signal s709 is active, the instruction fetch data s707d is converted from all the instruction codes to the undefined instruction, and the instruction fetch data signal is sent to the CPU 701. It outputs s7011.

分岐許可命令をCPU701が持っている既存命令に変換することで、命令解読部7012は既存のものを使用できる。また、CPU701内部での処理は、割り当てられた既存命令と同一の実行処理内容、実行処理サイクルで実行される。   By converting the branch permission instruction into an existing instruction of the CPU 701, the instruction decoding unit 7012 can use an existing instruction. The processing in the CPU 701 is executed in the same execution processing content and execution processing cycle as the assigned existing instruction.

以上により、動作モードの移行を伴う分岐命令が実行された際、分岐先アドレス上にその分岐命令の実行を許可する分岐許可命令が格納されていない場合は、不正分岐検出回路709が割り込み要求信号s709を出力するため、例えばフラッシュメモリ404に外部から追加されたユーザプログラム等によって命令ROM402に格納された特権プログラムが不正に実行されることを防ぎ、セキュリティを確保できる。   As described above, when a branch instruction with an operation mode transition is executed, if the branch enable instruction that permits the execution of the branch instruction is not stored in the branch destination address, the illegal branch detection circuit 709 outputs the interrupt request signal. Since s709 is output, it is possible to prevent the privileged program stored in the instruction ROM 402 from being illegally executed by, for example, a user program externally added to the flash memory 404, thereby ensuring security.

また、分岐許可命令コード変換回路715が、CPU701に対し、未定義命令に変換された命令フェッチデータ信号s7011を出力することによって、CPU701に対し未定義命令による例外処理を発生させる。これにより、以降の命令実行が妨げられ、セキュリティを確保できる。   The branch permission instruction code conversion circuit 715 outputs an instruction fetch data signal s7011 converted to an undefined instruction to the CPU 701, thereby causing the CPU 701 to perform an exception process due to the undefined instruction. As a result, subsequent instruction execution is prevented, and security can be ensured.

正当な処理の場合、実行を希望するプログラムが格納されているアドレスに対して直接分岐命令を実行できるので、動作モードの移行を最短実行処理サイクルで処理でき、リアルタイム性が向上する。また、CPU701に関しては既存のものを流用できるため設計容易性が高い。   In the case of legitimate processing, a branch instruction can be directly executed at the address where the program desired to be executed is stored, so that the transition of the operation mode can be processed in the shortest execution processing cycle, and the real-time property is improved. Further, as for the CPU 701, an existing one can be used, so that the design is easy.

なお、上述の実施の形態1〜4では、不正分岐検出部、実行領域判定部、実行動作モード決定部等のそれぞれを別個独立した回路として形成したが、これらの各部ブロックをどのように実装するかは任意である。すなわち、例えば、実行領域判定部と実行動作モード決定部のような複数のブロックを一つの回路で実現した構成も、本発明の技術的範囲に属する。   In the above-described first to fourth embodiments, each of the illegal branch detection unit, the execution region determination unit, the execution operation mode determination unit, and the like is formed as a separate and independent circuit, but how these unit blocks are implemented. Is optional. That is, for example, a configuration in which a plurality of blocks such as an execution region determination unit and an execution operation mode determination unit are realized by one circuit also belongs to the technical scope of the present invention.

また、実施の形態1〜4では、本発明のプロセッサをICカードシステムに適用した例を示したが、本発明のプロセッサの用途はこれに限定されない。   Further, in the first to fourth embodiments, an example in which the processor of the present invention is applied to an IC card system has been described, but the application of the processor of the present invention is not limited to this.

(実施の形態5)
図5は、実施の形態5を用いたコンパイラ装置の構成およびコンパイルフローである。
(Embodiment 5)
FIG. 5 shows a configuration and a compilation flow of a compiler device using the fifth embodiment.

本実施形態にかかるコンパイラ802は、C言語ソースコード801を入力してコンパイルし、アセンブラ803に変換する。   The compiler 802 according to the present embodiment inputs and compiles a C language source code 801 and converts it into an assembler 803.

C言語ソースコード801は、ユーザ領域中に記述されたメイン関数(main#1)16011と、特権領域中に記述された関数16012(function#a)と関数16013(function#b)によって構成されている。また、ユーザプログラムのメイン関数(main#1)16011は、プログラム中で関数16012(function#a)および関数16013(function#b)を呼び出し使用する。   The C language source code 801 includes a main function (main # 1) 16011 described in the user area, a function 16012 (function # a) and a function 16013 (function # b) described in the privileged area. I have. The main function (main # 1) 16011 of the user program calls and uses a function 16012 (function # a) and a function 16013 (function # b) in the program.

コンパイラ802は、コンパイルを行う際に、C言語ソースコード801中の関数が、それぞれ特権領域、ユーザ領域のいずれに記述されているか判定し、特権領域中に記述された関数を特権プログラムとして決定する。コンパイラ802は、コンパイルを実行する際に、特権プログラムのソースコードから生成されるアセンブラコードの先頭に、分岐許可命令(accept)16032,16033を挿入する。   When compiling, the compiler 802 determines whether the function in the C language source code 801 is described in a privileged area or a user area, respectively, and determines the function described in the privileged area as a privileged program. . When compiling, the compiler 802 inserts branch permission instructions (accept) 16032 and 16033 at the beginning of assembler code generated from the source code of the privileged program.

以上により、特権領域中のプログラムの開発を行う設計者は、C言語によるプログラム記述方法を使用しても、コンパイル時に分岐許可命令(accept)が自動挿入され、動作モードの移行を伴う分岐が発生した際の命令実行に対するセキュリティを確保できる。   As described above, even if the designer who develops a program in the privileged area uses the program description method in the C language, a branch permission instruction (accept) is automatically inserted at the time of compiling, and a branch accompanied by an operation mode transition occurs. Security for the execution of the instruction at the time of execution can be ensured.

以上のように、ユーザプログラムから特権プログラムまたはAPIプログラム中のアドレスに対して分岐命令が実行された際、分岐先アドレス上に分岐許可命令が格納されていない場合は不正分岐検出部が不正分岐検出信号を出力するため、ユーザプログラムによって特権プログラムが不正に実行されることを防ぎセキュリティを確保できる。またユーザプログラム上から特権プログラムまたはAPIプログラムを正当に実行する際、ユーザプログラム上で実行を希望する特権プログラムまたはAPIプログラムが格納されているアドレスに対して直接分岐命令を実行することができるため、動作モードの移行に伴う処理時間が削減されリアルタイム性が向上する。   As described above, when the branch instruction is executed from the user program to the address in the privileged program or the API program, if the branch enable instruction is not stored in the branch destination address, the illegal branch detection unit detects the illegal branch. Since the signal is output, the privilege program can be prevented from being illegally executed by the user program, and security can be ensured. In addition, when a privileged program or an API program is properly executed from a user program, a branch instruction can be directly executed at an address where the privileged program or the API program desired to be executed on the user program is stored. The processing time associated with the transition of the operation mode is reduced, and the real-time property is improved.

実施の形態1、実施の形態2、実施の形態3におけるプロセッサ回路構成Processor circuit configuration in the first, second, and third embodiments 実施の形態1におけるプログラム概念図Conceptual diagram of a program in the first embodiment 実施の形態2、実施の形態3、実施の形態4におけるプログラム概念図Schematic diagram of a program according to the second, third, and fourth embodiments. 実施の形態2におけるプロセッサ回路構成Processor circuit configuration in the second embodiment 実施の形態5におけるコンパイラ装置の構成Configuration of Compiler Device in Embodiment 5 従来のプロセッサ回路構成Conventional processor circuit configuration アドレス空間の領域区分Area division of address space 従来のプログラム概念図Conventional program conceptual diagram

符号の説明Explanation of reference numerals

200 全論理アドレス空間
211 命令ROM空間特権領域
212 命令ROM空間API領域
221 RAM空間特権領域
222 RAM空間API領域
223 RAM空間ユーザ領域
231 フラッシュ空間ユーザ領域
241 外部I/F空間ユーザ領域
301 特権領域
302 ユーザ領域
400 プロセッサ
401,701 CPU
4011,7011 命令フェッチ部
4012,7012 命令解読部
4013,7013 命令実行部
4014,7014 プログラムカウンタ
4015,7015 メモリアクセス制御回路
402,702 命令ROM
403,703 RAM
404,704 フラッシュメモリ
405,705 外部I/F
406,706 アンテナコイル
407a,707a アドレスバス
407d,707d データバス
408,708 割り込み制御回路
409,709 不正分岐検出回路
410,710 実行領域判定回路
411,711 実行動作モード決定回路
412,712 分岐先領域判定回路
413,713 分岐先動作モード決定回路
414,714 動作モード変更検出回路
501 特権領域
502 API領域
503 ユーザ領域
600 プロセッサ
601 特権領域
602 API領域
603 ユーザ領域
715 分岐許可命令コード変換回路
801 C言語ソースコード
802 コンパイラ
803 アセンブラソースファイル
200 All logical address space 211 Instruction ROM space privileged area 212 Instruction ROM space API area 221 RAM space privileged area 222 RAM space API area 223 RAM space user area 231 Flash space user area 241 External I / F space user area 301 Privileged area 302 user Area 400 Processor 401, 701 CPU
4011, 7011 instruction fetch unit 4012, 7012 instruction decoding unit 4013, 7013 instruction execution unit 4014, 7014 program counter 4015, 7015 memory access control circuit 402, 702 instruction ROM
403,703 RAM
404, 704 Flash memory 405, 705 External I / F
406,706 Antenna coil 407a, 707a Address bus 407d, 707d Data bus 408,708 Interrupt control circuit 409,709 Illegal branch detection circuit 410,710 Execution area determination circuit 411,711 Execution operation mode determination circuit 412,712 Branch destination area determination Circuit 413, 713 Branch destination operation mode determination circuit 414, 714 Operation mode change detection circuit 501 Privilege area 502 API area 503 User area 600 Processor 601 Privilege area 602 API area 603 User area 715 Branch permission instruction code conversion circuit 801 C language source code 802 compiler 803 assembler source file

Claims (10)

CPUと、
プログラムを格納するための命令メモリと、
前記命令メモリに格納されているプログラムによって、動作モードを異なる動作モードへ変更する分岐命令が実行された際、分岐先アドレスに分岐許可命令が存在するか否かを判断し、前記分岐許可命令が存在する場合は動作モードの変更を許可する一方、前記分岐許可命令が存在しない場合は不正分岐検出信号を出力する不正分岐検出部とを備えたことを特徴とするプロセッサ。
A CPU,
An instruction memory for storing programs,
When a branch instruction for changing an operation mode to a different operation mode is executed by a program stored in the instruction memory, it is determined whether or not a branch permission instruction is present at a branch destination address. A processor comprising: an illegal branch detection unit that permits an operation mode change when the instruction is present, and outputs an illegal branch detection signal when the branch permission instruction is not present.
前記CPUが実行している命令のプログラムカウンタの値によって実行領域を判定する実行領域判定部と、
前記実行領域判定部の判定結果によって、実行中の動作モードを決定する実行動作モード決定部と、
前記命令メモリに格納されているプログラムによって分岐命令が実行された際、分岐先アドレスの値によって分岐先領域を判定する分岐先領域判定部と、
前記分岐先領域判定部の判定結果によって、前記分岐命令による移行先の動作モードを決定する分岐先動作モード決定部と、
前記実行動作モード決定部によって決定された実行動作モードと、前記分岐先動作モード決定部によって決定された移行先動作モードとを比較することによって動作モードが変更されたか否かを検出する動作モード変更検出部とをさらに備え、
前記不正分岐検出部が、前記命令メモリに格納されているプログラムによって分岐命令が実行された際、分岐先アドレスに分岐許可命令が存在しない場合は、前記動作モード変更検出部によって動作モードの変更が検出されたことを条件として前記不正分岐検出信号を出力する、請求項1に記載のプロセッサ。
An execution area determination unit that determines an execution area based on a value of a program counter of an instruction executed by the CPU;
An execution operation mode determination unit that determines an operation mode being executed according to a determination result of the execution region determination unit;
When a branch instruction is executed by a program stored in the instruction memory, a branch destination area determination unit that determines a branch destination area based on a value of a branch destination address;
A branch destination operation mode determination unit that determines an operation mode of a transition destination by the branch instruction according to a determination result of the branch destination area determination unit;
An operation mode change that detects whether or not the operation mode has been changed by comparing the execution operation mode determined by the execution operation mode determination unit with the transition destination operation mode determined by the branch destination operation mode determination unit. Further comprising a detection unit,
When the illegal branch detection unit executes the branch instruction by the program stored in the instruction memory, if the branch permission instruction does not exist at the branch destination address, the operation mode change detection unit changes the operation mode. The processor according to claim 1, wherein the processor outputs the illegal branch detection signal on condition that the signal is detected.
前記不正分岐検出部が、前記命令メモリに格納されているプログラムによって分岐命令が実行された際、分岐先アドレスに分岐許可命令が存在しない場合は、前記動作モード変更検出部によって動作モードの変更が検出され、かつ、前記動作モード変更検出部によって検出された動作モードの変更と分岐許可命令が指定する動作モードの変更とが一致しないことを条件として、前記不正分岐検出信号を出力する、請求項2に記載のプロセッサ。   When the illegal branch detection unit executes a branch instruction according to a program stored in the instruction memory, if there is no branch permission instruction at the branch destination address, the operation mode change detection unit changes the operation mode. The illegal branch detection signal is output on condition that the change in the operation mode detected and detected by the operation mode change detection unit does not match the change in the operation mode specified by the branch permission instruction. 3. The processor according to 2. 前記分岐許可命令に、他の命令と重複しない特定の命令コードが割り当てられた、請求項1に記載のプロセッサ。   The processor according to claim 1, wherein a specific instruction code not overlapping with another instruction is assigned to the branch permission instruction. 前記分岐許可命令に、1つまたは複数の他の命令に対応する命令コードが重複して割り当てられた、請求項3に記載のプロセッサ。   The processor according to claim 3, wherein an instruction code corresponding to one or a plurality of other instructions is assigned to the branch permission instruction in an overlapping manner. 分岐許可命令が検出された際、当該命令コードを他の命令に対応する命令コードに変換する分岐許可命令コード変換部をさらに備えた、請求項3に記載のプロセッサ。   4. The processor according to claim 3, further comprising a branch permission instruction code conversion unit that converts the instruction code into an instruction code corresponding to another instruction when the branch permission instruction is detected. 前記不正分岐検出部より前記不正分岐検出信号が出力されたことを検知すると、前記CPUに対して割り込み要求を出力する割り込み出力部をさらに備えた、請求項1に記載のプロセッサ。   The processor according to claim 1, further comprising an interrupt output unit that outputs an interrupt request to the CPU when detecting that the illegal branch detection signal is output from the illegal branch detection unit. 前記不正分岐検出部より前記不正分岐検出信号が出力されたことを検知すると、前記CPUに対してリセット信号を出力するリセット出力部をさらに備えた、請求項1に記載のプロセッサ。   The processor according to claim 1, further comprising: a reset output unit that outputs a reset signal to the CPU when detecting that the illegal branch detection signal is output from the illegal branch detection unit. 前記不正分岐検出部より前記不正分岐検出信号が出力されたことを検知すると、分岐先アドレスの命令を未定義命令に置き換える命令変換部をさらに備えた、請求項1に記載のプロセッサ。   The processor according to claim 1, further comprising an instruction conversion unit that, when detecting that the illegal branch detection signal is output from the illegal branch detection unit, replaces an instruction at a branch destination address with an undefined instruction. 請求項1〜9のいずれかに記載のプロセッサ用のプログラムを生成するコンパイラ装置であって、
ソースプログラムをコンパイルしアセンブラに変換する際に、ソースプログラム内の関数構造と動作モードとを判定することにより、特権領域のプログラムの所定位置に前記分岐許可命令を挿入することを特徴とするコンパイラ装置。
A compiler device for generating a processor program according to any one of claims 1 to 9,
Compiler apparatus which inserts the branch permission instruction at a predetermined position of a program in a privileged area by determining a function structure and an operation mode in the source program when compiling the source program and converting it into an assembler. .
JP2004048531A 2003-02-24 2004-02-24 Processor and compiler apparatus for generating program for the processor Withdrawn JP2004280801A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2004048531A JP2004280801A (en) 2003-02-24 2004-02-24 Processor and compiler apparatus for generating program for the processor

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
JP2003046484 2003-02-24
JP2004048531A JP2004280801A (en) 2003-02-24 2004-02-24 Processor and compiler apparatus for generating program for the processor

Publications (1)

Publication Number Publication Date
JP2004280801A true JP2004280801A (en) 2004-10-07

Family

ID=33301694

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2004048531A Withdrawn JP2004280801A (en) 2003-02-24 2004-02-24 Processor and compiler apparatus for generating program for the processor

Country Status (1)

Country Link
JP (1) JP2004280801A (en)

Cited By (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2007020758A1 (en) * 2005-08-15 2007-02-22 Matsushita Electric Industrial Co., Ltd. Lsi for ic card
GB2448149A (en) * 2007-04-03 2008-10-08 Advanced Risc Mach Ltd Protected function calling across domains
US7966466B2 (en) 2007-04-03 2011-06-21 Arm Limited Memory domain based security control with data processing systems
US8006078B2 (en) 2007-04-13 2011-08-23 Samsung Electronics Co., Ltd. Central processing unit having branch instruction verification unit for secure program execution
JP2013161479A (en) * 2012-02-08 2013-08-19 Arm Ltd Data processing apparatus and method using secure domain and less secure domain
JP2013539574A (en) * 2010-08-11 2013-10-24 アーム・リミテッド Incorrect mode change operation
JP2014073397A (en) * 2013-11-26 2014-04-24 Daito Giken:Kk Game machine
US10025923B2 (en) 2012-02-08 2018-07-17 Arm Limited Data processing apparatus and method for protecting secure data and program code from non-secure access when switching between secure and less secure domains
US10083040B2 (en) 2012-02-08 2018-09-25 Arm Limited Exception handling in a data processing apparatus having a secure domain and a less secure domain
US10169573B2 (en) 2012-02-08 2019-01-01 Arm Limited Maintaining secure data isolated from non-secure access when switching between domains
US10210349B2 (en) 2012-02-08 2019-02-19 Arm Limited Data processing apparatus and method using secure domain and less secure domain
WO2020095410A1 (en) * 2018-11-08 2020-05-14 ソニー株式会社 Communication device

Cited By (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2007020758A1 (en) * 2005-08-15 2007-02-22 Matsushita Electric Industrial Co., Ltd. Lsi for ic card
GB2448149A (en) * 2007-04-03 2008-10-08 Advanced Risc Mach Ltd Protected function calling across domains
JP2008257735A (en) * 2007-04-03 2008-10-23 Arm Ltd Protected function calling
GB2448149B (en) * 2007-04-03 2011-05-18 Advanced Risc Mach Ltd Protected function calling
US7966466B2 (en) 2007-04-03 2011-06-21 Arm Limited Memory domain based security control with data processing systems
US8010772B2 (en) 2007-04-03 2011-08-30 Arm Limited Protected function calling
US8006078B2 (en) 2007-04-13 2011-08-23 Samsung Electronics Co., Ltd. Central processing unit having branch instruction verification unit for secure program execution
JP2013539574A (en) * 2010-08-11 2013-10-24 アーム・リミテッド Incorrect mode change operation
US8959318B2 (en) 2010-08-11 2015-02-17 Arm Limited Illegal mode change handling
JP2013161479A (en) * 2012-02-08 2013-08-19 Arm Ltd Data processing apparatus and method using secure domain and less secure domain
US10025923B2 (en) 2012-02-08 2018-07-17 Arm Limited Data processing apparatus and method for protecting secure data and program code from non-secure access when switching between secure and less secure domains
US10083040B2 (en) 2012-02-08 2018-09-25 Arm Limited Exception handling in a data processing apparatus having a secure domain and a less secure domain
US10169573B2 (en) 2012-02-08 2019-01-01 Arm Limited Maintaining secure data isolated from non-secure access when switching between domains
US10210349B2 (en) 2012-02-08 2019-02-19 Arm Limited Data processing apparatus and method using secure domain and less secure domain
JP2014073397A (en) * 2013-11-26 2014-04-24 Daito Giken:Kk Game machine
WO2020095410A1 (en) * 2018-11-08 2020-05-14 ソニー株式会社 Communication device
US11422949B2 (en) 2018-11-08 2022-08-23 Sony Group Corporation Communication device

Similar Documents

Publication Publication Date Title
EP3757853B1 (en) Cryptographic computing using encrypted base addresses and used in multi-tenant environments
US11416624B2 (en) Cryptographic computing using encrypted base addresses and used in multi-tenant environments
US7367057B2 (en) Processor based system and method for virus detection
US20220382885A1 (en) Cryptographic computing using encrypted base addresses and used in multi-tenant environments
US8745406B2 (en) Program executable image encryption
Tullsen et al. Storageless value prediction using prior register values
CN110659244A (en) Inline coding capability
US20130054934A1 (en) Method and Apparatus for Performing Mapping Within a Data Processing System Having Virtual Machines
KR20130036189A (en) Restricting memory areas for an instruction read in dependence upon a hardware mode and a security flag
JP2013533567A (en) Memory access control
US8132002B2 (en) Fast system call method
US20010005882A1 (en) Circuit and method for initiating exception routines using implicit exception checking
KR20130137591A (en) Illegal mode change handling
JP2004280801A (en) Processor and compiler apparatus for generating program for the processor
US20080140995A1 (en) Information processor and instruction fetch control method
US20040168047A1 (en) Processor and compiler for creating program for the processor
JP3202497B2 (en) Information processing device
Sinharoy et al. Advanced features in IBM POWER8 systems
US20070050619A1 (en) Processor having program protection function
JP2005084721A (en) Microcomputer
JP2005275841A (en) Memory protection system
US7143270B1 (en) System and method for adding an instruction to an instruction set architecture
JP2007286921A (en) Information processor and security release program unauthorized execution prohibition method using it
JPH05257815A (en) Central processing unit
WO2023188905A1 (en) Information processing device and method for controlling operation of information processing device

Legal Events

Date Code Title Description
A300 Withdrawal of application because of no request for examination

Free format text: JAPANESE INTERMEDIATE CODE: A300

Effective date: 20070501