Skip to contentSkip to conversation

i386 linux: eliminate hard coded items from __xen_guest section

PATCH New Jan Beulich 3 participants 5 messages Feb 15, 2006 – Feb 20, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i386 linux: eliminate hard coded items from __xen_guest section

To allow the new VMSPLIT_* Kconfig options to work, and to avoid problems when the position of the hypercall page changes, this patch eliminates the hard-coded entries in the __xen_guest section in head.S.

Jan

arch/i386/kernel/head-xen.S +22 -4
Index: head-2006-02-14/arch/i386/kernel/head-xen.S
===================================================================
@@ -1,11 +1,29 @@
 
 #include <linux/config.h>
+#include <asm/page.h>
+
+.macro utoa value, radix=16, upper=1
+ .if (\radix) < 2 || (\radix) > 36
+  .err
+ .elseif (\value) >= (\radix)
+	utoa (\value) / (\radix), (\radix), (\upper)
+ .endif
+ .if (\value) % (\radix) < 10
+  .byte '0' + (\value) % (\radix)
+ .elseif (\upper)
+  .byte 'A' + (\value) % (\radix) - 10
+ .else
+  .byte 'a' + (\value) % (\radix) - 10
+ .endif
+.endm
+
+#define HYPERCALL_PAGE_OFFSET 0x4000
 
 .section __xen_guest
 	.ascii	"GUEST_OS=linux,GUEST_VER=2.6"
 	.ascii	",XEN_VER=xen-3.0"
-	.ascii	",VIRT_BASE=0xC0000000"
-	.ascii	",HYPERCALL_PAGE=0x104" /* __pa(hypercall_page) >> 12 */
+	.ascii	",VIRT_BASE=0x"; utoa __PAGE_OFFSET
+	.ascii	",HYPERCALL_PAGE=0x"; utoa (__PHYSICAL_START+HYPERCALL_PAGE_OFFSET)>>PAGE_SHIFT
 #ifdef CONFIG_X86_PAE
 	.ascii	",PAE=yes"
 #else
@@ -190,10 +212,10 @@ ENTRY(cpu_gdt_table)
 .org 0x3000
 ENTRY(default_ldt)
 
-.org 0x4000
+.org HYPERCALL_PAGE_OFFSET
 ENTRY(hypercall_page)
+.skip 0x1000
 
-.org 0x5000
 /*
  * Real beginning of normal "text" segment
  */

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw

PATCH 1/1 i386 linux: eliminate hard coded items from __xen_guest section

To allow the new VMSPLIT_* Kconfig options to work, and to avoid problems when the position of the hypercall page changes, this patch eliminates the hard-coded entries in the __xen_guest section in head.S. Unfortunately the original version didn't work with gas newer than beginning of August 2005, where in an attempt to fix another problem a regression was introduced.

Jan

arch/i386/kernel/head-xen.S +22 -4
Index: head-2006-02-16/arch/i386/kernel/head-xen.S
===================================================================
@@ -1,11 +1,29 @@
 
 #include <linux/config.h>
+#include <asm/page.h>
+
+.macro utoa value, radix=16, upper=1
+ .if (\radix) < 2 || (\radix) > 36
+  .err
+ .elseif (\value) >= (\radix)
+	utoa ((\value)/(\radix)), (\radix), (\upper)
+ .endif
+ .if (\value) % (\radix) < 10
+  .byte '0' + (\value) % (\radix)
+ .elseif (\upper)
+  .byte 'A' + (\value) % (\radix) - 10
+ .else
+  .byte 'a' + (\value) % (\radix) - 10
+ .endif
+.endm
+
+#define HYPERCALL_PAGE_OFFSET 0x4000
 
 .section __xen_guest
 	.ascii	"GUEST_OS=linux,GUEST_VER=2.6"
 	.ascii	",XEN_VER=xen-3.0"
-	.ascii	",VIRT_BASE=0xC0000000"
-	.ascii	",HYPERCALL_PAGE=0x104" /* __pa(hypercall_page) >> 12 */
+	.ascii	",VIRT_BASE=0x"; utoa __PAGE_OFFSET
+	.ascii	",HYPERCALL_PAGE=0x"; utoa ((__PHYSICAL_START+HYPERCALL_PAGE_OFFSET)>>PAGE_SHIFT)
 #ifdef CONFIG_X86_PAE
 	.ascii	",PAE=yes"
 #else
