[RFC PATCH 10/10] KVM: x86/mmu: make FNAME(fetch) receive single argument

2021-04-20 Thread Isaku Yamahata
Convert FNAME(fetch) to receive single argument, struct kvm_page_fault instead of many arguments. No functional change is intended. Signed-off-by: Isaku Yamahata --- arch/x86/kvm/mmu/paging_tmpl.h | 36 +++--- 1 file changed, 16 insertions(+), 20 deletions(-) diff

[RFC PATCH 09/10] KVM: x86/mmu: make kvm_tdp_mmu_map() receive single argument

2021-04-20 Thread Isaku Yamahata
Convert kvm_tdp_mmu_map() to receive single argument, struct kvm_page_fault instead of many arguments. No functional change is intended. Signed-off-by: Isaku Yamahata --- arch/x86/kvm/mmu/mmu.c | 8 +--- arch/x86/kvm/mmu/tdp_mmu.c | 21 +++-- arch/x86/kvm/mmu/tdp_mmu.h

[RFC PATCH 08/10] KVM: x86/mmu: make __direct_map() receive single argument

2021-04-20 Thread Isaku Yamahata
Convert __direct_map() to receive single argument, struct kvm_page_fault instead of many arguments. No functional change is intended. Signed-off-by: Isaku Yamahata --- arch/x86/kvm/mmu/mmu.c | 27 --- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/arch

[RFC PATCH 07/10] KVM: x86/mmu: make fast_page_fault() receive single argument

2021-04-20 Thread Isaku Yamahata
Convert fast_page_fault() to receive single argument, struct kvm_page_fault instead of many arguments. No functional change is intended. Signed-off-by: Isaku Yamahata --- arch/x86/kvm/mmu/mmu.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/mmu/mmu.c b

[RFC PATCH 06/10] KVM: x86/mmu: make handle_abnormal_pfn() receive single argument

2021-04-20 Thread Isaku Yamahata
Convert handle_abnormal_pfn() to receive single argument, struct kvm_page_fault, instead of many arguments. No functional change is intended. Signed-off-by: Isaku Yamahata --- arch/x86/kvm/mmu/mmu.c | 14 -- arch/x86/kvm/mmu/paging_tmpl.h | 2 +- 2 files changed, 9

[RFC PATCH 05/10] KVM: x86/mmu: make page_fault_handle_page_track() receive single argument

2021-04-20 Thread Isaku Yamahata
Convert page_fault_handle_page_trace() to receive single argument, struct kvm_page_fault, instead of many arguments. No functional change is intended. Signed-off-by: Isaku Yamahata --- arch/x86/kvm/mmu/mmu.c | 9 + arch/x86/kvm/mmu/paging_tmpl.h | 4 ++-- 2 files changed, 7

[RFC PATCH 04/10] KVM: x86/mmu: make try_async_pf() receive single argument

2021-04-20 Thread Isaku Yamahata
Convert try_async_pf() to receive single struct kvm_page_fault instead of many arguments. No functional change is intended. Signed-off-by: Isaku Yamahata --- arch/x86/kvm/mmu.h | 9 +++ arch/x86/kvm/mmu/mmu.c | 45 +- arch/x86/kvm/mmu

[RFC PATCH 02/10] KVM: x86/mmu: make kvm_mmu:page_fault receive single argument

2021-04-20 Thread Isaku Yamahata
Convert kvm_mmu:page_fault callback to receive struct kvm_page_fault instead of many arguments. The following functions are converted by this patch. kvm_tdp_page_fault(), nonpaging_page_fault() and, FNAME(page_fault). No functional change is intended. Signed-off-by: Isaku Yamahata --- arch/x86

[RFC PATCH 03/10] KVM: x86/mmu: make direct_page_fault() receive single argument

2021-04-20 Thread Isaku Yamahata
Convert direct_page_fault() to receive struct kvm_page_fault instead of many arguments. No functional change is intended. Signed-off-by: Isaku Yamahata --- arch/x86/kvm/mmu.h | 10 ++ arch/x86/kvm/mmu/mmu.c | 32 2 files changed, 30 insertions

[RFC PATCH 01/10] KVM: x86/mmu: make kvm_mmu_do_page_fault() receive single argument

2021-04-20 Thread Isaku Yamahata
Introduce struct kvm_page_fault handler and its initialization function. Make the caller of kvm page fault handler allocate/initialize struct kvm_page_fault, and pass it to kvm_mmu_do_page_fault() instead of many arguments. No functional change is intended. Signed-off-by: Isaku Yamahata

[RFC PATCH 00/10] KVM: x86/mmu: simplify argument to kvm page fault handler

2021-04-20 Thread Isaku Yamahata
() . __direct_map() . kvm_tdp_mmu_map() . FNAME(fetch) Probably more functions should be converted. or some should not converted. Only code refactoring and no functional change is intended. Isaku Yamahata (10): KVM: x86/mmu: make kvm_mmu_do_page_fault() receive single argument KVM: x86/mmu: make

[tip: x86/urgent] x86/mem_encrypt: Correct physical address calculation in __set_clr_pte_enc()

