From patchwork Fri May 3 10:08:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kai Huang X-Patchwork-Id: 10928209 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1476E15A6 for ; Fri, 3 May 2019 10:09:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 04E70284FF for ; Fri, 3 May 2019 10:09:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ECEDE28501; Fri, 3 May 2019 10:09:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 913D0284FF for ; Fri, 3 May 2019 10:09:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727460AbfECKJR (ORCPT ); Fri, 3 May 2019 06:09:17 -0400 Received: from mga06.intel.com ([134.134.136.31]:59997 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726514AbfECKJR (ORCPT ); Fri, 3 May 2019 06:09:17 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 May 2019 03:09:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,425,1549958400"; d="scan'208";a="139552011" Received: from khuang2-desk.gar.corp.intel.com ([10.254.24.58]) by orsmga008.jf.intel.com with ESMTP; 03 May 2019 03:09:12 -0700 From: Kai Huang To: kvm@vger.kernel.org, pbonzini@redhat.com, rkrcmar@redhat.com Cc: sean.j.christopherson@intel.com, junaids@google.com, thomas.lendacky@amd.com, brijesh.singh@amd.com, guangrong.xiao@gmail.com, tglx@linutronix.de, bp@alien8.de, hpa@zytor.com, kai.huang@intel.com Subject: [PATCH 0/2] Fix reserved bits calculation errors caused by MKTME Date: Fri, 3 May 2019 22:08:51 +1200 Message-Id: X-Mailer: git-send-email 2.13.6 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This series fix reserved bits related calculation errors caused by MKTME. MKTME repurposes high bits of physical address bits as 'keyID' thus they are not reserved bits, and to honor such HW behavior those reduced bits are taken away from boot_cpu_data.x86_phys_bits when MKTME is detected (exactly how many bits are taken away is configured by BIOS). Currently KVM asssumes bits from boot_cpu_data.x86_phys_bits to 51 are reserved bits, which is not true anymore with MKTME, and needs fix. This series was splitted from the old patch I sent out around 2 weeks ago: kvm: x86: Fix several SPTE mask calculation errors caused by MKTME Changes to old patch: - splitted one patch into two patches. First patch is to move kvm_set_mmio_spte_mask() as prerequisite. It doesn't impact functionality. Patch 2 does the real fix. - renamed shadow_first_rsvd_bits to shadow_phys_bits suggested by Sean. - refined comments and commit msg to be more concise. Btw sorry that I will be out next week and won't be able to reply email. Kai Huang (2): kvm: x86: Move kvm_set_mmio_spte_mask() from x86.c to mmu.c kvm: x86: Fix reserved bits related calculation errors caused by MKTME arch/x86/kvm/mmu.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++---- arch/x86/kvm/x86.c | 31 --------------------------- 2 files changed, 57 insertions(+), 35 deletions(-)