Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7d97277b authored by Yinghai Lu's avatar Yinghai Lu Committed by Ingo Molnar
Browse files

acpi/x86: introduce __apci_map_table, v4



to prevent wrongly overwriting fixmap that still want to use.

ACPI used to rely on low mappings being all linearly mapped and
grew a habit: it never really unmapped certain kinds of tables
after use.

This can cause problems - for example the hypothetical case
when some spurious access still references it.

v2: remove prev_map and prev_size in __apci_map_table
v3: let acpi_os_unmap_memory() call early_iounmap too, so remove extral calling to
early_acpi_os_unmap_memory
v4: fix typo in one acpi_get_table_with_size calling

Signed-off-by: default avatarYinghai Lu <yhlu.kernel@gmail.com>
Acked-by: default avatarLen Brown <len.brown@intel.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 05876f88
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -199,6 +199,10 @@ char *__init __acpi_map_table(unsigned long phys_addr, unsigned long size)
	return __va(phys_addr);
}

char *__init __acpi_unmap_table(unsigned long virt_addr, unsigned long size)
{
}

/* --------------------------------------------------------------------------
                            Boot-time Table Parsing
   -------------------------------------------------------------------------- */
+7 −10
Original line number Diff line number Diff line
@@ -121,21 +121,18 @@ enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_PIC;
 */
char *__init __acpi_map_table(unsigned long phys, unsigned long size)
{
	static char *prev_map;
	static unsigned long prev_size;

	if (prev_map) {
		early_iounmap(prev_map, prev_size);
		prev_map = NULL;
	}

	if (!phys || !size)
		return NULL;

	prev_size = size;
	prev_map = early_ioremap(phys, size);
	return early_ioremap(phys, size);
}
void __init __acpi_unmap_table(char *map, unsigned long size)
{
	if (!map || !size)
		return;

	return prev_map;
	early_iounmap(map, size);
}

#ifdef CONFIG_PCI_MMCONFIG
+14 −3
Original line number Diff line number Diff line
@@ -365,7 +365,7 @@ ACPI_EXPORT_SYMBOL(acpi_unload_table_id)

/*******************************************************************************
 *
 * FUNCTION:    acpi_get_table
 * FUNCTION:    acpi_get_table_with_size
 *
 * PARAMETERS:  Signature           - ACPI signature of needed table
 *              Instance            - Which instance (for SSDTs)
@@ -377,8 +377,9 @@ ACPI_EXPORT_SYMBOL(acpi_unload_table_id)
 *
 *****************************************************************************/
acpi_status
acpi_get_table(char *signature,
	       u32 instance, struct acpi_table_header **out_table)
acpi_get_table_with_size(char *signature,
	       u32 instance, struct acpi_table_header **out_table,
	       acpi_size *tbl_size)
{
       u32 i;
       u32 j;
@@ -408,6 +409,7 @@ acpi_get_table(char *signature,
		    acpi_tb_verify_table(&acpi_gbl_root_table_list.tables[i]);
		if (ACPI_SUCCESS(status)) {
			*out_table = acpi_gbl_root_table_list.tables[i].pointer;
			*tbl_size = acpi_gbl_root_table_list.tables[i].length;
		}

		if (!acpi_gbl_permanent_mmap) {
@@ -420,6 +422,15 @@ acpi_get_table(char *signature,
	return (AE_NOT_FOUND);
}

acpi_status
acpi_get_table(char *signature,
	       u32 instance, struct acpi_table_header **out_table)
{
	acpi_size tbl_size;

	return acpi_get_table_with_size(signature,
		       instance, out_table, &tbl_size);
}
ACPI_EXPORT_SYMBOL(acpi_get_table)

/*******************************************************************************
+0 −6
Original line number Diff line number Diff line
@@ -694,12 +694,6 @@ void __init acpi_early_init(void)
	if (!acpi_strict)
		acpi_gbl_enable_interpreter_slack = TRUE;

	/*
	 * Doing a zero-sized mapping will clear out the previous
	 * __acpi_map_table() mapping, if any.
	 */
	__acpi_map_table(0, 0);

	acpi_gbl_permanent_mmap = 1;

	status = acpi_reallocate_root_table();
+9 −2
Original line number Diff line number Diff line
@@ -274,12 +274,19 @@ EXPORT_SYMBOL_GPL(acpi_os_map_memory);

void acpi_os_unmap_memory(void __iomem * virt, acpi_size size)
{
	if (acpi_gbl_permanent_mmap) {
	if (acpi_gbl_permanent_mmap)
		iounmap(virt);
	}
	else
		__acpi_unmap_table(virt, size);
}
EXPORT_SYMBOL_GPL(acpi_os_unmap_memory);

void early_acpi_os_unmap_memory(void __iomem * virt, acpi_size size)
{
	if (!acpi_gbl_permanent_mmap)
		__acpi_unmap_table(virt, size);
}

#ifdef ACPI_FUTURE_USAGE
acpi_status
acpi_os_get_physical_address(void *virt, acpi_physical_address * phys)
Loading