Skip to content

Commit 01f492e

Browse files
committed
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
Pull kvm updates from Paolo Bonzini: "Arm: - Add support for tracing in the standalone EL2 hypervisor code, which should help both debugging and performance analysis. This uses the new infrastructure for 'remote' trace buffers that can be exposed by non-kernel entities such as firmware, and which came through the tracing tree - Add support for GICv5 Per Processor Interrupts (PPIs), as the starting point for supporting the new GIC architecture in KVM - Finally add support for pKVM protected guests, where pages are unmapped from the host as they are faulted into the guest and can be shared back from the guest using pKVM hypercalls. Protected guests are created using a new machine type identifier. As the elusive guestmem has not yet delivered on its promises, anonymous memory is also supported This is only a first step towards full isolation from the host; for example, the CPU register state and DMA accesses are not yet isolated. Because this does not really yet bring fully what it promises, it is hidden behind CONFIG_ARM_PKVM_GUEST + 'kvm-arm.mode=protected', and also triggers TAINT_USER when a VM is created. Caveat emptor - Rework the dreaded user_mem_abort() function to make it more maintainable, reducing the amount of state being exposed to the various helpers and rendering a substantial amount of state immutable - Expand the Stage-2 page table dumper to support NV shadow page tables on a per-VM basis - Tidy up the pKVM PSCI proxy code to be slightly less hard to follow - Fix both SPE and TRBE in non-VHE configurations so that they do not generate spurious, out of context table walks that ultimately lead to very bad HW lockups - A small set of patches fixing the Stage-2 MMU freeing in error cases - Tighten-up accepted SMC immediate value to be only #0 for host SMCCC calls - The usual cleanups and other selftest churn LoongArch: - Use CSR_CRMD_PLV for kvm_arch_vcpu_in_kernel() - Add DMSINTC irqchip in kernel support RISC-V: - Fix steal time shared memory alignment checks - Fix vector context allocation leak - Fix array out-of-bounds in pmu_ctr_read() and pmu_fw_ctr_read_hi() - Fix double-free of sdata in kvm_pmu_clear_snapshot_area() - Fix integer overflow in kvm_pmu_validate_counter_mask() - Fix shift-out-of-bounds in make_xfence_request() - Fix lost write protection on huge pages during dirty logging - Split huge pages during fault handling for dirty logging - Skip CSR restore if VCPU is reloaded on the same core - Implement kvm_arch_has_default_irqchip() for KVM selftests - Factored-out ISA checks into separate sources - Added hideleg to struct kvm_vcpu_config - Factored-out VCPU config into separate sources - Support configuration of per-VM HGATP mode from KVM user space s390: - Support for ESA (31-bit) guests inside nested hypervisors - Remove restriction on memslot alignment, which is not needed anymore with the new gmap code - Fix LPSW/E to update the bear (which of course is the breaking event address register) x86: - Shut up various UBSAN warnings on reading module parameter before they were initialized - Don't zero-allocate page tables that are used for splitting hugepages in the TDP MMU, as KVM is guaranteed to set all SPTEs in the page table and thus write all bytes - As an optimization, bail early when trying to unsync 4KiB mappings if the target gfn can just be mapped with a 2MiB hugepage x86 generic: - Copy single-chunk MMIO write values into struct kvm_vcpu (more precisely struct kvm_mmio_fragment) to fix use-after-free stack bugs where KVM would dereference stack pointer after an exit to userspace - Clean up and comment the emulated MMIO code to try to make it easier to maintain (not necessarily "easy", but "easier") - Move VMXON+VMXOFF and EFER.SVME toggling out of KVM (not *all* of VMX and SVM enabling) as it is needed for trusted I/O - Advertise support for AVX512 Bit Matrix Multiply (BMM) instructions - Immediately fail the build if a required #define is missing in one of KVM's headers that is included multiple times - Reject SET_GUEST_DEBUG with -EBUSY if there's an already injected exception, mostly to prevent syzkaller from abusing the uAPI to trigger WARNs, but also because it can help prevent userspace from unintentionally crashing the VM - Exempt SMM from CPUID faulting on Intel, as per the spec - Misc hardening and cleanup changes x86 (AMD): - Fix and optimize IRQ window inhibit handling for AVIC; make it per-vCPU so that KVM doesn't prematurely re-enable AVIC if multiple vCPUs have to-be-injected IRQs - Clean up and optimize the OSVW handling, avoiding a bug in which KVM would overwrite state when enabling virtualization on multiple CPUs in parallel. This should not be a problem because OSVW should usually be the same for all CPUs - Drop a WARN in KVM_MEMORY_ENCRYPT_REG_REGION where KVM complains about a "too large" size based purely on user input - Clean up and harden the pinning code for KVM_MEMORY_ENCRYPT_REG_REGION - Disallow synchronizing a VMSA of an already-launched/encrypted vCPU, as doing so for an SNP guest will crash the host due to an RMP violation page fault - Overhaul KVM's APIs for detecting SEV+ guests so that VM-scoped queries are required to hold kvm->lock, and enforce it by lockdep. Fix various bugs where sev_guest() was not ensured to be stable for the whole duration of a function or ioctl - Convert a pile of kvm->lock SEV code to guard() - Play nicer with userspace that does not enable KVM_CAP_EXCEPTION_PAYLOAD, for which KVM needs to set CR2 and DR6 as a response to ioctls such as KVM_GET_VCPU_EVENTS (even if the payload would end up in EXITINFO2 rather than CR2, for example). Only set CR2 and DR6 when consumption of the payload is imminent, but on the other hand force delivery of the payload in all paths where userspace retrieves CR2 or DR6 - Use vcpu->arch.cr2 when updating vmcb12's CR2 on nested #VMEXIT instead of vmcb02->save.cr2. The value is out of sync after a save/restore or after a #PF is injected into L2 - Fix a class of nSVM bugs where some fields written by the CPU are not synchronized from vmcb02 to cached vmcb12 after VMRUN, and so are not up-to-date when saved by KVM_GET_NESTED_STATE - Fix a class of bugs where the ordering between KVM_SET_NESTED_STATE and KVM_SET_{S}REGS could cause vmcb02 to be incorrectly initialized after save+restore - Add a variety of missing nSVM consistency checks - Fix several bugs where KVM failed to correctly update VMCB fields on nested #VMEXIT - Fix several bugs where KVM failed to correctly synthesize #UD or #GP for SVM-related instructions - Add support for save+restore of virtualized LBRs (on SVM) - Refactor various helpers and macros to improve clarity and (hopefully) make the code easier to maintain - Aggressively sanitize fields when copying from vmcb12, to guard against unintentionally allowing L1 to utilize yet-to-be-defined features - Fix several bugs where KVM botched rAX legality checks when emulating SVM instructions. There are remaining issues in that KVM doesn't handle size prefix overrides for 64-bit guests - Fail emulation of VMRUN/VMLOAD/VMSAVE if mapping vmcb12 fails instead of somewhat arbitrarily synthesizing #GP (i.e. don't double down on AMD's architectural but sketchy behavior of generating #GP for "unsupported" addresses) - Cache all used vmcb12 fields to further harden against TOCTOU bugs x86 (Intel): - Drop obsolete branch hint prefixes from the VMX instruction macros - Use ASM_INPUT_RM() in __vmcs_writel() to coerce clang into using a register input when appropriate - Code cleanups guest_memfd: - Don't mark guest_memfd folios as accessed, as guest_memfd doesn't support reclaim, the memory is unevictable, and there is no storage to write back to LoongArch selftests: - Add KVM PMU test cases s390 selftests: - Enable more memory selftests x86 selftests: - Add support for Hygon CPUs in KVM selftests - Fix a bug in the MSR test where it would get false failures on AMD/Hygon CPUs with exactly one of RDPID or RDTSCP - Add an MADV_COLLAPSE testcase for guest_memfd as a regression test for a bug where the kernel would attempt to collapse guest_memfd folios against KVM's will" * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: (373 commits) KVM: x86: use inlines instead of macros for is_sev_*guest x86/virt: Treat SVM as unsupported when running as an SEV+ guest KVM: SEV: Goto an existing error label if charging misc_cg for an ASID fails KVM: SVM: Move lock-protected allocation of SEV ASID into a separate helper KVM: SEV: use mutex guard in snp_handle_guest_req() KVM: SEV: use mutex guard in sev_mem_enc_unregister_region() KVM: SEV: use mutex guard in sev_mem_enc_ioctl() KVM: SEV: use mutex guard in snp_launch_update() KVM: SEV: Assert that kvm->lock is held when querying SEV+ support KVM: SEV: Document that checking for SEV+ guests when reclaiming memory is "safe" KVM: SEV: Hide "struct kvm_sev_info" behind CONFIG_KVM_AMD_SEV=y KVM: SEV: WARN on unhandled VM type when initializing VM KVM: LoongArch: selftests: Add PMU overflow interrupt test KVM: LoongArch: selftests: Add basic PMU event counting test KVM: LoongArch: selftests: Add cpucfg read/write helpers LoongArch: KVM: Add DMSINTC inject msi to vCPU LoongArch: KVM: Add DMSINTC device support LoongArch: KVM: Make vcpu_is_preempted() as a macro rather than function LoongArch: KVM: Move host CSR_GSTAT save and restore in context switch LoongArch: KVM: Move host CSR_EENTRY save and restore in context switch ...
2 parents e55d98e + 6b80203 commit 01f492e

