All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boris Ostrovsky <boris.ostrovsky@oracle.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>,
	Jan Beulich <JBeulich@suse.com>
Cc: Juergen Gross <jgross@suse.com>,
	xen-devel <xen-devel@lists.xenproject.org>,
	Brian Woods <brian.woods@amd.com>,
	"Suthikulpanit, Suravee" <Suravee.Suthikulpanit@amd.com>
Subject: Re: [PATCH v3 2/2] SVM: introduce a VM entry helper
Date: Mon, 7 May 2018 12:16:56 -0400	[thread overview]
Message-ID: <c0125585-df75-2aeb-8ae0-c4a39a492ea1@oracle.com> (raw)
In-Reply-To: <72fe7254-0391-a113-8d7f-19a80a49e89f@citrix.com>

On 05/07/2018 11:49 AM, Andrew Cooper wrote:
> On 07/05/18 16:46, Boris Ostrovsky wrote:
>> On 05/07/2018 11:29 AM, Andrew Cooper wrote:
>>> On 07/05/18 16:25, Jan Beulich wrote:
>>>>>>> On 07.05.18 at 16:19, <andrew.cooper3@citrix.com> wrote:
>>>>> On 07/05/18 15:11, Jan Beulich wrote:
>>>>>>>>> On 04.05.18 at 17:11, <JBeulich@suse.com> wrote:
>>>>>>> --- a/xen/arch/x86/hvm/svm/entry.S
>>>>>>> +++ b/xen/arch/x86/hvm/svm/entry.S
>>>>>>> @@ -61,23 +61,8 @@ UNLIKELY_START(ne, nsvm_hap)
>>>>>>>          jmp  .Lsvm_do_resume
>>>>>>>  __UNLIKELY_END(nsvm_hap)
>>>>>>>  
>>>>>>> -        call svm_asid_handle_vmrun
>>>>>>> -
>>>>>>> -        cmpb $0,tb_init_done(%rip)
>>>>>>> -UNLIKELY_START(nz, svm_trace)
>>>>>>> -        call svm_trace_vmentry
>>>>>>> -UNLIKELY_END(svm_trace)
>>>>>>> -
>>>>>>> -        mov  VCPU_svm_vmcb(%rbx),%rcx
>>>>>>> -        mov  UREGS_rax(%rsp),%rax
>>>>>>> -        mov  %rax,VMCB_rax(%rcx)
>>>>>>> -        mov  UREGS_rip(%rsp),%rax
>>>>>>> -        mov  %rax,VMCB_rip(%rcx)
>>>>>>> -        mov  UREGS_rsp(%rsp),%rax
>>>>>>> -        mov  %rax,VMCB_rsp(%rcx)
>>>>>>> -        mov  UREGS_eflags(%rsp),%rax
>>>>>>> -        or   $X86_EFLAGS_MBS,%rax
>>>>>>> -        mov  %rax,VMCB_rflags(%rcx)
>>>>>>> +        mov  %rsp, %rdi
>>>>>>> +        call svm_vmenter_helper
>>>>>> While I had committed this earlier today, there's one concern I've just come
>>>>>> to think of: Now that we're calling into C land with CLGI in effect (for 
>>>>> more
>>>>>> than just the trivial svm_trace_vmentry()) we are at risk of confusing
>>>>>> parties using local_irq_is_enabled(), first and foremost
>>>>>> common/spinlock.c:check_lock(). While it's some extra overhead, I wonder
>>>>>> whether the call wouldn't better be framed by a CLI/STI pair.
>>>>> I can't see why the SVM vmentry path uses CLGI/STGI in the first place.
>>>>>
>>>>> The VMX path uses plain cli/sti and our NMI/MCE handlers can cope. 
>>>>> Furthermore, processing NMIs/MCEs at this point will be more efficient
>>>>> that taking a vmentry then immediately exiting again.
>>>> Perhaps you're right, i.e. we could replace all current CLGI/STGI by
>>>> CLI/STI, adding a single STGI right after VMRUN.
>> The APM say "It is assumed that VMM software cleared GIF some time before
>> executing the VMRUN instruction, to ensure an atomic state switch."
>>
>> Not sure if this is meant as suggestion or requirement.
> Hmm - that can probably be tested with this proposed patch and a very
> high frequency NMI perf counter.


This may only prove the we do need it, if the test without CLGI fails.

If the test passes I don't think we can say anything one way or the other.

I am adding Suravee and Brian, perhaps they know the answer (or can
check internally).


>
> Basically every other hypervisor does CLGI; VMSAVE (host state); VMLOAD
> (guest state); VMRUN, and Xen's lack of doing this is why we have to
> play with the IDT IST settings, as well as why we can't cope cleanly
> with stack overflows.
>

KVM manipulates both GIF and RFLAGS.IF.

-boris

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2018-05-07 16:14 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-04 15:07 [PATCH v3 0/2] SVM: guest state handling adjustments Jan Beulich
2018-05-04 15:10 ` [PATCH v3 1/2] SVM: re-work VMCB sync-ing Jan Beulich
2018-05-04 15:11 ` [PATCH v3 2/2] SVM: introduce a VM entry helper Jan Beulich
2018-05-07 14:11   ` Jan Beulich
2018-05-07 14:19     ` Andrew Cooper
2018-05-07 15:25       ` Jan Beulich
2018-05-07 15:29         ` Andrew Cooper
2018-05-07 15:46           ` Boris Ostrovsky
2018-05-07 15:47             ` Jan Beulich
2018-05-07 15:49             ` Andrew Cooper
2018-05-07 16:16               ` Boris Ostrovsky [this message]
2018-05-04 17:52 ` [PATCH v3 0/2] SVM: guest state handling adjustments Andrew Cooper
2018-05-04 18:38 ` Boris Ostrovsky
     [not found] ` <5AEC77E802000078001C0BEB@suse.com>
2018-05-07  6:30   ` [PATCH v3 1/2] SVM: re-work VMCB sync-ing Juergen Gross
     [not found] ` <5AEC782902000078001C0BEE@suse.com>
2018-05-07  6:31   ` [PATCH v3 2/2] SVM: introduce a VM entry helper Juergen Gross

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=c0125585-df75-2aeb-8ae0-c4a39a492ea1@oracle.com \
    --to=boris.ostrovsky@oracle.com \
    --cc=JBeulich@suse.com \
    --cc=Suravee.Suthikulpanit@amd.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=brian.woods@amd.com \
    --cc=jgross@suse.com \
    --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.