From patchwork Mon Feb 3 08:35:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13957004 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 A45A81E9905 for ; Mon, 3 Feb 2025 08:36:41 +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=1738571803; cv=none; b=KfKfhrjKlKLb0SaQu14HL04WDkZcviS/I5ei4Tto0xMHhKBCMSrRJebXpc5jHG3knZu67Liws9ZmYDuA0HZQhOTr9mhpwcoP46DrxUAPRhOy2uZ0t3yQlXVmjiYrhX6neIIVDcoWuMVuS1HkUuNUJjQQYP+fgbpygcOA0yC56ss= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738571803; c=relaxed/simple; bh=7+WUnlbRSofeOesk/qxJSNjQ278JVN/cIom+zd+gUMo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fOl8may3LsguLbWGrPlg6+3c1u3coJfNFaE78FdVET+sU25K3SogvWhJR3NTdal9sFQOieGZOXhcceSmWPRg0ltq+K9d4cqEAoXTCwh2FxIsqIHaaD3tGHJGjTOkrWuh2YeMtpswksB5ed/Fzl/OGn+PKeb6BhhJ7URH07z5tjI= 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=L0Hiqjne; 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="L0Hiqjne" 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 51320iP2006199; Mon, 3 Feb 2025 08:36: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=DbRdQ4X8TM2Ttacu3 Zt9a3hk+MaMY48vyuhq5rsZdng=; b=L0Hiqjnek1ztsIRFQ61f5CIdFwhDaWRgz WQUbucqKmCwtMmTU42ri0oNuDZehMg77dgqHLiJCAx4bHeEnU40PJlBPB0YLKrzY I/w0ns60e10APf17kx0gq5/kfaDAs8xyXIfsWJLWmeerg3xlWm8/QBkvhR6KMWtJ mcXoiVCkM2fdMJjet3Z0Td6xoTp5/IQXSvkIe+TwVlNZav80LjxqYYMHk+wYhovV w798ZFT+2wJTPbeTeab7gzkt8ZfENn6/FCAoH2oKxBIZMvZmaEsbM5ROhFEwNCM3 oH2uCjMvfo/CysReQvbkmWFiwrXVEuIrQxOif2Hd0G6T6wQi3fYgA== 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 44jmmy9cc1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2025 08:36:29 +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 5137pb3I024492; Mon, 3 Feb 2025 08:36:28 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 44hxxmwe3h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2025 08:36:28 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5138aOeb56623388 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 3 Feb 2025 08:36:24 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C6D0220040; Mon, 3 Feb 2025 08:36:24 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 562B02004B; Mon, 3 Feb 2025 08:36:24 +0000 (GMT) Received: from t14-nrb.lan (unknown [9.171.84.16]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 3 Feb 2025 08:36:24 +0000 (GMT) From: Nico Boehr To: thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, imbrenda@linux.ibm.com, Nina Schoetterl-Glausch Subject: [kvm-unit-tests GIT PULL 01/18] s390x: Split and rework cpacf query functions Date: Mon, 3 Feb 2025 09:35:09 +0100 Message-ID: <20250203083606.22864-2-nrb@linux.ibm.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250203083606.22864-1-nrb@linux.ibm.com> References: <20250203083606.22864-1-nrb@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: zeFQ08hIPYnoiACM54_xPvoPIaWklzM0 X-Proofpoint-ORIG-GUID: zeFQ08hIPYnoiACM54_xPvoPIaWklzM0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-02-03_03,2025-01-31_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 malwarescore=0 phishscore=0 impostorscore=0 priorityscore=1501 mlxscore=0 lowpriorityscore=0 mlxlogscore=999 bulkscore=0 spamscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2501170000 definitions=main-2502030068 From: Nina Schoetterl-Glausch Cherry-pick 830999bd7e72 ("s390/cpacf: Split and rework cpacf query functions") from the kernel: Rework the cpacf query functions to use the correct RRE or RRF instruction formats and set register fields within instructions correctly. Fixes: a555dc6b16bf ("s390x: add cpacf.h from Linux") Signed-off-by: Nina Schoetterl-Glausch Reviewed-by: Nico Boehr Link: https://lore.kernel.org/r/20240621102212.3311494-1-nsg@linux.ibm.com Signed-off-by: Nico Boehr --- lib/s390x/asm/cpacf.h | 77 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 67 insertions(+), 10 deletions(-) diff --git a/lib/s390x/asm/cpacf.h b/lib/s390x/asm/cpacf.h index 378cd5cf..ba53ec31 100644 --- a/lib/s390x/asm/cpacf.h +++ b/lib/s390x/asm/cpacf.h @@ -137,19 +137,76 @@ typedef struct { unsigned char bytes[16]; } cpacf_mask_t; -static __always_inline void __cpacf_query(unsigned int opcode, cpacf_mask_t *mask) +static __always_inline void __cpacf_query_rre(u32 opc, u8 r1, u8 r2, + cpacf_mask_t *mask) { - register unsigned long r0 asm("0") = 0; /* query function */ - register unsigned long r1 asm("1") = (unsigned long) mask; + asm volatile( + " la %%r1,%[mask]\n" + " xgr %%r0,%%r0\n" + " .insn rre,%[opc] << 16,%[r1],%[r2]\n" + : [mask] "=R" (*mask) + : [opc] "i" (opc), + [r1] "i" (r1), [r2] "i" (r2) + : "cc", "r0", "r1"); +} +static __always_inline void __cpacf_query_rrf(u32 opc, + u8 r1, u8 r2, u8 r3, u8 m4, + cpacf_mask_t *mask) +{ asm volatile( - " spm 0\n" /* pckmo doesn't change the cc */ - /* Parameter regs are ignored, but must be nonzero and unique */ - "0: .insn rrf,%[opc] << 16,2,4,6,0\n" - " brc 1,0b\n" /* handle partial completion */ - : "=m" (*mask) - : [fc] "d" (r0), [pba] "a" (r1), [opc] "i" (opcode) - : "cc"); + " la %%r1,%[mask]\n" + " xgr %%r0,%%r0\n" + " .insn rrf,%[opc] << 16,%[r1],%[r2],%[r3],%[m4]\n" + : [mask] "=R" (*mask) + : [opc] "i" (opc), [r1] "i" (r1), [r2] "i" (r2), + [r3] "i" (r3), [m4] "i" (m4) + : "cc", "r0", "r1"); +} + +static __always_inline void __cpacf_query(unsigned int opcode, + cpacf_mask_t *mask) +{ + switch (opcode) { + case CPACF_KIMD: + __cpacf_query_rre(CPACF_KIMD, 0, 2, mask); + break; + case CPACF_KLMD: + __cpacf_query_rre(CPACF_KLMD, 0, 2, mask); + break; + case CPACF_KM: + __cpacf_query_rre(CPACF_KM, 2, 4, mask); + break; + case CPACF_KMA: + __cpacf_query_rrf(CPACF_KMA, 2, 4, 6, 0, mask); + break; + case CPACF_KMAC: + __cpacf_query_rre(CPACF_KMAC, 0, 2, mask); + break; + case CPACF_KMC: + __cpacf_query_rre(CPACF_KMC, 2, 4, mask); + break; + case CPACF_KMCTR: + __cpacf_query_rrf(CPACF_KMCTR, 2, 4, 6, 0, mask); + break; + case CPACF_KMF: + __cpacf_query_rre(CPACF_KMF, 2, 4, mask); + break; + case CPACF_KMO: + __cpacf_query_rre(CPACF_KMO, 2, 4, mask); + break; + case CPACF_PCC: + __cpacf_query_rre(CPACF_PCC, 0, 0, mask); + break; + case CPACF_PCKMO: + __cpacf_query_rre(CPACF_PCKMO, 0, 0, mask); + break; + case CPACF_PRNO: + __cpacf_query_rre(CPACF_PRNO, 2, 4, mask); + break; + default: + asm volatile(".error \"bad opcode\""); + } } static inline int __cpacf_check_opcode(unsigned int opcode) From patchwork Mon Feb 3 08:35:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13957013 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 A8B8A1FBCB9 for ; Mon, 3 Feb 2025 08:36:43 +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=1738571806; cv=none; b=gPEn3sZBkfm54FPNGDSOYTFgpEpIsJfXSwwJuk65S42P3nT7PPSSzbGtlXut+rCG1MjGV+XgWf/Vl4h/pbu247llm89MonjAofDRphGSm0t7/J1u2zABv9YM5MuhUOwFfY+7p+t1d53YWaCYwIppNEtvJVvCAW4TcGGgLGIj81E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738571806; c=relaxed/simple; bh=UmmOtYnzoF8C0aZ+rRGIlDsrLjunYFJVD933xdA182E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=K5XkNHJfyqxYmcfFchkFPIS/Lucas4B4OV73wJ7gH9Y0HSeCG/OeHFYBGULTslqIjASs1jBETZHpSoMmJFfNXdKLpfpl2t8JA4WLaSHZ8O619y71SvZCV+sFq5E9HFvGCwXtXwFut9UVjJrMQo610GwkRNE5UHfHv6VVQDOC7B8= 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=ctipK6gk; 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="ctipK6gk" 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 512KvPYm001517; Mon, 3 Feb 2025 08:36: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=NiHKEOX31EOziF5kX DU/F1o/6D+KCLVyKKGfDazAuMw=; b=ctipK6gk13GEfjNG9lquIxiOHrbkcbylo CtTy/C16kBN62CJl9t/48RBGEWBBGjNoxmBzsf4T2Muj1dZt2H1peMMNAEcDe1pO 0VNFS3eyxKmgdZwMH3C2Gvpt6Gv9HqspzhXwbJU58A5C5X0/XXfCxrevzfSRe0gA Op/yWdBxkZ9AhVUi0FntZdK0zt/enug3L86anRYfVk34fhPfXwQagVj/iukUJQSK QpAz3vyNaOPI3w4t7Y2vNAXWbHvCTUCeEILTOvHaOsgjqtBmsHb87HOlF4A1HELz Nv4CICaL9Vq3LVMXTwKmSanFt853NJiyvu7IXEtN1On2kl2PbYM/A== 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 44jayyba03-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2025 08:36: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 5137xAAJ024506; Mon, 3 Feb 2025 08:36:29 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 44hxxmwe3r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2025 08:36:28 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5138aP8231130264 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 3 Feb 2025 08:36:25 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 485B820040; Mon, 3 Feb 2025 08:36:25 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D9DFF20043; Mon, 3 Feb 2025 08:36:24 +0000 (GMT) Received: from t14-nrb.lan (unknown [9.171.84.16]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 3 Feb 2025 08:36:24 +0000 (GMT) From: Nico Boehr To: thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [kvm-unit-tests GIT PULL 02/18] s390x: edat: test 2G large page spanning end of memory Date: Mon, 3 Feb 2025 09:35:10 +0100 Message-ID: <20250203083606.22864-3-nrb@linux.ibm.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250203083606.22864-1-nrb@linux.ibm.com> References: <20250203083606.22864-1-nrb@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: AopRkxTo31UmMTsmhC0bgr9pPDPIRCJq X-Proofpoint-ORIG-GUID: AopRkxTo31UmMTsmhC0bgr9pPDPIRCJq X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-02-03_03,2025-01-31_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 lowpriorityscore=0 mlxlogscore=999 adultscore=0 priorityscore=1501 phishscore=0 impostorscore=0 malwarescore=0 mlxscore=0 bulkscore=0 suspectscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2501170000 definitions=main-2502030068 From: Claudio Imbrenda Create a region 3 table with fc=1 (i.e. a 2G large page) mapping across the end of memory. Check that the part of the large page before the end of memory is accessible, and the part that is after the end of memory is not. Also fix a typo in the existing edat2 test. Signed-off-by: Claudio Imbrenda Reviewed-by: Nico Boehr Link: https://lore.kernel.org/r/20241001113640.55210-1-imbrenda@linux.ibm.com Signed-off-by: Nico Boehr --- s390x/edat.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/s390x/edat.c b/s390x/edat.c index 16138397..1f582efc 100644 --- a/s390x/edat.c +++ b/s390x/edat.c @@ -196,6 +196,8 @@ static void test_edat1(void) static void test_edat2(void) { + uint64_t mem_end, i; + report_prefix_push("edat2"); p[0] = 42; @@ -206,7 +208,21 @@ static void test_edat2(void) /* Prefixing should not work with huge pages, just like large pages */ report(!memcmp(0, VIRT(prefix_buf), LC_SIZE) && !memcmp(prefix_buf, VIRT(0), LC_SIZE), - "pmd, large, prefixing"); + "pud, large, prefixing"); + + mem_end = get_ram_size(); + if (mem_end >= BIT_ULL(REGION3_SHIFT)) { + report_skip("pud spanning end of memory"); + } else { + for (i = 0; i < mem_end; i += PAGE_SIZE) + READ_ONCE(*(uint64_t *)VIRT(i)); + for (i = mem_end; i < BIT_ULL(REGION3_SHIFT); i += PAGE_SIZE) { + expect_pgm_int(); + READ_ONCE(*(uint64_t *)VIRT(i)); + assert(clear_pgm_int() == PGM_INT_CODE_ADDRESSING); + } + report_pass("pud spanning end of memory"); + } report_prefix_pop(); } From patchwork Mon Feb 3 08:35:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13957009 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 DDEFF1FBEBE for ; Mon, 3 Feb 2025 08:36:43 +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=1738571805; cv=none; b=ToRAOR7QywxbNPy1pyEfmngw+fsR4Ncc3hRfATiVJMhdNMBg6MHkWVZKwGlsL2ajcMxqn0znBO+NOMpuiqCQsUNea228p8st4KaaLswNWYIotMsRXJ7ODoedVneASmbN49ll7WeXZZn0XVPDikxMNwYZNbVlR/20UTBqMFzNvBE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738571805; c=relaxed/simple; bh=PvWBwnQzf6bjsqTtlGWffhqOJyCJLVuGFwuLkxEbtkc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FrHEzwMI72gFSUtzcVQwm2POmwvkjFmY6pvxRRn3bdKkEWa2iAIo7H/S7rdo0j+8BvSYeeUCZEvDtSM+g92r0FJALbcXC3Xy6f40tGWwAkbv6vU71EnFunK9vykhoskP0H1osumNw1yAogJ+FcMDZCa7rpzPlgNnb4wQqDL1ZvQ= 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=fCR5BZwF; 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="fCR5BZwF" 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 512Laijd007728; Mon, 3 Feb 2025 08:36: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=iteFu9D/6btoi3OKV /v3SGtDQ5/0ouyXUM7vkTyw1A8=; b=fCR5BZwFA4Og6vuscJnOyqzeYvJ1LDcpH 0GHxrcnnbJeHtQNmnFKg8ehu6aj/Pr/rCEYYdx6H00tEwFzDQIvhIFAxiLwa7gHT /9F0vfh1NFoIr0jEgZRSPBGdfeeiQmGChKBRD8/BCNFUoFhSe8KKNfZxzaEDFFmR ALRJLzhqpK80ZbhP72BcjF/NHoIc5TTToCn4oNetXZKVE6rLNgykZ3Pgfktz+Soq HkL4napOk2SN/6Otl7U/FpeXoQz+DJhaQRrgwrYXnsI4mL6lfM53DBiL+YjcD9zm ME1FZAEhGAXwQobC34cpMf06J7rr1byRPhWs1E8TQaiZn5TaEXOow== 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 44jayyba07-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2025 08:36:30 +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 5134clwG005310; Mon, 3 Feb 2025 08:36:29 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 44j05jn69r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2025 08:36:29 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5138aPfi22872538 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 3 Feb 2025 08:36:25 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D14AB20040; Mon, 3 Feb 2025 08:36:25 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5BB6F20043; Mon, 3 Feb 2025 08:36:25 +0000 (GMT) Received: from t14-nrb.lan (unknown [9.171.84.16]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 3 Feb 2025 08:36:25 +0000 (GMT) From: Nico Boehr To: thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [kvm-unit-tests GIT PULL 03/18] s390x: edat: move LC_SIZE to arch_def.h Date: Mon, 3 Feb 2025 09:35:11 +0100 Message-ID: <20250203083606.22864-4-nrb@linux.ibm.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250203083606.22864-1-nrb@linux.ibm.com> References: <20250203083606.22864-1-nrb@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: ZmRsCLyvH3_p57IBHVbKHhdyN-6QfNSe X-Proofpoint-ORIG-GUID: ZmRsCLyvH3_p57IBHVbKHhdyN-6QfNSe X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-02-03_03,2025-01-31_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 lowpriorityscore=0 mlxlogscore=999 adultscore=0 priorityscore=1501 phishscore=0 impostorscore=0 malwarescore=0 mlxscore=0 bulkscore=0 suspectscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2501170000 definitions=main-2502030068 struct lowcore is defined in arch_def.h and LC_SIZE is useful to other tests as well, therefore move it to arch_def.h. Reviewed-by: Claudio Imbrenda Link: https://lore.kernel.org/r/20241010071228.565038-2-nrb@linux.ibm.com Signed-off-by: Nico Boehr --- lib/s390x/asm/arch_def.h | 1 + s390x/edat.c | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/s390x/asm/arch_def.h b/lib/s390x/asm/arch_def.h index 745a3387..5574a451 100644 --- a/lib/s390x/asm/arch_def.h +++ b/lib/s390x/asm/arch_def.h @@ -119,6 +119,7 @@ enum address_space { #define CTL2_GUARDED_STORAGE (63 - 59) +#define LC_SIZE (2 * PAGE_SIZE) struct lowcore { uint8_t pad_0x0000[0x0080 - 0x0000]; /* 0x0000 */ uint32_t ext_int_param; /* 0x0080 */ diff --git a/s390x/edat.c b/s390x/edat.c index 1f582efc..89b9c2d3 100644 --- a/s390x/edat.c +++ b/s390x/edat.c @@ -17,7 +17,6 @@ #define PGD_PAGE_SHIFT (REGION1_SHIFT - PAGE_SHIFT) -#define LC_SIZE (2 * PAGE_SIZE) #define VIRT(x) ((void *)((unsigned long)(x) + (unsigned long)mem)) static uint8_t prefix_buf[LC_SIZE] __attribute__((aligned(LC_SIZE))); From patchwork Mon Feb 3 08:35:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13957006 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 89F051FA859 for ; Mon, 3 Feb 2025 08:36:42 +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=1738571804; cv=none; b=qj8BeUEB9M3OtZ6xgNOcOAv3Z3gI2Aoo5y6/GxJxWVNuroErZvqkk0c5xxhXGYuto6h2rHhCOYgtxs2ulm1xGoK/hWrStX60tWSLXpO/SgcGs5vsYx04RfJhmpPbVJ9uepT5lOfszUByiL1y1axPnbceExjzoqRBpliG57EWDAE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738571804; c=relaxed/simple; bh=ncukha6i9MZuNaCtF7EYBW5F2f1OveHTEVYlPl45Cjo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z4k8kr3fH3+k4GnApOL45Gc/Os2LDDE20rl9FqYIfha+NvBKEz6vNZAonZk1Jj3GipyVc0V1QfW8JnZKVw72UKetteEuAbwu4+sMukR78nT1393gpTIw/QytDfkzGJalq6/m0QNlhxQtCQMTu/oharr+6X10jiAr1AUeMN6m5qs= 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=hnPI2E3j; 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="hnPI2E3j" 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 5135Ntwh013186; Mon, 3 Feb 2025 08:36: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=oM4QQRK/sxu0mHXYH K/yq72fPMU/OB2oKPnDC3Dy79Y=; b=hnPI2E3johAD6TJVEpRROJl/xtl7RGomR /7VHXoHu96lKs1VFyAAZ0LLKnMXPceb1yEg0RvZvxt8igLUb4TXK/cSWDO7nHq5X BWIa+2x/xfc+jBBLpTzUDFfLf8fI/5i3GnGh+xqLApytR/uSoY0CITd+jZmlHANN 3MeyNxqlX2djBiRJyfetZeMD3w2G+Cu/6hL0gFrVygopj9O9OFGhFHmBEolP3IAG pJgrpOZ0zcqSO9zAm9gvCjaAiCHCeIx5eY0r6LG/bkzitu0RpELodesH6Gb6wHeU Wmz08weIqnfHT30eo79lcLDLD57hwzkhF4uhnZWfUtyfbGLJgfOZg== 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 44jqm78suq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2025 08:36:30 +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 5134GvmL005266; Mon, 3 Feb 2025 08:36:29 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 44j05jn6a0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2025 08:36:29 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5138aQ4x54985062 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 3 Feb 2025 08:36:26 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 545D620040; Mon, 3 Feb 2025 08:36:26 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E49C720043; Mon, 3 Feb 2025 08:36:25 +0000 (GMT) Received: from t14-nrb.lan (unknown [9.171.84.16]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 3 Feb 2025 08:36:25 +0000 (GMT) From: Nico Boehr To: thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [kvm-unit-tests GIT PULL 04/18] s390x: add test for diag258 Date: Mon, 3 Feb 2025 09:35:12 +0100 Message-ID: <20250203083606.22864-5-nrb@linux.ibm.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250203083606.22864-1-nrb@linux.ibm.com> References: <20250203083606.22864-1-nrb@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: j4rFXslwzpG4I2oX7b0sEN4jDDsr90fV X-Proofpoint-ORIG-GUID: j4rFXslwzpG4I2oX7b0sEN4jDDsr90fV X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-02-03_03,2025-01-31_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 clxscore=1015 lowpriorityscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 suspectscore=0 priorityscore=1501 phishscore=0 impostorscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2501170000 definitions=main-2502030068 This adds a test for diag258 (page ref service/async page fault). There recently was a virtual-real address confusion bug, so we should test: - diag258 parameter Rx is a real adress - crossing the end of RAM with the parameter list yields an addressing exception - invalid diagcode in the parameter block yields an specification exception - diag258 correctly applies prefixing. Note that we're just testing error cases as of now. Reviewed-by: Claudio Imbrenda Link: https://lore.kernel.org/r/20241010071228.565038-3-nrb@linux.ibm.com Signed-off-by: Nico Boehr --- s390x/Makefile | 1 + s390x/diag258.c | 259 ++++++++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 3 + 3 files changed, 263 insertions(+) create mode 100644 s390x/diag258.c diff --git a/s390x/Makefile b/s390x/Makefile index 23342bd6..66d71351 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -44,6 +44,7 @@ tests += $(TEST_DIR)/exittime.elf tests += $(TEST_DIR)/ex.elf tests += $(TEST_DIR)/topology.elf tests += $(TEST_DIR)/sie-dat.elf +tests += $(TEST_DIR)/diag258.elf pv-tests += $(TEST_DIR)/pv-diags.elf pv-tests += $(TEST_DIR)/pv-icptcode.elf diff --git a/s390x/diag258.c b/s390x/diag258.c new file mode 100644 index 00000000..8ba75a72 --- /dev/null +++ b/s390x/diag258.c @@ -0,0 +1,259 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Diag 258: Async Page Fault Handler + * + * Copyright (c) 2024 IBM Corp + * + * Authors: + * Nico Boehr + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static uint8_t prefix_buf[LC_SIZE] __attribute__((aligned(LC_SIZE))); + +#define __PF_RES_FIELD 0x8000000000000000UL + +/* copied from Linux arch/s390/mm/pfault.c */ +struct pfault_refbk { + u16 refdiagc; + u16 reffcode; + u16 refdwlen; + u16 refversn; + u64 refgaddr; + u64 refselmk; + u64 refcmpmk; + u64 reserved; +}; + +uint64_t pfault_token = 0x0123fadec0fe3210UL; + +static struct pfault_refbk pfault_init_refbk __attribute__((aligned(8))) = { + .refdiagc = 0x258, + .reffcode = 0, /* TOKEN */ + .refdwlen = sizeof(struct pfault_refbk) / sizeof(uint64_t), + .refversn = 2, + .refgaddr = (u64)&pfault_token, + .refselmk = 1UL << 48, + .refcmpmk = 1UL << 48, + .reserved = __PF_RES_FIELD +}; + +static struct pfault_refbk pfault_cancel_refbk __attribute((aligned(8))) = { + .refdiagc = 0x258, + .reffcode = 1, /* CANCEL */ + .refdwlen = sizeof(struct pfault_refbk) / sizeof(uint64_t), + .refversn = 2, + .refgaddr = 0, + .refselmk = 0, + .refcmpmk = 0, + .reserved = 0 +}; + +static inline int diag258(struct pfault_refbk *refbk) +{ + int rc = -1; + + asm volatile( + " diag %[refbk],%[rc],0x258\n" + : [rc] "+d" (rc) + : [refbk] "a" (refbk), "m" (*(refbk)) + : "cc"); + return rc; +} + +static void test_priv(void) +{ + report_prefix_push("privileged"); + expect_pgm_int(); + enter_pstate(); + diag258(&pfault_init_refbk); + check_pgm_int_code(PGM_INT_CODE_PRIVILEGED_OPERATION); + report_prefix_pop(); +} + +static void *page_map_outside_real_space(phys_addr_t page_real) +{ + pgd_t *root = (pgd_t *)(stctg(1) & PAGE_MASK); + void *vaddr = alloc_vpage(); + + install_page(root, page_real, vaddr); + + return vaddr; +} + +/* + * Verify that the refbk pointer is a real address and not a virtual + * address. This is tested by enabling DAT and establishing a mapping + * for the refbk that is outside of the bounds of our (guest-)physical + * address space. + */ +static void test_refbk_real(void) +{ + struct pfault_refbk *refbk; + void *refbk_page; + pgd_t *root; + + report_prefix_push("refbk is real"); + + /* Set up virtual memory and allocate a physical page for storing the refbk */ + setup_vm(); + refbk_page = alloc_page(); + + /* Map refblk page outside of physical memory identity mapping */ + root = (pgd_t *)(stctg(1) & PAGE_MASK); + refbk = page_map_outside_real_space(virt_to_pte_phys(root, refbk_page)); + + /* Assert the mapping really is outside identity mapping */ + report_info("refbk is at 0x%lx", (u64)refbk); + report_info("ram size is 0x%lx", get_ram_size()); + assert((u64)refbk > get_ram_size()); + + /* Copy the init refbk to the page */ + memcpy(refbk, &pfault_init_refbk, sizeof(struct pfault_refbk)); + + /* Protect the virtual mapping to avoid diag258 actually doing something */ + protect_page(refbk, PAGE_ENTRY_I); + + expect_pgm_int(); + diag258(refbk); + check_pgm_int_code(PGM_INT_CODE_ADDRESSING); + report_prefix_pop(); + + free_page(refbk_page); + disable_dat(); + irq_set_dat_mode(false, 0); +} + +/* + * Verify diag258 correctly applies prefixing. + */ +static void test_refbk_prefixing(void) +{ + const size_t lowcore_offset_for_refbk = offsetof(struct lowcore, pad_0x03a0); + struct pfault_refbk *refbk_in_prefix, *refbk_in_reverse_prefix; + uint32_t old_prefix; + uint64_t ry; + + report_prefix_push("refbk prefixing"); + + report_info("refbk at lowcore offset 0x%lx", lowcore_offset_for_refbk); + + assert((unsigned long)&prefix_buf < SZ_2G); + + memcpy(prefix_buf, 0, LC_SIZE); + + /* + * After the call to set_prefix() below, this will refer to absolute + * address lowcore_offset_for_refbk (reverse prefixing). + */ + refbk_in_reverse_prefix = (struct pfault_refbk *)(&prefix_buf[0] + lowcore_offset_for_refbk); + + /* + * After the call to set_prefix() below, this will refer to absolute + * address &prefix_buf[0] + lowcore_offset_for_refbk (forward prefixing). + */ + refbk_in_prefix = (struct pfault_refbk *)OPAQUE_PTR(lowcore_offset_for_refbk); + + old_prefix = get_prefix(); + set_prefix((uint32_t)(uintptr_t)prefix_buf); + + /* + * If diag258 would not be applying prefixing on access to + * refbk_in_reverse_prefix correctly, it would access absolute address + * refbk_in_reverse_prefix (which to us is accessible at real address + * refbk_in_prefix). + * Make sure it really fails by putting invalid function code + * at refbk_in_prefix. + */ + refbk_in_prefix->refdiagc = 0xc0fe; + + /* + * Put a valid refbk at refbk_in_reverse_prefix. + */ + memcpy(refbk_in_reverse_prefix, &pfault_init_refbk, sizeof(pfault_init_refbk)); + + ry = diag258(refbk_in_reverse_prefix); + report(!ry, "real address refbk accessed"); + + /* + * Activating should have worked. Cancel the activation and expect + * return 0. If activation would not have worked, this should return with + * 4 (pfault handshaking not active). + */ + ry = diag258(&pfault_cancel_refbk); + report(!ry, "handshaking canceled"); + + set_prefix(old_prefix); + + report_prefix_pop(); +} + +/* + * Verify that a refbk exceeding physical memory is not accepted, even + * when crossing a frame boundary. + */ +static void test_refbk_crossing(void) +{ + const size_t bytes_in_last_page = 8; + struct pfault_refbk *refbk = (struct pfault_refbk *)(get_ram_size() - bytes_in_last_page); + + report_prefix_push("refbk crossing"); + + report_info("refbk is at 0x%lx", (u64)refbk); + report_info("ram size is 0x%lx", get_ram_size()); + assert(sizeof(struct pfault_refbk) > bytes_in_last_page); + + /* Copy bytes_in_last_page bytes of the init refbk to the page */ + memcpy(refbk, &pfault_init_refbk, bytes_in_last_page); + + expect_pgm_int(); + diag258(refbk); + check_pgm_int_code(PGM_INT_CODE_ADDRESSING); + report_prefix_pop(); +} + +/* + * Verify that a refbk with an invalid refdiagc is not accepted. + */ +static void test_refbk_invalid_diagcode(void) +{ + struct pfault_refbk refbk __attribute__((aligned(8))) = pfault_init_refbk; + + report_prefix_push("invalid refdiagc"); + refbk.refdiagc = 0xc0fe; + + expect_pgm_int(); + diag258(&refbk); + check_pgm_int_code(PGM_INT_CODE_SPECIFICATION); + report_prefix_pop(); +} + +int main(void) +{ + report_prefix_push("diag258"); + + expect_pgm_int(); + diag258((struct pfault_refbk *)0xfffffffffffffff0); + if (clear_pgm_int() == PGM_INT_CODE_SPECIFICATION) { + report_skip("diag258 not supported"); + } else { + test_priv(); + /* Other tests rely on invalid diagcodes doing nothing */ + test_refbk_invalid_diagcode(); + test_refbk_real(); + test_refbk_prefixing(); + test_refbk_crossing(); + } + + report_prefix_pop(); + return report_summary(); +} diff --git a/s390x/unittests.cfg b/s390x/unittests.cfg index 3a9decc9..8131ba10 100644 --- a/s390x/unittests.cfg +++ b/s390x/unittests.cfg @@ -392,3 +392,6 @@ file = sie-dat.elf [pv-attest] file = pv-attest.elf + +[diag258] +file = diag258.elf From patchwork Mon Feb 3 08:35:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13957005 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 A44C51D7E50 for ; Mon, 3 Feb 2025 08:36:41 +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=1738571803; cv=none; b=RXjojhYbwGDkc2XlZTlWDB9EdPOmF8g0RG+6f3B/HBAduuzgUEqRnw9wD11jbO92cL4XVg+BnSdNPlpnXKxzv/MyN+YnjkQ+/ZUf7bBVcPKP1PO/zpto7PAW2Mc+PLofBK8rkqncPgURcG7hVKsb/ST8YyZIu2hJ0YTDjrcqXMo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738571803; c=relaxed/simple; bh=qqt7Q+//GI4rNMBXX4IRYsr3rE+Vmle6zFjPsDaJjPQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WTjf9e2GCDKnFntjwlfbCqBoRrTx03TlVrCpD+5/N7KOt5GHYrcyur9IHi8Y2pOAQdeQRqzP30Kq64BPO6m3/KcJmZLfjHeUDMlGeEHsu9iiiPN6HN1/Y4Y0pXPNZXzsx67DCL5wqae1AUF2pSTabP4xyZujnWzt2fdqxyWLf2s= 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=bYTb9hyG; 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="bYTb9hyG" 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 5137WuRV014569; Mon, 3 Feb 2025 08:36:31 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=rcBWNf3C389sJMalt KjoaLYkTg84hXHUImAs4E/eDTY=; b=bYTb9hyGsOp3yuOIfyBReMMzmMrKbi81u zqCslj+ROJnenK0AQ5/ZUTd2bG/7FCkMZCdqYM6o/7nDvyOZgQRRThJy92UM/qnJ VS/3oC41MLbcO1fP6VQtthsUJfOg+v1clVBHGbieNJczBE1XiOX4lo4p43/q6U0D vqzbLZxsblAV/BDEGsNyjCwCSuLZJoS1SjeKLrwfvuYMXTfGzrTTD2jbE+ZMntp1 TQEOHPxfWQJx98aMz54cQ9850rKJ+hFnYB4HgoHkK5+8tgWR5ufiFiwIlcxshj7J Wk18S4HyOlaeFQ38T7twliNduJjWVFeVeBUhhJbkcTGXLhIFltB6g== 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 44jsgng8qg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2025 08:36:31 +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 5134kbe8021486; Mon, 3 Feb 2025 08:36:30 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 44j0n153g2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2025 08:36:30 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5138aQGG54985064 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 3 Feb 2025 08:36:27 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DE7F420040; Mon, 3 Feb 2025 08:36:26 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 676D02004B; Mon, 3 Feb 2025 08:36:26 +0000 (GMT) Received: from t14-nrb.lan (unknown [9.171.84.16]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 3 Feb 2025 08:36:26 +0000 (GMT) From: Nico Boehr To: thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, imbrenda@linux.ibm.com, Nina Schoetterl-Glausch Subject: [kvm-unit-tests GIT PULL 05/18] s390x: lib: Remove double include Date: Mon, 3 Feb 2025 09:35:13 +0100 Message-ID: <20250203083606.22864-6-nrb@linux.ibm.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250203083606.22864-1-nrb@linux.ibm.com> References: <20250203083606.22864-1-nrb@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: UrbFlEDHy3NeaSj9q2E8NXjRIZ0AkyXl X-Proofpoint-ORIG-GUID: UrbFlEDHy3NeaSj9q2E8NXjRIZ0AkyXl X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-02-03_03,2025-01-31_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=704 phishscore=0 mlxscore=0 priorityscore=1501 clxscore=1015 adultscore=0 malwarescore=0 impostorscore=0 lowpriorityscore=0 suspectscore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2501170000 definitions=main-2502030068 From: Nina Schoetterl-Glausch libcflat.h was included twice. Reviewed-by: Claudio Imbrenda Reviewed-by: Janosch Frank Signed-off-by: Nina Schoetterl-Glausch Link: https://lore.kernel.org/r/20241016180320.686132-2-nsg@linux.ibm.com Signed-off-by: Nico Boehr --- lib/s390x/sie.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/s390x/sie.c b/lib/s390x/sie.c index 28fbf146..40936bd2 100644 --- a/lib/s390x/sie.c +++ b/lib/s390x/sie.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include From patchwork Mon Feb 3 08:35:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13957007 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 2F64B1FAC4F for ; Mon, 3 Feb 2025 08:36:42 +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=1738571804; cv=none; b=YV9QSE1iKWv6A5ivyUi5YT09MfpxkqqlrcoEcdM2XUTSO/j06pR0e6XWzwmV6Mt9R9WObubQ9XbhatvotbbH0tAIJcUqMdTBsWhVowQPHz6QsTZVdkV3fbGyecwRV7aykJgkR7y0Whjc4B6g/idPdHDliXH94/qjRxdIA+OiKMs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738571804; c=relaxed/simple; bh=jXJTZPDaGAV7Vndo4A3F3OEuPthTyMAUtiSfH3DcI3k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cpObSoeOWEKHlt/JrPG6w9smckdlMPwSbTWLLNM2gwq/HbYTl66w0AEONXPr+zr6u0EQQTHfTYWp+OvLQKKFv0AYLcjbkBzXlODtaXmwuJy2AIPXk6UV2s3oXjrWoEsLUTA0NYev6MHEXIawxnQC4/5HO349W5KKmQdlA84YenE= 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=Eq3Z4BDh; 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="Eq3Z4BDh" 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 51320hEX006186; Mon, 3 Feb 2025 08:36:32 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=VJzSOimljqkl73IS/ NHN683jSVNW/XRPiOeLSsyJ1kw=; b=Eq3Z4BDh4coAsU4HyUwW1noyeVBeYjNF1 s8igr/ZheX8+BurPCehOkaAuK+FL6UQxfseeRFSAaq25gfxVU33BQ6KYdld8+QXf NBbtQ9oy3fPFyKIqytqvElJQSoqOVm0sjYaXrFBcGAMaMVLnXBix2xm4/qTWaXvp w0g39g89w8qQTd1Iu4qJS1kwpji8W+JSen0QQX7IgEUcGF8Ey3RPU+b+toPtNB6m bBl0fYV72OYEIyi7qCkQdKNzwA3qKlzkNXDopyPrr2geIGu2sjTrx4D8+jfKm9vJ uU9CehW2Y8uouCCRxtmBxtYvAPI2rrx+0wYiaUzBjftLXTZiWX08g== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 44jmmy9ccy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2025 08:36:32 +0000 (GMT) Received: from m0353725.ppops.net (m0353725.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 5138U44V021907; Mon, 3 Feb 2025 08:36:32 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 44jmmy9cct-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2025 08:36:32 +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 51376jZB007158; Mon, 3 Feb 2025 08:36:31 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 44hxaydhh5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2025 08:36:31 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5138aRRa42139998 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 3 Feb 2025 08:36:27 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 71BFF2004B; Mon, 3 Feb 2025 08:36:27 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F299120043; Mon, 3 Feb 2025 08:36:26 +0000 (GMT) Received: from t14-nrb.lan (unknown [9.171.84.16]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 3 Feb 2025 08:36:26 +0000 (GMT) From: Nico Boehr To: thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, imbrenda@linux.ibm.com, Nina Schoetterl-Glausch , Nicholas Piggin Subject: [kvm-unit-tests GIT PULL 06/18] s390x: Add sie_is_pv Date: Mon, 3 Feb 2025 09:35:14 +0100 Message-ID: <20250203083606.22864-7-nrb@linux.ibm.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250203083606.22864-1-nrb@linux.ibm.com> References: <20250203083606.22864-1-nrb@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: dQyb7k0PYrnbasL6eIK8nF-28Y37ASgM X-Proofpoint-ORIG-GUID: -Sh0BY8spWasISkY2X7N7o9YY2K83j6U X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-02-03_03,2025-01-31_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 malwarescore=0 phishscore=0 impostorscore=0 priorityscore=1501 mlxscore=0 lowpriorityscore=0 mlxlogscore=742 bulkscore=0 spamscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2501170000 definitions=main-2502030068 From: Nina Schoetterl-Glausch Add a function to check if a guest VM is currently running protected. Reviewed-by: Claudio Imbrenda Reviewed-by: Janosch Frank Reviewed-by: Nicholas Piggin Signed-off-by: Nina Schoetterl-Glausch Link: https://lore.kernel.org/r/20241016180320.686132-3-nsg@linux.ibm.com Signed-off-by: Nico Boehr --- lib/s390x/sie.h | 6 ++++++ lib/s390x/sie.c | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/s390x/sie.h b/lib/s390x/sie.h index c1724cf2..53cd767f 100644 --- a/lib/s390x/sie.h +++ b/lib/s390x/sie.h @@ -281,6 +281,12 @@ void sie_expect_validity(struct vm *vm); uint16_t sie_get_validity(struct vm *vm); void sie_check_validity(struct vm *vm, uint16_t vir_exp); void sie_handle_validity(struct vm *vm); + +static inline bool sie_is_pv(struct vm *vm) +{ + return vm->sblk->sdf == 2; +} + void sie_guest_sca_create(struct vm *vm); void sie_guest_create(struct vm *vm, uint64_t guest_mem, uint64_t guest_mem_len); void sie_guest_destroy(struct vm *vm); diff --git a/lib/s390x/sie.c b/lib/s390x/sie.c index 40936bd2..0fa915cf 100644 --- a/lib/s390x/sie.c +++ b/lib/s390x/sie.c @@ -59,7 +59,7 @@ void sie(struct vm *vm) /* When a pgm int code is set, we'll never enter SIE below. */ assert(!read_pgm_int_code()); - if (vm->sblk->sdf == 2) + if (sie_is_pv(vm)) memcpy(vm->sblk->pv_grregs, vm->save_area.guest.grs, sizeof(vm->save_area.guest.grs)); @@ -98,7 +98,7 @@ void sie(struct vm *vm) /* restore the old CR 13 */ lctlg(13, old_cr13); - if (vm->sblk->sdf == 2) + if (sie_is_pv(vm)) memcpy(vm->save_area.guest.grs, vm->sblk->pv_grregs, sizeof(vm->save_area.guest.grs)); } From patchwork Mon Feb 3 08:35:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13957011 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 DE5B91FAC23 for ; Mon, 3 Feb 2025 08:36:42 +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=1738571806; cv=none; b=Vx73QPqsFmEFrisCbXz3eAdJ3b1/7EXoYpaS3K2MwyaRd04vNgcnHhDuqH+tccvnZB2o1/jS9RrsyDAqzYxtUzVspty8ptnkWAttN3r8eCkls7Z8sOOsxEV6Ty+NDsH1DbZ7MRcWIzW4yrSkqrv6HKI+CPPzT4GFANq2HXxvhyI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738571806; c=relaxed/simple; bh=MTg4u83OG5wPCFXg7BvcZmXSPuICbhYcjI/W8yN31Gw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bcEjRF+LzK9XiVrKFoK9dDEN56ILTG29BwDgw62+HISyyXj0JkNyhSBHuQxwzHG2dFCei0sy3cEnK1HGf5Hiq1f8CUQLvYzyBaqTMa1ONkW2JFpfJo6gDAezj9vMXHSmnQ4dSotPFtM03KtvLcOmsYvSfK/TCSiIF41GkeuB8xE= 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=UZOfjoII; 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="UZOfjoII" 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 512NOvZP026239; Mon, 3 Feb 2025 08:36:32 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=IiKJPouBhocyFR/Ox 7gvxOPbLsJqC9Hk84fkUeDq7KA=; b=UZOfjoIIUWhyqdV7DtLSKlr5noC/bTQ9C HWeSG71geIL1CIg9JuqgGfU20yLxaQxZAHdHmNBR4OsqnnYAHY7YuIyFRrrKnlhP 1Ux0tRstE196tPtaWp1u1UvAEdTePHcQ5H3FD8pzDf6hHKkEYhopD51bklZPwTe9 SpcJw3VyweMMk06ezduUQyIZ2kfc5FASuCB1eXAOAo4AaA2B0dWpOJ4eVs/1x4VU 0UNT94r6rKily0DNy2rCCxrM5ZE7I8ssPf/He3/SUEIkZ3B5GfzwPozusFbLjXCP 9KXyPCLTv4Jl8NPWvM2Dc8U3V/v24ms2OBAKmG2/eSjX31krrhWyQ== 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 44jbht2xb8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2025 08:36:32 +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 5137H8PE007192; Mon, 3 Feb 2025 08:36:31 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 44hxaydhha-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2025 08:36:31 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5138aSIm46334362 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 3 Feb 2025 08:36:28 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 011652004B; Mon, 3 Feb 2025 08:36:28 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 84FF920043; Mon, 3 Feb 2025 08:36:27 +0000 (GMT) Received: from t14-nrb.lan (unknown [9.171.84.16]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 3 Feb 2025 08:36:27 +0000 (GMT) From: Nico Boehr To: thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, imbrenda@linux.ibm.com, Nina Schoetterl-Glausch Subject: [kvm-unit-tests GIT PULL 07/18] s390x: Add function for checking diagnose intercepts Date: Mon, 3 Feb 2025 09:35:15 +0100 Message-ID: <20250203083606.22864-8-nrb@linux.ibm.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250203083606.22864-1-nrb@linux.ibm.com> References: <20250203083606.22864-1-nrb@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: yhXgDRDF8r89jKsA8nS5JyZ6SxHcH-iO X-Proofpoint-GUID: yhXgDRDF8r89jKsA8nS5JyZ6SxHcH-iO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-02-03_03,2025-01-31_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 adultscore=0 impostorscore=0 phishscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 suspectscore=0 lowpriorityscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2501170000 definitions=main-2502030068 From: Nina Schoetterl-Glausch sie_is_diag_icpt() checks if the intercept is due to an expected diagnose call and is valid. It subsumes pv_icptdata_check_diag. Signed-off-by: Nina Schoetterl-Glausch Reviewed-by: Janosch Frank Link: https://lore.kernel.org/r/20241016180320.686132-4-nsg@linux.ibm.com Signed-off-by: Nico Boehr --- s390x/Makefile | 1 + lib/s390x/pv_icptdata.h | 42 ----------------------------- lib/s390x/sie-icpt.h | 39 +++++++++++++++++++++++++++ lib/s390x/sie-icpt.c | 60 +++++++++++++++++++++++++++++++++++++++++ s390x/pv-diags.c | 9 +++---- s390x/pv-icptcode.c | 12 ++++----- s390x/pv-ipl.c | 8 +++--- 7 files changed, 114 insertions(+), 57 deletions(-) delete mode 100644 lib/s390x/pv_icptdata.h create mode 100644 lib/s390x/sie-icpt.h create mode 100644 lib/s390x/sie-icpt.c diff --git a/s390x/Makefile b/s390x/Makefile index 66d71351..907b3a04 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -112,6 +112,7 @@ cflatobjs += lib/s390x/css_lib.o cflatobjs += lib/s390x/malloc_io.o cflatobjs += lib/s390x/uv.o cflatobjs += lib/s390x/sie.o +cflatobjs += lib/s390x/sie-icpt.o cflatobjs += lib/s390x/fault.o OBJDIRS += lib/s390x diff --git a/lib/s390x/pv_icptdata.h b/lib/s390x/pv_icptdata.h deleted file mode 100644 index 4746117e..00000000 --- a/lib/s390x/pv_icptdata.h +++ /dev/null @@ -1,42 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * Commonly used checks for PV SIE intercept data - * - * Copyright IBM Corp. 2023 - * Author: Janosch Frank - */ - -#ifndef _S390X_PV_ICPTDATA_H_ -#define _S390X_PV_ICPTDATA_H_ - -#include - -/* - * Checks the diagnose instruction intercept data for consistency with - * the constants defined by the PV SIE architecture - * - * Supports: 0x44, 0x9c, 0x288, 0x308, 0x500 - */ -static bool pv_icptdata_check_diag(struct vm *vm, int diag) -{ - int icptcode; - - switch (diag) { - case 0x44: - case 0x9c: - case 0x288: - case 0x308: - icptcode = ICPT_PV_NOTIFY; - break; - case 0x500: - icptcode = ICPT_PV_INSTR; - break; - default: - /* If a new diag is introduced add it to the cases above! */ - assert(0); - } - - return vm->sblk->icptcode == icptcode && vm->sblk->ipa == 0x8302 && - vm->sblk->ipb == 0x50000000 && vm->save_area.guest.grs[5] == diag; -} -#endif diff --git a/lib/s390x/sie-icpt.h b/lib/s390x/sie-icpt.h new file mode 100644 index 00000000..604a7221 --- /dev/null +++ b/lib/s390x/sie-icpt.h @@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Functionality for SIE interception handling. + * + * Copyright IBM Corp. 2024 + */ + +#ifndef _S390X_SIE_ICPT_H_ +#define _S390X_SIE_ICPT_H_ + +#include +#include + +struct diag_itext { + uint64_t opcode : 8; + uint64_t r_1 : 4; + uint64_t r_2 : 4; + uint64_t r_base : 4; + uint64_t displace : 12; + uint64_t zero : 16; + uint64_t : 16; +}; + +struct diag_itext sblk_ip_as_diag(struct kvm_s390_sie_block *sblk); + +/** + * sie_is_diag_icpt() - Check if intercept is due to diagnose instruction + * @vm: the guest + * @diag: the expected diagnose code + * + * Check that the intercept is due to diagnose @diag and valid. + * For protected virtualization, check that the intercept data meets additional + * constraints. + * + * Returns: true if intercept is due to a valid and has matching diagnose code + */ +bool sie_is_diag_icpt(struct vm *vm, unsigned int diag); + +#endif /* _S390X_SIE_ICPT_H_ */ diff --git a/lib/s390x/sie-icpt.c b/lib/s390x/sie-icpt.c new file mode 100644 index 00000000..17064424 --- /dev/null +++ b/lib/s390x/sie-icpt.c @@ -0,0 +1,60 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Functionality for SIE interception handling. + * + * Copyright IBM Corp. 2024 + */ + +#include + +struct diag_itext sblk_ip_as_diag(struct kvm_s390_sie_block *sblk) +{ + union { + struct { + uint64_t ipa : 16; + uint64_t ipb : 32; + uint64_t : 16; + }; + struct diag_itext diag; + } instr = { .ipa = sblk->ipa, .ipb = sblk->ipb }; + + return instr.diag; +} + +bool sie_is_diag_icpt(struct vm *vm, unsigned int diag) +{ + struct diag_itext instr = sblk_ip_as_diag(vm->sblk); + uint8_t icptcode; + uint64_t code; + + switch (diag) { + case 0x44: + case 0x9c: + case 0x288: + case 0x308: + icptcode = ICPT_PV_NOTIFY; + break; + case 0x500: + icptcode = ICPT_PV_INSTR; + break; + default: + /* If a new diag is introduced add it to the cases above! */ + assert_msg(false, "unknown diag 0x%x", diag); + } + + if (sie_is_pv(vm)) { + if (instr.r_1 != 0 || instr.r_2 != 2 || instr.r_base != 5) + return false; + if (instr.displace) + return false; + } else { + icptcode = ICPT_INST; + } + if (vm->sblk->icptcode != icptcode) + return false; + if (instr.opcode != 0x83 || instr.zero) + return false; + code = instr.r_base ? vm->save_area.guest.grs[instr.r_base] : 0; + code = (code + instr.displace) & 0xffff; + return code == diag; +} diff --git a/s390x/pv-diags.c b/s390x/pv-diags.c index 3193ad99..09b83d59 100644 --- a/s390x/pv-diags.c +++ b/s390x/pv-diags.c @@ -9,7 +9,7 @@ */ #include #include -#include +#include #include #include #include @@ -32,8 +32,7 @@ static void test_diag_500(void) size_gbin, size_hdr, SNIPPET_UNPACK_OFF); sie(&vm); - report(pv_icptdata_check_diag(&vm, 0x500), - "intercept values"); + report(sie_is_diag_icpt(&vm, 0x500), "intercept values"); report(vm.save_area.guest.grs[1] == 1 && vm.save_area.guest.grs[2] == 2 && vm.save_area.guest.grs[3] == 3 && @@ -45,7 +44,7 @@ static void test_diag_500(void) */ vm.sblk->iictl = IICTL_CODE_OPERAND; sie(&vm); - report(pv_icptdata_check_diag(&vm, 0x9c) && + report(sie_is_diag_icpt(&vm, 0x9c) && vm.save_area.guest.grs[0] == PGM_INT_CODE_OPERAND, "operand exception"); @@ -57,7 +56,7 @@ static void test_diag_500(void) vm.sblk->iictl = IICTL_CODE_SPECIFICATION; /* Inject PGM, next exit should be 9c */ sie(&vm); - report(pv_icptdata_check_diag(&vm, 0x9c) && + report(sie_is_diag_icpt(&vm, 0x9c) && vm.save_area.guest.grs[0] == PGM_INT_CODE_SPECIFICATION, "specification exception"); diff --git a/s390x/pv-icptcode.c b/s390x/pv-icptcode.c index d7c47d6f..5293306b 100644 --- a/s390x/pv-icptcode.c +++ b/s390x/pv-icptcode.c @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include #include @@ -47,7 +47,7 @@ static void test_validity_timing(void) size_gbin, size_hdr, SNIPPET_UNPACK_OFF); sie(&vm); - report(pv_icptdata_check_diag(&vm, 0x44), "spt done"); + report(sie_is_diag_icpt(&vm, 0x44), "spt done"); stck(&time_exit); tmp = vm.sblk->cputm; mb(); @@ -258,7 +258,7 @@ static void test_validity_asce(void) /* Try if we can still do an entry with the correct asce */ sie(&vm); - report(pv_icptdata_check_diag(&vm, 0x44), "re-entry with valid CR1"); + report(sie_is_diag_icpt(&vm, 0x44), "re-entry with valid CR1"); uv_destroy_guest(&vm); free_pages(pgd_new); report_prefix_pop(); @@ -294,7 +294,7 @@ static void run_icpt_122_tests_prefix(unsigned long prefix) sie(&vm); /* Guest indicates that it has been setup via the diag 0x44 */ - assert(pv_icptdata_check_diag(&vm, 0x44)); + assert(sie_is_diag_icpt(&vm, 0x44)); /* If the pages have not been shared these writes will cause exceptions */ ptr = (uint32_t *)prefix; WRITE_ONCE(ptr, 0); @@ -328,7 +328,7 @@ static void test_icpt_112(void) /* Setup of the guest's state for 0x0 prefix */ sie(&vm); - assert(pv_icptdata_check_diag(&vm, 0x44)); + assert(sie_is_diag_icpt(&vm, 0x44)); /* Test on standard 0x0 prefix */ run_icpt_122_tests_prefix(0); @@ -348,7 +348,7 @@ static void test_icpt_112(void) /* Try a re-entry after everything has been imported again */ sie(&vm); - report(pv_icptdata_check_diag(&vm, 0x9c) && + report(sie_is_diag_icpt(&vm, 0x9c) && vm.save_area.guest.grs[0] == 42, "re-entry successful"); report_prefix_pop(); diff --git a/s390x/pv-ipl.c b/s390x/pv-ipl.c index cc46e7f7..61a1e0c0 100644 --- a/s390x/pv-ipl.c +++ b/s390x/pv-ipl.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include @@ -35,7 +35,7 @@ static void test_diag_308(int subcode) /* First exit is a diag 0x500 */ sie(&vm); - assert(pv_icptdata_check_diag(&vm, 0x500)); + assert(sie_is_diag_icpt(&vm, 0x500)); /* * The snippet asked us for the subcode and we answer by @@ -46,7 +46,7 @@ static void test_diag_308(int subcode) /* Continue after diag 0x500, next icpt should be the 0x308 */ sie(&vm); - assert(pv_icptdata_check_diag(&vm, 0x308)); + assert(sie_is_diag_icpt(&vm, 0x308)); assert(vm.save_area.guest.grs[2] == subcode); /* @@ -118,7 +118,7 @@ static void test_diag_308(int subcode) * see a diagnose 0x9c PV instruction notification. */ sie(&vm); - report(pv_icptdata_check_diag(&vm, 0x9c) && + report(sie_is_diag_icpt(&vm, 0x9c) && vm.save_area.guest.grs[0] == 42, "continue after load"); From patchwork Mon Feb 3 08:35:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13957008 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 6F0221FBC92 for ; Mon, 3 Feb 2025 08:36:43 +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=1738571805; cv=none; b=WWtoEQ6FDtBKCPIqnvopA4BNMWRCI2PlnyohQwoQnUcoqAFjDQvzZG4MSM+egE1uzn+zfVEbYSTkzF2Kl1cJouch3AxkDiZg6XHG/lLUFC+XEPh8tnvMvpZ9vDUu/QU8yqZOqTQAmDgyneNr7X7lnQM8CX14mqdpk+hBOBH7Dsk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738571805; c=relaxed/simple; bh=6J2E+GafP9GP+EDU3mwFGlAbtSZDBQxjsHAovyykeA0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=th+iJPFwWhiClD6cKUEGeOkzr+P1LoOPdXi3vZw0Ovh2TIeDII3tZbEHE7nKDga69WnY34IIZtW6R26Hj6A2QGSyXNf4vwanrsDPyM/zCHnA7qPxO++gKrbAXk8kAclk0IAFvacYPqW2xFcU5LzprhgAX/OOhmOioY8r4am3Esk= 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=MJmDrr9X; 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="MJmDrr9X" 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 5135Nj0B012875; Mon, 3 Feb 2025 08:36:33 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=zWpbI07Qh1H179L5N ZcyLr/xpTr9x8G65Lj0lVc/pho=; b=MJmDrr9XkPoKux7+R1yxsaFQHaOCQ7TpQ fiirYCFF6qkicQFxM2JciowUx6r2C8rKLOZ7M6+coeiKg3TsS3V4GXpENORXSlmF O1m6NSttuUMI9OvuwkL2rGlL4zKNQ5pIJY3WqdbPYwlHlBT7QAWVw+0BiIkDQnWw Sr8YxHAmk/hXZOa2wvXoazJT82qUbq8YOUlD8BsYxc3sPVox8BAxdFsLLZIw2cCy IYvyt9DOm5ig6DFIo5oXz/xZt8Mm19+JYRSavQ/ZPJttSiUGmkly3sogQB6QNu4s T4tiRwLCDWhoI+f5+JLyHHkhCEVxk4zM5Mh0ja06T0bTDaDUKA4Pw== 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 44jqm78svf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2025 08:36:32 +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 5138aEFB005251; Mon, 3 Feb 2025 08:36:32 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 44j05jn6ap-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2025 08:36:32 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5138aSli48234752 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 3 Feb 2025 08:36:28 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 822BE20040; Mon, 3 Feb 2025 08:36:28 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1472F2004D; Mon, 3 Feb 2025 08:36:28 +0000 (GMT) Received: from t14-nrb.lan (unknown [9.171.84.16]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 3 Feb 2025 08:36:28 +0000 (GMT) From: Nico Boehr To: thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, imbrenda@linux.ibm.com, Nina Schoetterl-Glausch Subject: [kvm-unit-tests GIT PULL 08/18] s390x: Add library functions for exiting from snippet Date: Mon, 3 Feb 2025 09:35:16 +0100 Message-ID: <20250203083606.22864-9-nrb@linux.ibm.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250203083606.22864-1-nrb@linux.ibm.com> References: <20250203083606.22864-1-nrb@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: RwGLNSxHw8bd4zE002Wc3qT9h5OR69iM X-Proofpoint-ORIG-GUID: RwGLNSxHw8bd4zE002Wc3qT9h5OR69iM X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-02-03_03,2025-01-31_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 clxscore=1015 lowpriorityscore=0 mlxlogscore=862 bulkscore=0 mlxscore=0 suspectscore=0 priorityscore=1501 phishscore=0 impostorscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2501170000 definitions=main-2502030068 From: Nina Schoetterl-Glausch It is useful to be able to force an exit to the host from the snippet, as well as do so while returning a value. Add this functionality, also add helper functions for the host to check for an exit and get or check the value. Use diag 0x44 and 0x9c for this. Add a guest specific snippet header file and rename snippet.h to reflect that it is host specific. Signed-off-by: Nina Schoetterl-Glausch Link: https://lore.kernel.org/r/20241016180320.686132-5-nsg@linux.ibm.com [ nrb: fix out-of-tree builds ] Signed-off-by: Nico Boehr --- s390x/Makefile | 7 +++-- lib/s390x/asm/arch_def.h | 16 +++++++++++ lib/s390x/snippet-exit.h | 45 +++++++++++++++++++++++++++++++ s390x/snippets/lib/snippet-exit.h | 28 +++++++++++++++++++ 4 files changed, 94 insertions(+), 2 deletions(-) create mode 100644 lib/s390x/snippet-exit.h create mode 100644 s390x/snippets/lib/snippet-exit.h diff --git a/s390x/Makefile b/s390x/Makefile index 907b3a04..9eeff198 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -71,7 +71,8 @@ test_cases: $(tests) test_cases_binary: $(tests_binary) test_cases_pv: $(tests_pv_binary) -INCLUDE_PATHS = $(SRCDIR)/lib $(SRCDIR)/lib/s390x $(SRCDIR)/s390x +SNIPPET_INCLUDE := +INCLUDE_PATHS = $(SNIPPET_INCLUDE) $(SRCDIR)/lib $(SRCDIR)/lib/s390x $(SRCDIR)/s390x # Include generated header files (e.g. in case of out-of-source builds) INCLUDE_PATHS += lib CPPFLAGS = $(addprefix -I,$(INCLUDE_PATHS)) @@ -122,6 +123,7 @@ asmlib = $(TEST_DIR)/cstart64.o $(TEST_DIR)/cpu.o FLATLIBS = $(libcflat) SNIPPET_DIR = $(TEST_DIR)/snippets +SNIPPET_SRC_DIR = $(SRCDIR)/s390x/snippets snippet_asmlib = $(SNIPPET_DIR)/c/cstart.o snippet_lib = $(snippet_asmlib) lib/auxinfo.o @@ -149,9 +151,10 @@ snippet-hdr-obj = endif # the asm/c snippets %.o have additional generated files as dependencies -$(SNIPPET_DIR)/asm/%.o: $(SNIPPET_DIR)/asm/%.S $(asm-offsets) +$(SNIPPET_DIR)/asm/%.o: $(SNIPPET_SRC_DIR)/asm/%.S $(asm-offsets) $(CC) $(CFLAGS) -c -nostdlib -o $@ $< +$(SNIPPET_DIR)/c/%.o: SNIPPET_INCLUDE := $(SNIPPET_SRC_DIR)/lib $(SNIPPET_DIR)/c/%.o: $(SNIPPET_DIR)/c/%.c $(asm-offsets) $(CC) $(CFLAGS) -c -nostdlib -o $@ $< diff --git a/lib/s390x/asm/arch_def.h b/lib/s390x/asm/arch_def.h index 5574a451..03adcd3c 100644 --- a/lib/s390x/asm/arch_def.h +++ b/lib/s390x/asm/arch_def.h @@ -505,4 +505,20 @@ static inline uint32_t get_prefix(void) return current_prefix; } +static inline void diag44(void) +{ + asm volatile("diag 0,0,0x44\n"); +} + +static inline void diag500(uint64_t val) +{ + asm volatile( + "lgr 2,%[val]\n" + "diag 0,0,0x500\n" + : + : [val] "d"(val) + : "r2" + ); +} + #endif diff --git a/lib/s390x/snippet-exit.h b/lib/s390x/snippet-exit.h new file mode 100644 index 00000000..3ed4c22c --- /dev/null +++ b/lib/s390x/snippet-exit.h @@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Functionality handling snippet exits + * + * Copyright IBM Corp. 2024 + */ + +#ifndef _S390X_SNIPPET_EXIT_H_ +#define _S390X_SNIPPET_EXIT_H_ + +#include +#include +#include + +static inline bool snippet_is_force_exit(struct vm *vm) +{ + return sie_is_diag_icpt(vm, 0x44); +} + +static inline bool snippet_is_force_exit_value(struct vm *vm) +{ + return sie_is_diag_icpt(vm, 0x500); +} + +static inline uint64_t snippet_get_force_exit_value(struct vm *vm) +{ + assert(snippet_is_force_exit_value(vm)); + + return vm->save_area.guest.grs[2]; +} + +static inline void snippet_check_force_exit_value(struct vm *vm, uint64_t value_exp) +{ + uint64_t value; + + if (snippet_is_force_exit_value(vm)) { + value = snippet_get_force_exit_value(vm); + report(value == value_exp, "guest forced exit with value (0x%lx == 0x%lx)", + value, value_exp); + } else { + report_fail("guest forced exit with value"); + } +} + +#endif /* _S390X_SNIPPET_EXIT_H_ */ diff --git a/s390x/snippets/lib/snippet-exit.h b/s390x/snippets/lib/snippet-exit.h new file mode 100644 index 00000000..ac00de3f --- /dev/null +++ b/s390x/snippets/lib/snippet-exit.h @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Functionality for exiting the snippet. + * + * Copyright IBM Corp. 2023 + */ + +#ifndef _S390X_SNIPPET_LIB_EXIT_H_ +#define _S390X_SNIPPET_LIB_EXIT_H_ + +#include +#include + +static inline void force_exit(void) +{ + mb(); /* host may read any memory written by the guest before */ + diag44(); + mb(); /* allow host to modify guest memory */ +} + +static inline void force_exit_value(uint64_t val) +{ + mb(); /* host may read any memory written by the guest before */ + diag500(val); + mb(); /* allow host to modify guest memory */ +} + +#endif /* _S390X_SNIPPET_LIB_EXIT_H_ */ From patchwork Mon Feb 3 08:35:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13957021 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 B62A5207A19 for ; Mon, 3 Feb 2025 08:36:49 +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=1738571811; cv=none; b=pKKLdUThUX7Ce0ci7LGsD8YIx6rysUGkRGggbuRCBMsxojG0LdlH+2pRIsMT0oteeLcsckWWMC7ZHrmEku5EQqnJooWZ1w3WykiCUAUsjestY6juVhLkyJoTCOpaxTvrSJI1RhGlPD0wrmCtXW+rVAJUTXZh6PKrIu+QSQc/0K8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738571811; c=relaxed/simple; bh=pTt1HxOpcKGFulC43K15//sRXaSnw9CAJMmxbYk4W9w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ugDOhXaQPRHVe2RZXOyI24a1drx3thL3WouJDgb03pt0rypo0NTXsh2IG+FI2TRdsi5/vE4bmvnK4nCuK0/ZBdaQ4mjXgk6jnUeFjyMgiTfy7HC9dAl0bqtff2T2hjdEHE6swGAedUAARhepNuKlbjKfqBK8JyAmbXIM8v++a28= 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=aAq1DSOj; 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="aAq1DSOj" 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 512LkaJD027268; Mon, 3 Feb 2025 08:36:34 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=uzUC2co3msp0iiX6i mP+T7yNPXZnHyO+vvROU0ZAqfI=; b=aAq1DSOjxkYCB/Mjau8VOWrp8tu++48fb UhGZKEQfvh3VCbXM1Xk/bv/t7c0kZ+/0zJRz1GHDrMji+4h8MzOvFMqJjORq5ZY8 /8qleCwBTjL/Y5T13QcdjN9Gf0efnxzjovWyXs/S8VdU8kU1A5dR9wzBvLT7UUw3 NVExVIBCbGaQUFaPU/lLdgfswjh/EscrOSdH/cl81DHyCXrKTa4JPg0tM2vvgCvV PZIviExFIp8iZaLQw6EfEeEpOJSvbpHxy6baP2IeA1G1LRzfDQV1FWl+4kg7gvS/ iN00jaHVzrXSrkA15h7sGM7SoEIRWmc+vyNM2tlsf7Ck8Z/AysVoQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 44jayyba1v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2025 08:36:34 +0000 (GMT) Received: from m0356517.ppops.net (m0356517.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 5138aYTJ014597; Mon, 3 Feb 2025 08:36:34 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 44jayyba1c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2025 08:36:34 +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 5137OFgO007136; Mon, 3 Feb 2025 08:36:32 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 44hxaydhhu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2025 08:36:32 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5138aTLo48169336 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 3 Feb 2025 08:36:29 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 19E8020040; Mon, 3 Feb 2025 08:36:29 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 962EC20043; Mon, 3 Feb 2025 08:36:28 +0000 (GMT) Received: from t14-nrb.lan (unknown [9.171.84.16]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 3 Feb 2025 08:36:28 +0000 (GMT) From: Nico Boehr To: thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, imbrenda@linux.ibm.com, Nina Schoetterl-Glausch , Nicholas Piggin Subject: [kvm-unit-tests GIT PULL 09/18] s390x: Use library functions for snippet exit Date: Mon, 3 Feb 2025 09:35:17 +0100 Message-ID: <20250203083606.22864-10-nrb@linux.ibm.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250203083606.22864-1-nrb@linux.ibm.com> References: <20250203083606.22864-1-nrb@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: iQnsEK7vqMsgWpqXRwqBKG4PCks80ttk X-Proofpoint-ORIG-GUID: 2VtnVHaFpL6GxQqdHswPUi89HDJt5ZN4 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-02-03_03,2025-01-31_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 lowpriorityscore=0 mlxlogscore=999 adultscore=0 priorityscore=1501 phishscore=0 impostorscore=0 malwarescore=0 mlxscore=0 bulkscore=0 suspectscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2501170000 definitions=main-2502030068 From: Nina Schoetterl-Glausch Replace the existing code for exiting from snippets with the newly introduced library functionality. Reviewed-by: Claudio Imbrenda Reviewed-by: Nicholas Piggin Signed-off-by: Nina Schoetterl-Glausch Reviewed-by: Janosch Frank Link: https://lore.kernel.org/r/20241016180320.686132-6-nsg@linux.ibm.com Signed-off-by: Nico Boehr --- s390x/sie-dat.c | 12 ++++-------- s390x/snippets/c/sie-dat.c | 19 +------------------ 2 files changed, 5 insertions(+), 26 deletions(-) diff --git a/s390x/sie-dat.c b/s390x/sie-dat.c index f0257770..44bf29fe 100644 --- a/s390x/sie-dat.c +++ b/s390x/sie-dat.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "snippets/c/sie-dat.h" static struct vm vm; @@ -27,23 +28,18 @@ static void test_sie_dat(void) uint64_t test_page_gpa, test_page_hpa; uint8_t *test_page_hva, expected_val; bool contents_match; - uint8_t r1; /* guest will tell us the guest physical address of the test buffer */ sie(&vm); - assert(vm.sblk->icptcode == ICPT_INST && - (vm.sblk->ipa & 0xff00) == 0x8300 && vm.sblk->ipb == 0x9c0000); - - r1 = (vm.sblk->ipa & 0xf0) >> 4; - test_page_gpa = vm.save_area.guest.grs[r1]; + assert(snippet_is_force_exit_value(&vm)); + test_page_gpa = snippet_get_force_exit_value(&vm); test_page_hpa = virt_to_pte_phys(guest_root, (void*)test_page_gpa); test_page_hva = __va(test_page_hpa); report_info("test buffer gpa=0x%lx hva=%p", test_page_gpa, test_page_hva); /* guest will now write to the test buffer and we verify the contents */ sie(&vm); - assert(vm.sblk->icptcode == ICPT_INST && - vm.sblk->ipa == 0x8300 && vm.sblk->ipb == 0x440000); + assert(snippet_is_force_exit(&vm)); contents_match = true; for (unsigned int i = 0; i < GUEST_TEST_PAGE_COUNT; i++) { diff --git a/s390x/snippets/c/sie-dat.c b/s390x/snippets/c/sie-dat.c index 9d89801d..ba1604de 100644 --- a/s390x/snippets/c/sie-dat.c +++ b/s390x/snippets/c/sie-dat.c @@ -10,28 +10,11 @@ #include #include #include +#include #include "sie-dat.h" static uint8_t test_pages[GUEST_TEST_PAGE_COUNT * PAGE_SIZE] __attribute__((__aligned__(PAGE_SIZE))); -static inline void force_exit(void) -{ - asm volatile("diag 0,0,0x44\n" - : - : - : "memory" - ); -} - -static inline void force_exit_value(uint64_t val) -{ - asm volatile("diag %[val],0,0x9c\n" - : - : [val] "d"(val) - : "memory" - ); -} - int main(void) { uint8_t *invalid_ptr; From patchwork Mon Feb 3 08:35:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13957010 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 D91C11FBEB9 for ; Mon, 3 Feb 2025 08:36:43 +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=1738571805; cv=none; b=clAs7otkZD0+/GqujRL2/Hat44YUHKr6YtM4A48tTXa7wws2cqABBjjte92ubQFEUsKxyi8nFjRIaVNBTMRrEkissc1q6tFmbOUSm/fb0P2PX6KIx8fsaJYdnwZPSOZ3ieiC7dmVEFL7fIH8w2D414MIMJYJ5Wl/ItBIyrdAymE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738571805; c=relaxed/simple; bh=2cB7qri0j8Oj3glnvt/A09nFbQf++I3P/RZMQC5MURY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=koow0xAHXLPfmqu9ZzBDtP6wl6+wm9JfRPxpcNUJsGJuw6uuhsITDRcTvNujAHpmtWafOX1FHGU+vlyJz4Hup7vr1gDGl60zUUEwh84IF2ixB6sO0NVq1vJCx46j6jQgjQnC9pkogXC81F3YxeReYHgY4aTjLeVCSIGs9NYI4o0= 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=MOF71mnL; 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="MOF71mnL" 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 51320jUv006210; Mon, 3 Feb 2025 08:36:34 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=Y9OrjRuC5VqLymhs2 eUN753itGdMJOLUGEzng7OlUYQ=; b=MOF71mnLI5EjiCCEau9uPkBCClwe5OBWl 3G2lIrXllFGHnFnWECrzOPi6S80MHAJuEwANYDNY2vTHmMhsoPoRyvKRIQeuZkQ2 3nA7dQTGlp2IbBHXslU1lRf7ghNAVIMsoBnwzuGuu2mMWVXofw6S/XzRPYsry/z+ xj6ved7qD1C+R9FJKY7GvPwYHVBPhOC34gKig3S5P4/pEKXxjrpKXRdF84NfCUwn RU2eQfFR/yaHz+AypDc5mhLEOzLE9NRQ7GtSuK9lO/VaUJfpwsxYwTPgJydiPBp6 DfXBAwM95o9jwPOka2ahZu+7trbsi5vNCC/zCTHsVq1Y/+RU/L7yw== 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 44jmmy9cdc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2025 08:36:33 +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 5136tp9s016288; Mon, 3 Feb 2025 08:36:33 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 44hwxs5kt2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2025 08:36:33 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5138aTF848169338 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 3 Feb 2025 08:36:29 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9B5F520040; Mon, 3 Feb 2025 08:36:29 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2BDD920043; Mon, 3 Feb 2025 08:36:29 +0000 (GMT) Received: from t14-nrb.lan (unknown [9.171.84.16]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 3 Feb 2025 08:36:29 +0000 (GMT) From: Nico Boehr To: thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, imbrenda@linux.ibm.com, Nina Schoetterl-Glausch Subject: [kvm-unit-tests GIT PULL 10/18] s390x: Add test for STFLE interpretive execution (format-0) Date: Mon, 3 Feb 2025 09:35:18 +0100 Message-ID: <20250203083606.22864-11-nrb@linux.ibm.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250203083606.22864-1-nrb@linux.ibm.com> References: <20250203083606.22864-1-nrb@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: LpDSyQYCpAPVVqFiOGgauY67G1Kmb-5F X-Proofpoint-ORIG-GUID: LpDSyQYCpAPVVqFiOGgauY67G1Kmb-5F X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-02-03_03,2025-01-31_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 malwarescore=0 phishscore=0 impostorscore=0 priorityscore=1501 mlxscore=0 lowpriorityscore=0 mlxlogscore=999 bulkscore=0 spamscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2501170000 definitions=main-2502030068 From: Nina Schoetterl-Glausch The STFLE instruction indicates installed facilities. SIE can interpretively execute STFLE. Use a snippet guest executing STFLE to get the result of interpretive execution and check the result. Signed-off-by: Nina Schoetterl-Glausch Link: https://lore.kernel.org/r/20241016180320.686132-7-nsg@linux.ibm.com [ nrb: fixup minor checkpatch issues ] Signed-off-by: Nico Boehr --- s390x/Makefile | 2 + lib/s390x/asm/facility.h | 10 ++- s390x/snippets/c/stfle.c | 29 ++++++++ s390x/stfle-sie.c | 138 +++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 3 + 5 files changed, 181 insertions(+), 1 deletion(-) create mode 100644 s390x/snippets/c/stfle.c create mode 100644 s390x/stfle-sie.c diff --git a/s390x/Makefile b/s390x/Makefile index 9eeff198..4424877e 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -45,6 +45,7 @@ tests += $(TEST_DIR)/ex.elf tests += $(TEST_DIR)/topology.elf tests += $(TEST_DIR)/sie-dat.elf tests += $(TEST_DIR)/diag258.elf +tests += $(TEST_DIR)/stfle-sie.elf pv-tests += $(TEST_DIR)/pv-diags.elf pv-tests += $(TEST_DIR)/pv-icptcode.elf @@ -132,6 +133,7 @@ snippet_lib = $(snippet_asmlib) lib/auxinfo.o $(TEST_DIR)/mvpg-sie.elf: snippets = $(SNIPPET_DIR)/c/mvpg-snippet.gbin $(TEST_DIR)/sie-dat.elf: snippets = $(SNIPPET_DIR)/c/sie-dat.gbin $(TEST_DIR)/spec_ex-sie.elf: snippets = $(SNIPPET_DIR)/c/spec_ex.gbin +$(TEST_DIR)/stfle-sie.elf: snippets = $(SNIPPET_DIR)/c/stfle.gbin $(TEST_DIR)/pv-diags.elf: pv-snippets += $(SNIPPET_DIR)/asm/pv-diag-yield.gbin $(TEST_DIR)/pv-diags.elf: pv-snippets += $(SNIPPET_DIR)/asm/pv-diag-288.gbin diff --git a/lib/s390x/asm/facility.h b/lib/s390x/asm/facility.h index a66fe56a..2bad05c5 100644 --- a/lib/s390x/asm/facility.h +++ b/lib/s390x/asm/facility.h @@ -27,12 +27,20 @@ static inline void stfl(void) asm volatile(" stfl 0(0)\n" : : : "memory"); } -static inline void stfle(uint64_t *fac, unsigned int nb_doublewords) +static inline unsigned int stfle(uint64_t *fac, unsigned int nb_doublewords) { register unsigned long r0 asm("0") = nb_doublewords - 1; asm volatile(" .insn s,0xb2b00000,0(%1)\n" : "+d" (r0) : "a" (fac) : "memory", "cc"); + return r0 + 1; +} + +static inline unsigned long stfle_size(void) +{ + uint64_t dummy; + + return stfle(&dummy, 1); } static inline void setup_facilities(void) diff --git a/s390x/snippets/c/stfle.c b/s390x/snippets/c/stfle.c new file mode 100644 index 00000000..5fb6f948 --- /dev/null +++ b/s390x/snippets/c/stfle.c @@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright IBM Corp. 2023 + * + * Snippet used by the STLFE interpretive execution facilities test. + */ +#include +#include + +int main(void) +{ + const unsigned int max_fac_len = 8; + uint64_t len_arg = max_fac_len - 1; + uint64_t res[max_fac_len + 1]; + uint64_t fac[max_fac_len]; + + asm volatile (" lgr 0,%[len]\n" + " stfle %[fac]\n" + " lgr %[len],0\n" + : [fac] "=Q"(fac), + [len] "+d"(len_arg) + : + : "%r0", "cc" + ); + res[0] = len_arg; + memcpy(&res[1], fac, sizeof(fac)); + force_exit_value((uint64_t)&res); + return 0; +} diff --git a/s390x/stfle-sie.c b/s390x/stfle-sie.c new file mode 100644 index 00000000..21cf8ff8 --- /dev/null +++ b/s390x/stfle-sie.c @@ -0,0 +1,138 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright IBM Corp. 2023 + * + * SIE with STLFE interpretive execution facilities test. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static struct vm vm; +static uint64_t (*fac)[PAGE_SIZE / sizeof(uint64_t)]; +static prng_state prng_s; + +static void setup_guest(void) +{ + extern const char SNIPPET_NAME_START(c, stfle)[]; + extern const char SNIPPET_NAME_END(c, stfle)[]; + + setup_vm(); + fac = alloc_pages_flags(0, AREA_DMA31); + + snippet_setup_guest(&vm, false); + snippet_init(&vm, SNIPPET_NAME_START(c, stfle), + SNIPPET_LEN(c, stfle), SNIPPET_UNPACK_OFF); +} + +struct guest_stfle_res { + uint16_t len; + unsigned char *mem; +}; + +static struct guest_stfle_res run_guest(void) +{ + struct guest_stfle_res res; + uint64_t guest_stfle_addr; + uint64_t reg; + + sie(&vm); + assert(snippet_is_force_exit_value(&vm)); + guest_stfle_addr = snippet_get_force_exit_value(&vm); + res.mem = &vm.guest_mem[guest_stfle_addr]; + memcpy(®, res.mem, sizeof(reg)); + res.len = (reg & 0xff) + 1; + res.mem += sizeof(reg); + return res; +} + +static void test_stfle_format_0(void) +{ + struct guest_stfle_res res; + + report_prefix_push("format-0"); + for (int j = 0; j < stfle_size(); j++) + WRITE_ONCE((*fac)[j], prng64(&prng_s)); + vm.sblk->fac = (uint32_t)(uint64_t)fac; + res = run_guest(); + report(res.len == stfle_size(), "stfle len correct"); + report(!memcmp(*fac, res.mem, res.len * sizeof(uint64_t)), + "Guest facility list as specified"); + report_prefix_pop(); +} + +struct args { + uint64_t seed; +}; + +static bool parse_uint64_t(const char *arg, uint64_t *out) +{ + char *end; + uint64_t num; + + if (arg[0] == '\0') + return false; + num = strtoul(arg, &end, 0); + if (end[0] != '\0') + return false; + *out = num; + return true; +} + +static struct args parse_args(int argc, char **argv) +{ + struct args args; + const char *flag; + unsigned int i; + uint64_t arg; + bool has_arg; + + stck(&args.seed); + + for (i = 1; i < argc; i++) { + if (i + 1 < argc) + has_arg = parse_uint64_t(argv[i + 1], &arg); + else + has_arg = false; + + flag = "--seed"; + if (!strcmp(flag, argv[i])) { + if (!has_arg) + report_abort("%s needs an uint64_t parameter", flag); + args.seed = arg; + ++i; + continue; + } + report_abort("Unsupported parameter '%s'", + argv[i]); + } + + return args; +} + +int main(int argc, char **argv) +{ + struct args args = parse_args(argc, argv); + bool run_format_0 = test_facility(7); + + if (!sclp_facilities.has_sief2) { + report_skip("SIEF2 facility unavailable"); + goto out; + } + if (!run_format_0) + report_skip("STFLE facility not available"); + + report_info("PRNG seed: 0x%lx", args.seed); + prng_s = prng_init(args.seed); + setup_guest(); + if (run_format_0) + test_stfle_format_0(); +out: + return report_summary(); +} diff --git a/s390x/unittests.cfg b/s390x/unittests.cfg index 8131ba10..a9af6680 100644 --- a/s390x/unittests.cfg +++ b/s390x/unittests.cfg @@ -395,3 +395,6 @@ file = pv-attest.elf [diag258] file = diag258.elf + +[stfle-sie] +file = stfle-sie.elf From patchwork Mon Feb 3 08:35:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13957017 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 AA07F1FAC23 for ; Mon, 3 Feb 2025 08:36:47 +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=1738571809; cv=none; b=QCcb7pmP6bbe4v65hV8GxEEyueVP1l3sn9cfvtRp+tQpj7DcAk5WgrwW2ARApHE4F+Ogw7ZXukRBzc8PJlNeuEp2y8HztWJj/PBaMgGnpUeck7McP9daIiB/fb1bKmo3e8vttB5LenjXeuKfLBqg4XM2WtDEpX+D5aMeSc3ADns= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738571809; c=relaxed/simple; bh=QDVDZYrHdUZh2zI77ftl8Fb4u8BuJlQAmN7nKBHDijE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=E+MB7qT/BTAs5PfMvo+Ha+kXDK5G2uKR/edLEwn4FLr7Uw5eRhYtKBWHjImooPJodSLS00yDPg2KX7yuVG8DaVSrXgwM7NtE4R4yfxm8cEyvdhUzTcETsTbOv4HxS8bkJFizdtYpKm40I378utLTq2Oe++VA2K7OGW9AgY2FtA8= 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=NfWCNZMU; 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="NfWCNZMU" 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 5135NvBW013502; Mon, 3 Feb 2025 08:36:36 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=1fzZgQI3foxMfX61C 0R8fj1NsCIsfPMorxhWj3LgIQk=; b=NfWCNZMUXFqmTHoyClh2PoHYYzaJr4Iy9 1Iyk11WCUBZD300WzHnDQ1w8zjNK/kbH6sR0TjAOp3nK3xhK//fytg9u/NwvLYKg Ux5sPSpkq34uhlYG47EcnbMy5hU6DPvwTzqFrRueKSHH22Q07vWUE1fw/47vIzg1 xxtJdhG6VxS2NBSVgDp7lPYD3tlEa1fUdf22xxgjM76mbJ/OsPHeevXh4bZLFM1N piPkEzOv6xcpIBHTvvdIoAMBs7EsrVS3WPlxR8FieStRMkS8hf4BQn5D/YL6gKXq GjxQECXc5RkiqAQM3N7jxxXIYGCZiUeIzWKxws8jDizWFUEXXWI4A== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 44jqm78swh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2025 08:36:35 +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 5138MhiU023802; Mon, 3 Feb 2025 08:36:35 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 44jqm78sw8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2025 08:36:35 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 51388AUq006543; Mon, 3 Feb 2025 08:36:34 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 44hyek5b7g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2025 08:36:33 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5138aUTp19726648 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 3 Feb 2025 08:36:30 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 335D520040; Mon, 3 Feb 2025 08:36:30 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AE43C2004B; Mon, 3 Feb 2025 08:36:29 +0000 (GMT) Received: from t14-nrb.lan (unknown [9.171.84.16]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 3 Feb 2025 08:36:29 +0000 (GMT) From: Nico Boehr To: thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, imbrenda@linux.ibm.com, Marc Hartmayer , Nicholas Piggin Subject: [kvm-unit-tests GIT PULL 11/18] s390x/Makefile: snippets: Add separate target for the ELF snippets Date: Mon, 3 Feb 2025 09:35:19 +0100 Message-ID: <20250203083606.22864-12-nrb@linux.ibm.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250203083606.22864-1-nrb@linux.ibm.com> References: <20250203083606.22864-1-nrb@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: jX1OpnWfgahZqw9gLxtqLkN1gdM2Ls3k X-Proofpoint-ORIG-GUID: BIBRqJjr7YCjRZ1BQ-uK3Pn2yH8b5TFb X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-02-03_03,2025-01-31_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 clxscore=1015 lowpriorityscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 suspectscore=0 priorityscore=1501 phishscore=0 impostorscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2501170000 definitions=main-2502030068 From: Marc Hartmayer It's unusual to create multiple files in one target rule, and it's even more unusual to create an ELF file with a `.gbin` file extension first, and then overwrite it in the next step. It might even lead to errors as the input file path is also used as the output file path - but this depends on the objcopy implementation. Therefore, create an extra target for the ELF files and list it as a prerequisite for the *.gbin targets. Signed-off-by: Marc Hartmayer Reviewed-by: Nicholas Piggin Reviewed-by: Janosch Frank Link: https://lore.kernel.org/r/20240604115932.86596-2-mhartmay@linux.ibm.com Signed-off-by: Nico Boehr --- s390x/Makefile | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/s390x/Makefile b/s390x/Makefile index 4424877e..b3b2ae8c 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -160,14 +160,18 @@ $(SNIPPET_DIR)/c/%.o: SNIPPET_INCLUDE := $(SNIPPET_SRC_DIR)/lib $(SNIPPET_DIR)/c/%.o: $(SNIPPET_DIR)/c/%.c $(asm-offsets) $(CC) $(CFLAGS) -c -nostdlib -o $@ $< -$(SNIPPET_DIR)/asm/%.gbin: $(SNIPPET_DIR)/asm/%.o $(SNIPPET_DIR)/asm/flat.lds +$(SNIPPET_DIR)/asm/%.elf: $(SNIPPET_DIR)/asm/%.o $(SNIPPET_DIR)/asm/flat.lds $(CC) $(LDFLAGS) -o $@ -T $(SNIPPET_DIR)/asm/flat.lds $< - $(OBJCOPY) -O binary -j ".rodata" -j ".lowcore" -j ".text" -j ".data" -j ".bss" --set-section-flags .bss=alloc,load,contents $@ $@ + +$(SNIPPET_DIR)/asm/%.gbin: $(SNIPPET_DIR)/asm/%.elf + $(OBJCOPY) -O binary -j ".rodata" -j ".lowcore" -j ".text" -j ".data" -j ".bss" --set-section-flags .bss=alloc,load,contents $< $@ truncate -s '%4096' $@ -$(SNIPPET_DIR)/c/%.gbin: $(SNIPPET_DIR)/c/%.o $(snippet_lib) $(FLATLIBS) $(SNIPPET_DIR)/c/flat.lds +$(SNIPPET_DIR)/c/%.elf: $(SNIPPET_DIR)/c/%.o $(snippet_lib) $(FLATLIBS) $(SNIPPET_DIR)/c/flat.lds $(CC) $(LDFLAGS) -o $@ -T $(SNIPPET_DIR)/c/flat.lds $< $(snippet_lib) $(FLATLIBS) - $(OBJCOPY) -O binary -j ".rodata" -j ".lowcore" -j ".text" -j ".data" -j ".bss" --set-section-flags .bss=alloc,load,contents $@ $@ + +$(SNIPPET_DIR)/c/%.gbin: $(SNIPPET_DIR)/c/%.elf + $(OBJCOPY) -O binary -j ".rodata" -j ".lowcore" -j ".text" -j ".data" -j ".bss" --set-section-flags .bss=alloc,load,contents $< $@ truncate -s '%4096' $@ %.hdr: %.gbin $(HOST_KEY_DOCUMENT) From patchwork Mon Feb 3 08:35:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13957014 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 49C301FCD00 for ; Mon, 3 Feb 2025 08:36:44 +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=1738571806; cv=none; b=Xg7Jouhl0I0vjtHEtRSpB/XfiqgkzuAIo0UmPwCMgQaJlx+G9EPinATY4lG319zVOckDWRiUWJp+8HkcPGUgfRUt5CZBBsmfGQXHckz4ro1k8t/NyklnOBw+wqTlOe8/+GAZBcrYF3NltDA3+kZfNgTaphgmuoHkdnDhtVRvOzs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738571806; c=relaxed/simple; bh=M2SF6ovTZV654s61gYtGNNRknRSLebGHJVLd/GTgYOM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tmIIX1e4IRdr2ITvKj5c0NVKiiInONKlVBd89HpeaXGXTr5aodpCl0bbE9tw1S4U5TRoSBmgFrmuKN7KrrW2AfOXFPWDuD4eyt9WAURqo7oD8Mz2U0xcaQnNfLjUGFufRuuT2rt9z5oIqvAu6frsAhlMKhm1LXP5JKqIbiFMV0I= 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=FEWe+CUh; 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="FEWe+CUh" 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 5135OCo0013752; Mon, 3 Feb 2025 08:36:35 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=/a+3oPjaYZa+uvs5q 0AZpd1+n08noVzWAo7KIiewfdg=; b=FEWe+CUheZs1BARjacg17+wGBMB7OFvla ejY1FVtmnmWqunyTaDNcPtCgOxjsX+YXK50D5zcYbgia1JOiFiJJd0R0nuKgrRr/ Cm3RT+VdjZg5kgmkZjGygiMBK/zvNzWhLv0CYPjsevsT8Hikk1k+b5/gvVV0YrBA e4H3DAaMHR9W2Uyo5EdwA3IecA/qABW58sGSXLpKyA+uS3ln2wEIBfyeSUst9IjU Ddkf3U041fIbjBWd5GrLxoAcdI44+KtBU46T1Ip/6dMQzaec3M0ZtxvFuvBI5OXo Mm9XdvfZUfAOVQR+aFhoMqdHX+6rNVOI8Cubq+HYthKLZT4HUERxg== 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 44jqm78swa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2025 08:36:35 +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 5134v5CT005258; Mon, 3 Feb 2025 08:36:34 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 44j05jn6ba-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2025 08:36:34 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5138aUF319726650 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 3 Feb 2025 08:36:30 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B775520040; Mon, 3 Feb 2025 08:36:30 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4616820043; Mon, 3 Feb 2025 08:36:30 +0000 (GMT) Received: from t14-nrb.lan (unknown [9.171.84.16]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 3 Feb 2025 08:36:30 +0000 (GMT) From: Nico Boehr To: thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, imbrenda@linux.ibm.com, Christoph Schlameuss Subject: [kvm-unit-tests GIT PULL 12/18] s390x/Makefile: Split snippet makefile rules into new file Date: Mon, 3 Feb 2025 09:35:20 +0100 Message-ID: <20250203083606.22864-13-nrb@linux.ibm.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250203083606.22864-1-nrb@linux.ibm.com> References: <20250203083606.22864-1-nrb@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: qQTyOlHzfn9Fu3zOi8Pnky0mOnF5AbMP X-Proofpoint-ORIG-GUID: qQTyOlHzfn9Fu3zOi8Pnky0mOnF5AbMP X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-02-03_03,2025-01-31_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 clxscore=1015 lowpriorityscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 suspectscore=0 priorityscore=1501 phishscore=0 impostorscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2501170000 definitions=main-2502030068 From: Janosch Frank It's time to move the snippet related Makefile parts into a new file to make s390x/Makefile less busy. Signed-off-by: Janosch Frank Reviewed-by: Claudio Imbrenda Reviewed-by: Christoph Schlameuss Link: https://lore.kernel.org/r/20240806084409.169039-2-frankja@linux.ibm.com [ nrb: fix out-of-tree build ] Signed-off-by: Nico Boehr --- s390x/Makefile | 39 ++++----------------------------------- s390x/snippets/Makefile | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 35 deletions(-) create mode 100644 s390x/snippets/Makefile diff --git a/s390x/Makefile b/s390x/Makefile index b3b2ae8c..e41a6433 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -123,10 +123,12 @@ asmlib = $(TEST_DIR)/cstart64.o $(TEST_DIR)/cpu.o FLATLIBS = $(libcflat) +# Snippets SNIPPET_DIR = $(TEST_DIR)/snippets SNIPPET_SRC_DIR = $(SRCDIR)/s390x/snippets snippet_asmlib = $(SNIPPET_DIR)/c/cstart.o snippet_lib = $(snippet_asmlib) lib/auxinfo.o +include $(SNIPPET_SRC_DIR)/Makefile # perquisites (=guests) for the snippet hosts. # $(TEST_DIR)/.elf: snippets = $(SNIPPET_DIR)//.gbin @@ -152,39 +154,6 @@ else snippet-hdr-obj = endif -# the asm/c snippets %.o have additional generated files as dependencies -$(SNIPPET_DIR)/asm/%.o: $(SNIPPET_SRC_DIR)/asm/%.S $(asm-offsets) - $(CC) $(CFLAGS) -c -nostdlib -o $@ $< - -$(SNIPPET_DIR)/c/%.o: SNIPPET_INCLUDE := $(SNIPPET_SRC_DIR)/lib -$(SNIPPET_DIR)/c/%.o: $(SNIPPET_DIR)/c/%.c $(asm-offsets) - $(CC) $(CFLAGS) -c -nostdlib -o $@ $< - -$(SNIPPET_DIR)/asm/%.elf: $(SNIPPET_DIR)/asm/%.o $(SNIPPET_DIR)/asm/flat.lds - $(CC) $(LDFLAGS) -o $@ -T $(SNIPPET_DIR)/asm/flat.lds $< - -$(SNIPPET_DIR)/asm/%.gbin: $(SNIPPET_DIR)/asm/%.elf - $(OBJCOPY) -O binary -j ".rodata" -j ".lowcore" -j ".text" -j ".data" -j ".bss" --set-section-flags .bss=alloc,load,contents $< $@ - truncate -s '%4096' $@ - -$(SNIPPET_DIR)/c/%.elf: $(SNIPPET_DIR)/c/%.o $(snippet_lib) $(FLATLIBS) $(SNIPPET_DIR)/c/flat.lds - $(CC) $(LDFLAGS) -o $@ -T $(SNIPPET_DIR)/c/flat.lds $< $(snippet_lib) $(FLATLIBS) - -$(SNIPPET_DIR)/c/%.gbin: $(SNIPPET_DIR)/c/%.elf - $(OBJCOPY) -O binary -j ".rodata" -j ".lowcore" -j ".text" -j ".data" -j ".bss" --set-section-flags .bss=alloc,load,contents $< $@ - truncate -s '%4096' $@ - -%.hdr: %.gbin $(HOST_KEY_DOCUMENT) - $(GEN_SE_HEADER) -k $(HOST_KEY_DOCUMENT) -c $<,0x0,0x00000000000000420000000000000000 --psw-addr 0x4000 -o $@ - -.SECONDARY: -%.gobj: %.gbin - $(OBJCOPY) -I binary -O elf64-s390 -B "s390:64-bit" $< $@ - -.SECONDARY: -%.hdr.obj: %.hdr - $(OBJCOPY) -I binary -O elf64-s390 -B "s390:64-bit" $< $@ - lds-autodepend-flags = -MMD -MF $(dir $*).$(notdir $*).d -MT $@ %.lds: %.lds.S $(asm-offsets) $(CPP) $(lds-autodepend-flags) $(CPPFLAGS) -P -C -o $@ $< @@ -238,8 +207,8 @@ $(snippet_asmlib): $$(patsubst %.o,%.S,$$@) $(asm-offsets) $(CC) $(CFLAGS) -c -nostdlib -o $@ $< -arch_clean: asm_offsets_clean - $(RM) $(TEST_DIR)/*.{o,elf,bin,lds} $(SNIPPET_DIR)/*/*.{o,elf,*bin,*obj,hdr,lds} $(SNIPPET_DIR)/asm/.*.d $(TEST_DIR)/.*.d lib/s390x/.*.d $(comm-key) +arch_clean: asm_offsets_clean snippet_clean + $(RM) $(TEST_DIR)/*.{o,elf,bin,lds} $(TEST_DIR)/.*.d lib/s390x/.*.d $(comm-key) generated-files = $(asm-offsets) $(tests:.elf=.o) $(asmlib) $(cflatobjs): $(generated-files) diff --git a/s390x/snippets/Makefile b/s390x/snippets/Makefile new file mode 100644 index 00000000..ccadd733 --- /dev/null +++ b/s390x/snippets/Makefile @@ -0,0 +1,35 @@ +# the asm/c snippets %.o have additional generated files as dependencies +$(SNIPPET_DIR)/asm/%.o: $(SNIPPET_SRC_DIR)/asm/%.S $(asm-offsets) + $(CC) $(CFLAGS) -c -nostdlib -o $@ $< + +$(SNIPPET_DIR)/c/%.o: SNIPPET_INCLUDE := $(SNIPPET_SRC_DIR)/lib +$(SNIPPET_DIR)/c/%.o: $(SNIPPET_SRC_DIR)/c/%.c $(asm-offsets) + $(CC) $(CFLAGS) -c -nostdlib -o $@ $< + +$(SNIPPET_DIR)/asm/%.elf: $(SNIPPET_DIR)/asm/%.o $(SNIPPET_DIR)/asm/flat.lds + $(CC) $(LDFLAGS) -o $@ -T $(SNIPPET_SRC_DIR)/asm/flat.lds $< + +$(SNIPPET_DIR)/asm/%.gbin: $(SNIPPET_DIR)/asm/%.elf + $(OBJCOPY) -O binary -j ".rodata" -j ".lowcore" -j ".text" -j ".data" -j ".bss" --set-section-flags .bss=alloc,load,contents $< $@ + truncate -s '%4096' $@ + +$(SNIPPET_DIR)/c/%.elf: $(SNIPPET_DIR)/c/%.o $(snippet_lib) $(FLATLIBS) $(SNIPPET_DIR)/c/flat.lds + $(CC) $(LDFLAGS) -o $@ -T $(SNIPPET_DIR)/c/flat.lds $< $(snippet_lib) $(FLATLIBS) + +$(SNIPPET_DIR)/c/%.gbin: $(SNIPPET_DIR)/c/%.elf + $(OBJCOPY) -O binary -j ".rodata" -j ".lowcore" -j ".text" -j ".data" -j ".bss" --set-section-flags .bss=alloc,load,contents $< $@ + truncate -s '%4096' $@ + +%.hdr: %.gbin $(HOST_KEY_DOCUMENT) + $(GEN_SE_HEADER) -k $(HOST_KEY_DOCUMENT) -c $<,0x0,0x00000000000000420000000000000000 --psw-addr 0x4000 -o $@ + +.SECONDARY: +%.gobj: %.gbin + $(OBJCOPY) -I binary -O elf64-s390 -B "s390:64-bit" $< $@ + +.SECONDARY: +%.hdr.obj: %.hdr + $(OBJCOPY) -I binary -O elf64-s390 -B "s390:64-bit" $< $@ + +snippet_clean: + $(RM) $(SNIPPET_DIR)/*/*.{o,elf,*bin,*obj,hdr,lds} $(SNIPPET_DIR)/asm/.*.d From patchwork Mon Feb 3 08:35:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13957022 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 C8465207A34 for ; Mon, 3 Feb 2025 08:36:50 +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=1738571812; cv=none; b=OmQz2GZXIO/d9lEuUnCu6r2eRPtqjKwDryAHNTiH3WDeNHVbmMu8Hsf8CAehEvqrM4edQExtha4qhA3cyF4naYEpGgX2HULk10LsRZy3Cwaj7rIOTWmIywweT+NkRAwVJyJpfRNTwZdZU5h/XQd5AcI8sQS7mV5N+R4PxrH097c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738571812; c=relaxed/simple; bh=QgIgDmHBWQLIlLmPXvPPpAH6TyX/HsFAOYoG09vxduc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uqN/TPvZ4sDRWrbsCarUnzC66lRzrzSiD52dG3DCTYxMu6oJZlmCKTujHAHt380CggujDsDDdK2pjc/j/u+yj6ue2LB/BcFHl8wSGrhZncU+pTed1OwuFngXzPwc+O8AeTa2LJY2fPJj5Ne5zXxOMpzis5dyics66XVc9bnT4QY= 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=RGJWXad2; 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="RGJWXad2" 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 512Lkikh027628; Mon, 3 Feb 2025 08:36:36 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=rK7nLPSkYzBi6IbwR YJCpEg+Y2mdefaJ0CHctJF3igg=; b=RGJWXad2LMB0pdklBmUeA3q7T6ff5Mkn+ zbJfCHtxx42o/ZtHcgKFDSxsQ/UfxzbsDECIxz7Mq/323lMykqVeqOwcZY7CHl5Y QahzGtK9+xLUxoD/iDDE/jrUcL4/oNp4CBXS4CvnOZSjuQ7FsDWQolQG5Bwbp1qu CcLbD5ShGFpRpGcSLFtwtYZHQZaPg1I7jMZsI96RUttGB94iKmiLYoyIkYYONvyS Cl3DeYexmmP9v5U4QtZMpxm6/kQXHVes8hZQR8gBfOUGDdBVFvPt52XzWqklMEOp hBDaqWbCGfYSnxy+4HqeWR8IK+cyqP1AcyoZAxiq/cV+mM0Azo6jw== 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 44jayyba24-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2025 08:36:36 +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 5134qERh021483; Mon, 3 Feb 2025 08:36:35 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 44j0n153hn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2025 08:36:34 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5138aV0447382874 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 3 Feb 2025 08:36:31 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4572520040; Mon, 3 Feb 2025 08:36:31 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CD7C520043; Mon, 3 Feb 2025 08:36:30 +0000 (GMT) Received: from t14-nrb.lan (unknown [9.171.84.16]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 3 Feb 2025 08:36:30 +0000 (GMT) From: Nico Boehr To: thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, imbrenda@linux.ibm.com, Christoph Schlameuss Subject: [kvm-unit-tests GIT PULL 13/18] s390x/Makefile: Add more comments Date: Mon, 3 Feb 2025 09:35:21 +0100 Message-ID: <20250203083606.22864-14-nrb@linux.ibm.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250203083606.22864-1-nrb@linux.ibm.com> References: <20250203083606.22864-1-nrb@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: 81eXtxhi3KNkLeOwt_nLhjOWECsOX_t2 X-Proofpoint-ORIG-GUID: 81eXtxhi3KNkLeOwt_nLhjOWECsOX_t2 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-02-03_03,2025-01-31_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 lowpriorityscore=0 mlxlogscore=999 adultscore=0 priorityscore=1501 phishscore=0 impostorscore=0 malwarescore=0 mlxscore=0 bulkscore=0 suspectscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2501170000 definitions=main-2502030068 From: Janosch Frank More comments in Makefiles can only make them more approachable. Signed-off-by: Janosch Frank Reviewed-by: Christoph Schlameuss Reviewed-by: Claudio Imbrenda Link: https://lore.kernel.org/r/20240806084409.169039-3-frankja@linux.ibm.com Signed-off-by: Nico Boehr --- s390x/Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/s390x/Makefile b/s390x/Makefile index e41a6433..63e96d86 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -51,12 +51,15 @@ pv-tests += $(TEST_DIR)/pv-diags.elf pv-tests += $(TEST_DIR)/pv-icptcode.elf pv-tests += $(TEST_DIR)/pv-ipl.elf +# Add PV host tests if we're able to generate them +# The host key document and a tool to generate SE headers are the prerequisite ifneq ($(HOST_KEY_DOCUMENT),) ifneq ($(GEN_SE_HEADER),) tests += $(pv-tests) endif endif +# Add binary flat images for use in non-KVM hypervisors tests_binary = $(patsubst %.elf,%.bin,$(tests)) ifneq ($(HOST_KEY_DOCUMENT),) tests_pv_binary = $(patsubst %.bin,%.pv.bin,$(tests_binary)) @@ -146,6 +149,7 @@ $(TEST_DIR)/pv-icptcode.elf: pv-snippets += $(SNIPPET_DIR)/asm/loop.gbin $(TEST_DIR)/pv-icptcode.elf: pv-snippets += $(SNIPPET_DIR)/asm/pv-icpt-vir-timing.gbin $(TEST_DIR)/pv-ipl.elf: pv-snippets += $(SNIPPET_DIR)/asm/pv-diag-308.gbin +# Add PV tests and snippets if GEN_SE_HEADER is set ifneq ($(GEN_SE_HEADER),) snippets += $(pv-snippets) tests += $(pv-tests) @@ -154,6 +158,7 @@ else snippet-hdr-obj = endif +# Generate loader script lds-autodepend-flags = -MMD -MF $(dir $*).$(notdir $*).d -MT $@ %.lds: %.lds.S $(asm-offsets) $(CPP) $(lds-autodepend-flags) $(CPPFLAGS) -P -C -o $@ $< From patchwork Mon Feb 3 08:35:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13957015 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 3BDB61FBC86 for ; Mon, 3 Feb 2025 08:36:44 +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=1738571806; cv=none; b=CGW+8dm8aAOKqyK++oAE/MLYFpyHjdBUn/IzUpcjSKjlKen4Ve+nP1+2+AG1mCiafdTAGm3EBa0mOCfP9Ge5y7El9iICHn1qJ3o4+eH0eAGCCIaNQxmgKfiC0HcqbYhkc0cYzyrgSHBz1lpRMmcmrzs1MQGYmp/F0rQxpgX4yX8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738571806; c=relaxed/simple; bh=AaPBhkgaZX7ILQj/JrLmZqmr5IDtasGLRTnKRk1JJb8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o4slL4tg9bmfepiccg5r5KK5RIS7ns4ditn5vZ1wi2uwd7DfD/pIPyMg1935YBHZcBY324BJJxWvvGNiP5p4MPfPxTo2kkQ8rhh7WXmSJrO50rLaKk+IS1yV+D2PQJyg6ItTF2W6OQAkwQibz+0UMSEYZb5n4t3mmL73/bVQqVw= 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=WSoxhcid; 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="WSoxhcid" 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 5137MOUS014586; Mon, 3 Feb 2025 08:36:36 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=Pr7HN/ZedBZbzihlH Fz4VOiMJjWk5u6rYTRp8SByVk0=; b=WSoxhcid4tJ6hOwi5bVixx5jFvZG1cdN1 JI06qMOq7CO97l0UyYAJI7FcNf1u501956OIJZKeFRBzZd76CrJohD1LnFgSkV05 jtCI0I57HpT4M1MfCEefTw6zDJztDNOXeTtlSL+QD7uLIsz2JWR/dT1AtTPuEizt EEndgBUiPXVqeC1GXNpz5PcQRYnHS2NiGGv9MVL+ZG4NO0u2xHBqNLhVIoG6xMOR jo1k4X5uyhSI1FLZfYvpZAGXI5QPP/Z45Z/jVt8lg7rj4YP5HOnvo/7TxVs8hcYJ 7B6EcynEadizL6+PTGtzPUkIChwCQK+H4EaGj/9x914lpA5erln1w== 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 44jbht2xck-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2025 08:36:36 +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 5137feRJ024635; Mon, 3 Feb 2025 08:36:35 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 44hxxmwe5h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2025 08:36:35 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5138aVMI47382876 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 3 Feb 2025 08:36:32 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CABA220040; Mon, 3 Feb 2025 08:36:31 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5CFAA20043; Mon, 3 Feb 2025 08:36:31 +0000 (GMT) Received: from t14-nrb.lan (unknown [9.171.84.16]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 3 Feb 2025 08:36:31 +0000 (GMT) From: Nico Boehr To: thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, imbrenda@linux.ibm.com, Christoph Schlameuss Subject: [kvm-unit-tests GIT PULL 14/18] s390x: Move SIE assembly into new file Date: Mon, 3 Feb 2025 09:35:22 +0100 Message-ID: <20250203083606.22864-15-nrb@linux.ibm.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250203083606.22864-1-nrb@linux.ibm.com> References: <20250203083606.22864-1-nrb@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: UVMXOXQMdOHvMPIJJKqi_QYSuB9Y4QkH X-Proofpoint-GUID: UVMXOXQMdOHvMPIJJKqi_QYSuB9Y4QkH X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-02-03_03,2025-01-31_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 adultscore=0 impostorscore=0 phishscore=0 spamscore=0 mlxscore=0 mlxlogscore=915 bulkscore=0 suspectscore=0 lowpriorityscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2501170000 definitions=main-2502030068 From: Janosch Frank In contrast to the other functions in cpu.S it's quite lengthy so let's split it off. Signed-off-by: Janosch Frank Reviewed-by: Claudio Imbrenda Reviewed-by: Christoph Schlameuss Link: https://lore.kernel.org/r/20240806084409.169039-4-frankja@linux.ibm.com Signed-off-by: Nico Boehr --- s390x/Makefile | 2 +- s390x/cpu-sie.S | 74 +++++++++++++++++++++++++++++++++++++++++++++++++ s390x/cpu.S | 64 ------------------------------------------ 3 files changed, 75 insertions(+), 65 deletions(-) create mode 100644 s390x/cpu-sie.S diff --git a/s390x/Makefile b/s390x/Makefile index 63e96d86..e5572cb6 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -122,7 +122,7 @@ cflatobjs += lib/s390x/fault.o OBJDIRS += lib/s390x -asmlib = $(TEST_DIR)/cstart64.o $(TEST_DIR)/cpu.o +asmlib = $(TEST_DIR)/cstart64.o $(TEST_DIR)/cpu.o $(TEST_DIR)/cpu-sie.o FLATLIBS = $(libcflat) diff --git a/s390x/cpu-sie.S b/s390x/cpu-sie.S new file mode 100644 index 00000000..9370b5c0 --- /dev/null +++ b/s390x/cpu-sie.S @@ -0,0 +1,74 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * s390x SIE assembly library + * + * Copyright (c) 2019 IBM Corp. + * + * Authors: + * Janosch Frank + */ +#include + +/* + * sie64a calling convention: + * %r2 pointer to sie control block + * %r3 guest register save area + */ +.globl sie64a +sie64a: + # Save host grs, fprs, fpc + stmg %r0,%r14,SIE_SAVEAREA_HOST_GRS(%r3) # save kernel registers + .irp i, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 + std \i, \i * 8 + SIE_SAVEAREA_HOST_FPRS(%r3) + .endr + stfpc SIE_SAVEAREA_HOST_FPC(%r3) + + stctg %c1, %c1, SIE_SAVEAREA_HOST_ASCE(%r3) + lctlg %c1, %c1, SIE_SAVEAREA_GUEST_ASCE(%r3) + + # Store scb and save_area pointer into stack frame + stg %r2,__SF_SIE_CONTROL(%r15) # save control block pointer + stg %r3,__SF_SIE_SAVEAREA(%r15) # save guest register save area +.globl sie_entry_gregs +sie_entry_gregs: + # Load guest's gprs, fprs and fpc + .irp i, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 + ld \i, \i * 8 + SIE_SAVEAREA_GUEST_FPRS(%r3) + .endr + lfpc SIE_SAVEAREA_GUEST_FPC(%r3) + lmg %r0,%r13,SIE_SAVEAREA_GUEST_GRS(%r3) + + # Move scb ptr into r14 for the sie instruction + lg %r14,__SF_SIE_CONTROL(%r15) + +.globl sie_entry +sie_entry: + sie 0(%r14) + nopr 7 + nopr 7 + nopr 7 + +.globl sie_exit +sie_exit: + # Load guest register save area + lg %r14,__SF_SIE_SAVEAREA(%r15) + + # Restore the host asce + lctlg %c1, %c1, SIE_SAVEAREA_HOST_ASCE(%r14) + + # Store guest's gprs, fprs and fpc + stmg %r0,%r13,SIE_SAVEAREA_GUEST_GRS(%r14) # save guest gprs 0-13 + .irp i, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 + std \i, \i * 8 + SIE_SAVEAREA_GUEST_FPRS(%r14) + .endr + stfpc SIE_SAVEAREA_GUEST_FPC(%r14) + + # Restore host's gprs, fprs and fpc + .irp i, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 + ld \i, \i * 8 + SIE_SAVEAREA_HOST_FPRS(%r14) + .endr + lfpc SIE_SAVEAREA_HOST_FPC(%r14) + lmg %r0,%r14,SIE_SAVEAREA_HOST_GRS(%r14) # restore kernel registers +.globl sie_exit_gregs +sie_exit_gregs: + br %r14 diff --git a/s390x/cpu.S b/s390x/cpu.S index 9155b044..2ff4b8e1 100644 --- a/s390x/cpu.S +++ b/s390x/cpu.S @@ -62,70 +62,6 @@ smp_cpu_setup_state: /* If the function returns, just loop here */ 0: j 0 -/* - * sie64a calling convention: - * %r2 pointer to sie control block - * %r3 guest register save area - */ -.globl sie64a -sie64a: - # Save host grs, fprs, fpc - stmg %r0,%r14,SIE_SAVEAREA_HOST_GRS(%r3) # save kernel registers - .irp i, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 - std \i, \i * 8 + SIE_SAVEAREA_HOST_FPRS(%r3) - .endr - stfpc SIE_SAVEAREA_HOST_FPC(%r3) - - stctg %c1, %c1, SIE_SAVEAREA_HOST_ASCE(%r3) - lctlg %c1, %c1, SIE_SAVEAREA_GUEST_ASCE(%r3) - - # Store scb and save_area pointer into stack frame - stg %r2,__SF_SIE_CONTROL(%r15) # save control block pointer - stg %r3,__SF_SIE_SAVEAREA(%r15) # save guest register save area -.globl sie_entry_gregs -sie_entry_gregs: - # Load guest's gprs, fprs and fpc - .irp i, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 - ld \i, \i * 8 + SIE_SAVEAREA_GUEST_FPRS(%r3) - .endr - lfpc SIE_SAVEAREA_GUEST_FPC(%r3) - lmg %r0,%r13,SIE_SAVEAREA_GUEST_GRS(%r3) - - # Move scb ptr into r14 for the sie instruction - lg %r14,__SF_SIE_CONTROL(%r15) - -.globl sie_entry -sie_entry: - sie 0(%r14) - nopr 7 - nopr 7 - nopr 7 - -.globl sie_exit -sie_exit: - # Load guest register save area - lg %r14,__SF_SIE_SAVEAREA(%r15) - - # Restore the host asce - lctlg %c1, %c1, SIE_SAVEAREA_HOST_ASCE(%r14) - - # Store guest's gprs, fprs and fpc - stmg %r0,%r13,SIE_SAVEAREA_GUEST_GRS(%r14) # save guest gprs 0-13 - .irp i, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 - std \i, \i * 8 + SIE_SAVEAREA_GUEST_FPRS(%r14) - .endr - stfpc SIE_SAVEAREA_GUEST_FPC(%r14) - - # Restore host's gprs, fprs and fpc - .irp i, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 - ld \i, \i * 8 + SIE_SAVEAREA_HOST_FPRS(%r14) - .endr - lfpc SIE_SAVEAREA_HOST_FPC(%r14) - lmg %r0,%r14,SIE_SAVEAREA_HOST_GRS(%r14) # restore kernel registers -.globl sie_exit_gregs -sie_exit_gregs: - br %r14 - .align 8 reset_psw: .quad 0x0008000180000000 From patchwork Mon Feb 3 08:35:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13957019 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 2D6D02066DC for ; Mon, 3 Feb 2025 08:36:47 +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=1738571810; cv=none; b=o61fugAVTrz0ylgmRtSCpVPMrFNj+5uTRRCICatrys7LuojF9AXnwgsWaQiVEPlQL6YDGXgAr7SroXKQCAAwpDpgZkQpGRHOpZyJoOtR4keleIbBYNa2tGr9j6oyLRaG1ljeC6ruv4xOEDl83H2hh65+SnPVEDpqPhOsumEZ6bo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738571810; c=relaxed/simple; bh=fKumqxNAa62hWFXFFkG5i6fQMIrHgXBnMTlNdwgwo84=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YhWBDcJsV7llz966ueNph1WpIzhVQ7uXa7qsV8IM1cd4Fx4nNoyVYooRAJENTdE8WSou22tW48tM6al0ESeETC0MgaOE4JUKIvLd3aFTFlNAMlCPT0G4zG8qe7ENQIbnLePLOspnKgaq31R6XwMAB5SmCehLekw3VGbR3XYUEzw= 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=Pnhzu7yM; 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="Pnhzu7yM" 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 5138HbaO013869; Mon, 3 Feb 2025 08:36:37 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=HB5LBycd+LciFtaDJ vDUYLFDWAezLuL3wzSwWoYU8CE=; b=Pnhzu7yMA3nLitePJF/3r820UiwO0GY10 IoIvHe5OCmMYUfXN7M7QLW0OXBIAd5s3dmVUs2Qo82OBXzbVhhO6C68FFpbzzXOF KRG5jXMryIyeoUO1S3o2j+51y1i/ZBaBKs7wevOhe8d8zQZ25+3hS8LLUEF9WOm6 +UvlfacpGUIzC8ufWCPxqofpNLLEtvzYz2C17JZlhIcN49kWA99sNtcTBLNwrQh8 S5kt77xUjp1SyBd78jwWIy3XE6LKIU+ays/9ta9T2oHCdYePVnSF4a7osXdXSLli 7aUNbW/9A8k57RyV7j18A9adDmf4BElSICSsLqqhVeL3yTE4CFL3g== 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 44jbht2xct-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2025 08:36:37 +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 5137laen024533; Mon, 3 Feb 2025 08:36:36 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 44hxxmwe5t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2025 08:36:36 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5138aWeb20185538 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 3 Feb 2025 08:36:32 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5C61A20040; Mon, 3 Feb 2025 08:36:32 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E23EB20043; Mon, 3 Feb 2025 08:36:31 +0000 (GMT) Received: from t14-nrb.lan (unknown [9.171.84.16]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 3 Feb 2025 08:36:31 +0000 (GMT) From: Nico Boehr To: thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, imbrenda@linux.ibm.com, Christoph Schlameuss Subject: [kvm-unit-tests GIT PULL 15/18] lib: s390x: Split SIE fw structs from lib structs Date: Mon, 3 Feb 2025 09:35:23 +0100 Message-ID: <20250203083606.22864-16-nrb@linux.ibm.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250203083606.22864-1-nrb@linux.ibm.com> References: <20250203083606.22864-1-nrb@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: lVtbiVkfTApMH-lGnb-U8JseY04B-TEC X-Proofpoint-GUID: lVtbiVkfTApMH-lGnb-U8JseY04B-TEC X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-02-03_03,2025-01-31_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 adultscore=0 impostorscore=0 phishscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 suspectscore=0 lowpriorityscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2501170000 definitions=main-2502030068 From: Janosch Frank The SIE control block is huge and takes up too much space. Let's split the hardware definitions from sie.h into its own header, so that sie.h will only contain library functions and structs Signed-off-by: Janosch Frank Reviewed-by: Christoph Schlameuss Reviewed-by: Claudio Imbrenda Link: https://lore.kernel.org/r/20240806084409.169039-5-frankja@linux.ibm.com Signed-off-by: Nico Boehr --- lib/s390x/asm/sie-arch.h | 238 +++++++++++++++++++++++++++++++++++++++ lib/s390x/sie.h | 231 +------------------------------------ 2 files changed, 239 insertions(+), 230 deletions(-) create mode 100644 lib/s390x/asm/sie-arch.h diff --git a/lib/s390x/asm/sie-arch.h b/lib/s390x/asm/sie-arch.h new file mode 100644 index 00000000..4911c988 --- /dev/null +++ b/lib/s390x/asm/sie-arch.h @@ -0,0 +1,238 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#ifndef _S390X_SIE_ARCH_H_ +#define _S390X_SIE_ARCH_H_ + +#include +#include + +#define CPUSTAT_STOPPED 0x80000000 +#define CPUSTAT_WAIT 0x10000000 +#define CPUSTAT_ECALL_PEND 0x08000000 +#define CPUSTAT_STOP_INT 0x04000000 +#define CPUSTAT_IO_INT 0x02000000 +#define CPUSTAT_EXT_INT 0x01000000 +#define CPUSTAT_RUNNING 0x00800000 +#define CPUSTAT_RETAINED 0x00400000 +#define CPUSTAT_TIMING_SUB 0x00020000 +#define CPUSTAT_SIE_SUB 0x00010000 +#define CPUSTAT_RRF 0x00008000 +#define CPUSTAT_SLSV 0x00004000 +#define CPUSTAT_SLSR 0x00002000 +#define CPUSTAT_ZARCH 0x00000800 +#define CPUSTAT_MCDS 0x00000100 +#define CPUSTAT_KSS 0x00000200 +#define CPUSTAT_SM 0x00000080 +#define CPUSTAT_IBS 0x00000040 +#define CPUSTAT_GED2 0x00000010 +#define CPUSTAT_G 0x00000008 +#define CPUSTAT_GED 0x00000004 +#define CPUSTAT_J 0x00000002 +#define CPUSTAT_P 0x00000001 + +struct kvm_s390_sie_block { + uint32_t cpuflags; /* 0x0000 */ + uint32_t : 1; /* 0x0004 */ + uint32_t prefix : 18; + uint32_t : 1; + uint32_t ibc : 12; + uint8_t reserved08[4]; /* 0x0008 */ +#define PROG_IN_SIE (1<<0) + uint32_t prog0c; /* 0x000c */ +union { + uint8_t reserved10[16]; /* 0x0010 */ + struct { + uint64_t pv_handle_cpu; + uint64_t pv_handle_config; + }; + }; +#define PROG_BLOCK_SIE (1<<0) +#define PROG_REQUEST (1<<1) + uint32_t prog20; /* 0x0020 */ + uint8_t reserved24[4]; /* 0x0024 */ + uint64_t cputm; /* 0x0028 */ + uint64_t ckc; /* 0x0030 */ + uint64_t epoch; /* 0x0038 */ + uint32_t svcc; /* 0x0040 */ +#define LCTL_CR0 0x8000 +#define LCTL_CR6 0x0200 +#define LCTL_CR9 0x0040 +#define LCTL_CR10 0x0020 +#define LCTL_CR11 0x0010 +#define LCTL_CR14 0x0002 + uint16_t lctl; /* 0x0044 */ + int16_t icpua; /* 0x0046 */ +#define ICTL_OPEREXC 0x80000000 +#define ICTL_PINT 0x20000000 +#define ICTL_LPSW 0x00400000 +#define ICTL_STCTL 0x00040000 +#define ICTL_ISKE 0x00004000 +#define ICTL_SSKE 0x00002000 +#define ICTL_RRBE 0x00001000 +#define ICTL_TPROT 0x00000200 + uint32_t ictl; /* 0x0048 */ +#define ECA_CEI 0x80000000 +#define ECA_IB 0x40000000 +#define ECA_SIGPI 0x10000000 +#define ECA_MVPGI 0x01000000 +#define ECA_AIV 0x00200000 +#define ECA_VX 0x00020000 +#define ECA_PROTEXCI 0x00002000 +#define ECA_APIE 0x00000008 +#define ECA_SII 0x00000001 + uint32_t eca; /* 0x004c */ +#define ICPT_INST 0x04 +#define ICPT_PROGI 0x08 +#define ICPT_INSTPROGI 0x0C +#define ICPT_EXTREQ 0x10 +#define ICPT_EXTINT 0x14 +#define ICPT_IOREQ 0x18 +#define ICPT_WAIT 0x1c +#define ICPT_VALIDITY 0x20 +#define ICPT_STOP 0x28 +#define ICPT_OPEREXC 0x2C +#define ICPT_PARTEXEC 0x38 +#define ICPT_IOINST 0x40 +#define ICPT_KSS 0x5c +#define ICPT_INT_ENABLE 0x64 +#define ICPT_PV_INSTR 0x68 +#define ICPT_PV_NOTIFY 0x6c +#define ICPT_PV_PREF 0x70 + uint8_t icptcode; /* 0x0050 */ + uint8_t icptstatus; /* 0x0051 */ + uint16_t ihcpu; /* 0x0052 */ + uint8_t reserved54; /* 0x0054 */ +#define IICTL_CODE_NONE 0x00 +#define IICTL_CODE_MCHK 0x01 +#define IICTL_CODE_EXT 0x02 +#define IICTL_CODE_IO 0x03 +#define IICTL_CODE_RESTART 0x04 +#define IICTL_CODE_SPECIFICATION 0x10 +#define IICTL_CODE_OPERAND 0x11 + uint8_t iictl; /* 0x0055 */ + uint16_t ipa; /* 0x0056 */ + uint32_t ipb; /* 0x0058 */ + uint32_t scaoh; /* 0x005c */ +#define FPF_BPBC 0x20 + uint8_t fpf; /* 0x0060 */ +#define ECB_GS 0x40 +#define ECB_TE 0x10 +#define ECB_SPECI 0x08 +#define ECB_SRSI 0x04 +#define ECB_HOSTPROTINT 0x02 + uint8_t ecb; /* 0x0061 */ +#define ECB2_CMMA 0x80 +#define ECB2_IEP 0x20 +#define ECB2_PFMFI 0x08 +#define ECB2_ESCA 0x04 + uint8_t ecb2; /* 0x0062 */ +#define ECB3_DEA 0x08 +#define ECB3_AES 0x04 +#define ECB3_RI 0x01 + uint8_t ecb3; /* 0x0063 */ + uint32_t scaol; /* 0x0064 */ + uint8_t sdf; /* 0x0068 */ + uint8_t epdx; /* 0x0069 */ + uint8_t reserved6a[2]; /* 0x006a */ + uint32_t todpr; /* 0x006c */ +#define GISA_FORMAT1 0x00000001 + uint32_t gd; /* 0x0070 */ + uint8_t reserved74[12]; /* 0x0074 */ + uint64_t mso; /* 0x0080 */ + uint64_t msl; /* 0x0088 */ + struct psw gpsw; /* 0x0090 */ + uint64_t gg14; /* 0x00a0 */ + uint64_t gg15; /* 0x00a8 */ + uint8_t reservedb0[8]; /* 0x00b0 */ +#define HPID_KVM 0x4 +#define HPID_VSIE 0x5 + uint8_t hpid; /* 0x00b8 */ + uint8_t reservedb9[7]; /* 0x00b9 */ + union { + struct { + uint32_t eiparams; /* 0x00c0 */ + uint16_t extcpuaddr; /* 0x00c4 */ + uint16_t eic; /* 0x00c6 */ + }; + uint64_t mcic; /* 0x00c0 */ + } __attribute__ ((__packed__)); + uint32_t reservedc8; /* 0x00c8 */ + uint16_t pgmilc; /* 0x00cc */ + uint16_t iprcc; /* 0x00ce */ + uint32_t dxc; /* 0x00d0 */ + uint16_t mcn; /* 0x00d4 */ + uint8_t perc; /* 0x00d6 */ + uint8_t peratmid; /* 0x00d7 */ + uint64_t peraddr; /* 0x00d8 */ + uint8_t eai; /* 0x00e0 */ + uint8_t peraid; /* 0x00e1 */ + uint8_t oai; /* 0x00e2 */ + uint8_t armid; /* 0x00e3 */ + uint8_t reservede4[4]; /* 0x00e4 */ + uint64_t tecmc; /* 0x00e8 */ + uint8_t reservedf0[12]; /* 0x00f0 */ +#define CRYCB_FORMAT_MASK 0x00000003 +#define CRYCB_FORMAT0 0x00000000 +#define CRYCB_FORMAT1 0x00000001 +#define CRYCB_FORMAT2 0x00000003 + uint32_t crycbd; /* 0x00fc */ + uint64_t gcr[16]; /* 0x0100 */ + union { + uint64_t gbea; /* 0x0180 */ + uint64_t sidad; + }; + uint8_t reserved188[8]; /* 0x0188 */ + uint64_t sdnxo; /* 0x0190 */ + uint8_t reserved198[8]; /* 0x0198 */ + uint32_t fac; /* 0x01a0 */ + uint8_t reserved1a4[20]; /* 0x01a4 */ + uint64_t cbrlo; /* 0x01b8 */ + uint8_t reserved1c0[8]; /* 0x01c0 */ +#define ECD_HOSTREGMGMT 0x20000000 +#define ECD_MEF 0x08000000 +#define ECD_ETOKENF 0x02000000 +#define ECD_ECC 0x00200000 + uint32_t ecd; /* 0x01c8 */ + uint8_t reserved1cc[18]; /* 0x01cc */ + uint64_t pp; /* 0x01de */ + uint8_t reserved1e6[2]; /* 0x01e6 */ + uint64_t itdba; /* 0x01e8 */ + uint64_t riccbd; /* 0x01f0 */ + uint64_t gvrd; /* 0x01f8 */ + uint64_t reserved200[48]; /* 0x0200 */ + uint64_t pv_grregs[16]; /* 0x0380 */ +} __attribute__((packed)); + +union esca_sigp_ctrl { + uint16_t value; + struct { + uint8_t c : 1; + uint8_t reserved: 7; + uint8_t scn; + }; +}; + +struct esca_entry { + union esca_sigp_ctrl sigp_ctrl; + uint16_t reserved1[3]; + uint64_t sda; + uint64_t reserved2[6]; +}; + +union ipte_control { + unsigned long val; + struct { + unsigned long k : 1; + unsigned long kh : 31; + unsigned long kg : 32; + }; +}; + +struct esca_block { + union ipte_control ipte_control; + uint64_t reserved1[7]; + uint64_t mcn[4]; + uint64_t reserved2[20]; + struct esca_entry cpu[256]; +}; + +#endif /* _S390X_SIE_ARCH_H_ */ diff --git a/lib/s390x/sie.h b/lib/s390x/sie.h index 53cd767f..3ec49ed0 100644 --- a/lib/s390x/sie.h +++ b/lib/s390x/sie.h @@ -4,236 +4,7 @@ #include #include - -#define CPUSTAT_STOPPED 0x80000000 -#define CPUSTAT_WAIT 0x10000000 -#define CPUSTAT_ECALL_PEND 0x08000000 -#define CPUSTAT_STOP_INT 0x04000000 -#define CPUSTAT_IO_INT 0x02000000 -#define CPUSTAT_EXT_INT 0x01000000 -#define CPUSTAT_RUNNING 0x00800000 -#define CPUSTAT_RETAINED 0x00400000 -#define CPUSTAT_TIMING_SUB 0x00020000 -#define CPUSTAT_SIE_SUB 0x00010000 -#define CPUSTAT_RRF 0x00008000 -#define CPUSTAT_SLSV 0x00004000 -#define CPUSTAT_SLSR 0x00002000 -#define CPUSTAT_ZARCH 0x00000800 -#define CPUSTAT_MCDS 0x00000100 -#define CPUSTAT_KSS 0x00000200 -#define CPUSTAT_SM 0x00000080 -#define CPUSTAT_IBS 0x00000040 -#define CPUSTAT_GED2 0x00000010 -#define CPUSTAT_G 0x00000008 -#define CPUSTAT_GED 0x00000004 -#define CPUSTAT_J 0x00000002 -#define CPUSTAT_P 0x00000001 - -struct kvm_s390_sie_block { - uint32_t cpuflags; /* 0x0000 */ - uint32_t : 1; /* 0x0004 */ - uint32_t prefix : 18; - uint32_t : 1; - uint32_t ibc : 12; - uint8_t reserved08[4]; /* 0x0008 */ -#define PROG_IN_SIE (1<<0) - uint32_t prog0c; /* 0x000c */ -union { - uint8_t reserved10[16]; /* 0x0010 */ - struct { - uint64_t pv_handle_cpu; - uint64_t pv_handle_config; - }; - }; -#define PROG_BLOCK_SIE (1<<0) -#define PROG_REQUEST (1<<1) - uint32_t prog20; /* 0x0020 */ - uint8_t reserved24[4]; /* 0x0024 */ - uint64_t cputm; /* 0x0028 */ - uint64_t ckc; /* 0x0030 */ - uint64_t epoch; /* 0x0038 */ - uint32_t svcc; /* 0x0040 */ -#define LCTL_CR0 0x8000 -#define LCTL_CR6 0x0200 -#define LCTL_CR9 0x0040 -#define LCTL_CR10 0x0020 -#define LCTL_CR11 0x0010 -#define LCTL_CR14 0x0002 - uint16_t lctl; /* 0x0044 */ - int16_t icpua; /* 0x0046 */ -#define ICTL_OPEREXC 0x80000000 -#define ICTL_PINT 0x20000000 -#define ICTL_LPSW 0x00400000 -#define ICTL_STCTL 0x00040000 -#define ICTL_ISKE 0x00004000 -#define ICTL_SSKE 0x00002000 -#define ICTL_RRBE 0x00001000 -#define ICTL_TPROT 0x00000200 - uint32_t ictl; /* 0x0048 */ -#define ECA_CEI 0x80000000 -#define ECA_IB 0x40000000 -#define ECA_SIGPI 0x10000000 -#define ECA_MVPGI 0x01000000 -#define ECA_AIV 0x00200000 -#define ECA_VX 0x00020000 -#define ECA_PROTEXCI 0x00002000 -#define ECA_APIE 0x00000008 -#define ECA_SII 0x00000001 - uint32_t eca; /* 0x004c */ -#define ICPT_INST 0x04 -#define ICPT_PROGI 0x08 -#define ICPT_INSTPROGI 0x0C -#define ICPT_EXTREQ 0x10 -#define ICPT_EXTINT 0x14 -#define ICPT_IOREQ 0x18 -#define ICPT_WAIT 0x1c -#define ICPT_VALIDITY 0x20 -#define ICPT_STOP 0x28 -#define ICPT_OPEREXC 0x2C -#define ICPT_PARTEXEC 0x38 -#define ICPT_IOINST 0x40 -#define ICPT_KSS 0x5c -#define ICPT_INT_ENABLE 0x64 -#define ICPT_PV_INSTR 0x68 -#define ICPT_PV_NOTIFY 0x6c -#define ICPT_PV_PREF 0x70 - uint8_t icptcode; /* 0x0050 */ - uint8_t icptstatus; /* 0x0051 */ - uint16_t ihcpu; /* 0x0052 */ - uint8_t reserved54; /* 0x0054 */ -#define IICTL_CODE_NONE 0x00 -#define IICTL_CODE_MCHK 0x01 -#define IICTL_CODE_EXT 0x02 -#define IICTL_CODE_IO 0x03 -#define IICTL_CODE_RESTART 0x04 -#define IICTL_CODE_SPECIFICATION 0x10 -#define IICTL_CODE_OPERAND 0x11 - uint8_t iictl; /* 0x0055 */ - uint16_t ipa; /* 0x0056 */ - uint32_t ipb; /* 0x0058 */ - uint32_t scaoh; /* 0x005c */ -#define FPF_BPBC 0x20 - uint8_t fpf; /* 0x0060 */ -#define ECB_GS 0x40 -#define ECB_TE 0x10 -#define ECB_SPECI 0x08 -#define ECB_SRSI 0x04 -#define ECB_HOSTPROTINT 0x02 - uint8_t ecb; /* 0x0061 */ -#define ECB2_CMMA 0x80 -#define ECB2_IEP 0x20 -#define ECB2_PFMFI 0x08 -#define ECB2_ESCA 0x04 - uint8_t ecb2; /* 0x0062 */ -#define ECB3_DEA 0x08 -#define ECB3_AES 0x04 -#define ECB3_RI 0x01 - uint8_t ecb3; /* 0x0063 */ - uint32_t scaol; /* 0x0064 */ - uint8_t sdf; /* 0x0068 */ - uint8_t epdx; /* 0x0069 */ - uint8_t reserved6a[2]; /* 0x006a */ - uint32_t todpr; /* 0x006c */ -#define GISA_FORMAT1 0x00000001 - uint32_t gd; /* 0x0070 */ - uint8_t reserved74[12]; /* 0x0074 */ - uint64_t mso; /* 0x0080 */ - uint64_t msl; /* 0x0088 */ - struct psw gpsw; /* 0x0090 */ - uint64_t gg14; /* 0x00a0 */ - uint64_t gg15; /* 0x00a8 */ - uint8_t reservedb0[8]; /* 0x00b0 */ -#define HPID_KVM 0x4 -#define HPID_VSIE 0x5 - uint8_t hpid; /* 0x00b8 */ - uint8_t reservedb9[7]; /* 0x00b9 */ - union { - struct { - uint32_t eiparams; /* 0x00c0 */ - uint16_t extcpuaddr; /* 0x00c4 */ - uint16_t eic; /* 0x00c6 */ - }; - uint64_t mcic; /* 0x00c0 */ - } __attribute__ ((__packed__)); - uint32_t reservedc8; /* 0x00c8 */ - uint16_t pgmilc; /* 0x00cc */ - uint16_t iprcc; /* 0x00ce */ - uint32_t dxc; /* 0x00d0 */ - uint16_t mcn; /* 0x00d4 */ - uint8_t perc; /* 0x00d6 */ - uint8_t peratmid; /* 0x00d7 */ - uint64_t peraddr; /* 0x00d8 */ - uint8_t eai; /* 0x00e0 */ - uint8_t peraid; /* 0x00e1 */ - uint8_t oai; /* 0x00e2 */ - uint8_t armid; /* 0x00e3 */ - uint8_t reservede4[4]; /* 0x00e4 */ - uint64_t tecmc; /* 0x00e8 */ - uint8_t reservedf0[12]; /* 0x00f0 */ -#define CRYCB_FORMAT_MASK 0x00000003 -#define CRYCB_FORMAT0 0x00000000 -#define CRYCB_FORMAT1 0x00000001 -#define CRYCB_FORMAT2 0x00000003 - uint32_t crycbd; /* 0x00fc */ - uint64_t gcr[16]; /* 0x0100 */ - union { - uint64_t gbea; /* 0x0180 */ - uint64_t sidad; - }; - uint8_t reserved188[8]; /* 0x0188 */ - uint64_t sdnxo; /* 0x0190 */ - uint8_t reserved198[8]; /* 0x0198 */ - uint32_t fac; /* 0x01a0 */ - uint8_t reserved1a4[20]; /* 0x01a4 */ - uint64_t cbrlo; /* 0x01b8 */ - uint8_t reserved1c0[8]; /* 0x01c0 */ -#define ECD_HOSTREGMGMT 0x20000000 -#define ECD_MEF 0x08000000 -#define ECD_ETOKENF 0x02000000 -#define ECD_ECC 0x00200000 - uint32_t ecd; /* 0x01c8 */ - uint8_t reserved1cc[18]; /* 0x01cc */ - uint64_t pp; /* 0x01de */ - uint8_t reserved1e6[2]; /* 0x01e6 */ - uint64_t itdba; /* 0x01e8 */ - uint64_t riccbd; /* 0x01f0 */ - uint64_t gvrd; /* 0x01f8 */ - uint64_t reserved200[48]; /* 0x0200 */ - uint64_t pv_grregs[16]; /* 0x0380 */ -} __attribute__((packed)); - -union esca_sigp_ctrl { - uint16_t value; - struct { - uint8_t c : 1; - uint8_t reserved: 7; - uint8_t scn; - }; -}; - -struct esca_entry { - union esca_sigp_ctrl sigp_ctrl; - uint16_t reserved1[3]; - uint64_t sda; - uint64_t reserved2[6]; -}; - -union ipte_control { - unsigned long val; - struct { - unsigned long k : 1; - unsigned long kh : 31; - unsigned long kg : 32; - }; -}; - -struct esca_block { - union ipte_control ipte_control; - uint64_t reserved1[7]; - uint64_t mcn[4]; - uint64_t reserved2[20]; - struct esca_entry cpu[256]; -}; +#include struct vm_uv { uint64_t vm_handle; From patchwork Mon Feb 3 08:35:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13957012 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 BAADA1FC7D6 for ; Mon, 3 Feb 2025 08:36:44 +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=1738571806; cv=none; b=NW82Thc+AFfyPerBa3oH8ZvFMyNsq2NpmmQ8WLEbKuVUviZmns1rjhQfZ3EANl7r2ByQGITOcqEnZFJH54xlWKP1/Nngv4f1rx3+1bQDkGz3OuWqmvfTjmSFfbalM3sxkerEj0VLccvP9GFHN5f0iA6VHoJpx/Q7559Y/pM2+tI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738571806; c=relaxed/simple; bh=gVT1Jtu9kQIxSNCGfxdKVFekaMA+76rtRYHvfqD86Fc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sCcMb2wSZ0ceANDFOlPjzGvj1Xpl+Mgk48LdK9+BwTN50hPiiDnhf7/LHZtp6ZS5l+vfwER8VCnPYuG8sWilfxN0VNOU8F1zH4zBLjZZoInEFYJPFG2rXz/6FbJ8TfB8AEikr3CgVjHmqp8uFm8zgmKu46wgNlnZY+XgAIZSrng= 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=c5PyKqmg; 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="c5PyKqmg" Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 51319rlx029261; Mon, 3 Feb 2025 08:36:38 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=zP1InfUjIPB2SqFQd V3++4s5WM/mlnE0zERE2wdGJh8=; b=c5PyKqmgUH4Lpi0m8EerIfYeP8V3ad47S bM46dQK60X/nu04gK3XXTEcFRJNmg+dtZBLZb6u1l+Lb2dW/mSdy7Vs+YiwU3eUL 6qtATBLJgGFxDd42xYPhZ5HCT64KCPDEFXSXIX2ys4uqTrlPAf8IqIgNtziRam5p 1QKsyI+aBzpSF0vazIuSSC1o9ctlRcpxpC6SvEm0azWGFvUZM8+J6Qx21HUzPqTu 6B+VYLWIImw6kapAVeyTO5m70RaxTqXyHjYyrG382SUlDAa03EcJIQw8LIcMNqbA bI1LefD/KJ9WL7XMAWMxOmsIlzIXdpPrH7sv93VJg70tfAHuzbh5g== 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 44jkv91n9w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2025 08:36:38 +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 5134cwYj005292; Mon, 3 Feb 2025 08:36:37 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 44j05jn6cf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2025 08:36:37 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5138aWcn20185540 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 3 Feb 2025 08:36:33 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DD08E20040; Mon, 3 Feb 2025 08:36:32 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6F0202004B; Mon, 3 Feb 2025 08:36:32 +0000 (GMT) Received: from t14-nrb.lan (unknown [9.171.84.16]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 3 Feb 2025 08:36:32 +0000 (GMT) From: Nico Boehr To: thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, imbrenda@linux.ibm.com, Marc Hartmayer Subject: [kvm-unit-tests GIT PULL 16/18] s390x: Support newer version of genprotimg Date: Mon, 3 Feb 2025 09:35:24 +0100 Message-ID: <20250203083606.22864-17-nrb@linux.ibm.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250203083606.22864-1-nrb@linux.ibm.com> References: <20250203083606.22864-1-nrb@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: Pa2_iY2u6nm9SVWIQO-kuNwN807EM1qJ X-Proofpoint-ORIG-GUID: Pa2_iY2u6nm9SVWIQO-kuNwN807EM1qJ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-02-03_03,2025-01-31_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 mlxlogscore=999 priorityscore=1501 impostorscore=0 mlxscore=0 suspectscore=0 malwarescore=0 clxscore=1015 lowpriorityscore=0 spamscore=0 phishscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2501170000 definitions=main-2502030068 From: Marc Hartmayer Since s390-tools commit f4cf4ae6ebb1 ("rust: Add a new tool called 'pvimg'") the genprotimg command checks if a given image/kernel is a s390x Linux kernel, and it does no longer overwrite the output file by default. Disable the component check, since a KUT test is being prepared, and use the '--overwrite' option to overwrite the output. Signed-off-by: Marc Hartmayer Reviewed-by: Nico Boehr Link: https://lore.kernel.org/r/20241205160011.100609-1-mhartmay@linux.ibm.com [ nrb: re-wrapped commit message ] Signed-off-by: Nico Boehr --- s390x/Makefile | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/s390x/Makefile b/s390x/Makefile index e5572cb6..8970a85b 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -182,17 +182,26 @@ $(comm-key): %.bin: %.elf $(OBJCOPY) -O binary $< $@ +define test_genprotimg_opt +$(shell $(GENPROTIMG) --help | grep -q -- "$1" && echo yes || echo no) +endef + +GENPROTIMG_DEFAULT_ARGS := --no-verify +ifneq ($(HOST_KEY_DOCUMENT),) # The genprotimg arguments for the cck changed over time so we need to # figure out which argument to use in order to set the cck -ifneq ($(HOST_KEY_DOCUMENT),) -GENPROTIMG_HAS_COMM_KEY = $(shell $(GENPROTIMG) --help | grep -q -- --comm-key && echo yes) -ifeq ($(GENPROTIMG_HAS_COMM_KEY),yes) +ifeq ($(call test_genprotimg_opt,--comm-key),yes) GENPROTIMG_COMM_OPTION := --comm-key else GENPROTIMG_COMM_OPTION := --x-comm-key endif -else -GENPROTIMG_HAS_COMM_KEY = +# Newer version of the genprotimg command checks if the given image/kernel is a +# s390x Linux kernel and it does not overwrite the output file by default. +# Disable the component check, since a KUT test is being prepared, and always +# overwrite the output. +ifeq ($(call test_genprotimg_opt,--overwrite),yes) + GENPROTIMG_DEFAULT_ARGS += --overwrite --no-component-check +endif endif ifeq ($(CONFIG_DUMP),yes) @@ -206,7 +215,7 @@ endif $(patsubst %.parmfile,%.pv.bin,$(wildcard s390x/*.parmfile)): %.pv.bin: %.parmfile %.pv.bin: %.bin $(HOST_KEY_DOCUMENT) $(comm-key) $(eval parmfile_args = $(if $(filter %.parmfile,$^),--parmfile $(filter %.parmfile,$^),)) - $(GENPROTIMG) --host-key-document $(HOST_KEY_DOCUMENT) --no-verify $(GENPROTIMG_COMM_OPTION) $(comm-key) --x-pcf $(GENPROTIMG_PCF) $(parmfile_args) --image $(filter %.bin,$^) -o $@ + $(GENPROTIMG) $(GENPROTIMG_DEFAULT_ARGS) --host-key-document $(HOST_KEY_DOCUMENT) $(GENPROTIMG_COMM_OPTION) $(comm-key) --x-pcf $(GENPROTIMG_PCF) $(parmfile_args) --image $(filter %.bin,$^) -o $@ $(snippet_asmlib): $$(patsubst %.o,%.S,$$@) $(asm-offsets) $(CC) $(CFLAGS) -c -nostdlib -o $@ $< From patchwork Mon Feb 3 08:35:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13957016 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 75A822066FD for ; Mon, 3 Feb 2025 08:36:47 +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=1738571809; cv=none; b=Tj/EY9D1Hfntv2Orm9LLx5Ggo6NRIbHxHQ1XB6ZCyibqmQtL/D+y5fqn01b7m/NmXt8oFxzTbQM3dfv80PxN6QEh5pDboNlzpRM7I5spXaEccK6UjL1oUdsmgCoJ+0AB0N9kW42T7QVv7N3T9L4rxPB3aa4nO4lPAtj7uiWdBjc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738571809; c=relaxed/simple; bh=o4HClkW9EZDL1ZWfTKxgiodH/+5gSjgtu37be43xmS4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AkppGP4KRT1YZXB85YNOGd1mT+H8AP0zQOOowkk9BsqilX/uXSaacTWOoW1KvUQqKboOjEfsQ6volWRVFEZfCimIzWwZ/9R48KLdZB8xTePbVZPiwqXBPo7kqw/9c8rxRpMdkPTOCKaR6zhWLTCo3EroV54yo/KqquzFJsj3smE= 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=lu8+wmeX; 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="lu8+wmeX" 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 512NkVYc003245; Mon, 3 Feb 2025 08:36:38 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=JJe7eTSjIdWlLw1gF mc3NDBc1Gs5MJuuRX7PV6TZDdE=; b=lu8+wmeXXi26Re5tMW3zzSKxk174L6XdN uqyB2BUNx7zmMF3xAPElBckzl3c3LBZsq0xwK0VysB9OoDmcNRhHQRGWfs4KA9FH tYc9FHcFRYD5+Rqw+KWk70D/8MtbfnossZbDGBo3rPY5IuedVbvCBcFD9RqpCjIM F99UjthyNV3fK5k137YV8oADPBu/r7dlzeuU01XrW8iAuRAzRLiiREzvAGF6ICyR YDnEmrBvM9g5rcbb+tOquS6cnvTCR13R/4v+c1gvzTZZq1IqWUcdyZ3SGTV+VrpM PFCYdPr+7lg8M1r7idEqMgbjO0zp948R8+1JypH7LJH2AvkaOfcWw== 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 44jbht2xd8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2025 08:36:37 +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 5137xAAR024506; Mon, 3 Feb 2025 08:36:37 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 44hxxmwe62-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2025 08:36:37 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5138aXbC34406814 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 3 Feb 2025 08:36:33 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6A19B20040; Mon, 3 Feb 2025 08:36:33 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F06C220043; Mon, 3 Feb 2025 08:36:32 +0000 (GMT) Received: from t14-nrb.lan (unknown [9.171.84.16]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 3 Feb 2025 08:36:32 +0000 (GMT) From: Nico Boehr To: thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, imbrenda@linux.ibm.com, Marc Hartmayer Subject: [kvm-unit-tests GIT PULL 17/18] s390x/Makefile: Make sure the linker script is generated in the build directory Date: Mon, 3 Feb 2025 09:35:25 +0100 Message-ID: <20250203083606.22864-18-nrb@linux.ibm.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250203083606.22864-1-nrb@linux.ibm.com> References: <20250203083606.22864-1-nrb@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: AI9Obrac0Gfxs__74b67CyH81bShoI8Q X-Proofpoint-GUID: AI9Obrac0Gfxs__74b67CyH81bShoI8Q X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-02-03_03,2025-01-31_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 adultscore=0 impostorscore=0 phishscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 suspectscore=0 lowpriorityscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2501170000 definitions=main-2502030068 From: Marc Hartmayer This change makes sure that the 'flat.lds' linker script is actually generated in the build directory and not source directory - this makes a difference in case of an out-of-source build. Signed-off-by: Marc Hartmayer Reviewed-by: Nico Boehr Link: https://lore.kernel.org/r/20250128100639.41779-2-mhartmay@linux.ibm.com [ nrb: use TEST_DIR instead of s390x, wrap commit msg ] Signed-off-by: Nico Boehr --- s390x/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/s390x/Makefile b/s390x/Makefile index 8970a85b..eb3d5431 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -167,8 +167,8 @@ lds-autodepend-flags = -MMD -MF $(dir $*).$(notdir $*).d -MT $@ $(CC) $(CFLAGS) -c -o $@ $< -DPROGNAME=\"$(@:.aux.o=.elf)\" .SECONDEXPANSION: -%.elf: $(FLATLIBS) $(asmlib) $(SRCDIR)/s390x/flat.lds $$(snippets-obj) $$(snippet-hdr-obj) %.o %.aux.o - @$(CC) $(LDFLAGS) -o $@ -T $(SRCDIR)/s390x/flat.lds \ +%.elf: $(FLATLIBS) $(asmlib) $(TEST_DIR)/flat.lds $$(snippets-obj) $$(snippet-hdr-obj) %.o %.aux.o + @$(CC) $(LDFLAGS) -o $@ -T $(TEST_DIR)/flat.lds \ $(filter %.o, $^) $(FLATLIBS) $(snippets-obj) $(snippet-hdr-obj) || \ { echo "Failure probably caused by missing definition of gen-se-header executable"; exit 1; } @chmod a-x $@ From patchwork Mon Feb 3 08:35:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13957020 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 57C1C20766C for ; Mon, 3 Feb 2025 08:36:48 +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=1738571810; cv=none; b=QrYA2W9Uao6tqCpx2tWzbvn0MDuZ29iKC+JdShWLadO8Sj3TgsXP8rw25wQ8wqaTKUUVeGn5Tn1gwKTnrFSLgYrR9PiJLsuCyKNui4P0jXfhd7msziwHHjFTcCagcASEvdEHDLT5FhS8aou+TrEYedtd09pzb/kETM0dIUAZDZY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738571810; c=relaxed/simple; bh=LznEXqgR9tVR2hA1p9YnoLGgu5w7CGsfML1+Rr8ABzE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KIUxal+O71soaHqKenc0bPkvfKs7p2jDhVZi7lHod/16suk6iJ9jP5aKuVlGZQTh7c9jIVHATbEuAf87fN8uS5r8b6UkWd0j9NMDfYky0AkLbrQTGjkxiNX/HGQlNFA/54AHQxtF6VZ70udpsoxJh7bEw/5Ucc0c8oINhrk/X7Y= 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=H95J1i5T; 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="H95J1i5T" Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 51318Tck027273; Mon, 3 Feb 2025 08:36:38 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=fn2MbfMHxrsTEH1qS 3fO4eZGX6GDX4vBjCzWaX3YL88=; b=H95J1i5TYe8jxqPXq2olgPypqg/7utfHn Fzt67c4JCRIIuXBBHPlrxG3wJKluRS8Bhl9xcfJGii/V5mISVTUJCEXs3Z096NhS u8rx9obLYwT1hzcnE4FB9xGxhZlhmxdKCoArQJpdjC9jCsl+nPYKWqriF+jPgOUL 1dzxxu5Q1K1Exk5Jqi3lxHKwmlVofxpZ6gosTIswFtBmbsve0V2RcKyWrirQaDXf ZKm2i/aZ9PO7SoCAUS9isew+fu/1OVmgn54wjeXNKElfcRlRauaCFpqc4I346xKg MCariB1kBX1nrAHlzFgzNg7whYrO0abCTkX9oKjxb7ZL92xwLpekw== 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 44jkv91n9s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2025 08:36:38 +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 5137A87A016280; Mon, 3 Feb 2025 08:36:37 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 44hwxs5kub-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2025 08:36:37 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5138aYEA42140008 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 3 Feb 2025 08:36:34 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0022520040; Mon, 3 Feb 2025 08:36:34 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7CF6520043; Mon, 3 Feb 2025 08:36:33 +0000 (GMT) Received: from t14-nrb.lan (unknown [9.171.84.16]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 3 Feb 2025 08:36:33 +0000 (GMT) From: Nico Boehr To: thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, imbrenda@linux.ibm.com, Marc Hartmayer Subject: [kvm-unit-tests GIT PULL 18/18] s390x/Makefile: Add auxinfo.o to cflatobjs Date: Mon, 3 Feb 2025 09:35:26 +0100 Message-ID: <20250203083606.22864-19-nrb@linux.ibm.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250203083606.22864-1-nrb@linux.ibm.com> References: <20250203083606.22864-1-nrb@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: xqeCVZkZA2mfIF0GP6QvOZHbCCFPlSTQ X-Proofpoint-ORIG-GUID: xqeCVZkZA2mfIF0GP6QvOZHbCCFPlSTQ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-02-03_03,2025-01-31_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 mlxlogscore=999 priorityscore=1501 impostorscore=0 mlxscore=0 suspectscore=0 malwarescore=0 clxscore=1015 lowpriorityscore=0 spamscore=0 phishscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2501170000 definitions=main-2502030068 From: Marc Hartmayer This makes sure that the file is removed in case of `make clean` as the top Makefile cleans all objects defined in 'cflagsobjs'. AFAICT, the computed sh256sum values of the generated .elf and .bin files did not change. Signed-off-by: Marc Hartmayer Reviewed-by: Nico Boehr Link: https://lore.kernel.org/r/20250128100639.41779-3-mhartmay@linux.ibm.com [ nrb: remove "Note" in commit msg since it looked like a tag ] Signed-off-by: Nico Boehr --- s390x/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/s390x/Makefile b/s390x/Makefile index eb3d5431..47dda6d2 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -96,6 +96,7 @@ LDFLAGS += -Wl,--build-id=none asm-offsets = lib/$(ARCH)/asm-offsets.h include $(SRCDIR)/scripts/asm-offsets.mak +cflatobjs += lib/auxinfo.o cflatobjs += lib/util.o cflatobjs += lib/alloc.o cflatobjs += lib/alloc_phys.o