From: Paolo Bonzini <pbonzini@redhat.com>
To: Roman Bolshakov <r.bolshakov@yadro.com>, qemu-devel@nongnu.org
Cc: Eduardo Habkost <ehabkost@redhat.com>,
Claudio Fontana <cfontana@suse.de>,
Cameron Esfahani <dirty@apple.com>,
Richard Henderson <rth@twiddle.net>
Subject: Re: [PATCH v2 4/9] i386: hvf: Implement CPU kick
Date: Tue, 30 Jun 2020 14:33:42 +0200 [thread overview]
Message-ID: <d75c6bd1-b588-796b-e238-21ff41fce60d@redhat.com> (raw)
In-Reply-To: <20200630102824.77604-5-r.bolshakov@yadro.com>
On 30/06/20 12:28, Roman Bolshakov wrote:
> @@ -966,6 +964,20 @@ int hvf_vcpu_exec(CPUState *cpu)
> return ret;
> }
>
> +void hvf_vcpu_kick(CPUState *cpu)
> +{
> + X86CPU *x86_cpu = X86_CPU(cpu);
> + CPUX86State *env = &x86_cpu->env;
> + hv_return_t err;
> +
> + atomic_set(&env->hvf_deadline, 0);
> + err = hv_vcpu_interrupt(&cpu->hvf_fd, 1);
> + if (err) {
> + fprintf(stderr, "qemu:%s error %#x\n", __func__, err);
> + exit(1);
> + }
Can a signal interrupt hv_vcpu_run? If so you actually don't need
hv_vcpu_interrupt at all. You can also require the preemption time, all
processor that support HVF have it, but never set it by default. The
deadline can be left at 0 all the time; instead, you toggle the bit in
the pin-based controls. In the signal handler you do:
if (atomic_xchg(&env->hvf_in_guest, false)) {
wvmcs(cpu->hvf_fd, VMCS_PIN_BASED_CTLS,
rvmcs(cpu->hvf_fd, VMCS_PIN_BASED_CTLS)
| VMCS_PIN_BASED_CTLS_VMX_PREEMPT_TIMER);
}
In the main loop you do:
atomic_set(&env->hvf_guest_mode, true);
smp_mb();
hv_vcpu_run(...);
atomic_set(&env->hvf_guest_mode, false);
and in the preemption timer vmexit handler:
wvmcs(cpu->hvf_fd, VMCS_PIN_BASED_CTLS,
rvmcs(cpu->hvf_fd, VMCS_PIN_BASED_CTLS)
& ~VMCS_PIN_BASED_CTLS_VMX_PREEMPT_TIMER);
I'll leave out this patch in the meanwhile.
Paolo
> +}
> +
> bool hvf_allowed;
>
> static int hvf_accel_init(MachineState *ms)
> diff --git a/target/i386/hvf/vmcs.h b/target/i386/hvf/vmcs.h
> index 42de7ebc3a..6615365023 100644
> --- a/target/i386/hvf/vmcs.h
> +++ b/target/i386/hvf/vmcs.h
> @@ -349,6 +349,7 @@
> #define VMCS_PIN_BASED_CTLS_EXTINT (1 << 0)
> #define VMCS_PIN_BASED_CTLS_NMI (1 << 3)
> #define VMCS_PIN_BASED_CTLS_VNMI (1 << 5)
> +#define VMCS_PIN_BASED_CTLS_VMX_PREEMPT_TIMER (1 << 6)
>
> #define VMCS_PRI_PROC_BASED_CTLS_INT_WINDOW_EXITING (1 << 2)
> #define VMCS_PRI_PROC_BASED_CTLS_TSC_OFFSET (1 << 3)
>
next prev parent reply other threads:[~2020-06-30 12:38 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-30 10:28 [PATCH v2 0/9] Improve synchronization between QEMU and HVF Roman Bolshakov
2020-06-30 10:28 ` [PATCH v2 1/9] i386: hvf: Set env->eip in macvm_set_rip() Roman Bolshakov
2020-06-30 12:35 ` Paolo Bonzini
2020-06-30 10:28 ` [PATCH v2 2/9] i386: hvf: Move synchronize functions to sysemu Roman Bolshakov
2020-06-30 10:28 ` [PATCH v2 3/9] i386: hvf: Add hvf_cpu_synchronize_pre_loadvm() Roman Bolshakov
2020-06-30 10:28 ` [PATCH v2 4/9] i386: hvf: Implement CPU kick Roman Bolshakov
2020-06-30 12:33 ` Paolo Bonzini [this message]
2020-06-30 15:50 ` Roman Bolshakov
2020-06-30 16:04 ` Paolo Bonzini
2020-07-01 18:36 ` Roman Bolshakov
2020-07-01 18:50 ` Paolo Bonzini
2020-06-30 10:28 ` [PATCH v2 5/9] i386: hvf: Make long mode enter and exit clearer Roman Bolshakov
2020-06-30 10:28 ` [PATCH v2 6/9] i386: hvf: Move Guest LMA reset to macvm_set_cr0() Roman Bolshakov
2020-06-30 10:28 ` [PATCH v2 7/9] i386: hvf: Don't duplicate register reset Roman Bolshakov
2020-06-30 10:28 ` [PATCH v2 8/9] i386: hvf: Clean up synchronize functions Roman Bolshakov
2020-06-30 10:28 ` [PATCH v2 9/9] MAINTAINERS: Add Cameron as HVF co-maintainer Roman Bolshakov
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=d75c6bd1-b588-796b-e238-21ff41fce60d@redhat.com \
--to=pbonzini@redhat.com \
--cc=cfontana@suse.de \
--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).