Skip to contentSkip to conversation

: PVH: specify xen features strings cleany for PVH

PATCH In review Mukesh Rathor 5 participants 22 messages Jan 19, 2013 – Feb 5, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : PVH: specify xen features strings cleany for PVH

Quoted 5 lines · On Thu, 17 Jan 2013 22:22:47 -0500 Konrad Rzeszutek Wilk…

Jan had some comments about that patch:

https://patchwork.kernel.org/patch/1745041/

Please fix it up so I can put it in the Linux tree.

Please see below.

Thanks,
Mukesh

arch/x86/xen/xen-head.S +11 -6
index 1a6bca1..543877d 100644
@@ -14,12 +14,17 @@
 #include <asm/xen/interface.h>
 
 #ifdef CONFIG_XEN_X86_PVH
-#define FEATURES_PVH "|writable_descriptor_tables" \
-		     "|auto_translated_physmap" \
-		     "|supervisor_mode_kernel" \
-		     "|hvm_callback_vector"
+#define XEN_FEATURES_STR .ascii  "!writable_page_tables"       \
+                                 "|pae_pgdir_above_4gb"        \
+                                 "|writable_descriptor_tables" \
+                                 "|auto_translated_physmap"    \
+                                 "|supervisor_mode_kernel"     \
+                                 "|hvm_callback_vector"        \
+                                 "\0"
 #else
-#define FEATURES_PVH /* Not supported */
+#define XEN_FEATURES_STR .ascii "!writable_page_tables"        \
+                                "|pae_pgdir_above_4gb"         \
+                                 "\0"
 #endif
 
 	__INIT
@@ -104,7 +109,7 @@ NEXT_HYPERCALL(arch_6)
 #endif
 	ELFNOTE(Xen, XEN_ELFNOTE_ENTRY,          _ASM_PTR startup_xen)
 	ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, _ASM_PTR hypercall_page)
-	ELFNOTE(Xen, XEN_ELFNOTE_FEATURES,       .asciz "!writable_page_tables|pae_pgdir_above_4gb"FEATURES_PVH)
+        ELFNOTE(Xen, XEN_ELFNOTE_FEATURES,       XEN_FEATURES_STR)
 	ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE,       .asciz "yes")
 	ELFNOTE(Xen, XEN_ELFNOTE_LOADER,         .asciz "generic")
 	ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID,
#1 lore raw
Quoted 54 lines
Quoted 1 line
Quoted 1 line · Mukesh Rathor
Quoted 5 lines · On Thu, 17 Jan 2013 22:22:47 -0500 Konrad Rzeszutek Wilk…

Jan had some comments about that patch:

https://patchwork.kernel.org/patch/1745041/

Please fix it up so I can put it in the Linux tree.

Please see below.

Thanks,
Mukesh

arch/x86/xen/xen-head.S +11 -6
index 1a6bca1..543877d 100644
@@ -14,12 +14,17 @@
 #include <asm/xen/interface.h>
 
 #ifdef CONFIG_XEN_X86_PVH
-#define FEATURES_PVH "|writable_descriptor_tables" \
-		     "|auto_translated_physmap" \
-		     "|supervisor_mode_kernel" \
-		     "|hvm_callback_vector"
+#define XEN_FEATURES_STR .ascii  "!writable_page_tables"       \
+                                 "|pae_pgdir_above_4gb"        \
+                                 "|writable_descriptor_tables" \
+                                 "|auto_translated_physmap"    \
+                                 "|supervisor_mode_kernel"     \
+                                 "|hvm_callback_vector"        \
+                                 "\0"
 #else
-#define FEATURES_PVH /* Not supported */
+#define XEN_FEATURES_STR .ascii "!writable_page_tables"        \
+                                "|pae_pgdir_above_4gb"         \
+                                 "\0"
 #endif
 
 	__INIT
@@ -104,7 +109,7 @@ NEXT_HYPERCALL(arch_6)
 #endif
 	ELFNOTE(Xen, XEN_ELFNOTE_ENTRY,          _ASM_PTR startup_xen)
 	ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, _ASM_PTR hypercall_page)
-	ELFNOTE(Xen, XEN_ELFNOTE_FEATURES,       .asciz 
 "!writable_page_tables|pae_pgdir_above_4gb"FEATURES_PVH)
+        ELFNOTE(Xen, XEN_ELFNOTE_FEATURES,       XEN_FEATURES_STR)
 	ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE,       .asciz "yes")
 	ELFNOTE(Xen, XEN_ELFNOTE_LOADER,         .asciz "generic")
Quoted 1 line

ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID,

That's not really better. What I'd like you to do is keep the common part common (i.e. not redundantly defined) and add the PVH-specific bits (with what amounts to an empty string as the non-PVH replacement) on top. Meaning you will likely want a mixture of .ascii and .asciz.

Jan

#2 lore raw
Quoted 8 lines · On Mon, 21 Jan 2013 12:06:42 +0000 "Jan Beulich" <[email protected]> wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

On 19.01.13 at 02:35, Mukesh Rathor <[email protected]> wrote:

That's not really better. What I'd like you to do is keep the common part common (i.e. not redundantly defined) and add the PVH-specific bits (with what amounts to an empty string as the non-PVH replacement) on top. Meaning you will likely want a mixture of .ascii and .asciz.

         ELFNOTE(Xen, XEN_ELFNOTE_FEATURES,       .asciz "!writable_page_tables|pae_pgdir_above_4gb"PVH_FEATURES_STR);

Will put NULL char before PVH_FEATURES_STR, so we need:

         ELFNOTE(Xen, XEN_ELFNOTE_FEATURES,       .ascii "!writable_page_tables|pae_pgdir_above_4gb"PVH_FEATURES_STR);

