All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>,
	Jan Beulich <jbeulich@suse.com>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
	"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: Thu, 20 Aug 2026 16:48:55 +0100	[thread overview]
Message-ID: <fd51f8a9-b09b-4aaa-8aa9-13a65d0aaa5d@citrix.com> (raw)
In-Reply-To: <aob9xUZF12IJhLRz@MjU3Nj>

On 20/08/2026 2:14 pm, Sergii Dmytruk wrote:
> On Tue, Aug 18, 2026 at 02:08:48PM +0200, Jan Beulich wrote:
>> On 02.08.2026 15:09, Sergii Dmytruk wrote:
>>> @@ -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.)
> I think `volatile` was added just because it doesn't hurt, rather than
> because it's necessary, so it can be dropped.  Can add a wrapper, but
> there is only one use so far and a generic wrapper will have to use
> 64-bit parameters (`GETSEC[EXITAC]` sets RBX).

GETSEC is a horrible instruction.  The different functions (eax input)
produce and consume different registers,

This in turn requires different volatilities.  GETSEC[CAPABILITIES] and
GETSEC[PARAMETERS] should be non-volatile (they're read-only operation
without interesting side effects which the optimiser can safely discard)
whereas GETSEC[ENTERACCS] or GETSEC[SENTER] are really "jump into new
processor mode".  They're both longjmp-like so are considered volatile
by virtue of having no outputs.

I was going to request a getsec.h header to abstract these away.  Having
more than one location where we need to carefully check the asm
constraints against the SDM is too many.

~Andrew


  parent reply	other threads:[~2026-08-20 15:49 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
2026-08-20 13:14     ` Sergii Dmytruk
2026-08-20 15:48       ` Jan Beulich
2026-08-20 15:48       ` Andrew Cooper [this message]
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=fd51f8a9-b09b-4aaa-8aa9-13a65d0aaa5d@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.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.