Received: by 10.223.185.116 with SMTP id b49csp7214064wrg; Thu, 1 Mar 2018 01:37:32 -0800 (PST) X-Google-Smtp-Source: AG47ELuExYBsqk5k17Lfhe9hWQ9qEVCJ5HRH/Lt+pYn1BRlXNfJ5JO7AoCHmHaORYqsLX0wSUS9D X-Received: by 2002:a17:902:8bc3:: with SMTP id r3-v6mr1342167plo.450.1519897052483; Thu, 01 Mar 2018 01:37:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519897052; cv=none; d=google.com; s=arc-20160816; b=ewA6kEzUkmBG5lDBucW2bed4naC0huSBw1i8cBr6nuU9yHzlRiZSJXRZuSSRCbzWyM fXOD1frHfjgpuToETFvEAwxWhKH73D8U10U2GtFtjrfbizj4hXJsQn2nd7kIavF76V88 Ruky5GbbMqCM+5XxBl0RY+GLO2nymhkEb2tNBBsJBUxuhPIhDOEp2X48XFQSSOAPuHPD YzC/L4A9YCeGV/hNKuBSBuP2lS0aMrrONUQYDBjVIag7YYaT5QiEr3l/k2pZLQT0fsff 2eB97eTu3ykL35/Q7iXKGQOwNfhsjDVZpt7kCTtDd6uvDzK7COYm2wwlKWLKO9geiDYR Nb6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :arc-authentication-results; bh=ltddpsQqRrfjNDwpsUdFB+nJ7Y2DbGfMS8JFeT3M9Rs=; b=Ozv6vapBoQ9yL378xHflPYlqwpuAPkdyZTzuopOMXcRj/ror934/8lV45IS7OUG9qV 49VtJC0wiMLz0i9NlIUl0U1AAb/5Zz0SQx9v+jnMPQYqPJIA7eJ3vgTsJX4A7R1H4JRp 0BZeDzhxbolG/4meiCH7knzaPyw7engC9uk9RHwuhrgoa4bfKhA0hUQOe2/XM8Dzg8LP 9dUz8Ei3S/KFhUAHOM5S7pJNVzovahxH1g2lRq5Nllq+Wb696fsmKXW6XQZOHdew4fj8 echogYBKqNIbe9BSuYN+YRfVQNdLi09zOFXBZX1s06CpJUOX8k6CTEZwtpqCPmPA1jGR 2U6A== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a2si2179349pgd.452.2018.03.01.01.37.17; Thu, 01 Mar 2018 01:37:32 -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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967054AbeCAJfg (ORCPT + 99 others); Thu, 1 Mar 2018 04:35:36 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:55050 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S967027AbeCAJfZ (ORCPT ); Thu, 1 Mar 2018 04:35:25 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DC5B58182D27; Thu, 1 Mar 2018 09:35:24 +0000 (UTC) Received: from [10.36.116.189] (ovpn-116-189.ams2.redhat.com [10.36.116.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id 646DD2026E04; Thu, 1 Mar 2018 09:35:21 +0000 (UTC) Subject: Re: [PATCH v2 08/15] KVM: s390: interface to enable AP execution mode To: Tony Krowiak , 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: David Hildenbrand Organization: Red Hat GmbH Message-ID: Date: Thu, 1 Mar 2018 10:35:20 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 01 Mar 2018 09:35:25 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 01 Mar 2018 09:35:25 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'david@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) -- Thanks, David / dhildenb