Received: by 10.213.65.68 with SMTP id h4csp1097220imn; Wed, 14 Mar 2018 09:30:54 -0700 (PDT) X-Google-Smtp-Source: AG47ELuwKUfcPEwzt0NN3Ne6lSdCi5PzlxgDaW/n/g1bBFtvsrVd2P+m3hWeDdfAdn/f9zyOyCRI X-Received: by 2002:a17:902:a614:: with SMTP id u20-v6mr4643182plq.249.1521045054520; Wed, 14 Mar 2018 09:30:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521045054; cv=none; d=google.com; s=arc-20160816; b=vTO94QaFdWqupDThMZ1AnXoYmePAVdsQq5nbdkjXpq88ChMLGpZRbA55Zy5g8sdvK/ yPNA98pDiyLdDtsimochlzoClDbP/FBwuwBVx0GKE9/8ChnpIQLXP7p+mJwRsVRGw7P5 M/qGprldBmM82Zu5uqMEzDoRilBavWhQJAW+VdOQIm+7o5GBE0f1iJCUwPMct1jee8gs KCiRjv63tgo1SFoXO1cJ3vs+YFUDGvJ0/gB+KxrdbzADuXuKt5ENjvBzLqrAHmWVCKj5 wipmtx7t9QGY0dRooLsX5PyQXtU8vjAYouO4db7SOP1qkQIhJODViR7f6HyDgzO4EqvU hM8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :from:references:cc:to:subject:arc-authentication-results; bh=dSc/m4EA7pTRUbXyWEh+cS84aEEyoiZO/JD3DbkTuDI=; b=bUPq9GNJ7ppEP8fVjOuNjCmzVGHd85aAw8tDDAgt4DRfscG5yQYykADxc4cCNVGeJ5 CUD2R23lnMgUg7G7U7InAKEZ4s7MQsYGRMYSRncsvoDvkNHT7zqK0G8EmzPzgrx5pWkm kGPpZ9KnUtleoDQYS/njIYShCNgslz/N2XbF1N5swagR3vdAvAyZXxBajFlAJvl1TY0C UjCczusqYa/t/LUiPyx1p4YazxxFy5evs8UoMOQFiKfL05u8+T2iO+uQp+H1ZKkWKukE SIabg9zQlEYxhatc/Kc4LQdBVENt4CsekppYtVy+CkmthNxt+nc7Nx2UIYMdrd1W0WSS q01A== 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 p11si2333089pfl.127.2018.03.14.09.30.39; Wed, 14 Mar 2018 09:30:54 -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 S1751449AbeCNQ3m (ORCPT + 99 others); Wed, 14 Mar 2018 12:29:42 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:55734 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750998AbeCNQ3j (ORCPT ); Wed, 14 Mar 2018 12:29:39 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2EGPrK4093560 for ; Wed, 14 Mar 2018 12:29:39 -0400 Received: from e16.ny.us.ibm.com (e16.ny.us.ibm.com [129.33.205.206]) by mx0b-001b2d01.pphosted.com with ESMTP id 2gq5awp6jp-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Wed, 14 Mar 2018 12:29:38 -0400 Received: from localhost by e16.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 14 Mar 2018 12:29:38 -0400 Received: from b01cxnp22036.gho.pok.ibm.com (9.57.198.26) by e16.ny.us.ibm.com (146.89.104.203) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 14 Mar 2018 12:29:34 -0400 Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w2EGTWgK56950802; Wed, 14 Mar 2018 16:29:32 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1C0F8124037; Wed, 14 Mar 2018 13:31:44 -0400 (EDT) Received: from oc8043147753.ibm.com (unknown [9.85.151.171]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP id 586EA124044; Wed, 14 Mar 2018 13:31:42 -0400 (EDT) Subject: Re: [PATCH v2 08/15] KVM: s390: interface to enable AP execution mode To: David Hildenbrand , 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 References: <1519741693-17440-1-git-send-email-akrowiak@linux.vnet.ibm.com> <1519741693-17440-9-git-send-email-akrowiak@linux.vnet.ibm.com> <532c0f98-83d0-c687-55d6-a6c5cb263360@redhat.com> From: Tony Krowiak Date: Wed, 14 Mar 2018 12:29:30 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-TM-AS-GCONF: 00 x-cbid: 18031416-0024-0000-0000-000003367693 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008673; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000254; SDB=6.01002986; UDB=6.00510400; IPR=6.00782316; MB=3.00020033; MTD=3.00000008; XFM=3.00000015; UTC=2018-03-14 16:29:36 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18031416-0025-0000-0000-000047538DBC Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-03-14_08:,, 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-1803140185 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/01/2018 04:35 AM, David Hildenbrand wrote: > On 28.02.2018 21:39, Tony Krowiak wrote: >> On 02/28/2018 04:44 AM, David Hildenbrand wrote: >>> On 27.02.2018 15:28, Tony Krowiak wrote: >>>> Introduces a new interface to enable AP interpretive >>>> execution (IE) mode for the KVM guest. When running >>>> with IE mode enabled, AP instructions executed on the >>>> KVM guest will be interpreted by the firmware and >>>> passed directly through to an AP device installed on >>>> the system. The CPU model feature for AP must >>>> be enabled for the KVM guest in order to enable >>>> interpretive execution mode. >>>> >>>> This interface will be used in a subsequent patch >>>> by the VFIO AP device driver. >>>> >>>> Signed-off-by: Tony Krowiak >>>> --- >>>> arch/s390/include/asm/kvm-ap.h | 2 ++ >>>> arch/s390/include/asm/kvm_host.h | 1 + >>>> arch/s390/kvm/kvm-ap.c | 27 +++++++++++++++++++++++++++ >>>> arch/s390/kvm/kvm-s390.h | 1 + >>>> 4 files changed, 31 insertions(+), 0 deletions(-) >>>> >>>> diff --git a/arch/s390/include/asm/kvm-ap.h b/arch/s390/include/asm/kvm-ap.h >>>> index 46e7c5b..6bd6bfb 100644 >>>> --- a/arch/s390/include/asm/kvm-ap.h >>>> +++ b/arch/s390/include/asm/kvm-ap.h >>>> @@ -51,4 +51,6 @@ struct kvm_ap_matrix { >>>> >>>> void kvm_ap_deconfigure_matrix(struct kvm *kvm); >>>> >>>> +int kvm_ap_enable_ie_mode(struct kvm *kvm); >>>> + >>>> #endif /* _ASM_KVM_AP */ >>>> diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h >>>> index a4c77d3..1eebdd6 100644 >>>> --- a/arch/s390/include/asm/kvm_host.h >>>> +++ b/arch/s390/include/asm/kvm_host.h >>>> @@ -186,6 +186,7 @@ struct kvm_s390_sie_block { >>>> #define ECA_AIV 0x00200000 >>>> #define ECA_VX 0x00020000 >>>> #define ECA_PROTEXCI 0x00002000 >>>> +#define ECA_APIE 0x00000008 >>>> #define ECA_SII 0x00000001 >>>> __u32 eca; /* 0x004c */ >>>> #define ICPT_INST 0x04 >>>> diff --git a/arch/s390/kvm/kvm-ap.c b/arch/s390/kvm/kvm-ap.c >>>> index bb29045..862e54b 100644 >>>> --- a/arch/s390/kvm/kvm-ap.c >>>> +++ b/arch/s390/kvm/kvm-ap.c >>>> @@ -307,3 +307,30 @@ void kvm_ap_deconfigure_matrix(struct kvm *kvm) >>>> kvm_ap_clear_crycb_masks(kvm); >>>> } >>>> EXPORT_SYMBOL(kvm_ap_deconfigure_matrix); >>>> + >>>> +/** >>>> + * kvm_ap_enable_ie_mode >>>> + * >>>> + * Enable interpretrive execution of AP instructions for the guest. When >>>> + * enabled, AP instructions executed on the guest will be interpreted and >>>> + * passed through to an AP installed on the host system. >>>> + * >>>> + * Returns 0 if interpretrive execution is enabled. Returns -EOPNOTSUPP >>>> + * if AP facilities are not installed for the guest. >>>> + * >>>> + * @kvm: the guest's kvm structure >>>> + */ >>>> +int kvm_ap_enable_ie_mode(struct kvm *kvm) >>>> +{ >>>> + int i; >>>> + struct kvm_vcpu *vcpu; >>>> + >>>> + if (!test_kvm_cpu_feat(kvm, KVM_S390_VM_CPU_FEAT_AP)) >>>> + return -EOPNOTSUPP; >>>> + >>>> + kvm_for_each_vcpu(i, vcpu, kvm) >>>> + vcpu->arch.sie_block->eca |= ECA_APIE; >>>> + >>>> + return 0; >>>> +} >>>> +EXPORT_SYMBOL(kvm_ap_enable_ie_mode); >>>> diff --git a/arch/s390/kvm/kvm-s390.h b/arch/s390/kvm/kvm-s390.h >>>> index 1b5621f..3142541 100644 >>>> --- a/arch/s390/kvm/kvm-s390.h >>>> +++ b/arch/s390/kvm/kvm-s390.h >>>> @@ -18,6 +18,7 @@ >>>> #include >>>> #include >>>> #include >>>> +#include >>>> >>>> /* Transactional Memory Execution related macros */ >>>> #define IS_TE_ENABLED(vcpu) ((vcpu->arch.sie_block->ecb & ECB_TE)) >>>> >>> And also, what about hot-plugged CPUs? >> I haven't considered that, do you have any suggestions? > You should handle the KVM_S390_VM_CPU_FEAT_AP feature instead during > kvm_arch_vcpu_setup(), independent of any configured AP devices. > > This avoids the races I mentioned in regards to this series and also > will handle hotplugged CPUs properly. > > If KVM_S390_VM_CPU_FEAT_AP is configured for a guest -> each CPU sets > ECA_APIE during kvm_arch_vcpu_setup(). > > > (In the vSIE code, simply allow to set ECA_APIE in the shadow SCB in > case KVM_S390_VM_CPU_FEAT_AP is enabled) Patch series v3 will be posted very shortly, but I thought I'd give you a heads up concerning what is forthcoming with regard to ECA_APIE. I'm adding a device attribute to the KVM_S390_VM_CRYPTO group for setting a flag via the KVM_SET_DEVICE_ATTR ioctl. The flag indicates whether ECA_APIE should be set or not. The flag will be checked in the test_kvm_cpu_feat() function and set or clear ECA_APIE accordingly. You can comment on this in the v3 patch. >