Skip to content

Commit 79d0330

Browse files
Shawnshhwenlingz
authored andcommitted
HV: fix vmptable "Casting operation to a pointer"
ACRN Coding guidelines requires two different types pointer can't convert to each other, except void *. Tracked-On: #861 Signed-off-by: Huihuang Shi <huihuang.shi@intel.com>
1 parent 9063504 commit 79d0330

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

hypervisor/arch/x86/configs/vmptable.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,9 @@ static uint8_t mpt_compute_checksum(const void *base, size_t len)
8585
*/
8686
int32_t mptable_build(struct acrn_vm *vm)
8787
{
88-
char *startaddr;
89-
char *curraddr;
9088
struct mpcth *mpch;
9189
struct mpfps *mpfp;
90+
struct mptable_info *mpinfo;
9291
size_t mptable_length;
9392
uint16_t i;
9493
uint16_t vcpu_num;
@@ -127,14 +126,11 @@ int32_t mptable_build(struct acrn_vm *vm)
127126
/* Copy mptable info into guest memory */
128127
(void)copy_to_gpa(vm, (void *)mptable, MPTABLE_BASE, mptable_length);
129128

130-
startaddr = (char *)gpa2hva(vm, MPTABLE_BASE);
131-
curraddr = startaddr;
129+
mpinfo = (struct mptable_info *) gpa2hva(vm, MPTABLE_BASE);
132130
stac();
133-
mpfp = (struct mpfps *)curraddr;
131+
mpfp = &mpinfo->mpfp;
134132
mpfp->checksum = mpt_compute_checksum(mpfp, sizeof(struct mpfps));
135-
curraddr += sizeof(struct mpfps);
136-
137-
mpch = (struct mpcth *)curraddr;
133+
mpch = &mpinfo->mpch;
138134
mpch->checksum = mpt_compute_checksum(mpch, mpch->base_table_length);
139135
clac();
140136
ret = 0;

0 commit comments

Comments
 (0)