From 484400ffbf2dd33446d71c05b9cddf91932a882e Mon Sep 17 00:00:00 2001 From: Liu Jinsong Date: Sat, 16 Feb 2013 16:59:03 +0800 Subject: xen/acpi: xen memory hotplug minor updates Dan Carpenter found current xen memory hotplug logic has potential issue: at func acpi_memory_get_device() *mem_device = acpi_driver_data(device); while the device may be NULL and then dereference. At native side, Rafael recently updated acpi_memory_get_device(), dropping acpi_bus_add, adding lock, and avoiding above issue. This patch updates xen memory hotplug logic accordingly, removing redundant logic, adding lock, and avoiding dereference. Signed-off-by: Liu Jinsong Signed-off-by: Konrad Rzeszutek Wilk --- drivers/xen/xen-acpi-memhotplug.c | 52 +++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'drivers/xen') diff --git a/drivers/xen/xen-acpi-memhotplug.c b/drivers/xen/xen-acpi-memhotplug.c index 853b12dba5b..faef5b39605 100644 --- a/drivers/xen/xen-acpi-memhotplug.c +++ b/drivers/xen/xen-acpi-memhotplug.c @@ -158,31 +158,17 @@ acpi_memory_get_device_resources(struct acpi_memory_device *mem_device) return 0; } -static int -acpi_memory_get_device(acpi_handle handle, - struct acpi_memory_device **mem_device) +static int acpi_memory_get_device(acpi_handle handle, + struct acpi_memory_device **mem_device) { - acpi_status status; - acpi_handle phandle; struct acpi_device *device = NULL; - struct acpi_device *pdevice = NULL; - int result; + int result = 0; - if (!acpi_bus_get_device(handle, &device) && device) - goto end; + acpi_scan_lock_acquire(); - status = acpi_get_parent(handle, &phandle); - if (ACPI_FAILURE(status)) { - pr_warn(PREFIX "Cannot find acpi parent\n"); - return -EINVAL; - } - - /* Get the parent device */ - result = acpi_bus_get_device(phandle, &pdevice); - if (result) { - pr_warn(PREFIX "Cannot get acpi bus device\n"); - return -EINVAL; - } + acpi_bus_get_device(handle, &device); + if (device) + goto end; /* * Now add the notified device. This creates the acpi_device @@ -190,18 +176,28 @@ acpi_memory_get_device(acpi_handle handle, */ result = acpi_bus_scan(handle); if (result) { - pr_warn(PREFIX "Cannot add acpi bus\n"); - return -EINVAL; + pr_warn(PREFIX "ACPI namespace scan failed\n"); + result = -EINVAL; + goto out; + } + result = acpi_bus_get_device(handle, &device); + if (result) { + pr_warn(PREFIX "Missing device object\n"); + result = -EINVAL; + goto out; } end: *mem_device = acpi_driver_data(device); if (!(*mem_device)) { - pr_err(PREFIX "Driver data not found\n"); - return -ENODEV; + pr_err(PREFIX "driver data not found\n"); + result = -ENODEV; + goto out; } - return 0; +out: + acpi_scan_lock_release(); + return result; } static int acpi_memory_check_device(struct acpi_memory_device *mem_device) @@ -259,12 +255,15 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data) ACPI_DEBUG_PRINT((ACPI_DB_INFO, "\nReceived EJECT REQUEST notification for device\n")); + acpi_scan_lock_acquire(); if (acpi_bus_get_device(handle, &device)) { + acpi_scan_lock_release(); pr_err(PREFIX "Device doesn't exist\n"); break; } mem_device = acpi_driver_data(device); if (!mem_device) { + acpi_scan_lock_release(); pr_err(PREFIX "Driver Data is NULL\n"); break; } @@ -274,6 +273,7 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data) * acpi_bus_remove if Xen support hotremove in the future */ acpi_memory_disable_device(mem_device); + acpi_scan_lock_release(); break; default: -- cgit v1.2.3 From 1b37d6ea2cdc61102f4643d8cd654ec15212b927 Mon Sep 17 00:00:00 2001 From: Liu Jinsong Date: Sun, 17 Feb 2013 11:47:24 +0800 Subject: xen/acpi: xen cpu hotplug minor updates Recently at native Rafael did some cleanup for acpi, say, drop acpi_bus_add, remove unnecessary argument of acpi_bus_scan, and run acpi_bus_scan under acpi_scan_lock. This patch does similar cleanup for xen cpu hotplug, removing redundant logic, and adding lock. Signed-off-by: Liu Jinsong Signed-off-by: Konrad Rzeszutek Wilk --- drivers/xen/xen-acpi-cpuhotplug.c | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) (limited to 'drivers/xen') diff --git a/drivers/xen/xen-acpi-cpuhotplug.c b/drivers/xen/xen-acpi-cpuhotplug.c index 757827966e3..18c742bec91 100644 --- a/drivers/xen/xen-acpi-cpuhotplug.c +++ b/drivers/xen/xen-acpi-cpuhotplug.c @@ -239,24 +239,6 @@ static acpi_status xen_acpi_cpu_hotadd(struct acpi_processor *pr) return AE_OK; } -static -int acpi_processor_device_add(acpi_handle handle, struct acpi_device **device) -{ - acpi_handle phandle; - struct acpi_device *pdev; - - if (acpi_get_parent(handle, &phandle)) - return -ENODEV; - - if (acpi_bus_get_device(phandle, &pdev)) - return -ENODEV; - - if (acpi_bus_scan(handle)) - return -ENODEV; - - return 0; -} - static int acpi_processor_device_remove(struct acpi_device *device) { pr_debug(PREFIX "Xen does not support CPU hotremove\n"); @@ -272,6 +254,8 @@ static void acpi_processor_hotplug_notify(acpi_handle handle, u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; /* default */ int result; + acpi_scan_lock_acquire(); + switch (event) { case ACPI_NOTIFY_BUS_CHECK: case ACPI_NOTIFY_DEVICE_CHECK: @@ -286,12 +270,16 @@ static void acpi_processor_hotplug_notify(acpi_handle handle, if (!acpi_bus_get_device(handle, &device)) break; - result = acpi_processor_device_add(handle, &device); + result = acpi_bus_scan(handle); if (result) { pr_err(PREFIX "Unable to add the device\n"); break; } - + result = acpi_bus_get_device(handle, &device); + if (result) { + pr_err(PREFIX "Missing device object\n"); + break; + } ost_code = ACPI_OST_SC_SUCCESS; break; @@ -321,11 +309,13 @@ static void acpi_processor_hotplug_notify(acpi_handle handle, "Unsupported event [0x%x]\n", event)); /* non-hotplug event; possibly handled by other handler */ - return; + goto out; } (void) acpi_evaluate_hotplug_ost(handle, event, ost_code, NULL); - return; + +out: + acpi_scan_lock_release(); } static acpi_status is_processor_device(acpi_handle handle) -- cgit v1.2.3 From 45e27161c62216c163880d7aed751cb55a65c8e9 Mon Sep 17 00:00:00 2001 From: Steven Noonan Date: Fri, 1 Mar 2013 05:14:59 -0800 Subject: xenbus: fix compile failure on ARM with Xen enabled MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adding an include of linux/mm.h resolves this: drivers/xen/xenbus/xenbus_client.c: In function ‘xenbus_map_ring_valloc_hvm’: drivers/xen/xenbus/xenbus_client.c:532:66: error: implicit declaration of function ‘page_to_section’ [-Werror=implicit-function-declaration] CC: stable@vger.kernel.org Signed-off-by: Steven Noonan Signed-off-by: Konrad Rzeszutek Wilk --- drivers/xen/xenbus/xenbus_client.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/xen') diff --git a/drivers/xen/xenbus/xenbus_client.c b/drivers/xen/xenbus/xenbus_client.c index bcf3ba4a6ec..61786be9138 100644 --- a/drivers/xen/xenbus/xenbus_client.c +++ b/drivers/xen/xenbus/xenbus_client.c @@ -30,6 +30,7 @@ * IN THE SOFTWARE. */ +#include #include #include #include -- cgit v1.2.3