Skip to content

Commit

Permalink
Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/l…
Browse files Browse the repository at this point in the history
…inux/kernel/git/tip/tip

Pull x86 fixes from Peter Anvin:
 "This is a collection of miscellaneous fixes, the most important one is
  the fix for the Samsung laptop bricking issue (auto-blacklisting the
  samsung-laptop driver); the efi_enabled() changes you see below are
  prerequisites for that fix.

  The other issues fixed are booting on OLPC XO-1.5, an UV fix, NMI
  debugging, and requiring CAP_SYS_RAWIO for MSR references, just as
  with I/O port references."

* 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  samsung-laptop: Disable on EFI hardware
  efi: Make 'efi_enabled' a function to query EFI facilities
  smp: Fix SMP function call empty cpu mask race
  x86/msr: Add capabilities check
  x86/dma-debug: Bump PREALLOC_DMA_DEBUG_ENTRIES
  x86/olpc: Fix olpc-xo1-sci.c build errors
  arch/x86/platform/uv: Fix incorrect tlb flush all issue
  x86-64: Fix unwind annotations in recent NMI changes
  x86-32: Start out cr0 clean, disable paging before modifying cr3/4
  • Loading branch information
torvalds committed Jan 31, 2013
2 parents 0fe94b9 + e009424 commit bdb0ae6
Show file tree
Hide file tree
Showing 22 changed files with 118 additions and 66 deletions.
1 change: 1 addition & 0 deletions arch/x86/Kconfig
Expand Up @@ -2138,6 +2138,7 @@ config OLPC_XO1_RTC
config OLPC_XO1_SCI
bool "OLPC XO-1 SCI extras"
depends on OLPC && OLPC_XO1_PM
depends on INPUT=y
select POWER_SUPPLY
select GPIO_CS5535
select MFD_CORE
Expand Down
1 change: 1 addition & 0 deletions arch/x86/include/asm/efi.h
Expand Up @@ -94,6 +94,7 @@ extern void __iomem *efi_ioremap(unsigned long addr, unsigned long size,
#endif /* CONFIG_X86_32 */

extern int add_efi_memmap;
extern unsigned long x86_efi_facility;
extern void efi_set_executable(efi_memory_desc_t *md, bool executable);
extern int efi_memblock_x86_reserve_range(void);
extern void efi_call_phys_prelog(void);
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/include/asm/uv/uv.h
Expand Up @@ -16,7 +16,7 @@ extern void uv_system_init(void);
extern const struct cpumask *uv_flush_tlb_others(const struct cpumask *cpumask,
struct mm_struct *mm,
unsigned long start,
unsigned end,
unsigned long end,
unsigned int cpu);

#else /* X86_UV */
Expand Down
7 changes: 3 additions & 4 deletions arch/x86/kernel/entry_64.S
Expand Up @@ -1781,6 +1781,7 @@ first_nmi:
* Leave room for the "copied" frame
*/
subq $(5*8), %rsp
CFI_ADJUST_CFA_OFFSET 5*8

/* Copy the stack frame to the Saved frame */
.rept 5
Expand Down Expand Up @@ -1863,10 +1864,8 @@ end_repeat_nmi:
nmi_swapgs:
SWAPGS_UNSAFE_STACK
nmi_restore:
RESTORE_ALL 8

/* Pop the extra iret frame */
addq $(5*8), %rsp
/* Pop the extra iret frame at once */
RESTORE_ALL 6*8

/* Clear the NMI executing stack variable */
movq $0, 5*8(%rsp)
Expand Down
9 changes: 7 additions & 2 deletions arch/x86/kernel/head_32.S
Expand Up @@ -300,6 +300,12 @@ ENTRY(startup_32_smp)
leal -__PAGE_OFFSET(%ecx),%esp

default_entry:
#define CR0_STATE (X86_CR0_PE | X86_CR0_MP | X86_CR0_ET | \
X86_CR0_NE | X86_CR0_WP | X86_CR0_AM | \
X86_CR0_PG)
movl $(CR0_STATE & ~X86_CR0_PG),%eax
movl %eax,%cr0

/*
* New page tables may be in 4Mbyte page mode and may
* be using the global pages.
Expand Down Expand Up @@ -364,8 +370,7 @@ default_entry:
*/
movl $pa(initial_page_table), %eax
movl %eax,%cr3 /* set the page table pointer.. */
movl %cr0,%eax
orl $X86_CR0_PG,%eax
movl $CR0_STATE,%eax
movl %eax,%cr0 /* ..and set paging (PG) bit */
ljmp $__BOOT_CS,$1f /* Clear prefetch and normalize %eip */
1:
Expand Down
3 changes: 3 additions & 0 deletions arch/x86/kernel/msr.c
Expand Up @@ -174,6 +174,9 @@ static int msr_open(struct inode *inode, struct file *file)
unsigned int cpu;
struct cpuinfo_x86 *c;

