x86/svm: Provide EXITINFO decodes for MOV CR/DR intercepts
PATCH 1/1 x86/svm: Provide EXITINFO decodes for MOV CR/DR intercepts
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 | 4 ++-- xen/arch/x86/include/asm/hvm/svm/vmcb.h | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-)
xen/arch/x86/hvm/svm/svm.c +2 -2
@@ -1740,7 +1740,7 @@ static void svm_vmexit_do_cr_access( cr = vmcb->exitcode -VMEXIT_CR0_READ ; dir = (cr >15 ); cr &=0xf ; - gp = vmcb->exitinfo1 &0xf ; + gp = vmcb->ei.mov.gpr; rc = dir ?hvm_mov_to_cr (cr, gp) :hvm_mov_from_cr (cr, gp);
@@ -2961,7 +2961,7 @@ void svm_vmexit_handler(void) case VMEXIT_CR0_READ ... VMEXIT_CR15_READ: case VMEXIT_CR0_WRITE ... VMEXIT_CR15_WRITE: -if ( cpu_has_svm_decode && (vmcb->exitinfo1 & (1ULL <<63 )) ) +if ( cpu_has_svm_decode && vmcb->ei.mov.mov_insn )svm_vmexit_do_cr_access (vmcb, regs);else if ( !hvm_emulate_one_insn (x86_insn_is_cr_access,"CR access" ) )hvm_inject_hw_exception (X86_EXC_GP ,0 );
xen/arch/x86/include/asm/hvm/svm/vmcb.h +5 -0
@@ -450,6 +450,11 @@ struct vmcb_struct {uint64_t nrip; } io; +struct { +uint64_t gpr:4 ; + uint64_t :59; +bool mov_insn:1 ;/* MOV, as opposed to LMSW, CLTS, etc */ + } mov;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]>
One remark though:
xen/arch/x86/include/asm/hvm/svm/vmcb.h struct vmcb_struct { · line 457
Quoted 11 lines
xen/arch/x86/include/asm/hvm/svm/vmcb.h +5
-0@@ -450,6 +450,11 @@ struct vmcb_struct {uint64_t nrip; } io; +struct { +uint64_t gpr:4 ; + uint64_t :59; +bool mov_insn:1 ;/* MOV, as opposed to LMSW, CLTS, etc */ + } mov;
The field being named just "mov" makes it apparently applicable to DRn moves, too (and the title supports this), yet the top bit doesn't have this meaning there. So perhaps say "MOV-CR" (or alike) in the comment?
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.
Quoted 7 lines
One remark though:
Quoted 4 lines
xen/arch/x86/include/asm/hvm/svm/vmcb.h +0
-0@@ -450,6 +450,11 @@ struct vmcb_struct {
Quoted 10 lines
xen/arch/x86/include/asm/hvm/svm/vmcb.h struct vmcb_struct { · line 457
Quoted 7 lines
xen/arch/x86/include/asm/hvm/svm/vmcb.h +5
-0uint64_t nrip; } io; +struct { +uint64_t gpr:4 ; + uint64_t :59; +bool mov_insn:1 ;/* MOV, as opposed to LMSW, CLTS, etc */ + } mov;The field being named just "mov" makes it apparently applicable to DRn moves, too (and the title supports this), yet the top bit doesn't have this meaning there. So perhaps say "MOV-CR" (or alike) in the comment?
Hmm - I'd not spotted that distinction.
Xen never decodes the exitinfo for a DR access - we just resync dr state, drop the intercept and reenter the guest.
Therefore I think it would be better to rename "mov" to "mov_cr" so you can't use the mov_insn field in a context that plausibly looks like a dr access.
Thoughts?
~Andrew
Quoted 19 lines · Andrew Cooper
Quoted 5 lines · Jan Beulich
Quoted 4 lines · Andrew Cooper
xen/arch/x86/include/asm/hvm/svm/vmcb.h +0
-0@@ -450,6 +450,11 @@ struct vmcb_struct {Quoted 10 lines
xen/arch/x86/include/asm/hvm/svm/vmcb.h struct vmcb_struct { · line 457
Quoted 7 lines
xen/arch/x86/include/asm/hvm/svm/vmcb.h +5
-0uint64_t nrip; } io; +struct { +uint64_t gpr:4 ; + uint64_t :59; +bool mov_insn:1 ;/* MOV, as opposed to LMSW, CLTS, etc */ + } mov;The field being named just "mov" makes it apparently applicable to DRn moves, too (and the title supports this), yet the top bit doesn't have this meaning there. So perhaps say "MOV-CR" (or alike) in the comment?
Hmm - I'd not spotted that distinction.
Quoted 8 lines
Xen never decodes the exitinfo for a DR access - we just resync dr state, drop the intercept and reenter the guest.
Therefore I think it would be better to rename "mov" to "
mov_cr" so you can't use themov_insnfield in a context that plausibly looks like a dr access.Thoughts?
That was my other thought; it merely seemed to me that updating the comment would allow future (if ever) use with MOV-DR. So yes, if you prefer going that route: Fine with me.
Jan
Quoted 22 lines · Jan Beulich
Quoted 21 lines · Andrew Cooper
Quoted 5 lines · Jan Beulich
Quoted 4 lines · Andrew Cooper
xen/arch/x86/include/asm/hvm/svm/vmcb.h +0
-0@@ -450,6 +450,11 @@ struct vmcb_struct {Quoted 10 lines
xen/arch/x86/include/asm/hvm/svm/vmcb.h struct vmcb_struct { · line 457
Quoted 7 lines
xen/arch/x86/include/asm/hvm/svm/vmcb.h +5
-0uint64_t nrip; } io; +struct { +uint64_t gpr:4 ; + uint64_t :59; +bool mov_insn:1 ;/* MOV, as opposed to LMSW, CLTS, etc */ + } mov;The field being named just "mov" makes it apparently applicable to DRn moves, too (and the title supports this), yet the top bit doesn't have this meaning there. So perhaps say "MOV-CR" (or alike) in the comment?
Hmm - I'd not spotted that distinction.
Xen never decodes the exitinfo for a DR access - we just resync dr state, drop the intercept and reenter the guest.
Quoted 8 lines
Quoted 5 lines
Therefore I think it would be better to rename "mov" to "
mov_cr" so you can't use themov_insnfield in a context that plausibly looks like a dr access.Thoughts?
That was my other thought; it merely seemed to me that updating the comment would allow future (if ever) use with MOV-DR. So yes, if you prefer going that route: Fine with me.
Will do. I don't foresee us ever needing to inspect the dr decode information.
~Andrew