JPH045729A - Processor device - Google Patents

Processor device

Info

Publication number
JPH045729A
JPH045729A JP2107281A JP10728190A JPH045729A JP H045729 A JPH045729 A JP H045729A JP 2107281 A JP2107281 A JP 2107281A JP 10728190 A JP10728190 A JP 10728190A JP H045729 A JPH045729 A JP H045729A
Authority
JP
Japan
Prior art keywords
address
stack
program
stack pointer
memory
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.)
Pending
Application number
JP2107281A
Other languages
Japanese (ja)
Inventor
Takashi Fujinaga
隆史 藤永
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.)
Mitsubishi Electric Corp
Original Assignee
Mitsubishi Electric Corp
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 Mitsubishi Electric Corp filed Critical Mitsubishi Electric Corp
Priority to JP2107281A priority Critical patent/JPH045729A/en
Publication of JPH045729A publication Critical patent/JPH045729A/en
Pending legal-status Critical Current

Links

Landscapes

  • Executing Machine-Instructions (AREA)

Abstract

PURPOSE:To construct a highly reliable system capable of preventing surely the destruction of data by detecting that a stack pointer overflows by hardware, and interrupting the execution of an instruction. CONSTITUTION:At the time of the execution of a program, the maximum address of a stack area assigned beforehand to a memory 1 is set, and this value is set in a stack address register 8 by the program. As for the stack pointer 6, the address it shows is always compared with the set value of the register 8 by an address comparison circuit 9. When the address exceeds the set value, interruption is generated from an interruption generation circuit 10 to an instruction execution control part 4 based on the compared result of the circuit 9, and the control part 4 executed and so on. Through above- mentioned operation, the overflow of the pointer 6 is detected, and the destruction of a memory area other than stack can be prevented by executing the interrupting processing of the program or the new assignment of another memory by a processor.

Description

【発明の詳細な説明】 〔産業上の利用分野〕 この発明は、プロセッサ装置に関し、特にスタックポイ
ンタのアドレス格納領域のオーバーフローを検出するオ
ーバーフロー検出機能に関するものである。
DETAILED DESCRIPTION OF THE INVENTION [Field of Industrial Application] The present invention relates to a processor device, and particularly to an overflow detection function for detecting an overflow of an address storage area of a stack pointer.

〔従来の技術] 第2図は、従来のプロセッサ制御装置の構成図であり、
図において、(1)はプログラムデータ、割込み発生時
のリターンアドレス等の情報を記憶するメモリ、(2)
はメモリとプロセッサ制御装置のインターフェース制御
部、(3)は命令解析部、(4)は命令実行及び割込み
等制御部、(5)はプログラムカウンタ、(6)はスタ
ックポインタ、(ア)はメモリアドレス制御回路である
[Prior Art] FIG. 2 is a block diagram of a conventional processor control device.
In the figure, (1) is a memory that stores program data, information such as return addresses when an interrupt occurs, and (2)
is the memory and processor control unit interface control unit, (3) is the instruction analysis unit, (4) is the instruction execution and interrupt control unit, (5) is the program counter, (6) is the stack pointer, and (a) is the memory. This is an address control circuit.

次に、動作について説明する。プログラムの命令は、プ
ログラムカウンタ(5)にて示されるアドレスにより、
バスインターフェース制m部(2)を通してメモリ(1
)より読み出される。読み出された命令は命令解析部(
3)により解読され命令実行部(4)にて演算処理等が
実行される。このとき、命令がサブルーチンコールの場
合、プログラムカウンタ(5)は新たに飛先のアドレス
にセットされるが、そのときの元プログラムアドレス、
プログラムスティタス等のサブルーチンからリターン時
再実行するための情報はスタックポインタで示すアドレ
スに書き込まれる。スタックポインタの保持するアドレ
スは書き込み毎に逐次加算され最新のスタックポインタ
を示す。命令実行制御部(5)にて処理する割込みにつ
いても動作は同様である。又、サブルーチン、或は割込
み処理ルーチンからもとプログラムに戻る際には、スタ
ックポインタから再実行のためのアドレス等の情報が読
み出される。スタックポインタの保持するアドレスは読
込み毎に減算され、同じく読み出された後の最新スタッ
クアドレスを示す。
Next, the operation will be explained. Program instructions are given by the address indicated by the program counter (5).
The memory (1) is connected through the bus interface control unit (2).
). The read instructions are sent to the instruction analysis section (
3), and the instruction execution unit (4) executes arithmetic processing, etc. At this time, if the instruction is a subroutine call, the program counter (5) is newly set to the destination address, but the original program address at that time,
Information for re-execution upon return from a subroutine such as program status is written to the address indicated by the stack pointer. The address held by the stack pointer is sequentially added each time it is written to indicate the latest stack pointer. The operation is similar for interrupts processed by the instruction execution control unit (5). Furthermore, when returning to the original program from a subroutine or interrupt processing routine, information such as an address for re-execution is read from the stack pointer. The address held by the stack pointer is decremented each time it is read, and indicates the latest stack address after being read.

(発明が解決しようとする課題) 従来のプロセッサ装置は、以上のように構成されている
ので、サブルーチンコール或は割込み発生毎にスタック
ポインタのアドレスが加算される。そのため、サブルー
チンのネスティングが増大した場合、或は割込みが多数
発生した場合、スタックとしてアサインされているメモ
リ領域を越えてしまい、他にアサインされている領域を
破壊してしまう。又はメモリが物理的に無い場合はメモ
リアクセスエラーとなるなどの問題があフた。
(Problems to be Solved by the Invention) Since the conventional processor device is configured as described above, the address of the stack pointer is added every time a subroutine call or an interrupt occurs. Therefore, when the nesting of subroutines increases, or when a large number of interrupts occur, the memory area assigned as a stack is exceeded, and other assigned areas are destroyed. Or, if there is no physical memory, problems such as memory access errors occur.

この発明は上記のような問題点を解消するためになされ
たもので、スタックポインタの不すアドレスかアサイン
された、スタック用メモリエリアをオーバーすることを
検圧できるプロセッサ装置を得ることを目的とする。
This invention was made in order to solve the above-mentioned problems, and its purpose is to provide a processor device that can detect when the stack memory area assigned to the stack pointer exceeds the address. do.

〔課題を解決するための手段] この発明に係るプロセッサ装置は、各命令が記憶された
メモリにアドレス信号を出力し、命令を読み比すプログ
ラムカウンタと、読み出された命令を実行する命令実行
部と、命令がリターンアドレスを要するサブルーチンコ
ールの場合リターンアドレスを格納するスタックポイン
タと、スタックポインタの格納領域がリターンアドレス
によって規定領域外にオーバーフローするか判定するア
ドレス比較回路と、オーバーフロー時判定時に、上記命
令実行部へオーバーフローを示す割込み信号を出力する
割込み発生回路とを設けたものである。
[Means for Solving the Problems] A processor device according to the present invention includes a program counter that outputs an address signal to a memory in which each instruction is stored, reads and compares the instructions, and an instruction execution counter that executes the read instructions. a stack pointer that stores the return address when the instruction is a subroutine call that requires a return address; an address comparison circuit that determines whether the storage area of the stack pointer overflows outside the specified area due to the return address; and an interrupt generation circuit that outputs an interrupt signal indicating an overflow to the instruction execution section.

(作用) この発明によれば、アドレス比較回路にてスタックポイ
ンタかオーバーフローすることを検出したならば、割込
み発生回路を起動し、命令を実行中の命令実行部にオー
バーフローすることを伝達して命令実行を中断させる等
をしてプログラム暴走の進行を阻止する 〔実施例] 以下、この発明の一実施例を図について説明する。第1
図において(1)はメモリ装置、(2)ババスインター
フェース制御部、(3)は命令解析部、(4)は命令実
行制御部、(5)はプログラムカウンタ、(6)はスタ
ックポインタ、(ア)はアドレス制御部、(8)はスタ
ックポインタアドレスレジスタ、(9)はスタックポイ
ンタ(6)とスタックアドレスレジスタ(8)の内容比
較を行うアドレス比較回路、(10)はアドレス比較回
路(9)の比較結果より、オーバーフロー検出時に命令
実行制御部(4)に対し割込みを発生させる割込み発生
回路である。
(Operation) According to the present invention, when the address comparison circuit detects that the stack pointer overflows, it activates the interrupt generation circuit, transmits the overflow to the instruction execution unit currently executing the instruction, and Preventing Program Runaway by Interrupting Execution, etc. [Embodiment] An embodiment of the present invention will be described below with reference to the drawings. 1st
In the figure, (1) is a memory device, (2) a bus interface control unit, (3) is an instruction analysis unit, (4) is an instruction execution control unit, (5) is a program counter, (6) is a stack pointer, and (6) is a stack pointer. ) is an address control unit, (8) is a stack pointer address register, (9) is an address comparison circuit that compares the contents of the stack pointer (6) and the stack address register (8), and (10) is an address comparison circuit (9). From the comparison result, it is found that this is an interrupt generation circuit that generates an interrupt to the instruction execution control unit (4) when an overflow is detected.

次に上記構成に基づいて動作について説明する。Next, the operation will be explained based on the above configuration.

まず、プログラムの実行に際し、予めメモリ(1)にア
サインされたスタックエリアの最大アドレスが設定され
るが、その値はプログラムによりスタックアドレスレジ
スタ(8)に設定される。スタックポインタ(6)は従
来技術と同様に動作するが、その示すアドレスは常にス
タックアドレスレジスタ(8)の設定値と、アドレス比
較回路(9)によって比較される。アドレスが設定値を
越えた場合はアドレス比較回路(9)の比較結果をもと
に、割込み発生回路(10)から命令実行制御部(4)
に割込みが発生され、命令実行制御部(4)は、実行中
のプログラムを中断させる等の処置を行う。以上の動作
によりスタックポインタ(6)のオーバーフローが検知
され、プロセッサはプログラムの中断処理、又は別のメ
モリを新たにアサインする等の処理を行うことにより、
スタック以外のメモリエリアの破壊を防止することがで
きる。
First, when the program is executed, the maximum address of the stack area previously assigned to the memory (1) is set, and the value is set in the stack address register (8) by the program. The stack pointer (6) operates in the same manner as in the prior art, but the address it indicates is always compared with the set value of the stack address register (8) by the address comparison circuit (9). If the address exceeds the set value, the instruction execution control unit (4) is sent from the interrupt generation circuit (10) based on the comparison result of the address comparison circuit (9).
An interrupt is generated, and the instruction execution control unit (4) takes measures such as interrupting the program being executed. As a result of the above operations, an overflow of the stack pointer (6) is detected, and the processor interrupts the program or allocates another memory.
Destruction of memory areas other than the stack can be prevented.

なお、上記実施例では、スタックポインタ(6)にアサ
インされたメモリアドレスの最大値をスタックアドレス
レジスタ(8)で持つ構成としているか、そのアドレス
をROMで持つ、或は論理回路により固定して持つこと
も可能である。
In the above embodiment, the maximum value of the memory address assigned to the stack pointer (6) is held in the stack address register (8), or the address is held in the ROM, or fixed by a logic circuit. It is also possible.

又、複数のスタックポインタを用いる場合は、対応する
スタックアEレスレジスタを同数持つことにより同様の
効果を奏する。
Furthermore, when using a plurality of stack pointers, the same effect can be achieved by having the same number of corresponding stack address registers.

〔発明の効果) 以上のように、この発明によれば、スタックポインタが
オーバーフローすることをハードウェアにて検知し命令
実行を中断させるように構成したのでオーバーフロー前
にプログラム暴走によるデータ破壊を阻止すべく方策が
命令実行部にて立てられるため、確実にデータ破壊が阻
止できる信頼性の高いシステムを構築することができる
[Effects of the Invention] As described above, according to the present invention, since the hardware is configured to detect an overflow of the stack pointer and interrupt instruction execution, data destruction due to program runaway can be prevented before the overflow occurs. Since measures are taken by the instruction execution unit to prevent data destruction, it is possible to construct a highly reliable system that can reliably prevent data destruction.

【図面の簡単な説明】[Brief explanation of the drawing]

