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: 13174158 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9C369C6FD1D for ; Tue, 14 Mar 2023 11:51:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=s5uoCsk4/w05hxrdouAMDeBkNux8JzU8eEN93fO46l8=; b=x9kUEoUae2FczQ PTCedMXkwl8ZRLfMsX4m5WX6jTB+W0BeQdOlt/qU1wSYh1DWD5iPXvQ5XFj+lvNfozZjJu6ow25oc aYDdE3bPgcNguoVyGOpHzq+PoUsmUyQbBdWxgtx384bk5Zp1O2Imr/8Z1OsIC3X2F1AisgL819CmD Lo1GImeSlw+JDZVA71glT69qQK8hiefeaOGJ2RiNuiCA5kQtYBy6y2RpP+t2Kq0OK+ZILulPz11Fi YMyQZjajhurXwGM42Sg5Vt8ZCe6PL/d06LuFYPqCRu+LpntIjPFotsi17jutUooYNGCyi4rIjzxCM qfDtcZqFSvr2VQdqII0w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pc3B7-00A0m7-0W; Tue, 14 Mar 2023 11:50:53 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pc3Ax-00A0eb-0I for linux-arm-kernel@lists.infradead.org; Tue, 14 Mar 2023 11:50:44 +0000 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230314_045043_186597_3B0D5F4C X-CRM114-Status: GOOD ( 12.14 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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