This means PVH_FEATURES_STR has to be defined as:

#define PVH_FEATURES_STR "|writable_descriptor_tables|auto_translated_physmap|supervisor_mode_kernel|hvm_callback_vector\0"

because

#define PVH_FEATURES_STR "|writable_descriptor_tables" \
                         "|auto_translated_physmap"       
                         .....

will put null char after writable_descriptor_tables. Putting .ascii above will not work either with concatenation later.

So, I think what I proposed earlier is the cleanest. Alternately:

#ifdef CONFIG_XEN_X86_PVH

#define PVH_FEATURES_STR "|writable_descriptor_tables|auto_translated_physmap|supervisor_mode_kernel|hvm_callback_vector\0"

#else
#define PVH_FEATURES_STR "\0"
#endif

Then:

        ELFNOTE(Xen, XEN_ELFNOTE_FEATURES,       .ascii "!writable_page_tables|pae_pgdir_above_4gb"PVH_FEATURES_STR);

Let me know what you prefer, whats right above, or what I had originally last week. I can't figure any other way.

Thanks,
Mukesh

#3 lore raw
Quoted 47 lines
Quoted 1 line
Quoted 1 line · Mukesh Rathor
Quoted 8 lines · On Mon, 21 Jan 2013 12:06:42 +0000 "Jan Beulich" <[email protected]> wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

On 19.01.13 at 02:35, Mukesh Rathor <[email protected]> wrote:

That's not really better. What I'd like you to do is keep the common part common (i.e. not redundantly defined) and add the PVH-specific bits (with what amounts to an empty string as the non-PVH replacement) on top. Meaning you will likely want a mixture of .ascii and .asciz.

ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .asciz
"!writable_page_tables|pae_pgdir_above_4gb"PVH_FEATURES_STR);

Will put NULL char before PVH_FEATURES_STR, so we need:

ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .ascii
"!writable_page_tables|pae_pgdir_above_4gb"PVH_FEATURES_STR);

This means PVH_FEATURES_STR has to be defined as:

#define PVH_FEATURES_STR "|writable_descriptor_tables|auto_translated_physmap|supervisor_mode_kernel|h vm_callback_vector\0"

because

#define PVH_FEATURES_STR "|writable_descriptor_tables" \
                         "|auto_translated_physmap"       
                         .....

will put null char after writable_descriptor_tables. Putting .ascii above will not work either with concatenation later.

So, I think what I proposed earlier is the cleanest. Alternately:

#ifdef CONFIG_XEN_X86_PVH

#define PVH_FEATURES_STR "|writable_descriptor_tables|auto_translated_physmap|supervisor_mode_kernel|h vm_callback_vector\0"

#else
#define PVH_FEATURES_STR "\0"
#endif

Quoted 7 lines

Then:
ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .ascii
"!writable_page_tables|pae_pgdir_above_4gb"PVH_FEATURES_STR);

Let me know what you prefer, whats right above, or what I had originally last week. I can't figure any other way.

I continue to think that the cleanest is to use something like

ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .ascii "!writable_page_tables|pae_pgdir_above_4gb"; .asciz PVH_FEATURES_STR);

Jan

#4 lore raw
Quoted 17 lines · On Wed, 23 Jan 2013 08:22:47 +0000 "Jan Beulich" <[email protected]> wrote:
Quoted 17 lines
Quoted 2 lines
Quoted 2 lines

On 23.01.13 at 00:12, Mukesh Rathor <[email protected]> wrote:

On Mon, 21 Jan 2013 12:06:42 +0000
"Jan Beulich" <[email protected]> wrote:

So, I think what I proposed earlier is the cleanest. Alternately:

#ifdef CONFIG_XEN_X86_PVH

#define PVH_FEATURES_STR "|writable_descriptor_tables|auto_translated_physmap|supervisor_mode_kernel|h vm_callback_vector\0"

#else
#define PVH_FEATURES_STR "\0"
#endif

Quoted 7 lines
Quoted 4 lines

Then:
ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .ascii
"!writable_page_tables|pae_pgdir_above_4gb"PVH_FEATURES_STR);

ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .ascii "!writable_page_tables|pae_pgdir_above_4gb"; .asciz PVH_FEATURES_STR);

Not that different from what I have above since PVH_FEATURES_STR still has to be defined as null string for non PVH case. Anyways, below is the latest patch. Konard, kindly apply if Jan is OK.

Thanks,
Mukesh

PVH: Use .ascii and .asciz to define xen feature string. Note, the PVH string must be in a single line (not multiple lines with \) to keep the assembler from putting null char after each string before \.

arch/x86/xen/xen-head.S +5 -6
index 1a6bca1..45226cb 100644
@@ -14,12 +14,11 @@
 #include <asm/xen/interface.h>
 
 #ifdef CONFIG_XEN_X86_PVH
-#define FEATURES_PVH "|writable_descriptor_tables" \
-		     "|auto_translated_physmap" \
-		     "|supervisor_mode_kernel" \
-		     "|hvm_callback_vector"
+
+#define PVH_FEATURES_STR  "|writable_descriptor_tables|auto_translated_physmap|supervisor_mode_kernel|hvm_callback_vector"
+
 #else
-#define FEATURES_PVH /* Not supported */
+#define PVH_FEATURES_STR  ""
 #endif
 
 	__INIT
@@ -104,7 +103,7 @@ NEXT_HYPERCALL(arch_6)
 #endif
 	ELFNOTE(Xen, XEN_ELFNOTE_ENTRY,          _ASM_PTR startup_xen)
 	ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, _ASM_PTR hypercall_page)
