All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>
Cc: "Roger Pau Monné" <roger@xenproject.org>,
	"Teddy Astie" <teddy.astie@vates.tech>,
	trenchboot-devel@googlegroups.com,
	xen-devel@lists.xenproject.org
Subject: Re: [PATCH v4 02/23] x86/cpu: report SMX, TXT and SKINIT capabilities
Date: Tue, 18 Aug 2026 14:08:48 +0200	[thread overview]
Message-ID: <7489d730-6e91-4d6f-a355-4eaa62698c4c@suse.com> (raw)
In-Reply-To: <be993e757550b69a6f94f89476ba71131b434741.1785668458.git.sergii.dmytruk@3mdeb.com>

On 02.08.2026 15:09, Sergii Dmytruk wrote:
> From: Michał Żygowski <michal.zygowski@3mdeb.com>
> 
> Report TXT capabilities so that dom0 can query the Intel TXT or AMD
> SKINIT support information using xl dmesg.

Hmm. I first meant to ask: In how far is this extra logging useful,
especially as long as we don't use the features just yet? And only then
I noticed that I must have paid too little attention here already in v3.
Querying through "xl dmesg" is entirely unreliable. Sooner or later the
boot messages will scroll off of the ring buffer. Making this a
query-able interface also would mean we can't alter any of the messages,
should the want/need arise.

For AMD the situation is easy: It's part of the featureset / CPU policy
exposed via sysctl. The same is true for SMX on Intel, but the further
GETSEC output requires some other means to communicate. I wonder whether
making this part of the CPU policy would make sense, or whether to
introduce a Dom0-only hypervisor-CPUID bit for it, or whether yet
something else would be best here. Likely Andrew will have had thoughts
on this long before ...

Irrespective of the above also a few comments on the patch itself.