2021-03-23 Thread tip-bot2 for Isaku Yamahata
The following commit has been merged into the x86/urgent branch of tip: Commit-ID: 8249d17d3194eac064a8ca5bc5ca0abc86feecde Gitweb: https://git.kernel.org/tip/8249d17d3194eac064a8ca5bc5ca0abc86feecde Author:Isaku Yamahata AuthorDate:Thu, 18 Mar 2021 13:26:57 -07:00

[PATCH] X86: __set_clr_pte_enc() miscalculates physical address

2021-03-18 Thread Isaku Yamahata
boot") Reviewed-by: Kirill A. Shutemov Signed-off-by: Isaku Yamahata --- arch/x86/mm/mem_encrypt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/mm/mem_encrypt.c b/arch/x86/mm/mem_encrypt.c index 4b01f7dbaf30..ae78cef79980 100644 --- a/arch/x86/mm/mem_encrypt.c

[RFC PATCH 22/67] KVM: Add per-VM flag to mark read-only memory as unsupported

2020-11-16 Thread isaku . yamahata
From: Isaku Yamahata Add a flag for TDX to flag RO memory as unsupported and propagate it to KVM_MEM_READONLY to allow reporting RO memory as unsupported on a per-VM basis. TDX1 doesn't expose permission bits to the VMM in the SEPT tables, i.e. doesn't support read-only private memory. Signed

[RFC PATCH 17/67] KVM: x86: Introduce "protected guest" concept and block disallowed ioctls

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Add 'guest_state_protected' to mark a VM's state as being protected by hardware/firmware, e.g. SEV-ES or TDX-SEAM. Use the flag to disallow ioctls() and/or flows that attempt to access protected state. Return an error if userspace attempts to get/set register state

[RFC PATCH 30/67] KVM: x86: Check for pending APICv interrupt in kvm_vcpu_has_events()

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Return true for kvm_vcpu_has_events() if the vCPU has a pending APICv interrupt to support TDX's usage of APICv. Unlike VMX, TDX doesn't have access to vmcs.GUEST_INTR_STATUS and so can't emulate posted interrupts, i.e. needs to generate a posted interrupt and more

[RFC PATCH 04/67] KVM: Export kvm_io_bus_read for use by TDX for PV MMIO

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Signed-off-by: Sean Christopherson --- virt/kvm/kvm_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 2541a17ff1c4..65e1737c4354 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -4288,6 +4288,7 @@

[RFC PATCH 06/67] KVM: x86: Split core of hypercall emulation to helper function

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson By necessity, TDX will use a different register ABI for hypercalls. Break out the core functionality so that it may be reused for TDX. Signed-off-by: Sean Christopherson --- arch/x86/include/asm/kvm_host.h | 4 +++ arch/x86/kvm/x86.c | 49

[RFC PATCH 25/67] KVM: x86: Allow host-initiated WRMSR to set X2APIC regardless of CPUID

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Let userspace, or in the case of TDX, KVM itself, enable X2APIC even if X2APIC is not reported as supported in the guest's CPU model. KVM generally does not force specific ordering between ioctls(), e.g. this forces userspace to configure CPUID before MSRs. And for

[RFC PATCH 10/67] KVM: Export kvm_make_all_cpus_request() for use in marking VMs as bugged

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Export kvm_make_all_cpus_request() and hoist the request helper declarations of request up to the KVM_REQ_* definitions in preparation for adding a "VM bugged" framework. The framework will add KVM_BUG() and KVM_BUG_ON() as alternatives to full BUG()/BUG_ON() for cases

[RFC PATCH 09/67] KVM: Add infrastructure and macro to mark VM as bugged

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Signed-off-by: Sean Christopherson --- include/linux/kvm_host.h | 27 +++ virt/kvm/kvm_main.c | 10 +- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index

[RFC PATCH 15/67] KVM: x86: Add vm_type to differentiate legacy VMs from protected VMs

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Add a capability to effectively allow userspace to query what VM types are supported by KVM. Co-developed-by: Xiaoyao Li Signed-off-by: Xiaoyao Li Signed-off-by: Sean Christopherson --- arch/x86/include/asm/kvm_host.h | 2 ++ arch/x86/include/uapi/asm/kvm.h

[RFC PATCH 13/67] KVM: VMX: Explicitly check for hv_remote_flush_tlb when loading pgd()

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Explicitly check that kvm_x86_ops.tlb_remote_flush() points at Hyper-V's implementation for PV flushing instead of assuming that a non-NULL implemenation means running on Hyper-V. Wrap the related logic in ifdeffery as hv_remote_flush_tlb() is defined iff

[RFC PATCH 20/67] KVM: x86: Make KVM_CAP_X86_SMM a per-VM capability

2020-11-16 Thread isaku . yamahata
From: Isaku Yamahata TDX doesn't support SMM, whereas VMX conditionally support SMM. Rework kvm_x86_ops.has_emulated_msr() to take a struct kvm so that TDX can reject SMM by way of the MSR_IA32_SMBASE check. This pair with a QEMU change to query SMM support using a VM ioctl(). Signed-off

