Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4729727pxv; Tue, 6 Jul 2021 07:51:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxAH4pxw803EgqLPsK8ykU/Bizxqs/r5Wi6/aSAZVnvTrDoE0i5B+ixGy8gzpxDsANEoPd/ X-Received: by 2002:a50:9b5b:: with SMTP id a27mr23552809edj.170.1625583078828; Tue, 06 Jul 2021 07:51:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625583078; cv=none; d=google.com; s=arc-20160816; b=J0Icu4xAXvYe/v4oK8yzzr7wBjKwiWSU00pF1JwgucT3zQXWzKIHo6rok8eQVXoVM6 EsMgllkbij35fAGtfce+kuUshyjs268YQaRP5GbaP+6t8ZkQn+XnoqeCHiZ/5mvMVkmP 5a5EFHHShSjyiy8sXFQyAJ7sHQa9jsIy3lTmNe7saFAjEIThGfFmJ9DEqVh8plX/d3hM WqAT4Nzc2bIg0DK/WZov+fEssNvyTcKhgPDHeI9nW/pYz/WzkL6WWeITcrrspUgwoTBl aGHwsLMkXTkYlbk3Ms7Bh74107AS5/l0Esr+sYetXwazSd1Vj6UXPYgbdQXz9cNLJvr5 3qqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=20G35whReEHfIZ+dBsZvd5Uh4Y18foPVbA/ZdGuzNR0=; b=pUmDAGPFBHVPfGvaiBnU61eKMeocoYkCjuWkdZc0bc3m1fX65Wb3XAbkptQUOibeuY lsKaTMlFatJ2NZ+9LAkz0SmGx36dayUWsOVoUDvuMJZiRyYyJVqxB/SBYKxbXzja+gj5 7B/mnjLrKr/YVws3ppY0zVJD+x5fjcrWYCvDzIrZrz5GpqL4EyKlr6gHn89MaECDYRAp 2o99X5gLMVf/1+KIHjQIUFanPOvd9ugMv0GtW9n4Zx8ZsF1eXS9jdnSCZJyEGB37drVC xfpGT3/MPCdghF1NkoruCMTIE3qNhHgTOqLR53W3znUXQ5RZTJMDuLylb9tbxXms30do aGEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Yn3X0GlH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l20si14731851ejn.131.2021.07.06.07.50.55; Tue, 06 Jul 2021 07:51:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Yn3X0GlH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232030AbhGFOwl (ORCPT + 99 others); Tue, 6 Jul 2021 10:52:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:31783 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231979AbhGFOwj (ORCPT ); Tue, 6 Jul 2021 10:52:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625583000; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=20G35whReEHfIZ+dBsZvd5Uh4Y18foPVbA/ZdGuzNR0=; b=Yn3X0GlHfVu5fqeOxEtmqKORa1V4upzvnZ4Ec2n5js+FL0ogpnpzp4Vs6xErHXnkEQjvBv mDcmrmrc1Ebr9xDUKhmQBYnz1xyDOfe3lOYk9dIKhksJ7ZQCvcToj0lQV9EYlvInBZWprj V6tQxVDsaI2W/fRLAHU5061qQ1XyW4M= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-327-IDOJ8qn1PzWcXWaOhz6f8A-1; Tue, 06 Jul 2021 10:49:55 -0400 X-MC-Unique: IDOJ8qn1PzWcXWaOhz6f8A-1 Received: by mail-wm1-f70.google.com with SMTP id 9-20020a05600c2289b02901f519cc69a8so3171778wmf.9 for ; Tue, 06 Jul 2021 07:49:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=20G35whReEHfIZ+dBsZvd5Uh4Y18foPVbA/ZdGuzNR0=; b=n8YPq5fEJxQ/k3os4w3ZnhaV8Ay869nki7Iel0MeVdlx4GwAhxlUNtOtBxOYkM6Bt5 aTy5sFX5Q98JLVht9m6haQ3NbKHWgDP9oE3C/2q6/ll5rF3/5qtbu6lJQ3GMboerWDvL wVkCLMJ+e0h3ueX709SeEa7n7X5HA3oUPE8CoiDwrl8bEX79SxKDtezesd6yl4+xUiK3 DXWA9Od4Z0KiuD3YRe4shNmqi0LUvZWvS2q/2pQaWPlAnU0mCKpS/xXZNxeWQREoKsiP FkD82w3+PriyI82s3t59Imh4Mo2R9BDPuEmyq8GDWFxdOqOG7X4jcW0WZWBG8yBC0caP w1VA== X-Gm-Message-State: AOAM532Z8FjNpPeIIDlMzORkikbdYtR3Go8ipCnl+nT4IV1y7/Tyvlib 6VijCgq8wbqp9nxIP6LyREqUUU4SHHI18HaWSsM1kHFZwWOLpX97nKA/CfXc63+uBYyO/64UsIk b6MaVBCXV1bMzwGZbv7dhLsOJ X-Received: by 2002:a05:6000:1889:: with SMTP id a9mr22617175wri.141.1625582994539; Tue, 06 Jul 2021 07:49:54 -0700 (PDT) X-Received: by 2002:a05:6000:1889:: with SMTP id a9mr22617141wri.141.1625582994352; Tue, 06 Jul 2021 07:49:54 -0700 (PDT) Received: from ?IPv6:2001:b07:6468:f312:c8dd:75d4:99ab:290a? ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id n7sm3022759wmq.37.2021.07.06.07.49.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 06 Jul 2021 07:49:53 -0700 (PDT) Subject: Re: [RFC PATCH v2 00/69] KVM: X86: TDX support To: isaku.yamahata@intel.com, Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , erdemaktas@google.com, Connor Kuehl , Sean Christopherson , x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: isaku.yamahata@gmail.com References: From: Paolo Bonzini Message-ID: <23d1a076-1dee-cd97-0498-62df4c3ba05f@redhat.com> Date: Tue, 6 Jul 2021 16:49:52 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Based on the initial review, I think patches 2-3-17-18-19-20-23-49 can already be merged for 5.15. The next part should be the introduction of vm_types, blocking ioctls depending on the vm_type (patches 24-31) and possibly applying this block already to SEV-ES. On 03/07/21 00:04, isaku.yamahata@intel.com wrote: > From: Isaku Yamahata > > * What's TDX? > TDX stands for Trust Domain Extensions which isolates VMs from the > virtual-machine manager (VMM)/hypervisor and any other software on the > platform. [1] For details, the specifications, [2], [3], [4], [5], [6], [7], are > available. > > > * The goal of this RFC patch > The purpose of this post is to get feedback early on high level design issue of > KVM enhancement for TDX. The detailed coding (variable naming etc) is not cared > of. This patch series is incomplete (not working). So it's RFC. Although > multiple software components, not only KVM but also QEMU, guest Linux and > virtual bios, need to be updated, this includes only KVM VMM part. For those who > are curious to changes to other component, there are public repositories at > github. [8], [9] > > > * Patch organization > The patch 66 is main change. The preceding patches(1-65) The preceding > patches(01-61) are refactoring the code and introducing additional hooks. > > - 01-12: They are preparations. introduce architecture constants, code > refactoring, export symbols for following patches. > - 13-40: start to introduce the new type of VM and allow the coexistence of > multiple type of VM. allow/disallow KVM ioctl where > appropriate. Especially make per-system ioctl to per-VM ioctl. > - 41-65: refactoring KVM VMX/MMU and adding new hooks for Secure EPT. > - 66: main patch to add "basic" support for building/running TDX. > - 67: trace points for > - 68-69: Documentation > > * TODOs > Those major features are missing from this patch series to keep this patch > series small. > > - load/initialize TDX module > split out from this patch series. > - unmapping private page > Will integrate Kirill's patch to show how kvm will utilize it. > - qemu gdb stub support > - Large page support > - guest PMU support > - TDP MMU support > - and more > > Changes from v1: > - rebase to v5.13 > - drop load/initialization of TDX module > - catch up the update of related specifications. > - rework on C-wrapper function to invoke seamcall > - various code clean up > > [1] TDX specification > https://software.intel.com/content/www/us/en/develop/articles/intel-trust-domain-extensions.html > [2] Intel Trust Domain Extensions (Intel TDX) > https://software.intel.com/content/dam/develop/external/us/en/documents/tdx-whitepaper-final9-17.pdf > [3] Intel CPU Architectural Extensions Specification > https://software.intel.com/content/dam/develop/external/us/en/documents-tps/intel-tdx-cpu-architectural-specification.pdf > [4] Intel TDX Module 1.0 EAS > https://software.intel.com/content/dam/develop/external/us/en/documents/tdx-module-1eas-v0.85.039.pdf > [5] Intel TDX Loader Interface Specification > https://software.intel.com/content/dam/develop/external/us/en/documents-tps/intel-tdx-seamldr-interface-specification.pdf > [6] Intel TDX Guest-Hypervisor Communication Interface > https://software.intel.com/content/dam/develop/external/us/en/documents/intel-tdx-guest-hypervisor-communication-interface.pdf > [7] Intel TDX Virtual Firmware Design Guide > https://software.intel.com/content/dam/develop/external/us/en/documents/tdx-virtual-firmware-design-guide-rev-1.pdf > [8] intel public github > kvm TDX branch: https://github.com/intel/tdx/tree/kvm > TDX guest branch: https://github.com/intel/tdx/tree/guest > qemu TDX https://github.com/intel/qemu-tdx > [9] TDVF > https://github.com/tianocore/edk2-staging/tree/TDVF > > Isaku Yamahata (11): > KVM: TDX: introduce config for KVM TDX support > KVM: X86: move kvm_cpu_vmxon() from vmx.c to virtext.h > KVM: X86: move out the definition vmcs_hdr/vmcs from kvm to x86 > KVM: TDX: add a helper function for kvm to call seamcall > KVM: TDX: add trace point before/after TDX SEAMCALLs > KVM: TDX: Print the name of SEAMCALL status code > KVM: Add per-VM flag to mark read-only memory as unsupported > KVM: x86: add per-VM flags to disable SMI/INIT/SIPI > KVM: TDX: add trace point for TDVMCALL and SEPT operation > KVM: TDX: add document on TDX MODULE > Documentation/virtual/kvm: Add Trust Domain Extensions(TDX) > > Kai Huang (2): > KVM: x86: Add per-VM flag to disable in-kernel I/O APIC and level > routes > cpu/hotplug: Document that TDX also depends on booting CPUs once > > Rick Edgecombe (1): > KVM: x86: Add infrastructure for stolen GPA bits > > Sean Christopherson (53): > KVM: TDX: Add TDX "architectural" error codes > KVM: TDX: Add architectural definitions for structures and values > KVM: TDX: define and export helper functions for KVM TDX support > KVM: TDX: Add C wrapper functions for TDX SEAMCALLs > KVM: Export kvm_io_bus_read for use by TDX for PV MMIO > KVM: Enable hardware before doing arch VM initialization > KVM: x86: Split core of hypercall emulation to helper function > KVM: x86: Export kvm_mmio tracepoint for use by TDX for PV MMIO > KVM: x86/mmu: Zap only leaf SPTEs for deleted/moved memslot by default > KVM: Add infrastructure and macro to mark VM as bugged > KVM: Export kvm_make_all_cpus_request() for use in marking VMs as > bugged > KVM: x86: Use KVM_BUG/KVM_BUG_ON to handle bugs that are fatal to the > VM > KVM: x86/mmu: Mark VM as bugged if page fault returns RET_PF_INVALID > KVM: Add max_vcpus field in common 'struct kvm' > KVM: x86: Add vm_type to differentiate legacy VMs from protected VMs > KVM: x86: Hoist kvm_dirty_regs check out of sync_regs() > KVM: x86: Introduce "protected guest" concept and block disallowed > ioctls > KVM: x86: Add per-VM flag to disable direct IRQ injection > KVM: x86: Add flag to disallow #MC injection / KVM_X86_SETUP_MCE > KVM: x86: Add flag to mark TSC as immutable (for TDX) > KVM: Add per-VM flag to disable dirty logging of memslots for TDs > KVM: x86: Allow host-initiated WRMSR to set X2APIC regardless of CPUID > KVM: x86: Add kvm_x86_ops .cache_gprs() and .flush_gprs() > KVM: x86: Add support for vCPU and device-scoped KVM_MEMORY_ENCRYPT_OP > KVM: x86: Introduce vm_teardown() hook in kvm_arch_vm_destroy() > KVM: x86: Add a switch_db_regs flag to handle TDX's auto-switched > behavior > KVM: x86: Check for pending APICv interrupt in kvm_vcpu_has_events() > KVM: x86: Add option to force LAPIC expiration wait > KVM: x86: Add guest_supported_xss placholder > KVM: Export kvm_is_reserved_pfn() for use by TDX > KVM: x86/mmu: Explicitly check for MMIO spte in fast page fault > KVM: x86/mmu: Allow non-zero init value for shadow PTE > KVM: x86/mmu: Refactor shadow walk in __direct_map() to reduce > indentation > KVM: x86/mmu: Return old SPTE from mmu_spte_clear_track_bits() > KVM: x86/mmu: Frame in support for private/inaccessible shadow pages > KVM: x86/mmu: Move 'pfn' variable to caller of direct_page_fault() > KVM: x86/mmu: Introduce kvm_mmu_map_tdp_page() for use by TDX > KVM: VMX: Modify NMI and INTR handlers to take intr_info as param > KVM: VMX: Move NMI/exception handler to common helper > KVM: x86/mmu: Allow per-VM override of the TDP max page level > KVM: VMX: Split out guts of EPT violation to common/exposed function > KVM: VMX: Define EPT Violation architectural bits > KVM: VMX: Define VMCS encodings for shared EPT pointer > KVM: VMX: Add 'main.c' to wrap VMX and TDX > KVM: VMX: Move setting of EPT MMU masks to common VT-x code > KVM: VMX: Move register caching logic to common code > KVM: TDX: Define TDCALL exit reason > KVM: TDX: Stub in tdx.h with structs, accessors, and VMCS helpers > KVM: VMX: Add macro framework to read/write VMCS for VMs and TDs > KVM: VMX: Move AR_BYTES encoder/decoder helpers to common.h > KVM: VMX: MOVE GDT and IDT accessors to common code > KVM: VMX: Move .get_interrupt_shadow() implementation to common VMX > code > KVM: TDX: Add "basic" support for building and running Trust Domains > > Xiaoyao Li (2): > KVM: TDX: Introduce pr_seamcall_ex_ret_info() to print more info when > SEAMCALL fails > KVM: X86: Introduce initial_tsc_khz in struct kvm_arch > > Documentation/virt/kvm/api.rst | 6 +- > Documentation/virt/kvm/intel-tdx.rst | 441 ++++++ > Documentation/virt/kvm/tdx-module.rst | 48 + > arch/arm64/include/asm/kvm_host.h | 3 - > arch/arm64/kvm/arm.c | 7 +- > arch/arm64/kvm/vgic/vgic-init.c | 6 +- > arch/x86/Kbuild | 1 + > arch/x86/include/asm/cpufeatures.h | 2 + > arch/x86/include/asm/kvm-x86-ops.h | 8 + > arch/x86/include/asm/kvm_boot.h | 30 + > arch/x86/include/asm/kvm_host.h | 55 +- > arch/x86/include/asm/virtext.h | 25 + > arch/x86/include/asm/vmx.h | 17 + > arch/x86/include/uapi/asm/kvm.h | 60 + > arch/x86/include/uapi/asm/vmx.h | 7 +- > arch/x86/kernel/asm-offsets_64.c | 15 + > arch/x86/kvm/Kconfig | 11 + > arch/x86/kvm/Makefile | 3 +- > arch/x86/kvm/boot/Makefile | 6 + > arch/x86/kvm/boot/seam/tdx_common.c | 242 +++ > arch/x86/kvm/boot/seam/tdx_common.h | 13 + > arch/x86/kvm/ioapic.c | 4 + > arch/x86/kvm/irq_comm.c | 13 +- > arch/x86/kvm/lapic.c | 7 +- > arch/x86/kvm/lapic.h | 2 +- > arch/x86/kvm/mmu.h | 31 +- > arch/x86/kvm/mmu/mmu.c | 526 +++++-- > arch/x86/kvm/mmu/mmu_internal.h | 3 + > arch/x86/kvm/mmu/paging_tmpl.h | 25 +- > arch/x86/kvm/mmu/spte.c | 15 +- > arch/x86/kvm/mmu/spte.h | 18 +- > arch/x86/kvm/svm/svm.c | 18 +- > arch/x86/kvm/trace.h | 138 ++ > arch/x86/kvm/vmx/common.h | 178 +++ > arch/x86/kvm/vmx/main.c | 1098 ++++++++++++++ > arch/x86/kvm/vmx/posted_intr.c | 6 + > arch/x86/kvm/vmx/seamcall.S | 64 + > arch/x86/kvm/vmx/seamcall.h | 68 + > arch/x86/kvm/vmx/tdx.c | 1958 +++++++++++++++++++++++++ > arch/x86/kvm/vmx/tdx.h | 267 ++++ > arch/x86/kvm/vmx/tdx_arch.h | 370 +++++ > arch/x86/kvm/vmx/tdx_errno.h | 202 +++ > arch/x86/kvm/vmx/tdx_ops.h | 218 +++ > arch/x86/kvm/vmx/tdx_stubs.c | 45 + > arch/x86/kvm/vmx/vmcs.h | 11 - > arch/x86/kvm/vmx/vmenter.S | 146 ++ > arch/x86/kvm/vmx/vmx.c | 509 ++----- > arch/x86/kvm/x86.c | 285 +++- > include/linux/kvm_host.h | 51 +- > include/uapi/linux/kvm.h | 2 + > kernel/cpu.c | 4 + > tools/arch/x86/include/uapi/asm/kvm.h | 55 + > tools/include/uapi/linux/kvm.h | 2 + > virt/kvm/kvm_main.c | 44 +- > 54 files changed, 6717 insertions(+), 672 deletions(-) > create mode 100644 Documentation/virt/kvm/intel-tdx.rst > create mode 100644 Documentation/virt/kvm/tdx-module.rst > create mode 100644 arch/x86/include/asm/kvm_boot.h > create mode 100644 arch/x86/kvm/boot/Makefile > create mode 100644 arch/x86/kvm/boot/seam/tdx_common.c > create mode 100644 arch/x86/kvm/boot/seam/tdx_common.h > create mode 100644 arch/x86/kvm/vmx/common.h > create mode 100644 arch/x86/kvm/vmx/main.c > create mode 100644 arch/x86/kvm/vmx/seamcall.S > create mode 100644 arch/x86/kvm/vmx/seamcall.h > create mode 100644 arch/x86/kvm/vmx/tdx.c > create mode 100644 arch/x86/kvm/vmx/tdx.h > create mode 100644 arch/x86/kvm/vmx/tdx_arch.h > create mode 100644 arch/x86/kvm/vmx/tdx_errno.h > create mode 100644 arch/x86/kvm/vmx/tdx_ops.h > create mode 100644 arch/x86/kvm/vmx/tdx_stubs.c >