From patchwork Mon Sep 2 11:50:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Schlameuss X-Patchwork-Id: 13787142 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 747F91D6C73; Mon, 2 Sep 2024 11:50:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725277835; cv=none; b=o5K4FiGo1Hx2FEm9FHyhrPRExWiLuriDRcNsLVtdGIzuE9u4Bu7KRoa8hFYyNEBl5OLyIwCZl49TIArn9484mTQQg9IdNmTFlgGRkjgQVkV3BVEJVdg+/Cm+6w1q7lQv8KsfldiVp1o4sF4TPVozoGPOrRwkuiShXLnMunthVHE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725277835; c=relaxed/simple; bh=Lc7pUz4AG1LQUWDppC5hG1iXppxDzuNCF9T3re4hPlc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FG8XReXYOR6EiSotQIggWDAHZkI4mwp527Ltk36wRNV40GFzTJBOBWYKiL/H0spUPq3QKgX9RjkDBR3o4/0ZiwQNkxvTc3H7HR4F5lxkxd4AvIfMgOfou2KtS05T2EC1S/ZLiYJ0h7bnJHdjjSRDjgSyFpUfzicGCMXsU9potdk= 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=Vwlza/YH; 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="Vwlza/YH" 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 4827l8rc017559; Mon, 2 Sep 2024 11:50:21 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 :mime-version:content-transfer-encoding; s=pp1; bh=8pphi/Hl98Bjy Kfvc49PQxXzj4xrcBobwMiEiX409tM=; b=Vwlza/YHSpcJkEgaDSMmMPmM0jieH Q+ozrNTXLsOeA1BWp72msP+VdhHDoj4Ht8D+Uoq5AVgJjEP5Hw2lasu4lxK88vuR zJAc1BDQ+DBFpC63UgW4BAHFh4wY08tjqjfchfbOk6bP8hwarrIXqZxe3d8oWnAU DfAHX7PCGX+1OUEovnHrTZiurJUVQqWbyhI2ngHuMCgAzI+LlA3Rn79dWrC+uLKs oXYSlFL/XasSHKV8L/ysT35Dy3Q0amEl6sIWzu+slseI7+Q2qX4i1KJX1qFh9wYt 4BB9OJWA/AJpKZwOUzMvUxh/F+uze7IRhNgQpLDqmL38Y8KL9Ig1DelcQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 41brkqh1td-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 02 Sep 2024 11:50:21 +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 482BoL17032601; Mon, 2 Sep 2024 11:50:21 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 41brkqh1t6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 02 Sep 2024 11:50:21 +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 4827bEOm018448; Mon, 2 Sep 2024 11:50:20 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 41cdw0x4pn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 02 Sep 2024 11:50:20 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 482BoG9F51839440 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 2 Sep 2024 11:50:16 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3F34120040; Mon, 2 Sep 2024 11:50:16 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B63BE2004D; Mon, 2 Sep 2024 11:50:15 +0000 (GMT) Received: from darkmoore.ibmuc.com (unknown [9.171.60.16]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 2 Sep 2024 11:50:15 +0000 (GMT) From: Christoph Schlameuss To: kvm@vger.kernel.org Cc: linux-s390@vger.kernel.org, linux-kselftest@vger.kernel.org, Paolo Bonzini , Shuah Khan , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , David Hildenbrand , Nina Schoetterl-Glausch , schlameuss@linux.ibm.com Subject: [PATCH v2 3/3] selftests: kvm: s390: Verify reject memory region operations for ucontrol VMs Date: Mon, 2 Sep 2024 13:50:02 +0200 Message-ID: <20240902115002.199331-4-schlameuss@linux.ibm.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240902115002.199331-1-schlameuss@linux.ibm.com> References: <20240902115002.199331-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: 0QG0fnDf9hoSvSqlcfAC5YTol1pkf8eB X-Proofpoint-ORIG-GUID: mCU2SuZaMNhwynznCY6ZH43LRB-dxKj5 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-09-02_02,2024-09-02_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 clxscore=1011 mlxscore=0 impostorscore=0 malwarescore=0 suspectscore=0 priorityscore=1501 adultscore=0 mlxlogscore=999 bulkscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2407110000 definitions=main-2409020094 Add a test case verifying KVM_SET_USER_MEMORY_REGION and KVM_SET_USER_MEMORY_REGION2 cannot be executed on ucontrol VMs. Executing this test case on not patched kernels will cause a null pointer dereference in the host kernel. This is fixed with commit: commit 7816e58967d0 ("kvm: s390: Reject memory region operations for ucontrol VMs") Signed-off-by: Christoph Schlameuss Reviewed-by: Janosch Frank --- .../selftests/kvm/s390x/ucontrol_test.c | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tools/testing/selftests/kvm/s390x/ucontrol_test.c b/tools/testing/selftests/kvm/s390x/ucontrol_test.c index 331a4109b953..7eb103fc8eac 100644 --- a/tools/testing/selftests/kvm/s390x/ucontrol_test.c +++ b/tools/testing/selftests/kvm/s390x/ucontrol_test.c @@ -377,6 +377,28 @@ static void uc_assert_diag44(FIXTURE_DATA(uc_kvm) * self) TEST_ASSERT_EQ(0x440000, sie_block->ipb); } +TEST_F(uc_kvm, uc_no_user_region) +{ + struct kvm_userspace_memory_region region = { + .slot = 1, + .guest_phys_addr = self->code_gpa, + .memory_size = VM_MEM_EXT_SIZE, + .userspace_addr = (uintptr_t)self->code_hva, + }; + struct kvm_userspace_memory_region2 region2 = { + .slot = 1, + .guest_phys_addr = self->code_gpa, + .memory_size = VM_MEM_EXT_SIZE, + .userspace_addr = (uintptr_t)self->code_hva, + }; + + ASSERT_EQ(-1, ioctl(self->vm_fd, KVM_SET_USER_MEMORY_REGION, ®ion)); + ASSERT_EQ(EINVAL, errno); + + ASSERT_EQ(-1, ioctl(self->vm_fd, KVM_SET_USER_MEMORY_REGION2, ®ion2)); + ASSERT_EQ(EINVAL, errno); +} + TEST_F(uc_kvm, uc_map_unmap) { struct kvm_sync_regs *sync_regs = &self->run->s.regs;