Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id BC8151076370 for ; Wed, 1 Apr 2026 05:58:41 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.1269659.1558581 (Exim 4.92) (envelope-from ) id 1w7oan-0000EO-6E; Wed, 01 Apr 2026 05:58:17 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 1269659.1558581; Wed, 01 Apr 2026 05:58:17 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w7oan-0000E7-1F; Wed, 01 Apr 2026 05:58:17 +0000 Received: by outflank-mailman (input) for mailman id 1269659; Wed, 01 Apr 2026 05:58:15 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w7oak-0000E1-T5 for xen-devel@lists.xenproject.org; Wed, 01 Apr 2026 05:58:15 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1w7oak-00AZ8R-8p for xen-devel@lists.xenproject.org; Wed, 01 Apr 2026 07:58:14 +0200 Received: from [10.42.69.10] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 69ccb3dd-2eae-0a2a0a5409dd-0a2a450a8f5a-48 for ; Wed, 01 Apr 2026 07:58:14 +0200 Received: from [209.85.128.49] (helo=mail-wm1-f49.google.com) by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.55.2) (envelope-from ) id 69ccb3f5-1772-0a2a450a0019-d1558031a8f4-3 for ; Wed, 01 Apr 2026 07:58:13 +0200 Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-482f454be5bso5224535e9.0 for ; Tue, 31 Mar 2026 22:58:13 -0700 (PDT) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4887adc52b2sm35212055e9.12.2026.03.31.22.58.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 31 Mar 2026 22:58:12 -0700 (PDT) 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" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=suse.com header.i="@suse.com" header.h="Content-Transfer-Encoding:In-Reply-To:Autocrypt:From:Content-Language:References:Cc:To:Subject:User-Agent:MIME-Version:Date:Message-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1775023093; x=1775627893; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=cKMT8KyzZ1Mt9osAqCAjw+gKQXf80yubGZVZ0kKFnWo=; b=OEApTtg7Uni/BnVUZzcnKCg5RR0hRvEsIVyK8MZXDf4gVqbNtXmMEF8CX3vVYk3tt3 +TbJehgElfA5hjRyW0pe9vQyizk7ojpCsPDHmvevAPtoxL3/1327FomJfF8/0M3EPFz2 DPQOBIwcLYjg2e2E2YXFTHH1SmKpzrLAbmSGzeoyYhbeO9D6fsbMyn1ureWwWFRxrDjq Xo3Q6v/BogXnOqg5RFCIlpG55RK0TbS8EbdJPLvH7oUBfxTj5SNGiRkEGmb2fIniTeD8 62Vs4pIWx9okyyjE7aZEj8Wyakn4a13Ccm9KLPPebAyO+NQc55dPPUTrBZxbM662HniH nCfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775023093; x=1775627893; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=cKMT8KyzZ1Mt9osAqCAjw+gKQXf80yubGZVZ0kKFnWo=; b=IN+aetq+vV5cfoytHno0a7p+TkXhKMCP0uUZgJ5uTdvBoNFpEXM9RWYrLxdDAI2OoI S+ILeVydU38SV5gHcK+6cKxk4MJdmwSczmaqifOqmtVEz56j+RhaBA8qwyeETt8/I3NL /041wNuJpVKR3QZ7EZ2XZBV6l+Eluo5pXgzRvEXxyzJvmGBrMCBk4MJEJSjJCTj0Tkmq mJHFZLK6UA+B0938TkGXl5VteFH0lPdGRpiaF3IThtIp9lid0IeMJ0YnQJFOtJLq342R BnfnMDADvGLRfFMb4zfmeIpWRNl7vPoJUGzqlvlR+UJDq8xJoE1ALjEq3dNGLghykZW7 Nrng== X-Forwarded-Encrypted: i=1; AJvYcCWd1tUVoHUo01wQDrP/X96na4iKkKSrHBp92M83ZWbB9kqwnbGzEdKG8AiYaBa6fpvCBs1+r/634yc=@lists.xenproject.org X-Gm-Message-State: AOJu0Yw1vqszRs+DYC8ai3TsLYaZ2Sei9ThB/KwvFf/w4OPqeMhJcp3H KRkpH7sbGUTEsKl1flj865ycUAGhdP4ckwD1Wv8F5kn5Au6xsQMQI+IIhQ911S/KaA== X-Gm-Gg: ATEYQzzVVPRxIV3BvF3IZhh/0gM4M2A2DtfnaHQjhT9atbT4hwe4ONqYkL/5npUVpCR we3tregbQjNmUCcM1r8nKPmblKdpgIdFjJjegqQittDUxaYovo1gIrvqv64PKgktWGQH3266eGB VILgixe4kaXJ0Verg8Qgog49ISJwJJF04aiyWeSXqt3SHLNe1zDAT0ZNIHAIb+LPdtQJ/v16IZT KWDAr0WMsj56dTqM1Gkqr1HgLvZDYjfK7a2NpYLe/4bSnb7e/xunfDSoAIPaLZkAbvJjbgdtGwC 8InLE2WMbUQ0q5pavUu6h6g+uoP7zeoIQvoJBkGzL/uT1pm3gVpDjNwLL0bnZs2ExNkieC+o82g c3FJ23yUDCeBsLzau/GXY38H3WkQovZ0xDWb5BSxd55rWg9zmBk168svmG/pwJjH/8A92e5AGPd wXMd41Chfv1R6GjheNMG8e1yovMNi9rTIgUp15RjGtmXYDb+ixPz7TwKK527KqkpdO17/UYQSxR JDzYwCUwFNsVsHusnHOyC18XA== X-Received: by 2002:a05:600c:8b77:b0:485:3cef:d6ea with SMTP id 5b1f17b1804b1-488835bc362mr32141985e9.13.1775023093070; Tue, 31 Mar 2026 22:58:13 -0700 (PDT) Message-ID: Date: Wed, 1 Apr 2026 07:58:11 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 07/11] xen: move domain_use_host_layout() to common code To: Oleksii Kurochko Cc: Romain Caritey , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Andrew Cooper , Anthony PERARD , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= , xen-devel@lists.xenproject.org References: <533d01db2b36b8357cd87e99a64a6e66dbdd1db4.1774281309.git.oleksii.kurochko@gmail.com> <6df9470e-4969-48d1-bf0c-c6569a5e5577@suse.com> <57581b7d-cb9f-444c-9321-63b2fc3d09f0@gmail.com> Content-Language: en-US From: Jan Beulich Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZg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WDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-purgate-ID: tlsNG-4011c0/1775023093-BC882900-80AF429B/0/0 X-purgate-type: clean X-purgate-size: 3959 On 31.03.2026 18:32, Oleksii Kurochko wrote: > On 3/31/26 5:53 PM, Jan Beulich wrote: >> On 31.03.2026 17:20, Oleksii Kurochko wrote: >>> On 3/30/26 5:13 PM, Jan Beulich wrote: >>>> On 23.03.2026 17:29, Oleksii Kurochko wrote: >>>>> domain_use_host_layout() is not really architecture-specific, so move it >>>>> from the Arm header to the common header xen/domain.h and provide a common >>>>> implementation in xen/common/domain.c. domain_use_host_layout() potentially >>>>> is needed for x86 [1]. >>>> >>>> No matter that this may indeed be true, ... >>>> >>>>> Turn the macro into a function to avoid header dependency issues. >>>> >>>> ... this introduces unreachable code on x86, i.e. a Misra rule 2.1 violation. >>> >>> Do we have some deviation tag for such cases when the code temporary >>> isn't used? >> >> I'm sorry, but it'll take me about as long as you to find out. > > Sure, I will take a look. I just thought that maybe you have a solution > already just in your head. Well, I do: Don't make this an out-of-line function. > I wonder >> about "temporary" though: Do you have a clear understanding as to when >> that will change? > > No, I don't. As Stefano mentioned they will need this function one day. > Another option we could use ifndef x86 or ifdef DOM0_LESS and then when > someone will really need it on x86, this ifdef will be dropped. I don't > know if it is better solution. > > It seems like the best one solution will still make a try to make > declare this function as macro. Or an inline function. There's nothing ... >>>>> @@ -2544,6 +2544,12 @@ void thaw_domains(void) >>>>> >>>>> #endif /* CONFIG_SYSTEM_SUSPEND */ >>>>> >>>>> +bool domain_use_host_layout(struct domain *d) >>>>> +{ >>>>> + return is_domain_direct_mapped(d) || >>>>> + (paging_mode_translate(d) && is_hardware_domain(d)); >>>>> +} >>>> >>>> The placement of paging_mode_translate() doesn't match ... >>>> >>>>> --- a/xen/include/xen/domain.h >>>>> +++ b/xen/include/xen/domain.h >>>>> @@ -62,6 +62,22 @@ void domid_free(domid_t domid); >>>>> #define is_domain_direct_mapped(d) ((d)->cdf & CDF_directmap) >>>>> #define is_domain_using_staticmem(d) ((d)->cdf & CDF_staticmem) >>>>> >>>>> +/* >>>>> + * Is the auto-translated domain using the host memory layout? >>>>> + * >>>>> + * domain_use_host_layout() is always False for PV guests. >>>> >>>> ... the description of the function. >>> >>> But why the placement should be different? >> >> If you focus on auto-translated, then imo paging_mode_translate() >> better would guard everything. > > Then it make sense to do in the following way: > bool domain_use_host_layout(struct domain *d) > { > - return is_domain_direct_mapped(d) || > - (paging_mode_translate(d) && is_hardware_domain(d)); > + return paging_mode_translate(d) && > + (is_domain_direct_mapped(d) || is_hardware_domain(d)); > } ... in here which clearly speaks against doing so. And yes, this is what I was asking for (with the function parameter also suitably constified). >>> So if domain_use_host_layout() is fully depends on >>> paging_mode_translate(d) && is_hardware_domain(d) and for which >>> paging_mode_translate() is false if it is PV guest. >>> Thereby domain_use_host_layout() is false too. >>> >>>> >>>> Further, the first sentence above suggests the caller has to check >>>> paging_mode_translate() before calling, which as per the implementation >>>> clearly isn't the intention. >>> >>> Sorry, I don't follow you here. >> >> By starting the comment with "Is the auto-translated domain using", you >> imply the caller checked for that aspect already. At least the way I >> read it. > > My understanding was that it is an explanation what function is checking. For that you'd want to omit "auto-translated" from the first sentence, imo. Jan