Skip to content

Commit df11f7d

Browse files
suomilewisbonzini
authored andcommitted
selftests: kvm: Fix the segment descriptor layout to match the actual layout
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>
1 parent 2cdef91 commit df11f7d

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
@@ -59,7 +59,7 @@ struct gpr64_regs {
5959
struct desc64 {
6060
uint16_t limit0;
6161
uint16_t base0;
62-
unsigned base1:8, s:1, type:4, dpl:2, p:1;
62+
unsigned base1:8, type:4, s:1, dpl:2, p:1;
6363
unsigned limit1:4, avl:1, l:1, db:1, g:1, base2:8;
6464
uint32_t base3;
6565
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
@@ -392,11 +392,12 @@ static void kvm_seg_fill_gdt_64bit(struct kvm_vm *vm, struct kvm_segment *segp)
392392
desc->limit0 = segp->limit & 0xFFFF;
393393
desc->base0 = segp->base & 0xFFFF;
394394
desc->base1 = segp->base >> 16;
395-
desc->s = segp->s;
396395
desc->type = segp->type;
396+
desc->s = segp->s;
397397
desc->dpl = segp->dpl;
398398
desc->p = segp->present;
399399
desc->limit1 = segp->limit >> 16;
400+
desc->avl = segp->avl;
400401
desc->l = segp->l;
401402
desc->db = segp->db;
402403
desc->g = segp->g;

0 commit comments

Comments
 (0)