From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wanpeng Li Subject: Re: [PATCH] KVM: x86: pvclock: Handle first-time write to pvclock-page contains random junk Date: Mon, 13 Nov 2017 09:37:59 +0800 Message-ID: References: <1509891090-8985-1-git-send-email-liran.alon@oracle.com> <5A08EAEA.9060701@ORACLE.COM> <5A08ED7D.2020003@ORACLE.COM> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Cc: Paolo Bonzini , Radim Krcmar , kvm , idan.brown@oracle.com, Konrad Rzeszutek Wilk To: Liran Alon Return-path: Received: from mail-ot0-f179.google.com ([74.125.82.179]:47183 "EHLO mail-ot0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751110AbdKMBiA (ORCPT ); Sun, 12 Nov 2017 20:38:00 -0500 Received: by mail-ot0-f179.google.com with SMTP id s4so3204403ote.4 for ; Sun, 12 Nov 2017 17:38:00 -0800 (PST) In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: 2017-11-13 9:03 GMT+08:00 Wanpeng Li : > 2017-11-13 8:55 GMT+08:00 Liran Alon : >> >> >> On 13/11/17 02:52, Wanpeng Li wrote: >>> >>> 2017-11-13 8:44 GMT+08:00 Liran Alon : >>>> >>>> >>>> >>>> On 13/11/17 02:40, Wanpeng Li wrote: >>>>> >>>>> >>>>> 2017-11-05 22:11 GMT+08:00 Liran Alon : >>>>>> >>>>>> >>>>>> When guest passes KVM it's pvclock-page GPA via WRMSR to >>>>>> MSR_KVM_SYSTEM_TIME / MSR_KVM_SYSTEM_TIME_NEW, KVM don't initialize >>>>>> pvclock-page to some start-values. It just requests a clock-update >>>>>> which >>>>> >>>>> >>>>> >>>>> KVM does, please refer to memset(hv_clock, 0, size) in kvmclock_init(). >>>> >>>> >>>> >>>> kvmclock_init() is the code that runs in KVM-guest. I was talking here >>>> about >>>> the code that handles the WRMSR in KVM hypervisor code. >>>> >>>> The issue happens when the guest doesn't init pvclock-page as done in >>>> kvmclock_init(). Not all guests behave nicely :) >>> >>> >>> But the codes which you modify just works for kvm guest I think. >> >> No, it's the code that runs in KVM hypervisor for any guest that knows how >> to work with KVM pv-clock PV interface. >> Linux guest is just one of the possible guests which can use this interface. >> kvmclock_init() you mentioned is part of the linux-guest. But there are >> other guests which use KVM pv-clock PV interface. > > Good to know it, could you point one? In addition, there is a BUG_ON(if version != 0) just before the codes which you added. I will move these avoid random junk logics into msr setup in order that it can avoid '& operation' each time update the pv stuff. I will send a patch later. Regards, Wanpeng Li