Received: by 10.192.165.156 with SMTP id m28csp2994597imm; Sun, 15 Apr 2018 14:28:37 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/8WjShgsk5U3G/6tCnSJGU/Xx5za+2zE2bk1Na1VkF13WDQaYjS11VU6HjJBmF0HBy3gyL X-Received: by 10.98.102.79 with SMTP id a76mr19189114pfc.162.1523827717241; Sun, 15 Apr 2018 14:28:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523827717; cv=none; d=google.com; s=arc-20160816; b=cJiO3QF13XgsFiq5exkdYM9o3rmicBsGFNxIguL64S2iUriNgoAcFximrWS01yEj9d Yv5iUJTu0fX+pepzCyGo5Vqs/lkEmB0mPrUGN6rKGUGbrF3Uz8FOQgeI9ucVcc8wylcJ /qrlG0ApuFU1nnhbnx8Aw661qz8Kme6ox26juI6lJ3IXGO6l6vx0UO0QnkXogdMBvVbO +PtrgAYkZJ5/HQKh1ZdinVG9lHx9MBTioJBwDZOxAq9MU/OPDuzwOweqzD/DjYQlKuTN M7aAm0bxLtctZEeRG/XNyzW8fhnI/keTP9Nxv2tbQpapph2eEmiukg+OqVTtNJplTwuX vhSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:references:in-reply-to:date :subject:cc:to:from:arc-authentication-results; bh=d96zgbqN7ytpJ+3YGqxGYviF6XO7pBfQspdYkPyiFqc=; b=e5rZskuraHeKWAmdqYEorUbZ7QcMiYag1gJPQ4+cHgPYmk1nwUuLsBioikMv337x9c gTU8S3DaapjESr90QO1w1VY04WAPIKV/ejBRi/H+Fm2Utja2isPKnalCxpTWB6SaU73U fir6F/LLTHZterUy04LFLC9BZ1sWtvsbYUMYBM7DWikZormUKgQzUkUlRQzzOcwZcvgW 0NuBkWUeh0TcgCrtoHchC8Au/41lMNcBGXCLPLT5ywd5G1T8cPUGkcRd6LAo8biUmbHa nQfowUINMRqJB0Ojbxi5erQqcnHzb6XbiYJa8GdxXli65WgKUYoWT4x2zZsLJhlge361 +vhQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z18-v6si3449222plo.241.2018.04.15.14.28.23; Sun, 15 Apr 2018 14:28:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753025AbeDOVWk (ORCPT + 99 others); Sun, 15 Apr 2018 17:22:40 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:57310 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752944AbeDOVWh (ORCPT ); Sun, 15 Apr 2018 17:22:37 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w3FLJbPH004420 for ; Sun, 15 Apr 2018 17:22:37 -0400 Received: from e11.ny.us.ibm.com (e11.ny.us.ibm.com [129.33.205.201]) by mx0a-001b2d01.pphosted.com with ESMTP id 2hbxyyhmxf-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Sun, 15 Apr 2018 17:22:36 -0400 Received: from localhost by e11.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sun, 15 Apr 2018 17:22:35 -0400 Received: from b01cxnp22033.gho.pok.ibm.com (9.57.198.23) by e11.ny.us.ibm.com (146.89.104.198) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Sun, 15 Apr 2018 17:22:32 -0400 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w3FLMVOX45940746; Sun, 15 Apr 2018 21:22:31 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 65236AE03B; Sun, 15 Apr 2018 17:24:17 -0400 (EDT) Received: from localhost.localdomain (unknown [9.85.139.141]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTPS id 62DE8AE034; Sun, 15 Apr 2018 17:24:16 -0400 (EDT) From: Tony Krowiak To: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: freude@de.ibm.com, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, borntraeger@de.ibm.com, cohuck@redhat.com, kwankhede@nvidia.com, bjsdjshi@linux.vnet.ibm.com, pbonzini@redhat.com, alex.williamson@redhat.com, pmorel@linux.vnet.ibm.com, alifm@linux.vnet.ibm.com, mjrosato@linux.vnet.ibm.com, jjherne@linux.vnet.ibm.com, thuth@redhat.com, pasic@linux.vnet.ibm.com, berrange@redhat.com, fiuczy@linux.vnet.ibm.com, buendgen@de.ibm.com, akrowiak@linux.vnet.ibm.com Subject: [PATCH v4 01/15] s390: zcrypt: externalize AP instructions available function Date: Sun, 15 Apr 2018 17:22:11 -0400 X-Mailer: git-send-email 1.7.1 In-Reply-To: <1523827345-11600-1-git-send-email-akrowiak@linux.vnet.ibm.com> References: <1523827345-11600-1-git-send-email-akrowiak@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18041521-2213-0000-0000-000002920E50 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008862; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000257; SDB=6.01018429; UDB=6.00519481; IPR=6.00797666; MB=3.00020592; MTD=3.00000008; XFM=3.00000015; UTC=2018-04-15 21:22:35 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18041521-2214-0000-0000-000059C49247 Message-Id: <1523827345-11600-2-git-send-email-akrowiak@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-04-15_10:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1804150214 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the AP instructions are not available on the linux host, then AP devices can not be interpreted by the SIE. The AP bus has a function it uses to determine if the AP instructions are available. This patch provides a new function that wraps the AP bus's function to externalize it for use by KVM. Signed-off-by: Tony Krowiak Reviewed-by: Pierre Morel Reviewed-by: Harald Freudenberger --- arch/s390/include/asm/ap.h | 7 +++++++ arch/s390/include/asm/kvm-ap.h | 23 +++++++++++++++++++++++ arch/s390/kvm/Makefile | 2 +- arch/s390/kvm/kvm-ap.c | 21 +++++++++++++++++++++ drivers/s390/crypto/ap_bus.c | 6 ++++++ 5 files changed, 58 insertions(+), 1 deletions(-) create mode 100644 arch/s390/include/asm/kvm-ap.h create mode 100644 arch/s390/kvm/kvm-ap.c diff --git a/arch/s390/include/asm/ap.h b/arch/s390/include/asm/ap.h index c1bedb4..7773bfd 100644 --- a/arch/s390/include/asm/ap.h +++ b/arch/s390/include/asm/ap.h @@ -120,4 +120,11 @@ struct ap_queue_status ap_queue_irq_ctrl(ap_qid_t qid, struct ap_qirq_ctrl qirqctrl, void *ind); +/** + * ap_instructions_installed() - Tests whether AP instructions are installed + * + * Returns 1 if the AP instructions are installed, otherwise; returns 0 + */ +int ap_instructions_installed(void); + #endif /* _ASM_S390_AP_H_ */ diff --git a/arch/s390/include/asm/kvm-ap.h b/arch/s390/include/asm/kvm-ap.h new file mode 100644 index 0000000..84412a9 --- /dev/null +++ b/arch/s390/include/asm/kvm-ap.h @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Adjunct Processor (AP) configuration management for KVM guests + * + * Copyright IBM Corp. 2018 + * + * Author(s): Tony Krowiak + */ + +#ifndef _ASM_KVM_AP +#define _ASM_KVM_AP + +/** + * kvm_ap_instructions_installed() + * + * Tests whether AP instructions are installed on the linux host + * + * Returns 1 if the AP instructions are installed on the host, otherwise; + * returns 0 + */ +int kvm_ap_instructions_installed(void); + +#endif /* _ASM_KVM_AP */ diff --git a/arch/s390/kvm/Makefile b/arch/s390/kvm/Makefile index 05ee90a..1876bfe 100644 --- a/arch/s390/kvm/Makefile +++ b/arch/s390/kvm/Makefile @@ -9,6 +9,6 @@ common-objs = $(KVM)/kvm_main.o $(KVM)/eventfd.o $(KVM)/async_pf.o $(KVM)/irqch ccflags-y := -Ivirt/kvm -Iarch/s390/kvm kvm-objs := $(common-objs) kvm-s390.o intercept.o interrupt.o priv.o sigp.o -kvm-objs += diag.o gaccess.o guestdbg.o vsie.o +kvm-objs += diag.o gaccess.o guestdbg.o vsie.o kvm-ap.o obj-$(CONFIG_KVM) += kvm.o diff --git a/arch/s390/kvm/kvm-ap.c b/arch/s390/kvm/kvm-ap.c new file mode 100644 index 0000000..1267588 --- /dev/null +++ b/arch/s390/kvm/kvm-ap.c @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Adjunct Processor (AP) configuration management for KVM guests + * + * Copyright IBM Corp. 2018 + * + * Author(s): Tony Krowiak + */ +#include +#include +#include + +int kvm_ap_instructions_installed(void) +{ +#ifdef CONFIG_ZCRYPT + return ap_instructions_installed(); +#else + return 0; +#endif +} +EXPORT_SYMBOL(kvm_ap_instructions_installed); diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c index 35a0c2b..9d108b6 100644 --- a/drivers/s390/crypto/ap_bus.c +++ b/drivers/s390/crypto/ap_bus.c @@ -210,6 +210,12 @@ int ap_query_configuration(struct ap_config_info *info) } EXPORT_SYMBOL(ap_query_configuration); +int ap_instructions_installed(void) +{ + return (ap_instructions_available() == 0); +} +EXPORT_SYMBOL(ap_instructions_installed); + /** * ap_init_configuration(): Allocate and query configuration array. */ -- 1.7.1