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

[Xen-devel] Question about patch "svm: fix incorrect TSC scaling"



Hi Haozhong and AMD SVM maintainers,

I am writing to ask about below patch as I am not familiar with AMD tsc
scaling:

 commit 11eeca65126e51f03a883907751d5ccbe4f35aa3
 Author: Haozhong Zhang <haozhong.zhang@xxxxxxxxx>
 Date:   Tue Dec 8 09:46:12 2015 +0100

     svm: fix incorrect TSC scaling
 
     SVM TSC ratio is incorrectly used in the current
     svm_get_tsc_offset(). This patch replaces the scaling logic in
     svm_get_tsc_offset() with a correct implementation.
 
     Signed-off-by: Haozhong Zhang <haozhong.zhang@xxxxxxxxx>
     Reviewed-by: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>


The below equation is used in the above patch:

-------------------------
host_tsc * ratio * 2^-32.
-------------------------


While the below incorrect equation (indeed code) was used before above patch:

---------------------------------------------------------------
offset = (((host_tsc >> 32U) * (ratio >> 32U)) << 32U) +
         (host_tsc & 0xffffffffULL) * (ratio & 0xffffffffULL);
return guest_tsc - offset;
---------------------------------------------------------------

Can I summarize the above code as:

tsc_h * mult * 2^32 + tsc_l * frag or

tsc_h * int * 2^32 + tsc_l * frag ?


Would you please help confirm why the equation is replaced? Or would you please
help and let me know the chapter/page of AMD reference manual showing the
correct equation?

Thank you very much!

Dongli Zhang

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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