第1図はこの発明の一実施例によるプロセッサ装置を示
す構成図、第2図は従来装置の構成図である。 図において、(1)はメモリ、(4)は命令実行制御部
、(5)はプログラムカウンタ、(6)はスタックポイ
ンタ、(9)はアドレス比較回路、(1o)は割込み発
生回路。 尚、図中同一符号は同−又は相当部分を示す。
FIG. 1 is a block diagram showing a processor device according to an embodiment of the present invention, and FIG. 2 is a block diagram of a conventional device. In the figure, (1) is a memory, (4) is an instruction execution control unit, (5) is a program counter, (6) is a stack pointer, (9) is an address comparison circuit, and (1o) is an interrupt generation circuit. Note that the same reference numerals in the figures indicate the same or corresponding parts.

Claims (1)

【特許請求の範囲】[Claims]  各命令が記憶されたメモリにアドレス信号を出力し、
命令を読み出すプログラムカウンタと、読み出された命
令を実行する命令実行部と、命令がリターンアドレスを
要するサブルーチンコールの場合リターンアドレスを格
納するスタックポインタと、スタックポインタの格納領
域がリターンアドレスによって規定領域外にオーバーフ
ローするか判定するアドレス比較回路と、オーバーフロ
ー時判定時に、上記命令実行部へオーバーフローを示す
割込み信号を出力する割込み発生回路とを設けたことを
特徴とするプロセッサ装置。
Outputs an address signal to the memory where each instruction is stored,
A program counter that reads instructions, an instruction execution unit that executes the read instructions, a stack pointer that stores the return address if the instruction is a subroutine call that requires a return address, and an area where the storage area for the stack pointer is defined by the return address. 1. A processor device comprising: an address comparison circuit that determines whether an overflow occurs; and an interrupt generation circuit that outputs an interrupt signal indicating an overflow to the instruction execution section when determining an overflow.
JP2107281A 1990-04-23 1990-04-23 Processor device Pending JPH045729A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2107281A JPH045729A (en) 1990-04-23 1990-04-23 Processor device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2107281A JPH045729A (en) 1990-04-23 1990-04-23 Processor device

Publications (1)

Publication Number Publication Date
JPH045729A true JPH045729A (en) 1992-01-09

Family

ID=14455099

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2107281A Pending JPH045729A (en) 1990-04-23 1990-04-23 Processor device

Country Status (1)

Country Link
JP (1) JPH045729A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2007529818A (en) * 2004-03-18 2007-10-25 コリア ユニバーシティー インダストリー アンド アカデミー コーオペレーション ファウンデーション Method and apparatus for detecting and recovering from buffer overflow attack

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2007529818A (en) * 2004-03-18 2007-10-25 コリア ユニバーシティー インダストリー アンド アカデミー コーオペレーション ファウンデーション Method and apparatus for detecting and recovering from buffer overflow attack

Similar Documents

Publication Publication Date Title
US5812868A (en) Method and apparatus for selecting a register file in a data processing system
JPH0114611B2 (en)
JP3970609B2 (en) Processor system
EP0290942B1 (en) Guest machine execution control system for virtual machine system
CA1212478A (en) Data processor with interrupt facility
US6026504A (en) Multiprocessor system and method for error tracking
JPH045729A (en) Processor device
JPH01286029A (en) Microprogram patching system
JPH04266141A (en) Stack overflow detection system
JPH0668725B2 (en) Device for responding to interrupt condition in data processing system and method for responding to asynchronous interrupt condition
JPH0496167A (en) Interruption system for multi-processor system
JP3145937B2 (en) Runaway detection method for microcomputer
JPH04227548A (en) Information processing unit
JPH0484224A (en) Stack area protection circuit
JPH02176946A (en) Program runaway detecting method
JPS6175446A (en) Address comparison system
JPH03208132A (en) Single chip microcomputer
JP2503210B2 (en) Micro program controller
JPH059815B2 (en)
JP2615921B2 (en) Input / output control method in operating system
JPH0438526A (en) Microcomputer
JPS6243740A (en) Countermeasure circuit for runaway of microprocessor device
JPH04364545A (en) Memory dumping system
JPH0258648B2 (en)
JPS638841A (en) Interruption accepting system