From nobody Tue Nov 26 21:33:22 2024 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 891AD1F6671; Tue, 15 Oct 2024 16:43:32 +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=1729010615; cv=none; b=SFeYefE7mLD9wujKi0Iv9nHfl581b8ReVUewXK6Msix1tUPyfsbQxb/zXCa+FUy4fn8lj7Pvr9CvZjLrLFgjIOmyDFV3QAIdXWlqBWkuIe3SZFOiH3d/MwlGvdMNnULu8WeTPQwuOuOS3pIvRVNUfYlH+pP6n+CGP86xtYgb4Ig= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729010615; c=relaxed/simple; bh=xlPopFefVfTzh69o9E/BNWbjtqQJxBiEWh3waQB4SlE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tfurTDvOfHl4j15XRfmYFFCHXTGLS24ZGLdFdCIk4o65KbC1uthRA9NJhohXMvpstPPEZW2KPhAekJwzLn2jOsaigoy/ba7kAucDv0Y23pYFDNSlQOJyDiS1fM0q/zTyasD+NMeOWXMLxl6JsdeWf4508vn8wM98011Dbm5T4Gg= 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=QZVr+9wJ; 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="QZVr+9wJ" 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 49FEtaab008895; Tue, 15 Oct 2024 16:43:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=SKoxVlqtMbPWGZVFn uh11pMFTdjYbTM30VhHZOK5WO0=; b=QZVr+9wJCKxyW7loJZZsYirx3kodY1+9k Gss3sXIOWIG2A3EWg4DoDWgLF24zKFLOMjCIqRo9UAwe0mlSYs5jBcGHnw6Kjrgd 9QOEHQMnGzg8FW9PgoWg8a73l431sf25M0UjcY8SPgNLXT/nBrF0X1PdIkiIbflS kbNXejfqLi0zaGgob1+Wy68zJ3ACTBZ/vf4fX0iHN4MeC497dZhwO0YtYcTbUrdm /mgKEe8puHpxB5WWoECd8TWaICW+OfNg3c7TVzLfzzymSq9cZUP6cRQTInTRjgqJ RABraT+recVem906rwgGdG4EO35uEW2ZjSo6CUK4EDR1dVSazzH+A== Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 429tk78kab-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Oct 2024 16:43:31 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 49FDfnV1006674; Tue, 15 Oct 2024 16:43:30 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4283erw4bu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Oct 2024 16:43:30 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 49FGhRnu49545566 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Oct 2024 16:43:27 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 044D220040; Tue, 15 Oct 2024 16:43:27 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CFEDC20043; Tue, 15 Oct 2024 16:43:26 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.66]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 15 Oct 2024 16:43:26 +0000 (GMT) From: Claudio Imbrenda To: linux-kernel@vger.kernel.org Cc: borntraeger@de.ibm.com, nsg@linux.ibm.com, nrb@linux.ibm.com, frankja@linux.ibm.com, seiden@linux.ibm.com, hca@linux.ibm.com, agordeev@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, kvm@vger.kernel.org, linux-s390@vger.kernel.org Subject: [PATCH v3 01/11] s390/entry: Remove __GMAP_ASCE and use _PIF_GUEST_FAULT again Date: Tue, 15 Oct 2024 18:43:16 +0200 Message-ID: <20241015164326.124987-2-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241015164326.124987-1-imbrenda@linux.ibm.com> References: <20241015164326.124987-1-imbrenda@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: PT-XzVbdbjTznskM3dklUHzluxo81Wud X-Proofpoint-GUID: PT-XzVbdbjTznskM3dklUHzluxo81Wud X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=585 spamscore=0 lowpriorityscore=0 impostorscore=0 priorityscore=1501 bulkscore=0 clxscore=1015 malwarescore=0 phishscore=0 adultscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410150113 Content-Type: text/plain; charset="utf-8" Now that the guest ASCE is passed as a parameter to __sie64a(), _PIF_GUEST_FAULT can be used again to determine whether the fault was a guest or host fault. Since the guest ASCE will not be taken from the gmap pointer in lowcore anymore, __GMAP_ASCE can be removed. For the same reason the guest ASCE needs now to be saved into the cr1 save area unconditionally. Signed-off-by: Claudio Imbrenda Acked-by: Janosch Frank Reviewed-by: Heiko Carstens --- arch/s390/include/asm/ptrace.h | 2 ++ arch/s390/kernel/asm-offsets.c | 2 -- arch/s390/kernel/entry.S | 26 ++++++++++++++------------ arch/s390/mm/fault.c | 6 ++---- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/arch/s390/include/asm/ptrace.h b/arch/s390/include/asm/ptrace.h index 2ad9324f6338..788bc4467445 100644 --- a/arch/s390/include/asm/ptrace.h +++ b/arch/s390/include/asm/ptrace.h @@ -14,11 +14,13 @@ #define PIF_SYSCALL 0 /* inside a system call */ #define PIF_EXECVE_PGSTE_RESTART 1 /* restart execve for PGSTE binaries */ #define PIF_SYSCALL_RET_SET 2 /* return value was set via ptrace */ +#define PIF_GUEST_FAULT 3 /* indicates program check in sie64a */ #define PIF_FTRACE_FULL_REGS 4 /* all register contents valid (ftrace) */ =20 #define _PIF_SYSCALL BIT(PIF_SYSCALL) #define _PIF_EXECVE_PGSTE_RESTART BIT(PIF_EXECVE_PGSTE_RESTART) #define _PIF_SYSCALL_RET_SET BIT(PIF_SYSCALL_RET_SET) +#define _PIF_GUEST_FAULT BIT(PIF_GUEST_FAULT) #define _PIF_FTRACE_FULL_REGS BIT(PIF_FTRACE_FULL_REGS) =20 #define PSW32_MASK_PER _AC(0x40000000, UL) diff --git a/arch/s390/kernel/asm-offsets.c b/arch/s390/kernel/asm-offsets.c index 5529248d84fb..3a6ee5043761 100644 --- a/arch/s390/kernel/asm-offsets.c +++ b/arch/s390/kernel/asm-offsets.c @@ -13,7 +13,6 @@ #include #include #include -#include #include =20 int main(void) @@ -161,7 +160,6 @@ int main(void) OFFSET(__LC_PGM_TDB, lowcore, pgm_tdb); BLANK(); /* gmap/sie offsets */ - OFFSET(__GMAP_ASCE, gmap, asce); OFFSET(__SIE_PROG0C, kvm_s390_sie_block, prog0c); OFFSET(__SIE_PROG20, kvm_s390_sie_block, prog20); /* kexec_sha_region */ diff --git a/arch/s390/kernel/entry.S b/arch/s390/kernel/entry.S index d6d5317f768e..454841229ef4 100644 --- a/arch/s390/kernel/entry.S +++ b/arch/s390/kernel/entry.S @@ -327,13 +327,23 @@ SYM_CODE_START(pgm_check_handler) GET_LC %r13 stpt __LC_SYS_ENTER_TIMER(%r13) BPOFF - lgr %r10,%r15 lmg %r8,%r9,__LC_PGM_OLD_PSW(%r13) + xgr %r10,%r10 + xgr %r12,%r12 tmhh %r8,0x0001 # coming from user space? jno .Lpgm_skip_asce lctlg %c1,%c1,__LC_KERNEL_ASCE(%r13) j 3f # -> fault in user space .Lpgm_skip_asce: +#if IS_ENABLED(CONFIG_KVM) + lg %r11,__LC_CURRENT(%r13) + tm __TI_sie(%r11),0xff + jz 1f + BPENTER __SF_SIE_FLAGS(%r15),_TIF_ISOLATE_BP_GUEST + SIEEXIT __SF_SIE_CONTROL(%r15),%r13 + lg %r12,__SF_SIE_GUEST_ASCE(%r15) + lghi %r10,_PIF_GUEST_FAULT +#endif 1: tmhh %r8,0x4000 # PER bit set in old PSW ? jnz 2f # -> enabled, can't be a double fault tm __LC_PGM_ILC+3(%r13),0x80 # check for per exception @@ -344,21 +354,13 @@ SYM_CODE_START(pgm_check_handler) CHECK_VMAP_STACK __LC_SAVE_AREA,%r13,4f 3: lg %r15,__LC_KERNEL_STACK(%r13) 4: la %r11,STACK_FRAME_OVERHEAD(%r15) - xc __PT_FLAGS(8,%r11),__PT_FLAGS(%r11) + stg %r10,__PT_FLAGS(%r11) + stg %r12,__PT_CR1(%r11) xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15) stmg %r0,%r7,__PT_R0(%r11) mvc __PT_R8(64,%r11),__LC_SAVE_AREA(%r13) mvc __PT_LAST_BREAK(8,%r11),__LC_PGM_LAST_BREAK(%r13) - stctg %c1,%c1,__PT_CR1(%r11) -#if IS_ENABLED(CONFIG_KVM) - ltg %r12,__LC_GMAP(%r13) - jz 5f - clc __GMAP_ASCE(8,%r12), __PT_CR1(%r11) - jne 5f - BPENTER __SF_SIE_FLAGS(%r10),_TIF_ISOLATE_BP_GUEST - SIEEXIT __SF_SIE_CONTROL(%r10),%r13 -#endif -5: stmg %r8,%r9,__PT_PSW(%r11) + stmg %r8,%r9,__PT_PSW(%r11) # clear user controlled registers to prevent speculative use xgr %r0,%r0 xgr %r1,%r1 diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c index ad8b0d6b77ea..a6cf33b0f339 100644 --- a/arch/s390/mm/fault.c +++ b/arch/s390/mm/fault.c @@ -68,15 +68,13 @@ early_initcall(fault_init); static enum fault_type get_fault_type(struct pt_regs *regs) { union teid teid =3D { .val =3D regs->int_parm_long }; - struct gmap *gmap; =20 if (likely(teid.as =3D=3D PSW_BITS_AS_PRIMARY)) { if (user_mode(regs)) return USER_FAULT; if (!IS_ENABLED(CONFIG_PGSTE)) return KERNEL_FAULT; - gmap =3D (struct gmap *)get_lowcore()->gmap; - if (gmap && gmap->asce =3D=3D regs->cr1) + if (test_pt_regs_flag(regs, PIF_GUEST_FAULT)) return GMAP_FAULT; return KERNEL_FAULT; } @@ -187,7 +185,7 @@ static void dump_fault_info(struct pt_regs *regs) pr_cont("user "); break; case GMAP_FAULT: - asce =3D ((struct gmap *)get_lowcore()->gmap)->asce; + asce =3D regs->cr1; pr_cont("gmap "); break; case KERNEL_FAULT: --=20 2.47.0 From nobody Tue Nov 26 21:33:22 2024 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 419641F76A5; Tue, 15 Oct 2024 16:43:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729010616; cv=none; b=K/ai+jrAytGME2cZ1dC1DZTopJr4e2USx4+D7hf7FGMOpuPXXNO6D6Epm7VM9tj42uKegJD1JAV/KRXWrLHjsesrQhSWs7AO1z+wTzo9qd1CqfnsOYNhGIregHQ4vxWw4qgSTTyxLPohhiMS4QTZRiQrYd1FeVOl7PR+v/y4bMA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729010616; c=relaxed/simple; bh=QQvuMDB3i+1hQRxxMhfrS1fUCS2QiWa5R5FPahhxnCQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rDjGTa8IGHxkVvDE1oARLmFPSvu4HHVvN6bx0rTadfGrY3r3/veZBkS2M9Qf6ogUpQe4PX6/Ejl3iEgO36XdpuUbN0ly1cVMdkA0coFC33YqHEwLtqLXWdoKcwaLtFjK5p0L5j3fA7hA/VJeAzKkiEi61rc7jiut0tTCa5Kh7jg= 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=LMl3GBR8; arc=none smtp.client-ip=148.163.158.5 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="LMl3GBR8" Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49FDJiNC008390; Tue, 15 Oct 2024 16:43:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=smPbVVUTPeubekiFB 5BI/e3FMoGPpsz1X34wv6nlTYY=; b=LMl3GBR8domXCMBHAciEKRP09HA8QXCLf 6HFOUuVWx3NyW6gFv0jLaYy68JEkdGitXcSBNXhK+IRimXh64AcwhTnkyu95Touo 4Q37rh1AhZC4mIfdPzHbh/gbC8NepJKceTUORDqR4gg2/b6m9kvSL5cxr+3CYvIk wiERo9htE7TITErxtICKg7oOMSawOBTzMXXWO54b3HG0pM8pFkLwgMhbTTYwC6St 5Olwe0HajogZ6+TB7eHMr6w8y+GnflAqmSvPFXkLm3oO00H4KSItmE/JxAghW+/6 k3zW24QhaEah1WVH+HMrWA/A7qZ3TQNHxMUOQnLTvtXXbMcrToWtQ== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 429s68h427-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Oct 2024 16:43:31 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 49FE4dMF001991; Tue, 15 Oct 2024 16:43:31 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4284emmxav-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Oct 2024 16:43:30 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 49FGhRsF49545568 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Oct 2024 16:43:27 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 316C520040; Tue, 15 Oct 2024 16:43:27 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0952A2004B; Tue, 15 Oct 2024 16:43:27 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.66]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 15 Oct 2024 16:43:26 +0000 (GMT) From: Claudio Imbrenda To: linux-kernel@vger.kernel.org Cc: borntraeger@de.ibm.com, nsg@linux.ibm.com, nrb@linux.ibm.com, frankja@linux.ibm.com, seiden@linux.ibm.com, hca@linux.ibm.com, agordeev@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, kvm@vger.kernel.org, linux-s390@vger.kernel.org Subject: [PATCH v3 02/11] s390/kvm: Remove kvm_arch_fault_in_page() Date: Tue, 15 Oct 2024 18:43:17 +0200 Message-ID: <20241015164326.124987-3-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241015164326.124987-1-imbrenda@linux.ibm.com> References: <20241015164326.124987-1-imbrenda@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: fcOfuIXcB3I3Ax0CZ2Xalrx8EV9U60P3 X-Proofpoint-ORIG-GUID: fcOfuIXcB3I3Ax0CZ2Xalrx8EV9U60P3 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 phishscore=0 clxscore=1015 malwarescore=0 suspectscore=0 lowpriorityscore=0 mlxlogscore=999 adultscore=0 mlxscore=0 priorityscore=1501 bulkscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410150113 Content-Type: text/plain; charset="utf-8" kvm_arch_fault_in_page() is a useless wrapper around gmap_fault(); just use gmap_fault() directly instead. Signed-off-by: Claudio Imbrenda Reviewed-by: Janosch Frank --- arch/s390/kvm/intercept.c | 4 ++-- arch/s390/kvm/kvm-s390.c | 18 +----------------- arch/s390/kvm/kvm-s390.h | 1 - 3 files changed, 3 insertions(+), 20 deletions(-) diff --git a/arch/s390/kvm/intercept.c b/arch/s390/kvm/intercept.c index b16352083ff9..5bbaadf75dc6 100644 --- a/arch/s390/kvm/intercept.c +++ b/arch/s390/kvm/intercept.c @@ -367,7 +367,7 @@ static int handle_mvpg_pei(struct kvm_vcpu *vcpu) reg2, &srcaddr, GACC_FETCH, 0); if (rc) return kvm_s390_inject_prog_cond(vcpu, rc); - rc =3D kvm_arch_fault_in_page(vcpu, srcaddr, 0); + rc =3D gmap_fault(vcpu->arch.gmap, srcaddr, 0); if (rc !=3D 0) return rc; =20 @@ -376,7 +376,7 @@ static int handle_mvpg_pei(struct kvm_vcpu *vcpu) reg1, &dstaddr, GACC_STORE, 0); if (rc) return kvm_s390_inject_prog_cond(vcpu, rc); - rc =3D kvm_arch_fault_in_page(vcpu, dstaddr, 1); + rc =3D gmap_fault(vcpu->arch.gmap, dstaddr, FAULT_FLAG_WRITE); if (rc !=3D 0) return rc; =20 diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index bb7134faaebf..08f0c80ef5e9 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -4579,22 +4579,6 @@ int kvm_s390_try_set_tod_clock(struct kvm *kvm, cons= t struct kvm_s390_vm_tod_clo return 1; } =20 -/** - * kvm_arch_fault_in_page - fault-in guest page if necessary - * @vcpu: The corresponding virtual cpu - * @gpa: Guest physical address - * @writable: Whether the page should be writable or not - * - * Make sure that a guest page has been faulted-in on the host. - * - * Return: Zero on success, negative error code otherwise. - */ -long kvm_arch_fault_in_page(struct kvm_vcpu *vcpu, gpa_t gpa, int writable) -{ - return gmap_fault(vcpu->arch.gmap, gpa, - writable ? FAULT_FLAG_WRITE : 0); -} - static void __kvm_inject_pfault_token(struct kvm_vcpu *vcpu, bool start_to= ken, unsigned long token) { @@ -4797,7 +4781,7 @@ static int vcpu_post_run(struct kvm_vcpu *vcpu, int e= xit_reason) if (kvm_arch_setup_async_pf(vcpu)) return 0; vcpu->stat.pfault_sync++; - return kvm_arch_fault_in_page(vcpu, current->thread.gmap_addr, 1); + return gmap_fault(vcpu->arch.gmap, current->thread.gmap_addr, FAULT_FLAG= _WRITE); } return vcpu_post_run_fault_in_sie(vcpu); } diff --git a/arch/s390/kvm/kvm-s390.h b/arch/s390/kvm/kvm-s390.h index e680c6bf0c9d..0765ad1031c4 100644 --- a/arch/s390/kvm/kvm-s390.h +++ b/arch/s390/kvm/kvm-s390.h @@ -394,7 +394,6 @@ int kvm_s390_handle_sigp_pei(struct kvm_vcpu *vcpu); =20 /* implemented in kvm-s390.c */ int kvm_s390_try_set_tod_clock(struct kvm *kvm, const struct kvm_s390_vm_t= od_clock *gtod); -long kvm_arch_fault_in_page(struct kvm_vcpu *vcpu, gpa_t gpa, int writable= ); int kvm_s390_store_status_unloaded(struct kvm_vcpu *vcpu, unsigned long ad= dr); int kvm_s390_vcpu_store_status(struct kvm_vcpu *vcpu, unsigned long addr); int kvm_s390_vcpu_start(struct kvm_vcpu *vcpu); --=20 2.47.0 From nobody Tue Nov 26 21:33:22 2024 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 D948D1F76A4; Tue, 15 Oct 2024 16:43:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729010614; cv=none; b=ZsP1EFEtusUq4zsgu42JBD/TJvXtJ0oxxbVHHiNAJZ7zCHVIRYroeDfn7K8a/tY5aXGGIv7o7eHhO3yHWXmQEuVmVdpmccHg2OTRXKqrNuxMeZiwjXaFFAXJwoc6R5FGjrmFZx0ngeYRcs8gSF43MPEJC4xF6lrcUAM+6NpIDhE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729010614; c=relaxed/simple; bh=RduEoIU1ARqtEVM45IeWsmXgTlFn3jgCk19IW6wVi28=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qzawW5cQG/UA8dEdJhCtWYgyM3pJp494Pdh6T6LnwYPt86HwcoTefoVQGu3ljoDdK57jxSPga0h0Y5WGRi3nlNVz9R8A4k4cIvKx2+IIE68XQ2Gve7a0aPt7tXTz/70Yi8fNOfjA+qQ+JQ+G/BRQHBv0oi3Q9SJWa1FAONvuP1U= 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=Ln4Nvwdw; arc=none smtp.client-ip=148.163.158.5 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="Ln4Nvwdw" Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49FDJXxg007780; Tue, 15 Oct 2024 16:43:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=bywVcVF2riD6xid7c 0CPDJxkC3BTdenBYLP4Al5LcPQ=; b=Ln4NvwdwsWQEyMXks9Fwr9D/Sq/VB8BYa g6l/seJXPC2DqSg9ouxyGTIv2tqAUlAFyJGLgELU/lxl4ZYEVKHvZtZkC7vU728z z3ETZ4dwkM/xzwGrFXaPC1GQ4VMVqPXRJupp0+E1dOUhIx+Xz+3QdafSsXaOOgiN vRJ/IEIgYoqTNcQn/wucc6YayXnPj9VGfYjtXiCmo1uoeYdjvBntkPr6K8IhD+En TcE3rFNAHGQhSXTHiVzaHcmvsSIKa2ig6TOj4utq86pOyJDRN2NhZqTYsFTVkfjc oQd6gOG6nvCT3pDJfDeMeq3P9H2zo8kEDGhvWQ0quwpDqlq8CzNGA== Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 429s68h424-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Oct 2024 16:43:31 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 49FDoZI3006714; Tue, 15 Oct 2024 16:43:30 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4283erw4bw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Oct 2024 16:43:30 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 49FGhRGY49545570 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Oct 2024 16:43:27 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5D9BB20040; Tue, 15 Oct 2024 16:43:27 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 36DE620043; Tue, 15 Oct 2024 16:43:27 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.66]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 15 Oct 2024 16:43:27 +0000 (GMT) From: Claudio Imbrenda To: linux-kernel@vger.kernel.org Cc: borntraeger@de.ibm.com, nsg@linux.ibm.com, nrb@linux.ibm.com, frankja@linux.ibm.com, seiden@linux.ibm.com, hca@linux.ibm.com, agordeev@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, kvm@vger.kernel.org, linux-s390@vger.kernel.org Subject: [PATCH v3 03/11] s390/mm/gmap: Refactor gmap_fault() and add support for pfault Date: Tue, 15 Oct 2024 18:43:18 +0200 Message-ID: <20241015164326.124987-4-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241015164326.124987-1-imbrenda@linux.ibm.com> References: <20241015164326.124987-1-imbrenda@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: GCnQJhRIBaJqnCV4V8nw9FXw21eE_aN6 X-Proofpoint-ORIG-GUID: GCnQJhRIBaJqnCV4V8nw9FXw21eE_aN6 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 phishscore=0 clxscore=1015 malwarescore=0 suspectscore=0 lowpriorityscore=0 mlxlogscore=782 adultscore=0 mlxscore=0 priorityscore=1501 bulkscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410150113 Content-Type: text/plain; charset="utf-8" When specifying FAULT_FLAG_RETRY_NOWAIT as flag for gmap_fault(), the gmap fault will be processed only if it can be resolved quickly and without sleeping. This will be needed for pfault. Refactor gmap_fault() to improve readability. Signed-off-by: Claudio Imbrenda Acked-by: Alexander Gordeev Reviewed-by: Heiko Carstens --- arch/s390/mm/gmap.c | 119 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 100 insertions(+), 19 deletions(-) diff --git a/arch/s390/mm/gmap.c b/arch/s390/mm/gmap.c index eb0b51a36be0..f51ad948ba53 100644 --- a/arch/s390/mm/gmap.c +++ b/arch/s390/mm/gmap.c @@ -637,44 +637,125 @@ int __gmap_link(struct gmap *gmap, unsigned long gad= dr, unsigned long vmaddr) } =20 /** - * gmap_fault - resolve a fault on a guest address + * fixup_user_fault_nowait - manually resolve a user page fault without wa= iting + * @mm: mm_struct of target mm + * @address: user address + * @fault_flags:flags to pass down to handle_mm_fault() + * @unlocked: did we unlock the mmap_lock while retrying + * + * This function behaves similarly to fixup_user_fault(), but it guarantees + * that the fault will be resolved without waiting. The function might drop + * and re-acquire the mm lock, in which case @unlocked will be set to true. + * + * The guarantee is that the fault is handled without waiting, but the + * function itself might sleep, due to the lock. + * + * Context: Needs to be called with mm->mmap_lock held in read mode, and w= ill + * return with the lock held in read mode; @unlocked will indicate whether + * the lock has been dropped and re-acquired. This is the same behaviour as + * fixup_user_fault(). + * + * Return: 0 on success, -EAGAIN if the fault cannot be resolved without + * waiting, -EFAULT if the fault cannot be resolved, -ENOMEM if out of + * memory. + */ +static int fixup_user_fault_nowait(struct mm_struct *mm, unsigned long add= ress, + unsigned int fault_flags, bool *unlocked) +{ + struct vm_area_struct *vma; + unsigned int test_flags; + vm_fault_t fault; + int rc; + + fault_flags |=3D FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_RETRY_NOWAIT; + test_flags =3D fault_flags & FAULT_FLAG_WRITE ? VM_WRITE : VM_READ; + + vma =3D find_vma(mm, address); + if (unlikely(!vma || address < vma->vm_start)) + return -EFAULT; + if (unlikely(!(vma->vm_flags & test_flags))) + return -EFAULT; + + fault =3D handle_mm_fault(vma, address, fault_flags, NULL); + /* the mm lock has been dropped, take it again */ + if (fault & VM_FAULT_COMPLETED) { + *unlocked =3D true; + mmap_read_lock(mm); + return 0; + } + /* the mm lock has not been dropped */ + if (fault & VM_FAULT_ERROR) { + rc =3D vm_fault_to_errno(fault, 0); + BUG_ON(!rc); + return rc; + } + /* the mm lock has not been dropped because of FAULT_FLAG_RETRY_NOWAIT */ + if (fault & VM_FAULT_RETRY) + return -EAGAIN; + /* nothing needed to be done and the mm lock has not been dropped */ + return 0; +} + +/** + * __gmap_fault - resolve a fault on a guest address * @gmap: pointer to guest mapping meta data structure * @gaddr: guest address * @fault_flags: flags to pass down to handle_mm_fault() * - * Returns 0 on success, -ENOMEM for out of memory conditions, and -EFAULT - * if the vm address is already mapped to a different guest segment. + * Context: Needs to be called with mm->mmap_lock held in read mode. Might + * drop and re-acquire the lock. Will always return with the lock held. */ -int gmap_fault(struct gmap *gmap, unsigned long gaddr, - unsigned int fault_flags) +static int __gmap_fault(struct gmap *gmap, unsigned long gaddr, unsigned i= nt fault_flags) { unsigned long vmaddr; - int rc; bool unlocked; - - mmap_read_lock(gmap->mm); + int rc =3D 0; =20 retry: unlocked =3D false; + vmaddr =3D __gmap_translate(gmap, gaddr); - if (IS_ERR_VALUE(vmaddr)) { - rc =3D vmaddr; - goto out_up; - } - if (fixup_user_fault(gmap->mm, vmaddr, fault_flags, - &unlocked)) { - rc =3D -EFAULT; - goto out_up; + if (IS_ERR_VALUE(vmaddr)) + return vmaddr; + + if (fault_flags & FAULT_FLAG_RETRY_NOWAIT) { + rc =3D fixup_user_fault_nowait(gmap->mm, vmaddr, fault_flags, &unlocked); + if (rc) + return rc; + } else if (fixup_user_fault(gmap->mm, vmaddr, fault_flags, &unlocked)) { + return -EFAULT; } /* * In the case that fixup_user_fault unlocked the mmap_lock during - * faultin redo __gmap_translate to not race with a map/unmap_segment. + * fault-in, redo __gmap_translate() to avoid racing with a + * map/unmap_segment. + * In particular, __gmap_translate(), fixup_user_fault{,_nowait}(), + * and __gmap_link() must all be called atomically in one go; if the + * lock had been dropped in between, a retry is needed. */ if (unlocked) goto retry; =20 - rc =3D __gmap_link(gmap, gaddr, vmaddr); -out_up: + return __gmap_link(gmap, gaddr, vmaddr); +} + +/** + * gmap_fault - resolve a fault on a guest address + * @gmap: pointer to guest mapping meta data structure + * @gaddr: guest address + * @fault_flags: flags to pass down to handle_mm_fault() + * + * Returns 0 on success, -ENOMEM for out of memory conditions, -EFAULT if = the + * vm address is already mapped to a different guest segment, and -EAGAIN = if + * FAULT_FLAG_RETRY_NOWAIT was specified and the fault could not be proces= sed + * immediately. + */ +int gmap_fault(struct gmap *gmap, unsigned long gaddr, unsigned int fault_= flags) +{ + int rc; + + mmap_read_lock(gmap->mm); + rc =3D __gmap_fault(gmap, gaddr, fault_flags); mmap_read_unlock(gmap->mm); return rc; } --=20 2.47.0 From nobody Tue Nov 26 21:33:22 2024 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 419C31F76A7; Tue, 15 Oct 2024 16:43:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729010614; cv=none; b=i0cdiDfkI/OWdKCOzNzByIksRYzM1zihNt3cA7YJn9nHFynGWSZ2O0xbK35bWuc218vGBLX6aNjahQBlvvLnBYjhLvPbiGSBJsJR2dtAa7K27RWMwdE406pbwBAflF0oUqV7a+MGFdgxkm2B92+/TYmlyGNbXq+SVj6ho3EXxjU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729010614; c=relaxed/simple; bh=Y5FMepZoxGiJrpODOM+3gyu4NwjOwdk0gHSXaMccSD8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=d3ILuzsooD28XqCikxJcYz6LdwmbAGvGOd07VULc5qCNkKWcgUPo3Q3SJmtjRV/4X9R7/HoiTR9gxjaHNcbFS3ivfqOJnOXVL02YKd8CUfISA2qRa/fSs9z5DHsalJdynuzbdabGao0LMrXqVNL4xJ1RQVXlDS8AS0n01I+j+0E= 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=NaQV5n5L; arc=none smtp.client-ip=148.163.158.5 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="NaQV5n5L" Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49FGJKV3013131; Tue, 15 Oct 2024 16:43:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=QyY9neWltee04QluT O2GfGfyxlN0Z79eG6W6IJi/hzg=; b=NaQV5n5LAZ02Gj/UE7x6gSAZWstwqV/4M x2s0dka6P95zYr7p4LUJMF581LiUZpe7Gf/x4mvUtelVVaGz9o2i54i2xEh7zI26 VLYBFwclzBxGHOdDsm4S05u2uL7Gt2xNFEbp5mEj4ncYL+ZP1h33j8efE9ThdKcK DtYuLzDTjjqFwe0FEA56igV/5EP4OTz3It1XinZAKZR+KeIfFWLFxCrOLZo+lUf5 E9G2pFp2FpCPAd+6Spx+3M5IW4/jLvH5CNRhkB9tyrZgObYXTRIZuCYCeGPvxwpg wqipFWwfO+a7UFp2eHWq7//0pptV3DMnBm6bAsNWK83FVC2nc70nQ== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 429utbr4bx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Oct 2024 16:43:31 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 49FETmgR002343; Tue, 15 Oct 2024 16:43:31 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4284emmxaw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Oct 2024 16:43:31 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 49FGhRV049545572 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Oct 2024 16:43:27 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8944B20043; Tue, 15 Oct 2024 16:43:27 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 62D452004B; Tue, 15 Oct 2024 16:43:27 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.66]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 15 Oct 2024 16:43:27 +0000 (GMT) From: Claudio Imbrenda To: linux-kernel@vger.kernel.org Cc: borntraeger@de.ibm.com, nsg@linux.ibm.com, nrb@linux.ibm.com, frankja@linux.ibm.com, seiden@linux.ibm.com, hca@linux.ibm.com, agordeev@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, kvm@vger.kernel.org, linux-s390@vger.kernel.org Subject: [PATCH v3 04/11] s390/mm/gmap: Fix __gmap_fault() return code Date: Tue, 15 Oct 2024 18:43:19 +0200 Message-ID: <20241015164326.124987-5-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241015164326.124987-1-imbrenda@linux.ibm.com> References: <20241015164326.124987-1-imbrenda@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 6KGM_ShUI_rpT1Nt2Dbmnp8f0fq4cdyD X-Proofpoint-ORIG-GUID: 6KGM_ShUI_rpT1Nt2Dbmnp8f0fq4cdyD X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 clxscore=1015 suspectscore=0 phishscore=0 impostorscore=0 mlxscore=0 spamscore=0 bulkscore=0 lowpriorityscore=0 priorityscore=1501 mlxlogscore=896 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410150113 Content-Type: text/plain; charset="utf-8" Errors in fixup_user_fault() were masked and -EFAULT was returned for any error, including out of memory. Fix this by returning the correct error code. This means that in many cases the error code will be propagated all the way to userspace. Suggested-by: Heiko Carstens Signed-off-by: Claudio Imbrenda Reviewed-by: Heiko Carstens Acked-by: Alexander Gordeev --- arch/s390/mm/gmap.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/arch/s390/mm/gmap.c b/arch/s390/mm/gmap.c index f51ad948ba53..a8746f71c679 100644 --- a/arch/s390/mm/gmap.c +++ b/arch/s390/mm/gmap.c @@ -718,13 +718,12 @@ static int __gmap_fault(struct gmap *gmap, unsigned l= ong gaddr, unsigned int fau if (IS_ERR_VALUE(vmaddr)) return vmaddr; =20 - if (fault_flags & FAULT_FLAG_RETRY_NOWAIT) { + if (fault_flags & FAULT_FLAG_RETRY_NOWAIT) rc =3D fixup_user_fault_nowait(gmap->mm, vmaddr, fault_flags, &unlocked); - if (rc) - return rc; - } else if (fixup_user_fault(gmap->mm, vmaddr, fault_flags, &unlocked)) { - return -EFAULT; - } + else + rc =3D fixup_user_fault(gmap->mm, vmaddr, fault_flags, &unlocked); + if (rc) + return rc; /* * In the case that fixup_user_fault unlocked the mmap_lock during * fault-in, redo __gmap_translate() to avoid racing with a --=20 2.47.0 From nobody Tue Nov 26 21:33:22 2024 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 3F5131F76AF; Tue, 15 Oct 2024 16:43:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729010616; cv=none; b=GpS+oq42Mq7CekX0qOcIxjuMQ9w7gDYGHldsLdJwjV+M7yl4Dqw0d0NTRolLK2VeXDGRF5nQneXwWRdKPS7CgPX809+OQTlpKFyTT4gOqoOZLm2ebdw0Lsg9DZj0RmmEFqLHe55PdaywEBrjCVVvkXyDVUPF7TMz2RRNB60CPc0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729010616; c=relaxed/simple; bh=4RZHkD/NMld5kwpvWmYSzfZX84FVCy70N4g3rhDy0YM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RLPdv4fgTwRwiiYXdqBnljNSN7VTbyR0mKq00HDgJucUtqEV/LHdQYiiiif0XnJPfjdbk526J5nnIulYMZLzYeot5cvnBOWJ1cZQMPXOGvyKb+TG0NDymp5etZDDxPJ1EG9fImhxydA5oCVlA0/DH90xgIHqViWEM4cHB7P9oA0= 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=WOmJyNX4; arc=none smtp.client-ip=148.163.158.5 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="WOmJyNX4" Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49FDJljK008413; Tue, 15 Oct 2024 16:43:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=T58twZObNsWgOydiw mzOuHwP+2qwudqIpsSuKSB+BdM=; b=WOmJyNX4zwfCY523QscXwgAY+Vf2KgYUv 48Y4oWeTYU14CV33pBM2id0x8vB7fF+iSGvK+fwfZOYQM0ObbMSP5HGW3wEWKrum Td2gVv4fjikVp9I6gRYFMtS8alF1G8OofyIGD0dJ1ZBOrYY4yqGthAbaGD7n6g6D spJgFIW2WUfshyTYRqkaExR0si49r26YrxBkKevN202hHyITvXvK+S8+eY2MKmWx hof7H67GkaXBCBDhx4qSrjaHP4lnOiXMp5GDysywxFz4TjPqhaSiVgpJacfF5NTA GI05LlhTgBUmVu7GxZETwsVYUMR1sKDsUsQ4MJcG9Y/Pxz3V4sTTw== 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 429s68h428-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Oct 2024 16:43:32 +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 49FEMcuW027451; Tue, 15 Oct 2024 16:43:31 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4283txn026-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Oct 2024 16:43:31 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 49FGhRMe49545574 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Oct 2024 16:43:28 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C887520043; Tue, 15 Oct 2024 16:43:27 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8F42020040; Tue, 15 Oct 2024 16:43:27 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.66]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 15 Oct 2024 16:43:27 +0000 (GMT) From: Claudio Imbrenda To: linux-kernel@vger.kernel.org Cc: borntraeger@de.ibm.com, nsg@linux.ibm.com, nrb@linux.ibm.com, frankja@linux.ibm.com, seiden@linux.ibm.com, hca@linux.ibm.com, agordeev@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, kvm@vger.kernel.org, linux-s390@vger.kernel.org Subject: [PATCH v3 05/11] s390/mm/fault: Handle guest-related program interrupts in KVM Date: Tue, 15 Oct 2024 18:43:20 +0200 Message-ID: <20241015164326.124987-6-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241015164326.124987-1-imbrenda@linux.ibm.com> References: <20241015164326.124987-1-imbrenda@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: waekeJLRl87e-dDq8h8EyCnc2aTEHBgI X-Proofpoint-ORIG-GUID: waekeJLRl87e-dDq8h8EyCnc2aTEHBgI X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 phishscore=0 clxscore=1015 malwarescore=0 suspectscore=0 lowpriorityscore=0 mlxlogscore=999 adultscore=0 mlxscore=0 priorityscore=1501 bulkscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410150113 Content-Type: text/plain; charset="utf-8" Any program interrupt that happens in the host during the execution of a KVM guest will now short circuit the fault handler and return to KVM immediately. Guest fault handling (including pfault) will happen entirely inside KVM. When sie64a() returns zero, current->thread.gmap_int_code will contain the program interrupt number that caused the exit, or zero if the exit was not caused by a host program interrupt. KVM will now take care of handling all guest faults in vcpu_post_run(). Since gmap faults will not be visible by the rest of the kernel, remove GMAP_FAULT, the linux fault handlers for secure execution faults, the exception table entries for the sie instruction, the nop padding after the sie instruction, and all other references to guest faults from the s390 code. Signed-off-by: Claudio Imbrenda Co-developed-by: Heiko Carstens Signed-off-by: Heiko Carstens [agordeev@linux.ibm.com: remove spurious flags &=3D ~FAULT_FLAG_RETRY_NOWAI= T] --- arch/s390/include/asm/kvm_host.h | 3 + arch/s390/include/asm/processor.h | 5 +- arch/s390/kernel/entry.S | 22 ------ arch/s390/kernel/traps.c | 23 ++++-- arch/s390/kvm/kvm-s390.c | 116 ++++++++++++++++++++++++------ arch/s390/kvm/kvm-s390.h | 7 ++ arch/s390/kvm/vsie.c | 13 ++-- arch/s390/mm/fault.c | 99 +------------------------ 8 files changed, 132 insertions(+), 156 deletions(-) diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_h= ost.h index 8e77afbed58e..603b56bfccd3 100644 --- a/arch/s390/include/asm/kvm_host.h +++ b/arch/s390/include/asm/kvm_host.h @@ -527,6 +527,9 @@ struct kvm_vcpu_stat { #define PGM_REGION_FIRST_TRANS 0x39 #define PGM_REGION_SECOND_TRANS 0x3a #define PGM_REGION_THIRD_TRANS 0x3b +#define PGM_SECURE_STORAGE_ACCESS 0x3d +#define PGM_NON_SECURE_STORAGE_ACCESS 0x3e +#define PGM_SECURE_STORAGE_VIOLATION 0x3f #define PGM_MONITOR 0x40 #define PGM_PER 0x80 #define PGM_CRYPTO_OPERATION 0x119 diff --git a/arch/s390/include/asm/processor.h b/arch/s390/include/asm/proc= essor.h index 9a5236acc0a8..8761fd01a9f0 100644 --- a/arch/s390/include/asm/processor.h +++ b/arch/s390/include/asm/processor.h @@ -39,6 +39,7 @@ #include #include #include +#include =20 struct pcpu { unsigned long ec_mask; /* bit mask for ec_xxx functions */ @@ -187,10 +188,8 @@ struct thread_struct { unsigned long hardirq_timer; /* task cputime in hardirq context */ unsigned long softirq_timer; /* task cputime in softirq context */ const sys_call_ptr_t *sys_call_table; /* system call table address */ - unsigned long gmap_addr; /* address of last gmap fault. */ - unsigned int gmap_write_flag; /* gmap fault write indication */ + union teid gmap_teid; /* address and flags of last gmap fault */ unsigned int gmap_int_code; /* int code of last gmap fault */ - unsigned int gmap_pfault; /* signal of a pending guest pfault */ int ufpu_flags; /* user fpu flags */ int kfpu_flags; /* kernel fpu flags */ =20 diff --git a/arch/s390/kernel/entry.S b/arch/s390/kernel/entry.S index 454841229ef4..924bcb71a33f 100644 --- a/arch/s390/kernel/entry.S +++ b/arch/s390/kernel/entry.S @@ -222,17 +222,6 @@ SYM_FUNC_START(__sie64a) lctlg %c1,%c1,__LC_KERNEL_ASCE(%r14) # load primary asce lg %r14,__LC_CURRENT(%r14) mvi __TI_sie(%r14),0 -# some program checks are suppressing. C code (e.g. do_protection_exceptio= n) -# will rewind the PSW by the ILC, which is often 4 bytes in case of SIE. T= here -# are some corner cases (e.g. runtime instrumentation) where ILC is unpred= ictable. -# Other instructions between __sie64a and .Lsie_done should not cause prog= ram -# interrupts. So lets use 3 nops as a landing pad for all possible rewinds. -.Lrewind_pad6: - nopr 7 -.Lrewind_pad4: - nopr 7 -.Lrewind_pad2: - nopr 7 SYM_INNER_LABEL(sie_exit, SYM_L_GLOBAL) lg %r14,__SF_SIE_SAVEAREA(%r15) # load guest register save area stmg %r0,%r13,0(%r14) # save guest gprs 0-13 @@ -244,15 +233,6 @@ SYM_INNER_LABEL(sie_exit, SYM_L_GLOBAL) lmg %r6,%r14,__SF_GPRS(%r15) # restore kernel registers lg %r2,__SF_SIE_REASON(%r15) # return exit reason code BR_EX %r14 -.Lsie_fault: - lghi %r14,-EFAULT - stg %r14,__SF_SIE_REASON(%r15) # set exit reason code - j sie_exit - - EX_TABLE(.Lrewind_pad6,.Lsie_fault) - EX_TABLE(.Lrewind_pad4,.Lsie_fault) - EX_TABLE(.Lrewind_pad2,.Lsie_fault) - EX_TABLE(sie_exit,.Lsie_fault) SYM_FUNC_END(__sie64a) EXPORT_SYMBOL(__sie64a) EXPORT_SYMBOL(sie_exit) @@ -341,7 +321,6 @@ SYM_CODE_START(pgm_check_handler) jz 1f BPENTER __SF_SIE_FLAGS(%r15),_TIF_ISOLATE_BP_GUEST SIEEXIT __SF_SIE_CONTROL(%r15),%r13 - lg %r12,__SF_SIE_GUEST_ASCE(%r15) lghi %r10,_PIF_GUEST_FAULT #endif 1: tmhh %r8,0x4000 # PER bit set in old PSW ? @@ -355,7 +334,6 @@ SYM_CODE_START(pgm_check_handler) 3: lg %r15,__LC_KERNEL_STACK(%r13) 4: la %r11,STACK_FRAME_OVERHEAD(%r15) stg %r10,__PT_FLAGS(%r11) - stg %r12,__PT_CR1(%r11) xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15) stmg %r0,%r7,__PT_R0(%r11) mvc __PT_R8(64,%r11),__LC_SAVE_AREA(%r13) diff --git a/arch/s390/kernel/traps.c b/arch/s390/kernel/traps.c index 160b2acba8db..f5e978dfe5bf 100644 --- a/arch/s390/kernel/traps.c +++ b/arch/s390/kernel/traps.c @@ -31,6 +31,7 @@ #include #include #include +#include #include "entry.h" =20 static inline void __user *get_trap_ip(struct pt_regs *regs) @@ -317,9 +318,23 @@ void noinstr __do_pgm_check(struct pt_regs *regs) struct lowcore *lc =3D get_lowcore(); irqentry_state_t state; unsigned int trapnr; + union teid teid =3D { .val =3D lc->trans_exc_code }; =20 regs->int_code =3D lc->pgm_int_code; - regs->int_parm_long =3D lc->trans_exc_code; + regs->int_parm_long =3D teid.val; + + /* + * In case of a guest fault, short-circuit the fault handler and return. + * This way the sie64a() function will return 0; fault address and + * other relevant bits are saved in current->thread.gmap_teid, and + * the fault number in current->thread.gmap_int_code. KVM will be + * able to use this information to handle the fault. + */ + if (test_pt_regs_flag(regs, PIF_GUEST_FAULT) && (teid.as =3D=3D PSW_BITS_= AS_PRIMARY)) { + current->thread.gmap_teid.val =3D regs->int_parm_long; + current->thread.gmap_int_code =3D regs->int_code & 0xffff; + return; + } =20 state =3D irqentry_enter(regs); =20 @@ -408,8 +423,8 @@ static void (*pgm_check_table[128])(struct pt_regs *reg= s) =3D { [0x3b] =3D do_dat_exception, [0x3c] =3D default_trap_handler, [0x3d] =3D do_secure_storage_access, - [0x3e] =3D do_non_secure_storage_access, - [0x3f] =3D do_secure_storage_violation, + [0x3e] =3D default_trap_handler, + [0x3f] =3D default_trap_handler, [0x40] =3D monitor_event_exception, [0x41 ... 0x7f] =3D default_trap_handler, }; @@ -420,5 +435,3 @@ static void (*pgm_check_table[128])(struct pt_regs *reg= s) =3D { __stringify(default_trap_handler)) =20 COND_TRAP(do_secure_storage_access); -COND_TRAP(do_non_secure_storage_access); -COND_TRAP(do_secure_storage_violation); diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index 08f0c80ef5e9..cfe3f8182aa5 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -4646,12 +4646,11 @@ static bool kvm_arch_setup_async_pf(struct kvm_vcpu= *vcpu) if (!vcpu->arch.gmap->pfault_enabled) return false; =20 - hva =3D gfn_to_hva(vcpu->kvm, gpa_to_gfn(current->thread.gmap_addr)); - hva +=3D current->thread.gmap_addr & ~PAGE_MASK; + hva =3D gfn_to_hva(vcpu->kvm, current->thread.gmap_teid.addr); if (read_guest_real(vcpu, vcpu->arch.pfault_token, &arch.pfault_token, 8)) return false; =20 - return kvm_setup_async_pf(vcpu, current->thread.gmap_addr, hva, &arch); + return kvm_setup_async_pf(vcpu, current->thread.gmap_teid.addr * PAGE_SIZ= E, hva, &arch); } =20 static int vcpu_pre_run(struct kvm_vcpu *vcpu) @@ -4689,6 +4688,7 @@ static int vcpu_pre_run(struct kvm_vcpu *vcpu) clear_bit(vcpu->vcpu_idx, vcpu->kvm->arch.gisa_int.kicked_mask); =20 vcpu->arch.sie_block->icptcode =3D 0; + current->thread.gmap_int_code =3D 0; cpuflags =3D atomic_read(&vcpu->arch.sie_block->cpuflags); VCPU_EVENT(vcpu, 6, "entering sie flags %x", cpuflags); trace_kvm_s390_sie_enter(vcpu, cpuflags); @@ -4696,7 +4696,7 @@ static int vcpu_pre_run(struct kvm_vcpu *vcpu) return 0; } =20 -static int vcpu_post_run_fault_in_sie(struct kvm_vcpu *vcpu) +static int vcpu_post_run_addressing_exception(struct kvm_vcpu *vcpu) { struct kvm_s390_pgm_info pgm_info =3D { .code =3D PGM_ADDRESSING, @@ -4732,10 +4732,97 @@ static int vcpu_post_run_fault_in_sie(struct kvm_vc= pu *vcpu) return kvm_s390_inject_prog_irq(vcpu, &pgm_info); } =20 +static int vcpu_post_run_handle_fault(struct kvm_vcpu *vcpu) +{ + unsigned long gaddr; + unsigned int flags; + int rc =3D 0; + + gaddr =3D current->thread.gmap_teid.addr * PAGE_SIZE; + if (kvm_s390_cur_gmap_fault_is_write()) + flags =3D FAULT_FLAG_WRITE; + + switch (current->thread.gmap_int_code) { + case 0: + vcpu->stat.exit_null++; + break; + case PGM_NON_SECURE_STORAGE_ACCESS: + /* + * This is normal operation; a page belonging to a protected + * guest has not been imported yet. Try to import the page into + * the protected guest. + */ + if (gmap_convert_to_secure(vcpu->arch.gmap, gaddr) =3D=3D -EINVAL) + send_sig(SIGSEGV, current, 0); + break; + case PGM_SECURE_STORAGE_ACCESS: + case PGM_SECURE_STORAGE_VIOLATION: + /* + * This can happen after a reboot with asynchronous teardown; + * the new guest (normal or protected) will run on top of the + * previous protected guest. The old pages need to be destroyed + * so the new guest can use them. + */ + if (gmap_destroy_page(vcpu->arch.gmap, gaddr)) { + /* + * Either KVM messed up the secure guest mapping or the + * same page is mapped into multiple secure guests. + * + * This exception is only triggered when a guest 2 is + * running and can therefore never occur in kernel + * context. + */ + pr_warn_ratelimited("Secure storage violation (%x) in task: %s, pid %d\= n", + current->thread.gmap_int_code, current->comm, + current->pid); + send_sig(SIGSEGV, current, 0); + } + break; + case PGM_PROTECTION: + case PGM_SEGMENT_TRANSLATION: + case PGM_PAGE_TRANSLATION: + case PGM_ASCE_TYPE: + case PGM_REGION_FIRST_TRANS: + case PGM_REGION_SECOND_TRANS: + case PGM_REGION_THIRD_TRANS: + if (vcpu->arch.gmap->pfault_enabled) { + rc =3D gmap_fault(vcpu->arch.gmap, gaddr, flags | FAULT_FLAG_RETRY_NOWA= IT); + if (rc =3D=3D -EFAULT) + return vcpu_post_run_addressing_exception(vcpu); + if (rc =3D=3D -EAGAIN) { + trace_kvm_s390_major_guest_pfault(vcpu); + if (kvm_arch_setup_async_pf(vcpu)) + return 0; + vcpu->stat.pfault_sync++; + } else { + return rc; + } + } + rc =3D gmap_fault(vcpu->arch.gmap, gaddr, flags); + if (rc =3D=3D -EFAULT) { + if (kvm_is_ucontrol(vcpu->kvm)) { + vcpu->run->exit_reason =3D KVM_EXIT_S390_UCONTROL; + vcpu->run->s390_ucontrol.trans_exc_code =3D gaddr; + vcpu->run->s390_ucontrol.pgm_code =3D 0x10; + return -EREMOTE; + } + return vcpu_post_run_addressing_exception(vcpu); + } + break; + default: + KVM_BUG(1, vcpu->kvm, "Unexpected program interrupt 0x%x, TEID 0x%016lx", + current->thread.gmap_int_code, current->thread.gmap_teid.val); + send_sig(SIGSEGV, current, 0); + break; + } + return rc; +} + static int vcpu_post_run(struct kvm_vcpu *vcpu, int exit_reason) { struct mcck_volatile_info *mcck_info; struct sie_page *sie_page; + int rc; =20 VCPU_EVENT(vcpu, 6, "exit sie icptcode %d", vcpu->arch.sie_block->icptcode); @@ -4757,7 +4844,7 @@ static int vcpu_post_run(struct kvm_vcpu *vcpu, int e= xit_reason) } =20 if (vcpu->arch.sie_block->icptcode > 0) { - int rc =3D kvm_handle_sie_intercept(vcpu); + rc =3D kvm_handle_sie_intercept(vcpu); =20 if (rc !=3D -EOPNOTSUPP) return rc; @@ -4766,24 +4853,9 @@ static int vcpu_post_run(struct kvm_vcpu *vcpu, int = exit_reason) vcpu->run->s390_sieic.ipa =3D vcpu->arch.sie_block->ipa; vcpu->run->s390_sieic.ipb =3D vcpu->arch.sie_block->ipb; return -EREMOTE; - } else if (exit_reason !=3D -EFAULT) { - vcpu->stat.exit_null++; - return 0; - } else if (kvm_is_ucontrol(vcpu->kvm)) { - vcpu->run->exit_reason =3D KVM_EXIT_S390_UCONTROL; - vcpu->run->s390_ucontrol.trans_exc_code =3D - current->thread.gmap_addr; - vcpu->run->s390_ucontrol.pgm_code =3D 0x10; - return -EREMOTE; - } else if (current->thread.gmap_pfault) { - trace_kvm_s390_major_guest_pfault(vcpu); - current->thread.gmap_pfault =3D 0; - if (kvm_arch_setup_async_pf(vcpu)) - return 0; - vcpu->stat.pfault_sync++; - return gmap_fault(vcpu->arch.gmap, current->thread.gmap_addr, FAULT_FLAG= _WRITE); } - return vcpu_post_run_fault_in_sie(vcpu); + + return vcpu_post_run_handle_fault(vcpu); } =20 #define PSW_INT_MASK (PSW_MASK_EXT | PSW_MASK_IO | PSW_MASK_MCHECK) diff --git a/arch/s390/kvm/kvm-s390.h b/arch/s390/kvm/kvm-s390.h index 0765ad1031c4..597d7a71deeb 100644 --- a/arch/s390/kvm/kvm-s390.h +++ b/arch/s390/kvm/kvm-s390.h @@ -528,6 +528,13 @@ static inline int kvm_s390_use_sca_entries(void) void kvm_s390_reinject_machine_check(struct kvm_vcpu *vcpu, struct mcck_volatile_info *mcck_info); =20 +static inline bool kvm_s390_cur_gmap_fault_is_write(void) +{ + if (current->thread.gmap_int_code =3D=3D PGM_PROTECTION) + return true; + return test_facility(75) && (current->thread.gmap_teid.fsi =3D=3D TEID_FS= I_STORE); +} + /** * kvm_s390_vcpu_crypto_reset_all * diff --git a/arch/s390/kvm/vsie.c b/arch/s390/kvm/vsie.c index 89cafea4c41f..35e7dd882148 100644 --- a/arch/s390/kvm/vsie.c +++ b/arch/s390/kvm/vsie.c @@ -925,16 +925,16 @@ static int handle_fault(struct kvm_vcpu *vcpu, struct= vsie_page *vsie_page) if (current->thread.gmap_int_code =3D=3D PGM_PROTECTION) /* we can directly forward all protection exceptions */ return inject_fault(vcpu, PGM_PROTECTION, - current->thread.gmap_addr, 1); + current->thread.gmap_teid.addr * PAGE_SIZE, 1); =20 rc =3D kvm_s390_shadow_fault(vcpu, vsie_page->gmap, - current->thread.gmap_addr, NULL); + current->thread.gmap_teid.addr * PAGE_SIZE, NULL); if (rc > 0) { rc =3D inject_fault(vcpu, rc, - current->thread.gmap_addr, - current->thread.gmap_write_flag); + current->thread.gmap_teid.addr * PAGE_SIZE, + kvm_s390_cur_gmap_fault_is_write()); if (rc >=3D 0) - vsie_page->fault_addr =3D current->thread.gmap_addr; + vsie_page->fault_addr =3D current->thread.gmap_teid.addr * PAGE_SIZE; } return rc; } @@ -1148,6 +1148,7 @@ static int do_vsie_run(struct kvm_vcpu *vcpu, struct = vsie_page *vsie_page) * also kick the vSIE. */ vcpu->arch.sie_block->prog0c |=3D PROG_IN_SIE; + current->thread.gmap_int_code =3D 0; barrier(); if (!kvm_s390_vcpu_sie_inhibited(vcpu)) rc =3D sie64a(scb_s, vcpu->run->s.regs.gprs, gmap_get_enabled()->asce); @@ -1172,7 +1173,7 @@ static int do_vsie_run(struct kvm_vcpu *vcpu, struct = vsie_page *vsie_page) =20 if (rc > 0) rc =3D 0; /* we could still have an icpt */ - else if (rc =3D=3D -EFAULT) + else if (current->thread.gmap_int_code) return handle_fault(vcpu, vsie_page); =20 switch (scb_s->icptcode) { diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c index a6cf33b0f339..e48910b0b816 100644 --- a/arch/s390/mm/fault.c +++ b/arch/s390/mm/fault.c @@ -49,7 +49,6 @@ enum fault_type { KERNEL_FAULT, USER_FAULT, - GMAP_FAULT, }; =20 static DEFINE_STATIC_KEY_FALSE(have_store_indication); @@ -72,10 +71,6 @@ static enum fault_type get_fault_type(struct pt_regs *re= gs) if (likely(teid.as =3D=3D PSW_BITS_AS_PRIMARY)) { if (user_mode(regs)) return USER_FAULT; - if (!IS_ENABLED(CONFIG_PGSTE)) - return KERNEL_FAULT; - if (test_pt_regs_flag(regs, PIF_GUEST_FAULT)) - return GMAP_FAULT; return KERNEL_FAULT; } if (teid.as =3D=3D PSW_BITS_AS_SECONDARY) @@ -184,10 +179,6 @@ static void dump_fault_info(struct pt_regs *regs) asce =3D get_lowcore()->user_asce.val; pr_cont("user "); break; - case GMAP_FAULT: - asce =3D regs->cr1; - pr_cont("gmap "); - break; case KERNEL_FAULT: asce =3D get_lowcore()->kernel_asce.val; pr_cont("kernel "); @@ -285,7 +276,6 @@ static void do_exception(struct pt_regs *regs, int acce= ss) struct mm_struct *mm; enum fault_type type; unsigned int flags; - struct gmap *gmap; vm_fault_t fault; bool is_write; =20 @@ -304,7 +294,6 @@ static void do_exception(struct pt_regs *regs, int acce= ss) case KERNEL_FAULT: return handle_fault_error_nolock(regs, 0); case USER_FAULT: - case GMAP_FAULT: if (faulthandler_disabled() || !mm) return handle_fault_error_nolock(regs, 0); break; @@ -348,18 +337,6 @@ static void do_exception(struct pt_regs *regs, int acc= ess) } lock_mmap: mmap_read_lock(mm); - gmap =3D NULL; - if (IS_ENABLED(CONFIG_PGSTE) && type =3D=3D GMAP_FAULT) { - gmap =3D (struct gmap *)get_lowcore()->gmap; - current->thread.gmap_addr =3D address; - current->thread.gmap_write_flag =3D !!(flags & FAULT_FLAG_WRITE); - current->thread.gmap_int_code =3D regs->int_code & 0xffff; - address =3D __gmap_translate(gmap, address); - if (address =3D=3D -EFAULT) - return handle_fault_error(regs, SEGV_MAPERR); - if (gmap->pfault_enabled) - flags |=3D FAULT_FLAG_RETRY_NOWAIT; - } retry: vma =3D find_vma(mm, address); if (!vma) @@ -375,50 +352,22 @@ static void do_exception(struct pt_regs *regs, int ac= cess) return handle_fault_error(regs, SEGV_ACCERR); fault =3D handle_mm_fault(vma, address, flags, regs); if (fault_signal_pending(fault, regs)) { - if (flags & FAULT_FLAG_RETRY_NOWAIT) - mmap_read_unlock(mm); if (!user_mode(regs)) handle_fault_error_nolock(regs, 0); return; } /* The fault is fully completed (including releasing mmap lock) */ - if (fault & VM_FAULT_COMPLETED) { - if (gmap) { - mmap_read_lock(mm); - goto gmap; - } + if (fault & VM_FAULT_COMPLETED) return; - } if (unlikely(fault & VM_FAULT_ERROR)) { mmap_read_unlock(mm); goto error; } if (fault & VM_FAULT_RETRY) { - if (IS_ENABLED(CONFIG_PGSTE) && gmap && (flags & FAULT_FLAG_RETRY_NOWAIT= )) { - /* - * FAULT_FLAG_RETRY_NOWAIT has been set, - * mmap_lock has not been released - */ - current->thread.gmap_pfault =3D 1; - return handle_fault_error(regs, 0); - } - flags &=3D ~FAULT_FLAG_RETRY_NOWAIT; flags |=3D FAULT_FLAG_TRIED; mmap_read_lock(mm); goto retry; } -gmap: - if (IS_ENABLED(CONFIG_PGSTE) && gmap) { - address =3D __gmap_link(gmap, current->thread.gmap_addr, - address); - if (address =3D=3D -EFAULT) - return handle_fault_error(regs, SEGV_MAPERR); - if (address =3D=3D -ENOMEM) { - fault =3D VM_FAULT_OOM; - mmap_read_unlock(mm); - goto error; - } - } mmap_read_unlock(mm); return; error: @@ -494,7 +443,6 @@ void do_secure_storage_access(struct pt_regs *regs) struct folio_walk fw; struct mm_struct *mm; struct folio *folio; - struct gmap *gmap; int rc; =20 /* @@ -520,15 +468,6 @@ void do_secure_storage_access(struct pt_regs *regs) panic("Unexpected PGM 0x3d with TEID bit 61=3D0"); } switch (get_fault_type(regs)) { - case GMAP_FAULT: - mm =3D current->mm; - gmap =3D (struct gmap *)get_lowcore()->gmap; - mmap_read_lock(mm); - addr =3D __gmap_translate(gmap, addr); - mmap_read_unlock(mm); - if (IS_ERR_VALUE(addr)) - return handle_fault_error_nolock(regs, SEGV_MAPERR); - fallthrough; case USER_FAULT: mm =3D current->mm; mmap_read_lock(mm); @@ -564,40 +503,4 @@ void do_secure_storage_access(struct pt_regs *regs) } NOKPROBE_SYMBOL(do_secure_storage_access); =20 -void do_non_secure_storage_access(struct pt_regs *regs) -{ - struct gmap *gmap =3D (struct gmap *)get_lowcore()->gmap; - unsigned long gaddr =3D get_fault_address(regs); - - if (WARN_ON_ONCE(get_fault_type(regs) !=3D GMAP_FAULT)) - return handle_fault_error_nolock(regs, SEGV_MAPERR); - if (gmap_convert_to_secure(gmap, gaddr) =3D=3D -EINVAL) - send_sig(SIGSEGV, current, 0); -} -NOKPROBE_SYMBOL(do_non_secure_storage_access); - -void do_secure_storage_violation(struct pt_regs *regs) -{ - struct gmap *gmap =3D (struct gmap *)get_lowcore()->gmap; - unsigned long gaddr =3D get_fault_address(regs); - - /* - * If the VM has been rebooted, its address space might still contain - * secure pages from the previous boot. - * Clear the page so it can be reused. - */ - if (!gmap_destroy_page(gmap, gaddr)) - return; - /* - * Either KVM messed up the secure guest mapping or the same - * page is mapped into multiple secure guests. - * - * This exception is only triggered when a guest 2 is running - * and can therefore never occur in kernel context. - */ - pr_warn_ratelimited("Secure storage violation in task: %s, pid %d\n", - current->comm, current->pid); - send_sig(SIGSEGV, current, 0); -} - #endif /* CONFIG_PGSTE */ --=20 2.47.0 From nobody Tue Nov 26 21:33:22 2024 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 990CB1F76AC; Tue, 15 Oct 2024 16:43:33 +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=1729010615; cv=none; b=GhvCE7W4iUB3lFKG0Iy8ethaKp+dyyCTsO4QkrysEwaiCQcyJU9nGPKVI94wu42CVVUw/6HtrcV4OSLDd2ChM9i34gUK3qt3B5pj4Kil2xU+HSIvKJcxj1A6ROg0HM/cRLovcMYyJ8+VemeoQzwqgAWN35fFANF5K2qUmd/3Wks= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729010615; c=relaxed/simple; bh=kT4zk9z21wrdHKXfV1g/GKAsZZM+f6ovKFhpjkJtAb0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F1WmBh28SeVtCHPNlPLRq1KpCIWVjl73csZ3pmtn+FZMQtxAzk8yLS2u7etFrrdxlhGYtMZVJigyQtXdX+gJJM5TBtq3mqMLfLi5jNRX9BsWyO5tyjul39JXfl4sAiWsTykepF1qpmd0Qp+3WIgIHUE34bZeAAAzBl3ZttaDD80= 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=Rxg1s+TK; 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="Rxg1s+TK" Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49FGQYvF019569; Tue, 15 Oct 2024 16:43:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=ISMevC/t9VZZMZv48 gp/v+tTh8H+6JLghhUezTk6Boc=; b=Rxg1s+TKFMw8soUzgolZvehM0vHB/VwCd vRGk0TZtt/w4VSlpctmu1AwYtY+DWLy7HgRASbAa7rlgf0tY1bI8pn/lCqC6x19y 3IesLetLTZTJSDnVUIK92hhWWTEJI0pISWZ1GpyIsCnJsrl0zuDXLKAssozJ1I5E T0xDSgch33qt8x/e9qAOETT8+BgUneUIQwGneX017q5KlSOfcqGt3Q3ixcoBS+TA PwLgzRw3VQjX5ubFjYit7w8TuYCxWuJgY6PMZPqJnkz27MW0cz5nHG+ESteSFnWt IdetM6wdyv0QVUSv7RDkPlxL1FKk0Ht9XXZH0I0oaQzVYT/cqjdvg== Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 429uwjg2gc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Oct 2024 16:43:32 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 49FDfnV2006674; Tue, 15 Oct 2024 16:43:31 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4283erw4c0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Oct 2024 16:43:31 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 49FGhSwN50069772 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Oct 2024 16:43:28 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 00B9720040; Tue, 15 Oct 2024 16:43:28 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CDC572004B; Tue, 15 Oct 2024 16:43:27 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.66]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 15 Oct 2024 16:43:27 +0000 (GMT) From: Claudio Imbrenda To: linux-kernel@vger.kernel.org Cc: borntraeger@de.ibm.com, nsg@linux.ibm.com, nrb@linux.ibm.com, frankja@linux.ibm.com, seiden@linux.ibm.com, hca@linux.ibm.com, agordeev@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, kvm@vger.kernel.org, linux-s390@vger.kernel.org Subject: [PATCH v3 06/11] s390/kvm: Stop using gmap_{en,dis}able() Date: Tue, 15 Oct 2024 18:43:21 +0200 Message-ID: <20241015164326.124987-7-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241015164326.124987-1-imbrenda@linux.ibm.com> References: <20241015164326.124987-1-imbrenda@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 4uhVyAa4UzdxKKO3uM6y5Drv81cT-m-L X-Proofpoint-ORIG-GUID: 4uhVyAa4UzdxKKO3uM6y5Drv81cT-m-L X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 mlxlogscore=489 adultscore=0 clxscore=1015 mlxscore=0 phishscore=0 bulkscore=0 spamscore=0 lowpriorityscore=0 malwarescore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410150113 Content-Type: text/plain; charset="utf-8" Stop using gmap_enable(), gmap_disable(), gmap_get_enabled(). The correct guest ASCE is passed as a parameter of sie64a(), there is no need to save the current gmap in lowcore. Signed-off-by: Claudio Imbrenda Acked-by: Steffen Eiden Reviewed-by: Heiko Carstens --- arch/s390/kvm/kvm-s390.c | 7 +------ arch/s390/kvm/vsie.c | 4 +--- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index cfe3f8182aa5..df778a4a011d 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -3719,7 +3719,6 @@ __u64 kvm_s390_get_cpu_timer(struct kvm_vcpu *vcpu) void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) { =20 - gmap_enable(vcpu->arch.enabled_gmap); kvm_s390_set_cpuflags(vcpu, CPUSTAT_RUNNING); if (vcpu->arch.cputm_enabled && !is_vcpu_idle(vcpu)) __start_cpu_timer_accounting(vcpu); @@ -3732,8 +3731,6 @@ void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu) if (vcpu->arch.cputm_enabled && !is_vcpu_idle(vcpu)) __stop_cpu_timer_accounting(vcpu); kvm_s390_clear_cpuflags(vcpu, CPUSTAT_RUNNING); - vcpu->arch.enabled_gmap =3D gmap_get_enabled(); - gmap_disable(vcpu->arch.enabled_gmap); =20 } =20 @@ -3751,8 +3748,6 @@ void kvm_arch_vcpu_postcreate(struct kvm_vcpu *vcpu) } if (test_kvm_facility(vcpu->kvm, 74) || vcpu->kvm->arch.user_instr0) vcpu->arch.sie_block->ictl |=3D ICTL_OPEREXC; - /* make vcpu_load load the right gmap on the first trigger */ - vcpu->arch.enabled_gmap =3D vcpu->arch.gmap; } =20 static bool kvm_has_pckmo_subfunc(struct kvm *kvm, unsigned long nr) @@ -4891,7 +4886,7 @@ static int __vcpu_run(struct kvm_vcpu *vcpu) } exit_reason =3D sie64a(vcpu->arch.sie_block, vcpu->run->s.regs.gprs, - gmap_get_enabled()->asce); + vcpu->arch.gmap->asce); if (kvm_s390_pv_cpu_is_protected(vcpu)) { memcpy(vcpu->run->s.regs.gprs, sie_page->pv_grregs, diff --git a/arch/s390/kvm/vsie.c b/arch/s390/kvm/vsie.c index 35e7dd882148..d03f95e528fe 100644 --- a/arch/s390/kvm/vsie.c +++ b/arch/s390/kvm/vsie.c @@ -1151,7 +1151,7 @@ static int do_vsie_run(struct kvm_vcpu *vcpu, struct = vsie_page *vsie_page) current->thread.gmap_int_code =3D 0; barrier(); if (!kvm_s390_vcpu_sie_inhibited(vcpu)) - rc =3D sie64a(scb_s, vcpu->run->s.regs.gprs, gmap_get_enabled()->asce); + rc =3D sie64a(scb_s, vcpu->run->s.regs.gprs, vsie_page->gmap->asce); barrier(); vcpu->arch.sie_block->prog0c &=3D ~PROG_IN_SIE; =20 @@ -1296,10 +1296,8 @@ static int vsie_run(struct kvm_vcpu *vcpu, struct vs= ie_page *vsie_page) if (!rc) rc =3D map_prefix(vcpu, vsie_page); if (!rc) { - gmap_enable(vsie_page->gmap); update_intervention_requests(vsie_page); rc =3D do_vsie_run(vcpu, vsie_page); - gmap_enable(vcpu->arch.gmap); } atomic_andnot(PROG_BLOCK_SIE, &scb_s->prog20); =20 --=20 2.47.0 From nobody Tue Nov 26 21:33:22 2024 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 08EDB1F76AE; Tue, 15 Oct 2024 16:43:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729010615; cv=none; b=AP4KJDnA/tS2xxxbDXJB6FygcFYxOC0/VfgGp7Ja0jpYaEPvC6Fp/nqSlsryYlrcZuvzYiS6dj6Qp789F44OCq9ZSiJtMCHQ/0dOM4yn9xnYH1AfK8KNFaLh4wMa+/tZaNb8lQ5nvR78H9KbBdwCbxnxFSNN++9AXzBGlFyU/eM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729010615; c=relaxed/simple; bh=28wM1qxewzfvNwL0+ykl/a4jcDIEgRX7sG0DD0vn/No=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JozlzrUnrbwM21xaEzoeN2g7+L/oqIsjjnur6TqjM5kAKJQCi0JFDlDSLfAls5ZOwTwk+ZqMmjCF6Et5WfRxeNFYQ9oSgHK6l74aTgcWjO6TcBcZx1iJA4FkhbdE8v/eZ7cOg7bWQWnQfTkfwXbEW3iYHvHrSVGAvMDbMwiKAdU= 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=emPyMtaD; arc=none smtp.client-ip=148.163.158.5 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="emPyMtaD" Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49FFoU9Y031440; Tue, 15 Oct 2024 16:43:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=SJpHHEjRWzFGDQeMj OuxfSFN2DEbe/pb15pnfE0bjyU=; b=emPyMtaDaNsXav3wxcUSHnTstBDPxgwBh jUX7D2y5/xrYKQ/1jDWktrJ3j1RSTLqmJq1HA8DxzKYzoOGVkN7DyI/1TqdllbYl eh7hYq6yN8h3R/JoKMnl4EgyFDMJdL7AadvbNTfHeo6uZCwUnUEMg8/ec7Ri8PB1 aeDBMFfuhRithmogR+0HLE9XD/frdcYgSSmEpMeWQ4l0Af/HF2943MQCtgUtUc0z DZQoz7B39MFP9Q2XZWDjP8mdG+DkczxlCxZmjJt7WLKQzOvJ39iiqDDtifp/9RQI DfrvfE3tByWNN+0NvNQbivNpvUxuIbSRcboTEs+6nkMIzjDLI8Bzw== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 429ucwg8kx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Oct 2024 16:43:32 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 49FE7Vka002473; Tue, 15 Oct 2024 16:43:32 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4284emmxax-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Oct 2024 16:43:32 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 49FGhSpM50069774 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Oct 2024 16:43:28 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2DFF420043; Tue, 15 Oct 2024 16:43:28 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 064CA2004E; Tue, 15 Oct 2024 16:43:28 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.66]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 15 Oct 2024 16:43:27 +0000 (GMT) From: Claudio Imbrenda To: linux-kernel@vger.kernel.org Cc: borntraeger@de.ibm.com, nsg@linux.ibm.com, nrb@linux.ibm.com, frankja@linux.ibm.com, seiden@linux.ibm.com, hca@linux.ibm.com, agordeev@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, kvm@vger.kernel.org, linux-s390@vger.kernel.org Subject: [PATCH v3 07/11] s390/mm/gmap: Remove gmap_{en,dis}able() Date: Tue, 15 Oct 2024 18:43:22 +0200 Message-ID: <20241015164326.124987-8-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241015164326.124987-1-imbrenda@linux.ibm.com> References: <20241015164326.124987-1-imbrenda@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: Qi8ezuG3vi0fDN5plE30qjHRTkb9RQBY X-Proofpoint-GUID: Qi8ezuG3vi0fDN5plE30qjHRTkb9RQBY X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 malwarescore=0 mlxlogscore=801 spamscore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 suspectscore=0 bulkscore=0 adultscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410150113 Content-Type: text/plain; charset="utf-8" Remove gmap_enable(), gmap_disable(), and gmap_get_enabled() since they do not have any users anymore. Suggested-by: Heiko Carstens Signed-off-by: Claudio Imbrenda Reviewed-by: Heiko Carstens --- arch/s390/include/asm/gmap.h | 3 --- arch/s390/mm/gmap.c | 31 ------------------------------- 2 files changed, 34 deletions(-) diff --git a/arch/s390/include/asm/gmap.h b/arch/s390/include/asm/gmap.h index 9725586f4259..64761c78f774 100644 --- a/arch/s390/include/asm/gmap.h +++ b/arch/s390/include/asm/gmap.h @@ -107,9 +107,6 @@ void gmap_remove(struct gmap *gmap); struct gmap *gmap_get(struct gmap *gmap); void gmap_put(struct gmap *gmap); =20 -void gmap_enable(struct gmap *gmap); -void gmap_disable(struct gmap *gmap); -struct gmap *gmap_get_enabled(void); int gmap_map_segment(struct gmap *gmap, unsigned long from, unsigned long to, unsigned long len); int gmap_unmap_segment(struct gmap *gmap, unsigned long to, unsigned long = len); diff --git a/arch/s390/mm/gmap.c b/arch/s390/mm/gmap.c index a8746f71c679..329682655af2 100644 --- a/arch/s390/mm/gmap.c +++ b/arch/s390/mm/gmap.c @@ -281,37 +281,6 @@ void gmap_remove(struct gmap *gmap) } EXPORT_SYMBOL_GPL(gmap_remove); =20 -/** - * gmap_enable - switch primary space to the guest address space - * @gmap: pointer to the guest address space structure - */ -void gmap_enable(struct gmap *gmap) -{ - get_lowcore()->gmap =3D (unsigned long)gmap; -} -EXPORT_SYMBOL_GPL(gmap_enable); - -/** - * gmap_disable - switch back to the standard primary address space - * @gmap: pointer to the guest address space structure - */ -void gmap_disable(struct gmap *gmap) -{ - get_lowcore()->gmap =3D 0UL; -} -EXPORT_SYMBOL_GPL(gmap_disable); - -/** - * gmap_get_enabled - get a pointer to the currently enabled gmap - * - * Returns a pointer to the currently enabled gmap. 0 if none is enabled. - */ -struct gmap *gmap_get_enabled(void) -{ - return (struct gmap *)get_lowcore()->gmap; -} -EXPORT_SYMBOL_GPL(gmap_get_enabled); - /* * gmap_alloc_table is assumed to be called with mmap_lock held */ --=20 2.47.0 From nobody Tue Nov 26 21:33:22 2024 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 419AF1F76B1; Tue, 15 Oct 2024 16:43:34 +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=1729010615; cv=none; b=bfFbEOOLrJqUSssuW4fpcd52NOq7DoH2FwYCD5+21yrntCIP54drI/1kwL1OMITxlDEPP2Rr3FfZzwoK7W7Nf6fZoD0tMb9wEEbgnt/U9ODmHgryJUAVF59MR3A+8KHe/UTdNLqRz9Dfn3/6SDraFfUAKkMZDE2d4CMwYFyuObA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729010615; c=relaxed/simple; bh=k5lOefbufAjKCXSvAI0QZkBhEVgURXz8KGP/kcrvRLs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=f+eL+iSaGJuxfo3D3AxC66UUldsnAcIP5bBcJoBugt6JQideTlsWsR4DTm4Mkw3QGHGViYQBEbQ7Q5bQenUMS+e6UXG1eI4SEZm41M23DGhf90C1pWpAbFHl/hj7Qhz72yjOdekQyHUUd1hoFT+3nxnPbyjMXI3PXooZOUx33PM= 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=Qf06BEyG; 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="Qf06BEyG" Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49FGQXsx019561; Tue, 15 Oct 2024 16:43:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=A52Lr50fscREd2CRD tbP+ERY4Z2lSogVfSi5ya6LgN4=; b=Qf06BEyG/rxeVZZ5c71p5ufFVv+jddQvQ qTshQfQCBvK8rNBDE6Ax9zwYf2KqQWxT+oImIOCwJBev0G1lisSrc5SGEcnc3dZq WbrE1oEgOBTCfplfHoFJKP3yasJogmn520ZfUbizqr7ox3QN9X/fVa1qDdJ/ADMp bXfn4+k9inbfTjwQJP1SQjZRd5Rz6PZL45KBAilRsGbigTdyKk3lYeSjCS0gr52g 18KXGhympcjT1kA1UKWWqbeagmfJf59UB6tr2YV1U0OFkvUnkri5c10cpU3AWZ8M aA7r3aWqWdBCsv3PhT/WT6lvxrXQAykbv3Tq66nUNYWQNDrO7TiVg== 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 429uwjg2ge-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Oct 2024 16:43:33 +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 49FDoqOr027444; Tue, 15 Oct 2024 16:43:32 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4283txn027-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Oct 2024 16:43:31 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 49FGhSV450069776 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Oct 2024 16:43:28 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 59F5A20040; Tue, 15 Oct 2024 16:43:28 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 332EB2004B; Tue, 15 Oct 2024 16:43:28 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.66]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 15 Oct 2024 16:43:28 +0000 (GMT) From: Claudio Imbrenda To: linux-kernel@vger.kernel.org Cc: borntraeger@de.ibm.com, nsg@linux.ibm.com, nrb@linux.ibm.com, frankja@linux.ibm.com, seiden@linux.ibm.com, hca@linux.ibm.com, agordeev@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, kvm@vger.kernel.org, linux-s390@vger.kernel.org Subject: [PATCH v3 08/11] s390: Remove gmap pointer from lowcore Date: Tue, 15 Oct 2024 18:43:23 +0200 Message-ID: <20241015164326.124987-9-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241015164326.124987-1-imbrenda@linux.ibm.com> References: <20241015164326.124987-1-imbrenda@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 09bijSbFQjfpdl6JMIX0_p82HusvcrHk X-Proofpoint-ORIG-GUID: 09bijSbFQjfpdl6JMIX0_p82HusvcrHk X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 mlxlogscore=601 adultscore=0 clxscore=1015 mlxscore=0 phishscore=0 bulkscore=0 spamscore=0 lowpriorityscore=0 malwarescore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410150113 Content-Type: text/plain; charset="utf-8" Remove the gmap pointer from lowcore, since it is not used anymore. Signed-off-by: Claudio Imbrenda Reviewed-by: Steffen Eiden Reviewed-by: Heiko Carstens --- arch/s390/include/asm/lowcore.h | 3 +-- arch/s390/kernel/asm-offsets.c | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/s390/include/asm/lowcore.h b/arch/s390/include/asm/lowcor= e.h index 48c64716d1f2..42a092fa1029 100644 --- a/arch/s390/include/asm/lowcore.h +++ b/arch/s390/include/asm/lowcore.h @@ -165,8 +165,7 @@ struct lowcore { __u64 percpu_offset; /* 0x03b8 */ __u8 pad_0x03c0[0x03c8-0x03c0]; /* 0x03c0 */ __u64 machine_flags; /* 0x03c8 */ - __u64 gmap; /* 0x03d0 */ - __u8 pad_0x03d8[0x0400-0x03d8]; /* 0x03d8 */ + __u8 pad_0x03d0[0x0400-0x03d0]; /* 0x03d0 */ =20 __u32 return_lpswe; /* 0x0400 */ __u32 return_mcck_lpswe; /* 0x0404 */ diff --git a/arch/s390/kernel/asm-offsets.c b/arch/s390/kernel/asm-offsets.c index 3a6ee5043761..1d7ed0faff8b 100644 --- a/arch/s390/kernel/asm-offsets.c +++ b/arch/s390/kernel/asm-offsets.c @@ -137,7 +137,6 @@ int main(void) OFFSET(__LC_USER_ASCE, lowcore, user_asce); OFFSET(__LC_LPP, lowcore, lpp); OFFSET(__LC_CURRENT_PID, lowcore, current_pid); - OFFSET(__LC_GMAP, lowcore, gmap); OFFSET(__LC_LAST_BREAK, lowcore, last_break); /* software defined ABI-relevant lowcore locations 0xe00 - 0xe20 */ OFFSET(__LC_DUMP_REIPL, lowcore, ipib); --=20 2.47.0 From nobody Tue Nov 26 21:33:22 2024 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 67E331F76B5; Tue, 15 Oct 2024 16:43:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729010616; cv=none; b=qn0Xz/wOPxswtSN3x9Df2EJlH2+G4knqP191caorb/S+RCe8erh0WYZJA056oGTNPPXzXAPdKBI1OerJHBbgZiztt1edVTsry2ib59/m2cWVCSr+HkYKkvCa8hUR/JhgmZ5K8vULZiNPBEUHKjBBs7TTc00O3wygivKDFQpZbTA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729010616; c=relaxed/simple; bh=m5UAYB79TEfrioqAYLo0joh7a0Agaawt4tkZzvrD8QE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TrTcBvuBon4mWTDL8BpaMqN8uy2AyVDfyh+jWQwwfU5/PdDkdcTOAdWXBNKxtEHHuRzkxghB9/RsX8elkFyk5tJXzEOmGyQgttacly8ETdAbhXGiqijUmQ3kHZVTykhIbolzgU0vvnwRJo3lfCj+Kxor3wzl+pba9s7cVH96WFE= 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=HvNnXjsJ; arc=none smtp.client-ip=148.163.158.5 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="HvNnXjsJ" Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49FDJZD2007796; Tue, 15 Oct 2024 16:43:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=W4h7KWWUJ1nq8iuU+ j1U4vFtf2F9utqpqwfLBifPARA=; b=HvNnXjsJmmjwKw2I6TRGgW6vkHjtLT1/W 7pIpZXBy8TdZ6rcr88cQaV0/CJJeNSesOqgXbn/E30Ei41vXtGLsPsP2GsWsYgp1 yDnoP95uziu2mnSEguKUcqZL32Ks3aUCooYEQ1xdCkyPtFY4kWC1/cJH5VbhMSlG JHYDcA8dClO06jewQ70fd1hm0XjFtwaeapix0Owp/O4vPAvTdPf/QK/AfWlnq08c uikIM68UhrkURv9LVH9naxIJtTvHUIWpiGJT9MNuX4zLIAThnsl/iOBEE6eZU2Hr J4zg5q1C6q1fOVSw3p6p/CkwwWoG1mc3d/M8OubzjJDZbNlLC7VDQ== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 429s68h429-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Oct 2024 16:43:32 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 49FFP7Lg005215; Tue, 15 Oct 2024 16:43:32 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4285nj4mk9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Oct 2024 16:43:32 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 49FGhS9I50069778 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Oct 2024 16:43:28 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 85A8620040; Tue, 15 Oct 2024 16:43:28 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5EAA020043; Tue, 15 Oct 2024 16:43:28 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.66]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 15 Oct 2024 16:43:28 +0000 (GMT) From: Claudio Imbrenda To: linux-kernel@vger.kernel.org Cc: borntraeger@de.ibm.com, nsg@linux.ibm.com, nrb@linux.ibm.com, frankja@linux.ibm.com, seiden@linux.ibm.com, hca@linux.ibm.com, agordeev@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, kvm@vger.kernel.org, linux-s390@vger.kernel.org Subject: [PATCH v3 09/11] s390/mm: Simplify get_fault_type() Date: Tue, 15 Oct 2024 18:43:24 +0200 Message-ID: <20241015164326.124987-10-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241015164326.124987-1-imbrenda@linux.ibm.com> References: <20241015164326.124987-1-imbrenda@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 0ZzkNOr51_Qrin6GP7NUQDau07WJ4tF_ X-Proofpoint-ORIG-GUID: 0ZzkNOr51_Qrin6GP7NUQDau07WJ4tF_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 phishscore=0 clxscore=1015 malwarescore=0 suspectscore=0 lowpriorityscore=0 mlxlogscore=610 adultscore=0 mlxscore=0 priorityscore=1501 bulkscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410150113 Content-Type: text/plain; charset="utf-8" From: Heiko Carstens With the gmap code gone get_fault_type() can be simplified: - every fault with user_mode(regs) =3D=3D true must be a fault in user addr= ess space - every fault with user_mode(regs) =3D=3D false is only a fault in user address space if the used address space is the secondary address space - every other fault is within the kernel address space Signed-off-by: Heiko Carstens Reviewed-by: Alexander Gordeev --- arch/s390/mm/fault.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c index e48910b0b816..6e96fc7905fc 100644 --- a/arch/s390/mm/fault.c +++ b/arch/s390/mm/fault.c @@ -68,17 +68,10 @@ static enum fault_type get_fault_type(struct pt_regs *r= egs) { union teid teid =3D { .val =3D regs->int_parm_long }; =20 - if (likely(teid.as =3D=3D PSW_BITS_AS_PRIMARY)) { - if (user_mode(regs)) - return USER_FAULT; - return KERNEL_FAULT; - } - if (teid.as =3D=3D PSW_BITS_AS_SECONDARY) + if (user_mode(regs)) return USER_FAULT; - /* Access register mode, not used in the kernel */ - if (teid.as =3D=3D PSW_BITS_AS_ACCREG) + if (teid.as =3D=3D PSW_BITS_AS_SECONDARY) return USER_FAULT; - /* Home space -> access via kernel ASCE */ return KERNEL_FAULT; } =20 --=20 2.47.0 From nobody Tue Nov 26 21:33:22 2024 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 696041F76B6; Tue, 15 Oct 2024 16:43:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729010617; cv=none; b=ANpeg4iLUrayVC3AQ4daFZTYd5xyge6nS78JxQEvhjCgYe0DzMXdO0HmwwOlmFaFsAlXxQNJTzSSzc9Q+Puiwu2tc39Tnmw1btncAbpX48GBI1FE8b/oFfwOM89NYl7FJOCcJTsJG0lyLxy55i6EBoboCAAPql89ISzJk6mTENc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729010617; c=relaxed/simple; bh=Z9bRoxXyx3sAoKziQia3gv9KjvurarVGCYrbVX0wBQU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=f247pytElS3dIPj0pnt+vsiMzBxAm3A5YJMp7YVfEcCuwfHYnGETTaiim+nZcoVEPit4DQ/Q/6x06Vfx6cmeCenxvxS5TuZoQ4xlsSUuJPALgb7iIgd5UStgppnRP0mjGNqaIpS7SElTGw21xo6ClB8D643XRxNpNvTR/fw+Luo= 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=IA4bjy6p; arc=none smtp.client-ip=148.163.158.5 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="IA4bjy6p" Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49FGIvUo012451; Tue, 15 Oct 2024 16:43:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=l22CTdoToSQBMRy+l NB4xu65L+oAkrXxrMTQl1t93Lo=; b=IA4bjy6pnmOZlhiVovaZd1G+1ySDlP9eO 8rbbEht6DS4nvoNvfDeFRrUoQqd6ntKGLvyPIlSrQn+zoxP8xr9VKwINjRGnIY6U KIOgmkLFA0DXWX2oSOzc1auIopEPfqxsxNSAduQIjLskbE/UtTYvSREFnrWg1ceR yIteyoRvwZFlG5ZF89Oy3u5UgbNd2BrgL6YHnLk6jvzCF4JkbdiHV/vcLnqWkmDN XkP6ZrXkcVcxDmfl0ambNhnnUrK3NgwAqDjOJ25yDgR92vzpuwpQcD6orC1OcqrA bnnmq8QpjbyLZzJEaKgebJ7P+4PsqG7nmg/9fSPUU7OTehdNLCQnA== 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 429utbr4c0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Oct 2024 16:43:33 +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 49FDoqOs027444; Tue, 15 Oct 2024 16:43:32 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4283txn028-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Oct 2024 16:43:32 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 49FGhSaY50069780 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Oct 2024 16:43:28 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B18EC20043; Tue, 15 Oct 2024 16:43:28 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8ACCF2004B; Tue, 15 Oct 2024 16:43:28 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.66]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 15 Oct 2024 16:43:28 +0000 (GMT) From: Claudio Imbrenda To: linux-kernel@vger.kernel.org Cc: borntraeger@de.ibm.com, nsg@linux.ibm.com, nrb@linux.ibm.com, frankja@linux.ibm.com, seiden@linux.ibm.com, hca@linux.ibm.com, agordeev@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, kvm@vger.kernel.org, linux-s390@vger.kernel.org Subject: [PATCH v3 10/11] s390/mm: Get rid of fault type switch statements Date: Tue, 15 Oct 2024 18:43:25 +0200 Message-ID: <20241015164326.124987-11-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241015164326.124987-1-imbrenda@linux.ibm.com> References: <20241015164326.124987-1-imbrenda@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 4btRNoVUpFamlLieAt3rpuCttRKOy1ab X-Proofpoint-ORIG-GUID: 4btRNoVUpFamlLieAt3rpuCttRKOy1ab X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 clxscore=1015 suspectscore=0 phishscore=0 impostorscore=0 mlxscore=0 spamscore=0 bulkscore=0 lowpriorityscore=0 priorityscore=1501 mlxlogscore=956 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410150113 Content-Type: text/plain; charset="utf-8" From: Heiko Carstens With GMAP_FAULT fault type gone, there are only KERNEL_FAULT and USER_FAULT fault types left. Therefore there is no need for any fault type switch statements left. Rename get_fault_type() into is_kernel_fault() and let it return a boolean value. Change all switch statements to if statements. This removes quite a bit of code. Signed-off-by: Heiko Carstens Reviewed-by: Alexander Gordeev --- arch/s390/mm/fault.c | 70 ++++++++++++++------------------------------ 1 file changed, 22 insertions(+), 48 deletions(-) diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c index 6e96fc7905fc..93ae097ef0e0 100644 --- a/arch/s390/mm/fault.c +++ b/arch/s390/mm/fault.c @@ -46,11 +46,6 @@ #include #include "../kernel/entry.h" =20 -enum fault_type { - KERNEL_FAULT, - USER_FAULT, -}; - static DEFINE_STATIC_KEY_FALSE(have_store_indication); =20 static int __init fault_init(void) @@ -64,15 +59,15 @@ early_initcall(fault_init); /* * Find out which address space caused the exception. */ -static enum fault_type get_fault_type(struct pt_regs *regs) +static bool is_kernel_fault(struct pt_regs *regs) { union teid teid =3D { .val =3D regs->int_parm_long }; =20 if (user_mode(regs)) - return USER_FAULT; + return false; if (teid.as =3D=3D PSW_BITS_AS_SECONDARY) - return USER_FAULT; - return KERNEL_FAULT; + return false; + return true; } =20 static unsigned long get_fault_address(struct pt_regs *regs) @@ -167,17 +162,12 @@ static void dump_fault_info(struct pt_regs *regs) break; } pr_cont("mode while using "); - switch (get_fault_type(regs)) { - case USER_FAULT: - asce =3D get_lowcore()->user_asce.val; - pr_cont("user "); - break; - case KERNEL_FAULT: + if (is_kernel_fault(regs)) { asce =3D get_lowcore()->kernel_asce.val; pr_cont("kernel "); - break; - default: - unreachable(); + } else { + asce =3D get_lowcore()->user_asce.val; + pr_cont("user "); } pr_cont("ASCE.\n"); dump_pagetable(asce, get_fault_address(regs)); @@ -212,7 +202,6 @@ static void do_sigsegv(struct pt_regs *regs, int si_cod= e) =20 static void handle_fault_error_nolock(struct pt_regs *regs, int si_code) { - enum fault_type fault_type; unsigned long address; bool is_write; =20 @@ -223,17 +212,15 @@ static void handle_fault_error_nolock(struct pt_regs = *regs, int si_code) } if (fixup_exception(regs)) return; - fault_type =3D get_fault_type(regs); - if (fault_type =3D=3D KERNEL_FAULT) { + if (is_kernel_fault(regs)) { address =3D get_fault_address(regs); is_write =3D fault_is_write(regs); if (kfence_handle_page_fault(address, is_write, regs)) return; - } - if (fault_type =3D=3D KERNEL_FAULT) pr_alert("Unable to handle kernel pointer dereference in virtual kernel = address space\n"); - else + } else { pr_alert("Unable to handle kernel paging request in virtual user address= space\n"); + } dump_fault_info(regs); die(regs, "Oops"); } @@ -267,7 +254,6 @@ static void do_exception(struct pt_regs *regs, int acce= ss) struct vm_area_struct *vma; unsigned long address; struct mm_struct *mm; - enum fault_type type; unsigned int flags; vm_fault_t fault; bool is_write; @@ -282,15 +268,8 @@ static void do_exception(struct pt_regs *regs, int acc= ess) mm =3D current->mm; address =3D get_fault_address(regs); is_write =3D fault_is_write(regs); - type =3D get_fault_type(regs); - switch (type) { - case KERNEL_FAULT: + if (is_kernel_fault(regs) || faulthandler_disabled() || !mm) return handle_fault_error_nolock(regs, 0); - case USER_FAULT: - if (faulthandler_disabled() || !mm) - return handle_fault_error_nolock(regs, 0); - break; - } perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address); flags =3D FAULT_FLAG_DEFAULT; if (user_mode(regs)) @@ -460,8 +439,15 @@ void do_secure_storage_access(struct pt_regs *regs) */ panic("Unexpected PGM 0x3d with TEID bit 61=3D0"); } - switch (get_fault_type(regs)) { - case USER_FAULT: + if (is_kernel_fault(regs)) { + folio =3D phys_to_folio(addr); + if (unlikely(!folio_try_get(folio))) + return; + rc =3D arch_make_folio_accessible(folio); + folio_put(folio); + if (rc) + BUG(); + } else { mm =3D current->mm; mmap_read_lock(mm); vma =3D find_vma(mm, addr); @@ -470,7 +456,7 @@ void do_secure_storage_access(struct pt_regs *regs) folio =3D folio_walk_start(&fw, vma, addr, 0); if (!folio) { mmap_read_unlock(mm); - break; + return; } /* arch_make_folio_accessible() needs a raised refcount. */ folio_get(folio); @@ -480,18 +466,6 @@ void do_secure_storage_access(struct pt_regs *regs) if (rc) send_sig(SIGSEGV, current, 0); mmap_read_unlock(mm); - break; - case KERNEL_FAULT: - folio =3D phys_to_folio(addr); - if (unlikely(!folio_try_get(folio))) - break; - rc =3D arch_make_folio_accessible(folio); - folio_put(folio); - if (rc) - BUG(); - break; - default: - unreachable(); } } NOKPROBE_SYMBOL(do_secure_storage_access); --=20 2.47.0 From nobody Tue Nov 26 21:33:22 2024 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 B65C51F76D1; Tue, 15 Oct 2024 16:43:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729010616; cv=none; b=AQ6auebO/ut1oj9XuEW1r/FyDBjCbYMNqOARMfYdbagrss8Fe2ZRZtkIYKSXdxtQfgm0Xqu2az8G1NBOvnf5t12DH8Jz5U+RTWdzHuVfeCCfUtjRfn0XTJtpy4JJvHUNpZ1duUGckh3+tidXgXbfH63zHhQ993JXZSo/OBIG7WY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729010616; c=relaxed/simple; bh=OD/CTOrwcg6OiHs7buhnlA46yO9ruiybpAnnQ2ioFXg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gamNBTTcBoKjIAmoXzOu6NO2u24X6mQT12/saMGjSzOpdkrBqJP8ygxFUDXCiEXWIv7wgcQJCdk1PdCCf83mJAW3diRIYkNTkL3Jj4asg5CBLYDcDivphgD26sYzIxpksdP+M9Bee7E59NEjxHL+SITlc0Hw2SdISFTD4rhJotw= 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=ZytbZPv4; arc=none smtp.client-ip=148.163.158.5 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="ZytbZPv4" Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49FFoWDb031605; Tue, 15 Oct 2024 16:43:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=b1hrL5t3INOADSR8l YZwbXlFlIC3oQgm2SthebZwLds=; b=ZytbZPv4e3P1bzMOue/sbbzVsbqPyTIrJ ZzWDvHW9Z7VNzYfy+az5kh5PvwZVVrOKujAzxBWHB4iZP33ibMJv+vVv2YKzdTfW c4yGTP42d+L1cY5FF9MwvXFdDqXCuUWahUY1ix/Zo1JqK4A6d6rUI7RHd0GenP3x hAkzLrEQCFig3JfwutXa5eGNNF1KPc4zjadXlNZXu35wVfTIgN2oqmJ2NId1PbFI 1w2Hd1o4DomMYmkZAdZkwF0ZL9vDZcj9sBPoucmpsiuRFd5gG6ZYZMdxiDh3xHxp GClhUJqyWetYgCtCaMnnRRUNFJFXlLH37VcGWbrraO3x0kN+B9bZg== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 429ucwg8m0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Oct 2024 16:43:33 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 49FEmnAp007025; Tue, 15 Oct 2024 16:43:32 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4284xk4tre-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Oct 2024 16:43:32 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 49FGhSqp50069782 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Oct 2024 16:43:29 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DDC952004B; Tue, 15 Oct 2024 16:43:28 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B70A320040; Tue, 15 Oct 2024 16:43:28 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.66]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 15 Oct 2024 16:43:28 +0000 (GMT) From: Claudio Imbrenda To: linux-kernel@vger.kernel.org Cc: borntraeger@de.ibm.com, nsg@linux.ibm.com, nrb@linux.ibm.com, frankja@linux.ibm.com, seiden@linux.ibm.com, hca@linux.ibm.com, agordeev@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, kvm@vger.kernel.org, linux-s390@vger.kernel.org Subject: [PATCH v3 11/11] s390/mm: Convert to LOCK_MM_AND_FIND_VMA Date: Tue, 15 Oct 2024 18:43:26 +0200 Message-ID: <20241015164326.124987-12-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241015164326.124987-1-imbrenda@linux.ibm.com> References: <20241015164326.124987-1-imbrenda@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: mIwXe_1YdEff2xHHUJkxrOJMh3WJJF-U X-Proofpoint-GUID: mIwXe_1YdEff2xHHUJkxrOJMh3WJJF-U X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 malwarescore=0 mlxlogscore=641 spamscore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 suspectscore=0 bulkscore=0 adultscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410150113 Content-Type: text/plain; charset="utf-8" From: Heiko Carstens With the gmap code gone s390 can be easily converted to LOCK_MM_AND_FIND_VMA like it has been done for most other architectures. Signed-off-by: Heiko Carstens Reviewed-by: Gerald Schaefer --- arch/s390/Kconfig | 1 + arch/s390/mm/fault.c | 13 ++----------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index d339fe4fdedf..8109446f7b24 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig @@ -224,6 +224,7 @@ config S390 select HAVE_VIRT_CPU_ACCOUNTING_IDLE select IOMMU_HELPER if PCI select IOMMU_SUPPORT if PCI + select LOCK_MM_AND_FIND_VMA select MMU_GATHER_MERGE_VMAS select MMU_GATHER_NO_GATHER select MMU_GATHER_RCU_TABLE_FREE diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c index 93ae097ef0e0..8bd2b8d64273 100644 --- a/arch/s390/mm/fault.c +++ b/arch/s390/mm/fault.c @@ -308,18 +308,10 @@ static void do_exception(struct pt_regs *regs, int ac= cess) return; } lock_mmap: - mmap_read_lock(mm); retry: - vma =3D find_vma(mm, address); + vma =3D lock_mm_and_find_vma(mm, address, regs); if (!vma) - return handle_fault_error(regs, SEGV_MAPERR); - if (unlikely(vma->vm_start > address)) { - if (!(vma->vm_flags & VM_GROWSDOWN)) - return handle_fault_error(regs, SEGV_MAPERR); - vma =3D expand_stack(mm, address); - if (!vma) - return handle_fault_error_nolock(regs, SEGV_MAPERR); - } + return handle_fault_error_nolock(regs, SEGV_MAPERR); if (unlikely(!(vma->vm_flags & access))) return handle_fault_error(regs, SEGV_ACCERR); fault =3D handle_mm_fault(vma, address, flags, regs); @@ -337,7 +329,6 @@ static void do_exception(struct pt_regs *regs, int acce= ss) } if (fault & VM_FAULT_RETRY) { flags |=3D FAULT_FLAG_TRIED; - mmap_read_lock(mm); goto retry; } mmap_read_unlock(mm); --=20 2.47.0