Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp316989pxb; Thu, 5 Nov 2020 00:17:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJzRdmhkGhXBL7I1N7rqYfjM7hPY0dCtW0qkJJem5SXokZUU+z/Ylco3oC/AIiZRXMKrT/Tr X-Received: by 2002:a05:6402:31a5:: with SMTP id dj5mr1392254edb.325.1604564262027; Thu, 05 Nov 2020 00:17:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604564262; cv=none; d=google.com; s=arc-20160816; b=lSy3ZOwffQGJVp9UG1RLfJZLZjsG5tjeMxTBYP7vTqwRZvLiDIL4OzwFRMY+h9t565 yBk6fW2QSKdwfVidzFtzFEiBsQKD4lTUfmF8hSF5/A1UBTmYl+TLg9WSvJIDgrPj3wWC RI5XAt7qPhEOVDWGSSvo2wXBUZVb7+S2qCgzBNj8Y1QNk9HasJLC+Le/LZ/7QKlu8pq6 wu4k39HYn/dJHfcvv3KLE6zwC4lo6es4uVJ6V6YGp7eMjbvBVdMl4qjidgLEeWeg7Cpl dBbahCYRg25JRd/N7W/hjYhrvHR75OwhDy7eGMcV4booan2cB4sQlo2T8iB8OiP6t9Uq FkyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from:ironport-sdr :ironport-sdr; bh=sdig3kYjQPgRFjD8XvZaYFxRZ4x7sRXdmLNSrK1yMYI=; b=YXqV4rsETrZOf0PxAOEAR/v0ktDC3WRaXJacTOfmvhNaHDIGnb2/tVYMoAeIOX4q6k GbXXWzvQBP9hl/iTuD+jShc+nYiMZ7jHn76uJtgRPk3lhcpaelRX7zpLO0DIMNa7m0rB umvP7DlHsizrmCxYtTshfZ5PpPf9qo4uBcFseFQU0SPtnRnd9TUHU2dT5+Bx0CNZCFiA u8Y6pWCfMZWSMDKDDrHp1HSZF3f5rkM4IIL8M130hHacGTSU11KcCrnYGt97S4RIY/2U NCL0VvG91xtdfxRV58qB3tjgxqTrHZXYJXNon/b1eI9u+h/5tpNQqcB0PwRWKuIhsGRv zy4Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id l63si810347ede.607.2020.11.05.00.17.19; Thu, 05 Nov 2020 00:17:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1727923AbgKEIPn (ORCPT + 99 others); Thu, 5 Nov 2020 03:15:43 -0500 Received: from mga04.intel.com ([192.55.52.120]:39805 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726152AbgKEIPm (ORCPT ); Thu, 5 Nov 2020 03:15:42 -0500 IronPort-SDR: 4iOIAbZ6xTBUpHyalZNa5KJttoor0+pnRggT0rRNnWIU3xY1nrBdMPzwRunqKVZw0pBU5zU19x AUvSnWscIZrA== X-IronPort-AV: E=McAfee;i="6000,8403,9795"; a="166755691" X-IronPort-AV: E=Sophos;i="5.77,453,1596524400"; d="scan'208";a="166755691" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2020 00:15:42 -0800 IronPort-SDR: RH6MQYXqur+6PiFBZCIf9sVhu/Zlbxqbh609693aK753L2EJlnc0537WrsK3GbmDiQv6OXo7mH EoJmuZrnvOLA== X-IronPort-AV: E=Sophos;i="5.77,453,1596524400"; d="scan'208";a="539281365" Received: from chenyi-pc.sh.intel.com ([10.239.159.72]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2020 00:15:39 -0800 From: Chenyi Qiang To: Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Xiaoyao Li Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC v3 0/7] KVM: PKS Virtualization support Date: Thu, 5 Nov 2020 16:17:57 +0800 Message-Id: <20201105081805.5674-1-chenyi.qiang@intel.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Protection Keys for Supervisor Pages(PKS) is a feature that extends the Protection Keys architecture to support thread-specific permission restrictions on supervisor pages. PKS works similar to an existing feature named PKU(protecting user pages). They both perform an additional check after all legacy access permissions checks are done. If violated, #PF occurs and PFEC.PK bit will be set. PKS introduces MSR IA32_PKRS to manage supervisor protection key rights. The MSR contains 16 pairs of ADi and WDi bits. Each pair advertises on a group of pages with the same key which is set in the leaf paging-structure entries(bits[62:59]). Currently, IA32_PKRS is not supported by XSAVES architecture. This patchset aims to add the virtualization of PKS in KVM. It implemented PKS CPUID enumeration, vmentry/vmexit configuration, MSR exposure, nested supported etc. Currently, PKS is not yet supported for shadow paging. Detailed information about PKS can be found in the latest Intel 64 and IA-32 Architectures Software Developer's Manual. --- Changelogs: v2->v3: - No function changes since last submit - rebase on the latest PKS kernel support: https://lore.kernel.org/lkml/20201102205320.1458656-1-ira.weiny@intel.com/ - add MSR_IA32_PKRS to the vmx_possible_passthrough_msrs[] - RFC v2: https://lore.kernel.org/lkml/20201014021157.18022-1-chenyi.qiang@intel.com/ v1->v2: - rebase on the latest PKS kernel support: https://github.com/weiny2/linux-kernel/tree/pks-rfc-v3 - add a kvm-unit-tests for PKS - add the check in kvm_init_msr_list for PKRS - place the X86_CR4_PKS in mmu_role_bits in kvm_set_cr4 - add the support to expose VM_{ENTRY, EXIT}_LOAD_IA32_PKRS in nested VMX MSR - RFC v1: https://lore.kernel.org/lkml/20200807084841.7112-1-chenyi.qiang@intel.com/ --- Chenyi Qiang (7): KVM: VMX: Introduce PKS VMCS fields KVM: VMX: Expose IA32_PKRS MSR KVM: MMU: Rename the pkru to pkr KVM: MMU: Refactor pkr_mask to cache condition KVM: MMU: Add support for PKS emulation KVM: X86: Expose PKS to guest and userspace KVM: VMX: Enable PKS for nested VM arch/x86/include/asm/kvm_host.h | 13 ++--- arch/x86/include/asm/pkeys.h | 1 + arch/x86/include/asm/vmx.h | 6 +++ arch/x86/kvm/cpuid.c | 3 +- arch/x86/kvm/mmu.h | 36 +++++++------ arch/x86/kvm/mmu/mmu.c | 78 +++++++++++++++------------- arch/x86/kvm/vmx/capabilities.h | 6 +++ arch/x86/kvm/vmx/nested.c | 38 +++++++++++++- arch/x86/kvm/vmx/vmcs.h | 1 + arch/x86/kvm/vmx/vmcs12.c | 2 + arch/x86/kvm/vmx/vmcs12.h | 6 ++- arch/x86/kvm/vmx/vmx.c | 91 +++++++++++++++++++++++++++++++-- arch/x86/kvm/vmx/vmx.h | 3 +- arch/x86/kvm/x86.c | 9 +++- arch/x86/kvm/x86.h | 6 +++ arch/x86/mm/pkeys.c | 6 +++ include/linux/pkeys.h | 4 ++ 17 files changed, 240 insertions(+), 69 deletions(-) -- 2.17.1