lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0bd5a2f95a0f309ff35d511ce832c5f11abf6013.camel@intel.com>
Date:   Tue, 4 Jul 2023 21:50:22 +0000
From:   "Huang, Kai" <kai.huang@...el.com>
To:     "peterz@...radead.org" <peterz@...radead.org>,
        "Christopherson,, Sean" <seanjc@...gle.com>
CC:     "kvm@...r.kernel.org" <kvm@...r.kernel.org>,
        "x86@...nel.org" <x86@...nel.org>,
        "Raj, Ashok" <ashok.raj@...el.com>,
        "Hansen, Dave" <dave.hansen@...el.com>,
        "david@...hat.com" <david@...hat.com>,
        "bagasdotme@...il.com" <bagasdotme@...il.com>,
        "ak@...ux.intel.com" <ak@...ux.intel.com>,
        "Wysocki, Rafael J" <rafael.j.wysocki@...el.com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "Chatre, Reinette" <reinette.chatre@...el.com>,
        "mingo@...hat.com" <mingo@...hat.com>,
        "kirill.shutemov@...ux.intel.com" <kirill.shutemov@...ux.intel.com>,
        "tglx@...utronix.de" <tglx@...utronix.de>,
        "linux-mm@...ck.org" <linux-mm@...ck.org>,
        "pbonzini@...hat.com" <pbonzini@...hat.com>,
        "nik.borisov@...e.com" <nik.borisov@...e.com>,
        "Yamahata, Isaku" <isaku.yamahata@...el.com>,
        "Luck, Tony" <tony.luck@...el.com>,
        "hpa@...or.com" <hpa@...or.com>, "Shahar, Sagi" <sagis@...gle.com>,
        "imammedo@...hat.com" <imammedo@...hat.com>,
        "bp@...en8.de" <bp@...en8.de>, "Gao, Chao" <chao.gao@...el.com>,
        "isaku.yamahata@...il.com" <isaku.yamahata@...il.com>,
        "Brown, Len" <len.brown@...el.com>,
        "sathyanarayanan.kuppuswamy@...ux.intel.com" 
        <sathyanarayanan.kuppuswamy@...ux.intel.com>,
        "Huang, Ying" <ying.huang@...el.com>,
        "Williams, Dan J" <dan.j.williams@...el.com>
Subject: Re: [PATCH v12 07/22] x86/virt/tdx: Add skeleton to enable TDX on
 demand

On Tue, 2023-07-04 at 18:58 +0200, Peter Zijlstra wrote:
> On Fri, Jun 30, 2023 at 02:24:56PM -0700, Sean Christopherson wrote:
> 
> > Waiting until userspace attempts to create the first TDX guest adds complexity
> > and limits what KVM can do to harden itself.  Currently, all feature support in
> > KVM is effectively frozen at module load.  E.g. most of the setup code is
> > contained in __init functions, many module-scoped variables are effectively 
> > RO after init (though they can't be marked as such until we smush kvm-intel.ko
> > and kvm-amd.ko into kvm.ko, which is tentatively the long-term plan).  All of
> > those patterns would get tossed aside if KVM waits until userspace attempts to
> > create the first guest.
> 
> ....
> 
> People got poked and the following was suggested:
> 
> On boot do:
> 
>  TDH.SYS.INIT
>  TDH.SYS.LP.INIT
>  TDH.SYS.CONFIG
>  TDH.SYS.KEY.CONFIG
> 
> This should get TDX mostly sorted, but doesn't consume much resources.
> Then later, when starting the first TDX guest, do the whole
> 
>  TDH.TDMR.INIT
> 
> dance to set up the PAMT array -- which is what gobbles up memory. From
> what I understand the TDH.TDMR.INIT thing is not one of those
> excessively long calls.

The TDH.TDMR.INIT itself has it's own latency requirement implemented in the TDX
module, thus it only initializes a small chunk  (1M I guess) in each call. 
Therefore we need a loop to do bunch of TDH.TDMR.INIT in order to initialize all
PAMT entries for all TDX-usable memory, which can be time-consuming.

Currently for simplicity we just do this inside the module initialization, but
can be optimized later when we have an agreed solution of how to optimize.

> 
> If we have concerns about allocating the PAMT array, can't we use CMA
> for this? Allocate the whole thing at boot as CMA such that when not
> used for TDX it can be used for regular things like userspace and
> filecache pages?

The PAMT allocation itself isn't a concern I think.  The concern is the
TDH.TDMR.INIT to initialize them.

Also, one practical problem to prevent us from pre-allocating PAMT is the PAMT
size to be allocated can only be determined after the TDH.SYS.INFO SEAMCALL,
which reports the "PAMT entry size" in the TDSYSINFO_STRUCT.

> 
> Those TDH.SYS calls should be enough to ensure TDX is actually working,
> no?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