Skip to content

Commit 72de5fa

Browse files
vittyvkbonzini
authored andcommitted
KVM: x86: announce KVM_FEATURE_ASYNC_PF_INT
Introduce new capability to indicate that KVM supports interrupt based delivery of 'page ready' APF events. This includes support for both MSR_KVM_ASYNC_PF_INT and MSR_KVM_ASYNC_PF_ACK. Signed-off-by: Vitaly Kuznetsov <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 557a961 commit 72de5fa

File tree

6 files changed

+19
-5
lines changed

6 files changed

+19
-5
lines changed

Documentation/virt/kvm/cpuid.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ KVM_FEATURE_PV_SCHED_YIELD 13 guest checks this feature bit
8686
before using paravirtualized
8787
sched yield.
8888

89+
KVM_FEATURE_ASYNC_PF_INT 14 guest checks this feature bit
90+
before using the second async
91+
pf control msr 0x4b564d06 and
92+
async pf acknowledgment msr
93+
0x4b564d07.
94+
8995
KVM_FEATURE_CLOCSOURCE_STABLE_BIT 24 host will warn if no guest-side
9096
per-cpu warps are expeced in
9197
kvmclock

Documentation/virt/kvm/msr.rst

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ data:
213213
cpl == 0. Bit 2 is 1 if asynchronous page faults are delivered to L1 as
214214
#PF vmexits. Bit 2 can be set only if KVM_FEATURE_ASYNC_PF_VMEXIT is
215215
present in CPUID. Bit 3 enables interrupt based delivery of 'page ready'
216-
events.
216+
events. Bit 3 can only be set if KVM_FEATURE_ASYNC_PF_INT is present in
217+
CPUID.
217218

218219
'Page not present' events are currently always delivered as synthetic
219220
#PF exception. During delivery of these events APF CR2 register contains
@@ -242,7 +243,8 @@ data:
242243

243244
Note, MSR_KVM_ASYNC_PF_INT MSR specifying the interrupt vector for 'page
244245
ready' APF delivery needs to be written to before enabling APF mechanism
245-
in MSR_KVM_ASYNC_PF_EN or interrupt #0 can get injected.
246+
in MSR_KVM_ASYNC_PF_EN or interrupt #0 can get injected. The MSR is
247+
available if KVM_FEATURE_ASYNC_PF_INT is present in CPUID.
246248

247249
Note, previously, 'page ready' events were delivered via the same #PF
248250
exception as 'page not present' events but this is now deprecated. If
@@ -360,7 +362,8 @@ data:
360362

361363
Interrupt vector for asynchnonous 'page ready' notifications delivery.
362364
The vector has to be set up before asynchronous page fault mechanism
363-
is enabled in MSR_KVM_ASYNC_PF_EN.
365+
is enabled in MSR_KVM_ASYNC_PF_EN. The MSR is only available if
366+
KVM_FEATURE_ASYNC_PF_INT is present in CPUID.
364367

365368
MSR_KVM_ASYNC_PF_ACK:
366369
0x4b564d07
@@ -371,4 +374,5 @@ data:
371374
When the guest is done processing 'page ready' APF event and 'token'
372375
field in 'struct kvm_vcpu_pv_apf_data' is cleared it is supposed to
373376
write '1' to bit 0 of the MSR, this causes the host to re-scan its queue
374-
and check if there are more notifications pending.
377+
and check if there are more notifications pending. The MSR is available
378+
if KVM_FEATURE_ASYNC_PF_INT is present in CPUID.

arch/x86/include/uapi/asm/kvm_para.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#define KVM_FEATURE_PV_SEND_IPI 11
3232
#define KVM_FEATURE_POLL_CONTROL 12
3333
#define KVM_FEATURE_PV_SCHED_YIELD 13
34+
#define KVM_FEATURE_ASYNC_PF_INT 14
3435

3536
#define KVM_HINTS_REALTIME 0
3637

arch/x86/kvm/cpuid.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,8 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
711711
(1 << KVM_FEATURE_ASYNC_PF_VMEXIT) |
712712
(1 << KVM_FEATURE_PV_SEND_IPI) |
713713
(1 << KVM_FEATURE_POLL_CONTROL) |
714-
(1 << KVM_FEATURE_PV_SCHED_YIELD);
714+
(1 << KVM_FEATURE_PV_SCHED_YIELD) |
715+
(1 << KVM_FEATURE_ASYNC_PF_INT);
715716

716717
if (sched_info_on())
717718
entry->eax |= (1 << KVM_FEATURE_STEAL_TIME);

arch/x86/kvm/x86.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3446,6 +3446,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
34463446
case KVM_CAP_X86_ROBUST_SINGLESTEP:
34473447
case KVM_CAP_XSAVE:
34483448
case KVM_CAP_ASYNC_PF:
3449+
case KVM_CAP_ASYNC_PF_INT:
34493450
case KVM_CAP_GET_TSC_KHZ:
34503451
case KVM_CAP_KVMCLOCK_CTRL:
34513452
case KVM_CAP_READONLY_MEM:

include/uapi/linux/kvm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,6 +1018,7 @@ struct kvm_ppc_resize_hpt {
10181018
#define KVM_CAP_S390_PROTECTED 180
10191019
#define KVM_CAP_PPC_SECURE_GUEST 181
10201020
#define KVM_CAP_HALT_POLL 182
1021+
#define KVM_CAP_ASYNC_PF_INT 183
10211022

10221023
#ifdef KVM_CAP_IRQ_ROUTING
10231024

0 commit comments

Comments
 (0)