Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp1783215lqg; Mon, 4 Mar 2024 03:52:16 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUoB1AuruLTq/NKl0ifohAwQE+/za/gohF+gTiU0z28h7N0O9f41uR7ATFCgLnj+Rn6CpL84p2or3yKxoQPHY5H8dB3UuOFZPJ74S0GCQ== X-Google-Smtp-Source: AGHT+IHcL2Tz+9T8wrTtr0jJipAcpg9KMDFHdpKEFIJwhQBexCbnkHy9WxoURtNSweXgmZqj+LsV X-Received: by 2002:a05:6a21:394c:b0:1a1:489a:6f87 with SMTP id ac12-20020a056a21394c00b001a1489a6f87mr3577099pzc.41.1709553136557; Mon, 04 Mar 2024 03:52:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709553136; cv=pass; d=google.com; s=arc-20160816; b=0h+w/+QY4yRmfpMG+e7GEpTwFhGylhxd4JCcLn+g6iFOFphKvy8I7dyw/qL/GoViDt PQx+ZlqiMS9u2soWLb66xgZMq0zuswqwjTpbfJYeYscXlf+VOLEDkDt2iEQMpH5bJtvJ wYX/FfiJp5XOiWCY6IMRXbwzUb8AOzdRHRId5f4logmFkOwoEiF9wQn2aZqdZNmMZVx+ 50p8zvbAPF2rpKxAux6EVmpsOGV7xJ2j5ZQkLSRB3rHrx8f+s16IndZkqEtN6N2Fl2Sk Ql+oh0KvaAke4t3zTbi5NGfoK3OZpa7yz4fIvH4oVElg/3kTGJkg86kdxc/B/iKKkvPV jxWA== 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=8u3ZKUE4itA3oS5HviRsE+wBXJKRiMcfZN7VwqDsuPY=; fh=qEq6e5+8B+Gwkg34JvILlRSpg/wRAAWG5imw1F/XrPg=; b=caSBggl9JekUEpvQoCFicVQoyHsTy1gSU+gFpBNqDb23CEPFC2g9/eiC1o1Hp2fcHp y3kXVn+4qHQ2hWm7LzMVuzDvhjJrHCxTFwTOnpxHmJBfR12ZG5Y3UHagbcKF9kidCojr qajSlEnKz2rXzzjOGsFAHvx+WlsjnUOEc9JBkJaisoNGATpm6tuIbXoGfL2ECaER840a Eim+Qo9S5QB0LdY/90hDbTjkWLgrkDmbJYzpseokcGBOPoDOIVSzqaSkFlTMGcRdcy6e p0iiVzM2lH40Q5fSY302e9aY9p+RpdDd3uzUs5ViCGL0FpLi/b44UwDeCvIsPjjMipBF 4RHg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ce3AyCoU; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-90528-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90528-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id h1-20020a17090acf0100b0029a68dea817si10243893pju.88.2024.03.04.03.52.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 03:52:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90528-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ce3AyCoU; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-90528-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90528-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 59160B24475 for ; Mon, 4 Mar 2024 11:48:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F02863D0A4; Mon, 4 Mar 2024 11:47:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ce3AyCoU" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 737F83BB53 for ; Mon, 4 Mar 2024 11:47:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709552853; cv=none; b=D8JxQ4RPkLZA0HUqkHyckwpTkc3J2lxrg4Tl/pgoZQgmjtE3mEyQzXO0ATARklK/WHCqIZoPzZLQ8uASXrm8ZaOPkQ8Ohw/6sS49af7pizH7havnZxOZG928MGIZbVDAVcwqpciN3MghcH74BLyLF1FLA7Zc+8siBXLsBe9r7FI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709552853; c=relaxed/simple; bh=/seq8s9s5SaI2WG5otaQLdzF6dmyrocZTuz5aj2Hfv4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=do/WqcoZJ96Jh1Zm6cbByRE55YTka/yRxOqtglH7eoSbyVjnWsS3GeH8eHKdFf2YlJCDGvggIMAP9up5O1bHuRGOfiMmtsWC42yP6TRFSDnMlDpwmcM/uR1ou74AdU2SVsR1zT6h5cxB0t/593aYMyJdIinJSeFEpkPwNg7GXok= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=ce3AyCoU; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709552849; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=8u3ZKUE4itA3oS5HviRsE+wBXJKRiMcfZN7VwqDsuPY=; b=ce3AyCoU0H9PKn6wW11EGAOxAQhn/m2kOmhGbPSROrDVCikSzTwsNzkS8TRJLy7w23FFyd /0daa7aicEzSRc4pfLlhpbsuv5gqiw3Fa4gUDxrt5Sw6bW3H2bRQ9us3bPMGxK5JdZ1QU7 NQnd0aS06Ur6PHOEuLoXegXfNV2l5AY= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-652-6WsMwRiiNMqoARjO8uQNXQ-1; Mon, 04 Mar 2024 06:47:24 -0500 X-MC-Unique: 6WsMwRiiNMqoARjO8uQNXQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E1F2B2812941; Mon, 4 Mar 2024 11:47:23 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.193.36]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1EC23C03489; Mon, 4 Mar 2024 11:47:23 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 19CCC18009DB; Mon, 4 Mar 2024 12:47:22 +0100 (CET) Date: Mon, 4 Mar 2024 12:47:22 +0100 From: Gerd Hoffmann To: Tao Su 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: X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 On Mon, Mar 04, 2024 at 04:59:32PM +0800, Tao Su wrote: > 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. Do you talk about EPT or NPT or both? > 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(). See patches 2+3 of this series. Maybe it is better to just not set kvm_caps.guest_phys_bits in generic kvm code and leave that completely to vmx / svm vendor modules. Or let the generic code handle the !tdp_enabled case and have the vendor modules override (considering EPT / NPT limitations) in case tdp is enabled. take care, Gerd