Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp714764yba; Wed, 24 Apr 2019 08:27:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqxgKHNBwXWZ1MLEGctisQYP9fw6UUlVoJLVLK7Ji51mMzPU28af1g/ruWYHtysHUV/byrW2 X-Received: by 2002:a17:902:4481:: with SMTP id l1mr14070580pld.75.1556119635497; Wed, 24 Apr 2019 08:27:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556119635; cv=none; d=google.com; s=arc-20160816; b=i2I4vMYZcIx8BlnYxTVMMt296oS9U4Mb9M9Uh3BUPXl2l7XNe0T42eFVKd10sA9KDY JzNZOy2XjLgB8f28y1omQUDC+rTifyIJ9HQ3r5ggXfE2QgPKeNPF9nuuUs5AwyVgHsSd oQKJGK+EaloGFdhT/gOWvTE6WoE5uZmqKCy0pmc0TXij1qE0jkVyiu9S93H98DWq5Nrg eQGvVXsBCYAQdVfMGMa8LYab3OB7Hg7u2G4T7uPTP2IQy8mMcCjSxTVsQECgMx0Ls4tq kmztlhRXuLiLLnM0o7PcDiuKhRV+OLGqSmT2JoCOGTMIpnER1ffYQNv6gZZQ9iVCsuTK klLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=jy4yDKrc4yriyy49NKNbIGeaZKEJiVoy7GIQXjy8eHI=; b=MqK3U8Vzwh6jcre4/CJoj5GLHQH2qH+h0BAlLT3ZYnCKYz9VPTQ5OosljuMt/+a1By A+6EQ8fJz7xXm8jmwdAl7dazDPQIoOR07wlHWFxUsu/DjGdgmOnnm1hVoHD1BeGLoV/E EQSH3kcSGztueuTzmzRBLXfE7aglYArwAib+Wb78c6RJzNeTNaiphiVmsa0UCvtrw8Jn S7WEKY8BIIYEnAHgH9odsu/HAOOWPvDJKoFJV50jKVLcNgHLLniyo54XLAH4aDzhxq99 8F8yRQH+RV2T86AnDrywre+AcHOjq+/9/wpkExvT6dT5ieSgn5hlEFFFEXv5yFpReLWf g8VQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=uFZ+LaHn; 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=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 33si19511868plk.421.2019.04.24.08.27.00; Wed, 24 Apr 2019 08:27:15 -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=pass header.i=@efficios.com header.s=default header.b=uFZ+LaHn; 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=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731320AbfDXPZp (ORCPT + 99 others); Wed, 24 Apr 2019 11:25:45 -0400 Received: from mail.efficios.com ([167.114.142.138]:58022 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731185AbfDXPZj (ORCPT ); Wed, 24 Apr 2019 11:25:39 -0400 Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id 509271D91A7; Wed, 24 Apr 2019 11:25:38 -0400 (EDT) Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10032) with ESMTP id 3xiBb2YDewXD; Wed, 24 Apr 2019 11:25:37 -0400 (EDT) Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id 7CDA71D918D; Wed, 24 Apr 2019 11:25:37 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 7CDA71D918D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1556119537; bh=jy4yDKrc4yriyy49NKNbIGeaZKEJiVoy7GIQXjy8eHI=; h=From:To:Date:Message-Id; b=uFZ+LaHnvkT9cjexWbgOlX9xHsPhuWzkO/VCDPmQv5sUkt+9ARZEc1dTwvQ9okY/W gH8aPCjD/i0wG+0IgCeTFBBkOZ4vYsOMJcCR2+umYvTW9AfDQ0UpLHgOQFo0r4woLI ve00jrTocKXU2UktGVA08lnXeo2dQpzYRDDH7LuMnq+p09yciaRphH0+R68ewoaf2r GvZt5HnHVvM5nwfGup0Mt9nvSGFDxzwu+63sCm6CZqY8xPkggbMzmw9OAQFW5S39sF rVuEdCU6GaILCMmT9wDjCxlisYQ4sqV1SvRgEgGwf0K/3im0pjx2l85jBEJjhnuAbF PUw74dHWrpKzg== X-Virus-Scanned: amavisd-new at efficios.com Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10026) with ESMTP id PxSgngw5oy8l; Wed, 24 Apr 2019 11:25:37 -0400 (EDT) Received: from thinkos.internal.efficios.com (192-222-157-41.qc.cable.ebox.net [192.222.157.41]) by mail.efficios.com (Postfix) with ESMTPSA id C36BC1D9179; Wed, 24 Apr 2019 11:25:36 -0400 (EDT) From: Mathieu Desnoyers To: Peter Zijlstra , "Paul E . McKenney" , Boqun Feng Cc: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Thomas Gleixner , Andy Lutomirski , Dave Watson , Paul Turner , Andrew Morton , Russell King , Ingo Molnar , "H . Peter Anvin" , Andi Kleen , Chris Lameter , Ben Maurer , Steven Rostedt , Josh Triplett , Linus Torvalds , Catalin Marinas , Will Deacon , Michael Kerrisk , Joel Fernandes , Shuah Khan , Mathieu Desnoyers , linux-kselftest@vger.kernel.org Subject: [RFC PATCH for 5.2 05/10] rseq/selftests: x86: use ud1 instruction as RSEQ_SIG opcode Date: Wed, 24 Apr 2019 11:24:57 -0400 Message-Id: <20190424152502.14246-6-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190424152502.14246-1-mathieu.desnoyers@efficios.com> References: <20190424152502.14246-1-mathieu.desnoyers@efficios.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use ud1 as the guard instruction for the restartable sequence abort handler. Its benefit compared to nopl is to trap execution if the program ends up trying to execute it by mistake, which makes debugging easier. The 4-byte signature per se is unchanged (it is the instruction operand). Only the opcode is changed from nopl to ud1. Signed-off-by: Mathieu Desnoyers Suggested-by: Peter Zijlstra CC: Peter Zijlstra CC: Thomas Gleixner CC: Joel Fernandes CC: Catalin Marinas CC: Dave Watson CC: Will Deacon CC: Shuah Khan CC: Andi Kleen CC: linux-kselftest@vger.kernel.org CC: "H . Peter Anvin" CC: Chris Lameter CC: Russell King CC: Michael Kerrisk CC: "Paul E . McKenney" CC: Paul Turner CC: Boqun Feng CC: Josh Triplett CC: Steven Rostedt CC: Ben Maurer CC: linux-api@vger.kernel.org CC: Andy Lutomirski CC: Andrew Morton CC: Linus Torvalds --- tools/testing/selftests/rseq/rseq-x86.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/rseq/rseq-x86.h b/tools/testing/selftests/rseq/rseq-x86.h index 03095236f6fa..b2da6004fe30 100644 --- a/tools/testing/selftests/rseq/rseq-x86.h +++ b/tools/testing/selftests/rseq/rseq-x86.h @@ -7,6 +7,13 @@ #include +/* + * RSEQ_SIG is used with the following reserved undefined instructions, which + * trap in user-space: + * + * x86-32: 0f b9 3d 53 30 05 53 ud1 0x53053053,%edi + * x86-64: 0f b9 3d 53 30 05 53 ud1 0x53053053(%rip),%edi + */ #define RSEQ_SIG 0x53053053 /* @@ -88,8 +95,8 @@ do { \ #define RSEQ_ASM_DEFINE_ABORT(label, teardown, abort_label) \ ".pushsection __rseq_failure, \"ax\"\n\t" \ - /* Disassembler-friendly signature: nopl (%rip). */\ - ".byte 0x0f, 0x1f, 0x05\n\t" \ + /* Disassembler-friendly signature: ud1 (%rip),%edi. */ \ + ".byte 0x0f, 0xb9, 0x3d\n\t" \ ".long " __rseq_str(RSEQ_SIG) "\n\t" \ __rseq_str(label) ":\n\t" \ teardown \ @@ -609,8 +616,8 @@ do { \ #define RSEQ_ASM_DEFINE_ABORT(label, teardown, abort_label) \ ".pushsection __rseq_failure, \"ax\"\n\t" \ - /* Disassembler-friendly signature: nopl . */ \ - ".byte 0x0f, 0x1f, 0x05\n\t" \ + /* Disassembler-friendly signature: ud1 ,%edi. */ \ + ".byte 0x0f, 0xb9, 0x3d\n\t" \ ".long " __rseq_str(RSEQ_SIG) "\n\t" \ __rseq_str(label) ":\n\t" \ teardown \ -- 2.11.0