From patchwork Fri Aug 9 08:25:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muhammad Usama Anjum X-Patchwork-Id: 13758530 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4DC8C52D71 for ; Fri, 9 Aug 2024 08:25:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 239236B007B; Fri, 9 Aug 2024 04:25:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1C16B6B0082; Fri, 9 Aug 2024 04:25:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 03A1F6B0089; Fri, 9 Aug 2024 04:25:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id D73426B007B for ; Fri, 9 Aug 2024 04:25:40 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 38BAC1C1B61 for ; Fri, 9 Aug 2024 08:25:40 +0000 (UTC) X-FDA: 82432023240.08.54318EA Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) by imf05.hostedemail.com (Postfix) with ESMTP id 32B4E100005 for ; Fri, 9 Aug 2024 08:25:37 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=collabora.com header.s=zohomail header.b="J5y08/sJ"; arc=pass ("zohomail.com:s=zohoarc:i=1"); spf=pass (imf05.hostedemail.com: domain of usama.anjum@collabora.com designates 136.143.188.112 as permitted sender) smtp.mailfrom=usama.anjum@collabora.com; dmarc=pass (policy=none) header.from=collabora.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723191872; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=ARoGuwCRmzTNnu/zj+XGQUUTD1/UnUzYPaVkcwelbf8=; b=5ZSyhdc5xvmKE5SPbldoDohytkce8w0SWHWJJBZmCa/8IBdQElVEmh2ksIlTbB7zE6Xmqa MId8WMl7THOBFAA7KEyL0WKrvS8l+8APp0Kvd6IB8r1mWptz1ecqTE3T4sT8D/cD6C6Izo asoJA4hIIJfrw7FO0ipXKDDsTtGl668= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1723191872; a=rsa-sha256; cv=pass; b=fnPO3nDlIwJjQrisJaEEx4aegReiK79ZyJ7HmpLMxfdPHkgVPC1MMoC0qSvxWYdj1PjjzH VoGKehQsxiGV9T5WRUNK8us5fEBlrM16PmzGHE0ouBbUyAncwQAbLhtCV0ee+CV8UlTcGD J8+pe5xTB2pHAxTlm8p2XJodfIK/vIY= ARC-Authentication-Results: i=2; imf05.hostedemail.com; dkim=pass header.d=collabora.com header.s=zohomail header.b="J5y08/sJ"; arc=pass ("zohomail.com:s=zohoarc:i=1"); spf=pass (imf05.hostedemail.com: domain of usama.anjum@collabora.com designates 136.143.188.112 as permitted sender) smtp.mailfrom=usama.anjum@collabora.com; dmarc=pass (policy=none) header.from=collabora.com ARC-Seal: i=1; a=rsa-sha256; t=1723191931; cv=none; d=zohomail.com; s=zohoarc; b=X5r0Hj1uIIiLsjBYiKa6Z37Abt5npPlrIY9CPYNSQjGU8ICmGL7Dmdo6rxJm3FKZOQ4eESI+mJUjdYJE+Dmc4f3sMVV+9wXlDNMbgoayjDrroQXRwIy6kTc5FhEZ/0O0Zg8QuTJHIVhIki0qh5koPVO/PNPeBirrsfTn075Ck74= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723191931; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=ARoGuwCRmzTNnu/zj+XGQUUTD1/UnUzYPaVkcwelbf8=; b=n2L+1UcFnl5J/P9X9bzVXOyKpO/aTZZ6Fo2AaF9d0fEYbNa0d4kGeIkhU05xmieTSr5/oaXihqXcRw/1hJmjMGt+5KqX8soK4llU8h4UUwAoBQNVZvlCvxzutRoVkf2W2HRsqWGmR9HRUPAxYfqllni70Ig6iJk6DXVZQKIdU48= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=usama.anjum@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1723191931; s=zohomail; d=collabora.com; i=usama.anjum@collabora.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=ARoGuwCRmzTNnu/zj+XGQUUTD1/UnUzYPaVkcwelbf8=; b=J5y08/sJWA/tUY8j5hz3pFViQRkicFYOGrpqydElIaUGGgFtoieRS2zEGS0NKx38 FB7MvyyWlMP1ciJHyCAW0A/YIUJ3UcQD9z7ulLk+g4icNRjjKHpbh67L2QCj1z1b7bw qE5GvcexW8dK94Em0/m3iPSuNsRitistGVh0sf00= Received: by mx.zohomail.com with SMTPS id 1723191930315384.302913310908; Fri, 9 Aug 2024 01:25:30 -0700 (PDT) From: Muhammad Usama Anjum To: Andrew Morton , Shuah Khan , Jeff Xu , Kees Cook , "Liam R. Howlett" Cc: Muhammad Usama Anjum , kernel@collabora.com, stable@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] selftests: mm: Fix build errors on armhf Date: Fri, 9 Aug 2024 13:25:11 +0500 Message-Id: <20240809082511.497266-1-usama.anjum@collabora.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-ZohoMailClient: External X-Stat-Signature: t1fmjhhjy9a94jc1ns4hj5ftxe1yg4db X-Rspamd-Queue-Id: 32B4E100005 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1723191937-226249 X-HE-Meta: U2FsdGVkX190gi2tDDfogGUpWHY7Hv7jU4LPMQoI+/HtVIffq0dsIYhxsZWuzyipI2bQE8FE5NNdgdhTURyWuERuO3NUC38qGOCyzrKTDjBFD42P5KmQul4Xcc9BRcPwccAVEUzng72i9n4NSfzjF20jxELKbNAPPZg+GbVauxpgUw0Q81BgtnN0AyGnjsHVHsduMdPiL8RoBTBBn8DIl+0V8YkNHBedHv0pAI9U6K0YyEzvXHVRIg/Zq1XWJ7Y8UwHF9/zHsq12ObiKJtXzitqVKUSMBjLf9q6SjZwnsRTKPZP4KBZpMoz1VQBvCjLUeFSRu4t5uEt5jHSgB/DuM57lWNN6dXyybamwsyxb59iHytF+SGUQsmnReDdDddJ9XErwmCdyHUdTBjDzaJB6SQrg/UsypinC7I4oUXfkkUAI3Cur4ZwZRl/vnUPl0PLc4+yra69UVUnTRSWz43IvsNXQvOnKfgYKy/eXDUQZKzpV43OnwA2YiUtjed0fAvPCC8zGrGtYfXqqO0oUndjrb+kyev4E9qBIW86jY6WAjGDUDoIwYAAQNPVDYGt4XILN8XVz4+ciq3QQW+TioPjFFMlY6pvJ4eBB+AW3e/t+sodyP1Il0PFFczVQ2O6NFZjDvI+P0Hi4252lR26Ro/gRs89xJeVAisvJnc8qCoMnIjJpD8Mzba8ccFlubbMcdD9zgwy3C6dZlxo2Rt+cXkzksvd19eswgjiLjgmr6nQGpe26ctjjth0wwrlM+nVInTJMDIZBGa9+x6Ktl+HeDrMnBrpolbFLTrJr/wHUTTkRofWssxfXtPhKHjuYh5ov3Cc5eXTM0iBUtnQ46UkVlXRJZ7yWNvv+OcioMtOpVVhhLISUW9JjcQEV6B+lq3S/03FuJU4dNqDW6QJOU6GupS8PTflhZ5Hs5Kho5D+bceDeYMWrshVlLHPsIlCSKyUOXhdyBARLp/vTnRAaoAl6dv3 MJe/Ij5o jw5YDwetrXQt0FzmzF9BInqySdXoIkhz5zWx7kk1QUPJlDmMG2DAPJDAkFuKyh7fJWPu5LxQg4cV61yGL4Qk7CsJSYyyAoD7vtp7pd/rrzw8efg9TXjoqzxPyLptsEmqpnBizPDoOT/97hkLXOycl9Jvbw9BqGkq/LuCBNKO+3B6xcITDEf2TI9Ul7EwyB4aCb+OsKYtTBhsxK9Zzm8lxqGbzInNDGR8JvuSDcbRI6kNtK1V9NYPdagPiDvMOFqrcas47l4nUL3IlZNld8bJ4nTp2P7uYQEdb5Lh1goF3CvCbF40= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The __NR_mmap isn't found on armhf. The mmap() is commonly available system call and its wrapper is presnet on all architectures. So it should be used directly. It solves problem for armhf and doesn't create problem for architectures as well. Remove sys_mmap() functions as they aren't doing anything else other than calling mmap(). There is no need to set errno = 0 manually as glibc always resets it. For reference errors are as following: CC seal_elf seal_elf.c: In function 'sys_mmap': seal_elf.c:39:33: error: '__NR_mmap' undeclared (first use in this function) 39 | sret = (void *) syscall(__NR_mmap, addr, len, prot, | ^~~~~~~~~ mseal_test.c: In function 'sys_mmap': mseal_test.c:90:33: error: '__NR_mmap' undeclared (first use in this function) 90 | sret = (void *) syscall(__NR_mmap, addr, len, prot, | ^~~~~~~~~ Cc: stable@vger.kernel.org Fixes: 4926c7a52de7 ("selftest mm/mseal memory sealing") Signed-off-by: Muhammad Usama Anjum --- tools/testing/selftests/mm/mseal_test.c | 37 +++++++++---------------- tools/testing/selftests/mm/seal_elf.c | 13 +-------- 2 files changed, 14 insertions(+), 36 deletions(-) diff --git a/tools/testing/selftests/mm/mseal_test.c b/tools/testing/selftests/mm/mseal_test.c index a818f010de479..bfcea5cf9a484 100644 --- a/tools/testing/selftests/mm/mseal_test.c +++ b/tools/testing/selftests/mm/mseal_test.c @@ -81,17 +81,6 @@ static int sys_mprotect_pkey(void *ptr, size_t size, unsigned long orig_prot, return sret; } -static void *sys_mmap(void *addr, unsigned long len, unsigned long prot, - unsigned long flags, unsigned long fd, unsigned long offset) -{ - void *sret; - - errno = 0; - sret = (void *) syscall(__NR_mmap, addr, len, prot, - flags, fd, offset); - return sret; -} - static int sys_munmap(void *ptr, size_t size) { int sret; @@ -172,7 +161,7 @@ static void setup_single_address(int size, void **ptrOut) { void *ptr; - ptr = sys_mmap(NULL, size, PROT_READ, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + ptr = mmap(NULL, size, PROT_READ, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); *ptrOut = ptr; } @@ -181,7 +170,7 @@ static void setup_single_address_rw(int size, void **ptrOut) void *ptr; unsigned long mapflags = MAP_ANONYMOUS | MAP_PRIVATE; - ptr = sys_mmap(NULL, size, PROT_READ | PROT_WRITE, mapflags, -1, 0); + ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, mapflags, -1, 0); *ptrOut = ptr; } @@ -205,7 +194,7 @@ bool seal_support(void) void *ptr; unsigned long page_size = getpagesize(); - ptr = sys_mmap(NULL, page_size, PROT_READ, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + ptr = mmap(NULL, page_size, PROT_READ, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); if (ptr == (void *) -1) return false; @@ -481,8 +470,8 @@ static void test_seal_zero_address(void) int prot; /* use mmap to change protection. */ - ptr = sys_mmap(0, size, PROT_NONE, - MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); + ptr = mmap(0, size, PROT_NONE, + MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); FAIL_TEST_IF_FALSE(ptr == 0); size = get_vma_size(ptr, &prot); @@ -1209,8 +1198,8 @@ static void test_seal_mmap_overwrite_prot(bool seal) } /* use mmap to change protection. */ - ret2 = sys_mmap(ptr, size, PROT_NONE, - MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); + ret2 = mmap(ptr, size, PROT_NONE, + MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); if (seal) { FAIL_TEST_IF_FALSE(ret2 == MAP_FAILED); FAIL_TEST_IF_FALSE(errno == EPERM); @@ -1240,8 +1229,8 @@ static void test_seal_mmap_expand(bool seal) } /* use mmap to expand. */ - ret2 = sys_mmap(ptr, size, PROT_READ, - MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); + ret2 = mmap(ptr, size, PROT_READ, + MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); if (seal) { FAIL_TEST_IF_FALSE(ret2 == MAP_FAILED); FAIL_TEST_IF_FALSE(errno == EPERM); @@ -1268,8 +1257,8 @@ static void test_seal_mmap_shrink(bool seal) } /* use mmap to shrink. */ - ret2 = sys_mmap(ptr, 8 * page_size, PROT_READ, - MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); + ret2 = mmap(ptr, 8 * page_size, PROT_READ, + MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); if (seal) { FAIL_TEST_IF_FALSE(ret2 == MAP_FAILED); FAIL_TEST_IF_FALSE(errno == EPERM); @@ -1650,7 +1639,7 @@ static void test_seal_discard_ro_anon_on_filebacked(bool seal) ret = fallocate(fd, 0, 0, size); FAIL_TEST_IF_FALSE(!ret); - ptr = sys_mmap(NULL, size, PROT_READ, mapflags, fd, 0); + ptr = mmap(NULL, size, PROT_READ, mapflags, fd, 0); FAIL_TEST_IF_FALSE(ptr != MAP_FAILED); if (seal) { @@ -1680,7 +1669,7 @@ static void test_seal_discard_ro_anon_on_shared(bool seal) int ret; unsigned long mapflags = MAP_ANONYMOUS | MAP_SHARED; - ptr = sys_mmap(NULL, size, PROT_READ, mapflags, -1, 0); + ptr = mmap(NULL, size, PROT_READ, mapflags, -1, 0); FAIL_TEST_IF_FALSE(ptr != (void *)-1); if (seal) { diff --git a/tools/testing/selftests/mm/seal_elf.c b/tools/testing/selftests/mm/seal_elf.c index 7aa1366063e4e..d9f8ba8d5050b 100644 --- a/tools/testing/selftests/mm/seal_elf.c +++ b/tools/testing/selftests/mm/seal_elf.c @@ -30,17 +30,6 @@ static int sys_mseal(void *start, size_t len) return sret; } -static void *sys_mmap(void *addr, unsigned long len, unsigned long prot, - unsigned long flags, unsigned long fd, unsigned long offset) -{ - void *sret; - - errno = 0; - sret = (void *) syscall(__NR_mmap, addr, len, prot, - flags, fd, offset); - return sret; -} - static inline int sys_mprotect(void *ptr, size_t size, unsigned long prot) { int sret; @@ -56,7 +45,7 @@ static bool seal_support(void) void *ptr; unsigned long page_size = getpagesize(); - ptr = sys_mmap(NULL, page_size, PROT_READ, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + ptr = mmap(NULL, page_size, PROT_READ, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); if (ptr == (void *) -1) return false;