License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 22:07:57 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* bioscalls.c - the lowlevel layer of the PnPBIOS driver
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/linkage.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/pnp.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/smp.h>
|
|
|
|
#include <linux/kmod.h>
|
|
|
|
#include <linux/completion.h>
|
|
|
|
#include <linux/spinlock.h>
|
|
|
|
|
|
|
|
#include <asm/page.h>
|
|
|
|
#include <asm/desc.h>
|
|
|
|
#include <asm/byteorder.h>
|
|
|
|
|
|
|
|
#include "pnpbios.h"
|
|
|
|
|
2014-02-08 15:52:00 +08:00
|
|
|
__visible struct {
|
2007-07-27 01:41:20 +08:00
|
|
|
u16 offset;
|
|
|
|
u16 segment;
|
2005-04-17 06:20:36 +08:00
|
|
|
} pnp_bios_callpoint;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* These are some opcodes for a "static asmlinkage"
|
|
|
|
* As this code is *not* executed inside the linux kernel segment, but in a
|
|
|
|
* alias at offset 0, we need a far return that can not be compiled by
|
|
|
|
* default (please, prove me wrong! this is *really* ugly!)
|
|
|
|
* This is the only way to get the bios to return into the kernel code,
|
|
|
|
* because the bios code runs in 16 bit protected mode and therefore can only
|
|
|
|
* return to the caller if the call is within the first 64kB, and the linux
|
|
|
|
* kernel begins at offset 3GB...
|
|
|
|
*/
|
|
|
|
|
2014-05-02 06:44:38 +08:00
|
|
|
asmlinkage __visible void pnp_bios_callfunc(void);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-07-27 01:41:20 +08:00
|
|
|
__asm__(".text \n"
|
2005-04-17 06:20:36 +08:00
|
|
|
__ALIGN_STR "\n"
|
2014-02-08 15:52:00 +08:00
|
|
|
".globl pnp_bios_callfunc\n"
|
2005-04-17 06:20:36 +08:00
|
|
|
"pnp_bios_callfunc:\n"
|
|
|
|
" pushl %edx \n"
|
|
|
|
" pushl %ecx \n"
|
|
|
|
" pushl %ebx \n"
|
|
|
|
" pushl %eax \n"
|
|
|
|
" lcallw *pnp_bios_callpoint\n"
|
|
|
|
" addl $16, %esp \n"
|
2007-07-27 01:41:21 +08:00
|
|
|
" lret \n"
|
|
|
|
".previous \n");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#define Q2_SET_SEL(cpu, selname, address, size) \
|
|
|
|
do { \
|
2017-03-15 01:05:07 +08:00
|
|
|
struct desc_struct *gdt = get_cpu_gdt_rw((cpu)); \
|
2009-07-18 23:11:06 +08:00
|
|
|
set_desc_base(&gdt[(selname) >> 3], (u32)(address)); \
|
|
|
|
set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
|
2005-04-17 06:20:36 +08:00
|
|
|
} while(0)
|
|
|
|
|
2009-08-09 16:03:52 +08:00
|
|
|
static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
|
|
|
|
(unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* At some point we want to use this stack frame pointer to unwind
|
|
|
|
* after PnP BIOS oopses.
|
|
|
|
*/
|
|
|
|
|
2014-02-08 15:52:00 +08:00
|
|
|
__visible u32 pnp_bios_fault_esp;
|
|
|
|
__visible u32 pnp_bios_fault_eip;
|
|
|
|
__visible u32 pnp_bios_is_utter_crap = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
static spinlock_t pnp_bios_lock;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Support Functions
|
|
|
|
*/
|
|
|
|
|
|
|
|
static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
|
|
|
|
u16 arg4, u16 arg5, u16 arg6, u16 arg7,
|
|
|
|
void *ts1_base, u32 ts1_size,
|
|
|
|
void *ts2_base, u32 ts2_size)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
u16 status;
|
|
|
|
struct desc_struct save_desc_40;
|
|
|
|
int cpu;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PnP BIOSes are generally not terribly re-entrant.
|
|
|
|
* Also, don't rely on them to save everything correctly.
|
|
|
|
*/
|
2007-07-27 01:41:20 +08:00
|
|
|
if (pnp_bios_is_utter_crap)
|
2005-04-17 06:20:36 +08:00
|
|
|
return PNP_FUNCTION_NOT_SUPPORTED;
|
|
|
|
|
|
|
|
cpu = get_cpu();
|
2017-03-15 01:05:07 +08:00
|
|
|
save_desc_40 = get_cpu_gdt_rw(cpu)[0x40 / 8];
|
|
|
|
get_cpu_gdt_rw(cpu)[0x40 / 8] = bad_bios_desc;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* On some boxes IRQ's during PnP BIOS calls are deadly. */
|
|
|
|
spin_lock_irqsave(&pnp_bios_lock, flags);
|
|
|
|
|
|
|
|
/* The lock prevents us bouncing CPU here */
|
|
|
|
if (ts1_size)
|
|
|
|
Q2_SET_SEL(smp_processor_id(), PNP_TS1, ts1_base, ts1_size);
|
|
|
|
if (ts2_size)
|
|
|
|
Q2_SET_SEL(smp_processor_id(), PNP_TS2, ts2_base, ts2_size);
|
|
|
|
|
2007-07-27 01:41:20 +08:00
|
|
|
__asm__ __volatile__("pushl %%ebp\n\t"
|
|
|
|
"pushl %%edi\n\t"
|
|
|
|
"pushl %%esi\n\t"
|
|
|
|
"pushl %%ds\n\t"
|
|
|
|
"pushl %%es\n\t"
|
|
|
|
"pushl %%fs\n\t"
|
|
|
|
"pushl %%gs\n\t"
|
|
|
|
"pushfl\n\t"
|
|
|
|
"movl %%esp, pnp_bios_fault_esp\n\t"
|
|
|
|
"movl $1f, pnp_bios_fault_eip\n\t"
|
|
|
|
"lcall %5,%6\n\t"
|
|
|
|
"1:popfl\n\t"
|
|
|
|
"popl %%gs\n\t"
|
|
|
|
"popl %%fs\n\t"
|
|
|
|
"popl %%es\n\t"
|
|
|
|
"popl %%ds\n\t"
|
|
|
|
"popl %%esi\n\t"
|
2007-07-27 01:41:21 +08:00
|
|
|
"popl %%edi\n\t"
|
|
|
|
"popl %%ebp\n\t":"=a"(status)
|
2007-07-27 01:41:20 +08:00
|
|
|
:"0"((func) | (((u32) arg1) << 16)),
|
|
|
|
"b"((arg2) | (((u32) arg3) << 16)),
|
|
|
|
"c"((arg4) | (((u32) arg5) << 16)),
|
|
|
|
"d"((arg6) | (((u32) arg7) << 16)),
|
|
|
|
"i"(PNP_CS32), "i"(0)
|
|
|
|
:"memory");
|
2005-04-17 06:20:36 +08:00
|
|
|
spin_unlock_irqrestore(&pnp_bios_lock, flags);
|
|
|
|
|
2017-03-15 01:05:07 +08:00
|
|
|
get_cpu_gdt_rw(cpu)[0x40 / 8] = save_desc_40;
|
2005-04-17 06:20:36 +08:00
|
|
|
put_cpu();
|
|
|
|
|
|
|
|
/* If we get here and this is set then the PnP BIOS faulted on us. */
|
2007-07-27 01:41:20 +08:00
|
|
|
if (pnp_bios_is_utter_crap) {
|
|
|
|
printk(KERN_ERR
|
|
|
|
"PnPBIOS: Warning! Your PnP BIOS caused a fatal error. Attempting to continue\n");
|
|
|
|
printk(KERN_ERR
|
|
|
|
"PnPBIOS: You may need to reboot with the \"pnpbios=off\" option to operate stably\n");
|
|
|
|
printk(KERN_ERR
|
|
|
|
"PnPBIOS: Check with your vendor for an updated BIOS\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2007-07-27 01:41:20 +08:00
|
|
|
void pnpbios_print_status(const char *module, u16 status)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-07-27 01:41:20 +08:00
|
|
|
switch (status) {
|
2005-04-17 06:20:36 +08:00
|
|
|
case PNP_SUCCESS:
|
|
|
|
printk(KERN_ERR "PnPBIOS: %s: function successful\n", module);
|
|
|
|
break;
|
|
|
|
case PNP_NOT_SET_STATICALLY:
|
2007-07-27 01:41:20 +08:00
|
|
|
printk(KERN_ERR "PnPBIOS: %s: unable to set static resources\n",
|
|
|
|
module);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
case PNP_UNKNOWN_FUNCTION:
|
2007-07-27 01:41:20 +08:00
|
|
|
printk(KERN_ERR "PnPBIOS: %s: invalid function number passed\n",
|
|
|
|
module);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
case PNP_FUNCTION_NOT_SUPPORTED:
|
2007-07-27 01:41:20 +08:00
|
|
|
printk(KERN_ERR
|
|
|
|
"PnPBIOS: %s: function not supported on this system\n",
|
|
|
|
module);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
case PNP_INVALID_HANDLE:
|
|
|
|
printk(KERN_ERR "PnPBIOS: %s: invalid handle\n", module);
|
|
|
|
break;
|
|
|
|
case PNP_BAD_PARAMETER:
|
2007-07-27 01:41:20 +08:00
|
|
|
printk(KERN_ERR "PnPBIOS: %s: invalid parameters were passed\n",
|
|
|
|
module);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
case PNP_SET_FAILED:
|
2007-07-27 01:41:20 +08:00
|
|
|
printk(KERN_ERR "PnPBIOS: %s: unable to set resources\n",
|
|
|
|
module);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
case PNP_EVENTS_NOT_PENDING:
|
|
|
|
printk(KERN_ERR "PnPBIOS: %s: no events are pending\n", module);
|
|
|
|
break;
|
|
|
|
case PNP_SYSTEM_NOT_DOCKED:
|
2007-07-27 01:41:20 +08:00
|
|
|
printk(KERN_ERR "PnPBIOS: %s: the system is not docked\n",
|
|
|
|
module);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
case PNP_NO_ISA_PNP_CARDS:
|
2007-07-27 01:41:20 +08:00
|
|
|
printk(KERN_ERR
|
|
|
|
"PnPBIOS: %s: no isapnp cards are installed on this system\n",
|
|
|
|
module);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
case PNP_UNABLE_TO_DETERMINE_DOCK_CAPABILITIES:
|
2007-07-27 01:41:20 +08:00
|
|
|
printk(KERN_ERR
|
|
|
|
"PnPBIOS: %s: cannot determine the capabilities of the docking station\n",
|
|
|
|
module);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
case PNP_CONFIG_CHANGE_FAILED_NO_BATTERY:
|
2007-07-27 01:41:20 +08:00
|
|
|
printk(KERN_ERR
|
|
|
|
"PnPBIOS: %s: unable to undock, the system does not have a battery\n",
|
|
|
|
module);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
case PNP_CONFIG_CHANGE_FAILED_RESOURCE_CONFLICT:
|
2007-07-27 01:41:20 +08:00
|
|
|
printk(KERN_ERR
|
|
|
|
"PnPBIOS: %s: could not dock due to resource conflicts\n",
|
|
|
|
module);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
case PNP_BUFFER_TOO_SMALL:
|
2007-07-27 01:41:20 +08:00
|
|
|
printk(KERN_ERR "PnPBIOS: %s: the buffer passed is too small\n",
|
|
|
|
module);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
case PNP_USE_ESCD_SUPPORT:
|
|
|
|
printk(KERN_ERR "PnPBIOS: %s: use ESCD instead\n", module);
|
|
|
|
break;
|
|
|
|
case PNP_MESSAGE_NOT_SUPPORTED:
|
2007-07-27 01:41:20 +08:00
|
|
|
printk(KERN_ERR "PnPBIOS: %s: the message is unsupported\n",
|
|
|
|
module);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
case PNP_HARDWARE_ERROR:
|
2011-03-31 09:57:33 +08:00
|
|
|
printk(KERN_ERR "PnPBIOS: %s: a hardware failure has occurred\n",
|
2007-07-27 01:41:20 +08:00
|
|
|
module);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
default:
|
2007-07-27 01:41:20 +08:00
|
|
|
printk(KERN_ERR "PnPBIOS: %s: unexpected status 0x%x\n", module,
|
|
|
|
status);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PnP BIOS Low Level Calls
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define PNP_GET_NUM_SYS_DEV_NODES 0x00
|
|
|
|
#define PNP_GET_SYS_DEV_NODE 0x01
|
|
|
|
#define PNP_SET_SYS_DEV_NODE 0x02
|
|
|
|
#define PNP_GET_EVENT 0x03
|
|
|
|
#define PNP_SEND_MESSAGE 0x04
|
|
|
|
#define PNP_GET_DOCKING_STATION_INFORMATION 0x05
|
|
|
|
#define PNP_SET_STATIC_ALLOCED_RES_INFO 0x09
|
|
|
|
#define PNP_GET_STATIC_ALLOCED_RES_INFO 0x0a
|
|
|
|
#define PNP_GET_APM_ID_TABLE 0x0b
|
|
|
|
#define PNP_GET_PNP_ISA_CONFIG_STRUC 0x40
|
|
|
|
#define PNP_GET_ESCD_INFO 0x41
|
|
|
|
#define PNP_READ_ESCD 0x42
|
|
|
|
#define PNP_WRITE_ESCD 0x43
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Call PnP BIOS with function 0x00, "get number of system device nodes"
|
|
|
|
*/
|
|
|
|
static int __pnp_bios_dev_node_info(struct pnp_dev_node_info *data)
|
|
|
|
{
|
|
|
|
u16 status;
|
2007-07-27 01:41:21 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!pnp_bios_present())
|
|
|
|
return PNP_FUNCTION_NOT_SUPPORTED;
|
2007-07-27 01:41:21 +08:00
|
|
|
status = call_pnp_bios(PNP_GET_NUM_SYS_DEV_NODES, 0, PNP_TS1, 2,
|
|
|
|
PNP_TS1, PNP_DS, 0, 0, data,
|
|
|
|
sizeof(struct pnp_dev_node_info), NULL, 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
data->no_nodes &= 0xff;
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
int pnp_bios_dev_node_info(struct pnp_dev_node_info *data)
|
|
|
|
{
|
2007-07-27 01:41:20 +08:00
|
|
|
int status = __pnp_bios_dev_node_info(data);
|
2007-07-27 01:41:21 +08:00
|
|
|
|
2007-07-27 01:41:20 +08:00
|
|
|
if (status)
|
|
|
|
pnpbios_print_status("dev_node_info", status);
|
2005-04-17 06:20:36 +08:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Note that some PnP BIOSes (e.g., on Sony Vaio laptops) die a horrible
|
|
|
|
* death if they are asked to access the "current" configuration.
|
|
|
|
* Therefore, if it's a matter of indifference, it's better to call
|
|
|
|
* get_dev_node() and set_dev_node() with boot=1 rather than with boot=0.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Call PnP BIOS with function 0x01, "get system device node"
|
|
|
|
* Input: *nodenum = desired node,
|
|
|
|
* boot = whether to get nonvolatile boot (!=0)
|
|
|
|
* or volatile current (0) config
|
|
|
|
* Output: *nodenum=next node or 0xff if no more nodes
|
|
|
|
*/
|
2007-07-27 01:41:21 +08:00
|
|
|
static int __pnp_bios_get_dev_node(u8 *nodenum, char boot,
|
2007-07-27 01:41:20 +08:00
|
|
|
struct pnp_bios_node *data)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
u16 status;
|
[PATCH] x86: Pnp byte granularity
The one remaining caller of set_limit, the PnP BIOS code, calls into the PnP
BIOS, passing kernel parameters in and out. These parameteres may be passed
from arbitrary kernel virtual memory, so they deserve strict protection to
stop a bad BIOS from smashing beyond the object size.
Unfortunately, the use of set_limit was badly botching this by setting the
limit in terms of pages, when it really should have byte granularity.
When doing this, I discovered my BIOS had the buggy code during the "get
system device node" call:
mov ax, es:[bx]
Which is harmless, but has a trivial workaround.
Signed-off-by: Zachary Amsden <zach@vmware.com>
Cc: "Seth, Rohit" <rohit.seth@intel.com>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-01-06 16:11:55 +08:00
|
|
|
u16 tmp_nodenum;
|
2007-07-27 01:41:21 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!pnp_bios_present())
|
|
|
|
return PNP_FUNCTION_NOT_SUPPORTED;
|
2007-07-27 01:41:20 +08:00
|
|
|
if (!boot && pnpbios_dont_use_current_config)
|
2005-04-17 06:20:36 +08:00
|
|
|
return PNP_FUNCTION_NOT_SUPPORTED;
|
[PATCH] x86: Pnp byte granularity
The one remaining caller of set_limit, the PnP BIOS code, calls into the PnP
BIOS, passing kernel parameters in and out. These parameteres may be passed
from arbitrary kernel virtual memory, so they deserve strict protection to
stop a bad BIOS from smashing beyond the object size.
Unfortunately, the use of set_limit was badly botching this by setting the
limit in terms of pages, when it really should have byte granularity.
When doing this, I discovered my BIOS had the buggy code during the "get
system device node" call:
mov ax, es:[bx]
Which is harmless, but has a trivial workaround.
Signed-off-by: Zachary Amsden <zach@vmware.com>
Cc: "Seth, Rohit" <rohit.seth@intel.com>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-01-06 16:11:55 +08:00
|
|
|
tmp_nodenum = *nodenum;
|
2007-07-27 01:41:21 +08:00
|
|
|
status = call_pnp_bios(PNP_GET_SYS_DEV_NODE, 0, PNP_TS1, 0, PNP_TS2,
|
|
|
|
boot ? 2 : 1, PNP_DS, 0, &tmp_nodenum,
|
|
|
|
sizeof(tmp_nodenum), data, 65536);
|
[PATCH] x86: Pnp byte granularity
The one remaining caller of set_limit, the PnP BIOS code, calls into the PnP
BIOS, passing kernel parameters in and out. These parameteres may be passed
from arbitrary kernel virtual memory, so they deserve strict protection to
stop a bad BIOS from smashing beyond the object size.
Unfortunately, the use of set_limit was badly botching this by setting the
limit in terms of pages, when it really should have byte granularity.
When doing this, I discovered my BIOS had the buggy code during the "get
system device node" call:
mov ax, es:[bx]
Which is harmless, but has a trivial workaround.
Signed-off-by: Zachary Amsden <zach@vmware.com>
Cc: "Seth, Rohit" <rohit.seth@intel.com>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-01-06 16:11:55 +08:00
|
|
|
*nodenum = tmp_nodenum;
|
2005-04-17 06:20:36 +08:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2007-07-27 01:41:21 +08:00
|
|
|
int pnp_bios_get_dev_node(u8 *nodenum, char boot, struct pnp_bios_node *data)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
int status;
|
2007-07-27 01:41:21 +08:00
|
|
|
|
2007-07-27 01:41:20 +08:00
|
|
|
status = __pnp_bios_get_dev_node(nodenum, boot, data);
|
|
|
|
if (status)
|
|
|
|
pnpbios_print_status("get_dev_node", status);
|
2005-04-17 06:20:36 +08:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Call PnP BIOS with function 0x02, "set system device node"
|
|
|
|
* Input: *nodenum = desired node,
|
|
|
|
* boot = whether to set nonvolatile boot (!=0)
|
|
|
|
* or volatile current (0) config
|
|
|
|
*/
|
2007-07-27 01:41:20 +08:00
|
|
|
static int __pnp_bios_set_dev_node(u8 nodenum, char boot,
|
|
|
|
struct pnp_bios_node *data)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
u16 status;
|
2007-07-27 01:41:21 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!pnp_bios_present())
|
|
|
|
return PNP_FUNCTION_NOT_SUPPORTED;
|
2007-07-27 01:41:20 +08:00
|
|
|
if (!boot && pnpbios_dont_use_current_config)
|
2005-04-17 06:20:36 +08:00
|
|
|
return PNP_FUNCTION_NOT_SUPPORTED;
|
2007-07-27 01:41:21 +08:00
|
|
|
status = call_pnp_bios(PNP_SET_SYS_DEV_NODE, nodenum, 0, PNP_TS1,
|
|
|
|
boot ? 2 : 1, PNP_DS, 0, 0, data, 65536, NULL,
|
|
|
|
0);
|
2005-04-17 06:20:36 +08:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
int pnp_bios_set_dev_node(u8 nodenum, char boot, struct pnp_bios_node *data)
|
|
|
|
{
|
|
|
|
int status;
|
2007-07-27 01:41:21 +08:00
|
|
|
|
2007-07-27 01:41:20 +08:00
|
|
|
status = __pnp_bios_set_dev_node(nodenum, boot, data);
|
|
|
|
if (status) {
|
|
|
|
pnpbios_print_status("set_dev_node", status);
|
2005-04-17 06:20:36 +08:00
|
|
|
return status;
|
|
|
|
}
|
2007-07-27 01:41:20 +08:00
|
|
|
if (!boot) { /* Update devlist */
|
|
|
|
status = pnp_bios_get_dev_node(&nodenum, boot, data);
|
|
|
|
if (status)
|
2005-04-17 06:20:36 +08:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Call PnP BIOS with function 0x05, "get docking station information"
|
|
|
|
*/
|
|
|
|
int pnp_bios_dock_station_info(struct pnp_docking_station_info *data)
|
|
|
|
{
|
|
|
|
u16 status;
|
|
|
|
|
|
|
|
if (!pnp_bios_present())
|
|
|
|
return PNP_FUNCTION_NOT_SUPPORTED;
|
2007-07-27 01:41:21 +08:00
|
|
|
status = call_pnp_bios(PNP_GET_DOCKING_STATION_INFORMATION, 0, PNP_TS1,
|
|
|
|
PNP_DS, 0, 0, 0, 0, data,
|
|
|
|
sizeof(struct pnp_docking_station_info), NULL,
|
|
|
|
0);
|
2005-04-17 06:20:36 +08:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Call PnP BIOS with function 0x0a, "get statically allocated resource
|
|
|
|
* information"
|
|
|
|
*/
|
|
|
|
static int __pnp_bios_get_stat_res(char *info)
|
|
|
|
{
|
|
|
|
u16 status;
|
2007-07-27 01:41:21 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!pnp_bios_present())
|
|
|
|
return PNP_FUNCTION_NOT_SUPPORTED;
|
2007-07-27 01:41:21 +08:00
|
|
|
status = call_pnp_bios(PNP_GET_STATIC_ALLOCED_RES_INFO, 0, PNP_TS1,
|
|
|
|
PNP_DS, 0, 0, 0, 0, info, 65536, NULL, 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
int pnp_bios_get_stat_res(char *info)
|
|
|
|
{
|
|
|
|
int status;
|
2007-07-27 01:41:21 +08:00
|
|
|
|
2007-07-27 01:41:20 +08:00
|
|
|
status = __pnp_bios_get_stat_res(info);
|
|
|
|
if (status)
|
|
|
|
pnpbios_print_status("get_stat_res", status);
|
2005-04-17 06:20:36 +08:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Call PnP BIOS with function 0x40, "get isa pnp configuration structure"
|
|
|
|
*/
|
|
|
|
static int __pnp_bios_isapnp_config(struct pnp_isa_config_struc *data)
|
|
|
|
{
|
|
|
|
u16 status;
|
2007-07-27 01:41:21 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!pnp_bios_present())
|
|
|
|
return PNP_FUNCTION_NOT_SUPPORTED;
|
2007-07-27 01:41:21 +08:00
|
|
|
status = call_pnp_bios(PNP_GET_PNP_ISA_CONFIG_STRUC, 0, PNP_TS1, PNP_DS,
|
|
|
|
0, 0, 0, 0, data,
|
|
|
|
sizeof(struct pnp_isa_config_struc), NULL, 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
int pnp_bios_isapnp_config(struct pnp_isa_config_struc *data)
|
|
|
|
{
|
|
|
|
int status;
|
2007-07-27 01:41:21 +08:00
|
|
|
|
2007-07-27 01:41:20 +08:00
|
|
|
status = __pnp_bios_isapnp_config(data);
|
|
|
|
if (status)
|
|
|
|
pnpbios_print_status("isapnp_config", status);
|
2005-04-17 06:20:36 +08:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Call PnP BIOS with function 0x41, "get ESCD info"
|
|
|
|
*/
|
|
|
|
static int __pnp_bios_escd_info(struct escd_info_struc *data)
|
|
|
|
{
|
|
|
|
u16 status;
|
2007-07-27 01:41:21 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!pnp_bios_present())
|
|
|
|
return ESCD_FUNCTION_NOT_SUPPORTED;
|
2007-07-27 01:41:21 +08:00
|
|
|
status = call_pnp_bios(PNP_GET_ESCD_INFO, 0, PNP_TS1, 2, PNP_TS1, 4,
|
|
|
|
PNP_TS1, PNP_DS, data,
|
|
|
|
sizeof(struct escd_info_struc), NULL, 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
int pnp_bios_escd_info(struct escd_info_struc *data)
|
|
|
|
{
|
|
|
|
int status;
|
2007-07-27 01:41:21 +08:00
|
|
|
|
2007-07-27 01:41:20 +08:00
|
|
|
status = __pnp_bios_escd_info(data);
|
|
|
|
if (status)
|
|
|
|
pnpbios_print_status("escd_info", status);
|
2005-04-17 06:20:36 +08:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Call PnP BIOS function 0x42, "read ESCD"
|
|
|
|
* nvram_base is determined by calling escd_info
|
|
|
|
*/
|
|
|
|
static int __pnp_bios_read_escd(char *data, u32 nvram_base)
|
|
|
|
{
|
|
|
|
u16 status;
|
2007-07-27 01:41:21 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!pnp_bios_present())
|
|
|
|
return ESCD_FUNCTION_NOT_SUPPORTED;
|
2007-07-27 01:41:21 +08:00
|
|
|
status = call_pnp_bios(PNP_READ_ESCD, 0, PNP_TS1, PNP_TS2, PNP_DS, 0, 0,
|
|
|
|
0, data, 65536, __va(nvram_base), 65536);
|
2005-04-17 06:20:36 +08:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
int pnp_bios_read_escd(char *data, u32 nvram_base)
|
|
|
|
{
|
|
|
|
int status;
|
2007-07-27 01:41:21 +08:00
|
|
|
|
2007-07-27 01:41:20 +08:00
|
|
|
status = __pnp_bios_read_escd(data, nvram_base);
|
|
|
|
if (status)
|
|
|
|
pnpbios_print_status("read_escd", status);
|
2005-04-17 06:20:36 +08:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
void pnpbios_calls_init(union pnp_bios_install_struct *header)
|
|
|
|
{
|
|
|
|
int i;
|
2007-07-27 01:41:21 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
spin_lock_init(&pnp_bios_lock);
|
|
|
|
pnp_bios_callpoint.offset = header->fields.pm16offset;
|
|
|
|
pnp_bios_callpoint.segment = PNP_CS16;
|
|
|
|
|
2009-01-01 07:42:14 +08:00
|
|
|
for_each_possible_cpu(i) {
|
2017-03-15 01:05:07 +08:00
|
|
|
struct desc_struct *gdt = get_cpu_gdt_rw(i);
|
2007-07-27 01:41:20 +08:00
|
|
|
if (!gdt)
|
|
|
|
continue;
|
2009-07-18 23:11:06 +08:00
|
|
|
set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_CS32],
|
|
|
|
(unsigned long)&pnp_bios_callfunc);
|
|
|
|
set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_CS16],
|
|
|
|
(unsigned long)__va(header->fields.pm16cseg));
|
|
|
|
set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
|
|
|
|
(unsigned long)__va(header->fields.pm16dseg));
|
2007-07-27 01:41:20 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|