xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Xu Zhang <xzhang@cs.uic.edu>
To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>,
	gm281@cam.ac.uk
Subject: Re: Nested events in 64bit mini-OS
Date: Sun, 11 Nov 2012 09:36:22 -0600	[thread overview]
Message-ID: <509FC5F6.4050506@cs.uic.edu> (raw)
In-Reply-To: <20121110135218.GA5436@type>

Samuel,

Thanks for the reply.

On 11/10/2012 07:52 AM, Samuel Thibault wrote:

> You can simply run it, giving it a blk dev (or also a fb dev), it will
> run app_main(), which keeps reading stuff, and draws squares on the fb.
>
> Ideally you should manage to trigger fixups, by stuffing a wait loop in
> the critical section.
I'll try this in the following week. Thank you for pointing it out.

>> A follow-up question is that given this fix, do you still need
>> hypercall iret?
> Actually it's worse than that, see below.
>
>> +	movq %rbx,5*8(%rsp)
> ...
>> +
>> +	# check against re-entrance
>> +	movq RIP(%rsp),%rbx
>> +	cmpq $scrit,%rbx
>> +	jb 10f
>> +	cmpq $ecrit,%rbx
>> +	jb  critical_region_fixup
>> +
>> +10:	movq RBX(%rsp),%rbx			# restore rbx
> Do we really need to restore %rbx?  I don't think do_hypervisor_callback
> uses it.
No I don't think so. I was just being pre-cautious. :-)

>> +    .byte 0x78,0x78,0x78,0x78,0x78            # jmp    hypercall_page + (__HYPERVISOR_iret * 32)
> Here we would also need a fixup table for the code at hypercall_page!
Nice catch!

> A nicer fix would be to inline the hypercall code here.  That said, I
> have to say I don't know any detail about the NMI flag, I don't see it
> defined in the Intel manual, and I don't see it being set in the Xen
> hypervisor.  Unless somebody knows more about it, I would assume that it
> currently never happens, and simply stuff a
>
> ud2 /* TODO: fix re-entrance fixup for hypercall in NMI case (when does that happen actually?) */
>
> before the jmp, to catch it if it ever does happen.
I don't know that either. I tried to rise guest domain an NMI with "xl 
trigger", but it seems that only works for HVM hosts.

>
> Also, it would be good to check against critical section size change, in
> case somebody e.g. changes a value, or a macro like XEN_PUT_VCPU_INFO.
> For instance, stuff right after the table:
>
> 	.if (ecrit-scrit) != (critical_fixup_table_end - critical_fixup_table)
> 	.error "The critical has changed, the fixup table needs updating"
> 	.endif
Totally agree. And it somewhat saves the obligation of checking if the 
table size matches the one of critical section by looking at disassemble 
output. :-)

>
> More generally, some cleanup could go along the patch, but I'd say
> keep it as you have done, focused on only the fixup code, to have it
> as such in the repository history, and then we could clean some things
> afterwards.
>
> Samuel
>
I really appreciate your feedback. Thanks again, Samuel!

Xu

  reply	other threads:[~2012-11-11 15:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-23 22:43 Nested events in 64bit mini-OS Xu Zhang
2012-10-25 20:56 ` Samuel Thibault
2012-11-06  5:56   ` Xu Zhang
2012-11-10 13:52     ` Samuel Thibault
2012-11-11 15:36       ` Xu Zhang [this message]
2012-11-14  1:49         ` Xu Zhang
2012-11-18 17:43           ` Samuel Thibault
2012-11-19 10:22             ` Ian Campbell
2012-11-19 10:21       ` Ian Campbell

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=509FC5F6.4050506@cs.uic.edu \
    --to=xzhang@cs.uic.edu \
    --cc=gm281@cam.ac.uk \
    --cc=samuel.thibault@ens-lyon.org \
    --cc=xen-devel@lists.xen.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).