diff mbox

x86/domctl: don't waste domain CPUID slot for all zero data

Message ID 56F14F0702000078000DF2B4@prv-mh.provo.novell.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jan Beulich March 22, 2016, 12:56 p.m. UTC
domain_cpuid() returns all zeroes anyway when not finding a match, so
there's no need to explicitly store such a set of values.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
x86/domctl: don't waste domain CPUID slot for all zero data

domain_cpuid() returns all zeroes anyway when not finding a match, so
there's no need to explicitly store such a set of values.

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

--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -714,7 +714,7 @@ long arch_do_domctl(
 
     case XEN_DOMCTL_set_cpuid:
     {
-        xen_domctl_cpuid_t *ctl = &domctl->u.cpuid;
+        const xen_domctl_cpuid_t *ctl = &domctl->u.cpuid;
         cpuid_input_t *cpuid, *unused = NULL;
 
         if ( d == currd ) /* no domain_pause() */
@@ -742,7 +742,12 @@ long arch_do_domctl(
 
         domain_pause(d);
 
-        if ( i < MAX_CPUID_INPUT )
+        if ( !(ctl->eax | ctl->ebx | ctl->ecx | ctl->edx) )
+        {
+            if ( i < MAX_CPUID_INPUT )
+                cpuid->input[0] = XEN_CPUID_INPUT_UNUSED;
+        }
+        else if ( i < MAX_CPUID_INPUT )
             *cpuid = *ctl;
         else if ( unused )
             *unused = *ctl;

Comments

Andrew Cooper March 22, 2016, 3:10 p.m. UTC | #1
On 22/03/16 12:56, Jan Beulich wrote:

slot => slots in the subject.

> domain_cpuid() returns all zeroes anyway when not finding a match, so
> there's no need to explicitly store such a set of values.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
diff mbox

Patch

--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -714,7 +714,7 @@  long arch_do_domctl(
 
     case XEN_DOMCTL_set_cpuid:
     {
-        xen_domctl_cpuid_t *ctl = &domctl->u.cpuid;
+        const xen_domctl_cpuid_t *ctl = &domctl->u.cpuid;
         cpuid_input_t *cpuid, *unused = NULL;
 
         if ( d == currd ) /* no domain_pause() */
@@ -742,7 +742,12 @@  long arch_do_domctl(
 
         domain_pause(d);
 
-        if ( i < MAX_CPUID_INPUT )
+        if ( !(ctl->eax | ctl->ebx | ctl->ecx | ctl->edx) )
+        {
+            if ( i < MAX_CPUID_INPUT )
+                cpuid->input[0] = XEN_CPUID_INPUT_UNUSED;
+        }
+        else if ( i < MAX_CPUID_INPUT )
             *cpuid = *ctl;
         else if ( unused )
             *unused = *ctl;