Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5D8DC83000 for ; Tue, 28 Apr 2020 15:37:45 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A6122206D7 for ; Tue, 28 Apr 2020 15:37:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="oMrXPqb2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A6122206D7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jTSIk-00062U-0L; Tue, 28 Apr 2020 15:37:38 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jTSIi-00062K-Dg for xen-devel@lists.xenproject.org; Tue, 28 Apr 2020 15:37:36 +0000 X-Inumbo-ID: 2e888844-8966-11ea-9887-bc764e2007e4 Received: from mail-wr1-x432.google.com (unknown [2a00:1450:4864:20::432]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 2e888844-8966-11ea-9887-bc764e2007e4; Tue, 28 Apr 2020 15:37:35 +0000 (UTC) Received: by mail-wr1-x432.google.com with SMTP id b11so25165612wrs.6 for ; Tue, 28 Apr 2020 08:37:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:reply-to:to:cc:references:in-reply-to:subject:date:message-id :mime-version:content-transfer-encoding:content-language :thread-index; bh=hRYwxPFLHwj8CVn3Z8B1w3R87u1K31acM/EV4UOOpmU=; b=oMrXPqb2Oz7Fae5LM2feUPLVhTSvYHrxLXEwT7Y0S4Ii6WjDM5bp7tFVK9KO0hGwQ7 o5DX7Yn4nB0F84B7l5aHRAeqXQSqSZiUkely3xp8d1OaRP8iETpb1+YgTyrrInOHQdMz RB7XkMwpscAcGVGGiMJqt/5x71q+7udnLcNzk1Ktar0ZDNkeoBL8bkY9pqPcvwvz3bNp KS5HThU5Cjq9DwReqw0tlvy/0YA3wOwGgkPzwqwHt/a4mVgycdv3lLLJ/MkH9uoXl2AX zDmmGOC8Fa2xZSRVn9LxyYv+kqXNPVzb/TJ7+W9Y38PqWUQ2sB8asRVBFPafT5EXMrwQ Fb+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:reply-to:to:cc:references:in-reply-to :subject:date:message-id:mime-version:content-transfer-encoding :content-language:thread-index; bh=hRYwxPFLHwj8CVn3Z8B1w3R87u1K31acM/EV4UOOpmU=; b=YWB9/xD8BSeLIeDEiuew1yMd7Yp+Se3QXo8AmaAAvlfdqqatpNbNn+rLcofk4eKHES UcRjrLThuYfY/HI48FpnLqC0wY3CabUTz6SDqRzCGMFhDDLKy7kflhJW/km0Mu9CD5wA lAa8vMgjJjdtMEnugAVbsRwI+9ncZOui3lUWF++1U3Cze0LXgK3B98/t7y1cdGBjL60B z+nPoFcy/e4oGtGb4zIvxrgR5exIWVOlKPM3hZp3aeKDiKD4FFAKfbd3miv+yMMMDT7x 4jRY+jBQMsqchD/WC7EYMSzkR2dT+bBOxYtyUXd/YSkMYufA2YP6mGzioV2kDih4glKO ApBQ== X-Gm-Message-State: AGi0PuYk07tBIBjubGydFRGEKVeAP5wId3frBpoInS69o5sb08UKuaDL ufjl+cVMIbujbtpKXkhMbZ0= X-Google-Smtp-Source: APiQypLOL8BqwVPA1RpYH8LBHUM+RBTIsWULv9hfsmarBGHNKon21M+JAtfhMf0+D/R+00uEbYnrZQ== X-Received: by 2002:adf:cc81:: with SMTP id p1mr36049277wrj.372.1588088254520; Tue, 28 Apr 2020 08:37:34 -0700 (PDT) Received: from CBGR90WXYV0 ([54.239.6.187]) by smtp.gmail.com with ESMTPSA id w10sm27108845wrg.52.2020.04.28.08.37.33 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Apr 2020 08:37:33 -0700 (PDT) From: Paul Durrant X-Google-Original-From: "Paul Durrant" To: "'Julien Grall'" , References: <20200407173847.1595-1-paul@xen.org> <20200407173847.1595-5-paul@xen.org> <7f0821ed-34e8-2a63-aaab-bf781fdfb9e7@xen.org> In-Reply-To: <7f0821ed-34e8-2a63-aaab-bf781fdfb9e7@xen.org> Subject: RE: [PATCH v2 4/5] common/domain: add a domain context record for shared_info... Date: Tue, 28 Apr 2020 16:37:32 +0100 Message-ID: <001601d61d72$efb23840$cf16a8c0$@xen.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 16.0 Content-Language: en-gb Thread-Index: AQIOC3/NwyZzJjhdRz0oBcI7Is/lxwI2behTA1TXHdCn8nRy4A== X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Reply-To: paul@xen.org Cc: 'Stefano Stabellini' , 'Wei Liu' , 'Andrew Cooper' , 'Paul Durrant' , 'Ian Jackson' , 'George Dunlap' , 'Jan Beulich' Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" > -----Original Message----- > From: Julien Grall > Sent: 20 April 2020 18:35 > To: Paul Durrant ; xen-devel@lists.xenproject.org > Cc: Paul Durrant ; Ian Jackson ; Wei Liu ; > Andrew Cooper ; George Dunlap ; Jan Beulich > ; Stefano Stabellini > Subject: Re: [PATCH v2 4/5] common/domain: add a domain context record for shared_info... > > Hi Paul, > > On 07/04/2020 18:38, Paul Durrant wrote: > > ... and update xen-domctx to dump some information describing the record. > > > > Signed-off-by: Paul Durrant > > --- > > Cc: Ian Jackson > > Cc: Wei Liu > > Cc: Andrew Cooper > > Cc: George Dunlap > > Cc: Jan Beulich > > Cc: Julien Grall > > Cc: Stefano Stabellini > > > > v2: > > - Drop the header change to define a 'Xen' page size and instead use a > > variable length struct now that the framework makes this is feasible > > - Guard use of 'has_32bit_shinfo' in common code with CONFIG_COMPAT > > --- > > tools/misc/xen-domctx.c | 11 ++++++ > > xen/common/domain.c | 81 +++++++++++++++++++++++++++++++++++++++ > > xen/include/public/save.h | 10 ++++- > > 3 files changed, 101 insertions(+), 1 deletion(-) > > > > diff --git a/tools/misc/xen-domctx.c b/tools/misc/xen-domctx.c > > index d663522a8b..a8d3922321 100644 > > --- a/tools/misc/xen-domctx.c > > +++ b/tools/misc/xen-domctx.c > > @@ -59,6 +59,16 @@ static void dump_header(struct domain_save_descriptor *desc) > > off += desc->length; > > } > > > > +static void dump_shared_info(struct domain_save_descriptor *desc) > > +{ > > + DOMAIN_SAVE_TYPE(SHARED_INFO) s; > > + READ(s); > > + printf(" SHARED_INFO: field_width %u buffer size: %lu\n", > > + s.field_width, desc->length - sizeof(s)); > > + > > + off += desc->length; > > +} > > + > > static void dump_end(struct domain_save_descriptor *desc) > > { > > DOMAIN_SAVE_TYPE(END) e; > > @@ -125,6 +135,7 @@ int main(int argc, char **argv) > > switch (desc.typecode) > > { > > case DOMAIN_SAVE_CODE(HEADER): dump_header(&desc); break; > > + case DOMAIN_SAVE_CODE(SHARED_INFO): dump_shared_info(&desc); break; > > case DOMAIN_SAVE_CODE(END): dump_end(&desc); return 0; > > default: > > printf("Unknown type %u: skipping\n", desc.typecode); > > diff --git a/xen/common/domain.c b/xen/common/domain.c > > index 3dcd73f67c..8b72462e07 100644 > > --- a/xen/common/domain.c > > +++ b/xen/common/domain.c > > @@ -33,6 +33,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > #include > > @@ -1646,6 +1647,86 @@ int continue_hypercall_on_cpu( > > return 0; > > } > > > > +static int save_shared_info(const struct vcpu *v, struct domain_context *c, > > + bool dry_run) > > +{ > > + struct domain *d = v->domain; > > + struct domain_shared_info_context ctxt = {}; > > + size_t hdr_size = offsetof(typeof(ctxt), buffer); > > + size_t size = hdr_size + PAGE_SIZE; > > + int rc; > > + > > + rc = DOMAIN_SAVE_BEGIN(SHARED_INFO, c, v, size); > > + if ( rc ) > > + return rc; > > + > > + if ( !dry_run ) > > NIT: I think the if is not necessary here as you don't skip that much code. > I know, but it is illustrative so I'd rather keep it. > > + ctxt.field_width = > > +#ifdef CONFIG_COMPAT > > + has_32bit_shinfo(d) ? 4 : > > +#endif > > + 8; > > + > > + rc = domain_save_data(c, &ctxt, hdr_size); > > + if ( rc ) > > + return rc; > > + > > + rc = domain_save_data(c, d->shared_info, PAGE_SIZE); > > + if ( rc ) > > + return rc; > > + > > + return domain_save_end(c); > > +} > > + > > +static int load_shared_info(struct vcpu *v, struct domain_context *c) > > +{ > > + struct domain *d = v->domain; > > + struct domain_shared_info_context ctxt = {}; > > + size_t hdr_size = offsetof(typeof(ctxt), buffer); > > + size_t size = hdr_size + PAGE_SIZE; > > + unsigned int i; > > + int rc; > > + > > + rc = DOMAIN_LOAD_BEGIN(SHARED_INFO, c, v, size, true); > > + if ( rc ) > > + return rc; > > + > > + rc = domain_load_data(c, &ctxt, hdr_size); > > + if ( rc ) > > + return rc; > > + > > + for ( i = 0; i < ARRAY_SIZE(ctxt.pad); i++ ) > > + if ( ctxt.pad[i] ) > > + return -EINVAL; > > + > > + switch ( ctxt.field_width ) > > + { > > +#ifdef CONFIG_COMPAT > > + case 4: > > + d->arch.has_32bit_shinfo = 1; > > + break; > > +#endif > > + case 8: > > +#ifdef CONFIG_COMPAT > > + d->arch.has_32bit_shinfo = 0; > > +#endif > > + break; > > + > > + default: > > + rc = -EINVAL; > > + break; > > + } > > + > > + rc = domain_load_data(c, d->shared_info, PAGE_SIZE); > > + if ( rc ) > > + return rc; > > + > > + return domain_load_end(c); > > +} > > + > > +DOMAIN_REGISTER_SAVE_RESTORE(SHARED_INFO, false, save_shared_info, > > + load_shared_info); > > + > > /* > > * Local variables: > > * mode: C > > diff --git a/xen/include/public/save.h b/xen/include/public/save.h > > index 7e5f8752bd..ed994a8765 100644 > > --- a/xen/include/public/save.h > > +++ b/xen/include/public/save.h > > @@ -79,6 +79,14 @@ 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 field_width; > > + uint8_t pad[7]; > > + uint8_t buffer[]; /* Implementation specific size */ > > I would recommend to use buffer[XEN_FLEX_ARRAY_DIM]. > Ok. Paul > Cheers, > > -- > Julien Grall