From patchwork Thu Feb 3 09:19:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steffen Eiden X-Patchwork-Id: 12733985 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C9BEC4167B for ; Thu, 3 Feb 2022 09:19:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241209AbiBCJTt (ORCPT ); Thu, 3 Feb 2022 04:19:49 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:46102 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236813AbiBCJTo (ORCPT ); Thu, 3 Feb 2022 04:19:44 -0500 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 21398aPY012055; Thu, 3 Feb 2022 09:19:44 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=8/gTrN2duCgDJGqMcibs2fbQG7m52p9/xBz4OwXVtZY=; b=h/mDcOmM5tVyZFkbd6Fqlu5XYsdborXtZ7j9PgoNmJ7PeLRqYnVHJh7JHcgIclr5ZZYr gYlfy7HRgoV3taTa9wfQE+QmJ4gcTtl+9y5hHvAGgF/E06LbBFWP4jiZVM6s/1j7kB24 nYcuVeEdJdQ0Mzngeiqr+/dyDdGHZRffZoRvWhFKjmg8Tu4UfKI812bobDmHs4WUiUUr JnrQd9B00XtXv1ymIwYQsTEaBnmEKmSU38CLxr4RNs7NXwyf5kQB3IHXBD8NAe5m4p2b L46IDeB+BTQgBxPYtJv3Ui1lfMrR+oAP6vGbCMSOJMecBwWUjafSDPvt+XQYiZ4FIGNq SQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e09h03fmt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 03 Feb 2022 09:19:44 +0000 Received: from m0098394.ppops.net (m0098394.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 21399tb5017987; Thu, 3 Feb 2022 09:19:44 GMT Received: from ppma06fra.de.ibm.com (48.49.7a9f.ip4.static.sl-reverse.com [159.122.73.72]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e09h03fm0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 03 Feb 2022 09:19:44 +0000 Received: from pps.filterd (ppma06fra.de.ibm.com [127.0.0.1]) by ppma06fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2139HNpG010416; Thu, 3 Feb 2022 09:19:41 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma06fra.de.ibm.com with ESMTP id 3dvvujjf66-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 03 Feb 2022 09:19:41 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2139JcQt40042962 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 3 Feb 2022 09:19:38 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0674552057; Thu, 3 Feb 2022 09:19:38 +0000 (GMT) Received: from linux7.. (unknown [9.114.12.92]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 39F645204F; Thu, 3 Feb 2022 09:19:37 +0000 (GMT) From: Steffen Eiden To: Thomas Huth , Janosch Frank , Claudio Imbrenda , David Hildenbrand Cc: kvm@vger.kernel.org, linux-s390@vger.kernel.org Subject: [kvm-unit-tests PATCH v2 1/4] s390x: uv-host: Add attestation test Date: Thu, 3 Feb 2022 09:19:32 +0000 Message-Id: <20220203091935.2716-2-seiden@linux.ibm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220203091935.2716-1-seiden@linux.ibm.com> References: <20220203091935.2716-1-seiden@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: O6jRFusLlOJQn3_nlhlp39yyQs2Bi8pL X-Proofpoint-GUID: aXHqeRjebX_npx_-x_EV-2TylHE5N7BL X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-03_02,2022-02-01_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 impostorscore=0 suspectscore=0 lowpriorityscore=0 priorityscore=1501 malwarescore=0 spamscore=0 bulkscore=0 mlxlogscore=999 clxscore=1015 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202030056 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Adds an invalid command test for attestation in the uv-host. Signed-off-by: Steffen Eiden Reviewed-by: Janosch Frank Reviewed-by: Claudio Imbrenda --- lib/s390x/asm/uv.h | 23 ++++++++++++++++++++++- s390x/uv-host.c | 1 + 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/s390x/asm/uv.h b/lib/s390x/asm/uv.h index 97c90e81..7afbcffd 100644 --- a/lib/s390x/asm/uv.h +++ b/lib/s390x/asm/uv.h @@ -1,7 +1,7 @@ /* * s390x Ultravisor related definitions * - * Copyright (c) 2020 IBM Corp + * Copyright IBM Corp. 2020, 2022 * * Authors: * Janosch Frank @@ -47,6 +47,7 @@ #define UVC_CMD_UNPIN_PAGE_SHARED 0x0342 #define UVC_CMD_SET_SHARED_ACCESS 0x1000 #define UVC_CMD_REMOVE_SHARED_ACCESS 0x1001 +#define UVC_CMD_ATTESTATION 0x1020 /* Bits in installed uv calls */ enum uv_cmds_inst { @@ -71,6 +72,7 @@ enum uv_cmds_inst { BIT_UVC_CMD_UNSHARE_ALL = 20, BIT_UVC_CMD_PIN_PAGE_SHARED = 21, BIT_UVC_CMD_UNPIN_PAGE_SHARED = 22, + BIT_UVC_CMD_ATTESTATION = 28, }; struct uv_cb_header { @@ -178,6 +180,25 @@ struct uv_cb_cfs { u64 paddr; } __attribute__((packed)) __attribute__((aligned(8))); +/* Retrieve Attestation Measurement */ +struct uv_cb_attest { + struct uv_cb_header header; /* 0x0000 */ + u64 reserved08[2]; /* 0x0008 */ + u64 arcb_addr; /* 0x0018 */ + u64 continuation_token; /* 0x0020 */ + u8 reserved28[6]; /* 0x0028 */ + u16 user_data_length; /* 0x002e */ + u8 user_data[256]; /* 0x0030 */ + u32 reserved130[3]; /* 0x0130 */ + u32 measurement_length; /* 0x013c */ + u64 measurement_address; /* 0x0140 */ + u8 config_uid[16]; /* 0x0148 */ + u32 reserved158; /* 0x0158 */ + u32 add_data_length; /* 0x015c */ + u64 add_data_address; /* 0x0160 */ + u64 reserved168[4]; /* 0x0168 */ +} __attribute__((packed)) __attribute__((aligned(8))); + /* Set Secure Config Parameter */ struct uv_cb_ssc { struct uv_cb_header header; diff --git a/s390x/uv-host.c b/s390x/uv-host.c index 92a41069..946f031e 100644 --- a/s390x/uv-host.c +++ b/s390x/uv-host.c @@ -418,6 +418,7 @@ static struct cmd_list invalid_cmds[] = { { "bogus", 0x4242, sizeof(struct uv_cb_header), -1}, { "share", UVC_CMD_SET_SHARED_ACCESS, sizeof(struct uv_cb_share), BIT_UVC_CMD_SET_SHARED_ACCESS }, { "unshare", UVC_CMD_REMOVE_SHARED_ACCESS, sizeof(struct uv_cb_share), BIT_UVC_CMD_REMOVE_SHARED_ACCESS }, + { "attest", UVC_CMD_ATTESTATION, sizeof(struct uv_cb_attest), BIT_UVC_CMD_ATTESTATION }, { NULL, 0, 0 }, }; From patchwork Thu Feb 3 09:19:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steffen Eiden X-Patchwork-Id: 12733986 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A067BC433EF for ; Thu, 3 Feb 2022 09:19:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238127AbiBCJTu (ORCPT ); Thu, 3 Feb 2022 04:19:50 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:52510 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237963AbiBCJTq (ORCPT ); Thu, 3 Feb 2022 04:19:46 -0500 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 21388DjP013010; Thu, 3 Feb 2022 09:19:46 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=/pE9bxNfG6kL8HopJYYmH68KigzjetTd0Mjiknp64P8=; b=PH8jRoiLHQy54uCQm9M0s7vYGMNL2oZZdvPZyPKHhUekuDZp/MenKGK/KfbHFsCtVg0A yz2OxhvOruSLylEWIIqflCTWtXIOUgqTwP5Oq0LL//t4zJm2gkj8jRqiZyj/0D8dUOwT 5KSu0aTPzF7gdZAbfs/5BWBA4E7R5Y7ETSQixgjbMdGPgtqNw9zD/gPRQ5PuCkqRQ7aG BGd4ofLWzWE1eiwgHtZ0U4+iE6Ww2XlGIwCpmhPk/rFzZT4UpfnpBu4ZdJ4CFF4TbUfi 8lR7/rgoA43SA70wVnXSsOmLDSSpOT3puZHHOd7CZKAbWS0IjlbLSx9joRHJnZk4gPb5 IQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3dyvexjr0f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 03 Feb 2022 09:19:45 +0000 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 2139Gs8D028846; Thu, 3 Feb 2022 09:19:45 GMT Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 3dyvexjr00-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 03 Feb 2022 09:19:45 +0000 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2139H7wL005589; Thu, 3 Feb 2022 09:19:42 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma04fra.de.ibm.com with ESMTP id 3dvw79tbb6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 03 Feb 2022 09:19:42 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2139Jd8V31129984 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 3 Feb 2022 09:19:39 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EFDDD52050; Thu, 3 Feb 2022 09:19:38 +0000 (GMT) Received: from linux7.. (unknown [9.114.12.92]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 251C152059; Thu, 3 Feb 2022 09:19:38 +0000 (GMT) From: Steffen Eiden To: Thomas Huth , Janosch Frank , Claudio Imbrenda , David Hildenbrand Cc: kvm@vger.kernel.org, linux-s390@vger.kernel.org Subject: [kvm-unit-tests PATCH v2 2/4] s390x: lib: Add QUI getter Date: Thu, 3 Feb 2022 09:19:33 +0000 Message-Id: <20220203091935.2716-3-seiden@linux.ibm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220203091935.2716-1-seiden@linux.ibm.com> References: <20220203091935.2716-1-seiden@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 9ZFmDYAoF9kSrri2uxi9undLvteLMJsL X-Proofpoint-GUID: Ro2bPTz2yfeb5xoL6g1Ivpi4z4HbP818 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-03_02,2022-02-01_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 clxscore=1015 impostorscore=0 phishscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 bulkscore=0 priorityscore=1501 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202030056 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Some tests need the information provided by the QUI UVC and lib/s390x/uv.c already has cached the qui result. Let's add a function to avoid unnecessary QUI UVCs. Signed-off-by: Steffen Eiden --- lib/s390x/uv.c | 8 ++++++++ lib/s390x/uv.h | 1 + 2 files changed, 9 insertions(+) diff --git a/lib/s390x/uv.c b/lib/s390x/uv.c index 6fe11dff..602cbbfc 100644 --- a/lib/s390x/uv.c +++ b/lib/s390x/uv.c @@ -47,6 +47,14 @@ bool uv_query_test_call(unsigned int nr) return test_bit_inv(nr, uvcb_qui.inst_calls_list); } +const struct uv_cb_qui *uv_get_query_data(void) +{ + /* Query needs to be called first */ + assert(uvcb_qui.header.rc); + + return &uvcb_qui; +} + int uv_setup(void) { if (!test_facility(158)) diff --git a/lib/s390x/uv.h b/lib/s390x/uv.h index 8175d9c6..44264861 100644 --- a/lib/s390x/uv.h +++ b/lib/s390x/uv.h @@ -8,6 +8,7 @@ bool uv_os_is_guest(void); bool uv_os_is_host(void); bool uv_query_test_call(unsigned int nr); +const struct uv_cb_qui *uv_get_query_data(void); void uv_init(void); int uv_setup(void); void uv_create_guest(struct vm *vm); From patchwork Thu Feb 3 09:19:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steffen Eiden X-Patchwork-Id: 12733987 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56BE4C433F5 for ; Thu, 3 Feb 2022 09:19:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237572AbiBCJTx (ORCPT ); Thu, 3 Feb 2022 04:19:53 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:13500 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S237231AbiBCJTq (ORCPT ); Thu, 3 Feb 2022 04:19:46 -0500 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 2137807H029011; Thu, 3 Feb 2022 09:19:45 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=f1idZwrGhtomCKPDqR5MAoWzQwKDwoKGEoGt2Ape+9Y=; b=kCZioPF3zWcTAscIQ4LSF5Xj1bv4v572gB+CSceacBOSCo6Vt3Yi4uhdeYmVsP05KlLy nM9rhGpLgyKhgIJrGALeh7uJNbM3eg3cMjI2LdK9pjX4wbsR8+Ue8QkVTCKGqUrClzwz wY5P7MDNAQApA7dTupeiiQG35vmSoo10Xz2mG0ZG0i1CYuzm9JGYRxJ2POKFDbY0N7RP Ydtu/QXshZxferUy0Tj4bP5X4mI8hFlv9APus7MCjigpdEH6nWf5VF5Fu0MuY7RisUjm LVCNTexeuRSZjgaAfXdVwwa5V+LOrXdj/uA0wF4Dk3M5hkS3NCi2gRrCWAt4vA3Nb6Kb 0g== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3e00ufv4s0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 03 Feb 2022 09:19:45 +0000 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 2138g3aA006474; Thu, 3 Feb 2022 09:19:45 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0b-001b2d01.pphosted.com with ESMTP id 3e00ufv4rg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 03 Feb 2022 09:19:45 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2139IvWY015775; Thu, 3 Feb 2022 09:19:43 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma03ams.nl.ibm.com with ESMTP id 3dvw7a42rf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 03 Feb 2022 09:19:43 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2139Jdhm40632618 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 3 Feb 2022 09:19:40 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DAC545204F; Thu, 3 Feb 2022 09:19:39 +0000 (GMT) Received: from linux7.. (unknown [9.114.12.92]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 1A46152057; Thu, 3 Feb 2022 09:19:39 +0000 (GMT) From: Steffen Eiden To: Thomas Huth , Janosch Frank , Claudio Imbrenda , David Hildenbrand Cc: kvm@vger.kernel.org, linux-s390@vger.kernel.org Subject: [kvm-unit-tests PATCH v2 3/4] s390x: uv-guest: remove duplicated checks Date: Thu, 3 Feb 2022 09:19:34 +0000 Message-Id: <20220203091935.2716-4-seiden@linux.ibm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220203091935.2716-1-seiden@linux.ibm.com> References: <20220203091935.2716-1-seiden@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: GQiMIt4rKkflCFrtUFFwd4FYnMRfKKwz X-Proofpoint-ORIG-GUID: QChd0jbnAjqGFSWFaBBGjWXBH5E9IQgM X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-03_02,2022-02-01_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 phishscore=0 spamscore=0 lowpriorityscore=0 bulkscore=0 impostorscore=0 mlxscore=0 clxscore=1015 malwarescore=0 priorityscore=1501 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202030056 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Removing some tests which are done at other points in the code implicitly. In lib/s390x/uc.c#setup_uv(void) the rc of the qui result is verified using asserts. The whole test is fenced by lib/s390x/uc.c#os_is_guest(void) that checks if SET and REMOVE SHARED is present. Signed-off-by: Steffen Eiden Reviewed-by: Janosch Frank --- s390x/uv-guest.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/s390x/uv-guest.c b/s390x/uv-guest.c index 44ad2154..97ae4687 100644 --- a/s390x/uv-guest.c +++ b/s390x/uv-guest.c @@ -69,23 +69,15 @@ static void test_query(void) cc = uv_call(0, (u64)&uvcb); report(cc == 1 && uvcb.header.rc == UVC_RC_INV_LEN, "length"); - uvcb.header.len = sizeof(uvcb); - cc = uv_call(0, (u64)&uvcb); - report((!cc && uvcb.header.rc == UVC_RC_EXECUTED) || - (cc == 1 && uvcb.header.rc == 0x100), - "successful query"); - /* - * These bits have been introduced with the very first - * Ultravisor version and are expected to always be available - * because they are basic building blocks. + * BIT_UVC_CMD_QUI, BIT_UVC_CMD_SET_SHARED_ACCESS and + * BIT_UVC_CMD_SET_SHARED_ACCESS are always present as they + * have been introduced with the first Ultravisor version. + * However, we only need to check for QUI as + * SET/REMOVE SHARED are used to fence this test to be only + * executed by protected guests. */ - report(test_bit_inv(BIT_UVC_CMD_QUI, &uvcb.inst_calls_list[0]), - "query indicated"); - report(test_bit_inv(BIT_UVC_CMD_SET_SHARED_ACCESS, &uvcb.inst_calls_list[0]), - "share indicated"); - report(test_bit_inv(BIT_UVC_CMD_REMOVE_SHARED_ACCESS, &uvcb.inst_calls_list[0]), - "unshare indicated"); + report(uv_query_test_call(BIT_UVC_CMD_QUI), "query indicated"); report_prefix_pop(); } From patchwork Thu Feb 3 09:19:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steffen Eiden X-Patchwork-Id: 12733988 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71FB0C433FE for ; Thu, 3 Feb 2022 09:19:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343989AbiBCJTy (ORCPT ); Thu, 3 Feb 2022 04:19:54 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:5264 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240211AbiBCJTt (ORCPT ); Thu, 3 Feb 2022 04:19:49 -0500 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 21388DMe013013; Thu, 3 Feb 2022 09:19:49 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=fa5Hf/ZcIjEr1di9chVQMQiXrfOZLRD4dGJKN29yRf4=; b=JHdhsjS0hhl52+lnSva8GcK2zHb90lEqPDMy4jCEhyod1rX7BSocSb+rj3lFcgtHXc4t DZMAgIEktgCBlUIZGZLt0Fd04XI+vjNoRieBMkH2Ix9+S45ITjQr7xS7mmC+JcS5yXSa 1j3TwQKI1JJDR0PxVKV5+ow+DmuAftKKrfWveeCi+XNF4g54ddcxfnhkQFjJyykdH/Bx btXcc27o4XyqPeWbgrXaHsfh8J/QtrHL1XNEvO/bxO2OjCisLJpfThjAqlM2djRYAt8K gZBFnd1eZIaVy4iHkFOXvpEI3pe8YGiDtiabcwW8vVz9ksw/7TgSM66YDyaOsz/zpHyR gQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3dyvexjr1d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 03 Feb 2022 09:19:48 +0000 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 2139HtMO031095; Thu, 3 Feb 2022 09:19:48 GMT Received: from ppma06fra.de.ibm.com (48.49.7a9f.ip4.static.sl-reverse.com [159.122.73.72]) by mx0a-001b2d01.pphosted.com with ESMTP id 3dyvexjr0k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 03 Feb 2022 09:19:48 +0000 Received: from pps.filterd (ppma06fra.de.ibm.com [127.0.0.1]) by ppma06fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2139HNpJ010416; Thu, 3 Feb 2022 09:19:45 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma06fra.de.ibm.com with ESMTP id 3dvvujjf6n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 03 Feb 2022 09:19:45 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2139Jet645875690 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 3 Feb 2022 09:19:41 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C68A95204F; Thu, 3 Feb 2022 09:19:40 +0000 (GMT) Received: from linux7.. (unknown [9.114.12.92]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 062255204E; Thu, 3 Feb 2022 09:19:39 +0000 (GMT) From: Steffen Eiden To: Thomas Huth , Janosch Frank , Claudio Imbrenda , David Hildenbrand Cc: kvm@vger.kernel.org, linux-s390@vger.kernel.org Subject: [kvm-unit-tests PATCH v2 4/4] s390x: uv-guest: Add attestation tests Date: Thu, 3 Feb 2022 09:19:35 +0000 Message-Id: <20220203091935.2716-5-seiden@linux.ibm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220203091935.2716-1-seiden@linux.ibm.com> References: <20220203091935.2716-1-seiden@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: a74luRjzQDv1elCcp3hDjmD7c1SD13Nt X-Proofpoint-GUID: OnRJPqEQXuRkDwj3chknRaz8krIhltS4 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-03_02,2022-02-01_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 clxscore=1015 impostorscore=0 phishscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 bulkscore=0 priorityscore=1501 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202030056 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Adds several tests to verify correct error paths of attestation. Signed-off-by: Steffen Eiden --- lib/s390x/asm/uv.h | 5 +- s390x/uv-guest.c | 174 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 177 insertions(+), 2 deletions(-) diff --git a/lib/s390x/asm/uv.h b/lib/s390x/asm/uv.h index 7afbcffd..7fe55052 100644 --- a/lib/s390x/asm/uv.h +++ b/lib/s390x/asm/uv.h @@ -108,7 +108,10 @@ struct uv_cb_qui { u8 reserved88[158 - 136]; /* 0x0088 */ uint16_t max_guest_cpus; /* 0x009e */ u64 uv_feature_indications; /* 0x00a0 */ - u8 reserveda8[200 - 168]; /* 0x00a8 */ + u8 reserveda8[224 - 168]; /* 0x00a8 */ + u64 supported_att_hdr_versions; /* 0x00e0 */ + u64 supported_paf; /* 0x00e8 */ + u8 reservedf0[256 - 240]; /* 0x00f0 */ } __attribute__((packed)) __attribute__((aligned(8))); struct uv_cb_cgc { diff --git a/s390x/uv-guest.c b/s390x/uv-guest.c index 97ae4687..3fca9d21 100644 --- a/s390x/uv-guest.c +++ b/s390x/uv-guest.c @@ -2,10 +2,11 @@ /* * Guest Ultravisor Call tests * - * Copyright (c) 2020 IBM Corp + * Copyright IBM Corp. 2020, 2022 * * Authors: * Janosch Frank + * Steffen Eiden */ #include @@ -53,6 +54,15 @@ static void test_priv(void) check_pgm_int_code(PGM_INT_CODE_PRIVILEGED_OPERATION); report_prefix_pop(); + report_prefix_push("attest"); + uvcb.cmd = UVC_CMD_ATTESTATION; + uvcb.len = sizeof(struct uv_cb_attest); + expect_pgm_int(); + enter_pstate(); + uv_call_once(0, (u64)&uvcb); + check_pgm_int_code(PGM_INT_CODE_PRIVILEGED_OPERATION); + report_prefix_pop(); + report_prefix_pop(); } @@ -111,7 +121,168 @@ static void test_sharing(void) cc = uv_call(0, (u64)&uvcb); report(cc == 0 && uvcb.header.rc == UVC_RC_EXECUTED, "unshare"); report_prefix_pop(); +} + +#define ARCB_VERSION_1 0x0100 +#define ARCB_HMAC_SHA512 1 +/* arcb with one key slot and no nonce */ +struct uv_arcb_v1 { + uint64_t reserved0; /* 0x0000 */ + uint32_t req_ver; /* 0x0008 */ + uint32_t req_len; /* 0x000c */ + uint8_t iv[12]; /* 0x0010 */ + uint32_t reserved1c; /* 0x001c */ + uint8_t reserved20[7]; /* 0x0020 */ + uint8_t nks; /* 0x0027 */ + uint32_t reserved28; /* 0x0028 */ + uint32_t sea; /* 0x002c */ + uint64_t plaint_att_flags; /* 0x0030 */ + uint32_t meas_alg_id; /* 0x0038 */ + uint32_t reserved3c; /* 0x003c */ + uint8_t cpk[160]; /* 0x0040 */ + uint8_t key_slot[80]; /* 0x00e0 */ + uint8_t meas_key[64]; /* 0x0130 */ + uint8_t tag[16]; /* 0x0170 */ +} __attribute__((packed)); + +static void test_attest_v1(u64 supported_paf) +{ + struct uv_cb_attest uvcb = { + .header.cmd = UVC_CMD_ATTESTATION, + .header.len = sizeof(uvcb), + }; + struct uv_arcb_v1 *arcb = (void *)page; + uint64_t measurement = page + sizeof(*arcb); + size_t measurement_size = 64; + uint64_t additional = measurement + measurement_size; + size_t additional_size = 32; + uint64_t plaint_att_flags = 1ULL << 61; + int cc; + + memset((void *) page, 0, PAGE_SIZE); + + /* create a minimal arcb/uvcb such that FW has everything to start unsealing the request. */ + arcb->req_ver = ARCB_VERSION_1; + arcb->req_len = sizeof(*arcb); + arcb->nks = 1; + arcb->sea = sizeof(arcb->meas_key); + arcb->plaint_att_flags = plaint_att_flags; + arcb->meas_alg_id = ARCB_HMAC_SHA512; + uvcb.arcb_addr = page; + uvcb.measurement_address = measurement; + uvcb.measurement_length = measurement_size; + uvcb.add_data_address = additional; + uvcb.add_data_length = additional_size; + + uvcb.continuation_token = 0xff; + cc = uv_call(0, (u64)&uvcb); + report(cc == 1 && uvcb.header.rc == 0x0101, "invalid continuation token"); + uvcb.continuation_token = 0; + + uvcb.user_data_length = sizeof(uvcb.user_data) + 1; + cc = uv_call(0, (u64)&uvcb); + report(cc == 1 && uvcb.header.rc == 0x0102, "invalid user data size"); + uvcb.user_data_length = 0; + + uvcb.arcb_addr = 0; + cc = uv_call(0, (u64)&uvcb); + report(cc == 1 && uvcb.header.rc == 0x0103, "invalid address arcb"); + uvcb.arcb_addr = page; + + /* 0104 - 0105 need an unseal-able request */ + + /* version 0000 is an illegal version number */ + arcb->req_ver = 0x0000; + cc = uv_call(0, (u64)&uvcb); + report(cc == 1 && uvcb.header.rc == 0x0106, "unsupported version"); + arcb->req_ver = ARCB_VERSION_1; + + arcb->req_len += 1; + cc = uv_call(0, (u64)&uvcb); + report(cc == 1 && uvcb.header.rc == 0x0107, "invalid arcb size 1"); + arcb->req_len -= 1; + arcb->nks = 2; + cc = uv_call(0, (u64)&uvcb); + report(cc == 1 && uvcb.header.rc == 0x0107, "invalid arcb size 2"); + arcb->nks = 1; + + arcb->nks = 0; + cc = uv_call(0, (u64)&uvcb); + report(cc == 1 && uvcb.header.rc == 0x0108, "invalid num key slots"); + arcb->nks = 1; + + /* possible valid size (when using nonce). However, req_len too small to host a nonce */ + arcb->sea = 80; + cc = uv_call(0, (u64)&uvcb); + report(cc == 1 && uvcb.header.rc == 0x0109, "invalid encrypted size 1"); + arcb->sea = 17; + cc = uv_call(0, (u64)&uvcb); + report(cc == 1 && uvcb.header.rc == 0x0109, "invalid encrypted size 2"); + arcb->sea = 64; + + arcb->plaint_att_flags = supported_paf ^ ((u64) -1); + cc = uv_call(0, (u64)&uvcb); + report(cc == 1 && uvcb.header.rc == 0x010a, "invalid flag"); + arcb->plaint_att_flags = plaint_att_flags; + + /* reserved value */ + arcb->meas_alg_id = 0; + cc = uv_call(0, (u64)&uvcb); + report(cc == 1 && uvcb.header.rc == 0x010b, "invalid measurement algorithm"); + arcb->meas_alg_id = ARCB_HMAC_SHA512; + + cc = uv_call(0, (u64)&uvcb); + report(cc == 1 && uvcb.header.rc == 0x010c, "unable unseal"); + uvcb.measurement_length = 0; + cc = uv_call(0, (u64)&uvcb); + report(cc == 1 && uvcb.header.rc == 0x010d, "invalid measurement size"); + uvcb.measurement_length = measurement_size; + + uvcb.add_data_length = 0; + cc = uv_call(0, (u64)&uvcb); + report(cc == 1 && uvcb.header.rc == 0x010e, "invalid additional size"); + uvcb.add_data_length = additional_size; +} + +static void test_attest(void) +{ + struct uv_cb_attest uvcb = { + .header.cmd = UVC_CMD_ATTESTATION, + .header.len = sizeof(uvcb), + }; + const struct uv_cb_qui *uvcb_qui = uv_get_query_data(); + int cc; + + report_prefix_push("attest"); + + if (!uv_query_test_call(BIT_UVC_CMD_ATTESTATION)) { + report_skip("Attestation not supported."); + goto done; + } + + /* Verify that the uv supports at least one header version */ + report(uvcb_qui->supported_att_hdr_versions, "has hdr support"); + + memset((void *) page, 0, PAGE_SIZE); + + uvcb.header.len -= 1; + cc = uv_call(0, (u64)&uvcb); + report(cc && uvcb.header.rc == UVC_RC_INV_LEN, "invalid uvcb size 1"); + uvcb.header.len += 1; + + uvcb.header.len += 1; + cc = uv_call(0, (u64)&uvcb); + report(cc && uvcb.header.rc == UVC_RC_INV_LEN, "invalid uvcb size 2"); + uvcb.header.len -= 1; + + report_prefix_push("v1"); + if (test_bit_inv(0, &uvcb_qui->supported_att_hdr_versions)) + test_attest_v1(uvcb_qui->supported_paf); + else + report_skip("Attestation version 1 not supported"); + report_prefix_pop(); +done: report_prefix_pop(); } @@ -179,6 +350,7 @@ int main(void) test_invalid(); test_query(); test_sharing(); + test_attest(); free_page((void *)page); done: report_prefix_pop();