238 files changed

Lines changed: 11127 additions & 3413 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3264,8 +3264,8 @@ Kernel parameters
32643264
for the host. To force nVHE on VHE hardware, add
32653265
"arm64_sw.hvhe=0 id_aa64mmfr1.vh=0" to the
32663266
command-line.
3267-
"nested" is experimental and should be used with
3268-
extreme caution.
3267+
"nested" and "protected" are experimental and should be
3268+
used with extreme caution.
32693269

32703270
kvm-arm.vgic_v3_group0_trap=
32713271
[KVM,ARM,EARLY] Trap guest accesses to GICv3 group-0

Documentation/arch/x86/tdx.rst

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -60,44 +60,18 @@ Besides initializing the TDX module, a per-cpu initialization SEAMCALL
6060
must be done on one cpu before any other SEAMCALLs can be made on that
6161
cpu.
6262

63-
The kernel provides two functions, tdx_enable() and tdx_cpu_enable() to
64-
allow the user of TDX to enable the TDX module and enable TDX on local
65-
cpu respectively.
66-
67-
Making SEAMCALL requires VMXON has been done on that CPU. Currently only
68-
KVM implements VMXON. For now both tdx_enable() and tdx_cpu_enable()
69-
don't do VMXON internally (not trivial), but depends on the caller to
70-
guarantee that.
71-
72-
To enable TDX, the caller of TDX should: 1) temporarily disable CPU
73-
hotplug; 2) do VMXON and tdx_enable_cpu() on all online cpus; 3) call
74-
tdx_enable(). For example::
75-
76-
cpus_read_lock();
77-
on_each_cpu(vmxon_and_tdx_cpu_enable());
78-
ret = tdx_enable();
79-
cpus_read_unlock();
80-
if (ret)
81-
goto no_tdx;
82-
// TDX is ready to use
83-
84-
And the caller of TDX must guarantee the tdx_cpu_enable() has been
85-
successfully done on any cpu before it wants to run any other SEAMCALL.
86-
A typical usage is do both VMXON and tdx_cpu_enable() in CPU hotplug
87-
online callback, and refuse to online if tdx_cpu_enable() fails.
88-
8963
User can consult dmesg to see whether the TDX module has been initialized.
9064

