mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lv Zheng <lv.zheng@intel.com>
To: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
	Len Brown <len.brown@intel.com>
Cc: Lv Zheng <lv.zheng@intel.com>, Lv Zheng <zetalog@gmail.com>,
	<linux-kernel@vger.kernel.org>,
	linux-acpi@vger.kernel.org, Bob Moore <robert.moore@intel.com>,
	<stable@vger.kernel.org>
Subject: [PATCH 08/31] ACPICA: Utilities: split IO address types from data type models.
Date: Mon, 13 Apr 2015 11:48:58 +0800	[thread overview]
Message-ID: <4baba17ae37fcd0831fcbe779f75bc5cee6c63fb.1428893937.git.lv.zheng@intel.com> (raw)
In-Reply-To: <cover.1428893935.git.lv.zheng@intel.com>

ACPICA commit aacf863cfffd46338e268b7415f7435cae93b451

It is reported that on a physically 64-bit addressed machine, 32-bit kernel
can trigger crashes in accessing the memory regions that are beyond the
32-bit boundary. The region field's start address should still be 32-bit
compliant, but after a calculation (adding some offsets), it may exceed the
32-bit boundary. This case is rare and buggy, but there are real BIOSes
leaked with such issues (see References below).

This patch fixes this gap by always defining IO addresses as 64-bit, and
allows OSPMs to optimize it for a real 32-bit machine to reduce the size of
the internal objects.

Internal acpi_physical_address usages in the structures that can be fixed
by this change include:
1. struct acpi_object_region:
    acpi_physical_address		address;
2. struct acpi_address_range:
    acpi_physical_address		start_address;
    acpi_physical_address		end_address;
3. struct acpi_mem_space_context;
    acpi_physical_address		address;
4. struct acpi_table_desc
    acpi_physical_address		address;
See known issues 1 for other usages.

Note that acpi_io_address which is used for ACPI_PROCESSOR may also suffer
from same problem, so this patch changes it accordingly.

For iasl, it will enforce acpi_physical_address as 32-bit to generate
32-bit OSPM compatible tables on 32-bit platforms, we need to define
ACPI_32BIT_PHYSICAL_ADDRESS for it in acenv.h.

Known issues:
1. Cleanup of mapped virtual address
   In struct acpi_mem_space_context, acpi_physical_address is used as a virtual
   address:
    acpi_physical_address                   mapped_physical_address;
   It is better to introduce acpi_virtual_address or use acpi_size instead.
   This patch doesn't make such a change. Because this should be done along
   with a change to acpi_os_map_memory()/acpi_os_unmap_memory().
   There should be no functional problem to leave this unchanged except
   that only this structure is enlarged unexpectedly.

Link: https://github.com/acpica/acpica/commit/aacf863c
Reference: https://bugzilla.kernel.org/show_bug.cgi?id=87971
Reference: https://bugzilla.kernel.org/show_bug.cgi?id=79501
Reported-and-tested-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reported-and-tested-by: Sial Nije <sialnije@gmail.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Cc: <stable@vger.kernel.org>
---
 include/acpi/actypes.h        |   20 ++++++++++++++++++++
 include/acpi/platform/acenv.h |    1 +
 2 files changed, 21 insertions(+)

diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h
index b034f10..658c42e 100644
--- a/include/acpi/actypes.h
+++ b/include/acpi/actypes.h
@@ -199,9 +199,29 @@ typedef int s32;
 typedef s32 acpi_native_int;
 
 typedef u32 acpi_size;
+
+#ifdef ACPI_32BIT_PHYSICAL_ADDRESS
+
+/*
+ * OSPMs can define this to shrink the size of the structures for 32-bit
+ * none PAE environment. ASL compiler may always define this to generate
+ * 32-bit OSPM compliant tables.
+ */
 typedef u32 acpi_io_address;
 typedef u32 acpi_physical_address;
 
+#else				/* ACPI_32BIT_PHYSICAL_ADDRESS */
+
+/*
+ * It is reported that, after some calculations, the physical addresses can
+ * wrap over the 32-bit boundary on 32-bit PAE environment.
+ * https://bugzilla.kernel.org/show_bug.cgi?id=87971
+ */
+typedef u64 acpi_io_address;
+typedef u64 acpi_physical_address;
+
+#endif				/* ACPI_32BIT_PHYSICAL_ADDRESS */
+
 #define ACPI_MAX_PTR                    ACPI_UINT32_MAX
 #define ACPI_SIZE_MAX                   ACPI_UINT32_MAX
 
diff --git a/include/acpi/platform/acenv.h b/include/acpi/platform/acenv.h
index ad74dc5..ecdf940 100644
--- a/include/acpi/platform/acenv.h
+++ b/include/acpi/platform/acenv.h
@@ -76,6 +76,7 @@
 #define ACPI_LARGE_NAMESPACE_NODE
 #define ACPI_DATA_TABLE_DISASSEMBLY
 #define ACPI_SINGLE_THREADED
