public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Xiao Guangrong <guangrong.xiao@linux.intel.com>
Cc: gleb@kernel.org, mtosatti@redhat.com, kvm@vger.kernel.org,
	linux-kernel@vger.kernel.org, alex.williamson@redhat.com,
	bsd@redhat.com, lersek@redhat.com, jordan.l.justen@intel.com,
	edk2-devel@lists.sourceforge.net,
	Xiao Guangrong <guangrong.xiao@intel.com>
Subject: Re: [PATCH 3/3] KVM: x86: quirkily apply WB to all memory if cache is disabled
Date: Thu, 23 Jul 2015 07:56:01 +0200	[thread overview]
Message-ID: <55B081F1.50406@redhat.com> (raw)
In-Reply-To: <1436988356-4565-3-git-send-email-guangrong.xiao@linux.intel.com>



On 15/07/2015 21:25, Xiao Guangrong wrote:
> From: Xiao Guangrong <guangrong.xiao@intel.com>
> 
> Current firmware depends on WB to fast boot, please refer to
>       https://lkml.org/lkml/2015/7/12/115
> 
> Let's us WB if CR0.CD is set to make this kind of firmware happy
> 
> This quirk can be dropped by using KVM_ENABLE_CAP API with
> KVM_CAP_DISABLE_QUIRKS if the broken firmware is gone
> 
> Signed-off-by: Xiao Guangrong <guangrong.xiao@intel.com>

Your patch is actually *enabling* the quirk if KVM_QUIRK_CD_AS_WB is 
included in the disabled quirks.  I'm squashing in this change:

diff --cc arch/x86/kvm/x86.h
index edc8cdcd786b,ea99928d9d09..000000000000
--- a/arch/x86/kvm/x86.h
+++ b/arch/x86/kvm/x86.h
@@@ -147,9 +147,9 @@@ static inline void kvm_register_writel(
 	return ktime_get_boot_ns();
 }
 
-static inline bool kvm_check_disabled_quirks(struct kvm *kvm, u64 quirk)
+static inline bool kvm_check_has_quirk(struct kvm *kvm, u64 quirk)
 {
-	return !!(kvm->arch.disabled_quirks & quirk);
+	return !(kvm->arch.disabled_quirks & quirk);
 }
 
 void kvm_before_handle_nmi(struct kvm_vcpu *vcpu);
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 0d77b20d628a..1c425443a41a 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -1595,7 +1595,7 @@ void kvm_lapic_reset(struct kvm_vcpu *vcpu, bool init_event)
 	for (i = 0; i < APIC_LVT_NUM; i++)
 		apic_set_reg(apic, APIC_LVTT + 0x10 * i, APIC_LVT_MASKED);
 	apic_update_lvtt(apic);
-	if (!kvm_check_disabled_quirks(vcpu->kvm, KVM_QUIRK_LINT0_REENABLED))
+	if (kvm_check_has_quirk(vcpu->kvm, KVM_QUIRK_LINT0_REENABLED))
 		apic_set_reg(apic, APIC_LVT0,
 			     SET_APIC_DELIVERY_MODE(0, APIC_MODE_EXTINT));
 	apic_manage_nmi_watchdog(apic, kvm_apic_get_reg(apic, APIC_LVT0));
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index cac9ee6abea7..8cbec765b08d 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -1672,7 +1672,7 @@ static void svm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)
 	 * does not do it - this results in some delay at
 	 * reboot
 	 */
-	if (!kvm_check_disabled_quirks(vcpu->kvm, KVM_QUIRK_CD_NW_CLEARED))
+	if (kvm_check_has_quirk(vcpu->kvm, KVM_QUIRK_CD_NW_CLEARED))
 		cr0 &= ~(X86_CR0_CD | X86_CR0_NW);
 	svm->vmcb->save.cr0 = cr0;
 	mark_dirty(svm->vmcb, VMCB_CR);
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 7247891526ae..6b4890623146 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -8650,7 +8650,7 @@ static u64 vmx_get_mt_mask(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio)
 
 	if (kvm_read_cr0(vcpu) & X86_CR0_CD) {
 		ipat = VMX_EPT_IPAT_BIT;
-		if (kvm_check_disabled_quirks(vcpu->kvm, KVM_QUIRK_CD_AS_WB))
+		if (kvm_check_has_quirk(vcpu->kvm, KVM_QUIRK_CD_AS_WB))
 			cache = MTRR_TYPE_WRBACK;
 		else
 			cache = MTRR_TYPE_UNCACHABLE;
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 549051784955..5ef2560075bf 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3765,11 +3765,6 @@ static int kvm_vm_ioctl_enable_cap(struct kvm *kvm,
 	return r;
 }
 
-static void kvm_init_disabled_quirks(struct kvm *kvm)
-{
-	kvm->arch.disabled_quirks = KVM_QUIRK_CD_AS_WB;
-}
-
 long kvm_arch_vm_ioctl(struct file *filp,
 		       unsigned int ioctl, unsigned long arg)
 {
@@ -7671,8 +7666,6 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
 	INIT_DELAYED_WORK(&kvm->arch.kvmclock_update_work, kvmclock_update_fn);
 	INIT_DELAYED_WORK(&kvm->arch.kvmclock_sync_work, kvmclock_sync_fn);
 
-	kvm_init_disabled_quirks(kvm);
-
 	return 0;
 }
 

to avoid the double negation and invert the meaning of KVM_QUIRK_CD_AS_WB.

Paolo

  reply	other threads:[~2015-07-23  5:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-15 19:25 [PATCH 1/3] KVM: MTRR: fix memory type handling if MTRR is completely disabled Xiao Guangrong
2015-07-15 19:25 ` [PATCH 2/3] KVM: MTRR: simplify kvm_mtrr_get_guest_memory_type Xiao Guangrong
2015-07-29 19:07   ` Alex Williamson
2015-07-30  7:21     ` [edk2] " Paolo Bonzini
2015-07-15 19:25 ` [PATCH 3/3] KVM: x86: quirkily apply WB to all memory if cache is disabled Xiao Guangrong
2015-07-23  5:56   ` Paolo Bonzini [this message]
2015-07-23  6:03     ` Xiao Guangrong
2015-07-16  4:10 ` [PATCH 1/3] KVM: MTRR: fix memory type handling if MTRR is completely disabled Alex Williamson
2015-07-23  6:21   ` Paolo Bonzini
2015-07-23  6:29     ` Xiao Guangrong
2015-07-23  7:18       ` 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=55B081F1.50406@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=bsd@redhat.com \
    --cc=edk2-devel@lists.sourceforge.net \
    --cc=gleb@kernel.org \
    --cc=guangrong.xiao@intel.com \
    --cc=guangrong.xiao@linux.intel.com \
    --cc=jordan.l.justen@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=lersek@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtosatti@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