Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1255864lqp; Sun, 14 Apr 2024 23:56:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVqyuuYLi2QnDVvoZG+nuwzYoRTJmVlPaWlebPXTSZ3NKxKeCnRgDfmNqY28OZAld8DLw3UDzrHI+qvCRTcsGw8gn02t6EZP4aTsqV+cg== X-Google-Smtp-Source: AGHT+IFgSW86IagNFnpVbCMFBbK/W+5ZwhY7VGNDfyWNd6Hw9etnu79ZMCn1zGIeTbvjWafYTC8Q X-Received: by 2002:a17:902:650a:b0:1e5:4f5:7fa7 with SMTP id b10-20020a170902650a00b001e504f57fa7mr9229211plk.21.1713164197832; Sun, 14 Apr 2024 23:56:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713164197; cv=pass; d=google.com; s=arc-20160816; b=JnPC/AxOE5aIFNWHqRo65ofZl3FWLdnTnGmesCEhnFDUh5aJULeHCvWjpNgiHuj3p9 tj0TyeheaOZZou6WT0I1gJG4fMy8H5Y/dDZiMnDatCkslcGEKSvWSajdyWxafF2+C57M wsF88RGJrOr/YPXoCHCw1JcoZ+bfZwNRc8wm34ttNEXDjOrBo8VJJUqmSfrBKAjim647 O7/6G3UTyOsNQgrjCyvj4gvaF8FAV1mRvlYx9F0UPLYcMoyNajjQBRJbOj45kKprnEdR IwswgRX4+esfuQcuSoRN4Ez9NsS0+VO3pHRDyC7TWHlMxzVshoWkaNnOjfDzS7+X9OCZ Ioag== 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=/L+7fVxOA3nBz4ssiZ6m/QRFoiB5vK5bL7iDLjJG9tc=; fh=ACDzcgbaNdVZh5rYGX5uvjuD7vJOIVWNQkRf+hZhqPI=; b=EDtgDevsPy2FTGS/FJTKqGhs8zau03uedjXiTuKdvQW7LXbVoITFgcatU0W31diDij pg//kznsaJIZ6QG1tf9ZtbVfwDw5vSM+E9Ij3l8xW6SWFDfBm2RUmOdUCC0cMy7lhj0H Zy8OKxSZahziA5KMnxy6+oeK4uHRYdcly1bucv5YGNqFdWPHlgUkcM6HuYLh6xee/Wfs eziA0jeRyyi7lv5PUZE0kPDZX2H79Ga4dxj3urDqS5pz8cvX5u6iPFP1Kb4hr1UUZVXi 1ycqldksm/EuMhzWI3QXZnXN4HeFBMpE13TIib9tzgTyxWEDMgPQM/81FDMrxAHol7RK Y3Mg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-144622-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-144622-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id j4-20020a170903028400b001e0c95a0d66si7752341plr.32.2024.04.14.23.56.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Apr 2024 23:56:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-144622-linux.lists.archive=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=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-144622-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-144622-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 2106D283887 for ; Mon, 15 Apr 2024 06:56:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 29B053BBEB; Mon, 15 Apr 2024 06:54:45 +0000 (UTC) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (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 192923BBCE for ; Mon, 15 Apr 2024 06:54:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.188 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713164084; cv=none; b=MJSzh/WoddbsJt7gAwgr7xTxcz9eOacwVtCtvEAz/IwvrnFOx/LGTmRjrqMi1DN4aj9WEAIU+zn32yGNzJRrgjjuqdBAqR9f21HXLUkNCTFYLRvHW4F2wo48TxcdYC+jSy5JwktG22nLX4iwZdG8Nb4rlAjGXAnwcbAWWbidOUg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713164084; c=relaxed/simple; bh=L8BIW94zJz6w7DHCRiCf2wXwkrC31h4lsroI1eHffbU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nO77gvxr4mgwXlDygOULOEFLA+SYvdiJERiFMpqnlqZCOJOaxA2MJExzOhoe1P5i6ScbqaqcODM1+4tGY+MumkfKtKTnzen6A+Pwaj659bODKWrh+tT+kjXS4MfbzMBTZl1efQjZ/0BjimgbS/8D4GoI9UPhGjGWaMU/HsvsFzA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4VHyYv5H45zYdgf; Mon, 15 Apr 2024 14:53:39 +0800 (CST) Received: from kwepemd200013.china.huawei.com (unknown [7.221.188.133]) by mail.maildlp.com (Postfix) with ESMTPS id 1C60F1400CD; Mon, 15 Apr 2024 14:54:40 +0800 (CST) Received: from huawei.com (10.67.174.28) by kwepemd200013.china.huawei.com (7.221.188.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.28; Mon, 15 Apr 2024 14:54:28 +0800 From: Liao Chang To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , Subject: [PATCH v3 8/8] arm64: kprobe: Keep NMI maskabled while kprobe is stepping xol Date: Mon, 15 Apr 2024 06:47:58 +0000 Message-ID: <20240415064758.3250209-9-liaochang1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240415064758.3250209-1-liaochang1@huawei.com> References: <20240415064758.3250209-1-liaochang1@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemd200013.china.huawei.com (7.221.188.133) Keeping NMI maskable while executing instruction out of line, otherwise, add kprobe on the functions invoken while handling NMI will cause kprobe reenter bug and kernel panic. Signed-off-by: Liao Chang --- arch/arm64/include/asm/daifflags.h | 2 ++ arch/arm64/kernel/probes/kprobes.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/daifflags.h b/arch/arm64/include/asm/daifflags.h index 1196eb85aa8d..60fd3b25fd73 100644 --- a/arch/arm64/include/asm/daifflags.h +++ b/arch/arm64/include/asm/daifflags.h @@ -17,6 +17,8 @@ #define DAIF_PROCCTX_NOIRQ (PSR_I_BIT | PSR_F_BIT) #define DAIF_ERRCTX (PSR_A_BIT | PSR_I_BIT | PSR_F_BIT) #define DAIF_MASK (PSR_D_BIT | PSR_A_BIT | PSR_I_BIT | PSR_F_BIT) +#define DAIF_ALLINT_MASK \ + (system_uses_nmi() ? (ALLINT_ALLINT | DAIF_MASK) : (DAIF_MASK)) /* * For Arm64 processor support Armv8.8 or later, kernel supports three types diff --git a/arch/arm64/kernel/probes/kprobes.c b/arch/arm64/kernel/probes/kprobes.c index 327855a11df2..e8c2b993bbb8 100644 --- a/arch/arm64/kernel/probes/kprobes.c +++ b/arch/arm64/kernel/probes/kprobes.c @@ -187,13 +187,13 @@ static void __kprobes kprobes_save_local_irqflag(struct kprobe_ctlblk *kcb, struct pt_regs *regs) { kcb->saved_irqflag = regs->pstate & DAIF_MASK; - regs->pstate |= DAIF_MASK; + regs->pstate |= DAIF_ALLINT_MASK; } static void __kprobes kprobes_restore_local_irqflag(struct kprobe_ctlblk *kcb, struct pt_regs *regs) { - regs->pstate &= ~DAIF_MASK; + regs->pstate &= ~DAIF_ALLINT_MASK; regs->pstate |= kcb->saved_irqflag; } -- 2.34.1