[RFC PATCH 12/67] KVM: x86/mmu: Mark VM as bugged if page fault returns RET_PF_INVALID

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Signed-off-by: Sean Christopherson --- arch/x86/kvm/mmu/mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index 3c7e43e12513..bebd2b6ebcad 100644 --- a/arch/x86/kvm/mmu/mmu.c +++

[RFC PATCH 16/67] KVM: x86: Hoist kvm_dirty_regs check out of sync_regs()

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Move the kvm_dirty_regs vs. KVM_SYNC_X86_VALID_FIELDS check out of sync_regs() and into its sole caller, kvm_arch_vcpu_ioctl_run(). This allows a future patch to allow synchronizing select state for protected VMs. Signed-off-by: Sean Christopherson ---

[RFC PATCH 24/67] KVM: x86: Add per-VM flag to disable in-kernel I/O APIC and level routes

2020-11-16 Thread isaku . yamahata
From: Kai Huang Add a flag to let TDX disallow the in-kernel I/O APIC, level triggered routes for a userspace I/O APIC, and anything else that relies on being able to intercept EOIs. TDX-SEAM does not allow intercepting EOI. Note, technically KVM could partially emulate the I/O APIC by

[RFC PATCH 19/67] KVM: x86: Add flag to disallow #MC injection / KVM_X86_SETUP_MCE

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Add a flag to disallow MCE injection and reject KVM_X86_SETUP_MCE with -EINVAL when set. TDX doesn't support injecting exceptions, including (virtual) #MCs. Signed-off-by: Kai Huang Co-developed-by: Sean Christopherson Signed-off-by: Sean Christopherson ---

[RFC PATCH 03/67] x86/cpu: Move get_builtin_firmware() common code (from microcode only)

2020-11-16 Thread isaku . yamahata
From: Zhang Chen Move get_builtin_firmware() to common.c so that it can be used to get non-ucode firmware, e.g. Intel's SEAM modules, even if MICROCODE=n. Require the consumers to select FW_LOADER, which is already true for MICROCODE, instead of having dead code that returns false at runtime.

[RFC PATCH 11/67] KVM: x86: Use KVM_BUG/KVM_BUG_ON to handle bugs that are fatal to the VM

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Signed-off-by: Sean Christopherson --- arch/x86/kvm/svm/svm.c | 2 +- arch/x86/kvm/vmx/vmx.c | 23 ++- arch/x86/kvm/x86.c | 4 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/arch/x86/kvm/svm/svm.c

[RFC PATCH 07/67] KVM: x86: Export kvm_mmio tracepoint for use by TDX for PV MMIO

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Signed-off-by: Sean Christopherson --- arch/x86/kvm/x86.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 0f67f762717a..1d999b57f21a 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -11237,6 +11237,7 @@ int

[RFC PATCH 00/67] KVM: X86: TDX support

2020-11-16 Thread isaku . yamahata
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

[RFC PATCH 14/67] KVM: Add max_vcpus field in common 'struct kvm'

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Signed-off-by: Sean Christopherson --- arch/arm64/include/asm/kvm_host.h | 3 --- arch/arm64/kvm/arm.c | 7 ++- arch/arm64/kvm/vgic/vgic-init.c | 6 +++--- include/linux/kvm_host.h | 1 + virt/kvm/kvm_main.c | 3 ++- 5 files

[RFC PATCH 44/67] KVM: VMX: Modify NMI and INTR handlers to take intr_info as param

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Pass intr_info to the NMI and INTR handlers instead of pulling it from vcpu_vmx in preparation for sharing the bulk of the handlers with TDX. Signed-off-by: Sean Christopherson --- arch/x86/kvm/vmx/vmx.c | 16 ++-- 1 file changed, 6 insertions(+), 10

[RFC PATCH 42/67] KVM: x86/mmu: Move 'pfn' variable to caller of direct_page_fault()

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson When adding pages prior to boot, TDX will need the resulting host pfn so that it can be passed to TDADDPAGE (TDX-SEAM always works with physical addresses as it has its own page tables). Start plumbing pfn back up the page fault stack. Signed-off-by: Sean

[RFC PATCH 46/67] KVM: VMX: Split out guts of EPT violation to common/exposed function

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Signed-off-by: Sean Christopherson --- arch/x86/kvm/vmx/common.h | 29 + arch/x86/kvm/vmx/vmx.c| 32 +--- 2 files changed, 34 insertions(+), 27 deletions(-) diff --git a/arch/x86/kvm/vmx/common.h

[RFC PATCH 56/67] KVM: TDX: Add macro framework to wrap TDX SEAMCALLs

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Co-developed-by: Kai Huang Signed-off-by: Kai Huang Co-developed-by: Xiaoyao Li Signed-off-by: Xiaoyao Li Signed-off-by: Sean Christopherson --- arch/x86/kvm/vmx/tdx_ops.h | 531 + 1 file changed, 531 insertions(+) create mode

[RFC PATCH 33/67] KVM: Export kvm_is_reserved_pfn() for use by TDX

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson TDX will use kvm_is_reserved_pfn() to prevent installing a reserved PFN int SEPT. Or rather, to prevent such an attempt, as reserved PFNs are not covered by TDMRs. Signed-off-by: Sean Christopherson --- virt/kvm/kvm_main.c | 1 + 1 file changed, 1 insertion(+) diff

