Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp630256img; Mon, 18 Mar 2019 10:38:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqyxtvnMdIxavkOaQZalxMz93jCx1XwEBPTtOQ2FA2mv+q5jq2OREQKVCQOvIj84LgLscpXH X-Received: by 2002:a17:902:8a8a:: with SMTP id p10mr20503478plo.92.1552930711918; Mon, 18 Mar 2019 10:38:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552930711; cv=none; d=google.com; s=arc-20160816; b=uwDMHQX2jd/mvPl99EOS4haA2IK79ZR3OrrUTp/YUwKRX4Kz5dSC/WxYWL0mok4qb6 jyC05iwmyw9UNQht39BA+N+d0ZozCoKhUYMIQ2zNmZL3CHlk2Qpl6TkuOJsgNBwGLGmn iJnnrIktLFahz3AXpiTbbXjC6D8gxicivWymr+U83qW6ZrSjTKkXjffaorn1IPpRNdZ5 4nM/dYbWoUw1BP/4acns0z+Ca5q3D+5YxlwqrJ2tNjy0qJLsFkVptk52rVN5GOeU/bLB 0H0pZ88BRfA2TRuPw6+X/aMpFuiBU/NTwxa5nLKzbKE43nhMEb/OXCRp7pP++cDrE2Kd FInA== 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:dkim-signature; bh=8aD9+1W3V5mx6TORDEEgq4CgOe+FDRE1sNncKkZvLXM=; b=x7kqmPM2Tzzr0GjS7uQAqjKCl9oGf8NjMheUCnLYF2GAcoeGfKw+kU+/x+YoXR7NDi VxgzpUJ1DszldCJM4nMJjpLqivqVKapEGt+WeXd1h22ExRQLh2bYymWE5kCvBP6W752s lHBH+nByMsKUK+YT9CiqxkhA4Q1FQijZgo1ZWwKRGVWwP1gSSHEs79XD7DxGB6E0/4U4 vpgeOAKj6Hce/KyiArmd1Vjc+xnnHYLH9Qv1DGV9ubK5Ifq1ttrzLxQWti/38EBKXhV/ H0dmKAjVD1GLXoekqyHJStUcuLI94WdnybthRAh63ZRUa6N4/NtCFRKbaPSAIsnf4K2y wwNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=SqJlOsEt; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w10si9686569plp.329.2019.03.18.10.38.16; Mon, 18 Mar 2019 10:38:31 -0700 (PDT) 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=fail header.i=@infradead.org header.s=merlin.20170209 header.b=SqJlOsEt; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727563AbfCRRhS (ORCPT + 99 others); Mon, 18 Mar 2019 13:37:18 -0400 Received: from merlin.infradead.org ([205.233.59.134]:60694 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727358AbfCRRhR (ORCPT ); Mon, 18 Mar 2019 13:37:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=8aD9+1W3V5mx6TORDEEgq4CgOe+FDRE1sNncKkZvLXM=; b=SqJlOsEtqkNQbSIzFikfwRG7J NaNIRHTGFD3ED4ADeT3AJ3WeuFiEqViIf6/WufbHcpu9oMEvT+sjHT8fAWPAG5nUUxRWge4dfNs0S b3PF4oYhKkeTHI4OC1AT30PyGcrD4n1Aiv8Qdtj4obphbl/EToE7WmgNmP65voKeNaTbR1+wToKFD 8YeEzHzaYdxPWTgFkgBRdXNS3mjk8q1CrwnFl88rTc2QdcZto2mt85tLG/+kQb3Feqimp6KIhldlO lclNjzJJtFzcy1S9o+wOAhj5HqX+0kdp8KSFfi1tBjQIvVKoIax1wpeGkHXQz+rOsI5J7+EtyAMb9 MdMyL2zCA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1h5wC3-00070o-QM; Mon, 18 Mar 2019 17:37:00 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 6A0402030E118; Mon, 18 Mar 2019 18:36:57 +0100 (CET) Date: Mon, 18 Mar 2019 18:36:57 +0100 From: Peter Zijlstra To: Linus Torvalds Cc: Thomas Gleixner , Peter Anvin , Julien Thierry , Will Deacon , Andy Lutomirski , Ingo Molnar , Catalin Marinas , James Morse , valentin.schneider@arm.com, Brian Gerst , Josh Poimboeuf , Andrew Lutomirski , Borislav Petkov , Denys Vlasenko , Linux List Kernel Mailing , Dmitry Vyukov , Steven Rostedt Subject: Re: [PATCH 01/25] x86: Make SMAP 64-bit only Message-ID: <20190318173657.GV6058@hirez.programming.kicks-ass.net> References: <20190318153840.906404905@infradead.org> <20190318155139.963285969@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 Mon, Mar 18, 2019 at 09:58:20AM -0700, Linus Torvalds wrote: > On Mon, Mar 18, 2019 at 8:54 AM Peter Zijlstra wrote: > > > > We rely on objtool to verify AC=1 doesn't escape. However there is no > > objtool support for x86_32, and thus we cannot guarantee the > > correctness of the 32bit code. > > Absolutely not. > > This is just crazy. We had working SMAP long before objtool, and we > will have it regardless of objtool. Well, 'working', because as shown with this work, there's been a number of bugs around this. Anyway, since you mentioned it, I checked, about 16 months: Broadwell was Oct'14, objtool was Feb'16. > This is like saying "ok, I don't have an oxygen sensor, so I don't > know that the air I'm breathing is sufficient to maintain life, so > I'll just stop breathing". With PTI, booting a 32bit kernel on a Broadwell or later will already complain about it being sub-optimal for missing out on PCID. But sure; if you want to enable this.. > So no way in hell do we make SMAP go away on 32-bit for no sane reason > what-so-ever. then I'd sleep much better if we make 32bit context switch EFLAGS. Because, yes, x86_64 objtool validates a lot of the x86_32 code too, but unless we have 100% coverage, there's always the chance an AC=1 escapes. --- arch/x86/entry/entry_32.S | 2 ++ arch/x86/include/asm/switch_to.h | 1 + arch/x86/kernel/process_32.c | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S index d309f30cf7af..5fc76b755510 100644 --- a/arch/x86/entry/entry_32.S +++ b/arch/x86/entry/entry_32.S @@ -650,6 +650,7 @@ ENTRY(__switch_to_asm) pushl %ebx pushl %edi pushl %esi + pushfl /* switch stack */ movl %esp, TASK_threadsp(%eax) @@ -672,6 +673,7 @@ ENTRY(__switch_to_asm) #endif /* restore callee-saved registers */ + popfl popl %esi popl %edi popl %ebx diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h index 7cf1a270d891..18a4b6890fa8 100644 --- a/arch/x86/include/asm/switch_to.h +++ b/arch/x86/include/asm/switch_to.h @@ -46,6 +46,7 @@ struct inactive_task_frame { unsigned long r13; unsigned long r12; #else + unsigned long flags; unsigned long si; unsigned long di; #endif diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c index e471d8e6f0b2..d28e9a74b736 100644 --- a/arch/x86/kernel/process_32.c +++ b/arch/x86/kernel/process_32.c @@ -127,6 +127,11 @@ int copy_thread_tls(unsigned long clone_flags, unsigned long sp, struct task_struct *tsk; int err; + /* + * We start a new task with the RESET value of EFLAGS, in particular we + * context switch with IRQs disabled. + */ + frame->flags = X86_EFLAGS_FIXED; frame->bp = 0; frame->ret_addr = (unsigned long) ret_from_fork; p->thread.sp = (unsigned long) fork_frame;