Skip to content

Commit 58ced37

Browse files
suomilewisgregkh
authored andcommitted
selftests: kvm: Fix the segment descriptor layout to match the actual layout
[ Upstream commit df11f7d ] Fix the layout of 'struct desc64' to match the layout described in the SDM Vol 3, Chapter 3 "Protected-Mode Memory Management", section 3.4.5 "Segment Descriptors", Figure 3-8 "Segment Descriptor". The test added later in this series relies on this and crashes if this layout is not correct. Signed-off-by: Aaron Lewis <aaronlewis@google.com> Reviewed-by: Alexander Graf <graf@amazon.com> Message-Id: <20201012194716.3950330-2-aaronlewis@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 8ebc414 commit 58ced37

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

‎tools/testing/selftests/kvm/include/x86_64/processor.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ enum x86_register {
5757
struct desc64 {
5858
uint16_t limit0;
5959
uint16_t base0;
60-
unsigned base1:8, s:1, type:4, dpl:2, p:1;
60+
unsigned base1:8, type:4, s:1, dpl:2, p:1;
6161
unsigned limit1:4, avl:1, l:1, db:1, g:1, base2:8;
6262
uint32_t base3;
6363
uint32_t zero1;

‎tools/testing/selftests/kvm/lib/x86_64/processor.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,11 +446,12 @@ static void kvm_seg_fill_gdt_64bit(struct kvm_vm *vm, struct kvm_segment *segp)
446446
desc->limit0 = segp->limit & 0xFFFF;
447447
desc->base0 = segp->base & 0xFFFF;
448448
desc->base1 = segp->base >> 16;
449-
desc->s = segp->s;
450449
desc->type = segp->type;
450+
desc->s = segp->s;
451451
desc->dpl = segp->dpl;
452452
desc->p = segp->present;
453453
desc->limit1 = segp->limit >> 16;
454+
desc->avl = segp->avl;
454455
desc->l = segp->l;
455456
desc->db = segp->db;
456457
desc->g = segp->g;

0 commit comments

Comments
 (0)