Received: by 10.223.185.116 with SMTP id b49csp5017099wrg; Tue, 27 Feb 2018 06:33:37 -0800 (PST) X-Google-Smtp-Source: AH8x227pheZaT51tTPfxRg8yxDDFoyTSK3bBAHnfjyz0a3cRDkBr3P2LS06toJNNe+ElCWz54F8r X-Received: by 2002:a17:902:9686:: with SMTP id n6-v6mr14286173plp.333.1519742016990; Tue, 27 Feb 2018 06:33:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519742016; cv=none; d=google.com; s=arc-20160816; b=eVFdusLup+d0h9H5Tc4lGWHSLsr/eW8uZFEGjjbwwSRtNR+LaaMCXr0Gw1MXYnRyGk VEhDbANGxcH68s3j+iz9tXLcFI5E3esDilb0bYfL+uPboXL4GZzjxQJQvT3M4sTmJBK1 xvGWI4hHXfxB3CgYEodyavMPGD3lmdv6BACEQVdvTHNlXGzkbxl/AacnxR7jptj6mILY M6fnTyxLxEHzeWQe8RNROuWfB6d+DsNIKEypLh5ou8pwWrXFHo9dLitf16BX+JD9j2/V x+m0+m7hqyKpjtwIfAhuHN4FWAyM954uKs44x0lRwyK2F13Qd6wgjU5lJM1E7KxSyUPx Zqwg== 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=0SjCeQHDTAuxMAUHVbuYdDD59hd8oSuOFMytMQwar7M=; b=bM39NiGxA0l5waWSMY7lCmY2TSb38yuvpyWSod1s9N4Lf8y0kJjehQYUL3re2Xx78v EUIDuiHelRi57BhrEFYCCHJYLNkIY0hC3MhTVLBTC5BXIefCyukJDmF4ATk+fNmcwlOL CoXyVp9NlHwEyFYjCHDnaeRmHNfEJ3Bz+Wpv4qDCd6KyMvd84l2Mg+ddx1FlVGgGZKH9 yXX4WHuWyZkuzGVsqMzTQn8hLvkL/rKVkSwhgPsxsv7rNmYkyYhEQF3Tuv92u9iGdScN w2lOui5406OBYVC2xegKhcsEExAkjOfjnoAQx+1D5q5I3kZURkjJySsMVqSfNPqaQgq9 iKXQ== 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 h34-v6si8632622pld.761.2018.02.27.06.33.22; Tue, 27 Feb 2018 06:33:36 -0800 (PST) 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 S1753930AbeB0OcO (ORCPT + 99 others); Tue, 27 Feb 2018 09:32:14 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:58734 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753179AbeB0OcM (ORCPT ); Tue, 27 Feb 2018 09:32:12 -0500 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w1REUeqJ118903 for ; Tue, 27 Feb 2018 09:32:12 -0500 Received: from e33.co.us.ibm.com (e33.co.us.ibm.com [32.97.110.151]) by mx0a-001b2d01.pphosted.com with ESMTP id 2gd923g7t2-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 27 Feb 2018 09:31:59 -0500 Received: from localhost by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 27 Feb 2018 07:28:39 -0700 Received: from b03cxnp08025.gho.boulder.ibm.com (9.17.130.17) by e33.co.us.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 27 Feb 2018 07:28:35 -0700 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w1RESYqg13631916; Tue, 27 Feb 2018 07:28:34 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 74B6D78041; Tue, 27 Feb 2018 07:28:34 -0700 (MST) Received: from localhost.localdomain (unknown [9.60.75.238]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTPS id 9C4FA78038; Tue, 27 Feb 2018 07:28:32 -0700 (MST) 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, fiuczy@linux.vnet.ibm.com, buendgen@de.ibm.com, Tony Krowiak Subject: [PATCH v2 04/15] KVM: s390: CPU model support for AP virtualization Date: Tue, 27 Feb 2018 09:28:02 -0500 X-Mailer: git-send-email 1.7.1 In-Reply-To: <1519741693-17440-1-git-send-email-akrowiak@linux.vnet.ibm.com> References: <1519741693-17440-1-git-send-email-akrowiak@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18022714-0008-0000-0000-000009621B7C X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008601; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000254; SDB=6.00995862; UDB=6.00506230; IPR=6.00775186; MB=3.00019761; MTD=3.00000008; XFM=3.00000015; UTC=2018-02-27 14:28:38 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18022714-0009-0000-0000-00004631078A Message-Id: <1519741693-17440-5-git-send-email-akrowiak@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-02-27_05:,, 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-1802270183 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduces a new CPU model feature and two CPU model facilities to support AP virtualization for KVM guests. CPU model feature: The KVM_S390_VM_CPU_FEAT_AP feature indicates that the AP facilities are installed on the KVM guest. This feature will be enabled by the kernel only if the AP facilities are installed on the linux host. This feature must be specifically turned on for the KVM guest from userspace to allow guest access to AP devices installed on the linux host. CPU model facilities: 1. AP Query Configuration Information (QCI) facility is installed. This is indicated by setting facilities bit 12 for the guest. The kernel will not enable this facility for the guest if it is not set on the host. This facility must not be set by userspace if the KVM_S390_VM_CPU_FEAT_AP feature is not installed. 2. AP Facilities Test facility (APFT) is installed. This is indicated by setting facilities bit 15 for the guest. The kernel will not enable this facility for the guest if it is not set on the host. This facility must not be set by userspace if the KVM_S390_VM_CPU_FEAT_AP feature is not installed. Reviewed-by: Christian Borntraeger Reviewed-by: Halil Pasic Signed-off-by: Tony Krowiak --- arch/s390/include/uapi/asm/kvm.h | 1 + arch/s390/kvm/kvm-s390.c | 4 ++++ arch/s390/tools/gen_facilities.c | 2 ++ 3 files changed, 7 insertions(+), 0 deletions(-) diff --git a/arch/s390/include/uapi/asm/kvm.h b/arch/s390/include/uapi/asm/kvm.h index 4cdaa55..a580dec 100644 --- a/arch/s390/include/uapi/asm/kvm.h +++ b/arch/s390/include/uapi/asm/kvm.h @@ -130,6 +130,7 @@ struct kvm_s390_vm_cpu_machine { #define KVM_S390_VM_CPU_FEAT_PFMFI 11 #define KVM_S390_VM_CPU_FEAT_SIGPIF 12 #define KVM_S390_VM_CPU_FEAT_KSS 13 +#define KVM_S390_VM_CPU_FEAT_AP 14 struct kvm_s390_vm_cpu_feat { __u64 feat[16]; }; diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index de1e299..c68ca86 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -347,6 +347,10 @@ static void kvm_s390_cpu_feat_init(void) if (MACHINE_HAS_ESOP) allow_cpu_feat(KVM_S390_VM_CPU_FEAT_ESOP); + + if (ap_instructions_installed()) /* AP instructions installed on host */ + allow_cpu_feat(KVM_S390_VM_CPU_FEAT_AP); + /* * We need SIE support, ESOP (PROT_READ protection for gmap_shadow), * 64bit SCAO (SCA passthrough) and IDTE (for gmap_shadow unshadowing). diff --git a/arch/s390/tools/gen_facilities.c b/arch/s390/tools/gen_facilities.c index 90a8c9e..a52290b 100644 --- a/arch/s390/tools/gen_facilities.c +++ b/arch/s390/tools/gen_facilities.c @@ -106,6 +106,8 @@ struct facility_def { .name = "FACILITIES_KVM_CPUMODEL", .bits = (int[]){ + 12, /* AP Query Configuration Information */ + 15, /* AP Facilities Test */ -1 /* END */ } }, -- 1.7.1