[go: up one dir, main page]

KR20080079852A - CPU virtualization method - Google Patents

CPU virtualization method Download PDF

Info

Publication number
KR20080079852A
KR20080079852A KR1020070020397A KR20070020397A KR20080079852A KR 20080079852 A KR20080079852 A KR 20080079852A KR 1020070020397 A KR1020070020397 A KR 1020070020397A KR 20070020397 A KR20070020397 A KR 20070020397A KR 20080079852 A KR20080079852 A KR 20080079852A
Authority
KR
South Korea
Prior art keywords
mode
virtual
command
privileged
cpu
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
KR1020070020397A
Other languages
Korean (ko)
Inventor
박찬주
서상범
황주영
허성관
박성열
류재민
김철연
Original Assignee
삼성전자주식회사
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 삼성전자주식회사 filed Critical 삼성전자주식회사
Priority to KR1020070020397A priority Critical patent/KR20080079852A/en
Publication of KR20080079852A publication Critical patent/KR20080079852A/en
Withdrawn legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/14Protection against unauthorised use of memory or access to memory
    • G06F12/1458Protection against unauthorised use of memory or access to memory by checking the subject access rights
    • G06F12/1491Protection against unauthorised use of memory or access to memory by checking the subject access rights in a hierarchical protection system, e.g. privilege levels, memory rings
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0662Virtualisation aspects
    • G06F3/0667Virtualisation aspects at data level, e.g. file, record or object virtualisation
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/12Digital output to print unit, e.g. line printer, chain printer
    • G06F3/1201Dedicated interfaces to print systems
    • G06F3/1202Dedicated interfaces to print systems specifically adapted to achieve a particular effect
    • G06F3/1218Reducing or saving of used resources, e.g. avoiding waste of consumables or improving usage of hardware resources
    • G06F3/122Reducing or saving of used resources, e.g. avoiding waste of consumables or improving usage of hardware resources with regard to computing resources, e.g. memory, CPU

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Computer Security & Cryptography (AREA)
  • Mathematical Physics (AREA)
  • Memory System Of A Hierarchy Structure (AREA)

Abstract

본 발명은 CPU 가상화 방법에 관한 것이다. The present invention relates to a CPU virtualization method.

본 발명의 실시예에 따른 CPU 가상화 방법은, 복수의 게스트 운영체제를 동시 구동하며, 프로세서의 특권 모드에서 실행되는 가상화부를 제공하는 단계; 상기 프로세서의 비특권 모드를 계층적으로 서열화되어 있는 적어도 두 개의 가상 하부 모드로 분할 생성하는 단계; 상기 가상 하부 모드에서 특권 명령이 발생하면 상기 가상화부로 전이하는 단계; 상기 가상화부에서 상기 가상 하부 모드 중 상기 특권 명령을 처리하는 계층 모드로 상기 특권 명령을 전달하는 단계; 상기 특권 명령을 처리하는 계층 모드에서 상기 특권 명령을 처리하고, 상기 모드를 그대로 유지하거나, 다른 어느 하나의 상기 가상 하부 모드로 전이하는 단계를 포함한다.A CPU virtualization method according to an embodiment of the present invention includes: providing a virtualization unit which simultaneously runs a plurality of guest operating systems and runs in a privileged mode of a processor; Partitioning and generating a non-privileged mode of the processor into at least two virtual sub modes hierarchically ordered; Transitioning to the virtualization unit when a privilege command occurs in the virtual lower mode; Transmitting, by the virtualization unit, the privilege command to a hierarchical mode that processes the privilege command among the virtual lower modes; Processing the privileged command in a hierarchical mode of processing the privileged command, maintaining the mode as it is, or transitioning to one of the other virtual sub-modes.

Description

CPU 가상화 방법{CPU virtualization method}CPU virtualization method

도 1은 Xen의 CPU 모드를 도시한 도면,1 is a diagram illustrating a CPU mode of Xen;

도 2는 본 발명의 실시예에 따른 CPU를 가상화 하기 위한 구성 블록도,2 is a configuration block diagram for virtualizing a CPU according to an embodiment of the present invention;

도 3 및 도 4는 본 발명의 실시예에 따른 가상 CPU 모드에서 시스템 이벤트를 처리하기 위한 방법을 나타낸 흐름도, 3 and 4 are flowcharts illustrating a method for processing a system event in a virtual CPU mode according to an embodiment of the present invention;

도 5는 본 발명의 실시예에 따른 가상 스택 포인터 관리 방법을 설명하기 위한 블록도,5 is a block diagram illustrating a virtual stack pointer management method according to an embodiment of the present invention;

도 6은 도 3 및 도 4의 시스템 이벤트 처리 방법을 구체적으로 나타낸 흐름도,6 is a flowchart specifically illustrating a system event processing method of FIGS. 3 and 4;

도 7은 본 발명의 실시예에 따른 가상 커널 모드에서 가상 사용자 모드로 전환하는 방법을 나타낸 흐름도,7 is a flowchart illustrating a method of switching from a virtual kernel mode to a virtual user mode according to an embodiment of the present invention;

도 8은 본 발명의 실시예에 따른 가상 PSR의 처리 방법을 구체적으로 나타낸 흐름도이다.8 is a flowchart specifically showing a processing method of a virtual PSR according to an embodiment of the present invention.

<도면의 주요 부분에 대한 부호의 설명><Explanation of symbols for the main parts of the drawings>

10 : 가상 머신 모니터 12 : VMM 예외 벡터10: virtual machine monitor 12: VMM exception vector

14 : VMM 이벤트 처리부 16 : 가상 커널 모드 전환부14 VMM event processing unit 16: virtual kernel mode switch unit

18 : 하이퍼콜 처리부(18) 20 : 게스트 운영체제18: hyper call processing unit (18) 20: guest operating system

22 : 사용자 프로그램 24 : 가상 사용자 모드22: user program 24: virtual user mode

26 : 커널 프로그램 28 : 가상 커널 모드26: Kernel Program 28: Virtual Kernel Mode

30 : 게스트 운영체제 콜백 루틴 32 : 게스트 운영체제 예외 벡터30: Guest operating system callback routine 32: Guest operating system exception vector

34 : 게스트 운영체제 예외 처리부 40 : 공유 메모리34: guest operating system exception handler 40: shared memory

본 발명은 CPU 가상화 방법에 관한 것으로서, 보다 상세하게는 2가지 CPU 모드를 가지는 프로세서에서 동작하는 운영체제가 하나의 CPU 모드에서 안정적이고 효율적으로 반가상화될 수 있도록 하는 CPU 가상화 방법에 관한 것이다.The present invention relates to a CPU virtualization method, and more particularly, to a CPU virtualization method that enables an operating system operating in a processor having two CPU modes to be stably and efficiently paravirtualized in one CPU mode.

운영체제(Operating System ; OS)는 개인용 컴퓨터(Personal Computer ; PC)와 같은 컴퓨터 장치에서, 사용자가 하드웨어를 보다 용이하게 사용할 수 있도록 인터페이스를 제공해 주는 프로그램들의 집합으로서, 프로세서, 기억 장치, 입출력 장치, 통신 장치, 데이터 등의 자원을 관리한다. Operating System (OS) is a set of programs that provides an interface for a user to use hardware more easily in a computer device such as a personal computer (PC), and includes a processor, a memory device, an input / output device, and a communication device. Manage resources such as devices and data.

개인용 컴퓨터 장치에 탑재되는 운영체제는, 운영체제의 시초라 할 수 있는 IBM 시스템/360 이 개발된 이래, MS사의 도스(DOS), window 3.1, window 95, window 98 등을 거쳐 window XP 로 발전해오고 있다. 이에 비해 고성능의 마이크로프로세서가 탑재된 워크스테이션이나 서버용 컴퓨터 장치에는 window NT, window 2000, UNIX, UNIX가 변형된 운영체제인 Solaris나 LINUX 등이 널리 사용되고 있다.Since the development of the IBM System / 360, which is the beginning of the operating system, personal computer devices have been developed into Windows XP through MS's DOS, window 3.1, window 95, and window 98. In contrast, Windows NT, window 2000, UNIX, and UNIX-based operating systems such as Solaris and LINUX are widely used for workstations and servers equipped with high-performance microprocessors.