[RFC PATCH 39/67] KVM: x86/mmu: Refactor shadow walk in __direct_map() to reduce indentation

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Employ a 'continue' to reduce the indentation for linking a new shadow page during __direct_map() in preparation for linking private pages. Signed-off-by: Sean Christopherson --- arch/x86/kvm/mmu/mmu.c | 19 +-- 1 file changed, 9 insertions(+), 10

[RFC PATCH 63/67] cpu/hotplug: Document that TDX also depends on booting CPUs once

2020-11-16 Thread isaku . yamahata
From: Kai Huang Add a comment to explain that TDX also depends on booting logical CPUs at least once. TDSYSINITLP must be run on all CPUs, even software disabled CPUs in the -nosmt case. Fortunately, current SMT handling for #MC already supports booting all CPUs once; the to-be-disabled

[RFC PATCH 29/67] KVM: x86: Add a switch_db_regs flag to handle TDX's auto-switched behavior

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Add a flag, KVM_DEBUGREG_AUTO_SWITCHED, to skip saving/restoring DRs irrespective of any other flags. TDX-SEAM unconditionally saves and restores host DRs, ergo there is nothing to do. Opportunistically convert the KVM_DEBUGREG_* definitions to use BIT().

[RFC PATCH 57/67] KVM: TDX: Stub in tdx.h with structs, accessors, and VMCS helpers

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Stub in kvm_tdx, vcpu_tdx, their various accessors, and VMCS helpers. The VMCS helpers, which rely on the stubs, will be used by preparatory patches to move VMX functions for accessing VMCS state to common code. Signed-off-by: Sean Christopherson ---

[RFC PATCH 34/67] KVM: x86: Add infrastructure for stolen GPA bits

2020-11-16 Thread isaku . yamahata
From: Rick Edgecombe Add support in KVM's MMU for aliasing multiple GPAs (from a hardware perspective) to a single GPA (from a memslot perspective). GPA alising will be used to repurpose GPA bits as attribute bits, e.g. to expose an execute-only permission bit to the guest. To keep the

[RFC PATCH 65/67] KVM: x86: Mark the VM (TD) as bugged if non-coherent DMA is detected

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson TDX is not supported on platforms with non-coherent IOMMUs, freak out if one is encountered, and because SEPT doesn't allow the memtype control that's needed to support non-coherent DMA. Signed-off-by: Sean Christopherson --- arch/x86/kvm/x86.c | 1 + 1 file changed,

[RFC PATCH 55/67] KVM: TDX: Add SEAMRR related MSRs macro definition

2020-11-16 Thread isaku . yamahata
From: Kai Huang Two new MSRs IA32_SEAMRR_PHYS_BASE and IA32_SEAMRR_PHYS_MASK are added in SPR for TDX. Add macro definition for both of them. Signed-off-by: Kai Huang --- arch/x86/include/asm/msr-index.h | 8 1 file changed, 8 insertions(+) diff --git

[RFC PATCH 60/67] KVM: VMX: MOVE GDT and IDT accessors to common code

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Signed-off-by: Sean Christopherson --- arch/x86/kvm/vmx/main.c | 6 -- arch/x86/kvm/vmx/vmx.c | 12 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/arch/x86/kvm/vmx/main.c b/arch/x86/kvm/vmx/main.c index 30b1815fd5a7..53e1ea8df861

[RFC PATCH 36/67] KVM: x86/mmu: Track shadow MMIO value on a per-VM basis

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Signed-off-by: Sean Christopherson --- arch/x86/include/asm/kvm_host.h | 2 ++ arch/x86/kvm/mmu.h | 4 +++- arch/x86/kvm/mmu/mmu.c | 24 +++- arch/x86/kvm/mmu/spte.c | 26 ++

[RFC PATCH 32/67] KVM: x86: Add guest_supported_xss placholder

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Add a per-vcpu placeholder for the support XSS of the guest so that the TDX configuration code doesn't need to hack in manual computation of the supported XSS. KVM XSS enabling is currently being upstreamed, i.e. guest_supported_xss will no longer be a placeholder by

[RFC PATCH 53/67] KVM: TDX: Add architectural definitions for structures and values

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Co-developed-by: Kai Huang Signed-off-by: Kai Huang Co-developed-by: Xiaoyao Li Signed-off-by: Xiaoyao Li Signed-off-by: Sean Christopherson --- arch/x86/kvm/vmx/tdx_arch.h | 230 1 file changed, 230 insertions(+) create mode

[RFC PATCH 40/67] KVM: x86/mmu: Return old SPTE from mmu_spte_clear_track_bits()

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Return the old SPTE when clearing a SPTE and push the "old SPTE present" check to the caller. Private shadow page support will use the old SPTE in rmap_remove() to determine whether or not there is a linked private shadow page. Signed-off-by: Sean Christopherson ---