if (!capable(CAP_SYS_RAWIO))
return -EPERM;

cpu = iminor(file->f_path.dentry->d_inode);
if (cpu >= nr_cpu_ids || !cpu_online(cpu))
return -ENXIO; /* No such CPU */
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/kernel/pci-dma.c
Expand Up @@ -56,7 +56,7 @@ struct device x86_dma_fallback_dev = {
EXPORT_SYMBOL(x86_dma_fallback_dev);

/* Number of entries preallocated for DMA-API debugging */
#define PREALLOC_DMA_DEBUG_ENTRIES 32768
#define PREALLOC_DMA_DEBUG_ENTRIES 65536

int dma_set_mask(struct device *dev, u64 mask)
{
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/kernel/reboot.c
Expand Up @@ -584,7 +584,7 @@ static void native_machine_emergency_restart(void)
break;

case BOOT_EFI:
if (efi_enabled)
if (efi_enabled(EFI_RUNTIME_SERVICES))
efi.reset_system(reboot_mode ?
EFI_RESET_WARM :
EFI_RESET_COLD,
Expand Down
28 changes: 14 additions & 14 deletions arch/x86/kernel/setup.c
Expand Up @@ -807,15 +807,15 @@ void __init setup_arch(char **cmdline_p)
#ifdef CONFIG_EFI
if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature,
"EL32", 4)) {
efi_enabled = 1;
efi_64bit = false;
set_bit(EFI_BOOT, &x86_efi_facility);
} else if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature,
"EL64", 4)) {
efi_enabled = 1;
efi_64bit = true;
set_bit(EFI_BOOT, &x86_efi_facility);
set_bit(EFI_64BIT, &x86_efi_facility);
}
if (efi_enabled && efi_memblock_x86_reserve_range())
efi_enabled = 0;

if (efi_enabled(EFI_BOOT))
efi_memblock_x86_reserve_range();
#endif

x86_init.oem.arch_setup();
Expand Down Expand Up @@ -888,7 +888,7 @@ void __init setup_arch(char **cmdline_p)

finish_e820_parsing();

if (efi_enabled)
if (efi_enabled(EFI_BOOT))
efi_init();

dmi_scan_machine();
Expand Down Expand Up @@ -971,7 +971,7 @@ void __init setup_arch(char **cmdline_p)
* The EFI specification says that boot service code won't be called
* after ExitBootServices(). This is, in fact, a lie.
*/
if (efi_enabled)
if (efi_enabled(EFI_MEMMAP))
efi_reserve_boot_services();

/* preallocate 4k for mptable mpc */
Expand Down Expand Up @@ -1114,7 +1114,7 @@ void __init setup_arch(char **cmdline_p)

#ifdef CONFIG_VT
#if defined(CONFIG_VGA_CONSOLE)
if (!efi_enabled || (efi_mem_type(0xa0000) != EFI_CONVENTIONAL_MEMORY))
if (!efi_enabled(EFI_BOOT) || (efi_mem_type(0xa0000) != EFI_CONVENTIONAL_MEMORY))
conswitchp = &vga_con;
#elif defined(CONFIG_DUMMY_CONSOLE)
conswitchp = &dummy_con;
Expand All @@ -1131,14 +1131,14 @@ void __init setup_arch(char **cmdline_p)
register_refined_jiffies(CLOCK_TICK_RATE);

#ifdef CONFIG_EFI
/* Once setup is done above, disable efi_enabled on mismatched
* firmware/kernel archtectures since there is no support for
* runtime services.
/* Once setup is done above, unmap the EFI memory map on
* mismatched firmware/kernel archtectures since there is no
* support for runtime services.
*/
if (efi_enabled && IS_ENABLED(CONFIG_X86_64) != efi_64bit) {
if (efi_enabled(EFI_BOOT) &&
IS_ENABLED(CONFIG_X86_64) != efi_enabled(EFI_64BIT)) {
pr_info("efi: Setup done, disabling due to 32/64-bit mismatch\n");
efi_unmap_memmap();
efi_enabled = 0;
}
#endif
}
Expand Down
57 changes: 34 additions & 23 deletions arch/x86/platform/efi/efi.c
Expand Up @@ -51,9 +51,6 @@

#define EFI_DEBUG 1

int efi_enabled;
EXPORT_SYMBOL(efi_enabled);

