Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp835105imu; Tue, 11 Dec 2018 08:16:50 -0800 (PST) X-Google-Smtp-Source: AFSGD/WxZYLLCb+YZBQa0Va0E34bJro1EFr6Xp2cpssXk8cpA39WvEwBP+ZD6doP8CWmOioFi0j/ X-Received: by 2002:a17:902:708b:: with SMTP id z11mr16603574plk.203.1544545010119; Tue, 11 Dec 2018 08:16:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544545010; cv=none; d=google.com; s=arc-20160816; b=Mjkd+S5xj9a+FJA6KAdHV6k139YBb3gWeA3X61p6scHubyAjPP4wm/E4hJ0X+PXV3m i4wqf5kHV1kEu5S2ZwCsSOUwuUau8EqLDTTyi/4hrXQtv89+4abQ1VsWlKLm3PbytZaf jjGdSDEUPH/TZ7XEZhDKjjIYNeOQRkVadeKygfyPmgWMyi1XnbLJseVXncdJQrIeHBja iuUcpuf3bFbJM9f06pUoNPJsFjPhj+JG70dnF+mrmxM9KDz69+PbNxk41rEqoVh/7AER SYKSIM6YpS2vjFO4zC/JG/euRS1KiMYSndgLSBx+9XXPiuAuJRaaltxGlmcwagNyCsiy Zj3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=8FGm4F7qRiT6N3V0J+DkcpOEUULHH1H2BGEdrFrXZGM=; b=SC/7Veo1USrtBd585r8mpdo4dBDU81+RQCCtOJZRmRTrbB+d2EFov9vq4pz9VZU0oy R93iXfCdJnmRetwvY+SspB86Uo+nBuawmqIEVUBo/lgYW0UUiUEAYCvLDy3Pg6v99Obg YX8K2zGAq2jlDCGxIEBPbbri1Ch2RlWe80WgMCwu+H1dEk8TOrB5e/wEXeEU7RmNG5cH diMAEaXLJuvcayDee8wFSxoi4pmmcvWeU1wTjn1YoL0e3hSqUOOAlkz0Q5Yo5w+5RezH SvFCigXHZg8VBttZiQxrWBESv6BOrc+vPvPu3kbIjmZmbdSFA74hBri2S//YUIBBBVHY 3/jA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=OYMQghQS; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v6si13638481pfj.167.2018.12.11.08.16.35; Tue, 11 Dec 2018 08:16:50 -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=@alien8.de header.s=dkim header.b=OYMQghQS; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730495AbeLKQOs (ORCPT + 99 others); Tue, 11 Dec 2018 11:14:48 -0500 Received: from mail.skyhub.de ([5.9.137.197]:43824 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728331AbeLKQOr (ORCPT ); Tue, 11 Dec 2018 11:14:47 -0500 Received: from zn.tnic (p200300EC2BCD2B00C8FE208D32917CBC.dip0.t-ipconnect.de [IPv6:2003:ec:2bcd:2b00:c8fe:208d:3291:7cbc]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 532181EC0432; Tue, 11 Dec 2018 17:14:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1544544885; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8FGm4F7qRiT6N3V0J+DkcpOEUULHH1H2BGEdrFrXZGM=; b=OYMQghQS51gbClhqCVjEflz5KAtr/CL2i5Lpc0QUkEvGweZhlAP2eI4IalnZC3gkN3wT4/ pLa6gEAVXvB1dupxLlRNdLLDPryjRHZ+KCcc8USkn2fwqpPz3dqz0MoGS3530L7gjJJ2wr UTyRp+zb3zZZBOD9zk3v/VU3e+rNKtA= Date: Tue, 11 Dec 2018 17:14:40 +0100 From: Borislav Petkov To: Daniel =?utf-8?B?UC4gQmVycmFuZ8Op?= , Eduardo Habkost Cc: Paolo Bonzini , =?utf-8?B?SsO2cmcgUsO2ZGVs?= , Andre Przywara , kvm ML , lkml , Tom Lendacky , Eric Blake , qemu-devel@nongnu.org Subject: [PATCH] target-i386: Reenable RDTSCP support on Opteron_G[345] CPU models Message-ID: <20181211161440.GG27375@zn.tnic> References: <20181210181328.GA762@zn.tnic> <20181210183730.GJ4669@habkost.net> <20181210184153.GB5482@zn.tnic> <20181210190600.GK4669@habkost.net> <20181210194258.GD5482@zn.tnic> <20181210200843.GN4669@habkost.net> <20181211103839.GC921@redhat.com> <20181211115546.GQ4669@habkost.net> <20181211153017.GN921@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20181211153017.GN921@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org + qemu-devel. On Tue, Dec 11, 2018 at 03:30:17PM +0000, Daniel P. Berrangé wrote: > Great, then, this is a non-issue - we just need to mention that fact > in the commit that sets the min version for the kernel Ok, here's a first draft ontop of Eduardo's machine-next branch from http://github.com/ehabkost/qemu Also, thanks for the help Eduardo! :-) --- From: Borislav Petkov Date: Tue, 11 Dec 2018 17:01:00 +0100 The missing functionality was added ~3 years ago with the Linux commit 46896c73c1a4 ("KVM: svm: add support for RDTSCP") so reenable RDTSCP support on those CPU models. Opteron_G2 - being family 15, model 6, doesn't have RDTSCP support (the real hardware doesn't have it. K8 got RDTSCP support with the NPT models, i.e., models >= 0x40). Document the host's minimum required kernel version, while at it. Signed-off-by: Borislav Petkov --- include/hw/i386/pc.h | 17 +++++++++++++---- qemu-doc.texi | 13 +++++++++++++ target/i386/cpu.c | 11 ++++------- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 9d29c4b1df2a..ebc28e816b04 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -296,6 +296,19 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *); #define PC_COMPAT_3_1 \ HW_COMPAT_3_1 \ + {\ + .driver = "Opteron_G3" "-" TYPE_X86_CPU,\ + .property = "rdtscp",\ + .value = "off",\ + },{\ + .driver = "Opteron_G4" "-" TYPE_X86_CPU,\ + .property = "rdtscp",\ + .value = "off",\ + },{\ + .driver = "Opteron_G5" "-" TYPE_X86_CPU,\ + .property = "rdtscp",\ + .value = "off",\ + }, #define PC_COMPAT_3_0 \ HW_COMPAT_3_0 \ @@ -527,10 +540,6 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *); .driver = "qemu32" "-" TYPE_X86_CPU,\ .property = "popcnt",\ .value = "on",\ - },{\ - .driver = "Opteron_G2" "-" TYPE_X86_CPU,\ - .property = "rdtscp",\ - .value = "on",\ },{\ .driver = "Opteron_G3" "-" TYPE_X86_CPU,\ .property = "rdtscp",\ diff --git a/qemu-doc.texi b/qemu-doc.texi index f7ad1dfe4b69..16b955cbf985 100644 --- a/qemu-doc.texi +++ b/qemu-doc.texi @@ -37,6 +37,7 @@ * QEMU System emulator for non PC targets:: * QEMU Guest Agent:: * QEMU User space emulator:: +* System requirements:: * Implementation notes:: * Deprecated features:: * Supported build platforms:: @@ -2813,6 +2814,18 @@ Act as if the host page size was 'pagesize' bytes Run the emulation in single step mode. @end table +@node System requirements +@chapter System requirements + +@section KVM kernel module + +On x86_64 hosts, the default set of CPU features enabled by the KVM accelerator +require the host to be running Linux v4.5 or newer. + +The OpteronG[345] CPU models require KVM support for RDTSCP, which was +added with Linux 4.5 which is supported by the major distros. And even +if RHEL7 has kernel 3.10, KVM there has the required functionality there +to make it close to a 4.5 or newer kernel. @include qemu-tech.texi diff --git a/target/i386/cpu.c b/target/i386/cpu.c index f81d35e1f914..a7def11b27cd 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -2706,7 +2706,6 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_DE | CPUID_FP87, .features[FEAT_1_ECX] = CPUID_EXT_CX16 | CPUID_EXT_SSE3, - /* Missing: CPUID_EXT2_RDTSCP */ .features[FEAT_8000_0001_EDX] = CPUID_EXT2_LM | CPUID_EXT2_NX | CPUID_EXT2_SYSCALL, .features[FEAT_8000_0001_ECX] = @@ -2730,9 +2729,9 @@ static X86CPUDefinition builtin_x86_defs[] = { .features[FEAT_1_ECX] = CPUID_EXT_POPCNT | CPUID_EXT_CX16 | CPUID_EXT_MONITOR | CPUID_EXT_SSE3, - /* Missing: CPUID_EXT2_RDTSCP */ .features[FEAT_8000_0001_EDX] = - CPUID_EXT2_LM | CPUID_EXT2_NX | CPUID_EXT2_SYSCALL, + CPUID_EXT2_LM | CPUID_EXT2_NX | CPUID_EXT2_SYSCALL | + CPUID_EXT2_RDTSCP, .features[FEAT_8000_0001_ECX] = CPUID_EXT3_MISALIGNSSE | CPUID_EXT3_SSE4A | CPUID_EXT3_ABM | CPUID_EXT3_SVM | CPUID_EXT3_LAHF_LM, @@ -2757,10 +2756,9 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_EXT_POPCNT | CPUID_EXT_SSE42 | CPUID_EXT_SSE41 | CPUID_EXT_CX16 | CPUID_EXT_SSSE3 | CPUID_EXT_PCLMULQDQ | CPUID_EXT_SSE3, - /* Missing: CPUID_EXT2_RDTSCP */ .features[FEAT_8000_0001_EDX] = CPUID_EXT2_LM | CPUID_EXT2_PDPE1GB | CPUID_EXT2_NX | - CPUID_EXT2_SYSCALL, + CPUID_EXT2_SYSCALL | CPUID_EXT2_RDTSCP, .features[FEAT_8000_0001_ECX] = CPUID_EXT3_FMA4 | CPUID_EXT3_XOP | CPUID_EXT3_3DNOWPREFETCH | CPUID_EXT3_MISALIGNSSE | @@ -2788,10 +2786,9 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_EXT_AES | CPUID_EXT_POPCNT | CPUID_EXT_SSE42 | CPUID_EXT_SSE41 | CPUID_EXT_CX16 | CPUID_EXT_FMA | CPUID_EXT_SSSE3 | CPUID_EXT_PCLMULQDQ | CPUID_EXT_SSE3, - /* Missing: CPUID_EXT2_RDTSCP */ .features[FEAT_8000_0001_EDX] = CPUID_EXT2_LM | CPUID_EXT2_PDPE1GB | CPUID_EXT2_NX | - CPUID_EXT2_SYSCALL, + CPUID_EXT2_SYSCALL | CPUID_EXT2_RDTSCP, .features[FEAT_8000_0001_ECX] = CPUID_EXT3_TBM | CPUID_EXT3_FMA4 | CPUID_EXT3_XOP | CPUID_EXT3_3DNOWPREFETCH | CPUID_EXT3_MISALIGNSSE | -- 2.19.1 -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.