Received: by 2002:a05:7412:9c07:b0:fa:6e18:a558 with SMTP id lr7csp106350rdb; Fri, 26 Jan 2024 21:56:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IFfCnQqT2f4sD3rqrOpnPRHXfUw3d5Dgb6fWWNPmssvvQGDRzuH/a0gyeKkQgb7tne0ZmJT X-Received: by 2002:a17:902:c086:b0:1d5:e943:a8b3 with SMTP id j6-20020a170902c08600b001d5e943a8b3mr940088pld.7.1706335010727; Fri, 26 Jan 2024 21:56:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706335010; cv=pass; d=google.com; s=arc-20160816; b=S7HXrnjexjkEQz63RolGKCVJ4P8pVo1VkDbCsAi0PvixbtQ+QHBgYmUt08poIjQgFp 946dV0Oe44grAvAGzpPVdFllJGjOqbHTRsjbcOVAjqKqqXUUgQp92PIGJSYCskTEWZLJ KSpxe7nIvf+expV9BKfW0Vx7tXqVbpAzYqeV/XlCz48xaeXlY+Bh2+bEDGtqVKGn6rMh 0Uglb/63Ve4p4TP+WCYknR9vgKBxb6NLlFrqTa3HTamLLLx8J1/bjaoQhiC4BK9c1WVt Tz8FWejEj6ZwQcE3AupSaaDSQ9SMkMo4LTis4Yu+yMmRdmO+UzgouXICH4WY460E47sD FCsw== 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=Jaf7dwKCpzOam5AxGVkQC1zxu44hKX42z/tivO06WcI=; fh=ihYqxaSOeWkOf/TXzhQINhK9J+TBcUU0y3bPV7PZkzo=; b=ka1WScczOp8Rf7UKhEoxwZNd+x4ha9YAJKKddaR9oAF38MM1jcGoG+gW3AogW+RUFN Xwuj7YhrIQJAxKE2Q1vnI32wr+nMxbomnqHdRkJhdzbF/wN4kFNvMy+SUTp3cj5tMv5A dcfFc54/jdLatYFXGHZujmdvvWb59EWl1CbPEjxFxkqo/XpWw+v9LFHD9icmp9W3zO0/ r/Ng8WXwKgDgHLK3JBQZSOybPM0/nP5xFIaQIIK2NqQKD97hJF1Jj29IUvE/SiNIOHS/ kl/y0J2NYMSEqtk5qGdI4j5YKhf6cSCktUoDAmGmZ5qPfixw+0LNeJzvDl6l+V1e+a3z 1glA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@illinois.edu header.s=campusrelays header.b=bGsxg2TZ; arc=pass (i=1 spf=pass spfdomain=illinois.edu dkim=pass dkdomain=illinois.edu dmarc=pass fromdomain=illinois.edu); spf=pass (google.com: domain of linux-kernel+bounces-41075-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41075-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=illinois.edu Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id t2-20020a1709028c8200b001d7192fb733si2235701plo.227.2024.01.26.21.56.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 21:56:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-41075-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@illinois.edu header.s=campusrelays header.b=bGsxg2TZ; arc=pass (i=1 spf=pass spfdomain=illinois.edu dkim=pass dkdomain=illinois.edu dmarc=pass fromdomain=illinois.edu); spf=pass (google.com: domain of linux-kernel+bounces-41075-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41075-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=illinois.edu 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 5FEA628339D for ; Sat, 27 Jan 2024 05:56:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9EDD114A8D; Sat, 27 Jan 2024 05:56:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=illinois.edu header.i=@illinois.edu header.b="bGsxg2TZ" Received: from mx0b-00007101.pphosted.com (mx0b-00007101.pphosted.com [148.163.139.28]) (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 2E5FD7F; Sat, 27 Jan 2024 05:56:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.139.28 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706335002; cv=none; b=D0FGZcUtBEKtQfPdizDcPQXAjdPaQy/O5ic9TvNZrn93TiqDvJmm/66/yGB7iOrvTPQeV61YBBmFWax890QjrF3QcDWJ68AVsThwkHrNQq9gml0uNOcZqaVEwh5Xs9LWhg9VMqUv8j9zY/W95ziTLhX1L2FmF8mk9BfygFwFb7o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706335002; c=relaxed/simple; bh=QmTDRUbNHgrq5t9JI5UYewOWGURNdPHH08srd4UcjQA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=I4b9SBFTmLliRO3P7DggrM/u0zMjrZOvURkfiM6xYnqHSYHHX/cFaAGiUV9lwQCFIdDD7RfNI8TYVs/OXPSEXxw0NGW4y1RBQDu8nGnntIUaO6fiZ7wqq/AU6IZ39c1rAuN+lI6gTAv/y7lNeNJ6N4dckCUXfPjK8/jRMXgOA4E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=illinois.edu; spf=pass smtp.mailfrom=illinois.edu; dkim=pass (2048-bit key) header.d=illinois.edu header.i=@illinois.edu header.b=bGsxg2TZ; arc=none smtp.client-ip=148.163.139.28 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=illinois.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=illinois.edu Received: from pps.filterd (m0166258.ppops.net [127.0.0.1]) by mx0b-00007101.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 40R48jDX026485; Sat, 27 Jan 2024 04:41:36 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=illinois.edu; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=campusrelays; bh=Jaf7dwKCpzOam5AxGVkQC1zxu44hKX42z/tivO06WcI=; b=bGsxg2TZ2xE8ej0BpJ/gSoVrfxGnS5ugqZwGMh93/llF/eNRRRea/irYHs3FfIDUZlJX ibkixVycodjAcYTV5aGXRD7jEsi7VlED3Z92hVyjV9noUAZUxj3AxO02rPqBAUIae1ni cvCDspJe/mXcTJzbaCco3J3bOjCb0IuCuc/ew+DBeN7lA2eGRPDmkwBL6x6EX7llFVt4 EmpmsoM6ZCgqRjS8ABGsiPVcl7cuW3JWV2AliiU6Qbc6a6zgApV1fXJHLdVZ7OI+ObqQ J73LBn9KHqpF/JLBuC6MFL9eh8wnCKEsASBzHFdgxhSkCJtHGjXK7l1NBeeJuOu8GSiJ sQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-00007101.pphosted.com (PPS) with ESMTPS id 3vvr6sgk29-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 27 Jan 2024 04:41:36 +0000 Received: from m0166258.ppops.net (m0166258.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 40R4fZW7019561; Sat, 27 Jan 2024 04:41:36 GMT Received: from localhost.localdomain (oasis.cs.illinois.edu [130.126.137.13]) by mx0b-00007101.pphosted.com (PPS) with ESMTP id 3vvr6sgk26-1; Sat, 27 Jan 2024 04:41:35 +0000 From: Jinghao Jia To: "Masami Hiramatsu (Google)" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Peter Zijlstra Cc: linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org, Jinghao Jia Subject: [RFC PATCH 0/2] x86/kprobes: add exception opcode detector and boost more opcodes Date: Fri, 26 Jan 2024 22:41:22 -0600 Message-ID: <20240127044124.57594-1-jinghao7@illinois.edu> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-GUID: kVJuc-U0v0AAMI2LBDzzUlJWS0ZpTZDO X-Proofpoint-ORIG-GUID: 6YLeFrF7svbWsgXIk0n3OeKrq3OypKIi X-Spam-Details: rule=cautious_plus_nq_notspam policy=cautious_plus_nq score=0 impostorscore=0 spamscore=0 malwarescore=0 priorityscore=1501 clxscore=1011 mlxlogscore=899 phishscore=0 suspectscore=0 lowpriorityscore=0 mlxscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401270033 X-Spam-Score: 0 X-Spam-OrigSender: jinghao7@illinois.edu X-Spam-Bar: Hi everyone, This patch set makes the following 2 changes: - It adds an exception opcode detector to prevent kprobing on INTs and UDs. These opcodes serves special purposes in the kernel and kprobing them will also cause the stack trace to be polluted by the copy buffer address. This is suggested by Masami. - At the same time, this patch set also boosts more opcodes from the group 2/3/4/5. The newly boosted opcodes are all arithmetic instructions with semantics that are easy to reason about, and therefore, they are able to be boosted and executed out-of-line. These instructions were not boosted previously because they use opcode extensions that are not handled by the kernel. But now with the instruction decoder they can be easily handled. Boosting (and further jump optimizing) these instructions leads to a 10x performance gain for a single probe on QEMU. Jinghao Jia (2): x86/kprobes: Prohibit kprobing on INT and UD x86/kprobes: boost more instructions from grp2/3/4/5 arch/x86/kernel/kprobes/core.c | 54 ++++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 13 deletions(-) -- 2.43.0