Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2260490imu; Tue, 6 Nov 2018 11:33:31 -0800 (PST) X-Google-Smtp-Source: AJdET5dp8/AgdAPswJ4fyB3zPohSgFR+R9FJd3A9yBM1LgOdGb2UJD8lfCUjVssDI7h315ygI2X1 X-Received: by 2002:a63:df50:: with SMTP id h16mr25037498pgj.421.1541532811405; Tue, 06 Nov 2018 11:33:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541532811; cv=none; d=google.com; s=arc-20160816; b=jBOAmeAzx2y3Sc02bdiTYuIAnbYANQgT2DDva7EvRgXe+pZGklrrtrKr81NYzXmTqh oMUsYrJrSjxm6tlCnukk6STJJhfZvmeAqVlFhBGVLCq4o7/ACyOtpzWuvgNEusgeYHaV U5F1jAOqQc9ZuvQ8Vnfqm49iqR8AaoDiMXzn342taN54mraXSh/mUZtH5GtU7bBUZvWf QLWrb5OyWVneGdAv9Ybk7hEKdPTjHJ7ZnvtMlLz4wxxxRrTgAWU7ZEV4PI0mDmLgGHrJ vMyexGmHUH/AAeYOWdrXcgSjctjY5eAeUET1FxP6JNMjwRpVKy2j2UfMqSyxygkAllP9 TTOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=ff/unWpMYqcJyC/XCKzSyImdSvdxesphNOgvcWfV+bk=; b=tPjKXnqpW00uxVUz+iAGsaf5LjfEBJQQEPC+JwvxqXq95nLbV5B1jyW+QtFW98p3u4 mg6CV9COqPK2PWR1+aOjuCS0j7OWoBEyyzFI/kto08TdjgrlWr8w7BZEn+0vmZomj45u KiuWc7a82rx5kV+zzMCwjA8MFg0VBpQvM0Rb+nTNiYJKzngmyzp+0NwSluaPfr2KfeFG 47oaxU1vf4tFAfCkuSO5UeRfQyCptBU17y08XzreIAqjavrLDISgB1yjuS0RDxkqO2IJ aJz/aVcuZt19OJkkHqNp8cKPjjZguolSQpAdz0N8AYGHtJihgxTYUlCezNO5/+rVyHij gMdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=l6kTCtOP; 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 1-v6si48657260plr.113.2018.11.06.11.33.15; Tue, 06 Nov 2018 11:33:31 -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; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=l6kTCtOP; 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 S2388426AbeKGExj (ORCPT + 99 others); Tue, 6 Nov 2018 23:53:39 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:36593 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388065AbeKGExj (ORCPT ); Tue, 6 Nov 2018 23:53:39 -0500 Received: by mail-wm1-f66.google.com with SMTP id a8-v6so13356623wmf.1 for ; Tue, 06 Nov 2018 11:26:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ff/unWpMYqcJyC/XCKzSyImdSvdxesphNOgvcWfV+bk=; b=l6kTCtOPNRfKeJ7KL2f13bJCfI1UYCOAf5I1KstoDRVJ1mL+sIEZLE/B57oYb9iB/J 4fOLTRTsUpwioiO7XV72khVAZPAUHhAot+2kTyUpyrWKqRqz9ZjlSGITsAU+kl9I33zS Hymr2VpU39WWCBVWN5oiMR0uKqlwSUJGZ1Oy9U1XWsDVrF5UMGdYMbYb0TcV6AYxXsIS Hr5khBayLxxF7IIISHRg2/GDfek46yE+BZoI8yk5seVkrUFRSYQiVkRVcGOCXz3TFbU/ Wu8H4yGxvlggD4dK7byoQ4GSztdIUsdCloMCIus7wjP/ThMnVzci3sx6auy1YLnNlqLh QGWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ff/unWpMYqcJyC/XCKzSyImdSvdxesphNOgvcWfV+bk=; b=lqnI1q0AMm9EVZuSLe3HCQhz64rm0ryPD8iXor60UfK7gIYa8hPpkles3+p0JbWTDP RTOXwmL1bTP3KEvOh5Z0lJFv/35HgcGKBbkAMNTZFVUwREEvCzcmYGhOe/n4IaQMRzG6 ObcImPHJ5Y1h+vd6FvZhAsP6BjVQSRdg3rr3JRl69Q60v1fFG1FcYJC/LA3gO+6qud7F TcooO6kqmT9cam4kOpd3dSPjPprh2mrCoAPdvCLFdUrmks1ylKYCGUQ2h8ECPlQe6IMH ObFltL4zzRT5sUOQYx7anHbwFLnYTdEtiDE5XQzcWzl75dD0H29r2nDNs3ZfUaE34lHm S5Cg== X-Gm-Message-State: AGRZ1gICnadv8E17Qbbuh6allBcFmyOz8esX7sSdtRSt8WzcM8KJlIAF AXzWvDd4QX2/MMQJH1vqbmnaBEYRIU/myrLPBgFQoA== X-Received: by 2002:a1c:2b45:: with SMTP id r66-v6mr2951052wmr.128.1541530547984; Tue, 06 Nov 2018 10:55:47 -0800 (PST) MIME-Version: 1.0 References: <20181011151523.27101-1-yu-cheng.yu@intel.com> <20181011151523.27101-22-yu-cheng.yu@intel.com> In-Reply-To: From: Andy Lutomirski Date: Tue, 6 Nov 2018 10:55:36 -0800 Message-ID: Subject: Re: [PATCH v5 21/27] x86/cet/shstk: Introduce WRUSS instruction To: Dave Hansen Cc: Yu-cheng Yu , X86 ML , "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , LKML , "open list:DOCUMENTATION" , Linux-MM , linux-arch , Linux API , Arnd Bergmann , Balbir Singh , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H. J. Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , "Shanbhogue, Vedvyas" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 6, 2018 at 10:43 AM Dave Hansen wrote: > > On 10/11/18 8:15 AM, Yu-cheng Yu wrote: > > --- a/arch/x86/mm/fault.c > > +++ b/arch/x86/mm/fault.c > > @@ -1305,6 +1305,15 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code, > > error_code |= X86_PF_USER; > > flags |= FAULT_FLAG_USER; > > } else { > > + /* > > + * WRUSS is a kernel instruction and but writes > > + * to user shadow stack. When a fault occurs, > > + * both X86_PF_USER and X86_PF_SHSTK are set. > > + * Clear X86_PF_USER here. > > + */ > > + if ((error_code & (X86_PF_USER | X86_PF_SHSTK)) == > > + (X86_PF_USER | X86_PF_SHSTK)) > > + error_code &= ~X86_PF_USER; > This hunk of code basically points out that the architecture of WRUSS is > broken for Linux. The setting of X86_PF_USER for a ring-0 instruction > really is a mis-feature of the architecture for us and we *undo* it in > software which is unfortunate. Wish I would have caught this earlier. > > Andy, note that this is another case where hw_error_code and > sw_error_code will diverge, unfortunately. > > Anyway, this is going to necessitate some comment updates in the page > fault code. Yu-cheng, you are going to collide with some recent changes > I made to the page fault code. Please be careful with the context when > you do the merge and make sure that all the new comments stay correct. I'm going to send a patch set in the next day or two that cleans it up further and is probably good preparation for WRUSS.