9165
If the TDX module is initialized successfully, dmesg shows something
9266
like below::
9367

9468
[..] virt/tdx: 262668 KBs allocated for PAMT
95-
[..] virt/tdx: module initialized
69+
[..] virt/tdx: TDX-Module initialized
9670

9771
If the TDX module failed to initialize, dmesg also shows it failed to
9872
initialize::
9973

100-
[..] virt/tdx: module initialization failed ...
74+
[..] virt/tdx: TDX-Module initialization failed ...
10175

10276
TDX Interaction to Other Kernel Components
10377
------------------------------------------
@@ -129,9 +103,9 @@ CPU Hotplug
129103
~~~~~~~~~~~
130104

131105
TDX module requires the per-cpu initialization SEAMCALL must be done on
132-
one cpu before any other SEAMCALLs can be made on that cpu. The kernel
133-
provides tdx_cpu_enable() to let the user of TDX to do it when the user
134-
wants to use a new cpu for TDX task.
106+
one cpu before any other SEAMCALLs can be made on that cpu. The kernel,
107+
via the CPU hotplug framework, performs the necessary initialization when
108+
a CPU is first brought online.
135109

136110
TDX doesn't support physical (ACPI) CPU hotplug. During machine boot,
137111
TDX verifies all boot-time present logical CPUs are TDX compatible before

