xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Xu Zhang <xzhang@cs.uic.edu>
Cc: gm281@cam.ac.uk, "xen-devel@lists.xen.org" <xen-devel@lists.xen.org>
Subject: Re: Nested events in 64bit mini-OS
Date: Sat, 10 Nov 2012 14:52:18 +0100	[thread overview]
Message-ID: <20121110135218.GA5436@type> (raw)
In-Reply-To: <5098A674.5090203@cs.uic.edu>

Hello,

Xu Zhang, le Mon 05 Nov 2012 23:56:04 -0600, a écrit :
> I haven't seen any updates on this matter, so I try to come up with a fix.

Thanks!

> Generally speaking, I want to mimic 32-bit mini-OS behaviour,

Ok. Probably a good thing :)

> The "git diff" output is attached to this email. I only did some naive
> "tests" by running it inside gdb.

Do you mean that you actually ran a stack merging, even if only in gdb?
I would trust that well enough.

> I am wondering is there a test suite for mini-OS?

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.

> 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.

> +    .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!
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.

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

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

  reply	other threads:[~2012-11-10 13:52 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 [this message]
2012-11-11 15:36       ` Xu Zhang
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=20121110135218.GA5436@type \
    --to=samuel.thibault@ens-lyon.org \
    --cc=gm281@cam.ac.uk \
    --cc=xen-devel@lists.xen.org \
    --cc=xzhang@cs.uic.edu \
    /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).