Skip to content

Commit ae378e6

Browse files
author
Lai Jiangshan
committed
KVM: x86/pvm: Remove SWITCH_FLAGS_NMI_WIN
SWITCH_FLAGS_IRQ_WIN is used instead and add the comment on it. Signed-off-by: Lai Jiangshan <jiangshan.ljs@antgroup.com>
1 parent 1968ae3 commit ae378e6

2 files changed

Lines changed: 16 additions & 9 deletions

File tree

arch/x86/kvm/pvm/pvm.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,8 +1589,13 @@ static int __do_pvm_event(struct kvm_vcpu *vcpu, bool user, int vector,
15891589
* correspondingly.
15901590
*
15911591
* The guest should check async exceptions when it clears any
1592-
* PVM_PVCS_EVENT_VECTOR_* bits. The hypervisor should check
1593-
* async exceptions when handling ERETU/ERETS.
1592+
* PVM_PVCS_EVENT_VECTOR_* bits.
1593+
*
1594+
* While the guest sets PVM_PVCS_EVENT_VECTOR_STD before
1595+
* invoking ERETU/ERETS, it cannot check for any async
1596+
* exceptions in an atomic way. Instead, it relies on the
1597+
* hypervisor to check for any unhandled async exceptions
1598+
* when handling ERETU/ERETS.
15941599
*/
15951600
if (vector == NMI_VECTOR)
15961601
pvcs->event_vector |= PVM_PVCS_EVENT_VECTOR_NMI;
@@ -1600,8 +1605,13 @@ static int __do_pvm_event(struct kvm_vcpu *vcpu, bool user, int vector,
16001605
kvm_make_request(KVM_REQ_TRIPLE_FAULT, vcpu);
16011606

16021607
/*
1603-
* Set SWITCH_FLAGS_IRQ_WIN to stop the guest to directly
1604-
* switch to the user mode.
1608+
* Reuse SWITCH_FLAGS_IRQ_WIN to force the guest ERETU back to
1609+
* the hypervisor to meet the requirement stipulated above in
1610+
* case it is on the path to ERETU.
1611+
*
1612+
* When forced back to handle_synthetic_instruction_return(),
1613+
* SWITCH_FLAGS_IRQ_WIN will be cleared in kvm_set_rflags() or
1614+
* unhandled NMI/MCE will be reinjected.
16051615
*/
16061616
to_pvm(vcpu)->switch_flags |= SWITCH_FLAGS_IRQ_WIN;
16071617

arch/x86/kvm/pvm/pvm.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,14 @@
1111
* IRQ_WIN:
1212
* There is an irq window request, and the vcpu should not directly
1313
* switch to context with IRQ enabled, e.g. user mode.
14-
* NMI_WIN:
15-
* There is an NMI window request.
1614
* SINGLE_STEP:
1715
* KVM_GUESTDBG_SINGLESTEP is set.
1816
* PVCS_INVALID:
1917
* The GPC of PVCS is invalid and khva is NULL.
2018
*/
2119
#define SWITCH_FLAGS_IRQ_WIN _BITULL(8)
22-
#define SWITCH_FLAGS_NMI_WIN _BITULL(9)
23-
#define SWITCH_FLAGS_SINGLE_STEP _BITULL(10)
24-
#define SWITCH_FLAGS_PVCS_INVALID _BITULL(11)
20+
#define SWITCH_FLAGS_SINGLE_STEP _BITULL(9)
21+
#define SWITCH_FLAGS_PVCS_INVALID _BITULL(10)
2522

2623
#define SWITCH_FLAGS_INIT (SWITCH_FLAGS_SMOD | SWITCH_FLAGS_PVCS_INVALID)
2724

0 commit comments

Comments
 (0)