Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp765404imm; Wed, 11 Jul 2018 10:32:53 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf+a4NlP4z9G68XmnE3JLTw0w9RFHaBZf3EpyDPiIm/PESJQvwrRRgNHNoeWapMZrrC8alq X-Received: by 2002:a65:5a49:: with SMTP id z9-v6mr27617522pgs.244.1531330373403; Wed, 11 Jul 2018 10:32:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531330373; cv=none; d=google.com; s=arc-20160816; b=P8B/KtYXwXWF8Kl+nhX61wlTVJwkMHPSs/41Z+cwwIPsLPxG1jqg8k3Rba979J0XA+ 7PH2Oq66Zzfa0hC76fMfeRNrWcid/5cLn12jiefFlDtpMJg0iqNxcwl/vHdBJwWr9J60 qtKM7BpaaFHTIAgVw3yCFHAV9jGZJdfKz0ewEVwnZj2aG49f3XbRdcwlveTvmFz2fGGe zEmYrRovVFuzoMR8RLJnfE5HMVzrCYQ7IS3B22piJf+SBD4fQkk4lkb3Wi9ag91u2zkk Ck76UF8p1tL/Em+LdIMKkk2T7d2WobRQRLEoDjb1JbDY9p/42HeyR1CE4yCN0n9NLtOm O9WQ== 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:cc:to:from:subject:message-id :arc-authentication-results; bh=2zoYsjLcjuy1V8idvXOOFnwx9m6fYqUQEJSSPa8n1+A=; b=aKr3bkhk1NOapHbEL6uV5yC96oWuqc+a0krFr12M3tU+AWhESe/DKSIo6SR3wZJE7f R3aCqfVnHg/nXC0A5C33/I9DPRmfZgO+CqMgBL16n2dvAYH7fud7Zswh+Uey6JVzXON9 QBZXlFGZV4pSQbAn7iLijW4uun9Ax2Z+RBoFcolM0oR0dLYsYiVrP0oSgkp7/LmKni7H H2wCmsZ4/CmTeLJHPYqqPfrU5usDRVll2a6kJSVdKf+ncCxA2RJ/hZIzMXUNvzjjEzUP 8KDGMMNaaSfuAiCYXyBv862qunpFsYMVrOK2ud/KxipFoYKLyHmxPJcZzL5FO77E9Lhg sqEw== 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 u22-v6si19092545plq.135.2018.07.11.10.32.38; Wed, 11 Jul 2018 10:32:53 -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; 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 S2388755AbeGKPPV (ORCPT + 99 others); Wed, 11 Jul 2018 11:15:21 -0400 Received: from mga03.intel.com ([134.134.136.65]:12957 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732916AbeGKPPT (ORCPT ); Wed, 11 Jul 2018 11:15:19 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Jul 2018 08:10:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,338,1526367600"; d="scan'208";a="56086848" Received: from 2b52.sc.intel.com ([143.183.136.52]) by orsmga008.jf.intel.com with ESMTP; 11 Jul 2018 08:10:32 -0700 Message-ID: <1531321615.13297.9.camel@intel.com> Subject: Re: [RFC PATCH v2 18/27] x86/cet/shstk: Introduce WRUSS instruction From: Yu-cheng Yu To: Peter Zijlstra Cc: 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 , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , "Ravi V. Shankar" , Vedvyas Shanbhogue Date: Wed, 11 Jul 2018 08:06:55 -0700 In-Reply-To: <20180711094448.GZ2476@hirez.programming.kicks-ass.net> References: <20180710222639.8241-1-yu-cheng.yu@intel.com> <20180710222639.8241-19-yu-cheng.yu@intel.com> <20180711094448.GZ2476@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.18.5.2-0ubuntu3.2 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2018-07-11 at 11:44 +0200, Peter Zijlstra wrote: > On Tue, Jul 10, 2018 at 03:26:30PM -0700, Yu-cheng Yu wrote: > > > > WRUSS is a new kernel-mode instruction but writes directly > > to user shadow stack memory.  This is used to construct > > a return address on the shadow stack for the signal > > handler. > > > > This instruction can fault if the user shadow stack is > > invalid shadow stack memory.  In that case, the kernel does > > fixup. > > > > > > +static inline int write_user_shstk_64(unsigned long addr, unsigned > > long val) > > +{ > > + int err = 0; > > + > > + asm volatile("1: wrussq %[val], (%[addr])\n" > > +      "xor %[err], %[err]\n" > this XOR is superfluous, you already cleared @err above. I will fix it. > > > > > +      "2:\n" > > +      ".section .fixup,\"ax\"\n" > > +      "3: mov $-1, %[err]; jmp 2b\n" > > +      ".previous\n" > > +      _ASM_EXTABLE(1b, 3b) > > +      : [err] "=a" (err) > > +      : [val] "S" (val), [addr] "D" (addr)); > > + > > + return err; > > +} > > +#endif /* CONFIG_X86_INTEL_CET */ > > + > >  #define nop() asm volatile ("nop") > What happened to: > >   https://lkml.kernel.org/r/1528729376.4526.0.camel@2b52.sc.intel.com Yes, I put that in once and realized we only need to skip the instruction and return err.  Do you think we still need a handler for that? Yu-cheng