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=-2.0 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, 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 38973C2BA19 for ; Wed, 15 Apr 2020 13:26:59 +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 098CE20575 for ; Wed, 15 Apr 2020 13:26:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=xen.org header.i=@xen.org header.b="CC0u9Rzu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 098CE20575 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org 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 1jOi41-0003Ja-Dq; Wed, 15 Apr 2020 13:26:49 +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.89) (envelope-from ) id 1jOi40-0003JU-4O for xen-devel@lists.xenproject.org; Wed, 15 Apr 2020 13:26:48 +0000 X-Inumbo-ID: c164df40-7f1c-11ea-8a4d-12813bfff9fa Received: from mail.xenproject.org (unknown [104.130.215.37]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id c164df40-7f1c-11ea-8a4d-12813bfff9fa; Wed, 15 Apr 2020 13:26:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type:In-Reply-To: MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=x41VIlJivgIAl7su1MrknNaAlw7LUAGcP9Z9yp7xm+g=; b=CC0u9RzuO/gvCYdJuHP9wQGQJp ErJHn3u5zLzJvSDFS7aF22m2sWUTw9K+gIVVtPj37wEImsmOPFnBPIMV+M/Dt7hyLOj7jMJPzldEk hI57KuEkwcig+HVM7QEPPG+70HxM2+QNwYSBwRGh7VyrsdF6Xh73dE6uj77tHoItA5tM=; Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jOi3w-0003mu-0b; Wed, 15 Apr 2020 13:26:44 +0000 Received: from [54.239.6.177] (helo=a483e7b01a66.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1jOi3v-0006iK-Px; Wed, 15 Apr 2020 13:26:43 +0000 Subject: Re: [PATCH 01/12] xen: introduce xen_dom_flags To: Jan Beulich , Stefano Stabellini References: <20200415010255.10081-1-sstabellini@kernel.org> From: Julien Grall Message-ID: <992bade3-7717-62b0-06a8-88c9dc15937e@xen.org> Date: Wed, 15 Apr 2020 14:26:41 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit 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: Wei Liu , George Dunlap , andrew.cooper3@citrix.com, Ian Jackson , Dario Faggioli , xen-devel@lists.xenproject.org, Stefano Stabellini , Volodymyr_Babchuk@epam.com, =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" On 15/04/2020 10:12, Jan Beulich wrote: > On 15.04.2020 03:02, Stefano Stabellini wrote: >> We are passing an extra special boolean flag at domain creation to >> specify whether we want to the domain to be privileged (i.e. dom0) or >> not. Another flag will be introduced later in this series. >> >> Introduce a new struct xen_dom_flags and move the privileged flag to it. >> Other flags will be added to struct xen_dom_flags. > > I'm unsure whether introducing a 2nd structure is worth it here. > We could as well define some internal-use-only flags for > struct xen_domctl_createdomain's respective field. +1. > >> --- a/xen/arch/x86/domain.c >> +++ b/xen/arch/x86/domain.c >> @@ -529,7 +529,8 @@ static bool emulation_flags_ok(const struct domain *d, uint32_t emflags) >> } >> >> int arch_domain_create(struct domain *d, >> - struct xen_domctl_createdomain *config) >> + struct xen_domctl_createdomain *config, >> + struct xen_dom_flags *flags) > > const (also elsewhere)? > >> --- a/xen/arch/x86/setup.c >> +++ b/xen/arch/x86/setup.c >> @@ -706,6 +706,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) >> .max_maptrack_frames = -1, >> }; >> const char *hypervisor_name; >> + struct xen_dom_flags flags = { !pv_shim }; > > Here and elsewhere please use field designators right away, even if > there's only a single field now. > >> @@ -363,7 +363,7 @@ struct domain *domain_create(domid_t domid, >> ASSERT(is_system_domain(d) ? config == NULL : config != NULL); >> >> /* Sort out our idea of is_control_domain(). */ >> - d->is_privileged = is_priv; >> + d->is_privileged = flags ? flags->is_priv : false; > > Stray double blanks. > >> --- a/xen/common/domctl.c >> +++ b/xen/common/domctl.c >> @@ -364,6 +364,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl) >> bool_t copyback = 0; >> struct xen_domctl curop, *op = &curop; >> struct domain *d; >> + struct xen_dom_flags flags ={ false }; > > Missing blank. > >> --- a/xen/include/xen/domain.h >> +++ b/xen/include/xen/domain.h >> @@ -63,8 +63,13 @@ void arch_vcpu_destroy(struct vcpu *v); >> int map_vcpu_info(struct vcpu *v, unsigned long gfn, unsigned offset); >> void unmap_vcpu_info(struct vcpu *v); >> >> +struct xen_dom_flags { >> + bool is_priv; > > Use a single bit bitfield instead? May even want to consider passing > this struct by value then. This is an alternative if extending xen_domctl_createdomain is not a solution. The bitfield is easier to extend because we don't need to create a new field for each flag in struct domain. Cheers, -- Julien Grall