[RFC PATCH 49/67] KVM: VMX: Add 'main.c' to wrap VMX and TDX

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Wrap the VMX kvm_x86_ops hooks in preparation of adding TDX, which can coexist with VMX, i.e. KVM can run both VMs and TDs. Use 'vt' for the naming scheme as a nod to VT-x and as a concatenation of VmxTdx. Co-developed-by: Xiaoyao Li Signed-off-by: Xiaoyao Li

[RFC PATCH 41/67] KVM: x86/mmu: Frame in support for private/inaccessible shadow pages

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Add kvm_x86_ops hooks to set/clear private SPTEs, i.e. SEPT entries, and to link/free private shadow pages, i.e. non-leaf SEPT pages. Because SEAMCALLs are bloody expensive, and because KVM's MMU is already complex enough, TDX's SEPT will mirror KVM's shadow pages

[RFC PATCH 59/67] KVM: VMX: Move AR_BYTES encoder/decoder helpers to common.h

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Move the AR_BYTES helpers to common.h so that future patches can reuse them to decode/encode AR for TDX. Signed-off-by: Sean Christopherson --- arch/x86/kvm/vmx/common.h | 41 ++ arch/x86/kvm/vmx/vmx.c| 46

[RFC PATCH 35/67] KVM: x86/mmu: Explicitly check for MMIO spte in fast page fault

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Explicity check for an MMIO spte in the fast page fault flow. TDX will use a not-present entry for MMIO sptes, which can be mistaken for an access-tracked spte since both have SPTE_SPECIAL_MASK set. Signed-off-by: Sean Christopherson --- arch/x86/kvm/mmu/mmu.c | 2

[RFC PATCH 28/67] KVM: x86: Introduce vm_teardown() hook in kvm_arch_vm_destroy()

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Add a second kvm_x86_ops hook in kvm_arch_vm_destroy() to support TDX's destruction path, which needs to first put the VM into a teardown state, then free per-vCPU resource, and finally free per-VM resources. Note, this knowingly creates a discrepancy in nomenclature

[RFC PATCH 45/67] KVM: VMX: Move NMI/exception handler to common helper

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Signed-off-by: Sean Christopherson --- arch/x86/kvm/vmx/common.h | 54 +++ arch/x86/kvm/vmx/vmx.c| 42 +- 2 files changed, 60 insertions(+), 36 deletions(-) create mode 100644

[RFC PATCH 61/67] KVM: VMX: Move .get_interrupt_shadow() implementation to common VMX code

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Signed-off-by: Sean Christopherson --- arch/x86/kvm/vmx/common.h | 14 ++ arch/x86/kvm/vmx/vmx.c| 10 +- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/arch/x86/kvm/vmx/common.h b/arch/x86/kvm/vmx/common.h index

[RFC PATCH 66/67] fixup! KVM: TDX: Add "basic" support for building and running Trust Domains

2020-11-16 Thread isaku . yamahata
From: Isaku Yamahata --- arch/x86/kvm/vmx/tdx.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c index adcb866861b7..d2c1766416f2 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -331,9 +331,6 @@ static int tdx_vm_init

[RFC PATCH 31/67] KVM: x86: Add option to force LAPIC expiration wait

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Add an option to skip the IRR check in kvm_wait_lapic_expire(). This will be used by TDX to wait if there is an outstanding notification for a TD, i.e. a virtual interrupt is being triggered via posted interrupt processing. KVM TDX doesn't emulate PI processing, i.e.

[RFC PATCH 27/67] KVM: x86: Add support for vCPU and device-scoped KVM_MEMORY_ENCRYPT_OP

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Signed-off-by: Sean Christopherson --- arch/x86/include/asm/kvm_host.h | 2 ++ arch/x86/kvm/x86.c | 12 2 files changed, 14 insertions(+) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index

[RFC PATCH 37/67] KVM: x86/mmu: Ignore bits 63 and 62 when checking for "present" SPTEs

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Ignore bits 63 and 62 when checking for present SPTEs to allow setting said bits in not-present SPTEs. TDX will set bit 63 in "zero" SPTEs to suppress #VEs (TDX-SEAM unconditionally enables EPT Violation #VE), and will use bit 62 to track zapped private SPTEs.

[RFC PATCH 58/67] KVM: VMX: Add macro framework to read/write VMCS for VMs and TDs

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Add a macro framework to hide VMX vs. TDX details of VMREAD and VMWRITE so the VMX and TDX can shared common flows, e.g. accessing DTs. Note, the TDX paths are dead code at this time. There is no great way to deal with the chicken-and-egg scenario of having things in

[RFC PATCH 51/67] KVM: VMX: Move register caching logic to common code

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Move the guts of vmx_cache_reg() to vt_cache_reg() in preparation for reusing the bulk of the code for TDX, which can access guest state for debug TDs. Use kvm_x86_ops.cache_reg() in ept_update_paging_mode_cr0() rather than trying to expose vt_cache_reg() to vmx.c,

[RFC PATCH 18/67] KVM: x86: Add per-VM flag to disable direct IRQ injection

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Add a flag to disable IRQ injection, which is not supported by TDX. Signed-off-by: Sean Christopherson --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/x86.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git

