Commit 3fac3734 authored by Juergen Gross's avatar Juergen Gross
Browse files

xen/pv: support selecting safe/unsafe msr accesses



Instead of always doing the safe variants for reading and writing MSRs
in Xen PV guests, make the behavior controllable via Kconfig option
and a boot parameter.

The default will be the current behavior, which is to always use the
safe variant.

Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
parent a1886b91
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -6836,6 +6836,12 @@
			Crash from Xen panic notifier, without executing late
			Crash from Xen panic notifier, without executing late
			panic() code such as dumping handler.
			panic() code such as dumping handler.


	xen_msr_safe=	[X86,XEN]
			Format: <bool>
			Select whether to always use non-faulting (safe) MSR
			access functions when running as Xen PV guest. The
			default value is controlled by CONFIG_XEN_PV_MSR_SAFE.

	xen_nopvspin	[X86,XEN]
	xen_nopvspin	[X86,XEN]
			Disables the qspinlock slowpath using Xen PV optimizations.
			Disables the qspinlock slowpath using Xen PV optimizations.
			This parameter is obsoleted by "nopvspin" parameter, which
			This parameter is obsoleted by "nopvspin" parameter, which
+9 −0
Original line number Original line Diff line number Diff line
@@ -92,3 +92,12 @@ config XEN_DOM0
	select X86_X2APIC if XEN_PVH && X86_64
	select X86_X2APIC if XEN_PVH && X86_64
	help
	help
	  Support running as a Xen Dom0 guest.
	  Support running as a Xen Dom0 guest.

config XEN_PV_MSR_SAFE
	bool "Always use safe MSR accesses in PV guests"
	default y
	depends on XEN_PV
	help
	  Use safe (not faulting) MSR access functions even if the MSR access
	  should not fault anyway.
	  The default can be changed by using the "xen_msr_safe" boot parameter.
+14 −10
Original line number Original line Diff line number Diff line
@@ -108,6 +108,16 @@ struct tls_descs {
 */
 */
static DEFINE_PER_CPU(struct tls_descs, shadow_tls_desc);
static DEFINE_PER_CPU(struct tls_descs, shadow_tls_desc);


static __read_mostly bool xen_msr_safe = IS_ENABLED(CONFIG_XEN_PV_MSR_SAFE);

static int __init parse_xen_msr_safe(char *str)
{
	if (str)
		return strtobool(str, &xen_msr_safe);
	return -EINVAL;
}
early_param("xen_msr_safe", parse_xen_msr_safe);

static void __init xen_pv_init_platform(void)
static void __init xen_pv_init_platform(void)
{
{
	/* PV guests can't operate virtio devices without grants. */
	/* PV guests can't operate virtio devices without grants. */
@@ -1010,22 +1020,16 @@ static int xen_write_msr_safe(unsigned int msr, unsigned int low,


static u64 xen_read_msr(unsigned int msr)
static u64 xen_read_msr(unsigned int msr)
{
{
	/*
	 * This will silently swallow a #GP from RDMSR.  It may be worth
	 * changing that.
	 */
	int err;
	int err;


	return xen_read_msr_safe(msr, &err);
	return xen_do_read_msr(msr, xen_msr_safe ? &err : NULL);
}
}


static void xen_write_msr(unsigned int msr, unsigned low, unsigned high)
static void xen_write_msr(unsigned int msr, unsigned low, unsigned high)
{
{
	/*
	int err;
	 * This will silently swallow a #GP from WRMSR.  It may be worth

	 * changing that.
	xen_do_write_msr(msr, low, high, xen_msr_safe ? &err : NULL);
	 */
	xen_write_msr_safe(msr, low, high);
}
}


/* This is called once we have the cpu_possible_mask */
/* This is called once we have the cpu_possible_mask */