From patchwork Tue Jun 27 15:29:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 113491 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp8315774vqr; Tue, 27 Jun 2023 09:15:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6IdyVlavcqzOuW/9pNsFMRzBLJvVqzUhTYNDiP+Q4IzRGy8lBi/p5Omx5yShLOthCNDx40 X-Received: by 2002:a05:6402:759:b0:51a:7bcd:a82d with SMTP id p25-20020a056402075900b0051a7bcda82dmr19434692edy.23.1687882552795; Tue, 27 Jun 2023 09:15:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687882552; cv=none; d=google.com; s=arc-20160816; b=YVoPHajdHR6EZQ/amn3zMNLdhnLQiU5N6LNedpTyuG8oC90qK13ShAHw38WjDUuOvA kRX88ys+40Quzp8xG8znN7SeSzjlkgX2BwIqTGyRMoZmfTbNMiy2I4X7UM3/MvmP6rpL cj7EiFOWXjHZxDpFw8ogcHprlgtW7f/toLBMVWzXp6N6/jGBXqWWsV+Gff0gYsb1EG6I KAQY0B/THpHBAM8rScDWH+yzpvyj9EJ6klnNpEQ5068UEkHHzVN3k9xPyh9CqSFSm7tT /PbqM8n0ngGkSofY1YaQ36R0vABdFzV4wHFNli+h6gxljTgO/x28jbXrNmjzza7Q1Wkm cuvA== 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=WLy3PCdq/1jQ5oBkQFU/MS1ukAVItoTeydqfgtEoax8=; fh=HjVUg7QR3dsJtud2zMTn2hjb/BaTIryYfe/7zrQJEa8=; b=wJjIilLVxd3mXsFZ/UqoYQp6OGV+RkFDsb4zSDX6WUfgXOmPyHU/lql6Ap98GX7Fhv pfKYlTBVkP/UdbqLDuP2zZ5VFhyhC2fNE5x2zvY7jsAkx6UEBHEAq80+BEDN/BjeTvVM To24xRa1bDRJfFcHCt6qU6SNBS6uG/UXOW3q8kS1F228eEovv2rnpdkmJ6e+3Q2bmiSf fn9hsFUba1zbl/HHrUOVBSVR1G9Yu6zcYRT+6RWCF6oR63kRCt0now5NZ7Oh592pE8ht q8AxpdGkLi3d7xWpffwiNMbkwRR7PAydXwUK7rnaNnnhfAsqA+xE0SGuQ7nvsMwefDIB PQpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=xU4pfdv0; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q17-20020a056402033100b0051bfd314b71si4083382edw.59.2023.06.27.09.15.23; Tue, 27 Jun 2023 09:15:52 -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=xU4pfdv0; 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 S232375AbjF0P3o (ORCPT + 99 others); Tue, 27 Jun 2023 11:29:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231609AbjF0P3m (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 0BB1A185; Tue, 27 Jun 2023 08:29:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1687879779; bh=qFf1hun0+xYmubtn9VmGNMqI2i9FxElFjRQQBueSdgI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xU4pfdv0zWT4fDOWKSu6SVay/vLsZmBn+w1eiKvMdRhpmzWAdTSqWH3QLU85TR5Fn lYCX8RBcub8SX3++kZLjnASx7zg/kTy0l6nt6E02F/d3gNOo+7D54ENW6cirdAsc1u oFN+hpze7LO3nKY7CVNqLC1lptAHHbUP+KfVLLRqvQaht5UE/eiqySek54UnFXXkJd dYjLy39gDZSA2gD1Vmm9lpbPY2OPU12KzxjD6qcHmZId94+vw+Gqo7BuUkzjKqW7Q8 e8eCwDDXneqXYwM5bS2jNFT6WrLbjq4mcOJueKh3CR71CeQWTojEnL/kahPRyYj2wl PuctMtoeQXjDw== Received: from localhost.localdomain (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4Qr7tV6Dj0z19JQ; Tue, 27 Jun 2023 11:29:38 -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 Subject: [PATCH 1/4] selftests/rseq: Fix CID_ID typo in Makefile Date: Tue, 27 Jun 2023 11:29:20 -0400 Message-Id: <20230627152923.133238-2-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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769873135536318021?= X-GMAIL-MSGID: =?utf-8?q?1769873135536318021?= Ensure that the basic percpu ops tests are effectively built against mm_cid. Signed-off-by: Mathieu Desnoyers Cc: Peter Zijlstra --- tools/testing/selftests/rseq/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/rseq/Makefile b/tools/testing/selftests/rseq/Makefile index b357ba24af06..8f023b7cab60 100644 --- a/tools/testing/selftests/rseq/Makefile +++ b/tools/testing/selftests/rseq/Makefile @@ -31,7 +31,7 @@ $(OUTPUT)/%: %.c $(TEST_GEN_PROGS_EXTENDED) rseq.h rseq-*.h $(CC) $(CFLAGS) $< $(LDLIBS) -lrseq -o $@ $(OUTPUT)/basic_percpu_ops_mm_cid_test: basic_percpu_ops_test.c $(TEST_GEN_PROGS_EXTENDED) rseq.h rseq-*.h - $(CC) $(CFLAGS) -DBUILDOPT_RSEQ_PERCPU_MM_CID_ID $< $(LDLIBS) -lrseq -o $@ + $(CC) $(CFLAGS) -DBUILDOPT_RSEQ_PERCPU_MM_CID $< $(LDLIBS) -lrseq -o $@ $(OUTPUT)/param_test_benchmark: param_test.c $(TEST_GEN_PROGS_EXTENDED) \ rseq.h rseq-*.h From patchwork Tue Jun 27 15:29:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 113487 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp8297756vqr; Tue, 27 Jun 2023 08:50:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4URLHBQWVzXNIkc2BZnmaidEWddHixscrcaRXaMf7D17gksYZhIxK26PZblcxpMcR5YYAk X-Received: by 2002:a05:6a21:3392:b0:123:7989:ba55 with SMTP id yy18-20020a056a21339200b001237989ba55mr15456128pzb.41.1687881038639; Tue, 27 Jun 2023 08:50:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687881038; cv=none; d=google.com; s=arc-20160816; b=pJqwqKKndMtKlefTviKx43IVQ8Fz0dqMikyNlqgs+AGRQMgB4tgwDT3Ef9tyGDZYO7 vEkcMOqcrKYUc6+ElR7G3XmA9zroywvbiPWKC4hj0jjSI8RBkTZzcJjFjZEl0oz52N+F +u/fp86/4DckTMFlCDfjar1R7i6nsYm1w29W9fhhlreyeVDh2jJksM8OZfUugPDpJjAR NjLtUW9qdOGD0MoNAHQqL9zadze/1e2tZQdUq23EprpjgZbK20VBgluRiBsytf5cOxp2 t0ruPuT6Pj0BbGyszbtlvkBoaRlZux1Nnhb8G8T9qe9xdHV1AkHJBs6nMU7LL+oMqJWZ 3JqQ== 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=QZDyc+LphveGbkV8flCr5/AlZBA+s2syS9K6n52w050=; fh=HjVUg7QR3dsJtud2zMTn2hjb/BaTIryYfe/7zrQJEa8=; b=ogROovw5w/8fMX2YYxyVEHCNApc4S5bxafBhprVksqTu/oeDPqNVgSP8ZOkqlJubsY r8Ct/IgMLT/ITrTsuRJm1+2Y08NQ2P8NMizYzxU4JppjhgKs/2tLq12zkjbXBM6Uc/tC +rtXx5hvfrdN1n29LtIF8cpHuplPy60OrwWHZ6EkemxU4QO6rrrR3gCDqy5GWQMwtz7f xRpxHrFMQUzeyx4rEONz2YDXAPpVsDowmmWbJSyuTIQXE0U1TeN0Oe8dtnuoq4EKoeuc xVO9fsK5ei6Jm6pYJODw6DZ5GsjS2IAZUbP8fFHWUYoTBaVkBpCHC5o8a91SAXEcpsKD HDEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=hXNcy6nC; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q17-20020a056a00085100b0064d2d8d7c33si7838119pfk.45.2023.06.27.08.50.25; Tue, 27 Jun 2023 08:50:38 -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=hXNcy6nC; 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 S232420AbjF0P3x (ORCPT + 99 others); Tue, 27 Jun 2023 11:29:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231924AbjF0P3n (ORCPT ); Tue, 27 Jun 2023 11:29:43 -0400 Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1309E2942; Tue, 27 Jun 2023 08:29:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1687879779; bh=oKkXMwl9CppgPR3HEtDQfgVFXUAQ6EoIiQSv7ieSscM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hXNcy6nCTJIqA16UhPSgfyd6AmV61FoDTnapkgcJ42vPjzC5RL+3HyDJCfADcjXKz qhH8QxzBY3MBiUTblRqiY2gzlwUztpGUHOnefGoLogsru3uDCxZx9GV6NMw2u3U87k uZFgwcGLpCBzuzh+iIJ3Egtrv3EU+t6PGpl8e7vJhLQpUvr2/Oxi9tNLFbqLDWx6dB QEq7SIdMs/UB2+4uZtMup+3ZAMWza3WUDlYXJPN1IkRZBpxhVPGaeG7kgtRjkAc+qv bZsKJrTeuD11edopYYKU10/3SBu7m7Uwb+yVAQen3jLIoFlRHNfUtFir9yzWxURvyg jSAzD8CS+++YA== Received: from localhost.localdomain (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4Qr7tW19F9z19RQ; 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 Subject: [PATCH 2/4] selftests/rseq: Implement rseq_unqual_scalar_typeof Date: Tue, 27 Jun 2023 11:29:21 -0400 Message-Id: <20230627152923.133238-3-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 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,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769871547829987042?= X-GMAIL-MSGID: =?utf-8?q?1769871547829987042?= Allow defining variables and perform cast with a typeof which removes the volatile and const qualifiers. This prevents declaring a stack variable with a volatile qualifier within a macro, which would generate sub-optimal assembler. This is imported from the "librseq" project. Signed-off-by: Mathieu Desnoyers --- tools/testing/selftests/rseq/compiler.h | 26 +++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tools/testing/selftests/rseq/compiler.h b/tools/testing/selftests/rseq/compiler.h index f47092bddeba..49d62fbd6dda 100644 --- a/tools/testing/selftests/rseq/compiler.h +++ b/tools/testing/selftests/rseq/compiler.h @@ -33,4 +33,30 @@ #define RSEQ_COMBINE_TOKENS(_tokena, _tokenb) \ RSEQ__COMBINE_TOKENS(_tokena, _tokenb) +#ifdef __cplusplus +#define rseq_unqual_scalar_typeof(x) \ + std::remove_cv::type>::type +#else +#define rseq_scalar_type_to_expr(type) \ + unsigned type: (unsigned type)0, \ + signed type: (signed type)0 + +/* + * Use C11 _Generic to express unqualified type from expression. This removes + * volatile qualifier from expression type. + */ +#define rseq_unqual_scalar_typeof(x) \ + __typeof__( \ + _Generic((x), \ + char: (char)0, \ + rseq_scalar_type_to_expr(char), \ + rseq_scalar_type_to_expr(short), \ + rseq_scalar_type_to_expr(int), \ + rseq_scalar_type_to_expr(long), \ + rseq_scalar_type_to_expr(long long), \ + default: (x) \ + ) \ + ) +#endif + #endif /* RSEQ_COMPILER_H_ */ From patchwork Tue Jun 27 15:29:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 113492 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp8317902vqr; Tue, 27 Jun 2023 09:19:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5vqwOz7Naef6b4IV+ynm/z4U5oMHQ13m0v8C3ex1l//KJfTQxOUMvRICf5/sQJZrCOxGqB X-Received: by 2002:a05:6402:649:b0:51d:af4f:c8d1 with SMTP id u9-20020a056402064900b0051daf4fc8d1mr1286633edx.38.1687882744678; Tue, 27 Jun 2023 09:19:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687882744; cv=none; d=google.com; s=arc-20160816; b=N9pXpFb4YDuuSKtBEO5x1h63lVpR6kBRC6p87m+vJcEtBje7eS9hSGHb97ICANhH10 qeRXH830K9vKC8CoTQ4adR8aedBkDz6UHyUHrPxEeZMdDevmPIZkJsSy1t1x6hSI/IlB twqdyqkueXeHq029eBXGsVdZxmlxUvTSDfEkUPnqYJ7g5BGrkGHBZ99UxvJuRUbIlGB6 B8YEXWh4LAa0SLKarDHITS2/jHk0xh0RJeXI2eT6HmDJQBKsKVRypfDjbNznoxND6VAv M7T2N7XWs+FQWo+omla8xoKcB2r79d2Amt8H31xjyR15ZzGSFuIKmaANW08/hOnampdm 1g+Q== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e4-20020a056402088400b0051d975c7fbesi2910777edy.171.2023.06.27.09.18.40; Tue, 27 Jun 2023 09:19:04 -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 S232389AbjF0P3r (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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769873336938836701?= X-GMAIL-MSGID: =?utf-8?q?1769873336938836701?= 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; \ } \ From patchwork Tue Jun 27 15:29:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 113488 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp8297910vqr; Tue, 27 Jun 2023 08:50:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5eMTXrmAdBDMUwIWmfmyyZE7MgM/JIBZiqJ8J//O5TdTTc9j+Mm9qgNFEU6ATO7DdzlRYs X-Received: by 2002:a17:902:e744:b0:1b6:6e3a:77fb with SMTP id p4-20020a170902e74400b001b66e3a77fbmr13194827plf.2.1687881054402; Tue, 27 Jun 2023 08:50:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687881054; cv=none; d=google.com; s=arc-20160816; b=Itejo66uA0id3ZVGHqaB0i/dpYXDbON4e6SoSmUzuyWKQIOi2bg5tZLY7zV2Xv+R72 kzF37CwfEQNf5SYRPlJmC4yvPpKeYXS/83+JwfvJaIv4sAWvLNbNHFfb27PIIH5ynAlX VIbc6wcXuGYqBqEI+BUVCPE5yE8P5ndtlb8Q4zbJ8Bp33Av5upCNtD/kBpswDryI7aaK LtzvUJTUHsL0zbgatSCRuG1SFCpE+HPzonwAkj6A9Wkwrf4cWey41J+C6Gxn//dZVWR3 1KSyuDa2+pKCMm/qq4V3LAd/nHZ540Iwh6Yzxp41z8OHH66p/s0L8jEHF8OVKPx24D5k FsCw== 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=9Ofp1Ft5+NDKGumSAHbScNrto0F9ZJGiDvYbxh3s13E=; fh=HjVUg7QR3dsJtud2zMTn2hjb/BaTIryYfe/7zrQJEa8=; b=xhNZVtXsPKKPyQ1D8QJpCUDR42tlqE1qaWBF27Hn97YzYBP+3KPNXrH1VUUb360C6A u6gKENg8RhKhurFmERndhIwNDDBz15HwY2TOLK6rnrP3m3KTZabph2mAAHEscu0K5bh2 PJUjRanUyiJlAm2BnSI2ZHW8cHN2sri+lSBw9OgpvkR90fCj61h2QzBqYzGgCov4Awkw P0AGTu7JxgzO3Kz2qRDa+NkzFseMR5/r7CVzBI+bsRpvJ/2WJ716ErbObay/etGWUNrv YKqDo6L29shXS9RtzkPpz0gE6NA15btF/oi6XXN8K9cs8ODeepdOQ3fo93i780AiUFmQ ikWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=l2CFgGHS; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e18-20020a17090301d200b001a0544138b8si629903plh.395.2023.06.27.08.50.41; Tue, 27 Jun 2023 08:50:54 -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=l2CFgGHS; 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 S232439AbjF0P3z (ORCPT + 99 others); Tue, 27 Jun 2023 11:29:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231974AbjF0P3n (ORCPT ); Tue, 27 Jun 2023 11:29:43 -0400 Received: from smtpout.efficios.com (unknown [IPv6:2607:5300:203:b2ee::31e5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 889AA273C; 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=sUuJuaMEmAlyyRMOf/8VHfapTZrVaMFeI2CoS0ABZ7s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l2CFgGHSu56BZRopG2MyKoL8vpK51j2DxdvfY+3DnqE3iILve+RfIgSuLU8Ytf4p8 51cuYSnKWr+SBTleni42ze+MlbFBsszId1jETLtKq2n1baZkKmCaIyaxVocAsDkhg1 Dygh80QYwSpKZ+yba/FfeFMXd19WSyw+1zSYGV+MzyhbPnud5yXtQZ2o4gnRXzFkPI JCw/YUiAieLchT7VS1IiNHX167tWMpXjUEd7TBctDvmdLM1mt42UMKwWZ7vMoq1Uh8 zjH1NkYlBnST5KgULDqWjYPBvWUbLPuVSIWCeRbpx5+Wn74TOT2zzSk5tjZUw+GaXb SqMVPQm6xsubA== Received: from localhost.localdomain (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4Qr7tW5B6Nz19dJ; 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 Subject: [PATCH 4/4] selftests/rseq: Use rseq_unqual_scalar_typeof in macros Date: Tue, 27 Jun 2023 11:29:23 -0400 Message-Id: <20230627152923.133238-5-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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769871564593488584?= X-GMAIL-MSGID: =?utf-8?q?1769871564593488584?= Use rseq_unqual_scalar_typeof() rather than typeof() in macros to remove the volatile qualifier (if there is one in the input argument), thus generating better assembly code in those scenarios. Also add extra brackets around the "p" parameter in RSEQ_READ_ONCE(), RSEQ_WRITE_ONCE(), and rseq_unqual_scalar_typeof() across architectures to preserve expectations of operator priority. Here is an example that shows how operator priority may be an issue with missing parentheses: #define m(p) \ do { \ __typeof__(*p) v = 0; \ } while (0) void fct(unsigned long long *p1) { m(p1 + 1); /* works */ m(1 + p1); /* broken */ } Signed-off-by: Mathieu Desnoyers Cc: Peter Zijlstra --- tools/testing/selftests/rseq/rseq-arm.h | 4 ++-- tools/testing/selftests/rseq/rseq-mips.h | 4 ++-- tools/testing/selftests/rseq/rseq-ppc.h | 4 ++-- tools/testing/selftests/rseq/rseq-riscv.h | 6 +++--- tools/testing/selftests/rseq/rseq-s390.h | 4 ++-- tools/testing/selftests/rseq/rseq-x86.h | 4 ++-- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/tools/testing/selftests/rseq/rseq-arm.h b/tools/testing/selftests/rseq/rseq-arm.h index 8414fc3eac15..d887b3bbe257 100644 --- a/tools/testing/selftests/rseq/rseq-arm.h +++ b/tools/testing/selftests/rseq/rseq-arm.h @@ -66,7 +66,7 @@ #define rseq_smp_load_acquire(p) \ __extension__ ({ \ - __typeof(*p) ____p1 = RSEQ_READ_ONCE(*p); \ + rseq_unqual_scalar_typeof(*(p)) ____p1 = RSEQ_READ_ONCE(*(p)); \ rseq_smp_mb(); \ ____p1; \ }) @@ -76,7 +76,7 @@ __extension__ ({ \ #define rseq_smp_store_release(p, v) \ do { \ rseq_smp_mb(); \ - RSEQ_WRITE_ONCE(*p, v); \ + RSEQ_WRITE_ONCE(*(p), v); \ } while (0) #define __RSEQ_ASM_DEFINE_TABLE(label, version, flags, start_ip, \ diff --git a/tools/testing/selftests/rseq/rseq-mips.h b/tools/testing/selftests/rseq/rseq-mips.h index 50b950cf9585..42ef8e946693 100644 --- a/tools/testing/selftests/rseq/rseq-mips.h +++ b/tools/testing/selftests/rseq/rseq-mips.h @@ -45,7 +45,7 @@ #define rseq_smp_load_acquire(p) \ __extension__ ({ \ - __typeof(*p) ____p1 = RSEQ_READ_ONCE(*p); \ + rseq_unqual_scalar_typeof(*(p)) ____p1 = RSEQ_READ_ONCE(*(p)); \ rseq_smp_mb(); \ ____p1; \ }) @@ -55,7 +55,7 @@ __extension__ ({ \ #define rseq_smp_store_release(p, v) \ do { \ rseq_smp_mb(); \ - RSEQ_WRITE_ONCE(*p, v); \ + RSEQ_WRITE_ONCE(*(p), v); \ } while (0) #if _MIPS_SZLONG == 64 diff --git a/tools/testing/selftests/rseq/rseq-ppc.h b/tools/testing/selftests/rseq/rseq-ppc.h index dc9190facee9..57b160597189 100644 --- a/tools/testing/selftests/rseq/rseq-ppc.h +++ b/tools/testing/selftests/rseq/rseq-ppc.h @@ -23,7 +23,7 @@ #define rseq_smp_load_acquire(p) \ __extension__ ({ \ - __typeof(*p) ____p1 = RSEQ_READ_ONCE(*p); \ + rseq_unqual_scalar_typeof(*(p)) ____p1 = RSEQ_READ_ONCE(*(p)); \ rseq_smp_lwsync(); \ ____p1; \ }) @@ -33,7 +33,7 @@ __extension__ ({ \ #define rseq_smp_store_release(p, v) \ do { \ rseq_smp_lwsync(); \ - RSEQ_WRITE_ONCE(*p, v); \ + RSEQ_WRITE_ONCE(*(p), v); \ } while (0) /* diff --git a/tools/testing/selftests/rseq/rseq-riscv.h b/tools/testing/selftests/rseq/rseq-riscv.h index 17932a79e066..37e598d0a365 100644 --- a/tools/testing/selftests/rseq/rseq-riscv.h +++ b/tools/testing/selftests/rseq/rseq-riscv.h @@ -36,8 +36,8 @@ #define rseq_smp_load_acquire(p) \ __extension__ ({ \ - __typeof(*(p)) ____p1 = RSEQ_READ_ONCE(*(p)); \ - RISCV_FENCE(r, rw) \ + rseq_unqual_scalar_typeof(*(p)) ____p1 = RSEQ_READ_ONCE(*(p)); \ + RISCV_FENCE(r, rw); \ ____p1; \ }) @@ -46,7 +46,7 @@ __extension__ ({ \ #define rseq_smp_store_release(p, v) \ do { \ RISCV_FENCE(rw, w); \ - RSEQ_WRITE_ONCE(*(p), v); \ + RSEQ_WRITE_ONCE(*(p), v); \ } while (0) #define __RSEQ_ASM_DEFINE_TABLE(label, version, flags, start_ip, \ diff --git a/tools/testing/selftests/rseq/rseq-s390.h b/tools/testing/selftests/rseq/rseq-s390.h index 46c92598acc7..33baaa9f9997 100644 --- a/tools/testing/selftests/rseq/rseq-s390.h +++ b/tools/testing/selftests/rseq/rseq-s390.h @@ -15,7 +15,7 @@ #define rseq_smp_load_acquire(p) \ __extension__ ({ \ - __typeof(*p) ____p1 = RSEQ_READ_ONCE(*p); \ + rseq_unqual_scalar_typeof(*(p)) ____p1 = RSEQ_READ_ONCE(*(p)); \ rseq_barrier(); \ ____p1; \ }) @@ -25,7 +25,7 @@ __extension__ ({ \ #define rseq_smp_store_release(p, v) \ do { \ rseq_barrier(); \ - RSEQ_WRITE_ONCE(*p, v); \ + RSEQ_WRITE_ONCE(*(p), v); \ } while (0) #ifdef __s390x__ diff --git a/tools/testing/selftests/rseq/rseq-x86.h b/tools/testing/selftests/rseq/rseq-x86.h index fb65ef54b0fb..a2aa428ba151 100644 --- a/tools/testing/selftests/rseq/rseq-x86.h +++ b/tools/testing/selftests/rseq/rseq-x86.h @@ -42,7 +42,7 @@ #define rseq_smp_load_acquire(p) \ __extension__ ({ \ - __typeof(*p) ____p1 = RSEQ_READ_ONCE(*p); \ + rseq_unqual_scalar_typeof(*(p)) ____p1 = RSEQ_READ_ONCE(*(p)); \ rseq_barrier(); \ ____p1; \ }) @@ -52,7 +52,7 @@ __extension__ ({ \ #define rseq_smp_store_release(p, v) \ do { \ rseq_barrier(); \ - RSEQ_WRITE_ONCE(*p, v); \ + RSEQ_WRITE_ONCE(*(p), v); \ } while (0) #define __RSEQ_ASM_DEFINE_TABLE(label, version, flags, \