Skip to content

Commit

Permalink
hv:add volatile keyword for some variables
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
mingqiangchi authored and wenlingz committed Sep 10, 2019
1 parent be0c2a8 commit c691c5b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion hypervisor/arch/x86/cpu.c
Expand Up @@ -37,7 +37,7 @@ static uint64_t pcpu_sync = 0UL;
static uint64_t startup_paddr = 0UL;

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

static void pcpu_xsave_init(void);
static void set_current_pcpu_id(uint16_t pcpu_id);
Expand Down
2 changes: 1 addition & 1 deletion hypervisor/include/arch/x86/guest/vcpu.h
Expand Up @@ -360,7 +360,7 @@ struct acrn_vcpu {

struct sched_object sched_obj;
bool launched; /* Whether the vcpu is launched on target pcpu */
bool running; /* vcpu is picked up and run? */
volatile bool running; /* vcpu is picked up and run? */

struct instr_emul_ctxt inst_ctxt;
struct io_request req; /* used by io/ept emulation */
Expand Down

0 comments on commit c691c5b

Please sign in to comment.