This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: PR gas/1874: mwait/monitor don't work in 64bit


>Here is the information I got from our chip people. The address size
>override prefix is honored for "monitor" in both 16 and 32bit modes.
>In 64bit mode, RCX and RDX are used for "monitor", RAX and RCX are
>used for "mwait". This patch implements it.

Indeed, monitor and mwait GP-fault on non-zero RCX (but zero ECX) in
64-bit mode (regardless of address size override). In addition to what
you say (but consistent with what your new tests implement) monitor also
honors the address size override in 64-bit mode. Further, even in 16-bit
mode (and thus I suppose also in 32-bit mode), use of the operand size
override causes a (presumably #UD) fault (the manual mentions this only
for 64-bit mode).

Bottom line is the documentation really doesn't match actual behavior.

However, I also have doubts that in 16-bit mode the address size
handling is as you say: Using a value of 0x80000000 for eax doesn't
produce a #GP fault regardless of the use of an address size override.

Regarding the patch, I don't think hard-coding the address size
override for 16-bit operation of monitor is appropriate - under .code16
this is not going to produce the desired effect (and likewise is the
opposite 32-bit operation in 16-bit mode then missing the override). The
base problem here is that monitor's address operand, when explicitly
specified, should take the form of a memory operand rather than a plain
register (and note that the SDM doesn't indicate any particular syntax
for how the operands should be specified). Once that is done, the
address size prefixing will come out right implicitly, and the
restriction to only use %ax/%eax/%rax could be easily added to the code
in i386_index_check that already deals with AMD's SVME instructions that
have the same restriction (except that they also ignore segment
overrides, which monitor doesn't).

Further, for the disassembly part I'd really like to see the explicit
addr16/addr32 displaying to go away; these should only be output on
instructions where none of the operands indicates the address size
used.

Jan


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]