All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: x86: obey KVM_X86_QUIRK_CD_NW_CLEARED in kvm_set_cr0()
@ 2015-11-03 18:34 Laszlo Ersek
  2015-11-03 18:57 ` Laszlo Ersek
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Laszlo Ersek @ 2015-11-03 18:34 UTC (permalink / raw)
  To: kvm, lersek
  Cc: Paolo Bonzini, Jordan Justen, Janusz Mocek, Alex Williamson,
	Xiao Guangrong

Commit b18d5431acc7 ("KVM: x86: fix CR0.CD virtualization") was
technically correct, but it broke OVMF guests by slowing down various
parts of the firmware.

Commit fb279950ba02 ("KVM: vmx: obey KVM_QUIRK_CD_NW_CLEARED") quirked the
first function modified by b18d5431acc7, vmx_get_mt_mask(), for OVMF's
sake. This restored the speed of the OVMF code that runs before
PlatformPei (including the memory intensive LZMA decompression in SEC).

This patch extends the quirk to the second function modified by
b18d5431acc7, kvm_set_cr0(). It eliminates the intrusive slowdown that
hits the EFI_MP_SERVICES_PROTOCOL implementation of edk2's
UefiCpuPkg/CpuDxe -- which is built into OVMF --, when CpuDxe starts up
all APs at once for initialization, in order to count them.

We also carry over the kvm_arch_has_noncoherent_dma() sub-condition from
the other half of the original commit b18d5431acc7.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Janusz Mocek <januszmk6@gmail.com>
Cc: Alex Williamson <alex.williamson@redhat.com>
Cc: Xiao Guangrong <guangrong.xiao@linux.intel.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 arch/x86/kvm/x86.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index a24bae0..30723a4 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -625,7 +625,9 @@ int kvm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)
 	if ((cr0 ^ old_cr0) & update_bits)
 		kvm_mmu_reset_context(vcpu);
 
-	if ((cr0 ^ old_cr0) & X86_CR0_CD)
+	if (((cr0 ^ old_cr0) & X86_CR0_CD) &&
+	    kvm_arch_has_noncoherent_dma(vcpu->kvm) &&
+	    !kvm_check_has_quirk(vcpu->kvm, KVM_X86_QUIRK_CD_NW_CLEARED))
 		kvm_zap_gfn_range(vcpu->kvm, 0, ~0ULL);
 
 	return 0;
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] KVM: x86: obey KVM_X86_QUIRK_CD_NW_CLEARED in kvm_set_cr0()
  2015-11-03 18:34 [PATCH] KVM: x86: obey KVM_X86_QUIRK_CD_NW_CLEARED in kvm_set_cr0() Laszlo Ersek
@ 2015-11-03 18:57 ` Laszlo Ersek
  2015-11-03 23:57   ` Janusz Mocek
  2015-11-04  3:09 ` Xiao Guangrong
  2015-11-04 11:56 ` Paolo Bonzini
  2 siblings, 1 reply; 5+ messages in thread
From: Laszlo Ersek @ 2015-11-03 18:57 UTC (permalink / raw)
  To: kvm
  Cc: Paolo Bonzini, Jordan Justen, Janusz Mocek, Alex Williamson,
	Xiao Guangrong

On 11/03/15 19:34, Laszlo Ersek wrote:
> Commit b18d5431acc7 ("KVM: x86: fix CR0.CD virtualization") was
> technically correct, but it broke OVMF guests by slowing down various
> parts of the firmware.
> 
> Commit fb279950ba02 ("KVM: vmx: obey KVM_QUIRK_CD_NW_CLEARED") quirked the
> first function modified by b18d5431acc7, vmx_get_mt_mask(), for OVMF's
> sake. This restored the speed of the OVMF code that runs before
> PlatformPei (including the memory intensive LZMA decompression in SEC).
> 
> This patch extends the quirk to the second function modified by
> b18d5431acc7, kvm_set_cr0(). It eliminates the intrusive slowdown that
> hits the EFI_MP_SERVICES_PROTOCOL implementation of edk2's
> UefiCpuPkg/CpuDxe -- which is built into OVMF --, when CpuDxe starts up
> all APs at once for initialization, in order to count them.
> 
> We also carry over the kvm_arch_has_noncoherent_dma() sub-condition from
> the other half of the original commit b18d5431acc7.
> 
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Jordan Justen <jordan.l.justen@intel.com>
> Cc: Janusz Mocek <januszmk6@gmail.com>
> Cc: Alex Williamson <alex.williamson@redhat.com>
> Cc: Xiao Guangrong <guangrong.xiao@linux.intel.com>
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> ---
>  arch/x86/kvm/x86.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index a24bae0..30723a4 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -625,7 +625,9 @@ int kvm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)
>  	if ((cr0 ^ old_cr0) & update_bits)
>  		kvm_mmu_reset_context(vcpu);
>  
> -	if ((cr0 ^ old_cr0) & X86_CR0_CD)
> +	if (((cr0 ^ old_cr0) & X86_CR0_CD) &&
> +	    kvm_arch_has_noncoherent_dma(vcpu->kvm) &&
> +	    !kvm_check_has_quirk(vcpu->kvm, KVM_X86_QUIRK_CD_NW_CLEARED))
>  		kvm_zap_gfn_range(vcpu->kvm, 0, ~0ULL);
>  
>  	return 0;
> 


I had notes on this patch, but I forgot to format it with --notes. They
were:

- People on the CC list, please reply with your Tested-by, Reported-by,
  etc tags as appropriate; it's getting blurry who participated in what
  and how.

- This patch is *not* necessary for the OVMF SMM work; instead it
  addresses an independent OVMF boot regression seen by users.

Thanks
Laszlo

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] KVM: x86: obey KVM_X86_QUIRK_CD_NW_CLEARED in kvm_set_cr0()
  2015-11-03 18:57 ` Laszlo Ersek
