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

[PATCH 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: Tue, 7 Sep 2021 12:07:28 +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=VGr5KaKrPB+ECiV3mI7JH4ZubnK2Jw/FcM9+PIVCR9A=; b=fkAvpHWiBc9h1bqrhaK5I963N+DD6VmjRJlVSZiYOy6sj/8wPjtRuPllCh0S1I58WDZ+0EamhtXYH4+lgXm6+X8D6Vwk5l2f+bvvJC1eGKvv0hWEvotTrer/ve6ZdCEUkJ4bT2GKn9U47on+ZDsb4zzdSW1dC877irj87ABIrhBOJdGkEfDC2Y6aE9fnFKbDodlk+6qeAPOoB6EiM3IJlCVnwxLP80+C61HtcTkPokC7kkprSxBQ75aR+phEqm/5nIEX3WnyF2Z2cZu1znJVmCmYQx5+VbzY+tKrSrPPmV451fQaCEdRwFQkGnqvz3T+6HFszpEShKMzIeBlGBxtnA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E7w8LcHGWrntrIYAkeiSiGk55H9JXGxZWhzHMFppR/cRrQdSZv+/igXsqnHTmP0Db4BWfQ3SykDnf9DCNSlASWI78IYAYrGBxrUsI92qSlLC7WOiPER6Ot6kzhw90XiSweJmrg/Q5/zTEg9NkLFa6ZIskZhmAB/qwoykyhZvyZSNOxmDLzfvGmrTTZejD5lDZ0BpYAh/a1F6AEt6A8zJq/4c7vitO2JvcAZAc3Gei1wZCMmRbdnT6DHFc5xuEKUR1bPBy4EK8xK9Hh7P9qhyl7aFHqdZhmoj/YOkM2xOiHThcXDRxuwrPLlrxD5OwKJ1tzyQWIVkWznrpiCei+EsAQ==
  • 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>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Tue, 07 Sep 2021 10:07:40 +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>

--- 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®.