From nobody Wed May 15 19:40:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1690463427; cv=none; d=zohomail.com; s=zohoarc; b=Luj+YP5VEAq+XwoP2ZkB7KtDmD/ghJ/dXilkG2yvuVE4qOMpONgPOcdqpz5Tqrvk5FR/dZd2PB1tR/dZ1y0hX3pTrGXcEYsX2U6WDJohbnsRPYTsmIbOiRIKfR4ybluLz2xWcVniKsgct6gMO6ptDE25Bimb0+mufZMr3ZqbZMc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690463427; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BbwLORcfAUBPqJsYQK4Qm5SGuif8s7Qz81E3J+S5XLY=; b=RuOIAFPSXIL09iJYn1Cj81vcbfvJ8/jgbGsAfZPYtNPGaKJOHz2FRO5hxf1xCusPJAydg3J9wl76Ru1EKEFhq4CyQ70rEWk6e3R9sYlW/imleaSzURW26MxCtn5QxuyPWP+QmVPG1Uk2if6yGCR5cCCTyqjZ6uQE6qx9jn4xUcc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16904634277521016.0369612391421; Thu, 27 Jul 2023 06:10:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qP03n-00011k-2J; Thu, 27 Jul 2023 08:25:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qP03P-0000yG-CJ; Thu, 27 Jul 2023 08:25:16 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qP03M-00019w-FZ; Thu, 27 Jul 2023 08:25:14 -0400 Received: from pps.filterd (m0353722.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36RCF26l004198; Thu, 27 Jul 2023 12:25:08 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3s3rdpga8f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 27 Jul 2023 12:25:08 +0000 Received: from m0353722.ppops.net (m0353722.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 36RCI6YQ014487; Thu, 27 Jul 2023 12:25:07 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3s3rdpga80-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 27 Jul 2023 12:25:07 +0000 Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36RCBDot026217; Thu, 27 Jul 2023 12:25:07 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3s0sesdw0v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 27 Jul 2023 12:25:07 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36RCP45o60686750 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 27 Jul 2023 12:25:04 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 51C2A20040; Thu, 27 Jul 2023 12:25:04 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0FBB32004B; Thu, 27 Jul 2023 12:25:04 +0000 (GMT) Received: from a46lp73.lnxne.boe (unknown [9.152.108.100]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 27 Jul 2023 12:25:04 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=BbwLORcfAUBPqJsYQK4Qm5SGuif8s7Qz81E3J+S5XLY=; b=jrmLS/f851AMuag6gl7io6n4ER9XgAyiTRBrpD7fHoCgLl6ukXSjhVOmZEkckLbiyqwn qnHmCTVyh794As1zajpBJb9RcXNUeRaJ8poTgRIC6rbqPyvJ+Ngi3w8N/o8gh8EqSlJZ ocQultG7TWAq9zw1Oe4sESdWWvQ1nwUnXzkfmJ1q8Hppz0HtHA87PEL/6EtnfSX9zBdY 9Nl6oLvhDSFrGtDz0kGdOMgZKJJbMbF+rQQ0d3RrNf8pMDeJB6vLVgLP+YUbBP4nYQ69 Hp9c+CY4qW0f78MDSnFebgRrnxO+Y+Tcr29XKBDM0zFnPbjIzk7NoDsbUw8JoobBeiv2 cg== From: Steffen Eiden To: qemu-s390x@nongnu.org, qemu-devel@nongnu.org Cc: Janosch Frank , Thomas Huth , David Hildenbrand , Michael Mueller , Marc Hartmayer , Christian Borntraeger Subject: [PATCH 1/3] linux-headers: update asm-s390/kvm.h Date: Thu, 27 Jul 2023 14:25:01 +0200 Message-Id: <20230727122503.775084-2-seiden@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230727122503.775084-1-seiden@linux.ibm.com> References: <20230727122503.775084-1-seiden@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: veQS5hNCCN1q6jRgr0DMlFeO0csbStCu X-Proofpoint-ORIG-GUID: 53kHzzzyxYSScA3EKW3TrE87UlKjlUsy X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-27_06,2023-07-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 malwarescore=0 adultscore=0 phishscore=0 clxscore=1011 priorityscore=1501 spamscore=0 impostorscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307270108 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=seiden@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1690463429513100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Steffen Eiden --- linux-headers/asm-s390/kvm.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/linux-headers/asm-s390/kvm.h b/linux-headers/asm-s390/kvm.h index e2afd95420..178edb959e 100644 --- a/linux-headers/asm-s390/kvm.h +++ b/linux-headers/asm-s390/kvm.h @@ -159,6 +159,27 @@ struct kvm_s390_vm_cpu_subfunc { __u8 reserved[1728]; }; =20 +#define KVM_S390_VM_CPU_PROCESSOR_UV_FEAT_GUEST 6 +#define KVM_S390_VM_CPU_MACHINE_UV_FEAT_GUEST 7 + +#define KVM_S390_VM_CPU_UV_FEAT_NR_BITS 64 +struct kvm_s390_vm_cpu_uv_feat { + union { + struct { + __u64 res0 : 4; + __u64 ap : 1; /* bit 4 */ + __u64 ap_intr : 1; /* bit 5 */ + }; + __u64 feat; + }; +}; + +#define KVM_S390_VM_CPU_UV_FEAT_GUEST_MASK \ +(((struct kvm_s390_vm_cpu_uv_feat) { \ + .ap =3D 1, \ + .ap_intr =3D 1, \ +}).feat) + /* kvm attributes for crypto */ #define KVM_S390_VM_CRYPTO_ENABLE_AES_KW 0 #define KVM_S390_VM_CRYPTO_ENABLE_DEA_KW 1 --=20 2.40.1 From nobody Wed May 15 19:40:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1690462135; cv=none; d=zohomail.com; s=zohoarc; b=MtZ3kX3Kc3NP29oO5SQ9Flci9C6XM7DMJyvjsFU52/WoieYJ9nCbgA4LWH2LDGHt9CqoGXPk52pjg9LFB1PIgPInLbRzMFGVwbZZh6fLcYxcw2XaQ72zxwE0mvFDLDiX9pO0i9fQ2HVU2P2MjuEXKjSEzJsQmoVm+5wNcixsZfY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690462135; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=n84K8P23Sh5AYEVWROIIfO9iw8kEaaTuXMtdgS7QSPo=; b=L5A4/ecWlqrrALGE5IMttH1hwNskfh7iQ/Fbw5EwORUTRbYhMtJNifoxLWjlyS0Jda332tkN1NwXFhv4wor8ZWAqwG0CIXOaGzHKpJQGNQVNeswwncaHEZuzz+iWkMrrrjZmeZkbyLRYgsb/6TvagvrmAEs1RAg210j/nymBwME= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1690462135652541.8719591925081; Thu, 27 Jul 2023 05:48:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qP03U-0000yf-5d; Thu, 27 Jul 2023 08:25:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qP03N-0000y5-Tb; Thu, 27 Jul 2023 08:25:13 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qP03M-0001A4-1g; Thu, 27 Jul 2023 08:25:13 -0400 Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36RCJ7F5003901; Thu, 27 Jul 2023 12:25:09 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3s3qyfs3yt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 27 Jul 2023 12:25:08 +0000 Received: from m0356516.ppops.net (m0356516.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 36RCAZrN000377; Thu, 27 Jul 2023 12:25:08 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 3s3qyfs3yc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 27 Jul 2023 12:25:08 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36RBSUQd002412; Thu, 27 Jul 2023 12:25:07 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3s0txkd9dw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 27 Jul 2023 12:25:07 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36RCP4as60686752 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 27 Jul 2023 12:25:04 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 90BD72004B; Thu, 27 Jul 2023 12:25:04 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5991120043; Thu, 27 Jul 2023 12:25:04 +0000 (GMT) Received: from a46lp73.lnxne.boe (unknown [9.152.108.100]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 27 Jul 2023 12:25:04 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=n84K8P23Sh5AYEVWROIIfO9iw8kEaaTuXMtdgS7QSPo=; b=S68FSarHvxfpbjrU42qvwsWCIH7glmvvEN/JlmYBgH6kkcyrqaoM1nqrBE5+xMRPPxzw HG2c5pZL/Nn1+OM111jBYlpA47x53313ZM0EvStm8eBaM+wkftpD3XignnSMcF4UsJyn 5arTjEZ7gs+7AYhOkeMMEFdVLfcdRErIDmeCf+tj0F9o7VwoBBYwVUbl0gtZR4UEHXZI wPGljqfu+8tptQ798SJCz+sdmPrVXpxjODs3eR5/6ILfglwJRGLjjMWX406xo5DOGSZH E8XOde7BGl7Unwa9oTShzyfo5IxLW+jVoY5dOTuc70QgVHG5vdozCCZY5JFCw8hICn2H wg== From: Steffen Eiden To: qemu-s390x@nongnu.org, qemu-devel@nongnu.org Cc: Janosch Frank , Thomas Huth , David Hildenbrand , Michael Mueller , Marc Hartmayer , Christian Borntraeger Subject: [PATCH 2/3] target/s390x: refractor AP functionalities Date: Thu, 27 Jul 2023 14:25:02 +0200 Message-Id: <20230727122503.775084-3-seiden@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230727122503.775084-1-seiden@linux.ibm.com> References: <20230727122503.775084-1-seiden@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: cFCrH0TuZh3DxL2j4X9ll5jiPm1mfqHI X-Proofpoint-GUID: mrlTkt3PyPQ0YrlApmlwaSSwAv_Tt_xE X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-27_06,2023-07-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 adultscore=0 malwarescore=0 lowpriorityscore=0 clxscore=1015 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307270108 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=seiden@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1690462137108100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Steffen Eiden --- target/s390x/kvm/kvm.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c index 3ac7ec9acf..bd62a7f606 100644 --- a/target/s390x/kvm/kvm.c +++ b/target/s390x/kvm/kvm.c @@ -250,7 +250,7 @@ static void kvm_s390_enable_cmma(void) trace_kvm_enable_cmma(rc); } =20 -static void kvm_s390_set_attr(uint64_t attr) +static void kvm_s390_set_crypto_attr(uint64_t attr) { struct kvm_device_attr attribute =3D { .group =3D KVM_S390_VM_CRYPTO, @@ -275,7 +275,7 @@ static void kvm_s390_init_aes_kw(void) } =20 if (kvm_vm_check_attr(kvm_state, KVM_S390_VM_CRYPTO, attr)) { - kvm_s390_set_attr(attr); + kvm_s390_set_crypto_attr(attr); } } =20 @@ -289,7 +289,7 @@ static void kvm_s390_init_dea_kw(void) } =20 if (kvm_vm_check_attr(kvm_state, KVM_S390_VM_CRYPTO, attr)) { - kvm_s390_set_attr(attr); + kvm_s390_set_crypto_attr(attr); } } =20 @@ -2296,6 +2296,11 @@ static int configure_cpu_subfunc(const S390FeatBitma= p features) return kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attr); } =20 +static bool ap_available(void) +{ + return kvm_vm_check_attr(kvm_state, KVM_S390_VM_CRYPTO, KVM_S390_VM_CR= YPTO_ENABLE_APIE); +} + static int kvm_to_feat[][2] =3D { { KVM_S390_VM_CPU_FEAT_ESOP, S390_FEAT_ESOP }, { KVM_S390_VM_CPU_FEAT_SIEF2, S390_FEAT_SIE_F2 }, @@ -2475,8 +2480,7 @@ void kvm_s390_get_host_cpu_model(S390CPUModel *model,= Error **errp) return; } /* for now, we can only provide the AP feature with HW support */ - if (kvm_vm_check_attr(kvm_state, KVM_S390_VM_CRYPTO, - KVM_S390_VM_CRYPTO_ENABLE_APIE)) { + if (ap_available()) { set_bit(S390_FEAT_AP, model->features); } =20 @@ -2502,7 +2506,7 @@ static void kvm_s390_configure_apie(bool interpret) KVM_S390_VM_CRYPTO_DISABLE_APIE; =20 if (kvm_vm_check_attr(kvm_state, KVM_S390_VM_CRYPTO, attr)) { - kvm_s390_set_attr(attr); + kvm_s390_set_crypto_attr(attr); } } =20 @@ -2556,7 +2560,7 @@ void kvm_s390_apply_cpu_model(const S390CPUModel *mod= el, Error **errp) kvm_s390_enable_cmma(); } =20 - if (test_bit(S390_FEAT_AP, model->features)) { + if (ap_enabled(model->features)) { kvm_s390_configure_apie(true); } } --=20 2.40.1 From nobody Wed May 15 19:40:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1690463349; cv=none; d=zohomail.com; s=zohoarc; b=IvUeDqH1U4Yrp4vyp8vg5IghSjs4qGTTBCcQFBCuhv+7AvQf0DXbqw3CvRWT8NIudvEgyt4jY/faVb8fE4jIraXxUreB8jUmtLl8j2Tt/kyLztCn0AOJR6HZyTZAK36pvfe1V4i4pkKMh8oCbfrKjqldL5D3fgb0lmOeDZg/yGU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690463349; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=X9WB5JQ2lHFulrq0bpP4+zs9ypnpfxdUIKkyr++DW9U=; b=NLE9koMskAiY/mAGGucVgrZ+lVu+4EhkC2zQks32eqToJ591r6EJ0Vu4BB2XIdugUOLGQk3HmIXd8m0HCjRLV2cRB8ZotGmLcSuH7nannHmBGzHO7rC/K+dIgmNYAuf/QXaAK9gSoLQY5eIvVR1CyAjzijK7a9YkxrGTKrPtEbA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1690463349018521.1222437364602; Thu, 27 Jul 2023 06:09:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qP03n-00011o-1y; Thu, 27 Jul 2023 08:25:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qP03P-0000yH-Cb; Thu, 27 Jul 2023 08:25:16 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qP03L-0001A7-TQ; Thu, 27 Jul 2023 08:25:14 -0400 Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36RCEKEf008939; Thu, 27 Jul 2023 12:25:09 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3s3rdk0apq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 27 Jul 2023 12:25:08 +0000 Received: from m0360072.ppops.net (m0360072.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 36RCG0xt013841; Thu, 27 Jul 2023 12:25:08 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3s3rdk0ap8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 27 Jul 2023 12:25:08 +0000 Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36RBvVGC026200; Thu, 27 Jul 2023 12:25:07 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3s0sesdw13-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 27 Jul 2023 12:25:07 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36RCP4v260686754 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 27 Jul 2023 12:25:05 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D0F7B20043; Thu, 27 Jul 2023 12:25:04 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 996192004E; Thu, 27 Jul 2023 12:25:04 +0000 (GMT) Received: from a46lp73.lnxne.boe (unknown [9.152.108.100]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 27 Jul 2023 12:25:04 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=X9WB5JQ2lHFulrq0bpP4+zs9ypnpfxdUIKkyr++DW9U=; b=eD2ZOkn5zHONiACJiSE/cn0fN6t1s3UlRwppnNunY4/OtJdS9EHWC36B+NXAJ2+NWAfz GeJmp8OiZcwIeT10c4o6zh+M45IFJ0w2EYXlfKJ3JnTch45ytZBmTYV2GkbN6/W+dR23 p1Z9cm9EJ2fMkXHNrTGpA2b3djr3r+ekOwRuotxcC7A9vcMd2uzdeCNPaHWYldhchqLT 8z9NEtK3r7sEDiTPlGwOhs6HLEz1ZYdeOSSk9eulMyOG5BQizE4sV0ZI2mOa3CQtLHpN hr2VlieNQvipd+8W84Bya5wlmpMIMpFM3Wzz8JDH1JE+X1DiMeC5WVfnyFIxtnYfhcSp fw== From: Steffen Eiden To: qemu-s390x@nongnu.org, qemu-devel@nongnu.org Cc: Janosch Frank , Thomas Huth , David Hildenbrand , Michael Mueller , Marc Hartmayer , Christian Borntraeger Subject: [PATCH 3/3] target/s390x: AP-passthrough for PV guests Date: Thu, 27 Jul 2023 14:25:03 +0200 Message-Id: <20230727122503.775084-4-seiden@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230727122503.775084-1-seiden@linux.ibm.com> References: <20230727122503.775084-1-seiden@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: N3-EBQvrrf8yD6g1PJ9D00XjZ1_5MzPU X-Proofpoint-GUID: 8M_Za6K8eZnP7kOipdkEs8p1tDQ6z-vu X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-27_06,2023-07-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 spamscore=0 phishscore=0 priorityscore=1501 mlxlogscore=999 mlxscore=0 lowpriorityscore=0 adultscore=0 clxscore=1015 bulkscore=0 malwarescore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307270108 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=seiden@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1690463350625100001 Content-Type: text/plain; charset="utf-8" Enabling AP-passthrough(AP-pt) for PV-guest via using the new CPU features for PV-AP-pt of kvm. As usual QEMU first checks which CPU features are available and then sets them if available and selected by user. An additional check is done to verify that PV-AP can only be enabled if "regular" AP-pt is enabled as well. Note that KVM itself does not enforce this restriction. If regular AP-pt is enabled and kvm/firmware supports PV-AP-pt it is also turned on by default. Signed-off-by: Steffen Eiden --- target/s390x/cpu_features.h | 1 + target/s390x/cpu_features_def.h.inc | 4 ++ target/s390x/cpu_models.c | 2 + target/s390x/gen-features.c | 4 ++ target/s390x/kvm/kvm.c | 73 +++++++++++++++++++++++++++++ 5 files changed, 84 insertions(+) diff --git a/target/s390x/cpu_features.h b/target/s390x/cpu_features.h index 87463f064d..40928c60e9 100644 --- a/target/s390x/cpu_features.h +++ b/target/s390x/cpu_features.h @@ -43,6 +43,7 @@ typedef enum { S390_FEAT_TYPE_KDSA, S390_FEAT_TYPE_SORTL, S390_FEAT_TYPE_DFLTCC, + S390_FEAT_TYPE_UV_CALL, } S390FeatType; =20 /* Definition of a CPU feature */ diff --git a/target/s390x/cpu_features_def.h.inc b/target/s390x/cpu_feature= s_def.h.inc index e3cfe63735..4b659d4064 100644 --- a/target/s390x/cpu_features_def.h.inc +++ b/target/s390x/cpu_features_def.h.inc @@ -379,3 +379,7 @@ DEF_FEAT(DEFLATE_GHDT, "dfltcc-gdht", DFLTCC, 1, "DFLTC= C GDHT") DEF_FEAT(DEFLATE_CMPR, "dfltcc-cmpr", DFLTCC, 2, "DFLTCC CMPR") DEF_FEAT(DEFLATE_XPND, "dfltcc-xpnd", DFLTCC, 4, "DFLTCC XPND") DEF_FEAT(DEFLATE_F0, "dfltcc-f0", DFLTCC, 192, "DFLTCC format 0 parameter-= block") + +/* Features exposed via the UV-CALL instruction */ +DEF_FEAT(UV_CALL_AP, "appv", UV_CALL, 4, "AP instructions installed for se= cure guests") +DEF_FEAT(UV_CALL_AP_INTR, "appvi", UV_CALL, 5, "AP instructions interpreti= on for secure guests") diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index ae8880e81d..6d703b3c55 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -483,6 +483,8 @@ static void check_consistency(const S390CPUModel *model) { S390_FEAT_DIAG_318, S390_FEAT_EXTENDED_LENGTH_SCCB }, { S390_FEAT_NNPA, S390_FEAT_VECTOR }, { S390_FEAT_RDP, S390_FEAT_LOCAL_TLB_CLEARING }, + { S390_FEAT_UV_CALL_AP, S390_FEAT_AP }, + { S390_FEAT_UV_CALL_AP_INTR, S390_FEAT_UV_CALL_AP }, }; int i; =20 diff --git a/target/s390x/gen-features.c b/target/s390x/gen-features.c index 1e3b7c0dc9..0220864d89 100644 --- a/target/s390x/gen-features.c +++ b/target/s390x/gen-features.c @@ -576,6 +576,8 @@ static uint16_t full_GEN16_GA1[] =3D { S390_FEAT_RDP, S390_FEAT_PAI, S390_FEAT_PAIE, + S390_FEAT_UV_CALL_AP, + S390_FEAT_UV_CALL_AP_INTR, }; =20 =20 @@ -671,6 +673,8 @@ static uint16_t default_GEN16_GA1[] =3D { S390_FEAT_RDP, S390_FEAT_PAI, S390_FEAT_PAIE, + S390_FEAT_UV_CALL_AP, + S390_FEAT_UV_CALL_AP_INTR, }; =20 /* QEMU (CPU model) features */ diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c index bd62a7f606..cf11bfb0fa 100644 --- a/target/s390x/kvm/kvm.c +++ b/target/s390x/kvm/kvm.c @@ -2301,6 +2301,39 @@ static bool ap_available(void) return kvm_vm_check_attr(kvm_state, KVM_S390_VM_CRYPTO, KVM_S390_VM_CR= YPTO_ENABLE_APIE); } =20 +static bool uv_feat_supported(void) +{ + return kvm_vm_check_attr( + kvm_state, KVM_S390_VM_CPU_MODEL, KVM_S390_VM_CPU_PROCESSOR_UV= _FEAT_GUEST); +} + +static int query_uv_feat_guest(S390FeatBitmap features) +{ + struct kvm_s390_vm_cpu_uv_feat prop =3D {}; + struct kvm_device_attr attr =3D { + .group =3D KVM_S390_VM_CPU_MODEL, + .attr =3D KVM_S390_VM_CPU_MACHINE_UV_FEAT_GUEST, + .addr =3D (uint64_t) &prop, + }; + int rc; + + if (!uv_feat_supported()) + return 0; + + rc =3D kvm_vm_ioctl(kvm_state, KVM_GET_DEVICE_ATTR, &attr); + if (rc) { + return rc; + } + + if (ap_available()) { + if (prop.ap) + set_bit(S390_FEAT_UV_CALL_AP, features); + if (prop.ap_intr) + set_bit(S390_FEAT_UV_CALL_AP_INTR, features); + } + return 0; +} + static int kvm_to_feat[][2] =3D { { KVM_S390_VM_CPU_FEAT_ESOP, S390_FEAT_ESOP }, { KVM_S390_VM_CPU_FEAT_SIEF2, S390_FEAT_SIE_F2 }, @@ -2495,11 +2528,44 @@ void kvm_s390_get_host_cpu_model(S390CPUModel *mode= l, Error **errp) set_bit(S390_FEAT_DIAG_318, model->features); } =20 + /* Test for Ultravisor features that influence secure guest behavior */ + query_uv_feat_guest(model->features); + /* strip of features that are not part of the maximum model */ bitmap_and(model->features, model->features, model->def->full_feat, S390_FEAT_MAX); } =20 +static bool ap_enabled(const S390FeatBitmap features) +{ + return test_bit(S390_FEAT_AP, features); +} + +static int configure_uv_feat_guest(const S390FeatBitmap features, bool int= erpret) +{ + + struct kvm_s390_vm_cpu_uv_feat uv_feat =3D {}; + struct kvm_device_attr attribute =3D { + .group =3D KVM_S390_VM_CPU_MODEL, + .attr =3D KVM_S390_VM_CPU_PROCESSOR_UV_FEAT_GUEST, + .addr =3D (__u64)&uv_feat, + }; + + if (!uv_feat_supported()) + return 0; + + if (ap_enabled(features)) { + if (test_bit(S390_FEAT_UV_CALL_AP, features)) { + uv_feat.ap =3D 1; + } + if (test_bit(S390_FEAT_UV_CALL_AP_INTR, features) && interpret) { + uv_feat.ap_intr =3D 1; + } + } + + return kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attribute); +} + static void kvm_s390_configure_apie(bool interpret) { uint64_t attr =3D interpret ? KVM_S390_VM_CRYPTO_ENABLE_APIE : @@ -2563,6 +2629,13 @@ void kvm_s390_apply_cpu_model(const S390CPUModel *mo= del, Error **errp) if (ap_enabled(model->features)) { kvm_s390_configure_apie(true); } + + /* configure uv features for the guest indicated via query / test_bit*/ + rc =3D configure_uv_feat_guest(model->features, true); + if (rc) { + error_setg(errp, "KVM: Error configuring CPU UV features %d", rc); + return; + } } =20 void kvm_s390_restart_interrupt(S390CPU *cpu) --=20 2.40.1