From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Ian Campbell <Ian.Campbell@eu.citrix.com>,
xen-devel <xen-devel@lists.xenproject.org>,
Keir Fraser <keir@xen.org>,
Ian Jackson <Ian.Jackson@eu.citrix.com>, Tim Deegan <tim@xen.org>
Subject: Re: [PATCH 1/3] x86: fix guest CPUID handling
Date: Wed, 30 Apr 2014 18:03:06 +0100 [thread overview]
Message-ID: <53612CCA.4060403@citrix.com> (raw)
In-Reply-To: <53612347020000780000DD53@mail.emea.novell.com>
[-- Attachment #1.1: Type: text/plain, Size: 2831 bytes --]
On 30/04/14 15:22, Jan Beulich wrote:
> The way XEN_DOMCTL_set_cpuid got handled so far allowed for surprises
> to the caller. With this set of operations
> - set leaf A (using array index 0)
> - set leaf B (using array index 1)
> - clear leaf A (clearing array index 0)
> - set leaf B (using array index 0)
> - clear leaf B (clearing array index 0)
> the entry for leaf B at array index 1 would still be in place, while
> the caller would expect it to be cleared.
>
> While looking at the use sites of d->arch.cpuid[] I also noticed that
> the allocation of the array needlessly uses the zeroing form - the
> relevant fields of the array elements get set in a loop immediately
> following the allocation.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
>
> --- 2014-04-16.orig/xen/arch/x86/domain.c 2014-02-05 15:21:00.000000000 +0100
> +++ 2014-04-16/xen/arch/x86/domain.c 2014-04-30 13:53:18.000000000 +0200
> @@ -549,7 +549,7 @@ int arch_domain_create(struct domain *d,
>
> if ( !is_idle_domain(d) )
> {
> - d->arch.cpuids = xzalloc_array(cpuid_input_t, MAX_CPUID_INPUT);
> + d->arch.cpuids = xmalloc_array(cpuid_input_t, MAX_CPUID_INPUT);
> rc = -ENOMEM;
> if ( d->arch.cpuids == NULL )
> goto fail;
> --- 2014-04-16.orig/xen/arch/x86/domctl.c 2014-02-05 15:21:01.000000000 +0100
> +++ 2014-04-16/xen/arch/x86/domctl.c 2014-04-30 13:43:30.000000000 +0200
> @@ -1006,14 +1006,18 @@ long arch_do_domctl(
> case XEN_DOMCTL_set_cpuid:
> {
> xen_domctl_cpuid_t *ctl = &domctl->u.cpuid;
> - cpuid_input_t *cpuid = NULL;
> + cpuid_input_t *cpuid, *unused = NULL;
>
> for ( i = 0; i < MAX_CPUID_INPUT; i++ )
> {
> cpuid = &d->arch.cpuids[i];
>
> if ( cpuid->input[0] == XEN_CPUID_INPUT_UNUSED )
> - break;
> + {
> + if ( !unused )
> + unused = cpuid;
> + continue;
> + }
>
> if ( (cpuid->input[0] == ctl->input[0]) &&
> ((cpuid->input[1] == XEN_CPUID_INPUT_UNUSED) ||
> @@ -1021,15 +1025,12 @@ long arch_do_domctl(
> break;
> }
>
> - if ( i == MAX_CPUID_INPUT )
> - {
> - ret = -ENOENT;
> - }
> + if ( i < MAX_CPUID_INPUT )
> + *cpuid = *ctl;
> + else if ( unused )
> + *unused = *ctl;
> else
> - {
> - memcpy(cpuid, ctl, sizeof(cpuid_input_t));
> - ret = 0;
> - }
> + ret = -ENOENT;
> }
> break;
>
>
>
>
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
[-- Attachment #1.2: Type: text/html, Size: 3664 bytes --]
[-- Attachment #2: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2014-04-30 17:03 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-30 14:11 [PATCH 0/3] domctl related adjustments Jan Beulich
2014-04-30 14:22 ` [PATCH 1/3] x86: fix guest CPUID handling Jan Beulich
2014-04-30 17:03 ` Andrew Cooper [this message]
2014-05-01 15:29 ` Tim Deegan
2014-04-30 14:23 ` [PATCH 2/3] domctl: perform initial post-XSA-77 auditing Jan Beulich
2014-04-30 16:52 ` Andrew Cooper
2014-05-01 15:30 ` Tim Deegan
2014-04-30 14:24 ` [PATCH 3/3] domctl: tighten XEN_DOMCTL_*_permission Jan Beulich
2014-04-30 17:17 ` Andrew Cooper
2014-05-02 7:49 ` Jan Beulich
2014-05-02 8:19 ` Ian Campbell
2014-05-02 20:34 ` Daniel De Graaf
2014-05-01 15:37 ` Tim Deegan
2014-05-02 7:41 ` Jan Beulich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53612CCA.4060403@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=Ian.Campbell@eu.citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=JBeulich@suse.com \
--cc=keir@xen.org \
--cc=tim@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.