Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1272868rbb; Mon, 26 Feb 2024 04:33:41 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVIsmvJbSoojNOXH8utSsU3EyKw3SqAg+QqtGmkujPOH6vdVuP6TKncpUbmYQdxLCqvzg1StWUE5+cVznlav/fxT2loH1XEZhjke6Kj1w== X-Google-Smtp-Source: AGHT+IHoaPBMum2ifHzJHdW4eQHjSiH6LHspFvt3keyCfs+wfKUJst6SxbzyS5Jx7gXUSmuvtBGr X-Received: by 2002:a05:6358:6405:b0:17b:89bd:e6cd with SMTP id f5-20020a056358640500b0017b89bde6cdmr7427281rwh.8.1708950820960; Mon, 26 Feb 2024 04:33:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708950820; cv=pass; d=google.com; s=arc-20160816; b=hQy4+jyiwYVsPAeNeHg8QyI65l7kg4CuPRf+lFO5GEu6plpqcI+cu8BDRtClE5oj7h ThrrXgQ21yGUgbdy0F8UnQgm68Tqtqo727D88jQhF4dsfzmjVCW0O/haLV6g5LmeBLhs kiydc9OFOvV+i70vtBTgPwverP0qki2O0CjwabyxRj/WvEWM1DVb9v4V+ZPp0uODtjhK uPBR7sc5ZEsjSQfB3o/nKwv0UgN8KnbCH+CCBCr6sT9XyfdmjUiFhm7wrgGhjgh80Bpa 6uyi2z7Ta2gWE+RmEgijMgKeM3dkvZceRC5Kd9+v5O6xRnw2qH6cK3n1K1fqKQv190w9 FgCw== 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=dwo7taSc2Vgy3Llhb5YEXHBD0lYMoBHvIkNerpHzXZY=; fh=dOi0//N54fxxzaBDQHTTo4V0kcKe6Zb64NjvPx6CWxU=; b=Lyir5D1xPAgNMCy0fnFLgHGrQb/SYgP3FE++PM1hoidYta0Av+nhltLwqVQCaZVujB Niim3zS3mlgOiCGZ8uVRO/0v0CJ5LZzn0Ej6il7qanNTS/IFRshhIIB2ZAseM8JdofKz mNSZVtxcA2WBYC7wQMtyjnVoEGpte+2okIW6p1ByeYrKQAtAtQFPYjRPX7UpVr9jTThl Ps9J1t3TtWEGMr0LgCbzUCiGgga4qrjfaG6sUC0OLb41xH9CwQpWsbqcM3HehUWveTtI o1hV9se0djhz253R1B7ktrsiBUCVz36Txlp0qDU2SK5l8vzG8qe1EwrePUeuS+L2fv8Y Dd8w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hFO19x23; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-80622-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80622-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d23-20020a63f257000000b005dc82971737si3505087pgk.365.2024.02.26.04.33.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 04:33:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80622-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=@intel.com header.s=Intel header.b=hFO19x23; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-80622-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80622-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 4CBBAB20CFD for ; Mon, 26 Feb 2024 07:14:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A35831BF20; Mon, 26 Feb 2024 07:14:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="hFO19x23" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 5D6531BDCD; Mon, 26 Feb 2024 07:14:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708931678; cv=none; b=owP+ckRp89TpfLCRpz9DwY55KYFe99v/BubuZtDo+xWxzouBSwWcebyM1KpdptqlaKjhy5Nu0scIkfvhQv57h49SIled9xyuwDKXHvaZmY1TxUUTVzzapwDI3X6zzzHAJLlkFX8VjhZRnUnYSg18+idlCOumYcquOqm7IdUhNro= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708931678; c=relaxed/simple; bh=84WLTzyDlnzOxy+y2JEyz7+nxtE7gM9OqxOxGtRK5fA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=oVewCmWvVEZ5yhAhwUInNvq4kDHua8jCupnNQ84Vi7qn6ERSLx0e1GQJFUe4mxVrcritb/If19qgggw8j1IwmoTq+I1POjSuZjrV7tS9iRCNmOxlZAChLaQH6eSNmszUVjSXpHEMgAY1dJ4aRdmR57Km7nf9oTWu/BoyqIDDddY= 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=hFO19x23; arc=none smtp.client-ip=192.198.163.13 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=1708931677; x=1740467677; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=84WLTzyDlnzOxy+y2JEyz7+nxtE7gM9OqxOxGtRK5fA=; b=hFO19x237BzvQ3Zsryh6l6aq5tmQEh0glJhPXFMCqtpRL2qg3nfsdUTc heMdaK+OmLrZ0nhlK3LLN+ig/i+mtZVDsR5BiYYv1o4m/UGBfaraJLbhV R9nv9Xuz7cB0KponAck8Q7tO7Pibxx8jSaq4xkrqI4nVaXLYes+1+dEHk Hh09uPYukv3Rg1IQ7wQW9465sQlkPsSNojcRgYrN0VM6mSR/8jAnUiOIv Vly0yFX47J/kj5JmTH53Bz62zzISr3TmIF3lgH77lWxxEXj9NZg3zD/PN WVMrr/0TZgge2x/j3OqvH2BIXy6iIsyQgbHejMOpDJuULzKkbNYW3SD4Y w==; X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="6146193" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="6146193" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Feb 2024 23:14:36 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="37569524" Received: from linux.bj.intel.com ([10.238.157.71]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Feb 2024 23:14:33 -0800 Date: Mon, 26 Feb 2024 15:11:39 +0800 From: Tao Su To: Xiaoyao Li Cc: Sean Christopherson , Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Yi Lai , Xudong Hao Subject: Re: [PATCH] x86/cpu: Add a VMX flag to enumerate 5-level EPT support to userspace Message-ID: References: <20240110002340.485595-1-seanjc@google.com> <170864656017.3080257.14048100709856204250.b4-ty@google.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, Feb 26, 2024 at 09:30:33AM +0800, Xiaoyao Li wrote: > On 2/23/2024 9:35 AM, Sean Christopherson wrote: > > On Tue, 09 Jan 2024 16:23:40 -0800, Sean Christopherson wrote: > > > Add a VMX flag in /proc/cpuinfo, ept_5level, so that userspace can query > > > whether or not the CPU supports 5-level EPT paging. EPT capabilities are > > > enumerated via MSR, i.e. aren't accessible to userspace without help from > > > the kernel, and knowing whether or not 5-level EPT is supported is sadly > > > necessary for userspace to correctly configure KVM VMs. > > > > > > When EPT is enabled, bits 51:49 of guest physical addresses are consumed > > > if and only if 5-level EPT is enabled. For CPUs with MAXPHYADDR > 48, KVM > > > *can't* map all legal guest memory if 5-level EPT is unsupported, e.g. > > > creating a VM with RAM (or anything that gets stuffed into KVM's memslots) > > > above bit 48 will be completely broken. > > > > > > [...] > > > > Applied to kvm-x86 vmx, with a massaged changelog to avoid presenting this as a > > bug fix (and finally fixed the 51:49=>51:48 goof): > > > > Add a VMX flag in /proc/cpuinfo, ept_5level, so that userspace can query > > whether or not the CPU supports 5-level EPT paging. EPT capabilities are > > enumerated via MSR, i.e. aren't accessible to userspace without help from > > the kernel, and knowing whether or not 5-level EPT is supported is useful > > for debug, triage, testing, etc. > > For example, when EPT is enabled, bits 51:48 of guest physical addresses > > are consumed by the CPU if and only if 5-level EPT is enabled. For CPUs > > with MAXPHYADDR > 48, KVM *can't* map all legal guest memory if 5-level > > EPT is unsupported, making it more or less necessary to know whether or > > not 5-level EPT is supported. > > > > [1/1] x86/cpu: Add a VMX flag to enumerate 5-level EPT support to userspace > > https://github.com/kvm-x86/linux/commit/b1a3c366cbc7 > > Do we need a new KVM CAP for this? This decides how to interact with old > kernel without this patch. In that case, no ept_5level in /proc/cpuinfo, > what should we do in the absence of ept_5level? treat it only 4 level EPT > supported? Maybe also adding flag for 4-level EPT can be an option. If userspace checks both 4-level and 5-level are not in /proc/cpuinfo, it can regard the kernel as old. Thanks, Tao > > > > > -- > > https://github.com/kvm-x86/linux/tree/next > > >