Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions varstored.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,22 @@
#include "io_port.h"
#include "option.h"

/* Get the correct defines for memory barriers - do not fall
* back to those provided by the kernel */
/* from <xen-barrier.h> in 4.20.0 */

#define xen_barrier() asm volatile ( "" : : : "memory")
Copy link
Collaborator

@rosslagerwall rosslagerwall Oct 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this added if it is not used?

Having said that, I think it might be preferable to simply include a copy of xen-barrier.h and #include it. It would be easier to keep up-to-date and mean less tat in this file.


#if defined(__i386__)
# define smp_mb() asm volatile ( "lock addl $0, -4(%%esp)" ::: "memory" )
#define xen_mb() asm volatile ( "lock addl $0, -4(%%esp)" ::: "memory" )
#elif defined(__x86_64__)
# define smp_mb() asm volatile ( "lock addl $0, -32(%%rsp)" ::: "memory" )
#define xen_mb() asm volatile ( "lock addl $0, -32(%%rsp)" ::: "memory" )
#elif defined(__arm__)
#define xen_mb() asm volatile ("dmb" : : : "memory")
#elif defined(__aarch64__)
#define xen_mb() asm volatile ("dmb sy" : : : "memory")
#else
#error "Define barriers"
#endif

#define IO_PORT_ADDRESS 0x0100
Expand Down Expand Up @@ -551,15 +563,15 @@ varstored_poll_iopage(unsigned int i)
fprintf(stderr, "IO request not ready\n");
return;
}
smp_mb();
xen_mb();

ioreq->state = STATE_IOREQ_INPROCESS;

handle_ioreq(ioreq);
smp_mb();
xen_mb();

ioreq->state = STATE_IORESP_READY;
smp_mb();
xen_mb();

xenevtchn_notify(varstored_state.evth, varstored_state.ioreq_local_port[i]);
}
Expand Down