Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp948394pxb; Wed, 6 Apr 2022 05:05:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxzOiBBIIzXUNtcw7yCjLSH+jnBeC94mUtX2caMgBLkEDagpzugE19XDPoSDgsXrqIjyXci X-Received: by 2002:a6b:fb17:0:b0:649:b0dd:e381 with SMTP id h23-20020a6bfb17000000b00649b0dde381mr3845902iog.95.1649246755387; Wed, 06 Apr 2022 05:05:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649246755; cv=none; d=google.com; s=arc-20160816; b=Z7Zkfc83uWKMnTyhMKnZJAQ7lE2A6HS1r4INil2BAr5wd/bR+VcMOMP54uZ4ooFXkm V+y6wucW32T1IBgEZ6VKLgqfN0R3Fhyrho4AZSPhSk2yOq2D3tHBAQb5SCuBW8L4FIDO CiXZZW8Cd7PfWhDqLkshCLKHsxYZ/ut9P6hvS13U2TW2lZ55PMPvo6swJ8RZWJ+kRgl7 ZRIsdMU2KLPdGX6guJOB0kdXBC8jN9hlfBUu+XfLyUGHmJm2NdOHocenJM5tUmVocpmV zxTKdX6M1F0WeIgzQgI9QgNVLd+WFjx7PxPlrVQW+ITY3/gYH0/JhuGTponQ6mySPshs +/gA== 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=OPBrHNx2LKQ6ml17qXIWn5lDvY4BPmJwK+vmBz/2ztM=; b=INPq0rfozjqeZwcCLFz9vp3iBu4miQE5imHQdmOilexGm8DutiWUk4QxuCCwjCX2rW IQ0Sq3ra1wrN48R0mJnYl/W4FR6aTBfU6TFDQZWOwD9tdCj6Y/GBau883457fjTcTuuP 2PjyRS6IxJGwvEYlsckMVeNg6nchD7ZSNWMVM8682+GaR3EjkO/3rNAc4D6pWDoT5gvX 2geJp49FLm662Z0/h9BwiwRtvTetkJ+SNV9/eKBtXlCsHMIEcbRmZp6UVPXR5OMzr6XV NazDH2kQ39aKqu1aiz6do8r+KS4xD8wEOTzn0Oo92Jr4nkbvrabUuCTwN5Dwij/feF1w b8sQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xhxXitVc; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id u3-20020a056e021a4300b002ca1cdf0c68si7460235ilv.165.2022.04.06.05.05.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 05:05:55 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xhxXitVc; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D1C1768258E; Wed, 6 Apr 2022 03:33:31 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346628AbiDEJpO (ORCPT + 99 others); Tue, 5 Apr 2022 05:45:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238917AbiDEITa (ORCPT ); Tue, 5 Apr 2022 04:19:30 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 021BE75215; Tue, 5 Apr 2022 01:09:43 -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 4DD68608C0; Tue, 5 Apr 2022 08:09:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5A775C385A0; Tue, 5 Apr 2022 08:09:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649146182; bh=Vge0+JI6dnmSDzj8z8QK4MArKmPEiy+UaJEPPJBued8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xhxXitVc3fj3BFoF0HMuruMBC2xemtRhUsUSm3nVB16CsnvQNaaILn6AuaB3zDgpR LZUzOjAxPAPZrzLjcUku5KzWbGU3ERyoKZPKjhO+6W7DzFm3z9EDg+Dq3fyPLg84xw 49Hbu1hCDmMrSFpcs8Qtg1euQaoGQIOGfJf8xRW0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicholas Piggin , Michael Ellerman , Sasha Levin Subject: [PATCH 5.17 0670/1126] powerpc/time: Fix KVM host re-arming a timer beyond decrementer range Date: Tue, 5 Apr 2022 09:23:37 +0200 Message-Id: <20220405070427.293514868@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070407.513532867@linuxfoundation.org> References: <20220405070407.513532867@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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: Nicholas Piggin [ Upstream commit cf74ff52e352112be78c4c4c3637a37ec36a6608 ] If the next host timer is beyond decrementer range, timer_rearm_host_dec will leave decrementer not programmed. This will not cause a problem for the host it will just set the decrementer correctly when the decrementer interrupt hits, it seems safer not to leave the next host decrementer interrupt timing able to be influenced by a guest. This code is only used in the P9 KVM paths so it's unlikely to be hit practically unless large decrementer is force disabled in the host. Fixes: 25aa145856cd ("powerpc/time: add API for KVM to re-arm the host timer/decrementer") Signed-off-by: Nicholas Piggin Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20220124143930.3923442-2-npiggin@gmail.com Signed-off-by: Sasha Levin --- arch/powerpc/kernel/time.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c index cd0b8b71ecdd..384f58a3f373 100644 --- a/arch/powerpc/kernel/time.c +++ b/arch/powerpc/kernel/time.c @@ -582,8 +582,9 @@ void timer_rearm_host_dec(u64 now) local_paca->irq_happened |= PACA_IRQ_DEC; } else { now = *next_tb - now; - if (now <= decrementer_max) - set_dec_or_work(now); + if (now > decrementer_max) + now = decrementer_max; + set_dec_or_work(now); } } EXPORT_SYMBOL_GPL(timer_rearm_host_dec); -- 2.34.1