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 355D7C5B549 for ; Mon, 2 Jun 2025 07:17:50 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.1002812.1382198 (Exim 4.92) (envelope-from ) id 1uLzQO-0001nI-GW; Mon, 02 Jun 2025 07:17:36 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 1002812.1382198; Mon, 02 Jun 2025 07:17:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uLzQO-0001nB-DP; Mon, 02 Jun 2025 07:17:36 +0000 Received: by outflank-mailman (input) for mailman id 1002812; Mon, 02 Jun 2025 07:17:35 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uLzQN-0001n5-AB for xen-devel@lists.xenproject.org; Mon, 02 Jun 2025 07:17:35 +0000 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [2a00:1450:4864:20::430]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id a6c71e15-3f81-11f0-b894-0df219b8e170; Mon, 02 Jun 2025 09:17:33 +0200 (CEST) Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-3a50fc7ac4dso79298f8f.0 for ; Mon, 02 Jun 2025 00:17:33 -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 d2e1a72fcca58-747afeabc6asm7211856b3a.53.2025.06.02.00.17.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 02 Jun 2025 00:17:31 -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" X-Inumbo-ID: a6c71e15-3f81-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1748848652; x=1749453452; 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=MBNE0WMUvarYwLkTpc6pA2ckZ9CoSB6Ya1Gn/flLcnA=; b=IOjuXXxILBIN9d9+/yN46u4x+I4tgEOHzB+pShVyoKKmdsLxg9w9+faX+nzeJRf4Nq TZ/TuVHrr5Ilsrt2sYcAp4x47iQvVcsIhn9S91Ieg9LWBIyyXvn4XlNjMxFIdmCDIsLz jLrmSxGEpEWBAVTzjbSUD+NQDQTvley1DRQAyGLzbh39t6dSrnPPcj4g/waNZWkzZo5D P5ubknsqAJ40I0MyGdKCbK8VFBxca6uBkv5/V4gBk1ltFAKafDz3wggqbgxd543L5VmH DHDEyTUmiDZwImNfVDLlL2J318BTU6dTZdEWd2pyNolWdIv2FLD2EUh/6JlZZGEGswJe sW1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748848652; x=1749453452; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=MBNE0WMUvarYwLkTpc6pA2ckZ9CoSB6Ya1Gn/flLcnA=; b=q2W1greYo4xBRESkRfdAhT8EYRWphm9ijYLJhpwjey/mGOTL09hVso0Tp2gg//t6yj q5Gh/6hYefW6Y+DYcNdE9Jw8GH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40:4d3f with SMTP id ffacd0b85a97d-3a4f7aafa70mr10891201f8f.53.1748848652480; Mon, 02 Jun 2025 00:17:32 -0700 (PDT) Message-ID: <31c7faf1-d393-40d5-87f9-1a01d1ab39cb@suse.com> Date: Mon, 2 Jun 2025 09:17:37 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 01/22] x86/include/asm/intel-txt.h: constants and accessors for TXT registers and heap To: Sergii Dmytruk Cc: "Daniel P. Smith" , Ross Philipson , Andrew Cooper , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= , Lukasz Hawrylko , =?UTF-8?Q?Mateusz_M=C3=B3wka?= , trenchboot-devel@googlegroups.com, xen-devel@lists.xenproject.org References: Content-Language: en-US From: Jan Beulich Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 23.05.2025 21:51, Sergii Dmytruk wrote: > On Wed, May 21, 2025 at 05:19:57PM +0200, Jan Beulich wrote: >>> +/* >>> + * Secure Launch defined OS/MLE TXT Heap table >>> + */ >>> +struct txt_os_mle_data { >>> + uint32_t version; >>> + uint32_t reserved; >>> + uint64_t slrt; >>> + uint64_t txt_info; >>> + uint32_t ap_wake_block; >>> + uint32_t ap_wake_block_size; >>> + uint8_t mle_scratch[64]; >>> +} __packed; >> >> This being x86-specific, what's the __packed intended to achieve here? > > This structure is passed to Xen by a bootloader, __packed makes sure the > structure has a compatible layout. And it won't have a compatible layout without the attribute? >>> +/* >>> + * TXT specification defined BIOS data TXT Heap table >>> + */ >>> +struct txt_bios_data { >>> + uint32_t version; /* Currently 5 for TPM 1.2 and 6 for TPM 2.0 */ >>> + uint32_t bios_sinit_size; >>> + uint64_t reserved1; >>> + uint64_t reserved2; >>> + uint32_t num_logical_procs; >>> + /* Versions >= 3 && < 5 */ >>> + uint32_t sinit_flags; >>> + /* Versions >= 5 with updates in version 6 */ >>> + uint32_t mle_flags; >>> + /* Versions >= 4 */ >>> + /* Ext Data Elements */ >>> +} __packed; >> >> It does affect sizeof() here, which I'm unsure is going to matter. > > It doesn't hurt anything and makes sure offsets match those in the > specification. It similarly doesn't appear to hurt anything if the attribute was omitted. Imo we ought to use compiler extensions on when there is a need to do so. >>> +static inline uint64_t txt_bios_data_size(void *heap) >> >> Here, below, and in general: Please try to have code be const-correct, i.e. >> use pointers-to-const wherever applicable. > > I assume this doesn't apply to functions returning `void *`. The > approach used in libc is to accept pointers-to-const but then cast the > constness away for the return value, but this header isn't a widely-used > code. Which is, from all I know, bad practice not only by my own view. Jan