From mboxrd@z Thu Jan 1 00:00:00 1970 From: Don Slutz Subject: Re: [PATCH v4 01/16] xen: Add support for VMware cpuid leaves Date: Fri, 12 Sep 2014 13:46:45 -0400 Message-ID: <54133185.9070203@terremark.com> References: <1410460610-14759-1-git-send-email-dslutz@verizon.com> <1410460610-14759-2-git-send-email-dslutz@verizon.com> <5411FCCD.2000707@citrix.com> <5412DDCF020000780003465F@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <5412DDCF020000780003465F@mail.emea.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich , Andrew Cooper , xen-devel@lists.xen.org, Don Slutz Cc: Jun Nakajima , Kevin Tian , Keir Fraser , Ian Campbell , Stefano Stabellini , George Dunlap , Eddie Dong , Ian Jackson , Tim Deegan , Aravind Gopalakrishnan , Suravee Suthikulpanit , Boris Ostrovsky List-Id: xen-devel@lists.xenproject.org On 09/12/14 05:49, Jan Beulich wrote: >>>> On 11.09.14 at 21:49, wrote: >>>> >>> + case 0x10: >>> + /* (Virtual) TSC frequency in kHz. */ >>> + *eax = d->arch.tsc_khz; >>> + /* (Virtual) Bus (local apic timer) frequency in kHz. */ >>> + *ebx = 1000000000ull / APIC_BUS_CYCLE_NS / 1000ull; >> At least 1 pair of brackets please, especially as the placement of >> brackets affects the result of this particular calculation. > Or simply eliminate one of the divisions using > "1000000ull / APIC_BUS_CYCLE_NS". I am totally confused. I am happy to go with Jan's version. The confusion is that I get the same answer all the ways I try. This includes when APIC_BUS_CYCLE_NS is other values then 10. Some facts: 1) 1000000000 takes only 30bits, I am asking it to be 64. 2) I am only making it smaller in all cases. I have tested this on CentOS release 6.5 (Final) both 32 and 64 and it all says they are all the same. Here is my testing: build1:~/tmp/zz-div>p /etc/redhat-release CentOS release 6.5 (Final) build1:~/tmp/zz-div>uname -a Linux build1 2.6.32-431.el6.i686 #1 SMP Fri Nov 22 00:26:36 UTC 2013 i686 i686 i386 GNU/Linux build1:~/tmp/zz-div>cat zz-div.c #include #include int main(void) { uint32_t ebx1, ebx2, ebx3, ebx4, ebx5; uint32_t start = 1000000000ull; uint32_t APIC_BUS_CYCLE_NS; printf("start=0x%x, %d\n\n", start, start); for ( APIC_BUS_CYCLE_NS = 1; APIC_BUS_CYCLE_NS < 10000; APIC_BUS_CYCLE_NS++ ) { ebx1 = 1000000000ull / APIC_BUS_CYCLE_NS / 1000ull; ebx2 = (1000000000ull / APIC_BUS_CYCLE_NS) / 1000ull; ebx3 = 1000000000ull / (APIC_BUS_CYCLE_NS * 1000ull); ebx4 = 1000000000ull / 1000ull / APIC_BUS_CYCLE_NS; ebx5 = 1000000ull / APIC_BUS_CYCLE_NS; if ( ebx1 != ebx2 || ebx1 != ebx3 || ebx1 != ebx4 || ebx1 != ebx5 ) { printf("APIC_BUS_CYCLE_NS=%d:\n", APIC_BUS_CYCLE_NS); printf(" ebx1=0x%x, %d\n", ebx1, ebx1); printf(" ebx2=0x%x, %d\n", ebx2, ebx2); printf(" ebx3=0x%x, %d\n", ebx3, ebx3); printf(" ebx4=0x%x, %d\n", ebx4, ebx4); printf(" ebx5=0x%x, %d\n", ebx5, ebx5); } } return 0; } /* * Local variables: * mode: C * c-file-style: "BSD" * c-basic-offset: 4 * indent-tabs-mode: nil * End: */ build1:~/tmp/zz-div>gcc -g -o zz-div zz-div.c build1:~/tmp/zz-div>./zz-div start=0x3b9aca00, 1000000000 build1:~/tmp/zz-div> -Don Slutz > > > Jan >