@ 2015-11-03 23:57   ` Janusz Mocek
  0 siblings, 0 replies; 5+ messages in thread
From: Janusz Mocek @ 2015-11-03 23:57 UTC (permalink / raw)
  To: Laszlo Ersek, kvm
  Cc: Paolo Bonzini, Jordan Justen, Alex Williamson, Xiao Guangrong

W dniu 03.11.2015 o 19:57, Laszlo Ersek pisze:
> On 11/03/15 19:34, Laszlo Ersek wrote:
>> Commit b18d5431acc7 ("KVM: x86: fix CR0.CD virtualization") was
>> technically correct, but it broke OVMF guests by slowing down various
>> parts of the firmware.
>>
>> Commit fb279950ba02 ("KVM: vmx: obey KVM_QUIRK_CD_NW_CLEARED") quirked the
>> first function modified by b18d5431acc7, vmx_get_mt_mask(), for OVMF's
>> sake. This restored the speed of the OVMF code that runs before
>> PlatformPei (including the memory intensive LZMA decompression in SEC).
>>
>> This patch extends the quirk to the second function modified by
>> b18d5431acc7, kvm_set_cr0(). It eliminates the intrusive slowdown that
>> hits the EFI_MP_SERVICES_PROTOCOL implementation of edk2's
>> UefiCpuPkg/CpuDxe -- which is built into OVMF --, when CpuDxe starts up
>> all APs at once for initialization, in order to count them.
>>
>> We also carry over the kvm_arch_has_noncoherent_dma() sub-condition from
>> the other half of the original commit b18d5431acc7.
>>
>> Cc: Paolo Bonzini <pbonzini@redhat.com>
>> Cc: Jordan Justen <jordan.l.justen@intel.com>
>> Cc: Janusz Mocek <januszmk6@gmail.com>
>> Cc: Alex Williamson <alex.williamson@redhat.com>
>> Cc: Xiao Guangrong <guangrong.xiao@linux.intel.com>
>> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
>> ---
>>  arch/x86/kvm/x86.c | 4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
>> index a24bae0..30723a4 100644
>> --- a/arch/x86/kvm/x86.c
>> +++ b/arch/x86/kvm/x86.c
>> @@ -625,7 +625,9 @@ int kvm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)
>>  	if ((cr0 ^ old_cr0) & update_bits)
>>  		kvm_mmu_reset_context(vcpu);
>>  
>> -	if ((cr0 ^ old_cr0) & X86_CR0_CD)
>> +	if (((cr0 ^ old_cr0) & X86_CR0_CD) &&
>> +	    kvm_arch_has_noncoherent_dma(vcpu->kvm) &&
>> +	    !kvm_check_has_quirk(vcpu->kvm, KVM_X86_QUIRK_CD_NW_CLEARED))
>>  		kvm_zap_gfn_range(vcpu->kvm, 0, ~0ULL);
>>  
>>  	return 0;
>>
>
> I had notes on this patch, but I forgot to format it with --notes. They
> were:
>
> - People on the CC list, please reply with your Tested-by, Reported-by,
>   etc tags as appropriate; it's getting blurry who participated in what
>   and how.
>
> - This patch is *not* necessary for the OVMF SMM work; instead it
>   addresses an independent OVMF boot regression seen by users.
>
> Thanks
> Laszlo
Tested-by: Janusz Mocek <januszmk6@gmail.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] KVM: x86: obey KVM_X86_QUIRK_CD_NW_CLEARED in kvm_set_cr0()
  2015-11-03 18:34 [PATCH] KVM: x86: obey KVM_X86_QUIRK_CD_NW_CLEARED in kvm_set_cr0() Laszlo Ersek
  2015-11-03 18:57 ` Laszlo Ersek