Documentation/virt/kvm/api.rst

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -907,10 +907,12 @@ The irq_type field has the following values:
907907
- KVM_ARM_IRQ_TYPE_CPU:
908908
out-of-kernel GIC: irq_id 0 is IRQ, irq_id 1 is FIQ
909909
- KVM_ARM_IRQ_TYPE_SPI:
910-
in-kernel GIC: SPI, irq_id between 32 and 1019 (incl.)
910+
in-kernel GICv2/GICv3: SPI, irq_id between 32 and 1019 (incl.)
911911
(the vcpu_index field is ignored)
912+
in-kernel GICv5: SPI, irq_id between 0 and 65535 (incl.)
912913
- KVM_ARM_IRQ_TYPE_PPI:
913-
in-kernel GIC: PPI, irq_id between 16 and 31 (incl.)
914+
in-kernel GICv2/GICv3: PPI, irq_id between 16 and 31 (incl.)
915+
in-kernel GICv5: PPI, irq_id between 0 and 127 (incl.)
914916

915917
(The irq_id field thus corresponds nicely to the IRQ ID in the ARM GIC specs)
916918

@@ -9436,6 +9438,14 @@ KVM exits with the register state of either the L1 or L2 guest
94369438
depending on which executed at the time of an exit. Userspace must
94379439
take care to differentiate between these cases.
94389440

9441+
8.47 KVM_CAP_S390_VSIE_ESAMODE
9442+
------------------------------
9443+
9444+
:Architectures: s390
9445+
9446+
The presence of this capability indicates that the nested KVM guest can
9447+
start in ESA mode.
9448+
94399449
9. Known KVM API problems
94409450
=========================
94419451

