Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2102302rwd; Mon, 15 May 2023 07:18:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ71uhyxtfLkr0a0leitoloxutBRGrZ7xnaca3l8rehFKvix7z2S917YhMMr63OYo3CUitai X-Received: by 2002:a05:6a00:a05:b0:63b:5496:7af5 with SMTP id p5-20020a056a000a0500b0063b54967af5mr50612823pfh.1.1684160316312; Mon, 15 May 2023 07:18:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684160316; cv=none; d=google.com; s=arc-20160816; b=kyCQ0qUws++kpAIAiVaS7ITeoXvljwFAurKMDDGzXwYIJTgq6gotDWJUDemZobFYbF hr0ZAcN59QsIoPvnKWXAL/nMeQNLo9RCq7FEqLGQjvkHdKE98/NXYHMwSYi6kbltXjMt 83X77B9AUetHzKD3OXDOi40qKfMP9uK5fNWWHMfPz7KnGnR2bGNKTrqcXyvgyJpRAWGN xqqqRNiazBe45HbCua8CQtnz8UMvbMzWMz7ugqnGB1pvVO7mnar2GDojXDDGop5TriKe jBe5qwu/FvCDcWLD74EccNR9wkZV5y3VRWYTO9s8nTxO/g9XafaAaQbcPrZdQYjMGWnN 3RBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=p7yIdMUHa3wF/HBuRqqOLUfYvEG1ouewyAEX7xxTeFI=; b=NXON0fDIjn9Ph/v0QJ3WBg0JNuangDjmRUbR/xhhMaOPTEJsq1czp8n8r9RO/1Pmt8 iSq20Wq35BxhKsCpveeteaRaXmvcGGSLIY9ZMEQz54FJwj3Z6ZFLeFLqFA6Ew3ZVDloN gJHo9uqSOuJptPbrdsP8CXdtxt1sQmY0Zi8fGy6FkvsE5XnTFeI0qj05ApiRbsc/BGHz kuy9774SWLNdO0rmSxEa1GrcHN7pR6twr3RKO5xci47dZVV52OuWgSCAty121Pb4ugxZ Tdbp4rS00HkHwf91cgyZSatFyJXfhmujv5LDM6naXnzpWyy7eFpfUd8qha4QhrkDkVuB MANQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=nDgfbrEt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i128-20020a625486000000b00647e5f1d563si14550642pfb.387.2023.05.15.07.18.14; Mon, 15 May 2023 07:18:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=nDgfbrEt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S238248AbjEON6Z (ORCPT + 99 others); Mon, 15 May 2023 09:58:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237865AbjEON6P (ORCPT ); Mon, 15 May 2023 09:58:15 -0400 Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01E0410F8; Mon, 15 May 2023 06:58:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1684159089; bh=JFXZOyA+MaNEabXquELDZyqKe3MTOQ5kU8hAyTwsfD4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nDgfbrEtJniYoufZtGytwj2VVpBRKHysGWQuZAYJ5UofGIR7P4vK+zc94+1sEuqWX p6XkXSOM6y2bK3v1BMxsipftIGVCGC2G0qxbIbzXd3mfmzEvvFDvA6g3KJakjqZmmi Jk6Dgqq1UfWsGU2UX+uftZXrLFxCEug27wesLLDeloTZm2CU7qd9mk2SvMVO4Zuist pMZbv54fXLrVgArD4X/N726kYtB70Y0fzQzDrtyiamavVbrGEPuyrnGaeUAkGoKggd O2vLI4OyK6Z2AuJzTUIVpfTLT9WkzQhWVDVDaDs3gEHhTDmZX13iXbGwVB//w0x/rW 23SqyZym8TPAw== Received: from localhost.localdomain (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4QKgtn4Jc6z12VT; Mon, 15 May 2023 09:58:09 -0400 (EDT) From: Mathieu Desnoyers To: Peter Zijlstra Cc: linux-kernel@vger.kernel.org, Thomas Gleixner , "Paul E . McKenney" , Boqun Feng , "H . Peter Anvin" , Paul Turner , linux-api@vger.kernel.org, Shuah Khan , linux-kselftest@vger.kernel.org, Mathieu Desnoyers , Catalin Marinas , Will Deacon Subject: [PATCH 3/4] selftests/rseq: Fix arm64 buggy load-acquire/store-release macros Date: Mon, 15 May 2023 09:58:00 -0400 Message-Id: <20230515135801.15220-4-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230515135801.15220-1-mathieu.desnoyers@efficios.com> References: <20230515135801.15220-1-mathieu.desnoyers@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The arm64 load-acquire/store-release macros from the Linux kernel rseq selftests are buggy. Remplace them by a working implementation. Signed-off-by: Mathieu Desnoyers Cc: Catalin Marinas Cc: Will Deacon Cc: Peter Zijlstra --- tools/testing/selftests/rseq/rseq-arm64.h | 58 ++++++++++++----------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/tools/testing/selftests/rseq/rseq-arm64.h b/tools/testing/selftests/rseq/rseq-arm64.h index 85b90977e7e6..21e1626a7235 100644 --- a/tools/testing/selftests/rseq/rseq-arm64.h +++ b/tools/testing/selftests/rseq/rseq-arm64.h @@ -27,59 +27,61 @@ #define rseq_smp_load_acquire(p) \ __extension__ ({ \ - __typeof(*p) ____p1; \ - switch (sizeof(*p)) { \ + union { rseq_unqual_scalar_typeof(*(p)) __val; char __c[sizeof(*(p))]; } __u; \ + switch (sizeof(*(p))) { \ case 1: \ - asm volatile ("ldarb %w0, %1" \ - : "=r" (*(__u8 *)p) \ - : "Q" (*p) : "memory"); \ + __asm__ __volatile__ ("ldarb %w0, %1" \ + : "=r" (*(__u8 *)__u.__c) \ + : "Q" (*(p)) : "memory"); \ break; \ case 2: \ - asm volatile ("ldarh %w0, %1" \ - : "=r" (*(__u16 *)p) \ - : "Q" (*p) : "memory"); \ + __asm__ __volatile__ ("ldarh %w0, %1" \ + : "=r" (*(__u16 *)__u.__c) \ + : "Q" (*(p)) : "memory"); \ break; \ case 4: \ - asm volatile ("ldar %w0, %1" \ - : "=r" (*(__u32 *)p) \ - : "Q" (*p) : "memory"); \ + __asm__ __volatile__ ("ldar %w0, %1" \ + : "=r" (*(__u32 *)__u.__c) \ + : "Q" (*(p)) : "memory"); \ break; \ case 8: \ - asm volatile ("ldar %0, %1" \ - : "=r" (*(__u64 *)p) \ - : "Q" (*p) : "memory"); \ + __asm__ __volatile__ ("ldar %0, %1" \ + : "=r" (*(__u64 *)__u.__c) \ + : "Q" (*(p)) : "memory"); \ break; \ } \ - ____p1; \ + (rseq_unqual_scalar_typeof(*(p)))__u.__val; \ }) #define rseq_smp_acquire__after_ctrl_dep() rseq_smp_rmb() #define rseq_smp_store_release(p, v) \ do { \ - switch (sizeof(*p)) { \ + union { rseq_unqual_scalar_typeof(*(p)) __val; char __c[sizeof(*(p))]; } __u = \ + { .__val = (rseq_unqual_scalar_typeof(*(p))) (v) }; \ + switch (sizeof(*(p))) { \ case 1: \ - asm volatile ("stlrb %w1, %0" \ - : "=Q" (*p) \ - : "r" ((__u8)v) \ + __asm__ __volatile__ ("stlrb %w1, %0" \ + : "=Q" (*(p)) \ + : "r" (*(__u8 *)__u.__c) \ : "memory"); \ break; \ case 2: \ - asm volatile ("stlrh %w1, %0" \ - : "=Q" (*p) \ - : "r" ((__u16)v) \ + __asm__ __volatile__ ("stlrh %w1, %0" \ + : "=Q" (*(p)) \ + : "r" (*(__u16 *)__u.__c) \ : "memory"); \ break; \ case 4: \ - asm volatile ("stlr %w1, %0" \ - : "=Q" (*p) \ - : "r" ((__u32)v) \ + __asm__ __volatile__ ("stlr %w1, %0" \ + : "=Q" (*(p)) \ + : "r" (*(__u32 *)__u.__c) \ : "memory"); \ break; \ case 8: \ - asm volatile ("stlr %1, %0" \ - : "=Q" (*p) \ - : "r" ((__u64)v) \ + __asm__ __volatile__ ("stlr %1, %0" \ + : "=Q" (*(p)) \ + : "r" (*(__u64 *)__u.__c) \ : "memory"); \ break; \ } \ -- 2.25.1