xen: x86: copy back tsc info, not pointer to tsc info in domctl
PATCH v2 1/2 xen: x86: copy back tsc info, not pointer to tsc info in domctl
In 38b37ed82705 "x86/domctl: cleanup", XEN_DOMCTL_gettscinfo was changed to use the standard copyback mechanism.
However the output TSC Info is a guerst handle, i.e. a pointer to the location for the information, copyback just copies the unchanged pointer back.
Switch back to fetching the details into a local struct and explicitly copying it back.
This caused test failures in the Cambridge instance of osstest, but not for some reason in the production instance.
---
v2: Copy back outside domain pause.
--- xen/arch/x86/domctl.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
xen/arch/x86/domctl.c +8 -5
@@ -856,13 +856,16 @@ long arch_do_domctl( ret = -EINVAL ; else { +xen_guest_tsc_info_t info = {0 }; +domain_pause (d); -tsc_get_info (d, &domctl->u.tsc_info.info.tsc_mode, - &domctl->u.tsc_info.info.elapsed_nsec, - &domctl->u.tsc_info.info.gtsc_khz, - &domctl->u.tsc_info.info.incarnation); +tsc_get_info (d, &info.tsc_mode, + &info.elapsed_nsec, + &info.gtsc_khz, + &info.incarnation);domain_unpause (d); - copyback =1 ; +if (copy_to_guest (domctl->u.tsc_info.out_info, &info,1 ) ) + ret = -EFAULT ; }break ;
Signature · 1 line
1.7.10.4
Quoted 15 lines
Quoted 1 line
Quoted 1 line · On 26.05.15 at 13:14, <[email protected]> wrote:
xen/arch/x86/domctl.c +3
-4@@ -856,13 +856,16 @@ long arch_do_domctl( ret = -EINVAL ; else { +xen_guest_tsc_info_t info = {0 }; +domain_pause (d); -tsc_get_info (d, &domctl->u.tsc_info.info.tsc_mode, - &domctl->u.tsc_info.info.elapsed_nsec, - &domctl->u.tsc_info.info.gtsc_khz, - &domctl->u.tsc_info.info.incarnation); + tsc_get_info(d, &info.tsc_mode,
xen/arch/x86/domctl.c long arch_do_domctl( · line 871
Quoted 10 lines
xen/arch/x86/domctl.c +5
-1+ &info.elapsed_nsec, + &info.gtsc_khz, + &info.incarnation);domain_unpause (d); - copyback =1 ; +if (copy_to_guest (domctl->u.tsc_info.out_info, &info,1 ) ) + ret = -EFAULT ; }break ;
I have to admit that I don't see the point of this change when patch 2 basically undoes it all.
Jan
Quoted 20 lines · Jan Beulich
Quoted 20 lines
Quoted 1 line
Quoted 1 line · On 26.05.15 at 13:14, <[email protected]> wrote:
xen/arch/x86/domctl.c +6
-5@@ -856,13 +856,16 @@ long arch_do_domctl( ret = -EINVAL ; else { +xen_guest_tsc_info_t info = {0 }; +domain_pause (d); -tsc_get_info (d, &domctl->u.tsc_info.info.tsc_mode, - &domctl->u.tsc_info.info.elapsed_nsec, - &domctl->u.tsc_info.info.gtsc_khz, - &domctl->u.tsc_info.info.incarnation); +tsc_get_info (d, &info.tsc_mode, + &info.elapsed_nsec, + &info.gtsc_khz, + &info.incarnation);domain_unpause (d); - copyback =1 ;
Quoted 8 lines
xen/arch/x86/domctl.c long arch_do_domctl( · line 871
Quoted 5 lines
xen/arch/x86/domctl.c +2
-0+if (copy_to_guest (domctl->u.tsc_info.out_info, &info,1 ) ) + ret = -EFAULT ; }break ;I have to admit that I don't see the point of this change when patch 2 basically undoes it all.
I thought so at first but the restructuring in the second patch was large enough that I didn't want to mix it in with an actual functional change. Plus the second patch does more than undo it, it removes "info." from the domctl access.
Ian.
Quoted 31 lines
Quoted 1 line
Quoted 1 line · On 26.05.15 at 14:56, <[email protected]> wrote:
Quoted 20 lines · Jan Beulich
Quoted 20 lines
Quoted 1 line
Quoted 1 line · On 26.05.15 at 13:14, <[email protected]> wrote:
xen/arch/x86/domctl.c +6
-5@@ -856,13 +856,16 @@ long arch_do_domctl( ret = -EINVAL ; else { +xen_guest_tsc_info_t info = {0 }; +domain_pause (d); -tsc_get_info (d, &domctl->u.tsc_info.info.tsc_mode, - &domctl->u.tsc_info.info.elapsed_nsec, - &domctl->u.tsc_info.info.gtsc_khz, - &domctl->u.tsc_info.info.incarnation); +tsc_get_info (d, &info.tsc_mode, + &info.elapsed_nsec, + &info.gtsc_khz, + &info.incarnation);domain_unpause (d); - copyback =1 ;Quoted 8 lines
xen/arch/x86/domctl.c long arch_do_domctl( · line 871
Quoted 5 lines
xen/arch/x86/domctl.c +2
-0+if (copy_to_guest (domctl->u.tsc_info.out_info, &info,1 ) ) + ret = -EFAULT ; }break ;I have to admit that I don't see the point of this change when patch 2 basically undoes it all.
Quoted 4 lines
I thought so at first but the restructuring in the second patch was large enough that I didn't want to mix it in with an actual functional change. Plus the second patch does more than undo it, it removes "info." from the domctl access.
Hmm, yeah. I guess in that case the fix (patch 1) could have been to drop out_info, and the cleanup (patch 2) to eliminate struct xen_guest_tsc_info. But anyway, feel free to commit as is, taking this as an ack for patch 2 even in its current shape.
Jan
Quoted 36 lines · Jan Beulich
Quoted 31 lines
Quoted 1 line
Quoted 1 line · On 26.05.15 at 14:56, <[email protected]> wrote:
Quoted 20 lines · Jan Beulich
Quoted 20 lines
Quoted 1 line
Quoted 1 line · On 26.05.15 at 13:14, <[email protected]> wrote:
xen/arch/x86/domctl.c +6
-5@@ -856,13 +856,16 @@ long arch_do_domctl( ret = -EINVAL ; else { +xen_guest_tsc_info_t info = {0 }; +domain_pause (d); -tsc_get_info (d, &domctl->u.tsc_info.info.tsc_mode, - &domctl->u.tsc_info.info.elapsed_nsec, - &domctl->u.tsc_info.info.gtsc_khz, - &domctl->u.tsc_info.info.incarnation); +tsc_get_info (d, &info.tsc_mode, + &info.elapsed_nsec, + &info.gtsc_khz, + &info.incarnation);domain_unpause (d); - copyback =1 ;Quoted 8 lines
xen/arch/x86/domctl.c long arch_do_domctl( · line 871
Quoted 5 lines
xen/arch/x86/domctl.c +2
-0+if (copy_to_guest (domctl->u.tsc_info.out_info, &info,1 ) ) + ret = -EFAULT ; }break ;I have to admit that I don't see the point of this change when patch 2 basically undoes it all.
Quoted 4 lines
I thought so at first but the restructuring in the second patch was large enough that I didn't want to mix it in with an actual functional change. Plus the second patch does more than undo it, it removes "info." from the domctl access.
Quoted 4 lines
Hmm, yeah. I guess in that case the fix (patch 1) could have been to drop
out_info, and the cleanup (patch 2) to eliminate structxen_guest_tsc_info. But anyway, feel free to commit as is, taking this as an ack for patch 2 even in its current shape.
Done, thanks.