-	ELFNOTE(Xen, XEN_ELFNOTE_FEATURES,       .asciz "!writable_page_tables|pae_pgdir_above_4gb"FEATURES_PVH)
+        ELFNOTE(Xen, XEN_ELFNOTE_FEATURES,       .ascii "!writable_page_tables|pae_pgdir_above_4gb"; .asciz PVH_FEATURES_STR);
 	ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE,       .asciz "yes")
 	ELFNOTE(Xen, XEN_ELFNOTE_LOADER,         .asciz "generic")
 	ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID,
#5 lore raw
Quoted 34 lines
Quoted 1 line
Quoted 1 line · Mukesh Rathor
Quoted 11 lines · On Wed, 23 Jan 2013 08:22:47 +0000 "Jan Beulich" <[email protected]> wrote:
Quoted 11 lines
Quoted 2 lines
Quoted 2 lines

On 23.01.13 at 00:12, Mukesh Rathor <[email protected]> wrote:

On Mon, 21 Jan 2013 12:06:42 +0000
"Jan Beulich" <[email protected]> wrote:

So, I think what I proposed earlier is the cleanest. Alternately:

#ifdef CONFIG_XEN_X86_PVH

#define PVH_FEATURES_STR

"|writable_descriptor_tables|auto_translated_physmap|supervisor_mode_kernel|h

Quoted 6 lines
Quoted 6 lines

vm_callback_vector\0"

#else
#define PVH_FEATURES_STR "\0"
#endif

Quoted 7 lines
Quoted 4 lines

Then:
ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .ascii
"!writable_page_tables|pae_pgdir_above_4gb"PVH_FEATURES_STR);

ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .ascii "!writable_page_tables|pae_pgdir_above_4gb"; .asciz PVH_FEATURES_STR);

Not that different from what I have above since PVH_FEATURES_STR still has to be defined as null string for non PVH case. Anyways, below is the latest patch. Konard, kindly apply if Jan is OK.

Quoted 7 lines

Thanks,
Mukesh

PVH: Use .ascii and .asciz to define xen feature string. Note, the PVH string must be in a single line (not multiple lines with \) to keep the assembler from putting null char after each string before \.

This looks to be an incremental patch on top of something I don't think I've seen - there's neither an embedded \0 nor any redundancy being removed here, yet I'm sure that was so in the prior patch, and these two were what I disliked most. So perhaps sending out the original patch this one goes on top of was simply never done?

Jan

Quoted 36 lines
arch/x86/xen/xen-head.S +2 -4
index 1a6bca1..45226cb 100644
@@ -14,12 +14,11 @@
 #include <asm/xen/interface.h>
 
 #ifdef CONFIG_XEN_X86_PVH
-#define FEATURES_PVH "|writable_descriptor_tables" \
-		     "|auto_translated_physmap" \
-		     "|supervisor_mode_kernel" \
-		     "|hvm_callback_vector"
+
+#define PVH_FEATURES_STR  

"|writable_descriptor_tables|auto_translated_physmap|supervisor_mode_kernel|h vm_callback_vector"

arch/x86/xen/xen-head.S +3 -2
+
 #else
-#define FEATURES_PVH /* Not supported */
+#define PVH_FEATURES_STR  ""
 #endif
 
 	__INIT
@@ -104,7 +103,7 @@ NEXT_HYPERCALL(arch_6)
 #endif
 	ELFNOTE(Xen, XEN_ELFNOTE_ENTRY,          _ASM_PTR startup_xen)
 	ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, _ASM_PTR hypercall_page)
-	ELFNOTE(Xen, XEN_ELFNOTE_FEATURES,       .asciz 
 "!writable_page_tables|pae_pgdir_above_4gb"FEATURES_PVH)
+        ELFNOTE(Xen, XEN_ELFNOTE_FEATURES,       .ascii 
 "!writable_page_tables|pae_pgdir_above_4gb"; .asciz PVH_FEATURES_STR);
 	ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE,       .asciz "yes")
arch/x86/xen/xen-head.S +0 -0
 	ELFNOTE(Xen, XEN_ELFNOTE_LOADER,         .asciz "generic")
 	ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID,
#6 lore raw
Quoted 6 lines · Jan Beulich

This looks to be an incremental patch on top of something I don't think I've seen - there's neither an embedded \0 nor any redundancy being removed here, yet I'm sure that was so in the prior patch, and these two were what I disliked most. So perhaps sending out the original patch this one goes on top of was simply never done?

The baseline of this patch wouldn't have worked because it has .asciz as the first (global) features, so that would be NULL terminated and the PVH features wouldn't appear.

This one one of the first revisions I think it's probably what is current in Konrad's tree.

Ian.

#7 lore raw
Quoted 8 lines · Ian Campbell
Quoted 6 lines · Jan Beulich

This looks to be an incremental patch on top of something I don't think I've seen - there's neither an embedded \0 nor any redundancy being removed here, yet I'm sure that was so in the prior patch, and these two were what I disliked most. So perhaps sending out the original patch this one goes on top of was simply never done?

Quoted 6 lines

The baseline of this patch wouldn't have worked because it has .asciz as the first (global) features, so that would be NULL terminated and the PVH features wouldn't appear.

This one one of the first revisions I think it's probably what is current in Konrad's tree.

Yup.

Quoted 3 lines

Ian.

#8 lore raw
In reply to Jan Beulich
Quoted 6 lines · On Thu, 24 Jan 2013 09:16:56 +0000 "Jan Beulich" <[email protected]> wrote:

