Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2139908pxa; Mon, 17 Aug 2020 01:42:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxgeuVO68XuLImW2WFFrr2ObTsk73xYRqyLrBQ1wOCcI6fhj+GfD4dqVggtDHGMntZaYQGv X-Received: by 2002:a05:6402:743:: with SMTP id p3mr13764552edy.19.1597653754416; Mon, 17 Aug 2020 01:42:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597653754; cv=none; d=google.com; s=arc-20160816; b=acDNDCfQavoFyDDPG28GlALQ1aEQB5fGIPLqhjiHY5yZFbzGstgwfpDYRz+YO3cEgz sCDLXflKBNaXRO9rcIqyha0rW/moWyCtsavc+F1dq+hKIwlNUV73n+bIl6esO7eTZogv stNLduZUvqQ9cuPyKyKp9/jMytsadNpr/uuYj8DPellCr7vEJCoIHXCBWq68AtQQFRu7 EpMIBBUdhxCaBo1U3VbraddJQWuZNU1YT/WQyIUtUhuID+RBWjfmWU/+KBO7UDTYmbBl 2QP10PzUsegbPFH9ctCzkNlPvm4y3kq/UuHkV5BhjOlpsv+VaslPXUvdNVc89hqpnIAw Jk2g== 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:subject:cc :to:from; bh=tq1wgz4ZYBHzDynh9hJ8VILHm/l9QadNts7QkF8+63g=; b=bYXSDoiLy58fwm3DVHMBUkgWxIC58fm/YGHFPgMsOIdP+5WBM5m3j+ylKRY2RxogM4 2hjmYKF0V6YQESxUo30p7+wfnexzT1/EW8o/3bZX8fugzqdzE2Qdev+XGZLM0mmoB7eb oKV8bqe3UYByladWmEhC7WEEKLY8mSMZOCK8ZSD5aDfuRkfQ7S8qzwCwizuCCqcTeU7G cJ6dJfQ8Cv8apfzgx4Y0DVBH2/iiz/430c/Z12whOmnSIwb3teQYWhybZ0OmpjZ4qKsq ynKC4hoIihOBPxc7RRiwYGZIZfbkziZqM74Gfb6JGZoqGTUeiE5KBs3Q/73E2vRXldK+ SDBQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a5si11207574ejt.549.2020.08.17.01.42.11; Mon, 17 Aug 2020 01:42:34 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727794AbgHQIle (ORCPT + 99 others); Mon, 17 Aug 2020 04:41:34 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:45200 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726361AbgHQIl2 (ORCPT ); Mon, 17 Aug 2020 04:41:28 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 724AC236C0FF1FBF5E6D; Mon, 17 Aug 2020 16:41:22 +0800 (CST) Received: from DESKTOP-5IS4806.china.huawei.com (10.174.187.22) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.487.0; Mon, 17 Aug 2020 16:41:12 +0800 From: Keqian Zhu To: , , , CC: Marc Zyngier , Steven Price , Catalin Marinas , Will Deacon , James Morse , Suzuki K Poulose , , Keqian Zhu Subject: [RFC PATCH 0/5] KVM: arm64: Add pvtime LPT support Date: Mon, 17 Aug 2020 16:41:05 +0800 Message-ID: <20200817084110.2672-1-zhukeqian1@huawei.com> X-Mailer: git-send-email 2.8.4.windows.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.174.187.22] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi all, This patch series picks up the LPT pvtime feature originally developed by Steven Price: https://patchwork.kernel.org/cover/10726499/ Backgroud: There is demand for cross-platform migration, which means we have to solve different CPU features and arch counter frequency between hosts. This patch series can solve the latter problem. About LPT: This implements support for Live Physical Time (LPT) which provides the guest with a method to derive a stable counter of time during which the guest is executing even when the guest is being migrated between hosts with different physical counter frequencies. Changes on Steven Price's work: 1. LPT structure: use symmatical semantics of scale multiplier, and use fraction bits instead of "shift" to make everything clear. 2. Structure allocation: host kernel does not allocates the LPT structure, instead it is allocated by userspace through VM attributes. The save/restore functionality can be removed. 3. Since LPT structure just need update once for each guest run, add a flag to indicate the update status. This has two benifits: 1) avoid multiple update by each vCPUs. 2) If the update flag is not set, then return NOT SUPPORT for coressponding guest HVC call. 4. Add VM device attributes interface for userspace configuration. 5. Add a base LPT read/write layer to reduce code. 6. Support ptimer scaling. 7. Support timer event stream translation. Things need concern: 1. https://developer.arm.com/docs/den0057/a needs update. 2. If a guest fails to initialize and use LPT, when it migrates to a host with different native frequency, it will see the virtual counter jump. However this concern is not a problem. 1) Guest does not support LPT or host does not enable LPT: we won't migrate guest to a host with different frequency. 2) Guest kernel faces problem when initilize LPT: guest can not boot up, so counter jump is not a problem at this situation. Patch 2 and 3 implement host KVM part. Patch 4 and 5 implement guest driver part. Keqian Zhu (5): KVM: arm64: Document pvtime LPT interface KVM: arm64: Support Live Physical Time reporting KVM: arm64: Provide VM device attributes for LPT time clocksource: arm_arch_timer: Add pvtime LPT initialization clocksource: arm_arch_timer: Use pvtime LPT Documentation/virt/kvm/arm/pvtime.rst | 78 +++++++++++-- Documentation/virt/kvm/devices/vm.rst | 30 +++++ arch/arm64/include/asm/arch_timer.h | 179 ++++++++++++++++++++++++++-- arch/arm64/include/asm/kvm_host.h | 14 +++ arch/arm64/include/uapi/asm/kvm.h | 5 + arch/arm64/kvm/arm.c | 71 ++++++++++++ arch/arm64/kvm/hypercalls.c | 5 + arch/arm64/kvm/pvtime.c | 212 +++++++++++++++++++++++++++++++++- drivers/clocksource/arm_arch_timer.c | 120 +++++++++++++++---- 9 files changed, 669 insertions(+), 45 deletions(-) -- 1.8.3.1