From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2ABA1C432C2 for ; Wed, 25 Sep 2019 21:37:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F3A6D20872 for ; Wed, 25 Sep 2019 21:37:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728235AbfIYVhj (ORCPT ); Wed, 25 Sep 2019 17:37:39 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:38554 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728016AbfIYVhh (ORCPT ); Wed, 25 Sep 2019 17:37:37 -0400 Received: from localhost ([127.0.0.1] helo=flow.W.breakpoint.cc) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1iDEyX-0002Dx-FF; Wed, 25 Sep 2019 23:37:29 +0200 From: Sebastian Andrzej Siewior To: kvm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org, Sebastian Andrzej Siewior Subject: [PATCH 2/2] KVM: x86: Expose CLZERO and XSAVEERPTR to the guest Date: Wed, 25 Sep 2019 23:37:21 +0200 Message-Id: <20190925213721.21245-3-bigeasy@linutronix.de> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190925213721.21245-1-bigeasy@linutronix.de> References: <20190925213721.21245-1-bigeasy@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I was surprised to see that the guest reported `fxsave_leak' while the host did not. After digging deeper I noticed that the bits are simply masked out during enumeration. The XSAVEERPTR feature is actually a bug fix on AMD which means the kernel can disable a workaround. While here, I've seen that CLZERO is also masked out. This opcode is unprivilged so exposing it to the guest should not make any difference. Pass CLZERO and XSAVEERPTR to the guest if available on the host. Signed-off-by: Sebastian Andrzej Siewior --- arch/x86/kvm/cpuid.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index 22c2720cd948e..0ae9194d0f4d2 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -473,6 +473,7 @@ static inline int __do_cpuid_func(struct kvm_cpuid_entr= y2 *entry, u32 function, =20 /* cpuid 0x80000008.ebx */ const u32 kvm_cpuid_8000_0008_ebx_x86_features =3D + F(CLZERO) | F(XSAVEERPTR) | F(WBNOINVD) | F(AMD_IBPB) | F(AMD_IBRS) | F(AMD_SSBD) | F(VIRT_SSBD) | F(AMD_SSB_NO) | F(AMD_STIBP) | F(AMD_STIBP_ALWAYS_ON); =20 --=20 2.23.0