From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA64AC2D0E2 for ; Thu, 24 Sep 2020 13:54:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 67452206F7 for ; Thu, 24 Sep 2020 13:54:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=efficios.com header.i=@efficios.com header.b="FZvEyBC0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728031AbgIXNyC (ORCPT ); Thu, 24 Sep 2020 09:54:02 -0400 Received: from mail.efficios.com ([167.114.26.124]:47098 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727749AbgIXNyB (ORCPT ); Thu, 24 Sep 2020 09:54:01 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id B8B292D4D18; Thu, 24 Sep 2020 09:54:00 -0400 (EDT) Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id VGsJ-Aue3d2w; Thu, 24 Sep 2020 09:54:00 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 6129D2D4D17; Thu, 24 Sep 2020 09:54:00 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 6129D2D4D17 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1600955640; bh=qEP3NmHnEDlTNp38YWppCtsdQwzePXqrYoLu/kAga7I=; h=Date:From:To:Message-ID:MIME-Version; b=FZvEyBC0fFjrZJagQKZEm0zcMvgCL45RW1cF+XnicczPa3msBM/tEIqGhjrEmc4dx mKWxCEHw/iekVFMKKa4gD9MjvzZP7cpXqd/r47NkwNGh6qtLDn/9yCbOzcOPErSvXo Fv135kfqCa3nJIOsVDvcLeP9EdIYMLSHYG0jWVsIpcLGwknmlhAD6TM6mXGlnsuSg/ 3Xo0NLiCK5JkeaUP8GUCSYC6s4s6QzxaPhkyzvtHBAfhXlYCiitjeD1Oe4UMZKhNDy BcRTMFTwg6zbyeZoEoBy2ZdwizcxpH8rMReC4hZaZvPR/bx4sZIOOiSkn9BksXK9I7 k5dvKLoX3y3ew== X-Virus-Scanned: amavisd-new at efficios.com Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 8ICkpus41-4t; Thu, 24 Sep 2020 09:54:00 -0400 (EDT) Received: from mail03.efficios.com (mail03.efficios.com [167.114.26.124]) by mail.efficios.com (Postfix) with ESMTP id 539D32D4D16; Thu, 24 Sep 2020 09:54:00 -0400 (EDT) Date: Thu, 24 Sep 2020 09:54:00 -0400 (EDT) From: Mathieu Desnoyers To: Peter Oskolkov , Peter Zijlstra Cc: paulmck , Boqun Feng , linux-kernel , Paul Turner , Chris Kennelly , Peter Oskolkov , shuah , linux-kselftest Message-ID: <1466248917.67912.1600955640316.JavaMail.zimbra@efficios.com> In-Reply-To: <1143241390.67886.1600954399326.JavaMail.zimbra@efficios.com> References: <20200923233618.2572849-1-posk@google.com> <20200923233618.2572849-2-posk@google.com> <1143241390.67886.1600954399326.JavaMail.zimbra@efficios.com> Subject: Re: [PATCH v8 2/3] rseq/selftests: add rseq_offset_deref_addv MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [167.114.26.124] X-Mailer: Zimbra 8.8.15_GA_3965 (ZimbraWebClient - FF80 (Linux)/8.8.15_GA_3963) Thread-Topic: rseq/selftests: add rseq_offset_deref_addv Thread-Index: YpoSNcdzzS1e6+zsawvuzl/RfjrswmKSqAcE Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- On Sep 24, 2020, at 9:33 AM, Mathieu Desnoyers mathieu.desnoyers@efficios.com wrote: > ----- On Sep 23, 2020, at 7:36 PM, Peter Oskolkov posk@google.com wrote: > > The patch title should state that it only adds rseq_offset_deref_addv > to x86-64. Considering that other architecture maintainers will look > at it as inspiration for other architectures, we should also state in > the commit message that architectures implementing it should define > "RSEQ_ARCH_HAS_OFFSET_DEREF_ADDV". With those changes applied, you can also add my: Acked-by: Mathieu Desnoyers Thanks, Mathieu > > Thanks, > > Mathieu > >> This patch adds rseq_offset_deref_addv function to >> tools/testing/selftests/rseq/rseq-x86.h, to be used >> in a selftest in the next patch in the patchset. >> >> v7->v8: this patch split out of the v7 selftest patch. >> >> Signed-off-by: Peter Oskolkov >> --- >> tools/testing/selftests/rseq/rseq-x86.h | 57 +++++++++++++++++++++++++ >> 1 file changed, 57 insertions(+) >> >> diff --git a/tools/testing/selftests/rseq/rseq-x86.h >> b/tools/testing/selftests/rseq/rseq-x86.h >> index b2da6004fe30..640411518e46 100644 >> --- a/tools/testing/selftests/rseq/rseq-x86.h >> +++ b/tools/testing/selftests/rseq/rseq-x86.h >> @@ -279,6 +279,63 @@ int rseq_addv(intptr_t *v, intptr_t count, int cpu) >> #endif >> } >> >> +#define RSEQ_ARCH_HAS_OFFSET_DEREF_ADDV >> + >> +/* >> + * pval = *(ptr+off) >> + * *pval += inc; >> + */ >> +static inline __attribute__((always_inline)) >> +int rseq_offset_deref_addv(intptr_t *ptr, off_t off, intptr_t inc, int cpu) >> +{ >> + RSEQ_INJECT_C(9) >> + >> + __asm__ __volatile__ goto ( >> + RSEQ_ASM_DEFINE_TABLE(3, 1f, 2f, 4f) /* start, commit, abort */ >> +#ifdef RSEQ_COMPARE_TWICE >> + RSEQ_ASM_DEFINE_EXIT_POINT(1f, %l[error1]) >> +#endif >> + /* Start rseq by storing table entry pointer into rseq_cs. */ >> + RSEQ_ASM_STORE_RSEQ_CS(1, 3b, RSEQ_CS_OFFSET(%[rseq_abi])) >> + RSEQ_ASM_CMP_CPU_ID(cpu_id, RSEQ_CPU_ID_OFFSET(%[rseq_abi]), 4f) >> + RSEQ_INJECT_ASM(3) >> +#ifdef RSEQ_COMPARE_TWICE >> + RSEQ_ASM_CMP_CPU_ID(cpu_id, RSEQ_CPU_ID_OFFSET(%[rseq_abi]), %l[error1]) >> +#endif >> + /* get p+v */ >> + "movq %[ptr], %%rbx\n\t" >> + "addq %[off], %%rbx\n\t" >> + /* get pv */ >> + "movq (%%rbx), %%rcx\n\t" >> + /* *pv += inc */ >> + "addq %[inc], (%%rcx)\n\t" >> + "2:\n\t" >> + RSEQ_INJECT_ASM(4) >> + RSEQ_ASM_DEFINE_ABORT(4, "", abort) >> + : /* gcc asm goto does not allow outputs */ >> + : [cpu_id] "r" (cpu), >> + [rseq_abi] "r" (&__rseq_abi), >> + /* final store input */ >> + [ptr] "m" (*ptr), >> + [off] "er" (off), >> + [inc] "er" (inc) >> + : "memory", "cc", "rax", "rbx", "rcx" >> + RSEQ_INJECT_CLOBBER >> + : abort >> +#ifdef RSEQ_COMPARE_TWICE >> + , error1 >> +#endif >> + ); >> + return 0; >> +abort: >> + RSEQ_INJECT_FAILED >> + return -1; >> +#ifdef RSEQ_COMPARE_TWICE >> +error1: >> + rseq_bug("cpu_id comparison failed"); >> +#endif >> +} >> + >> static inline __attribute__((always_inline)) >> int rseq_cmpeqv_trystorev_storev(intptr_t *v, intptr_t expect, >> intptr_t *v2, intptr_t newv2, >> -- >> 2.28.0.709.gb0816b6eb0-goog > > -- > Mathieu Desnoyers > EfficiOS Inc. > http://www.efficios.com -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com