Complete r323772 on amd64.
Compilers are allowed to combine plain reads into group operations, e.g. 64bit element copies of one array into another can be legitimately optimized back to a memcpy() call, which r323772 tried to prevent. Qualify accesses to LDT descriptors with volatile dereference to ensure that each write indeed occurs. After that, our usual claim of native-size aligned writes being atomic applies. This is equivalent to atomic_store(memory_order_relaxed) C11 accesses, but our machine/atomic.h does not provide corresponding primitive. Noted and reviewed by: bde Sponsored by: The FreeBSD Foundation MFC after: 1 week
This commit is contained in:
parent
3684a76fa7
commit
00ef4a21e2
@ -616,7 +616,7 @@ amd64_set_ldt(struct thread *td, struct i386_ldt_args *uap,
|
||||
return (EINVAL);
|
||||
mtx_lock(&dt_lock);
|
||||
for (i = uap->start; i < largest_ld; i++)
|
||||
((uint64_t *)(pldt->ldt_base))[i] = 0;
|
||||
((volatile uint64_t *)(pldt->ldt_base))[i] = 0;
|
||||
mtx_unlock(&dt_lock);
|
||||
return (0);
|
||||
}
|
||||
@ -734,15 +734,15 @@ amd64_set_ldt_data(struct thread *td, int start, int num,
|
||||
{
|
||||
struct mdproc *mdp;
|
||||
struct proc_ldt *pldt;
|
||||
uint64_t *dst, *src;
|
||||
volatile uint64_t *dst, *src;
|
||||
int i;
|
||||
|
||||
mtx_assert(&dt_lock, MA_OWNED);
|
||||
|
||||
mdp = &td->td_proc->p_md;
|
||||
pldt = mdp->md_ldt;
|
||||
dst = (uint64_t *)(pldt->ldt_base);
|
||||
src = (uint64_t *)descs;
|
||||
dst = (volatile uint64_t *)(pldt->ldt_base);
|
||||
src = (volatile uint64_t *)descs;
|
||||
for (i = 0; i < num; i++)
|
||||
dst[start + i] = src[i];
|
||||
return (0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user