Skip to content

Commit

Permalink
Merge branch 'x86-fixes-for-linus' of git://git.kernel.org/pub/scm/li…
Browse files Browse the repository at this point in the history
…nux/kernel/git/tip/linux-2.6-tip

* 'x86-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
  x86: Remove redundant non-NUMA topology functions
  x86: early_printk: Protect against using the same device twice
  x86: Reduce verbosity of "PAT enabled" kernel message
  x86: Reduce verbosity of "TSC is reliable" message
  x86: mce: Use safer ways to access MCE registers
  x86: mce, inject: Use real inject-msg in raise_local
  x86: mce: Fix thermal throttling message storm
  x86: mce: Clean up thermal throttling state tracking code
  x86: split NX setup into separate file to limit unstack-protected code
  xen: check EFER for NX before setting up GDT mapping
  x86: Cleanup linker script using new linker script macros.
  x86: Use section .data.page_aligned for the idt_table.
  x86: convert to use __HEAD and HEAD_TEXT macros.
  x86: convert compressed loader to use __HEAD and HEAD_TEXT macros.
  x86: fix fragile computation of vsyscall address
  • Loading branch information
Linus Torvalds committed Sep 26, 2009
2 parents 76e0134 + 704daf5 commit 5bb241b
Show file tree
Hide file tree
Showing 19 changed files with 180 additions and 188 deletions.
3 changes: 2 additions & 1 deletion arch/x86/boot/compressed/head_32.S
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@
*/
.text

#include <linux/init.h>
#include <linux/linkage.h>
#include <asm/segment.h>
#include <asm/page_types.h>
#include <asm/boot.h>
#include <asm/asm-offsets.h>

.section ".text.head","ax",@progbits
__HEAD
ENTRY(startup_32)
cld
/*
Expand Down
3 changes: 2 additions & 1 deletion arch/x86/boot/compressed/head_64.S
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
.code32
.text

#include <linux/init.h>
#include <linux/linkage.h>
#include <asm/segment.h>
#include <asm/pgtable_types.h>
Expand All @@ -33,7 +34,7 @@
#include <asm/processor-flags.h>
#include <asm/asm-offsets.h>

.section ".text.head"
__HEAD
.code32
ENTRY(startup_32)
cld
Expand Down
6 changes: 4 additions & 2 deletions arch/x86/boot/compressed/vmlinux.lds.S
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <asm-generic/vmlinux.lds.h>

OUTPUT_FORMAT(CONFIG_OUTPUT_FORMAT, CONFIG_OUTPUT_FORMAT, CONFIG_OUTPUT_FORMAT)

#undef i386
Expand All @@ -18,9 +20,9 @@ SECTIONS
* address 0.
*/
. = 0;
.text.head : {
.head.text : {
_head = . ;
*(.text.head)
HEAD_TEXT
_ehead = . ;
}
.rodata.compressed : {
Expand Down
1 change: 1 addition & 0 deletions arch/x86/include/asm/pgtable_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ static inline pteval_t pte_flags(pte_t pte)
typedef struct page *pgtable_t;

extern pteval_t __supported_pte_mask;
extern void set_nx(void);
extern int nx_enabled;

#define pgprot_writecombine pgprot_writecombine
Expand Down
10 changes: 0 additions & 10 deletions arch/x86/include/asm/topology.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,21 +165,11 @@ static inline int numa_node_id(void)
return 0;
}

static inline int cpu_to_node(int cpu)
{
return 0;
}

static inline int early_cpu_to_node(int cpu)
{
return 0;
}

static inline const struct cpumask *cpumask_of_node(int node)
{
return cpu_online_mask;
}

static inline void setup_node_to_cpumask_map(void) { }

#endif
Expand Down
7 changes: 4 additions & 3 deletions arch/x86/kernel/cpu/mcheck/mce-inject.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ static struct notifier_block mce_raise_nb = {
};

/* Inject mce on current CPU */
static int raise_local(struct mce *m)
static int raise_local(void)
{
struct mce *m = &__get_cpu_var(injectm);
int context = MCJ_CTX(m->inject_flags);
int ret = 0;
int cpu = m->extcpu;
Expand Down Expand Up @@ -167,12 +168,12 @@ static void raise_mce(struct mce *m)
}
cpu_relax();
}
raise_local(m);
raise_local();
put_cpu();
put_online_cpus();
} else
#endif
raise_local(m);
raise_local();
}

