All of lore.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
To: Rusty Russell <rusty-8n+1lVoiYb80n/F98K4Iww@public.gmane.org>
Cc: kvm-devel <kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Subject: Re: [PATCH 1/2] kvm: Insist on a reason when injecting a	#GP into a	guest
Date: Tue, 24 Jul 2007 13:15:47 +0300	[thread overview]
Message-ID: <46A5D153.9020302@qumranet.com> (raw)
In-Reply-To: <1185259677.1803.239.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>

Rusty Russell wrote:
> Insist on a reason when injecting a #GP into a guest
>
> All places but one already do a printk before injecting a #GP: just
> formalize it a little.
>
> Signed-off-by: Rusty Russell <rusty-8n+1lVoiYb80n/F98K4Iww@public.gmane.org>
>
> diff -r f75b0a5fc387 drivers/kvm/kvm_main.c
> --- a/drivers/kvm/kvm_main.c	Mon Jul 23 11:16:12 2007 +1000
> +++ b/drivers/kvm/kvm_main.c	Mon Jul 23 16:59:56 2007 +1000
> @@ -419,8 +419,15 @@ static int kvm_vm_release(struct inode *
>  	return 0;
>  }
>  
> -static void inject_gp(struct kvm_vcpu *vcpu)
> -{
> +static void __attribute__((format(printf, 2, 3)))
> +inject_gp(struct kvm_vcpu *vcpu, const char *why_fmt, ...)
> +{
> +	va_list args;
> +
> +	va_start(args, why_fmt);
> +	printk(KERN_DEBUG "kvm: #GP ");
> +	vprintk(why_fmt, args);
> +	va_end(args);
>  	kvm_arch_ops->inject_gp(vcpu, 0);
>  }
>   

Some guests (non hardware accelerated hypervisors, mostly) will generate 
#gp.  We'll want to inject exceptions without noise then.  I don't think 
we have such an exception today, but it's an excuse to have a clean 
__inject_gp() and a varargs-infested inject_gp().

>  
> @@ -464,22 +471,21 @@ void set_cr0(struct kvm_vcpu *vcpu, unsi
>  void set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)
>  {
>  	if (cr0 & CR0_RESERVED_BITS) {
> -		printk(KERN_DEBUG "set_cr0: 0x%lx #GP, reserved bits 0x%lx\n",
> -		       cr0, vcpu->cr0);
> -		inject_gp(vcpu);
> +		inject_gp(vcpu,
> +			  "set_cr0: 0x%lx reserved bits 0x%lx\n",
> +			  cr0, vcpu->cr0);
>   

Why three lines?

>  		return;
>  	}
>  
>  	if ((cr0 & X86_CR0_NW) && !(cr0 & X86_CR0_CD)) {
> -		printk(KERN_DEBUG "set_cr0: #GP, CD == 0 && NW == 1\n");
> -		inject_gp(vcpu);
> +		inject_gp(vcpu,
> +			  "set_cr0: CD == 0 && NW == 1\n");
>  		return;
>   

Are you deliberately ignoring an opportunity to reduce our line count?!

> @@ -1843,8 +1834,7 @@ int kvm_setup_pio(struct kvm_vcpu *vcpu,
>  		/*
>  		 * String I/O in reverse.  Yuck.  Kill the guest, fix later.
>  		 */
> -		printk(KERN_ERR "kvm: guest string pio down\n");
> -		inject_gp(vcpu);
> +		inject_gp(vcpu, "guest string pio down\n");
>  		return 1;
>  	}
>  	vcpu->run->io.count = now;
>   

This one really wants to be a KERN_ERR.  It's not a guest exception, 
it's a kvm unimplemented feature for which the guest pays the price.  I 
guess a good place for __inject_gp().

-- 
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/

  parent reply	other threads:[~2007-07-24 10:15 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-24  6:47 [PATCH 1/2] kvm: Insist on a reason when injecting a #GP into a guest Rusty Russell
     [not found] ` <1185259677.1803.239.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-07-24  7:03   ` [PATCH 2/2] kvm: pr_guest: don't let guest invoke printk() on host Rusty Russell
     [not found]     ` <1185260620.1803.245.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-07-24 10:19       ` Avi Kivity
     [not found]         ` <46A5D215.5030301-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-07-24 10:48           ` Rusty Russell
     [not found]             ` <1185274114.1803.309.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-07-24 11:01               ` Avi Kivity
     [not found]                 ` <46A5DC11.4070400-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-07-24 11:29                   ` Rusty Russell
     [not found]                     ` <1185276567.1803.330.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-07-24 12:19                       ` Avi Kivity
     [not found]                         ` <46A5EE38.3060703-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-07-25  0:19                           ` Rusty Russell
     [not found]                             ` <1185322747.1803.392.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-07-25  6:25                               ` Avi Kivity
     [not found]                                 ` <46A6ECD4.8040804-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-07-25  6:45                                   ` Avi Kivity
2007-07-24 10:15   ` Avi Kivity [this message]
     [not found]     ` <46A5D153.9020302-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-07-24 10:41       ` [PATCH 1/2] kvm: Insist on a reason when injecting a #GP into a guest Rusty Russell
     [not found]         ` <1185273661.1803.300.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-07-24 10:44           ` Avi Kivity

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=46A5D153.9020302@qumranet.com \
    --to=avi-atkuwr5tajbwk0htik3j/w@public.gmane.org \
    --cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=rusty-8n+1lVoiYb80n/F98K4Iww@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.