Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp6931912imm; Tue, 24 Jul 2018 05:47:28 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf38hToCmREIcG/riS24h5piEzvYUinGWqvT+r8cRm6dRpU2Mz4t1RGeHpH5Klg6Z60udXS X-Received: by 2002:a62:843:: with SMTP id c64-v6mr17703122pfd.14.1532436448426; Tue, 24 Jul 2018 05:47:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532436448; cv=none; d=google.com; s=arc-20160816; b=EriCI2YVHfhD1vYEETPgVywGBwen3k2joBjfNV3vq1fFJ64d99idX6EIE2iGIiSSBQ PiUifYKMb4G2jnKCdXWOLPecsoxtwipD1c3M4PvttjkWUv3uw7asNpCOj4XcqgOvCAWa uTorkWKS5o8pkYLjhvuboEuf8ZsF49z9GcM9rTnm3fTJy0tH73W7CEtwB9lsxsb0rOA3 /5PDUF3CX5ozioXPhHjx31w0NSUp04P6cVRWHTKNNx1j7nyslys8wufwR28tKghlwIz0 Wn5MLlQ97WjH9+HuoW6dAg1K/mj13VLhN6EQlJ9XJ5lKjdR/jTM+qrp85wUyy9SiC1Tq Jmdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=qqU+ZfIW7C7SJ3HuHsGutidh4lERfAloPwVtD2HpMQw=; b=FTFNRKFPhLkW/scFrqaPWlkA6O/hsx3e8TpzHJsbK/3Xz+WdRIH5Lq57K3S+M4Qx+f LB7P2VPpDv9ALR1y0XeOglFsW99piUmRq1R8tCHaGCdMUzHmcx4bx2NuBkgWYa2EpkRU mMVobdbTlQ4pxscNDwhHfnwqsyi786DeppBhy0Vxark/JTbmfvREhibexmUWa+UHI5TS 3QXrMn72hqk46pJj8oY79lRnLKHb86bygtuhp0V2pSl7riBwcLz5ZP5U816N8GINSuSn bzLe3Ak8MLT1/Gz83wDLPqTly8GkrybSFQCHE5hA6wU94F+63YMv/r8VGud6jqpoUq9I 4Eyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@runbox.com header.s=rbselector1 header.b=D3lEORAP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 184-v6si11092622pfe.249.2018.07.24.05.47.13; Tue, 24 Jul 2018 05:47:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@runbox.com header.s=rbselector1 header.b=D3lEORAP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388384AbeGXNwh (ORCPT + 99 others); Tue, 24 Jul 2018 09:52:37 -0400 Received: from aibo.runbox.com ([91.220.196.211]:37148 "EHLO aibo.runbox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388321AbeGXNwg (ORCPT ); Tue, 24 Jul 2018 09:52:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=rbselector1; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=qqU+ZfIW7C7SJ3HuHsGutidh4lERfAloPwVtD2HpMQw=; b=D3lEORAPZMY16qmn2IPI20fpU YgSgDYzr+dOWr1Po1o/Gqphfh1630XdgCbN+hWbMZFQbeFF9YSXTkzXB0LG9x5mSn84lw8PbcTXmp zL831npzpgANkCeM6hbti8EokpudT7ARczmkqMJUYJ3HsTEKYd2fW9q9QpLeVXkyp1njioeGE/V8W chVhAnebNECXH9xIhQ44zMRfC3NGNPtLq6/ZXJWBO+RrqQMmk7Wjt8JGdFEUm94nuOO5vriaVbOOi dmNuF7lmcXnzDLDmRJ9UkLInLknZGyZTFKFVhBrYUxP1oL/uVVP34KsFfmhfemn+k2ASftusO5Neq n8j069H9A==; Received: from [10.9.9.211] (helo=mailfront11.runbox.com) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1fhwhk-0008KQ-Hf; Tue, 24 Jul 2018 14:46:16 +0200 Received: by mailfront11.runbox.com with esmtpsa (uid:769847 ) (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.82) id 1fhwhi-0006Yj-N1; Tue, 24 Jul 2018 14:46:15 +0200 From: "M. Vefa Bicakci" To: linux-kernel@vger.kernel.org Cc: "M . Vefa Bicakci" , "Kirill A. Shutemov" , Andy Lutomirski , Ingo Molnar , "H. Peter Anvin" , Thomas Gleixner , Boris Ostrovsky , Juergen Gross , xen-devel@lists.xenproject.org, x86@kernel.org, stable@vger.kernel.org Subject: [PATCH v2] xen/pv: Call get_cpu_address_sizes to set x86_virt/phys_bits Date: Tue, 24 Jul 2018 08:45:47 -0400 Message-Id: <20180724124547.32562-1-m.v.b@runbox.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180721194909.23903-2-m.v.b@runbox.com> References: <20180721194909.23903-2-m.v.b@runbox.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit d94a155c59c9 ("x86/cpu: Prevent cpuinfo_x86::x86_phys_bits adjustment corruption") has moved the query and calculation of the x86_virt_bits and x86_phys_bits fields of the cpuinfo_x86 struct from the get_cpu_cap function to a new function named get_cpu_address_sizes. One of the call sites related to Xen PV VMs was unfortunately missed in the aforementioned commit. This prevents successful boot-up of kernel versions 4.17 and up in Xen PV VMs if CONFIG_DEBUG_VIRTUAL is enabled, due to the following code path: enlighten_pv.c::xen_start_kernel mmu_pv.c::xen_reserve_special_pages page.h::__pa physaddr.c::__phys_addr physaddr.h::phys_addr_valid phys_addr_valid uses boot_cpu_data.x86_phys_bits to validate physical addresses. boot_cpu_data.x86_phys_bits is no longer populated before the call to xen_reserve_special_pages due to the aforementioned commit though, so the validation performed by phys_addr_valid fails, which causes __phys_addr to trigger a BUG, preventing boot-up. Signed-off-by: M. Vefa Bicakci Cc: "Kirill A. Shutemov" Cc: Andy Lutomirski Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: Thomas Gleixner Cc: Boris Ostrovsky Cc: Juergen Gross Cc: xen-devel@lists.xenproject.org Cc: x86@kernel.org Cc: stable@vger.kernel.org # for v4.17 and up Fixes: d94a155c59c9 ("x86/cpu: Prevent cpuinfo_x86::x86_phys_bits adjustment corruption") --- Changes since v1: - Move the call to get_cpu_address_sizes below the call to x86_configure_nx. - Amend the commit message to describe why PV VMs do not boot up successfully when CONFIG_DEBUG_VIRTUAL is enabled. --- arch/x86/kernel/cpu/common.c | 2 +- arch/x86/kernel/cpu/cpu.h | 1 + arch/x86/xen/enlighten_pv.c | 3 +++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index f73fa6f6d85e..dd282482de09 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -911,7 +911,7 @@ void get_cpu_cap(struct cpuinfo_x86 *c) apply_forced_caps(c); } -static void get_cpu_address_sizes(struct cpuinfo_x86 *c) +void get_cpu_address_sizes(struct cpuinfo_x86 *c) { u32 eax, ebx, ecx, edx; diff --git a/arch/x86/kernel/cpu/cpu.h b/arch/x86/kernel/cpu/cpu.h index 38216f678fc3..12a5f0cec0b2 100644 --- a/arch/x86/kernel/cpu/cpu.h +++ b/arch/x86/kernel/cpu/cpu.h @@ -46,6 +46,7 @@ extern const struct cpu_dev *const __x86_cpu_dev_start[], *const __x86_cpu_dev_end[]; extern void get_cpu_cap(struct cpuinfo_x86 *c); +extern void get_cpu_address_sizes(struct cpuinfo_x86 *c); extern void cpu_detect_cache_sizes(struct cpuinfo_x86 *c); extern void init_scattered_cpuid_features(struct cpuinfo_x86 *c); extern u32 get_scattered_cpuid_leaf(unsigned int level, diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c index 105a57d73701..ee3b00c7acda 100644 --- a/arch/x86/xen/enlighten_pv.c +++ b/arch/x86/xen/enlighten_pv.c @@ -1256,6 +1256,9 @@ asmlinkage __visible void __init xen_start_kernel(void) get_cpu_cap(&boot_cpu_data); x86_configure_nx(); + /* Determine virtual and physical address sizes */ + get_cpu_address_sizes(&boot_cpu_data); + /* Let's presume PV guests always boot on vCPU with id 0. */ per_cpu(xen_vcpu_id, 0) = 0; -- 2.17.1