Skip to content

target-i386: kvm: Increase MSR entry array limits, check for array overrun

Eduardo Habkost kvm qemu-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest5 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5target-i386: kvm: Allocate kvm_msrs struct once per VCPUtarget-i386/cpu-qom.h target-i386/kvm.c+23 -180 replies
2/5target-i386: kvm: Increase MSR_BUF_SIZEtarget-i386/kvm.c+3 -20 replies
3/5target-i386: kvm: Simplify MSR array constructiontarget-i386/kvm.c+125 -1370 replies
4/5target-i386: kvm: Simplify MSR setting functionstarget-i386/kvm.c+6 -220 replies
5/5target-i386: kvm: Eliminate kvm_msr_entry_set()target-i386/kvm.c+3 -90 replies

Reviews trailers per patch

None of the 5 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchPaolo Bonzini
SeriesR-b
1/5
2/5
3/5
4/5
5/5

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/5] target-i386: kvm: Increase MSR entry array limits, check for array overrun

We are dangerously close to the array limits in kvm_put_msrs() and kvm_get_msrs(): with the default mcg_cap configuration, we can set up to 148 MSRs in kvm_put_msrs(), and if we allow mcg_cap to be changed, we can write up to 236 MSRs[1].

This series changes the code to allocate a buffer once per VCPU, increase buffer size to 4096 bytes (that can hold up to 255 MSR entries), and check array limits before appending new entries.

[1] I have checked the limits by copying and pasting the kvm_put_msrs() code to a new file, replacing the "if" lines, copying the macro definitions, and adding a helper macro to keep track of the kvm_msr_entry_set() calls. The code can be seen at:
https://gist.github.com/ehabkost/08d4177a33b8648a71ef

Eduardo Habkost (5):
target-i386: kvm: Allocate kvm_msrs struct once per VCPU
target-i386: kvm: Increase MSR_BUF_SIZE
target-i386: kvm: Simplify MSR array construction
target-i386: kvm: Simplify MSR setting functions
target-i386: kvm: Eliminate kvm_msr_entry_set()

 target-i386/cpu-qom.h |   4 +
 target-i386/kvm.c     | 322 +++++++++++++++++++++++---------------------------
 2 files changed, 149 insertions(+), 177 deletions(-)
Signature · 1 line
2.1.0