2c9b351240
* Initial infrastructure for shadow stage-2 MMUs, as part of nested virtualization enablement * Support for userspace changes to the guest CTR_EL0 value, enabling (in part) migration of VMs between heterogenous hardware * Fixes + improvements to pKVM's FF-A proxy, adding support for v1.1 of the protocol * FPSIMD/SVE support for nested, including merged trap configuration and exception routing * New command-line parameter to control the WFx trap behavior under KVM * Introduce kCFI hardening in the EL2 hypervisor * Fixes + cleanups for handling presence/absence of FEAT_TCRX * Miscellaneous fixes + documentation updates LoongArch: * Add paravirt steal time support. * Add support for KVM_DIRTY_LOG_INITIALLY_SET. * Add perf kvm-stat support for loongarch. RISC-V: * Redirect AMO load/store access fault traps to guest * perf kvm stat support * Use guest files for IMSIC virtualization, when available ONE_REG support for the Zimop, Zcmop, Zca, Zcf, Zcd, Zcb and Zawrs ISA extensions is coming through the RISC-V tree. s390: * Assortment of tiny fixes which are not time critical x86: * Fixes for Xen emulation. * Add a global struct to consolidate tracking of host values, e.g. EFER * Add KVM_CAP_X86_APIC_BUS_CYCLES_NS to allow configuring the effective APIC bus frequency, because TDX. * Print the name of the APICv/AVIC inhibits in the relevant tracepoint. * Clean up KVM's handling of vendor specific emulation to consistently act on "compatible with Intel/AMD", versus checking for a specific vendor. * Drop MTRR virtualization, and instead always honor guest PAT on CPUs that support self-snoop. * Update to the newfangled Intel CPU FMS infrastructure. * Don't advertise IA32_PERF_GLOBAL_OVF_CTRL as an MSR-to-be-saved, as it reads '0' and writes from userspace are ignored. * Misc cleanups x86 - MMU: * Small cleanups, renames and refactoring extracted from the upcoming Intel TDX support. * Don't allocate kvm_mmu_page.shadowed_translation for shadow pages that can't hold leafs SPTEs. * Unconditionally drop mmu_lock when allocating TDP MMU page tables for eager page splitting, to avoid stalling vCPUs when splitting huge pages. * Bug the VM instead of simply warning if KVM tries to split a SPTE that is non-present or not-huge. KVM is guaranteed to end up in a broken state because the callers fully expect a valid SPTE, it's all but dangerous to let more MMU changes happen afterwards. x86 - AMD: * Make per-CPU save_area allocations NUMA-aware. * Force sev_es_host_save_area() to be inlined to avoid calling into an instrumentable function from noinstr code. * Base support for running SEV-SNP guests. API-wise, this includes a new KVM_X86_SNP_VM type, encrypting/measure the initial image into guest memory, and finalizing it before launching it. Internally, there are some gmem/mmu hooks needed to prepare gmem-allocated pages before mapping them into guest private memory ranges. This includes basic support for attestation guest requests, enough to say that KVM supports the GHCB 2.0 specification. There is no support yet for loading into the firmware those signing keys to be used for attestation requests, and therefore no need yet for the host to provide certificate data for those keys. To support fetching certificate data from userspace, a new KVM exit type will be needed to handle fetching the certificate from userspace. An attempt to define a new KVM_EXIT_COCO/KVM_EXIT_COCO_REQ_CERTS exit type to handle this was introduced in v1 of this patchset, but is still being discussed by community, so for now this patchset only implements a stub version of SNP Extended Guest Requests that does not provide certificate data. x86 - Intel: * Remove an unnecessary EPT TLB flush when enabling hardware. * Fix a series of bugs that cause KVM to fail to detect nested pending posted interrupts as valid wake eents for a vCPU executing HLT in L2 (with HLT-exiting disable by L1). * KVM: x86: Suppress MMIO that is triggered during task switch emulation Explicitly suppress userspace emulated MMIO exits that are triggered when emulating a task switch as KVM doesn't support userspace MMIO during complex (multi-step) emulation. Silently ignoring the exit request can result in the WARN_ON_ONCE(vcpu->mmio_needed) firing if KVM exits to userspace for some other reason prior to purging mmio_needed. See commit0dc902267c
("KVM: x86: Suppress pending MMIO write exits if emulator detects exception") for more details on KVM's limitations with respect to emulated MMIO during complex emulator flows. Generic: * Rename the AS_UNMOVABLE flag that was introduced for KVM to AS_INACCESSIBLE, because the special casing needed by these pages is not due to just unmovability (and in fact they are only unmovable because the CPU cannot access them). * New ioctl to populate the KVM page tables in advance, which is useful to mitigate KVM page faults during guest boot or after live migration. The code will also be used by TDX, but (probably) not through the ioctl. * Enable halt poll shrinking by default, as Intel found it to be a clear win. * Setup empty IRQ routing when creating a VM to avoid having to synchronize SRCU when creating a split IRQCHIP on x86. * Rework the sched_in/out() paths to replace kvm_arch_sched_in() with a flag that arch code can use for hooking both sched_in() and sched_out(). * Take the vCPU @id as an "unsigned long" instead of "u32" to avoid truncating a bogus value from userspace, e.g. to help userspace detect bugs. * Mark a vCPU as preempted if and only if it's scheduled out while in the KVM_RUN loop, e.g. to avoid marking it preempted and thus writing guest memory when retrieving guest state during live migration blackout. Selftests: * Remove dead code in the memslot modification stress test. * Treat "branch instructions retired" as supported on all AMD Family 17h+ CPUs. * Print the guest pseudo-RNG seed only when it changes, to avoid spamming the log for tests that create lots of VMs. * Make the PMU counters test less flaky when counting LLC cache misses by doing CLFLUSH{OPT} in every loop iteration. -----BEGIN PGP SIGNATURE----- iQFIBAABCAAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmaZQB0UHHBib256aW5p QHJlZGhhdC5jb20ACgkQv/vSX3jHroNkZwf/bv2jiENaLFNGPe/VqTKMQ6PHQLMG +sNHx6fJPP35gTM8Jqf0/7/ummZXcSuC1mWrzYbecZm7Oeg3vwNXHZ4LquwwX6Dv 8dKcUzLbWDAC4WA3SKhi8C8RV2v6E7ohy69NtAJmFWTc7H95dtIQm6cduV2osTC3 OEuHe1i8d9umk6couL9Qhm8hk3i9v2KgCsrfyNrQgLtS3hu7q6yOTR8nT0iH6sJR KE5A8prBQgLmF34CuvYDw4Hu6E4j+0QmIqodovg2884W1gZQ9LmcVqYPaRZGsG8S iDdbkualLKwiR1TpRr3HJGKWSFdc7RblbsnHRvHIZgFsMQiimh4HrBSCyQ== =zepX -----END PGP SIGNATURE----- Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm Pull kvm updates from Paolo Bonzini: "ARM: - Initial infrastructure for shadow stage-2 MMUs, as part of nested virtualization enablement - Support for userspace changes to the guest CTR_EL0 value, enabling (in part) migration of VMs between heterogenous hardware - Fixes + improvements to pKVM's FF-A proxy, adding support for v1.1 of the protocol - FPSIMD/SVE support for nested, including merged trap configuration and exception routing - New command-line parameter to control the WFx trap behavior under KVM - Introduce kCFI hardening in the EL2 hypervisor - Fixes + cleanups for handling presence/absence of FEAT_TCRX - Miscellaneous fixes + documentation updates LoongArch: - Add paravirt steal time support - Add support for KVM_DIRTY_LOG_INITIALLY_SET - Add perf kvm-stat support for loongarch RISC-V: - Redirect AMO load/store access fault traps to guest - perf kvm stat support - Use guest files for IMSIC virtualization, when available s390: - Assortment of tiny fixes which are not time critical x86: - Fixes for Xen emulation - Add a global struct to consolidate tracking of host values, e.g. EFER - Add KVM_CAP_X86_APIC_BUS_CYCLES_NS to allow configuring the effective APIC bus frequency, because TDX - Print the name of the APICv/AVIC inhibits in the relevant tracepoint - Clean up KVM's handling of vendor specific emulation to consistently act on "compatible with Intel/AMD", versus checking for a specific vendor - Drop MTRR virtualization, and instead always honor guest PAT on CPUs that support self-snoop - Update to the newfangled Intel CPU FMS infrastructure - Don't advertise IA32_PERF_GLOBAL_OVF_CTRL as an MSR-to-be-saved, as it reads '0' and writes from userspace are ignored - Misc cleanups x86 - MMU: - Small cleanups, renames and refactoring extracted from the upcoming Intel TDX support - Don't allocate kvm_mmu_page.shadowed_translation for shadow pages that can't hold leafs SPTEs - Unconditionally drop mmu_lock when allocating TDP MMU page tables for eager page splitting, to avoid stalling vCPUs when splitting huge pages - Bug the VM instead of simply warning if KVM tries to split a SPTE that is non-present or not-huge. KVM is guaranteed to end up in a broken state because the callers fully expect a valid SPTE, it's all but dangerous to let more MMU changes happen afterwards x86 - AMD: - Make per-CPU save_area allocations NUMA-aware - Force sev_es_host_save_area() to be inlined to avoid calling into an instrumentable function from noinstr code - Base support for running SEV-SNP guests. API-wise, this includes a new KVM_X86_SNP_VM type, encrypting/measure the initial image into guest memory, and finalizing it before launching it. Internally, there are some gmem/mmu hooks needed to prepare gmem-allocated pages before mapping them into guest private memory ranges This includes basic support for attestation guest requests, enough to say that KVM supports the GHCB 2.0 specification There is no support yet for loading into the firmware those signing keys to be used for attestation requests, and therefore no need yet for the host to provide certificate data for those keys. To support fetching certificate data from userspace, a new KVM exit type will be needed to handle fetching the certificate from userspace. An attempt to define a new KVM_EXIT_COCO / KVM_EXIT_COCO_REQ_CERTS exit type to handle this was introduced in v1 of this patchset, but is still being discussed by community, so for now this patchset only implements a stub version of SNP Extended Guest Requests that does not provide certificate data x86 - Intel: - Remove an unnecessary EPT TLB flush when enabling hardware - Fix a series of bugs that cause KVM to fail to detect nested pending posted interrupts as valid wake eents for a vCPU executing HLT in L2 (with HLT-exiting disable by L1) - KVM: x86: Suppress MMIO that is triggered during task switch emulation Explicitly suppress userspace emulated MMIO exits that are triggered when emulating a task switch as KVM doesn't support userspace MMIO during complex (multi-step) emulation Silently ignoring the exit request can result in the WARN_ON_ONCE(vcpu->mmio_needed) firing if KVM exits to userspace for some other reason prior to purging mmio_needed See commit0dc902267c
("KVM: x86: Suppress pending MMIO write exits if emulator detects exception") for more details on KVM's limitations with respect to emulated MMIO during complex emulator flows Generic: - Rename the AS_UNMOVABLE flag that was introduced for KVM to AS_INACCESSIBLE, because the special casing needed by these pages is not due to just unmovability (and in fact they are only unmovable because the CPU cannot access them) - New ioctl to populate the KVM page tables in advance, which is useful to mitigate KVM page faults during guest boot or after live migration. The code will also be used by TDX, but (probably) not through the ioctl - Enable halt poll shrinking by default, as Intel found it to be a clear win - Setup empty IRQ routing when creating a VM to avoid having to synchronize SRCU when creating a split IRQCHIP on x86 - Rework the sched_in/out() paths to replace kvm_arch_sched_in() with a flag that arch code can use for hooking both sched_in() and sched_out() - Take the vCPU @id as an "unsigned long" instead of "u32" to avoid truncating a bogus value from userspace, e.g. to help userspace detect bugs - Mark a vCPU as preempted if and only if it's scheduled out while in the KVM_RUN loop, e.g. to avoid marking it preempted and thus writing guest memory when retrieving guest state during live migration blackout Selftests: - Remove dead code in the memslot modification stress test - Treat "branch instructions retired" as supported on all AMD Family 17h+ CPUs - Print the guest pseudo-RNG seed only when it changes, to avoid spamming the log for tests that create lots of VMs - Make the PMU counters test less flaky when counting LLC cache misses by doing CLFLUSH{OPT} in every loop iteration" * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: (227 commits) crypto: ccp: Add the SNP_VLEK_LOAD command KVM: x86/pmu: Add kvm_pmu_call() to simplify static calls of kvm_pmu_ops KVM: x86: Introduce kvm_x86_call() to simplify static calls of kvm_x86_ops KVM: x86: Replace static_call_cond() with static_call() KVM: SEV: Provide support for SNP_EXTENDED_GUEST_REQUEST NAE event x86/sev: Move sev_guest.h into common SEV header KVM: SEV: Provide support for SNP_GUEST_REQUEST NAE event KVM: x86: Suppress MMIO that is triggered during task switch emulation KVM: x86/mmu: Clean up make_huge_page_split_spte() definition and intro KVM: x86/mmu: Bug the VM if KVM tries to split a !hugepage SPTE KVM: selftests: x86: Add test for KVM_PRE_FAULT_MEMORY KVM: x86: Implement kvm_arch_vcpu_pre_fault_memory() KVM: x86/mmu: Make kvm_mmu_do_page_fault() return mapped level KVM: x86/mmu: Account pf_{fixed,emulate,spurious} in callers of "do page fault" KVM: x86/mmu: Bump pf_taken stat only in the "real" page fault handler KVM: Add KVM_PRE_FAULT_MEMORY vcpu ioctl to pre-populate guest memory KVM: Document KVM_PRE_FAULT_MEMORY ioctl mm, virt: merge AS_UNMOVABLE and AS_INACCESSIBLE perf kvm: Add kvm-stat for loongarch64 LoongArch: KVM: Add PV steal time support in guest side ...
401 lines
11 KiB
C
401 lines
11 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Copyright (C) 2019 Western Digital Corporation or its affiliates.
|
|
*
|
|
* Authors:
|
|
* Anup Patel <anup.patel@wdc.com>
|
|
*/
|
|
|
|
#ifndef __RISCV_KVM_HOST_H__
|
|
#define __RISCV_KVM_HOST_H__
|
|
|
|
#include <linux/types.h>
|
|
#include <linux/kvm.h>
|
|
#include <linux/kvm_types.h>
|
|
#include <linux/spinlock.h>
|
|
#include <asm/hwcap.h>
|
|
#include <asm/kvm_aia.h>
|
|
#include <asm/ptrace.h>
|
|
#include <asm/kvm_vcpu_fp.h>
|
|
#include <asm/kvm_vcpu_insn.h>
|
|
#include <asm/kvm_vcpu_sbi.h>
|
|
#include <asm/kvm_vcpu_timer.h>
|
|
#include <asm/kvm_vcpu_pmu.h>
|
|
|
|
#define KVM_MAX_VCPUS 1024
|
|
|
|
#define KVM_HALT_POLL_NS_DEFAULT 500000
|
|
|
|
#define KVM_VCPU_MAX_FEATURES 0
|
|
|
|
#define KVM_IRQCHIP_NUM_PINS 1024
|
|
|
|
#define KVM_REQ_SLEEP \
|
|
KVM_ARCH_REQ_FLAGS(0, KVM_REQUEST_WAIT | KVM_REQUEST_NO_WAKEUP)
|
|
#define KVM_REQ_VCPU_RESET KVM_ARCH_REQ(1)
|
|
#define KVM_REQ_UPDATE_HGATP KVM_ARCH_REQ(2)
|
|
#define KVM_REQ_FENCE_I \
|
|
KVM_ARCH_REQ_FLAGS(3, KVM_REQUEST_WAIT | KVM_REQUEST_NO_WAKEUP)
|
|
#define KVM_REQ_HFENCE_GVMA_VMID_ALL KVM_REQ_TLB_FLUSH
|
|
#define KVM_REQ_HFENCE_VVMA_ALL \
|
|
KVM_ARCH_REQ_FLAGS(4, KVM_REQUEST_WAIT | KVM_REQUEST_NO_WAKEUP)
|
|
#define KVM_REQ_HFENCE \
|
|
KVM_ARCH_REQ_FLAGS(5, KVM_REQUEST_WAIT | KVM_REQUEST_NO_WAKEUP)
|
|
#define KVM_REQ_STEAL_UPDATE KVM_ARCH_REQ(6)
|
|
|
|
#define KVM_HEDELEG_DEFAULT (BIT(EXC_INST_MISALIGNED) | \
|
|
BIT(EXC_BREAKPOINT) | \
|
|
BIT(EXC_SYSCALL) | \
|
|
BIT(EXC_INST_PAGE_FAULT) | \
|
|
BIT(EXC_LOAD_PAGE_FAULT) | \
|
|
BIT(EXC_STORE_PAGE_FAULT))
|
|
|
|
#define KVM_HIDELEG_DEFAULT (BIT(IRQ_VS_SOFT) | \
|
|
BIT(IRQ_VS_TIMER) | \
|
|
BIT(IRQ_VS_EXT))
|
|
|
|
enum kvm_riscv_hfence_type {
|
|
KVM_RISCV_HFENCE_UNKNOWN = 0,
|
|
KVM_RISCV_HFENCE_GVMA_VMID_GPA,
|
|
KVM_RISCV_HFENCE_VVMA_ASID_GVA,
|
|
KVM_RISCV_HFENCE_VVMA_ASID_ALL,
|
|
KVM_RISCV_HFENCE_VVMA_GVA,
|
|
};
|
|
|
|
struct kvm_riscv_hfence {
|
|
enum kvm_riscv_hfence_type type;
|
|
unsigned long asid;
|
|
unsigned long order;
|
|
gpa_t addr;
|
|
gpa_t size;
|
|
};
|
|
|
|
#define KVM_RISCV_VCPU_MAX_HFENCE 64
|
|
|
|
struct kvm_vm_stat {
|
|
struct kvm_vm_stat_generic generic;
|
|
};
|
|
|
|
struct kvm_vcpu_stat {
|
|
struct kvm_vcpu_stat_generic generic;
|
|
u64 ecall_exit_stat;
|
|
u64 wfi_exit_stat;
|
|
u64 wrs_exit_stat;
|
|
u64 mmio_exit_user;
|
|
u64 mmio_exit_kernel;
|
|
u64 csr_exit_user;
|
|
u64 csr_exit_kernel;
|
|
u64 signal_exits;
|
|
u64 exits;
|
|
};
|
|
|
|
struct kvm_arch_memory_slot {
|
|
};
|
|
|
|
struct kvm_vmid {
|
|
/*
|
|
* Writes to vmid_version and vmid happen with vmid_lock held
|
|
* whereas reads happen without any lock held.
|
|
*/
|
|
unsigned long vmid_version;
|
|
unsigned long vmid;
|
|
};
|
|
|
|
struct kvm_arch {
|
|
/* G-stage vmid */
|
|
struct kvm_vmid vmid;
|
|
|
|
/* G-stage page table */
|
|
pgd_t *pgd;
|
|
phys_addr_t pgd_phys;
|
|
|
|
/* Guest Timer */
|
|
struct kvm_guest_timer timer;
|
|
|
|
/* AIA Guest/VM context */
|
|
struct kvm_aia aia;
|
|
};
|
|
|
|
struct kvm_cpu_trap {
|
|
unsigned long sepc;
|
|
unsigned long scause;
|
|
unsigned long stval;
|
|
unsigned long htval;
|
|
unsigned long htinst;
|
|
};
|
|
|
|
struct kvm_cpu_context {
|
|
unsigned long zero;
|
|
unsigned long ra;
|
|
unsigned long sp;
|
|
unsigned long gp;
|
|
unsigned long tp;
|
|
unsigned long t0;
|
|
unsigned long t1;
|
|
unsigned long t2;
|
|
unsigned long s0;
|
|
unsigned long s1;
|
|
unsigned long a0;
|
|
unsigned long a1;
|
|
unsigned long a2;
|
|
unsigned long a3;
|
|
unsigned long a4;
|
|
unsigned long a5;
|
|
unsigned long a6;
|
|
unsigned long a7;
|
|
unsigned long s2;
|
|
unsigned long s3;
|
|
unsigned long s4;
|
|
unsigned long s5;
|
|
unsigned long s6;
|
|
unsigned long s7;
|
|
unsigned long s8;
|
|
unsigned long s9;
|
|
unsigned long s10;
|
|
unsigned long s11;
|
|
unsigned long t3;
|
|
unsigned long t4;
|
|
unsigned long t5;
|
|
unsigned long t6;
|
|
unsigned long sepc;
|
|
unsigned long sstatus;
|
|
unsigned long hstatus;
|
|
union __riscv_fp_state fp;
|
|
struct __riscv_v_ext_state vector;
|
|
};
|
|
|
|
struct kvm_vcpu_csr {
|
|
unsigned long vsstatus;
|
|
unsigned long vsie;
|
|
unsigned long vstvec;
|
|
unsigned long vsscratch;
|
|
unsigned long vsepc;
|
|
unsigned long vscause;
|
|
unsigned long vstval;
|
|
unsigned long hvip;
|
|
unsigned long vsatp;
|
|
unsigned long scounteren;
|
|
unsigned long senvcfg;
|
|
};
|
|
|
|
struct kvm_vcpu_config {
|
|
u64 henvcfg;
|
|
u64 hstateen0;
|
|
unsigned long hedeleg;
|
|
};
|
|
|
|
struct kvm_vcpu_smstateen_csr {
|
|
unsigned long sstateen0;
|
|
};
|
|
|
|
struct kvm_vcpu_arch {
|
|
/* VCPU ran at least once */
|
|
bool ran_atleast_once;
|
|
|
|
/* Last Host CPU on which Guest VCPU exited */
|
|
int last_exit_cpu;
|
|
|
|
/* ISA feature bits (similar to MISA) */
|
|
DECLARE_BITMAP(isa, RISCV_ISA_EXT_MAX);
|
|
|
|
/* Vendor, Arch, and Implementation details */
|
|
unsigned long mvendorid;
|
|
unsigned long marchid;
|
|
unsigned long mimpid;
|
|
|
|
/* SSCRATCH, STVEC, and SCOUNTEREN of Host */
|
|
unsigned long host_sscratch;
|
|
unsigned long host_stvec;
|
|
unsigned long host_scounteren;
|
|
unsigned long host_senvcfg;
|
|
unsigned long host_sstateen0;
|
|
|
|
/* CPU context of Host */
|
|
struct kvm_cpu_context host_context;
|
|
|
|
/* CPU context of Guest VCPU */
|
|
struct kvm_cpu_context guest_context;
|
|
|
|
/* CPU CSR context of Guest VCPU */
|
|
struct kvm_vcpu_csr guest_csr;
|
|
|
|
/* CPU Smstateen CSR context of Guest VCPU */
|
|
struct kvm_vcpu_smstateen_csr smstateen_csr;
|
|
|
|
/* CPU context upon Guest VCPU reset */
|
|
struct kvm_cpu_context guest_reset_context;
|
|
spinlock_t reset_cntx_lock;
|
|
|
|
/* CPU CSR context upon Guest VCPU reset */
|
|
struct kvm_vcpu_csr guest_reset_csr;
|
|
|
|
/*
|
|
* VCPU interrupts
|
|
*
|
|
* We have a lockless approach for tracking pending VCPU interrupts
|
|
* implemented using atomic bitops. The irqs_pending bitmap represent
|
|
* pending interrupts whereas irqs_pending_mask represent bits changed
|
|
* in irqs_pending. Our approach is modeled around multiple producer
|
|
* and single consumer problem where the consumer is the VCPU itself.
|
|
*/
|
|
#define KVM_RISCV_VCPU_NR_IRQS 64
|
|
DECLARE_BITMAP(irqs_pending, KVM_RISCV_VCPU_NR_IRQS);
|
|
DECLARE_BITMAP(irqs_pending_mask, KVM_RISCV_VCPU_NR_IRQS);
|
|
|
|
/* VCPU Timer */
|
|
struct kvm_vcpu_timer timer;
|
|
|
|
/* HFENCE request queue */
|
|
spinlock_t hfence_lock;
|
|
unsigned long hfence_head;
|
|
unsigned long hfence_tail;
|
|
struct kvm_riscv_hfence hfence_queue[KVM_RISCV_VCPU_MAX_HFENCE];
|
|
|
|
/* MMIO instruction details */
|
|
struct kvm_mmio_decode mmio_decode;
|
|
|
|
/* CSR instruction details */
|
|
struct kvm_csr_decode csr_decode;
|
|
|
|
/* SBI context */
|
|
struct kvm_vcpu_sbi_context sbi_context;
|
|
|
|
/* AIA VCPU context */
|
|
struct kvm_vcpu_aia aia_context;
|
|
|
|
/* Cache pages needed to program page tables with spinlock held */
|
|
struct kvm_mmu_memory_cache mmu_page_cache;
|
|
|
|
/* VCPU power state */
|
|
struct kvm_mp_state mp_state;
|
|
spinlock_t mp_state_lock;
|
|
|
|
/* Don't run the VCPU (blocked) */
|
|
bool pause;
|
|
|
|
/* Performance monitoring context */
|
|
struct kvm_pmu pmu_context;
|
|
|
|
/* 'static' configurations which are set only once */
|
|
struct kvm_vcpu_config cfg;
|
|
|
|
/* SBI steal-time accounting */
|
|
struct {
|
|
gpa_t shmem;
|
|
u64 last_steal;
|
|
} sta;
|
|
};
|
|
|
|
static inline void kvm_arch_sync_events(struct kvm *kvm) {}
|
|
|
|
#define KVM_RISCV_GSTAGE_TLB_MIN_ORDER 12
|
|
|
|
void kvm_riscv_local_hfence_gvma_vmid_gpa(unsigned long vmid,
|
|
gpa_t gpa, gpa_t gpsz,
|
|
unsigned long order);
|
|
void kvm_riscv_local_hfence_gvma_vmid_all(unsigned long vmid);
|
|
void kvm_riscv_local_hfence_gvma_gpa(gpa_t gpa, gpa_t gpsz,
|
|
unsigned long order);
|
|
void kvm_riscv_local_hfence_gvma_all(void);
|
|
void kvm_riscv_local_hfence_vvma_asid_gva(unsigned long vmid,
|
|
unsigned long asid,
|
|
unsigned long gva,
|
|
unsigned long gvsz,
|
|
unsigned long order);
|
|
void kvm_riscv_local_hfence_vvma_asid_all(unsigned long vmid,
|
|
unsigned long asid);
|
|
void kvm_riscv_local_hfence_vvma_gva(unsigned long vmid,
|
|
unsigned long gva, unsigned long gvsz,
|
|
unsigned long order);
|
|
void kvm_riscv_local_hfence_vvma_all(unsigned long vmid);
|
|
|
|
void kvm_riscv_local_tlb_sanitize(struct kvm_vcpu *vcpu);
|
|
|
|
void kvm_riscv_fence_i_process(struct kvm_vcpu *vcpu);
|
|
void kvm_riscv_hfence_gvma_vmid_all_process(struct kvm_vcpu *vcpu);
|
|
void kvm_riscv_hfence_vvma_all_process(struct kvm_vcpu *vcpu);
|
|
void kvm_riscv_hfence_process(struct kvm_vcpu *vcpu);
|
|
|
|
void kvm_riscv_fence_i(struct kvm *kvm,
|
|
unsigned long hbase, unsigned long hmask);
|
|
void kvm_riscv_hfence_gvma_vmid_gpa(struct kvm *kvm,
|
|
unsigned long hbase, unsigned long hmask,
|
|
gpa_t gpa, gpa_t gpsz,
|
|
unsigned long order);
|
|
void kvm_riscv_hfence_gvma_vmid_all(struct kvm *kvm,
|
|
unsigned long hbase, unsigned long hmask);
|
|
void kvm_riscv_hfence_vvma_asid_gva(struct kvm *kvm,
|
|
unsigned long hbase, unsigned long hmask,
|
|
unsigned long gva, unsigned long gvsz,
|
|
unsigned long order, unsigned long asid);
|
|
void kvm_riscv_hfence_vvma_asid_all(struct kvm *kvm,
|
|
unsigned long hbase, unsigned long hmask,
|
|
unsigned long asid);
|
|
void kvm_riscv_hfence_vvma_gva(struct kvm *kvm,
|
|
unsigned long hbase, unsigned long hmask,
|
|
unsigned long gva, unsigned long gvsz,
|
|
unsigned long order);
|
|
void kvm_riscv_hfence_vvma_all(struct kvm *kvm,
|
|
unsigned long hbase, unsigned long hmask);
|
|
|
|
int kvm_riscv_gstage_ioremap(struct kvm *kvm, gpa_t gpa,
|
|
phys_addr_t hpa, unsigned long size,
|
|
bool writable, bool in_atomic);
|
|
void kvm_riscv_gstage_iounmap(struct kvm *kvm, gpa_t gpa,
|
|
unsigned long size);
|
|
int kvm_riscv_gstage_map(struct kvm_vcpu *vcpu,
|
|
struct kvm_memory_slot *memslot,
|
|
gpa_t gpa, unsigned long hva, bool is_write);
|
|
int kvm_riscv_gstage_alloc_pgd(struct kvm *kvm);
|
|
void kvm_riscv_gstage_free_pgd(struct kvm *kvm);
|
|
void kvm_riscv_gstage_update_hgatp(struct kvm_vcpu *vcpu);
|
|
void __init kvm_riscv_gstage_mode_detect(void);
|
|
unsigned long __init kvm_riscv_gstage_mode(void);
|
|
int kvm_riscv_gstage_gpa_bits(void);
|
|
|
|
void __init kvm_riscv_gstage_vmid_detect(void);
|
|
unsigned long kvm_riscv_gstage_vmid_bits(void);
|
|
int kvm_riscv_gstage_vmid_init(struct kvm *kvm);
|
|
bool kvm_riscv_gstage_vmid_ver_changed(struct kvm_vmid *vmid);
|
|
void kvm_riscv_gstage_vmid_update(struct kvm_vcpu *vcpu);
|
|
|
|
int kvm_riscv_setup_default_irq_routing(struct kvm *kvm, u32 lines);
|
|
|
|
void __kvm_riscv_unpriv_trap(void);
|
|
|
|
unsigned long kvm_riscv_vcpu_unpriv_read(struct kvm_vcpu *vcpu,
|
|
bool read_insn,
|
|
unsigned long guest_addr,
|
|
struct kvm_cpu_trap *trap);
|
|
void kvm_riscv_vcpu_trap_redirect(struct kvm_vcpu *vcpu,
|
|
struct kvm_cpu_trap *trap);
|
|
int kvm_riscv_vcpu_exit(struct kvm_vcpu *vcpu, struct kvm_run *run,
|
|
struct kvm_cpu_trap *trap);
|
|
|
|
void __kvm_riscv_switch_to(struct kvm_vcpu_arch *vcpu_arch);
|
|
|
|
void kvm_riscv_vcpu_setup_isa(struct kvm_vcpu *vcpu);
|
|
unsigned long kvm_riscv_vcpu_num_regs(struct kvm_vcpu *vcpu);
|
|
int kvm_riscv_vcpu_copy_reg_indices(struct kvm_vcpu *vcpu,
|
|
u64 __user *uindices);
|
|
int kvm_riscv_vcpu_get_reg(struct kvm_vcpu *vcpu,
|
|
const struct kvm_one_reg *reg);
|
|
int kvm_riscv_vcpu_set_reg(struct kvm_vcpu *vcpu,
|
|
const struct kvm_one_reg *reg);
|
|
|
|
int kvm_riscv_vcpu_set_interrupt(struct kvm_vcpu *vcpu, unsigned int irq);
|
|
int kvm_riscv_vcpu_unset_interrupt(struct kvm_vcpu *vcpu, unsigned int irq);
|
|
void kvm_riscv_vcpu_flush_interrupts(struct kvm_vcpu *vcpu);
|
|
void kvm_riscv_vcpu_sync_interrupts(struct kvm_vcpu *vcpu);
|
|
bool kvm_riscv_vcpu_has_interrupts(struct kvm_vcpu *vcpu, u64 mask);
|
|
void __kvm_riscv_vcpu_power_off(struct kvm_vcpu *vcpu);
|
|
void kvm_riscv_vcpu_power_off(struct kvm_vcpu *vcpu);
|
|
void __kvm_riscv_vcpu_power_on(struct kvm_vcpu *vcpu);
|
|
void kvm_riscv_vcpu_power_on(struct kvm_vcpu *vcpu);
|
|
bool kvm_riscv_vcpu_stopped(struct kvm_vcpu *vcpu);
|
|
|
|
void kvm_riscv_vcpu_sbi_sta_reset(struct kvm_vcpu *vcpu);
|
|
void kvm_riscv_vcpu_record_steal_time(struct kvm_vcpu *vcpu);
|
|
|
|
#endif /* __RISCV_KVM_HOST_H__ */
|