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=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,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 72C68C2D0E4 for ; Tue, 24 Nov 2020 18:41:01 +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 D1705206D8 for ; Tue, 24 Nov 2020 18:41:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="drD5GkCS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D1705206D8 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 list by lists.xenproject.org with outflank-mailman.36786.68810 (Exim 4.92) (envelope-from ) id 1khdF2-0007jC-6x; Tue, 24 Nov 2020 18:40:40 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 36786.68810; Tue, 24 Nov 2020 18:40:40 +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 1khdF2-0007j5-3v; Tue, 24 Nov 2020 18:40:40 +0000 Received: by outflank-mailman (input) for mailman id 36786; Tue, 24 Nov 2020 18:40:39 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1khdF1-0007j0-Kl for xen-devel@lists.xenproject.org; Tue, 24 Nov 2020 18:40:39 +0000 Received: from mail-wm1-x331.google.com (unknown [2a00:1450:4864:20::331]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 45289449-690e-4326-b0ac-a1da34df2809; Tue, 24 Nov 2020 18:40:38 +0000 (UTC) Received: by mail-wm1-x331.google.com with SMTP id w24so3950248wmi.0 for ; Tue, 24 Nov 2020 10:40:38 -0800 (PST) Received: from CBGR90WXYV0 (54-240-197-232.amazon.com. [54.240.197.232]) by smtp.gmail.com with ESMTPSA id q66sm7533447wme.6.2020.11.24.10.40.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Nov 2020 10:40:37 -0800 (PST) Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1khdF1-0007j0-Kl for xen-devel@lists.xenproject.org; Tue, 24 Nov 2020 18:40:39 +0000 X-Inumbo-ID: 45289449-690e-4326-b0ac-a1da34df2809 Received: from mail-wm1-x331.google.com (unknown [2a00:1450:4864:20::331]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 45289449-690e-4326-b0ac-a1da34df2809; Tue, 24 Nov 2020 18:40:38 +0000 (UTC) Received: by mail-wm1-x331.google.com with SMTP id w24so3950248wmi.0 for ; Tue, 24 Nov 2020 10:40:38 -0800 (PST) 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:thread-index :content-language; bh=xVMrEUi82jOaWz0MJruX61qpO0RoLueRqr3pVIhR4Cg=; b=drD5GkCS69gCpKabzmP2fuT1G/hrFF0qpR3ZPu9kw/geTe9rfR+BgudS9nIFeiBtTF vlPJIY+GagP2dHMAhAze6reyi+Xcgsxn2F82pT8vvDIsw5ZazERD/eFKj14SmUieNTlx KZo7x+l+kyUlJngbNkiJa8ETwKIja364otFQtc4G9NoTG1vW8f8vRXN0P8KsJhqsuwh6 G409CgujLGK/ugRQAjG275YS2hnXM1a+Ei5W8Ew8sDRhKNchalSL21jeYjRYo/r9ukOJ VSeGSG68dFnGObZnmBOqtUOxArP4ELiXMEqoXbV3wvdu79Y2WXHVlH2bDOgWloVD+evA iKqA== 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 :thread-index:content-language; bh=xVMrEUi82jOaWz0MJruX61qpO0RoLueRqr3pVIhR4Cg=; b=A1qODfOnBtQU/99EO3tuH3gPIJUpRuuQiYJvYYsP12vf8S8G2fd6prGrm4YlqepTCA 8qPhfNZqygiplpGiFRDUegPdl5yCsz5KRuOVKCWAbbO2xjkBsFysDZzbpSRA0RxC1oBF hYUUyiDKlOd/NB+ijvH8vKC4N5682JtObtrLMFGsgvJmB+gmEImIHlg/H2zvX0ZFrQZt +n5Sp6lSfUWWSyHnw6VY9WXBfpolKOkyhj1XWjMaHQgEKWGZaPJa6C9lfumESJd/qzyU YI3huiODIyuQGjYTdXIDHbuBqz7DmTHFyaJkC45lfiZWQf37bL7ziogsemhUUulsrhJL xoqg== X-Gm-Message-State: AOAM533i/cYjqxuZ9sE8IGV+FFQku6d7fwODy5Mt+GxJiN20Ad3EJoec QI/rtfc6H1mmsUtfhNiSWmU= X-Google-Smtp-Source: ABdhPJz2wq7G9BCrob+7dJcpXgP9tx15CHmCavNyi7Z8p9yg+hLdvXssdTEDk17i+o1WFWfo5CJ2Xw== X-Received: by 2002:a1c:e907:: with SMTP id q7mr6039192wmc.161.1606243237862; Tue, 24 Nov 2020 10:40:37 -0800 (PST) Received: from CBGR90WXYV0 (54-240-197-232.amazon.com. [54.240.197.232]) by smtp.gmail.com with ESMTPSA id q66sm7533447wme.6.2020.11.24.10.40.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Nov 2020 10:40:37 -0800 (PST) From: Paul Durrant X-Google-Original-From: "Paul Durrant" Reply-To: To: "'Jan Beulich'" Cc: "'Paul Durrant'" , "'Wei Liu'" , "'Andrew Cooper'" , =?UTF-8?Q?'Roger_Pau_Monn=C3=A9'?= , References: <20201120094900.1489-1-paul@xen.org> <20201120094900.1489-9-paul@xen.org> <1b8d71bc-5f6d-b458-e0fc-2a2f0d29ddd8@suse.com> In-Reply-To: <1b8d71bc-5f6d-b458-e0fc-2a2f0d29ddd8@suse.com> Subject: RE: [PATCH v2 08/12] viridian: add ExProcessorMasks variants of the flush hypercalls Date: Tue, 24 Nov 2020 18:40:36 -0000 Message-ID: <006101d6c291$4d12ea20$e738be60$@xen.org> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQH2MKAKjLdIZTWPg9fOgT90SKBicQEWVvALAlYgE+upfVyzYA== Content-Language: en-gb > -----Original Message----- > From: Jan Beulich > Sent: 24 November 2020 16:56 > To: Paul Durrant > Cc: Paul Durrant ; Wei Liu ; Andrew = Cooper > ; Roger Pau Monn=C3=A9 = ; xen-devel@lists.xenproject.org > Subject: Re: [PATCH v2 08/12] viridian: add ExProcessorMasks variants = of the flush hypercalls >=20 > 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 >=20 > 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. >=20 > > --- 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)) >=20 > 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. >=20 No, I actually prefer using offsetof() and yes I do indeed need to = parenthesize 'banks'. > > +#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)]; > > + }; > > +}; >=20 > A struct with just a union as member could be expressed as a simple > union - any reason you prefer the slightly more involved variant? >=20 Not really... it's only that it was a struct in the original patch. I'll = change to using a union. > > +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, >=20 > const? >=20 Ok. > > @@ -656,6 +720,78 @@ static int hvcall_flush(union hypercall_input = *input, > > return 0; > > } > > > > +static int hvcall_flush_ex(union hypercall_input *input, >=20 > const again? >=20 True, but I'll need to go back and do that for the others too. > > + union hypercall_output *output, > > + unsigned long input_params_gpa, > > + unsigned long output_params_gpa) >=20 > 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? >=20 Ok. Again I'll fix the prior patches to match. Paul > Jan