Received: by 10.223.176.46 with SMTP id f43csp1127808wra; Wed, 24 Jan 2018 11:04:33 -0800 (PST) X-Google-Smtp-Source: AH8x226U1dcX05aXMi8ieeKHjJAx40p9ep9ExuA04xySb1fCf4/JcELM5Sm96SMdiD8MCUPBjqPI X-Received: by 10.98.242.77 with SMTP id y13mr13631345pfl.156.1516820673418; Wed, 24 Jan 2018 11:04:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516820673; cv=none; d=google.com; s=arc-20160816; b=hTRrCkoWI6NyEiGSELzIQjpAVHaRvLpLWPapp2jrO/qWQjrnq6t2ja4YZBazQ9gagt 2F8mc5ZmUY0tN6nAWZ50ps8GqWN+2k4Nwy7XGuolEC/rC1emuQ72yjbZF7yt8t9/5/Gr Ij5KsNIUA2L9GBzMsK6ycUe6RkJbWgVObmkNMPCiPjEXfijMEP/2z6fUueeuu7sXD/yH Sh+8yNDTcbAAgM5OybrefWDTPe30ywt0suTkGi6oWt8TRDgj/UGWYNn53AWmNEb1OHui 6MfMWo6LL4Xh7EyUYbMK6FqOBoGORcpL1Q0QJYuiw0JqQgHC8vVVuOK+IksyA4klsiZb Ah5A== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=bnqz3zvVy08JhNn5F+RW+S6qbw0SntCgmsEJiAwCCLE=; b=NGxdmw5CX+YJDqSOjC3RE4KIzTrUHGGu56ViaehJCmhnIlDRfUyGH1beiFvdhtdP1m U6ueCc5fW2JgbQ18FmAreL6WiyWwctXgz5rRvs474VTUMM72DRUCir2aAKSgj4Wo2V/q Alxn0Bbl9X6m43Oi1PG/3dsjhk0p7Z/49r+W4z4i2POG2cgZC7NbjvAk0aRHifzVAKNj cWJ1F3yoU2A30wm2v201ZfoahGerZqAeUhj8PZuUj5yj1Lv5c9dgqpt83zR3TauTBzBs L8+hgU8DfQbslKmBigjuTORhzU4k7mhdGgckUt0ybqpfW2WXv/4P2g1xZqayQFGFPCf5 WIKw== 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=podlesie.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r15si3330041pfb.86.2018.01.24.11.04.19; Wed, 24 Jan 2018 11:04:33 -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; 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=podlesie.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965107AbeAXTDm (ORCPT + 99 others); Wed, 24 Jan 2018 14:03:42 -0500 Received: from shrek-s3.podlesie.net ([85.14.110.209]:37858 "EHLO shrek.podlesie.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965002AbeAXTDl (ORCPT ); Wed, 24 Jan 2018 14:03:41 -0500 X-Greylist: delayed 338 seconds by postgrey-1.27 at vger.kernel.org; Wed, 24 Jan 2018 14:03:41 EST Received: by shrek.podlesie.net (Postfix, from userid 603) id 5C6B34E2; Wed, 24 Jan 2018 19:58:00 +0100 (CET) Date: Wed, 24 Jan 2018 19:58:00 +0100 From: Krzysztof Mazur To: Joerg Roedel Cc: Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , x86@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Linus Torvalds , Andy Lutomirski , Dave Hansen , Josh Poimboeuf , Juergen Gross , Peter Zijlstra , Borislav Petkov , Jiri Kosina , Boris Ostrovsky , Brian Gerst , David Laight , Denys Vlasenko , Eduardo Valentin , Greg KH , Will Deacon , aliguori@amazon.com, daniel.gruss@iaik.tugraz.at, hughd@google.com, keescook@google.com, Andrea Arcangeli Subject: Re: [RFC PATCH 00/16] PTI support for x86-32 Message-ID: <20180124185800.GA11515@shrek.podlesie.net> References: <1516120619-1159-1-git-send-email-joro@8bytes.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1516120619-1159-1-git-send-email-joro@8bytes.org> User-Agent: Mutt/1.6.2 (2016-07-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 16, 2018 at 05:36:43PM +0100, Joerg Roedel wrote: > From: Joerg Roedel > > Hi, > > here is my current WIP code to enable PTI on x86-32. It is > still in a pretty early state, but it successfully boots my > KVM guest with PAE and with legacy paging. The existing PTI > code for x86-64 already prepares a lot of the stuff needed > for 32 bit too, thanks for that to all the people involved > in its development :) Hi, I've waited for this patches for a long time, until I've tried to exploit meltdown on some old 32-bit CPUs and failed. Pentium M seems to speculatively execute the second load with eax always equal to 0: movzx (%[addr]), %%eax shl $12, %%eax movzx (%[target], %%eax), %%eax And on Pentium 4-based Xeon the second load seems to be never executed, even without shift (shifts are slow on some or all Pentium 4's). Maybe not all P6 and Netbursts CPUs are affected, but I'm not sure. Maybe the kernel, at least on 32-bit, should try to exploit meltdown to test if the CPU is really affected. The series boots on Pentium M (and crashes when I've used perf, but it is an already known issue). However, I don't like the performance regression with CONFIG_PAGE_TABLE_ISOLATION=n (about 7.2%), trivial "benchmark": --- cut here --- #include #include int main(void) { unsigned long i; int fd; fd = open("/dev/null", O_WRONLY); for (i = 0; i < 10000000; i++) { char x = 0; write(fd, &x, 1); } return 0; } --- cut here --- Time (on Pentium M 1.73 GHz): baseline (4.15.0-rc8-gdda3e152): 2.415 s (+/- 0.64%) patched, without CONFIG_PAGE_TABLE_ISOLATION=n 2.588 s (+/- 0.01%) patched, nopti 2.597 s (+/- 0.31%) patched, pti 18.272 s (some older kernel, pre 4.15) 2.378 s Thanks, Krzysiek -- perf results: baseline: Performance counter stats for './bench' (5 runs): 2401.539139 task-clock:HG # 0.995 CPUs utilized ( +- 0.23% ) 23 context-switches:HG # 0.009 K/sec ( +- 4.02% ) 0 cpu-migrations:HG # 0.000 K/sec 30 page-faults:HG # 0.013 K/sec ( +- 1.24% ) 4142375834 cycles:HG # 1.725 GHz ( +- 0.23% ) [39.99%] 385110908 stalled-cycles-frontend:HG # 9.30% frontend cycles idle ( +- 0.06% ) [40.01%] stalled-cycles-backend:HG 4142489274 instructions:HG # 1.00 insns per cycle # 0.09 stalled cycles per insn ( +- 0.00% ) [40.00%] 802270380 branches:HG # 334.065 M/sec ( +- 0.00% ) [40.00%] 34278 branch-misses:HG # 0.00% of all branches ( +- 1.94% ) [40.00%] 2.414741497 seconds time elapsed ( +- 0.64% ) patched, without CONFIG_PAGE_TABLE_ISOLATION=n Performance counter stats for './bench' (5 runs): 2587.026405 task-clock:HG # 1.000 CPUs utilized ( +- 0.01% ) 28 context-switches:HG # 0.011 K/sec ( +- 5.95% ) 0 cpu-migrations:HG # 0.000 K/sec 31 page-faults:HG # 0.012 K/sec ( +- 1.21% ) 4462401079 cycles:HG # 1.725 GHz ( +- 0.01% ) [39.98%] 388646121 stalled-cycles-frontend:HG # 8.71% frontend cycles idle ( +- 0.05% ) [40.01%] stalled-cycles-backend:HG 4283638646 instructions:HG # 0.96 insns per cycle # 0.09 stalled cycles per insn ( +- 0.00% ) [40.03%] 822484311 branches:HG # 317.927 M/sec ( +- 0.00% ) [40.01%] 39372 branch-misses:HG # 0.00% of all branches ( +- 2.33% ) [39.98%] 2.587818354 seconds time elapsed ( +- 0.01% )