qemu-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-discuss] How to check cpu running mode?


From: Jakob Bohm
Subject: Re: [Qemu-discuss] How to check cpu running mode?
Date: Tue, 21 Aug 2018 01:31:04 +0200
User-agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1

On 18/08/2018 05:59, krishnaLee wrote:
Jakob:
I need more help,just now,I'm trigger a page fault in 64-bit mode,see this picture:
https://github.com/krishna116/test/blob/master/test-qemu-in-64bit-mode.png

so I can write some system mode code accroding to this information,
but my follow code seems can't get the right answer, is my algorithm wrong?

//this is my algorithm in 64-bit mode:
#define CS_L_BIT 0x1<<(32+22-1)
//CS_selector_index=0x7;                     //0x38>>3
//GDTR_base=0x7E90000;                       //0x7e9f598&~0xffff
int64* segment_descriptor_address=(int64*)(int64) (*(0x7E90000+0x7*8*2));  //GDTR_base+CS_selector_index* sizeof(Segment_Descriptor*2)
if((*segment_descriptor_address)&CS_L_BIT)
{
//it is 64bit mode
}else
{
//it is Compatibility mode
}


thank you,
krishna

Detecting if the CPU is in long mode (i.e. is running 64 bit code!) is
not useful if you are not going to write low level assembler or similar
code that does something different depending on it.

Because "being in long mode" means "running a 64 bit program or OS
kernel" and similar for the other cases my (completely untested) example
code tried to detect.

So most of the time, this is a difference you choose up front, not
something you detect.



Enjoy

Jakob
--
Jakob Bohm, CIO, Partner, WiseMo A/S.  https://www.wisemo.com
Transformervej 29, 2860 Søborg, Denmark.  Direct +45 31 13 16 10
This public discussion message is non-binding and may contain errors.
WiseMo - Remote Service Management for PCs, Phones and Embedded



reply via email to

[Prev in Thread] Current Thread [Next in Thread]