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.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 C8791C2BA19 for ; Tue, 21 Apr 2020 05:55:08 +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 9C4CC2071E for ; Tue, 21 Apr 2020 05:55:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9C4CC2071E 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.89) (envelope-from ) id 1jQlrv-0006uQ-G7; Tue, 21 Apr 2020 05:54:51 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jQlru-0006uK-3U for xen-devel@lists.xenproject.org; Tue, 21 Apr 2020 05:54:50 +0000 X-Inumbo-ID: 9c5903b2-8394-11ea-b4f4-bc764e2007e4 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 9c5903b2-8394-11ea-b4f4-bc764e2007e4; Tue, 21 Apr 2020 05:54:49 +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 30384AA55; Tue, 21 Apr 2020 05:54:47 +0000 (UTC) Subject: Re: [PATCH v2 1/2] x86/HVM: expose VM assist hypercall To: Julien Grall , Andrew Cooper References: <51dfb592-2653-738f-6933-9521ffa4fecd@suse.com> <1f463b9e-9629-4ba0-3b7f-373b4bcb5b64@xen.org> From: Jan Beulich Message-ID: <5863d6d0-22cf-7237-a88b-a3a2c4809635@suse.com> Date: Tue, 21 Apr 2020 07:54:46 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <1f463b9e-9629-4ba0-3b7f-373b4bcb5b64@xen.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Wei Liu , Ian Jackson , George Dunlap , "xen-devel@lists.xenproject.org" , =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" On 20.04.2020 19:53, Julien Grall wrote: >> --- a/xen/common/domain.c >> +++ b/xen/common/domain.c >> @@ -1517,20 +1517,23 @@ long do_vcpu_op(int cmd, unsigned int vc >>       return rc; >>   } >>   -#ifdef VM_ASSIST_VALID >> -long vm_assist(struct domain *p, unsigned int cmd, unsigned int type, >> -               unsigned long valid) >> +#ifdef arch_vm_assist_valid > > How about naming the function arch_vm_assist_valid_mask? Certainly a possibility, albeit to me the gain would be marginal and possibly not outweigh the growth in length. Andrew, any preference? >> --- a/xen/include/asm-x86/domain.h >> +++ b/xen/include/asm-x86/domain.h >> @@ -700,6 +700,20 @@ static inline void pv_inject_sw_interrup >>     pv_inject_event(&event); >> } >> +#define PV_VM_ASSIST_VALID  ((1UL << VMASST_TYPE_4gb_segments)        | \ >> +                             (1UL << VMASST_TYPE_4gb_segments_notify) | \ >> +                             (1UL << VMASST_TYPE_writable_pagetables) | \ >> +                             (1UL << VMASST_TYPE_pae_extended_cr3)    | \ >> +                             (1UL << VMASST_TYPE_architectural_iopl)  | \ >> +                             (1UL << VMASST_TYPE_runstate_update_flag)| \ >> +                             (1UL << VMASST_TYPE_m2p_strict)) >> +#define HVM_VM_ASSIST_VALID (1UL << VMASST_TYPE_runstate_update_flag) >> + >> +#define arch_vm_assist_valid(d) \ >> +    (is_hvm_domain(d) ? HVM_VM_ASSIST_VALID \ >> +                      : is_pv_32bit_domain(d) ? (uint32_t)PV_VM_ASSIST_VALID \ > > I understand this is matching the current code, however without > looking at the rest of patch this is not clear why the cast. May > I suggest to add a comment explaining the rationale? Hmm, I can state that the rationale is history. Many of the assists in the low 32 bits are for 32-bit guests only. But we can't start refusing a 64-bit kernel requesting them. The ones in the high 32 bits are, for now, applicable to 64-bit guests only, and have always been refused for 32-bit ones. Imo if anything an explanation on where new bits should be put should go next to the VMASST_TYPE_* definitions in the public header, yet then again the public headers aren't (imo) a good place to put implementation detail comments. Again, Andrew - since you've ack-ed the patch already, any thoughts here either way? Jan