Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1670758imu; Wed, 12 Dec 2018 02:10:35 -0800 (PST) X-Google-Smtp-Source: AFSGD/VoQEm9zzwreDPUviKsPqBzYpVfyBYkOpcl7Q4G5DPb18kZcgUfufo91SUISazoNW70G1qW X-Received: by 2002:a17:902:4124:: with SMTP id e33mr19258814pld.236.1544609435720; Wed, 12 Dec 2018 02:10:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544609435; cv=none; d=google.com; s=arc-20160816; b=PRa4lXQd/ZklxfXzp4qJRpWjnvVA8LQk1DnkFxTW7+mDgEY3KBMp0PuRFP7iDwx6cA fwr754Ynd4ExB/6wCStwrNm4OVbMA30GHTKOKp69p9xIP0ePkvj+p5P4hltqW32VXnuX lQJXEWk4o9bW1noVLS+nufk6BWZcNc8zq62nlBw/Eg5NZfsYLmYUCwZG6MLyns1Xudxz 4eENpfyuaT1m39c2Lfo7zlB6KQBS0aLtY4YSJ6nmeVn3K3bogfh/wo8913lykp2hQ1YY lbq/fnVysvPLSP4194EKgbpPRg5eWWPM2R8NzwjDn9ZHN/yFYG7ZkFyN1xccwmNWLMmc WBhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=GrLCOdT8HY4i4jpK3TF15BC8SA0WXnvSAbaQiVANtt8=; b=dmRMxSuQrDU4Ke/XmMUzL6h9CBTkoLCDU6V7+XF35YcK56YEDvpKGKKlsXDSMjosm4 p/w3kGlnLwh0no7ef0YsKP83koXGd0NAGOTnIOuZPS/ZrkXnPdWj6RBGCn710FIKAxxW OD6E9tMr5mi5oUTZERFvJflURq/MeS+eA8c0qO8SnXhz4aCc4hnQGYjA6TrJhWKZlj6O TfD+Eq4i6l+WyM9i7qq/XNhQkP1HGVIbCfal+qqxt/AVeyH3EVxh62Iyl/Tb7rxRBQsz hAOlBiV6WPGhhokDt6xzxEhBek50+Rnd3yv/ptr0NBGpRav9Oqwplc+6ZXpIvWo034AR 6itw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=kEOXUyK1; 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=REJECT sp=REJECT dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d25si14203668pgd.88.2018.12.12.02.10.20; Wed, 12 Dec 2018 02:10:35 -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=@alien8.de header.s=dkim header.b=kEOXUyK1; 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=REJECT sp=REJECT dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726915AbeLLKIS (ORCPT + 99 others); Wed, 12 Dec 2018 05:08:18 -0500 Received: from mail.skyhub.de ([5.9.137.197]:60342 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726796AbeLLKIS (ORCPT ); Wed, 12 Dec 2018 05:08:18 -0500 Received: from zn.tnic (p200300EC2BCDD8002DC08A63FFF8C6E5.dip0.t-ipconnect.de [IPv6:2003:ec:2bcd:d800:2dc0:8a63:fff8:c6e5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 019891EC0BFC; Wed, 12 Dec 2018 11:08:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1544609297; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GrLCOdT8HY4i4jpK3TF15BC8SA0WXnvSAbaQiVANtt8=; b=kEOXUyK11mXOuyxZ/n2Lf3vl4ubdxKhviV8iZlzPaHi18O8nGhBcfwrWUsMKYPbDiXcxJd c5Viabsuyb3w8+RPiduYNDkbpOynPAz+BJjRY6aBJf9xhLcbSjY4EMedtPTPbCQkTH2yYc YCYKzw7fhIO7Y9QCQ0X9aTGjtdXsf8E= Date: Wed, 12 Dec 2018 11:08:14 +0100 From: Borislav Petkov To: Andy Lutomirski Cc: Tom Lendacky , LKML , X86 ML , "H. Peter Anvin" , Josh Poimboeuf , Peter Zijlstra , John Stultz Subject: Re: [RFC PATCH 4/4] x86/TSC: Use RDTSCP Message-ID: <20181212100814.GB6653@zn.tnic> References: <20181211222326.14581-1-bp@alien8.de> <20181211222326.14581-5-bp@alien8.de> <59aad362-4a5b-dd8b-642f-0dc3f83cf7ee@amd.com> <20181211233901.GV27375@zn.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 11, 2018 at 06:24:44PM -0800, Andy Lutomirski wrote: > This makes me nervous, since no one knows what “serializing” means. Why no one? If you wanna say that X86_FEATURE_LFENCE_SERIALIZING is not really telling, so is X86_FEATURE_LFENCE_RDTSC, TBH. :) > IIRC AMD specifically documents that MFENCE is required before RDTSC > to get sensible ordering. So it’s entirely plausible to me that > LFENCE is okay for Spectre mitigation but MFENCE is needed for RDTSC > on some CPU. Look at init_amd(), the if (cpu_has(c, X86_FEATURE_XMM2)) branch where we make LFENCE serializing. The logic with the new names would be: asm volatile(ALTERNATIVE_3("rdtsc", "mfence; rdtsc", X86_FEATURE_MFENCE, "lfence; rdtsc", X86_FEATURE_LFENCE_SERIALIZING, "rdtscp", X86_FEATURE_RDTSCP) RDTSC is put there during build. At boot time: if CPU has MFENCE use MFENCE to stop RDTSC speculation if LFENCE is serializing use LFENCE... if CPU has RDTSCP even better, use that as it is the fastest or on par. Of course the order of those is important. Ok? -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.