Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp47746imu; Wed, 12 Dec 2018 12:11:55 -0800 (PST) X-Google-Smtp-Source: AFSGD/UUP0J+dgJ2KU6oZpjrfS9pcMDHwiz/NTHpNqWgU2PS0jn8wZnEjwyv+RAau18mVL0gq2so X-Received: by 2002:a62:ea09:: with SMTP id t9mr22654031pfh.228.1544645515153; Wed, 12 Dec 2018 12:11:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544645515; cv=none; d=google.com; s=arc-20160816; b=EoR3H5nBjD9k9JPAT02eiyteHE1vKlwdPeMXLlvFN+odAoShUd3w1w58pdkReq+9lA TiQUBNtnKht+4k2kBTgMtwcuqw4o2zMEjzjSvSlrDHTfVjMVM7zXyxiVxBixZWHUOQeU Pedp0DJh7l+qODGkq/bHPN5+Q0OD/k0zFEbMrTp85W1XELKtkClWWmvEiHmB4OFGNT92 qFHt0svGQ2DyIMys3U3XC3T6ZDrOsYUH3xAPmDDsKJkVsJKQot8Kri0tdwKqpUEo0s7J rxVwzHJT953IF6M9b/3nC4Y5XJojo6WDGm+Ho3wiXTLPoykyHQW7PDkGMHZ88A9z+VDW OpwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=0Gx9zbXyruKAXhWr9uZun6nXORDbMbWHz5VWzxxSpFk=; b=esOi4yg/yuRb3xG9hwk5YfD+eZrotqWcMF6tzmGvrCKGa3Fcqkonul0RkXyIkWB9Cz FI3TMUhfT/tpoZJETCBnpjvYbtf8lHUjlaWVZQOtZZOG0Aawqz3/jIzFCQAA/GFbw7ia fzLNXLuvPc2lytyv7Qtvx/eyEFOA2vSeYqVwo7Bn5LyKy1v9TeM9Y5jU6VHEl8EPZpAa C3ZsbsjDGzK7Xf2XNhAYuel4scRo7vXTzHnCZrvQdjlLLRWL3dntxwYeXmratVWM8wXu nc7LMSoYP04Rced/QLiyhpSC+eRfvnZPTQ9ZY42f9tF7KCZOTQ3Vmdxqa78R2P3kMZx8 Wdtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ylT647h2; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x61si11360514plb.303.2018.12.12.12.11.31; Wed, 12 Dec 2018 12:11:55 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=ylT647h2; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727594AbeLLUJP (ORCPT + 99 others); Wed, 12 Dec 2018 15:09:15 -0500 Received: from mail.kernel.org ([198.145.29.99]:48034 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726293AbeLLUJO (ORCPT ); Wed, 12 Dec 2018 15:09:14 -0500 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 09C8A20873 for ; Wed, 12 Dec 2018 20:09:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544645354; bh=Up4QSoGGtDSeM9LKvXeYN0szRM/NuBsJRcn32KRHA9g=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=ylT647h2lU5ShSs5JQqe3zpQUtUHp+akfSFl6OoGHNzSuJCVXY8OaYjX282MyhtIc n5xTMz4/3WAWC6+VtOsvUPIamHxk8KNNuq3q8u5/oGLJlocC3tGc1GpFUQ9NtDYTpR LbxCWO0FO1WkfckGeDM5XszMVtZvzy003M56BSlM= Received: by mail-wr1-f51.google.com with SMTP id u3so18989695wrs.3 for ; Wed, 12 Dec 2018 12:09:13 -0800 (PST) X-Gm-Message-State: AA+aEWYE2FRUWmuqP39NqT6F1qEsAMyOxWayP0P/IPdCt8T1lqlA2yoT jRWfh0AHzfT/sP7PztBYVzDyghBqEsspjABmZnt/eg== X-Received: by 2002:adf:e08c:: with SMTP id c12mr17509289wri.199.1544645352500; Wed, 12 Dec 2018 12:09:12 -0800 (PST) MIME-Version: 1.0 References: <20181211222326.14581-1-bp@alien8.de> <20181211222326.14581-5-bp@alien8.de> <59aad362-4a5b-dd8b-642f-0dc3f83cf7ee@amd.com> <20181211233901.GV27375@zn.tnic> <20181212100814.GB6653@zn.tnic> <20181212184459.GE6653@zn.tnic> <20181212200005.GF6653@zn.tnic> In-Reply-To: <20181212200005.GF6653@zn.tnic> From: Andy Lutomirski Date: Wed, 12 Dec 2018 12:09:00 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH 4/4] x86/TSC: Use RDTSCP To: Borislav Petkov Cc: Andrew Lutomirski , Tom Lendacky , LKML , X86 ML , "H. Peter Anvin" , Josh Poimboeuf , Peter Zijlstra , John Stultz Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 12, 2018 at 12:00 PM Borislav Petkov wrote: > > On Wed, Dec 12, 2018 at 10:50:30AM -0800, Andy Lutomirski wrote: > > As far as I know, RDTSCP gets the job done, as does LFENCE, RDTSC on > > Intel. > > Same on AMD when LFENCE has been made dispatch-serializing. > > > There was a big discussion a few years ago where we changed it > > from LFENCE;RDTSC;LFENCE to just LFENCE;RDTSC after everyone was > > reasonably convinced that the uarch would not dispatch two RDTSCs > > backwards if the first one was immediately preceeded by LFENCE. > > Yeah, the second one won't pass the LFENCE so you won't see time going > backwards, sure. > Also that the uarch doesn't turn: LFENCE RDTSC load some memory into a load followed a cycle later by RDTSC. If that happened, then some cooperating CPUs could observe time going backwards. But RDTSC has no dependencies, so, barring odd register renaming effects or similar, this isn't going to be a problem in practice. Also, the actual clock reading code is complicated enough that we have several cycles of wiggle room :)