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: krishnaLee
Subject: Re: [Qemu-discuss] How to check cpu running mode?
Date: Tue, 21 Aug 2018 14:34:34 +0800 (CST)

Jakob,
I know very  few things about write low level asm-code and compile it,I should 
collect more informations if I want to continue,
may be I should using some debugger to observe the  various registers and avoid 
writing this code.




but thank you very much,
krishna.








At 2018-08-21 07:31:04, "Jakob Bohm" <address@hidden> wrote:
>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]