[RFC PATCH 52/67] KVM: TDX: Add TDX "architectural" error codes

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson TDX-SEAM uses bits 31:0 to return more information, so these error codes will only exactly match RAX[63:32]. Signed-off-by: Sean Christopherson --- arch/x86/kvm/vmx/tdx_errno.h | 91 1 file changed, 91 insertions(+) create mode

[RFC PATCH 38/67] KVM: x86/mmu: Allow non-zero init value for shadow PTE

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson TDX will run with EPT violation #VEs enabled, which means KVM needs to set the "suppress #VE" bit in unused PTEs to avoid unintentionally reflecting not-present EPT violations into the guest. Signed-off-by: Sean Christopherson --- arch/x86/kvm/mmu.h | 1 +

[RFC PATCH 54/67] KVM: TDX: Define TDCALL exit reason

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Define the TDCALL exit reason, which is carved out from the VMX exit reason namespace as the TDCALL exit from TDX guest to TDX-SEAM is really just a VM-Exit. Co-developed-by: Xiaoyao Li Signed-off-by: Xiaoyao Li Signed-off-by: Sean Christopherson ---

[RFC PATCH 64/67] KVM: TDX: Add "basic" support for building and running Trust Domains

2020-11-16 Thread isaku . yamahata
-developed-by: Isaku Yamahata Signed-off-by: Isaku Yamahata Signed-off-by: Sean Christopherson --- arch/x86/include/uapi/asm/kvm.h | 51 + arch/x86/kvm/trace.h | 57 + arch/x86/kvm/vmx/common.h |1 + arch/x86/kvm/vmx/main.c | 384 - arch/x86

[RFC PATCH 02/67] x86/msr-index: Define MSR_IA32_MKTME_KEYID_PART used by TDX

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Define MSR_IA32_MKTME_KEYID_PART, used by TDX to enumerate the TDX KeyID space, which is carved out from the regular MKTME KeyIDs. Signed-off-by: Sean Christopherson --- arch/x86/include/asm/msr-index.h | 2 ++ 1 file changed, 2 insertions(+) diff --git

[RFC PATCH 50/67] KVM: VMX: Move setting of EPT MMU masks to common VT-x code

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Signed-off-by: Sean Christopherson --- arch/x86/kvm/vmx/main.c | 17 + arch/x86/kvm/vmx/vmx.c | 13 - 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/arch/x86/kvm/vmx/main.c b/arch/x86/kvm/vmx/main.c index

[RFC PATCH 05/67] KVM: Enable hardware before doing arch VM initialization

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Swap the order of hardware_enable_all() and kvm_arch_init_vm() to accommodate Intel's TDX, which needs VMX to be enabled during VM init in order to make SEAMCALLs. This also provides consistent ordering between kvm_create_vm() and kvm_destroy_vm() with respect to

[RFC PATCH 01/67] x86/cpufeatures: Add synthetic feature flag for TDX (in host)

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Signed-off-by: Sean Christopherson --- arch/x86/include/asm/cpufeatures.h | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index dad350d42ecf..1bd2a414dcc0 100644 ---

[RFC PATCH 23/67] KVM: Add per-VM flag to disable dirty logging of memslots for TDs

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Add a flag for TDX to mark dirty logging as unsupported. Suggested-by: Kai Huang Signed-off-by: Sean Christopherson --- include/linux/kvm_host.h | 1 + virt/kvm/kvm_main.c | 5 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git

[RFC PATCH 43/67] KVM: x86/mmu: Introduce kvm_mmu_map_tdp_page() for use by TDX

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Introduce a helper to directly (pun intented) fault-in a TDP page without having to go through the full page fault path. This allows TDX to get the resulting pfn and also allows the RET_PF_* enums to stay in mmu.c where they belong. Signed-off-by: Sean Christopherson

[RFC PATCH 21/67] KVM: x86: Add flag to mark TSC as immutable (for TDX)

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson The TSC for TDX1 guests is fixed at TD creation time. Add tsc_immutable to reflect that the TSC of the guest cannot be changed in any way, and use it to short circuit all paths that lead to one of the myriad TSC adjustment flows. Suggested-by: Kai Huang

[RFC PATCH 48/67] KVM: VMX: Define VMCS encodings for shared EPT pointer

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Add the VMCS field encoding for the shared EPTP, which will be used by TDX to have separate EPT walks for private GPAs (existing EPTP) versus shared GPAs (new shared EPTP). Signed-off-by: Sean Christopherson --- arch/x86/include/asm/vmx.h | 2 ++ 1 file changed, 2

[RFC PATCH 26/67] KVM: x86: Add kvm_x86_ops .cache_gprs() and .flush_gprs()

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Add hooks to cache and flush GPRs and invoke them from KVM_GET_REGS and KVM_SET_REGS respecitively. TDX will use the hooks to read/write GPRs from TDX-SEAM on-demand (for debug TDs). Cc: Tom Lendacky Signed-off-by: Sean Christopherson ---

[RFC PATCH 67/67] KVM: X86: not for review: add dummy file for TDX-SEAM module

