|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH-for-4.9 v1 8/8] x86/hvm: serialize trap injecting producer and consumer
On 11/18/2016 07:14 PM, Paul Durrant wrote:
> Since injection works on a remote vCPU, and since there's no
> enforcement of the subject vCPU being paused, there's a potential race
> between the producing and consuming sides. Fix this by leveraging the
> vector field as synchronization variable.
>
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
> [re-based]
> Signed-off-by: Paul Durrant <paul.durrant@xxxxxxxxxx>
> ---
> Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
> ---
> xen/arch/x86/hvm/dm.c | 5 ++++-
> xen/arch/x86/hvm/hvm.c | 7 ++++---
> xen/include/asm-x86/hvm/hvm.h | 2 ++
> 3 files changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/xen/arch/x86/hvm/dm.c b/xen/arch/x86/hvm/dm.c
> index ee0aeed..45e164e 100644
> --- a/xen/arch/x86/hvm/dm.c
> +++ b/xen/arch/x86/hvm/dm.c
> @@ -300,13 +300,16 @@ static int dm_op_inject_trap(struct domain *d, unsigned
> int vcpuid,
> if ( vcpuid >= d->max_vcpus || (v = d->vcpu[vcpuid]) == NULL )
> return -EINVAL;
>
> - if ( v->arch.hvm_vcpu.inject_trap.vector != -1 )
> + if ( cmpxchg(&v->arch.hvm_vcpu.inject_trap.vector,
> + HVM_TRAP_VECTOR_UNSET, HVM_TRAP_VECTOR_UPDATING) !=
> + HVM_TRAP_VECTOR_UNSET )
> return -EBUSY;
>
> v->arch.hvm_vcpu.inject_trap.type = type;
> v->arch.hvm_vcpu.inject_trap.insn_len = insn_len;
> v->arch.hvm_vcpu.inject_trap.error_code = error_code;
> v->arch.hvm_vcpu.inject_trap.cr2 = cr2;
> + smp_wmb();
> v->arch.hvm_vcpu.inject_trap.vector = vector;
>
> return 0;
> diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
> index 90c4b43..f817c32 100644
> --- a/xen/arch/x86/hvm/hvm.c
> +++ b/xen/arch/x86/hvm/hvm.c
> @@ -533,10 +533,11 @@ void hvm_do_resume(struct vcpu *v)
> }
>
> /* Inject pending hw/sw trap */
> - if ( v->arch.hvm_vcpu.inject_trap.vector != -1 )
> + if ( v->arch.hvm_vcpu.inject_trap.vector >= 0 )
> {
> + smp_rmb();
> hvm_inject_trap(&v->arch.hvm_vcpu.inject_trap);
> - v->arch.hvm_vcpu.inject_trap.vector = -1;
> + v->arch.hvm_vcpu.inject_trap.vector = HVM_TRAP_VECTOR_UNSET;
> }
> }
Does this mean I should rebase my vm_event patch?
Thanks,
Razvan
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |