Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3978059yba; Wed, 17 Apr 2019 01:49:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqyH/BCSReOXtu5aA+RwNIXjfnqgWryHjFCiORap7UhyCqLlwpA+2JoUr64etiB93qSnvhQo X-Received: by 2002:aa7:8615:: with SMTP id p21mr88574071pfn.98.1555490986352; Wed, 17 Apr 2019 01:49:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555490986; cv=none; d=google.com; s=arc-20160816; b=bZwyU5rYXEKGsE0uP4R1KR9iORgv1vNccR7Z+qFX0TKCboUzL7J/bNfTnaJ0A+zEDJ 5uWffExzXWru9ULX8qE9C3foUHvo/cyFF9EYa9qPh+8Ukr4iz/k5hpYEzil1a7RmhVty 5QvyPc/jMm2ki1p/WmPIu4kDK5XDUKdTB1rTfmsOZO8tIDrCWaeIl5vNDpTBFT1XxZEf se6C5uXF+dhiHKhUOD2N9BnrUp+LtEsiWvqu/QYsmdbvFF971uLnI0E8Vs1ANTbCDrjM G+3Uj8eDT8G+QMJR2075fKzIdLzi80FJhh/UuwLV5KB5VfaHRBw8kZqe2iXC7PsvGf1I 0JfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=zqgNnOZqnQ/wqqxty81rLBWhvD69B5D3qv2W/4HVVT4=; b=TNE1mftmTJIB3qSvWd6ANOZp/UUnUsrV0T70bK+KPIhl3iUvFrJ0cmsX57MbATLpKO cSM99i39JGYqRPkDU4YnmmDs0MoGCBiAp++zKNNBBAOE4u4eYakcR7gpJqz26RUQrxQo CUlgpQu8nq5fPiWl66YqH2ByijPt741X3x5QXgGSlQC+ylBqpL92aJ2UpN933cu6FWfb IbslI4bosnvmzA47CXNdazEUugVFBpfZfvfUpJT2Q4A881vxp+pJGod72aS4fuVF1q8j FK6Mn4l5Dw91ef/MCg/nEFe/s0MY4z0kNAs/ENz+N5LIvy/DdUiU9Dtmigos6Z8vbE/a Mr0Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z8si41258212pgf.593.2019.04.17.01.49.31; Wed, 17 Apr 2019 01:49:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731168AbfDQIsh (ORCPT + 99 others); Wed, 17 Apr 2019 04:48:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56402 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727013AbfDQIsg (ORCPT ); Wed, 17 Apr 2019 04:48:36 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CA715C04959F; Wed, 17 Apr 2019 08:48:36 +0000 (UTC) Received: from holly.tpb.lab.eng.brq.redhat.com (holly.tpb.lab.eng.brq.redhat.com [10.43.134.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 56FC41001DF3; Wed, 17 Apr 2019 08:48:35 +0000 (UTC) From: Miroslav Lichvar To: linux-kernel@vger.kernel.org Cc: Ondrej Mosnacek , Miroslav Lichvar , Thomas Gleixner , John Stultz , Richard Cochran , Prarit Bhargava Subject: [PATCH] ntp: Allow TAI-UTC offset to be set to zero Date: Wed, 17 Apr 2019 10:48:33 +0200 Message-Id: <20190417084833.7401-1-mlichvar@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 17 Apr 2019 08:48:36 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The ADJ_TAI adjtimex mode sets the TAI-UTC offset of the system clock. It is typically set by NTP/PTP implementations and it is automatically updated by the kernel on leap seconds. The initial value is zero (which applications may interpret as unknown), but this value cannot be set by adjtimex. This limitation seems to go back to the original "nanokernel" implementation by David Mills. Change the ADJ_TAI check to accept zero as a valid TAI-UTC offset in order to allow setting it back to the initial value. Cc: Thomas Gleixner Cc: John Stultz Cc: Richard Cochran Cc: Prarit Bhargava Suggested-by: Ondrej Mosnacek Signed-off-by: Miroslav Lichvar --- kernel/time/ntp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c index 92a90014a925..f43d47c8c3b6 100644 --- a/kernel/time/ntp.c +++ b/kernel/time/ntp.c @@ -690,7 +690,7 @@ static inline void process_adjtimex_modes(const struct __kernel_timex *txc, time_constant = max(time_constant, 0l); } - if (txc->modes & ADJ_TAI && txc->constant > 0) + if (txc->modes & ADJ_TAI && txc->constant >= 0) *time_tai = txc->constant; if (txc->modes & ADJ_OFFSET) -- 2.17.2