From: Keir Fraser <keir.xen@gmail.com>
To: Jan Beulich <JBeulich@suse.com>,
"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>
Cc: Yangxiaowei <xiaowei.yang@huawei.com>,
"keir@xen.org" <keir@xen.org>, Eddie Dong <eddie.dong@intel.com>,
Jun Nakajima <jun.nakajima@intel.com>,
Wangzhenguo <wangzhenguo@huawei.com>
Subject: Re: [PATCH v2] x86/HVM: fix x2APIC APIC_ID read emulation
Date: Mon, 10 Jun 2013 13:23:14 +0100 [thread overview]
Message-ID: <CDDB83C2.290BC%keir.xen@gmail.com> (raw)
In-Reply-To: <51B5B36302000078000DC918@nat28.tlf.novell.com>
On 10/06/2013 10:07, "Jan Beulich" <JBeulich@suse.com> wrote:
> APIC and x2APIC have different format for APIC_ID register. Need
> translation.
>
> Signed-off-by: Zhenguo Wang <wangzhenguo@huawei.com>
> Signed-off-by: Xiaowei Yang <xiaowei.yang@huawei.com>
>
> Convert code to use switch(), fixing coding style issue at once, and
> use GET_xAPIC_ID() on the value read instead of VLAPIC_ID() (reading
> the field again).
>
> In the course of this also properly reject both read and writes on the
> non-existing MSR corresponding to APIC_ICR2.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
> --- a/xen/arch/x86/hvm/vlapic.c
> +++ b/xen/arch/x86/hvm/vlapic.c
> @@ -582,8 +582,19 @@ int hvm_x2apic_msr_read(struct vcpu *v,
> return 1;
>
> vlapic_read_aligned(vlapic, offset, &low);
> - if ( offset == APIC_ICR )
> + switch ( offset )
> + {
> + case APIC_ID:
> + low = GET_xAPIC_ID(low);
> + break;
> +
> + case APIC_ICR:
> vlapic_read_aligned(vlapic, APIC_ICR2, &high);
> + break;
> +
> + case APIC_ICR2:
> + return 1;
> + }
>
> *msr_content = (((uint64_t)high) << 32) | low;
> return 0;
> @@ -837,11 +848,17 @@ int hvm_x2apic_msr_write(struct vcpu *v,
> if ( !vlapic_x2apic_mode(vlapic) )
> return X86EMUL_UNHANDLEABLE;
>
> - if ( offset == APIC_ICR )
> + switch ( offset )
> {
> - int rc = vlapic_reg_write(v, APIC_ICR2, (uint32_t)(msr_content >>
> 32));
> + int rc;
> +
> + case APIC_ICR:
> + rc = vlapic_reg_write(v, APIC_ICR2, (uint32_t)(msr_content >> 32));
> if ( rc )
> return rc;
> +
> + case APIC_ICR2:
> + return X86EMUL_UNHANDLEABLE;
> }
>
> return vlapic_reg_write(v, offset, (uint32_t)msr_content);
>
>
>
prev parent reply other threads:[~2013-06-10 12:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-09 2:20 [PATCH] hvm/x86: fix x2APIC APIC_ID read emulation Wangzhenguo
2013-06-09 9:19 ` Wei Liu
2013-06-10 9:07 ` [PATCH v2] x86/HVM: " Jan Beulich
2013-06-10 12:23 ` Keir Fraser [this message]
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=CDDB83C2.290BC%keir.xen@gmail.com \
--to=keir.xen@gmail.com \
--cc=JBeulich@suse.com \
--cc=eddie.dong@intel.com \
--cc=jun.nakajima@intel.com \
--cc=keir@xen.org \
--cc=wangzhenguo@huawei.com \
--cc=xen-devel@lists.xen.org \
--cc=xiaowei.yang@huawei.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 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.