x86/svm: Provide EXITINFO decodes for IO intercetps
PATCH 1/1 x86/svm: Provide EXITINFO decodes for IO intercetps
This removes raw number manipulation, and makes the logic easier to follow.
No functional change.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
--- xen/arch/x86/hvm/svm/svm.c | 11 +++++------ xen/arch/x86/include/asm/hvm/svm/vmcb.h | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 6 deletions(-)
xen/arch/x86/hvm/svm/svm.c +5 -6
@@ -2939,13 +2939,12 @@ void svm_vmexit_handler(void)break ;case VMEXIT_IOIO : -if ( (vmcb->exitinfo1 & (1u <<2 )) ==0 ) +if ( !vmcb->ei.io.str ) { -uint16_t port = (vmcb->exitinfo1 >>16 ) &0xFFFF ; -int bytes = ((vmcb->exitinfo1 >>4 ) &0x07 ); -int dir = (vmcb->exitinfo1 &1 ) ?IOREQ_READ :IOREQ_WRITE ; -if (handle_pio (port, bytes, dir) ) -__update_guest_eip (regs, vmcb->exitinfo2 - vmcb->rip); +if (handle_pio (vmcb->ei.io.port, + vmcb->ei.io.bytes, + vmcb->ei.io.in ?IOREQ_READ :IOREQ_WRITE ) ) +__update_guest_eip (regs, vmcb->ei.io.nrip - vmcb->rip); }else if ( !hvm_emulate_one_insn (x86_insn_is_portio,"port I/O" ) )hvm_inject_hw_exception (TRAP_gp_fault,0 );
xen/arch/x86/include/asm/hvm/svm/vmcb.h +14 -0
@@ -436,6 +436,20 @@ struct vmcb_struct {uint64_t exitinfo2;/* offset 0x80 */ };union { +struct { +bool in:1 ; + bool :1; +bool str:1 ; + bool /* rep */:1; +uint16_t bytes:3 ; + uint16_t /* asz */:3; + uint16_t /* seg */:3; + uint16_t :3; +uint16_t port; + uint32_t :32; + +uint64_t nrip; + } io;struct {uint16_t sel; uint64_t :48;
Signature · 1 line
2.30.2
Quoted 5 lines · Andrew Cooper
This removes raw number manipulation, and makes the logic easier to follow.
No functional change.
Signed-off-by Andrew Cooper <[email protected]>
But I have a question:
Quoted 4 lines
xen/arch/x86/include/asm/hvm/svm/vmcb.h +0
-0@@ -436,6 +436,20 @@ struct vmcb_struct {uint64_t exitinfo2;/* offset 0x80 */
xen/arch/x86/include/asm/hvm/svm/vmcb.h struct vmcb_struct { · line 446
Quoted 10 lines
xen/arch/x86/include/asm/hvm/svm/vmcb.h +8
-0};union { +struct { +bool in:1 ; + bool :1; +bool str:1 ; + bool /* rep */:1; +uint16_t bytes:3 ; + uint16_t /* asz */:3; + uint16_t /* seg */:3;
Is there a particular reason you comment out some of the field names? I can see that "asz" might be a little odd to use, but both "rep" and "seg" are imo fine to have a name even if currently there's nothing accessing these fields.
Jan
Quoted 7 lines · Jan Beulich
Quoted 5 lines · Andrew Cooper
This removes raw number manipulation, and makes the logic easier to follow.
No functional change.
Signed-off-by Andrew Cooper <[email protected]>Reviewed-by Jan Beulich <[email protected]>
Thanks.
Although looking through the emails on list, apparently the vmx side of this got missed.
They're both to simplify the current monitor patch.
Quoted 13 lines
But I have a question:
Quoted 10 lines
xen/arch/x86/include/asm/hvm/svm/vmcb.h +4
-0@@ -436,6 +436,20 @@ struct vmcb_struct {uint64_t exitinfo2;/* offset 0x80 */ };union { +struct { +bool in:1 ; + bool :1; +bool str:1 ;
Quoted 8 lines
xen/arch/x86/include/asm/hvm/svm/vmcb.h struct vmcb_struct { · line 446
Quoted 4 lines
xen/arch/x86/include/asm/hvm/svm/vmcb.h +4
-0+ bool /* rep */:1; + uint16_t bytes:3; + uint16_t /* asz */:3; + uint16_t /* seg */:3;Is there a particular reason you comment out some of the field names? I can see that "asz" might be a little odd to use, but both "rep" and "seg" are imo fine to have a name even if currently there's nothing accessing these fields.
There's not currently used, and in particular asz looks hard to use as it doesn't appear to translate nicely. Also, I don't that seg matches Xen's x86_segment_* encoding.
I can uncomment them if you'd prefer, but I thought this was marginally safer. I suppose it doesn't really matter.
As for asz, I previously had osz to match before renaming to bytes. Suggestions welcome.
~Andrew
Quoted 6 lines · Andrew Cooper
Quoted 5 lines · Jan Beulich
Quoted 4 lines · Andrew Cooper
This removes raw number manipulation, and makes the logic easier to follow.
No functional change.
Quoted 7 lines
Quoted 2 lines
Quoted 1 line
Signed-off-by Andrew Cooper <[email protected]>Reviewed-by Jan Beulich <[email protected]>Thanks.
Although looking through the emails on list, apparently the vmx side of this got missed.
I was wondering, but then expected it would be a separate patch at some other time.
Quoted 19 lines
Quoted 10 lines
Quoted 10 lines
xen/arch/x86/include/asm/hvm/svm/vmcb.h +4
-0@@ -436,6 +436,20 @@ struct vmcb_struct {uint64_t exitinfo2;/* offset 0x80 */ };union { +struct { +bool in:1 ; + bool :1; +bool str:1 ;Quoted 8 lines
xen/arch/x86/include/asm/hvm/svm/vmcb.h struct vmcb_struct { · line 446
Quoted 4 lines
xen/arch/x86/include/asm/hvm/svm/vmcb.h +4
-0+ bool /* rep */:1; + uint16_t bytes:3; + uint16_t /* asz */:3; + uint16_t /* seg */:3;Is there a particular reason you comment out some of the field names? I can see that "asz" might be a little odd to use, but both "rep" and "seg" are imo fine to have a name even if currently there's nothing accessing these fields.
Quoted 6 lines
There's not currently used, and in particular asz looks hard to use as it doesn't appear to translate nicely. Also, I don't that seg matches Xen's x86_segment_* encoding.
I can uncomment them if you'd prefer, but I thought this was marginally safer. I suppose it doesn't really matter.
I would appreciate if you uncommented rep and seg; leaving asz commented is ...
Quoted 2 lines
As for asz, I previously had osz to match before renaming to bytes. Suggestions welcome.
... perhaps better, as the name would be misleading, and half_asz isn't very nice either.
Jan