diff mbox

[Quantal,SRU] xen: enable platform-pci only in a Xen guest

Message ID 1354100657-13063-1-git-send-email-stefan.bader@canonical.com
State New
Headers show

Commit Message

Stefan Bader Nov. 28, 2012, 11:04 a.m. UTC
This is a change asked to be included by Citrix. There is a crash
if the cpuid bits of a guest are masked in a way that it would not
detect the hypervisor being present (so the guest thinks it run on
bare-metal). The exact masking is unknown, though.

The patch, however, looks like a straight forward change and is
upstream as well.

-Stefan

From 38ad4f4b6cc713b3c42cb4252688ef5c296d7455 Mon Sep 17 00:00:00 2001
From: Olaf Hering <olaf@aepfle.de>
Date: Tue, 10 Jul 2012 15:31:39 +0200
Subject: [PATCH] xen: enable platform-pci only in a Xen guest

While debugging kexec issues in a PVonHVM guest I modified
xen_hvm_platform() to return false to disable all PV drivers. This
caused a crash in platform_pci_init() because it expects certain data
structures to be initialized properly.

To avoid such a crash make sure the driver is initialized only if
running in a Xen guest.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>

BugLink: http://bugs.launchpad.net/bugs/1081054

(cherry-picked from commit 38ad4f4b6cc713b3c42cb4252688ef5c296d7455 upstream)
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
---
 drivers/xen/platform-pci.c |    3 +++
 1 file changed, 3 insertions(+)

Comments

Colin Ian King Nov. 28, 2012, 11:08 a.m. UTC | #1
On 28/11/12 11:04, Stefan Bader wrote:
> This is a change asked to be included by Citrix. There is a crash
> if the cpuid bits of a guest are masked in a way that it would not
> detect the hypervisor being present (so the guest thinks it run on
> bare-metal). The exact masking is unknown, though.
>
> The patch, however, looks like a straight forward change and is
> upstream as well.
>
> -Stefan
>
>  From 38ad4f4b6cc713b3c42cb4252688ef5c296d7455 Mon Sep 17 00:00:00 2001
> From: Olaf Hering <olaf@aepfle.de>
> Date: Tue, 10 Jul 2012 15:31:39 +0200
> Subject: [PATCH] xen: enable platform-pci only in a Xen guest
>
> While debugging kexec issues in a PVonHVM guest I modified
> xen_hvm_platform() to return false to disable all PV drivers. This
> caused a crash in platform_pci_init() because it expects certain data
> structures to be initialized properly.
>
> To avoid such a crash make sure the driver is initialized only if
> running in a Xen guest.
>
> Signed-off-by: Olaf Hering <olaf@aepfle.de>
> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
>
> BugLink: http://bugs.launchpad.net/bugs/1081054
>
> (cherry-picked from commit 38ad4f4b6cc713b3c42cb4252688ef5c296d7455 upstream)
> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
> ---
>   drivers/xen/platform-pci.c |    3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/drivers/xen/platform-pci.c b/drivers/xen/platform-pci.c
> index 2389e58..97ca359 100644
> --- a/drivers/xen/platform-pci.c
> +++ b/drivers/xen/platform-pci.c
> @@ -109,6 +109,9 @@ static int __devinit platform_pci_init(struct pci_dev *pdev,
>   	long mmio_addr, mmio_len;
>   	unsigned int max_nr_gframes;
>
> +	if (!xen_domain())
> +		return -ENODEV;
> +
>   	i = pci_enable_device(pdev);
>   	if (i)
>   		return i;
>

Upstream and looks sane.

Acked-by: Colin Ian King <colin.king@canonical.com>
Tim Gardner Nov. 28, 2012, 12:37 p.m. UTC | #2

diff mbox

Patch

diff --git a/drivers/xen/platform-pci.c b/drivers/xen/platform-pci.c
index 2389e58..97ca359 100644
--- a/drivers/xen/platform-pci.c
+++ b/drivers/xen/platform-pci.c
@@ -109,6 +109,9 @@  static int __devinit platform_pci_init(struct pci_dev *pdev,
 	long mmio_addr, mmio_len;
 	unsigned int max_nr_gframes;
 
+	if (!xen_domain())
+		return -ENODEV;
+
 	i = pci_enable_device(pdev);
 	if (i)
 		return i;