From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BA55F486BAE; Thu, 27 Aug 2026 15:53:08 +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=1787845990; cv=none; b=oCoqG4YllJBWwzXWxYDZX5qDp5crcvnlPQZTMQQSoaFnMCRvb+FREuuX1SmDOFQ1+FUX6OEeFhvSTGLvHybiCNmrWljIl9UhH6MkizXXTC/SAPdIx+82RPZ3oTm4hsT8BmM8097cfi9BiIX0cD3XPkle94CG7JFJ8FIH0qNTd3o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787845990; c=relaxed/simple; bh=1d/ElOgjNWOLvso2yHSfNvLdQTtu69dW57Nfq5pIx14=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=d3Wewdiqy8KC6MeUsEELL8khZZBnmmXFt6sYkBkIG/uJo2i+hKjuQ2z9kwsjIorNKm8y1uE8p2Xra0ZcKLsie3AuP6BWQnthkq5VCV3nZJxyEbXSwMaKnqkl98Im+xBbnn7O1Y2xp1rjk1xyg4YHD4nza677Gm3lAnoeTDc/sLE= 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=mHj5/iqY; 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="mHj5/iqY" Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67RF5BLB3329014; Thu, 27 Aug 2026 15:53:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=XI8aiu VtwtLBDksj07nEbzOSbLHJGk8g4GudQzZ7BbQ=; b=mHj5/iqYviY74PQY6jOGZA pT2iyyfgjTFgV4Nsy/mWjHkIA7LKhVfdK4Hi7dOISXatD7/l+DCSSdD2pehY+GiJ K5ikuqPRWUc0qmyyTVI3cw+c5P9Ka4H1ukDx92rYoWCCtvpRU5b8yWUdFzyASzF4 ovMv8h2Yn80aSk/Kr5hKBBjappmdM+j/E4h5DOERa7E6bM75XYwdiEl1P5fGvm1Z 7RW1GSjmc93VGxiupHH7mArt7vqCuXIp2A8fjp9G25yWV5tWINmQ8KHPfRkQg1wO 62E8psRKcTDfG9wiTpw5/lW9mU5AUmL9RdkaddG0hAQy5meX3c8A80F8U7QSwj2A == 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 4g7394eef6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 27 Aug 2026 15:53:05 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 67RFfkwE008875; Thu, 27 Aug 2026 15:53:04 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4g7rsygm9k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 27 Aug 2026 15:53:04 +0000 (GMT) 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 67RFr0iH47579548 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 27 Aug 2026 15:53:00 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 63D712004B; Thu, 27 Aug 2026 15:53:00 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A416D20043; Thu, 27 Aug 2026 15:52:59 +0000 (GMT) Received: from [192.168.88.251] (unknown [9.111.61.153]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 27 Aug 2026 15:52:59 +0000 (GMT) From: Christoph Schlameuss Date: Thu, 27 Aug 2026 17:52:48 +0200 Subject: [PATCH v6 08/21] KVM: s390: vsie: Create helpers to alloc and free vsie_pages Precedence: bulk X-Mailing-List: linux-s390@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260827-vsie-sigpi-v6-8-8020bb53be52@linux.ibm.com> References: <20260827-vsie-sigpi-v6-0-8020bb53be52@linux.ibm.com> In-Reply-To: <20260827-vsie-sigpi-v6-0-8020bb53be52@linux.ibm.com> To: kvm@vger.kernel.org, linux-s390@vger.kernel.org Cc: Alexander Gordeev , Christian Borntraeger , Claudio Imbrenda , David Hildenbrand , Eric Farman , Heiko Carstens , Janosch Frank , Nico Boehr , Sven Schnelle , Vasily Gorbik , Paolo Bonzini , Shuah Khan , Sean Christopherson , Christoph Schlameuss X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2511; i=schlameuss@linux.ibm.com; h=from:subject:message-id; bh=1d/ElOgjNWOLvso2yHSfNvLdQTtu69dW57Nfq5pIx14=; b=owGbwMvMwCUmoqVx+bqN+mXG02pJDFkTYoM+W8QdWyS6cVcc56yLy2J2/M/rUH597+ON3cWq2 g8WZR6901HKwiDGxSArpshSLW6dV9XXunTOQctrMHNYmUCGMHBxCsBELh5m+J8VM7X3KfdB++JJ qsv/zrpUany6iV1Iq/fT7y3+IS8bvj5n+MNbZcgVJHeFY9WbWZNut4jJffqaFq0qapCYPaWytfl zBScA X-Developer-Key: i=schlameuss@linux.ibm.com; a=openpgp; fpr=0E34A68642574B2253AF4D31EEED6AB388551EC3 X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-GUID: 4hSbxBYE4VM53YsQimAwXq78qIuZUJZi X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODI3MDEzMSBTYWx0ZWRfX+pt1y5hiMY/1 d7RZsZe/iKS1nrm7IryResmZDcyIMyt9qYH74ldIGJgzvb4Bf2Z6TKbVqcQmI7fhF95oloUALAE Dlh+GQ+O1ojm+/qTUlVawW2XskuVfTWNyEEbPYb3InkEjEa3bspkBIEmJlFViQ6SXiftZn4zfPx 4dnCZN/d54Uu+WFJ0e61y2Pu6t/f5ft/P8JqEUhF0laHFh9NGfh5bwYVF7s3eqOJwaZrcEGfg8C v6JbjbrjLUZE/SanDGeL257kRUHYGcL/MtI6LzkrgbCeFJJBe3XjVme89iWx96frB4lHEuXkMU/ wC+9LqhveuUkG+DcpKwmTIKSnBdkU2TMObUi/27oJGlUC57+T53UD4E5uvm+zV3GUlnqDDFDlax 3QusHX0otVhD1JWXfDPsZnYyft6Rsql9xY+MxhkhYwWE7tgvSwgbWte5r3aAroFN+bTrkv9+chy H7sFHBT/vTcxV4cUg0g== X-Authority-Analysis: v=2.4 cv=Y/nIdBeN c=1 sm=1 tr=0 ts=6a905d61 cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=VnNF1IyMAAAA:8 a=-UiXzxHpo5ppJV-mmbwA:9 a=QEXdDO2ut3YA:10 X-Proofpoint-Spam-Info: AW1haW4tMjYwODI3MDEzMSBTYWx0ZWRfXw41Lv1R+Wb/i 0/gt5g8OaDFYijGvuwTBFp1BQPYOXCAMBaYMjlZQbfcv9uXH407C5ToCHh/ZNp8cc661F+Anol8 i3yEIWTbzqkY85FrXGg+WzeZxriDOb8= X-Proofpoint-ORIG-GUID: gb6xPs2oRP0IpbqOA-VrY-1SaNGpaBsN X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-27_06,2026-08-27_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 impostorscore=0 priorityscore=1501 adultscore=0 bulkscore=0 suspectscore=0 malwarescore=0 clxscore=1015 lowpriorityscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608270131 Encapsulate allocation of struct vsie_page and free into its own methods to allow this from multiple code paths. Signed-off-by: Christoph Schlameuss --- arch/s390/kvm/s390/vsie.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/arch/s390/kvm/s390/vsie.c b/arch/s390/kvm/s390/vsie.c index afc2e56fcabf..e7005bade757 100644 --- a/arch/s390/kvm/s390/vsie.c +++ b/arch/s390/kvm/s390/vsie.c @@ -1502,6 +1502,24 @@ static void put_vsie_page(struct vsie_page *vsie_page) clear_bit(VSIE_PAGE_IN_USE, &vsie_page->flags); } +static void free_vsie_page(struct vsie_page *vsie_page) +{ + free_page((unsigned long)vsie_page); +} + +static struct vsie_page *alloc_vsie_page(struct kvm *kvm) +{ + struct vsie_page *vsie_page; + + vsie_page = (struct vsie_page *)__get_free_page(GFP_KERNEL_ACCOUNT | __GFP_ZERO | GFP_DMA); + if (!vsie_page) + return vsie_page; + + /* Mark it as invalid until it resides in the tree. */ + vsie_page->scb_gpa = ULONG_MAX; + return vsie_page; +} + /* * Get or create a vsie page for a scb address. * @@ -1537,7 +1555,7 @@ static struct vsie_page *get_vsie_page(struct kvm *kvm, unsigned long addr) mutex_lock(&kvm->arch.vsie.mutex); if (kvm->arch.vsie.page_count < nr_vcpus) { - vsie_page = (void *)__get_free_page(GFP_KERNEL_ACCOUNT | __GFP_ZERO | GFP_DMA); + vsie_page = alloc_vsie_page(kvm); if (!vsie_page) { mutex_unlock(&kvm->arch.vsie.mutex); return ERR_PTR(-ENOMEM); @@ -1557,9 +1575,9 @@ static struct vsie_page *get_vsie_page(struct kvm *kvm, unsigned long addr) if (vsie_page->scb_gpa != ULONG_MAX) radix_tree_delete(&kvm->arch.vsie.addr_to_page, vsie_page->scb_gpa >> SCB_ALIGNMENT_SHIFT); + /* Mark it as invalid until it resides in the tree. */ + vsie_page->scb_gpa = ULONG_MAX; } - /* Mark it as invalid until it resides in the tree. */ - vsie_page->scb_gpa = ULONG_MAX; /* Double use of the same address or allocation failure. */ if (radix_tree_insert(&kvm->arch.vsie.addr_to_page, addr >> SCB_ALIGNMENT_SHIFT, @@ -1662,7 +1680,7 @@ void kvm_s390_vsie_destroy(struct kvm *kvm) if (vsie_page->scb_gpa != ULONG_MAX) radix_tree_delete(&kvm->arch.vsie.addr_to_page, vsie_page->scb_gpa >> SCB_ALIGNMENT_SHIFT); - free_page((unsigned long)vsie_page); + free_vsie_page(vsie_page); } kvm->arch.vsie.page_count = 0; mutex_unlock(&kvm->arch.vsie.mutex); -- 2.55.0