Received: by 10.223.185.116 with SMTP id b49csp3831162wrg; Tue, 13 Feb 2018 08:23:45 -0800 (PST) X-Google-Smtp-Source: AH8x227O2DNCyuBYzhDxf4CS79aowE3510kqTJ9NjKiLaAVxzLlf/kvhQGLPFUbFYibZj8Ip1CGb X-Received: by 2002:a17:902:8285:: with SMTP id y5-v6mr1632750pln.190.1518539025637; Tue, 13 Feb 2018 08:23:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518539025; cv=none; d=google.com; s=arc-20160816; b=rLzUW9HWhLeI77s74nfGWiWC9UrsN6tbZv5hvWlrdxd9SU9Rvbk3xJLwENCmvNjzx1 ZjvI7sC0OyfZQKO/Om203J67ImJ2DIGsZMY5RUgtf+ujUyq/ilkK7C4CY9LThMeETAnR qe5V3y2z//wI71dMfRHFeJEKNE1paVaa4TNfVfb3VbYzJFwSyEDptSE2ojgbR68+3I8x oPtSia/askUoq47jcbWMDodODGeXkT8Z9G9pMfWkdE8WpTaOG5Dv5+u7RHD7CUAcB4Ts DW5bJdd/uqVPfesaexEHiX2ukvZhpFxrMOUngfyV75cO1PLpPX/CKfEWqEga77ES7yKH EE9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=0adXz3klU0C2DcTYugWPBMd262TB0xncV+JoOdFzRxc=; b=Dz5X0mbRxsyOQl4WgX7GrRZwhzXQ8Rvj4yoNTm18oYjcuUFzIiacxAmXnQK1tyQDks 0i0yeyWfcVpw7i4bn7+2uHaC7kYN3FuZgekTdNRynMVmSUe3g5LS3Y/hKrMgBE7QZ1HO rpXC7Vs7UjEH1lKk6g5avUfRFEAH93uIAWM6jI9BYztiXS7KsIt6m8kOdBuSrBfRfSzk QwLUdxfKmcBQZxMgZ8riSR3gl48aZLdimL0fPjvBqV4Z9qxrsn08bCSi021xGV3rbRRs ISvB5Jm3Ta77GLwX4mGPugYfzK+zzHB5zNE3ByuzBbVS/u03h6UHg4ywBpHW0feCwuGZ AU5g== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u85si19691pfi.5.2018.02.13.08.23.31; Tue, 13 Feb 2018 08:23:45 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934850AbeBMQWb (ORCPT + 99 others); Tue, 13 Feb 2018 11:22:31 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:60352 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934472AbeBMQW3 (ORCPT ); Tue, 13 Feb 2018 11:22:29 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0E62E40FB645; Tue, 13 Feb 2018 16:22:29 +0000 (UTC) Received: from [10.36.116.223] (ovpn-116-223.ams2.redhat.com [10.36.116.223]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9D1B81227754; Tue, 13 Feb 2018 16:22:27 +0000 (UTC) Subject: Re: [RFC PATCH 2/2] KVM: SVM: Add MSR feature support for serializing LFENCE To: Tom Lendacky , x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Joerg Roedel , Borislav Petkov , Thomas Gleixner , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= References: <20180208225833.22074.25995.stgit@tlendack-t1.amdoffice.net> <20180208225856.22074.98252.stgit@tlendack-t1.amdoffice.net> From: Paolo Bonzini Message-ID: <584e51cc-1a79-4e5d-45ef-1850bb6c155e@redhat.com> Date: Tue, 13 Feb 2018 17:22:25 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <20180208225856.22074.98252.stgit@tlendack-t1.amdoffice.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 13 Feb 2018 16:22:29 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 13 Feb 2018 16:22:29 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'pbonzini@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/02/2018 23:58, Tom Lendacky wrote: > Create an entry in the new MSR as a feature framework to allow a guest to > recognize LFENCE as a serializing instruction on AMD processors. The MSR > can only be set by the host, any write by the guest will be ignored. A > read by the guest will return the value as set by the host. In this way, > the support to expose the feature to the guest is controlled by the > hypervisor. > > Signed-off-by: Tom Lendacky > --- > arch/x86/kvm/svm.c | 16 ++++++++++++++++ > arch/x86/kvm/x86.c | 6 ++++++ > 2 files changed, 22 insertions(+) > > @@ -4047,6 +4052,17 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr) > case MSR_VM_IGNNE: > vcpu_unimpl(vcpu, "unimplemented wrmsr: 0x%x data 0x%llx\n", ecx, data); > break; > + case MSR_F10H_DECFG: > + /* Only the host can set this MSR, silently ignore */ > + if (!msr->host_initiated) > + break; Just one thing I'm wondering, should we #GP if the guest attempts to clear MSR_F10H_DECFG_LFENCE_SERIALIZE? Thanks, Paolo > + > + /* Check the supported bits */ > + if (!kvm_valid_msr_feature(MSR_F10H_DECFG, data)) > + return 1; > + > + svm->msr_decfg = data; > + break; > case MSR_IA32_APICBASE: > if (kvm_vcpu_apicv_active(vcpu)) > avic_update_vapic_bar(to_svm(vcpu), data); > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 4251c34..21ec73b 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -1060,7 +1060,13 @@ struct kvm_msr_based_features { > u64 value; /* MSR value */ > }; > > +static const struct x86_cpu_id msr_decfg_match[] = { > + { X86_VENDOR_AMD, X86_FAMILY_ANY, X86_MODEL_ANY, X86_FEATURE_LFENCE_RDTSC }, > + {} > +}; > + > static struct kvm_msr_based_features msr_based_features[] = { > + { MSR_F10H_DECFG, MSR_F10H_DECFG_LFENCE_SERIALIZE, msr_decfg_match }, > {} > }; > >