Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4080714imu; Mon, 10 Dec 2018 12:47:37 -0800 (PST) X-Google-Smtp-Source: AFSGD/UMO6dD2pxsa37OjDa+/jj0QQyvoFWg9Bk36iSCxTKiMYA2jxhUZUtrPq/7YcCnHdeXmrZI X-Received: by 2002:a63:e20a:: with SMTP id q10mr11828905pgh.206.1544474857160; Mon, 10 Dec 2018 12:47:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544474857; cv=none; d=google.com; s=arc-20160816; b=H4FPcnT8wuG+6ny043HHIiVT+xTDi4ecmmhJrJ48qmT/r6YTaqDKJfqsU4sIx0UBk2 Y16CoiU1QpLL968m5KY8Lr76botV4lIGM4UmFu07CSLsxaWVWMRiUmufSeJ4D1PImTJT jLstmblV9HmVije3iMSncLqOKjKxN9+6GcvE+hs/zpNwLJarucFsNWIzZnDdRNUilPuS aqKaWNA2fXx+cKm7tRCDDct2MDea+DslPy5da8F1mjsaaow4yKJr9HFwrfzcLbQbTzRj EiM5LtD2kgLTKQKJUTPwD8EFdXoG8MxUCqKoidrh7nQkhVvql2rQ+5fpMb3/y5tjYqBt jEdA== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=vJVoCEbVQTKjndn2sfQ0TIxUjDGxPv9bnp8WpazORJ4=; b=Xz0+6JXvIstTVU+XVIcmKkU+hvz6GdNmduZuxh3urfj2efuyES4hIogyxMpA+x6qEF e8A6KxMxWSQX1DPGxySNbD4qEqV/qeTOIxT2xKGQqHxwtM20L2SB1LeRbD9fYUdNmhJd qgMrG0qd10h4I3EAvUODNQNxBBph6f64AxXcy7iklF1+cAp2S6GzljlZNl0dHPbRtmsZ bH0UdImWrNtY0ktOhEwN7S4Sjv25dtdYHMqOYgdLnsAoEQiFuHH3vH/hxRwsrEvxKTwS zpwlWUbhdZcnCkvVi7rqzZK2wpUbhSyIj6uSoeuOjzqqiyQHkuY0xzrSypODvIOO7Zo7 sbtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=YMSHMvXO; 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 r22si9494876pgl.537.2018.12.10.12.47.21; Mon, 10 Dec 2018 12:47:37 -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=YMSHMvXO; 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 S1729814AbeLJUQl (ORCPT + 99 others); Mon, 10 Dec 2018 15:16:41 -0500 Received: from mail.skyhub.de ([5.9.137.197]:45546 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726392AbeLJUQk (ORCPT ); Mon, 10 Dec 2018 15:16:40 -0500 Received: from zn.tnic (p200300EC2BCAD0002992494E33A10E64.dip0.t-ipconnect.de [IPv6:2003:ec:2bca:d000:2992:494e:33a1:e64]) (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 55C311EC0322; Mon, 10 Dec 2018 21:16:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1544472998; 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:in-reply-to:in-reply-to: references:references; bh=vJVoCEbVQTKjndn2sfQ0TIxUjDGxPv9bnp8WpazORJ4=; b=YMSHMvXONrJMzIOYA9CjEk3C5ssb3TISvNWOVwCsz3oB5dAGeh8oHl8Ib5zHrpUwK1z9uM rcPe6lZQDB9r2zJS1GfGKBmMTujmuMgkkE3sn822AOY7UWszKJOIji6w4QpXDeZ+XpuMkE ABCLrLBagHWxDftSXoZXGYGN27hX7ps= Date: Mon, 10 Dec 2018 21:16:26 +0100 From: Borislav Petkov To: Eduardo Habkost Cc: Paolo Bonzini , =?utf-8?B?SsO2cmcgUsO2ZGVs?= , Andre Przywara , kvm ML , lkml , Tom Lendacky Subject: Re: kvm: RDTSCP on AMD Message-ID: <20181210201626.GE5482@zn.tnic> References: <20181210181328.GA762@zn.tnic> <20181210183730.GJ4669@habkost.net> <20181210184153.GB5482@zn.tnic> <20181210194725.GM4669@habkost.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20181210194725.GM4669@habkost.net> 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 On Mon, Dec 10, 2018 at 05:47:25PM -0200, Eduardo Habkost wrote: > On Mon, Dec 10, 2018 at 07:41:53PM +0100, Borislav Petkov wrote: > > On Mon, Dec 10, 2018 at 04:37:30PM -0200, Eduardo Habkost wrote: > > > It isn't as simply as reverting commit 33b5e8c03ae7, but we can > > > surely re-add RDTSCP on pc-*-4.0 and newer. > > > > Sure. If you could only point me to an example how to add that to > > pc-*-4.0 and newer, I'll gladly cook up a patch and test it. > > Sorry, I forgot to reply to this part. > > See commit 33b5e8c03ae7 for reference. The differences will be: > * Instead of removing RDTSCP from builtin_x86_defs, you'll be adding it. > * Instead of adding rdtscp=on entries to PC_COMPAT_2_4, you'll > be adding rdtscp=off entries to PC_COMPAT_3_1. > > PC_COMPAT_3_1 is added by the patch that creates the 4.0 > machine-types. You can find it on my machine-next branch at: > > http://github.com/ehabkost/qemu Thanks for the patient explanation, diff below ontop of your branch. It is notable to point out that Opteron_G2 - it being family 0xf, model 6 - should not deal with RDTSCP as it doesn't have it. Although looking at the docs, they say it does but I *have* a K8 laptop which I just checked and it *doesn't* have RDTSCP in CPUID. So lemme clarify that aspect first with folks. :) --- 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..913b2ef68d54 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,13 @@ 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. @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 | -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.