Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752950AbbBYJjv (ORCPT ); Wed, 25 Feb 2015 04:39:51 -0500 Received: from mail-wg0-f43.google.com ([74.125.82.43]:45436 "EHLO mail-wg0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752788AbbBYJjr (ORCPT ); Wed, 25 Feb 2015 04:39:47 -0500 Date: Wed, 25 Feb 2015 10:39:42 +0100 From: Ingo Molnar To: "H. Peter Anvin" Cc: Andy Lutomirski , Denys Vlasenko , Linus Torvalds , Steven Rostedt , Borislav Petkov , Oleg Nesterov , Frederic Weisbecker , Alexei Starovoitov , Will Drewry , Kees Cook , X86 ML , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH 1/4] x86: entry.S: tidy up several suboptimal insns Message-ID: <20150225093942.GA6676@gmail.com> References: <1424803895-4420-1-git-send-email-dvlasenk@redhat.com> <54ED00B5.3020203@zytor.com> <20150225092043.GB16165@gmail.com> <54ED957D.8000709@zytor.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <54ED957D.8000709@zytor.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1448 Lines: 50 * H. Peter Anvin wrote: > > So could we just zap the high 32 bits of RAX early in > > the entry code, and then from that point on we could > > both use 32-bit ops and won't have to remember the > > possibility either? > > We do that, [...] Ok, indeed, so in ia32_sysenter_target() we have: movl %eax, %eax > [...] but people keep "optimizing" the zero extend away. > [...] Possibly because there's not a single comment near that code explaining the importance of that line. But nobody will get a change past me with such a warning next to the line. > [...] We have had this cause a wide-open security hole > twice already. So the extra REX prefix is a cheap cost > to avoid this happen again. But since we already zap the high bits, there's no point in doing 64-bit compares... Just make sure the high zero bit clearing is there and is never removed. So in that sense the changes are correct, even in the security robustness sense. Furthermore, with the masking suggestion I made in the previous mail it's moot as we can solve both problems: 64-bit uses of RAX will become correct as well, and it will be a bit faster as well. Hm? Thanks, Ingo -- 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/