@@ -190,10 +208,10 @@ ENTRY(cpu_gdt_table)
 .org 0x3000
 ENTRY(default_ldt)
 
-.org 0x4000
+.org HYPERCALL_PAGE_OFFSET
 ENTRY(hypercall_page)
+.skip 0x1000
 
-.org 0x5000
 /*
  * Real beginning of normal "text" segment
  */

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#2 lore raw
Quoted 4 lines · Jan Beulich

To allow the new VMSPLIT_* Kconfig options to work, and to avoid problems when the position of the hypercall page changes, this patch eliminates the hard-coded entries in the __xen_guest section in head.S. Unfortunately the original version didn't work with gas newer than beginning of August 2005, where in an attempt to fix another problem a regression was introduced.

The calculation doesn't seem to work on 32-bit for PAGE_OFFSET >= 2^31, at least not with:

cl349@firebug:~/ls/xen-unstable-clean.hg$ as --version
GNU assembler 2.15.92.0.2 20040927

I'll checkin the following:
.macro bigutoa value

    utoa (\value) >> 12
    .ascii "000"
.endm
.macro utoa value
 .if (\value) >= 16
	utoa (\value) >> 4

.endif
.if (\value) % 16 < 10
.byte '0' + (\value) % 16
.else
.byte 'A' + (\value) % 16 - 10
.endif
.endm

.section __xen_guest

	.ascii	"GUEST_OS=linux,GUEST_VER=2.6"
	.ascii	",XEN_VER=xen-3.0"
	.ascii	",VIRT_BASE=0x"; bigutoa __PAGE_OFFSET
	.ascii	",HYPERCALL_PAGE=0x"; utoa

((__PHYSICAL_START+HYPERCALL_PAGE_OFFSET)>>PAGE_SHIFT)

It's a bit gross, maybe there's a neater solution.

christian

#3 lore raw

Hmm, I would assume your assembler then only does 32-bit calculations. In that case (if such assemblers still exist), I'd rather want to use the same macro as on 64-bits, where a similar problem needed to be worked around. Jan

Quoted 1 line
Quoted 1 line
Quoted 1 line

[email protected] 20.02.06 17:04:35 >>>

Quoted 3 lines · Jan Beulich

To allow the new VMSPLIT_* Kconfig options to work, and to avoid problems when the position of the hypercall page changes, this patch eliminates the hard-coded entries in the __xen_guest section in head.S. Unfortunately the original version didn't work with gas newer than beginning of August 2005, where in an attempt to

fix

Quoted 1 line

another problem a regression was introduced.

The calculation doesn't seem to work on 32-bit for PAGE_OFFSET >= 2^31, at least not with:

cl349@firebug:~/ls/xen-unstable-clean.hg$ as --version
GNU assembler 2.15.92.0.2 20040927

I'll checkin the following:
.macro bigutoa value

    utoa (\value) >> 12
    .ascii "000"
.endm
.macro utoa value
 .if (\value) >= 16
	utoa (\value) >> 4

.endif
.if (\value) % 16 < 10
.byte '0' + (\value) % 16
.else
.byte 'A' + (\value) % 16 - 10
.endif
.endm

.section __xen_guest

	.ascii	"GUEST_OS=linux,GUEST_VER=2.6"
	.ascii	",XEN_VER=xen-3.0"
	.ascii	",VIRT_BASE=0x"; bigutoa __PAGE_OFFSET
	.ascii	",HYPERCALL_PAGE=0x"; utoa

((__PHYSICAL_START+HYPERCALL_PAGE_OFFSET)>>PAGE_SHIFT)

It's a bit gross, maybe there's a neater solution.

christian

#4 lore raw
Quoted 1 line · Jan Beulich

Hmm, I would assume your assembler then only does 32-bit calculations. In that case (if such assemblers still exist),

It's the one from Fedora Core 3, running in a 32bit chroot on a 64bit machine (also FC3).

Quoted 1 line

I'd rather want to use the same macro as on 64-bits, where a similar problem needed to be worked around. Jan

Indeed, I've changed it accordingly.

christian