From nobody Tue Nov 26 02:26:53 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 ABCA719D083; Tue, 22 Oct 2024 12:06:11 +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=1729598773; cv=none; b=as4TCGuTdW0g6xeG5Q12fwL6HI6cZwtARzaEq/N5rkXxaavX/8dO4sTZQx3Jh83QMomMXRGBGOo/l8amPjKrtExyWytfa9HKi18QP9foO/Gqz0RS9z3rwpHvRD93WP0lmAeE0L26mqzsD6zBezGDeTcNe4ykE8yiRUGcFbul0HI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729598773; c=relaxed/simple; bh=xlPopFefVfTzh69o9E/BNWbjtqQJxBiEWh3waQB4SlE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hC4oZKiKM/A1kK9Bw4luRMDpi3+kKhAeH+jj3mdlXhzW50Giz/lNTxo2BLLBVe616KTG/F07k/yUR+drXugfKyI1ecfwjY8DlbJg3IxnAQ+55FQKkdxgLn3UaYCzY8Myi1pkZU3pvZ+oh29t/kek68Sr1uRwIW0NNe202RxzrlM= 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=XehVmtU0; 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="XehVmtU0" 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 49M2HBEe009278; Tue, 22 Oct 2024 12:06:08 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=XehVmtU0s1G7Tad1CTuRmthmwRtEcRBZB ajOhC9Enf0cphYFc9ep4ZJnXzBDbGczDpQ1yWq3ioN/4EJotUeL+6LFEryyYxTf8 QAahqx1MOiHDGUpWEwiOvCiUbiW/CooIuK3hOqelWgTR6/4kNbEWEVLRnLcVWeep S2XZBI/9FL6Bkisiz2+YJMZkfNVDCZDm2Z00aGpd6qh7KbzIB2FEdC8c6UwntAC4 Gj+qIgJjqaQ3RNYFkSjHP17j/7sEw5PZG/bBq3h67jO/pxkKhoVC7vc3yEVGVA7A X0qtZ3hFqz5XyGVSaJrpnOcShPwM0wT/+DwJJrRrfatFCwT4dycDw== 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 42c5hmeevf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Oct 2024 12:06:07 +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 49MAOb6k018605; Tue, 22 Oct 2024 12:06:07 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 42csajauas-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Oct 2024 12:06:06 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 49MC63BR34210474 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Oct 2024 12:06:03 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 83D5F20043; Tue, 22 Oct 2024 12:06:03 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A7CC720040; Tue, 22 Oct 2024 12:06:02 +0000 (GMT) Received: from p-imbrenda.ibmuc.com (unknown [9.171.37.93]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 22 Oct 2024 12:06:02 +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, david@redhat.com Subject: [PATCH v4 01/11] s390/entry: Remove __GMAP_ASCE and use _PIF_GUEST_FAULT again Date: Tue, 22 Oct 2024 14:05:51 +0200 Message-ID: <20241022120601.167009-2-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241022120601.167009-1-imbrenda@linux.ibm.com> References: <20241022120601.167009-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: JUzmOZ2eRGMp-EAH6zKDMD-4Qc-QaUIE X-Proofpoint-GUID: JUzmOZ2eRGMp-EAH6zKDMD-4Qc-QaUIE 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 clxscore=1015 phishscore=0 impostorscore=0 priorityscore=1501 lowpriorityscore=0 bulkscore=0 mlxscore=0 adultscore=0 mlxlogscore=573 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410220074 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 02:26:53 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 7DC8B19D890; Tue, 22 Oct 2024 12:06:13 +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=1729598775; cv=none; b=uA3HJShXUhG9ns6m6tuGXst5VpzNSdif9GePt2kjrtS0Hi+LgnpNLq9iNSoWRvEBqZyJjDW5gpNYRJMt/SLv5otXJSBKJCansJjjLRidWK+2ZsqkIapHnOPAO8q+jtcTyb9+xqqPit+OYFNKOVE5fyYiu0oqf5iXCSUxekoOPlU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729598775; c=relaxed/simple; bh=QQvuMDB3i+1hQRxxMhfrS1fUCS2QiWa5R5FPahhxnCQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Xwzd5Q23GIDhswNLwV2lKsBW8TFskL32vJB1qSRzBxrz8r+fB8GSLG2Us+lgqT3Qu2EtwJjSDy0ycEVZLMdh+3TH9aWzSl8/YrNApk4lCitdbx4zbRT32+GuPVO17AkGyBmuas3qg6RE0SKojv1bQ0AAulYFDtMmxKsvQHnZg64= 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=VTH1HxOH; 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="VTH1HxOH" 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 49M2HCRO005367; Tue, 22 Oct 2024 12:06:10 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=VTH1HxOHia+uxp2ywIGK1LKs8ybLr2ivJ zar4CA/1gLzU3acoW65jf15HTT4pcJpaTWAYcgLTkJK/DFvDh8O9E/7DXpTZT2z5 fpQUdk+nVSfiZFLDEeXe/PLi5/U83VTAdHP4UveWX+65BnJ8P26CFZvWVPDZ40qr MF4WbFidlXY8uPbozCWloRBKoUrxs22MRLN+2L172SwvOMRVjphAOThu6OqxNEYz vvstuFpm8pfZlxvdBp3OhJfhb8a+jNuHLffwfUmUutUGgL1K0f1XEE5ff6F7UvbB SwEjkkPkT+8FKrp7uizBVTo7PhwiiKmo/OnQIId1tWnRHpiHqaXPA== 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 42c5fcnqer-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Oct 2024 12:06:10 +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 49M9M438009312; Tue, 22 Oct 2024 12:06:09 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 42cr3mu3xe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Oct 2024 12:06:09 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 49MC65g443975096 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Oct 2024 12:06:05 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BB9A920040; Tue, 22 Oct 2024 12:06:05 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 96BE72004B; Tue, 22 Oct 2024 12:06:03 +0000 (GMT) Received: from p-imbrenda.ibmuc.com (unknown [9.171.37.93]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 22 Oct 2024 12:06:03 +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, david@redhat.com Subject: [PATCH v4 02/11] s390/kvm: Remove kvm_arch_fault_in_page() Date: Tue, 22 Oct 2024 14:05:52 +0200 Message-ID: <20241022120601.167009-3-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241022120601.167009-1-imbrenda@linux.ibm.com> References: <20241022120601.167009-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: 9nGNns7ZY--qaPU5mnPegO9Rbu9VzTaQ X-Proofpoint-GUID: 9nGNns7ZY--qaPU5mnPegO9Rbu9VzTaQ 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 bulkscore=0 mlxscore=0 clxscore=1015 mlxlogscore=999 phishscore=0 impostorscore=0 malwarescore=0 lowpriorityscore=0 adultscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410220074 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 02:26:53 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 317E619DF75; Tue, 22 Oct 2024 12:06:15 +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=1729598778; cv=none; b=AeluqNlGXMjxS1nwWUewjSpV8+bIt+FYgX2usP99TXENmwU64gsBrKEgDJRdGoGa+Ih5yIlQ3fMXPwEuWEdhK0a2FDEkCMtEYLwNe+Q2yyRvxSpxoiTmBcORSBDCza4pTZ/gaVKMulB1hsQz9w+HTgTiREsRaDXOBQPEVPh7nws= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729598778; c=relaxed/simple; bh=h5/6DKrykAbE8bJds/TWcnfzEes4D2GTN90XTpLRS1w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WbW9iTgoeW+hbkuXlyj5wZej/95Cqg0xGIzr5TsOBbjGOauKB1OeDxGzwNqadnBusF7C9CWX0vVmnkG2mqBR8Kd0/W1mlDn/WRcL3ApUBQJ2pX6BV2uEXHR1kvUqqLlxOfZDoadxx3GN5/ObuyVmo/eTNvOe3eokUX7Qlzsl4SA= 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=XP/LAhZo; 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="XP/LAhZo" 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 49M2HJ8I009463; Tue, 22 Oct 2024 12:06:12 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=Ywjmb3nwir9sPobCY Agfz2dnTAU7iFKkWNpN84UE7X8=; b=XP/LAhZoHYK2N2Kl5yrTE1qap2gdE0VQj Y8rl1UaY73DG8lkMrqzisBi3/WCr3UX2ykGGpGDSfxoIffY5kvrAp8GXtE0is2FJ oijoqcDyTacdeQXIT4rxPBy+Pa02GST54Z5nbe2zNTKY2NCBA1QDDMLA1uRX0Vn+ xs8TACDScJlyLM+4AmBGXX7U70Tkei5Cjq+eKIZShsTbx6P0XTRYqjY/b3feUwE0 UldOuxV+QKtZGTWnnZfai4IHDr/SxsKCWWqq9JTui1PJfBPypCGJJQt55W+4mV9d O0Sl4zjVJqCVoPoMVzXBeeQhNNlVysN9Eu7vMbCfens2eNcEeVjQw== 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 42c5hmeevn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Oct 2024 12:06:12 +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 49MA1qZr029300; Tue, 22 Oct 2024 12:06:10 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 42crkk2yau-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Oct 2024 12:06:10 +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 49MC66dr55247192 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Oct 2024 12:06:06 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AF6B72004F; Tue, 22 Oct 2024 12:06:06 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CEC1D20043; Tue, 22 Oct 2024 12:06:05 +0000 (GMT) Received: from p-imbrenda.ibmuc.com (unknown [9.171.37.93]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 22 Oct 2024 12:06:05 +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, david@redhat.com Subject: [PATCH v4 03/11] s390/mm/gmap: Refactor gmap_fault() and add support for pfault Date: Tue, 22 Oct 2024 14:05:53 +0200 Message-ID: <20241022120601.167009-4-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241022120601.167009-1-imbrenda@linux.ibm.com> References: <20241022120601.167009-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: EZy342TeQYjhJBiYh6LuP9pQ4VpPumpQ X-Proofpoint-GUID: EZy342TeQYjhJBiYh6LuP9pQ4VpPumpQ 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 clxscore=1015 phishscore=0 impostorscore=0 priorityscore=1501 lowpriorityscore=0 bulkscore=0 mlxscore=0 adultscore=0 mlxlogscore=805 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410220074 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 02:26:53 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 19B0C19DF66; Tue, 22 Oct 2024 12:06:13 +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=1729598776; cv=none; b=mcLeUSekAr9kKFJiV8XKNh1xpfXjHqxjbCyOnFP2ptk4DdY5/2D9LpymtqnITIB9y4jP8sAfu3428MJxD31Vokh5kfDEN80GSiB/CQYRlTWyG2VkQepJDZwWWWlHnKW7Pk1yc4OC8WUbnlOaoumMUmnoobAyDlPbI9Jh++610GM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729598776; c=relaxed/simple; bh=Y5FMepZoxGiJrpODOM+3gyu4NwjOwdk0gHSXaMccSD8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CvQ8hYDvVf2ZV1/WQOd0lfZF/02C3u55FR+oQrSbRDOEUIhu2yl1zcNiyLcbdVjIP3Go81NmlD0cdr9vog4aL5XqjlU6Q00Grg8HRwxtdz6AHpzHUjtLJRQ8+Magux/sCeOWK+Gwh1FjDSPAyswq6IJwyCN54FbngdHeLAE8ks0= 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=YttzeOXZ; 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="YttzeOXZ" 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 49M2HCnU029534; Tue, 22 Oct 2024 12:06:11 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=YttzeOXZcKMlWAmHcZPma+Wh0skMJlaPm khHa8qpYtIxyWGp7F+4MOLll8qOaQVRqLgioC8QSXbQhik0MhyVxlHnsdgm/oeQh nkpnFMQMSWN7z1k5DNYahTdLFPvNsXuKm9+y9D9NEgnbdr9zkjvZMola1ydW0aGE +v3F7UMdGD91o7je0Qo197hitCkVInPKIzxJO4w6u0hvvJEVBViBrXqHOccxw9Q+ WfQoo/NBAJq8uvLZvPZV7BkuDklEHtta3FahxlnEk/GLcq+PmBjsnbfQ+7pKKgcZ z1thnjFWAtqgf9aUwecJ/xIRBPfskmK1yLyVYruCbk4kryKNWwlkA== 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 42c5eudry2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Oct 2024 12:06:11 +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 49MAOb6l018605; Tue, 22 Oct 2024 12:06:10 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 42csajauax-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Oct 2024 12:06:10 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 49MC67Dh18416082 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Oct 2024 12:06:07 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5CEE620043; Tue, 22 Oct 2024 12:06:07 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C20A320040; Tue, 22 Oct 2024 12:06:06 +0000 (GMT) Received: from p-imbrenda.ibmuc.com (unknown [9.171.37.93]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 22 Oct 2024 12:06:06 +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, david@redhat.com Subject: [PATCH v4 04/11] s390/mm/gmap: Fix __gmap_fault() return code Date: Tue, 22 Oct 2024 14:05:54 +0200 Message-ID: <20241022120601.167009-5-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241022120601.167009-1-imbrenda@linux.ibm.com> References: <20241022120601.167009-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: 4in1kTelQOLqK7G99PyyB8Y_oDhKS6Px X-Proofpoint-ORIG-GUID: 4in1kTelQOLqK7G99PyyB8Y_oDhKS6Px 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 lowpriorityscore=0 adultscore=0 spamscore=0 suspectscore=0 phishscore=0 impostorscore=0 mlxlogscore=889 mlxscore=0 bulkscore=0 priorityscore=1501 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410220074 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 02:26:53 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 4E67D19F47A; Tue, 22 Oct 2024 12:06:18 +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=1729598780; cv=none; b=Yb4xEY8Q+m/xTTPsJ72MMoXN+wT211wOm/jBmKdT6hYtPeMdJZPQpvlfre2T4kKibUukbnYD1AGKlV/O+0OF7ytQeHQdkTnvmzL6eAH9qInQpDcJdFn/GZCqj57MU6hpoEpohbjiMLBjJyj649suRhxrzEegyvGBzs7mAGxTZMY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729598780; c=relaxed/simple; bh=+g9t5WufnlNvzouzFwgjvpnjUHXr6pbQ3jNUSlRVc14=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=L3CUJTunD3Xdmym1GbEoX2oiTfNi1lVnpce3B+Cp/9qjQXDwEWvfGTrmfIedjlrwYLvjeYsmgsPJP4/lyn1hdtRgaC6FgpbR86dGjYLdA4gm4Q9gk5TdrGJW+VIzmiFju4Q29dVZjMwRnqg9B/rBUnl03poMw2xF7YUwnY5camc= 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=AYSRPEOd; 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="AYSRPEOd" 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 49M2HD4D009315; Tue, 22 Oct 2024 12:06:13 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=R+YVoTU9vVboQiluc VJHs3H+c/Qmy79N2AV76dBKy/0=; b=AYSRPEOdNKt3sBWpIDiLO2OsB64DWjtHN moHvG7D0gu5IyWefX6XjvZGWTH4rhlLztQwyElqtXr4qgNKr8XDBEToPuI0UWVXz chSR02P7MqYfXh1scVsy93Xsk6uYS4qPPvb3InbzVjZjwV18ZGFHCRFBnAHD1tIX PHWJhDD2WMLAo6f5vTFW5HY7V3eoAwS0cSSYTrfnFSYib6GyNgY2R/of85qy8v+E +DrRjfdhumncmpNzQ/aeGSNumMKQalwHFdKJx9G9dg1fVTMalIEpLYpO8085aYqq EOsQ4sQsvCjWoGFEfnVs9V6zTOwXbvgGY0+hvndl+C6aR217Fc4FA== Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 42c5hmeevt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Oct 2024 12:06:13 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 49MAkbsS023815; Tue, 22 Oct 2024 12:06:11 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 42cst12scm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Oct 2024 12:06:11 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 49MC68f554853888 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Oct 2024 12:06:08 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 36CF620043; Tue, 22 Oct 2024 12:06:08 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 707CD20040; Tue, 22 Oct 2024 12:06:07 +0000 (GMT) Received: from p-imbrenda.ibmuc.com (unknown [9.171.37.93]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 22 Oct 2024 12:06:07 +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, david@redhat.com Subject: [PATCH v4 05/11] s390/mm/fault: Handle guest-related program interrupts in KVM Date: Tue, 22 Oct 2024 14:05:55 +0200 Message-ID: <20241022120601.167009-6-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241022120601.167009-1-imbrenda@linux.ibm.com> References: <20241022120601.167009-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: oOTvuI0niK3Lny5ta_FNq26UA1UUBjpF X-Proofpoint-GUID: oOTvuI0niK3Lny5ta_FNq26UA1UUBjpF 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 clxscore=1015 phishscore=0 impostorscore=0 priorityscore=1501 lowpriorityscore=0 bulkscore=0 mlxscore=0 adultscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410220074 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 | 119 ++++++++++++++++++++++++------ arch/s390/kvm/kvm-s390.h | 7 ++ arch/s390/kvm/vsie.c | 13 ++-- arch/s390/mm/fault.c | 99 +------------------------ 8 files changed, 135 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..b7ce15107477 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)) { + 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..050710549a10 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,100 @@ static int vcpu_post_run_fault_in_sie(struct kvm_v= cpu *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: + KVM_BUG_ON(current->thread.gmap_teid.as !=3D PSW_BITS_AS_PRIMARY, vcpu->= kvm); + /* + * 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: + KVM_BUG_ON(current->thread.gmap_teid.as !=3D PSW_BITS_AS_PRIMARY, vcpu->= kvm); + /* + * 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: + KVM_BUG_ON(current->thread.gmap_teid.as !=3D PSW_BITS_AS_PRIMARY, vcpu->= kvm); + 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 +4847,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 +4856,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 02:26:53 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 8F3AF19DFA7; Tue, 22 Oct 2024 12:06:15 +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=1729598777; cv=none; b=Cnqyz8rBvmme6va1awSUGeEu6vQ859rKUdQdI9EWsFtXnJcW1xVLQPjTC/5nO+PYCTd/6NW4uf3JQQ+evLrSPMslY6u/arTlWSDpciOjyriHdHNGUrzVZRdtOgdeacmyghxGwD/2ggK9sz1Udzl0oHwJ3w0eEojqiQ9WreOVkH8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729598777; c=relaxed/simple; bh=SNYB9kl8yrez8KUjM5etlo/vK5PUvW0MNO0GLb/Elmc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PC4TLoqtdxqQBcLmZRaTcucr1+ACx1WR8r1Xm0OQ8T6qtbhTcXH74vmbGcsrrQh+3cOysrq+cE6ocKbUWpDOrnJc8IsV2EOZAMmI/xnetMli0c9UOa327vIxXC1UkFxjFbcn8PA5HKAPvgpDGWvvtZTj/h1SxbnPDz+5bT0HBYk= 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=HPd94Juc; 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="HPd94Juc" 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 49M2HSUN029851; Tue, 22 Oct 2024 12:06:13 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=END8AhP18F9CTYe9n ifD5SEHyRSd505yRrZtToSFHPk=; b=HPd94JucWs91VUSZ0GJJyl26nf+BobLyb /etxPQyHvKb9aB4aDevMVvv3TJ+3dSr2kiiRSVHrisFtRf7CUJ+UA2wte4yK6enL mJTE+ob99p99ha8Ha2oR7vOZdUe75Y8riU6v05NQVfpwV8f+CjgNFDJy5au3Yz6h hURr+pGYf5caSrqZ7bYq2S+C0n01ecT4SazVNuUoYSFUVUOprWiuJJrRMN/IyJFm uv2aP07HpVU0vC5Ark3/oxyLOG7J50Iod++/0/+HcAdRjfd4lkfSrJy6dxzVQ47J 9mk9F6VEdI2JyhTqcPvMJp6fcl6EApn4vwsx4X0uhW4o/ExB/DhyA== 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 42c5eudry7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Oct 2024 12:06:13 +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 49M8GD9t026443; Tue, 22 Oct 2024 12:06:12 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 42cq3sb9ph-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Oct 2024 12:06:12 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 49MC685946203340 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Oct 2024 12:06:09 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DB69120043; Tue, 22 Oct 2024 12:06:08 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 49F122004B; Tue, 22 Oct 2024 12:06:08 +0000 (GMT) Received: from p-imbrenda.ibmuc.com (unknown [9.171.37.93]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 22 Oct 2024 12:06:08 +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, david@redhat.com Subject: [PATCH v4 06/11] s390/kvm: Stop using gmap_{en,dis}able() Date: Tue, 22 Oct 2024 14:05:56 +0200 Message-ID: <20241022120601.167009-7-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241022120601.167009-1-imbrenda@linux.ibm.com> References: <20241022120601.167009-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: 4R5dQv_GcPbvK5aOlxcOA5vKLUiNlz6k X-Proofpoint-ORIG-GUID: 4R5dQv_GcPbvK5aOlxcOA5vKLUiNlz6k 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 lowpriorityscore=0 adultscore=0 spamscore=0 suspectscore=0 phishscore=0 impostorscore=0 mlxlogscore=531 mlxscore=0 bulkscore=0 priorityscore=1501 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410220074 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/include/asm/kvm_host.h | 2 -- arch/s390/kvm/kvm-s390.c | 7 +------ arch/s390/kvm/vsie.c | 4 +--- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_h= ost.h index 603b56bfccd3..51201b4ac93a 100644 --- a/arch/s390/include/asm/kvm_host.h +++ b/arch/s390/include/asm/kvm_host.h @@ -750,8 +750,6 @@ struct kvm_vcpu_arch { struct hrtimer ckc_timer; struct kvm_s390_pgm_info pgm; struct gmap *gmap; - /* backup location for the currently enabled gmap when scheduled out */ - struct gmap *enabled_gmap; struct kvm_guestdbg_info_arch guestdbg; unsigned long pfault_token; unsigned long pfault_select; diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index 050710549a10..a5750c14bb4d 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) @@ -4894,7 +4889,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 02:26:53 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 4025A19F42D; Tue, 22 Oct 2024 12:06:18 +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=1729598780; cv=none; b=dfFo4iKR8bd2gnAHu3AZuRdUIoSUtF5pJe/J8//iX8D7jL8KnV2hSOq1g3s5hOGkPP7NG3WglhBTYZzncC8iWB4Eskro5zapZvICCPONUCe7Hg/j2brWT5f4poyqQH//iApwGaYHBzrR2dwOE1WeWs8zXYEyNG9FFYTnQQEPyAs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729598780; c=relaxed/simple; bh=U/Q0FYgw4N+6bjm1hhWprnFA8/rbFYZFZJYh9pLBgaw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sVoaL5uSE3J5Asuki7TxJbSNa/fTmetmaCGh5c3TBOHFQZsi8rq0PsxQhRIqZ6RckwIoUql9EUjsebv6Gn8CtpWgBvFXtY69UwiTBfmSXcMd66IAZjXtdtEvd91/O8kZg9NLxqKAKHxgCHi26xF/PN60BofZ+I2Tuv0k4mO1/bs= 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=E2JxGBSm; 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="E2JxGBSm" 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 49M2HJjE009455; Tue, 22 Oct 2024 12:06:15 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=jQXWkkdtFT5Ju/qQ7 OlEmvEzDIGx9EoKxIFEulkLuPc=; b=E2JxGBSmvFZUYtDhKKvIC0S34xzyjT778 uCoe3VK8E8wTF6UoLEo7iXCxinz+NpDMIUVIzLhJRTIJ0iCGI7BUG0Y+NIcqWrHP 5sCIM00cYgGGckTH4XXVMdLP8/iRA5i/izo+kwkKIt4Kj3RWVujJKCgAm4v8tXYe 6PJdq5YqNxWHaijAWuPLUxT2ScFCpIHVZ/8CmI8VlMcuvufK/y9EWbLJDsonp+Oh oziZC+GdWCIfkGQsfaRUsXINXWXfU2CDyuOqoA6z04IkbnHI0p6lCY/0n4GAhCkv v89Iq/ovoxnR6gANQbilHYBwTF2deVKvw0elob05wkzsVmo/GfDkA== 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 42c5hmeevw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Oct 2024 12:06:14 +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 49M90l4P028879; Tue, 22 Oct 2024 12:06:13 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 42cqfxk76d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Oct 2024 12:06:13 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 49MC69Qs57606480 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Oct 2024 12:06:09 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8EAEC20040; Tue, 22 Oct 2024 12:06:09 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EE3BE2004B; Tue, 22 Oct 2024 12:06:08 +0000 (GMT) Received: from p-imbrenda.ibmuc.com (unknown [9.171.37.93]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 22 Oct 2024 12:06:08 +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, david@redhat.com Subject: [PATCH v4 07/11] s390/mm/gmap: Remove gmap_{en,dis}able() Date: Tue, 22 Oct 2024 14:05:57 +0200 Message-ID: <20241022120601.167009-8-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241022120601.167009-1-imbrenda@linux.ibm.com> References: <20241022120601.167009-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: 1xcBIag9uTvRw696clqHxokYf2_bdjVt X-Proofpoint-GUID: 1xcBIag9uTvRw696clqHxokYf2_bdjVt 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 clxscore=1015 phishscore=0 impostorscore=0 priorityscore=1501 lowpriorityscore=0 bulkscore=0 mlxscore=0 adultscore=0 mlxlogscore=827 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410220074 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 02:26:53 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 3E07019EEC7; Tue, 22 Oct 2024 12:06:16 +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=1729598778; cv=none; b=JI8vf2PVjNH8V4n0fjqkiqB6dmWJvT6ziqJl91r2To/1p6NOR2grF/5ffUZLxbpbn6E74NgU6YaA2L7EiWD38B8rNjZgN4HrVC2GyVBbhkUELlSkMW67hC8kGi9i7FMrg4fCvcuGqs0aN5OVmEAqorS+s2GE+T7MQGVll2mFsqM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729598778; c=relaxed/simple; bh=39oSipGDXH9p1T4K8H6XcCxakzf8Fn/NsTJugMKljtk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=n3KILQQnXybdyk+c2/gQHn7bKhyamGXHGutgnly+BM+tJHMu6rf0eb3ApficTt7R6zzC+nYASaib14K1UgH1K+0nKEpQMxW37z8qCEww+mPJXzCQLvHUNc0haNbry3137c+rsv215aYxlNqbVhB4b3Vv2AoTl6xcMA4wCAQu6H4= 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=Gtja4ZOR; 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="Gtja4ZOR" 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 49M4KW4k004606; Tue, 22 Oct 2024 12:06:14 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=FUZLhdRDl2ic51Het OVDs8c+zc3+2YK+1ohzJjc6My4=; b=Gtja4ZORGLpDRmQgqMxmSHMPcxxCGZzzp F+AS+86jrLKkCXXhYUQfor756grHZVKaROojBjQQcCafckS36lgaXbuhaPzfOBHo cv8LKuiNgc/kO/7VoNbZTNC4MT7YEvUJzOe4wnk5QDahRVL10NHqbJB+a/1j1Kf6 GkHeXjVRCUh4N6DP+9XYjRz5ekyjRqHZhuz3nyKkZwyFyfXIIp69eV1If7/PBwAV KPacBV7PfzNWn2Ev3llFUDeBT4AMtBXbcL8nTY7TNPvhzE4inTWDPLYXYvrTIFbX HASV6QmoBj+nF2Fsu5/6Pl4tZf63ohtmmC/bObqUCXuga9YC4/kaw== Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 42e4xfhnrv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Oct 2024 12:06:14 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 49MBGvki023927; Tue, 22 Oct 2024 12:06:13 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 42cst12scr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Oct 2024 12:06:13 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 49MC6AC320251034 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Oct 2024 12:06:10 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 410C020040; Tue, 22 Oct 2024 12:06:10 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A20D220043; Tue, 22 Oct 2024 12:06:09 +0000 (GMT) Received: from p-imbrenda.ibmuc.com (unknown [9.171.37.93]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 22 Oct 2024 12:06:09 +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, david@redhat.com Subject: [PATCH v4 08/11] s390: Remove gmap pointer from lowcore Date: Tue, 22 Oct 2024 14:05:58 +0200 Message-ID: <20241022120601.167009-9-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241022120601.167009-1-imbrenda@linux.ibm.com> References: <20241022120601.167009-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: bf_8Vt_KDaKs6TICJzc_WEJxr4LlXn4F X-Proofpoint-ORIG-GUID: bf_8Vt_KDaKs6TICJzc_WEJxr4LlXn4F 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 phishscore=0 lowpriorityscore=0 priorityscore=1501 suspectscore=0 impostorscore=0 clxscore=1015 bulkscore=0 malwarescore=0 spamscore=0 mlxscore=0 adultscore=0 mlxlogscore=601 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410220074 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 02:26:53 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 C165719F130; Tue, 22 Oct 2024 12:06:17 +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=1729598779; cv=none; b=qQJkpGOElHjBgv9UNEgkI36FSneDTRkI1Ow4LHjM3ZoU5WHeCbOqTmCHppO2q8WdjXyZb/QBSF7rV6968Fwbgl06/ocGtX+jPEwDl03KknmuASfhlXYUX78gtDDTabEw8bGdELUVL4GJLJ/qXzpKg8d7gfDxQapQi6pxhmZlvpE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729598779; c=relaxed/simple; bh=m5UAYB79TEfrioqAYLo0joh7a0Agaawt4tkZzvrD8QE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HHXZXmS4iw/4gLjIloN1txL0oSWfXB1l7/yIsx2yzycNa7uXdEpHps9tjSnb9PoQuEzuT83zJMv2PidqqPt2qAsVc2aadeqUh/xkPwjEsXIneLTqjyMCfVUk29Xm9nr2rrSWlO9OkXWHvOjfELg3k9wTuyKxMqAMr9Hnn21UhWk= 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=c4VO0Z6a; 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="c4VO0Z6a" 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 49M4KM7k004504; Tue, 22 Oct 2024 12:06:15 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=c4VO0Z6akgUBdGmrAIldzAh7+XMctl0qv PnAY7/gtK5nrZFwk8gOcJvEhlMu8f2cqVbCEQaDuYfjARwbDvof4aFLarYFwStB8 Z7wlSiCn5AXXSqGGtAP2WZYkhyHJn9tCHNOsxxZev48BWDqu6L1/rhpdP7iQMNzw FfHe2A+XvbKsWgTruj+sO2C388ClXS9ADDnBtwcMelr3sXOu+UIePgFIWmPKbKRw Er14/oRhfUHQMb0JsdolBoYNqe7y/GHwFKI0S0VQ1iPfx7cpntWiGC2KHWFnLGD9 JCDtNlHKDWoSEmpYHx2Z9vWeRwPg51NZVwn7GB0bRqtvGD2dJ3I0w== 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 42e4xfhnrw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Oct 2024 12:06:15 +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 49MAh8hq018590; Tue, 22 Oct 2024 12:06:14 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 42csajaub1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Oct 2024 12:06:14 +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 49MC6Bgr57016716 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Oct 2024 12:06:11 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E78F620040; Tue, 22 Oct 2024 12:06:10 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 53A8720043; Tue, 22 Oct 2024 12:06:10 +0000 (GMT) Received: from p-imbrenda.ibmuc.com (unknown [9.171.37.93]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 22 Oct 2024 12:06:10 +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, david@redhat.com Subject: [PATCH v4 09/11] s390/mm: Simplify get_fault_type() Date: Tue, 22 Oct 2024 14:05:59 +0200 Message-ID: <20241022120601.167009-10-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241022120601.167009-1-imbrenda@linux.ibm.com> References: <20241022120601.167009-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: _3a04Q7ounfNeSJUG-puTxH0MEWLHUZV X-Proofpoint-ORIG-GUID: _3a04Q7ounfNeSJUG-puTxH0MEWLHUZV 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 phishscore=0 lowpriorityscore=0 priorityscore=1501 suspectscore=0 impostorscore=0 clxscore=1015 bulkscore=0 malwarescore=0 spamscore=0 mlxscore=0 adultscore=0 mlxlogscore=608 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410220074 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 02:26:53 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 9683D19D07B; Tue, 22 Oct 2024 12:06:18 +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=1729598780; cv=none; b=mMUfbHRxCEwBDn3e8MJ53X4O7MLenS0vu/yVYFgdS0bN8jEhWANf1pdDdjVOJRdv70QZ8SgaBpYhxC1thFAy5NLySVlP+kB/N519xtx3BSc8/+GtihoHckN1tDYPUDuKRSvJ9lwux4TKP/omtjtW4MjFRkGcjB7Q0E0qwWI5Gw4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729598780; c=relaxed/simple; bh=Z9bRoxXyx3sAoKziQia3gv9KjvurarVGCYrbVX0wBQU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ebpPIK1k1piUM3EcT6u9gNJ/OjCWqIA9IT3ni9ilRqZc1UK/saqlHiLUjj8bbms9EIDes6ZrkObOiPGc1NnffmSsPRvPFIdQcz0WLwNR5tLOmveb3tLivhdQbWu9BvjvMG+LdM0GLXExhembQmGmMSAW7F/yhw9GCgx7VAJYiWk= 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=UYsiTxLM; 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="UYsiTxLM" 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 49M2HOAN029787; Tue, 22 Oct 2024 12:06:16 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=UYsiTxLMWDjA1dCUphbu5xxXd1aWXJnKP cDTqShEnY5KfDL8HD6TxPbItMFMNvgGIaSiXOo01C7GEVBHj0Qxuk37k8ZaOTv8A dq8g1cXP+OuatH5w383pPv4fcE9BGJTwIwmv0J85H7oilon1smSKkGT1ahbbEhux 0xLykn0GL2kYdve5gVL9lt30V9mnleRXFZHQC6I6SdOLtUN8zd18Ud80BThwYaLc ZKr2rPehpjuOiODKZAhl2ol1kOhcKqv9iUAmp/FTkG2T6SXYAVAjaeTpsIUxPfw6 tvInsNiImPHxmoeVXK78Ik61fI7xfpSJGLUOZnnVcX3lZmT5ndEKw== 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 42c5eudryd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Oct 2024 12:06:16 +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 49MA0Vni029398; Tue, 22 Oct 2024 12:06:15 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 42crkk2yb2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Oct 2024 12:06:15 +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 49MC6BQL57016718 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Oct 2024 12:06:11 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9A64320040; Tue, 22 Oct 2024 12:06:11 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 068F520043; Tue, 22 Oct 2024 12:06:11 +0000 (GMT) Received: from p-imbrenda.ibmuc.com (unknown [9.171.37.93]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 22 Oct 2024 12:06:10 +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, david@redhat.com Subject: [PATCH v4 10/11] s390/mm: Get rid of fault type switch statements Date: Tue, 22 Oct 2024 14:06:00 +0200 Message-ID: <20241022120601.167009-11-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241022120601.167009-1-imbrenda@linux.ibm.com> References: <20241022120601.167009-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: NHv-J2qTubhjXDWE5kH0p6in6RV6xCW3 X-Proofpoint-ORIG-GUID: NHv-J2qTubhjXDWE5kH0p6in6RV6xCW3 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 lowpriorityscore=0 adultscore=0 spamscore=0 suspectscore=0 phishscore=0 impostorscore=0 mlxlogscore=953 mlxscore=0 bulkscore=0 priorityscore=1501 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410220074 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 02:26:53 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 4C3561A0706; Tue, 22 Oct 2024 12:06:18 +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=1729598781; cv=none; b=olkbCYhKoECRgHtiJT8A8WTdholRaN1Agyvx5c0vQXJjWr6eXcHrFjUicNqFjxFO0ju9hNV2lSbaEG1dHGYkN//iROu1MpFMc4KDQ4KmCm7Y6HtALWOa5ZG/h7hn5BY+4QAM5RgUTWpUJXYSNCbVvrSmdCwpxt/pll+rO9uSUAQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729598781; c=relaxed/simple; bh=OD/CTOrwcg6OiHs7buhnlA46yO9ruiybpAnnQ2ioFXg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tZunYYFLHtH7QHp3X+3W3hVRwgbeS13vLMmgz8f6qzMAI4lq5YLb9Xi2fkLQmAsrHaCoXk3XlOO78uHT3CYSpuQvBjnynPeM6vROzgylVQnB+buS8IVstUSSrjULIfpiE3aJIDT5mSRBBTVQnKCkKdgCRbQ8UWDJRPBzTZE81Ys= 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=hcswGXHZ; 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="hcswGXHZ" 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 49M2HjYa006796; Tue, 22 Oct 2024 12:06:17 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=hcswGXHZWpEsGBiVwX1ZlSZ8JIgQBPZ5z l4qYVVskoVTmYnWRIl6N4nEuSaJ7RADZY5GPe1i3LKo0jHNfWMYAvLieiv6nk8ie fJQNHW1TAJ6kAKkj8Un42T+T7CCPoJTPAtjE/YOgF7oGdDr9X8ifbcuNmCuLA6D+ lFgrnnBffCJSvlMRX/uq2naAtIR/QxZzVUdwanVGo55jNva6BxuyvfSgFFBHqmRF GVMG9ho50XGD2c6e0DYC/2nazPFkuq/oXmzNPbVv++lp5zgtVI6MRNTBuq0Bh3vx fg49MaBEV3gkcgyXWysSO5fe/YVhT6xdmlnYGSqVlykNm8hM8oZjw== Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 42c5fcnqf5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Oct 2024 12:06:16 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 49MBGvkj023927; Tue, 22 Oct 2024 12:06:15 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 42cst12scw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Oct 2024 12:06:15 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 49MC6Ckr55050594 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Oct 2024 12:06:12 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 84ED420040; Tue, 22 Oct 2024 12:06:12 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ADA082004B; Tue, 22 Oct 2024 12:06:11 +0000 (GMT) Received: from p-imbrenda.ibmuc.com (unknown [9.171.37.93]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 22 Oct 2024 12:06:11 +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, david@redhat.com Subject: [PATCH v4 11/11] s390/mm: Convert to LOCK_MM_AND_FIND_VMA Date: Tue, 22 Oct 2024 14:06:01 +0200 Message-ID: <20241022120601.167009-12-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241022120601.167009-1-imbrenda@linux.ibm.com> References: <20241022120601.167009-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: wvpmKYq1BQyazEQmuq0JDh8QT7Y17-eg X-Proofpoint-GUID: wvpmKYq1BQyazEQmuq0JDh8QT7Y17-eg 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 bulkscore=0 mlxscore=0 clxscore=1015 mlxlogscore=641 phishscore=0 impostorscore=0 malwarescore=0 lowpriorityscore=0 adultscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410220074 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