/* Error injection interface */
Expand Down
23 changes: 21 additions & 2 deletions arch/x86/kernel/cpu/mcheck/mce.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,20 +305,33 @@ static int msr_to_offset(u32 msr)
static u64 mce_rdmsrl(u32 msr)
{
u64 v;

if (__get_cpu_var(injectm).finished) {
int offset = msr_to_offset(msr);

if (offset < 0)
return 0;
return *(u64 *)((char *)&__get_cpu_var(injectm) + offset);
}
rdmsrl(msr, v);

if (rdmsrl_safe(msr, &v)) {
WARN_ONCE(1, "mce: Unable to read msr %d!\n", msr);
/*
* Return zero in case the access faulted. This should
* not happen normally but can happen if the CPU does
* something weird, or if the code is buggy.
*/
v = 0;
}

return v;
}

static void mce_wrmsrl(u32 msr, u64 v)
{
if (__get_cpu_var(injectm).finished) {
int offset = msr_to_offset(msr);

if (offset >= 0)
*(u64 *)((char *)&__get_cpu_var(injectm) + offset) = v;
return;
Expand Down Expand Up @@ -415,7 +428,7 @@ static inline void mce_get_rip(struct mce *m, struct pt_regs *regs)
m->ip = mce_rdmsrl(rip_msr);
}

#ifdef CONFIG_X86_LOCAL_APIC
#ifdef CONFIG_X86_LOCAL_APIC
/*
* Called after interrupts have been reenabled again
* when a MCE happened during an interrupts off region
Expand Down Expand Up @@ -1172,6 +1185,7 @@ static int mce_banks_init(void)
return -ENOMEM;
for (i = 0; i < banks; i++) {
struct mce_bank *b = &mce_banks[i];

b->ctl = -1ULL;
b->init = 1;
}
Expand Down Expand Up @@ -1203,6 +1217,7 @@ static int __cpuinit mce_cap_init(void)
banks = b;
if (!mce_banks) {
int err = mce_banks_init();

if (err)
return err;
}
Expand Down Expand Up @@ -1237,6 +1252,7 @@ static void mce_init(void)

for (i = 0; i < banks; i++) {
struct mce_bank *b = &mce_banks[i];

if (!b->init)
continue;
wrmsrl(MSR_IA32_MCx_CTL(i), b->ctl);
Expand Down Expand Up @@ -1626,6 +1642,7 @@ static int mce_disable(void)

for (i = 0; i < banks; i++) {
struct mce_bank *b = &mce_banks[i];

if (b->init)
wrmsrl(MSR_IA32_MCx_CTL(i), 0);
}
Expand Down Expand Up @@ -1911,6 +1928,7 @@ static void mce_disable_cpu(void *h)
cmci_clear();
for (i = 0; i < banks; i++) {
struct mce_bank *b = &mce_banks[i];

if (b->init)
wrmsrl(MSR_IA32_MCx_CTL(i), 0);
}
Expand All @@ -1928,6 +1946,7 @@ static void mce_reenable_cpu(void *h)
cmci_reenable();
for (i = 0; i < banks; i++) {
struct mce_bank *b = &mce_banks[i];

if (b->init)
wrmsrl(MSR_IA32_MCx_CTL(i), b->ctl);
}
Expand Down
67 changes: 42 additions & 25 deletions arch/x86/kernel/cpu/mcheck/therm_throt.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,40 +34,51 @@
/* How long to wait between reporting thermal events */
#define CHECK_INTERVAL (300 * HZ)

static DEFINE_PER_CPU(__u64, next_check) = INITIAL_JIFFIES;
static DEFINE_PER_CPU(unsigned long, thermal_throttle_count);
static DEFINE_PER_CPU(bool, thermal_throttle_active);
/*
* Current thermal throttling state:
*/
struct thermal_state {
bool is_throttled;

u64 next_check;
unsigned long throttle_count;
unsigned long last_throttle_count;
};

static DEFINE_PER_CPU(struct thermal_state, thermal_state);

static atomic_t therm_throt_en = ATOMIC_INIT(0);
static atomic_t therm_throt_en = ATOMIC_INIT(0);

#ifdef CONFIG_SYSFS
#define define_therm_throt_sysdev_one_ro(_name) \
static SYSDEV_ATTR(_name, 0444, therm_throt_sysdev_show_##_name, NULL)

#define define_therm_throt_sysdev_show_func(name) \
static ssize_t therm_throt_sysdev_show_##name(struct sys_device *dev, \
struct sysdev_attribute *attr, \
char *buf) \
\
static ssize_t therm_throt_sysdev_show_##name( \
struct sys_device *dev, \
struct sysdev_attribute *attr, \
char *buf) \
{ \
unsigned int cpu = dev->id; \
ssize_t ret; \
\
preempt_disable(); /* CPU hotplug */ \
if (cpu_online(cpu)) \
ret = sprintf(buf, "%lu\n", \
per_cpu(thermal_throttle_##name, cpu)); \
per_cpu(thermal_state, cpu).name); \
else \
ret = 0; \
preempt_enable(); \
\
return ret; \
}

define_therm_throt_sysdev_show_func(count);
define_therm_throt_sysdev_one_ro(count);
define_therm_throt_sysdev_show_func(throttle_count);
define_therm_throt_sysdev_one_ro(throttle_count);

static struct attribute *thermal_throttle_attrs[] = {
&attr_count.attr,
&attr_throttle_count.attr,
NULL
};

Expand All @@ -93,33 +104,39 @@ static struct attribute_group thermal_throttle_attr_group = {
* 1 : Event should be logged further, and a message has been
* printed to the syslog.
*/
static int therm_throt_process(int curr)
static int therm_throt_process(bool is_throttled)
{
unsigned int cpu = smp_processor_id();
__u64 tmp_jiffs = get_jiffies_64();
bool was_throttled = __get_cpu_var(thermal_throttle_active);
bool is_throttled = __get_cpu_var(thermal_throttle_active) = curr;
struct thermal_state *state;
unsigned int this_cpu;
bool was_throttled;
u64 now;

this_cpu = smp_processor_id();
now = get_jiffies_64();
state = &per_cpu(thermal_state, this_cpu);

was_throttled = state->is_throttled;
state->is_throttled = is_throttled;

if (is_throttled)
__get_cpu_var(thermal_throttle_count)++;
state->throttle_count++;

if (!(was_throttled ^ is_throttled) &&
time_before64(tmp_jiffs, __get_cpu_var(next_check)))
if (time_before64(now, state->next_check) &&
state->throttle_count != state->last_throttle_count)
return 0;

__get_cpu_var(next_check) = tmp_jiffs + CHECK_INTERVAL;
state->next_check = now + CHECK_INTERVAL;
state->last_throttle_count = state->throttle_count;

/* if we just entered the thermal event */
if (is_throttled) {
printk(KERN_CRIT "CPU%d: Temperature above threshold, "
"cpu clock throttled (total events = %lu)\n",
cpu, __get_cpu_var(thermal_throttle_count));
printk(KERN_CRIT "CPU%d: Temperature above threshold, cpu clock throttled (total events = %lu)\n", this_cpu, state->throttle_count);

add_taint(TAINT_MACHINE_CHECK);
return 1;
}
if (was_throttled) {
printk(KERN_INFO "CPU%d: Temperature/speed normal\n", cpu);
printk(KERN_INFO "CPU%d: Temperature/speed normal\n", this_cpu);
return 1;
}

Expand Down Expand Up @@ -213,7 +230,7 @@ static void intel_thermal_interrupt(void)
__u64 msr_val;

rdmsrl(MSR_IA32_THERM_STATUS, msr_val);
if (therm_throt_process(msr_val & THERM_STATUS_PROCHOT))
if (therm_throt_process((msr_val & THERM_STATUS_PROCHOT) != 0))
mce_log_therm_throt_event(msr_val);
}

Expand Down
5 changes: 5 additions & 0 deletions arch/x86/kernel/early_printk.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ asmlinkage void early_printk(const char *fmt, ...)

static inline void early_console_register(struct console *con, int keep_early)
{
if (early_console->index != -1) {
printk(KERN_CRIT "ERROR: earlyprintk= %s already used\n",
con->name);
return;
}
early_console = con;
if (keep_early)
early_console->flags &= ~CON_BOOT;
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/kernel/head_32.S
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
* any particular GDT layout, because we load our own as soon as we
* can.
*/
.section .text.head,"ax",@progbits
__HEAD
ENTRY(startup_32)
/* test KEEP_SEGMENTS flag to see if the bootloader is asking
us to not reload segments */
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/kernel/head_64.S
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ L4_START_KERNEL = pgd_index(__START_KERNEL_map)
L3_START_KERNEL = pud_index(__START_KERNEL_map)

.text
.section .text.head
__HEAD
.code64
.globl startup_64
startup_64:
Expand Down
6 changes: 2 additions & 4 deletions arch/x86/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,9 @@ char ignore_fpu_irq;

/*
* The IDT has to be page-aligned to simplify the Pentium
* F0 0F bug workaround.. We have a special link segment
* for this.
* F0 0F bug workaround.
*/
gate_desc idt_table[NR_VECTORS]
__attribute__((__section__(".data.idt"))) = { { { { 0, 0 } } }, };
gate_desc idt_table[NR_VECTORS] __page_aligned_data = { { { { 0, 0 } } }, };
#endif

DECLARE_BITMAP(used_vectors, NR_VECTORS);
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/kernel/tsc_sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void __cpuinit check_tsc_sync_source(int cpu)
return;

if (boot_cpu_has(X86_FEATURE_TSC_RELIABLE)) {
pr_info("Skipping synchronization checks as TSC is reliable.\n");
printk_once(KERN_INFO "Skipping synchronization checks as TSC is reliable.\n");
return;
}

Expand Down
Loading

0 comments on commit 5bb241b

Please sign in to comment.