Skip to content

Commit e2aa39b

Browse files
committed
Merge tag 'x86_misc_for_6.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull misc x86 updates from Dave Hansen: "The most significant are some changes to ensure that symbols exported for KVM are used only by KVM modules themselves, along with some related cleanups. In true x86/misc fashion, the other patch is completely unrelated and just enhances an existing pr_warn() to make it clear to users how they have tainted their kernel when something is mucking with MSRs. Summary: - Make MSR-induced taint easier for users to track down - Restrict KVM-specific exports to KVM itself" * tag 'x86_misc_for_6.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86: Restrict KVM-induced symbol exports to KVM modules where obvious/possible x86/mm: Drop unnecessary export of "ptdump_walk_pgd_level_debugfs" x86/mtrr: Drop unnecessary export of "mtrr_state" x86/bugs: Drop unnecessary export of "x86_spec_ctrl_base" x86/msr: Add CPU_OUT_OF_SPEC taint name to "unrecognized" pr_warn(msg)
2 parents 54de197 + 6276c67 commit e2aa39b

35 files changed

Lines changed: 145 additions & 108 deletions

arch/x86/entry/entry.S

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55

66
#include <linux/export.h>
7+
#include <linux/kvm_types.h>
78
#include <linux/linkage.h>
89
#include <linux/objtool.h>
910
#include <asm/msr-index.h>
@@ -29,8 +30,7 @@ SYM_FUNC_START(write_ibpb)
2930
FILL_RETURN_BUFFER %rax, RSB_CLEAR_LOOPS, X86_BUG_IBPB_NO_RET
3031
RET
3132
SYM_FUNC_END(write_ibpb)
32-
/* For KVM */
33-
EXPORT_SYMBOL_GPL(write_ibpb);
33+
EXPORT_SYMBOL_FOR_KVM(write_ibpb);
3434

3535
SYM_FUNC_START(__WARN_trap)
3636
ANNOTATE_NOENDBR
@@ -56,8 +56,7 @@ SYM_CODE_START_NOALIGN(x86_verw_sel)
5656
.word __KERNEL_DS
5757
.align L1_CACHE_BYTES, 0xcc
5858
SYM_CODE_END(x86_verw_sel);
59-
/* For KVM */
60-
EXPORT_SYMBOL_GPL(x86_verw_sel);
59+
EXPORT_SYMBOL_FOR_KVM(x86_verw_sel);
6160

6261
.popsection
6362

arch/x86/entry/entry_64.S

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
* - idtentry: Define exception entry points.
2020
*/
2121
#include <linux/export.h>
22+
#include <linux/kvm_types.h>
2223
#include <linux/linkage.h>
2324
#include <asm/segment.h>
2425
#include <asm/cache.h>
@@ -1566,5 +1567,5 @@ SYM_FUNC_START(clear_bhb_loop)
15661567
pop %rbp
15671568
RET
15681569
SYM_FUNC_END(clear_bhb_loop)
1569-
EXPORT_SYMBOL_GPL(clear_bhb_loop)
1570+
EXPORT_SYMBOL_FOR_KVM(clear_bhb_loop)
15701571
STACK_FRAME_NON_STANDARD(clear_bhb_loop)

arch/x86/entry/entry_64_fred.S

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55

66
#include <linux/export.h>
7+
#include <linux/kvm_types.h>
78

89
#include <asm/asm.h>
910
#include <asm/fred.h>
@@ -146,5 +147,5 @@ SYM_FUNC_START(asm_fred_entry_from_kvm)
146147
RET
147148

148149
SYM_FUNC_END(asm_fred_entry_from_kvm)
149-
EXPORT_SYMBOL_GPL(asm_fred_entry_from_kvm);
150+
EXPORT_SYMBOL_FOR_KVM(asm_fred_entry_from_kvm);
150151
#endif

arch/x86/events/amd/core.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <linux/perf_event.h>
33
#include <linux/jump_label.h>
44
#include <linux/export.h>
5+
#include <linux/kvm_types.h>
56
#include <linux/types.h>
67
#include <linux/init.h>
78
#include <linux/slab.h>
@@ -1574,7 +1575,7 @@ void amd_pmu_enable_virt(void)
15741575
/* Reload all events */
15751576
amd_pmu_reload_virt();
15761577
}
1577-
EXPORT_SYMBOL_GPL(amd_pmu_enable_virt);
1578+
EXPORT_SYMBOL_FOR_KVM(amd_pmu_enable_virt);
15781579

15791580
void amd_pmu_disable_virt(void)
15801581
{
@@ -1591,4 +1592,4 @@ void amd_pmu_disable_virt(void)
15911592
/* Reload all events */
15921593
amd_pmu_reload_virt();
15931594
}
1594-
EXPORT_SYMBOL_GPL(amd_pmu_disable_virt);
1595+
EXPORT_SYMBOL_FOR_KVM(amd_pmu_disable_virt);

arch/x86/events/core.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <linux/export.h>
2121
#include <linux/init.h>
2222
#include <linux/kdebug.h>
23+
#include <linux/kvm_types.h>
2324
#include <linux/sched/mm.h>
2425
#include <linux/sched/clock.h>
2526
#include <linux/uaccess.h>
@@ -723,7 +724,7 @@ struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr, void *data)
723724
{
724725
return static_call(x86_pmu_guest_get_msrs)(nr, data);
725726
}
726-
EXPORT_SYMBOL_GPL(perf_guest_get_msrs);
727+
EXPORT_SYMBOL_FOR_KVM(perf_guest_get_msrs);
727728

