x86/emulate: Check current->arch.vm_event in hvmemul_virtual_to_linear()
PATCH 1/1 x86/emulate: Check current->arch.vm_event in hvmemul_virtual_to_linear()
Theoretically it is possible for mem_access_emulate_each_rep to be true even when current->arch.vm_event == NULL, so add an extra check to hvmemul_virtual_to_linear().
--- xen/arch/x86/hvm/emulate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/hvm/emulate.c +1 -1
@@ -514,7 +514,7 @@ static int hvmemul_virtual_to_linear(* vm_event being triggered for repeated writes to a whole page. */ if (unlikely (current->domain->arch.mem_access_emulate_each_rep) && - current->arch.vm_event->emulate_flags !=0 ) + current->arch.vm_event && current->arch.vm_event->emulate_flags !=0 ) max_reps =1 ;/*
Signature · 7 lines
1.9.1 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 07.04.16 at 10:39, <[email protected]> wrote:
Theoretically it is possible for
mem_access_emulate_each_repto be true even whencurrent->arch.vm_event== NULL, so add an extra check tohvmemul_virtual_to_linear().
Mind saying what those theoretical conditions are when this might happen?
xen/arch/x86/hvm/emulate.c static int hvmemul_virtual_to_linear( · line 517
Quoted 8 lines
xen/arch/x86/hvm/emulate.c +1
-1@@ -514,7 +514,7 @@ static int hvmemul_virtual_to_linear(* vm_event being triggered for repeated writes to a whole page. */ if (unlikely (current->domain->arch.mem_access_emulate_each_rep) && - current->arch.vm_event->emulate_flags !=0 ) + current->arch.vm_event && current->arch.vm_event->emulate_flags !=0 )
That's then the third instance of "current" here - this needs latching into a local variable.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 7 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 07.04.16 at 10:39, <[email protected]> wrote:
Theoretically it is possible for
mem_access_emulate_each_repto be true even whencurrent->arch.vm_event== NULL, so add an extra check tohvmemul_virtual_to_linear().Mind saying what those theoretical conditions are when this might happen?
This could happen if someone were to call xc_monitor_emulate_each_rep(), but not xc_monitor_enable() (when current->arch.vm_event gets allocated), or after someone called both, but afterwards called xc_monitor_disable() (when current->arch.vm_event gets freed).
Quoted 11 lines
xen/arch/x86/hvm/emulate.c static int hvmemul_virtual_to_linear( · line 517
Quoted 8 lines
xen/arch/x86/hvm/emulate.c +1
-1@@ -514,7 +514,7 @@ static int hvmemul_virtual_to_linear(* vm_event being triggered for repeated writes to a whole page. */ if (unlikely (current->domain->arch.mem_access_emulate_each_rep) && - current->arch.vm_event->emulate_flags !=0 ) + current->arch.vm_event && current->arch.vm_event->emulate_flags !=0 )That's then the third instance of "current" here - this needs latching into a local variable.
No problem.
Thanks,
Razvan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 6 lines · Razvan Cojocaru
Quoted 5 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 07.04.16 at 10:39, <[email protected]> wrote:
Theoretically it is possible for
mem_access_emulate_each_repto be true even whencurrent->arch.vm_event== NULL, so add an extra check tohvmemul_virtual_to_linear().
Quoted 7 lines
Quoted 2 lines
Mind saying what those theoretical conditions are when this might happen?
This could happen if someone were to call
xc_monitor_emulate_each_rep(), but notxc_monitor_enable()(whencurrent->arch.vm_eventgets allocated), or after someone called both, but afterwards calledxc_monitor_disable()(whencurrent->arch.vm_eventgets freed).
Actually, I need to correct myself here: only the first case applies. I was looking at older Xen source code, but there's a "d->arch.mem_access_emulate_each_rep = 0;" statement in vm_event_cleanup_domain() now, so calling xc_monitor_disable() would not cause a problem.
Thanks,
Razvan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 07.04.16 at 19:54, <[email protected]> wrote:
Quoted 5 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 07.04.16 at 10:39, <[email protected]> wrote:
Theoretically it is possible for
mem_access_emulate_each_repto be true even whencurrent->arch.vm_event== NULL, so add an extra check tohvmemul_virtual_to_linear().
Quoted 7 lines
Quoted 2 lines
Mind saying what those theoretical conditions are when this might happen?
This could happen if someone were to call
xc_monitor_emulate_each_rep(), but notxc_monitor_enable()(whencurrent->arch.vm_eventgets allocated), or after someone called both, but afterwards calledxc_monitor_disable()(whencurrent->arch.vm_eventgets freed).
Then wouldn't the correct action be to fail xc_monitor_emulate_each_rep() (i.e. whatever hypercall this resolves to) when the monitor is not enabled? (You did already clarify that the other variant isn't applicable)?
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 15 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 07.04.16 at 19:54, <[email protected]> wrote:
Quoted 5 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 07.04.16 at 10:39, <[email protected]> wrote:
Theoretically it is possible for
mem_access_emulate_each_repto be true even whencurrent->arch.vm_event== NULL, so add an extra check tohvmemul_virtual_to_linear().Quoted 7 lines
Quoted 2 lines
Mind saying what those theoretical conditions are when this might happen?
This could happen if someone were to call
xc_monitor_emulate_each_rep(), but notxc_monitor_enable()(whencurrent->arch.vm_eventgets allocated), or after someone called both, but afterwards calledxc_monitor_disable()(whencurrent->arch.vm_eventgets freed).
Quoted 4 lines
Then wouldn't the correct action be to fail
xc_monitor_emulate_each_rep()(i.e. whatever hypercall this resolves to) when the monitor is not enabled? (You did already clarify that the other variant isn't applicable)?
Yes, I think that's better. I'll do that instead.
Thanks,
Razvan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel