Skip to content

Commit a71dbda

Browse files
Boris OstrovskyDavid Vrabel
authored andcommitted
hypervisor/x86/xen: Unset X86_BUG_SYSRET_SS_ATTRS on Xen PV guests
Commit 61f01dd ("x86_64, asm: Work around AMD SYSRET SS descriptor attribute issue") makes AMD processors set SS to __KERNEL_DS in __switch_to() to deal with cases when SS is NULL. This breaks Xen PV guests who do not want to load SS with__KERNEL_DS. Since the problem that the commit is trying to address would have to be fixed in the hypervisor (if it in fact exists under Xen) there is no reason to set X86_BUG_SYSRET_SS_ATTRS flag for PV VPCUs here. This can be easily achieved by adding x86_hyper_xen_hvm.set_cpu_features op which will clear this flag. (And since this structure is no longer HVM-specific we should do some renaming). Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com> Reported-by: Sander Eikelenboom <linux@eikelenboom.it> Signed-off-by: David Vrabel <david.vrabel@citrix.com>
1 parent 16e6bd5 commit a71dbda

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

arch/x86/include/asm/hypervisor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ extern const struct hypervisor_x86 *x86_hyper;
5050
/* Recognized hypervisors */
5151
extern const struct hypervisor_x86 x86_hyper_vmware;
5252
extern const struct hypervisor_x86 x86_hyper_ms_hyperv;
53-
extern const struct hypervisor_x86 x86_hyper_xen_hvm;
53+
extern const struct hypervisor_x86 x86_hyper_xen;
5454
extern const struct hypervisor_x86 x86_hyper_kvm;
5555

5656
extern void init_hypervisor(struct cpuinfo_x86 *c);

arch/x86/kernel/cpu/hypervisor.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727

2828
static const __initconst struct hypervisor_x86 * const hypervisors[] =
2929
{
30-
#ifdef CONFIG_XEN_PVHVM
31-
&x86_hyper_xen_hvm,
30+
#ifdef CONFIG_XEN
31+
&x86_hyper_xen,
3232
#endif
3333
&x86_hyper_vmware,
3434
&x86_hyper_ms_hyperv,

arch/x86/xen/enlighten.c

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,6 +1760,9 @@ static struct notifier_block xen_hvm_cpu_notifier = {
17601760

17611761
static void __init xen_hvm_guest_init(void)
17621762
{
1763+
if (xen_pv_domain())
1764+
return;
1765+
17631766
init_hvm_pv_info();
17641767

17651768
xen_hvm_init_shared_info();
@@ -1775,6 +1778,7 @@ static void __init xen_hvm_guest_init(void)
17751778
xen_hvm_init_time_ops();
17761779
xen_hvm_init_mmu_ops();
17771780
}
1781+
#endif
17781782

17791783
static bool xen_nopv = false;
17801784
static __init int xen_parse_nopv(char *arg)
@@ -1784,14 +1788,11 @@ static __init int xen_parse_nopv(char *arg)
17841788
}
17851789
early_param("xen_nopv", xen_parse_nopv);
17861790

1787-
static uint32_t __init xen_hvm_platform(void)
1791+
static uint32_t __init xen_platform(void)
17881792
{
17891793
if (xen_nopv)
17901794
return 0;
17911795

1792-
if (xen_pv_domain())
1793-
return 0;
1794-
17951796
return xen_cpuid_base();
17961797
}
17971798

@@ -1809,11 +1810,19 @@ bool xen_hvm_need_lapic(void)
18091810
}
18101811
EXPORT_SYMBOL_GPL(xen_hvm_need_lapic);
18111812

1812-
const struct hypervisor_x86 x86_hyper_xen_hvm __refconst = {
1813-
.name = "Xen HVM",
1814-
.detect = xen_hvm_platform,
1813+
static void xen_set_cpu_features(struct cpuinfo_x86 *c)
1814+
{
1815+
if (xen_pv_domain())
1816+
clear_cpu_bug(c, X86_BUG_SYSRET_SS_ATTRS);
1817+
}
1818+
1819+
const struct hypervisor_x86 x86_hyper_xen = {
1820+
.name = "Xen",
1821+
.detect = xen_platform,
1822+
#ifdef CONFIG_XEN_PVHVM
18151823
.init_platform = xen_hvm_guest_init,
1824+
#endif
18161825
.x2apic_available = xen_x2apic_para_available,
1826+
.set_cpu_features = xen_set_cpu_features,
18171827
};
1818-
EXPORT_SYMBOL(x86_hyper_xen_hvm);
1819-
#endif
1828+
EXPORT_SYMBOL(x86_hyper_xen);

0 commit comments

Comments
 (0)