From: Jan Beulich <jbeulich@suse.com>
To: Paul Durrant <paul@xen.org>
Cc: Stefano Stabellini <sstabellini@kernel.org>,
Julien Grall <julien@xen.org>, Wei Liu <wl@xen.org>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Paul Durrant <pdurrant@amazon.com>,
Ian Jackson <ian.jackson@eu.citrix.com>,
George Dunlap <george.dunlap@citrix.com>,
xen-devel@lists.xenproject.org
Subject: Re: [PATCH v3 4/5] common/domain: add a domain context record for shared_info...
Date: Tue, 19 May 2020 16:07:37 +0200 [thread overview]
Message-ID: <bbebc62f-8066-a60e-5717-58e46cd2d172@suse.com> (raw)
In-Reply-To: <20200514104416.16657-5-paul@xen.org>
On 14.05.2020 12:44, Paul Durrant wrote:
> @@ -61,6 +62,76 @@ static void dump_header(void)
>
> }
>
> +static void print_binary(const char *prefix, void *val, size_t size,
const also for val?
> + const char *suffix)
> +{
> + printf("%s", prefix);
> +
> + while (size--)
Judging from style elsewhere you look to be missing two blanks
here.
> + {
> + uint8_t octet = *(uint8_t *)val++;
Following the above then also better don't cast const away here.
> + unsigned int i;
> +
> + for ( i = 0; i < 8; i++ )
> + {
> + printf("%u", octet & 1);
> + octet >>= 1;
> + }
> + }
> +
> + printf("%s", suffix);
> +}
> +
> +static void dump_shared_info(void)
> +{
> + DOMAIN_SAVE_TYPE(SHARED_INFO) *s;
> + shared_info_any_t *info;
> + unsigned int i;
> +
> + GET_PTR(s);
> +
> + printf(" SHARED_INFO: has_32bit_shinfo: %s buffer_size: %u\n",
> + s->has_32bit_shinfo ? "true" : "false", s->buffer_size);
> +
> + info = (shared_info_any_t *)s->buffer;
> +
> +#define GET_FIELD_PTR(_f) \
> + (s->has_32bit_shinfo ? (void *)&(info->x32._f) : (void *)&(info->x64._f))
Better cast to const void * ?
> +#define GET_FIELD_SIZE(_f) \
> + (s->has_32bit_shinfo ? sizeof(info->x32._f) : sizeof(info->x64._f))
> +#define GET_FIELD(_f) \
> + (s->has_32bit_shinfo ? info->x32._f : info->x64._f)
> +
> + /* Array lengths are the same for 32-bit and 64-bit shared info */
Not really, no:
xen_ulong_t evtchn_pending[sizeof(xen_ulong_t) * 8];
xen_ulong_t evtchn_mask[sizeof(xen_ulong_t) * 8];
> @@ -167,12 +238,14 @@ int main(int argc, char **argv)
> if ( (typecode < 0 || typecode == desc->typecode) &&
> (instance < 0 || instance == desc->instance) )
> {
> +
> printf("[%u] type: %u instance: %u length: %u\n", entry++,
> desc->typecode, desc->instance, desc->length);
Stray insertion of a blank line?
> @@ -1649,6 +1650,65 @@ int continue_hypercall_on_cpu(
> return 0;
> }
>
> +static int save_shared_info(const struct domain *d, struct domain_context *c,
> + bool dry_run)
> +{
> + struct domain_shared_info_context ctxt = { .buffer_size = PAGE_SIZE };
Why not sizeof(shared_info), utilizing the zero padding on the
receiving side?
> + size_t hdr_size = offsetof(typeof(ctxt), buffer);
> + int rc;
> +
> + rc = DOMAIN_SAVE_BEGIN(SHARED_INFO, c, 0);
> + if ( rc )
> + return rc;
> +
> +#ifdef CONFIG_COMPAT
> + if ( !dry_run )
> + ctxt.has_32bit_shinfo = has_32bit_shinfo(d);
> +#endif
Nothing will go wrong without the if(), I suppose? Better drop it
then? It could then also easily be part of the initializer of ctxt.
> + rc = domain_save_data(c, &ctxt, hdr_size);
> + if ( rc )
> + return rc;
> +
> + rc = domain_save_data(c, d->shared_info, ctxt.buffer_size);
> + if ( rc )
> + return rc;
> +
> + return domain_save_end(c);
> +}
> +
> +static int load_shared_info(struct domain *d, struct domain_context *c)
> +{
> + struct domain_shared_info_context ctxt;
> + size_t hdr_size = offsetof(typeof(ctxt), buffer);
> + unsigned int i;
> + int rc;
> +
> + rc = DOMAIN_LOAD_BEGIN(SHARED_INFO, c, &i);
> + if ( rc || i ) /* expect only a single instance */
> + return rc;
> +
> + rc = domain_load_data(c, &ctxt, hdr_size);
> + if ( rc )
> + return rc;
> +
> + if ( ctxt.pad[0] || ctxt.pad[1] || ctxt.pad[2] ||
> + ctxt.buffer_size != PAGE_SIZE )
> + return -EINVAL;
> +
> +#ifdef CONFIG_COMPAT
> + d->arch.has_32bit_shinfo = ctxt.has_32bit_shinfo;
> +#endif
There's nothing wrong with using has_32bit_shinfo(d) here as well.
> --- a/xen/include/public/save.h
> +++ b/xen/include/public/save.h
> @@ -73,7 +73,16 @@ struct domain_save_header {
> };
> DECLARE_DOMAIN_SAVE_TYPE(HEADER, 1, struct domain_save_header);
>
> -#define DOMAIN_SAVE_CODE_MAX 1
> +struct domain_shared_info_context {
> + uint8_t has_32bit_shinfo;
> + uint8_t pad[3];
32-(or 16-)bit flags, with just a single bit used for the purpose?
Jan
next prev parent reply other threads:[~2020-05-19 14:07 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-14 10:44 [PATCH v3 0/5] domain context infrastructure Paul Durrant
2020-05-14 10:44 ` [PATCH v3 1/5] xen/common: introduce a new framework for save/restore of 'domain' context Paul Durrant
2020-05-19 13:03 ` Jan Beulich
2020-05-19 14:04 ` Paul Durrant
2020-05-19 14:23 ` Jan Beulich
2020-05-19 15:10 ` Paul Durrant
2020-05-19 15:18 ` Jan Beulich
2020-05-19 15:32 ` Paul Durrant
2020-05-19 15:37 ` Jan Beulich
2020-05-19 15:38 ` Paul Durrant
2020-05-14 10:44 ` [PATCH v3 2/5] xen/common/domctl: introduce XEN_DOMCTL_get/setdomaincontext Paul Durrant
2020-05-19 13:49 ` Jan Beulich
2020-05-19 15:12 ` Paul Durrant
2020-05-14 10:44 ` [PATCH v3 3/5] tools/misc: add xen-domctx to present domain context Paul Durrant
2020-05-14 10:44 ` [PATCH v3 4/5] common/domain: add a domain context record for shared_info Paul Durrant
2020-05-19 14:07 ` Jan Beulich [this message]
2020-05-19 15:21 ` Paul Durrant
2020-05-19 15:34 ` Jan Beulich
2020-05-19 15:35 ` Paul Durrant
2020-05-14 10:44 ` [PATCH v3 5/5] tools/libxc: make use of domain context SHARED_INFO record Paul Durrant
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=bbebc62f-8066-a60e-5717-58e46cd2d172@suse.com \
--to=jbeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=george.dunlap@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=julien@xen.org \
--cc=paul@xen.org \
--cc=pdurrant@amazon.com \
--cc=sstabellini@kernel.org \
--cc=wl@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.