x86/pv: Fix determination of 64bit mode in emulate_privilege_op()
PATCH 1/2 x86/pv: Fix determination of 64bit mode in emulate_privilege_op()
ctxt->addr_size is expressed in bits rather than bytes, and has the value 16, 32 or 64. Comparing < 8 made the intended non-64bit paths dead.
---
CC: Jan Beulich <[email protected]>
--- xen/arch/x86/traps.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
xen/arch/x86/traps.c +2 -2
@@ -2100,7 +2100,7 @@ static int pv_emul_virt_to_linear(unsigned long base, unsigned long offset, *addr = base + offset; -if ( ctxt->addr_size <8 ) +if ( ctxt->addr_size <64 ) {if ( limit < bytes -1 || offset > limit - bytes +1 ) rc =X86EMUL_EXCEPTION ;
@@ -2169,7 +2169,7 @@ static int priv_op_read_segment(enum x86_segment seg, struct segment_register *reg, struct x86_emulate_ctxt *ctxt) { -if ( ctxt->addr_size <8 ) +if ( ctxt->addr_size <64 ) {unsigned long limit;unsigned int sel, ar;
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 2/2 x86/pv: Defer I/O bitmap checks even in 64bit mode for emulate_privilege_op()
The I/O bitmap doesn't change function depending on mode. 64bit userspace such as an X server still needs to enter guest_io_okay() to find that the PV kernel did set up an appropriate virtual I/O bitmap to permit access.
While moving the check, alter its representation to be easier to read.
---
CC: Jan Beulich <[email protected]>
--- xen/arch/x86/traps.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
xen/arch/x86/traps.c +13 -5
@@ -2169,6 +2169,19 @@ static int priv_op_read_segment(enum x86_segment seg, struct segment_register *reg, struct x86_emulate_ctxt *ctxt) { +/* Check if this is an attempt to access to I/O bitmap. */ +if ( seg == x86_seg_tr ) + { +switch ( ctxt->opcode ) + { + case 0x6c ... 0x6f: /* ins / outs */ + case 0xe4 ... 0xe7: /* in / out (immediate port) */ + case 0xec ... 0xef: /* in / out (port in %dx) */ +/* Defer the check to priv_op_{read,write}_io(). */ +return X86EMUL_DONE ; + } + } +if ( ctxt->addr_size <64 ) {unsigned long limit;
@@ -2182,11 +2195,6 @@ static int priv_op_read_segment(enum x86_segment seg,case x86_seg_fs: sel =read_sreg (fs);break ;case x86_seg_gs: sel =read_sreg (gs);break ;case x86_seg_ss: sel = ctxt->regs->ss;break ; -case x86_seg_tr: -/* Check if this is an attempt to access to I/O bitmap. */ -if ( (ctxt->opcode & ~0xb ) ==0xe4 || (ctxt->opcode & ~3 ) ==0x6c ) -return X86EMUL_DONE ; -/* fall through */ default :return X86EMUL_UNHANDLEABLE ; }
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 2/2] x86/pv: Defer I/O bitmap checks even in 64bit mode for emulate_privilege_op()
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 05.01.17 at 13:00, <[email protected]> wrote:
xen/arch/x86/traps.c +2
-0@@ -2169,6 +2169,19 @@ static int priv_op_read_segment(enum x86_segment seg, struct segment_register *reg, struct x86_emulate_ctxt *ctxt) { +/* Check if this is an attempt to access to I/O bitmap. */ +if ( seg == x86_seg_tr )
xen/arch/x86/traps.c static int priv_op_read_segment(enum x86_segment seg, · line 2183
Quoted 10 lines
xen/arch/x86/traps.c +10
-0+ { +switch ( ctxt->opcode ) + { + case 0x6c ... 0x6f: /* ins / outs */ + case 0xe4 ... 0xe7: /* in / out (immediate port) */ + case 0xec ... 0xef: /* in / out (port in %dx) */ +/* Defer the check to priv_op_{read,write}_io(). */ +return X86EMUL_DONE ; + } + }
Well, I think I did like the old way a little better, but if you prefer this switch(), then fine. When putting together my variant of the change for testing I did notice the comment to have a wrong "to" (should be "the"), so with that adjusted
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 2/2] x86/pv: Defer I/O bitmap checks even in 64bit mode for emulate_privilege_op()
Quoted 14 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 05.01.17 at 13:00, <[email protected]> wrote:
xen/arch/x86/traps.c +7
-0@@ -2169,6 +2169,19 @@ static int priv_op_read_segment(enum x86_segment seg, struct segment_register *reg, struct x86_emulate_ctxt *ctxt) { +/* Check if this is an attempt to access to I/O bitmap. */ +if ( seg == x86_seg_tr ) + { +switch ( ctxt->opcode ) + { + case 0x6c ... 0x6f: /* ins / outs */ + case 0xe4 ... 0xe7: /* in / out (immediate port) */
Quoted 8 lines
xen/arch/x86/traps.c static int priv_op_read_segment(enum x86_segment seg, · line 2183
Quoted 5 lines
xen/arch/x86/traps.c +5
-0+ case 0xec ... 0xef: /* in / out (port in %dx) */ +/* Defer the check to priv_op_{read,write}_io(). */ +return X86EMUL_DONE ; + } + }Well, I think I did like the old way a little better, but if you prefer this
switch(), then fine. When putting together my variant of the change for testing I did notice the comment to have a wrong "to" (should be "the"),
So it is. Will fix.
Quoted 2 lines
so with that adjusted
Reviewed-by Jan Beulich <[email protected]>
Thanks.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 05.01.17 at 13:00, <[email protected]> wrote:
ctxt->addr_sizeis expressed in bits rather than bytes, and has the value 16, 32 or 64. Comparing < 8 made the intended non-64bit paths dead.Signed-off-by Andrew Cooper <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel