Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3018559rwb; Mon, 15 Aug 2022 16:15:23 -0700 (PDT) X-Google-Smtp-Source: AA6agR5QoYdYnGPLEv9iTlNqFZsY7yDVXyMtQWYgKsLSWUVSDgYwFBsx/I28kl4o4ZTfS7u9fOnG X-Received: by 2002:a17:906:847c:b0:730:b6a0:e0d with SMTP id hx28-20020a170906847c00b00730b6a00e0dmr12031044ejc.126.1660605323087; Mon, 15 Aug 2022 16:15:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660605323; cv=none; d=google.com; s=arc-20160816; b=KkbZXwEUNwmIQvAwocsLInpchDwpZYumrXlG1RRrRRSEl8lQM86936ZrHxqN0dRGq7 UaGVmt2KmaMdvRAX9Su8ut0X4VEzU9CuCD131bxHZ3j4PqKfdBkbAnHPAkYrNbFaU7H6 qORbImFUaksPCvO6nOZhcZmuTdPhY7aiXFWSqswa7g9IQg+roWcaAManTuE3GoJCqEx+ NNvi9ieyBYkWTRCF3v65L3ajvBPSXu7D9LDtF7dxWKkI+iy7pNNL0gkQJMmzjxrGYvOE dtlsIHFOOgHMpbzHz7sazqhNuR2y18BoUMqNffBg5DUZP3z/Y3ITUb0Z17Y5qEdNzTw4 r84g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=SuNCsvP7WRGuqTy5UyeNzlI/fNVMebJUEpdV92uoByo=; b=ZHmp5UIl8VcnBng7YBUrJw3gRKhLIO3VPJBGQEqJ3/CqXD9aMhddeTT5EFdZ/CtKnd 6v5oJLk27BXxtOb98UUicgGUUaRGNpMYu77nEWBWGIiTjOaC4kB+stEY7GDcQbMXZ/RG riqODU2Ks7n59H1nsWfBPC6HuIjjK/tAB8AXERdG+gzCnOaFoDiQcU9jgYi3P4nfkv+I 7QA/H2b3G7MK1effQ8lY/YUJxHE9cIJ8GCn0rUDJAPM7ea2a4L8BjpZ7nX+gicryCbnf 3qLI5Kk2bKBtWjD/ETToQF/DNihADkMPb1Fpc3wCEP/5v4CtRHe2+Ri8jqxUgQweQsYj 2ABQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=eQz+OFFn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id wt11-20020a170906ee8b00b00730881cddb4si6576351ejb.454.2022.08.15.16.14.57; Mon, 15 Aug 2022 16:15:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=eQz+OFFn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350124AbiHOVwP (ORCPT + 99 others); Mon, 15 Aug 2022 17:52:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350263AbiHOVrd (ORCPT ); Mon, 15 Aug 2022 17:47:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB3272B62B; Mon, 15 Aug 2022 12:31:29 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 88F3960FB9; Mon, 15 Aug 2022 19:31:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91FD3C433D6; Mon, 15 Aug 2022 19:31:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660591889; bh=/aQnZQ5JFG9L15x7QKi8JUfhjGN48NNx0wirGU2yGxo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eQz+OFFnxXhTIIG2cKs/jrqH9t0rjYV+cHDx1JfPvIu/vgHFolOmD7PPQkbXcQSOY j6a0NaLqdgojfTYoVxu8DhLM5KPDFUIWKIO6CceCGa6dSJY1kna+WAsAg4UvKgG6lD bWCR7kEHzTdNNiD1+Jj81aJSMJVlDiZoaNkT5rXk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nico Boehr , Claudio Imbrenda , Janosch Frank , Christian Borntraeger Subject: [PATCH 5.19 0026/1157] KVM: s390: pv: dont present the ecall interrupt twice Date: Mon, 15 Aug 2022 19:49:42 +0200 Message-Id: <20220815180440.466734194@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nico Boehr commit c3f0e5fd2d33d80c5a5a8b5e5d2bab2841709cc8 upstream. When the SIGP interpretation facility is present and a VCPU sends an ecall to another VCPU in enabled wait, the sending VCPU receives a 56 intercept (partial execution), so KVM can wake up the receiving CPU. Note that the SIGP interpretation facility will take care of the interrupt delivery and KVM's only job is to wake the receiving VCPU. For PV, the sending VCPU will receive a 108 intercept (pv notify) and should continue like in the non-PV case, i.e. wake the receiving VCPU. For PV and non-PV guests the interrupt delivery will occur through the SIGP interpretation facility on SIE entry when SIE finds the X bit in the status field set. However, in handle_pv_notification(), there was no special handling for SIGP, which leads to interrupt injection being requested by KVM for the next SIE entry. This results in the interrupt being delivered twice: once by the SIGP interpretation facility and once by KVM through the IICTL. Add the necessary special handling in handle_pv_notification(), similar to handle_partial_execution(), which simply wakes the receiving VCPU and leave interrupt delivery to the SIGP interpretation facility. In contrast to external calls, emergency calls are not interpreted but also cause a 108 intercept, which is why we still need to call handle_instruction() for SIGP orders other than ecall. Since kvm_s390_handle_sigp_pei() is now called for all SIGP orders which cause a 108 intercept - even if they are actually handled by handle_instruction() - move the tracepoint in kvm_s390_handle_sigp_pei() to avoid possibly confusing trace messages. Signed-off-by: Nico Boehr Cc: # 5.7 Fixes: da24a0cc58ed ("KVM: s390: protvirt: Instruction emulation") Reviewed-by: Claudio Imbrenda Reviewed-by: Janosch Frank Reviewed-by: Christian Borntraeger Link: https://lore.kernel.org/r/20220718130434.73302-1-nrb@linux.ibm.com Message-Id: <20220718130434.73302-1-nrb@linux.ibm.com> Signed-off-by: Claudio Imbrenda Signed-off-by: Greg Kroah-Hartman --- arch/s390/kvm/intercept.c | 15 +++++++++++++++ arch/s390/kvm/sigp.c | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) --- a/arch/s390/kvm/intercept.c +++ b/arch/s390/kvm/intercept.c @@ -528,12 +528,27 @@ static int handle_pv_uvc(struct kvm_vcpu static int handle_pv_notification(struct kvm_vcpu *vcpu) { + int ret; + if (vcpu->arch.sie_block->ipa == 0xb210) return handle_pv_spx(vcpu); if (vcpu->arch.sie_block->ipa == 0xb220) return handle_pv_sclp(vcpu); if (vcpu->arch.sie_block->ipa == 0xb9a4) return handle_pv_uvc(vcpu); + if (vcpu->arch.sie_block->ipa >> 8 == 0xae) { + /* + * Besides external call, other SIGP orders also cause a + * 108 (pv notify) intercept. In contrast to external call, + * these orders need to be emulated and hence the appropriate + * place to handle them is in handle_instruction(). + * So first try kvm_s390_handle_sigp_pei() and if that isn't + * successful, go on with handle_instruction(). + */ + ret = kvm_s390_handle_sigp_pei(vcpu); + if (!ret) + return ret; + } return handle_instruction(vcpu); } --- a/arch/s390/kvm/sigp.c +++ b/arch/s390/kvm/sigp.c @@ -480,9 +480,9 @@ int kvm_s390_handle_sigp_pei(struct kvm_ struct kvm_vcpu *dest_vcpu; u8 order_code = kvm_s390_get_base_disp_rs(vcpu, NULL); - trace_kvm_s390_handle_sigp_pei(vcpu, order_code, cpu_addr); - if (order_code == SIGP_EXTERNAL_CALL) { + trace_kvm_s390_handle_sigp_pei(vcpu, order_code, cpu_addr); + dest_vcpu = kvm_get_vcpu_by_id(vcpu->kvm, cpu_addr); BUG_ON(dest_vcpu == NULL);