From: "Jan Beulich" Subject: =?utf-8?q?=5BPATCH_v2_1/4=5D_vm=E2=80=91assist=3A_pre?= =?utf-8?q?pare_for_discontiguous_used_bit_numbers?= Date: Fri, 20 Mar 2015 15:21:37 +0000 Message-ID: <550C4911020000780006C201@mail.emea.novell.com> References: <550C481D020000780006C1DD@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part1B2F4F11.2__=" Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YYyjy-0007Rh-Vj for xen-devel@lists.xenproject.org; Fri, 20 Mar 2015 15:21:39 +0000 In-Reply-To: <550C481D020000780006C1DD@mail.emea.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Ian Campbell , Andrew Cooper , Keir Fraser , Ian Jackson , Tim Deegan List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part1B2F4F11.2__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Since the a flag will get assigned a value discontiguous to the existing ones (in order to preserve the low bits, as only those are currently accessible to 32-bit guests), this requires a little bit of rework of the VM assist code in general: An architecture specific VM_ASSIST_VALID definition gets introduced (with an optional compat mode counterpart), and compilation of the respective code becomes conditional upon this being defined (ARM doesn't wire these up and hence doesn't need that code). Signed-off-by: Jan Beulich --- v2: Split original patch into two. --- a/xen/common/compat/kernel.c +++ b/xen/common/compat/kernel.c @@ -41,6 +41,11 @@ CHECK_TYPE(domain_handle); #define xennmi_callback compat_nmi_callback #define xennmi_callback_t compat_nmi_callback_t =20 +#ifdef COMPAT_VM_ASSIST_VALID +#undef VM_ASSIST_VALID +#define VM_ASSIST_VALID COMPAT_VM_ASSIST_VALID +#endif + #define DO(fn) int compat_##fn #define COMPAT =20 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -1318,9 +1318,11 @@ long do_vcpu_op(int cmd, unsigned int vc return rc; } =20 -long vm_assist(struct domain *p, unsigned int cmd, unsigned int type) +#ifdef VM_ASSIST_VALID +long vm_assist(struct domain *p, unsigned int cmd, unsigned int type, + unsigned long valid) { - if ( type > MAX_VMASST_TYPE ) + if ( type >=3D BITS_PER_LONG || !test_bit(type, &valid) ) return -EINVAL; =20 switch ( cmd ) @@ -1335,6 +1337,7 @@ long vm_assist(struct domain *p, unsigne =20 return -ENOSYS; } +#endif =20 struct pirq *pirq_get_info(struct domain *d, int pirq) { --- a/xen/common/kernel.c +++ b/xen/common/kernel.c @@ -386,10 +386,12 @@ DO(nmi_op)(unsigned int cmd, XEN_GUEST_H return rc; } =20 +#ifdef VM_ASSIST_VALID DO(vm_assist)(unsigned int cmd, unsigned int type) { - return vm_assist(current->domain, cmd, type); + return vm_assist(current->domain, cmd, type, VM_ASSIST_VALID); } +#endif =20 DO(ni_hypercall)(void) { --- a/xen/include/asm-x86/config.h +++ b/xen/include/asm-x86/config.h @@ -343,6 +343,15 @@ extern unsigned long xen_phys_start; #define ARG_XLAT_START(v) \ (ARG_XLAT_VIRT_START + ((v)->vcpu_id << ARG_XLAT_VA_SHIFT)) =20 +#define NATIVE_VM_ASSIST_VALID ((1UL << VMASST_TYPE_4gb_segments) = | \ + (1UL << VMASST_TYPE_4gb_segments_notify)= | \ + (1UL << VMASST_TYPE_writable_pagetables)= | \ + (1UL << VMASST_TYPE_pae_extended_cr3) = | \ + (1UL << VMASST_TYPE_m2p_strict)) +#define VM_ASSIST_VALID NATIVE_VM_ASSIST_VALID +#define COMPAT_VM_ASSIST_VALID (NATIVE_VM_ASSIST_VALID & \ + ((1UL << COMPAT_BITS_PER_LONG) - 1)) + #define ELFSIZE 64 =20 #define ARCH_CRASH_SAVE_VMCOREINFO --- a/xen/include/public/xen.h +++ b/xen/include/public/xen.h @@ -486,7 +486,9 @@ DEFINE_XEN_GUEST_HANDLE(mmuext_op_t); /* x86/PAE guests: support PDPTs above 4GB. */ #define VMASST_TYPE_pae_extended_cr3 3 =20 +#if __XEN_INTERFACE_VERSION__ < 0x00040600 #define MAX_VMASST_TYPE 3 +#endif =20 #ifndef __ASSEMBLY__ =20 --- a/xen/include/xen/lib.h +++ b/xen/include/xen/lib.h @@ -80,7 +80,8 @@ extern void guest_printk(const struct do __attribute__ ((format (printf, 2, 3))); extern void noreturn panic(const char *format, ...) __attribute__ ((format (printf, 1, 2))); -extern long vm_assist(struct domain *, unsigned int, unsigned int); +extern long vm_assist(struct domain *, unsigned int cmd, unsigned int = type, + unsigned long valid); extern int __printk_ratelimit(int ratelimit_ms, int ratelimit_burst); extern int printk_ratelimit(void); =20 --=__Part1B2F4F11.2__= Content-Type: text/plain; name="vm-assist-discontiguous.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="vm-assist-discontiguous.patch" vm-assist: prepare for discontiguous used bit numbers=0A=0ASince the a = flag will get assigned a value discontiguous to the=0Aexisting ones (in = order to preserve the low bits, as only those are=0Acurrently accessible = to 32-bit guests), this requires a little bit of=0Arework of the VM assist = code in general: An architecture specific=0AVM_ASSIST_VALID definition = gets introduced (with an optional compat=0Amode counterpart), and = compilation of the respective code becomes=0Aconditional upon this being = defined (ARM doesn't wire these up and=0Ahence doesn't need that = code).=0A=0ASigned-off-by: Jan Beulich =0A---=0Av2: = Split original patch into two.=0A=0A--- a/xen/common/compat/kernel.c=0A+++ = b/xen/common/compat/kernel.c=0A@@ -41,6 +41,11 @@ CHECK_TYPE(domain_handle)= ;=0A #define xennmi_callback compat_nmi_callback=0A #define xennmi_callback= _t compat_nmi_callback_t=0A =0A+#ifdef COMPAT_VM_ASSIST_VALID=0A+#undef = VM_ASSIST_VALID=0A+#define VM_ASSIST_VALID COMPAT_VM_ASSIST_VALID=0A+#endif= =0A+=0A #define DO(fn) int compat_##fn=0A #define COMPAT=0A =0A--- = a/xen/common/domain.c=0A+++ b/xen/common/domain.c=0A@@ -1318,9 +1318,11 @@ = long do_vcpu_op(int cmd, unsigned int vc=0A return rc;=0A }=0A = =0A-long vm_assist(struct domain *p, unsigned int cmd, unsigned int = type)=0A+#ifdef VM_ASSIST_VALID=0A+long vm_assist(struct domain *p, = unsigned int cmd, unsigned int type,=0A+ unsigned long = valid)=0A {=0A- if ( type > MAX_VMASST_TYPE )=0A+ if ( type >=3D = BITS_PER_LONG || !test_bit(type, &valid) )=0A return -EINVAL;=0A = =0A switch ( cmd )=0A@@ -1335,6 +1337,7 @@ long vm_assist(struct = domain *p, unsigne=0A =0A return -ENOSYS;=0A }=0A+#endif=0A =0A struct = pirq *pirq_get_info(struct domain *d, int pirq)=0A {=0A--- a/xen/common/ker= nel.c=0A+++ b/xen/common/kernel.c=0A@@ -386,10 +386,12 @@ DO(nmi_op)(unsign= ed int cmd, XEN_GUEST_H=0A return rc;=0A }=0A =0A+#ifdef VM_ASSIST_VALI= D=0A DO(vm_assist)(unsigned int cmd, unsigned int type)=0A {=0A- return = vm_assist(current->domain, cmd, type);=0A+ return vm_assist(current->dom= ain, cmd, type, VM_ASSIST_VALID);=0A }=0A+#endif=0A =0A DO(ni_hypercall)(vo= id)=0A {=0A--- a/xen/include/asm-x86/config.h=0A+++ b/xen/include/asm-x86/c= onfig.h=0A@@ -343,6 +343,15 @@ extern unsigned long xen_phys_start;=0A = #define ARG_XLAT_START(v) \=0A (ARG_XLAT_VIRT_START + ((v)->vcpu= _id << ARG_XLAT_VA_SHIFT))=0A =0A+#define NATIVE_VM_ASSIST_VALID ((1UL = << VMASST_TYPE_4gb_segments) | \=0A+ = (1UL << VMASST_TYPE_4gb_segments_notify) | \=0A+ = (1UL << VMASST_TYPE_writable_pagetables) | \=0A+ = (1UL << VMASST_TYPE_pae_extended_cr3) | \=0A+ = (1UL << VMASST_TYPE_m2p_strict))=0A+#define = VM_ASSIST_VALID NATIVE_VM_ASSIST_VALID=0A+#define COMPAT_VM_ASSIST= _VALID (NATIVE_VM_ASSIST_VALID & \=0A+ = ((1UL << COMPAT_BITS_PER_LONG) - 1))=0A+=0A #define ELFSIZE 64=0A =0A = #define ARCH_CRASH_SAVE_VMCOREINFO=0A--- a/xen/include/public/xen.h=0A+++ = b/xen/include/public/xen.h=0A@@ -486,7 +486,9 @@ DEFINE_XEN_GUEST_HANDLE(mm= uext_op_t);=0A /* x86/PAE guests: support PDPTs above 4GB. */=0A #define = VMASST_TYPE_pae_extended_cr3 3=0A =0A+#if __XEN_INTERFACE_VERSION__ < = 0x00040600=0A #define MAX_VMASST_TYPE 3=0A+#endif=0A =0A = #ifndef __ASSEMBLY__=0A =0A--- a/xen/include/xen/lib.h=0A+++ b/xen/include/= xen/lib.h=0A@@ -80,7 +80,8 @@ extern void guest_printk(const struct do=0A = __attribute__ ((format (printf, 2, 3)));=0A extern void noreturn = panic(const char *format, ...)=0A __attribute__ ((format (printf, 1, = 2)));=0A-extern long vm_assist(struct domain *, unsigned int, unsigned = int);=0A+extern long vm_assist(struct domain *, unsigned int cmd, unsigned = int type,=0A+ unsigned long valid);=0A extern int = __printk_ratelimit(int ratelimit_ms, int ratelimit_burst);=0A extern int = printk_ratelimit(void);=0A =0A --=__Part1B2F4F11.2__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__Part1B2F4F11.2__=--