Received: by 10.223.185.116 with SMTP id b49csp5136388wrg; Wed, 7 Mar 2018 06:59:19 -0800 (PST) X-Google-Smtp-Source: AG47ELsmsgc3nyJbMK/Qe8I533l98D7jj2qSbR1K0v/8JV5TGkCeofTfbfa2MFZ5YGGiWa1uNQlA X-Received: by 10.99.42.83 with SMTP id q80mr18341423pgq.115.1520434759273; Wed, 07 Mar 2018 06:59:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520434759; cv=none; d=google.com; s=arc-20160816; b=jQGGex9TB2bsfGYDQwVWEcQEA67BZb/CjD29Eg5s3IyeQMTqDkST4FOo2/VM+zuOBi 6KZRzN1I6VffLgTyw/gpHqhtdnKbu6ECOx5CkEOeZ19RiZIYrhcL/q0MaBEnfKTMRMXd 6l8ijow9ckb/xcxAPzhJ6RGUWEw+/oTjK+e8ZLdekn0KaAIaDjYyfzzvecCgLyoNJ0Sa ygwaGrvJesrebThV0Rk9vLb0u4DA6GjpolRIB3SzACGXS8JCWLFcIZ42uF9NC9laAjx/ LGAFe+Q3B8sYv1tcSXtrJthnk4GV7iuzY5+KNNdvARXYLR1xnSUYoFuNX1gvEi8BgVLR 6qdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=TswKBRl36C+CX5mcr1bnHIzwfdG8l4P65B4+qIkA31U=; b=oMUhndzRshA8fefXjiKoYR2CKqmzMGdy8ruqcQk6hi7EVXtLR8OG1TB64TNjD8Xzhy SUX2HvWg4v14twAKjp9PiKCh9PUi5dytpPc8ricBsVUZU8nMGHiqDIdTIPJhUxXB5kuE z1WNIPJBt3QbQr+SKSqE/siGSCHUZ7pWc39xr8F/5dGkza01f0DswjgdjQw3mYkF4tJS LmNecaUOEyJ+vwNtnHBNY+h5dd+nQ1XQr5lQSNn1ZTzl3lYSrYlIeIgnzsX2CrgUmWPr 21EIoReikYefDlvrVVYSxyi4ZSzuXNkOg1R9MPWqjI7M1D9f6wdUcfVlJSrVnu7NPZYV bRLQ== 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 80si12459321pfn.73.2018.03.07.06.59.04; Wed, 07 Mar 2018 06:59:19 -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 S1754620AbeCGO5N (ORCPT + 99 others); Wed, 7 Mar 2018 09:57:13 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:46044 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754557AbeCGO5J (ORCPT ); Wed, 7 Mar 2018 09:57:09 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8B1A3406E8BA; Wed, 7 Mar 2018 14:57:08 +0000 (UTC) Received: from flask (unknown [10.43.2.80]) by smtp.corp.redhat.com (Postfix) with SMTP id 6E7F9215CDA7; Wed, 7 Mar 2018 14:57:06 +0000 (UTC) Received: by flask (sSMTP sendmail emulation); Wed, 07 Mar 2018 15:56:28 +0100 Date: Wed, 7 Mar 2018 15:56:28 +0100 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: Paolo Bonzini Cc: Konrad Rzeszutek Wilk , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, David Woodhouse , KarimAllah Ahmed Subject: Re: [PATCH] KVM: VMX: expose the host's ARCH_CAPABILITIES MSR to userspace Message-ID: <20180307145628.GA12299@flask> References: <1519433546-33879-1-git-send-email-pbonzini@redhat.com> <20180226221300.GK22024@char.us.oracle.com> <20180301213205.GB29001@flask> <20180302214212.GB13606@flask> <9cad32c8-fdb6-95db-2cd3-a0e3297b1811@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <9cad32c8-fdb6-95db-2cd3-a0e3297b1811@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 07 Mar 2018 14:57:08 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 07 Mar 2018 14:57:08 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'rkrcmar@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2018-03-07 12:53+0100, Paolo Bonzini: > On 02/03/2018 22:42, Radim Krčmář wrote: > > Ok, sounds good. I've deferred it to rc5 as I think we'll want to use > > this to replace the auto setting: I would not bet that it is going to > > be safe to expose future bits, so having the userspace always sanitize > > the capabilities would be safer (and more in line with what we do with > > other MSRs). i.e. this patch would also > > > > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c > > index 051dab74e4e9..86ea4a83af1f 100644 > > --- a/arch/x86/kvm/vmx.c > > +++ b/arch/x86/kvm/vmx.c > > @@ -5740,9 +5740,6 @@ static void vmx_vcpu_setup(struct vcpu_vmx *vmx) > > ++vmx->nmsrs; > > } > > > > - if (boot_cpu_has(X86_FEATURE_ARCH_CAPABILITIES)) > > - rdmsrl(MSR_IA32_ARCH_CAPABILITIES, vmx->arch_capabilities); > > - > > vm_exit_controls_init(vmx, vmcs_config.vmexit_ctrl); > > > > /* 22.2.1, 20.8.1 */ > > I don't know. There are good reasons for both behaviors, and especially > the following two for _not_ removing the rdmsr: > > 1) so far you could just pass the result of KVM_GET_SUPPORTED_CPUID to > KVM_SET_CPUID2, and expect the result to be "as close as possible to the > host"; > > 2) having different behavior for VMX and ARCH_CAPABILITIES MSRs would be > confusing. Right, we can't just stop setting them by default ... (I am in favor of forcing the userspace to configure everything and I'd accept this exception as a mistake of the past.) > I think I'm leaning more towards the following direction: whitelist > ARCH_CAPABILITIES, like we do for the AMD LFENCE MSR already, and > default the AMD LFENCE MSR to the host value. The whitelisting is a good idea and I'm ok with just that, thanks. The MSR_F10H_DECFG default is questionable -- MSR_F10H_DECFG is an architectural MSR, so we'd be changing the guest under the sight of existing userspaces. A potential security risk if they migrate the guest to a CPU that doesn't serialize LFENCE. ARCH_CAPABILITIES are at least hidden by a new CPUID bit. The feature MSR defaults are going to be a mess anyway: we have MSR_IA32_UCODE_REV that is tightly coupled with CPUID. Not a good candidate for passing by default and currently also has a default value.