Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp715143yba; Wed, 24 Apr 2019 08:27:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqwrjFY35oGJ6LKHrlAsVIqXHlnycGIaqEVP/pEG0UgauI0QI0aIulGptQMyLAcHEVnxHlUc X-Received: by 2002:a17:902:714d:: with SMTP id u13mr24491061plm.104.1556119655597; Wed, 24 Apr 2019 08:27:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556119655; cv=none; d=google.com; s=arc-20160816; b=XLlNmHU7nj26jk7AZOPwY3WgAEUuvu1wR2mvSxBARfmV4iobTiUqrtOpQOfZ4BNoTe MLS9xyajFcDLEuya+rbD/mj0L/O6cmv3N2957j8um2TOxsJGwqlpSiaQkvPUqI0iJg6I 0IQM9pgAZTy6t3m0T6oqTp0imcYBV4lnziCzi7x3nTSH2Lx5exzugazXaGpH0jxvQYJa GOgpm6XO+W4+XIzCv7XYiOA/vaGW7TLl/hjUo3xjRzID+VVZ0IO0j8mb/cCIl/ya4gak dpJcfO2tEhuxRIXgQbiO+OMfpx53jRR+nM2QhuRLsiCzddoU/DtZKosOkWum5CVu1OD2 aOkw== 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=HKvroncAGMEGmOUp7SnchUF8B52rTeenvfZlybbg6Hw=; b=SWLkH9G+SGJgfqhHi0/fk7p05WIr6tHA9qLEHd67IJPQRJrHm68pkR+hsmkZdu2YX0 UknF+qeEIPBfKF0EulUtsyMCisAQKd5vHsqOCvHxmi/jjueDHLukksEk5EWq2xDAsUAE eX3uM9XxgKl/Z1H1p8DAXSPvk6OfvR5weqs9KYZjdI4VP+vg5AVIWU4eni17882Xx1n9 r4FhT/lHphe9tVaP8bpAD5i0hK/5i3HZpdYQUIZJ54skQ1Qk5+hx32Bnu8IrdhlhPeNY 81KAD9Nt/W50R34Uao07Rt9WgxvVUOb+4jHd0VHxrQ1VLs+i78+NLwfbILa2VhwOdfgD oeuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=manuagDv; 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 q7si17968956pgh.541.2019.04.24.08.27.19; Wed, 24 Apr 2019 08:27:35 -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=manuagDv; 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 S1731485AbfDXP0O (ORCPT + 99 others); Wed, 24 Apr 2019 11:26:14 -0400 Received: from mail.efficios.com ([167.114.142.138]:58050 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731113AbfDXPZn (ORCPT ); Wed, 24 Apr 2019 11:25:43 -0400 Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id 9293E1D91E0; Wed, 24 Apr 2019 11:25:41 -0400 (EDT) Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10032) with ESMTP id Ss8JZna-6OU2; Wed, 24 Apr 2019 11:25:41 -0400 (EDT) Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id 26CE71D91CF; Wed, 24 Apr 2019 11:25:41 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 26CE71D91CF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1556119541; bh=HKvroncAGMEGmOUp7SnchUF8B52rTeenvfZlybbg6Hw=; h=From:To:Date:Message-Id; b=manuagDvDmaUX9s/0e0I0qi/Bfa8UlTQDPaHTdbabYTH9US3Bpqmp/e1EyyLG8ugi 0YzMjBl/gbl/JErnSB9St/vdYL+Imjcdd4FfsiC50JlPlw6iv9vmm2Nxbtoy4kYE+c ZdGPpS+K33eoJmjsWmeOqD07vxgWeyIn7uQKyYdeL8MgFdwY9+3qxRXT+D6zDt19tZ 6/3qfAJukHbuAEf2xHXIHAwbexnKi9iBI4zQImS8Z3Q/YavmuW5JQsGm48XW0FW27l ki08uH0IZqPk7jRCCe0x6Js4HgO1/UnVYgAxk7fGAOZTwm0U8qshWJFn3C2M5ZtFws JOkqbF0Z3+vWw== 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 az42ab1i1Odd; Wed, 24 Apr 2019 11:25:41 -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 9900E1D91B4; Wed, 24 Apr 2019 11:25:38 -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 08/10] rseq/selftests: aarch64 code signature: handle big-endian environment Date: Wed, 24 Apr 2019 11:25:00 -0400 Message-Id: <20190424152502.14246-9-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 Handle compiling with -mbig-endian on aarch64, which generates binaries with mixed code vs data endianness (little endian code, big endian data). Else mismatch between code endianness for the generated signatures and data endianness for the RSEQ_SIG parameter passed to the rseq registration will trigger application segmentation faults when the kernel try to abort rseq critical sections. Signed-off-by: Mathieu Desnoyers 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-arm64.h | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/rseq/rseq-arm64.h b/tools/testing/selftests/rseq/rseq-arm64.h index b41a2a48e965..200dae9e4208 100644 --- a/tools/testing/selftests/rseq/rseq-arm64.h +++ b/tools/testing/selftests/rseq/rseq-arm64.h @@ -6,7 +6,20 @@ * (C) Copyright 2018 - Will Deacon */ -#define RSEQ_SIG 0xd428bc00 /* BRK #0x45E0 */ +/* + * aarch64 -mbig-endian generates mixed endianness code vs data: + * little-endian code and big-endian data. Ensure the RSEQ_SIG signature + * matches code endianness. + */ +#define RSEQ_SIG_CODE 0xd428bc00 /* BRK #0x45E0. */ + +#ifdef __AARCH64EB__ +#define RSEQ_SIG_DATA 0x00bc28d4 /* BRK #0x45E0. */ +#else +#define RSEQ_SIG_DATA RSEQ_SIG_CODE +#endif + +#define RSEQ_SIG RSEQ_SIG_DATA #define rseq_smp_mb() __asm__ __volatile__ ("dmb ish" ::: "memory") #define rseq_smp_rmb() __asm__ __volatile__ ("dmb ishld" ::: "memory") @@ -121,7 +134,7 @@ do { \ #define RSEQ_ASM_DEFINE_ABORT(label, abort_label) \ " b 222f\n" \ - " .inst " __rseq_str(RSEQ_SIG) "\n" \ + " .inst " __rseq_str(RSEQ_SIG_CODE) "\n" \ __rseq_str(label) ":\n" \ " b %l[" __rseq_str(abort_label) "]\n" \ "222:\n" -- 2.11.0