arch/x86/kernel/cpu/bus_lock.c
Source file repositories/reference/linux-study-clean/arch/x86/kernel/cpu/bus_lock.c
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/kernel/cpu/bus_lock.c- Extension
.c- Size
- 11202 bytes
- Lines
- 438
- Domain
- Architecture Layer
- Bucket
- arch/x86
- Inferred role
- Architecture Layer: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/semaphore.hlinux/workqueue.hlinux/delay.hlinux/cpuhotplug.hlinux/kvm_types.hasm/cpu_device_id.hasm/cmdline.hasm/traps.hasm/cpu.hasm/msr.h
Detected Declarations
enum split_lock_detect_statefunction sld_mitigate_sysctl_initfunction match_optionfunction split_lock_verify_msrfunction sld_state_setupfunction setup_split_lock_detectfunction __split_lock_setupfunction sld_update_msrfunction split_lock_initfunction __split_lock_reenable_unlockfunction __split_lock_reenablefunction setup_per_cpu_areasfunction for_each_possible_cpufunction splitlock_cpu_offlinefunction split_lock_warnfunction handle_guest_split_lockfunction bus_lock_initfunction handle_user_split_lockfunction handle_bus_lockfunction split_lock_setupfunction sld_state_showfunction sld_setup
Annotated Snippet
if (match_option(arg, ret, sld_options[i].option)) {
state = sld_options[i].state;
break;
}
}
}
sld_state = state;
}
static __init int setup_split_lock_detect(char *arg)
{
return 1;
}
__setup("split_lock_detect=", setup_split_lock_detect);
static void __init __split_lock_setup(void)
{
if (!split_lock_verify_msr(false)) {
pr_info("MSR access failed: Disabled\n");
return;
}
rdmsrq(MSR_TEST_CTRL, msr_test_ctrl_cache);
if (!split_lock_verify_msr(true)) {
pr_info("MSR access failed: Disabled\n");
return;
}
/* Restore the MSR to its cached value. */
wrmsrq(MSR_TEST_CTRL, msr_test_ctrl_cache);
setup_force_cpu_cap(X86_FEATURE_SPLIT_LOCK_DETECT);
}
/*
* MSR_TEST_CTRL is per core, but we treat it like a per CPU MSR. Locking
* is not implemented as one thread could undo the setting of the other
* thread immediately after dropping the lock anyway.
*/
static void sld_update_msr(bool on)
{
u64 test_ctrl_val = msr_test_ctrl_cache;
if (on)
test_ctrl_val |= MSR_TEST_CTRL_SPLIT_LOCK_DETECT;
wrmsrq(MSR_TEST_CTRL, test_ctrl_val);
}
void split_lock_init(void)
{
/*
* #DB for bus lock handles ratelimit and #AC for split lock is
* disabled.
*/
if (sld_state == sld_ratelimit) {
split_lock_verify_msr(false);
return;
}
if (cpu_model_supports_sld)
split_lock_verify_msr(sld_state != sld_off);
}
static void __split_lock_reenable_unlock(struct work_struct *work)
{
sld_update_msr(true);
up(&buslock_sem);
}
static DECLARE_DELAYED_WORK(sl_reenable_unlock, __split_lock_reenable_unlock);
static void __split_lock_reenable(struct work_struct *work)
{
sld_update_msr(true);
}
/*
* In order for each CPU to schedule its delayed work independently of the
* others, delayed work struct must be per-CPU. This is not required when
* sysctl_sld_mitigate is enabled because of the semaphore that limits
* the number of simultaneously scheduled delayed works to 1.
*/
static DEFINE_PER_CPU(struct delayed_work, sl_reenable);
/*
* Per-CPU delayed_work can't be statically initialized properly because
* the struct address is unknown. Thus per-CPU delayed_work structures
* have to be initialized during kernel initialization and after calling
* setup_per_cpu_areas().
Annotation
- Immediate include surface: `linux/semaphore.h`, `linux/workqueue.h`, `linux/delay.h`, `linux/cpuhotplug.h`, `linux/kvm_types.h`, `asm/cpu_device_id.h`, `asm/cmdline.h`, `asm/traps.h`.
- Detected declarations: `enum split_lock_detect_state`, `function sld_mitigate_sysctl_init`, `function match_option`, `function split_lock_verify_msr`, `function sld_state_setup`, `function setup_split_lock_detect`, `function __split_lock_setup`, `function sld_update_msr`, `function split_lock_init`, `function __split_lock_reenable_unlock`.
- Atlas domain: Architecture Layer / arch/x86.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.