Documentation/virt/kvm/arm/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ ARM
1010
fw-pseudo-registers
1111
hyp-abi
1212
hypercalls
13+
pkvm
1314
pvtime
1415
ptp_kvm
1516
vcpu-features
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
3+
====================
4+
Protected KVM (pKVM)
5+
====================
6+
7+
**NOTE**: pKVM is currently an experimental, development feature and
8+
subject to breaking changes as new isolation features are implemented.
9+
Please reach out to the developers at kvmarm@lists.linux.dev if you have
10+
any questions.
11+
12+
Overview
13+
========
14+
15+
Booting a host kernel with '``kvm-arm.mode=protected``' enables
16+
"Protected KVM" (pKVM). During boot, pKVM installs a stage-2 identity
17+
map page-table for the host and uses it to isolate the hypervisor
18+
running at EL2 from the rest of the host running at EL1/0.
19+
20+
pKVM permits creation of protected virtual machines (pVMs) by passing
21+
the ``KVM_VM_TYPE_ARM_PROTECTED`` machine type identifier to the
22+
``KVM_CREATE_VM`` ioctl(). The hypervisor isolates pVMs from the host by
23+
unmapping pages from the stage-2 identity map as they are accessed by a
24+
pVM. Hypercalls are provided for a pVM to share specific regions of its
25+
IPA space back with the host, allowing for communication with the VMM.
26+
A Linux guest must be configured with ``CONFIG_ARM_PKVM_GUEST=y`` in
27+
order to issue these hypercalls.
28+
29+
See hypercalls.rst for more details.
30+
31+
Isolation mechanisms
32+
====================
33+
34+
pKVM relies on a number of mechanisms to isolate PVMs from the host:
35+
36+
CPU memory isolation
37+
--------------------
38+
39+
Status: Isolation of anonymous memory and metadata pages.
40+
41+
Metadata pages (e.g. page-table pages and '``struct kvm_vcpu``' pages)
42+
are donated from the host to the hypervisor during pVM creation and
43+
are consequently unmapped from the stage-2 identity map until the pVM is
44+
destroyed.
45+
46+
Similarly to regular KVM, pages are lazily mapped into the guest in
47+
response to stage-2 page faults handled by the host. However, when
48+
running a pVM, these pages are first pinned and then unmapped from the
49+
stage-2 identity map as part of the donation procedure. This gives rise
50+
to some user-visible differences when compared to non-protected VMs,
51+
largely due to the lack of MMU notifiers:
52+
53+
* Memslots cannot be moved or deleted once the pVM has started running.
54+
* Read-only memslots and dirty logging are not supported.
55+
* With the exception of swap, file-backed pages cannot be mapped into a
56+
pVM.
57+
* Donated pages are accounted against ``RLIMIT_MLOCK`` and so the VMM
58+
must have a sufficient resource limit or be granted ``CAP_IPC_LOCK``.
59+
The lack of a runtime reclaim mechanism means that memory locked for
60+
a pVM will remain locked until the pVM is destroyed.
61+
* Changes to the VMM address space (e.g. a ``MAP_FIXED`` mmap() over a
62+
mapping associated with a memslot) are not reflected in the guest and
63+
may lead to loss of coherency.
64+
* Accessing pVM memory that has not been shared back will result in the
65+
delivery of a SIGSEGV.
66+
* If a system call accesses pVM memory that has not been shared back
67+
then it will either return ``-EFAULT`` or forcefully reclaim the
68+
memory pages. Reclaimed memory is zeroed by the hypervisor and a
69+
subsequent attempt to access it in the pVM will return ``-EFAULT``
70+
from the ``VCPU_RUN`` ioctl().
71+
72+
CPU state isolation
73+
-------------------
74+
75+
Status: **Unimplemented.**
76+
77+
DMA isolation using an IOMMU
78+
----------------------------
79+
80+
Status: **Unimplemented.**
81+
82+
Proxying of Trustzone services
83+
------------------------------
84+
85+
Status: FF-A and PSCI calls from the host are proxied by the pKVM
86+
hypervisor.
87+
88+
The FF-A proxy ensures that the host cannot share pVM or hypervisor
89+
memory with Trustzone as part of a "confused deputy" attack.
90+
91+
The PSCI proxy ensures that CPUs always have the stage-2 identity map
92+
installed when they are executing in the host.
93+
94+
Protected VM firmware (pvmfw)
95+
-----------------------------
96+
97+
Status: **Unimplemented.**
98+
99+
Resources
100+
=========
101+
102+
Quentin Perret's KVM Forum 2022 talk entitled "Protected KVM on arm64: A
103+
technical deep dive" remains a good resource for learning more about
104+
pKVM, despite some of the details having changed in the meantime:
105+
106+
https://www.youtube.com/watch?v=9npebeVFbFw
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
3+
====================================================
4+
ARM Virtual Generic Interrupt Controller v5 (VGICv5)
5+
====================================================
6+
7+
8+
Device types supported:
9+
- KVM_DEV_TYPE_ARM_VGIC_V5 ARM Generic Interrupt Controller v5.0
10+
11+
Only one VGIC instance may be instantiated through this API. The created VGIC
12+
will act as the VM interrupt controller, requiring emulated user-space devices
13+
to inject interrupts to the VGIC instead of directly to CPUs.
14+
15+
Creating a guest GICv5 device requires a host GICv5 host. The current VGICv5
16+
device only supports PPI interrupts. These can either be injected from emulated
17+
in-kernel devices (such as the Arch Timer, or PMU), or via the KVM_IRQ_LINE
18+
ioctl.
19+
20+
Groups:
21+
KVM_DEV_ARM_VGIC_GRP_CTRL
22+
Attributes:
23+
24+
KVM_DEV_ARM_VGIC_CTRL_INIT
25+
request the initialization of the VGIC, no additional parameter in
26+
kvm_device_attr.addr. Must be called after all VCPUs have been created.
27+
28+
KVM_DEV_ARM_VGIC_USERPSPACE_PPIs
29+
request the mask of userspace-drivable PPIs. Only a subset of the PPIs can
30+
be directly driven from userspace with GICv5, and the returned mask
31+
informs userspace of which it is allowed to drive via KVM_IRQ_LINE.
32+
33+
Userspace must allocate and point to __u64[2] of data in
34+
kvm_device_attr.addr. When this call returns, the provided memory will be
35+
populated with the userspace PPI mask. The lower __u64 contains the mask
36+
for the lower 64 PPIS, with the remaining 64 being in the second __u64.
37+
38+
This is a read-only attribute, and cannot be set. Attempts to set it are
39+
rejected.
40+
41+
Errors:
42+
43+
======= ========================================================
44+
-ENXIO VGIC not properly configured as required prior to calling
45+
this attribute
46+
-ENODEV no online VCPU
47+
-ENOMEM memory shortage when allocating vgic internal data
48+
-EFAULT Invalid guest ram access
49+
-EBUSY One or more VCPUS are running
50+
======= ========================================================

