Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2313425imu; Tue, 6 Nov 2018 12:27:27 -0800 (PST) X-Google-Smtp-Source: AJdET5f1UKpOAAiH2aA+pZkrIjfht/td4arsiSxccXmBMzcoRsf91yTBT2Frj5OwXKQRA72xCliE X-Received: by 2002:a17:902:784c:: with SMTP id e12-v6mr2070367pln.185.1541536047144; Tue, 06 Nov 2018 12:27:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541536047; cv=none; d=google.com; s=arc-20160816; b=t2V9ZjdnJUJnAD1Im5OkcjUDJDJzj53Q+9XKBLpzBe9XNggiLoQzzF0Lx7tnLrPFcU FDJ94AAMDTfdtWqzYESU5tZ/0/RqDQGpIvq4L2GIgOrzRSci/aKcVQN15A5Fjd6k3V9l 0B5PwGLtlkn05oUndf53kISFGiom+vAsLwjxI4uA6awmyEFf2DJ7d2jT64gSKbCs9Atn SGtyfXkPzynKU1cX1U924P528s9OKuMhUcoRxhhXmT3o/dloH+04OBBRTSAXgXOvXzi6 60QghrnOycMySPkboQWP1UretV3Z2n590QATF2wRzBEYPd+xZR6vQmc0cYaBCTSJ70dh lraQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:to:from:subject:message-id; bh=J4MO9HmPD7lR02vtLiplKIlsCbohlLEOdYs7KpC6auo=; b=C8neqplSNFbcXecezCMrEV+DTJzGih0j4GbOZZR6OV2cwH+nBk88qkBX03Diteg2Cl kzI2SIPSDG4KLK/vCPPEq0aEO/rJi788tAk+VvLHC193vvdRBg161MN727ZyQCM1N51V qRPaHwGg8DTrsLZ3hvEn5fnOkJIIrfc3p7wQf19bxaWUsuO3UQwQsJXNgZHUuy7JbTIF YyVnK57erx9nSMqUTYFjA4986K/Bv1as/UKR4wmy/G3ZlR4tndWUn4SkgRqFJJStQdcB 7QykypSPotehsxAAQ6pyHem5GhX991DEOpMItRmQcCVgu/fB1B+gLlHx83pQunN8qORs Qd6w== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e14-v6si46440426pgb.254.2018.11.06.12.27.11; Tue, 06 Nov 2018 12:27:27 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388394AbeKGFxt (ORCPT + 99 others); Wed, 7 Nov 2018 00:53:49 -0500 Received: from mga03.intel.com ([134.134.136.65]:29200 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726184AbeKGFxt (ORCPT ); Wed, 7 Nov 2018 00:53:49 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Nov 2018 12:26:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,472,1534834800"; d="scan'208";a="89057739" Received: from unknown (HELO yyu32-desk1) ([143.183.136.51]) by orsmga006.jf.intel.com with ESMTP; 06 Nov 2018 12:26:49 -0800 Message-ID: <26c7e2dd72efe8168b296285985eb5f025881bb1.camel@intel.com> Subject: Re: [PATCH v5 21/27] x86/cet/shstk: Introduce WRUSS instruction From: Yu-cheng Yu To: Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, Arnd Bergmann , Andy Lutomirski , 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" , Vedvyas Shanbhogue Date: Tue, 06 Nov 2018 12:21:38 -0800 In-Reply-To: References: <20181011151523.27101-1-yu-cheng.yu@intel.com> <20181011151523.27101-22-yu-cheng.yu@intel.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.1-2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2018-11-06 at 10:43 -0800, 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. Ok. Thanks! Yu-cheng