From: Marcelo Tosatti <mtosatti@redhat.com>
To: Igor Mammedov <imammedo@redhat.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, eabatalov89@gmail.com
Subject: Re: [PATCH] x86: kvmclock: zero initialize pvclock shared memory area
Date: Mon, 10 Jun 2013 17:19:33 -0300 [thread overview]
Message-ID: <20130610201933.GA31409@amt.cnet> (raw)
In-Reply-To: <1370881871-13130-1-git-send-email-imammedo@redhat.com>
On Mon, Jun 10, 2013 at 06:31:11PM +0200, Igor Mammedov wrote:
> ===
> Could be the following an acceptable fix?
> ===
Read of kvmclock should return proper value from hypervisor: system
timestamp + tsc delta.
Should find the offender site and have it register MSR_KVM_SYSTEM_TIME
before reading the area.
> kernel might hung in pvclock_clocksource_read() due to
> uninitialized memory might contain odd version value in
> following cycle:
>
> do {
> version = __pvclock_read_cycles(src, &ret, &flags);
> } while ((src->version & 1) || version != src->version);
>
> if secondary kvmclock is accessed before it's registered with kvm.
>
> Clear garbage in pvclock shared memory area right after it's
> allocated to avoid this issue.
>
> Ref: https://bugzilla.kernel.org/show_bug.cgi?id=59521
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
> arch/x86/kernel/kvmclock.c | 1 +
> 1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
> index d2c3812..3dd37eb 100644
> --- a/arch/x86/kernel/kvmclock.c
> +++ b/arch/x86/kernel/kvmclock.c
> @@ -242,6 +242,7 @@ void __init kvmclock_init(void)
> if (!mem)
> return;
> hv_clock = __va(mem);
> + memset(hv_clock, 0, size);
>
> if (kvm_register_clock("boot clock")) {
> hv_clock = NULL;
> --
> 1.7.1
next prev parent reply other threads:[~2013-06-10 20:28 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <bug-59521-28872@https.bugzilla.kernel.org/>
2013-06-10 16:31 ` [PATCH] x86: kvmclock: zero initialize pvclock shared memory area Igor Mammedov
2013-06-10 20:19 ` Marcelo Tosatti [this message]
2013-06-15 18:01 ` [PATCHv1] kvm guest: fix uninitialized kvmclock read by KVM guest Eugene Batalov
2013-06-18 22:21 ` Marcelo Tosatti
2013-06-19 13:05 ` Paolo Bonzini
[not found] ` <CAJF2t5sYHy9q9a7-fZauf1Z7_FkK1_DOP13GHji=8-vDUsnnsQ@mail.gmail.com>
2013-06-19 13:29 ` Paolo Bonzini
2013-06-20 8:30 ` Igor Mammedov
2013-06-20 8:35 ` Paolo Bonzini
2013-06-21 9:01 ` [PATCH 0/2 v2] x86: kvmclock: Prevent uninitialized per-cpu kvmclock usage Igor Mammedov
2013-06-21 9:01 ` [PATCH 1/2] x86: kvmclock: zero initialize pvclock shared memory area Igor Mammedov
2013-06-21 9:01 ` [PATCH 2/2] x86: kvmclock: register per-cpu kvmclock at earliest possible time Igor Mammedov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130610201933.GA31409@amt.cnet \
--to=mtosatti@redhat.com \
--cc=eabatalov89@gmail.com \
--cc=imammedo@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).