Skip to contentSkip to conversation

Patches for Xen 4.2 (v2).

PATCH New Konrad Rzeszutek Wilk 3 participants 7 messages Apr 2, 2012 – Apr 3, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Patches for Xen 4.2 (v2).

Patches that were posted last week - with review comments addressed.

#1 lore raw

PATCH 1/1 xen/vga: Add 'vga_delay' parameter to delay screen output by X miliseconds per line

# HG changeset patch
# User Konrad Rzeszutek Wilk <[email protected]>
# Date 1333398408 14400
# Node ID f1da2ce71ed41d1b74ebe6916ff7710d6579438e
# Parent 1088c8557a46ab28e509bb9482e2a73a21590df8
xen/vga: Add 'vga_delay' parameter to delay screen output by X miliseconds per line.

This is useful if you find yourself on machine that has no serial console, nor any PCI, PCIe to put in a serial card. Nothing really fancy except it allows to capture the screenshot of the screen using a camera.

xen/drivers/video/vga.c +10 -1
diff -r 1088c8557a46 -r f1da2ce71ed4 xen/drivers/video/vga.c
@@ -10,7 +10,7 @@
 #include <xen/mm.h>
 #include <xen/vga.h>
 #include <asm/io.h>
-
+#include <xen/delay.h>
 /* Filled in by arch boot code. */
 struct xen_vga_console_info vga_console_info;
 
@@ -49,6 +49,12 @@ void (*vga_puts)(const char *) = vga_noo
 static char __initdata opt_vga[30] = "";
 string_param("vga", opt_vga);
 
+/*
+ * 'vga_delay=miliseconds' which defines to delay to print a line
+ * to the screen. 2 is a a good value to get a good screen output.
+ */
+unsigned int __read_mostly vga_delay;
+integer_param("vga_delay", vga_delay);
 /* VGA text-mode definitions. */
 static unsigned int columns, lines;
 #define ATTRIBUTE   7
@@ -135,6 +141,9 @@ static void vga_text_puts(const char *s)
                 ypos = lines - 1;
                 memmove(video, video + 2 * columns, ypos * 2 * columns);
                 memset(video + ypos * 2 * columns, 0, 2 * xpos);
+                if (vga_delay)
+                    mdelay(vga_delay);
+
             }
             xpos = 0;
         }
#4 lore raw

PATCH 1/1 xen/pat: After suspend re-write PAT if BIOS changed it

In reply to Konrad Rzeszutek Wilk

# HG changeset patch
# User Simon Graham <[email protected]> # Date 1333398413 14400
# Node ID caefa03c38366c3e70d937bc95740c5d33c0892a # Parent f1da2ce71ed41d1b74ebe6916ff7710d6579438e xen/pat: After suspend re-write PAT if BIOS changed it.

Certain AMD machines (this was a MSI or GigaBYTE BIOS) after resume would reset the PAT MSR causing rather weird issues - where the pages would (say they would be set to WC) would end up with the wrong type (as they would use the BIOS PAT instead of the one set by the hypervisor). And in some cases the PAT was stuck and needed a couple of WRMSRL to actually take.

xen/arch/x86/acpi/power.c +20 -0
diff -r f1da2ce71ed4 -r caefa03c3836 xen/arch/x86/acpi/power.c
@@ -41,8 +41,27 @@ static DEFINE_SPINLOCK(pm_lock);
 
 struct acpi_sleep_info acpi_sinfo;
 
+static void pat_resume(void);
 void do_suspend_lowlevel(void);
 