This looks to be an incremental patch on top of something I don't think I've seen - there's neither an embedded \0 nor any redundancy being removed here, yet I'm sure that was so in the prior patch, and these two were what I disliked most. So perhaps sending out the original patch this one goes on top of was simply never done?

This is on top of what konrad already has in his linux tree so he can just apply it. Here's the final version of the file, just in case:

/* Xen-specific pieces of head.S, intended to be included in the right
place in head.S */

#ifdef CONFIG_XEN

#include <linux/elfnote.h>
#include <linux/init.h>

#include <asm/boot.h>
#include <asm/asm.h>
#include <asm/page_types.h>

#include <xen/interface/elfnote.h>
#include <asm/xen/interface.h>

#ifdef CONFIG_XEN_X86_PVH

#define PVH_FEATURES_STR "|writable_descriptor_tables|auto_translated_physmap|supervisor_mode_kernel|hvm_callback_vector"

#else
#define PVH_FEATURES_STR ""
#endif

	__INIT

ENTRY(startup_xen)
cld
#ifdef CONFIG_X86_32
mov %esi,xen_start_info
mov $init_thread_union+THREAD_SIZE,%esp
#else
mov %rsi,xen_start_info
mov $init_thread_union+THREAD_SIZE,%rsp

#endif
	jmp xen_start_kernel

	__FINIT

.pushsection .text
.balign PAGE_SIZE
ENTRY(hypercall_page)

#define NEXT_HYPERCALL(x) \
	ENTRY(xen_hypercall_##x) \
	.skip 32

NEXT_HYPERCALL(set_trap_table)
NEXT_HYPERCALL(mmu_update)
NEXT_HYPERCALL(set_gdt)
NEXT_HYPERCALL(stack_switch)
NEXT_HYPERCALL(set_callbacks)
NEXT_HYPERCALL(fpu_taskswitch)
NEXT_HYPERCALL(sched_op_compat)
NEXT_HYPERCALL(platform_op)
NEXT_HYPERCALL(set_debugreg)
NEXT_HYPERCALL(get_debugreg)
NEXT_HYPERCALL(update_descriptor)
NEXT_HYPERCALL(ni)
NEXT_HYPERCALL(memory_op)
NEXT_HYPERCALL(multicall)
NEXT_HYPERCALL(update_va_mapping)
NEXT_HYPERCALL(set_timer_op)
NEXT_HYPERCALL(event_channel_op_compat)
NEXT_HYPERCALL(xen_version)
NEXT_HYPERCALL(console_io)
NEXT_HYPERCALL(physdev_op_compat)
NEXT_HYPERCALL(grant_table_op)
NEXT_HYPERCALL(vm_assist)
NEXT_HYPERCALL(update_va_mapping_otherdomain)
NEXT_HYPERCALL(iret)
NEXT_HYPERCALL(vcpu_op)
NEXT_HYPERCALL(set_segment_base)
NEXT_HYPERCALL(mmuext_op)
NEXT_HYPERCALL(xsm_op)
NEXT_HYPERCALL(nmi_op)
NEXT_HYPERCALL(sched_op)
NEXT_HYPERCALL(callback_op)
NEXT_HYPERCALL(xenoprof_op)
NEXT_HYPERCALL(event_channel_op)
NEXT_HYPERCALL(physdev_op)
NEXT_HYPERCALL(hvm_op)
NEXT_HYPERCALL(sysctl)
NEXT_HYPERCALL(domctl)
NEXT_HYPERCALL(kexec_op)
NEXT_HYPERCALL(tmem_op) /* 38 */
ENTRY(xen_hypercall_rsvr)

	.skip 320

NEXT_HYPERCALL(mca) /* 48 */
NEXT_HYPERCALL(arch_1)
NEXT_HYPERCALL(arch_2)
NEXT_HYPERCALL(arch_3)
NEXT_HYPERCALL(arch_4)
NEXT_HYPERCALL(arch_5)
NEXT_HYPERCALL(arch_6)
.balign PAGE_SIZE
.popsection

	ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS,       .asciz "linux")
	ELFNOTE(Xen, XEN_ELFNOTE_GUEST_VERSION,  .asciz "2.6")
	ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION,    .asciz "xen-3.0")

#ifdef CONFIG_X86_32
ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE, _ASM_PTR __PAGE_OFFSET)
#else
ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE, _ASM_PTR __START_KERNEL_map)
#endif
ELFNOTE(Xen, XEN_ELFNOTE_ENTRY, _ASM_PTR startup_xen)
ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, _ASM_PTR hypercall_page)
ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .ascii "!writable_page_tables|pae_pgdir_above_4gb"; .asciz PVH_FEATURES_STR);
ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE, .asciz "yes")
ELFNOTE(Xen, XEN_ELFNOTE_LOADER, .asciz "generic")
ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID,
.quad _PAGE_PRESENT; .quad _PAGE_PRESENT)
ELFNOTE(Xen, XEN_ELFNOTE_SUSPEND_CANCEL, .long 1)
ELFNOTE(Xen, XEN_ELFNOTE_HV_START_LOW, _ASM_PTR __HYPERVISOR_VIRT_START)
ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET, _ASM_PTR 0)

#endif /*CONFIG_XEN */

#9 lore raw
Quoted 3 lines
Quoted 1 line
Quoted 1 line · Mukesh Rathor

This is on top of what konrad already has in his linux tree so he can just apply it. Here's the final version of the file, just in case:

Looks okay to me, and I don't mind whether this

Quoted 2 lines

ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .ascii
"!writable_page_tables|pae_pgdir_above_4gb"; .asciz PVH_FEATURES_STR);

is done using the .ascii/.asciz or the simpler string concatenation way, as long as the latter works. All I do mind are redundancy and embedded \0 characters.

