2012-05-04 14:10:25

by Konrad Rzeszutek Wilk

[permalink] [raw]
Subject: [PATCH] patches for v3.5-rc6.

Was thinking to push these patches to Linus for v3.5-rc6.

arch/x86/xen/enlighten.c | 40 ++++++++++++++++++++++++++++++++++++++--
arch/x86/xen/mmu.c | 7 ++++++-
drivers/video/xen-fbfront.c | 25 +++++++++++++++----------
3 files changed, 59 insertions(+), 13 deletions(-)

David Vrabel (1):
xen/pci: don't use PCI BIOS service for configuration space accesses

Julia Lawall (1):
drivers/video/xen-fbfront.c: add missing cleanup code

Konrad Rzeszutek Wilk (2):
xen/apic: Return the APIC ID (and version) for CPU 0.
xen/pte: Fix crashes when trying to see non-existent PGD/PMD/PUD/PTEs


2012-05-04 14:10:29

by Konrad Rzeszutek Wilk

[permalink] [raw]
Subject: [PATCH 4/4] xen/pci: don't use PCI BIOS service for configuration space accesses

From: David Vrabel <[email protected]>

The accessing PCI configuration space with the PCI BIOS32 service does
not work in PV guests.

On systems without MMCONFIG or where the BIOS hasn't marked the
MMCONFIG region as reserved in the e820 map, the BIOS service is
probed (even though direct access is preferred) and this hangs.

CC: [email protected]
Acked-by: Jan Beulich <[email protected]>
Signed-off-by: David Vrabel <[email protected]>
Signed-off-by: Konrad Rzeszutek Wilk <[email protected]>
---
arch/x86/xen/enlighten.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 4f437de..fbf9a75 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -63,6 +63,7 @@
#include <asm/stackprotector.h>
#include <asm/hypervisor.h>
#include <asm/mwait.h>
+#include <asm/pci_x86.h>

#ifdef CONFIG_ACPI
#include <linux/acpi.h>
@@ -1398,7 +1399,9 @@ asmlinkage void __init xen_start_kernel(void)
/* Make sure ACS will be enabled */
pci_request_acs();
}
-
+
+ /* PCI BIOS service won't work from a PV guest. */
+ pci_probe &= ~PCI_PROBE_BIOS;

xen_raw_console_write("about to get started...\n");

--
1.7.7.5

2012-05-04 14:10:55

by Konrad Rzeszutek Wilk

[permalink] [raw]
Subject: [PATCH 1/4] drivers/video/xen-fbfront.c: add missing cleanup code

From: Julia Lawall <[email protected]>

The operations in the subsequent error-handling code appear to be also
useful here.

Acked-by: Florian Tobias Schandinat <[email protected]>
Signed-off-by: Julia Lawall <[email protected]>
[v1: Collapse some of the error handling functions]
Signed-off-by: Konrad Rzeszutek Wilk <[email protected]>
---
drivers/video/xen-fbfront.c | 25 +++++++++++++++----------
1 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/drivers/video/xen-fbfront.c b/drivers/video/xen-fbfront.c
index cb4529c..aa42160 100644
--- a/drivers/video/xen-fbfront.c
+++ b/drivers/video/xen-fbfront.c
@@ -458,26 +458,31 @@ static int __devinit xenfb_probe(struct xenbus_device *dev,
xenfb_init_shared_page(info, fb_info);

ret = xenfb_connect_backend(dev, info);
- if (ret < 0)
- goto error;
+ if (ret < 0) {
+ xenbus_dev_fatal(dev, ret, "xenfb_connect_backend");
+ goto error_fb;
+ }

ret = register_framebuffer(fb_info);
if (ret) {
- fb_deferred_io_cleanup(fb_info);
- fb_dealloc_cmap(&fb_info->cmap);
- framebuffer_release(fb_info);
xenbus_dev_fatal(dev, ret, "register_framebuffer");
- goto error;
+ goto error_fb;
}
info->fb_info = fb_info;

xenfb_make_preferred_console();
return 0;

- error_nomem:
- ret = -ENOMEM;
- xenbus_dev_fatal(dev, ret, "allocating device memory");
- error:
+error_fb:
+ fb_deferred_io_cleanup(fb_info);
+ fb_dealloc_cmap(&fb_info->cmap);
+ framebuffer_release(fb_info);
+error_nomem:
+ if (!ret) {
+ ret = -ENOMEM;
+ xenbus_dev_fatal(dev, ret, "allocating device memory");
+ }
+error:
xenfb_remove(dev);
return ret;
}
--
1.7.7.5

