From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 B046226ED48 for ; Mon, 26 Jan 2026 13:54:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769435679; cv=none; b=JFJ9X6u4EWd/lxRiLLHEAFKkBCVZ+8n+AEtgf+kZTfi5qgvsDqGmnZ8URCKlzlGZeOt5JjBZyuEnmCvGurCvxFXw+Fh6jdqdzhZRQcoke+Oo/Pp/Hca+6ZGLyPTGPd3lQN2bh53aCoX2AE8ylMEFBkdTG0V9a0/de/pfLBEldEA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769435679; c=relaxed/simple; bh=3bppmrs0y2sFBBs5MaDhuIJrWkksAAf5jz94BfVCFPY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=pJ3wRVyAc9c72rqkjrx2HFkctsn1svvlxe/BLNFTxC48qBeVdfT8Aqm22JCXTEEZRhyVq0iGiG8vHKSzOxk60qGjq94dRDJBkZCMfNQoY32APUIrD0KybkvnwCzAKstUFWasad2kBLnLNwt766ToOReNPWQf6WQvCjffwNuavSU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=f3rBpq/F; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="f3rBpq/F" Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 60PMdDwU004938; Mon, 26 Jan 2026 13:54:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=CFcBAl C1i+T83gIDpUoIuODo1IKNZ4kcTdp9hgHYcIg=; b=f3rBpq/FswZ49t2Ddvx8r4 Z898D7vSNsG6ZHROha31Zt+kNIe1K++Z+g+BcUOVKLKWhozxeppPnpzHybgRgxIU YooVBY7NpG9XB2gWBaw3bv+E6LmvYsVDVz7GrGX6hacWhiMX20FviDMSp5WQfxG9 GMON+nWennk9KBXK8Ftjp1xEiAApFUnTJFedK5TJdNS1+rLcQ1VqjSI+iVRvsuTg Q4i7p06FBM4qWz5uCPaxtWL41m7MkcEsTCRI9XSqkHDdwIFmbks9XfHwQCzQc91Y yHdufEXGODVQ9aEu7asDYHDOwkfwuJZRN4SeICPTU/54s4ro8/tWtcWzZAtRhMCg == Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4bvnk6rabm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Jan 2026 13:54:28 +0000 (GMT) Received: from m0360083.ppops.net (m0360083.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 60QDsSWZ029258; Mon, 26 Jan 2026 13:54:28 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4bvnk6rabh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Jan 2026 13:54:28 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 60QAZn9n006741; Mon, 26 Jan 2026 13:54:26 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4bw8sy4v0w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Jan 2026 13:54:26 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 60QDsMRU30474984 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Jan 2026 13:54:22 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A294E20043; Mon, 26 Jan 2026 13:54:22 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9464720040; Mon, 26 Jan 2026 13:54:20 +0000 (GMT) Received: from [9.124.209.168] (unknown [9.124.209.168]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 26 Jan 2026 13:54:20 +0000 (GMT) Message-ID: <26372850-476d-457f-ba97-9119cf81d376@linux.ibm.com> Date: Mon, 26 Jan 2026 19:24:19 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 0/1] powerpc: Fix kuap warnings To: "Christophe Leroy (CS GROUP)" , riteshh@linux.ibm.com Cc: linux-kernel@vger.kernel.org, hbathini@linux.ibm.com, maddy@linux.ibm.com, linuxppc-dev@lists.ozlabs.org, rostedt@goodmis.org, mhiramat@kernel.org, Nicholas Piggin References: <20260109064917.777587-1-sshegde@linux.ibm.com> <336d274e-c831-4af9-ae65-42908b3c2c61@kernel.org> Content-Language: en-US From: Shrikanth Hegde In-Reply-To: <336d274e-c831-4af9-ae65-42908b3c2c61@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 5IyPpdhM0mTH-Fwp-F2uM9U94O3BiEad X-Proofpoint-ORIG-GUID: 5zRq1vsl7zfbSDQk2pUstQDni1W_4SCB X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMTI2MDExNyBTYWx0ZWRfX3Rorn6Dh6jMt 1eZFOUJfw+JQ9cxwsppqfTubxamoM+VI5NCEIaNruxRMxszrGO/jCgasOM7oNnqvdLA1AkPwr0Z 3KmEg3RK5tN65aNVWccbaWCQCCVN3v6cBZrvtDfmC8FCjAjDyB8Pv0WB+WGU5oYJLmbTG5Gxvx9 wB0RMznhcXgSGjkjmRCcI5lDGkxXfZJK4hFJGfoaaW/rv+0BOOr8QT+j/9+r/6uWGhC9jyxNYW4 LHX1/yWPJLbRFQClu4xH/G6y7mR+KA7q3/iIbGHBOjbF+k/NcOqY4zr1hE27S2mh6cwwe2Mw4XU EF8nLDDwnRtoEpWKip19cmypFFOxcYD0YiETJACM2p64S2x0yKtBdmsuPfc+C6kVi9rKkddrN7Z 2mIAeYFAlJDBYRTUwtPJcwNstbhZnxJN63lYal45b58VuKA+nwWIGAwx7Gpen89hOFPNxXTkpHZ yQBcbPgfEoiO1mB3NmQ== X-Authority-Analysis: v=2.4 cv=AMiVTGgp c=1 sm=1 tr=0 ts=69777214 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=IkcTkHD0fZMA:10 a=vUbySO9Y5rIA:10 a=VkNPw1HP01LnGYTKEx00:22 a=ifPovhY8YLxVixpNiMkA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.20,FMLib:17.12.100.49 definitions=2026-01-26_03,2026-01-26_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 spamscore=0 phishscore=0 bulkscore=0 suspectscore=0 adultscore=0 clxscore=1015 priorityscore=1501 lowpriorityscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2601150000 definitions=main-2601260117 Hi Christophe. On 1/9/26 6:24 PM, Christophe Leroy (CS GROUP) wrote: > Hi Shrikanth, > > Le 09/01/2026 à 13:19, Shrikanth Hegde a écrit : >> Hi Christophe. >> >> On 1/9/26 1:41 PM, Christophe Leroy (CS GROUP) wrote: >>> >>> >>> Le 09/01/2026 à 07:49, Shrikanth Hegde a écrit : >>>> Recently stumbled upon these kuap warnings. This happens with >>>> preempt=full/lazy kernel with function tracing enabled. What irked >>>> me was kernel compilation was getting failed when i had tracing >>>> enabled. It doesn't fail everytime. While running stress-ng memory >>>> class >>>> it threw same warnings. So that helped to narrow it down. >>>> So one possible way is to disable tracing for these enter/exit >>>> vmx_usercopy. That seems to fix the bug/warnings. But that will make >>>> them as non trace-able. If there is a better way to fix these >>>> warning while >>>> keeping them as trace-able, please let me know. >>>> >>>> Anyone with insights on amr, vmx and tracing, please advise. >>> >>> The main principle with KUAP is to not call subfunctions once >>> userspace access enabled. There are a few exceptions like >>> __copy_tofrom_user() that are allowed in order to optimise large >>> copies. However this needs to be handled very carefully, and in >>> principle we don't expect __copy_tofrom_user() to call other functions. >>> >> >> I didn't understand. My knowledge is quite limited in this space. >> Could you please explain how this will help us avoid the warnings? >> or are you saying we have more callsites which needs to worked upon. > > Read tools/objtool/Documentation/objtool.txt section "Objtool warning" > item 9. > > Unfortunately powerpc doesn't yet implement objtool to detect it, but > the principle applies anyway. > >> >>> So it might require wider rework but we should narrow as much as >>> possible the period during which access to userspace is opened, with >>> something like: >>> >>> raw_coy_to_user_power7() >>> { >>>      enter_vmx_usercopy(); >> >> I think the problem is when it comes here, it has some AMR state, but >> it is preemptible. So shouldn't call schedule IIUC. > > See commit 00ff1eaac129 ("powerpc: Fix reschedule bug in KUAP-unlocked > user copy") > > The problem is because enter_vmx_usercopy() is called _after_ > allow_write_to_user() which changes AMR. > > If you call enter_vmx_usercopy() _before_ allow_write_to_user() and call > exit_vmx_usercopy() _after_ prevent_write_to_user() the problem is solved. > >> >>>      allow_write_to_user(to, n); >>>      ret = __copy_tofrom_user_power7(); >>>      prevent_write_to_user(to, n); >>>      exit_vmx_usercopy(); >>>      return ret; >>> } >>> >>> raw_copy_to_user() >>> { >>>      if (cpu_has_feature(CPU_FTR_VMX_COPY)) >>>          raw_copy_to_user_power7(); >>> >>>      allow_write_to_user(to, n); >>>      ret = __copy_tofrom_user(to, (__force const void __user *)from, n); >>>      prevent_write_to_user(to, n); >>>      return ret; >>> } >> > Sorry, I forgot to update. I spoke to ritesh a while ago and someone with better knowledge in this area will work on a proper fix for this.