From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5CD51C35250 for ; Sun, 9 Feb 2020 13:41:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 309DC20838 for ; Sun, 9 Feb 2020 13:41:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581255687; bh=oHXH9rP1iL5HVX8omikttGK8oZn8tRY2ygUMFElKn3I=; h=Subject:To:Cc:From:Date:List-ID:From; b=PNYi5EPXCT5d1dt1OlzZNWCfPH1ywcjTdksM9tGHn0uKIRD7lV9rDbY3bKoWpZQ1f lPQudAHmwPy6LcBLpf+7ouoR5e18tSbsbSp8+smoGYVO2KBtZybr8WL6xosaq8MTyt SgGu+vHHck+4leEpgMwIbUQ3hpsp13Qdvruw+/Bw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727663AbgBINl0 (ORCPT ); Sun, 9 Feb 2020 08:41:26 -0500 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:59189 "EHLO out3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727654AbgBINl0 (ORCPT ); Sun, 9 Feb 2020 08:41:26 -0500 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 6F65821D51; Sun, 9 Feb 2020 08:41:25 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Sun, 09 Feb 2020 08:41:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=8LDMTQ 2AgyE0GjXGMJK/PKlM2EW8JcvbdGCQGcbCvLs=; b=YqDT0FQ+dJ8MfeNjFcKkul 8acapM8I6buQt9Mq8qPwXy1HX4kSBAcVPbo3O7Fx2J9L/UVL1UnydVrgAUPQYGgy dsE6XQ7dtMFb7l7MP1MSFbay0/cTj3kGyPWYaqXA2NX7FHar8/Uz4lgCNnd1bkTu H2065s0Ju5VoDg4U/y9/oNf5ppCeZqqSBOrDzT+XAucfEkPCd4j4al6jXtldxLNr UdwnnkMqUbopu8yk9ScgDW8UUv0NfMiFZK85lk/36TJjfYJvL7iaGrMjuQNFKMUB LJDtyZUd2CrG68HVUUgZKS64WVNXQrwr5L9HUR9tME6z1yWkI3l85m7TDrYf3MsA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrheelgdefvdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepuffvhfffkfggtgfgsehtkeertddttd flnecuhfhrohhmpeeoghhrvghgkhhhsehlihhnuhigfhhouhhnuggrthhiohhnrdhorhhg qeenucfkphepfeekrdelkedrfeejrddufeehnecuvehluhhsthgvrhfuihiivgepudenuc frrghrrghmpehmrghilhhfrhhomhepghhrvghgsehkrhhorghhrdgtohhm X-ME-Proxy: Received: from localhost (unknown [38.98.37.135]) by mail.messagingengine.com (Postfix) with ESMTPA id 220753060701; Sun, 9 Feb 2020 08:41:24 -0500 (EST) Subject: FAILED: patch "[PATCH] KVM: x86: use CPUID to locate host page table reserved bits" failed to apply to 4.19-stable tree To: pbonzini@redhat.com, thomas.lendacky@amd.com Cc: From: Date: Sun, 09 Feb 2020 13:31:11 +0100 Message-ID: <158125147120864@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The patch below does not apply to the 4.19-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 7adacf5eb2d2048045d9fd8fdab861fd9e7e2e96 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 4 Dec 2019 15:50:27 +0100 Subject: [PATCH] KVM: x86: use CPUID to locate host page table reserved bits The comment in kvm_get_shadow_phys_bits refers to MKTME, but the same is actually true of SME and SEV. Just use CPUID[0x8000_0008].EAX[7:0] unconditionally if available, it is simplest and works even if memory is not encrypted. Cc: stable@vger.kernel.org Reported-by: Tom Lendacky Signed-off-by: Paolo Bonzini diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index 6f92b40d798c..1e4ee4f8de5f 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -538,16 +538,20 @@ EXPORT_SYMBOL_GPL(kvm_mmu_set_mask_ptes); static u8 kvm_get_shadow_phys_bits(void) { /* - * boot_cpu_data.x86_phys_bits is reduced when MKTME is detected - * in CPU detection code, but MKTME treats those reduced bits as - * 'keyID' thus they are not reserved bits. Therefore for MKTME - * we should still return physical address bits reported by CPUID. + * boot_cpu_data.x86_phys_bits is reduced when MKTME or SME are detected + * in CPU detection code, but the processor treats those reduced bits as + * 'keyID' thus they are not reserved bits. Therefore KVM needs to look at + * the physical address bits reported by CPUID. */ - if (!boot_cpu_has(X86_FEATURE_TME) || - WARN_ON_ONCE(boot_cpu_data.extended_cpuid_level < 0x80000008)) - return boot_cpu_data.x86_phys_bits; + if (likely(boot_cpu_data.extended_cpuid_level >= 0x80000008)) + return cpuid_eax(0x80000008) & 0xff; - return cpuid_eax(0x80000008) & 0xff; + /* + * Quite weird to have VMX or SVM but not MAXPHYADDR; probably a VM with + * custom CPUID. Proceed with whatever the kernel found since these features + * aren't virtualizable (SME/SEV also require CPUIDs higher than 0x80000008). + */ + return boot_cpu_data.x86_phys_bits; } static void kvm_mmu_reset_all_pte_masks(void)