1 From 7f284d3cc96e02468a42e045f77af11e5ff8b095 Mon Sep 17 00:00:00 2001
2 From: Frank Arnold <frank.arnold@amd.com>
3 Date: Thu, 22 Apr 2010 16:06:59 +0200
4 Subject: x86, cacheinfo: Turn off L3 cache index disable feature in virtualized environments
6 From: Frank Arnold <frank.arnold@amd.com>
8 commit 7f284d3cc96e02468a42e045f77af11e5ff8b095 upstream.
10 When running a quest kernel on xen we get:
12 BUG: unable to handle kernel NULL pointer dereference at 0000000000000038
13 IP: [<ffffffff8142f2fb>] cpuid4_cache_lookup_regs+0x2ca/0x3df
20 Pid: 0, comm: swapper Tainted: G W 2.6.34-rc3 #1 /HVM domU
21 RIP: 0010:[<ffffffff8142f2fb>] [<ffffffff8142f2fb>] cpuid4_cache_lookup_regs+0x
23 RSP: 0018:ffff880002203e08 EFLAGS: 00010046
24 RAX: 0000000000000000 RBX: 0000000000000003 RCX: 0000000000000060
25 RDX: 0000000000000000 RSI: 0000000000000040 RDI: 0000000000000000
26 RBP: ffff880002203ed8 R08: 00000000000017c0 R09: ffff880002203e38
27 R10: ffff8800023d5d40 R11: ffffffff81a01e28 R12: ffff880187e6f5c0
28 R13: ffff880002203e34 R14: ffff880002203e58 R15: ffff880002203e68
29 FS: 0000000000000000(0000) GS:ffff880002200000(0000) knlGS:0000000000000000
30 CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b
31 CR2: 0000000000000038 CR3: 0000000001a3c000 CR4: 00000000000006f0
32 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
33 DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
34 Process swapper (pid: 0, threadinfo ffffffff81a00000, task ffffffff81a44020)
36 ffffffff810d7ecb ffff880002203e20 ffffffff81059140 ffff880002203e30
37 <0> ffffffff810d7ec9 0000000002203e40 000000000050d140 ffff880002203e70
38 <0> 0000000002008140 0000000000000086 ffff880040020140 ffffffff81068b8b
41 [<ffffffff810d7ecb>] ? sync_supers_timer_fn+0x0/0x1c
42 [<ffffffff81059140>] ? mod_timer+0x23/0x25
43 [<ffffffff810d7ec9>] ? arm_supers_timer+0x34/0x36
44 [<ffffffff81068b8b>] ? hrtimer_get_next_event+0xa7/0xc3
45 [<ffffffff81058e85>] ? get_next_timer_interrupt+0x19a/0x20d
46 [<ffffffff8142fa23>] get_cpu_leaves+0x5c/0x232
47 [<ffffffff8106a7b1>] ? sched_clock_local+0x1c/0x82
48 [<ffffffff8106a9a0>] ? sched_clock_tick+0x75/0x7a
49 [<ffffffff8107748c>] generic_smp_call_function_single_interrupt+0xae/0xd0
50 [<ffffffff8101f6ef>] smp_call_function_single_interrupt+0x18/0x27
51 [<ffffffff8100a773>] call_function_single_interrupt+0x13/0x20
53 [<ffffffff8143c468>] ? notifier_call_chain+0x14/0x63
54 [<ffffffff810295c6>] ? native_safe_halt+0xc/0xd
55 [<ffffffff810114eb>] ? default_idle+0x36/0x53
56 [<ffffffff81008c22>] cpu_idle+0xaa/0xe4
57 [<ffffffff81423a9a>] rest_init+0x7e/0x80
58 [<ffffffff81b10dd2>] start_kernel+0x40e/0x419
59 [<ffffffff81b102c8>] x86_64_start_reservations+0xb3/0xb7
60 [<ffffffff81b103c4>] x86_64_start_kernel+0xf8/0x107
61 Code: 14 d5 40 ff ae 81 8b 14 02 31 c0 3b 15 47 1c 8b 00 7d 0e 48 8b 05 36 1c 8b
62 00 48 63 d2 48 8b 04 d0 c7 85 5c ff ff ff 00 00 00 00 <8b> 70 38 48 8d 8d 5c ff
63 ff ff 48 8b 78 10 ba c4 01 00 00 e8 eb
64 RIP [<ffffffff8142f2fb>] cpuid4_cache_lookup_regs+0x2ca/0x3df
65 RSP <ffff880002203e08>
67 ---[ end trace a7919e7f17c0a726 ]---
69 The L3 cache index disable feature of AMD CPUs has to be disabled if the
70 kernel is running as guest on top of a hypervisor because northbridge
71 devices are not available to the guest. Currently, this fixes a boot
72 crash on top of Xen. In the future this will become an issue on KVM as
75 Check if northbridge devices are present and do not enable the feature
78 [ hpa: backported to 2.6.34 ]
80 Signed-off-by: Frank Arnold <frank.arnold@amd.com>
81 LKML-Reference: <1271945222-5283-3-git-send-email-bp@amd64.org>
82 Acked-by: Borislav Petkov <borislav.petkov@amd.com>
83 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
84 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
87 arch/x86/kernel/cpu/intel_cacheinfo.c | 4 ++++
88 1 file changed, 4 insertions(+)
90 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
91 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
92 @@ -338,6 +338,10 @@ amd_check_l3_disable(int index, struct _
93 (boot_cpu_data.x86_mask < 0x1)))
96 + /* not in virtualized environments */
97 + if (num_k8_northbridges == 0)
100 this_leaf->can_disable = true;
101 this_leaf->l3_indices = amd_calc_l3_indices();