File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -5839,6 +5839,7 @@ static int emulator_cmpxchg_emulated(struct x86_emulate_ctxt *ctxt,
5839
5839
{
5840
5840
struct kvm_host_map map ;
5841
5841
struct kvm_vcpu * vcpu = emul_to_vcpu (ctxt );
5842
+ u64 page_line_mask ;
5842
5843
gpa_t gpa ;
5843
5844
char * kaddr ;
5844
5845
bool exchanged ;
@@ -5853,7 +5854,16 @@ static int emulator_cmpxchg_emulated(struct x86_emulate_ctxt *ctxt,
5853
5854
(gpa & PAGE_MASK ) == APIC_DEFAULT_PHYS_BASE )
5854
5855
goto emul_write ;
5855
5856
5856
- if (((gpa + bytes - 1 ) & PAGE_MASK ) != (gpa & PAGE_MASK ))
5857
+ /*
5858
+ * Emulate the atomic as a straight write to avoid #AC if SLD is
5859
+ * enabled in the host and the access splits a cache line.
5860
+ */
5861
+ if (boot_cpu_has (X86_FEATURE_SPLIT_LOCK_DETECT ))
5862
+ page_line_mask = ~(cache_line_size () - 1 );
5863
+ else
5864
+ page_line_mask = PAGE_MASK ;
5865
+
5866
+ if (((gpa + bytes - 1 ) & page_line_mask ) != (gpa & page_line_mask ))
5857
5867
goto emul_write ;
5858
5868
5859
5869
if (kvm_vcpu_map (vcpu , gpa_to_gfn (gpa ), & map ))
You can’t perform that action at this time.
0 commit comments