xenalyze: use packed structs with u64 members
PATCH 1/1 xenalyze: use packed structs with u64 members
George,
there is some padding after the first struct member if it is followed by an unsigned long long. This happens with 64bit builds. Adding an attribute to this struct fixes the size checks in hvm_msr_write_process() for me. There are a few more places where the padding will break things. This explains also the unexpected rip values.
Signed-off-by Olaf Hering <[email protected]>
xenalyze.c +6 -6
@@ -4138,7 +4138,7 @@ void hvm_cr_write_process(struct record_struct {unsigned cr;unsigned long long val; - } x64; + } __attribute__((packed)) x64; } *r = (typeof (r ))h->d;unsigned cr;unsigned long long val;
@@ -4204,7 +4204,7 @@ void hvm_msr_write_process(struct recordstruct {unsigned int addr;unsigned long long val; - } *r = (typeof (r ))h->d; + } __attribute__((packed)) *r = (typeof (r ))h->d;int expected_extra=(sizeof (*r)/sizeof (unsigned int ));
@@ -4256,7 +4256,7 @@ void hvm_msr_read_process(struct record_struct {unsigned int addr;unsigned long long val; - } *r = (typeof (r ))h->d; + } __attribute__((packed)) *r = (typeof (r ))h->d;int expected_extra=(sizeof (*r)/sizeof (unsigned int ));
@@ -4499,7 +4499,7 @@ void hvm_pf_inject_process(struct recordstruct {unsigned ec;unsigned long long cr2; - } x64; + } __attribute__((packed)) x64; } *r = (typeof (r ))h->d;unsigned int ec;unsigned long long cr2;
@@ -4945,7 +4945,7 @@ void hvm_vmexit_process(struct record_instruct {unsigned int exit_reason;unsigned long long rip; - } x64; + } __attribute__((packed)) x64;struct {unsigned int exit_reason;unsigned int eip;
@@ -6788,7 +6788,7 @@ void sched_runstate_process(struct pcpu_struct {unsigned vcpu:16 , dom:16 ;unsigned long long p1, p2; - } * r = (typeof (r ))ri->d; + } __attribute__((packed)) * r = (typeof (r ))ri->d; union { unsigned int event; struct {
PATCH 1/1 xenalyze: add missing newline to fprintf
Add missing newline to fprintf.
Signed-off-by Olaf Hering <[email protected]>
xenalyze.c +1 -1
@@ -4980,7 +4980,7 @@ void hvm_vmexit_process(struct record_in v->guest_paging_levels =4 ; }if (!is_valid_addr64 (r->x64.rip)) -fprintf (warn,"%s: invalid va %llx" , +fprintf (warn,"%s: invalid va %llx\n" , __func__, r->x64.rip); h->rip = r->x64.rip; h->exit_reason = r->x64.exit_reason;
PATCH 1/1 xenalyze: use correct sizeof argument when counting extra_data
In reply to Olaf Heringtracedata are units of u32, so make sure the sizeof() gets the correct argument.
Signed-off-by Olaf Hering <[email protected]>
xenalyze.c +2 -2
@@ -3588,12 +3588,12 @@ void hvm_mmio_assist_process(struct recoif (mevt.x64) { e->gpa = r->x64.gpa; e->data = r->x64.data; -if (ri->extra_words*(sizeof (unsigned long ))==sizeof (r->x64)) +if (ri->extra_words*(sizeof (unsigned int ))==sizeof (r->x64)) e->mmio_data_valid=1 ; }else { e->gpa = r->x32.gpa; e->data = r->x32.data; -if (ri->extra_words*(sizeof (unsigned long ))==sizeof (r->x32)) +if (ri->extra_words*(sizeof (unsigned int ))==sizeof (r->x32)) e->mmio_data_valid=1 ; }