From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: xen-devel <xen-devel@lists.xenproject.org>,
Keir Fraser <keir@xen.org>, Eddie Dong <eddie.dong@intel.com>,
Jun Nakajima <jun.nakajima@intel.com>
Subject: Re: [PATCH 1/4] VMX: streamline entry.S code
Date: Mon, 26 Aug 2013 12:48:52 +0100 [thread overview]
Message-ID: <521B40A4.2090704@citrix.com> (raw)
In-Reply-To: <521B51B702000078000EE53E@nat28.tlf.novell.com>
On 26/08/2013 12:01, Jan Beulich wrote:
>>> push %r8
>>> push %r9
>>> push %r10
>>> push %r11
>>> push %rbx
>>> + GET_CURRENT(%rbx)
>> This seems a little less obvious. I presume you are just breaking true
>> read-after-write data hazard on %rbx ?
> No, this is to hide the latency between loading %rbx and use of
> it in the address of a memory access.
Right - so we are talking about the same thing.
>
>>> -.globl vmx_asm_do_vmentry
>>> -vmx_asm_do_vmentry:
>> If you move the ENTRY(vmx_asm_do_vmentry) up from below, you should be
>> able to completely drop the jmp in it.
> That would be possible, at the expense of added padding. I prefer
> it the way it is now, as vmx_asm_do_vmentry is not performance
> critical (as being used exactly once per HVM vCPU).
There are a number of places where we have ENTRY()-like constructs but
don't want the padding with it.
Would an __ENTRY() macro go down well? I can spin a patch for it.
>> However...
>>
>>> +.Lvmx_do_vmentry:
>>> call vmx_intr_assist
>>> call nvmx_switch_guest
>>> ASSERT_NOT_IN_ATOMIC
>>>
>>> - GET_CURRENT(%rbx)
>>> - cli
>> The movement of this cli indicates a possible issue.
>>
>> If we have softirqs pending, we jump to .Lvmx_process_softirqs, which
>> calls do_softirq, and then jumps back to the top of .Lvmx_do_vmentry,
>> which reruns the top of do_vmentry with interrupts now enabled.
> That was this way already before. The "cli" got moved only past
> some address calculation (which clearly doesn't need to be done
> with interrupts disabled).
Sorry - I wasn't clear. It was simply the cli moving place that caused
me to notice, rather than the behaviour actually changing.
>
>> First of all, I cant see anything in vmx_intr_assist or
>> nvmx_switch_guest which should require calling multiple times on a
>> vmentry. They are also expecting to be called with interrupts disabled
>> (although I cant spot anything obvious in the callpath which would be
>> affected).
> And both of these functions had been called before disabling
> interrupts.
I need more coffee - I had mentally swapped cli and sti.
My point about re-executing it does still apply. Looking at the code, I
do not believe it is correct to be executing vmx_intr_assist or
nvmx_switch_guest multiple times on a context switch to an HVM VCPU.
vmx_intr_assist at the very least has a huge amount of work to do before
it considers exiting.
It does appear that there is possible interaction between do_softirq()
and vmx_intr_assist(), at which point vmx_intr_assist() should be run
after do_softirq(), which removes the apparently redundant run with
interrupts enabled.
>
>>> - cmpb $0,VCPU_vmx_launched(%rbx)
>>> pop %r15
>>> pop %r14
>>> pop %r13
>>> pop %r12
>>> pop %rbp
>>> + mov %rax,%cr2
>>> + cmpb $0,VCPU_vmx_launched(%rbx)
>> Again, I presume the move of "mov %rax,%cr2" is about the %rax data hazard?
> The %cr2 write's move is indeed debatable - I tried to get it farther
> away from the producer of the data in %rax, but it's not clear
> whether that's very useful. The second purpose was to get
> something interleaved with the many "pop"s, so that the CPU can
> get busy other than just its memory load ports. If controversial
> I'm fine with undoing that change.
>
> Jan
>From my understanding of a serialising instruction, it forces the
completion of all previous instructions before starting, and prevents
the issue of any subsequent instructions until it itself has completed.
Therefore, I doubt it has the intended effect.
~Andrew
next prev parent reply other threads:[~2013-08-26 11:48 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-23 13:58 [PATCH 0/4] HVM: produce better binary code Jan Beulich
2013-08-23 14:01 ` [PATCH 1/4] VMX: streamline entry.S code Jan Beulich
2013-08-26 10:44 ` Andrew Cooper
2013-08-26 11:01 ` Jan Beulich
2013-08-26 11:48 ` Andrew Cooper [this message]
2013-08-26 13:12 ` Jan Beulich
2013-08-26 13:22 ` Andrew Cooper
2013-08-29 11:01 ` Tim Deegan
2013-08-29 12:35 ` Jan Beulich
2013-08-23 14:02 ` [PATCH 2/4] VMX: move various uses of UD2 out of fast paths Jan Beulich
2013-08-23 22:06 ` Andrew Cooper
2013-08-26 8:50 ` Jan Beulich
2013-08-26 9:07 ` Andrew Cooper
2013-08-26 8:58 ` [PATCH v2 " Jan Beulich
2013-08-26 9:09 ` Andrew Cooper
2013-08-29 11:08 ` Tim Deegan
2013-08-23 14:03 ` [PATCH 3/4] VMX: use proper instruction mnemonics if assembler supports them Jan Beulich
2013-08-24 22:18 ` Andrew Cooper
2013-08-26 9:06 ` Jan Beulich
2013-08-26 9:25 ` Andrew Cooper
2013-08-26 9:41 ` Jan Beulich
2013-08-26 10:18 ` [PATCH v3 " Jan Beulich
2013-08-26 13:05 ` Andrew Cooper
2013-08-26 13:20 ` Jan Beulich
2013-08-26 14:03 ` [PATCH v4 " Jan Beulich
2013-08-26 14:18 ` Andrew Cooper
2013-08-26 14:29 ` Jan Beulich
2013-08-26 15:07 ` Andrew Cooper
2013-08-26 15:10 ` Andrew Cooper
2013-08-26 15:30 ` Jan Beulich
2013-08-26 15:29 ` Jan Beulich
2013-08-26 15:33 ` Andrew Cooper
2013-08-26 15:31 ` [PATCH v5 " Jan Beulich
2013-08-26 15:36 ` Andrew Cooper
2013-08-29 11:47 ` Tim Deegan
2013-08-29 12:30 ` Jan Beulich
2013-08-29 13:11 ` Tim Deegan
2013-08-29 13:27 ` Jan Beulich
2013-08-29 14:02 ` Tim Deegan
2013-08-29 12:45 ` Jan Beulich
2013-08-29 13:19 ` Tim Deegan
2013-08-26 9:03 ` [PATCH v2 " Jan Beulich
2013-08-23 14:04 ` [PATCH 4/4] SVM: streamline entry.S code Jan Beulich
2013-08-26 16:20 ` Andrew Cooper
2013-08-26 17:20 ` Keir Fraser
2013-08-26 17:46 ` Andrew Cooper
2013-08-26 21:47 ` Andrew Cooper
2013-08-27 7:38 ` Jan Beulich
2013-08-29 11:56 ` Tim Deegan
2013-09-04 14:39 ` Boris Ostrovsky
2013-09-04 14:50 ` Jan Beulich
2013-09-04 15:09 ` Boris Ostrovsky
2013-09-04 15:20 ` Jan Beulich
2013-09-04 16:42 ` Boris Ostrovsky
2013-09-05 7:10 ` Jan Beulich
2013-09-04 10:06 ` Ping: [PATCH 0/4] HVM: produce better binary code Jan Beulich
2013-09-04 16:16 ` Andrew Cooper
2013-09-04 16:30 ` Tim Deegan
2013-09-05 7:52 ` Jan Beulich
2013-09-05 7:58 ` Tim Deegan
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=521B40A4.2090704@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=eddie.dong@intel.com \
--cc=jun.nakajima@intel.com \
--cc=keir@xen.org \
--cc=xen-devel@lists.xenproject.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.