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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 16 Jun 2010 11:03:31 -0300
From:	Glauber Costa <glommer@...hat.com>
To:	Jason Wang <jasowang@...hat.com>
Cc:	Zachary Amsden <zamsden@...hat.com>, Avi Kivity <avi@...hat.com>,
	mtosatti@...hat.com, kvm@...r.kernel.org,
	linux-kernel@...r.kernel.org, john stultz <johnstul@...ibm.com>,
	Thomas Gleixner <tglx@...utronix.de>
Subject: Re: [PATCH 12/17] Add helper function get_kernel_ns

On Wed, Jun 16, 2010 at 04:12:46PM +0800, Jason Wang wrote:
> Zachary Amsden wrote:
> > On 06/14/2010 10:41 PM, Avi Kivity wrote:
> >   
> >> On 06/15/2010 10:34 AM, Zachary Amsden wrote:
> >>     
> >>> Add a helper function for the multiple places this is used.  Note 
> >>> that it
> >>> must not be called in preemptible context, as that would mean the kernel
> >>> could enter software suspend state, which would cause non-atomic 
> >>> operation
> >>> of the monotonic_to_bootbased computation.
> >>>
> >>> Open question: should the KVM_SET_CLOCK / KVM_GET_CLOCK ioctls use this
> >>> as well?  Currently, they are not bootbased (but perhaps should be).
> >>>
> >>> Signed-off-by: Zachary Amsden<zamsden@...hat.com>
> >>> ---
> >>>   arch/x86/kvm/x86.c |   26 +++++++++++++-------------
> >>>   1 files changed, 13 insertions(+), 13 deletions(-)
> >>>
> >>> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> >>> index 703ea43..15c7317 100644
> >>> --- a/arch/x86/kvm/x86.c
> >>> +++ b/arch/x86/kvm/x86.c
> >>> @@ -915,6 +915,16 @@ static void kvm_get_time_scale(uint32_t 
> >>> scaled_khz, uint32_t base_khz,
> >>>            __func__, base_khz, scaled_khz, shift, *pmultiplier);
> >>>   }
> >>>
> >>> +static inline u64 get_kernel_ns(void)
> >>> +{
> >>> +    struct timespec ts;
> >>> +
> >>> +    WARN_ON(preemptible());
> >>> +    ktime_get_ts(&ts);
> >>> +    monotonic_to_bootbased(&ts);
> >>> +    return timespec_to_ns(&ts);
> >>> +}
> >>> +
> >>>   static DEFINE_PER_CPU(unsigned long, cpu_tsc_khz);
> >>>
> >>>       
> >> Isn't something like this a candidate for the time infrastructure?
> >>
> >>     
> >
> > Should it be?  It certainly seems reasonable.
> >
> >
> > Also, should we be using it for the cases KVM_GET_CLOCK / 
> > KVM_SET_CLOCK?  It seems global kvmclock_offset for the VM ignores the 
> > bootbased conversion.
> >
> >   
> Yes we should.
indeed. Also shows the importance of doing it in a central place.
Have we had an acessor like that before, we would probably not have
made this mistake.



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