Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp3627660pxy; Mon, 26 Apr 2021 06:17:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvb22D7osd4fRmWhv0oMSrp3eB9nGBlLOnQZ1ntyNIxoFjX4wVa6Fy8S2eWcNrm+/skYnt X-Received: by 2002:a17:906:e4b:: with SMTP id q11mr18527244eji.540.1619443056160; Mon, 26 Apr 2021 06:17:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619443056; cv=none; d=google.com; s=arc-20160816; b=QyUmxHquRZRfkPGqKwnLT05q3cWja4WFgnOTBoYb6ZgUCUItSL6PCwyyw++DSMIFZy /oQNx7yhiM2s0Fuy0gjyRt6b1Qi3cLQJNLeHf4k3dv66oAtXOa6Ab098hpj1iSD+A/8a GLmD1/4b648Z1M33JUDxd33kuy0IYnATUwFuDjD2972aiwPqw8XtgpVCZ7iT0lKXcAuf FzVwijfKsA8XbR2PJwwE4ztHuFS8Fk5fLhUhyWMouVVZRhE8D0hrW/5Y8iwLVAFR59ci lCEE68u+/CmI0yK7DZa40ifNaI8b/Llz0Vio87iJ+4fx6N0F1YDre4Q28VfkG+ZoKZqX UFBg== 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:date:cc:to:from:subject :message-id:dkim-signature; bh=q1QoYvHAS2PJHcD4J9inVUs2O0h3REMpAF4YKOpBDCU=; b=dRfuLqqPTc60flsYdRy13LcmVcWqP55UQ/hZOW/g4GZbwi5kzKntsylsNgtMCr2/NJ FaUrzv9vpFm9gSjB7ISaAkHxkJxhk53qJzrcEYIz9Fwe5a33KwoE3Uzws26DqhhqEAOA wlMtZNfkaQeoGTzhpH7bAPUlhwWZvH6TpTgvsaXkP3C5fBqj7lgN3muADQ03+E7MyzdN 58m1ngV0XPcRolBk+x2i5KGoXFQzyOvbV7LmkbgcqvxhVmW/fEVDC4228RL4c2Lnjx1Q f13RLOnhAyuf79SLxzPB4R2ldIJdDcbcPXP248F0I5LCo+NZd+H9C9UvbdY3h/j0cLmk fuSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="A/N3ILX1"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lc12si13593140ejc.79.2021.04.26.06.17.11; Mon, 26 Apr 2021 06:17:36 -0700 (PDT) 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=@redhat.com header.s=mimecast20190719 header.b="A/N3ILX1"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233573AbhDZNQ6 (ORCPT + 99 others); Mon, 26 Apr 2021 09:16:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:48437 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231862AbhDZNQ5 (ORCPT ); Mon, 26 Apr 2021 09:16:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619442975; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=q1QoYvHAS2PJHcD4J9inVUs2O0h3REMpAF4YKOpBDCU=; b=A/N3ILX1a/NS0LikGim/U4Enl2Rp5LDakBcKazd24HsqyDXDzQ7lrRO9BItWjGfdd+Jtqn hOiJSbu/BsuQVMPCjXPLVXLRbzx7fgqxW47owxa/1lOzEYZkL/GzzfC5vkI7jTM6W8XS10 qAXrWgb15+CgFyGNmTtuof330VMoZgA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-120-d0pn2xLjOviwd4szRfX5vw-1; Mon, 26 Apr 2021 09:16:13 -0400 X-MC-Unique: d0pn2xLjOviwd4szRfX5vw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B7C50343A8; Mon, 26 Apr 2021 13:16:10 +0000 (UTC) Received: from starship (unknown [10.40.192.73]) by smtp.corp.redhat.com (Postfix) with ESMTP id 615C71002EE6; Mon, 26 Apr 2021 13:15:54 +0000 (UTC) Message-ID: <0cfc93405443bed335981ffd5cc07272ffb0ce3a.camel@redhat.com> Subject: Re: [RFC PATCH 0/6] x86/kvm: Virtual suspend time injection support From: Maxim Levitsky To: Hikaru Nishida , kvm@vger.kernel.org Cc: suleiman@google.com, Borislav Petkov , "H. Peter Anvin" , Ingo Molnar , Jim Mattson , Joerg Roedel , John Stultz , Jonathan Corbet , Paolo Bonzini , Sean Christopherson , Stephen Boyd , Thomas Gleixner , Vitaly Kuznetsov , Wanpeng Li , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org Date: Mon, 26 Apr 2021 16:15:52 +0300 In-Reply-To: <20210426090644.2218834-1-hikalium@chromium.org> References: <20210426090644.2218834-1-hikalium@chromium.org> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2021-04-26 at 18:06 +0900, Hikaru Nishida wrote: > Hi, > > This patch series adds virtual suspend time injection support to KVM. > > Before this change, if the host goes into suspended state while the > guest is running, the guest will experience a time jump after the host's > resume. This can confuse some services in the guest since they can't > detect if the system went into suspend or not by comparing > CLOCK_BOOTTIME and CLOCK_MONOTONIC. > > To solve this problem, we wanted to add a way to adjust the guest clocks > without actually suspending the guests. However, there was no way to > modify a gap between CLOCK_BOOTTIME and CLOCK_MONOTONIC without actually > suspending the guests. Therefore, this series introduce a new struct > called kvm_host_suspend_time to share the suspend time between host and > guest and a mechanism to inject a suspend time to the guest while > keeping > monotonicity of the clocks. > > Could you take a look and let me know how we can improve the patches if > they are doing something wrong? > > Thanks, > > Hikaru Nishida > I haven't yet looked at that, but in my experience when I suspend the host with VMs running, after resume all my VMs complain something about TSC watchdog and stop using it. The TSC is stable/synchornized, but after resume it does reset to 0 on all CPUs. I use INVTSC flag for all my VMs. I haven't investigated this futher yet. Just my 0.2 cents. Best regards, Maxim Levitsky > > > Hikaru Nishida (6): > x86/kvm: Reserve KVM_FEATURE_HOST_SUSPEND_TIME and > MSR_KVM_HOST_SUSPEND_TIME > x86/kvm: Add a struct and constants for virtual suspend time injection > x86/kvm: Add CONFIG_KVM_VIRT_SUSPEND_TIMING > x86/kvm: Add a host side support for virtual suspend time injection > x86/kvm: Add CONFIG_KVM_VIRT_SUSPEND_TIMING_GUEST > x86/kvm: Add a guest side support for virtual suspend time injection > > Documentation/virt/kvm/cpuid.rst | 3 + > Documentation/virt/kvm/msr.rst | 29 +++++++++ > arch/x86/Kconfig | 13 ++++ > arch/x86/include/asm/kvm_host.h | 5 ++ > arch/x86/include/asm/kvm_para.h | 9 +++ > arch/x86/include/uapi/asm/kvm_para.h | 6 ++ > arch/x86/kernel/kvmclock.c | 25 ++++++++ > arch/x86/kvm/Kconfig | 13 ++++ > arch/x86/kvm/cpuid.c | 4 ++ > arch/x86/kvm/x86.c | 89 +++++++++++++++++++++++++++- > include/linux/kvm_host.h | 7 +++ > include/linux/timekeeper_internal.h | 4 ++ > kernel/time/timekeeping.c | 31 ++++++++++ > 13 files changed, 237 insertions(+), 1 deletion(-) >