Jan

#10 lore raw
Quoted 11 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · Mukesh Rathor

This is on top of what konrad already has in his linux tree so he can just apply it. Here's the final version of the file, just in case:

Looks okay to me, and I don't mind whether this

Quoted 2 lines

ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .ascii
"!writable_page_tables|pae_pgdir_above_4gb"; .asciz PVH_FEATURES_STR);

is done using the .ascii/.asciz or the simpler string concatenation way, as long as the latter works.

String concat in gas doesn't work like in C, you get a \0 at the join...

Quoted 10 lines

All I do mind are redundancy
and embedded \0 characters.

Jan

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

#11 lore raw
Quoted 8 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 6 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · Mukesh Rathor

This is on top of what konrad already has in his linux tree so he can just apply it. Here's the final version of the file, just in case:

Looks okay to me, and I don't mind whether this

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .ascii
"!writable_page_tables|pae_pgdir_above_4gb"; .asciz PVH_FEATURES_STR);

is done using the .ascii/.asciz or the simpler string concatenation way, as long as the latter works.

String concat in gas doesn't work like in C, you get a \0 at the join...

But this is going through the C preprocessor, and that one, according to all I know, ought to concatenate adjacent strings. But of course it depends between which translation phases the preprocessor/compiler boundary is being set, so perhaps doing it the .ascii/.asciz way is indeed the only universal one.

Jan

#12 lore raw
Quoted 11 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 9 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · Mukesh Rathor

This is on top of what konrad already has in his linux tree so he can just apply it. Here's the final version of the file, just in case:

Looks okay to me, and I don't mind whether this

Quoted 2 lines

ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .ascii
"!writable_page_tables|pae_pgdir_above_4gb"; .asciz PVH_FEATURES_STR);

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

is done using the .ascii/.asciz or the simpler string concatenation way, as long as the latter works.

String concat in gas doesn't work like in C, you get a \0 at the join...

But this is going through the C preprocessor, and that one, according to all I know, ought to concatenate adjacent strings.

I don't think so, turning

        "Foo" "Bar"

into
"FooBar"
happens at the C level not the CPP level.

        #define FOO(x) x
        FOO(.asciz "Foo" "Bar")
        
        #define CAT(x,y) x y
        FOO(.asciz CAT("Foo","Bar"))
        
        #define CAT2(x,y) x #y
        FOO(CAT2(.asciz, Foo Bar))
will produce
        .asciz "Foo" "Bar"
        .asciz "Foo" "Bar"
        .asciz "Foo Bar"

(where FOO(x) ~= ELFNOTE(..., x))

The third form might be an alternative fix to this issue but I don't think it is any better than the .ascii/.asciz solution.

Ian.

#13 lore raw

Is: PVH + ARM new hypercalls. Was: Re: [PATCH]: PVH: specify xen features strings cleany for PVH

Quoted 39 lines · Ian Campbell
Quoted 11 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 9 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · Mukesh Rathor

This is on top of what konrad already has in his linux tree so he can just apply it. Here's the final version of the file, just in case:

Looks okay to me, and I don't mind whether this

Quoted 2 lines

ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .ascii
"!writable_page_tables|pae_pgdir_above_4gb"; .asciz PVH_FEATURES_STR);

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

is done using the .ascii/.asciz or the simpler string concatenation way, as long as the latter works.

String concat in gas doesn't work like in C, you get a \0 at the join...

But this is going through the C preprocessor, and that one, according to all I know, ought to concatenate adjacent strings.

I don't think so, turning

        "Foo" "Bar"

into
"FooBar"
happens at the C level not the CPP level.

        #define FOO(x) x
        FOO(.asciz "Foo" "Bar")
        
        #define CAT(x,y) x y
        FOO(.asciz CAT("Foo","Bar"))
        
        #define CAT2(x,y) x #y
        FOO(CAT2(.asciz, Foo Bar))
will produce
        .asciz "Foo" "Bar"
        .asciz "Foo" "Bar"
        .asciz "Foo Bar"
Quoted 4 lines

(where FOO(x) ~= ELFNOTE(..., x))

The third form might be an alternative fix to this issue but I don't think it is any better than the .ascii/.asciz solution.

OK. So I stuck Mukesh's patch in the tree along with yours:

http://git.kernel.org/?p=linux/kernel/git/konrad/xen.git;a=shortlog;h=refs/heads/stable/pvh.v7

and all of that on top of v3.8-rc5:

http://git.kernel.org/?p=linux/kernel/git/konrad/xen.git;a=shortlog;h=refs/heads/linux-next

We still have a couple of weeks before we have to make the go/no-go decision on the the new hypercalls:

#define XENMEM_add_to_physmap_range 23

struct xen_add_to_physmap_range {
    /* IN */
    /* Which domain to change the mapping for. */
    domid_t domid;
    uint16_t space; /* => enum phys_map_space */

    /* Number of pages to go through */
    uint16_t size;
    domid_t foreign_domid; /* IFF gmfn_foreign */

    /* Indexes into space being mapped. */
    GUEST_HANDLE(xen_ulong_t) idxs;

    /* GPFN in domid where the source mapping page should appear. */
    GUEST_HANDLE(xen_pfn_t) gpfns;

    /* OUT */

    /* Per index error code. */
    GUEST_HANDLE(int) errs;
};

/*
* Unmaps the page appearing at a particular GPFN from the specified guest's
* pseudophysical address space.
* arg == addr of xen_remove_from_physmap_t.
*/
#define XENMEM_remove_from_physmap 15

struct xen_remove_from_physmap {
    /* Which domain to change the mapping for. */
    domid_t domid;

