lkml.org 
[lkml]   [2024]   [Mar]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH v19 039/130] KVM: TDX: initialize VM with TDX specific parameters
    On Wed, Mar 20, 2024 at 04:15:23PM +0800,
    Xiaoyao Li <xiaoyao.li@intel.com> wrote:

    > On 2/26/2024 4:25 PM, isaku.yamahata@intel.com wrote:
    >
    > ...
    >
    > > +static int setup_tdparams_xfam(struct kvm_cpuid2 *cpuid, struct td_params *td_params)
    > > +{
    > > + const struct kvm_cpuid_entry2 *entry;
    > > + u64 guest_supported_xcr0;
    > > + u64 guest_supported_xss;
    > > +
    > > + /* Setup td_params.xfam */
    > > + entry = kvm_find_cpuid_entry2(cpuid->entries, cpuid->nent, 0xd, 0);
    > > + if (entry)
    > > + guest_supported_xcr0 = (entry->eax | ((u64)entry->edx << 32));
    > > + else
    > > + guest_supported_xcr0 = 0;
    > > + guest_supported_xcr0 &= kvm_caps.supported_xcr0;
    > > +
    > > + entry = kvm_find_cpuid_entry2(cpuid->entries, cpuid->nent, 0xd, 1);
    > > + if (entry)
    > > + guest_supported_xss = (entry->ecx | ((u64)entry->edx << 32));
    > > + else
    > > + guest_supported_xss = 0;
    > > +
    > > + /*
    > > + * PT and CET can be exposed to TD guest regardless of KVM's XSS, PT
    > > + * and, CET support.
    > > + */
    > > + guest_supported_xss &=
    > > + (kvm_caps.supported_xss | XFEATURE_MASK_PT | TDX_TD_XFAM_CET);
    > > +
    > > + td_params->xfam = guest_supported_xcr0 | guest_supported_xss;
    > > + if (td_params->xfam & XFEATURE_MASK_LBR) {
    > > + /*
    > > + * TODO: once KVM supports LBR(save/restore LBR related
    > > + * registers around TDENTER), remove this guard.
    > > + */
    > > +#define MSG_LBR "TD doesn't support LBR yet. KVM needs to save/restore IA32_LBR_DEPTH properly.\n"
    > > + pr_warn(MSG_LBR);
    > > + return -EOPNOTSUPP;
    >
    > This unsupported behavior is totally decided by KVM even if TDX module
    > supports it. I think we need to reflect it in tdx_info->xfam_fixed0, which
    > gets reported to userspace via KVM_TDX_CAPABILITIES. So userspace will aware
    > that LBR is not supported for TDs.

    Yes, we can suppress KVM unpported features. I replied at
    https://lore.kernel.org/kvm/20240321155513.GL1994522@ls.amr.corp.intel.com/

    So far we used KVM_TDX_CAPABILITIES for feature enumeration. I'm wondering about
    KVM_GET_DEVICE_ATTR [1]. It's future extensible. It's also consistent with SEV.

    [1] https://lore.kernel.org/r/20240226190344.787149-7-pbonzini@redhat.com
    --
    Isaku Yamahata <isaku.yamahata@intel.com>

    \
     
     \ /
      Last update: 2024-05-27 15:58    [W:4.089 / U:0.076 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site