Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S937322Ab3DJKky (ORCPT ); Wed, 10 Apr 2013 06:40:54 -0400 Received: from out03.mta.xmission.com ([166.70.13.233]:56370 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751606Ab3DJKkw (ORCPT ); Wed, 10 Apr 2013 06:40:52 -0400 From: ebiederm@xmission.com (Eric W. Biederman) To: Ingo Molnar Cc: "H. Peter Anvin" , Kees Cook , Ingo Molnar , linux-kernel@vger.kernel.org, Thomas Gleixner , x86@kernel.org, Konrad Rzeszutek Wilk , Jeremy Fitzhardinge , Marcelo Tosatti , Alex Shi , Borislav Petkov , Alexander Duyck , Frederic Weisbecker , Steven Rostedt , "Paul E. McKenney" , xen-devel@lists.xensource.com, virtualization@lists.linux-foundation.org, kernel-hardening@lists.openwall.com, Dan Rosenberg , Julien Tinnes , Will Drewry , Eric Northup References: <20130408224328.GA17641@www.outflux.net> <51634935.9010905@zytor.com> <877gkc596d.fsf@xmission.com> <20130410095716.GF24443@gmail.com> Date: Wed, 10 Apr 2013 03:40:33 -0700 In-Reply-To: <20130410095716.GF24443@gmail.com> (Ingo Molnar's message of "Wed, 10 Apr 2013 11:57:16 +0200") Message-ID: <87sj2yzn1a.fsf@xmission.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-AID: U2FsdGVkX184UBvStsrjzUdD6I5NX+waJejGFrYpl8w= X-SA-Exim-Connect-IP: 98.207.154.105 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 1.7 KHOP_BIG_TO_CC Sent to 10+ recipients instaed of Bcc or a list * 0.0 T_TM2_M_HEADER_IN_MSG BODY: T_TM2_M_HEADER_IN_MSG * -3.0 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa06 1397; Body=1 Fuz1=1 Fuz2=1] X-Spam-DCC: XMission; sa06 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ;Ingo Molnar X-Spam-Relay-Country: Subject: Re: [PATCH] x86: make IDT read-only X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Wed, 14 Nov 2012 14:26:46 -0700) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2460 Lines: 57 Ingo Molnar writes: > * Eric W. Biederman wrote: > >> "H. Peter Anvin" writes: >> >> > On 04/08/2013 03:43 PM, Kees Cook wrote: >> >> This makes the IDT unconditionally read-only. This primarily removes >> >> the IDT from being a target for arbitrary memory write attacks. It has >> >> an added benefit of also not leaking (via the "sidt" instruction) the >> >> kernel base offset, if it has been relocated. >> >> >> >> Signed-off-by: Kees Cook >> >> Cc: Eric Northup >> > >> > Also, tglx: does this interfere with your per-cpu IDT efforts? >> >> Given that we don't change any IDT entries why would anyone want a >> per-cpu IDT? The cache lines should easily be shared accross all >> processors. > > That's true iif they are cached. > > If not then it's a remote DRAM access cache miss for all CPUs except the node that > holds that memory. > >> Or are there some giant NUMA machines that trigger cache misses when accessing >> the IDT and the penalty for pulling the cache line across the NUMA fabric is >> prohibitive? > > IDT accesses for pure userspace execution are pretty rare. So we are not just > talking about huge NUMA machines here but about ordinary NUMA machines taking a > remote cache miss hit for the first IRQ or other IDT-accessing operation they do > after some cache-intense user-space processing. > > It's a small effect, but it exists and improving it would be > legitimate. If the effect is measurable I agree it is a legitimate optimization. At one point there was a suggestion to make the code in the IDT vectors differ based on the which interrupt was registed. While that can also reduce cache misses that can get hairy very quickly, and of course that would require read-write IDTs. My only practical concern with duplicating the IDT tables per cpu is (a) there are generic idt handlers that remain unduplicated reducing the benefit and this is essentially the same optimization as making the entire kernel text per cpu which last time it was examined was not an optimization worth making. So I wonder if just a subset of the optimization is worth making. Eric -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/