diff mbox series

x86emul/fuzz: extend canonicalization to 57-bit linear address width case

Message ID 5CA1C0F902000078002236A3@prv1-mh.provo.novell.com (mailing list archive)
State New, archived
Headers show
Series x86emul/fuzz: extend canonicalization to 57-bit linear address width case | expand

Commit Message

Jan Beulich April 1, 2019, 7:42 a.m. UTC
Don't enforce any other dependencies for now, just like we don't enforce
e.g. PAE enabled as a prereq for long mode.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

Comments

Jan Beulich May 27, 2019, 9:26 a.m. UTC | #1
>>> On 01.04.19 at 09:42,  wrote:
> Don't enforce any other dependencies for now, just like we don't enforce
> e.g. PAE enabled as a prereq for long mode.
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> 
> --- a/tools/fuzz/x86_instruction_emulator/fuzz-emul.c
> +++ b/tools/fuzz/x86_instruction_emulator/fuzz-emul.c
> @@ -662,21 +662,21 @@ static void set_sizes(struct x86_emulate
>      }
>  }
>  
> -#define CANONICALIZE(x)                                   \
> +#define CANONICALIZE(x, bits)                             \
>      do {                                                  \
>          uint64_t _y = (x);                                \
> -        if ( _y & (1ULL << 47) )                          \
> -            _y |= (~0ULL) << 48;                          \
> +        if ( _y & (1ULL << ((bits) - 1)) )                \
> +            _y |= (~0ULL) << (bits);                      \
>          else                                              \
> -            _y &= (1ULL << 48)-1;                         \
> +            _y &= (1ULL << (bits)) - 1;                   \
>          printf("Canonicalized %" PRIx64 " to %" PRIx64 "\n", x, _y);    \
>          (x) = _y;                                       \
>      } while( 0 )
>  
> -/* Expects bitmap and regs to be defined */
> +/* Expects bitmap, regs, and c to be defined */
>  #define CANONICALIZE_MAYBE(reg)                       \
>      if ( !(bitmap & (1 << CANONICALIZE_##reg)) )      \
> -        CANONICALIZE(regs->reg);                      \
> +        CANONICALIZE(regs->reg, c->cr[4] & X86_CR4_LA57 ? 57 : 48); \
>  
>  enum {
>      HOOK_read,
> --- a/xen/include/asm-x86/x86-defns.h
> +++ b/xen/include/asm-x86/x86-defns.h
> @@ -64,6 +64,7 @@
>  #define X86_CR4_OSFXSR     0x00000200 /* enable fast FPU save and restore 
> */
>  #define X86_CR4_OSXMMEXCPT 0x00000400 /* enable unmasked SSE exceptions */
>  #define X86_CR4_UMIP       0x00000800 /* enable UMIP */
> +#define X86_CR4_LA57       0x00001000 /* enable 5-level paging */
>  #define X86_CR4_VMXE       0x00002000 /* enable VMX */
>  #define X86_CR4_SMXE       0x00004000 /* enable SMX */
>  #define X86_CR4_FSGSBASE   0x00010000 /* enable {rd,wr}{fs,gs}base */
> 
> 
> 
>
George Dunlap May 27, 2019, 10:21 a.m. UTC | #2
On 4/1/19 8:42 AM, Jan Beulich wrote:
> Don't enforce any other dependencies for now, just like we don't enforce
> e.g. PAE enabled as a prereq for long mode.
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: George Dunlap <george.dunlap@citrix.com>
diff mbox series

Patch

--- a/tools/fuzz/x86_instruction_emulator/fuzz-emul.c
+++ b/tools/fuzz/x86_instruction_emulator/fuzz-emul.c
@@ -662,21 +662,21 @@  static void set_sizes(struct x86_emulate
     }
 }
 
-#define CANONICALIZE(x)                                   \
+#define CANONICALIZE(x, bits)                             \
     do {                                                  \
         uint64_t _y = (x);                                \
-        if ( _y & (1ULL << 47) )                          \
-            _y |= (~0ULL) << 48;                          \
+        if ( _y & (1ULL << ((bits) - 1)) )                \
+            _y |= (~0ULL) << (bits);                      \
         else                                              \
-            _y &= (1ULL << 48)-1;                         \
+            _y &= (1ULL << (bits)) - 1;                   \
         printf("Canonicalized %" PRIx64 " to %" PRIx64 "\n", x, _y);    \
         (x) = _y;                                       \
     } while( 0 )
 
-/* Expects bitmap and regs to be defined */
+/* Expects bitmap, regs, and c to be defined */
 #define CANONICALIZE_MAYBE(reg)                       \
     if ( !(bitmap & (1 << CANONICALIZE_##reg)) )      \
-        CANONICALIZE(regs->reg);                      \
+        CANONICALIZE(regs->reg, c->cr[4] & X86_CR4_LA57 ? 57 : 48); \
 
 enum {
     HOOK_read,
--- a/xen/include/asm-x86/x86-defns.h
+++ b/xen/include/asm-x86/x86-defns.h
@@ -64,6 +64,7 @@ 
 #define X86_CR4_OSFXSR     0x00000200 /* enable fast FPU save and restore */
 #define X86_CR4_OSXMMEXCPT 0x00000400 /* enable unmasked SSE exceptions */
 #define X86_CR4_UMIP       0x00000800 /* enable UMIP */
+#define X86_CR4_LA57       0x00001000 /* enable 5-level paging */
 #define X86_CR4_VMXE       0x00002000 /* enable VMX */
 #define X86_CR4_SMXE       0x00004000 /* enable SMX */
 #define X86_CR4_FSGSBASE   0x00010000 /* enable {rd,wr}{fs,gs}base */