lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <46C9A38D.6090509@bull.net>
Date:	Mon, 20 Aug 2007 16:22:05 +0200
From:	Laurent Vivier <Laurent.Vivier@...l.net>
To:	Avi Kivity <avi@...ranet.com>
Cc:	kvm-devel <kvm-devel@...ts.sourceforge.net>,
	linux-kernel <linux-kernel@...r.kernel.org>,
	virtualization <virtualization@...ts.linux-foundation.org>
Subject: Re: [kvm-devel] [PATCH 4/4] Modify KVM to update guest time	accounting.

Avi Kivity wrote:
> Laurent Vivier wrote:
>> Avi Kivity wrote:
>>   
>>> Laurent Vivier wrote:
>>>     
>>>> [PATCH 4/4] Modify KVM to update guest time accounting.
>>>>
>>>>   
>>>>       
>>>> Index: kvm/drivers/kvm/kvm.h
>>>> ===================================================================
>>>> --- kvm.orig/drivers/kvm/kvm.h    2007-08-20 13:23:53.000000000 +0200
>>>> +++ kvm/drivers/kvm/kvm.h    2007-08-20 13:23:58.000000000 +0200
>>>> @@ -589,6 +589,17 @@ void kvm_mmu_unload(struct kvm_vcpu *vcp
>>>>  
>>>>  int kvm_hypercall(struct kvm_vcpu *vcpu, struct kvm_run *run);
>>>>  
>>>> +static inline void kvm_guest_enter(void)
>>>> +{
>>>> +#ifdef CONFIG_GUEST_ACCOUNTING
>>>> +    current->flags |= PF_VCPU;
>>>> +#endif
>>>>   
>>>>       
>>> Since you select GUEST_ACCOUNTING, the #ifdef is always true?
>>>     
>> It is just to avoid error if we compile kvm module outside of the kernel, with
>> kernel without support of guest accounting. Can be removed if you want.
>>
>>   
> 
> Ah okay.  We take care of the external module in 
> external-module-compat.h (in this case, we can #define PF_VCPU to 0 if 
> it is undefined).

OK

>>>> +}
>>>> +
>>>> +static inline void kvm_guest_exit(void)
>>>> +{
>>>>   
>>>>       
>>> Missing content?
>>>     
>> No, empty function.
>>
>> It is just to introduce "symmetry" in code, the VCPU code begins with
>> "kvm_guest_start()" and ends with "kvm_guest_exit()". And we have no operation
>> to do in kvm_guest_exit() (the PF_VCPU is cleared by account_system_time()), so
>> "empty function", removed by the optimizer (I hope).
>>   
> 
> But what if account_system_time() is not called (because we exited 
> before the timer interrupt hit)?

account_system_time() is called by the scheduler on tick. If we clear PF_VCPU in
kvm_guest_exit(), the flag is always cleared when account_system_time() is
executed, so we account "0", if we call account_system_time() directly from
kvm_guest_exit() we account "1", so we subtract 1 to system time, and we have
perhaps not used 1 tick in system: in my opinion this implies wrong results.

Laurent
-- 
------------- Laurent.Vivier@...l.net  --------------
          "Software is hard" - Donald Knuth


Download attachment "signature.asc" of type "application/pgp-signature" (190 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