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=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no 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 39FCDC38A24 for ; Thu, 7 May 2020 07:40:15 +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 056BD2078C for ; Thu, 7 May 2020 07:40:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 056BD2078C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.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 1jWb8O-0006Kp-Ga; Thu, 07 May 2020 07:39:56 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jWb8N-0006Kk-Ji for xen-devel@lists.xenproject.org; Thu, 07 May 2020 07:39:55 +0000 X-Inumbo-ID: f13b0fc6-9035-11ea-b9cf-bc764e2007e4 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id f13b0fc6-9035-11ea-b9cf-bc764e2007e4; Thu, 07 May 2020 07:39:54 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 17780ADD2; Thu, 7 May 2020 07:39:56 +0000 (UTC) Subject: Re: [PATCH v2 1/5] xen/common: introduce a new framework for save/restore of 'domain' context To: paul@xen.org References: <20200407173847.1595-1-paul@xen.org> <20200407173847.1595-2-paul@xen.org> <009601d623c5$9547abc0$bfd70340$@xen.org> <63772836-3b3c-753a-18e5-d9fe3a6666a2@suse.com> <00ab01d62441$ef2630e0$cd7292a0$@xen.org> From: Jan Beulich Message-ID: <4ac9fc33-393d-d550-c656-94814d8f5467@suse.com> Date: Thu, 7 May 2020 09:39:52 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <00ab01d62441$ef2630e0$cd7292a0$@xen.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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: , Cc: 'Stefano Stabellini' , 'Julien Grall' , 'Wei Liu' , 'Andrew Cooper' , 'Paul Durrant' , 'Ian Jackson' , 'George Dunlap' , xen-devel@lists.xenproject.org, 'Volodymyr Babchuk' , =?UTF-8?B?J1JvZ2VyIFBhdSBNb25uw6kn?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" On 07.05.2020 09:34, Paul Durrant wrote: >> From: Jan Beulich >> Sent: 07 May 2020 08:22 >> >> On 06.05.2020 18:44, Paul Durrant wrote: >>>> From: Jan Beulich >>>> Sent: 29 April 2020 12:02 >>>> >>>> On 07.04.2020 19:38, Paul Durrant wrote: >>>>> +int domain_load_begin(struct domain_context *c, unsigned int tc, >>>>> + const char *name, const struct vcpu *v, size_t len, >>>>> + bool exact) >>>>> +{ >>>>> + if ( c->log ) >>>>> + gdprintk(XENLOG_INFO, "%pv load: %s (%lu)\n", v, name, >>>>> + (unsigned long)len); >>>>> + >>>>> + BUG_ON(tc != c->desc.typecode); >>>>> + BUG_ON(v->vcpu_id != c->desc.vcpu_id); >>>>> + >>>>> + if ( (exact && (len != c->desc.length)) || >>>>> + (len < c->desc.length) ) >>>>> + return -EINVAL; >>>> >>>> How about >>>> >>>> if ( exact ? len != c->desc.length >>>> : len < c->desc.length ) >>>> >>> >>> Yes, that doesn't look too bad. >>> >>>> ? I'm also unsure about the < - don't you mean > instead? Too >>>> little data would be compensated by zero padding, but too >>>> much data can't be dealt with. But maybe I'm getting the sense >>>> of len wrong ... >>> >>> I think the < is correct. The caller needs to have at least enough >>> space to accommodate the context record. >> >> But this is load, not save - the caller supplies the data. If >> there's less data than can be fit, it'll be zero-extended. If >> there's too much data, the excess you don't know what to do >> with (it might be okay to tolerate it being all zero). >> > > But this is a callback. The outer load function iterates over > the records calling the appropriate hander for each one. Those > handlers then call this function saying how much data they > expect and whether they want exactly that amount, or whether > they can tolerate less (i.e. zero-extend). Hence > len < c->desc.length is an error, because it means the > descriptor contains more data than the hander knows how to > handle. Oh, I see - "But maybe I'm getting the sense of len wrong ..." then indeed applies. Any thoughts on tolerating the excess data being zero? Jan