Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp525626rdb; Thu, 22 Feb 2024 10:47:05 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU0B6+xU8PAQmAmbajGdCskvDIA3OcDkGC+e3nklIayFeivFE4Xzh3OgJvYUEJYgpVZwijuyJ5kMdobSpRfOPmEoozqNMqpTY2O45fIjg== X-Google-Smtp-Source: AGHT+IGfPN0UDSDopT6eK+paxaGX+bBhHdcnLvdPEg71Pl17DBA3ojX0wz9hRq1dxkrVELPM9Yp7 X-Received: by 2002:a17:906:27ce:b0:a3f:6e81:1801 with SMTP id k14-20020a17090627ce00b00a3f6e811801mr2461401ejc.6.1708627625228; Thu, 22 Feb 2024 10:47:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708627625; cv=pass; d=google.com; s=arc-20160816; b=nZBf29oA1rATIYLI8RiSrIootca0WGhQJqyesZ3fIT5znea5nPJZVDq9cL8YNd1/1V BwkncnfU46i1A6/w9NMr27jwI/VJYPDqRAlS2HCqKa4TjQIUP7bfl42QK1goR6ONIX8P bpBv2Wka97R/Q6Cc0UHM8F49sVAqz3VTAO+QLEWfaLegjKyFQ6spKTWzr5PGmvd8twgp VyEy7z/HPVANXLljHcBVmVvbX7cf1OzatEmFAh9B9mwekhLR89jEqtGTf3koAc+cUYe4 KopOKp5yodGCB1Y3uEapnROocBpNjkky6La1RpVtln0orUMOxpAB1KfdGjmpHZA2JKKP xa/A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:message-id :in-reply-to:references:date:from:cc:to:subject:dkim-signature; bh=dk3KxauaZ19ldFt6g2T4xXr4Zf7AGHl7NgTUS/J/CRs=; fh=HUgOPOMLUPcroonsK10/uEWpbBCP57e0QFUoVmMwghQ=; b=DLnUsevmI0HQEV/4EBqP5wO8q2jnlRXt/2eoXk/23SO2keORIVpBI7YgDwK11kr/L6 WjOLtYvDno9/430OWxA/ly+gvWhEXtpvAY1YfgVgakXDDII2pFHY3UDhEaIPyWVwnPGH Jp3RCOcRXGC/5Fih7DFdsGmUzK+ThbkPIpUoH0/psyjranPkqAwIQehXVe9oXBCxhlEh PAUqbsTl2Y2KubOhiswbY8bI+XBxcYANffV6eqzU5ZcmKoXCxaReSiDwnaq50nJIoY/+ J0ykeSbTTHre07VhjAZ2R8J/vY7ie0nNME4l+icUcKGePrQl8XP6sEl72rlJH6yVtuF4 1sYg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=I9hzTZxp; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-77171-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77171-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id i2-20020a1709061cc200b00a3e4d5ca656si4419129ejh.60.2024.02.22.10.47.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 10:47:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-77171-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=I9hzTZxp; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-77171-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77171-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id AEC431F290EB for ; Thu, 22 Feb 2024 18:46:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8AED514036E; Thu, 22 Feb 2024 18:39:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="I9hzTZxp" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0AC2713BADF for ; Thu, 22 Feb 2024 18:39:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708627191; cv=none; b=PT6r0ncInl0uEZ7vPq5Ga4ToTSjJTGAlhV2kpiCtUqyJzfiW+62dweBwhGaXoE+3t3AOddaNjdjT67TFPb0Gf+CtSS0Z2eHKntl5wpBnNOq2OJW6kFp4TPgEqXVfA7Us94KPakrnZhoIIA28JIVozwwvDFQ1eekqbH++FIQ/TT4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708627191; c=relaxed/simple; bh=buneXK45S59L265wMYbZIbp62iDWv2uaPtRPDjg659o=; h=Subject:To:Cc:From:Date:References:In-Reply-To:Message-Id; b=R6lOHY18iExwQP8KQ6LwygOkH4zuUR4TN69+7WE4PmP8mzsnInPYWYqLogFlQh9zaLyzi9sxUEKY35ews4XbuEhrpakv4Jm5GKJlBcDcVuM6JsRSSHUV9aft/7KDkDn+wS6MBx4hsizryCcduUiNglCgiTkDmmhphazDiFSxW7Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=I9hzTZxp; arc=none smtp.client-ip=198.175.65.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708627191; x=1740163191; h=subject:to:cc:from:date:references:in-reply-to: message-id; bh=buneXK45S59L265wMYbZIbp62iDWv2uaPtRPDjg659o=; b=I9hzTZxpfBReaGeCDchDKhaAiEYy/6+MJj4eyVwR918nKwR4z+gycbm6 QhxljElDmPCdq4YeMmuk8Y5v3XN2aR8nX+5y+ekKlba73wlriQRPbqW/l flY47BQy2GJKFR1WVVugmksNLtXzHhpVNuy4ZojwT7I88ShEvmRy0Pplk OzWmipRHUEMFOerhUwEtwnBry7gZii2byKfqzxIX+KEBzVZGbl3KLyI2v lMETii/FwjG4bstfRa6YHRohs6aCgJTJYPfYBRIMqxhohbel0g4K60R1u Vytsyjgwa4t3tAhuDCFlszw8G9Rzgn6a7oBso2ANUjyAm7uDEjkKN0a99 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10992"; a="3031816" X-IronPort-AV: E=Sophos;i="6.06,179,1705392000"; d="scan'208";a="3031816" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Feb 2024 10:39:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,179,1705392000"; d="scan'208";a="5975536" Received: from davehans-spike.ostc.intel.com (HELO localhost.localdomain) ([10.165.164.11]) by orviesa008.jf.intel.com with ESMTP; 22 Feb 2024 10:39:50 -0800 Subject: [RFC][PATCH 17/34] x86/cpu: Move virtual address limit out of cpuinfo_x86 To: linux-kernel@vger.kernel.org Cc: kirill.shutemov@linux.intel.com,pbonzini@redhat.com,tglx@linutronix.de,x86@kernel.org,bp@alien8.de,Dave Hansen From: Dave Hansen Date: Thu, 22 Feb 2024 10:39:49 -0800 References: <20240222183926.517AFCD2@davehans-spike.ostc.intel.com> In-Reply-To: <20240222183926.517AFCD2@davehans-spike.ostc.intel.com> Message-Id: <20240222183949.9E1C5A1E@davehans-spike.ostc.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: From: Dave Hansen There are no longer any direct references to cpuinfo_x86->x86_virt_bits. The only remaining references are to 'boot_cpu_data' via the x86_virt_bits() helper. This means the farce that x86_virt_bits is per-cpu data can end. Remove it from cpuinfo_x86 and add it to 'x86_config'. Signed-off-by: Dave Hansen --- b/arch/x86/include/asm/processor.h | 6 +++--- b/arch/x86/kernel/cpu/common.c | 8 +++----- b/arch/x86/mm/maccess.c | 9 +++++---- 3 files changed, 11 insertions(+), 12 deletions(-) diff -puN arch/x86/include/asm/processor.h~no-cpu-data-virt_bits arch/x86/include/asm/processor.h --- a/arch/x86/include/asm/processor.h~no-cpu-data-virt_bits 2024-02-22 10:08:56.748778725 -0800 +++ b/arch/x86/include/asm/processor.h 2024-02-22 10:08:56.752778882 -0800 @@ -117,7 +117,6 @@ struct cpuinfo_x86 { #ifdef CONFIG_X86_VMX_FEATURE_NAMES __u32 vmx_capability[NVMXINTS]; #endif - __u8 x86_virt_bits; /* CPUID returned core id bits: */ __u8 x86_coreid_bits; /* Max extended CPUID function supported: */ @@ -182,8 +181,9 @@ struct x86_addr_config { * modified after that. */ struct x86_sys_config { - /* Physical address bits supported by all processors */ + /* Address bits supported by all processors */ u8 phys_bits; + u8 virt_bits; }; extern struct x86_sys_config x86_config; @@ -800,7 +800,7 @@ static inline u8 x86_phys_bits(void) static inline u8 x86_virt_bits(void) { - return boot_cpu_data.x86_virt_bits; + return x86_config.virt_bits; } static inline u8 x86_clflush_size(void) diff -puN arch/x86/kernel/cpu/common.c~no-cpu-data-virt_bits arch/x86/kernel/cpu/common.c --- a/arch/x86/kernel/cpu/common.c~no-cpu-data-virt_bits 2024-02-22 10:08:56.748778725 -0800 +++ b/arch/x86/kernel/cpu/common.c 2024-02-22 10:08:56.752778882 -0800 @@ -1106,17 +1106,17 @@ void get_cpu_address_sizes(struct cpuinf if (vp_bits_from_cpuid) { cpuid(0x80000008, &eax, &ebx, &ecx, &edx); - c->x86_virt_bits = (eax >> 8) & 0xff; + x86_config.virt_bits = (eax >> 8) & 0xff; x86_config.phys_bits = eax & 0xff; } else { if (IS_ENABLED(CONFIG_X86_64)) { x86_config.phys_bits = 36; + x86_config.virt_bits = 48; c->x86_clflush_size = 64; - c->x86_virt_bits = 48; } else { x86_config.phys_bits = 32; + x86_config.virt_bits = 32; c->x86_clflush_size = 32; - c->x86_virt_bits = 32; if (cpu_has(c, X86_FEATURE_PAE) || cpu_has(c, X86_FEATURE_PSE36)) @@ -1827,11 +1827,9 @@ static void identify_cpu(struct cpuinfo_ c->topo.l2c_id = BAD_APICID; #ifdef CONFIG_X86_64 c->x86_clflush_size = 64; - c->x86_virt_bits = 48; #else c->cpuid_level = -1; /* CPUID not detected */ c->x86_clflush_size = 32; - c->x86_virt_bits = 32; #endif c->x86_cache_alignment = x86_clflush_size(); memset(&c->x86_capability, 0, sizeof(c->x86_capability)); diff -puN arch/x86/mm/maccess.c~no-cpu-data-virt_bits arch/x86/mm/maccess.c --- a/arch/x86/mm/maccess.c~no-cpu-data-virt_bits 2024-02-22 10:08:56.752778882 -0800 +++ b/arch/x86/mm/maccess.c 2024-02-22 10:08:56.752778882 -0800 @@ -16,11 +16,12 @@ bool copy_from_kernel_nofault_allowed(co return false; /* - * Allow everything during early boot before 'x86_virt_bits' - * is initialized. Needed for instruction decoding in early - * exception handlers. + * Allow everything during early boot before 'virt_bits' is + * initialized. Needed for instruction decoding in early + * exception handlers. Avoid the helper because it may do + * error checking for being uninitiazed. */ - if (!x86_virt_bits()) + if (!x86_config.virt_bits) return true; return __is_canonical_address(vaddr, x86_virt_bits()); _