    /* GPFN of the current mapping of the page. */
    xen_pfn_t gpfn;
};

DEFINE_GUEST_HANDLE_STRUCT(xen_remove_from_physmap);

/*
* Returns the location in virtual address space of the machine_to_phys
* mapping table. Architectures which do not have a m2p table, or which do not
* map it by default into guest address space, do not implement this command.
* arg == addr of xen_machphys_mapping_t.
*/
#define XENMEM_machphys_mapping 12
struct xen_machphys_mapping {
xen_ulong_t v_start, v_end; /* Start and end virtual addresses. */
xen_ulong_t max_mfn; /* Maximum MFN that can be looked up. */
};

#define PHYSDEVOP_map_iomem 30

struct physdev_map_iomem {
    /* IN */
    uint64_t first_gfn;
    uint64_t first_mfn;
    uint32_t nr_mfns;
    uint32_t add_mapping; /* 1 == add mapping;  0 == unmap */

};

and the modification to one:

commit 50c0b3df91be7a440b50ee7d74fd2042bca173fd

Author: Mukesh Rathor <[email protected]>
Date:   Mon Oct 22 11:37:57 2012 -0400

xen/pvh: Extend vcpu_guest_context, p2m, event, and XenBus.

Make gdt_frames[]/gdt_ents into a union with {gdtaddr, gdtsz}, as PVH only needs to send down gdtaddr and gdtsz in the vcpu_guest_context structure..

For interrupts, PVH uses native_irq_ops so we can skip most of the PV ones. In the future we can support the pirq_eoi_map.. Also VCPU hotplug is currently not available for PVH.

For events (and IRQs) we follow what PVHVM does - so use callback vector. Lastly, for XenBus we use the same logic that is used in the PVHVM case.

