lkml.org 
[lkml]   [2023]   [Mar]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v13 112/113] RFC: KVM: TDX: Make busy with S-EPT on entry bug
    Date
    From: Isaku Yamahata <isaku.yamahata@intel.com>

    TDX module has mitigation against zero-step attacks or single-step attacks.
    When the TDX module finds repeated EPT violations on the same guest RIP,
    i.e. no advance in guest, it starts to suspect the attack. The mitigation
    logic on the next entry tries to take the lock of S-EPT. It may result in
    an error of TDX_OPERAND_BUSY | TDX_OPERAND_ID_SEPT. As KVM shouldn't
    spuriously zap private S-EPT so that guest can make progress, KVM
    shouldn't cause the TDX module to trigger the mitigation. Make
    (TDX_OPERAND_BUSY | TDX_OPERAND_ID_SEPT) on entry KVM bug.

    Suggested-by: Sean Christopherson <seanjc@google.com>
    Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com>
    ---
    - This patch is RFC because this is only lightly tested and stress test
    isn't done.
    ---
    arch/x86/kvm/vmx/tdx.c | 16 ++++++++++++++--
    1 file changed, 14 insertions(+), 2 deletions(-)

    diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c
    index 8e392bc3330b..b668f06bbb64 100644
    --- a/arch/x86/kvm/vmx/tdx.c
    +++ b/arch/x86/kvm/vmx/tdx.c
    @@ -1670,8 +1670,20 @@ int tdx_handle_exit(struct kvm_vcpu *vcpu, fastpath_t fastpath)
    {
    union tdx_exit_reason exit_reason = to_tdx(vcpu)->exit_reason;

    - /* See the comment of tdh_sept_seamcall(). */
    - if (unlikely(exit_reason.full == (TDX_OPERAND_BUSY | TDX_OPERAND_ID_SEPT)))
    + /*
    + * See the comment of tdh_sept_seamcall().
    + * TDX module has mitigation against zero-step attacks or single-step
    + * attacks. When the TDX module finds repeated EPT violations on the
    + * same guest RIP, i.e. no advance in guest, it starts to suspect the
    + * attack. The mitigation logic on the next entry tries to take the
    + * lock of S-EPT. It may result in an error of (TDX_OPERAND_BUSY |
    + * TDX_OPERAND_ID_SEPT). As KVM shouldn't spuriously zap private S-EPT
    + * so that guest can make progress, KVM shouldn't cause the TDX module
    + * to trigger the mitigation. Make (TDX_OPERAND_BUSY |
    + * TDX_OPERAND_ID_SEPT) on entry KVM bug.
    + */
    + if (KVM_BUG_ON(exit_reason.full == (TDX_OPERAND_BUSY | TDX_OPERAND_ID_SEPT),
    + vcpu->kvm))
    return 1;

    if (unlikely(exit_reason.full == TDX_SEAMCALL_UD)) {
    --
    2.25.1
    \
     
     \ /
      Last update: 2023-03-27 00:55    [W:4.078 / U:0.144 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site