Received: by 10.223.176.46 with SMTP id f43csp2053782wra; Sun, 21 Jan 2018 10:08:23 -0800 (PST) X-Google-Smtp-Source: AH8x224Jl3YNELmoiwezZvcymIJGPQoD6BTDauXmtJw2x9XPpC6JHMWVkIuqWK28XKm87xmjgEHH X-Received: by 2002:a17:902:7e0c:: with SMTP id b12-v6mr2240101plm.308.1516558103628; Sun, 21 Jan 2018 10:08:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516558103; cv=none; d=google.com; s=arc-20160816; b=LwsWz6O/bvIvxcbEejLXSdno1K3/5SHBAfMpqdlm+pkm1KsZiBWaH8bcI9jElukbjI ImHrG7m+Mbsziu5URcGzmB2R5yqyYxx4Bid4wsKUN2gQ6sj5A4d37RpseqlaoYM1vJnk k47KUad1FrBDUjyI84BOftgiiDXQhXLseAXnDkNsrN5X7r/Txx3jX9u9fExRBLCmzfdY YcjCjGANifHc4pxhEjdMo9Sg17o+iFsq38axKPyqSSzv8zoyr5Db7ShiB/jpgtd+CXCj mXaJuzQjeS5WU/6/NMyHEWANGCMMNidgRI/oR+NEVJTuh1kbbFtWoeteIaEAvyJAV5h0 tAEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :to:subject:dkim-signature:arc-authentication-results; bh=H00pqRFU3XnA4fUt/z0mRbZAm+pwLz8zTIuKppQAf44=; b=w2CHXoKFar39HCmKNkNog372yuyetwdSp9rVkisPjqQuUUGDaskFTsKlMmlBsF6rRu 8iGbZFFk3UeUJHqNRgq2HOuYIUl0OcObs53dJrzWKHO2KEhHtdLdHnI2Yy+8Mc2DPE5i 4wMA5y0ROo12/wy0IRZrldarAeK72yDiPExxUKaGygGIYYB5h0J6fkiy0eM+Do/qiUrQ uQnMLGxxLqvFbQZ1s8DshZxTZ1iLQQPnOUFXEikPYcVJ/B5QPDfC5ESLmJY6JxhShE/0 K04wb32B6ro9F9ZpZuwZ6DW0aB/T0xwst0ho0+bnc4M8FCa3up7KxsDjOXBWcpHM9iMX 1DXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=zCH82Ynq; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e4si12289271pgs.271.2018.01.21.10.08.09; Sun, 21 Jan 2018 10:08:23 -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; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=zCH82Ynq; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751403AbeAUSHF (ORCPT + 99 others); Sun, 21 Jan 2018 13:07:05 -0500 Received: from mail-sn1nam02on0079.outbound.protection.outlook.com ([104.47.36.79]:14752 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750954AbeAUSHD (ORCPT ); Sun, 21 Jan 2018 13:07:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=H00pqRFU3XnA4fUt/z0mRbZAm+pwLz8zTIuKppQAf44=; b=zCH82YnqEii+k+X2r+qnt886fowhdiQtJg9Arj+6Y0h88cJhCdk+oj89nnjzjujYVNYy5jccbxf9PH26sBB5UWCbcCiRdZllRbGdtTw0GTpsseQXmAngecU1DBodnXS4zrnDdyVBntL4ETY5l3Ox95R6gQlK9v9A+Ta1sbMzvjY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Thomas.Lendacky@amd.com; Received: from [10.236.65.116] (165.204.78.1) by CY4PR12MB1143.namprd12.prod.outlook.com (10.168.164.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.428.17; Sun, 21 Jan 2018 18:06:57 +0000 Subject: Re: [PATCH v2 6/8] x86/kvm: Add IBPB support To: David Woodhouse , arjan@linux.intel.com, tglx@linutronix.de, karahmed@amazon.de, x86@kernel.org, linux-kernel@vger.kernel.org, tim.c.chen@linux.intel.com, bp@alien8.de, peterz@infradead.org, pbonzini@redhat.com, ak@linux.intel.com, torvalds@linux-foundation.org, gregkh@linux-foundation.org References: <1516528149-9370-1-git-send-email-dwmw@amazon.co.uk> <1516528149-9370-7-git-send-email-dwmw@amazon.co.uk> From: Tom Lendacky Message-ID: <9cdb7ecb-c3ef-dc69-a8a8-b67ab3a488c2@amd.com> Date: Sun, 21 Jan 2018 12:06:52 -0600 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <1516528149-9370-7-git-send-email-dwmw@amazon.co.uk> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: MWHPR21CA0071.namprd21.prod.outlook.com (10.172.93.161) To CY4PR12MB1143.namprd12.prod.outlook.com (10.168.164.135) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b9085bee-9b6e-45e1-1781-08d560f9c41d X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4604075)(48565401081)(2017052603307)(7153060)(7193020);SRVR:CY4PR12MB1143; X-Microsoft-Exchange-Diagnostics: 1;CY4PR12MB1143;3:p9s/uvhdP8wETy8W8k13JJnUha5DXyrURe6JcDjsMXjUbeACKK5y7fBhhns1msk2Zt/yRoo7qeDDxd3oIOhdL2P6+v8MunHzb00mu0CmzpI1Nzm7rBeb678YPldiMQ6kjzqrODOwDI2qUttLXc5dd6WZKKrDMa38s6qKD4cIEPFmExk7N/UKx8TPaHEfora48PyAzc2b3wySWqoIGhTyy2BDsjP21ARbS42SX/JP81RUGBx9yN/Jn7Y2PqTmRZ3S;25:ESQm+wtckrX7mkCShL3CTEQLbcEd4g7CIcyMUQHjLouGuHDxFN2lhIuJBkaoljEcMd8Df+zNASCTx3OizqplM0RMiRb0W4Ax1Pi5ufvNo9nj6BMc8vyhWXRMrBjoieVeZq/0OoZ0KTPdKfV82wiqwOB3MppLQLmP+sEkw39eBH9ogVjRXZ9DbT3iyYBwxSCXEctSBIqACRl248MxS0otyg+42pzLyAMFDz23zS92uYhBbP6cLgU0skZT1PcPjVfp6/50hMPyc8/j30z2sU+8gcX4g328nq0ULWteX+beFBNM/VJnCEmDqwdiVh9QQqmfeuUrIs8A1o6jJAIrqUutzg==;31:jWB2UjRo5oJCKLb0afpfbY9mgXwG5+rF0ha7CvFrGCYYm/dcYpInQe+rNVOYckKvIYe3G4oONWL2Bcx1CWpedGNBvCFMMJCdo7DoQdQn4pNu+Mg5JKCBnr3Gp1FXgicERGsHcUg03ty9LrmvaOSg0V5fjqij9Kpovey37BqlF66k81VnqCWXmSpZMqe0QqmJr3JAJ3yFaibAS204Uc4lDquVgUyqlx44T6Ba6H16GR0= X-MS-TrafficTypeDiagnostic: CY4PR12MB1143: X-Microsoft-Exchange-Diagnostics: 1;CY4PR12MB1143;20:Vvj3vmJHYS6NIUgdmajF8BFJ2U8nTaDZtYFg3pcDdQU2DAUVdTc1faVziXQzS/uDAD6YzwfvfhRnurqgB+GMzpocbpy/aSuXqJD4TG9iCf9Hx2fc9flLRXTlHZHFWk5kskqFT7VVEbGEm25doHoEJvuP9euW2D+y45G5XAm44VURX+G4vkChNikEd6/NTfwcJQCIOFhZUNWs/6nXuKY63SfMhGH8kCVh7IWc1pIqw8+oQ1QXG/lc6mnOPOrd5epjjFKz0kbu8yrg87/Dy1Cr1dFNFHbxfxB4MCLUC2gUr98dzViEQrOafT174Y/naa+mbvCdwN/ebBsB94gjYS90CnD1hfBTVRT2ct+RJQ2LUKjdsAuAUcAOCuljE6HblTSlidSWZHIjUWP8FJeG1MXZaNkWByyUTViqt8XTBVR11bFKC9ERGXMJXYUDRKyb8o8KOaLhAdT1XqhbPVTuR9V7Tx0yV7s4cwphwcqepTwwqH72GWg4pERvEJmNaJQ165lJ;4:VifEe3tPa3SXmQddibckDJLQNWbhprXwvpeFo5mT48raa+PFd9dvAMyGEjXy3UuPiFNDksILiawMJeOkpaV+BqkkmV3CrdKAb8+LPL/mElLVy4LtjgqiQCFo9lYEyJX+wUF8mpDQ0hpYzwY2HYbSYCRmAMIZcWgQ2k6Vdvu2+VBIJG1G4do/mos/dwaT/8MDxdSmZ8y60l7FymlSe4l0HNIxfsc0lTe6AsFr6hfZEKXAdFxjTt7VFHuLMlOhkd6X0ZIjW5yn6Vp6C5fbb2mR9JLQH5r23cvtyFmWDJoutcf1N7zI/vHNWf57VpSxLz9aqYk0hRy5FTHDp4vhHNcUUan3oTCPyFnDV+ZKiBT+/6bn7jO9DKAuJikjjCL9jgo/ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(42068640409301)(146755900322472)(228905959029699); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040501)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3002001)(3231023)(2400081)(944501161)(6055026)(6041288)(20161123564045)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(6072148)(201708071742011);SRVR:CY4PR12MB1143;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:CY4PR12MB1143; X-Forefront-PRVS: 0559FB9674 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6049001)(366004)(376002)(39860400002)(346002)(396003)(39380400002)(54534003)(199004)(189003)(6306002)(5660300001)(97736004)(86362001)(25786009)(65826007)(3260700006)(31686004)(77096007)(64126003)(229853002)(47776003)(386003)(65806001)(23676004)(2906002)(8936002)(53936002)(65956001)(90366009)(26005)(305945005)(58126008)(16576012)(16526018)(66066001)(52146003)(2486003)(53546011)(6486002)(230700001)(3846002)(478600001)(36756003)(68736007)(52116002)(31696002)(7416002)(7736002)(81166006)(81156014)(2950100002)(316002)(6246003)(966005)(83506002)(6666003)(6116002)(8676002)(59450400001)(50466002)(106356001)(105586002)(76176011)(72206003)(921003)(1121003);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR12MB1143;H:[10.236.65.116];FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtDWTRQUjEyTUIxMTQzOzIzOmVBYlhIUGs2bGgwOExyZDZtS3hSekpNc2Qw?= =?utf-8?B?OGRidFc2V1ZkNDEzNUxTRCs5b0taM0tyandIT3MyVU1GZFRTallmbnFsZlRJ?= =?utf-8?B?VTZ4UW1KTTNtN1VUR2xXS29UdVM2OC9PVHlNdVVGSHhTWGtPUWpPOXg2ZVJL?= =?utf-8?B?amwrOVh1SkFFZUtKaWV0MkgybE1GQ0RRQ3ZRWEVtNU1jVndldXhhV2lDOWNh?= =?utf-8?B?aC9TT3VmTHkxV1NERGRwT0NCVDl5dkY4aEdEdTZuQ29EQnk3NmZVeDFzcGxJ?= =?utf-8?B?RnhWNU5GOFdGalBaZjdLbXNtd1BSRGFHK2NnY3N4c25ieWs5bWgxcDN1a2Jq?= =?utf-8?B?WEpXQjczSkZGMDNEcDUvOHdZMTRZb1hFdDVrZ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3CrFxIBwLWR12zDU+iYXAogCyLFuFNzcCTSFxgN5Na6MQ0FTs7urqBMfNfE3mL8yInTmF4ZTC33pEuXUBMmiI6Y9itnwIci+hE X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jan 2018 18:06:57.6157 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b9085bee-9b6e-45e1-1781-08d560f9c41d X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1143 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/21/2018 3:49 AM, David Woodhouse wrote: > From: Ashok Raj > > Add MSR passthrough for MSR_IA32_PRED_CMD and place branch predictor > barriers on switching between VMs to avoid inter VM specte-v2 attacks. > > [peterz: rebase and changelog rewrite] > [karahmed: - vmx: expose PRED_CMD whenever it is available > - svm: only pass through IBPB if it is available] > [dwmw2: - vmx: allow X86_FEATURE_AMD_PRED_CMD too] > Cc: Asit Mallick > Cc: Dave Hansen > Cc: Arjan Van De Ven > Cc: Tim Chen > Cc: Linus Torvalds > Cc: Andrea Arcangeli > Cc: Andi Kleen > Cc: Thomas Gleixner > Cc: Dan Williams > Cc: Jun Nakajima > Cc: Andy Lutomirski > Cc: Greg KH > Cc: Paolo Bonzini > Signed-off-by: Ashok Raj > Signed-off-by: Peter Zijlstra (Intel) > Link: http://lkml.kernel.org/r/1515720739-43819-6-git-send-email-ashok.raj@intel.com > > Signed-off-by: David Woodhouse > Signed-off-by: KarimAllah Ahmed > --- > arch/x86/kvm/svm.c | 14 ++++++++++++++ > arch/x86/kvm/vmx.c | 11 +++++++++++ > 2 files changed, 25 insertions(+) > > diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c > index 2744b973..cfdb9ab 100644 > --- a/arch/x86/kvm/svm.c > +++ b/arch/x86/kvm/svm.c > @@ -529,6 +529,7 @@ struct svm_cpu_data { > struct kvm_ldttss_desc *tss_desc; > > struct page *save_area; > + struct vmcb *current_vmcb; > }; > > static DEFINE_PER_CPU(struct svm_cpu_data *, svm_data); > @@ -918,6 +919,9 @@ static void svm_vcpu_init_msrpm(u32 *msrpm) > > set_msr_interception(msrpm, direct_access_msrs[i].index, 1, 1); > } > + > + if (boot_cpu_has(X86_FEATURE_AMD_PRED_CMD)) > + set_msr_interception(msrpm, MSR_IA32_PRED_CMD, 1, 1); I don't think there's any reason to make the "if" check. You can just add this to the direct_access_msrs array instead, as: { .index = MSR_IA32_PRED_CMD, .always = true }, Thanks, Tom > } > > static void add_msr_offset(u32 offset) > @@ -1706,11 +1710,17 @@ static void svm_free_vcpu(struct kvm_vcpu *vcpu) > __free_pages(virt_to_page(svm->nested.msrpm), MSRPM_ALLOC_ORDER); > kvm_vcpu_uninit(vcpu); > kmem_cache_free(kvm_vcpu_cache, svm); > + /* > + * The vmcb page can be recycled, causing a false negative in > + * svm_vcpu_load(). So do a full IBPB now. > + */ > + indirect_branch_prediction_barrier(); > } > > static void svm_vcpu_load(struct kvm_vcpu *vcpu, int cpu) > { > struct vcpu_svm *svm = to_svm(vcpu); > + struct svm_cpu_data *sd = per_cpu(svm_data, cpu); > int i; > > if (unlikely(cpu != vcpu->cpu)) { > @@ -1739,6 +1749,10 @@ static void svm_vcpu_load(struct kvm_vcpu *vcpu, int cpu) > if (static_cpu_has(X86_FEATURE_RDTSCP)) > wrmsrl(MSR_TSC_AUX, svm->tsc_aux); > > + if (sd->current_vmcb != svm->vmcb) { > + sd->current_vmcb = svm->vmcb; > + indirect_branch_prediction_barrier(); > + } > avic_vcpu_load(vcpu, cpu); > } > > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c > index d1e25db..1e45bb3 100644 > --- a/arch/x86/kvm/vmx.c > +++ b/arch/x86/kvm/vmx.c > @@ -2279,6 +2279,7 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu) > if (per_cpu(current_vmcs, cpu) != vmx->loaded_vmcs->vmcs) { > per_cpu(current_vmcs, cpu) = vmx->loaded_vmcs->vmcs; > vmcs_load(vmx->loaded_vmcs->vmcs); > + indirect_branch_prediction_barrier(); > } > > if (!already_loaded) { > @@ -6791,6 +6792,16 @@ static __init int hardware_setup(void) > kvm_tsc_scaling_ratio_frac_bits = 48; > } > > + /* > + * The AMD_PRED_CMD bit might be exposed by hypervisors on Intel > + * chips which only want to expose PRED_CMD to guests and not > + * SPEC_CTRL. Because PRED_CMD is one-shot write-only, while > + * PRED_CMD requires storage, live migration support, etc. > + */ > + if (boot_cpu_has(X86_FEATURE_SPEC_CTRL) || > + boot_cpu_has(X86_FEATURE_AMD_PRED_CMD)) > + vmx_disable_intercept_for_msr(MSR_IA32_PRED_CMD, false); > + > vmx_disable_intercept_for_msr(MSR_FS_BASE, false); > vmx_disable_intercept_for_msr(MSR_GS_BASE, false); > vmx_disable_intercept_for_msr(MSR_KERNEL_GS_BASE, true); >