Skip to contentSkip to conversation

x86/msr: Drop {pv,hvm}_max_vcpu_msrs objects

PATCH In review Andrew Cooper 3 participants 4 messages Feb 24, 2020 – Feb 25, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/msr: Drop {pv,hvm}_max_vcpu_msrs objects

It turns out that these are unused, and we dup a type-dependent block of zeros. Use xzalloc() instead.

Read/write MSRs are typically 0 to being with, and non-zero defaults would need dealing with at suitable INIT/RESET points (e.g. arch_vcpu_regs_init).

---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monné <[email protected]>

---
 xen/arch/x86/msr.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
xen/arch/x86/msr.c +1 -7
index dd26c87758..3ebf777c53 100644
@@ -35,9 +35,6 @@ struct msr_policy __read_mostly     raw_msr_policy,
                   __read_mostly hvm_max_msr_policy,
                   __read_mostly  pv_max_msr_policy;
 
-struct vcpu_msrs __read_mostly hvm_max_vcpu_msrs,
-                 __read_mostly  pv_max_vcpu_msrs;
-
 static void __init calculate_raw_policy(void)
 {
     /* 0x000000ce  MSR_INTEL_PLATFORM_INFO */
@@ -103,10 +100,7 @@ int init_domain_msr_policy(struct domain *d)
 
 int init_vcpu_msr_policy(struct vcpu *v)
 {
-    struct domain *d = v->domain;
-    struct vcpu_msrs *msrs =
-        xmemdup(is_pv_domain(d) ?  &pv_max_vcpu_msrs
-                                : &hvm_max_vcpu_msrs);
+    struct vcpu_msrs *msrs = xzalloc(*msrs);
 
     if ( !msrs )
         return -ENOMEM;
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Reviewed-by on v1 1/1
#1 lore raw

Re: [Xen-devel] [PATCH] x86/msr: Drop {pv, hvm}_max_vcpu_msrs objects

Quoted 7 lines · Andrew Cooper

It turns out that these are unused, and we dup a type-dependent block of zeros. Use xzalloc() instead.

Read/write MSRs are typically 0 to being with, and non-zero defaults would need dealing with at suitable INIT/RESET points (e.g. arch_vcpu_regs_init).

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw

Re: [Xen-devel] [PATCH] x86/msr: Drop {pv, hvm}_max_vcpu_msrs objects

Quoted 9 lines · Roger Pau Monné
Quoted 7 lines · Andrew Cooper

It turns out that these are unused, and we dup a type-dependent block of zeros. Use xzalloc() instead.

Read/write MSRs are typically 0 to being with, and non-zero defaults would need dealing with at suitable INIT/RESET points (e.g. arch_vcpu_regs_init).

Thanks.

FWIW, I rewrote the second paragraph to not mix up begin and being.

Also, this patch logically depends on "xen/xmalloc Unify type handling in macros".

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reviewed-by on v1 1/1
#3 lore raw

Re: [Xen-devel] [PATCH] x86/msr: Drop {pv, hvm}_max_vcpu_msrs objects

In reply to Andrew Cooper

xen/arch/x86/msr.c int init_domain_msr_policy(struct domain *d) · line 103

Quoted 9 lines · Andrew Cooper
xen/arch/x86/msr.c +1 -4
@@ -103,10 +100,7 @@ int init_domain_msr_policy(struct domain *d)
 
 int init_vcpu_msr_policy(struct vcpu *v)
 {
-    struct domain *d = v->domain;
-    struct vcpu_msrs *msrs =
-        xmemdup(is_pv_domain(d) ?  &pv_max_vcpu_msrs
-                                : &hvm_max_vcpu_msrs);
+    struct vcpu_msrs *msrs = xzalloc(*msrs);

As said on the other thread, I don't think this visual (even if not factual) use of an uninitialized variable is not helpful. I don't see anything wrong with continuing the traditional

    struct vcpu_msrs *msrs = xzalloc(struct vcpu_msrs);

way. It would be a different thing if the variable to be initialized was passed into the macro, and hence there wouldn't be any explicit assignment (or initialization) at the use sites ...

For the suggested alternative form

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel