From mboxrd@z Thu Jan 1 00:00:00 1970 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=-17.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 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 CBE19C2D0E4 for ; Tue, 24 Nov 2020 16:56:23 +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 48DDA206D9 for ; Tue, 24 Nov 2020 16:56:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="lnjdMv0G" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 48DDA206D9 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.36592.68549 (Exim 4.92) (envelope-from ) id 1khbbe-000489-4H; Tue, 24 Nov 2020 16:55:54 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 36592.68549; Tue, 24 Nov 2020 16:55:54 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1khbbe-000482-1J; Tue, 24 Nov 2020 16:55:54 +0000 Received: by outflank-mailman (input) for mailman id 36592; Tue, 24 Nov 2020 16:55:52 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1khbbc-00047x-Dg for xen-devel@lists.xenproject.org; Tue, 24 Nov 2020 16:55:52 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id c7fe34b5-944a-4837-b013-ae874e18f264; Tue, 24 Nov 2020 16:55:51 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 4A94EAC77; Tue, 24 Nov 2020 16:55:50 +0000 (UTC) Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1khbbc-00047x-Dg for xen-devel@lists.xenproject.org; Tue, 24 Nov 2020 16:55:52 +0000 X-Inumbo-ID: c7fe34b5-944a-4837-b013-ae874e18f264 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id c7fe34b5-944a-4837-b013-ae874e18f264; Tue, 24 Nov 2020 16:55:51 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1606236950; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ufwAhUrq/oOi8AfhpClhMYTGxOOsopGr05vHJJZQ93o=; b=lnjdMv0GXFoaIdP5g911w7kldh0cp6BlW+1aWwErtxGT35dJwpyDptFHoLiF4nH7HiqpEI flDkw9akTG6LoVIY57WC9tT0Mr4zRcSk1fftSI25PdQH4Lq0ckSHURA80jFrU4Tw4hfXk+ fs+PAlLyqFo3HNKosUEbJyipwaS8Nrg= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 4A94EAC77; Tue, 24 Nov 2020 16:55:50 +0000 (UTC) Subject: Re: [PATCH v2 08/12] viridian: add ExProcessorMasks variants of the flush hypercalls To: Paul Durrant Cc: Paul Durrant , Wei Liu , Andrew Cooper , =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= , xen-devel@lists.xenproject.org References: <20201120094900.1489-1-paul@xen.org> <20201120094900.1489-9-paul@xen.org> From: Jan Beulich Message-ID: <1b8d71bc-5f6d-b458-e0fc-2a2f0d29ddd8@suse.com> Date: Tue, 24 Nov 2020 17:55:49 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: <20201120094900.1489-9-paul@xen.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 20.11.2020 10:48, Paul Durrant wrote: > From: Paul Durrant > > The Microsoft Hypervisor TLFS specifies variants of the already implemented > HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE/LIST hypercalls that take a 'Virtual > Processor Set' as an argument rather than a simple 64-bit mask. > > This patch adds a new hvcall_flush_ex() function to implement these > (HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE/LIST_EX) hypercalls. This makes use of > new helper functions, hv_vpset_nr_banks() and hv_vpset_to_vpmask(), to > determine the size of the Virtual Processor Set (so it can be copied from > guest memory) and parse it into hypercall_vpmask (respectively). > > NOTE: A guest should not yet issue these hypercalls as 'ExProcessorMasks' > support needs to be advertised via CPUID. This will be done in a > subsequent patch. > > Signed-off-by: Paul Durrant Just a couple of cosmetic remarks, apart from them this looks good to me, albeit some of the size calculations are quite, well, involved. I guess like with most parts if this series, in the end Wei will need to give his ack. > --- a/xen/arch/x86/hvm/viridian/viridian.c > +++ b/xen/arch/x86/hvm/viridian/viridian.c > @@ -576,6 +576,70 @@ static unsigned int vpmask_nr(const struct hypercall_vpmask *vpmask) > return bitmap_weight(vpmask->mask, HVM_MAX_VCPUS); > } > > +#define HV_VPSET_BANK_SIZE \ > + sizeof_field(struct hv_vpset, bank_contents[0]) > + > +#define HV_VPSET_SIZE(banks) \ > + (sizeof(struct hv_vpset) + (banks * HV_VPSET_BANK_SIZE)) Personally I think this would be better done using offsetof(struct hv_vpset, bank_contents), but you're the maintainer. However, "banks" wants parenthesizing, just in case. > +#define HV_VPSET_MAX_BANKS \ > + (sizeof_field(struct hv_vpset, valid_bank_mask) * 8) > + > +struct hypercall_vpset { > + union { > + struct hv_vpset set; > + uint8_t pad[HV_VPSET_SIZE(HV_VPSET_MAX_BANKS)]; > + }; > +}; A struct with just a union as member could be expressed as a simple union - any reason you prefer the slightly more involved variant? > +static DEFINE_PER_CPU(struct hypercall_vpset, hypercall_vpset); > + > +static unsigned int hv_vpset_nr_banks(struct hv_vpset *vpset) > +{ > + return hweight64(vpset->valid_bank_mask); > +} > + > +static uint16_t hv_vpset_to_vpmask(struct hv_vpset *set, const? > @@ -656,6 +720,78 @@ static int hvcall_flush(union hypercall_input *input, > return 0; > } > > +static int hvcall_flush_ex(union hypercall_input *input, const again? > + union hypercall_output *output, > + unsigned long input_params_gpa, > + unsigned long output_params_gpa) Mainly for cosmetic reasons and to be in sync with hvm_copy_from_guest_phys()'s respective parameter, perhaps both would better be paddr_t? Jan