Skip to content

Commit 08cf8f6

Browse files
lyan3wenlingz
authored andcommitted
hv: lapic: fix MISRA-C violation of potential numeric overflow
This patch fixes the MISRA-C violations in arch/x86/lapic.c, change local variable from uint32_t to uint64_t to avoid potential numeric overflow. Tracked-On: #861 Signed-off-by: Yan, Like <like.yan@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent 83ebd43 commit 08cf8f6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

hypervisor/arch/x86/lapic.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,15 +154,15 @@ static void restore_lapic(const struct lapic_regs *regs)
154154

155155
void suspend_lapic(void)
156156
{
157-
uint32_t val;
157+
uint64_t val;
158158

159159
saved_lapic_base_msr.value = msr_read(MSR_IA32_APIC_BASE);
160160
save_lapic(&saved_lapic_regs);
161161

162162
/* disable APIC with software flag */
163-
val = (uint32_t) msr_read(MSR_IA32_EXT_APIC_SIVR);
164-
val = (~LAPIC_SVR_APIC_ENABLE_MASK) & val;
165-
msr_write(MSR_IA32_EXT_APIC_SIVR, (uint64_t) val);
163+
val = msr_read(MSR_IA32_EXT_APIC_SIVR);
164+
val = (~(uint64_t)LAPIC_SVR_APIC_ENABLE_MASK) & val;
165+
msr_write(MSR_IA32_EXT_APIC_SIVR, val);
166166
}
167167

168168
void resume_lapic(void)

0 commit comments

Comments
 (0)