> --- a/xen/arch/x86/cpu/amd.c
> +++ b/xen/arch/x86/cpu/amd.c
> @@ -617,6 +617,21 @@ void amd_process_freq(const struct cpuinfo_x86 *c,
>  		*low_mhz = amd_parse_freq(c->family, lo);
>  }
>  
> +void amd_log_skinit(const struct cpuinfo_x86 *c)
> +{
> +    /*
> +     * Run only on BSP and not during resume to report the capability only once.
> +     */
> +    if ( system_state == SYS_STATE_resume || smp_processor_id() )
> +        return;

If this is BSP-on-boot only, the function really wants to be __init. For that,
...

> +    printk("CPU: SKINIT capability ");
> +    if ( !test_bit(X86_FEATURE_SKINIT, &boot_cpu_data.x86_capability) )
> +        printk("not supported\n");
> +    else
> +        printk("supported\n");
> +}
> +
>  void cf_check early_init_amd(struct cpuinfo_x86 *c)
>  {
>  	if (c == &boot_cpu_data)

... use this condition ...

> @@ -1325,6 +1340,7 @@ static void cf_check init_amd(struct cpuinfo_x86 *c)
>  		setup_force_cpu_cap(X86_FEATURE_XEN_REP_MOVSB);
>  
>  	amd_log_freq(c);
> +	amd_log_skinit(c);

... at the call site (and of course also the other one). Same for the Intel
code, obviously.

> @@ -620,6 +625,49 @@ static void init_intel_perf(struct cpuinfo_x86 *c)
>      }
>  }
>  
> +/*
> + * Print out the SMX and TXT capabilties, so that dom0 can determine if the
> + * system is DRTM-capable.
> + */
> +static void intel_log_smx_txt(void)
> +{
> +    unsigned long cr4_val, getsec_caps;
> +
> +    /*
> +     * Run only on BSP and not during resume to report the capability only once.
> +     */
> +    if ( system_state == SYS_STATE_resume || smp_processor_id() )
> +        return;
> +
> +    printk("CPU: SMX capability ");
> +    if ( !test_bit(X86_FEATURE_SMX, &boot_cpu_data.x86_capability) )
> +    {
> +        printk("not supported\n");
> +        return;
> +    }
> +    printk("supported\n");
> +
> +    /* Can't run GETSEC without VMX and SMX */
> +    if ( !test_bit(X86_FEATURE_VMX, &boot_cpu_data.x86_capability) )
> +        return;
> +
> +    cr4_val = read_cr4();
> +    if ( !(cr4_val & X86_CR4_SMXE) )
> +        write_cr4(cr4_val | X86_CR4_SMXE);
> +
> +    asm volatile ("getsec\n"
> +        : "=a" (getsec_caps)
> +        : "a" (GETSEC_CAPABILITIES), "b" (0) :);

Nit (style): Bad indentation, missing blanks, unnecessary \n, and stray colon.
Overall:

    asm volatile ( "getsec"
                   : "=a" (getsec_caps)
                   : "a" (GETSEC_CAPABILITIES), "b" (0) );

I further question the need for volatile here. (Like for we have for CPUID, we
anyway may want to gain a getsec() wrapper for GETSEC.)

> +    if ( !(cr4_val & X86_CR4_SMXE) )
> +        write_cr4(cr4_val & ~X86_CR4_SMXE);

The clearing of SMXE here is pointless, as the if() already guarantees the bit
to be clear.

Jan


  reply	other threads:[~2026-08-18 12:09 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-02 13:09 [PATCH v4 00/23] x86: Trenchboot Secure Launch DRTM (Xen) Sergii Dmytruk
2026-08-02 13:09 ` [PATCH v4 01/23] x86/mtrr: get rid of a static variable on pause/restore Sergii Dmytruk
2026-08-18 11:44   ` Jan Beulich
2026-08-20 12:34   ` Teddy Astie
2026-08-02 13:09 ` [PATCH v4 02/23] x86/cpu: report SMX, TXT and SKINIT capabilities Sergii Dmytruk
2026-08-18 12:08   ` Jan Beulich [this message]
2026-08-20 13:14     ` Sergii Dmytruk
2026-08-20 15:48       ` Jan Beulich
2026-08-20 15:48       ` Andrew Cooper
2026-08-20 12:59   ` Teddy Astie
2026-08-20 15:09     ` Andrew Cooper
2026-08-02 13:09 ` [PATCH v4 03/23] x86/tpm.c: hashing and extending PCRs for TPM1.2 Sergii Dmytruk
2026-08-02 13:09 ` [PATCH v4 04/23] x86/tpm.c: support extending PCRs of TPM2.0 via TIS Sergii Dmytruk
2026-08-02 13:09 ` [PATCH v4 05/23] x86/tpm.c: add CRB interface support Sergii Dmytruk
2026-08-02 13:09 ` [PATCH v4 06/23] x86/include/asm/intel-txt.h: constants and accessors for TXT registers and heap Sergii Dmytruk
2026-08-02 13:09 ` [PATCH v4 07/23] x86/boot: add CONFIG_SLAUNCH, MLE header and Secure Launch entry point Sergii Dmytruk
2026-08-02 13:09 ` [PATCH v4 08/23] include/xen/slr-table.h: Secure Launch Resource Table definitions Sergii Dmytruk
2026-08-02 13:09 ` [PATCH v4 09/23] x86/boot/slaunch-early: implement early initialization Sergii Dmytruk
2026-08-02 13:09 ` [PATCH v4 10/23] x86/boot/slaunch-early: early Intel TXT sanity checks Sergii Dmytruk
2026-08-02 13:09 ` [PATCH v4 11/23] xen/arch/x86: reserve TXT memory during Slaunch Sergii Dmytruk
2026-08-02 13:09 ` [PATCH v4 12/23] x86/slaunch: restore boot MTRRs after Intel TXT DRTM Sergii Dmytruk
2026-08-02 13:09 ` [PATCH v4 13/23] x86/slaunch: measure MBI into TPM Sergii Dmytruk
2026-08-02 13:09 ` [PATCH v4 14/23] x86/slaunch: update TPM event log (TPM1.2 or TPM2.0) Sergii Dmytruk
2026-08-02 13:09 ` [PATCH v4 15/23] x86/hvm: check for VMX in SMX if Slaunch is active Sergii Dmytruk
2026-08-02 13:09 ` [PATCH v4 16/23] x86/boot: choose AP stack based on APIC ID Sergii Dmytruk
2026-08-02 13:09 ` [PATCH v4 17/23] x86/smpboot.c: TXT AP bringup Sergii Dmytruk
2026-08-02 13:09 ` [PATCH v4 18/23] x86/slaunch: process DRTM policy Sergii Dmytruk
2026-08-02 13:09 ` [PATCH v4 19/23] x86/acpi: disallow S3 on Secure Launch boot Sergii Dmytruk
2026-08-02 13:09 ` [PATCH v4 20/23] x86/slaunch: support AMD CPUs Sergii Dmytruk
2026-08-02 13:09 ` [PATCH v4 21/23] x86/slaunch: support EFI boot Sergii Dmytruk
2026-08-02 13:09 ` [PATCH v4 22/23] xen/arch/x86: add TPR (TXT Protected Range) DMA protection support Sergii Dmytruk
2026-08-02 13:09 ` [PATCH v4 23/23] MAINTAINERS: add a section for TrenchBoot Slaunch Sergii Dmytruk

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=7489d730-6e91-4d6f-a355-4eaa62698c4c@suse.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=roger@xenproject.org \
    --cc=sergii.dmytruk@3mdeb.com \
    --cc=teddy.astie@vates.tech \
    --cc=trenchboot-devel@googlegroups.com \
    --cc=xen-devel@lists.xenproject.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 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.