kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Krish Sadhukhan <krish.sadhukhan@oracle.com>
To: Nadav Amit <nadav.amit@gmail.com>, Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, Marc Orr <marcorr@google.com>
Subject: Re: [kvm-unit-tests PATCH] x86: vmx: Consider CMCI enabled based on IA32_MCG_CAP[10]
Date: Wed, 26 Jun 2019 17:13:24 -0700	[thread overview]
Message-ID: <0f1322a1-6019-97e8-178a-70556dc349d4@oracle.com> (raw)
In-Reply-To: <20190625120756.8781-1-nadav.amit@gmail.com>


On 6/25/19 5:07 AM, Nadav Amit wrote:
> CMCI is enabled if IA32_MCG_CAP[10] is set. VMX tests do not respect
> this condition. Fix it.
>
> Cc: Marc Orr <marcorr@google.com>
> Signed-off-by: Nadav Amit <nadav.amit@gmail.com>
> ---
>   x86/vmx_tests.c | 19 ++++++++++++++-----
>   1 file changed, 14 insertions(+), 5 deletions(-)
>
> diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
> index 3731757..1776e46 100644
> --- a/x86/vmx_tests.c
> +++ b/x86/vmx_tests.c
> @@ -5855,6 +5855,11 @@ static u64 virt_x2apic_mode_nibble1(u64 val)
>   	return val & 0xf0;
>   }
>   
> +static bool is_cmci_enabled(void)
> +{
> +	return rdmsr(MSR_IA32_MCG_CAP) & BIT_ULL(10);
> +}
> +
>   static void virt_x2apic_mode_rd_expectation(
>   	u32 reg, bool virt_x2apic_mode_on, bool disable_x2apic,
>   	bool apic_register_virtualization, bool virtual_interrupt_delivery,
> @@ -5862,8 +5867,10 @@ static void virt_x2apic_mode_rd_expectation(
>   {
>   	bool readable =
>   		!x2apic_reg_reserved(reg) &&
> -		reg != APIC_EOI &&
> -		reg != APIC_CMCI;
> +		reg != APIC_EOI;
> +
> +	if (reg == APIC_CMCI && !is_cmci_enabled())
> +		readable = false;
>   
>   	expectation->rd_exit_reason = VMX_VMCALL;
>   	expectation->virt_fn = virt_x2apic_mode_identity;
> @@ -5893,9 +5900,6 @@ static void virt_x2apic_mode_rd_expectation(
>    * For writable registers, get_x2apic_wr_val() deposits the write value into the
>    * val pointer arg and returns true. For non-writable registers, val is not
>    * modified and get_x2apic_wr_val() returns false.
> - *
> - * CMCI, including the LVT CMCI register, is disabled by default. Thus,
> - * get_x2apic_wr_val() treats this register as non-writable.
>    */
>   static bool get_x2apic_wr_val(u32 reg, u64 *val)
>   {
> @@ -5930,6 +5934,11 @@ static bool get_x2apic_wr_val(u32 reg, u64 *val)
>   		 */
>   		*val = apic_read(reg);
>   		break;
> +	case APIC_CMCI:
> +		if (!is_cmci_enabled())
> +			return false;
> +		*val = apic_read(reg);
> +		break;
>   	case APIC_ICR:
>   		*val = 0x40000 | 0xf1;
>   		break;


Reviewed-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>


  reply	other threads:[~2019-06-27  0:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-25 12:07 [kvm-unit-tests PATCH] x86: vmx: Consider CMCI enabled based on IA32_MCG_CAP[10] Nadav Amit
2019-06-27  0:13 ` Krish Sadhukhan [this message]
2019-06-27  0:29 ` Marc Orr
2019-07-02 15:55 ` Paolo Bonzini

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=0f1322a1-6019-97e8-178a-70556dc349d4@oracle.com \
    --to=krish.sadhukhan@oracle.com \
    --cc=kvm@vger.kernel.org \
    --cc=marcorr@google.com \
    --cc=nadav.amit@gmail.com \
    --cc=pbonzini@redhat.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).