Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A332C433EF for ; Wed, 13 Oct 2021 00:55:51 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2AE0B610CC for ; Wed, 13 Oct 2021 00:55:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2AE0B610CC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.207828.363766 (Exim 4.92) (envelope-from ) id 1maSYa-0001ET-1j; Wed, 13 Oct 2021 00:55:44 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 207828.363766; Wed, 13 Oct 2021 00:55:44 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1maSYZ-0001EM-Uy; Wed, 13 Oct 2021 00:55:43 +0000 Received: by outflank-mailman (input) for mailman id 207828; Wed, 13 Oct 2021 00:55:43 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1maSYZ-0001EE-E1 for xen-devel@lists.xenproject.org; Wed, 13 Oct 2021 00:55:43 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 89b1dc24-b5e2-463f-ba1c-53df36477a53; Wed, 13 Oct 2021 00:55:42 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id F226261039; Wed, 13 Oct 2021 00:55:40 +0000 (UTC) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 89b1dc24-b5e2-463f-ba1c-53df36477a53 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634086542; bh=n1tTSWQDnZCGccnS6zBfI+YWb3yAxp76XfmkA1dlrOQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GpFJDcVEH43iEE/AqkAslB9mWUnB+TepZtBYDlqP/usuJrQHekz0MlJVGq/KpgcI3 0qNu0NN8ObkJsCIBWri/KevJM4Nvr9oYxg32KQP0U6Xy9h+C+0B4t22fDPa/Z+CH8R sdivdPIQuicTn//VNUGz/c8WDp+rPE66eWCSzbbfSHKAvU5n+MuukZbr/EShVOheWv OtpxIjiRDLnXqxrnp69j7P1GD4qanhdV6cF3p/5gwCnYZt+OKxQAN0LzSgFzLMbGvd HCvXuvxvdc83cN0hjlFJR/OlPTzPRiMPUdqKQSQJdZvVKb+O+aQgA843r1JVtvGtVS 9j6DrJ9G4yhfA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jan Beulich , Juergen Gross , Sasha Levin , boris.ostrovsky@oracle.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, xen-devel@lists.xenproject.org Subject: [PATCH AUTOSEL 5.10 05/11] xen/x86: prevent PVH type from getting clobbered Date: Tue, 12 Oct 2021 20:55:25 -0400 Message-Id: <20211013005532.700190-5-sashal@kernel.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211013005532.700190-1-sashal@kernel.org> References: <20211013005532.700190-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Jan Beulich [ Upstream commit 9172b5c4a778da1f855b2e3780b1afabb3cfd523 ] 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 Reviewed-by: Juergen Gross Link: https://lore.kernel.org/r/d301677b-6f22-5ae6-bd36-458e1f323d0b@suse.com Signed-off-by: Juergen Gross Signed-off-by: Sasha Levin --- arch/x86/xen/enlighten.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c index aa9f50fccc5d..0f68c6da7382 100644 --- a/arch/x86/xen/enlighten.c +++ b/arch/x86/xen/enlighten.c @@ -51,9 +51,6 @@ DEFINE_PER_CPU(struct vcpu_info, xen_vcpu_info); 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; @@ -68,9 +65,11 @@ __read_mostly int xen_have_vector_callback; 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); -- 2.33.0