Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7310528imu; Thu, 31 Jan 2019 08:15:45 -0800 (PST) X-Google-Smtp-Source: ALg8bN6i+ef2kQEP/UtZwmNAL6PBjOYNTmbF2nJoHmc2KVXsggczstLBTbB4xzuztbdJBlK9p/ox X-Received: by 2002:a63:5346:: with SMTP id t6mr32508527pgl.40.1548951345234; Thu, 31 Jan 2019 08:15:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548951345; cv=none; d=google.com; s=arc-20160816; b=C4cnMjA3U5dE1z0sNkLmHIxNM5fmkbiXUTdIWsVGDpsmixt47vc8Yr6TU4nNdtzpg/ 7367C1+4wduLwkHQtoXvOw6H8IhQSKGBK6Jvwo5q3Zb3cVA1HaOwjDYhjdj0M1cAoxoP YtxJQIzpoMfONulYAx17xxrP9XkyTFp4uU3HPnrc036owwGGxP/1VgNbkXAR8iTDzTAi gdh7C0YXpFFvfjlOgq33x3baB3R9P9u7KFee26umfdw2FU8RdSugHr6zMn0WsIVIOgJ2 AuhxZ1ylDUvcq3wOpJCRjiDkA2R5oZxmrRlzI75E+F/l28Zd9UknALzTb/qyWGm+nB7X f3bA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:message-id:date :subject:cc:to:from; bh=ECs4D+BB6T4wT4hfyxBYjSzgYrb1TpjJw03wJpxLrHU=; b=oMZ+9obuBNRdq4hn3wgXw2BG1WJQ6Pg+PiFWA2HFtOFEEs5Cn24Q/4/vOueE2erYlY BmMWtkBqCZT3AEdXivoJ3ywDzt1Dhx3JKsq7CuHhI+utTgrgye8ltL3CjD7fRaIwh98z vdIEGQmLAVOGbjJMf6oLLxRvqIZ8FVAXPgJDlmgxLnVM8PUaZVXdLtCzFxK9bFxsXvey nTjdFDNv9bhDro+Dw9QT3lvD6PaPnnECFZnvcrYfIxaBcYL5ssb4TtsOiI44G83ZWROG EkJyxZpiojUKmH7/Hlqrjv4FhiBYt1GY9sJcy4jK60EJNTLQPWwbXRdEWMo5n29oWE9x 1TjQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i5si4817201pfo.189.2019.01.31.08.15.29; Thu, 31 Jan 2019 08:15:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388195AbfAaQNt (ORCPT + 99 others); Thu, 31 Jan 2019 11:13:49 -0500 Received: from mga03.intel.com ([134.134.136.65]:65471 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388109AbfAaQNt (ORCPT ); Thu, 31 Jan 2019 11:13:49 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 Jan 2019 08:13:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,545,1539673200"; d="scan'208";a="296179629" Received: from zhangyu-optiplex-9020.bj.intel.com ([10.238.135.159]) by orsmga005.jf.intel.com with ESMTP; 31 Jan 2019 08:13:46 -0800 From: Yu Zhang To: kvm@vger.kernel.org Cc: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , linux-kernel@vger.kernel.org Subject: [PATCH] kvm: x86: Return LA57 feature based on hardware capability Date: Fri, 1 Feb 2019 00:09:43 +0800 Message-Id: <1548950983-18458-1-git-send-email-yu.c.zhang@linux.intel.com> X-Mailer: git-send-email 1.9.1 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Previously, 'commit 372fddf70904 ("x86/mm: Introduce the 'no5lvl' kernel parameter")' cleared X86_FEATURE_LA57 in boot_cpu_data, if Linux chooses to not run in 5-level paging mode. Yet boot_cpu_data is queried by do_cpuid_ent() as the host capability later when creating vcpus, and Qemu will not be able to detect this feature and create VMs with LA57 feature. As discussed earlier, VMs can still benefit from extended linear address width, e.g. to enhance features like ASLR. So we would like to fix this, by return the true hardware capability when Qemu queries. Signed-off-by: Yu Zhang --- Cc: Paolo Bonzini Cc: "Radim Krčmář" Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: "H. Peter Anvin" Cc: linux-kernel@vger.kernel.org --- arch/x86/kvm/cpuid.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index bbffa6c..c07958b 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -335,6 +335,7 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function, unsigned f_xsaves = kvm_x86_ops->xsaves_supported() ? F(XSAVES) : 0; unsigned f_umip = kvm_x86_ops->umip_emulated() ? F(UMIP) : 0; unsigned f_intel_pt = kvm_x86_ops->pt_supported() ? F(INTEL_PT) : 0; + unsigned f_la57 = 0; /* cpuid 1.edx */ const u32 kvm_cpuid_1_edx_x86_features = @@ -489,7 +490,10 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function, // TSC_ADJUST is emulated entry->ebx |= F(TSC_ADJUST); entry->ecx &= kvm_cpuid_7_0_ecx_x86_features; + f_la57 = entry->ecx & F(LA57); cpuid_mask(&entry->ecx, CPUID_7_ECX); + /* Set LA57 based on hardware capability. */ + entry->ecx |= f_la57; entry->ecx |= f_umip; /* PKU is not yet implemented for shadow paging. */ if (!tdp_enabled || !boot_cpu_has(X86_FEATURE_OSPKE)) -- 1.9.1