From mboxrd@z Thu Jan 1 00:00:00 1970 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 D8D5EC78853 for ; Fri, 20 Sep 2024 14:59:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3E6856B0085; Fri, 20 Sep 2024 10:59:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 396646B0088; Fri, 20 Sep 2024 10:59:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 25E3F6B0089; Fri, 20 Sep 2024 10:59:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 02CB26B0085 for ; Fri, 20 Sep 2024 10:59:17 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id A4A47A045E for ; Fri, 20 Sep 2024 14:59:17 +0000 (UTC) X-FDA: 82585424754.21.9CA15BB Received: from mail-il1-f175.google.com (mail-il1-f175.google.com [209.85.166.175]) by imf07.hostedemail.com (Postfix) with ESMTP id 8EE4B4000B for ; Fri, 20 Sep 2024 14:59:15 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=google header.b=RZh8aP6U; dmarc=pass (policy=none) header.from=linuxfoundation.org; spf=pass (imf07.hostedemail.com: domain of skhan@linuxfoundation.org designates 209.85.166.175 as permitted sender) smtp.mailfrom=skhan@linuxfoundation.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1726844322; a=rsa-sha256; cv=none; b=YivuuHbRuLBwl8jyIJjtMJaS+Cfg82XtWtTCIhTBF8HDF8umxmYQHo/zk0jQ87kwIONpxD N7gYCYOqEmuF8gVck5RQCnQ6rrvsF0sTDhlAYxvL/5FDqmfZoE/VDh7KpUZLYzxwqsoQFk r8Df7YTM5R7DcC0sWjR78ojVUFVPLzg= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=google header.b=RZh8aP6U; dmarc=pass (policy=none) header.from=linuxfoundation.org; spf=pass (imf07.hostedemail.com: domain of skhan@linuxfoundation.org designates 209.85.166.175 as permitted sender) smtp.mailfrom=skhan@linuxfoundation.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1726844322; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=WYxe9kwrqo1GfeH3C0KfOo+V1SDp2i8OljG3N7NL5wA=; b=gJco5Bl1C/xJ75RNPthmo3leKrKlgcjxzxcDDPImAn/bJD4xZKdy6p72OosufE2462xO9u qlOw1a40dHuRsWMDgzyfe2jLQNsRMDBv8jM5Nk9sYUIY3QHj4vkzNcyJHlEwD/1oWQE71R A871aP1WH8DKpQkpkt0xt1qgtaWg8Qc= Received: by mail-il1-f175.google.com with SMTP id e9e14a558f8ab-39f49600297so8557325ab.1 for ; Fri, 20 Sep 2024 07:59:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; t=1726844354; x=1727449154; darn=kvack.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=WYxe9kwrqo1GfeH3C0KfOo+V1SDp2i8OljG3N7NL5wA=; b=RZh8aP6US8PxMlQRrM22+1M7dGvid8QXmNuHoc/+b58L1QfPiUUs2siCcBmMmzvg0L 7Q6mdVnWy2NDf2a46edxt5Q5AZfkSV48uyxIcm5YbLSXegVYdiDrJjjzTgPJR+PFN9/k lOne4IleXcSbx85clvfle+W3e29XqnLSqscFs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726844354; x=1727449154; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=WYxe9kwrqo1GfeH3C0KfOo+V1SDp2i8OljG3N7NL5wA=; b=w+rv5n7yPR2bSnhXzpUtwKAG8CpMSnfRF1N01Lw0uzJ0jrj0Oqi5uVEKycvNaXQgS1 XhJAuWkomtUDX88K8U7WkeYrmwU45wEwAwc7gFXGZGaA4cbMyv4bfSMeK8Bid7Rek2YF hKbj2gj5suB66HwVWEGYbExY6ceVJX8Vvj1GtdqdvbzdbzUZfFN9L+aCso1wYf8VjUMd yH6tcf/5TPUc8Xcbv/UOY4OKzuVJZk0WymjQDwixuJIcOcP0N3ovCPZDdIojsOzJz7Pj 9oeImfe0EQMt6YCf/2nzAQCV+OHI/OSamAYdXB9jVc9hvsnnOvEJAed8bIaCqZX94QBW rgVg== X-Forwarded-Encrypted: i=1; AJvYcCW8G0Qpum9Mp8Jsv/E0RLhrtSgs7hk3z8ySooKDNV0d+e/UGTLLu7R+vYoLox+20mRz01jN4UUaEQ==@kvack.org X-Gm-Message-State: AOJu0YyEY8JwTK8J1bub7/t2jS3LlJnAjIv03jzpNuqAZd93AxgIF4D+ 5xNB0MlRNi78ENOr9XF/h4ZE6R8aQN8jPeVZg/MypRnni2Lm+bjyCWcT1OFg8RI= X-Google-Smtp-Source: AGHT+IFR1dxehC1DeauIKJjZxKxCtU9ZHfRiqWSorqoWsZuZa7+canQ6L2+MemljTc3siNvr4bdfdg== X-Received: by 2002:a05:6e02:1c49:b0:3a0:c88c:e668 with SMTP id e9e14a558f8ab-3a0c8cba344mr35924225ab.14.1726844354353; Fri, 20 Sep 2024 07:59:14 -0700 (PDT) Received: from [10.212.145.178] ([12.216.155.19]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-3a092e72080sm41727115ab.68.2024.09.20.07.59.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 20 Sep 2024 07:59:13 -0700 (PDT) Message-ID: Date: Fri, 20 Sep 2024 08:59:12 -0600 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/2] kselftests: mm: Fix wrong __NR_userfaultfd value To: Muhammad Usama Anjum , Andrew Morton , Shuah Khan , David Hildenbrand , Peter Xu Cc: kernel@collabora.com, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, John Hubbard , Shuah Khan References: <20240912103151.1520254-1-usama.anjum@collabora.com> <3cb9d266-4d4b-4031-8603-da7fd9e3ad47@collabora.com> <0b847784-a95f-4ed5-a0fb-1b7b4023df13@collabora.com> Content-Language: en-US From: Shuah Khan In-Reply-To: <0b847784-a95f-4ed5-a0fb-1b7b4023df13@collabora.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspam-User: X-Rspamd-Queue-Id: 8EE4B4000B X-Rspamd-Server: rspam01 X-Stat-Signature: ueoopzbdjz7mzm6prpksfspgixhn3ikh X-HE-Tag: 1726844355-675428 X-HE-Meta: U2FsdGVkX1+bGkqsduq/puhWRSmtHCFEVhYgNDOPPF3d3cru5WVDwbpk5YyBgpRZjjZfFiwBRq0Es/217E/gAgFc7B5og5VZ1lUxKIPTNsDuPOLX0g6Or2fUA59bxaP135hPICsGX8bj72612EggENzEUjAXFVZ8OM/hA/9zPXV8G0LrecADvtel0XcEGaEFNSwAe/0hXlUvOVPTGrKyt8hKtRAjvnbAV6K/B2DGl13b7URMWyKMCWiXDR2JjTfv9blIiwaOMe6bmKbhxIYeQT6AcCfO54V7s0ibu0+AP6GqJX/jhgtQuGUbWnz5yfiWMA3RivYILa6L0Pu2ZM6R5GVuOk7ljB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.000005, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 9/17/24 23:46, Muhammad Usama Anjum wrote: > On 9/17/24 6:56 AM, Shuah Khan wrote: >> On 9/16/24 00:32, Muhammad Usama Anjum wrote: >>> On 9/12/24 8:44 PM, Shuah Khan wrote: >>>> On 9/12/24 04:31, Muhammad Usama Anjum wrote: >>>>> The value of __NR_userfaultfd was changed to 282 when >>>>> asm-generic/unistd.h was included. It makes the test to fail every time >>>>> as the correct number of this syscall on x86_64 is 323. Fix the header >>>>> to asm/unistd.h. >>>>> >>>> >>>> "please elaborate every time" - I just built on my x86_64 and built >>>> just fine. >>> The build isn't broken. >>> >>>> I am not saying this isn't a problem, it is good to >>>> understand why and how it is failing before making the change. >>> I mean to say that the test is failing at run time because the correct >>> userfaultfd syscall isn't being found with __NR_userfaultfd = 282. >>> _NR_userfaultfd's value depends on the header. When asm-generic/unistd.h >>> is included, its value (282) is wrong. I've tested on x86_64. >>> >> >> Okay - how do you know this is wrong? can you provide more details. >> >> git grep _NR_userfaultfd >> include/uapi/asm-generic/unistd.h:#define __NR_userfaultfd 282 >> include/uapi/asm-generic/unistd.h:__SYSCALL(__NR_userfaultfd, >> sys_userfaultfd) >> tools/include/uapi/asm-generic/unistd.h:#define __NR_userfaultfd 282 >> >>> The fix is simple. Add the correct header which has _NR_userfaultfd = >>> 323. > > grep -rnIF "#define __NR_userfaultfd" > tools/include/uapi/asm-generic/unistd.h:681:#define __NR_userfaultfd 282 > arch/x86/include/generated/uapi/asm/unistd_32.h:374:#define > __NR_userfaultfd 374 > arch/x86/include/generated/uapi/asm/unistd_64.h:327:#define > __NR_userfaultfd 323 > arch/x86/include/generated/uapi/asm/unistd_x32.h:282:#define > __NR_userfaultfd (__X32_SYSCALL_BIT + 323) > arch/arm/include/generated/uapi/asm/unistd-eabi.h:347:#define > __NR_userfaultfd (__NR_SYSCALL_BASE + 388) > arch/arm/include/generated/uapi/asm/unistd-oabi.h:359:#define > __NR_userfaultfd (__NR_SYSCALL_BASE + 388) > include/uapi/asm-generic/unistd.h:681:#define __NR_userfaultfd 282 > > The number is dependent on the architecture. The above data shows that: > x86 374 > x86_64 323 Correct and the generated header files do the right thing and it is good to include them as this patch does. This is a good find and fix. I wish you explained this in your changelog. Please add more details when you send v2. There could be other issues lurking based on what I found. The other two files are the problem where they hard code it to 282 without taking the __NR_SYSCALL_BASE for the arch into consideration: tools/include/uapi/asm-generic/unistd.h:681:#define __NR_userfaultfd 282 include/uapi/asm-generic/unistd.h:681:#define __NR_userfaultfd 282 > > I'm unable to find the history of why it is set to 282 in unistd.h and > when this problem happened. According to git history it is added in the following commit to include/uapi/asm-generic/unistd.h: 09f7298100ea9767324298ab0c7979f6d7463183 Subject: [PATCH] userfaultfd: register uapi generic syscall (aarch64) and it is added in the following commit to tools/include/uapi/asm-generic/unistd.h 34b009cfde2b8ce20a69c7bfd6bad4ce0e7cd970 Subject: [PATCH] tools include: Grab copies of arm64 dependent unistd.h files I think, the above defines from include/uapi/asm-generic/unistd.h and tools/include/uapi/asm-generic/unistd.h should be removed. Maybe others familiar with userfaultfd can determine the best course of action. We might have other NR_ defines in these two files that are causing problems for tests and tools that we haven't uncovered yet. thanks, -- Shuah