All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Campbell <Ian.Campbell@citrix.com>
To: Lin Ming <mlin@ss.pku.edu.cn>
Cc: Andrew Cooper <Andrew.Cooper3@citrix.com>,
	"xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"Konrad Rzeszutek Wilk" <konrad.wilk@oracle.com>
Subject: Re: [Xen-devel] [PATCH] xen/apic: implement io apic read with hypercall
Date: Fri, 20 Apr 2012 13:38:28 +0100	[thread overview]
Message-ID: <1334925508.28331.63.camel@zakaz.uk.xensource.com> (raw)
In-Reply-To: <1334920396.2863.16.camel@hp6530s>

On Fri, 2012-04-20 at 12:13 +0100, Lin Ming wrote:
> On Fri, 2012-04-20 at 10:58 +0100, Andrew Cooper wrote:
> > On 20/04/12 10:25, Lin Ming wrote:
> > > Implements xen_io_apic_read with hypercall, so it returns proper IO-APIC
> > > information instead of fabricated one.
> > >
> > > Signed-off-by: Lin Ming <mlin@ss.pku.edu.cn>
> > > ---
> > >  arch/x86/xen/apic.c |   16 +++++++++++-----
> > >  1 files changed, 11 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/arch/x86/xen/apic.c b/arch/x86/xen/apic.c
> > > index aee16ab..f1f392d 100644
> > > --- a/arch/x86/xen/apic.c
> > > +++ b/arch/x86/xen/apic.c
> > > @@ -1,14 +1,20 @@
> > >  #include <linux/init.h>
> > >  #include <asm/x86_init.h>
> > > +#include <asm/apic.h>
> > > +#include <xen/interface/physdev.h>
> > > +#include <asm/xen/hypercall.h>
> > >  
> > >  unsigned int xen_io_apic_read(unsigned apic, unsigned reg)
> > >  {
> > > -	if (reg == 0x1)
> > > -		return 0x00170020;
> > > -	else if (reg == 0x0)
> > > -		return apic << 24;
> > > +	struct physdev_apic apic_op;
> > > +	int ret;
> > >  
> > > -	return 0xff;
> > > +	apic_op.apic_physbase = mpc_ioapic_addr(apic);
> > > +	apic_op.reg = reg;
> > > +	ret = HYPERVISOR_physdev_op(PHYSDEVOP_apic_read, &apic_op);
> > > +	if (ret)
> > > +		return ret;
> > > +	return apic_op.value;
> > 
> > Hypercall ret errors are negative, yet this function is unsigned.  Given
> > that the previous function had no possible way to fail, perhaps on error
> > you should fake up the values as before.
> 
> How about return -1 on error?
> The calling function can check -1 for error. 

Isn't -1 potentially (at least theoretically) a valid value to read from
one of these registers?

Under what circumstances can these hypercalls fail? Would a BUG_ON be
appropriate/

> unsigned int ret = apic_read(...);
> if (ret == -1)
> 	//handle error.
> 
> Thanks,
> Lin Ming
> 
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel



  reply	other threads:[~2012-04-20 12:38 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-20  9:25 Lin Ming
2012-04-20  9:58 ` [Xen-devel] " Andrew Cooper
2012-04-20 11:13   ` Lin Ming
2012-04-20 12:38     ` Ian Campbell [this message]
2012-04-20 12:52       ` Jan Beulich
2012-04-20 12:53       ` Andrew Cooper
2012-04-20 13:12         ` Ian Campbell
2012-04-20 13:20           ` Andrew Cooper
2012-04-20 14:50           ` Lin Ming
2012-04-20 14:50             ` Lin Ming
2012-04-20 14:59             ` [Xen-devel] " Jan Beulich
2012-04-20 15:06             ` Ian Campbell
2012-04-20 15:39               ` Lin Ming
2012-04-20 16:43                 ` Konrad Rzeszutek Wilk
2012-04-20 16:41       ` Konrad Rzeszutek Wilk
2012-04-23  8:42         ` Lin Ming
2012-04-23 15:11           ` Konrad Rzeszutek Wilk
2012-04-24 14:43             ` Lin Ming
2012-04-24 16:23               ` Konrad Rzeszutek Wilk
2012-04-25 10:06                 ` Lin Ming
2012-04-26 15:33                   ` Konrad Rzeszutek Wilk
2012-04-26 15:33                     ` Konrad Rzeszutek Wilk

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=1334925508.28331.63.camel@zakaz.uk.xensource.com \
    --to=ian.campbell@citrix.com \
    --cc=Andrew.Cooper3@citrix.com \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mlin@ss.pku.edu.cn \
    --cc=xen-devel@lists.xensource.com \
    --subject='Re: [Xen-devel] [PATCH] xen/apic: implement io apic read with hypercall' \
    /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

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.