All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Bryan D. Payne" <bryan@thepaynes.cc>
To: Ian Campbell <Ian.Campbell@XenSource.com>
Cc: Xen Developers <xen-devel@lists.xensource.com>
Subject: Re: hypercall execution path?
Date: Thu, 22 Feb 2007 15:28:30 -0500	[thread overview]
Message-ID: <45DDFCEE.6020201@thepaynes.cc> (raw)
In-Reply-To: <1172174731.19233.6.camel@localhost.localdomain>

> Where have you put this tracing?
> 
> How you are arranging for the hypercall you are expecting to be called
> and how you are matching that up with where your tracing is placed?
> 
> Perhaps you could post your code so we can see what you are actually
> doing?

This all started with me playing with grant tables.  I have a simple 
example setup where I am passing a string from a domU kernel module to a 
dom0 kernel module.  Dom0 allocates the page and sets permissions in the 
grant table using gnttab_grant_foreign_access.

In domU, the kernel module makes a GNTTABOP_copy hypercall to pass the 
string.  The domU code looks like this:

static int send_string (grant_ref_t gref)
{
     struct gnttab_copy op;
     char str[MAX_STR_LENGTH];

     /* hard code string for testing */
     memset(str, 0, MAX_STR_LENGTH);
     memcpy(str, "This is a test\n", 16);

     op.source.domid = DOMID_SELF;
     op.source.offset = (PAGE_SIZE-1) & (uint32_t)str;
     op.source.u.gmfn = virt_to_mfn(str);
     op.dest.domid = 0;
     op.dest.offset = 0;
     op.dest.u.ref = gref;
     op.len = strnlen(str, MAX_LOG_LENGTH);
     op.flags = GNTCOPY_dest_gref;

     HYPERVISOR_grant_table_op(GNTTABOP_priv_write, &op, 1);

     /* make sure that the hypercall succeeded */
     if (op.status){
         printk("Grant table operation failure\n");
         return 1;
     }

     return 0;
}

This code setup seems to work just fine.  I can pass the string to dom0 
without any problems.

Next, I wanted to study the execution path between the two kernel 
modules.  As part of this, I placed code in the hypervisor to print out 
the EIP value from domU while servicing the hypercall (the one shown in 
the code above).  I put this code in the __gnttab_copy function of 
common/grant_table.c, because this is the function that does most of the 
work for this hypercall.  Here I simply print out the EIP value, as 
indicated in my prior email:

uint32_t eip = sd->vcpu[0]->arch.guest_context.user_regs.eip;
gdprintk(XENLOG_WARNING, "eip=0x%x", eip);

Note that I'm using 'sd' for the domain since I'm interested in the 
domain that invoked the hypercall.  This is where I see the eip value 
that I indicated in my previous email.  Also note that I am doing this 
after 'sd' is initialized, of course :-)

My assumptions are as follows:

* When I make a hypercall from domU, the execution switches to the 
hypervisor immediately (as soon as the 'int' instruction is issued).

* The hypervisor services this hypercall and then returns to domU where 
it left off.

However, this is now what I'm seeing... and this is why I'm confused. 
Hopefully this helps explain the problem.  Let me know if you have any 
other questions about my setup.

Thanks,
bryan


-
Bryan D. Payne
Graduate Student, Computer Science
Georgia Tech Information Security Center
http://www.bryanpayne.org

  reply	other threads:[~2007-02-22 20:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-22 17:17 hypercall execution path? Bryan D. Payne
     [not found] ` <1172168208.12407.26.camel@lapbode42.lrr.in.tum.de>
2007-02-22 18:18   ` Daniel Stodden
2007-02-22 18:30     ` Bryan D. Payne
2007-02-22 18:37       ` Ian Campbell
2007-02-22 19:11         ` Bryan D. Payne
2007-02-22 20:05           ` Ian Campbell
2007-02-22 20:28             ` Bryan D. Payne [this message]
2007-02-22 20:46               ` Ian Campbell
2007-02-22 21:18                 ` Bryan D. Payne

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=45DDFCEE.6020201@thepaynes.cc \
    --to=bryan@thepaynes.cc \
    --cc=Ian.Campbell@XenSource.com \
    --cc=xen-devel@lists.xensource.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 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.