Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp329538lqh; Mon, 6 May 2024 23:32:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUS4LKdBsIogBlAtnbgfQanEuIFJSvYPzqPi9GmlrlbfOciStxm1y7hELx1hWy/nUdi9p8LWe8QKHDeu2fHoma9IrwwjGKTQ2+o59440g== X-Google-Smtp-Source: AGHT+IGyIxDHa03vJy2kQs2HzId7Wrmy2KLwSubP8ORSAEuAYDiNhWK6NBuNzqIHhBvuLhUl+/Qq X-Received: by 2002:a9d:630d:0:b0:6f0:688c:487 with SMTP id q13-20020a9d630d000000b006f0688c0487mr4963306otk.10.1715063534919; Mon, 06 May 2024 23:32:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715063534; cv=pass; d=google.com; s=arc-20160816; b=ckpXEkmsRylJg/Fqg3eFuJEo1UJ0e+oaWnjR8hhUlZvS0/5/Vf6pme1VCRKpL7qvZN joJs8+9StakK1djmp5H3176a3U6srBd5wTRNCRof2I7HhSMB3yBjzbW3C1wfvtoVCSjI L7gKDTbptVLH1Z2Uh0ahByhzHm3CBRcM+QXOQ/XnkzLcrzBwoDLfTH0xRUiia8T7u2gO x/134Mu5YmlI97EObZJWK/rbA0uhbBNZP9ge4+uk+G1dZR3vpEuiNOkx7lG4/QB92mpn +PT5OrbiJ+G2FdxGKiMtvd/CKY/nVMksA+M959aQojgmSVoWXGAlg5ebMVA0H838/ymm XzYw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=81CPei3+HKuViwOF6fZ8HfrgG0pyW7nCmzUY60LsSoA=; fh=9e3DP5TMlL0jeKkEfBqjJh8gHzbema2+SNyqE7m2Rv8=; b=W44OKnHGLpmBhHasPfMEpC9p4kI7CGYWzG4F18scKzM2QfK7n1UYps5VAu3bteRfOY 36QeGQrjo9alx0NV89zITEEs0047QE/dgUHp4DiETtNJeCOMxzMlK70F1vsH2URxr8r9 reSfhct/44AelJ1znYJGPH9EossPZFTsquevqN4liyFzYolCVl7ejLDGR5YlzyeEPe17 TJ3s13ZZSZ5E7DqN9L/zdjIwkXleauURQGxQEl+DSYr7ANA4C5B38QbcfrUtJBZI6yyp RZ9wEwudZYuvrCwVUZveuyVqZ3m/o2VF/iXzFQxRNqZInZplum/xc/x+wy6HMhWoKJx+ ccpA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MugYcY8m; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-170751-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170751-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id r3-20020a632b03000000b0060afff2216asi9956132pgr.94.2024.05.06.23.32.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 23:32:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-170751-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MugYcY8m; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-170751-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170751-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 86796B22FCD for ; Tue, 7 May 2024 06:30:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 189246FE06; Tue, 7 May 2024 06:30:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="MugYcY8m" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6D2AA6BB4E; Tue, 7 May 2024 06:29:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715063400; cv=none; b=DRx2KmrNdq5ZePBdLHslkyXUY7+WJ68kxEVTXecfSVZTK4Ntsv3+36qh+Sj2K+m+SgnL14VFIq8Q9Uu5Ojg048RpdqN10pjWgCtptdgHPQrXqIi0+1kC+rjn2EwYDqPUaQliljejyWBmn5g5uaUnvi8ZGjX0WIKtM3nWlfgrRO0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715063400; c=relaxed/simple; bh=56e8bED4V6W28096yUKf8RNEXz6YOYzyF3VADr9TI8I=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ChSFIfwU1dwaR7373ajUWNJLdnH8zlzDN494BhDykZODwQfN/pG1/uABph05Zq7RW3xiLpkw/YdZM27uLaNpuDlephKjmLXg9G4Z3bwip6f0vh16dc6IJt3w6FrA/O6joyY1czA3iwYvjpj7gQvM6CfgkSrKTvEbCAtbWAt7MrA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=MugYcY8m; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715063399; x=1746599399; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=56e8bED4V6W28096yUKf8RNEXz6YOYzyF3VADr9TI8I=; b=MugYcY8moHc+6DetqGQuaudOjoD6JL70gK/mRj2Q79CAZn5b/g6OGEAW goNJeSs45qt4+2RiTGtd8Q0pqMJ2woWuq7P6Vc8J6iUTZFlZPxdAnWtRM Ip6xEjKSRGlpvPEfaN2yrqw/8vjvvN8c1sRwbAHf6zNA9iNBNEXbZYQ+S 3CRgU5b0Fp493njPGjWzInecfM5PZqA7jy9FPN9VQllGG6FQ6tYgzjFqa 9MTmtGOE0h7nj8SxsJPUeuhPbZmEtqQFv7jrdpgXyEseQ47XqDS3TW2xa phdwQIolbLztN3YdSvjAiLIF+IaYACg7zKbb+SQxyeRpQ3zhiQMdqwbu5 w==; X-CSE-ConnectionGUID: i1HkxT/OScufA5Ky3LnD3A== X-CSE-MsgGUID: ANjC379ASXKR5Ghx/VFMMg== X-IronPort-AV: E=McAfee;i="6600,9927,11065"; a="28310310" X-IronPort-AV: E=Sophos;i="6.07,260,1708416000"; d="scan'208";a="28310310" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 May 2024 23:29:58 -0700 X-CSE-ConnectionGUID: ZbdwN7B/QKOYWMvoqZTbhg== X-CSE-MsgGUID: rhqLLXceR/WPYY+cor1KiA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,260,1708416000"; d="scan'208";a="32872739" Received: from unknown (HELO dcai-bmc-sherry-1.sh.intel.com) ([10.239.138.57]) by fmviesa005.fm.intel.com with ESMTP; 06 May 2024 23:29:54 -0700 From: Haiyue Wang To: bpf@vger.kernel.org Cc: Haiyue Wang , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , linux-kernel@vger.kernel.org (open list) Subject: [PATCH bpf-next v1] bpf,arena: Remove redundant page mask of vmf->address Date: Tue, 7 May 2024 14:33:39 +0800 Message-ID: <20240507063358.8048-1-haiyue.wang@intel.com> X-Mailer: git-send-email 2.43.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit As the comment described in "struct vm_fault": ".address" : 'Faulting virtual address - masked' ".real_address" : 'Faulting virtual address - unmasked' The link [1] said: "Whatever the routes, all architectures end up to the invocation of handle_mm_fault() which, in turn, (likely) ends up calling __handle_mm_fault() to carry out the actual work of allocating the page tables." __handle_mm_fault() does address assignment: .address = address & PAGE_MASK, .real_address = address, This is debug dump by running `./test_progs -a "*arena*"`: [ 69.767494] arena fault: vmf->address = 10000001d000, vmf->real_address = 10000001d008 [ 69.767496] arena fault: vmf->address = 10000001c000, vmf->real_address = 10000001c008 [ 69.767499] arena fault: vmf->address = 10000001b000, vmf->real_address = 10000001b008 [ 69.767501] arena fault: vmf->address = 10000001a000, vmf->real_address = 10000001a008 [ 69.767504] arena fault: vmf->address = 100000019000, vmf->real_address = 100000019008 [ 69.769388] arena fault: vmf->address = 10000001e000, vmf->real_address = 10000001e1e8 So we can use the value of 'vmf->address' to do BPF arena kernel address space cast directly. [1] https://docs.kernel.org/mm/page_tables.html Signed-off-by: Haiyue Wang --- kernel/bpf/arena.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/bpf/arena.c b/kernel/bpf/arena.c index 343c3456c8dd..1876dc7ebb57 100644 --- a/kernel/bpf/arena.c +++ b/kernel/bpf/arena.c @@ -251,7 +251,7 @@ static vm_fault_t arena_vm_fault(struct vm_fault *vmf) int ret; kbase = bpf_arena_get_kern_vm_start(arena); - kaddr = kbase + (u32)(vmf->address & PAGE_MASK); + kaddr = kbase + (u32)(vmf->address); guard(mutex)(&arena->lock); page = vmalloc_to_page((void *)kaddr); -- 2.43.2