Re: [PART1 RFC 9/9] svm: Manage vcpu load/unload when enable AVIC
From: Paolo Bonzini
Date: Fri Feb 12 2016 - 10:46:53 EST
On 12/02/2016 14:59, Suravee Suthikulpanit wrote:
> +
> + if (is_running) {
> + phys_addr_t pa = PFN_PHYS(page_to_pfn(svm->avic_bk_page));
> +
> + entry->bk_pg_ptr = (pa >> 12) & 0xffffffffff;
> + entry->valid = 1;
> + entry->host_phy_apic_id = h_phy_apic_id;
> + barrier();
> + entry->is_running = is_running;
I'm not sure if you can rely on the compiler doing the right thing here.
I would prefer something like:
new_entry = READ_ONCE(entry);
new_entry.bk_pg_ptr = (pa >> 12) & 0xffffffffff;
new_entry.valid = 1;
new_entry.host_phy_apic_id = h_phy_apic_id;
new_entry.is_running = is_running;
WRITE_ONCE(entry, new_entry);
Paolo