+#define ACPI_32BIT_PHYSICAL_ADDRESS
 #endif
 
 /* acpi_exec configuration. Multithreaded with full AML debugger */
-- 
1.7.10


  parent reply	other threads:[~2015-04-13  3:49 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-13  3:48 [PATCH 00/31] ACPICA: 20150410 Release Lv Zheng
2015-04-13  3:48 ` [PATCH 01/31] ACPICA: Linuxize: Reduce divergences for 20150410 release Lv Zheng
2015-04-13  3:48 ` [PATCH 02/31] ACPICA: Tables: Change acpi_find_root_pointer() to use acpi_physical_address Lv Zheng
2015-04-13  3:48 ` [PATCH 03/31] ACPICA: Unix: Cleanup to use ACPI_TO_INTEGER() to calc page offset Lv Zheng
2015-04-13  3:48 ` [PATCH 04/31] ACPICA: Executer: Cleanup to remove an unnecessary conversion Lv Zheng
2015-04-13  3:48 ` [PATCH 05/31] ACPICA: Utilities: Cleanup to enforce ACPI_PHYSADDR_TO_PTR()/ACPI_PTR_TO_PHYSADDR() Lv Zheng
2015-04-13  3:48 ` [PATCH 06/31] ACPICA: Utilities: Cleanup to convert physical address printing formats Lv Zheng
2015-04-13  3:48 ` [PATCH 07/31] ACPICA: Utilities: Cleanup to remove useless ACPI_PRINTF/FORMAT_xxx helpers Lv Zheng
2015-04-13  3:48 ` Lv Zheng [this message]
2015-04-13  3:49 ` [PATCH 09/31] ACPICA: Tables: Don't release ACPI_MTX_TABLES in acpi_tb_install_standard_table() Lv Zheng
2015-04-13  3:49 ` [PATCH 10/31] ACPICA: Events: Add support to return both enable/status register values for GPE and fixed event Lv Zheng
2015-04-13  3:49 ` [PATCH 11/31] ACPICA: Applications: Remove use of __DATE__ macro Lv Zheng
2015-04-13  3:49 ` [PATCH 12/31] ACPICA: Utilities: Remove unused acpi_ut_create_pkg_state_and_push() Lv Zheng
2015-04-13  3:49 ` [PATCH 13/31] ACPICA: Tables: Move an iasl specific table function to iasl source file Lv Zheng
2015-04-13  3:49 ` [PATCH 14/31] ACPICA: Utilities: Correct conditional compilation definitions Lv Zheng
2015-04-13  3:49 ` [PATCH 15/31] ACPICA: Resources: " Lv Zheng
2015-04-13  3:49 ` [PATCH 16/31] ACPICA: Casting changes around acpi_physical_address/acpi_size Lv Zheng
2015-04-13  3:50 ` [PATCH 17/31] ACPICA: Fix a sscanf format string Lv Zheng
2015-04-13  3:50 ` [PATCH 18/31] ACPICA: Update Resource descriptor dump module Lv Zheng
2015-04-13  3:50 ` [PATCH 19/31] ACPICA: Update AML Debugger global variables Lv Zheng
2015-04-13  3:50 ` [PATCH 20/31] ACPICA: iASL/Disassembler: Add option to assume table contains valid AML Lv Zheng
2015-04-13  3:50 ` [PATCH 21/31] ACPICA: iASL: Enhancement for constant folding Lv Zheng
2015-04-13  3:50 ` [PATCH 22/31] ACPICA: Add infrastructure for External() opcode Lv Zheng
2015-04-13  3:50 ` [PATCH 23/31] ACPICA: Add "Windows 2015" string to _OSI support Lv Zheng
2015-04-13  3:50 ` [PATCH 24/31] ACPICA: Permanently set _REV to the value '2' Lv Zheng
2015-04-13  3:50 ` [PATCH 25/31] ACPICA: Remove unused internal AML opcode Lv Zheng
2015-04-13  3:50 ` [PATCH 26/31] ACPICA: Add "//" before ascii output of buffers Lv Zheng
2015-04-13  3:51 ` [PATCH 27/31] ACPICA: Update for SLIC ACPI table Lv Zheng
2015-04-13  3:51 ` [PATCH 28/31] ACPICA: iASL: Add support for MSDM " Lv Zheng
2015-04-13  3:51 ` [PATCH 29/31] ACPICA: Disassembler: Some cleanup of the table dump module Lv Zheng
2015-04-13  3:51 ` [PATCH 30/31] ACPICA: Fix a couple issues with the local printf module Lv Zheng
2015-04-13  3:51 ` [PATCH 31/31] ACPICA: Update version to 20150410 Lv Zheng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4baba17ae37fcd0831fcbe779f75bc5cee6c63fb.1428893937.git.lv.zheng@intel.com \
    --to=lv.zheng@intel.com \
    --cc=len.brown@intel.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=robert.moore@intel.com \
    --cc=stable@vger.kernel.org \
    --cc=zetalog@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®