From patchwork Tue Mar 14 11:50:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 6604 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1715000wrd; Tue, 14 Mar 2023 05:05:29 -0700 (PDT) X-Google-Smtp-Source: AK7set+W5Un/W8d0h5KdX0FRzKIZbOoHIhUHst1c5pHy4p3UGATjnWrSz8tfc2E0oGqlyHhc5cdx X-Received: by 2002:a05:6a20:669e:b0:d4:72ab:df31 with SMTP id o30-20020a056a20669e00b000d472abdf31mr6000664pzh.11.1678795529131; Tue, 14 Mar 2023 05:05:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678795529; cv=none; d=google.com; s=arc-20160816; b=mP9AtjOWJCfTTqwdn8QR0pyW/cw+d79kSOoQtm31l1UFxNVgVu+sime7jGFy/Y/5df M8m9wOQOUj4Lr2Wls9jRcGIMdvhLBRPVvOUtybFJnfm5feh948Rguti2g+dwxVGV3GOa xXTdjJdFGe247Bu9jA9ebxWuc7mXI9fLdIxrDNaztiDc/eZ8Dv4k0C5EaULkErKEsrSX MvSlRC4c5rdwLH/RMYaflhNzBCJ3AEIOG4nHSJ5dAhDauG8bxXUphxVCR3l54mv2pAHt fQrjbUMhUAvliroGVkWmzKGl5ZBIe+ohbjbOy1TdIGwV30QLOxSKB10sGIiGPWDchsfe aHMw== 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 :message-id:date:subject:cc:to:from; bh=88S6XLbQts+Um8RD0550BdZ1Yla2O9XImR63IpcNYPg=; b=k0flGq4SNlWnfQvct9ZuNAb9AiveKCHaZcd0qingxGRW9u5rivB9XYyC+5ehBk7Pip t9YM0ZbO2UAl1BOmehaMOgPYZypGQMI15TzvJi/9PjFmb/DiLFfBsSFuq/oQwiaEUmmD sL5uQYKKbf5ZKe8hyiuvwekgS2vOwHg0hHxceyNChgSHE1lthrq5Z+0a3V1pbN4NKQg0 droY5/4sYsAKsvDpKtQBmXCcJxtck9fDapMPFgw50Ql5XUMKx2dhfV2l4sOVow+BdMcA OklNz/tnJxIsm9HDARctKjSL/UW0C5jKPKgmSf5UCH9DNxPUkgh1/eazOZNtj7UGddFJ omhw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 20-20020a631854000000b004fbc2116e12si447431pgy.587.2023.03.14.05.05.15; Tue, 14 Mar 2023 05:05:29 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230255AbjCNLum (ORCPT + 99 others); Tue, 14 Mar 2023 07:50:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230173AbjCNLuk (ORCPT ); Tue, 14 Mar 2023 07:50:40 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AEFFF1814B for ; Tue, 14 Mar 2023 04:50:39 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 293AA4B3; Tue, 14 Mar 2023 04:51:23 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7D30C3F67D; Tue, 14 Mar 2023 04:50:38 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org, Al Viro , Catalin Marinas , Will Deacon Cc: linux-kernel@vger.kernel.org, mark.rutland@arm.com, robin.murphy@arm.com Subject: [PATCH 0/4] usercopy: generic tests + arm64 fixes Date: Tue, 14 Mar 2023 11:50:26 +0000 Message-Id: <20230314115030.347976-1-mark.rutland@arm.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE 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?1760344700328144965?= X-GMAIL-MSGID: =?utf-8?q?1760344700328144965?= This series adds tests for the usercopy functions, and fixes some deficiencies on arm64. This is a follow-up to Robin's earlier usercopy refresh [1], where we found some issues and Will had asked for tests. In the process of writing tests, I discovered arm64 had some latent issues, and running the tests on other architectures, it looks like most have issues... Al, I'd appreciate if you could take a look at the first couple of patches and check if I've got the intended semantics correct. I think I've got that right for __raw_copy_{to,from}_user(), but I'm not sure whether clear_user() is expected to behave the same, and I may have missed something or assumed something overly strong. Catalin, Will, the last two patches fix arm64's implementation of __raw_copy_to_user() and clear_user(), per the understanding above. I believe these are correct (as they've passed exhaustive testing), and benchmarking shows they're at least as good as the current implementations. Thanks, Mark. [1] https://lore.kernel.org/linux-arm-kernel/cover.1664363162.git.robin.murphy@arm.com/ Mark Rutland (4): lib: test copy_{to,from}_user() lib: test clear_user() arm64: fix __raw_copy_to_user semantics arm64: fix clear_user() semantics arch/arm64/lib/clear_user.S | 195 ++++++++++--- arch/arm64/lib/copy_to_user.S | 203 ++++++++++--- lib/Kconfig.debug | 9 + lib/Makefile | 1 + lib/usercopy_kunit.c | 520 ++++++++++++++++++++++++++++++++++ 5 files changed, 848 insertions(+), 80 deletions(-) create mode 100644 lib/usercopy_kunit.c