2012-05-04 14:10:23

by Konrad Rzeszutek Wilk

[permalink] [raw]
Subject: [PATCH 3/4] xen/pte: Fix crashes when trying to see non-existent PGD/PMD/PUD/PTEs

If I try to do "cat /sys/kernel/debug/kernel_page_tables"
I end up with:

BUG: unable to handle kernel paging request at ffffc7fffffff000
IP: [<ffffffff8106aa51>] ptdump_show+0x221/0x480
PGD 0
Oops: 0000 [#1] SMP
CPU 0
.. snip..
RAX: 0000000000000000 RBX: ffffc00000000fff RCX: 0000000000000000
RDX: 0000800000000000 RSI: 0000000000000000 RDI: ffffc7fffffff000

which is due to the fact we are trying to access a PFN that is not
accessible to us. The reason (at least in this case) was that
PGD[256] is set to __HYPERVISOR_VIRT_START which setup (by the
hypervisor) to point to a read-only linear map of the MFN->PFN array.
During our parsing we would get the MFN (a valid one), try to look
it up in the MFN->PFN tree and find it invalid and return ~0 as PFN.
Then pte_mfn_to_pfn would happilly feed that in, attach the flags
and return it back to the caller. In this case the ptdump_show
bitshifts it and we get this invalid value.

Instead of doing all of that, we detect the ~0 case and just return
!_PAGE_PRESENT.

Signed-off-by: Konrad Rzeszutek Wilk <[email protected]>
---
arch/x86/xen/mmu.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index b8e2794..69f5857 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -353,8 +353,13 @@ static pteval_t pte_mfn_to_pfn(pteval_t val)
{
if (val & _PAGE_PRESENT) {
unsigned long mfn = (val & PTE_PFN_MASK) >> PAGE_SHIFT;
+ unsigned long pfn = mfn_to_pfn(mfn);
+
pteval_t flags = val & PTE_FLAGS_MASK;
- val = ((pteval_t)mfn_to_pfn(mfn) << PAGE_SHIFT) | flags;
+ if (unlikely(pfn == ~0))
+ val = flags & ~_PAGE_PRESENT;
+ else
+ val = ((pteval_t)pfn << PAGE_SHIFT) | flags;
}

return val;
--
1.7.7.5

2012-05-04 14:10:21

by Konrad Rzeszutek Wilk

[permalink] [raw]
Subject: [PATCH 2/4] xen/apic: Return the APIC ID (and version) for CPU 0.

On x86_64 on AMD machines where the first APIC_ID is not zero, we get:

ACPI: LAPIC (acpi_id[0x01] lapic_id[0x10] enabled)
BIOS bug: APIC version is 0 for CPU 1/0x10, fixing up to 0x10
BIOS bug: APIC version mismatch, boot CPU: 0, CPU 1: version 10

which means that when the ACPI processor driver loads and
tries to parse the _Pxx states it fails to do as, as it
ends up calling acpi_get_cpuid which does this:

for_each_possible_cpu(i) {
if (cpu_physical_id(i) == apic_id)
return i;
}

And the bootup CPU, has not been found so it fails and returns -1
for the first CPU - which then subsequently in the loop that
"acpi_processor_get_info" does results in returning an error, which
means that "acpi_processor_add" failing and per_cpu(processor)
is never set (and is NULL).

That means that when xen-acpi-processor tries to load (much much
later on) and parse the P-states it gets -ENODEV from
acpi_processor_register_performance() (which tries to read
the per_cpu(processor)) and fails to parse the data.

Reported-by-and-Tested-by: Stefan Bader <[email protected]>
Suggested-by: Boris Ostrovsky <[email protected]>
[v2: Bit-shift APIC ID by 24 bits]
Signed-off-by: Konrad Rzeszutek Wilk <[email protected]>
---
arch/x86/xen/enlighten.c | 35 ++++++++++++++++++++++++++++++++++-
1 files changed, 34 insertions(+), 1 deletions(-)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index a8f8844..4f437de 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -809,9 +809,40 @@ static void xen_io_delay(void)
}

#ifdef CONFIG_X86_LOCAL_APIC
+static unsigned long xen_set_apic_id(unsigned int x)
+{
+ WARN_ON(1);
+ return x;
+}
+static unsigned int xen_get_apic_id(unsigned long x)
+{
+ return ((x)>>24) & 0xFFu;
+}
static u32 xen_apic_read(u32 reg)
{
- return 0;
+ struct xen_platform_op op = {
+ .cmd = XENPF_get_cpuinfo,
+ .interface_version = XENPF_INTERFACE_VERSION,
+ .u.pcpu_info.xen_cpuid = 0,
+ };
+ int ret = 0;
+
+ /* Shouldn't need this as APIC is turned off for PV, and we only
+ * get called on the bootup processor. But just in case. */
+ if (!xen_initial_domain() || smp_processor_id())
+ return 0;
+
+ if (reg == APIC_LVR)
+ return 0x10;
+
+ if (reg != APIC_ID)
+ return 0;
+
+ ret = HYPERVISOR_dom0_op(&op);
+ if (ret)
+ return 0;
+
+ return op.u.pcpu_info.apic_id << 24;
}

static void xen_apic_write(u32 reg, u32 val)
@@ -849,6 +880,8 @@ static void set_xen_basic_apic_ops(void)
apic->icr_write = xen_apic_icr_write;
apic->wait_icr_idle = xen_apic_wait_icr_idle;
apic->safe_wait_icr_idle = xen_safe_apic_wait_icr_idle;
+ apic->set_apic_id = xen_set_apic_id;
+ apic->get_apic_id = xen_get_apic_id;
}

