From patchwork Mon Jun 18 10:06:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 138870 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp3760338lji; Mon, 18 Jun 2018 03:08:58 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLSVOzvssIwkmUug+hht3wCr34aksD1j8pACvnJMjskIB1DlJ+VaxEyedaDsizYAm2aX1QU X-Received: by 2002:a17:902:9b92:: with SMTP id y18-v6mr13120108plp.57.1529316538770; Mon, 18 Jun 2018 03:08:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529316538; cv=none; d=google.com; s=arc-20160816; b=QlFLnBg430s2YSSaUPr8WZ4dNtIRmZ11gG37lVl86Fm1l3VU1CI2YcFkLFGrGOjYs2 Jd96wUm2Kv5i9GbOKEeFUsPFtXDSRNv6k+kRzc67WuHpqgRak6WMnFQ0Ew5TGNvGYwQ3 HAb3b89Rli1Ji9lks/+QTnyb42GV+eKoHle0SLMZFX/MCaWKNZywoy9FhJoW3Gp2m2aJ McyOJ6del8X4cldSQumGUPq/xxX3s+0NN/2uQgqq3PVhwaofkGq5o997/y+XhCom+RM7 YffK5wHJDb1FQHO60iVQOo9oiKA6QE4rLnE29yCnBcF3+Z3GGGLZs3+vRLu/DE7CzUpC jekg== 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 :arc-authentication-results; bh=ZJGiEcMgX7jSbeYblaTD1/S9PLwleKFSx+YbcfK04as=; b=USA9mKnRvG614tHEcPZWp6kNCucgXbOMTq9T6Ctf4VCnsFlA3UJjlVjvft9G2PSJQh 28ZnxeBRa4NHecy77JbR5hb58Z6jTZPb5w0wK/Wb9owKhdX/Aa3AF+3QMnn1zJ1VdAn/ aclcPuutAINtJZYNDZnk5PUpcjZp91gCFSVkugfp0KxFohE8WhdSo8CAZcBix7rt6J5Y Ahbz3h9ZS/vWnbBT0vlATuX7YzmdH2hMHu5NFF5wxLIKzzGeNDTCCX32g2Xp+t8IIgrD Kub07z+TMcTWa7HCh+wCc71RQLA4AgBeBbGXcywZmxbORJ42Qm1rpn2elmQd0uYwfCS7 Zj8A== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c7-v6si14000304plo.47.2018.06.18.03.08.58; Mon, 18 Jun 2018 03:08:58 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964833AbeFRKI5 (ORCPT + 30 others); Mon, 18 Jun 2018 06:08:57 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:57907 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934816AbeFRKIy (ORCPT ); Mon, 18 Jun 2018 06:08:54 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue103 [212.227.15.145]) with ESMTPA (Nemesis) id 0Meu09-1fssHc1lNJ-00OUWW; Mon, 18 Jun 2018 12:08:05 +0200 From: Arnd Bergmann To: Tony Luck , Borislav Petkov , Thomas Gleixner , Ingo Molnar , x86@kernel.org Cc: y2038@lists.linaro.org, Arnd Bergmann , "H. Peter Anvin" , Yazen Ghannam , linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] x86: mce: always use 64-bit timestamps Date: Mon, 18 Jun 2018 12:06:46 +0200 Message-Id: <20180618100759.1921750-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K1:/gD/4FHZoPykeF9LtSxeOZYaiu25VmXC2YABBWG6FNwVJHtwEO3 IG7lij89dOLso+z/KMNmrtQvTxWgoaCeu0hzOBngCObf9T23xqx+6C8abiTUICAlZdaX1HU 4LgQKuxKRjEsfpTbRc6Bbxx4azethfLbPLm4yCVlhgGoogkAh4xSFCNjE4DwVlxB3Wtcm+h GnQd87PlKbgNPLvliaqHw== X-UI-Out-Filterresults: notjunk:1; V01:K0:Pri8vuxQUpU=:c5MhX04gQ7ucHsrJwhJy46 lMtpABvm2cI23XnijTzt2vhLbjC0eGUIn+rz0uYeFrPYVpiRrI+3FKf7UbDC01sFEGinidnSy D2KlMg0DATpXv4dN+TyEL7tVTGt4PRNprgzudrk0MPZiPi80Qb9nBWNyPKWTWg67v+87CWGMj F92YeEKLj6x9AQ2gkxJtuTz6NVAHvp0///j2EClpNN2Apm9ztnhsutrqeNFeOCIvzOzuj0jX1 dN6i/qDRM7RprhfRQ+U0LYb5nbn93ujl2IfUw0EEXPZxg6F/PwuasuYVxmthCudy9EEIjc/fn IZmzZTqbynRZElyjF8gKWWqJmsL0AHD+Sg1uqqLYqbbw+avmZ3JDHMr9UMJTteGOCDYJswurT njlpRBlaup2ukbY9YNgw7HHC236v2Jw7yaZfnKi/lbNPBKtyAe3tgVdApVOJEH2YOfxNjW1Jh n8QtYjAFxJ2ah3fvufp1p3v6GTf+v9GCa75FczbcZyjSCic7CB1HEZ2v8JBsVxIdlfgu2q5uU udMB85DEJPGq4x+Dc6EXo0C9d0kn7DXCPXjodLhaUT/HgIMAJ+476wE0vwSWnNmY0ODu9KFDT DxY+1/IPpPSEvSztdbtYlNZrLK7SxwwfZiBdM0W7QANbB+XP8xoaMz7hTv3W8Udf4PGXYgsgk D6bMc2iymmsI+fAeIQ+zk1XUTAthsZMK6bP0V1zAGlN+ZuYOp2B1wac3l6qbnd7R/TVA= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The machine check timestamp uses get_seconds(), which returns an 'unsigned long' number that might overflow on 32-bit architectures (in the distant future) and is therefore deprecated. The normal replacement would be ktime_get_real_seconds(), but that needs to use a sequence lock that might cause a deadlock if the mce happens at just the wrong moment. The __ktime_get_real_seconds() skips that lock and is safer here, but has a miniscule risk of returning the wrong time when we read it on a 32-bit architecture at the same time as updating the epoch, i.e. from before y2106 overflow time to after, or vice versa. This seems to be an acceptable risk in this particular case, and is the same thing we do in kdb. Signed-off-by: Arnd Bergmann --- arch/x86/kernel/cpu/mcheck/mce.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.9.0 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c index e4cf6ff1c2e1..b887415652ed 100644 --- a/arch/x86/kernel/cpu/mcheck/mce.c +++ b/arch/x86/kernel/cpu/mcheck/mce.c @@ -123,8 +123,8 @@ void mce_setup(struct mce *m) { memset(m, 0, sizeof(struct mce)); m->cpu = m->extcpu = smp_processor_id(); - /* We hope get_seconds stays lockless */ - m->time = get_seconds(); + /* need the internal __ version to avoid deadlocks */ + m->time = __ktime_get_real_seconds(); m->cpuvendor = boot_cpu_data.x86_vendor; m->cpuid = cpuid_eax(1); m->socketid = cpu_data(m->extcpu).phys_proc_id;