Merge branch 'stable/for-linus-fixes-3.3' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen
* 'stable/for-linus-fixes-3.3' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen: xen/granttable: Disable grant v2 for HVM domains. x86: xen: size struct xen_spinlock to always fit in arch_spinlock_t
This commit is contained in:
@@ -116,9 +116,26 @@ static inline void spin_time_accum_blocked(u64 start)
|
|||||||
}
|
}
|
||||||
#endif /* CONFIG_XEN_DEBUG_FS */
|
#endif /* CONFIG_XEN_DEBUG_FS */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Size struct xen_spinlock so it's the same as arch_spinlock_t.
|
||||||
|
*/
|
||||||
|
#if NR_CPUS < 256
|
||||||
|
typedef u8 xen_spinners_t;
|
||||||
|
# define inc_spinners(xl) \
|
||||||
|
asm(LOCK_PREFIX " incb %0" : "+m" ((xl)->spinners) : : "memory");
|
||||||
|
# define dec_spinners(xl) \
|
||||||
|
asm(LOCK_PREFIX " decb %0" : "+m" ((xl)->spinners) : : "memory");
|
||||||
|
#else
|
||||||
|
typedef u16 xen_spinners_t;
|
||||||
|
# define inc_spinners(xl) \
|
||||||
|
asm(LOCK_PREFIX " incw %0" : "+m" ((xl)->spinners) : : "memory");
|
||||||
|
# define dec_spinners(xl) \
|
||||||
|
asm(LOCK_PREFIX " decw %0" : "+m" ((xl)->spinners) : : "memory");
|
||||||
|
#endif
|
||||||
|
|
||||||
struct xen_spinlock {
|
struct xen_spinlock {
|
||||||
unsigned char lock; /* 0 -> free; 1 -> locked */
|
unsigned char lock; /* 0 -> free; 1 -> locked */
|
||||||
unsigned short spinners; /* count of waiting cpus */
|
xen_spinners_t spinners; /* count of waiting cpus */
|
||||||
};
|
};
|
||||||
|
|
||||||
static int xen_spin_is_locked(struct arch_spinlock *lock)
|
static int xen_spin_is_locked(struct arch_spinlock *lock)
|
||||||
@@ -164,8 +181,7 @@ static inline struct xen_spinlock *spinning_lock(struct xen_spinlock *xl)
|
|||||||
|
|
||||||
wmb(); /* set lock of interest before count */
|
wmb(); /* set lock of interest before count */
|
||||||
|
|
||||||
asm(LOCK_PREFIX " incw %0"
|
inc_spinners(xl);
|
||||||
: "+m" (xl->spinners) : : "memory");
|
|
||||||
|
|
||||||
return prev;
|
return prev;
|
||||||
}
|
}
|
||||||
@@ -176,8 +192,7 @@ static inline struct xen_spinlock *spinning_lock(struct xen_spinlock *xl)
|
|||||||
*/
|
*/
|
||||||
static inline void unspinning_lock(struct xen_spinlock *xl, struct xen_spinlock *prev)
|
static inline void unspinning_lock(struct xen_spinlock *xl, struct xen_spinlock *prev)
|
||||||
{
|
{
|
||||||
asm(LOCK_PREFIX " decw %0"
|
dec_spinners(xl);
|
||||||
: "+m" (xl->spinners) : : "memory");
|
|
||||||
wmb(); /* decrement count before restoring lock */
|
wmb(); /* decrement count before restoring lock */
|
||||||
__this_cpu_write(lock_spinners, prev);
|
__this_cpu_write(lock_spinners, prev);
|
||||||
}
|
}
|
||||||
@@ -373,6 +388,8 @@ void xen_uninit_lock_cpu(int cpu)
|
|||||||
|
|
||||||
void __init xen_init_spinlocks(void)
|
void __init xen_init_spinlocks(void)
|
||||||
{
|
{
|
||||||
|
BUILD_BUG_ON(sizeof(struct xen_spinlock) > sizeof(arch_spinlock_t));
|
||||||
|
|
||||||
pv_lock_ops.spin_is_locked = xen_spin_is_locked;
|
pv_lock_ops.spin_is_locked = xen_spin_is_locked;
|
||||||
pv_lock_ops.spin_is_contended = xen_spin_is_contended;
|
pv_lock_ops.spin_is_contended = xen_spin_is_contended;
|
||||||
pv_lock_ops.spin_lock = xen_spin_lock;
|
pv_lock_ops.spin_lock = xen_spin_lock;
|
||||||
|
@@ -948,9 +948,12 @@ static void gnttab_request_version(void)
|
|||||||
int rc;
|
int rc;
|
||||||
struct gnttab_set_version gsv;
|
struct gnttab_set_version gsv;
|
||||||
|
|
||||||
|
if (xen_hvm_domain())
|
||||||
|
gsv.version = 1;
|
||||||
|
else
|
||||||
gsv.version = 2;
|
gsv.version = 2;
|
||||||
rc = HYPERVISOR_grant_table_op(GNTTABOP_set_version, &gsv, 1);
|
rc = HYPERVISOR_grant_table_op(GNTTABOP_set_version, &gsv, 1);
|
||||||
if (rc == 0) {
|
if (rc == 0 && gsv.version == 2) {
|
||||||
grant_table_version = 2;
|
grant_table_version = 2;
|
||||||
gnttab_interface = &gnttab_v2_ops;
|
gnttab_interface = &gnttab_v2_ops;
|
||||||
} else if (grant_table_version == 2) {
|
} else if (grant_table_version == 2) {
|
||||||
|
Reference in New Issue
Block a user