qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Qin, Chao" <chao.qin@linux.intel.com>
To: Igor Mammedov <imammedo@redhat.com>
Cc: qemu-devel@nongnu.org, yu.ning@linux.intel.com,
	Qin Chao <chao.qin@intel.com>,
	Richard Henderson <rth@twiddle.net>,
	Eduardo Habkost <ehabkost@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] hax: Properly handle IA32_APIC_BASE MSR
Date: Tue, 20 Mar 2018 13:29:24 +0800	[thread overview]
Message-ID: <c7354c76-afb6-e6f2-a0ca-86b6077228ea@linux.intel.com> (raw)
In-Reply-To: <20180319170525.1016391d@igors-macbook-pro.local>



On 3/20/2018 12:05 AM, Igor Mammedov wrote:
> On Mon, 19 Mar 2018 17:04:49 +0800 chao.qin@linux.intel.com wrote:  > >> From: Qin Chao <chao.qin@intel.com> >> >> Emulation of 
IA32_APIC_BASE MSR in HAXM is not correct, such as >> bit 8, which is 
BSP flag and should be set to 1 for the bootstrap >> processor and set 
to 0 for the application processors, but it's >> set to 0 for all 
processors in HAXM. So guest OSes that expect a >> valid BSP flag, such 
as Zircon (the core of Google Fuchsia OS), >> cannot boot with "-accel 
hax". To solve this problem, HAXM (which >> lacks APIC virtualization) 
and QEMU must notify each other of any >> change to guest IA32_APIC_BASE 
MSR. The HAXM patch has been merged >> into HAXM source. QEMU needs to 
use the new HAXM API (apic_base in >> "struct hax_tunnel") to initialize 
the guest IA32_APIC_BASE MSR, >> and then, update its own copy at every 
return from >> HAX_VCPU_IOCTL_RUN. >> >> There will be a backward 
compatility issue caused by the new field >> "apic_base" added into 
"struct hax_tunnel". In order to fix the >> problem, the validation for 
size of "struct hax_tunnel" is removed >> and a new capability flag 
"HAX_CAP_TUNNEL_PAGE" is added, which >> means that one page (4KB) is 
allocated in HAXM kernel to store >> "struct hax_tunnel", instead of the 
size of "struct hax_tunnel". >> >> Change-Id: 
I8505bc1d75c495dd2765e581d6014125dcb538f3 Signed-off-by: >> Qin Chao 
<chao.qin@intel.com> --- target/i386/hax-all.c | 24 >> 
+++++++++++++++++++----- target/i386/hax-darwin.c | 6 ------ >> 
target/i386/hax-i386.h | 2 +- target/i386/hax-interface.h | >> 3 +++ 
target/i386/hax-windows.c | 5 ----- 5 files changed, 23 >> 
insertions(+), 17 deletions(-) >> >> diff --git a/target/i386/hax-all.c 
b/target/i386/hax-all.c index >> cad7531..6a840d9 100644 --- 
a/target/i386/hax-all.c +++ >> b/target/i386/hax-all.c > [...] >> @@ 
-933,6 +944,9 @@ static int hax_set_msrs(CPUArchState *env) >> 
hax_msr_entry_set(&msrs[n++], MSR_FMASK, env->fmask); >> 
hax_msr_entry_set(&msrs[n++], MSR_KERNELGSBASE, >> env->kernelgsbase); 
#endif + hax_msr_entry_set(&msrs[n++], >> MSR_IA32_APICBASE, \ + >> 
cpu_get_apic_base(x86_env_get_cpu(env)->apic_state)); + md.nr_msr = >> 
n; md.done = 0; > Does it work for you if you drop everything except of 
this chunk?
Yes, it works just with this chunk.

>  > There is no much point in syncing BPS flag from HAXM since Seabios > 
nor OVMF do not implement BSP selection protocol, it's hard-coded in > 
QEMU that BSP is the first CPU. > > Considering that typically no sane 
OS does change MSR_IA32_APICBASE > there is no need to sync it back to 
QEMU. So no need to introduce all > that complexity for no gain.
Yes, the BSP is hard-coded in QEMU. But other bits, not just BSP flag, are
also needed to sync from HAXM, such as x2APIC mode flag (bit 10) and
APIC enable/disable flag(bit 11). As in the Google Zircon
(https://github.com/fuchsia-mirror/zircon/blob/master/kernel/arch/x86/lapic.cpp#L157),
it will change IA32_APIC_BASE[10] and set the bit to 1 if x2APIC enabled.
Although x2APIC mode is not supported yet for TCG mode, it's worthy to
keep the codes that syncing IA32_APIC_BASE from HAXM to QEMU and if
x2APIC mode is supported for TCG in future, there is no any effort needed
to make HAXM to work with this mode. Also, in KVM it will synced the
IA32_APIC_BASE MSR to QEMU at every VM-Exit.

>  > [...] > > >

  reply	other threads:[~2018-03-20  5:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-19  9:04 [Qemu-devel] [PATCH] hax: Properly handle IA32_APIC_BASE MSR chao.qin
2018-03-19 15:52 ` Paolo Bonzini
2018-03-19 16:05 ` Igor Mammedov
2018-03-20  5:29   ` Qin, Chao [this message]
2018-03-20  7:12     ` Igor Mammedov
2018-03-20  7:45       ` Qin, Chao

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=c7354c76-afb6-e6f2-a0ca-86b6077228ea@linux.intel.com \
    --to=chao.qin@linux.intel.com \
    --cc=chao.qin@intel.com \
    --cc=ehabkost@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=yu.ning@linux.intel.com \
    /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).