[PATCH v8] um: Enable preemption in UML

Tiwei Bie tiwei.btw at antgroup.com
Mon Apr 1 04:04:42 PDT 2024


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(&current_thread_info()->aux_fp_regs, KNOWN_387_FEATURES);
> +	else if (likely(cpu_has(&boot_cpu_data, X86_FEATURE_XSAVE)))
> +			__builtin_ia32_xsave64(&current_thread_info()->aux_fp_regs, KNOWN_387_FEATURES);

Only need two levels of indentation (i.e. two tabs) here.

> +	else
> +		__builtin_ia32_fxsave64(&current_thread_info()->aux_fp_regs);
> +#else
> +	if (likely(cpu_has(&boot_cpu_data, X86_FEATURE_XSAVEOPT)))
> +		__builtin_ia32_xsaveopt(&current->aux_fp_regs, KNOWN_387_FEATURES);
> +	else if (likely(cpu_has(&boot_cpu_data, X86_FEATURE_XSAVE)))
> +			__builtin_ia32_xsave(&current->aux_fp_regs, KNOWN_387_FEATURES);

Ditto.

> +	else
> +		__builtin_ia32_fxsave(&current->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.

Regards,
Tiwei



More information about the linux-um mailing list