Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1900427yba; Thu, 25 Apr 2019 07:30:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqwdQhxO5yv0KOcAHR+N2KB1cmMVaQanPmMC5hPk/RqDClGeWL2c1wZtknDF6Rd7nDaN4ywL X-Received: by 2002:a65:5304:: with SMTP id m4mr13209476pgq.281.1556202646919; Thu, 25 Apr 2019 07:30:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556202646; cv=none; d=google.com; s=arc-20160816; b=ZTOech4JTRbtGiW4lktNY6d/vNVJ9kcQ+0b1j8kXPq64SEyC/w1Yq5wN76iVoErGwm eSaVkQd3PHRJ4Lvy9nVrh0t/2Q/DIJA5xRvW065CQJtURceHsFDqkCFXXLuUJkVQDCMm 2DTFRC5fFmDsEGkmicQZAoY61j0DEPKl/Nhw96NJbsfFK6Paz5ugCAIbu33c+uEsyIc/ EnE0VZ0rEp0bVl5JAdNGkvEyfO8Jblon6G8KWSKlsLC1XEpCoD5tgjumA8PDbtVHl2UM U7Ap6D5OyOz0RtJsh1JOTMzUiTu/pl71yV0eaJEQvF3zXRpwifilCpXsTzNDw/jS6u3B hLSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:thread-index:thread-topic :content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:dkim-signature:dkim-filter; bh=hChOmBoqO3NUzgFtXBDTLegXBKfZ7EYkQrqnF5s/I1w=; b=fCH7y3+j6z7Xq0IUnPkJG7Q0khqgsK98pRX4oY5bOeIp8m1oABzJEZBKXxGQOPx+fu uP733yNtKLgGiJi81nNkz7gKKXqizTTaR/k57uK4Mc/GIYkLi9e7rfxiOVhYYtyfkC8J 6UUyoD4/5SjCXWyFmTs64m9YR/AW9TD73HpH+vkmvUlyMq8rUnXEyQ4I7c7MFL/Azx99 XHe1LM8wlfkrI1PF2L51Y3w8cHx/HtfLhsUKNy2Qs6+cW9z6gbb56+3bCB6eqQjC89zp StUoNcfIZJNaMFrnqfngHEGgIcey8zVgNAXS+M26t9hGGTdz+wH9vUrK1VB0Xmo5Cwgp UN1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=Dt4u28Bj; 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 p22si21348922pgi.449.2019.04.25.07.30.31; Thu, 25 Apr 2019 07:30:46 -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=Dt4u28Bj; 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 S1727325AbfDYOVf (ORCPT + 99 others); Thu, 25 Apr 2019 10:21:35 -0400 Received: from mail.efficios.com ([167.114.142.138]:38316 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726213AbfDYOVe (ORCPT ); Thu, 25 Apr 2019 10:21:34 -0400 Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id A26D51D98DD; Thu, 25 Apr 2019 10:21:33 -0400 (EDT) Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10032) with ESMTP id Y57XpTG9ZkeC; Thu, 25 Apr 2019 10:21:32 -0400 (EDT) Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id D0B661D98D7; Thu, 25 Apr 2019 10:21:32 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com D0B661D98D7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1556202092; bh=hChOmBoqO3NUzgFtXBDTLegXBKfZ7EYkQrqnF5s/I1w=; h=Date:From:To:Message-ID:MIME-Version; b=Dt4u28BjWtCETk37x3nT3EkpvJZv+7swpd9lWV7Rz+vKw8A8KjSr11szUPWEbwPeY ujrtud6snk0Feg/rD37fl52ku3+XpWRaYQI9pw2wY7VhY1gdlJZDZKmizKwWFNtODt N9dDuIl5/X65gu05uYdHyha/b+cMSEqDM4CJcHykhwnZb4Fdy3cjyNJy6Jm81zxnBp RFUx289ieZW0Ak4ld6ahc2wCkM9QDrnwWEZQi/YY60N4esAhcdkzfw4QSCluVcZpC+ mNDIiVpseNe8KpGOnheIpKKM4qXckhgRljLx8NJOjvxrRHY13Fl7kQojKf2lb8sHJw 53Mda7pwNBmOQ== 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 F5CD6uwdSYD1; Thu, 25 Apr 2019 10:21:32 -0400 (EDT) Received: from mail02.efficios.com (mail02.efficios.com [167.114.142.138]) by mail.efficios.com (Postfix) with ESMTP id B09F71D98D0; Thu, 25 Apr 2019 10:21:32 -0400 (EDT) Date: Thu, 25 Apr 2019 10:21:32 -0400 (EDT) From: Mathieu Desnoyers To: Paul Burton Cc: Peter Zijlstra , "Paul E . McKenney" , Boqun Feng , linux-kernel , linux-api , Thomas Gleixner , Andy Lutomirski , Dave Watson , Paul Turner , Andrew Morton , Russell King , Ingo Molnar , "H. Peter Anvin" , Andi Kleen , Chris Lameter , Ben Maurer , rostedt , Josh Triplett , Linus Torvalds , Catalin Marinas , Will Deacon , Michael Kerrisk , Joel Fernandes , shuah , James Hogan , Ralf Baechle , linux-mips Message-ID: <1183307732.352.1556202092390.JavaMail.zimbra@efficios.com> In-Reply-To: <20190424220609.4kryfcgsv46iu3ds@pburton-laptop> References: <20190424152502.14246-1-mathieu.desnoyers@efficios.com> <20190424152502.14246-11-mathieu.desnoyers@efficios.com> <20190424220609.4kryfcgsv46iu3ds@pburton-laptop> Subject: Re: [RFC PATCH for 5.2 10/10] rseq/selftests: mips: use break instruction for RSEQ_SIG MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [167.114.142.138] X-Mailer: Zimbra 8.8.12_GA_3794 (ZimbraWebClient - FF66 (Linux)/8.8.12_GA_3794) Thread-Topic: rseq/selftests: mips: use break instruction for RSEQ_SIG Thread-Index: AQHU+rH+AJnCxtNxUESFNInzrhwEUaZL3nOAgK8p+5Y= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- On Apr 24, 2019, at 6:06 PM, Paul Burton paul.burton@mips.com wrote: > Hi Mathieu, > > On Wed, Apr 24, 2019 at 11:25:02AM -0400, Mathieu Desnoyers wrote: >> diff --git a/tools/testing/selftests/rseq/rseq-mips.h >> b/tools/testing/selftests/rseq/rseq-mips.h >> index fe3eabcdcbe5..eb53a6adfbbb 100644 >> --- a/tools/testing/selftests/rseq/rseq-mips.h >> +++ b/tools/testing/selftests/rseq/rseq-mips.h >> @@ -7,7 +7,11 @@ >> * (C) Copyright 2016-2018 - Mathieu Desnoyers >> */ >> >> -#define RSEQ_SIG 0x53053053 >> +/* >> + * RSEQ_SIG uses the break instruction. The instruction pattern is >> + * 0350000d break 0x350 >> + */ >> +#define RSEQ_SIG 0x0350000d > > My apologies for taking a while to get back to you on the various ISAs & > endian issues here, but I think we'll want this to be something like: > > #if defined(__nanomips__) > # ifdef __MIPSEL__ > # define RSEQ_SIG 0x03500010 > # else > # define RSEQ_SIG 0x00100350 > # endif > #elif defined(__mips_micromips) > # ifdef __MIPSEL__ > # define RSEQ_SIG 0xd4070000 > # else > # define RSEQ_SIG 0x0000d407 > # endif > #else > # define RSEQ_SIG 0x0350000d > #endif > > For plain old MIPS the .word directive will be fine endian-wise, but for > microMIPS & nanoMIPS we need to take into account that the instruction > stream is encoded as 16b halfwords & swap those accordingly for little > endian. Considering that we have micromips and nanomips already, I guess something along the lines of "picomips" is not that far away... I've tried to figure out if we could find a way to have RSEQ_SIG left undefined if it's not on the plain mips environment, but could not find anything that would be #defined on plain mips, but #undefined on both micromips and nanomips. What I'd like to do is e.g.: #if defined(__nanomips__) # ifdef __MIPSEL__ # define RSEQ_SIG 0x03500010 # else # define RSEQ_SIG 0x00100350 # endif #elif defined(__mips_micromips) # ifdef __MIPSEL__ # define RSEQ_SIG 0xd4070000 # else # define RSEQ_SIG 0x0000d407 # endif #elif defined(__mips__) # define RSEQ_SIG 0x0350000d #else /* Leave RSEQ_SIG as is. */ #endif The idea here is to not allow code targeting future MIPS ISA to compile with the wrong signature. The delta between compiling without/with -mmicromips on a gcc-8 compiler is only: > #define __mips_micromips 1 Some interesting delta when compiling for plain little-endian mips with gcc-8 compared to the nanomips compiler is: < #define __mips__ 1 < #define _mips 1 < #define MIPSEL 1 > #define __nanomips__ 1 < #define __mips_isa_rev 2 > #define __mips_isa_rev 6 So let's say we have a picomips introduced in the future, can we rely on it not defining __mips__ like the nanomips compiler does ? If so, my "#elif defined(__mips__)" approach would indeed leave RSEQ_SIG undefined as expected. Thoughts ? Thanks, Mathieu -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com