Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp3458269pxy; Mon, 26 Apr 2021 02:10:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0xpAPZeuMgssVqpnu+LNDg26iRJyirHInF6pW8rqE15R/HVxJeSwPeNuCTMWsJhOpq8xx X-Received: by 2002:a63:f447:: with SMTP id p7mr15650603pgk.272.1619428208215; Mon, 26 Apr 2021 02:10:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619428208; cv=none; d=google.com; s=arc-20160816; b=LqpztbzsfVZx8jsj//yAWS0uc4+ldq3NJTcZFjLtVk4Dq1qxuhR4ZwMKFVmX5qX775 qZ51x22gNp+/RWmGc8XW0Z26A1tA4JfVawQOvCR6D3WeTO/ccmRKXhbYt4KdbwWt+bj2 a59oJn4mAtjLKP1voloNHZx4QhREWlzqfCLJAy+mVooK21PPOhteevyhi4H7o8fn31Ax FQi4JXi/5x6wBn+WKqhy5ce1eEZELF+quLEhlbrWdIwbVZopw/cs5v0fTxUZ6mosmE3K iwKqQgPkio+rA0bHd+ihp4rIwneM1+5XOQT/sjzT48x68FbXBWEJEaoCCvNeyVQIDJ8a UxWg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=HNdzFDdOgeWXGKXmnjDGLCV9ZQhV0CgleaBxzMVsBew=; b=gUPreqMhaZK5oo1EUXSkdL6a/avY1Ib/HZuoXWO2T3TahGEkzrYvKi1p/RfrmyINxs ZlU0rNCH5UG+u5d72MXhk6mCHJXm7GfncXn8xGCUl59oSuAOWRNK9s9rpRP/Zy0cunLO QdzmrppfrtVfDokv3M7i8g7vlabd0RAIINIZb/uv0CcvvVc++1RcYhNmR2bH4R4Mih9e prZe7uxBwdhke6ofQdWNE7EN72+EHcsQ0DcvoKOm2b8XmWOfo6A0f8YK8+Bi9EmC6q+S ApJIwwaf2cII5cgWDTMj51BHIROaL1mGcHRYwA0xEcVMoG6IWNPW+uWUEe4b/afI9AbH 4j5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Zu3BggN8; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i23si17114589pfr.315.2021.04.26.02.09.55; Mon, 26 Apr 2021 02:10:08 -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=@chromium.org header.s=google header.b=Zu3BggN8; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232695AbhDZJJw (ORCPT + 99 others); Mon, 26 Apr 2021 05:09:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232706AbhDZJJG (ORCPT ); Mon, 26 Apr 2021 05:09:06 -0400 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E4DBC06175F for ; Mon, 26 Apr 2021 02:08:24 -0700 (PDT) Received: by mail-pg1-x52b.google.com with SMTP id d10so1277730pgf.12 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=CQDmCpBB7VYfhf/xh++apwjukxb5eQrlF4qnY4qHFF2+5d70gRRtGthYBRm21yuYgk tLE8/6EvcR3Bo9mY8Da/bxZKW5hhngxU3kvoMH9y9QZCvCa9zkReZ+lc9PCTEPBbZjTi +4OTpU4sUogqIEKcth46gcdU7wbAMlTrcxD3xz3EhHQ4mnHiSzvMJIqr5l2HIotTnDS/ 4ekDk9ltHoUzSwBwRKPeRr74pOpM6JzLZjwt2PQEmyRtTUiEUKrd3EwPDZihbqctH8cb eFSW9FC45g2v2VnklE4K3Z+CDMmD0jB1mAsi3X5fTphmXjSNpb3sEc6fmKPVJSgg1e2q eOvA== X-Gm-Message-State: AOAM5318vlw3n3lV0+yWXoKvmtXp5zLKWVcZmRt0ihldgbdWRLj5UrFT 5XElSPDFrtSifBIg0qeMCsBncA== 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: linux-kernel@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