2020-11-16 Thread isaku . yamahata
From: Isaku Yamahata This patch is not for review, but to make build success. Add dummy empty file for TDX-SEAM module as linux/lib/firmware/intel-seam/libtdx.so. TDX-SEAM module isn't published. Its specification is at [1]. [1] Intel TDX Module 1.0 EAS https://software.intel.com/content/dam

[RFC PATCH 08/67] KVM: x86/mmu: Zap only leaf SPTEs for deleted/moved memslot by default

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Zap only leaf SPTEs when deleting/moving a memslot by default, and add a module param to allow reverting to the old behavior of zapping all SPTEs at all levels and memslots when any memslot is updated. Signed-off-by: Sean Christopherson --- arch/x86/kvm/mmu/mmu.c |

[RFC PATCH 47/67] KVM: VMX: Define EPT Violation architectural bits

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Define the EPT Violation #VE control bit, #VE info VMCS fields, and the suppress #VE bit for EPT entries. Signed-off-by: Sean Christopherson --- arch/x86/include/asm/vmx.h | 4 arch/x86/include/asm/vmxfeatures.h | 2 +- 2 files changed, 5 insertions(+),

[RFC PATCH 62/67] KVM: TDX: Load and init TDX-SEAM module during boot

2020-11-16 Thread isaku . yamahata
From: Sean Christopherson Add a hook into the early boot flow to load TDX-SEAM and do BSP-only init of TDX-SEAM. Perform TDSYSINIT, TDSYSINITLP sequence to initialize TDX during kernel boot. Call TDSYSINIT on BSP for platform level initialization, and call TDSYSINITLP for all cpus for per-cpu

Re: [PATCH 0/3] x86/mtrr, pat: make PAT independent from MTRR

