Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753161AbbBXUN1 (ORCPT ); Tue, 24 Feb 2015 15:13:27 -0500 Received: from mail-qg0-f48.google.com ([209.85.192.48]:56532 "EHLO mail-qg0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752576AbbBXUNY (ORCPT ); Tue, 24 Feb 2015 15:13:24 -0500 MIME-Version: 1.0 In-Reply-To: <20150224195801.GM3420@pd.tnic> References: <1424803895-4420-1-git-send-email-dvlasenk@redhat.com> <20150224195801.GM3420@pd.tnic> From: Denys Vlasenko Date: Tue, 24 Feb 2015 21:13:03 +0100 Message-ID: Subject: Re: [PATCH 1/4] x86: entry.S: tidy up several suboptimal insns To: Borislav Petkov Cc: Denys Vlasenko , Andy Lutomirski , Linus Torvalds , Steven Rostedt , Ingo Molnar , "H. Peter Anvin" , Oleg Nesterov , Frederic Weisbecker , Alexei Starovoitov , Will Drewry , Kees Cook , X86 ML , Linux Kernel Mailing List Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1685 Lines: 46 On Tue, Feb 24, 2015 at 8:58 PM, Borislav Petkov wrote: > On Tue, Feb 24, 2015 at 07:51:32PM +0100, Denys Vlasenko wrote: >> In all three 32-bit entry points, %eax is zero-extended to %rax. >> It is safe to do 32-bit compare when checking that syscall# >> is not too large. >> >> The last instance of "mysterious" SS+8 constant is replaced by SIZEOF_PTREGS. >> >> The $AUDIT_ARCH_X86_64 parameter to syscall_trace_enter_phase1/2 >> is a 32-bit constant, loading it with 64-bit MOV produces 10-byte insn >> instead of 5-byte one. >> >> After TEST insn, JE anctually means "jump of zero", >> let's use JZ mnemonic instead. > > Actually, JE == LZ as that's the same opcode for testing ZF=1. Yes, I know that :) > And I have to object: > > testl $3,CS(%rsp) > je retint_kernel > > is much more understandable than > > testl $3,CS(%rsp) > jz retint_kernel > > It basically says are $3 and CS(%rsp) equal. They aren't equal. $1 and $2 in two lowest bits will also be interpreted as "userspace" here. "Equal to $3" sends a wrong message here to a human reading the code, the code doesn't test for CPL=3, it tests for any nonzero CPL. > JZ, on the other hand, not so clear: the TEST ANDed the two operands and > set flags accordingly, so JZ is testing the ZF. This means, you actually > know what TEST does and you haven't forgotten. JZ says "jump if zero", in this case, "jump if CPL is zero". -- 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/