Skip to content

KVM: x86: Add CMCI and UCNA emulation

Jue Wang kvm 5 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest8 patches 6 repliesIn review
  2. v48 patches 7 repliesSuperseded
  3. v37 patches 2 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v24 patches8 repliesSuperseded
v11 patch9 repliesSuperseded

Changes in v5 from the cover letter

- Incorporate feedback from David Matlack <[email protected]>
- Rewrite the change log to be more concise and accurate.
- Removes several duplicated checks in UCNA injection code.
- Add test cases that validate CMCI emulation to self test.

Patches in v5 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8KVM: x86: Make APIC_VERSION capture only the magic 0x14UL.arch/x86/kvm/lapic.c+2 -20 replies
2/8KVM: x86: Fill apic_lvt_mask with enums / explicit entries.arch/x86/kvm/lapic.c arch/x86/kvm/lapic.h+21 -100 replies
3/8KVM: x86: Add APIC_LVTx() macro.arch/x86/kvm/lapic.c arch/x86/kvm/lapic.h+5 -40 replies
4/8KVM: x86: Add Corrected Machine Check Interrupt (CMCI) emulation to lapic.arch/x86/kvm/lapic.c arch/x86/kvm/lapic.h arch/x86/kvm/x86.c+38 -163 replies
5/8KVM: x86: Use kcalloc to allocate the mce_banks array.arch/x86/kvm/x86.c+1 -10 replies
6/8KVM: x86: Add emulation for MSR_IA32_MCx_CTL2 MSRs.arch/x86/include/asm/kvm_host.h arch/x86/kvm/x86.c+92 -390 replies
7/8KVM: x86: Enable CMCI capability by default and handle injected UCNA errorsarch/x86/kvm/vmx/vmx.c arch/x86/kvm/x86.c+44 -10 replies
8/8KVM: selftests: Add a self test for CMCI and UCNA emulations.tools/testing/selftests/kvm/.gitignore tools/testing/selftests/kvm/Makefile tools/testing/selftests/kvm/include/x86_64/apic.h +4 more+377 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v5 yet.

Read the v5 thread

Cover letter [PATCH v5 0/8] KVM: x86: Add CMCI and UCNA emulation

This patch series implement emulation for Corrected Machine Check Interrupt (CMCI) signaling and UnCorrectable No Action required (UCNA) error injection.

UCNA errors signaled via CMCI allow a guest to be notified as soon as uncorrectable memory errors get detected by some background threads, e.g., threads that migrate guest memory across hosts or threads that constantly scan system memory for errors [1].

Upon receiving UCNAs, guest kernel isolates the poisoned pages which may still be free, preventing future accesses that may cause fatal MCEs.

1. https://lore.kernel.org/linux-mm/[email protected]/t/

Patch 1-3 clean up KVM APIC LVT logic in preparation to adding APIC_LVTCMCI.

Patch 4 adds APIC_LVTCMCI emulation.

Patch 5 updates mce_banks to use array allocation api.

Patch 6 adds emulation for MSR_IA32_MCx_CTL2 registers that provide per bank control of CMCI signaling.

Patch 7 enables MCG_CMCI_P and handles injected UCNA errors.

Patch 8 adds a KVM self test that validates UCNA injection and CMCI emulation.

v5 changes
- Incorporate feedback from David Matlack <[email protected]>
- Rewrite the change log to be more concise and accurate.
- Removes several duplicated checks in UCNA injection code.
- Add test cases that validate CMCI emulation to self test.

v4 changes
- Incorporate feedback from David Matlack <[email protected]>
- Rewrite the change logs to be more descriptive.
- Add a KVM self test.

v3 changes
- Incorporate feedback from Sean Christopherson <[email protected]>
- Split clean up to KVM APIC LVT logic to 3 patches.
- Put the clean up of mce_array allocation in a separate patch.
- Base the MCi_CTL2 register emulation on Sean's clean up and fix series [2]
- Fix bugs around MCi_CTL2 register offset validation and the free of mci_ctl2_banks array.
- Rewrite the change log with more details in architectural information about CMCI, UCNA and MCG_CMCI_P.
- Fix various comments and wrapping style.

2. https://lore.kernel.org/lkml/[email protected]/T/

v2 chanegs
- Incorporate feedback from Sean Christopherson <[email protected]>
- Split the single patch into 4:
1). clean up KVM APIC LVT logic
2). add CMCI emulation to lapic
3). add emulation of MSR_IA32_MCx_CTL2
4). enable MCG_CMCI_P and handle injected UCNAs
- Fix various style issues.

Jue Wang (8):
KVM: x86: Make APIC_VERSION capture only the magic 0x14UL.
KVM: x86: Fill apic_lvt_mask with enums / explicit entries.
KVM: x86: Add APIC_LVTx() macro.
KVM: x86: Add Corrected Machine Check Interrupt (CMCI) emulation to
lapic.
KVM: x86: Use kcalloc to allocate the mce_banks array.
KVM: x86: Add emulation for MSR_IA32_MCx_CTL2 MSRs.
KVM: x86: Enable CMCI capability by default and handle injected UCNA
errors
KVM: selftests: Add a self test for CMCI and UCNA emulations.

 arch/x86/include/asm/kvm_host.h               |   1 +
 arch/x86/kvm/lapic.c                          |  66 ++--
 arch/x86/kvm/lapic.h                          |  16 +-
 arch/x86/kvm/vmx/vmx.c                        |   1 +
 arch/x86/kvm/x86.c                            | 178 ++++++---
 tools/testing/selftests/kvm/.gitignore        |   1 +
 tools/testing/selftests/kvm/Makefile          |   1 +
 .../selftests/kvm/include/x86_64/apic.h       |   1 +
 .../selftests/kvm/include/x86_64/mce.h        |  25 ++
 .../selftests/kvm/include/x86_64/processor.h  |   1 +
 .../selftests/kvm/lib/x86_64/processor.c      |   2 +-
 .../kvm/x86_64/ucna_injection_test.c          | 347 ++++++++++++++++++
 12 files changed, 573 insertions(+), 67 deletions(-)
 create mode 100644 tools/testing/selftests/kvm/include/x86_64/mce.h
 create mode 100644 tools/testing/selftests/kvm/x86_64/ucna_injection_test.c
Signature · 1 line
2.36.1.255.ge46751e96f-goog