From patchwork Fri Feb 2 10:39:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hou Tao X-Patchwork-Id: 195786 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp336867dyc; Fri, 2 Feb 2024 02:39:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IHXAayAd02MzgDcjkQax/KACXafV8uZkw3OpBkXZHEtdgGdFtRZNQuv1MmO7rtx9hBqwSq1 X-Received: by 2002:a05:6358:5d83:b0:178:7542:1a58 with SMTP id s3-20020a0563585d8300b0017875421a58mr9202371rwm.7.1706870369687; Fri, 02 Feb 2024 02:39:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706870369; cv=pass; d=google.com; s=arc-20160816; b=QIWlBElt8RWhsTZ1ftLjNb08CaPi7jFW1Bvq2MJXF5dNOamekScBF81QnpqbIKTEnR dJuFdFfRFvs1GmPOp9amCJoW2Dotg55ZKJVc0iaov1HyvMD7MInXNJrb88sFaaKK5D8M EPWoEp2wDbAM42DBVCON+oUIHQJQWOV/1RC4vQMgH58TSkZR1KPExn/+UNf11Hynwb7l gbslBNjRFjishAW0aC4dhqiez2cMCDzigb/4oQ/7qBFfelD89cyKKWvWY8lXLhlDgg8Y vbeLPN1xQqrvwCc9afbZOfeM65oLduBT8wsfVejwK2dFsahFene2bYp3sqCgs4CqBARQ OBBA== 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:references:in-reply-to:message-id :date:subject:cc:to:from; bh=8g+Inh+k+y3S5+oImGrlVQ/LdrnQuJkeaGlEInSzAd0=; fh=YvoXuuWEKmWKfhK4h/mGpYLRchTZwmtK7qVTzaokfyw=; b=uVMyj/djx17/wnHuV1xA5/t+9u22D61UbhGwXOOeCXBJGCslyqpORxFeHG4OO7LJ/6 HVxne8k4Amj4fL2LoCcPWTufUjAjJ3TqVshGAptZtGu4UUYYWU5YeQ3kQ+lgpV0TjPUK aXhz+uzwsQHV+Kx4Q41KdbYuUNTtVPw35a6cC+pkhpKcNZxeSczS1pK1aPJex59t+w/y Plg15Xsn6yzHoOdzQ0rhkyZBNvGx6i5I7aNZ+1hBU3QQ2vVKtTFMuIh5TbZlOmJtkxAA fbdN7pTcwDD7sexmRLIo2EgMm8QsHs0zT+w2lGq32x6xEZESN8xV2+M0dEyBZ+R5GoXm 7EkQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-49683-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49683-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCWQOsjCp8f7RQTU1WDi7BPJ0VCeJlS3u5ER+BzzG4XNEqtj2zZAg+U1XorrDFs+YPZv5GvsPXfzP6sLEKxO8aHCiKiW9A== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id y28-20020a056a001c9c00b006dff73eee3bsi1100442pfw.53.2024.02.02.02.39.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 02:39:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49683-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-49683-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49683-ouuuleilei=gmail.com@vger.kernel.org" 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id E4F75290CFA for ; Fri, 2 Feb 2024 10:39:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8441913DBAC; Fri, 2 Feb 2024 10:38:52 +0000 (UTC) Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) (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 8825183CDF; Fri, 2 Feb 2024 10:38:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706870330; cv=none; b=o5iiXTtApUl1hPIVN9+D41WT24BqcpWNpYSoE/mvHFxXoeXbaf14KY5K4oAaNGMQBsYv8GLhKzmdMdT/FbSR29gZKHIwnW8dzG9IUaJ8G2t3p02Zl6tcKTv/hJ0EWGuAxtTVmdAQoQCxqPHT8/9PJ35+03bqCStXhT+0VTAhAX8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706870330; c=relaxed/simple; bh=20m1Y/wCslG96LNpA7pTV6a7oWvp2QJOcY87YCTge+Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IRzPtzBrDeq+dR/OhQQTmjoiRrYEJ6EIUtIW5lTC2GoXfJxU4OUoa/7c2Wz8TCRd1jb9SSrIf7hq+zh6O4r52AESKBbHGiIV9gycBG0HUiKzELFS7xV3i31WAu4nqzmTnjS4/qmglozq2oLNYDXHaXMywAHI5SVx0RhaTbxZQH8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4TRC1F5895z4f3jqK; Fri, 2 Feb 2024 18:38:41 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 58D0F1A017A; Fri, 2 Feb 2024 18:38:44 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP1 (Coremail) with SMTP id cCh0CgAn+REwxrxl46r1Cg--.15879S5; Fri, 02 Feb 2024 18:38:44 +0800 (CST) From: Hou Tao To: x86@kernel.org, bpf@vger.kernel.org Cc: Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , linux-kernel@vger.kernel.org, xingwei lee , Jann Horn , Sohil Mehta , Yonghong Song , houtao1@huawei.com Subject: [PATCH bpf v3 1/3] x86/mm: Move is_vsyscall_vaddr() into asm/vsyscall.h Date: Fri, 2 Feb 2024 18:39:33 +0800 Message-Id: <20240202103935.3154011-2-houtao@huaweicloud.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20240202103935.3154011-1-houtao@huaweicloud.com> References: <20240202103935.3154011-1-houtao@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: cCh0CgAn+REwxrxl46r1Cg--.15879S5 X-Coremail-Antispam: 1UD129KBjvJXoW7CF13Xr47Wr15uw1xuw47CFg_yoW8Zr1fpF 9xA3Z7WFWFg34aka9rXryUZ34fA3Z7Gr40qrW2grWYvF17Z34Ygr1I93WkGry7Ja97KFWr XF4Svry8Jr1qy3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBjb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUGw A2048vs2IY020Ec7CjxVAFwI0_Gr0_Xr1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV WxJVW8Jr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_ GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx 0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWU JVW8JwACjcxG0xvY0x0EwIxGrwACI402YVCY1x02628vn2kIc2xKxwCF04k20xvY0x0EwI xGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480 Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7 IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k2 6cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxV AFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x07jn9N3UUUUU= X-CM-SenderInfo: xkrx3t3r6k3tpzhluzxrxghudrp/ X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789783304793692134 X-GMAIL-MSGID: 1789783304793692134 From: Hou Tao Move is_vsyscall_vaddr() into asm/vsyscall.h to make it available for copy_from_kernel_nofault_allowed() in arch/x86/mm/maccess.c. Reviewed-by: Sohil Mehta Signed-off-by: Hou Tao --- arch/x86/include/asm/vsyscall.h | 10 ++++++++++ arch/x86/mm/fault.c | 9 --------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/arch/x86/include/asm/vsyscall.h b/arch/x86/include/asm/vsyscall.h index ab60a71a8dcb9..472f0263dbc61 100644 --- a/arch/x86/include/asm/vsyscall.h +++ b/arch/x86/include/asm/vsyscall.h @@ -4,6 +4,7 @@ #include #include +#include #ifdef CONFIG_X86_VSYSCALL_EMULATION extern void map_vsyscall(void); @@ -24,4 +25,13 @@ static inline bool emulate_vsyscall(unsigned long error_code, } #endif +/* + * The (legacy) vsyscall page is the long page in the kernel portion + * of the address space that has user-accessible permissions. + */ +static inline bool is_vsyscall_vaddr(unsigned long vaddr) +{ + return unlikely((vaddr & PAGE_MASK) == VSYSCALL_ADDR); +} + #endif /* _ASM_X86_VSYSCALL_H */ diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index 679b09cfe241c..d6375b3c633bc 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -798,15 +798,6 @@ show_signal_msg(struct pt_regs *regs, unsigned long error_code, show_opcodes(regs, loglvl); } -/* - * The (legacy) vsyscall page is the long page in the kernel portion - * of the address space that has user-accessible permissions. - */ -static bool is_vsyscall_vaddr(unsigned long vaddr) -{ - return unlikely((vaddr & PAGE_MASK) == VSYSCALL_ADDR); -} - static void __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code, unsigned long address, u32 pkey, int si_code)