Skip to content

Commit c691c5b

Browse files
mingqiangchiwenlingz
authored andcommitted
hv:add volatile keyword for some variables
pcpu_active_bitmap was read continuously in wait_pcpus_offline(), acrn_vcpu->running was read continuously in pause_vcpu(), add volatile keyword to ensure that such accesses are not optimised away by the complier. Tracked-On: #1842 Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
1 parent be0c2a8 commit c691c5b

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

hypervisor/arch/x86/cpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static uint64_t pcpu_sync = 0UL;
3737
static uint64_t startup_paddr = 0UL;
3838

3939
/* physical cpu active bitmap, support up to 64 cpus */
40-
static uint64_t pcpu_active_bitmap = 0UL;
40+
static volatile uint64_t pcpu_active_bitmap = 0UL;
4141

4242
static void pcpu_xsave_init(void);
4343
static void set_current_pcpu_id(uint16_t pcpu_id);

hypervisor/include/arch/x86/guest/vcpu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ struct acrn_vcpu {
360360

361361
struct sched_object sched_obj;
362362
bool launched; /* Whether the vcpu is launched on target pcpu */
363-
bool running; /* vcpu is picked up and run? */
363+
volatile bool running; /* vcpu is picked up and run? */
364364

365365
struct instr_emul_ctxt inst_ctxt;
366366
struct io_request req; /* used by io/ept emulation */

0 commit comments

Comments
 (0)