From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Xen-devel <xen-devel@lists.xenproject.org>, Wei Liu <wl@xen.org>,
Jan Beulich <JBeulich@suse.com>
Subject: Re: [PATCH] x86/vmce: Dispatch vmce_{rd,wr}msr() from guest_{rd,wr}msr()
Date: Thu, 23 Jul 2020 12:07:27 +0200 [thread overview]
Message-ID: <20200723100727.GA7191@Air-de-Roger> (raw)
In-Reply-To: <20200722101809.8389-1-andrew.cooper3@citrix.com>
On Wed, Jul 22, 2020 at 11:18:09AM +0100, Andrew Cooper wrote:
> ... rather than from the default clauses of the PV and HVM MSR handlers.
>
> This means that we no longer take the vmce lock for any unknown MSR, and
> accesses to architectural MCE banks outside of the subset implemented for the
> guest no longer fall further through the unknown MSR path.
>
> With the vmce calls removed, the hvm alternative_call()'s expression can be
> simplified substantially.
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
LGTM, I just have one question below regarding the ranges.
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
> ---
> CC: Jan Beulich <JBeulich@suse.com>
> CC: Wei Liu <wl@xen.org>
> CC: Roger Pau Monné <roger.pau@citrix.com>
> ---
> xen/arch/x86/hvm/hvm.c | 16 ++--------------
> xen/arch/x86/msr.c | 16 ++++++++++++++++
> xen/arch/x86/pv/emul-priv-op.c | 15 ---------------
> 3 files changed, 18 insertions(+), 29 deletions(-)
>
> diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
> index 5bb47583b3..a9d1685549 100644
> --- a/xen/arch/x86/hvm/hvm.c
> +++ b/xen/arch/x86/hvm/hvm.c
> @@ -3560,13 +3560,7 @@ int hvm_msr_read_intercept(unsigned int msr, uint64_t *msr_content)
> break;
>
> default:
> - if ( (ret = vmce_rdmsr(msr, msr_content)) < 0 )
> - goto gp_fault;
> - /* If ret == 0 then this is not an MCE MSR, see other MSRs. */
> - ret = ((ret == 0)
> - ? alternative_call(hvm_funcs.msr_read_intercept,
> - msr, msr_content)
> - : X86EMUL_OKAY);
> + ret = alternative_call(hvm_funcs.msr_read_intercept, msr, msr_content);
> break;
> }
>
> @@ -3696,13 +3690,7 @@ int hvm_msr_write_intercept(unsigned int msr, uint64_t msr_content,
> break;
>
> default:
> - if ( (ret = vmce_wrmsr(msr, msr_content)) < 0 )
> - goto gp_fault;
> - /* If ret == 0 then this is not an MCE MSR, see other MSRs. */
> - ret = ((ret == 0)
> - ? alternative_call(hvm_funcs.msr_write_intercept,
> - msr, msr_content)
> - : X86EMUL_OKAY);
> + ret = alternative_call(hvm_funcs.msr_write_intercept, msr, msr_content);
> break;
> }
>
> diff --git a/xen/arch/x86/msr.c b/xen/arch/x86/msr.c
> index 22f921cc71..ca4307e19f 100644
> --- a/xen/arch/x86/msr.c
> +++ b/xen/arch/x86/msr.c
> @@ -227,6 +227,14 @@ int guest_rdmsr(struct vcpu *v, uint32_t msr, uint64_t *val)
> *val = msrs->misc_features_enables.raw;
> break;
>
> + case MSR_IA32_MCG_CAP ... MSR_IA32_MCG_CTL: /* 0x179 -> 0x17b */
> + case MSR_IA32_MCx_CTL2(0) ... MSR_IA32_MCx_CTL2(31): /* 0x280 -> 0x29f */
> + case MSR_IA32_MCx_CTL(0) ... MSR_IA32_MCx_MISC(31): /* 0x400 -> 0x47f */
Where do you get the ranges from 0 to 31? It seems like the count
field in the CAP register is 8 bits, which could allow for up to 256
banks?
I'm quite sure this would then overlap with other MSRs?
> + case MSR_IA32_MCG_EXT_CTL: /* 0x4d0 */
> + if ( vmce_rdmsr(msr, val) < 0 )
> + goto gp_fault;
> + break;
> +
> case MSR_X2APIC_FIRST ... MSR_X2APIC_LAST:
> if ( !is_hvm_domain(d) || v != curr )
> goto gp_fault;
> @@ -436,6 +444,14 @@ int guest_wrmsr(struct vcpu *v, uint32_t msr, uint64_t val)
> break;
> }
>
> + case MSR_IA32_MCG_CAP ... MSR_IA32_MCG_CTL: /* 0x179 -> 0x17b */
> + case MSR_IA32_MCx_CTL2(0) ... MSR_IA32_MCx_CTL2(31): /* 0x280 -> 0x29f */
> + case MSR_IA32_MCx_CTL(0) ... MSR_IA32_MCx_MISC(31): /* 0x400 -> 0x47f */
> + case MSR_IA32_MCG_EXT_CTL: /* 0x4d0 */
> + if ( vmce_wrmsr(msr, val) < 0 )
> + goto gp_fault;
> + break;
> +
> case MSR_X2APIC_FIRST ... MSR_X2APIC_LAST:
> if ( !is_hvm_domain(d) || v != curr )
> goto gp_fault;
> diff --git a/xen/arch/x86/pv/emul-priv-op.c b/xen/arch/x86/pv/emul-priv-op.c
> index 254da2b849..f14552cb4b 100644
> --- a/xen/arch/x86/pv/emul-priv-op.c
> +++ b/xen/arch/x86/pv/emul-priv-op.c
> @@ -855,8 +855,6 @@ static int read_msr(unsigned int reg, uint64_t *val,
>
> switch ( reg )
> {
> - int rc;
> -
> case MSR_FS_BASE:
> if ( is_pv_32bit_domain(currd) )
> break;
> @@ -955,12 +953,6 @@ static int read_msr(unsigned int reg, uint64_t *val,
> }
> /* fall through */
> default:
> - rc = vmce_rdmsr(reg, val);
> - if ( rc < 0 )
> - break;
> - if ( rc )
> - return X86EMUL_OKAY;
> - /* fall through */
> normal:
We could remove the 'normal' label and just use the default one
instead.
Thanks, Roger.
next prev parent reply other threads:[~2020-07-23 10:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-22 10:18 [PATCH] x86/vmce: Dispatch vmce_{rd,wr}msr() from guest_{rd,wr}msr() Andrew Cooper
2020-07-23 10:07 ` Roger Pau Monné [this message]
2020-07-23 11:00 ` Andrew Cooper
2020-07-23 11:30 ` Roger Pau Monné
2020-07-23 13:27 ` Andrew Cooper
2020-07-23 10:37 ` Jan Beulich
2020-07-23 11:17 ` Andrew Cooper
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=20200723100727.GA7191@Air-de-Roger \
--to=roger.pau@citrix.com \
--cc=JBeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=wl@xen.org \
--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.