From: Dan Williams <dan.j.williams@intel.com>
To: Paolo Bonzini <pbonzini@redhat.com>, Dave Hansen <dave.hansen@intel.com>
Cc: Kai Huang <kai.huang@intel.com>,
<kirill.shutemov@linux.intel.com>, <tglx@linutronix.de>,
<bp@alien8.de>, <peterz@infradead.org>, <mingo@redhat.com>,
<hpa@zytor.com>, <dan.j.williams@intel.com>, <seanjc@google.com>,
<x86@kernel.org>, <linux-kernel@vger.kernel.org>,
<kvm@vger.kernel.org>, <rick.p.edgecombe@intel.com>,
<isaku.yamahata@intel.com>, <adrian.hunter@intel.com>,
<nik.borisov@suse.com>
Subject: Re: [PATCH v5 0/8] TDX host: metadata reading tweaks, bug fix and info dump
Date: Tue, 15 Oct 2024 12:04:07 -0700 [thread overview]
Message-ID: <670ebca6e8aa0_3f14294cf@dwillia2-xfh.jf.intel.com.notmuch> (raw)
In-Reply-To: <CABgObfYXUxqQV_FoxKjC8U3t5DnyM45nz5DpTxYZv2x_uFK_Kw@mail.gmail.com>
Paolo Bonzini wrote:
> On Tue, Oct 15, 2024 at 5:30 PM Dave Hansen <dave.hansen@intel.com> wrote:
> >
> > I'm having one of those "I hate this all" moments. Look at what we say
> > in the code:
> >
> > > * See the "global_metadata.json" in the "TDX 1.5 ABI definitions".
> >
> > Basically step one in verifying that this is all right is: Hey, humans,
> > please go parse a machine-readable format. That's insanity. If Intel
> > wants to publish JSON as the canonical source of truth, that's fine.
> > It's great, actually. But let's stop playing human JSON parser and make
> > the computers do it for us, OK?
> >
> > Let's just generate the code. Basically, as long as the generated C is
> > marginally readable, I'm OK with it. The most important things are:
> >
> > 1. Adding a field is dirt simple
> > 2. Using the generated C is simple
> >
> > In 99% of the cases, nobody ends up having to ever look at the generated
> > code.
> >
> > Take a look at the attached python program and generated C file. I
> > think they qualify. We can check the script into tools/scripts/ and it
> > can get re-run when new json comes out or when a new field is needed.
> > You'd could call the generated code like this:
>
> Ok, so let's move this thing forward. Here is a more polished script
> and the output. Untested beyond compilation.
>
> Kai, feel free to include it in v6 with my
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.om>
>
> I made an attempt at adding array support and using it with the CMR
> information; just to see if Intel is actually trying to make
> global_metadata.json accurate. The original code has
>
> for (i = 0; i < sysinfo_cmr->num_cmrs; i++) {
> READ_SYS_INFO(CMR_BASE + i, cmr_base[i]);
> READ_SYS_INFO(CMR_SIZE + i, cmr_size[i]);
> }
>
> The generated code instead always tries to read 32 fields and returns
> non-zero from get_tdx_sys_info_cmr if they are missing. If it fails to
> read the fields above NUM_CMRS, just remove that part of the tdx.py
> script and make sure that a comment in the code shames the TDX ABI
> documentation adequately. :)
Thanks for doing this Paolo, I regret not pushing harder [1] / polishing
up the bash+jq script I threw together to do the same.
I took a look at your script and the autogenerated code and it looks good
to me.
Feel free to add my Reviewed-by on a patch that adds that collateral to
the tools/ directory.
[1]: http://lore.kernel.org/66b19beaadd28_4fc729410@dwillia2-xfh.jf.intel.com.notmuch
next prev parent reply other threads:[~2024-10-15 19:04 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-14 11:31 Kai Huang
2024-10-14 11:31 ` [PATCH v5 1/8] x86/virt/tdx: Rename 'struct tdx_tdmr_sysinfo' to reflect the spec better Kai Huang
2024-10-14 11:31 ` [PATCH v5 2/8] x86/virt/tdx: Rework TD_SYSINFO_MAP to support build-time verification Kai Huang
2024-10-14 15:56 ` Dave Hansen
2024-10-14 19:13 ` Dan Williams
2024-10-15 11:34 ` Huang, Kai
2024-10-14 11:31 ` [PATCH v5 3/8] x86/virt/tdx: Prepare to support reading other global metadata fields Kai Huang
2024-10-14 11:31 ` [PATCH v5 4/8] x86/virt/tdx: Refine a comment to reflect the latest TDX spec Kai Huang
2024-10-14 11:31 ` [PATCH v5 5/8] x86/virt/tdx: Start to track all global metadata in one structure Kai Huang
2024-10-14 11:31 ` [PATCH v5 6/8] x86/virt/tdx: Print TDX module version Kai Huang
2024-10-14 11:31 ` [PATCH v5 7/8] x86/virt/tdx: Require the module to assert it has the NO_RBP_MOD mitigation Kai Huang
2024-10-14 11:31 ` [PATCH v5 8/8] x86/virt/tdx: Reduce TDMR's reserved areas by using CMRs to find memory holes Kai Huang
2024-10-15 15:30 ` [PATCH v5 0/8] TDX host: metadata reading tweaks, bug fix and info dump Dave Hansen
2024-10-15 16:29 ` Paolo Bonzini
2024-10-15 19:04 ` Dan Williams [this message]
2024-10-15 21:11 ` Huang, Kai
2024-10-28 12:07 ` 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=670ebca6e8aa0_3f14294cf@dwillia2-xfh.jf.intel.com.notmuch \
--to=dan.j.williams@intel.com \
--cc=adrian.hunter@intel.com \
--cc=bp@alien8.de \
--cc=dave.hansen@intel.com \
--cc=hpa@zytor.com \
--cc=isaku.yamahata@intel.com \
--cc=kai.huang@intel.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=nik.borisov@suse.com \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=rick.p.edgecombe@intel.com \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®