Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp17937692rwd; Tue, 27 Jun 2023 09:20:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7dg91vTzS8fugTKbDD2H/PhJicpTgd3t3ZBCVfNoq6f8zjHUbEUqmwOsNZDE0uO0ioFAHq X-Received: by 2002:a17:907:9449:b0:988:b58d:5e0 with SMTP id dl9-20020a170907944900b00988b58d05e0mr21339836ejc.16.1687882821090; Tue, 27 Jun 2023 09:20:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687882821; cv=none; d=google.com; s=arc-20160816; b=ZjRh5laSqwFqKxqMX1tZ7F6BwQoeOU71ETgmfrWcWi08ByvnmEAL00f+pQPc39pM/A xPUSKP0mNeANiCajgOYPwYjxsrX6Z9YrCGNxn41hXyMXR8/wwkCX+BPxknmNzB8hnqNr R/hJyxwBe0d70NG2/vIIAOYbdYz9bbMHszO5oEOM8crLXi7Y0GpkOfnAuieNblDy3RGX TphZgx4e6lNMVPjH7ktMpKwkPpywLi0Os+cczCfIrXMz57Fh6gKNqFenArOV1JU/2MHv kvGlBTdU/dw6qhPrL1Z/yMlokzjPwX52JHb5tamG3JNPjcRXFDwdjitks5AP1gTmmkHO uqtA== 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=; fh=h+p94bQ9RwZNj0bVHKkJAtN4uEBINQnGD4A9BN+YSik=; b=sQmbebOQOb7BMuF0sYfhgq0aslgmPWaaQvNnMeTSL78vyn6hKO70z0KvhPEsvUu3Au SJFaB7yCF+mH1SrBE+8OsHGUXUHC+qaDx3mrJYrQCtCspvNyOACjdOifVMrxCqYADT7R zf/famW64x0XgbB9W+1w9tpbMfpRUETBsqdy8HhWBv9Z5kOnA6EwDBMVDYwfUarpWrls 2DitenKAATltDsXhzdoeM6SCYyeo1h6xjKiZQD5i18ccu1RRVqhDdEUxucSejdaI3mpo mlIA59n+8/hE/4uuW5Hl4xAKT2gS5ik4FmYSSqsVclypYibzBy8JL+dbIk/boZIhggQ/ z62A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=dKIIJDfo; 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 b11-20020a170906d10b00b00987606c11a2si4079420ejz.349.2023.06.27.09.19.54; Tue, 27 Jun 2023 09:20:21 -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=dKIIJDfo; 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 S232381AbjF0P3r (ORCPT + 99 others); Tue, 27 Jun 2023 11:29:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231637AbjF0P3m (ORCPT ); Tue, 27 Jun 2023 11:29:42 -0400 Received: from smtpout.efficios.com (unknown [IPv6:2607:5300:203:b2ee::31e5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CA0E1BCF; Tue, 27 Jun 2023 08:29:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1687879779; bh=JFXZOyA+MaNEabXquELDZyqKe3MTOQ5kU8hAyTwsfD4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dKIIJDfoTTs+30uLmwEbMUJNd5+s/W+E3r8raAud+wS/HMFcv3azT3BIcxFZJ3V8C 3s5AlHrgjySwakSB+cq0/FSoJpkUpSErmSm0KqD6fPZhfHLQsa3uKw8ArrP33GlHa5 9Xy+7pTbENE0utQBhsYr1qQ242gnc1Wy5iOmfbqkV/bH1XUz1TAjDc9DkVMyJkQjxd XH3j9E+pOZIwLt4ci5YcmveVWNx5fFjdNq4xOtlBm5jttHzOV7+STet3LOl1U5e+Jc /P4xN23KoLGxhXWAlYBo9OzAbryZxes/j2+8e5nENsMhMYEV6c2JO7lvE+9a1wouIo 8PjfdXoTa7PJQ== Received: from localhost.localdomain (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4Qr7tW3401z19RR; Tue, 27 Jun 2023 11:29:39 -0400 (EDT) From: Mathieu Desnoyers To: Shuah Khan Cc: linux-kernel@vger.kernel.org, Thomas Gleixner , Peter Zijlstra , "Paul E . McKenney" , Boqun Feng , "H . Peter Anvin" , Paul Turner , linux-api@vger.kernel.org, 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: Tue, 27 Jun 2023 11:29:22 -0400 Message-Id: <20230627152923.133238-4-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230627152923.133238-1-mathieu.desnoyers@efficios.com> References: <20230627152923.133238-1-mathieu.desnoyers@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RDNS_NONE,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no 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