Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5784295ybp; Tue, 8 Oct 2019 08:15:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqwv7tHk1pfgRj+nasrxlO320hI2Ungjxef8njjQfbqaQLe+fvSLzIl+WxTzSOLBwRTunN8q X-Received: by 2002:a50:fa09:: with SMTP id b9mr34605911edq.165.1570547731707; Tue, 08 Oct 2019 08:15:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570547731; cv=none; d=google.com; s=arc-20160816; b=saR6nqtXyFlS2jUJZs/QGAOAxo13PNAxv47Ky4cOD8y9Cphafi4bnHwipNj3jHLXOv Fr0KvZ7nTL1DgXkFvAuEJQltiwNnR5gpBqqLNDVv31CABynhtPwrNxPvpmm2Y+mxsXkL VsVrpXAtY2V+8wuvayGld0GFSfY/Z6v+EhmKVDdIGlQZVYs7SfkJTtG3rgnk4mbpLGey gp9+8w7lNi7rMans3EOwGxwCQZ/gaXBuEW6BxAsX/fK+f8pABdI3U31fQ7eC42QV0R4D U5x8TgR3UxnaOzHQyu3aX9SiVVTTYrAWXHRbY9O7YphrA/vOzKNZfJucAOPwdhndKCjV Jd9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=TVxQtqSMZ2FHlKInFtkoosjtqyBQr57VDotUlK3rfd8=; b=O+xPJEdxtTzW91LVOxhgFamnA6vcYYkfSGI41tvFTvybXhuUZtMARonEP6JD9cweE5 Zm24cMdaxnceFcMVUCuKcD5S/1qOq1im/l46ISgfRpZAh7ZDLb13Iyz0/hEXz88NKFDI 8NVxPXvWzWLMpsLWw0MQoG/eG31l+pKXWk3nrYxcPRASaKFtoFulU6HAONNgPQwg6Qor lZMof8jhQAX4JT31fKWwdAzId4Y3gs1+qzZ3xzAYjMWwEl2jVMvbZorXNSwJRe1LiUJr eeLE2yYodT6/tIXP2jLS6irp/eBaVYohl/vkh4YY+O46pvpLavHacIQdYyookWXsI1oL n22g== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w30si10722427edd.137.2019.10.08.08.15.05; Tue, 08 Oct 2019 08:15:31 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726239AbfJHPM3 (ORCPT + 99 others); Tue, 8 Oct 2019 11:12:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54400 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725953AbfJHPM3 (ORCPT ); Tue, 8 Oct 2019 11:12:29 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2A3BC796EB for ; Tue, 8 Oct 2019 15:12:28 +0000 (UTC) Received: by mail-wr1-f69.google.com with SMTP id n3so9291468wrt.9 for ; Tue, 08 Oct 2019 08:12:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=TVxQtqSMZ2FHlKInFtkoosjtqyBQr57VDotUlK3rfd8=; b=awPBI37PTPe/qiZsaefHnGCoHnrhD0uHg/+IAmu2gEVmL1d+o5301C5jaSpVovT5Lz kwnTkUZgffZSkyOaTpz8eYzRMZ3oYWrGaTTHrRdr8uj/c4OfSSrwiTZaNAvxrMMmcbGe eifzL5qzSRi9lCCbG5Er2i+iB7wrcbwq/n0rHD85TO1Ytl3ZwnUZlh4FjD+5C2sHMGL+ vko7HELwDU06tAFVZ5SMt5ewMS4mq785bfKgdugHihARe1/tc0v8VuXa4m8Pb3lWKFoA G+EiroA1yfhkKPwGW8mczpu2Ypiich96mmfQF16FTCGbvGPNzyWA2IIdru6gTaK9dfyP wVAw== X-Gm-Message-State: APjAAAXqe9pJkcDzAwTh4PPYcp7eJQKBqLNvIO8CXspuUvIjGX15b8Bh huW+8NIBMPZEO0ow0wC5GB0vZB7gDMMKUKcLC+yJmAEzamEaAibeZ78vVhM6qG3t4AxV998/ggk Z56TchjlyQybPSoBfp7w1RMY7 X-Received: by 2002:a5d:6885:: with SMTP id h5mr27879949wru.92.1570547546800; Tue, 08 Oct 2019 08:12:26 -0700 (PDT) X-Received: by 2002:a5d:6885:: with SMTP id h5mr27879921wru.92.1570547546560; Tue, 08 Oct 2019 08:12:26 -0700 (PDT) Received: from vitty.brq.redhat.com (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id h7sm19634893wrs.15.2019.10.08.08.12.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2019 08:12:25 -0700 (PDT) From: Vitaly Kuznetsov To: Michael Kelley , Andrea Parri , "linux-kernel\@vger.kernel.org" , "linux-hyperv\@vger.kernel.org" , "x86\@kernel.org" Cc: KY Srinivasan , Haiyang Zhang , Stephen Hemminger , Sasha Levin , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , Andrea Parri Subject: RE: [PATCH 1/2] x86/hyperv: Allow guests to enable InvariantTSC In-Reply-To: References: <20191003155200.22022-1-parri.andrea@gmail.com> <87k19k1mad.fsf@vitty.brq.redhat.com> Date: Tue, 08 Oct 2019 17:12:25 +0200 Message-ID: <87tv8jz2xy.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Michael Kelley writes: > From: Vitaly Kuznetsov Sent: Friday, October 4, 2019 9:57 AM >> >> Andrea Parri writes: >> >> > If the hardware supports TSC scaling, Hyper-V will set bit 15 of the >> > HV_PARTITION_PRIVILEGE_MASK in guest VMs with a compatible Hyper-V >> > configuration version. Bit 15 corresponds to the >> > AccessTscInvariantControls privilege. If this privilege bit is set, >> > guests can access the HvSyntheticInvariantTscControl MSR: guests can >> > set bit 0 of this synthetic MSR to enable the InvariantTSC feature. >> > After setting the synthetic MSR, CPUID will enumerate support for >> > InvariantTSC. >> >> I tried getting more information from TLFS but as of 5.0C this feature >> is not described there. I'm really interested in why this additional >> interface is needed, e.g. why can't Hyper-V just set InvariantTSC >> unconditionally when TSC scaling is supported? >> > > Yes, this is very new functionality that is not yet available in a released > version of Hyper-V. And as you know, the Hyper-V TLFS has gotten > woefully out-of-date. :-( > > Your question is the same question I asked. The reason given by > Hyper-V is to take the more cautious approach of not "automatically" > giving VMs an InvariantTSC due to updating the underlying Hyper-V > version. Instead, guest VMs must have been explicitly coded to take > advantage of the new InvariantTSC feature. It's not clear to me how > much of this caution is driven by Windows guests vs. Linux or FreeBSD > guests, but it is what it is. > > Having to explicitly enable the InvariantTSC does give the Linux code > the opportunity to be a bit cleaner by doing things like not marking > the TSC as unstable when the InvariantTSC feature is present, and to > mark the TSC as reliable so we don't try to do TSC synchronization > (which Hyper-V does not want guests to try to do). Thank you for these additional details Michael, we'll probably have to add support for this bit to KVM and I'd like to know the background. From Linux perspective, no matter what's the interface we'd like to get InvariantTSC. Feel free to add Reviewed-by: Vitaly Kuznetsov -- Vitaly