All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Huang, Kai" <kai.huang@intel.com>
To: Xiaoyao Li <xiaoyao.li@intel.com>, <linux-kernel@vger.kernel.org>,
	<kvm@vger.kernel.org>
Cc: <x86@kernel.org>, <dave.hansen@intel.com>,
	<kirill.shutemov@linux.intel.com>, <peterz@infradead.org>,
	<tglx@linutronix.de>, <bp@alien8.de>, <mingo@redhat.com>,
	<hpa@zytor.com>, <seanjc@google.com>, <pbonzini@redhat.com>,
	<isaku.yamahata@intel.com>, <jgross@suse.com>
Subject: Re: [PATCH 5/5] x86/virt/tdx: Export global metadata read infrastructure
Date: Fri, 15 Mar 2024 13:24:29 +1300	[thread overview]
Message-ID: <1c8537b8-bb91-48ee-ae9a-5f54b828b49c@intel.com> (raw)
In-Reply-To: <bd61e29d-5842-4136-b30f-929b00bdf6f9@intel.com>



On 13/03/2024 4:44 pm, Xiaoyao Li wrote:
> On 3/1/2024 7:20 PM, Kai Huang wrote:
>> KVM will need to read a bunch of non-TDMR related metadata to create and
>> run TDX guests.  Export the metadata read infrastructure for KVM to use.
>>
>> Specifically, export two helpers:
>>
>> 1) The helper which reads multiple metadata fields to a buffer of a
>>     structure based on the "field ID -> structure member" mapping table.
>>
>> 2) The low level helper which just reads a given field ID.
> 
> How about introducing a helper to read a single metadata field comparing 
> to 1) instead of the low level helper.
> 
> The low level helper tdx_sys_metadata_field_read() requires the data buf 
> to be u64 *. So the caller needs to use a temporary variable and handle 
> the memcpy when the field is less than 8 bytes.
> 
> so why not expose a high level helper to read single field, e.g.,
> 
> +int tdx_sys_metadata_read_single(u64 field_id, int bytes, void *buf)
> +{
> +       return stbuf_read_sys_metadata_field(field_id, 0, bytes, buf);
> +}
> +EXPORT_SYMBOL_GPL(tdx_sys_metadata_read_single);

As replied here where these APIs are (supposedly) to be used:

https://lore.kernel.org/kvm/e88e5448-e354-4ec6-b7de-93dd8f7786b5@intel.com/

I don't see why we need to use a temporary 'u64'.  We can just use it 
directly or type cast to 'u16' when needed, which has the same result of 
doing explicit memory copy based on size.

So I am not convinced at this stage that we need the code as you 
suggested.  At least I believe the current APIs are sufficient for KVM 
to use.

However I'll put more background on how KVM is going to use into the 
changelog to justify the current APIs are enough.

  reply	other threads:[~2024-03-15  0:24 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-01 11:20 [PATCH 0/5] TDX host: Provide TDX module metadata reading APIs Kai Huang
2024-03-01 11:20 ` [PATCH 1/5] x86/virt/tdx: Rename _offset to _member for TD_SYSINFO_MAP() macro Kai Huang
2024-05-03  0:07   ` Edgecombe, Rick P
2024-05-06 11:34     ` Huang, Kai
2024-03-01 11:20 ` [PATCH 2/5] x86/virt/tdx: Move TDMR metadata fields map table to local variable Kai Huang
2024-05-03  0:09   ` Edgecombe, Rick P
2024-05-03  0:18     ` Huang, Kai
2024-05-03  0:29       ` Edgecombe, Rick P
2024-05-03  0:54         ` Huang, Kai
2024-05-03 16:01   ` Dave Hansen
2024-05-06  8:04     ` Huang, Kai
2024-03-01 11:20 ` [PATCH 3/5] x86/virt/tdx: Unbind global metadata read with 'struct tdx_tdmr_sysinfo' Kai Huang
2024-05-03  0:12   ` Edgecombe, Rick P
2024-05-03  0:52     ` Huang, Kai
2024-05-03 19:03       ` Edgecombe, Rick P
2024-05-06 11:15         ` Huang, Kai
2024-03-01 11:20 ` [PATCH 4/5] x86/virt/tdx: Support global metadata read for all element sizes Kai Huang
2024-03-16  0:49   ` Isaku Yamahata
2024-03-20 12:24     ` Huang, Kai
2024-05-03  0:19   ` Edgecombe, Rick P
2024-05-03  1:14     ` Huang, Kai
2024-05-03 12:10       ` Huang, Kai
2024-05-03 12:26         ` Huang, Kai
2024-05-03 18:32           ` Edgecombe, Rick P
2024-05-06 10:59             ` Huang, Kai
2024-03-01 11:20 ` [PATCH 5/5] x86/virt/tdx: Export global metadata read infrastructure Kai Huang
2024-03-13  3:44   ` Xiaoyao Li
2024-03-15  0:24     ` Huang, Kai [this message]
2024-03-15  2:10       ` Xiaoyao Li
2024-05-03  0:21   ` Edgecombe, Rick P
2024-05-03  2:17     ` Huang, Kai
2024-05-03 18:31       ` Edgecombe, Rick P
2024-05-06 11:35         ` Huang, Kai
2024-05-06 15:43   ` Dave Hansen
2024-05-06 22:13     ` Huang, Kai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1c8537b8-bb91-48ee-ae9a-5f54b828b49c@intel.com \
    --to=kai.huang@intel.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@intel.com \
    --cc=hpa@zytor.com \
    --cc=isaku.yamahata@intel.com \
    --cc=jgross@suse.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterz@infradead.org \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=xiaoyao.li@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.