한편, 사용자들은 목적이나 필요에 따라 하나의 기록 매체에 복수의 운영체 제를 설치하여 사용하기도 한다. 예를 들면, 하나의 기록 매체에서 논리적으로 분할된 두 영역에 각각 window XP 및 LINUX를 설치하고, 각각의 운영체제 상에 해당 운영체제에서 지원하는 응용 프로그램들을 설치한 후, 컴퓨터 장치가 원하는 운영체제로 부팅되도록 하여, 해당 운영체제에서의 작업을 수행한다.On the other hand, users may install and use a plurality of operating systems on one recording medium depending on the purpose or need. For example, install Windows XP and LINUX in two logically partitioned areas on one recording medium, install applications supported by the operating system on each operating system, and then boot the computer device to the desired operating system. To perform the operation in the operating system.

이와 같이, 복수의 운영체제를 설치하고, 사용자에 의해 선택된 운영체제로 부팅되도록 하는 것을 멀티부팅이라고 한다. 그런데 멀티부팅에 있어, 소정 운영체제에서 다른 운영체제로 전환하기 위해서는 컴퓨터 장치를 재부팅해야한다는 번거로움이 있다. As such, installing a plurality of operating systems and booting the operating system selected by the user is referred to as multibooting. However, in multi-booting, it is troublesome to reboot the computer device in order to switch from one operating system to another.

이러한 문제를 해결하기 위해 종래에는 하나의 플랫폼 상에서 복수의 운영체제를 구동할 수 있도록 하는 가상화 기술(Virtualization Technology)이 제시되었다. 좀 더 구체적으로, 가상화 기술은, 호스트 운영체제(host OS) 상에 가상화 계층(Virtualization Layer)을 형성하거나 직접 가상화 계층을 제공하는 가상 머신 모니터(10)(Virtual Machine Monitor ; VMM) 혹은 하이퍼바이저(Hypervisor)를 두고, 이 가상화 계층 상에 복수의 논리적인 가상 머신(Virtual Machine ; VM)이 생성되도록 한다. 복수의 가상 머신에는 각각 게스트 운영체제(guest OS)가 설치될 수 있으며, 각각의 게스트 운영체제 상에는 해당 게스트 운영체제에서 지원되는 프로그램이 설치될 수 있다. In order to solve this problem, a virtualization technology has been proposed that enables a plurality of operating systems to run on one platform. More specifically, the virtualization technology may include a virtual machine monitor (VMM) or a hypervisor that forms a virtualization layer on a host OS or directly provides a virtualization layer. ), So that a plurality of logical virtual machines (VMs) are created on this virtualization layer. A guest OS may be installed in each of the plurality of virtual machines, and a program supported by the corresponding guest OS may be installed on each guest OS.

이러한 가상화 기술에는 게스트 운영체제의 수정이 필요 없는 전가상화(full-virtualization)와 기존의 게스트 운영체제에 대비하여 성능 저하의 최소화 및 보안성 강화 등의 목적으로 게스트 운영체제의 수정이 요구되는 반가상 화(para-virtualization)가 있다. These virtualization technologies include full-virtualization that does not require modification of the guest operating system, and para-virtualization that requires modification of the guest operating system for the purpose of minimizing performance degradation and enhancing security in preparation for the existing guest operating system. virtualization).

도 1은 인텔 x86 프로세서를 기반으로 하는 가상화 기술인 Xen의 CPU(Central Processing Unit) 모드를 도시한 것이다. VirtualPC, VMWare가 전가상화 기술이 적용되는 반면, Xen은 특정 하드웨어 구조에 맞게 운영체제를 수정해야 하는 반가상화 기술이 적용된다. Figure 1 illustrates the Central Processing Unit (CPU) mode of Xen, a virtualization technology based on Intel x86 processors. VirtualPC and VMWare apply full-virtualization technology, while Xen uses para-virtualization technology that requires modification of the operating system to specific hardware architectures.

도 1에 도시된 바와 같이, Xen에서는 x86의 3가지 CPU 모드를 기반으로 하여, Xen VMM(100)은 CPU ring 0에서, 게스트 운영체제의 커널(kernel)(102)은 CPU ring 1에서, 사용자 프로그램(user application)(104)은 CPU ring 3에서 동작한다.As shown in FIG. 1, based on three CPU modes of x86 in Xen, the Xen VMM 100 is in CPU ring 0, the kernel 102 of the guest operating system in CPU ring 1, and the user program. (user application) 104 operates on CPU ring 3.

한편, ARM 프로세서와 같은 임베디드 프로세서(embedded processor)의 경우 사용자 모드(user mode), 특권 모드(privileged mode)의 2가지 CPU 모드를 가진다. 사용자 모드에서는 사용자 프로그램이, 특권 모드에서는 커널이 동작한다. Meanwhile, an embedded processor such as an ARM processor has two CPU modes, a user mode and a privileged mode. The user program runs in user mode and the kernel runs in privileged mode.

따라서, 3가지 CPU 모드를 기반으로 하는 Xen은 2가지 모드의 ARM 프로세서에서는 사용될 수 없고, 사용하고자 한다면 새롭게 포팅(porting)을 해야 한다. Therefore, Xen, based on three CPU modes, cannot be used on ARM processors in two modes, and must be ported anew if desired.

그리고, 2가지 CPU 모드(예컨대, 사용자 모드, 특권 모드)를 가지는 시스템에서 동작하는 운영체제를 반가상화 하기 위해 수정할 경우, 가상 머신 모니터(10)가 프로세서의 특권 모드에서 동작하게 되므로, 게스트 운영체제의 커널과 사용자 프로그램은 사용자 모드에서 동작 가능하도록 수정해야 한다. 그런데, 기존의 운영체제가 이미 2가지 CPU 모드에서 동작하도록 구현되어 있으므로 이와 관련된 커널의 일부 코드를 수정해야 한다. In addition, when the virtual machine monitor 10 is operated in the privileged mode of the processor when the operating system operating in the system having two CPU modes (eg, the user mode and the privileged mode) is modified, the kernel of the guest operating system is changed. The user program must be modified to run in user mode. However, since the existing operating system is already implemented to operate in two CPU modes, some code of the relevant kernel must be modified.

본 발명은 상기한 문제점을 개선하기 위해 안출된 것으로, 2가지 CPU 모드를 가지는 프로세서에서 동작하는 운영체제가 하나의 CPU 모드에서 안정적이고 효율적으로 반가상화될 수 있도록 하는 CPU 가상화 방법을 제공하는 데 그 목적이 있다. SUMMARY OF THE INVENTION The present invention has been made to solve the above problems, and an object of the present invention is to provide a CPU virtualization method that enables an operating system operating in a processor having two CPU modes to be stably and efficiently paravirtualized in one CPU mode. There is this.

그러나 본 발명의 목적들은 상기에 언급된 목적으로 제한되지 않으며, 언급되지 않은 또 다른 목적들은 아래의 기재로부터 당업자에게 명확하게 이해될 수 있을 것이다. However, the objects of the present invention are not limited to the above-mentioned objects, and other objects not mentioned will be clearly understood by those skilled in the art from the following description.