#endif
--
1.7.7.5

2012-05-06 09:04:51

by Pasi Kärkkäinen

[permalink] [raw]
Subject: Re: [Xen-devel] [PATCH] patches for v3.5-rc6.

On Fri, May 04, 2012 at 10:04:23AM -0400, Konrad Rzeszutek Wilk wrote:
> Was thinking to push these patches to Linus for v3.5-rc6.
>

Hmm.. that probably should say for v3.4-rc6 ? :)

-- Pasi

> arch/x86/xen/enlighten.c | 40 ++++++++++++++++++++++++++++++++++++++--
> arch/x86/xen/mmu.c | 7 ++++++-
> drivers/video/xen-fbfront.c | 25 +++++++++++++++----------
> 3 files changed, 59 insertions(+), 13 deletions(-)
>
> David Vrabel (1):
> xen/pci: don't use PCI BIOS service for configuration space accesses
>
> Julia Lawall (1):
> drivers/video/xen-fbfront.c: add missing cleanup code
>
> Konrad Rzeszutek Wilk (2):
> xen/apic: Return the APIC ID (and version) for CPU 0.
> xen/pte: Fix crashes when trying to see non-existent PGD/PMD/PUD/PTEs
>

2012-05-07 13:49:25

by Konrad Rzeszutek Wilk

[permalink] [raw]
Subject: Re: [Xen-devel] [PATCH] patches for v3.5-rc6.

On Sun, May 06, 2012 at 12:04:46PM +0300, Pasi K?rkk?inen wrote:
> On Fri, May 04, 2012 at 10:04:23AM -0400, Konrad Rzeszutek Wilk wrote:
> > Was thinking to push these patches to Linus for v3.5-rc6.
> >
>
> Hmm.. that probably should say for v3.4-rc6 ? :)

Yeah :-)
>
> -- Pasi
>
> > arch/x86/xen/enlighten.c | 40 ++++++++++++++++++++++++++++++++++++++--
> > arch/x86/xen/mmu.c | 7 ++++++-
> > drivers/video/xen-fbfront.c | 25 +++++++++++++++----------
> > 3 files changed, 59 insertions(+), 13 deletions(-)
> >
> > David Vrabel (1):
> > xen/pci: don't use PCI BIOS service for configuration space accesses
> >
> > Julia Lawall (1):
> > drivers/video/xen-fbfront.c: add missing cleanup code
> >
> > Konrad Rzeszutek Wilk (2):
> > xen/apic: Return the APIC ID (and version) for CPU 0.
> > xen/pte: Fix crashes when trying to see non-existent PGD/PMD/PUD/PTEs
> >
>
>
> _______________________________________________
> Xen-devel mailing list
> [email protected]
> http://lists.xen.org/xen-devel