Received: by 10.223.185.116 with SMTP id b49csp5449130wrg; Wed, 7 Mar 2018 11:58:30 -0800 (PST) X-Google-Smtp-Source: AG47ELvHoaOwgRiapqvX4YIQBzq1sxBMo2OgfnRE54zew+5SGhKNYxcCDZ4mYRf63oWBVCcPdABb X-Received: by 2002:a17:902:b185:: with SMTP id s5-v6mr2416930plr.109.1520452710645; Wed, 07 Mar 2018 11:58:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520452710; cv=none; d=google.com; s=arc-20160816; b=HB79FCweCl0C+dyS++5hzCXOPPAwUdmuSl+w55Y/Jc5WFN9G2LvRpl2ukI4xTiPu8A bMqZHxtE4AgGh7kVWEKANXWT+w6ZEL6xaGgdDBOiaIMomujXERJUXxPHbL/3lhvePfgJ ld+R3UTdz7xH4KucQuHn9ckYzTyyOGws0yFtubKMitDvPFbZQSqU55w/H3FWrm5m5LjW FkvwS88GDwpcEOa8hGPx/gCEXpSf/rmWjewiBvY1fokw6BAOowxT+YwQ8Qdg4SvlC+qh kHkkpNLcXmkw/7qXtGK/AwF+C4Ba4vWGyOmEaTW7jivuA0yAY08o61Mq0TJabS1OEbG9 Ruvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=gnZxVFZXt9Qc71/CzhP3IxRsfJi1TNp3aG8ukwl1tMs=; b=H4JkT+4z3RCYqULgvwuJe9bsKaEZudJDEiu1kGRcDQT6YYn/W2WR8hSVkS1I+dWV7L cekzxJCkzFVwMF5XyEAP9ubnjIWrmRMyHG38VUvTgZyUWqZtJ0JnayBPv2c+/bRxAPmk +ByWZ0TTOleUzKxSqZRtAInm1YcZgBKuRbrsyyDzLALCKRvDisVKx3zaemtN15FuJS5Y GMx6NE+PYZuT/RPfr7BvCvaF3e2STioYKg8OWOErshdQOedFIGdONrKQ9DxUFLTJhuqi 7uWjPJcLH4yGPVNF1n6WlDXZbXNn3YMIE82/qwWqrlcUd9EXnAS+IklkquSYUhrIR4rg lKhA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e5-v6si13378910plb.566.2018.03.07.11.58.16; Wed, 07 Mar 2018 11:58:30 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965740AbeCGTra (ORCPT + 99 others); Wed, 7 Mar 2018 14:47:30 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:45008 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935038AbeCGTr2 (ORCPT ); Wed, 7 Mar 2018 14:47:28 -0500 Received: from localhost (unknown [185.236.200.248]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 756B910EC; Wed, 7 Mar 2018 19:47:27 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Hildenbrand , Christian Borntraeger Subject: [PATCH 4.14 086/110] KVM: s390: take care of clock-comparator sign control Date: Wed, 7 Mar 2018 11:39:09 -0800 Message-Id: <20180307191050.859341930@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180307191039.748351103@linuxfoundation.org> References: <20180307191039.748351103@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: David Hildenbrand commit 5fe01793dd953ab947fababe8abaf5ed5258c8df upstream. Missed when enabling the Multiple-epoch facility. If the facility is installed and the control is set, a sign based comaprison has to be performed. Right now we would inject wrong interrupts and ignore interrupt conditions. Also the sleep time is calculated in a wrong way. Signed-off-by: David Hildenbrand Message-Id: <20180207114647.6220-2-david@redhat.com> Fixes: 8fa1696ea781 ("KVM: s390: Multiple Epoch Facility support") Cc: stable@vger.kernel.org Reviewed-by: Christian Borntraeger Signed-off-by: Christian Borntraeger Signed-off-by: Greg Kroah-Hartman --- arch/s390/kvm/interrupt.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) --- a/arch/s390/kvm/interrupt.c +++ b/arch/s390/kvm/interrupt.c @@ -173,8 +173,15 @@ static int ckc_interrupts_enabled(struct static int ckc_irq_pending(struct kvm_vcpu *vcpu) { - if (vcpu->arch.sie_block->ckc >= kvm_s390_get_tod_clock_fast(vcpu->kvm)) + const u64 now = kvm_s390_get_tod_clock_fast(vcpu->kvm); + const u64 ckc = vcpu->arch.sie_block->ckc; + + if (vcpu->arch.sie_block->gcr[0] & 0x0020000000000000ul) { + if ((s64)ckc >= (s64)now) + return 0; + } else if (ckc >= now) { return 0; + } return ckc_interrupts_enabled(vcpu); } @@ -1004,13 +1011,19 @@ int kvm_cpu_has_pending_timer(struct kvm static u64 __calculate_sltime(struct kvm_vcpu *vcpu) { - u64 now, cputm, sltime = 0; + const u64 now = kvm_s390_get_tod_clock_fast(vcpu->kvm); + const u64 ckc = vcpu->arch.sie_block->ckc; + u64 cputm, sltime = 0; if (ckc_interrupts_enabled(vcpu)) { - now = kvm_s390_get_tod_clock_fast(vcpu->kvm); - sltime = tod_to_ns(vcpu->arch.sie_block->ckc - now); - /* already expired or overflow? */ - if (!sltime || vcpu->arch.sie_block->ckc <= now) + if (vcpu->arch.sie_block->gcr[0] & 0x0020000000000000ul) { + if ((s64)now < (s64)ckc) + sltime = tod_to_ns((s64)ckc - (s64)now); + } else if (now < ckc) { + sltime = tod_to_ns(ckc - now); + } + /* already expired */ + if (!sltime) return 0; if (cpu_timer_interrupts_enabled(vcpu)) { cputm = kvm_s390_get_cpu_timer(vcpu);