[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2 1/9] xen/x86: prevent PVH type from getting clobbered


  • To: Juergen Gross <jgross@xxxxxxxx>, Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 30 Sep 2021 14:16:15 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=/NqxYuSK5poj82wwlDFvGZG2lRpG9jB2q+2T7aAqVlo=; b=FtPtM23utb3A1B3gG1FuTQdA4iP0x4YwzZyve2vTyJM+HS41jAA0UifkrFtFtFmzo7WhU1wZEMNZD7rL9mhCQfwTOwleSMURjUzzu7cfjiqK758XhEImBet6fDahTXmGWjch1fm6aoBExGjzzR3rhrXLiKV6PMZXbkn+0sUW/U3zB2TzODepRTpOPOcE5eyd6X+8Ndn7B+R6dSEjY4FodgqIpCHwbIjzifgKMp3RCUO54AS6nm/8b7RcvgkmuIfIlAN5qwx8M3inOzuiqh+NAhORg62WzrrCCSXA77s9fHi461TsiZc3+p9rRjZhJ6Q8oufPYCXrqC3B9IBDUO7N3w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ifElNPL8ivCsdVMzAXc5ocymM357vWVNWj+2KoAVTKem4Z8uo3uOk3lsqXh/PFnGfrzAKvzXjYgKhzUTydzPihZi02FmMjcqp2jZ+8fEzfaPqJ9O4CQpaZNAzMjsYEFzkKXnnxWR24xNx6uZLP4Mm1tjVgJY1bBkeaT2vOedcaHAT5Eej3UDk+Yzh37ZDKjbFGo+jxHvrqUKR2TEKK3UzPMrk8QTbnHtRdcYEpxx76Fj4WoLJAfF6RYFRFbIMxKcOs/Yk7lb4WWBjpySkDJ1GxIa8GvaPx95nH4ZRDN+8c/+45scCf7PUjZgkS8sNYfr5MrLzVcUrZRfMzoSlwxv8w==
  • Authentication-results: lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; dmarc=none action=none header.from=suse.com;
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, lkml <linux-kernel@xxxxxxxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 30 Sep 2021 12:16:27 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Like xen_start_flags, xen_domain_type gets set before .bss gets cleared.
Hence this variable also needs to be prevented from getting put in .bss,
which is possible because XEN_NATIVE is an enumerator evaluating to
zero. Any use prior to init_hvm_pv_info() setting the variable again
would lead to wrong decisions; one such case is xenboot_console_setup()
when called as a result of "earlyprintk=xen".

Use __ro_after_init as more applicable than either __section(".data") or
__read_mostly.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Reviewed-by: Juergen Gross <jgross@xxxxxxxx>

--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -52,9 +52,6 @@ DEFINE_PER_CPU(struct vcpu_info, xen_vcp
 DEFINE_PER_CPU(uint32_t, xen_vcpu_id);
 EXPORT_PER_CPU_SYMBOL(xen_vcpu_id);
 
-enum xen_domain_type xen_domain_type = XEN_NATIVE;
-EXPORT_SYMBOL_GPL(xen_domain_type);
-
 unsigned long *machine_to_phys_mapping = (void *)MACH2PHYS_VIRT_START;
 EXPORT_SYMBOL(machine_to_phys_mapping);
 unsigned long  machine_to_phys_nr;
@@ -69,9 +66,11 @@ __read_mostly int xen_have_vector_callba
 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
 
 /*
- * NB: needs to live in .data because it's used by xen_prepare_pvh which runs
- * before clearing the bss.
+ * NB: These need to live in .data or alike because they're used by
+ * xen_prepare_pvh() which runs before clearing the bss.
  */
+enum xen_domain_type __ro_after_init xen_domain_type = XEN_NATIVE;
+EXPORT_SYMBOL_GPL(xen_domain_type);
 uint32_t xen_start_flags __section(".data") = 0;
 EXPORT_SYMBOL(xen_start_flags);
 




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.