Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9938100ybi; Wed, 24 Jul 2019 12:40:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqwUMx8pBKbtzBMYKOfCOI6eQL+jiOCempdls+0Sq7BlOJ60yY/uULdv8KcA5F32iy80b3ix X-Received: by 2002:a63:5d45:: with SMTP id o5mr83969435pgm.40.1563997222421; Wed, 24 Jul 2019 12:40:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563997222; cv=none; d=google.com; s=arc-20160816; b=oulUUvg1uvt6X0/kjXaTcLb9TtJf1LzeI85XPnRk6qBoLtnm5Sds83SZzmHq4B9efm lfPDpGWh4SdZfF7pdjSmRoO4R++aj4onUKRR2eln1jvxnHsI+xW7ANGJcEsErr/+ENMv DIBNkMTHDfHjE5pViU7xyZCBSCWF7sFHH/RIjos2TgWQkpYeUp6D3NqrisRq9xInH4Yo y6immgdXot2lQa1gOEq9j6DghcRGmNajag2opxno7YjzvEwikn0PWGKH9wD+i+Ej1Oi/ UtnmebD48Kdyotwm5YHptC0CZkL0tk7BJhKTYRce17p6NG+GQXo8PehXcBsSztsvcnWe uKww== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5zXNx8YQIKIQox0TIj5d4MwhHb6bw0tW1sb20ew40ug=; b=xFWyQkXH/Xhv24pImFEF4QQpoJ41H+mhoSndxJJllMi7KjWyjlGLfgGLxHZV3amTvH cLrNk31FWaTHTw4ViuugQ2hP6KUX3AAx4MkPEOHB0BkeOF4F7p9qDX4z2hj54XkumWZY WnluRVHS9WG76aLLCN2R2gOvOMCFpXakYr5b8cQfdfj7Y8Vgevzr2DLr4hGqh2HJDumQ aGSBi/bjyyHkrJtTsRkBH/hy1rZ97TSTUeWlIPKJgi8YizxG0myozf17VQuMcUpzJD67 6Pq39tmlL+35sKEQLBzrxgqvzv9Uuy6f/ahHprBpMuxfx5izbyVQsSa/WXrVrw+RZe2E ZXqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Tyv3O0fn; 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 t190si13821256pgd.465.2019.07.24.12.40.07; Wed, 24 Jul 2019 12:40:22 -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; dkim=pass header.i=@kernel.org header.s=default header.b=Tyv3O0fn; 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 S2389825AbfGXTi7 (ORCPT + 99 others); Wed, 24 Jul 2019 15:38:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:39826 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389063AbfGXTi5 (ORCPT ); Wed, 24 Jul 2019 15:38:57 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6DE53229F4; Wed, 24 Jul 2019 19:38:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563997136; bh=BYgD140YwXZPbXuTbm/opODkBbWxfFqvPxTOrrDkIHs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tyv3O0fn8tOQAOT+TyaaSFXA122WlL8UYtKyWzQpxMaHxsjt17O/bgnwvtWlHWhmN m2xaTcZ6gnUZ1aeRDpFhUNfm0nKdQalMyPvie1FwypQsbGwMegq8RrZVATwFIMLLZd Tio0r5n9nVu+WRi0CHab642fcMOfUb0ZnBlQMiB0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Suraj Jitindar Singh , Michael Ellerman Subject: [PATCH 5.2 332/413] KVM: PPC: Book3S HV: Signed extend decrementer value if not using large decrementer Date: Wed, 24 Jul 2019 21:20:23 +0200 Message-Id: <20190724191759.582493703@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191735.096702571@linuxfoundation.org> References: <20190724191735.096702571@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suraj Jitindar Singh commit 869537709ebf1dc865e75c3fc97b23f8acf37c16 upstream. On POWER9 the decrementer can operate in large decrementer mode where the decrementer is 56 bits and signed extended to 64 bits. When not operating in this mode the decrementer behaves as a 32 bit decrementer which is NOT signed extended (as on POWER8). Currently when reading a guest decrementer value we don't take into account whether the large decrementer is enabled or not, and this means the value will be incorrect when the guest is not using the large decrementer. Fix this by sign extending the value read when the guest isn't using the large decrementer. Fixes: 95a6432ce903 ("KVM: PPC: Book3S HV: Streamlined guest entry/exit path on P9 for radix guests") Cc: stable@vger.kernel.org # v4.20+ Signed-off-by: Suraj Jitindar Singh Signed-off-by: Michael Ellerman Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/kvm/book3s_hv.c | 2 ++ 1 file changed, 2 insertions(+) --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -3603,6 +3603,8 @@ int kvmhv_p9_guest_entry(struct kvm_vcpu vcpu->arch.slb_max = 0; dec = mfspr(SPRN_DEC); + if (!(lpcr & LPCR_LD)) /* Sign extend if not using large decrementer */ + dec = (s32) dec; tb = mftb(); vcpu->arch.dec_expires = dec + tb; vcpu->cpu = -1;