From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1253C432C3 for ; Sat, 6 Feb 2021 02:57:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8A2F364FE4 for ; Sat, 6 Feb 2021 02:57:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232392AbhBFC47 (ORCPT ); Fri, 5 Feb 2021 21:56:59 -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