linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] svm/avic: Fix invalidate logical APIC id entry
@ 2019-03-22 10:17 Suthikulpanit, Suravee
  2019-03-22 13:04 ` Vitaly Kuznetsov
  0 siblings, 1 reply; 3+ messages in thread
From: Suthikulpanit, Suravee @ 2019-03-22 10:17 UTC (permalink / raw)
  To: linux-kernel, kvm; +Cc: joro, pbonzini, rkrcmar, Suthikulpanit, Suravee

Only clear the valid bit when invalidate logical APIC id entry.
The current logic clear the valid bit, but also set the rest of
the bits (including reserved bits) to 1.

Fixes: 98d90582be2e ('svm: Fix AVIC DFR and LDR handling')
Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
---
 arch/x86/kvm/svm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 7a4ce1a22ca0..f4fb766e474c 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -4640,7 +4640,7 @@ static void avic_invalidate_logical_id_entry(struct kvm_vcpu *vcpu)
 	u32 *entry = avic_get_logical_id_entry(vcpu, svm->ldr_reg, flat);
 
 	if (entry)
-		WRITE_ONCE(*entry, (u32) ~AVIC_LOGICAL_ID_ENTRY_VALID_MASK);
+		WRITE_ONCE(*entry, (u32)(*entry & ~AVIC_LOGICAL_ID_ENTRY_VALID_MASK));
 }
 
 static int avic_handle_ldr_update(struct kvm_vcpu *vcpu)
-- 
2.17.1


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

* Re: [PATCH] svm/avic: Fix invalidate logical APIC id entry
  2019-03-22 10:17 [PATCH] svm/avic: Fix invalidate logical APIC id entry Suthikulpanit, Suravee
@ 2019-03-22 13:04 ` Vitaly Kuznetsov
  2019-03-26  3:47   ` Suthikulpanit, Suravee
  0 siblings, 1 reply; 3+ messages in thread
From: Vitaly Kuznetsov @ 2019-03-22 13:04 UTC (permalink / raw)
  To: Suthikulpanit, Suravee; +Cc: joro, pbonzini, rkrcmar, linux-kernel, kvm

"Suthikulpanit, Suravee" <Suravee.Suthikulpanit@amd.com> writes:

> Only clear the valid bit when invalidate logical APIC id entry.
> The current logic clear the valid bit, but also set the rest of
> the bits (including reserved bits) to 1.
>
> Fixes: 98d90582be2e ('svm: Fix AVIC DFR and LDR handling')
> Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
> ---
>  arch/x86/kvm/svm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
> index 7a4ce1a22ca0..f4fb766e474c 100644
> --- a/arch/x86/kvm/svm.c
> +++ b/arch/x86/kvm/svm.c
> @@ -4640,7 +4640,7 @@ static void avic_invalidate_logical_id_entry(struct kvm_vcpu *vcpu)
>  	u32 *entry = avic_get_logical_id_entry(vcpu, svm->ldr_reg, flat);
>  
>  	if (entry)
> -		WRITE_ONCE(*entry, (u32) ~AVIC_LOGICAL_ID_ENTRY_VALID_MASK);
> +		WRITE_ONCE(*entry, (u32)(*entry & ~AVIC_LOGICAL_ID_ENTRY_VALID_MASK));

I'm not sure how important this is, but this change creates a tiny time
window between reading from *entry and writing there. Should we use
atomic bitops instead?

>  }
>  
>  static int avic_handle_ldr_update(struct kvm_vcpu *vcpu)

-- 
Vitaly

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

* Re: [PATCH] svm/avic: Fix invalidate logical APIC id entry
  2019-03-22 13:04 ` Vitaly Kuznetsov
@ 2019-03-26  3:47   ` Suthikulpanit, Suravee
  0 siblings, 0 replies; 3+ messages in thread
From: Suthikulpanit, Suravee @ 2019-03-26  3:47 UTC (permalink / raw)
  To: Vitaly Kuznetsov; +Cc: joro, pbonzini, rkrcmar, linux-kernel, kvm



On 3/22/19 8:04 PM, Vitaly Kuznetsov wrote:
> "Suthikulpanit, Suravee" <Suravee.Suthikulpanit@amd.com> writes:
> 
>> Only clear the valid bit when invalidate logical APIC id entry.
>> The current logic clear the valid bit, but also set the rest of
>> the bits (including reserved bits) to 1.
>>
>> Fixes: 98d90582be2e ('svm: Fix AVIC DFR and LDR handling')
>> Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
>> ---
>>   arch/x86/kvm/svm.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
>> index 7a4ce1a22ca0..f4fb766e474c 100644
>> --- a/arch/x86/kvm/svm.c
>> +++ b/arch/x86/kvm/svm.c
>> @@ -4640,7 +4640,7 @@ static void avic_invalidate_logical_id_entry(struct kvm_vcpu *vcpu)
>>   	u32 *entry = avic_get_logical_id_entry(vcpu, svm->ldr_reg, flat);
>>   
>>   	if (entry)
>> -		WRITE_ONCE(*entry, (u32) ~AVIC_LOGICAL_ID_ENTRY_VALID_MASK);
>> +		WRITE_ONCE(*entry, (u32)(*entry & ~AVIC_LOGICAL_ID_ENTRY_VALID_MASK));
> 
> I'm not sure how important this is, but this change creates a tiny time
> window between reading from *entry and writing there. Should we use
> atomic bitops instead?

Sure. That is also simpler. I'll send out V2 w/ clear_bit() instead.

Suravee

> 
>>   }
>>   
>>   static int avic_handle_ldr_update(struct kvm_vcpu *vcpu)
> 

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

end of thread, other threads:[~2019-03-26  3:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-22 10:17 [PATCH] svm/avic: Fix invalidate logical APIC id entry Suthikulpanit, Suravee
2019-03-22 13:04 ` Vitaly Kuznetsov
2019-03-26  3:47   ` Suthikulpanit, Suravee

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).