kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Nicholas Krause <xerofoify@gmail.com>, gleb@kernel.org
Cc: x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH RESEND] kvm:x86:Fix error handling in the function kvm_write_wall_clock
Date: Thu, 17 Dec 2015 11:36:35 +0100	[thread overview]
Message-ID: <56729033.80706@redhat.com> (raw)
In-Reply-To: <1450319418-29032-1-git-send-email-xerofoify@gmail.com>



On 17/12/2015 03:30, Nicholas Krause wrote:
> This fixes error handling in the function kvm_write_wall_clock
> by checking if any of the calls to kvm_write_guest have failed
> inside this paricutlar function and if so print to the console
> with pr_err that we are unable to write the data to the guest
> system to warn the user of this failure before directly returning
> to the caller of the function kvm_write_wall_check as we cannot
> continue the function to this function after a failed call to
> 
> Signed-off-by: Nicholas Krause <xerofoify@gmail.com>

I think I have explained before why this is mostly unnecessary, but the
patch can be saved.  I'll go through the problems again first.

> -	kvm_write_guest(kvm, wall_clock, &version, sizeof(version));
> +	if (kvm_write_guest(kvm, wall_clock, &version, sizeof(version))) {
> +		pr_err("Unable to correctly write data to guest system\n");
> +		return;
> +	}

You've written a message to the log that can be triggered by the guest
(by writing an invalid value to the wall clock MSR).  We don't let the
guest spam the host logs.

>  	/*
>  	 * The guest calculates current wall clock time by adding
> @@ -1168,10 +1171,16 @@ static void kvm_write_wall_clock(struct kvm *kvm, gpa_t wall_clock)
>  	wc.nsec = boot.tv_nsec;
>  	wc.version = version;
>  
> -	kvm_write_guest(kvm, wall_clock, &wc, sizeof(wc));
> +	if (kvm_write_guest(kvm, wall_clock, &wc, sizeof(wc))) {
> +		pr_err("Unable to correctly write data to guest system\n");
> +		return;
> +	}

The other kvm_write_guest will probably also fail but, if it doesn't,
you've left an odd version in the data structure. The guest will loop
forever waiting for the even value.

Plus, same problem with logs.

>  	version++;
> -	kvm_write_guest(kvm, wall_clock, &version, sizeof(version));
> +	if (kvm_write_guest(kvm, wall_clock, &version, sizeof(version))) {
> +		pr_err("Unable to correctly write data to guest system\n");
> +		return;
> +	}
>  }

Same problem with logs, and the return is not useful.

Can you send a patch that only adds a return if the *first*
kvm_write_guest fails?  You can leave aside the others, and not add any
pr_err.

Thanks,

Paolo

>  static uint32_t div_frac(uint32_t dividend, uint32_t divisor)
> 

           reply	other threads:[~2015-12-17 10:36 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <1450319418-29032-1-git-send-email-xerofoify@gmail.com>]

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=56729033.80706@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=gleb@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=x86@kernel.org \
    --cc=xerofoify@gmail.com \
    /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).