struct efi __read_mostly efi = {
.mps = EFI_INVALID_TABLE_ADDR,
.acpi = EFI_INVALID_TABLE_ADDR,
Expand All @@ -69,19 +66,28 @@ EXPORT_SYMBOL(efi);

struct efi_memory_map memmap;

bool efi_64bit;

static struct efi efi_phys __initdata;
static efi_system_table_t efi_systab __initdata;

static inline bool efi_is_native(void)
{
return IS_ENABLED(CONFIG_X86_64) == efi_64bit;
return IS_ENABLED(CONFIG_X86_64) == efi_enabled(EFI_64BIT);
}

unsigned long x86_efi_facility;

/*
* Returns 1 if 'facility' is enabled, 0 otherwise.
*/
int efi_enabled(int facility)
{
return test_bit(facility, &x86_efi_facility) != 0;
}
EXPORT_SYMBOL(efi_enabled);

static int __init setup_noefi(char *arg)
{
efi_enabled = 0;
clear_bit(EFI_BOOT, &x86_efi_facility);
return 0;
}
early_param("noefi", setup_noefi);
Expand Down Expand Up @@ -426,6 +432,7 @@ void __init efi_reserve_boot_services(void)

void __init efi_unmap_memmap(void)
{
clear_bit(EFI_MEMMAP, &x86_efi_facility);
if (memmap.map) {
early_iounmap(memmap.map, memmap.nr_map * memmap.desc_size);
memmap.map = NULL;
Expand Down Expand Up @@ -460,7 +467,7 @@ void __init efi_free_boot_services(void)

static int __init efi_systab_init(void *phys)
{
if (efi_64bit) {
if (efi_enabled(EFI_64BIT)) {
efi_system_table_64_t *systab64;
u64 tmp = 0;

Expand Down Expand Up @@ -552,7 +559,7 @@ static int __init efi_config_init(u64 tables, int nr_tables)
void *config_tables, *tablep;
int i, sz;

if (efi_64bit)
if (efi_enabled(EFI_64BIT))
sz = sizeof(efi_config_table_64_t);
else
sz = sizeof(efi_config_table_32_t);
Expand All @@ -572,7 +579,7 @@ static int __init efi_config_init(u64 tables, int nr_tables)
efi_guid_t guid;
unsigned long table;

if (efi_64bit) {
if (efi_enabled(EFI_64BIT)) {
u64 table64;
guid = ((efi_config_table_64_t *)tablep)->guid;
table64 = ((efi_config_table_64_t *)tablep)->table;
Expand Down Expand Up @@ -684,7 +691,6 @@ void __init efi_init(void)
if (boot_params.efi_info.efi_systab_hi ||
boot_params.efi_info.efi_memmap_hi) {
pr_info("Table located above 4GB, disabling EFI.\n");
efi_enabled = 0;
return;
}
efi_phys.systab = (efi_system_table_t *)boot_params.efi_info.efi_systab;
Expand All @@ -694,10 +700,10 @@ void __init efi_init(void)
((__u64)boot_params.efi_info.efi_systab_hi<<32));
#endif

if (efi_systab_init(efi_phys.systab)) {
efi_enabled = 0;
if (efi_systab_init(efi_phys.systab))
return;
}

set_bit(EFI_SYSTEM_TABLES, &x86_efi_facility);

/*
* Show what we know for posterity
Expand All @@ -715,10 +721,10 @@ void __init efi_init(void)
efi.systab->hdr.revision >> 16,
efi.systab->hdr.revision & 0xffff, vendor);

if (efi_config_init(efi.systab->tables, efi.systab->nr_tables)) {
efi_enabled = 0;
if (efi_config_init(efi.systab->tables, efi.systab->nr_tables))
return;
}

set_bit(EFI_CONFIG_TABLES, &x86_efi_facility);

/*
* Note: We currently don't support runtime services on an EFI
Expand All @@ -727,15 +733,17 @@ void __init efi_init(void)

if (!efi_is_native())
pr_info("No EFI runtime due to 32/64-bit mismatch with kernel\n");
else if (efi_runtime_init()) {
efi_enabled = 0;
return;
else {
if (efi_runtime_init())
return;
set_bit(EFI_RUNTIME_SERVICES, &x86_efi_facility);
}

if (efi_memmap_init()) {
efi_enabled = 0;
if (efi_memmap_init())
return;
}

set_bit(EFI_MEMMAP, &x86_efi_facility);

#ifdef CONFIG_X86_32
if (efi_is_native()) {
x86_platform.get_wallclock = efi_get_time;
Expand Down Expand Up @@ -969,6 +977,9 @@ u32 efi_mem_type(unsigned long phys_addr)
efi_memory_desc_t *md;
void *p;

if (!efi_enabled(EFI_MEMMAP))
return 0;

for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
md = p;
if ((md->phys_addr <= phys_addr) &&
Expand Down
10 changes: 7 additions & 3 deletions arch/x86/platform/uv/tlb_uv.c
Expand Up @@ -1034,7 +1034,8 @@ static int set_distrib_bits(struct cpumask *flush_mask, struct bau_control *bcp,
* globally purge translation cache of a virtual address or all TLB's
* @cpumask: mask of all cpu's in which the address is to be removed
* @mm: mm_struct containing virtual address range
* @va: virtual address to be removed (or TLB_FLUSH_ALL for all TLB's on cpu)
* @start: start virtual address to be removed from TLB
* @end: end virtual address to be remove from TLB
* @cpu: the current cpu
*
* This is the entry point for initiating any UV global TLB shootdown.
Expand All @@ -1056,7 +1057,7 @@ static int set_distrib_bits(struct cpumask *flush_mask, struct bau_control *bcp,
*/
const struct cpumask *uv_flush_tlb_others(const struct cpumask *cpumask,
struct mm_struct *mm, unsigned long start,
unsigned end, unsigned int cpu)
unsigned long end, unsigned int cpu)
{
int locals = 0;
int remotes = 0;
Expand Down Expand Up @@ -1113,7 +1114,10 @@ const struct cpumask *uv_flush_tlb_others(const struct cpumask *cpumask,

record_send_statistics(stat, locals, hubs, remotes, bau_desc);

bau_desc->payload.address = start;
if (!end || (end - start) <= PAGE_SIZE)
bau_desc->payload.address = start;
else
bau_desc->payload.address = TLB_FLUSH_ALL;
bau_desc->payload.sending_cpu = cpu;
/*
* uv_flush_send_and_wait returns 0 if all cpu's were messaged,
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/osl.c
Expand Up @@ -250,7 +250,7 @@ acpi_physical_address __init acpi_os_get_root_pointer(void)
return acpi_rsdp;
#endif

if (efi_enabled) {
if (efi_enabled(EFI_CONFIG_TABLES)) {
if (efi.acpi20 != EFI_INVALID_TABLE_ADDR)
return efi.acpi20;
else if (efi.acpi != EFI_INVALID_TABLE_ADDR)
Expand Down
2 changes: 1 addition & 1 deletion drivers/firmware/dmi_scan.c
Expand Up @@ -471,7 +471,7 @@ void __init dmi_scan_machine(void)
char __iomem *p, *q;
int rc;

if (efi_enabled) {
if (efi_enabled(EFI_CONFIG_TABLES)) {
if (efi.smbios == EFI_INVALID_TABLE_ADDR)
goto error;

Expand Down
4 changes: 2 additions & 2 deletions drivers/firmware/efivars.c
Expand Up @@ -1782,7 +1782,7 @@ efivars_init(void)
printk(KERN_INFO "EFI Variables Facility v%s %s\n", EFIVARS_VERSION,
EFIVARS_DATE);

if (!efi_enabled)
if (!efi_enabled(EFI_RUNTIME_SERVICES))
return 0;

/* For now we'll register the efi directory at /sys/firmware/efi */
Expand Down Expand Up @@ -1822,7 +1822,7 @@ efivars_init(void)
static void __exit
efivars_exit(void)
{
if (efi_enabled) {
if (efi_enabled(EFI_RUNTIME_SERVICES)) {
unregister_efivars(&__efivars);
kobject_put(efi_kobj);
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/firmware/iscsi_ibft_find.c
Expand Up @@ -99,7 +99,7 @@ unsigned long __init find_ibft_region(unsigned long *sizep)
/* iBFT 1.03 section 1.4.3.1 mandates that UEFI machines will
* only use ACPI for this */

if (!efi_enabled)
if (!efi_enabled(EFI_BOOT))
find_ibft_in_mem();

if (ibft_addr) {
Expand Down
3 changes: 2 additions & 1 deletion drivers/gpu/drm/radeon/radeon_device.c
Expand Up @@ -429,7 +429,8 @@ bool radeon_card_posted(struct radeon_device *rdev)
{
uint32_t reg;

if (efi_enabled && rdev->pdev->subsystem_vendor == PCI_VENDOR_ID_APPLE)
if (efi_enabled(EFI_BOOT) &&
rdev->pdev->subsystem_vendor == PCI_VENDOR_ID_APPLE)
return false;

/* first check CRTCs */
Expand Down

0 comments on commit bdb0ae6

Please sign in to comment.