Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753168AbdGGNrO (ORCPT ); Fri, 7 Jul 2017 09:47:14 -0400 Received: from mail-by2nam01on0081.outbound.protection.outlook.com ([104.47.34.81]:46933 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751862AbdGGNoK (ORCPT ); Fri, 7 Jul 2017 09:44:10 -0400 Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=amd.com; From: Tom Lendacky Subject: [PATCH v9 30/38] kvm: x86: svm: Support Secure Memory Encryption within KVM To: linux-arch@vger.kernel.org, linux-efi@vger.kernel.org, kvm@vger.kernel.org, linux-doc@vger.kernel.org, x86@kernel.org, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, xen-devel@lists.xen.org, linux-mm@kvack.org, iommu@lists.linux-foundation.org Cc: Brijesh Singh , Toshimitsu Kani , Radim =?utf-8?b?S3LEjW3DocWZ?= , Matt Fleming , Alexander Potapenko , "H. Peter Anvin" , Larry Woodman , Jonathan Corbet , Joerg Roedel , "Michael S. Tsirkin" , Ingo Molnar , Andrey Ryabinin , Dave Young , Rik van Riel , Arnd Bergmann , Konrad Rzeszutek Wilk , Borislav Petkov , Andy Lutomirski , Boris Ostrovsky , Dmitry Vyukov , Juergen Gross , Thomas Gleixner , Paolo Bonzini Date: Fri, 07 Jul 2017 08:43:47 -0500 Message-ID: <20170707134346.29711.20203.stgit@tlendack-t1.amdoffice.net> In-Reply-To: <20170707133804.29711.1616.stgit@tlendack-t1.amdoffice.net> References: <20170707133804.29711.1616.stgit@tlendack-t1.amdoffice.net> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: MWHPR1001CA0019.namprd10.prod.outlook.com (10.174.165.32) To MWHPR12MB1149.namprd12.prod.outlook.com (10.169.204.13) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8ef61f47-a6bb-4d4e-12e4-08d4c53e3412 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:MWHPR12MB1149; X-Microsoft-Exchange-Diagnostics: 1;MWHPR12MB1149;3:YWXmN8/jjEjjOJIcKfI34Abb9egR+QxZfF7Jj5NGJyqeQleJ/wbTwOx9V2ktyBxFZ9v0OnQo8hkM0M6fMT5xd8TC1o2d91YjsVEmrq5/aoOvnZUrJA+o5MsBkdVyNBrjYt2zbpBHstifVjK/jYpGViMV8v2D0MjgkWDgC4Z25V3OUhFpFi9ccSdgoPSpf2ab1rasx+D9lE9VxPUkUzW7l5oUGW6/wfcfvdXh3MP/PiUXp63kzqEL2GptbzQt+DtsxIAROi3r831HZBqShepd3uHRZxGTa3TrK4gPxqX4+JyPICxe4Px37YqEuOVPHmQs4wE+3S2ZyG0Wv0+wGPg6rnJHmiA6TWjDYLYf4IV6yVdlQDmDYElpymhqJerxTPqldtkdvi2hXqVnD19+hB3lEIa3TEECcCwLPdife20CjpMfPdJI0RlxrVEH6L/mHptSdAyO9Z4r0CXBTFhuP6lSmp/Ng59CWzP3cLWBOXTeRcS2c7MJJhjO3uRrr8WnBuwtJzUqvUFE2UWetpGIByv53WfD9cTjHcWnTu/iyIMY2wGZFBFwvOQqi6O+Ft3DJSG/wa3eZ7x18lrI5ezM6GJVtCzcQDztuOSN4r0qj9xnLWqPKuMJOA0xMSjw2w7eHlKjVcJ9lrc4cQbsImYcIbGkrtYtohysFrNUhc26DfOsq24+1C9g+CtSgKig0CAIb0xlK2gXuG7pqUyoUzM/1ZzTji8fMxt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644zS5q380QHUVtPTIi3qfNhsRaxPO0c1hEv8T4bno7uCPEz/zjg7Bfkvu26JkaP1Tvi4IgmGO4kzs33HjhXcHUXiQLmNFkuM6eJjOskzb7qHHKTr5tR/gKon72Xboc3tL8GUztqGGxWGKp7S37vOPhcXn2fbzNBgzLjvcdU X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(125551606395959)(133145235818549)(236129657087228)(767451399110)(148574349560750)(167848164394848); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(2017060910064)(8121501046)(5005006)(100000703101)(100105400095)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041248)(20161123564025)(20161123558100)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123562025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:MWHPR12MB1149;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:MWHPR12MB1149; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtNV0hQUjEyTUIxMTQ5OzQ6b3Z5MnRuSnJDUWdSdG8wOVFjRlNkMVF5NDZD?= =?utf-8?B?SjM4TkNabHNQZmZwNEZpQVdZaE5WMGFlYXJZaWxqeTRjUm5Ndk1pVnlkL2ty?= =?utf-8?B?cmNhOS9WdjcyZWJ6dTlnK0NIaS9RSnlMTDZkYmJSRzRhbng4SFdoekYzVnM1?= =?utf-8?B?THAwQ01HZzNDQitRbW80Q2F6bS9NdW4vc0tGTlhGcnZzOGFIY2ZObEx3UWZ3?= =?utf-8?B?eWh0M01qSnJFUUtFRmsrdmtmY29sYTU4VUNMSWxGbVlKOWt1dllOUE9NNnhV?= =?utf-8?B?VkVVQXBkMU5PbDdlZm04QlRZNkQ2RTJMR01mb2xZ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FnSVZhWEpuMVdQVnM1VFJZQ21xcWhhakQzbzVuKzZy?= =?utf-8?B?TUU2NGpoWkJqaE5xZ2VyVWlBcjhBMTRKNTYvd0Q2S3hUQmdYTWRuNjNVaEhr?= =?utf-8?B?Yk5VSFl1dW9udHM3OWdGWHVoWnVaK3FLdk1xTlB3T1VOQXB0dmQycitabXBR?= =?utf-8?B?b1piYXl1YnRNeGtCbi9IWVY0MVFzU2ZHMGhhcSs4aU12L3phRUE3R09LUW9i?= =?utf-8?B?RkJXaDlUaWQzZDdNZnIxRXVEcXk2OWpUT0xZZGFNMC9oS0NaOEdDdm1FWXlI?= =?utf-8?B?RnpYcDRVNHZsV3ZmQkk1Y2ZCU20vUjg0aWJQd3BHc3VvSHhsOWovdUo1ck5N?= =?utf-8?B?YWZpVVVnUXcxd1pwMjVjalg3ZWV4ajR6YUhMUDZqeTZ3bVFvcmVEMXVnZGUx?= =?utf-8?B?NllOS21KQXZuRTM3eXd6VlZmMlUycnUrY0lHYUY1cUVVM0xqbWFFOWpmV1Nq?= =?utf-8?B?Q1pLLzRNcEZVSjM2cUh3RlE3ODFBOWNHZEhUOFVkdmxIbnRiS3VlMXRMUkhh?= =?utf-8?B?YUlvTzJaYWYxcjBvdHRsRFE3cit5NmNtRjI4bTJpdGgyQnlmek81TUJnbWxy?= =?utf-8?B?ZlJxQi9xelVJVUc4Qm5XWkozaFpuajhmL21CbUcxZWhHY0R1Wkw4SldKMnFa?= =?utf-8?Q?lwGTRsMJbQq0NVzTSGNHodKrkp5SCtf?= X-Forefront-PRVS: 0361212EA8 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(39400400002)(39850400002)(39410400002)(39450400003)(39840400002)(39860400002)(9686003)(54906002)(53936002)(33646002)(47776003)(103116003)(6116002)(3846002)(25786009)(54356999)(76176999)(110136004)(38730400002)(42186005)(1076002)(53416004)(4326008)(50986999)(230700001)(66066001)(6506006)(86362001)(55016002)(2950100002)(2906002)(23676002)(305945005)(189998001)(50466002)(97746001)(478600001)(575784001)(72206003)(81166006)(8676002)(83506001)(7736002)(7406005)(5660300001)(7416002)(921003)(1121003);DIR:OUT;SFP:1101;SCL:1;SRVR:MWHPR12MB1149;H:tlendack-t1.amdoffice.net;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtNV0hQUjEyTUIxMTQ5OzIzOk53MG1BdVpzV2I2SXpONmpidWovRE9CTWVF?= =?utf-8?B?UUFhTmFQaHozRFVWamVEL0NYV1N4YzVWS1dDTW5PMmszZEJIMDVOTWEwWVNj?= =?utf-8?B?MENENUZzYkhvRHNPRGwrZVUwYm5OL0RhKzZFWHdhdmw2Sno5bXJoenJsRGNw?= =?utf-8?B?c1g0ZWZZRVRFWFVPWndQZ2hSZENRZTRnTmx3MCtqeXhzNGZIZDcvWWJObUdX?= =?utf-8?B?L296K2w0QmhCa2tJaXNTem9jV241ei95OFQwUFBtU0x4czBlK3p3cXlPd2tV?= =?utf-8?B?VTFQL3gzUVlwVVFZeUEvei9EQTM4VUp3V2MweDltOFVGdTdJelA3ZzRSRHkz?= =?utf-8?B?YS8ySFU4bzFTd3JJRFVWd1c5Wi9zRG0vTnVkVVU3bU9FN01hTEJCU0xPZWxX?= =?utf-8?B?QTNIY28rMkw2eE1uMktCbmpVcGZ6TjFHOHIveG16a2lIVFJMRlpZQWtQdXEv?= =?utf-8?B?NzZTRFlsMDU5dEN1czMvelhFR2E4cXJvM2xJTVVtNTVzS0dzbHZqS001MFZL?= =?utf-8?B?WW45bHExbjZXbGdBMCs4aHg3dDg3cmhuOURoalVIVFlxS0RzY251NW83NHRV?= =?utf-8?B?VlozWlNQRThad2FNSTdnekZvUUFGcEF2T0RmbDhVb3hlcmVqZStRb2VBcElM?= =?utf-8?B?SWlIT1ZqTThsaHQ2a3E0cTdFTk5XVjhMMWVmdXFOekZ1K0hONnE1cTc5M01a?= =?utf-8?B?MTVMSGhBK3ZORGd0RGFTYzlQczVSWV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yKZBX406aXyaoSSJBgSWYSERZZ0aus4wuctX+noEIbMhQF8TTIjKIVBwyzYD6N79ZMql333sslgG6soKTiQDZ3+bFbbW6HggySt3HqMnM5ng2+ZY6L4DQVff0T+LTr+wwfctIiQTrnOSI3200qAP/DRpcubJR6n/0+BCNKrST4VW/2m4FNswYh9rb;24:oCJNDTWdbIBWobpomFqSg2CGl7k23G3G5/Tb15kXG5cw7KxtFIxgfdHchevrPIOMTab34oEBIGirr23rmew2q2Z0K/qkEi6j6nVMNwPTyng= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;MWHPR12MB1149;7:ou/F3NoE1mG8LblEdeHmQnRhQLyvGJo0xzKkUvVrFNqezV6/IWxXsXgsvA80wg+G2fLT1CYGCw6jlD6zZShxXJEUpBQCN0EiScG2nioFkZkRIQwgrQ68VlFTry9bNBQ+M6TMzeAAbmABtmRz4qxF2UD6dySs5b9GB5AXV6WJYCQLYcR9bNGipU7gKKtuZeEyPSeef2+PCMoAFdSvv2WwGPVk4f5gne304puOKaaYFcL0ueyRALMQQa/h4k1kJY15wExG9kxWgxOYxkWVEGOSxjYnlEUURefD4zFhCiWZfyIuoXFDkPXTOX0i7+EoALNdKnsvmEnG7S7FOoYtgV5DeLPwAyotwFNhFycpsyJNCHAubF1iQqLMWgCKa0xPF+i/sSTTgWWZ1CSu8WwgBRRjkVCmCoKRKEVDad5DLVOkVTr/FtB1kM+A8nWCrOEU01ljFtsJgqBh02jxE38GY5DkUQNW6QCIrMSjFd/olbl1sjv3RM9HSYAGKTPYyLIwA40brh7UnUzZjJvyRIfBcawMdePC12Dl9Pk5SF4uyIhusequOULPGz3kOifgf+TxSgL2oR+srTWjDHl+G02paz1crPIdFTimUPvKwwYHUEIAt8Vvr1tSsdoRDo4bsDlgPhUkEn52hC7AYb3E79SrMRHjPDZW6q0hamHDex9hDHVejZXBiUNStLGo3PPrhQAyOweWH8/TJ6MXuseFppBkwzceabukH/rV/18kCBgof1cvOFlPC6m4Geci/x9kMHMypv/XDqapbgjOEWQHmUf9Qx5SvGu3m9M++0lBdhddoa5QKcs= X-Microsoft-Exchange-Diagnostics: 1;MWHPR12MB1149;20:cHVxnr1/z/RFYZCGn/4Ma7zX3VG1W4D+6ib3ZPlrNwxv35GzyKRPZiACGo6/ppzqDp3Cb5wfCURiJTMZYBShV5zhympHmnf3atyb5S5/EHpSb5rfrHkWSFRwepetU8NVeInANk+kQQsUhtboxqptOB1Wh9vvVHCm1m21gXFnYu6IkG8UbWhCO7CoA8VdX9gYp4kFx/E7SXv+NgVEO1VsFpUDsWwxXjGwWO7Sd3sLZu4pYYAC98eZanbfa0Q2Ag71 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2017 13:43:49.8389 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1149 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 9940 Lines: 266 Update the KVM support to work with SME. The VMCB has a number of fields where physical addresses are used and these addresses must contain the memory encryption mask in order to properly access the encrypted memory. Also, use the memory encryption mask when creating and using the nested page tables. Reviewed-by: Borislav Petkov Signed-off-by: Tom Lendacky --- arch/x86/include/asm/kvm_host.h | 2 +- arch/x86/kvm/mmu.c | 12 ++++++++---- arch/x86/kvm/mmu.h | 2 +- arch/x86/kvm/svm.c | 35 ++++++++++++++++++----------------- arch/x86/kvm/vmx.c | 3 ++- arch/x86/kvm/x86.c | 3 ++- 6 files changed, 32 insertions(+), 25 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 695605e..6d1267f 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1069,7 +1069,7 @@ struct kvm_arch_async_pf { void kvm_mmu_uninit_vm(struct kvm *kvm); void kvm_mmu_set_mask_ptes(u64 user_mask, u64 accessed_mask, u64 dirty_mask, u64 nx_mask, u64 x_mask, u64 p_mask, - u64 acc_track_mask); + u64 acc_track_mask, u64 me_mask); void kvm_mmu_reset_context(struct kvm_vcpu *vcpu); void kvm_mmu_slot_remove_write_access(struct kvm *kvm, diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index cb82259..e85888c 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -107,7 +107,7 @@ enum { (((address) >> PT32_LEVEL_SHIFT(level)) & ((1 << PT32_LEVEL_BITS) - 1)) -#define PT64_BASE_ADDR_MASK (((1ULL << 52) - 1) & ~(u64)(PAGE_SIZE-1)) +#define PT64_BASE_ADDR_MASK __sme_clr((((1ULL << 52) - 1) & ~(u64)(PAGE_SIZE-1))) #define PT64_DIR_BASE_ADDR_MASK \ (PT64_BASE_ADDR_MASK & ~((1ULL << (PAGE_SHIFT + PT64_LEVEL_BITS)) - 1)) #define PT64_LVL_ADDR_MASK(level) \ @@ -125,7 +125,7 @@ enum { * PT32_LEVEL_BITS))) - 1)) #define PT64_PERM_MASK (PT_PRESENT_MASK | PT_WRITABLE_MASK | shadow_user_mask \ - | shadow_x_mask | shadow_nx_mask) + | shadow_x_mask | shadow_nx_mask | shadow_me_mask) #define ACC_EXEC_MASK 1 #define ACC_WRITE_MASK PT_WRITABLE_MASK @@ -184,6 +184,7 @@ struct kvm_shadow_walk_iterator { static u64 __read_mostly shadow_dirty_mask; static u64 __read_mostly shadow_mmio_mask; static u64 __read_mostly shadow_present_mask; +static u64 __read_mostly shadow_me_mask; /* * The mask/value to distinguish a PTE that has been marked not-present for @@ -317,7 +318,7 @@ static bool check_mmio_spte(struct kvm_vcpu *vcpu, u64 spte) void kvm_mmu_set_mask_ptes(u64 user_mask, u64 accessed_mask, u64 dirty_mask, u64 nx_mask, u64 x_mask, u64 p_mask, - u64 acc_track_mask) + u64 acc_track_mask, u64 me_mask) { if (acc_track_mask != 0) acc_track_mask |= SPTE_SPECIAL_MASK; @@ -330,6 +331,7 @@ void kvm_mmu_set_mask_ptes(u64 user_mask, u64 accessed_mask, shadow_present_mask = p_mask; shadow_acc_track_mask = acc_track_mask; WARN_ON(shadow_accessed_mask != 0 && shadow_acc_track_mask != 0); + shadow_me_mask = me_mask; } EXPORT_SYMBOL_GPL(kvm_mmu_set_mask_ptes); @@ -2398,7 +2400,8 @@ static void link_shadow_page(struct kvm_vcpu *vcpu, u64 *sptep, BUILD_BUG_ON(VMX_EPT_WRITABLE_MASK != PT_WRITABLE_MASK); spte = __pa(sp->spt) | shadow_present_mask | PT_WRITABLE_MASK | - shadow_user_mask | shadow_x_mask | shadow_accessed_mask; + shadow_user_mask | shadow_x_mask | shadow_accessed_mask | + shadow_me_mask; mmu_spte_set(sptep, spte); @@ -2700,6 +2703,7 @@ static int set_spte(struct kvm_vcpu *vcpu, u64 *sptep, pte_access &= ~ACC_WRITE_MASK; spte |= (u64)pfn << PAGE_SHIFT; + spte |= shadow_me_mask; if (pte_access & ACC_WRITE_MASK) { diff --git a/arch/x86/kvm/mmu.h b/arch/x86/kvm/mmu.h index 330bf3a..08b779d 100644 --- a/arch/x86/kvm/mmu.h +++ b/arch/x86/kvm/mmu.h @@ -48,7 +48,7 @@ static inline u64 rsvd_bits(int s, int e) { - return ((1ULL << (e - s + 1)) - 1) << s; + return __sme_clr(((1ULL << (e - s + 1)) - 1) << s); } void kvm_mmu_set_mmio_spte_mask(u64 mmio_mask); diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 33460fc..c2fcd31 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -1139,9 +1139,9 @@ static void avic_init_vmcb(struct vcpu_svm *svm) { struct vmcb *vmcb = svm->vmcb; struct kvm_arch *vm_data = &svm->vcpu.kvm->arch; - phys_addr_t bpa = page_to_phys(svm->avic_backing_page); - phys_addr_t lpa = page_to_phys(vm_data->avic_logical_id_table_page); - phys_addr_t ppa = page_to_phys(vm_data->avic_physical_id_table_page); + phys_addr_t bpa = __sme_set(page_to_phys(svm->avic_backing_page)); + phys_addr_t lpa = __sme_set(page_to_phys(vm_data->avic_logical_id_table_page)); + phys_addr_t ppa = __sme_set(page_to_phys(vm_data->avic_physical_id_table_page)); vmcb->control.avic_backing_page = bpa & AVIC_HPA_MASK; vmcb->control.avic_logical_id = lpa & AVIC_HPA_MASK; @@ -1204,8 +1204,8 @@ static void init_vmcb(struct vcpu_svm *svm) set_intercept(svm, INTERCEPT_MWAIT); } - control->iopm_base_pa = iopm_base; - control->msrpm_base_pa = __pa(svm->msrpm); + control->iopm_base_pa = __sme_set(iopm_base); + control->msrpm_base_pa = __sme_set(__pa(svm->msrpm)); control->int_ctl = V_INTR_MASKING_MASK; init_seg(&save->es); @@ -1339,9 +1339,9 @@ static int avic_init_backing_page(struct kvm_vcpu *vcpu) return -EINVAL; new_entry = READ_ONCE(*entry); - new_entry = (page_to_phys(svm->avic_backing_page) & - AVIC_PHYSICAL_ID_ENTRY_BACKING_PAGE_MASK) | - AVIC_PHYSICAL_ID_ENTRY_VALID_MASK; + new_entry = __sme_set((page_to_phys(svm->avic_backing_page) & + AVIC_PHYSICAL_ID_ENTRY_BACKING_PAGE_MASK) | + AVIC_PHYSICAL_ID_ENTRY_VALID_MASK); WRITE_ONCE(*entry, new_entry); svm->avic_physical_id_cache = entry; @@ -1609,7 +1609,7 @@ static struct kvm_vcpu *svm_create_vcpu(struct kvm *kvm, unsigned int id) svm->vmcb = page_address(page); clear_page(svm->vmcb); - svm->vmcb_pa = page_to_pfn(page) << PAGE_SHIFT; + svm->vmcb_pa = __sme_set(page_to_pfn(page) << PAGE_SHIFT); svm->asid_generation = 0; init_vmcb(svm); @@ -1637,7 +1637,7 @@ static void svm_free_vcpu(struct kvm_vcpu *vcpu) { struct vcpu_svm *svm = to_svm(vcpu); - __free_page(pfn_to_page(svm->vmcb_pa >> PAGE_SHIFT)); + __free_page(pfn_to_page(__sme_clr(svm->vmcb_pa) >> PAGE_SHIFT)); __free_pages(virt_to_page(svm->msrpm), MSRPM_ALLOC_ORDER); __free_page(virt_to_page(svm->nested.hsave)); __free_pages(virt_to_page(svm->nested.msrpm), MSRPM_ALLOC_ORDER); @@ -2304,7 +2304,7 @@ static u64 nested_svm_get_tdp_pdptr(struct kvm_vcpu *vcpu, int index) u64 pdpte; int ret; - ret = kvm_vcpu_read_guest_page(vcpu, gpa_to_gfn(cr3), &pdpte, + ret = kvm_vcpu_read_guest_page(vcpu, gpa_to_gfn(__sme_clr(cr3)), &pdpte, offset_in_page(cr3) + index * 8, 8); if (ret) return 0; @@ -2316,7 +2316,7 @@ static void nested_svm_set_tdp_cr3(struct kvm_vcpu *vcpu, { struct vcpu_svm *svm = to_svm(vcpu); - svm->vmcb->control.nested_cr3 = root; + svm->vmcb->control.nested_cr3 = __sme_set(root); mark_dirty(svm->vmcb, VMCB_NPT); svm_flush_tlb(vcpu); } @@ -2804,7 +2804,7 @@ static bool nested_svm_vmrun_msrpm(struct vcpu_svm *svm) svm->nested.msrpm[p] = svm->msrpm[p] | value; } - svm->vmcb->control.msrpm_base_pa = __pa(svm->nested.msrpm); + svm->vmcb->control.msrpm_base_pa = __sme_set(__pa(svm->nested.msrpm)); return true; } @@ -4436,7 +4436,7 @@ static int svm_ir_list_add(struct vcpu_svm *svm, struct amd_iommu_pi_data *pi) pr_debug("SVM: %s: use GA mode for irq %u\n", __func__, irq.vector); *svm = to_svm(vcpu); - vcpu_info->pi_desc_addr = page_to_phys((*svm)->avic_backing_page); + vcpu_info->pi_desc_addr = __sme_set(page_to_phys((*svm)->avic_backing_page)); vcpu_info->vector = irq.vector; return 0; @@ -4487,7 +4487,8 @@ static int svm_update_pi_irte(struct kvm *kvm, unsigned int host_irq, struct amd_iommu_pi_data pi; /* Try to enable guest_mode in IRTE */ - pi.base = page_to_phys(svm->avic_backing_page) & AVIC_HPA_MASK; + pi.base = __sme_set(page_to_phys(svm->avic_backing_page) & + AVIC_HPA_MASK); pi.ga_tag = AVIC_GATAG(kvm->arch.avic_vm_id, svm->vcpu.vcpu_id); pi.is_guest_mode = true; @@ -4913,7 +4914,7 @@ static void svm_set_cr3(struct kvm_vcpu *vcpu, unsigned long root) { struct vcpu_svm *svm = to_svm(vcpu); - svm->vmcb->save.cr3 = root; + svm->vmcb->save.cr3 = __sme_set(root); mark_dirty(svm->vmcb, VMCB_CR); svm_flush_tlb(vcpu); } @@ -4922,7 +4923,7 @@ static void set_tdp_cr3(struct kvm_vcpu *vcpu, unsigned long root) { struct vcpu_svm *svm = to_svm(vcpu); - svm->vmcb->control.nested_cr3 = root; + svm->vmcb->control.nested_cr3 = __sme_set(root); mark_dirty(svm->vmcb, VMCB_NPT); /* Also sync guest cr3 here in case we live migrate */ diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 6dcc487..a0db541 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -6453,7 +6453,8 @@ void vmx_enable_tdp(void) enable_ept_ad_bits ? VMX_EPT_DIRTY_BIT : 0ull, 0ull, VMX_EPT_EXECUTABLE_MASK, cpu_has_vmx_ept_execute_only() ? 0ull : VMX_EPT_READABLE_MASK, - enable_ept_ad_bits ? 0ull : VMX_EPT_RWX_MASK); + enable_ept_ad_bits ? 0ull : VMX_EPT_RWX_MASK, + 0ull); ept_set_mmio_spte_mask(); kvm_enable_tdp(); diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 0e846f0..268fed5 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -54,6 +54,7 @@ #include #include #include +#include #include @@ -6097,7 +6098,7 @@ int kvm_arch_init(void *opaque) kvm_mmu_set_mask_ptes(PT_USER_MASK, PT_ACCESSED_MASK, PT_DIRTY_MASK, PT64_NX_MASK, 0, - PT_PRESENT_MASK, 0); + PT_PRESENT_MASK, 0, sme_me_mask); kvm_timer_init(); perf_register_guest_info_callbacks(&kvm_guest_cbs);