Documentation/virt/kvm/devices/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Devices
1010
arm-vgic-its
1111
arm-vgic
1212
arm-vgic-v3
13+
arm-vgic-v5
1314
mpic
1415
s390_flic
1516
vcpu

Documentation/virt/kvm/devices/vcpu.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ Returns:
3737
A value describing the PMUv3 (Performance Monitor Unit v3) overflow interrupt
3838
number for this vcpu. This interrupt could be a PPI or SPI, but the interrupt
3939
type must be same for each vcpu. As a PPI, the interrupt number is the same for
40-
all vcpus, while as an SPI it must be a separate number per vcpu.
40+
all vcpus, while as an SPI it must be a separate number per vcpu. For
41+
GICv5-based guests, the architected PPI (23) must be used.
4142

4243
1.2 ATTRIBUTE: KVM_ARM_VCPU_PMU_V3_INIT
4344
---------------------------------------
@@ -50,7 +51,7 @@ Returns:
5051
-EEXIST Interrupt number already used
5152
-ENODEV PMUv3 not supported or GIC not initialized
5253
-ENXIO PMUv3 not supported, missing VCPU feature or interrupt
53-
number not set
54+
number not set (non-GICv5 guests, only)
5455
-EBUSY PMUv3 already initialized
5556
======= ======================================================
5657

