From patchwork Mon Dec 9 11:07:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Schlameuss X-Patchwork-Id: 13899329 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 A817621D015; Mon, 9 Dec 2024 11:07:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733742454; cv=none; b=EBCYHezaoDItqJpVcPq3grQ7oju10/PlIpeut++tJrS+y7fTdvvSimh71WyrixmVGIuyVvZs0JBz6SQ3FODlM83v8YnQydVcURMAYGaCevpBg8JoVHOGgJnUUPeWjjuvYCxZCFFUdpYC6/GsTnemYoWoItfrCkuwgpufdPE+WOs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733742454; c=relaxed/simple; bh=SkohOH3IVePyGW8+1NVUsviezzJw9M7C9age5bPnX2Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R+DU20zAXUMPT/eH46cXeJ9XwWsNjq8lNxR5sYpJ2KK2nVNlfpAECnFleWHL5iLnIOQvkzcMryQCnRmJuQErg8Ddrhyp0lUc1CZF3nlkz39NZxtyOozPNi02GJNTS7iaMkSwt0S9GZEZikwd6OurjKMDtT+3HQof/HWv48IDl+4= 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=hsjJyd9D; 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="hsjJyd9D" 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 4B9Aei9k011210; Mon, 9 Dec 2024 11:07:27 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=7nm06ya67cLBtHkdT Dq/1GFvduq1/+F3RDKhiAtAoaE=; b=hsjJyd9DAcvp6kT6rKA8DWTOiLJaZP4Ds 6WlcUAwHCQXpzIAOxyRlxNgqepij+Lpv2kEBdlhBHZRl3IJAXCpdNd9mp5YraSmB vslAS5eF5gNjl9PE0YztX8p7ZE2R91rKhQsJ8Uhbwy8Xc58qLo29uc2DZqhjiqln c5jcLC3cd7vIz3k30GSCh2mfbI1v87Y9lBFo0DBEAJ3XOZ/7sSwV+W1V/1fG/sQe fU63BAV+fhr7zOhw/F7f6CcKG5RIlvJeMB74Ure83yx3t50BNQBK27fDw7e+7eCy dZuFaVnrwIM8vl3fKZdu0M0FOOI1bWmS59BQvPoKjS4CgVoo7d0/g== 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 43cbsq0anf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Dec 2024 11:07:27 +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 4B982Hdg017428; Mon, 9 Dec 2024 11:07:26 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 43d3d1dxa9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Dec 2024 11:07:26 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4B9B7Ni942205666 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 9 Dec 2024 11:07:23 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5C9AF2004B; Mon, 9 Dec 2024 11:07:23 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D452B20040; Mon, 9 Dec 2024 11:07:22 +0000 (GMT) Received: from darkmoore.ibmuc.com (unknown [9.179.10.206]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 9 Dec 2024 11:07:22 +0000 (GMT) From: Christoph Schlameuss To: kvm@vger.kernel.org Cc: Christian Borntraeger , Janosch Frank , Claudio Imbrenda , David Hildenbrand , Paolo Bonzini , Shuah Khan , linux-s390@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v1 1/6] kvm: s390: Reject setting flic pfault attributes on ucontrol VMs Date: Mon, 9 Dec 2024 12:07:12 +0100 Message-ID: <20241209110717.77279-2-schlameuss@linux.ibm.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241209110717.77279-1-schlameuss@linux.ibm.com> References: <20241209110717.77279-1-schlameuss@linux.ibm.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: A1rZHKnIRmuBnPi4inbGRHfBniPZpoyb X-Proofpoint-GUID: A1rZHKnIRmuBnPi4inbGRHfBniPZpoyb X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=452 adultscore=0 lowpriorityscore=0 clxscore=1015 phishscore=0 impostorscore=0 suspectscore=0 spamscore=0 mlxscore=0 priorityscore=1501 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2412090086 Prevent null pointer dereference when processing the KVM_DEV_FLIC_APF_ENABLE and KVM_DEV_FLIC_APF_DISABLE_WAIT ioctls in the interrupt controller. Reported-by: Claudio Imbrenda Signed-off-by: Christoph Schlameuss --- arch/s390/kvm/interrupt.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c index ea8dce299954..22d73c13e555 100644 --- a/arch/s390/kvm/interrupt.c +++ b/arch/s390/kvm/interrupt.c @@ -2678,9 +2678,13 @@ static int flic_set_attr(struct kvm_device *dev, struct kvm_device_attr *attr) kvm_s390_clear_float_irqs(dev->kvm); break; case KVM_DEV_FLIC_APF_ENABLE: + if (kvm_is_ucontrol(dev->kvm)) + return -EINVAL; dev->kvm->arch.gmap->pfault_enabled = 1; break; case KVM_DEV_FLIC_APF_DISABLE_WAIT: + if (kvm_is_ucontrol(dev->kvm)) + return -EINVAL; dev->kvm->arch.gmap->pfault_enabled = 0; /* * Make sure no async faults are in transition when From patchwork Mon Dec 9 11:07:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Schlameuss X-Patchwork-Id: 13899331 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 259DD21D01F; Mon, 9 Dec 2024 11:07:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733742454; cv=none; b=kgbaDllTdjZC1KvZ1FnytgpEwXlXV4Woln4/2syvIhdUU1S2w6gfRwkmA6KWElXPdo1LV/aTjNcpeLJ3gCjyGitJnCJd2IUamv8KZrDbEpRMXrT7NJMIMMWY5XB+NDpY4XjkYue7FfeYMyocOm3nQOcKfEaYSTsEMs4z+/iIyf4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733742454; c=relaxed/simple; bh=H41krADckwSSUM18EDLrvu8Lh4Z+GBPmhDjE0mRRl4U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IqzEXNTYznpRZtmP5x6GBfSZL2x8IdfzW6ROtHsWVLkLGEQ0nLqzZY4nuMsobVLrDXFixyi1k5Es51yD/pig921S1wK1vPNixEsgyGhU11B40swFO+JR4kSIfW7Ioo3Tgtd8e919+zhyGWsJfbGnABhpCIzmqOya4Cvup4XeKME= 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=FEpgqsUW; 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="FEpgqsUW" 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 4B92ZRiE028575; Mon, 9 Dec 2024 11:07:28 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=u0bFFaioMTWO2bOyi BFfn1W5MGQdiyzGiVcKA7z137k=; b=FEpgqsUWIDp4m39fEzw8UW4s2J/fmLFkz LKrZnHQDtNfbhzPL5c++n2bNYTe1cQ58CvvY0OcQrp4f5o1tfjtrF3E8jDY3bKj7 MRUEXusCGjhvlsfaJkB9YDggh4QHcnL70e/iu3uaFUdJGRS3hc8wzgJy5n9yRna/ 55Ud2eJaT48kI2RGuoi7URNqgm+a9gIHJI2TCvr8p1XiqQYuT857+me5i4bt6swD EoX3+OIEc1PjG3Le154H8THOeWcLlzGvwYOCgi8T54KvqcFkiULDz7bYVAer10ws 9m0zV0W9Tq8TJ2odiDWcG0h36ITUo+qeqW2Rh39d7jtM3Sh83eRog== 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 43ccsj84ea-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Dec 2024 11:07:28 +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 4B9AJ7K0032555; Mon, 9 Dec 2024 11:07:27 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 43d1pmx9aa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Dec 2024 11:07:27 +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 4B9B7OuF56426856 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 9 Dec 2024 11:07:24 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E789520043; Mon, 9 Dec 2024 11:07:23 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7268520040; Mon, 9 Dec 2024 11:07:23 +0000 (GMT) Received: from darkmoore.ibmuc.com (unknown [9.179.10.206]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 9 Dec 2024 11:07:23 +0000 (GMT) From: Christoph Schlameuss To: kvm@vger.kernel.org Cc: Christian Borntraeger , Janosch Frank , Claudio Imbrenda , David Hildenbrand , Paolo Bonzini , Shuah Khan , linux-s390@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v1 2/6] selftests: kvm: s390: Add ucontrol flic attr selftests Date: Mon, 9 Dec 2024 12:07:13 +0100 Message-ID: <20241209110717.77279-3-schlameuss@linux.ibm.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241209110717.77279-1-schlameuss@linux.ibm.com> References: <20241209110717.77279-1-schlameuss@linux.ibm.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 7OuncuPyZJiFx9b2RM7hFjgpjHyJaV6z X-Proofpoint-ORIG-GUID: 7OuncuPyZJiFx9b2RM7hFjgpjHyJaV6z X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 adultscore=0 impostorscore=0 spamscore=0 lowpriorityscore=0 bulkscore=0 mlxlogscore=818 mlxscore=0 priorityscore=1501 suspectscore=0 malwarescore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2412090086 Add some superficial selftests for the floating interrupt controller when using ucontrol VMs. These tests are intended to cover very basic calls only. Some of the calls may trigger null pointer dereferences on kernels not containing the fixes in this patch series. Signed-off-by: Christoph Schlameuss --- .../selftests/kvm/s390x/ucontrol_test.c | 150 ++++++++++++++++++ 1 file changed, 150 insertions(+) diff --git a/tools/testing/selftests/kvm/s390x/ucontrol_test.c b/tools/testing/selftests/kvm/s390x/ucontrol_test.c index 0c112319dab1..972fac1023b5 100644 --- a/tools/testing/selftests/kvm/s390x/ucontrol_test.c +++ b/tools/testing/selftests/kvm/s390x/ucontrol_test.c @@ -635,4 +635,154 @@ TEST_F(uc_kvm, uc_skey) uc_assert_diag44(self); } +static char uc_flic_b[PAGE_SIZE]; +static struct kvm_s390_io_adapter uc_flic_ioa = { .id = 0 }; +static struct kvm_s390_io_adapter_req uc_flic_ioam = { .id = 0 }; +static struct kvm_s390_ais_req uc_flic_asim = { .isc = 0 }; +static struct kvm_s390_ais_all uc_flic_asima = { .simm = 0 }; +static struct uc_flic_attr_test { + char *name; + struct kvm_device_attr a; + int hasrc; + u64 getrc; + int geterrno; + u64 setrc; + int seterrno; +} uc_flic_attr_tests[] = { + { + .name = "KVM_DEV_FLIC_GET_ALL_IRQS", + .setrc = 1, .seterrno = EINVAL, + .a = { + .group = KVM_DEV_FLIC_GET_ALL_IRQS, + .addr = (u64)&uc_flic_b, + .attr = PAGE_SIZE, + }, + }, + { + .name = "KVM_DEV_FLIC_ENQUEUE", + .getrc = 1, .geterrno = EINVAL, + .a = { .group = KVM_DEV_FLIC_ENQUEUE, }, + }, + { + .name = "KVM_DEV_FLIC_CLEAR_IRQS", + .getrc = 1, .geterrno = EINVAL, + .a = { .group = KVM_DEV_FLIC_CLEAR_IRQS, }, + }, + { + .name = "KVM_DEV_FLIC_ADAPTER_REGISTER", + .getrc = 1, .geterrno = EINVAL, + .a = { + .group = KVM_DEV_FLIC_ADAPTER_REGISTER, + .addr = (u64)&uc_flic_ioa, + }, + }, + { + .name = "KVM_DEV_FLIC_ADAPTER_MODIFY", + .getrc = 1, .geterrno = EINVAL, + .setrc = 1, .seterrno = EINVAL, + .a = { + .group = KVM_DEV_FLIC_ADAPTER_MODIFY, + .addr = (u64)&uc_flic_ioam, + .attr = sizeof(uc_flic_ioam), + }, + }, + { + .name = "KVM_DEV_FLIC_CLEAR_IO_IRQ", + .getrc = 1, .geterrno = EINVAL, + .setrc = 1, .seterrno = EINVAL, + .a = { + .group = KVM_DEV_FLIC_CLEAR_IO_IRQ, + .attr = 32, + }, + }, + { + .name = "KVM_DEV_FLIC_AISM", + .getrc = 1, .geterrno = EINVAL, + .setrc = 1, .seterrno = ENOTSUP, + .a = { + .group = KVM_DEV_FLIC_AISM, + .addr = (u64)&uc_flic_asim, + }, + }, + { + .name = "KVM_DEV_FLIC_AIRQ_INJECT", + .getrc = 1, .geterrno = EINVAL, + .a = { .group = KVM_DEV_FLIC_AIRQ_INJECT, }, + }, + { + .name = "KVM_DEV_FLIC_AISM_ALL", + .getrc = 1, .geterrno = ENOTSUP, + .setrc = 1, .seterrno = ENOTSUP, + .a = { + .group = KVM_DEV_FLIC_AISM_ALL, + .addr = (u64)&uc_flic_asima, + .attr = sizeof(uc_flic_asima), + }, + }, + { + .name = "KVM_DEV_FLIC_APF_ENABLE", + .getrc = 1, .geterrno = EINVAL, + .setrc = 1, .seterrno = EINVAL, + .a = { .group = KVM_DEV_FLIC_APF_ENABLE, }, + }, + { + .name = "KVM_DEV_FLIC_APF_DISABLE_WAIT", + .getrc = 1, .geterrno = EINVAL, + .setrc = 1, .seterrno = EINVAL, + .a = { .group = KVM_DEV_FLIC_APF_DISABLE_WAIT, }, + }, +}; + +TEST_F(uc_kvm, uc_flic_attrs) +{ + struct kvm_create_device cd = { .type = KVM_DEV_TYPE_FLIC }; + struct kvm_device_attr attr; + u64 value; + int rc, i; + + rc = ioctl(self->vm_fd, KVM_CREATE_DEVICE, &cd); + ASSERT_EQ(0, rc) TH_LOG("create device failed with err %s (%i)", + strerror(errno), errno); + + for (i = 0; i < ARRAY_SIZE(uc_flic_attr_tests); i++) { + TH_LOG("test %s", uc_flic_attr_tests[i].name); + attr = (struct kvm_device_attr) { + .group = uc_flic_attr_tests[i].a.group, + .attr = uc_flic_attr_tests[i].a.attr, + .addr = uc_flic_attr_tests[i].a.addr, + }; + if (attr.addr == 0) + attr.addr = (u64)&value; + + rc = ioctl(cd.fd, KVM_HAS_DEVICE_ATTR, &attr); + EXPECT_EQ(uc_flic_attr_tests[i].hasrc, !!rc) + TH_LOG("expected dev attr missing %s", + uc_flic_attr_tests[i].name); + + rc = ioctl(cd.fd, KVM_GET_DEVICE_ATTR, &attr); + EXPECT_EQ(uc_flic_attr_tests[i].getrc, !!rc) + TH_LOG("get dev attr rc not expected on %s %s (%i)", + uc_flic_attr_tests[i].name, + strerror(errno), errno); + if (uc_flic_attr_tests[i].geterrno) + EXPECT_EQ(uc_flic_attr_tests[i].geterrno, errno) + TH_LOG("get dev attr errno not expected on %s %s (%i)", + uc_flic_attr_tests[i].name, + strerror(errno), errno); + + rc = ioctl(cd.fd, KVM_SET_DEVICE_ATTR, &attr); + EXPECT_EQ(uc_flic_attr_tests[i].setrc, !!rc) + TH_LOG("set sev attr rc not expected on %s %s (%i)", + uc_flic_attr_tests[i].name, + strerror(errno), errno); + if (uc_flic_attr_tests[i].seterrno) + EXPECT_EQ(uc_flic_attr_tests[i].seterrno, errno) + TH_LOG("set dev attr errno not expected on %s %s (%i)", + uc_flic_attr_tests[i].name, + strerror(errno), errno); + } + + close(cd.fd); +} + TEST_HARNESS_MAIN From patchwork Mon Dec 9 11:07:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Schlameuss X-Patchwork-Id: 13899330 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 F0EC621D019; Mon, 9 Dec 2024 11:07:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733742454; cv=none; b=ZwuOZQse2/5dN4U+wiGpW9CmNOH7asVR+JRCQS9rN+nWWduwS4jMaTw/LSEFL7MKRVbOclI6QiFdrhCzZV4awO3yDyaZzC7eT2mAmw/p5sliZ+c/z+Tn9OfX2ehbNQUYVpgNHbefvaSsF350o+MIIVQJNy06Dyo3j+qLkzY4gN0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733742454; c=relaxed/simple; bh=WPeA4EGDZk+ccGormQuFLlWWzmuKEoE2qZ4QG/URbUQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TF9B84cFdXj7zRKGCLUTvR1p9AVgtV38nKnjXtPk2EIWV4RCp0K/0qPqAzoHfXfbJ6xFB2yNoseH86pd/mrHL7eqLTVxh1WYwUXKCniUYMVIrd38MBI1A/928ePWOv/9XdRmuj8kOiHW8aR2RdhrJ1btwcY137mW9vYbrizk4XQ= 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=Yws98zxI; 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="Yws98zxI" Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4B8NjLpf016921; Mon, 9 Dec 2024 11:07:29 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=58VrcdrLf1Ke/bfKi Tr7jj6voshAvZBLb8cIovv6reg=; b=Yws98zxI+k9VbSmP0hwsd7+y+dV6/YcZG mI051+WYIOm9ab+dWbzE6KX+EkkCOq+sS9NeCg5i+efX6C0R++PifRMpvgNLRsEq sjUoblf2fKPG42iV07O3DvPdonX3e/9KFx7rOXlCgHzc91CH1bP3FG1DzQcJnBgy 3VjKxRKlKe0U/KKU19xdY00HskEzak5uRcYsOIRZv/bRGItLxtYaio33Rewz6qwn q6qNUCzmVBAM78K2JwdyxvVAHFfWPkHABBI1rLbSimSbdKpt8f/gtwKYmaOE/K7u Ukhemm2N9Cum7oxJYP5nJ0xrIffl1JjBXuK4aykNrh86/Svd3FsHQ== 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 43ce38gvhw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Dec 2024 11:07:28 +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 4B97nwNW023029; Mon, 9 Dec 2024 11:07:28 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 43d2wjp17d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Dec 2024 11:07:27 +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 4B9B7OX656426858 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 9 Dec 2024 11:07:24 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 82B0820043; Mon, 9 Dec 2024 11:07:24 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 06E1B20040; Mon, 9 Dec 2024 11:07:24 +0000 (GMT) Received: from darkmoore.ibmuc.com (unknown [9.179.10.206]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 9 Dec 2024 11:07:23 +0000 (GMT) From: Christoph Schlameuss To: kvm@vger.kernel.org Cc: Christian Borntraeger , Janosch Frank , Claudio Imbrenda , David Hildenbrand , Paolo Bonzini , Shuah Khan , linux-s390@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v1 3/6] kvm: s390: Reject KVM_SET_GSI_ROUTING on ucontrol VMs Date: Mon, 9 Dec 2024 12:07:14 +0100 Message-ID: <20241209110717.77279-4-schlameuss@linux.ibm.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241209110717.77279-1-schlameuss@linux.ibm.com> References: <20241209110717.77279-1-schlameuss@linux.ibm.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: xoq6o0zwZdznxpR4-DwN7BjthtbyiDsp X-Proofpoint-ORIG-GUID: xoq6o0zwZdznxpR4-DwN7BjthtbyiDsp 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 adultscore=0 suspectscore=0 spamscore=0 clxscore=1015 priorityscore=1501 lowpriorityscore=0 impostorscore=0 bulkscore=0 mlxscore=0 malwarescore=0 mlxlogscore=599 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2412090086 Prevent null pointer dereference when processing KVM_IRQ_ROUTING_S390_ADAPTER routing entries. The ioctl cannot be processed for ucontrol VMs. Signed-off-by: Christoph Schlameuss --- arch/s390/kvm/interrupt.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c index 22d73c13e555..d4f031e086fc 100644 --- a/arch/s390/kvm/interrupt.c +++ b/arch/s390/kvm/interrupt.c @@ -2898,6 +2898,8 @@ int kvm_set_routing_entry(struct kvm *kvm, switch (ue->type) { /* we store the userspace addresses instead of the guest addresses */ case KVM_IRQ_ROUTING_S390_ADAPTER: + if (kvm_is_ucontrol(kvm)) + return -EINVAL; e->set = set_adapter_int; uaddr = gmap_translate(kvm->arch.gmap, ue->u.adapter.summary_addr); if (uaddr == -EFAULT) From patchwork Mon Dec 9 11:07:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Schlameuss X-Patchwork-Id: 13899332 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 B825421D5A0; Mon, 9 Dec 2024 11:07:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733742455; cv=none; b=Utt+MzEXoK7Q8/aLwmOuGqZGS4Y5AOZMVWEbaKxOFaC0NbSI+4WLUFxyNQ5mCuL5we9O7/yvZ4QcGDwdPEEFNGnE/DwycrBXxVYtztT8pjKIYrhFpfHUwTKbkaPc444sCHFwPebGsggpVHgg7CK6dN07S19WIwu55bk3A0ztgq8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733742455; c=relaxed/simple; bh=6Gb2frNMTdFtRnJsl2x5J3o2gU61aFGEFMpOe4dH5nk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=II5TroGU/FsgRR8sqs/jZES3D2BK0tdeNBUvlFjVBNycuLSDCyXXlMwrW/U98g+85PhLTQTovJZ4/zjIO79L6N/iLn9faxxAZjIft1ma4RATWVHd0RBvOPITRRx5Zy1PN9jirV9pIal4VDJPOB4bfXeTkAtiyTPFBXTjHB4bkMg= 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=Fr5H2cr0; 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="Fr5H2cr0" Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4B8NPOc7015089; Mon, 9 Dec 2024 11:07:29 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=XZLMVfk7zaeLh8YGb mG0xOTw17vUgJUXqAvNpSqpz2g=; b=Fr5H2cr0qQREVIoKJUwcW0ehjAhdvxoIZ l3TMs20ogsTKDaw7txvg4tKd1av1cuSgNRYKMTuG91fVswYmNl5JBDKBVVs2/6eS JCrB4XuM7S8ah5tCvLT5JKJtENZenzh3C3GgVda+1y2NeOCQndyaD80IbgGHNDwJ OQDPeTk/xR6BDFcRwW3AhhEDTi1VWoJ6jgxkZb9ocMYPywroT/FnNGrlH6IwXuG6 zkQWbnfPGZpXwSn4ClZTI5SxGq1lrlgxM4Ox89Ce3xo2FOsd2feicMtgtLmAP0zz xROOCIrr/SdTmt7HcOOgTAaU9M4iGNGkFQJsAKjRPMvKUnExZ0uBA== 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 43ce38gvhy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Dec 2024 11:07:29 +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 4B99WfMF032727; Mon, 9 Dec 2024 11:07:28 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 43d0ps6gh3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Dec 2024 11:07:28 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4B9B7PH516122338 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 9 Dec 2024 11:07:25 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 193E42004E; Mon, 9 Dec 2024 11:07:25 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 97C9420040; Mon, 9 Dec 2024 11:07:24 +0000 (GMT) Received: from darkmoore.ibmuc.com (unknown [9.179.10.206]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 9 Dec 2024 11:07:24 +0000 (GMT) From: Christoph Schlameuss To: kvm@vger.kernel.org Cc: Christian Borntraeger , Janosch Frank , Claudio Imbrenda , David Hildenbrand , Paolo Bonzini , Shuah Khan , linux-s390@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v1 4/6] selftests: kvm: s390: Add ucontrol gis routing test Date: Mon, 9 Dec 2024 12:07:15 +0100 Message-ID: <20241209110717.77279-5-schlameuss@linux.ibm.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241209110717.77279-1-schlameuss@linux.ibm.com> References: <20241209110717.77279-1-schlameuss@linux.ibm.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Zz7L67ECQL1v-IB65n63QpK64grkAPdC X-Proofpoint-ORIG-GUID: Zz7L67ECQL1v-IB65n63QpK64grkAPdC 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 adultscore=0 suspectscore=0 spamscore=0 clxscore=1015 priorityscore=1501 lowpriorityscore=0 impostorscore=0 bulkscore=0 mlxscore=0 malwarescore=0 mlxlogscore=933 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2412090086 Add a selftests for the interrupt routing configuration when using ucontrol VMs. Calling the test may trigger a null pointer dereferences on kernels not containing the fixes in this patch series. Signed-off-by: Christoph Schlameuss --- .../selftests/kvm/s390x/ucontrol_test.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tools/testing/selftests/kvm/s390x/ucontrol_test.c b/tools/testing/selftests/kvm/s390x/ucontrol_test.c index 972fac1023b5..d3a5dbfabade 100644 --- a/tools/testing/selftests/kvm/s390x/ucontrol_test.c +++ b/tools/testing/selftests/kvm/s390x/ucontrol_test.c @@ -785,4 +785,23 @@ TEST_F(uc_kvm, uc_flic_attrs) close(cd.fd); } +TEST_F(uc_kvm, uc_set_gsi_routing) +{ + struct kvm_irq_routing *routing = kvm_gsi_routing_create(); + struct kvm_irq_routing_entry ue = { + .type = KVM_IRQ_ROUTING_S390_ADAPTER, + .gsi = 1, + .u.adapter = (struct kvm_irq_routing_s390_adapter) { + .ind_addr = 0, + }, + }; + int rc; + + routing->entries[0] = ue; + routing->nr = 1; + rc = ioctl(self->vm_fd, KVM_SET_GSI_ROUTING, routing); + ASSERT_EQ(-1, rc) TH_LOG("err %s (%i)", strerror(errno), errno); + ASSERT_EQ(EINVAL, errno) TH_LOG("err %s (%i)", strerror(errno), errno); +} + TEST_HARNESS_MAIN From patchwork Mon Dec 9 11:07:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Schlameuss X-Patchwork-Id: 13899333 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 6BAAE21E092; Mon, 9 Dec 2024 11:07:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733742456; cv=none; b=eILaNXSeDNvim61dCWGdPyaLPdVcp3y9qVcJ7Xp3Ue6zJwbfsb0sO7O1r1g5Zp3rgi+bFKf5RBpoCVPdAobj/0ZgPs2aNdFXU0S3XOrZz4y0h2NT2LnB98roS94bpFyTJp7WiHN4mlIt8ndZHqgL4HFzBp5zVHuvzMbip2fBzpM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733742456; c=relaxed/simple; bh=djd6MJW/2LGfUDl+xDRhSN+G/7HVpLguZkpCu3HFhJY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t8ydMo5a52nbCE6OBpD7oQenHFuldKclruVV+Y4CLg1LjXaARo8n2g256jgirigVFWCTQIZHm2p5Q0F2lQZyoA1id3tdJJm+QtJV3Q4Ee7jkwwclYjVm9aailSLQmKAN8nPQdKvb08Jy+XKoicamPutGEZMWRjwo1Zr33Yj6miU= 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=JfDIbA4/; 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="JfDIbA4/" 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 4B8MotfM008466; Mon, 9 Dec 2024 11:07:30 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=eeBMDI0kP+FxyT4dt LaNx29dbsp9ZBEPwfu5vflKj/w=; b=JfDIbA4/cCYvb+9mIayhzc/lBgMEpQfSo Ui5JkNPPiFAwyosLe16F3jXUeSoTGz6YtIssS+DZ8AAKnE/+Tk6xcEXKI5cxutDO dB+gT4o4vK9lqj6bbhIDEkc6s7I+/L42rRfAxbS9/xqBRk+uUlCIGXjdb0Z/UwB+ qdS/B/6Fxy6DFgNRpffUCPC91VNwkBb3ix1HvUIL6q8/Hudyw8XUzHtPdT78KMyc zJ7hfoXN4TVrJRc7kKsIvfw4xcmGr4YKg/o36lVCLlxZLllmDTQOlY3QxFydbZol +mpRrk2HkMGWVfz05LVPicgCtpnHE0uKgNK8/yx3705Y3o3jG0M5Q== 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 43ce0x7y5e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Dec 2024 11:07:30 +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 4B99c9i5016910; Mon, 9 Dec 2024 11:07:29 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 43d12xxews-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Dec 2024 11:07:29 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4B9B7P2X35652154 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 9 Dec 2024 11:07:25 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A2EB520043; Mon, 9 Dec 2024 11:07:25 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2E8182004B; Mon, 9 Dec 2024 11:07:25 +0000 (GMT) Received: from darkmoore.ibmuc.com (unknown [9.179.10.206]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 9 Dec 2024 11:07:25 +0000 (GMT) From: Christoph Schlameuss To: kvm@vger.kernel.org Cc: Christian Borntraeger , Janosch Frank , Claudio Imbrenda , David Hildenbrand , Paolo Bonzini , Shuah Khan , linux-s390@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v1 5/6] selftests: kvm: s390: Streamline uc_skey test to issue iske after sske Date: Mon, 9 Dec 2024 12:07:16 +0100 Message-ID: <20241209110717.77279-6-schlameuss@linux.ibm.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241209110717.77279-1-schlameuss@linux.ibm.com> References: <20241209110717.77279-1-schlameuss@linux.ibm.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: xL0l9NC9hRSIu2X_T9mgtBpXJyX6ZWVK X-Proofpoint-ORIG-GUID: xL0l9NC9hRSIu2X_T9mgtBpXJyX6ZWVK 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 spamscore=0 clxscore=1015 impostorscore=0 mlxscore=0 mlxlogscore=914 priorityscore=1501 malwarescore=0 adultscore=0 bulkscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2412090086 In some rare situations a non default storage key is already set on the memory used by the test. Within normal VMs the key is reset / zapped when the memory is added to the VM. This is not the case for ucontrol VMs. With the initial iske check removed this test case can work in all situations. The function of the iske instruction is still validated by the remaining code. Signed-off-by: Christoph Schlameuss --- .../selftests/kvm/s390x/ucontrol_test.c | 22 +++++-------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/tools/testing/selftests/kvm/s390x/ucontrol_test.c b/tools/testing/selftests/kvm/s390x/ucontrol_test.c index d3a5dbfabade..755cd31e6387 100644 --- a/tools/testing/selftests/kvm/s390x/ucontrol_test.c +++ b/tools/testing/selftests/kvm/s390x/ucontrol_test.c @@ -88,10 +88,6 @@ asm("test_skey_asm:\n" " ahi %r0,1\n" " st %r1,0(%r5,%r6)\n" - " iske %r1,%r6\n" - " ahi %r0,1\n" - " diag 0,0,0x44\n" - " sske %r1,%r6\n" " xgr %r1,%r1\n" " iske %r1,%r6\n" @@ -593,7 +589,9 @@ TEST_F(uc_kvm, uc_skey) ASSERT_EQ(true, uc_handle_exit(self)); ASSERT_EQ(1, sync_regs->gprs[0]); - /* ISKE */ + /* SSKE + ISKE */ + sync_regs->gprs[1] = skeyvalue; + run->kvm_dirty_regs |= KVM_SYNC_GPRS; ASSERT_EQ(0, uc_run_once(self)); /* @@ -607,19 +605,9 @@ TEST_F(uc_kvm, uc_skey) TEST_ASSERT_EQ(ICPT_INST, sie_block->icptcode); TEST_REQUIRE(sie_block->ipa != 0xb229); - /* ISKE contd. */ + /* SSKE + ISKE contd. */ ASSERT_EQ(false, uc_handle_exit(self)); ASSERT_EQ(2, sync_regs->gprs[0]); - /* assert initial skey (ACC = 0, R & C = 1) */ - ASSERT_EQ(0x06, sync_regs->gprs[1]); - uc_assert_diag44(self); - - /* SSKE + ISKE */ - sync_regs->gprs[1] = skeyvalue; - run->kvm_dirty_regs |= KVM_SYNC_GPRS; - ASSERT_EQ(0, uc_run_once(self)); - ASSERT_EQ(false, uc_handle_exit(self)); - ASSERT_EQ(3, sync_regs->gprs[0]); ASSERT_EQ(skeyvalue, sync_regs->gprs[1]); uc_assert_diag44(self); @@ -628,7 +616,7 @@ TEST_F(uc_kvm, uc_skey) run->kvm_dirty_regs |= KVM_SYNC_GPRS; ASSERT_EQ(0, uc_run_once(self)); ASSERT_EQ(false, uc_handle_exit(self)); - ASSERT_EQ(4, sync_regs->gprs[0]); + ASSERT_EQ(3, sync_regs->gprs[0]); /* assert R reset but rest of skey unchanged */ ASSERT_EQ(skeyvalue & 0xfa, sync_regs->gprs[1]); ASSERT_EQ(0, sync_regs->gprs[1] & 0x04); From patchwork Mon Dec 9 11:07:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Schlameuss X-Patchwork-Id: 13899334 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 25CD7221448; Mon, 9 Dec 2024 11:07:35 +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=1733742457; cv=none; b=qzeX+rQx5vRIIos+BJtyPNIAREygg+5xe2TzflfpNWd3HZKC6i7eGOiG9mUAvR8y0+b0TJIIH1Nlm96/1LyBA1Zrb3oGdiizgBdTqDXEYrLPaAMEmkmm1YhIKWLv9OfM6AR9fUjZYPP6pgq9x5Wpxbm/aYeKFMgX+y+1TrCBaEw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733742457; c=relaxed/simple; bh=ZCImB94yC55O4DJzZe+v7xwlS7jAorIbdZMzeTMZpaA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c2wtmPmnbzDMeVIiQhvti8yBErCNWqmu7tCNScRoajE32Q2lRXZz7jGib2dMeOeNn1YsW1E/tI1cwMOsogXShDU+8FoSsRIJPDQPg3buyKwZNDwVYdbdTBYyJ6afJKpnzeh5kw+USrhQGTIK3OvaZ3Otoq513uZ37aoBXDaRIaw= 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=NYneA0DJ; 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="NYneA0DJ" 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 4B8MeN2f023036; Mon, 9 Dec 2024 11:07:30 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=z+mwhYRDkIb/n+oau tR5WD/kA6zuLj360NkhhyMl4RA=; b=NYneA0DJrQC7/19i4v/EGAd9PvoNGtoYV MNDkUwQHeZsZ+D4ITFh53jrZ87VcUjR7Uz+OMlfA20gzQXS3XNtcWSaRzSzBIDTb oLFac+RWfAs68IozWBy1I1SC3Q+E7t3o8IaciPtuEodwwKk4YU+zonyGbIgZNLUA icoW4tySR5jvvNi9xZxhWEmGGPN8UUiDff+V4HlIBFIUUXGT8n9TwZBFaNuPKOGb CWoaxmyKrGtG6a11BX4grzI/av/y3/5R80zY4lmDxuE7nYLX+ZngSpGXixGGF9z9 vsvzIfdDO9UGVdNPP5Y7GARD2yIRgJPxdZWHpDvDmXcyaIJ3NdRGw== 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 43ce0x7y5f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Dec 2024 11:07:30 +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 4B9AChb4032575; Mon, 9 Dec 2024 11:07:30 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 43d1pmx9aj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Dec 2024 11:07:29 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4B9B7Q8W58851682 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 9 Dec 2024 11:07:26 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4138520040; Mon, 9 Dec 2024 11:07:26 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B741E2004B; Mon, 9 Dec 2024 11:07:25 +0000 (GMT) Received: from darkmoore.ibmuc.com (unknown [9.179.10.206]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 9 Dec 2024 11:07:25 +0000 (GMT) From: Christoph Schlameuss To: kvm@vger.kernel.org Cc: Christian Borntraeger , Janosch Frank , Claudio Imbrenda , David Hildenbrand , Paolo Bonzini , Shuah Khan , linux-s390@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v1 6/6] selftests: kvm: s390: Add has device attr check to uc_attr_mem_limit selftest Date: Mon, 9 Dec 2024 12:07:17 +0100 Message-ID: <20241209110717.77279-7-schlameuss@linux.ibm.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241209110717.77279-1-schlameuss@linux.ibm.com> References: <20241209110717.77279-1-schlameuss@linux.ibm.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: -etal_45Cf-QPHKfKu89NrMUrA47ry0X X-Proofpoint-ORIG-GUID: -etal_45Cf-QPHKfKu89NrMUrA47ry0X 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 spamscore=0 clxscore=1015 impostorscore=0 mlxscore=0 mlxlogscore=806 priorityscore=1501 malwarescore=0 adultscore=0 bulkscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2412090086 Fixup the uc_attr_mem_limit test case to also cover the KVM_HAS_DEVICE_ATTR ioctl. Signed-off-by: Christoph Schlameuss --- tools/testing/selftests/kvm/s390x/ucontrol_test.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/kvm/s390x/ucontrol_test.c b/tools/testing/selftests/kvm/s390x/ucontrol_test.c index 755cd31e6387..e4a24dc7c7a6 100644 --- a/tools/testing/selftests/kvm/s390x/ucontrol_test.c +++ b/tools/testing/selftests/kvm/s390x/ucontrol_test.c @@ -206,10 +206,13 @@ TEST_F(uc_kvm, uc_attr_mem_limit) struct kvm_device_attr attr = { .group = KVM_S390_VM_MEM_CTRL, .attr = KVM_S390_VM_MEM_LIMIT_SIZE, - .addr = (unsigned long)&limit, + .addr = (u64)&limit, }; int rc; + rc = ioctl(self->vm_fd, KVM_HAS_DEVICE_ATTR, &attr); + EXPECT_EQ(0, rc); + rc = ioctl(self->vm_fd, KVM_GET_DEVICE_ATTR, &attr); EXPECT_EQ(0, rc); EXPECT_EQ(~0UL, limit);