[v2: Rebased it]
[v3: Move 64-bit ifdef and based on Stefan add extra comments.]
[v4: Rebased it once more]
arch/x86/include/asm/xen/interface.h +10 -1
index fd9cb76..20e738a 100644
@@ -145,7 +145,16 @@ struct vcpu_guest_context {
     struct cpu_user_regs user_regs;         /* User-level CPU registers     */
     struct trap_info trap_ctxt[256];        /* Virtual IDT                  */
     unsigned long ldt_base, ldt_ents;       /* LDT (linear address, # ents) */
-    unsigned long gdt_frames[16], gdt_ents; /* GDT (machine frames, # ents) */
+    union {
+	struct {
+		/* PV: GDT (machine frames, # ents).*/
+		unsigned long gdt_frames[16], gdt_ents;
+	} pv;
+	struct {
+		/* PVH: GDTR addr and size */
+		unsigned long gdtaddr, gdtsz;
+	} pvh;
+    } u;
     unsigned long kernel_ss, kernel_sp;     /* Virtual TSS (only SS1/SP1)   */
     /* NB. User pagetable on x86/64 is placed in ctrlreg[1]. */
     unsigned long ctrlreg[8];               /* CR0-CR7 (control registers)  */
Quoted 9 lines

Ian.

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

#14 lore raw

Re: Is: PVH + ARM new hypercalls. Was: Re: [PATCH]: PVH: specify xen features strings cleany for PVH

Quoted 4 lines · On Mon, 28 Jan 2013 11:26:08 -0500 Konrad Rzeszutek Wilk <[email protected]>…
Quoted 1 line · Ian Campbell

On Fri, 2013-01-25 at 10:27 +0000, Jan Beulich wrote:

#define PHYSDEVOP_map_iomem 30

Quoted 8 lines
struct physdev_map_iomem {
    /* IN */
    uint64_t first_gfn;
    uint64_t first_mfn;
    uint32_t nr_mfns;
    uint32_t add_mapping; /* 1 == add mapping;  0 == unmap */

};

Since the new recommendation is to map transparently, we don't need this anymore. I'll submit an incremental patch to you Konrad.

Quoted 39 lines

and the modification to one:

commit 50c0b3df91be7a440b50ee7d74fd2042bca173fd

Author: Mukesh Rathor <[email protected]>
Date:   Mon Oct 22 11:37:57 2012 -0400

xen/pvh: Extend vcpu_guest_context, p2m, event, and XenBus.

Make gdt_frames[]/gdt_ents into a union with {gdtaddr, gdtsz}, as PVH only needs to send down gdtaddr and gdtsz in the vcpu_guest_context structure..

For interrupts, PVH uses native_irq_ops so we can skip most of the PV ones. In the future we can support the pirq_eoi_map.. Also VCPU hotplug is currently not available for PVH.

For events (and IRQs) we follow what PVHVM does - so use callback vector. Lastly, for XenBus we use the same logic that is used in the PVHVM case.

[v2: Rebased it]
[v3: Move 64-bit ifdef and based on Stefan add extra comments.]
[v4: Rebased it once more]
(quoted diff) +0 -0

b/arch/x86/include/asm/xen/interface.h index fd9cb76..20e738a 100644

arch/x86/include/asm/xen/interface.h +0 -0
@@ -145,7 +145,16 @@ struct vcpu_guest_context {
     struct cpu_user_regs user_regs;         /* User-level CPU

registers */ struct trap_info trap_ctxt[256]; /* Virtual
IDT */ unsigned long ldt_base, ldt_ents; /*
LDT (linear address, # ents) */
- unsigned long gdt_frames[16], gdt_ents; /* GDT (machine frames,
# ents) */

arch/x86/include/asm/xen/interface.h +1 -0
+    union {

arch/x86/include/asm/xen/interface.h struct vcpu_guest_context {

Quoted 10 lines
arch/x86/include/asm/xen/interface.h +9 -0
+	struct {
+		/* PV: GDT (machine frames, # ents).*/
+		unsigned long gdt_frames[16], gdt_ents;
+	} pv;
+	struct {
+		/* PVH: GDTR addr and size */
+		unsigned long gdtaddr, gdtsz;
+	} pvh;
+    } u;
     unsigned long kernel_ss, kernel_sp;     /* Virtual TSS (only

On xen side I added the ifdef:

#if __XEN_INTERFACE_VERSION__ < 0x00040300
unsigned long gdt_frames[16], gdt_ents; /* GDT (machine frames, # ents) */

#else
    union {
        struct {
            /* GDT (machine frames, # ents) */
            unsigned long gdt_frames[16], gdt_ents;
        } pv;
        struct {
            /* PVH: GDTR addr and size */
            unsigned long gdtaddr, gdtsz;
        } pvh;
    } u;

#endif

but it doesn't matter on linux side, so up to you.

#15 lore raw

Re: Is: PVH + ARM new hypercalls. Was: Re: [PATCH]: PVH: specify xen features strings cleany for PVH

Quoted 17 lines
Quoted 1 line
Quoted 1 line · Mukesh Rathor

On xen side I added the ifdef:

#if __XEN_INTERFACE_VERSION__ < 0x00040300
unsigned long gdt_frames[16], gdt_ents; /* GDT (machine frames, # ents)
*/

#else
    union {
        struct {
            /* GDT (machine frames, # ents) */
            unsigned long gdt_frames[16], gdt_ents;
        } pv;
        struct {
            /* PVH: GDTR addr and size */
            unsigned long gdtaddr, gdtsz;
        } pvh;
    } u;
Quoted 3 lines

#endif

but it doesn't matter on linux side, so up to you.

But I'd still prefer for this to go away again - you could simply use gdt_frames[0] for gdtaddr and gdt_ents for the (normalized) gdtsz.

And if you nevertheless go the union route, call it "gdt" instead of "u" and drop the gdt/gdt_ prefixes from the member names (yes, I know, grepping and cscoping for such member is more difficult, but I continue to see more advantage in avoiding the redundancy).

Jan

#16 lore raw

Re: Is: PVH + ARM new hypercalls. Was: Re: [PATCH]: PVH: specify xen features strings cleany for PVH

Quoted 20 lines · On Tue, 29 Jan 2013 10:48:12 +0000 "Jan Beulich" <[email protected]> wrote:
Quoted 20 lines
Quoted 2 lines
Quoted 2 lines

On 29.01.13 at 03:57, Mukesh Rathor <[email protected]> wrote:

On xen side I added the ifdef:

#if __XEN_INTERFACE_VERSION__ < 0x00040300
unsigned long gdt_frames[16], gdt_ents; /* GDT (machine frames,
# ents) */

#else
    union {
        struct {
            /* GDT (machine frames, # ents) */
            unsigned long gdt_frames[16], gdt_ents;
        } pv;
        struct {
            /* PVH: GDTR addr and size */
            unsigned long gdtaddr, gdtsz;
        } pvh;
    } u;

#endif

Quoted 5 lines
Quoted 1 line

but it doesn't matter on linux side, so up to you.

But I'd still prefer for this to go away again - you could simply use gdt_frames[0] for gdtaddr and gdt_ents for the (normalized) gdtsz.

That was my patch version 1 during linux patch review. Then the reviewer suggested to make it a union.

Quoted 5 lines

And if you nevertheless go the union route, call it "gdt" instead of "u" and drop the gdt/gdt_ prefixes from the member names (yes, I know, grepping and cscoping for such member is more difficult, but I continue to see more advantage in avoiding the redundancy).

That was my patch version 2, where I called it gdt and another reviewer suggested to change to u. So I changed it to u.

It's gone thru enough iterations that I'd like to leave as is. Thank you in advance for your compromise in helping us mortals grep/cscope to learn code.

Thanks,
Mukesh

#17 lore raw

Re: Is: PVH + ARM new hypercalls. Was: Re: [PATCH]: PVH: specify xen features strings cleany for PVH

Quoted 37 lines
Quoted 1 line
Quoted 1 line

Mukesh Rathor <[email protected]> 02/01/13 3:23 AM >>>

Quoted 20 lines · On Tue, 29 Jan 2013 10:48:12 +0000 "Jan Beulich" <[email protected]> wrote:
Quoted 20 lines
Quoted 2 lines
Quoted 2 lines

On 29.01.13 at 03:57, Mukesh Rathor <[email protected]> wrote:

On xen side I added the ifdef:

#if __XEN_INTERFACE_VERSION__ < 0x00040300
unsigned long gdt_frames[16], gdt_ents; /* GDT (machine frames,
# ents) */

#else
    union {
        struct {
            /* GDT (machine frames, # ents) */
            unsigned long gdt_frames[16], gdt_ents;
        } pv;
        struct {
            /* PVH: GDTR addr and size */
            unsigned long gdtaddr, gdtsz;
        } pvh;
    } u;

#endif

Quoted 5 lines
Quoted 1 line

but it doesn't matter on linux side, so up to you.

But I'd still prefer for this to go away again - you could simply use gdt_frames[0] for gdtaddr and gdt_ents for the (normalized) gdtsz.

That was my patch version 1 during linux patch review. Then the reviewer suggested to make it a union.

Quoted 5 lines

And if you nevertheless go the union route, call it "gdt" instead of "u" and drop the gdt/gdt_ prefixes from the member names (yes, I know, grepping and cscoping for such member is more difficult, but I continue to see more advantage in avoiding the redundancy).

Quoted 6 lines

That was my patch version 2, where I called it gdt and another reviewer suggested to change to u. So I changed it to u.

It's gone thru enough iterations that I'd like to leave as is. Thank you in advance for your compromise in helping us mortals grep/cscope to learn code.

That's part of the reason why I said from the beginning that doing the Linux side first is wrong.

Jan

#18 lore raw

Re: Is: PVH + ARM new hypercalls. Was: Re: [PATCH]: PVH: specify xen features strings cleany for PVH

Quoted 11 lines · On Fri, 01 Feb 2013 16:24:57 +0000 "Jan Beulich" <[email protected]> wrote:
Quoted 11 lines
Quoted 1 line
Quoted 1 line

Mukesh Rathor <[email protected]> 02/01/13 3:23 AM >>>

Quoted 4 lines · On Tue, 29 Jan 2013 10:48:12 +0000 "Jan Beulich" <[email protected]> wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

On 29.01.13 at 03:57, Mukesh Rathor <[email protected]> wrote:

difficult, but I continue to see more advantage in avoiding the redundancy).

That was my patch version 2, where I called it gdt and another reviewer suggested to change to u. So I changed it to u.

Quoted 6 lines
Quoted 3 lines

It's gone thru enough iterations that I'd like to leave as is. Thank you in advance for your compromise in helping us mortals grep/cscope to learn code.

That's part of the reason why I said from the beginning that doing the Linux side first is wrong.

It was reviewed by xen folks like Ian C, Stefano, etc...

Thanks,
Mukesh

#19 lore raw

Re: Is: PVH + ARM new hypercalls. Was: Re: [PATCH]: PVH: specify xen features strings cleany for PVH

Quoted 14 lines · Mukesh Rathor
Quoted 11 lines · On Fri, 01 Feb 2013 16:24:57 +0000 "Jan Beulich" <[email protected]> wrote:
Quoted 11 lines
Quoted 1 line
Quoted 1 line

Mukesh Rathor <[email protected]> 02/01/13 3:23 AM >>>

Quoted 4 lines · On Tue, 29 Jan 2013 10:48:12 +0000 "Jan Beulich" <[email protected]> wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

On 29.01.13 at 03:57, Mukesh Rathor <[email protected]> wrote:

difficult, but I continue to see more advantage in avoiding the redundancy).

That was my patch version 2, where I called it gdt and another reviewer suggested to change to u. So I changed it to u.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

It's gone thru enough iterations that I'd like to leave as is. Thank you in advance for your compromise in helping us mortals grep/cscope to learn code.

That's part of the reason why I said from the beginning that doing the Linux side first is wrong.

It was reviewed by xen folks like Ian C, Stefano, etc...

Well, that doesn't in any way mean that Jan's opinion isn't valid or relevant and where reviewers/authors cannot reach consensus over something then it is ultimately the maintainer's call.

I deliberately avoided formally Acking any of the Linux side patches until the hypervisor side was posted and reviewed, precisely because it is necessary to review the hypervisor interfaces as part of the hypervisor changes before committing to them. I believe we explicitly agreed that the interface would be subject to change when the hypervisor patches were posted for review.

WRT this particular change I don't personally like the idea of sharing gdt_frames[0] and gdt_ents for two semantically different usages, but I would defer to Jan as a hypervisor maintainer on that point.

I don't much care about the gdt vs u naming for the union, although I would probably have gone with the more meaningful gdt if it were me. cscope-wise in emacs I would just use "C-c s t" to look for "gdt.size" etc.

Ian.

#20 lore raw

Re: Is: PVH + ARM new hypercalls. Was: Re: [PATCH]: PVH: specify xen features strings cleany for PVH

Quoted 9 lines · On Mon, 4 Feb 2013 10:31:41 +0000 Ian Campbell <[email protected]> wrote:
Quoted 3 lines · Mukesh Rathor

On Fri, 01 Feb 2013 16:24:57 +0000
"Jan Beulich" <[email protected]> wrote:

I don't much care about the gdt vs u naming for the union, although I would probably have gone with the more meaningful gdt if it were me. cscope-wise in emacs I would just use "C-c s t" to look for "gdt.size" etc.

Unf vim cscope doesn't support that. Moreover, I bet if size was accessed via pointer, you couldn't search it that way either. In general, all enterprise software I've worked on prohibited such generic names for the reason people couldn't easily find their usages. I find it very frustrating, and I hope I can continue to be able to read xen code.

Thanks,
Mukesh

#21 lore raw

Re: Is: PVH + ARM new hypercalls. Was: Re: [PATCH]: PVH: specify xen features strings cleany for PVH

Quoted 14 lines
Quoted 1 line
Quoted 1 line · Mukesh Rathor
Quoted 9 lines · On Mon, 4 Feb 2013 10:31:41 +0000 Ian Campbell <[email protected]> wrote:
Quoted 3 lines · Mukesh Rathor

On Fri, 01 Feb 2013 16:24:57 +0000
"Jan Beulich" <[email protected]> wrote:

I don't much care about the gdt vs u naming for the union, although I would probably have gone with the more meaningful gdt if it were me. cscope-wise in emacs I would just use "C-c s t" to look for "gdt.size" etc.

Quoted 5 lines

Unf vim cscope doesn't support that. Moreover, I bet if size was accessed via pointer, you couldn't search it that way either. In general, all enterprise software I've worked on prohibited such generic names for the reason people couldn't easily find their usages. I find it very frustrating, and I hope I can continue to be able to read xen code.

I'm sorry, Mukesh, but if everyone else manages to read Xen code with untagged field names and the like, then I'm afraid you'll need to find a way for yourself to handle this...

Jan