From patchwork Thu Jul 11 11:00:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 13730395 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 7216D16D321; Thu, 11 Jul 2024 11:08:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720696120; cv=none; b=O6GYESEM8rhpKjwVRiujDmJO0MS4+j2tRTkqfZMGGxxkYxy7o0xrnO+Y/stIcStckAbBpsoCp1parn53fWiC2Ba8wg/8nWQgf1FCNhcVW8Gs3y/15JWxghXlGp9kjJ0rXXzYnNK8amLiOH/Pez3dMOQTj6geHJZfobvYNIoGoBs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720696120; c=relaxed/simple; bh=yh0BHoY1BLA0lcs0XgvzlpB4DY9vXmV+XIWT4bVZ9cA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SUOm0MPZk68QIes/h+YAov9jrRGypsRFjsE5vxbKEpEqDCE+JslnTS99+GBxCZs3D7TzmQQS9l/qVF4pvQSfyWqxMCnHXY2wsRSDam+IcaNPZlhAISfNOxq8NPWlGh1bIAFny96SCIIx+X0GvqjyIHcakrjkd/T/mQhKh6k8Jmo= 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=ZlCWpqIK; 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="ZlCWpqIK" Received: from pps.filterd (m0353728.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46BAueU8001374; Thu, 11 Jul 2024 11:08:36 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:mime-version; s=pp1; bh=SDm7egWgGB+6P F0dXLEK+dmNsE1P6KTHHxIBAVf+qYE=; b=ZlCWpqIK6HjnBMCQKiIU8h5CUzuQ1 SdvWX+N013P8b2arw1utymPNrDRcccshxwdoyBRLAXdWoUAdeW5kVnHt79BNAaF7 as7U5rPIv0YwnCRQ9nvTLUOtRhiDtDMKrFiq0siF0QohOhjaePuSfi7xa2skVfXl VQnyTlK9dcd7EHu7uA+4OKFl7YN9yZ2nH0TO5k68sqBEtQVVLSyNg82H1AykRIz6 XIybwkInoec75yGtADN/H/lSSOq0aM3VGZpQ+d7SNW6UJi0Ct1qChTxWl+qOAgY/ sZv9CJLG2qWKObXL6lRMH2lOk7W8mMs6q2ZLLwqVF5uDBypDrctXuNcpQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 40adnvg2r7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Jul 2024 11:08:36 +0000 (GMT) Received: from m0353728.ppops.net (m0353728.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 46BB8a3A018802; Thu, 11 Jul 2024 11:08:36 GMT 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 40adnvg2r5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Jul 2024 11:08:36 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 46B7V3Ob024690; Thu, 11 Jul 2024 11:08:35 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 407g8ugmq0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Jul 2024 11:08:35 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 46BB8TIF52101618 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Jul 2024 11:08:31 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A479520040; Thu, 11 Jul 2024 11:08:29 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 714802004B; Thu, 11 Jul 2024 11:08:29 +0000 (GMT) Received: from li-9fd7f64c-3205-11b2-a85c-df942b00d78d.boeblingen.de.ibm.com (unknown [9.152.224.253]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 11 Jul 2024 11:08:29 +0000 (GMT) From: Janosch Frank To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, david@redhat.com, borntraeger@linux.ibm.com, cohuck@redhat.com, linux-s390@vger.kernel.org, imbrenda@linux.ibm.com Subject: [GIT PULL 1/3] KVM: s390: remove useless include Date: Thu, 11 Jul 2024 13:00:04 +0200 Message-ID: <20240711110654.40152-2-frankja@linux.ibm.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240711110654.40152-1-frankja@linux.ibm.com> References: <20240711110654.40152-1-frankja@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: iSOoIhkAmV9gGjZBnUnBmaQ4fLx8fZaF X-Proofpoint-GUID: rGqPOvUYjHiVmpJ_CdWfuuSnJbhAgyDR X-Proofpoint-UnRewURL: 0 URL was un-rewritten Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-11_06,2024-07-11_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 clxscore=1015 adultscore=0 suspectscore=0 priorityscore=1501 impostorscore=0 mlxlogscore=274 phishscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2407110077 From: Claudio Imbrenda arch/s390/include/asm/kvm_host.h includes linux/kvm_host.h, but linux/kvm_host.h includes asm/kvm_host.h . It turns out that arch/s390/include/asm/kvm_host.h only needs linux/kvm_types.h, which it already includes. Stop including linux/kvm_host.h from arch/s390/include/asm/kvm_host.h . Due to the #ifdef guards, the code works as it is today, but it's ugly and it will get in the way of future patches. Signed-off-by: Claudio Imbrenda Reviewed-by: Janosch Frank Reviewed-by: Nico Boehr Link: https://lore.kernel.org/r/20240702155606.71398-1-imbrenda@linux.ibm.com Signed-off-by: Janosch Frank Message-ID: <20240702155606.71398-1-imbrenda@linux.ibm.com> --- arch/s390/include/asm/kvm_host.h | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h index 95990461888f..736cc88f497d 100644 --- a/arch/s390/include/asm/kvm_host.h +++ b/arch/s390/include/asm/kvm_host.h @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include From patchwork Thu Jul 11 11:00:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 13730397 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 AE7B316D4EA; Thu, 11 Jul 2024 11:08:38 +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=1720696121; cv=none; b=KvvK46PNPZ9OqaXoueizUn0VbRggw0GEH8SpFkmZ9U6vSTBC813D2OHqvLfFsF+qhGx4kc10zDbM5Qj/c5dt7CTCTJ6jJSiMiNT/oROiVq0WsP+7Uxy5BwTGpAbWDNEsbrSNB21zMeoONFNb/u6SK3YdHgmnrqaF1XpTvOfBfeQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720696121; c=relaxed/simple; bh=IABTRFxquWcoENQEtDDW3l3TEiDDy6sa2JNxbsmZd/U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GzXHVoYoePrthB4TBunOhhXYx8kE4QsGnMXC3kdS+eTpkufOAD7TGhKdIbaIaA3Z1Px7AQgXjPmjHkPTtOem3MOwBs7w/wHcY+q9MZwP7a3n5QoJHDpi4dtm9/7Kj61ah0CqPyJnbE8tGVjcSsTE/1s0tKrYjOuvMy3x5wbGVzM= 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=Uo8nZKiU; 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="Uo8nZKiU" Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46BARGpv023217; Thu, 11 Jul 2024 11:08:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:mime-version; s=pp1; bh=TXpiNzJHmycEc Bq86ON7M/jx2YamGeA/2VUwOpU/VgI=; b=Uo8nZKiUMVZR3+C3M/8OSA0lXCL0t DTqh3AEqEZhb1EjMfdqzJbApiqF9vpJ6Ex3rrugyvMbn1I/WS6mjl/cx6+Z+UtAN 3yoOMsFgc1sbnNE52lwMXKIBl+63bRpK96B3IsnkgGQztG1A+6jaJgW1wt05SJ7x ZGftlEmxdlYfmGXKRgqAJDpsmHck3tHcwjQxL4CMy2hzkB4COO+afgME5J+a34ZH BvSm6HKyTPW+b90XROblmaysBUuuhliBaaVXZUZMPO2r7P8WJdu4V+L/Kmm9xeGC FuZtnIONe6ZHLIg6t5EhWe4yS9JRqNPrSmsreUGcl7IuiIGpt/ejrZW0Q== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 40abwm8a20-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Jul 2024 11:08:37 +0000 (GMT) Received: from m0353729.ppops.net (m0353729.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 46BB8bCS017463; Thu, 11 Jul 2024 11:08:37 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 40abwm8a1y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Jul 2024 11:08:37 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 46B7vfGG013901; Thu, 11 Jul 2024 11:08:35 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 407gn10kbf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Jul 2024 11:08:35 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 46BB8UpI55706032 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Jul 2024 11:08:32 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E4F5C2004B; Thu, 11 Jul 2024 11:08:29 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AE2052004D; Thu, 11 Jul 2024 11:08:29 +0000 (GMT) Received: from li-9fd7f64c-3205-11b2-a85c-df942b00d78d.boeblingen.de.ibm.com (unknown [9.152.224.253]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 11 Jul 2024 11:08:29 +0000 (GMT) From: Janosch Frank To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, david@redhat.com, borntraeger@linux.ibm.com, cohuck@redhat.com, linux-s390@vger.kernel.org, imbrenda@linux.ibm.com Subject: [GIT PULL 2/3] KVM: s390: vsie: retry SIE instruction on host intercepts Date: Thu, 11 Jul 2024 13:00:05 +0200 Message-ID: <20240711110654.40152-3-frankja@linux.ibm.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240711110654.40152-1-frankja@linux.ibm.com> References: <20240711110654.40152-1-frankja@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 6GYP1UT8Uib4f4Jdb0ujA7RIrcu5djoq X-Proofpoint-ORIG-GUID: AVTjD2wkEPjIb4TH8tTC1pfM5CIsLMeE X-Proofpoint-UnRewURL: 0 URL was un-rewritten Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-11_06,2024-07-11_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 mlxlogscore=599 lowpriorityscore=0 adultscore=0 malwarescore=0 mlxscore=0 priorityscore=1501 phishscore=0 impostorscore=0 clxscore=1015 suspectscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2407110077 From: Eric Farman It's possible that SIE exits for work that the host needs to perform rather than something that is intended for the guest. A Linux guest will ignore this intercept code since there is nothing for it to do, but a more robust solution would rewind the PSW back to the SIE instruction. This will transparently resume the guest once the host completes its work, without the guest needing to process what is effectively a NOP and re-issue SIE itself. Signed-off-by: Eric Farman Acked-by: Christian Borntraeger Link: https://lore.kernel.org/r/20240301204342.3217540-1-farman@linux.ibm.com Signed-off-by: Janosch Frank Message-ID: <20240301204342.3217540-1-farman@linux.ibm.com> --- arch/s390/kvm/vsie.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/arch/s390/kvm/vsie.c b/arch/s390/kvm/vsie.c index c9ecae830634..54deafd0d698 100644 --- a/arch/s390/kvm/vsie.c +++ b/arch/s390/kvm/vsie.c @@ -1304,10 +1304,24 @@ static int vsie_run(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page) if (rc == -EAGAIN) rc = 0; - if (rc || scb_s->icptcode || signal_pending(current) || - kvm_s390_vcpu_has_irq(vcpu, 0) || - kvm_s390_vcpu_sie_inhibited(vcpu)) + + /* + * Exit the loop if the guest needs to process the intercept + */ + if (rc || scb_s->icptcode) break; + + /* + * Exit the loop if the host needs to process an intercept, + * but rewind the PSW to re-enter SIE once that's completed + * instead of passing a "no action" intercept to the guest. + */ + if (signal_pending(current) || + kvm_s390_vcpu_has_irq(vcpu, 0) || + kvm_s390_vcpu_sie_inhibited(vcpu)) { + kvm_s390_rewind_psw(vcpu, 4); + break; + } cond_resched(); } @@ -1426,8 +1440,10 @@ int kvm_s390_handle_vsie(struct kvm_vcpu *vcpu) return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION); if (signal_pending(current) || kvm_s390_vcpu_has_irq(vcpu, 0) || - kvm_s390_vcpu_sie_inhibited(vcpu)) + kvm_s390_vcpu_sie_inhibited(vcpu)) { + kvm_s390_rewind_psw(vcpu, 4); return 0; + } vsie_page = get_vsie_page(vcpu->kvm, scb_addr); if (IS_ERR(vsie_page)) From patchwork Thu Jul 11 11:00:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 13730398 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 92C4316D4E7; Thu, 11 Jul 2024 11:08:38 +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=1720696122; cv=none; b=JHNxRnOp2Va1sHLYzblE1VkxomcGhpn4Jy9jNUp1ATEMyIcSmwDDvwWFdtBKjYW2e74SZJgORHfJj0eLXU/UhJWNOwKr04dPCCY3axu9vGZFdKh6owqiMWpsc47Mvl3x8+fCB+E3S4QUunieqYB5CNGl1P4uSZJYMls9QO6sqBw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720696122; c=relaxed/simple; bh=tJ0WDaiZSrkoDFfUfrvBOPR6uQJKoP7k3abyg6RnqWA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Aevl8aMcGHmRpj3WC0KbEiU+7LiN1KFsjA0Gaq2yS/0PFc4MTszmp3c4bLlBw3L3Sv/VjwUgCivwunNNKnuljx6nK+b6Q/caNfKyns8+z/RYxnEUiu2kvhfkWzoz/0X2GJFm38KrGIzaJnFyR2i4UvE52j0KapNo4gucIQJUJzk= 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=a2OB7XMw; 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="a2OB7XMw" 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 46B9wOxt030314; Thu, 11 Jul 2024 11:08:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:mime-version; s=pp1; bh=YwZzhwTzf2kTd BYM1RNQrc86wmNw0u6u6titRLNClHo=; b=a2OB7XMwPssAVpcxMvk9jZ+6Pgmlx v4+n0WiuK1+7T870PMNbl5VSMnxaQZezvokrvy5OrDyEbiFFOY2Qi365X0kfv0kl UCZlHDydky/yAmujU7oQ5Cb8bTXHzZDqa5jWzUEzinPT9PY6oZAI6FD0yXTuDgvi s4ijDZcc4hDyU3skfm+vU9K1DQQ6mmUQzzJabPMogTHL0utft8GHXaSGLZPZa16E 6kx/LJ1vHGZ8pq1FAkBYTV3470/5MUX/pnjmUewa3YeqKCLhyjt0LaU5Hm2YLOdZ juCINx3lT8ZFq6vRNJK3qStJeLPaTkTTEUIy3k9jIOw5p8vEWEKjqvvEw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 40ad7ur5cd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Jul 2024 11:08:36 +0000 (GMT) Received: from m0356516.ppops.net (m0356516.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 46BB8a0D004322; Thu, 11 Jul 2024 11:08:36 GMT 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 40ad7ur5cc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Jul 2024 11:08:36 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 46BABVUk014004; Thu, 11 Jul 2024 11:08:35 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 407jy3g236-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Jul 2024 11:08:35 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 46BB8U8953543254 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Jul 2024 11:08:32 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 30FA42004D; Thu, 11 Jul 2024 11:08:30 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EE0832004E; Thu, 11 Jul 2024 11:08:29 +0000 (GMT) Received: from li-9fd7f64c-3205-11b2-a85c-df942b00d78d.boeblingen.de.ibm.com (unknown [9.152.224.253]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 11 Jul 2024 11:08:29 +0000 (GMT) From: Janosch Frank To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, david@redhat.com, borntraeger@linux.ibm.com, cohuck@redhat.com, linux-s390@vger.kernel.org, imbrenda@linux.ibm.com Subject: [GIT PULL 3/3] kvm: s390: Reject memory region operations for ucontrol VMs Date: Thu, 11 Jul 2024 13:00:06 +0200 Message-ID: <20240711110654.40152-4-frankja@linux.ibm.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240711110654.40152-1-frankja@linux.ibm.com> References: <20240711110654.40152-1-frankja@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Jf6ec76ceP6sD6Yf-QdVuP3hp1YjxGno X-Proofpoint-ORIG-GUID: LkL1XTZSh4nh45XY8HNDd1TNSBKU5DZU X-Proofpoint-UnRewURL: 0 URL was un-rewritten Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-11_06,2024-07-11_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 clxscore=1015 bulkscore=0 malwarescore=0 lowpriorityscore=0 spamscore=0 adultscore=0 mlxscore=0 mlxlogscore=725 phishscore=0 suspectscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2407110077 From: Christoph Schlameuss This change rejects the KVM_SET_USER_MEMORY_REGION and KVM_SET_USER_MEMORY_REGION2 ioctls when called on a ucontrol VM. This is necessary since ucontrol VMs have kvm->arch.gmap set to 0 and would thus result in a null pointer dereference further in. Memory management needs to be performed in userspace and using the ioctls KVM_S390_UCAS_MAP and KVM_S390_UCAS_UNMAP. Also improve s390 specific documentation for KVM_SET_USER_MEMORY_REGION and KVM_SET_USER_MEMORY_REGION2. Signed-off-by: Christoph Schlameuss Fixes: 27e0393f15fc ("KVM: s390: ucontrol: per vcpu address spaces") Reviewed-by: Claudio Imbrenda Link: https://lore.kernel.org/r/20240624095902.29375-1-schlameuss@linux.ibm.com Signed-off-by: Janosch Frank [frankja@linux.ibm.com: commit message spelling fix, subject prefix fix] Message-ID: <20240624095902.29375-1-schlameuss@linux.ibm.com> --- Documentation/virt/kvm/api.rst | 12 ++++++++++++ arch/s390/kvm/kvm-s390.c | 3 +++ 2 files changed, 15 insertions(+) diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst index a71d91978d9e..eec8df1dde06 100644 --- a/Documentation/virt/kvm/api.rst +++ b/Documentation/virt/kvm/api.rst @@ -1403,6 +1403,12 @@ Instead, an abort (data abort if the cause of the page-table update was a load or a store, instruction abort if it was an instruction fetch) is injected in the guest. +S390: +^^^^^ + +Returns -EINVAL if the VM has the KVM_VM_S390_UCONTROL flag set. +Returns -EINVAL if called on a protected VM. + 4.36 KVM_SET_TSS_ADDR --------------------- @@ -6273,6 +6279,12 @@ state. At VM creation time, all memory is shared, i.e. the PRIVATE attribute is '0' for all gfns. Userspace can control whether memory is shared/private by toggling KVM_MEMORY_ATTRIBUTE_PRIVATE via KVM_SET_MEMORY_ATTRIBUTES as needed. +S390: +^^^^^ + +Returns -EINVAL if the VM has the KVM_VM_S390_UCONTROL flag set. +Returns -EINVAL if called on a protected VM. + 4.141 KVM_SET_MEMORY_ATTRIBUTES ------------------------------- diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index 82e9631cd9ef..854d0d1410be 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -5748,6 +5748,9 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm, { gpa_t size; + if (kvm_is_ucontrol(kvm)) + return -EINVAL; + /* When we are protected, we should not change the memory slots */ if (kvm_s390_pv_get_handle(kvm)) return -EINVAL;