arch/arm64/include/asm/el2_setup.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
* effectively VHE-only or not.
5151
*/
5252
msr_hcr_el2 x0 // Setup HCR_EL2 as nVHE
53-
isb
5453
mov x1, #1 // Write something to FAR_EL1
5554
msr far_el1, x1
5655
isb
@@ -64,7 +63,6 @@
6463
.LnE2H0_\@:
6564
orr x0, x0, #HCR_E2H
6665
msr_hcr_el2 x0
67-
isb
6866
.LnVHE_\@:
6967
.endm
7068

@@ -248,6 +246,8 @@
248246
ICH_HFGWTR_EL2_ICC_CR0_EL1 | \
249247
ICH_HFGWTR_EL2_ICC_APR_EL1)
250248
msr_s SYS_ICH_HFGWTR_EL2, x0 // Disable reg write traps
249+
mov x0, #(ICH_VCTLR_EL2_En)
250+
msr_s SYS_ICH_VCTLR_EL2, x0 // Enable vHPPI selection
251251
.Lskip_gicv5_\@:
252252
.endm
253253

arch/arm64/include/asm/kvm_asm.h

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
#include <linux/mm.h>
5252

5353
enum __kvm_host_smccc_func {
54-
/* Hypercalls available only prior to pKVM finalisation */
54+
/* Hypercalls that are unavailable once pKVM has finalised. */
5555
/* __KVM_HOST_SMCCC_FUNC___kvm_hyp_init */
5656
__KVM_HOST_SMCCC_FUNC___pkvm_init = __KVM_HOST_SMCCC_FUNC___kvm_hyp_init + 1,
5757
__KVM_HOST_SMCCC_FUNC___pkvm_create_private_mapping,
@@ -60,16 +60,9 @@ enum __kvm_host_smccc_func {
6060
__KVM_HOST_SMCCC_FUNC___vgic_v3_init_lrs,
6161
__KVM_HOST_SMCCC_FUNC___vgic_v3_get_gic_config,
6262
__KVM_HOST_SMCCC_FUNC___pkvm_prot_finalize,
63+
__KVM_HOST_SMCCC_FUNC_MIN_PKVM = __KVM_HOST_SMCCC_FUNC___pkvm_prot_finalize,
6364

64-
/* Hypercalls available after pKVM finalisation */
65-
__KVM_HOST_SMCCC_FUNC___pkvm_host_share_hyp,
66-
__KVM_HOST_SMCCC_FUNC___pkvm_host_unshare_hyp,
67-
__KVM_HOST_SMCCC_FUNC___pkvm_host_share_guest,
68-
__KVM_HOST_SMCCC_FUNC___pkvm_host_unshare_guest,
69-
__KVM_HOST_SMCCC_FUNC___pkvm_host_relax_perms_guest,
70-
__KVM_HOST_SMCCC_FUNC___pkvm_host_wrprotect_guest,
71-
__KVM_HOST_SMCCC_FUNC___pkvm_host_test_clear_young_guest,
72-
__KVM_HOST_SMCCC_FUNC___pkvm_host_mkyoung_guest,
65+
/* Hypercalls that are always available and common to [nh]VHE/pKVM. */
7366
__KVM_HOST_SMCCC_FUNC___kvm_adjust_pc,
7467
__KVM_HOST_SMCCC_FUNC___kvm_vcpu_run,
7568
__KVM_HOST_SMCCC_FUNC___kvm_flush_vm_context,
@@ -81,14 +74,40 @@ enum __kvm_host_smccc_func {
8174
__KVM_HOST_SMCCC_FUNC___kvm_timer_set_cntvoff,
8275
__KVM_HOST_SMCCC_FUNC___vgic_v3_save_aprs,
8376
__KVM_HOST_SMCCC_FUNC___vgic_v3_restore_vmcr_aprs,
77+
__KVM_HOST_SMCCC_FUNC___vgic_v5_save_apr,
78+
__KVM_HOST_SMCCC_FUNC___vgic_v5_restore_vmcr_apr,
79+
__KVM_HOST_SMCCC_FUNC_MAX_NO_PKVM = __KVM_HOST_SMCCC_FUNC___vgic_v5_restore_vmcr_apr,
80+
81+
/* Hypercalls that are available only when pKVM has finalised. */
82+
__KVM_HOST_SMCCC_FUNC___pkvm_host_share_hyp,
83+
__KVM_HOST_SMCCC_FUNC___pkvm_host_unshare_hyp,
84+
__KVM_HOST_SMCCC_FUNC___pkvm_host_donate_guest,
85+
__KVM_HOST_SMCCC_FUNC___pkvm_host_share_guest,
86+
__KVM_HOST_SMCCC_FUNC___pkvm_host_unshare_guest,
87+
__KVM_HOST_SMCCC_FUNC___pkvm_host_relax_perms_guest,
88+
__KVM_HOST_SMCCC_FUNC___pkvm_host_wrprotect_guest,
89+
__KVM_HOST_SMCCC_FUNC___pkvm_host_test_clear_young_guest,
90+
__KVM_HOST_SMCCC_FUNC___pkvm_host_mkyoung_guest,
8491
__KVM_HOST_SMCCC_FUNC___pkvm_reserve_vm,
8592
__KVM_HOST_SMCCC_FUNC___pkvm_unreserve_vm,
8693
__KVM_HOST_SMCCC_FUNC___pkvm_init_vm,
8794
__KVM_HOST_SMCCC_FUNC___pkvm_init_vcpu,
88-
__KVM_HOST_SMCCC_FUNC___pkvm_teardown_vm,
95+
__KVM_HOST_SMCCC_FUNC___pkvm_vcpu_in_poison_fault,
96+
__KVM_HOST_SMCCC_FUNC___pkvm_force_reclaim_guest_page,
97+
__KVM_HOST_SMCCC_FUNC___pkvm_reclaim_dying_guest_page,
98+
__KVM_HOST_SMCCC_FUNC___pkvm_start_teardown_vm,
99+
__KVM_HOST_SMCCC_FUNC___pkvm_finalize_teardown_vm,
89100
__KVM_HOST_SMCCC_FUNC___pkvm_vcpu_load,
90101
__KVM_HOST_SMCCC_FUNC___pkvm_vcpu_put,
91102
__KVM_HOST_SMCCC_FUNC___pkvm_tlb_flush_vmid,
103+
__KVM_HOST_SMCCC_FUNC___tracing_load,
104+
__KVM_HOST_SMCCC_FUNC___tracing_unload,
105+
__KVM_HOST_SMCCC_FUNC___tracing_enable,
106+
__KVM_HOST_SMCCC_FUNC___tracing_swap_reader,
107+
__KVM_HOST_SMCCC_FUNC___tracing_update_clock,
108+
__KVM_HOST_SMCCC_FUNC___tracing_reset,
109+
__KVM_HOST_SMCCC_FUNC___tracing_enable_event,
110+
__KVM_HOST_SMCCC_FUNC___tracing_write_event,
92111
};
93112

94113
#define DECLARE_KVM_VHE_SYM(sym) extern char sym[]
@@ -291,7 +310,8 @@ asmlinkage void __noreturn hyp_panic_bad_stack(void);
291310
asmlinkage void kvm_unexpected_el2_exception(void);
292311
struct kvm_cpu_context;
293312
void handle_trap(struct kvm_cpu_context *host_ctxt);
294-
asmlinkage void __noreturn __kvm_host_psci_cpu_entry(bool is_cpu_on);
313+
asmlinkage void __noreturn __kvm_host_psci_cpu_on_entry(void);
314+
asmlinkage void __noreturn __kvm_host_psci_cpu_resume_entry(void);
295315
void __noreturn __pkvm_init_finalise(void);
296316
void kvm_nvhe_prepare_backtrace(unsigned long fp, unsigned long pc);
297317
void kvm_patch_vector_branch(struct alt_instr *alt,

0 commit comments

Comments
 (0)