From patchwork Wed Jan 29 20:20:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11356781 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EE45714E3 for ; Wed, 29 Jan 2020 20:21:59 +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 CAC4720702 for ; Wed, 29 Jan 2020 20:21:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UGdQvDH0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CAC4720702 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iwtpc-0006Yk-HM; Wed, 29 Jan 2020 20:21:00 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iwtpa-0006YD-VO for xen-devel@lists.xenproject.org; Wed, 29 Jan 2020 20:20:58 +0000 X-Inumbo-ID: d290ead6-42d4-11ea-8396-bc764e2007e4 Received: from mail-wr1-x441.google.com (unknown [2a00:1450:4864:20::441]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id d290ead6-42d4-11ea-8396-bc764e2007e4; Wed, 29 Jan 2020 20:20:42 +0000 (UTC) Received: by mail-wr1-x441.google.com with SMTP id z7so979852wrl.13 for ; Wed, 29 Jan 2020 12:20:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gCFi7p2cW832Oj/4SVP/DOq5zNQ19Ssf0CeEfHPDZW8=; b=UGdQvDH0kvj8CPfpAVPM2GPWDjpOeQV+LlipPwIQQajytXitYVU8e6auoEOexZ51Co aHmLhglQy5QVyCWl3gat1MnhrmwvsMCmRwcO7jBKjHSAheIsJBmJ9/5zVm0JlqhJc0z5 vpSyvSxrZuVPWRgMK+Z2gj1KvOBQKr1LxVtV5G9bOrU4U0otxJ3hgayBaGwMjSoF2KWs SsyBWWoPbzMmHkGZ6o3VMEZD8Wq0JMjE5Sgf/z6+E4p6eL7frHtH3C0rBs5T2TJEoCLp zfjM2/o4D1rP3tSFDvHoilybJwCdv5SHxK07xbM2WNtkKkfE0VxBaJlK4kS66auL2K2s BrfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=gCFi7p2cW832Oj/4SVP/DOq5zNQ19Ssf0CeEfHPDZW8=; b=nDENmJdvw+LLqx/pHB40SCWfmLzs15p05uaTKmFMPkLsEDgGfL0H9KiScXDDGgr5/7 zlI+OC3Ugdl1GwT18ZPIPqjlepfKfjlosbkJ/2mn0qkcG/givdCu5Y7KvlzY8jyqwIJO Bb51LNRGCVU5sOVnESz76Lxnw+QhEfx4xiFfwSLVxq3V6l8TMngFCDQf7xLqElphLHOW 43WREbyZjwc3kPUnRhbm1sWMiCiC0P5OzwN1nTyEedPk9yM/ZehYOp4HNjPOIdSGH50H XF7forzZNwhDa1OzGt3xCyKC9s7IHyh+e5rkwAzTlFv+NtLbID0wvBl/Jn42DhfdiIdG jXug== X-Gm-Message-State: APjAAAWNzSCFl/lDEKxM8TFIv8v+YEzspzVJ706nsfqYxNUdxroxoK1z sDUZYb4rtlEh+3GthfrEKg8hjPD0+BY= X-Google-Smtp-Source: APXvYqzt8Mlxu7sk+n0p3Z+yz/gJsQAhDgj0fvBlFArkkEcdGPWBrI5u9ORxFQ9ccso3qsYIEDpQhQ== X-Received: by 2002:adf:f64b:: with SMTP id x11mr560145wrp.355.1580329241596; Wed, 29 Jan 2020 12:20:41 -0800 (PST) Received: from localhost.localdomain (41.142.6.51.dyn.plus.net. [51.6.142.41]) by smtp.gmail.com with ESMTPSA id a22sm3564115wmd.20.2020.01.29.12.20.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jan 2020 12:20:41 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Wed, 29 Jan 2020 20:20:26 +0000 Message-Id: <20200129202034.15052-5-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200129202034.15052-1-liuwe@microsoft.com> References: <20200129202034.15052-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v5 04/12] x86: make paddr_bits available earlier X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Wei Liu , Wei Liu , Andrew Cooper , Paul Durrant , Michael Kelley , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Move early_cpu_init before init_e820, such that paddr_bits can be used by e820 code. This will reduce code repetition and prepare for further adjustment when L0 hypervisor comes into play. Signed-off-by: Wei Liu Reviewed-by: Roger Pau Monné Acked-by: Jan Beulich --- xen/arch/x86/e820.c | 14 ++++---------- xen/arch/x86/setup.c | 5 +++-- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/xen/arch/x86/e820.c b/xen/arch/x86/e820.c index 082f9928a1..3892c9cfb7 100644 --- a/xen/arch/x86/e820.c +++ b/xen/arch/x86/e820.c @@ -420,7 +420,7 @@ static uint64_t __init mtrr_top_of_ram(void) { uint32_t eax, ebx, ecx, edx; uint64_t mtrr_cap, mtrr_def, addr_mask, base, mask, top; - unsigned int i, phys_bits = 36; + unsigned int i; /* By default we check only Intel systems. */ if ( e820_mtrr_clip == -1 ) @@ -445,15 +445,9 @@ static uint64_t __init mtrr_top_of_ram(void) if ( !test_bit(X86_FEATURE_MTRR & 31, &edx) ) return 0; - /* Find the physical address size for this CPU. */ - eax = cpuid_eax(0x80000000); - if ( (eax >> 16) == 0x8000 && eax >= 0x80000008 ) - { - phys_bits = (uint8_t)cpuid_eax(0x80000008); - if ( phys_bits > PADDR_BITS ) - phys_bits = PADDR_BITS; - } - addr_mask = ((1ull << phys_bits) - 1) & ~((1ull << 12) - 1); + /* paddr_bits must have been set at this point */ + ASSERT(paddr_bits); + addr_mask = ((1ull << paddr_bits) - 1) & PAGE_MASK; rdmsrl(MSR_MTRRcap, mtrr_cap); rdmsrl(MSR_MTRRdefType, mtrr_def); diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index d858883404..89fe49149f 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -954,6 +954,9 @@ void __init noreturn __start_xen(unsigned long mbi_p) else panic("Bootloader provided no memory information\n"); + /* This must come before e820 code becuause it sets paddr_bits. */ + early_cpu_init(); + /* Sanitise the raw E820 map to produce a final clean version. */ max_page = raw_max_page = init_e820(memmap_type, &e820_raw); @@ -1532,8 +1535,6 @@ void __init noreturn __start_xen(unsigned long mbi_p) softirq_init(); tasklet_subsys_init(); - early_cpu_init(); - paging_init(); tboot_probe();