[PATCH v8] um: Enable preemption in UML
Anton Ivanov
anton.ivanov at cambridgegreys.com
Mon Apr 1 04:06:39 PDT 2024
On 01/04/2024 12:04, Tiwei Bie wrote:
> On 3/29/24 3:50 AM, anton.ivanov at cambridgegreys.com wrote:
> [...]
>> +
>> +void kernel_fpu_begin(void)
>> +{
>> + preempt_disable();
>> +
>> + WARN_ON(this_cpu_read(in_kernel_fpu));
>> +
>> + this_cpu_write(in_kernel_fpu, true);
>> +
>> +#ifdef CONFIG_64BIT
>> + if (likely(cpu_has(&boot_cpu_data, X86_FEATURE_XSAVEOPT)))
>> + __builtin_ia32_xsaveopt64(¤t_thread_info()->aux_fp_regs, KNOWN_387_FEATURES);
>> + else if (likely(cpu_has(&boot_cpu_data, X86_FEATURE_XSAVE)))
>> + __builtin_ia32_xsave64(¤t_thread_info()->aux_fp_regs, KNOWN_387_FEATURES);
>
> Only need two levels of indentation (i.e. two tabs) here.
>
>> + else
>> + __builtin_ia32_fxsave64(¤t_thread_info()->aux_fp_regs);
>> +#else
>> + if (likely(cpu_has(&boot_cpu_data, X86_FEATURE_XSAVEOPT)))
>> + __builtin_ia32_xsaveopt(¤t->aux_fp_regs, KNOWN_387_FEATURES);
>> + else if (likely(cpu_has(&boot_cpu_data, X86_FEATURE_XSAVE)))
>> + __builtin_ia32_xsave(¤t->aux_fp_regs, KNOWN_387_FEATURES);
>
> Ditto.
>
>> + else
>> + __builtin_ia32_fxsave(¤t->aux_fp_regs);
>> +#endif
>> +}
>> +EXPORT_SYMBOL_GPL(kernel_fpu_begin);
>> +
> [...]
>>
>> @@ -466,6 +475,8 @@ void flush_tlb_page(struct vm_area_struct *vma, unsigned long address)
>>
>> address &= PAGE_MASK;
>>
>> + preempt_disable();
>> +
>> pgd = pgd_offset(mm, address);
>> if (!pgd_present(*pgd))
>> goto kill;
>> @@ -520,6 +531,7 @@ void flush_tlb_page(struct vm_area_struct *vma, unsigned long address)
>>
>> *pte = pte_mkuptodate(*pte);
>>
>> + preempt_enable();
>> return;
>>
>> kill:
>
> Preemption isn't enabled in the error path.
Thanks - missed that.
>
> Regards,
> Tiwei
>
--
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/
More information about the linux-um
mailing list