Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp253076imm; Wed, 3 Oct 2018 15:34:11 -0700 (PDT) X-Google-Smtp-Source: ACcGV61RqDyKx6AOTreqk7v4ghAhVsVLfPP945HDAl79N07JUqtqQ5yQ1qY1vyjbMapofSDPz8Ex X-Received: by 2002:a17:902:b598:: with SMTP id a24-v6mr3642392pls.40.1538606051111; Wed, 03 Oct 2018 15:34:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538606051; cv=none; d=google.com; s=arc-20160816; b=W5mjPeuO8+lB0aMladtKxz0eo0Pm2NUZIQgRVR4o2qYr1hHUQJO3KiL4yEaAazWQ1l ik9SneP/eHtikM2VYuSr4XZFvQzCloMqJiYx2uGmTYIoqbqgBDWhM61KjeIN5mywbsEH SPuLEOD0lqc9Qv+7lKCcU3u1sjOrZ48ViYkqOiURzYaJlel441jyt4Qqt8YPqlp9qnKD LLElT5+ktwXoMY47BszE3UqH5Y/0vDl4wJvsrEjqTo+QxL8e4YnWwTaRNmomIqChTfMF 5WqUsaWpUU4WhDtaUaH15ifSIP00+RlpY+daymPoyOCLeUE1nfp5aI6BmPNzvHDjNiWO +U/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=ap9V3hx3riZSL6GOqEMkte4B6wqjaHkZbt5LwyYm5dM=; b=PT7gDC0gz2WlkublydIpXxIKIa6O2wtakwNaaxQzI6T3kEhG57NQ08RHasaYL8kA9w CCk4uYTCVNeik7h7/dFEWY1FEe79/B1Vd//yFtZw3ZQEJhwGRmm0U8Pw1QEunGWPWPr5 os7lUEzVuC54Xlghf12aytUTOerDfbKy1cZBJPj5K6kurrGP2tg1mpO9lXTra2NCeg0L hXX8sAzRhIZrDVbTEVtAxVgDcpT+x+mYPDxfL2OWmAwpkQZDtZnwBlUaLDaIC5HJauFJ FIUt92W2AwImZXO3BSEbrlX/Q+rSxtRM+Elppacuo/pf7bPHaH5DnADvHjjHKjpPUupq ZBsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="DO/tU0Yz"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s16-v6si2853697plr.38.2018.10.03.15.33.56; Wed, 03 Oct 2018 15:34:11 -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="DO/tU0Yz"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727559AbeJDFWn (ORCPT + 99 others); Thu, 4 Oct 2018 01:22:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:43258 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726770AbeJDFWn (ORCPT ); Thu, 4 Oct 2018 01:22:43 -0400 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B03BF214C1 for ; Wed, 3 Oct 2018 22:32:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1538605942; bh=44K1dXoUqnnLNzkcFJ9rnt23TL/ivNkgJS3eEc4dMCs=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=DO/tU0YzoQrkY8tMszsAloZeTUrFvFPT91fTqbFo33ulMPxRTRKI2IvoGpgB4iLdX zFXmcd7lf9Gbp4KsRLtWXAKG5jNAsOI2gsFSIYBTqpip68VYEsVn3HJ/Ai/mLulOqr 0C2TnSK12TDAUFScP4oGLU7u1mbF1yOh2RA16Ijs= Received: by mail-wr1-f47.google.com with SMTP id 63-v6so7791164wra.11 for ; Wed, 03 Oct 2018 15:32:21 -0700 (PDT) X-Gm-Message-State: ABuFfog+/u0XFtiuIKD3P3rGN+lEtRckSZ6dTX1Dwwdm82kkuaLNnaeW 85wfHbiT/16QNg65fJJkIp9BV4L4ZGK7wdokve/qLA== X-Received: by 2002:adf:9792:: with SMTP id s18-v6mr2824733wrb.283.1538605940010; Wed, 03 Oct 2018 15:32:20 -0700 (PDT) MIME-Version: 1.0 References: <20180914125006.349747096@linutronix.de> <20181003190026.GB21381@amt.cnet> In-Reply-To: <20181003190026.GB21381@amt.cnet> From: Andy Lutomirski Date: Wed, 3 Oct 2018 15:32:08 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [patch 00/11] x86/vdso: Cleanups, simmplifications and CLOCK_TAI support To: Marcelo Tosatti Cc: Andrew Lutomirski , Thomas Gleixner , Paolo Bonzini , Radim Krcmar , Wanpeng Li , LKML , X86 ML , Peter Zijlstra , Matt Rickard , Stephen Boyd , John Stultz , Florian Weimer , KY Srinivasan , Vitaly Kuznetsov , devel@linuxdriverproject.org, Linux Virtualization , Arnd Bergmann , Juergen Gross 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 On Wed, Oct 3, 2018 at 12:01 PM Marcelo Tosatti wrote: > > On Tue, Oct 02, 2018 at 10:15:49PM -0700, Andy Lutomirski wrote: > > Hi Vitaly, Paolo, Radim, etc., > > > > On Fri, Sep 14, 2018 at 5:52 AM Thomas Gleixner wrote: > > > > > > Matt attempted to add CLOCK_TAI support to the VDSO clock_gettime() > > > implementation, which extended the clockid switch case and added yet > > > another slightly different copy of the same code. > > > > > > Especially the extended switch case is problematic as the compiler tends to > > > generate a jump table which then requires to use retpolines. If jump tables > > > are disabled it adds yet another conditional to the existing maze. > > > > > > This series takes a different approach by consolidating the almost > > > identical functions into one implementation for high resolution clocks and > > > one for the coarse grained clock ids by storing the base data for each > > > clock id in an array which is indexed by the clock id. > > > > > > > I was trying to understand more of the implications of this patch > > series, and I was again reminded that there is an entire extra copy of > > the vclock reading code in arch/x86/kvm/x86.c. And the purpose of > > that code is very, very opaque. > > > > Can one of you explain what the code is even doing? From a couple of > > attempts to read through it, it's a whole bunch of > > probably-extremely-buggy code that, > > Yes, probably. > > > drumroll please, tries to atomically read the TSC value and the time. And decide whether the > > result is "based on the TSC". > > I think "based on the TSC" refers to whether TSC clocksource is being > used. > > > And then synthesizes a TSC-to-ns > > multiplier and shift, based on *something other than the actual > > multiply and shift used*. > > > > IOW, unless I'm totally misunderstanding it, the code digs into the > > private arch clocksource data intended for the vDSO, uses a poorly > > maintained copy of the vDSO code to read the time (instead of doing > > the sane thing and using the kernel interfaces for this), and > > propagates a totally made up copy to the guest. > > I posted kernel interfaces for this, and it was suggested to > instead write a "in-kernel user of pvclock data". > > If you can get kernel interfaces to replace that, go for it. I prefer > kernel interfaces as well. > > > And gets it entirely > > wrong when doing nested virt, since, unless there's some secret in > > this maze, it doesn't acutlaly use the scaling factor from the host > > when it tells the guest what to do. > > > > I am really, seriously tempted to send a patch to simply delete all > > this code. > > If your patch which deletes the code gets the necessary features right, > sure, go for it. > > > The correct way to do it is to hook > > Can you expand on the correct way to do it? > > > And I don't see how it's even possible to pass kvmclock correctly to > > the L2 guest when L0 is hyperv. KVM could pass *hyperv's* clock, but > > L1 isn't notified when the data structure changes, so how the heck is > > it supposed to update the kvmclock structure? > > I don't parse your question. Let me ask it more intelligently: when the "reenlightenment" IRQ happens, what tells KVM to do its own update for its guests?