@ 2015-11-04  3:09 ` Xiao Guangrong
  2015-11-04 11:56 ` Paolo Bonzini
  2 siblings, 0 replies; 5+ messages in thread
From: Xiao Guangrong @ 2015-11-04  3:09 UTC (permalink / raw)
  To: Laszlo Ersek, kvm
  Cc: Paolo Bonzini, Jordan Justen, Janusz Mocek, Alex Williamson



On 11/04/2015 02:34 AM, Laszlo Ersek wrote:
> Commit b18d5431acc7 ("KVM: x86: fix CR0.CD virtualization") was
> technically correct, but it broke OVMF guests by slowing down various
> parts of the firmware.
>
> Commit fb279950ba02 ("KVM: vmx: obey KVM_QUIRK_CD_NW_CLEARED") quirked the
> first function modified by b18d5431acc7, vmx_get_mt_mask(), for OVMF's
> sake. This restored the speed of the OVMF code that runs before
> PlatformPei (including the memory intensive LZMA decompression in SEC).
>
> This patch extends the quirk to the second function modified by
> b18d5431acc7, kvm_set_cr0(). It eliminates the intrusive slowdown that
> hits the EFI_MP_SERVICES_PROTOCOL implementation of edk2's
> UefiCpuPkg/CpuDxe -- which is built into OVMF --, when CpuDxe starts up
> all APs at once for initialization, in order to count them.
>
> We also carry over the kvm_arch_has_noncoherent_dma() sub-condition from
> the other half of the original commit b18d5431acc7.

Reviewed-by: Xiao Guangrong <guangrong.xiao@linux.intel.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] KVM: x86: obey KVM_X86_QUIRK_CD_NW_CLEARED in kvm_set_cr0()
  2015-11-03 18:34 [PATCH] KVM: x86: obey KVM_X86_QUIRK_CD_NW_CLEARED in kvm_set_cr0() Laszlo Ersek
  2015-11-03 18:57 ` Laszlo Ersek
  2015-11-04  3:09 ` Xiao Guangrong
@ 2015-11-04 11:56 ` Paolo Bonzini
  2 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2015-11-04 11:56 UTC (permalink / raw)
  To: Laszlo Ersek, kvm
  Cc: Jordan Justen, Janusz Mocek, Alex Williamson, Xiao Guangrong



On 03/11/2015 19:34, Laszlo Ersek wrote:
> Commit b18d5431acc7 ("KVM: x86: fix CR0.CD virtualization") was
> technically correct, but it broke OVMF guests by slowing down various
> parts of the firmware.
> 
> Commit fb279950ba02 ("KVM: vmx: obey KVM_QUIRK_CD_NW_CLEARED") quirked the
> first function modified by b18d5431acc7, vmx_get_mt_mask(), for OVMF's
> sake. This restored the speed of the OVMF code that runs before
> PlatformPei (including the memory intensive LZMA decompression in SEC).
> 
> This patch extends the quirk to the second function modified by
> b18d5431acc7, kvm_set_cr0(). It eliminates the intrusive slowdown that
> hits the EFI_MP_SERVICES_PROTOCOL implementation of edk2's
> UefiCpuPkg/CpuDxe -- which is built into OVMF --, when CpuDxe starts up
> all APs at once for initialization, in order to count them.
> 
> We also carry over the kvm_arch_has_noncoherent_dma() sub-condition from
> the other half of the original commit b18d5431acc7.
> 
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Jordan Justen <jordan.l.justen@intel.com>
> Cc: Janusz Mocek <januszmk6@gmail.com>
> Cc: Alex Williamson <alex.williamson@redhat.com>
> Cc: Xiao Guangrong <guangrong.xiao@linux.intel.com>
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> ---
>  arch/x86/kvm/x86.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index a24bae0..30723a4 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -625,7 +625,9 @@ int kvm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)
>  	if ((cr0 ^ old_cr0) & update_bits)
>  		kvm_mmu_reset_context(vcpu);
>  
> -	if ((cr0 ^ old_cr0) & X86_CR0_CD)
> +	if (((cr0 ^ old_cr0) & X86_CR0_CD) &&
> +	    kvm_arch_has_noncoherent_dma(vcpu->kvm) &&
> +	    !kvm_check_has_quirk(vcpu->kvm, KVM_X86_QUIRK_CD_NW_CLEARED))
>  		kvm_zap_gfn_range(vcpu->kvm, 0, ~0ULL);
>  
>  	return 0;
> 

Applied, thanks.

Paolo

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-11-04 11:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-03 18:34 [PATCH] KVM: x86: obey KVM_X86_QUIRK_CD_NW_CLEARED in kvm_set_cr0() Laszlo Ersek
2015-11-03 18:57 ` Laszlo Ersek
2015-11-03 23:57   ` Janusz Mocek
2015-11-04  3:09 ` Xiao Guangrong
2015-11-04 11:56 ` Paolo Bonzini

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.