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=-14.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 E48E8C433B4 for ; Mon, 26 Apr 2021 09:09:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9B54E60FEF for ; Mon, 26 Apr 2021 09:09:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232756AbhDZJJl (ORCPT ); Mon, 26 Apr 2021 05:09:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232710AbhDZJJG (ORCPT ); Mon, 26 Apr 2021 05:09:06 -0400 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B73CC061756 for ; Mon, 26 Apr 2021 02:08:24 -0700 (PDT) Received: by mail-pg1-x52e.google.com with SMTP id j7so30238155pgi.3 for ; Mon, 26 Apr 2021 02:08:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=HNdzFDdOgeWXGKXmnjDGLCV9ZQhV0CgleaBxzMVsBew=; b=Zu3BggN8BFpvKZGn6qHGXUPTHBTV4x1GkM1zsI4Okx7UF40oT4oF5Pmw6uYulawjjb 0KlLYFgLhZvaknAJ+/IQfINmmgk96eMHEw89RwtnWU85lDW76coUguECJmDwWTADV7mo i8DhqIGQCCJNYmZWbVFxUAd6UsCPsRA4APklA= 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:date:message-id:mime-version :content-transfer-encoding; bh=HNdzFDdOgeWXGKXmnjDGLCV9ZQhV0CgleaBxzMVsBew=; b=J9yl47Ugn7SoifenbUTo3AVysjCLY3R7TDq8tZoz9pFPK5F4VOEJ+QkuI5THol0O5U UcfyW7uPLEWkgbsGcg8lKcndCGMfsJ7eVGIzPe+BapwE2ZldMTHci8i8wly+Tnoe1oWQ CdOBtsh6Fs12qu1ZwGniMdztE/9/EdHjV0goYPiNRK95vmYTxEwl0ZvqZZk2t01vTzJO EZyRbMcgoh0o805vByMojbzdBDN+ax2w+c1UXoM1aUGKltDdVwQjhcaaTkzisRipVYk9 3zBGfLDqIj0ljuRfOjFteY2W9/jCQw32OTp00FN4AoOUr0DAI8aQN2BnQPRnx8gvMiPY wF/Q== X-Gm-Message-State: AOAM533kGrWR4jOT66Si1i5kYoOFWwVMU+Cc5WunfthIjSeXEsiXYe7k wuMxsWF5NI5J2sEsGQzc0CYWFbSYFDgsBA== X-Google-Smtp-Source: ABdhPJxCIKL4jdEbT9jB4QA6Zvprni9bDSdgXrCbWLLsGOXVPQwykN6qzWsE4gCtmVAhCaRxtGLepA== X-Received: by 2002:aa7:9046:0:b029:272:3729:e10a with SMTP id n6-20020aa790460000b02902723729e10amr9940066pfo.49.1619428103205; Mon, 26 Apr 2021 02:08:23 -0700 (PDT) Received: from localhost (160.131.236.35.bc.googleusercontent.com. [35.236.131.160]) by smtp.gmail.com with UTF8SMTPSA id kk9sm12011641pjb.23.2021.04.26.02.08.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Apr 2021 02:08:22 -0700 (PDT) From: Hikaru Nishida To: kvm@vger.kernel.org Cc: suleiman@google.com, Hikaru Nishida , 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 Subject: [RFC PATCH 0/6] x86/kvm: Virtual suspend time injection support Date: Mon, 26 Apr 2021 18:06:39 +0900 Message-Id: <20210426090644.2218834-1-hikalium@chromium.org> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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 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(-) -- 2.31.1.498.g6c1eba8ee3d-goog