728729
/*
729730
* There may be PMI landing after enabled=0. The PMI hitting could be before or
@@ -3078,7 +3079,7 @@ void perf_get_x86_pmu_capability(struct x86_pmu_capability *cap)
30783079
cap->events_mask_len = x86_pmu.events_mask_len;
30793080
cap->pebs_ept = x86_pmu.pebs_ept;
30803081
}
3081-
EXPORT_SYMBOL_GPL(perf_get_x86_pmu_capability);
3082+
EXPORT_SYMBOL_FOR_KVM(perf_get_x86_pmu_capability);
30823083

30833084
u64 perf_get_hw_event_config(int hw_event)
30843085
{
@@ -3089,4 +3090,4 @@ u64 perf_get_hw_event_config(int hw_event)
30893090

30903091
return 0;
30913092
}
3092-
EXPORT_SYMBOL_GPL(perf_get_hw_event_config);
3093+
EXPORT_SYMBOL_FOR_KVM(perf_get_hw_event_config);

arch/x86/events/intel/lbr.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// SPDX-License-Identifier: GPL-2.0
2+
#include <linux/kvm_types.h>
23
#include <linux/perf_event.h>
34
#include <linux/types.h>
45

@@ -1705,7 +1706,7 @@ void x86_perf_get_lbr(struct x86_pmu_lbr *lbr)
17051706
lbr->info = x86_pmu.lbr_info;
17061707
lbr->has_callstack = x86_pmu_has_lbr_callstack();
17071708
}
1708-
EXPORT_SYMBOL_GPL(x86_perf_get_lbr);
1709+
EXPORT_SYMBOL_FOR_KVM(x86_perf_get_lbr);
17091710

17101711
struct event_constraint vlbr_constraint =
17111712
__EVENT_CONSTRAINT(INTEL_FIXED_VLBR_EVENT, (1ULL << INTEL_PMC_IDX_FIXED_VLBR),

arch/x86/events/intel/pt.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <linux/limits.h>
1818
#include <linux/slab.h>
1919
#include <linux/device.h>
20+
#include <linux/kvm_types.h>
2021

2122
#include <asm/cpuid/api.h>
2223
#include <asm/perf_event.h>
@@ -82,13 +83,13 @@ u32 intel_pt_validate_cap(u32 *caps, enum pt_capabilities capability)
8283

8384
return (c & cd->mask) >> shift;
8485
}
85-
EXPORT_SYMBOL_GPL(intel_pt_validate_cap);
86+
EXPORT_SYMBOL_FOR_KVM(intel_pt_validate_cap);
8687

8788
u32 intel_pt_validate_hw_cap(enum pt_capabilities cap)
8889
{
8990
return intel_pt_validate_cap(pt_pmu.caps, cap);
9091
}
91-
EXPORT_SYMBOL_GPL(intel_pt_validate_hw_cap);
92+
EXPORT_SYMBOL_FOR_KVM(intel_pt_validate_hw_cap);
9293

9394
static ssize_t pt_cap_show(struct device *cdev,
9495
struct device_attribute *attr,
@@ -1590,7 +1591,7 @@ void intel_pt_handle_vmx(int on)
15901591

15911592
local_irq_restore(flags);
15921593
}
1593-
EXPORT_SYMBOL_GPL(intel_pt_handle_vmx);
1594+
EXPORT_SYMBOL_FOR_KVM(intel_pt_handle_vmx);
15941595

15951596
/*
15961597
* PMU callbacks

arch/x86/include/asm/kvm_types.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
#define KVM_SUB_MODULES kvm-intel
1111
#else
1212
#undef KVM_SUB_MODULES
13+
/*
14+
* Don't export symbols for KVM without vendor modules, as kvm.ko is built iff
15+
* at least one vendor module is enabled.
16+
*/
17+
#define EXPORT_SYMBOL_FOR_KVM(symbol)
1318
#endif
1419

1520
#define KVM_ARCH_NR_OBJS_PER_MEMORY_CACHE 40

arch/x86/kernel/apic/apic.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include <linux/dmi.h>
3737
#include <linux/smp.h>
3838
#include <linux/mm.h>
39+
#include <linux/kvm_types.h>
3940

4041
#include <xen/xen.h>
4142

@@ -2319,7 +2320,7 @@ u32 x86_msi_msg_get_destid(struct msi_msg *msg, bool extid)
23192320
dest |= msg->arch_addr_hi.destid_8_31 << 8;
23202321
return dest;
23212322
}
2322-
EXPORT_SYMBOL_GPL(x86_msi_msg_get_destid);
2323+
EXPORT_SYMBOL_FOR_KVM(x86_msi_msg_get_destid);
23232324

23242325
static void __init apic_bsp_up_setup(void)
23252326
{

arch/x86/kernel/apic/apic_common.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* SPDX-License-Identifier: GPL-2.0
55
*/
66
#include <linux/irq.h>
7+
#include <linux/kvm_types.h>
78
#include <asm/apic.h>
89

910
#include "local.h"
@@ -25,7 +26,7 @@ u32 default_cpu_present_to_apicid(int mps_cpu)
2526
else
2627
return BAD_APICID;
2728
}
28-
EXPORT_SYMBOL_GPL(default_cpu_present_to_apicid);
29+
EXPORT_SYMBOL_FOR_KVM(default_cpu_present_to_apicid);
2930

3031
/*
3132
* Set up the logical destination ID when the APIC operates in logical

0 commit comments

Comments
 (0)