From patchwork Thu Dec 3 12:47:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yifei Jiang X-Patchwork-Id: 11948685 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=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 E0E48C83017 for ; Thu, 3 Dec 2020 12:48:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 96DD5206A1 for ; Thu, 3 Dec 2020 12:48:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389004AbgLCMsf (ORCPT ); Thu, 3 Dec 2020 07:48:35 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:8627 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388928AbgLCMsf (ORCPT ); Thu, 3 Dec 2020 07:48:35 -0500 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4CmwbK0by7z15X07; Thu, 3 Dec 2020 20:47:25 +0800 (CST) Received: from huawei.com (10.174.186.236) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.487.0; Thu, 3 Dec 2020 20:47:42 +0800 From: Yifei Jiang To: , CC: , , , , , , , , , , , , , Yifei Jiang Subject: [PATCH RFC v4 15/15] target/riscv: Add time frequency migration support Date: Thu, 3 Dec 2020 20:47:03 +0800 Message-ID: <20201203124703.168-16-jiangyifei@huawei.com> X-Mailer: git-send-email 2.26.2.windows.1 In-Reply-To: <20201203124703.168-1-jiangyifei@huawei.com> References: <20201203124703.168-1-jiangyifei@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.186.236] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org If vcpu's time frequency is not specified by CPU option 'time-frequency' on the destination, the time frequency of destination will follow the source. If vcpu's time frequency specified by CPU option 'time-frequency' on the destination is different from migrated time frequency. The migration will be abort. Signed-off-by: Yifei Jiang Signed-off-by: Yipeng Yin --- target/riscv/machine.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/target/riscv/machine.c b/target/riscv/machine.c index ef2d5395a8..6955542fef 100644 --- a/target/riscv/machine.c +++ b/target/riscv/machine.c @@ -144,6 +144,13 @@ static int cpu_post_load(void *opaque, int version_id) CPURISCVState *env = &cpu->env; env->kvm_timer_dirty = true; + + if (env->user_frequency && env->user_frequency != env->frequency) { + error_report("Mismatch between user-specified time frequency and " + "migrated time frequency"); + return -EINVAL; + } + return 0; } @@ -198,6 +205,7 @@ const VMStateDescription vmstate_riscv_cpu = { VMSTATE_UINT64(env.kvm_timer_time, RISCVCPU), VMSTATE_UINT64(env.kvm_timer_compare, RISCVCPU), VMSTATE_UINT64(env.kvm_timer_state, RISCVCPU), + VMSTATE_UINT64(env.frequency, RISCVCPU), VMSTATE_END_OF_LIST() },