Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp1892645lqg; Mon, 4 Mar 2024 07:01:51 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVmfe85nO7yatj/DscQE9MegYrvmjeWJvVRzWH/b9EcqOhlrWq09xkWFndz0oQEWTI+/0V1DFf/JdPQCshJh2VkcPuA0dWkmhu2Fp0ZCQ== X-Google-Smtp-Source: AGHT+IHRAeoWDBYemKwcL/8xC51at16kpEBE5KdOIIEqM97kUYbUcJgzQcjCxOiLwOREE3NOuWoc X-Received: by 2002:a17:906:616:b0:a45:8ab6:5f3b with SMTP id s22-20020a170906061600b00a458ab65f3bmr381743ejb.6.1709564510902; Mon, 04 Mar 2024 07:01:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709564510; cv=pass; d=google.com; s=arc-20160816; b=yPky+olw3bzfeP1BZizPPUOllQxmWpEUONH0rmzSHaea1JEB2GF5cg37oNOTx/4HWi kwtNF3yvY1wHuxWMRDZazX45qWoydXeGkPuuabZ39uCq3eTuo7hFT2xtT7smgtxDGaOw RmwuutTyz3eryxHSd3mRllEjLxbfnoav62pG5A6Lk/zzgtoGRY7A60Dge60wFubNOUHo 12y0WGin/AP6N5DODl3EGXx4/+z79Fjn1Ekay178aklPoGzb15tCIb4qtl+K0u6GeC1V UI/6dJD/eqmF33uR+gGQb7cQvQcknLNr3SbE6BuxNluLiBrJiaCnmHQzmpAL/VvnooBR 0rtg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=l1ytQDMmgcwCeKgSWNOL8casDiMojXpwWbO7RiX8XOk=; fh=CCwMDcp0mdNlKoDKEeziwLNTREbq+XCGKGNO/lY0rw4=; b=ZjjTL/dOVYx8XAQsGPZbYe2dNTblwFGutAIGrGSanNIXRQgGt3MkbF2+GKIj0O7lkP CwsdoxKRdkrkPCXJ63h7StdOWkzU2JqHnyyc5PZFKLFnwBqyB5MVDdwffCSlvqCDZ36P EzRzWFAZk/ZmZTuF7mjxfEkGCZUzmGVFhRJzD7w0SRNaRiK6vReJg1xjDj/DlsLz6Nx9 Mz3raLXfbsAkJLensxPy9UsPkgqv8A0EhcYVP712X47NMIkXDUlPnZ6SDCrazjhX5KeR L64uueiY/0JaEnre0WuPHG0zab4DjxAiBeTHdn7074uAXbR1I0Q2AzhQpv3XH9AP7cgQ 9XMg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=avBUcNoz; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-90265-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90265-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 m15-20020a170906160f00b00a4439b5c147si4098690ejd.530.2024.03.04.07.01.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 07:01:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90265-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=avBUcNoz; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-90265-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90265-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 B127B1F22AAB for ; Mon, 4 Mar 2024 09:02:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A56FC1B7E8; Mon, 4 Mar 2024 09:02:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="avBUcNoz" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (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 4302A199C7; Mon, 4 Mar 2024 09:02:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709542949; cv=none; b=Lk88SQAEIz3J4Yjzh0wo/442oyQbObknRrW4s2PfX0Pwy9rPBKIMHfmAQIHHPdYHKcTjgDBL1zjL43hiQnTyqoHEf3vzjNSx0lhqKEzVtWnFieL6fFuWoxsUg+5FD56DLj3CKmxh1Z/BKKJtBP5tqk/Y2I3D6bTh1JT0wDJm3HE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709542949; c=relaxed/simple; bh=02GHhgzzwCODHSLjtoC02aB2+aErcjAhYrJviGy6hi4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=QLdYv5TEYEa2nmcP+6TzQCpjiylCIYZ/X5ONZIASRVBB2/yZpJ0D3Auwbxzoc7gNbQyAx/AwxuS/kRTWCvbqYpH2gh5VSI//JW3Xc97biUsvR6mkQulWBS/0UrBf3ZBEViQB7SZKmuviQa4bwjVF0RGUHN2T+KRMmZrukx3F/W4= 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=avBUcNoz; arc=none smtp.client-ip=192.198.163.18 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=1709542948; x=1741078948; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=02GHhgzzwCODHSLjtoC02aB2+aErcjAhYrJviGy6hi4=; b=avBUcNozTsVwTioIPnDJC8KCTwMgelcRhZ9h0GqT/etEi1BaiqKcYoGL TF2B++EEIhaJPV8rdL0/qX/VLxm+yNxLpbOH3AiMlIEpbUAmBholuwU5b i5K+FtVFmA7Lt9plzpVHVuW/eMJiV+4qQkezsOVXR0ZAEmAoej0KBA+jP HHbCyHMmOjKdt8zwE4mgyFv4ATF+oT979uXJ9XWWEWEAtqnzPVvUCgpua Hb7C0AWMWJlqErMSB5fwDPLwVNJpvDwUP70iUK7lFQzGT4Xran2Cr3mhQ 725ibdZu4G/0u1ZQYwtlWD6B90y7bSVS8cC2MWUf/WUUTGdP/v4/42cP0 A==; X-IronPort-AV: E=McAfee;i="6600,9927,11002"; a="3887588" X-IronPort-AV: E=Sophos;i="6.06,203,1705392000"; d="scan'208";a="3887588" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Mar 2024 01:02:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,203,1705392000"; d="scan'208";a="8813391" Received: from linux.bj.intel.com ([10.238.157.71]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Mar 2024 01:02:24 -0800 Date: Mon, 4 Mar 2024 16:59:32 +0800 From: Tao Su To: Gerd Hoffmann Cc: kvm@vger.kernel.org, Sean Christopherson , Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , "H. Peter Anvin" , "open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)" Subject: Re: [PATCH 1/3] kvm: wire up KVM_CAP_VM_GPA_BITS for x86 Message-ID: References: <20240301101410.356007-1-kraxel@redhat.com> <20240301101410.356007-2-kraxel@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Mon, Mar 04, 2024 at 09:43:53AM +0100, Gerd Hoffmann wrote: > > > + kvm_caps.guest_phys_bits = boot_cpu_data.x86_phys_bits; > > > > When KeyID_bits is non-zero, MAXPHYADDR != boot_cpu_data.x86_phys_bits > > here, you can check in detect_tme(). > > from detect_tme(): > > /* > * KeyID bits effectively lower the number of physical address > * bits. Update cpuinfo_x86::x86_phys_bits accordingly. > */ > c->x86_phys_bits -= keyid_bits; > > This looks like x86_phys_bits gets adjusted if needed. If TDP is enabled and supports 5-level, we want kvm_caps.guest_phys_bits=52, but c->x86_phys_bits!=52 here. Maybe we need to set kvm_caps.guest_phys_bits according to whether TDP is enabled or not, like leaf 0x80000008 in __do_cpuid_func(). Thanks, Tao