Skip to contentSkip to conversation

x86emul: MSR indexes are only 32 bits wide

PATCH In review Jan Beulich 2 participants 3 messages Feb 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86emul: MSR indexes are only 32 bits wide

... and hence the respective {read,write}_msr() hook parameter doesn't need to be "unsigned long".

xen/arch/x86/hvm/emulate.c +3 -3
@@ -966,7 +966,7 @@ static int hvmemul_write_io_discard(
 }
 
 static int hvmemul_write_msr_discard(
-    unsigned long reg,
+    unsigned int reg,
     uint64_t val,
     struct x86_emulate_ctxt *ctxt)
 {
@@ -1439,7 +1439,7 @@ static int hvmemul_write_cr(
 }
 
 static int hvmemul_read_msr(
-    unsigned long reg,
+    unsigned int reg,
     uint64_t *val,
     struct x86_emulate_ctxt *ctxt)
 {
@@ -1447,7 +1447,7 @@ static int hvmemul_read_msr(
 }
 
 static int hvmemul_write_msr(
-    unsigned long reg,
+    unsigned int reg,
     uint64_t val,
     struct x86_emulate_ctxt *ctxt)
 {
xen/arch/x86/x86_emulate/x86_emulate.h +2 -2
@@ -334,7 +334,7 @@ struct x86_emulate_ops
      *  @reg:   [IN ] Register to read.
      */
     int (*read_msr)(
-        unsigned long reg,
+        unsigned int reg,
         uint64_t *val,
         struct x86_emulate_ctxt *ctxt);
 
@@ -343,7 +343,7 @@ struct x86_emulate_ops
      *  @reg:   [IN ] Register to write.
      */
     int (*write_msr)(
-        unsigned long reg,
+        unsigned int reg,
         uint64_t val,
         struct x86_emulate_ctxt *ctxt);
 

x86emul: MSR indexes are only 32 bits wide

... and hence the respective {read,write}_msr() hook parameter doesn't need to be "unsigned long".

xen/arch/x86/hvm/emulate.c +3 -3
@@ -966,7 +966,7 @@ static int hvmemul_write_io_discard(
 }
 
 static int hvmemul_write_msr_discard(
-    unsigned long reg,
+    unsigned int reg,
     uint64_t val,
     struct x86_emulate_ctxt *ctxt)
 {
@@ -1439,7 +1439,7 @@ static int hvmemul_write_cr(
 }
 
 static int hvmemul_read_msr(
-    unsigned long reg,
+    unsigned int reg,
     uint64_t *val,
     struct x86_emulate_ctxt *ctxt)
 {
@@ -1447,7 +1447,7 @@ static int hvmemul_read_msr(
 }
 
 static int hvmemul_write_msr(
-    unsigned long reg,
+    unsigned int reg,
     uint64_t val,
     struct x86_emulate_ctxt *ctxt)
 {
xen/arch/x86/x86_emulate/x86_emulate.h +2 -2
@@ -334,7 +334,7 @@ struct x86_emulate_ops
      *  @reg:   [IN ] Register to read.
      */
     int (*read_msr)(
-        unsigned long reg,
+        unsigned int reg,
         uint64_t *val,
         struct x86_emulate_ctxt *ctxt);
 
@@ -343,7 +343,7 @@ struct x86_emulate_ops
      *  @reg:   [IN ] Register to write.
      */
     int (*write_msr)(
-        unsigned long reg,
+        unsigned int reg,
         uint64_t val,
         struct x86_emulate_ctxt *ctxt);
 

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

#1 lore raw
Quoted 4 lines · Jan Beulich

... and hence the respective {read,write}_msr() hook parameter doesn't need to be "unsigned long".

I would suggest uint32_t instead (being more architecturally self-documenting), but either way, Reviewed-by: Andrew Cooper <[email protected]>

#2 lore raw
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 15.02.16 at 13:51, <[email protected]> wrote:
Quoted 4 lines · Jan Beulich

... and hence the respective {read,write}_msr() hook parameter doesn't need to be "unsigned long".

I would suggest uint32_t instead (being more architecturally self-documenting), but either way, Reviewed-by: Andrew Cooper <[email protected]>

While it might be "more architecturally self-documenting", it would also be less in line with types used elsewhere (at least for those pieces which I had looked at). This consistency consideration made me use unsigned int (which we imply to be at least 32 bits wide anyway).

Jan