상기 목적을 달성하기 위하여 본 발명의 일 실시예에 따른 CPU 가상화 방법은, 복수의 게스트 운영체제를 동시 구동하며, 프로세서의 특권 모드에서 실행되는 가상화부를 제공하는 단계; 상기 프로세서의 비특권 모드를 계층적으로 서열화되어 있는 적어도 두 개의 가상 하부 모드로 분할 생성하는 단계; 상기 가상 하부 모드에서 특권 명령이 발생하면 상기 가상화부로 전이하는 단계; 상기 가상화부에서 상기 가상 하부 모드 중 상기 특권 명령을 처리하는 계층 모드로 상기 특권 명령을 전달하는 단계; 상기 특권 명령을 처리하는 계층 모드에서 상기 특권 명령을 처리하고, 상기 모드를 그대로 유지하거나, 다른 어느 하나의 상기 가상 하부 모드로 전이하는 단계를 포함한다. In order to achieve the above object, a CPU virtualization method according to an embodiment of the present invention comprises: providing a virtualization unit which simultaneously runs a plurality of guest operating systems and runs in a privileged mode of a processor; Partitioning and generating a non-privileged mode of the processor into at least two virtual sub modes hierarchically ordered; Transitioning to the virtualization unit when a privilege command occurs in the virtual lower mode; Transmitting, by the virtualization unit, the privilege command to a hierarchical mode that processes the privilege command among the virtual lower modes; Processing the privileged command in a hierarchical mode of processing the privileged command, maintaining the mode as it is, or transitioning to one of the other virtual sub-modes.

기타 실시예들의 구체적인 사항들은 상세한 설명 및 도면들에 포함되어 있으며, 본 발명의 이점 및 특징, 그리고 그것들을 달성하는 방법은 첨부되는 도면과 함께 상세하게 후술되어 있는 실시예들을 참조하면 명확해질 것이다.Specific details of other embodiments are included in the detailed description and drawings, and the advantages and features of the present invention and methods for achieving them will be apparent with reference to the embodiments described below in detail with the accompanying drawings.

그러나 본 발명은 이하에서 개시되는 실시예들에 한정되는 것이 아니라 서로 다른 다양한 형태로 구현될 수 있으며, 단지 본 실시예들은 본 발명의 개시가 완전하도록 하고, 본 발명이 속하는 기술 분야에서 통상의 지식을 가진 자에게 발명의 범주를 완전하게 알려주기 위해 제공되는 것이며, 본 발명은 청구항의 범주에 의해 정의될 뿐이다. 명세서 전체에 걸쳐 동일 참조 부호는 동일 구성 요소를 지칭한다.However, the present invention is not limited to the embodiments disclosed below, but may be embodied in various different forms, and the present embodiments merely make the disclosure of the present invention complete and common knowledge in the technical field to which the present invention belongs. It is provided to fully inform the person having the scope of the invention, which is defined only by the scope of the claims. Like reference numerals refer to like elements throughout.

이하, 첨부된 블록도 또는 처리 흐름도에 대한 도면들을 참고하여 본 발명의 실시예에 따른 CPU 가상화 방법에 대해 설명하도록 한다. Hereinafter, a CPU virtualization method according to an embodiment of the present invention will be described with reference to the accompanying block diagrams or the drawings of the processing flowchart.

이 때, 처리 흐름도 도면들의 각 블록과 흐름도 도면들의 조합들은 컴퓨터 프로그램 인스트럭션들에 의해 수행될 수 있음을 이해할 수 있을 것이다. At this point, it will be understood that each block of the flowchart illustrations and combinations of flowchart illustrations may be performed by computer program instructions.

이들 컴퓨터 프로그램 인스트럭션들은 범용 컴퓨터, 특수용 컴퓨터 또는 기타 프로그램 가능한 데이터 프로세싱 장비의 프로세서에 탑재될 수 있으므로, 컴퓨터 또는 기타 프로그램 가능한 데이터 프로세싱 장비의 프로세서를 통해 수행되는 그 인스트럭션들이 흐름도 블록(들)에서 설명된 기능들을 수행하는 수단을 생성하게 된다. Since these computer program instructions may be mounted on a processor of a general purpose computer, special purpose computer, or other programmable data processing equipment, those instructions executed through the processor of the computer or other programmable data processing equipment may be described in flow chart block (s). It creates a means to perform the functions.

이들 컴퓨터 프로그램 인스트럭션들은 특정 방식으로 기능을 구현하기 위해 컴퓨터 또는 기타 프로그램 가능한 데이터 프로세싱 장비를 지향할 수 있는 컴퓨터 이용 가능 또는 컴퓨터 판독 가능 메모리에 저장되는 것도 가능하므로, 그 컴퓨터 이용가능 또는 컴퓨터 판독 가능 메모리에 저장된 인스트럭션들은 흐름도 블록(들)에서 설명된 기능을 수행하는 인스트럭션 수단을 내포하는 제조 품목을 생산하는 것도 가능하다. 컴퓨터 프로그램 인스트럭션들은 컴퓨터 또는 기타 프로그램 가능한 데이터 프로세싱 장비 상에 탑재되는 것도 가능하므로, 컴퓨터 또는 기타 프로 그램 가능한 데이터 프로세싱 장비 상에서 일련의 동작 단계들이 수행되어 컴퓨터로 실행되는 프로세스를 생성해서 컴퓨터 또는 기타 프로그램 가능한 데이터 프로세싱 장비를 수행하는 인스트럭션들은 흐름도 블록(들)에서 설명된 기능들을 실행하기 위한 단계들을 제공하는 것도 가능하다. These computer program instructions may be stored in a computer usable or computer readable memory that can be directed to a computer or other programmable data processing equipment to implement functionality in a particular manner, and thus the computer usable or computer readable memory. It is also possible for the instructions stored in to produce an article of manufacture containing instruction means for performing the functions described in the flowchart block (s). Computer program instructions It can also be mounted on a computer or other programmable data processing equipment, so that a series of operating steps are performed on the computer or other programmable data processing equipment to create a computer-implemented process to create a computer or other programmable data processing equipment. The instructions that perform may also provide steps for performing the functions described in the flowchart block (s).

또한, 각 블록은 특정된 논리적 기능(들)을 실행하기 위한 하나 이상의 실행 가능한 인스트럭션들을 포함하는 모듈, 세그먼트 또는 코드의 일부를 나타낼 수 있다. 또, 몇 가지 대체 실행예들에서는 블록들에서 언급된 기능들이 순서를 벗어나서 발생하는 것도 가능함을 주목해야 한다. 예컨대, 잇달아 도시되어 있는 두 개의 블록들은 사실 실질적으로 동시에 수행되는 것도 가능하고 또는 그 블록들이 때때로 해당하는 기능에 따라 역순으로 수행되는 것도 가능하다.In addition, each block may represent a portion of a module, segment, or code that includes one or more executable instructions for executing a specified logical function (s). It should also be noted that in some alternative implementations, the functions noted in the blocks may occur out of order. For example, the two blocks shown in succession may in fact be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending on the corresponding function.

도 2는 본 발명의 실시예에 따른 CPU를 가상화 하기 위한 구성 블록도를 나타낸 것이다.2 illustrates a configuration block diagram for virtualizing a CPU according to an embodiment of the present invention.

한편, 본 발명의 실시예에서 '시스템 이벤트'는 특권 명령으로서, 예외(exception) 또는 인터럽트(interrupt) 등에 의해 발생하는 이벤트를 포함하는 용어로 사용된다. 또한, '예외'란, 프로세서에서 정의되지 않은 명령어를 실행하려고 시도하는 경우, 권한이 필요한 운영체제 기능에 액세스 하려는 경우 등을 의미한다.Meanwhile, in the exemplary embodiment of the present invention, 'system event' is a privileged command and is used as a term including an event generated by an exception or an interrupt. In addition, 'exception' refers to an attempt to execute an instruction not defined in the processor, an access to an operating system function that requires permission, and the like.

