qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Roman Bolshakov <r.bolshakov@yadro.com>, qemu-devel@nongnu.org
Cc: Eduardo Habkost <ehabkost@redhat.com>,
	Cameron Esfahani <dirty@apple.com>,
	Richard Henderson <rth@twiddle.net>
Subject: Re: [PATCH] i386: hvf: Reset IRQ inhibition after moving RIP
Date: Mon, 30 Mar 2020 14:43:03 +0200	[thread overview]
Message-ID: <f013fab5-7a78-5c1c-6070-c23fd2f7ea53@redhat.com> (raw)
In-Reply-To: <20200328174411.51491-1-r.bolshakov@yadro.com>

On 28/03/20 18:44, Roman Bolshakov wrote:
> The sequence of instructions exposes an issue:
>   sti
>   hlt
> 
> Interrupts cannot be delivered to hvf after hlt instruction cpu because
> HF_INHIBIT_IRQ_MASK is set just before hlt is handled and never reset
> after moving instruction pointer beyond hlt.
> 
> So, after hvf_vcpu_exec() returns, CPU thread gets locked up forever in
> qemu_wait_io_event() (cpu_thread_is_idle() evaluates inhibition
> flag and considers the CPU idle if the flag is set).
> 
> Cc: Cameron Esfahani <dirty@apple.com>
> Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
> ---
>  target/i386/hvf/vmx.h | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/target/i386/hvf/vmx.h b/target/i386/hvf/vmx.h
> index 03d2c79b9c..ce2a1532d5 100644
> --- a/target/i386/hvf/vmx.h
> +++ b/target/i386/hvf/vmx.h
> @@ -167,6 +167,8 @@ static inline void macvm_set_cr4(hv_vcpuid_t vcpu, uint64_t cr4)
>  
>  static inline void macvm_set_rip(CPUState *cpu, uint64_t rip)
>  {
> +    X86CPU *x86_cpu = X86_CPU(cpu);
> +    CPUX86State *env = &x86_cpu->env;
>      uint64_t val;
>  
>      /* BUG, should take considering overlap.. */
> @@ -176,6 +178,7 @@ static inline void macvm_set_rip(CPUState *cpu, uint64_t rip)
>     val = rvmcs(cpu->hvf_fd, VMCS_GUEST_INTERRUPTIBILITY);
>     if (val & (VMCS_INTERRUPTIBILITY_STI_BLOCKING |
>                 VMCS_INTERRUPTIBILITY_MOVSS_BLOCKING)) {
> +        env->hflags &= ~HF_INHIBIT_IRQ_MASK;
>          wvmcs(cpu->hvf_fd, VMCS_GUEST_INTERRUPTIBILITY,
>                 val & ~(VMCS_INTERRUPTIBILITY_STI_BLOCKING |
>                 VMCS_INTERRUPTIBILITY_MOVSS_BLOCKING));
> 

Queued, thanks!

Paolo



  reply	other threads:[~2020-03-30 12:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-28 17:44 [PATCH] i386: hvf: Reset IRQ inhibition after moving RIP Roman Bolshakov
2020-03-30 12:43 ` Paolo Bonzini [this message]
2020-03-31  2:04 ` Cameron Esfahani via

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=f013fab5-7a78-5c1c-6070-c23fd2f7ea53@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=dirty@apple.com \
    --cc=ehabkost@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=r.bolshakov@yadro.com \
    --cc=rth@twiddle.net \
    /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).