[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v2 2/3] xen/x86: ensure copying to L1 guest in update_secondary_system_time()



>>> On 23.02.17 at 10:41, <haozhong.zhang@xxxxxxxxx> wrote:
> @@ -992,10 +993,30 @@ bool_t update_secondary_system_time(struct vcpu *v,
>  {
>      XEN_GUEST_HANDLE(vcpu_time_info_t) user_u = v->arch.time_info_guest;
>      smap_check_policy_t saved_policy;
> +    bool nested_guest_mode = false;
>  
>      if ( guest_handle_is_null(user_u) )
>          return 1;
>  
> +    /*
> +     * Must be before all following __copy_field_to_guest() and
> +     * __copy_to_guest().
> +     *
> +     * Otherwise, if 'v' is in the nested guest mode, paging_gva_to_gfn() 
> called
> +     * from __copy_field_to_guest() and __copy_to_guest() will treat the 
> target
> +     * address as L2 gva, and __copy_field_to_guest() and __copy_to_guest() 
> will
> +     * consequently copy runstate to L2 guest rather than L1 guest.
> +     *
> +     * Therefore, we clear the nested guest flag before 
> __copy_field_to_guest()
> +     * and __copy_to_guest(), and restore the flag after all guest copy.
> +     */
> +    if ( nestedhvm_enabled(v->domain) )
> +    {
> +        nested_guest_mode = nestedhvm_is_n2(v);
> +        if ( nested_guest_mode )
> +            nestedhvm_vcpu_exit_guestmode(v);
> +    }
> +
>      saved_policy = smap_policy_change(v, SMAP_CHECK_ENABLED);
>  
>      /* 1. Update userspace version. */

There is an early exit path right below here. Taking this together with
the code and comment redundancy with patch 1, this is a pretty clear
sign that you want to rename smap_policy_change() and use the new
function, taking care of both issues, in both code paths.

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.