도시된 CPU를 가상화하기 위한 장치는, 가상화 계층을 제공하는 가상 머신 모니터(10)와, 가상 머신 모니터(10) 상에서 구동하는 게스트 운영체제(20)를 포함한다. 여기서, 게스트 운영체제(20)는 하나 또는 그 이상이 될 수 있다.The apparatus for virtualizing the illustrated CPU includes a virtual machine monitor 10 providing a virtualization layer and a guest operating system 20 running on the virtual machine monitor 10. Here, the guest operating system 20 may be one or more.

2가지 CPU 모드(예컨대, 사용자 모드, 특권 모드)를 가지는 시스템에서 가상 머신 모니터(10)는 특권 모드에서 동작하며, 게스트 운영체제(20)는 비특권 모드인 사용자 모드에서 동작한다.In a system having two CPU modes (e.g., user mode, privileged mode), virtual machine monitor 10 operates in privileged mode, and guest operating system 20 operates in non-privileged user mode.

비특권 모드인 사용자 모드는 가상 머신 모니터(10)에 의해 사용자 프로그램(22) 수행 모드인 가상 사용자 모드(virtual user mode)(24)와 커널 프로그램(26) 수행 모드인 가상 커널 모드(virtual kernel mode)(28)로 분할 생성된다. 가상 사용자 모드(24)와 가상 커널 모드(28)는 계층적으로 서열화되어 있으며, 가상 커널 모드(28)는 가상 사용자 모드(24)보다 상위 계층 모드인 것이 바람직하다. 한편, 본 실시예에서는 비특권 모드를 2개의 가상 하부 모드인 가상 사용자 모드(24), 가상 커널 모드(28)로 분할 생성하였으나, 그 이상이 될 수도 있음은 물론이다. The non-privileged user mode is the virtual user mode 24 which is the user program 22 execution mode and the virtual kernel mode which is the kernel program 26 execution mode by the virtual machine monitor 10. Is divided into (28). The virtual user mode 24 and the virtual kernel mode 28 are hierarchically ordered, and the virtual kernel mode 28 is preferably a higher layer mode than the virtual user mode 24. In the present embodiment, the non-privileged mode is divided into two virtual sub-modes, the virtual user mode 24 and the virtual kernel mode 28. However, the non-privileged mode may be more than that.

가상 커널 모드(28)에서는 가상 머신 모니터(10)로부터 제어권을 부여받는 게스트 운영체제(20)의 콜백 루틴(callback routine)(30)과, 콜백 루틴(30)의 명령에 따라 예외를 처리하기 위한 게스트 운영체제(20)의 예외 처리부(exception handler)(34)가 동작한다. In the virtual kernel mode 28, a guest for handling an exception according to a callback routine 30 of a guest operating system 20, which is given control from the virtual machine monitor 10, and an instruction of the callback routine 30. An exception handler 34 of the operating system 20 operates.

콜백 루틴(30)은 프로세서의 레지스터에 저장된 벡터의 오프셋 값을 이용하여 게스트 운영체제(20)의 예외 벡터(32)로 분기한다.The callback routine 30 branches to the exception vector 32 of the guest operating system 20 using the offset value of the vector stored in the processor's register.

기존의 운영체제에서는 시스템 이벤트를 가장 처음 수행하는 부분이 예외 벡터가 된다. 하지만, 가상 머신 모니터(10) 상에서의 게스트 운영체제(20)는 예외 벡터(32)로 분기하기 전에 가상 머신 모니터(10)에 의해서 제어가 전달되는 일종의 콜백 루틴(30)이 수행된다. 이 콜백 루틴(30)에서는 가상 머신 모니터(10)가 생성한 가상 CPU 컨텍스트를 이용하여 가상 예외 벡터(32)로 분기하도록 설정된다. 이에, 게스트 운영체제(20)의 커널 수정을 최소화하여 안정성을 확보할 수 있게 된다. In an existing operating system, the first part of a system event is the exception vector. However, the guest operating system 20 on the virtual machine monitor 10 performs some sort of callback routine 30 where control is passed by the virtual machine monitor 10 before branching to the exception vector 32. The callback routine 30 is set to branch to the virtual exception vector 32 using the virtual CPU context generated by the virtual machine monitor 10. Thus, it is possible to secure stability by minimizing kernel modification of the guest operating system 20.

게스트 운영체제(20) 예외 처리부(34)는 게스트 운영체제(20) 예외 벡터(32) 값에 따라 호출되어 각기 상이한 명령을 수행하는 하나 혹은 그 이상의 루틴일 수 있다.The guest operating system 20 exception processing unit 34 may be one or more routines that are called according to the value of the guest operating system 20 exception vector 32 to perform different instructions.

가상 머신 모니터(10)에는 예외를 처리하기 위한 VMM 예외 벡터(12) 및 VMM 이벤트 처리부(14)와, 가상 커널 모드 전환부(16)와, 하이퍼콜 처리부(18)를 포함한다.The virtual machine monitor 10 includes a VMM exception vector 12 and a VMM event processor 14, a virtual kernel mode switch unit 16, and a hypercall processor 18 for handling exceptions.

가상 커널 모드 전환부(16)는 가상 커널 모드(28)에서 시스템 이벤트를 처리하기 위해, 가상 머신 모니터(10)에서 가상 커널 모드(28)로 전환하기 위한 부분이다. The virtual kernel mode switching unit 16 is a part for switching from the virtual machine monitor 10 to the virtual kernel mode 28 in order to process a system event in the virtual kernel mode 28.

하이퍼콜 처리부(18)는 하이퍼콜 요청에 따라 해당 명령을 수행한다. 여기서, 하이퍼콜이란, 게스트 운영체제(20)에서, 또는 게스트 운영체제(20)의 커널에서 가상 머신 모니터(10)에 특정 명령을 수행하기 위해 요청하는 일종의 시스템 콜을 말한다. The hypercall processing unit 18 performs a corresponding command according to the hypercall request. Here, the hypercall refers to a kind of system call requested by the guest operating system 20 or the kernel of the guest operating system 20 to perform a specific command to the virtual machine monitor 10.

그리고, 도시된 CPU를 가상화하기 위한 장치는, 가상 머신 모니터(10)와 게스트 운영체제(20)의 커널이 정보를 공유하기 위해 마련된 공유 메모리(40)를 더 포함한다. The apparatus for virtualizing the illustrated CPU further includes a shared memory 40 provided for sharing information between the kernel of the virtual machine monitor 10 and the guest operating system 20.

가상 머신 모니터(10) 및 게스트 운영체제(20)에서는 시스템 이벤트가 발생한 시점의 가상 CPU 모드 정보가 필요하게 되는데, 공유 메모리(40)는 이 가상 CPU 모드 정보를 저장하고 있다. 이에, 필요에 따라 가상 CPU 모드 정보를 리드(read)/라이트(write) 할 수 있도록 한다.The virtual machine monitor 10 and the guest operating system 20 need the virtual CPU mode information at the time the system event occurs, and the shared memory 40 stores the virtual CPU mode information. Accordingly, the virtual CPU mode information can be read / written as necessary.

구체적으로, 공유 메모리(40)에는 가상 머신 모니터(10)로부터 가상 커널 모드(28)로 전환시 가상 커널 모드 정보가 저장되고, 가상 커널 모드(28)에서 가상 사용자 모드(24)로 전환시 가상 사용자 모드 정보가 저장된다. 즉, 현재 실행 중인 가상 CPU 모드 정보가 저장된다.Specifically, the virtual memory mode information is stored in the shared memory 40 when switching from the virtual machine monitor 10 to the virtual kernel mode 28, and the virtual when switching from the virtual kernel mode 28 to the virtual user mode 24. User mode information is stored. That is, the virtual CPU mode information currently being executed is stored.

또한, 공유 메모리(40)에는 가상 사용자 모드 스택 포인터, 가상 커널 모드 스택 포인터가 저장된다. 공유 메모리(40)에 각 모드의 스택 포인터를 저장하는 이유는, 시스템 이벤트 처리 후 각 모드로 복귀할 때 해당 CPU 컨텍스트를 복원하기 위함이다. The shared memory 40 also stores a virtual user mode stack pointer and a virtual kernel mode stack pointer. The reason for storing the stack pointer of each mode in the shared memory 40 is to restore the CPU context when returning to each mode after processing the system event.

물론, 도시된 바에 의하면 시스템 이벤트로서 예외가 발생한 경우의 구성 블록도를 도시하였으나, 인터럽트에 의한 인터럽트 벡터, 인터럽트 핸들러 등이 구성될 수도 있다.Of course, although shown in the block diagram of the configuration when an exception occurs as a system event, an interrupt vector by interrupt, an interrupt handler, and the like may be configured.

도 3 및 도 4는 본 발명의 실시예에 따른 가상 CPU 모드에서 시스템 이벤트를 처리하기 위한 방법을 나타낸 흐름도이다.3 and 4 are flowcharts illustrating a method for processing a system event in a virtual CPU mode according to an embodiment of the present invention.

한편, 2가지 CPU 모드에서 커널과 사용자 프로그램(22)이 동작되도록 설계된 운영체제의 가상화 구현시, 가상 머신 모니터(10)를 고려한 스택 포인터(Stack Pointer ; SP) 관리 방법이 필요하다. 특히, 가상 머신 모니터(10)가 특권 모드에 서 동작되는 경우, 가상 사용자 모드 스택 포인터 및 가상 커널 모드 스택 포인터를 별도로 관리하여야 한다. 도 3 및 도 4의 흐름도를 참조하여 가상 스택 포인터 관리 방법도 함께 설명하기로 한다.Meanwhile, when implementing a virtualization of an operating system designed to operate the kernel and the user program 22 in two CPU modes, a stack pointer (SP) management method considering the virtual machine monitor 10 is required. In particular, when the virtual machine monitor 10 is operated in a privileged mode, the virtual user mode stack pointer and the virtual kernel mode stack pointer must be managed separately. The virtual stack pointer management method will also be described with reference to the flowcharts of FIGS. 3 and 4.

먼저, 가상 머신 모니터(10) 환경에서 게스트 운영체제(20)의 사용자 프로그램(22)(가상 사용자 모드(24)) 또는 커널 프로그램(26)(가상 커널 모드(28))에서 코드가 수행 중일 때, 시스템 이벤트가 발생하면(S100), 가상 머신 모니터(10)의 예외 처리부(exception handler) 혹은 인터럽트 처리부(interrupt handler) 등의 이벤트 처리부(event handler)(14)로 제어권이 넘어간다.First, when code is running in the user program 22 (virtual user mode 24) or kernel program 26 (virtual kernel mode 28) of the guest operating system 20 in the virtual machine monitor 10 environment, When a system event occurs (S100), control passes to an event handler 14 such as an exception handler or interrupt handler of the virtual machine monitor 10.

이 때, 가상 머신 모니터(10)에서는 현재 상태(가상 사용자 모드(24) 또는 가상 커널 모드(28))의 CPU 컨텍스트(context)를 스택 프레임(stack frame)에 저장한다(S102). 그리고, 공유 메모리(40)에 저장된 가상 CPU 모드 정보를 독출하여, 시스템 이벤트가 발생한 가상 CPU 모드를 판별한다(S104). At this time, the virtual machine monitor 10 stores the CPU context of the current state (virtual user mode 24 or virtual kernel mode 28) in a stack frame (S102). The virtual CPU mode information stored in the shared memory 40 is read, and the virtual CPU mode in which the system event occurs is determined (S104).

가상 머신 모니터(10)의 이벤트 처리부(14)에서는 판별된 모드의 스택 포인터 값을 공유 메모리(40)에 저장한다(S106, S108). 예를 들면, 가상 사용자 모드(24) 실행 중 시스템 이벤트가 발생한 경우라면 가상 사용자 모드 스택 포인터 값을 공유 메모리(40)의 가상 사용자 모드 스택 포인터를 유지하는 필드에 저장하고, 가상 커널 모드(28) 실행 중 시스템 이벤트가 발생한 경우라면 가상 커널 모드 스택 포인터 값을 공유 메모리(40)의 가상 커널 모드 스택 포인터를 유지하는 필드에 저장한다. The event processing unit 14 of the virtual machine monitor 10 stores the stack pointer value of the determined mode in the shared memory 40 (S106 and S108). For example, if a system event occurs while executing the virtual user mode 24, the virtual user mode stack pointer value is stored in a field holding the virtual user mode stack pointer of the shared memory 40, and the virtual kernel mode 28 is stored. If a system event occurs during execution, the virtual kernel mode stack pointer value is stored in a field holding the virtual kernel mode stack pointer of the shared memory 40.

그 후, 가상 머신 모니터(10)의 이벤트 처리부(14)는 시스템 이벤트에 대해 1차 처리를 하고(S110), 게스트 운영체제(20)의 가상 커널 모드(28)로 제어권을 넘겨주기 위해, 공유 메모리(40)의 가상 CPU 모드 정보 필드에 가상 커널 모드 정보를 저장하고(S112), 공유 메모리(40)에 저장된 가상 커널 모드 스택 포인터 값을 독출한다(S114). 그리고, 가상 머신 모니터(10)는 스택 프레임의 가상 커널 모드 스택 포인터 값을 갱신하여 CPU 컨텍스트 정보를 설정하고 게스트 운영체제(20)의 가상 커널 모드(28)로 전환한다(S116). Thereafter, the event processing unit 14 of the virtual machine monitor 10 performs primary processing on the system event (S110), and transfers control to the virtual kernel mode 28 of the guest operating system 20, shared memory. The virtual kernel mode information is stored in the virtual CPU mode information field of 40 (S112), and the virtual kernel mode stack pointer value stored in the shared memory 40 is read (S114). The virtual machine monitor 10 updates the virtual kernel mode stack pointer value of the stack frame to set CPU context information and switches to the virtual kernel mode 28 of the guest operating system 20 (S116).

게스트 운영체제(20)의 가상 커널 모드(28)에서 시스템 이벤트에 대한 처리를 완료하게 되면(S118), 가상 사용자 모드(24)로의 전환이 필요한지를 확인하고, 필요한 경우 하이퍼콜(hypercall)을 요청한다(S120). When the processing of the system event is completed in the virtual kernel mode 28 of the guest operating system 20 (S118), it is checked whether the switch to the virtual user mode 24 is necessary, and requests a hypercall if necessary. (S120).

그러면, 가상 머신 모니터(10)에서는 공유 메모리(40)의 가상 CPU 모드 정보 필드에 가상 사용자 모드 정보를 저장하고(S122), 공유 메모리(40)에 저장된 가상 사용자 모드 스택 포인터 값을 독출하여(S124), 가상 사용자 모드(24)의 CPU 컨텍스트를 복원하고(S126), 가상 커널 모드(28)에서 가상 사용자 모드(24)로 전환한다(S128). Then, the virtual machine monitor 10 stores the virtual user mode information in the virtual CPU mode information field of the shared memory 40 (S122), reads the virtual user mode stack pointer value stored in the shared memory 40 (S124). In step S126, the CPU context of the virtual user mode 24 is restored (S126) and the virtual user mode 24 is switched from the virtual kernel mode 28 to the virtual user mode 24 (S128).

한편, 도시되지는 않았으나, 가상 커널 모드(28)에서 가상 머신 모니터(10)로 하이퍼콜 요청시, 공유 메모리(40)에 가상 커널 모드 스택 포인터 값이 저장됨은 물론이다. On the other hand, although not shown, when the hypercall request to the virtual machine monitor 10 in the virtual kernel mode 28, the virtual kernel mode stack pointer value is stored in the shared memory 40, of course.

한편, 도 3 및 도 4를 참조하면, 가상 사용자 모드(24)에서 시스템 이벤트가 발생하여 이벤트 처리 후 가상 사용자 모드(24)로 복귀하거나 가상 커널 모드(28)로 전이하는 경우, 가상 커널 모드(28)에서 시스템 이벤트가 발생하여 이벤트 처리 후 가상 사용자 모드(24)로 전이하거나 가상 커널 모드(28)로 복귀하는 경우가 존재하나, 시스템 이벤트가 발생하였던 시점의 모드로 복귀하는 것이 더 바람직하다. Meanwhile, referring to FIGS. 3 and 4, when a system event occurs in the virtual user mode 24 and returns to the virtual user mode 24 or transitions to the virtual kernel mode 28 after the event processing, the virtual kernel mode ( There is a case where a system event occurs in 28) and transitions to the virtual user mode 24 after the event processing or returns to the virtual kernel mode 28. However, it is more preferable to return to the mode where the system event occurred.

도 5는 가상 사용자 모드에서 시스템 이벤트가 발생한 경우의 스택 포인터 처리 방법의 일예를 나타낸 블록도이다. 5 is a block diagram illustrating an example of a stack pointer processing method when a system event occurs in a virtual user mode.

가상 사용자 모드(24)에서 시스템 이벤트가 발생한 경우, 가상 머신 모니터(10)에서는 가상 사용자 모드 스택 포인터를 공유 메모리(40)에 저장한다. 그리고, 시스템 이벤트 정보를 가상 커널 모드(28)로 전송하기 위해 공유 메모리(40)에 저장된 가상 커널 모드 스택 포인터를 독출하여 CPU 컨텍스트를 복원한다. 가상 커널 모드(28)에서 시스템 이벤트 처리 완료 후, 가상 사용자 모드(24)로 다시 복귀하는 경우, 가상 커널 모드 스택 포인터를 공유 메모리(40)에 저장하고, 커널로부터 하이퍼콜을 요청받은 가상 머신 모니터(10)의 하이퍼콜 처리부(18)는 공유 메모리(40)에 저장된 가상 사용자 모드 스택 포인터를 독출하여 CPU 컨텍스트를 복원한다. 이로써, 모드 사이의 전환이 가능하다. When a system event occurs in the virtual user mode 24, the virtual machine monitor 10 stores the virtual user mode stack pointer in the shared memory 40. The CPU context is restored by reading the virtual kernel mode stack pointer stored in the shared memory 40 to transmit the system event information to the virtual kernel mode 28. After returning to the virtual user mode 24 after the system event processing in the virtual kernel mode 28 is completed, the virtual machine monitor stores the virtual kernel mode stack pointer in the shared memory 40 and receives a hypercall from the kernel. The hypercall processor 18 of 10 reads the virtual user mode stack pointer stored in the shared memory 40 to restore the CPU context. In this way, switching between modes is possible.

도 6은 도 3 및 도 4의 시스템 이벤트 처리 방법을 구체적으로 나타낸 흐름도이다.6 is a flowchart specifically illustrating a system event processing method of FIGS. 3 and 4.

먼저, 가상 머신 모니터(10)는, 예컨대 시스템 이벤트로서 예외가 발생한 경우(S130), 예외 벡터(exception vector)(12) 값을 스택 프레임에 저장하여 게스트 운영체제(20)가 이를 이용하도록 한다(S132). 그리고, 이벤트 처리부(14)에서 해당 처리 작업을 수행한다(S134). 그 후, 이벤트 정보를 게스트 운영체제(20)로 전달해야 하는데, 이는 가상 커널 모드 전환부(16)에서 담당한다. First, when an exception occurs, for example, as a system event (S130), the virtual machine monitor 10 stores the exception vector 12 value in a stack frame so that the guest operating system 20 uses it (S132). ). Then, the event processing unit 14 performs the processing (S134). Thereafter, event information must be delivered to the guest operating system 20, which is handled by the virtual kernel mode switcher 16.

가상 커널 모드 전환부(16)는, 가상 커널 모드(28) CPU 컨텍스트를 복구하는 작업을 수행한다(S136). 그리고, 게스트 운영체제(20)가 예외를 수신할 수 있는 상태인지를 검사하고(S138), 검사 결과 수신 가능한 상태이면 예외에 대한 정보를 전송한다(S140). The virtual kernel mode switching unit 16 performs a task of restoring the virtual kernel mode 28 CPU context (S136). In operation S138, the guest operating system 20 may check whether an exception may be received (S138).

가상 머신 모니터(10)로부터 제어권을 넘겨받은 가상 커널 모드(28)의 콜백 루틴(callback routine)(30)에서는 예외 벡터(32)로 분기하여 게스트 운영체제(20)의 예외 처리부(34)에서 예외를 처리하도록 한다(S142, S144). In the callback routine 30 of the virtual kernel mode 28, which has passed control from the virtual machine monitor 10, the callback routine 30 branches to the exception vector 32 to catch an exception in the exception processing unit 34 of the guest operating system 20. Processing is performed (S142, S144).

한편, 앞서 설명한 바와 같이, 게스트 운영체제(20)에서 사용자 프로그램(22)이 수행되던 중, 시스템 이벤트가 발생하면, 가상 머신 모니터(10) 및 가상 커널에서 시스템 이벤트에 대한 처리를 수행한 후 다시 사용자 프로그램(22)이 동작했던 가상 사용자 모드(24)로 전환하는 것이 바람직하다.Meanwhile, as described above, if a system event occurs while the user program 22 is being executed in the guest operating system 20, the virtual machine monitor 10 and the virtual kernel process the system event and then the user again. It is desirable to switch to the virtual user mode 24 in which the program 22 has operated.

ARM 프로세서의 경우, 슈퍼바이저(supervisor) 모드와 사용자 모드에서 사용하는 프로그램 상태 레지스터(Program Status Register ; PSR) 값이 서로 다르므로, 가상 사용자 모드(24)로 전환할 때 PSR 정보까지 같이 전환해야 한다.For ARM processors, the Program Status Register (PSR) values used in supervisor mode and user mode are different, so when switching to virtual user mode 24, the PSR information must be switched as well. .

또한, 가상 사용자 모드(24)로 전환할 시점에서 인터럽트는 디스에이블(disable)된 상태이므로, 인터럽트를 인에이블(enable)로 설정하고 전환을 해야 한다. 그런데, 만일 미리 인터럽트를 인에이블하고 전환하게 될 경우, 아직 컨텍스트가 스위칭되지 않은 상태에서 인터럽트가 발생하면 문제가 생기므로 어토믹(atomic)하게 모드가 스위칭 되어야 한다. In addition, since the interrupt is disabled at the time of switching to the virtual user mode 24, it is necessary to set the interrupt to enable and switch. However, if the interrupt is enabled and switched in advance, a problem occurs if an interrupt occurs while the context is not yet switched, so the mode must be switched atomically.

기존 운영체제의 커널에서는 CPU 모드 전환 명령어를 사용하여 커널의 컨텍 스트와 사용자의 컨텍스트를 어토믹(atomic)하게 전환하였다. 그런데, 가상 머신 모니터(10) 환경의 게스트 운영체제(20)에서는 가상 커널 모드(28)에서 가상 사용자 모드(24)로 컨텍스트를 전환하게 될 경우 동일한 사용자 모드이므로 특권 모드에서만 유효한 모드 전환 명령어가 동작을 하지 않게 된다. 또한, PSR의 값을 변경하는 명령어도 슈퍼바이저 모드에서만 가능하므로 하이퍼콜을 재수행해야 하는 문제가 발생한다.In the kernel of the existing operating system, the CPU mode switch command is used to atomically switch the context of the kernel and the user's context. However, in the guest operating system 20 of the virtual machine monitor 10 environment, when the context is switched from the virtual kernel mode 28 to the virtual user mode 24, the mode switching command valid only in the privileged mode is operated. You will not. In addition, the command to change the value of the PSR is also available only in the supervisor mode, which causes a problem of having to redo the hypercall.

