From mboxrd@z Thu Jan 1 00:00:00 1970 From: Radim =?utf-8?B?S3LEjW3DocWZ?= Subject: Re: [PATCH] KVM: x86: remove irq disablement around KVM_SET_CLOCK/KVM_GET_CLOCK Date: Wed, 12 Apr 2017 19:40:51 +0200 Message-ID: <20170412174051.GB23556@potion> References: <20170412172313.GA26589@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm-devel , Paolo Bonzini , pagupta@redhat.com To: Marcelo Tosatti Return-path: Received: from mx1.redhat.com ([209.132.183.28]:32864 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754620AbdDLRlA (ORCPT ); Wed, 12 Apr 2017 13:41:00 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C94218049E for ; Wed, 12 Apr 2017 17:40:54 +0000 (UTC) Content-Disposition: inline In-Reply-To: <20170412172313.GA26589@amt.cnet> Sender: kvm-owner@vger.kernel.org List-ID: 2017-04-12 14:23-0300, Marcelo Tosatti: > The disablement of interrupts at KVM_SET_CLOCK/KVM_GET_CLOCK > attempts to disable interrupts in that section to protect > the values that are calculated in that section from interrupt interference. > > now_ns is calculated inside the irq protected region, > user_ns.clock is passed from userspace (therefore not susceptible > to interrupt variation). > > About the line > now_ns = __get_kvmclock_ns(kvm); (1) > > Interrupts can happen afterwards local_irq_enable(), > rendering "now_ns" relative to its execution time PLUS > interrupt time. > > Therefore the local_irq_disable() / local_irq_enable() protection is not > necessary (that is: interrupts triggering after local_irq_enable cause > the same problem that the protection is trying to avoid). Makes sense. get_kvmclock_ns() has the same problem and this patch should cover it as well.