flat assembler
Message board for the users of flat assembler.

Index > Windows > sysret in legacy mode?

Author
Thread Post new topic Reply to topic
b1528932



Joined: 21 May 2010
Posts: 287
b1528932
Im trying to make sysret work in legacy mode, but i cant.
syscall is executing properly, but sysret is not.

and where from are flags loaded, i dont have r11 avaiable in legace mode?
Post 23 Aug 2010, 13:29
View user's profile Send private message Reply with quote
Feryno



Joined: 23 Mar 2005
Posts: 454
Location: Czech republic, Slovak republic
Feryno
syscall / sysret are valid only in long mode in its 64-bit submode (EFER.LMA must be 1, CS.L must be 1)
EFER.SCE bit must be set to 1
CPL must be 0 for the sysret

if you want to make transition in long mode from 64-bit ring0 to ring3 compatibility mode (32 bit subsystem, WOW), then use the sysret instruction (db 0Fh, 07h)
if you want to make transition in long mode from 64-bit ring0 to ring3 64-bit mode then use the sysretq instruction - it is with the REX.W prefix (db 48h, 0Fh, 07h)
Post 24 Aug 2010, 05:18
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
b1528932



Joined: 21 May 2010
Posts: 287
b1528932
Quote:
syscall / sysret are valid only in long mode in its 64-bit submode (EFER.LMA must be 1, CS.L must be 1)

not according to amd manual. star msr hold EIP for legacy mode.
and syscall is working under bochs
Post 24 Aug 2010, 07:24
View user's profile Send private message Reply with quote
Feryno



Joined: 23 Mar 2005
Posts: 454
Location: Czech republic, Slovak republic
Feryno
you are right - another incompatibility between AMD and Intel (my post was related to Intel manual)
Intel 253666.pdf says:
IF (CS.L=0 ) or (IA32_EFER.LMA = 0) or (IA32_EFER.SCE = 0)
(* Not in 64-Bit Mode or SYSCALL/SYSRET not enabled in IA32_EFER *)
THEN #UD; FI;

seems you don't need to worry about flags register, the only one modification of flags register when executing sysret at AMD in compatibility or legacy mode is forcing flags.IF=1 which is usually set to 1 when running in ring0 (interrupts are disabled only for as much short time as possible)

How do you play with the sysret instruction - do you have a win driver? Sysret must be executed at CPL=0 (syscall is executed at CPL=3) + driver task is also necessary to set some MSRs.
Post 24 Aug 2010, 08:56
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.