From patchwork Thu Nov 7 14:10:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Schlameuss X-Patchwork-Id: 13866578 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 8880B17BB0D; Thu, 7 Nov 2024 14:13:31 +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=1730988814; cv=none; b=rYKPkXBNW0Us7pF79NFsmakQ+aLOYn21HjKd+XpQmaFIRukI4IaD9REJq0RNjOCZ7t5mnO9VDq+SvZxiM/bwUYo2BKy2s76cb13e4tQbp4GHBsybYvyXbcLhPj43wydNaxEjo9UvM0f87sw2d5gJUIXk7q+Sdk3QH5G7LR+GB4Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730988814; c=relaxed/simple; bh=JARxfBIBVcpzs8kya5mHo170BgDdBt5gJG0s99g/j7Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qISdLu6ugHexcOICp3lcPXqXMLN+47kZge8tyC3XtPn90D8nS9Bj/egrFBujlNVZDZUcZZnsOoPiMeouASaNQFwo8rHCr5GoVNCbOBYcOeUxXoZAb5t5EQmmBaiT44DGyNBEexc+2kJ+A5/QOpM91zhlz7BkfLCoHWd1zu+1VXU= 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=JgzzcuMQ; 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="JgzzcuMQ" 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 4A7Dloo1024357; Thu, 7 Nov 2024 14:10:39 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=mNvQ0d/IN31oXYeYO 9pK7Fb2bWCXnLn+upB85w3QsAc=; b=JgzzcuMQtiwSfmO26ceX87qDOGAMP9jXG Qpkc/38HrKPQNp4jDCar2648nQn6pYt8PfJ+30PeGP6GZTtPmjBPRw82WZsraL4S XtU9liGusxRuu1tbYpeCNBryck73ZtKBqFWsNZFUbYz5f+3JxhDsQFn+4PgrYXcn LgpKWGuDwpPN+9iYAZKRJeEsfnTNQ85mdld9fbbLCwTQt1GZ2wxOgold/896RR30 J4zzD/Qwohi1vhDAZmyeEjFufEXLhY4FqtHcMEQ4NeAv3NyypLpTvhvC3Dq3kV5u UPgSr2h2W1RYGG0bf08XCerAoNVp0erY0LPNjn/CxXYFvWiI0AavQ== 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 42rxmnr6s1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 07 Nov 2024 14:10:38 +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 4A7DWQda013158; Thu, 7 Nov 2024 14:10:38 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 42p14108du-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 07 Nov 2024 14:10:38 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4A7EAYaB55902542 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 7 Nov 2024 14:10:34 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9625F20049; Thu, 7 Nov 2024 14:10:34 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 72C772004E; Thu, 7 Nov 2024 14:10:34 +0000 (GMT) Received: from darkmoore.boeblingen.de.ibm.com (unknown [9.152.222.253]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 7 Nov 2024 14:10:34 +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 , schlameuss@linux.ibm.com Subject: [PATCH v7 3/5] selftests: kvm: s390: Verify reject memory region operations for ucontrol VMs Date: Thu, 7 Nov 2024 15:10:22 +0100 Message-ID: <20241107141024.238916-4-schlameuss@linux.ibm.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241107141024.238916-1-schlameuss@linux.ibm.com> References: <20241107141024.238916-1-schlameuss@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 7BaG1bRBIzkho1Yoj_TILwFH8DSD7MJV X-Proofpoint-ORIG-GUID: 7BaG1bRBIzkho1Yoj_TILwFH8DSD7MJV 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 suspectscore=0 spamscore=0 clxscore=1015 impostorscore=0 lowpriorityscore=0 mlxscore=0 priorityscore=1501 adultscore=0 phishscore=0 bulkscore=0 mlxlogscore=985 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2411070110 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 fe5c0d3aabbc..68d17b1ab128 100644 --- a/tools/testing/selftests/kvm/s390x/ucontrol_test.c +++ b/tools/testing/selftests/kvm/s390x/ucontrol_test.c @@ -439,6 +439,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;