Re: [PATCH v5 09/18] x86/split_lock: Handle #AC exception for split lock

From: Dave Hansen
Date: Tue Mar 12 2019 - 19:51:25 EST


On 3/12/19 4:00 PM, Fenghua Yu wrote:
> +#ifndef CONFIG_CPU_SUP_INTEL
> DO_ERROR(X86_TRAP_AC, SIGBUS, BUS_ADRALN, NULL, "alignment check", alignment_check)
> +#else
> +dotraplinkage void do_alignment_check(struct pt_regs *regs, long error_code)
> +{
> + unsigned int trapnr = X86_TRAP_AC;
> + char str[] = "alignment check";
> + int signr = SIGBUS;
> +
> + RCU_LOCKDEP_WARN(!rcu_is_watching(), "entry code didn't wake RCU");
> +
> + if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) !=
> + NOTIFY_STOP) {
> + cond_local_irq_enable(regs);
> + if (!user_mode(regs)) {
> + /*
> + * Only split lock can generate #AC from kernel. Warn
> + * and disable #AC for split lock on current CPU.
> + */
> + msr_clear_bit(MSR_TEST_CTL,
> + TEST_CTL_ENABLE_SPLIT_LOCK_DETECT_SHIFT)

I don't see any feature checking here. Don't we need to see if this MSR
is supported?

Shouldn't the code here on systems that don't support split lock
disabling be the same as on CONFIG_CPU_SUP_INTEL=n systems?

> + WARN_ONCE(1, "A split lock issue is detected.\n");
> +
> + return;
> + }
> + /* Handle #AC generated from user code. */
> + do_trap(X86_TRAP_AC, SIGBUS, "alignment check", regs,
> + error_code, BUS_ADRALN, NULL);
> + }
> +}
> +#endif

So... Do we really need an Intel-specific #ifdef for this sucker?