+static void
+pat_resume()
+{
+    u64 pat;
+    if (!cpu_has_pat)
+        return;
+
+    rdmsrl(MSR_IA32_CR_PAT, pat);
+    if (pat != host_pat) {
+	printk(KERN_INFO PREFIX "Found PAT MSR: 0x%"PRIx64"\n", pat);
+	printk(KERN_INFO PREFIX "reseting to 0x%"PRIx64"\n", host_pat);
+	wrmsrl(MSR_IA32_CR_PAT, host_pat);
+	rdmsrl(MSR_IA32_CR_PAT, pat);
+	if (pat != host_pat)
+	    printk(KERN_WARNING PREFIX "PAT MSR stuck on: 0x%"PRIx64"\n", pat);
+    }
+}
+
 static int device_power_down(void)
 {
     console_suspend();
@@ -194,6 +213,7 @@ static int enter_state(u32 state)
     if ( cpu_has_efer )
         write_efer(read_efer());
 
+    pat_resume();
     device_power_up();
 
     mcheck_init(&boot_cpu_data, 0);
#6 lore raw

PATCH 1/1 xend: Don't crash due to weird PCI devices

In reply to Konrad Rzeszutek Wilk

# HG changeset patch
# User Konrad Rzeszutek Wilk <[email protected]> # Date 1333398413 14400
# Node ID f789a3effeb6f876b9672e6e64bbd98857f59b61 # Parent caefa03c38366c3e70d937bc95740c5d33c0892a
xend: Don't crash due to weird PCI devices

This fixes Red Hat BZ 767742 where a user had some truly weird PCI devices:

$ lspci -vvv -xxx -s 0000:01:00.0
01:00.0 VGA compatible controller: nVidia Corporation GT218 [NVS 3100M] (rev
ff) (prog-if ff)
 !!! Unknown header type 7f
00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
10: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
20: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
30: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff

And xend would report:

ERROR (pci:1272) Caught 'Looped capability chain: 0000:01:00.0'

This fixes it.

tools/python/xen/util/pci.py +6 -1
diff -r caefa03c3836 -r f789a3effeb6 tools/python/xen/util/pci.py
@@ -1268,7 +1268,12 @@ class PciDevice:
             pass
 
     def get_info_from_sysfs(self):
-        self.find_capability(0x11)
+        try:
+            self.find_capability(0x11)
+        except PciDeviceParseError, err:
+            log.error("Caught '%s'" % err)
+            return False
+
         sysfs_mnt = find_sysfs_mnt()
         if sysfs_mnt == None:
             return False
#2 lore raw

Re: [PATCH 1 of 3] xen/vga: Add 'vga_delay' parameter to delay screen output by X miliseconds per line

In reply to Konrad Rzeszutek Wilk
Quoted 29 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk

# HG changeset patch
# User Konrad Rzeszutek Wilk <[email protected]>
# Date 1333398408 14400
# Node ID f1da2ce71ed41d1b74ebe6916ff7710d6579438e
# Parent 1088c8557a46ab28e509bb9482e2a73a21590df8
xen/vga: Add 'vga_delay' parameter to delay screen output by X miliseconds per line.

This is useful if you find yourself on machine that has no serial console, nor any PCI, PCIe to put in a serial card. Nothing really fancy except it allows
to capture the screenshot of the screen using a camera.

diff -r 1088c8557a46 -r f1da2ce71ed4 xen/drivers/video/vga.c

xen/drivers/video/vga.c +1 -1
@@ -10,7 +10,7 @@
 #include <xen/mm.h>
 #include <xen/vga.h>
 #include <asm/io.h>
-
+#include <xen/delay.h>
 /* Filled in by arch boot code. */
 struct xen_vga_console_info vga_console_info;
 

xen/drivers/video/vga.c void (*vga_puts)(const char *) = vga_noo · line 54

Quoted 6 lines
xen/drivers/video/vga.c +3 -0
@@ -49,6 +49,12 @@ void (*vga_puts)(const char *) = vga_noo
 static char __initdata opt_vga[30] = "";
 string_param("vga", opt_vga);
 
+/*
+ * 'vga_delay=miliseconds' which defines to delay to print a line
+ * to the screen. 2 is a a good value to get a good screen output.

Maybe add something like "If you need to use this, do so with care as it might screw up time handling", since this will suppress the timer softirq for arbitrary periods of time.

xen/drivers/video/vga.c void (*vga_puts)(const char *) = vga_noo · line 56

Quoted 2 lines
xen/drivers/video/vga.c +2 -0
+ */
+unsigned int __read_mostly vga_delay;

static.

xen/drivers/video/vga.c void (*vga_puts)(const char *) = vga_noo · line 57

Quoted 1 line
xen/drivers/video/vga.c +1 -0
+integer_param("vga_delay", vga_delay);

Missing blank line.

xen/drivers/video/vga.c static void vga_text_puts(const char *s) · line 144

Quoted 8 lines
xen/drivers/video/vga.c +1 -0
 /* VGA text-mode definitions. */
 static unsigned int columns, lines;
 #define ATTRIBUTE   7
@@ -135,6 +141,9 @@ static void vga_text_puts(const char *s)
                 ypos = lines - 1;
                 memmove(video, video + 2 * columns, ypos * 2 * columns);
                 memset(video + ypos * 2 * columns, 0, 2 * xpos);
+                if (vga_delay)

I don't think a conditional is needed here.

Jan

Quoted 5 lines
xen/drivers/video/vga.c +2 -0
+                    mdelay(vga_delay);
+
             }
             xpos = 0;
         }
