Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2431425pxb; Fri, 5 Feb 2021 18:59:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJxepIPuqquFPFmdqNQZwiTjYt2jMOl8YKp9p0ck3XQ3uuyECMX+YnRHGtk5sXohCxsSTM6b X-Received: by 2002:a17:907:9702:: with SMTP id jg2mr7022177ejc.48.1612580352040; Fri, 05 Feb 2021 18:59:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612580352; cv=none; d=google.com; s=arc-20160816; b=eeYHxgVK5EcafEfrdOFUioD59clfVbfkNy9KhfAXzvbJNuRfBAbzQIvQMAx4nPO8/u iSEeSO42Y+hCYgWQkAKtxo1WxOAz15MSRfP2C1dzwCPxArHjUQIoMC0IHEkWoDoKDkh1 VqGieXCKQLuErFrjJBeG2dsbch+2ne/FftFHNRWWHlksEPY6IJ0mth647hcjNHN2joVx XH9cRRV1bYgQxycKfYxHr57yQD6bL+BlVBnJmjdIvkAOne2ZXzyaL8SrAPl38OSFKvCC 8nzQKIBCh8kitvLn2xlkR+bAmOgQq36szewoAQOQnAbO49aX2alVwzVIK85C1C8KbbSW 8nNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=HGai+pQgKTisicDdHwktYzQMGc4r7YcFqy7xIJsZFUA=; b=y/4PRozMEeqRfo/mBVUt9IqzhSMUIcwOIdhac9Pxd2QFsE6/hGm27zmQRxOflY2Gqc SVkMSQtud6MU4WQCIh2PXolKzFkEjithRvi6A3rsHFLaNIJDkfnu6+/ucApsOVKPhsJb XfuUymmyI03CMCwnsihb/I4wfFCMyzdcsmA6zRP3eDCR0uKOMvXAputloiWYDS7yYfpz rnBb1oSjGNQFtspAu6BncQQP0W3l0qmQWZT+jYyBYdPesoOd+lf5rSfFuiulT8sHBQcv NUdLvqM2euCOdgbuIdVsFN7ssuC19QC7sK3KEcBoX51SRhsN4wjYK94xLy3QXT0CX3JK VSvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ellerman.id.au header.s=201909 header.b=HIpXaQUI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z13si3440008edl.531.2021.02.05.18.58.47; Fri, 05 Feb 2021 18:59:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ellerman.id.au header.s=201909 header.b=HIpXaQUI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232364AbhBFC4m (ORCPT + 99 others); Fri, 5 Feb 2021 21:56:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230489AbhBFCew (ORCPT ); Fri, 5 Feb 2021 21:34:52 -0500 Received: from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1387C08ED81; Fri, 5 Feb 2021 15:33:04 -0800 (PST) Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4DXWtg3J8rz9sVq; Sat, 6 Feb 2021 10:32:59 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ellerman.id.au; s=201909; t=1612567981; bh=YEW0go1tFxFTxPolBx8L31xUfYen5gFpEkFsTBzAGzI=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=HIpXaQUIpsnljSZbduOd3aUyuZSR5xDnELAdF1j+5z/HWCYImoa+1yAm1XltVrrvv D33mnCqMEFECxr9UnWzV1mvmfmkqsbcJr5f3aITbibDk5vjienHXHJMRbEI12PDhqK gI3BeEz2UjvpjcBHeEn4bGI/EcmPBUU1fiSljcQRZEFvTgZnVlVf/gaGg4kEjv8RA0 SFBAju1jx5nuVG35gO2HG74GoQhFmiVjbJZASsr1ftGXA5uVvfkCt5k/E7LAyDyKi8 oN9TZIft6KvJvKjwgvOvNChlr4QYR3rhkgjgj8oMkPrj1k7h69noE05DZPEN/SDELL nKIfAUDWlTobQ== From: Michael Ellerman To: Nicholas Piggin , "Aneesh Kumar K.V" , Athira Rajeev , Benjamin Herrenschmidt , Christophe Leroy , Frederic Weisbecker , Geert Uytterhoeven , Jordan Niethe , Leonardo Bras , Paul Mackerras , Thomas Gleixner Cc: kvm-ppc@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH v2 1/1] powerpc/kvm: Save Timebase Offset to fix sched_clock() while running guest code. In-Reply-To: <1612506268.6rrvx34gzu.astroid@bobo.none> References: <20210205060643.233481-1-leobras.c@gmail.com> <1612506268.6rrvx34gzu.astroid@bobo.none> Date: Sat, 06 Feb 2021 10:32:58 +1100 Message-ID: <878s82ozth.fsf@mpe.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Nicholas Piggin writes: > Excerpts from Leonardo Bras's message of February 5, 2021 4:06 pm: >> Before guest entry, TBU40 register is changed to reflect guest timebase. >> After exitting guest, the register is reverted to it's original value. >> >> If one tries to get the timestamp from host between those changes, it >> will present an incorrect value. >> >> An example would be trying to add a tracepoint in >> kvmppc_guest_entry_inject_int(), which depending on last tracepoint >> acquired could actually cause the host to crash. >> >> Save the Timebase Offset to PACA and use it on sched_clock() to always >> get the correct timestamp. > > Ouch. Not sure how reasonable it is to half switch into guest registers > and expect to call into the wider kernel, fixing things up as we go. Yeah it's not. We need to disable tracing on those routines that are called in that half-exited state. cheers