Re: Timer calculation for hypervisor

nick <[email protected]> Sun, 17 Jul 2022 12:57:33 +0300
Newsgroups gmane.comp.emulators.bochs.devel
Message-ID <[email protected]>
Hi,

Thanks for the reply. My couple of nanoseconds is 0x3000(vmx timer) and 
then i call `bx_pc_system.tickn(0x3000)`. Initially my thought process 
behind this is that the minimum timer(excluding hpet vdev) is around 
0x3000, so instead doing a vm exit after every instruction and call the 
bochs tickn(), I thought it would be faster to do it for a minimum event 
needed time. I noticed that if I change the vmx timer to `100` and the 
tickn to a big number like `1000000` the execution is way faster. So I 
am trying to figure out what would be the fastest execution. Are you 
suggesting that I should call tick1() after every executed guest 
instruction? I thought that there should be a way based on my host cpu 
to calculate the right timer values.

Thanks,

On 7/17/2022 7:37 AM, [email protected] wrote:
> Couple of nanoseconds might be several execution cycles on your host.
> Single cache miss with DRAM access is ~10ns.
> How much is your "couple"?
>
> In general Bochs is trying to be as reproducible as possible and therefore its time is defined according to x86 instructions execution.
> 1 tick = 1 instructions.
> For rep string flows 1 tick = 1 iteration of the repeat.
> This models machine with exactly 1 IPC
>
> -----Original Message-----
> From: nick <[email protected]>
> Sent: Sunday, 17 July 2022 2:21
> To: [email protected]
> Subject: [Bochs-developers] Timer calculation for hypervisor
>
> Greetings,
>
> I am doing a fun project, where I am replacing the cpu emulator of bochs with a hypervisor(intel vmx).
>
> There are virtual devices, like the keyboard controller, that are using a timer for certain events.
>
> The way I am handling it with the hypervisor is to use a vmx timer exit(VMX-preemption timer) every couple nanoseconds and then handle it in bochs by calling `bx_pc_system.tickn(timer)`.
>
> I noticed that there is a significant execution delay based on the value of the timers. I was wondering what is the right way to calculate the timer for the fastest execution(both the VMX and the value in bochs).
>
> My cpu is `i7-6700K CPU @ 4.00GHz` if that somehow helps with the calculation.
>
> Thank you,
>
>
>
>
>
> _______________________________________________
> bochs-developers mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/bochs-developers
>