따라서, 본 발명의 실시예에서는 가상 커널 모드(28)에서 가상 사용자 모드(24)로 전환시, 한 번의 하이퍼콜 수행으로 PSR 및 컨텍스트 전환, 인터럽트 인에이블이 어토믹(atomic)하게 되는 방법을 제시한다. 그 구체적인 방법은 도 7을 참조하여 설명하기로 한다. Accordingly, an embodiment of the present invention proposes a method in which a PSR, a context switch, and an interrupt enable are atomic when performing a single hypercall when switching from the virtual kernel mode 28 to the virtual user mode 24. do. The detailed method will be described with reference to FIG. 7.

먼저, 게스트 운영체제(20)의 예외 처리부(34)에서 예외 처리 완료 후(S150), 가상 CPU 모드 스위칭(switching)을 위한 하이퍼콜을 수행한다(S152). 그러면, 가상 머신 모니터(10)의 하이퍼콜 처리부(18)가 호출된다(S154). First, after exception processing is completed in the exception processing unit 34 of the guest operating system 20 (S150), a hypercall for virtual CPU mode switching is performed (S152). Then, the hypercall processing unit 18 of the virtual machine monitor 10 is called (S154).

호출된 하이퍼콜 처리부(18)는 공유 메모리(40)에 저장된 가상 사용자 모드의 스택 포인터 값을 이용하여 가상 사용자 모드(24)의 CPU 컨텍스트를 복원할 수 있다(S156). 하이퍼콜 처리부(18)는 가상 PSR 값을 인터럽트 인에이블되도록 설정하고(S158), 모드 스위칭 명령(movs)을 이용하여 가상 사용자 모드(24)의 컨텍스트로 전환한다(S160).The called hypercall processor 18 may restore the CPU context of the virtual user mode 24 using the stack pointer value of the virtual user mode stored in the shared memory 40 (S156). The hypercall processor 18 sets the virtual PSR value to be interrupt enabled (S158), and switches to the context of the virtual user mode 24 by using mode switching commands (movs) (S160).

도 8은 본 발명의 실시예에 따른 가상 PSR의 처리 방법을 구체적으로 나타낸 흐름도이다. 8 is a flowchart specifically showing a processing method of a virtual PSR according to an embodiment of the present invention.

게스트 운영체제(20)에서는 각종 예외를 처리할 때, 직접 혹은 간접적으로 PSR을 액세스해야 하기 때문에, PSR을 가상화시켜 운영체제에 이미 구현되어 있는 예외 처리부에서 기존과 동일한 방법으로 PSR을 액세스할 수 있어야 한다. 여기서, 게스트 운영체제(20)에 이미 구현되어 있는 예외 처리부(34)에서는 PSR의 각종 비트를 통해 예외가 발생한 프로세서 모드를 판단한다. Since the guest operating system 20 needs to directly or indirectly access the PSR when handling various exceptions, the PSR should be virtualized so that the PSR can be accessed in the same manner as the existing method in the exception processing unit already implemented in the operating system. Here, the exception processor 34, which is already implemented in the guest operating system 20, determines the processor mode in which the exception has occurred through various bits of the PSR.

도 8을 참조하면, 먼저 가상 머신 모니터(10)는 게스트 운영체제(20)로 예외 처리에 대한 제어권을 넘겨주기에 앞서, 가상 머신 모니터(10)의 스택에 저장되어 있는 PSR의 모든 비트의 값을 이전의 가상 CPU 모드 값으로 대치하여 게스트 운영체제(20)의 예외 처리부(34)에서 이전에 실행되던 가상 CPU 모드와 연산 상태를 식별할 수 있도록 한다(S164). 예를 들면, 가상 사용자 모드(24)에서 시스템 이벤트가 발생하여 가상 머신 모니터(10)에서 이벤트 처리 후 게스트 운영체제(20)로 예외 처리에 대한 제어권을 넘겨주기 전에, PSR의 값을 이전의 가상 CPU 모드인 가상 사용자 모드(24) 값으로 대치한다. Referring to FIG. 8, the virtual machine monitor 10 first checks the value of all bits of the PSR stored in the stack of the virtual machine monitor 10 before transferring control of exception handling to the guest operating system 20. In operation S164, the exception processing unit 34 of the guest operating system 20 may identify the virtual CPU mode and the operation state that were previously executed by replacing the previous virtual CPU mode value. For example, before a system event occurs in the virtual user mode 24 and transfers control of exception handling to the guest operating system 20 after event processing in the virtual machine monitor 10, the value of the PSR is returned to the previous virtual CPU. The value is replaced with the virtual user mode 24 value.

게스트 운영체제(20)의 예외 처리부(34)가 수행을 종료하면(S166), 프로세서의 실제 상태를 이전 상태로 복원해야 한다(S168). 이 때, 이전에 이루어지던 각종 연산의 상태, 프로세서의 실제 동작 모드 등이 완전하게 복원되어야 한다. ARM 프로세서의 경우, 게스트 운영체제(20)를 비롯하여 사용자 프로그램(22)이 프로세서의 비특권 모드인 사용자 모드에서 실행되는 관계로 이 때 PSR의 모드 비트들은 실제 사용자 모드 비트로 치환된다.When the exception processing unit 34 of the guest operating system 20 ends execution (S166), the actual state of the processor should be restored to the previous state (S168). At this time, the state of various operations previously performed, the actual operation mode of the processor, etc. must be completely restored. In the case of an ARM processor, the user operating system 20, including the guest operating system 20, is executed in a user mode, which is a non-privileged mode of the processor, at which time the mode bits of the PSR are replaced with actual user mode bits.

한편, 본 발명의 실시예에서는 가상화 계층을 제공하는 가상화부로서 가상 머신 모니터(10)를 일예로 들었으나, 이에 한정되지 않으며 하이퍼바이저나 가상화 계층을 제공하는 소프트웨어이면 어떠한 것도 가능하다. Meanwhile, in the embodiment of the present invention, the virtual machine monitor 10 is taken as an example of the virtualization unit that provides the virtualization layer. However, the present invention is not limited thereto, and any software may be used as long as it provides a hypervisor or a virtualization layer.

이상과 같이 예시된 도면을 참조로 하여, 본 발명에 따른 CPU 가상화 방법에 대하여 설명하였으나, 본 발명은 본 명세서에 개시된 실시예와 도면에 의해 한정되지 않으며, 그 발명의 기술사상 범위 내에서 당업자에 의해 다양한 변형이 이루어질 수 있음은 물론이다.Although the CPU virtualization method according to the present invention has been described with reference to the drawings exemplified as above, the present invention is not limited to the embodiments and drawings disclosed in the present specification, and those skilled in the art within the technical scope of the present invention. Of course, various modifications can be made.

상기한 바와 같이 본 발명에 의한 CPU 가상화 방법에 따르면 2가지 CPU 모드를 가지는 프로세서에서 동작하는 운영체제가 하나의 CPU 모드에서 안정적이고 효율적으로 반가상화될 수 있으며, 기존 운영체제의 커널의 수정을 최소화하여 커널의 안정성을 유지하는 한편, 개발기간을 단축시킬 수 있는 효과가 있다. As described above, according to the CPU virtualization method of the present invention, an operating system operating in a processor having two CPU modes can be stably and efficiently paravirtualized in one CPU mode, and minimizes modification of the kernel of the existing operating system. While maintaining the stability of the, it is effective to shorten the development period.

Claims (5)