#5 lore raw

Re: [PATCH 2 of 3] xen/pat: After suspend re-write PAT if BIOS changed it

In reply to Konrad Rzeszutek Wilk
Quoted 8 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk

# HG changeset patch
# User Simon Graham <[email protected]> # Date 1333398413 14400
# Node ID caefa03c38366c3e70d937bc95740c5d33c0892a # Parent f1da2ce71ed41d1b74ebe6916ff7710d6579438e xen/pat: After suspend re-write PAT if BIOS changed it.

Quoted 6 lines

Certain AMD machines (this was a MSI or GigaBYTE BIOS) after resume would reset the PAT MSR causing rather weird issues - where the pages would (say they would be set to WC) would end up with the wrong type (as they would use the BIOS PAT instead of the one set by the hypervisor). And in some cases the PAT was stuck and needed a couple of WRMSRL to actually take.

But you still fail to explain why the existing PAT resume handling is insufficient, and without understanding that we shouldn't be applying a patch like this.

Jan

Quoted 42 lines

diff -r f1da2ce71ed4 -r caefa03c3836 xen/arch/x86/acpi/power.c

xen/arch/x86/acpi/power.c +20 -0
@@ -41,8 +41,27 @@ static DEFINE_SPINLOCK(pm_lock);
 
 struct acpi_sleep_info acpi_sinfo;
 
+static void pat_resume(void);
 void do_suspend_lowlevel(void);
 
+static void
+pat_resume()
+{
+    u64 pat;
+    if (!cpu_has_pat)
+        return;
+
+    rdmsrl(MSR_IA32_CR_PAT, pat);
+    if (pat != host_pat) {
+	printk(KERN_INFO PREFIX "Found PAT MSR: 0x%"PRIx64"\n", pat);
+	printk(KERN_INFO PREFIX "reseting to 0x%"PRIx64"\n", host_pat);
+	wrmsrl(MSR_IA32_CR_PAT, host_pat);
+	rdmsrl(MSR_IA32_CR_PAT, pat);
+	if (pat != host_pat)
+	    printk(KERN_WARNING PREFIX "PAT MSR stuck on: 0x%"PRIx64"\n", pat);
+    }
+}
+
 static int device_power_down(void)
 {
     console_suspend();
@@ -194,6 +213,7 @@ static int enter_state(u32 state)
     if ( cpu_has_efer )
         write_efer(read_efer());
 
+    pat_resume();
     device_power_up();
 
     mcheck_init(&boot_cpu_data, 0);
#3 lore raw

Re: [PATCH 1 of 3] xen/vga: Add 'vga_delay' parameter to delay screen output by X miliseconds per line

In reply to Konrad Rzeszutek Wilk

xen/drivers/video/vga.c void (*vga_puts)(const char *) = vga_noo · line 57

Quoted 10 lines · Konrad Rzeszutek Wilk
xen/drivers/video/vga.c +6 -0
@@ -49,6 +49,12 @@ void (*vga_puts)(const char *) = vga_noo
 static char __initdata opt_vga[30] = "";
 string_param("vga", opt_vga);
 
+/*
+ * 'vga_delay=miliseconds' which defines to delay to print a line
+ * to the screen. 2 is a a good value to get a good screen output.
+ */
+unsigned int __read_mostly vga_delay;
+integer_param("vga_delay", vga_delay);

Please patch docs/misc/xen-command-line.markdown too.

Ian.