2019-08-13 Thread Isaku Yamahata
On Fri, Aug 09, 2019 at 07:51:17PM +, "Kani, Toshi" wrote: > On Fri, 2019-08-09 at 09:06 +0200, Borislav Petkov wrote: > > On Thu, Aug 08, 2019 at 08:54:17PM -0700, Isaku Yamahata wrote: > > > Make PAT(Page Attribute Table) independent from > > > MTRR(Me

[PATCH 0/3] x86/mtrr, pat: make PAT independent from MTRR

2019-08-08 Thread Isaku Yamahata
h 3 is an essential patch which makes PAT independent from MTRR. Isaku Yamahata (3): x86/mtrr: split common funcs from mtrr.c x86/mtrr: split common funcs from generic.c x86/mtrr, pat: make PAT independent from MTRR arch/x86/Kconfig | 1 - arch/x86/include/asm/mtr

[PATCH 2/3] x86/mtrr: split common funcs from generic.c

2019-08-08 Thread Isaku Yamahata
prefix rename and movement, no logic change. Signed-off-by: Isaku Yamahata --- arch/x86/include/asm/mtrr.h | 4 + arch/x86/kernel/cpu/mtrr/generic.c| 111 ++ arch/x86/kernel/cpu/mtrr/mtrr.c | 2 +- arch/x86/kernel/cpu/mtrr/mtrr.h | 3 +- arch

[PATCH 3/3] x86/mtrr, pat: make PAT independent from MTRR

2019-08-08 Thread Isaku Yamahata
technologies don't support MTRR, but only PAT. This patch make PAT available on such environments without MTRR. Signed-off-by: Isaku Yamahata --- arch/x86/Kconfig | 1 - arch/x86/include/asm/mtrr.h | 32 + arch/x86/include/asm/pat.h| 2 + arch/x86

[PATCH 1/3] x86/mtrr: split common funcs from mtrr.c

2019-08-08 Thread Isaku Yamahata
and movement, no logic change. Signed-off-by: Isaku Yamahata --- arch/x86/include/asm/mtrr.h | 25 +-- arch/x86/kernel/cpu/common.c | 2 +- arch/x86/kernel/cpu/mtrr/Makefile | 2 +- arch/x86/kernel/cpu/mtrr/mtrr.c | 201 ++- arch/x86/kernel/cpu/mtrr

Re: [PATCH 0/4] madvise(MADV_USERFAULT) & sys_remap_anon_pages()

2013-05-07 Thread Isaku Yamahata
On Mon, May 06, 2013 at 09:56:57PM +0200, Andrea Arcangeli wrote: > Hello everyone, > > this is a patchset to implement two new kernel features: > MADV_USERFAULT and remap_anon_pages. > > The combination of the two features are what I would propose to > implement postcopy live migration, and in

Re: [PATCH 0/4] madvise(MADV_USERFAULT) sys_remap_anon_pages()

2013-05-07 Thread Isaku Yamahata
On Mon, May 06, 2013 at 09:56:57PM +0200, Andrea Arcangeli wrote: Hello everyone, this is a patchset to implement two new kernel features: MADV_USERFAULT and remap_anon_pages. The combination of the two features are what I would propose to implement postcopy live migration, and in general

[PATCH v4 2/2] umem: chardevice for kvm postcopy

2012-10-30 Thread Isaku Yamahata
This is a character device to hook page access. The page fault in the area is propagated to another user process by this chardriver. Then, the process fills the page contents and resolves the page fault. Cc: Andrea Arcangeli Cc: Avi Kivity Cc: Paolo Bonzini Signed-off-by: Isaku Yamahata

[PATCH v4 0/2] postcopy migration: uvmem: Linux char device for postcopy

2012-10-30 Thread Isaku Yamahata
- make ioctl structures padded to align - un-KVM KVM_VMEM -> UMEM - dropped some ioctl commands as Avi requested Isaku Yamahata (2): export necessary symbols umem: chardevice for kvm postcopy Documentation/misc-devices/uvmem.txt | 292 drivers/char/Kconfig | 10

[PATCH v4 1/2] export necessary symbols

2012-10-30 Thread Isaku Yamahata
Cc: Andrea Arcangeli Cc: Avi Kivity Cc: Paolo Bonzini Signed-off-by: Isaku Yamahata --- mm/memcontrol.c |1 + mm/mempolicy.c |1 + mm/shmem.c |1 + 3 files changed, 3 insertions(+) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 7acf43b..bc9fd53 100644 --- a/mm

[PATCH v4 1/2] export necessary symbols

2012-10-30 Thread Isaku Yamahata
Cc: Andrea Arcangeli aarca...@redhat.com Cc: Avi Kivity a...@redhat.com Cc: Paolo Bonzini pbonz...@redhat.com Signed-off-by: Isaku Yamahata yamah...@valinux.co.jp --- mm/memcontrol.c |1 + mm/mempolicy.c |1 + mm/shmem.c |1 + 3 files changed, 3 insertions(+) diff --git a/mm

[PATCH v4 0/2] postcopy migration: uvmem: Linux char device for postcopy

2012-10-30 Thread Isaku Yamahata
padded to align - un-KVM KVM_VMEM - UMEM - dropped some ioctl commands as Avi requested Isaku Yamahata (2): export necessary symbols umem: chardevice for kvm postcopy Documentation/misc-devices/uvmem.txt | 292 drivers/char/Kconfig | 10 + drivers/char/Makefile

[PATCH v4 2/2] umem: chardevice for kvm postcopy

2012-10-30 Thread Isaku Yamahata
pbonz...@redhat.com Signed-off-by: Isaku Yamahata yamah...@valinux.co.jp --- Changes v4 - v5: - rename umem to uvmem to avoid name conflict Changes v3 - v4: - simplified umem_init: kill {a,}sync_req_max - make fault handler killable even when core-dumping - documentation Changes v2 - v3: - made

[PATCH 09/11] xen: make grant table arch portable.

2008-02-21 Thread Isaku Yamahata
split out x86 specific part from grant-table.c Signed-off-by: Isaku Yamahata <[EMAIL PROTECTED]> --- arch/x86/xen/Makefile |2 +- arch/x86/xen/grant-table.c | 91 drivers/xen/grant-table.c | 35 +--- include/xen/grant_t

[PATCH 07/11] xen: make include/xen/page.h portable moving those definitions under asm dir.

2008-02-21 Thread Isaku Yamahata
Those definitions in include/asm/xen/page.h are arch specific. ia64/xen wants to define its own version. So move them to arch specific directory and keep include/xen/page.h in order not to break compilation. Signed-off-by: Isaku Yamahata <[EMAIL PROTECTED]> --- include/{ => asm-x86}/x

[PATCH 11/11] xen: import arch generic part of xencomm.

2008-02-21 Thread Isaku Yamahata
On xen/ia64 and xen/powerpc hypercall arguments are passed by pseudo physical address (guest physical address) so that it's necessary to convert from virtual address into pseudo physical address. The frame work is called xencomm. Import arch generic part of xencomm. Signed-off-by: Isaku Yamahata

[PATCH 10/11] xen: import include/xen/interface/callback.h which ia64/xen needs.

2008-02-21 Thread Isaku Yamahata
Signed-off-by: Isaku Yamahata <[EMAIL PROTECTED]> --- include/xen/interface/callback.h | 119 ++ 1 files changed, 119 insertions(+), 0 deletions(-) create mode 100644 include/xen/interface/callback.h diff --git a/include/xen/interface/callback.h b/i

[PATCH 08/11] xen: replace callers of alloc_vm_area()/free_vm_area() with xen_ prefixed one.

2008-02-21 Thread Isaku Yamahata
allocate vm area contradictory to those names. Now vanilla Linux already has its definitions so that it's impossible to have IA64 definitions of allocate_vm_area()/free_vm_area(). Instead introduce xen_allocate_vm_area()/xen_free_vm_area() and use them. Signed-off-by: Isaku Yamahata <[EM

[PATCH 06/11] xen: move arch/x86/xen/events.c undedr drivers/xen and split out arch specific part.

2008-02-21 Thread Isaku Yamahata
ia64/xen also uses events.c. clean it up so that ia64/xen can use. make ipi_to_irq globly visible. ia64/xen nees to reference it from other file. introduce resend_irq_on_evtchn() which ia64 needs. introduce xen_do_IRQ() to split out arch specific code. Signed-off-by: Isaku Yamahata <[EM

  1   2   >