복수의 게스트 운영체제를 동시 구동하며, 프로세서의 특권 모드에서 실행되는 가상화부를 제공하는 단계;Providing a virtualization unit which simultaneously runs a plurality of guest operating systems and runs in a privileged mode of a processor; 상기 프로세서의 비특권 모드를 계층적으로 서열화되어 있는 적어도 두 개의 가상 하부 모드로 분할 생성하는 단계;Partitioning and generating a non-privileged mode of the processor into at least two virtual sub modes hierarchically ordered; 상기 가상 하부 모드에서 특권 명령이 발생하면 상기 가상화부로 전이하는 단계;Transitioning to the virtualization unit when a privilege command occurs in the virtual lower mode; 상기 가상화부에서 상기 가상 하부 모드 중 상기 특권 명령을 처리하는 계층 모드로 상기 특권 명령을 전달하는 단계;Transmitting, by the virtualization unit, the privilege command to a hierarchical mode that processes the privilege command among the virtual lower modes; 상기 특권 명령을 처리하는 계층 모드에서 상기 특권 명령을 처리하고, 상기 모드를 그대로 유지하거나, 다른 어느 하나의 상기 가상 하부 모드로 전이하는 단계를 포함하는, CPU 가상화 방법.Processing the privileged command in a hierarchical mode of processing the privileged command, and maintaining the mode as it is or transitioning to any other virtual sub-mode. 제 1 항에 있어서,The method of claim 1, 상기 가상 하부 모드로의 전환시마다 전환된 상기 가상 하부 모드 정보를 저장하는 단계; Storing the switched virtual lower mode information each time the switch to the virtual lower mode; 상기 가상화부에서, 상기 저장된 가상 하부 모드 정보를 독출하여 모드를 판별하는 단계; 및 In the virtualization unit, determining a mode by reading the stored virtual lower mode information; And 상기 판별된 모드의 스택 포인터 값 또는 상기 가상 하부 모드로의 전환시마 다 전환되기 전의 상기 가상 하부 모드의 스택 포인터 값을 저장하는 단계를 더 포함하고, Storing a stack pointer value of the determined sub mode or a stack pointer value of the virtual sub mode before being switched to the virtual sub mode; 상기 가상 하부 모드로 전이하는 단계는, 상기 저장된 스택 포인터 값을 독출하여, 해당 모드의 컨텍스트를 복원하는 단계를 포함하는, CPU 가상화 방법. And transitioning to the virtual lower mode includes reading the stored stack pointer value and restoring the context of the mode. 제 2 항에 있어서, The method of claim 2, 상기 특권 명령을 전달하는 단계는, Delivering the privilege command, 상기 특권 명령을 처리하는 계층 모드의 스택 포인터 값을 독출하여 해당 모드의 컨텍스트를 설정하는 단계를 포함하는, CPU 가상화 방법. And setting a context of a corresponding mode by reading a stack pointer value of a hierarchical mode that processes the privileged command. 제 1 항에 있어서, The method of claim 1, 상기 가상 하부 모드로 전이하는 단계는, Transitioning to the virtual lower mode, 상기 특권 명령을 처리하는 계층 모드에서 상기 가상화부로 하이퍼콜을 요청하는 단계;Requesting a hypercall to the virtualization unit in a hierarchical mode of processing the privilege command; 상기 하이퍼콜을 요청받은 상기 가상화부에서 상기 다른 어느 하나의 가상 하부 모드의 스택 포인터 값을 이용하여 해당 모드의 컨텍스트를 복원하는 단계를 포함하는, CPU 가상화 방법. And restoring a context of a corresponding mode by using the stack pointer value of the other virtual lower mode in the virtualization unit that has received the hypercall. 제 4 항에 있어서, The method of claim 4, wherein 상기 가상화부에서 상기 특권 명령을 처리하는 계층 모드로 상기 특권 명령 전달시, 프로그램 상태 레지스터(Program Status Register ; PSR) 값을 상기 특권 명령이 발생된 상기 가상 하부 모드의 값으로 대치하는 단계;Replacing a Program Status Register (PSR) value with a value of the virtual lower mode in which the privilege command is generated when the privilege command is transferred to the hierarchical mode in which the virtual command processes the privilege command; 상기 특권 명령을 처리하면, 상기 프로그램 상태 레지스터 값을 실제 프로세서 모드의 값으로 치환하는 한편, 인터럽트 인에이블 되도록 설정하는 단계를 더 포함하는, CPU 가상화 방법.Processing the privileged command, replacing the program status register value with a value of an actual processor mode, and setting it to be interrupt enabled.
KR1020070020397A 2007-02-28 2007-02-28 CPU virtualization method Withdrawn KR20080079852A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
KR1020070020397A KR20080079852A (en) 2007-02-28 2007-02-28 CPU virtualization method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
KR1020070020397A KR20080079852A (en) 2007-02-28 2007-02-28 CPU virtualization method

Publications (1)

Publication Number Publication Date
KR20080079852A true KR20080079852A (en) 2008-09-02

Family

ID=40020632

Family Applications (1)

Application Number Title Priority Date Filing Date
KR1020070020397A Withdrawn KR20080079852A (en) 2007-02-28 2007-02-28 CPU virtualization method

Country Status (1)

Country Link
KR (1) KR20080079852A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102508682A (en) * 2011-11-10 2012-06-20 北京交通大学 Hardware-assisted CPU (central processing unit) virtualized environment setup method at pre-boot stage of system
WO2024037482A1 (en) * 2022-08-19 2024-02-22 华为技术有限公司 Interrupt message processing method and apparatus

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102508682A (en) * 2011-11-10 2012-06-20 北京交通大学 Hardware-assisted CPU (central processing unit) virtualized environment setup method at pre-boot stage of system
WO2024037482A1 (en) * 2022-08-19 2024-02-22 华为技术有限公司 Interrupt message processing method and apparatus

Similar Documents

Publication Publication Date Title
US8589940B2 (en) On-line replacement and changing of virtualization software
US7945436B2 (en) Pass-through and emulation in a virtual machine environment
US9483639B2 (en) Service partition virtualization system and method having a secure application
US7434224B2 (en) Plural operating systems having interrupts for all operating systems processed by the highest priority operating system
US8151263B1 (en) Real time cloning of a virtual machine
US10067783B2 (en) Interposition method suitable for hardware-assisted virtual machine
US10146570B2 (en) Nested virtualization for virtual machine exits
US7743389B2 (en) Selecting between pass-through and emulation in a virtual machine environment
KR101019937B1 (en) Secure operating system switching
CN104021063B (en) Modular computer forensic system and method based on hardware virtualization
US9465617B1 (en) Implementing upcall from secure to non-secure mode by injecting exception into non-secure mode
US20090007112A1 (en) Method for controlling a virtual machine and a virtual machine system
US20150261952A1 (en) Service partition virtualization system and method having a secure platform
CN107924325B (en) Apparatus and method for multi-level virtualization
US20130263132A1 (en) Method and system for tracking data correspondences
US7840790B1 (en) Method and system for providing device drivers in a virtualization system
Li et al. Iso-UniK: lightweight multi-process unikernel through memory protection keys
Im et al. On-demand virtualization for post-copy os migration in bare-metal cloud
US11726811B2 (en) Parallel context switching for interrupt handling
US11669620B2 (en) System platform initializer for mixed-critical systems
KR20080079852A (en) CPU virtualization method
US20240193281A1 (en) Unified encryption across multi-vendor graphics processing units
Im et al. On-demand virtualization for live migration in bare metal cloud
JP2006522971A (en) operating system
Kanda et al. SIGMA system: A multi-OS environment for embedded systems

Legal Events

Date Code Title Description
PA0109 Patent application

Patent event code: PA01091R01D

Comment text: Patent Application

Patent event date: 20070228

PG1501 Laying open of application
PC1203 Withdrawal of no request for examination
WITN Application deemed withdrawn, e.g. because no request for examination was filed or no examination fee was paid